Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckpointHarness and analyzer mutexes #995

Merged
merged 57 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
45ac6f9
starter
max-hoffman May 2, 2022
57793be
Merge branch 'main' into max/versioned-enginetests
max-hoffman May 2, 2022
373cb26
some tests passing
max-hoffman May 4, 2022
d5a861c
prog
max-hoffman May 4, 2022
a8593ef
merge main
max-hoffman May 4, 2022
892be2e
faster
max-hoffman May 4, 2022
5861076
cleanup
max-hoffman May 4, 2022
50a90c6
fix races
max-hoffman May 4, 2022
72612ca
format
max-hoffman May 4, 2022
66d65cc
cleanup
max-hoffman May 5, 2022
608bef3
parallel
max-hoffman May 5, 2022
c67ad01
Merge branch 'main' into max/versioned-enginetests
max-hoffman May 5, 2022
74e16de
starter
max-hoffman May 6, 2022
5332557
prog
max-hoffman May 6, 2022
2a812d8
[ga-format-pr] Run ./format_repo.sh to fix formatting
max-hoffman May 6, 2022
6b11ffa
prog
max-hoffman May 11, 2022
0094956
Merge branch 'max/versioned-enginetests' of github.com:dolthub/go-mys…
max-hoffman May 11, 2022
25365c6
merge main
max-hoffman May 12, 2022
ac01e0e
prog
max-hoffman May 12, 2022
9b7223c
complex index tests fast again
max-hoffman May 12, 2022
43194b9
merge
max-hoffman May 12, 2022
47fc1e8
Revert "merge"
max-hoffman May 12, 2022
d937eb7
stash
max-hoffman May 12, 2022
472a144
merge stash
max-hoffman May 12, 2022
aa26a1e
prog
max-hoffman May 13, 2022
7eaf240
revert versioned tests
max-hoffman May 13, 2022
cbe11c2
all but sleep stall
max-hoffman May 13, 2022
a0340be
[ga-format-pr] Run ./format_repo.sh to fix formatting
max-hoffman May 13, 2022
6438357
prog
max-hoffman May 13, 2022
7e2a2fc
fix versioning test hanress
max-hoffman May 13, 2022
3a82cd5
Merge branch 'max/versioned-enginetests' of github.com:dolthub/go-mys…
max-hoffman May 13, 2022
4442908
[ga-format-pr] Run ./format_repo.sh to fix formatting
max-hoffman May 13, 2022
c7abdd8
cleanup
max-hoffman May 13, 2022
8441c8f
revert readOnlyDatabase
max-hoffman May 13, 2022
e9bc14c
drop extraneous tests
max-hoffman May 13, 2022
94f800b
refactor new test
max-hoffman May 13, 2022
39494cb
queries in folder
max-hoffman May 13, 2022
5d17410
format
max-hoffman May 13, 2022
e193eef
Merge branch 'max/versioned-enginetests' of github.com:dolthub/go-mys…
max-hoffman May 13, 2022
a27da2b
tests in go structs
max-hoffman May 17, 2022
29dfd19
prog
max-hoffman May 17, 2022
cdc6900
merge main
max-hoffman May 17, 2022
e1697e6
hacky fix for tests
max-hoffman May 18, 2022
3f4513b
Merge branch 'main' into max/versioned-enginetests
max-hoffman May 18, 2022
d703c51
prog
max-hoffman May 18, 2022
2401d38
prog
max-hoffman May 18, 2022
06ef369
merge
max-hoffman May 19, 2022
386a625
new storage engine edits
max-hoffman May 19, 2022
039d137
[ga-format-pr] Run ./format_repo.sh to fix formatting
max-hoffman May 19, 2022
1b91d9c
skip codegen tets
max-hoffman May 19, 2022
3e91ac5
Merge branch 'max/versioned-enginetests' of github.com:dolthub/go-mys…
max-hoffman May 19, 2022
13b2371
refactor scriptgen
max-hoffman May 19, 2022
852a651
prog remove old harness interface
max-hoffman May 19, 2022
c449331
fix orderby refactor
max-hoffman May 19, 2022
57fe2c5
copyright headers
max-hoffman May 19, 2022
28ea779
better scriptgen package nesting
max-hoffman May 19, 2022
5349494
[ga-format-pr] Run ./format_repo.sh to fix formatting
max-hoffman May 19, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,11 @@ func (e *Engine) PrepareQuery(
if err != nil {
return nil, err
}
e.cachePreparedStmt(ctx, node, query)
e.CachePreparedStmt(ctx, node, query)
return node, nil
}

// Query executes a query. If parsed is non-nil, it will be used instead of parsing the query from text.
// Query executes a query.
func (e *Engine) Query(ctx *sql.Context, query string) (sql.Schema, sql.RowIter, error) {
return e.QueryWithBindings(ctx, query, nil)
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func (e *Engine) QueryNodeWithBindings(
return analyzed.Schema(), iter, nil
}

func (e *Engine) cachePreparedStmt(ctx *sql.Context, analyzed sql.Node, query string) {
func (e *Engine) CachePreparedStmt(ctx *sql.Context, analyzed sql.Node, query string) {
e.mu.Lock()
defer e.mu.Unlock()
e.PreparedData[ctx.Session.ID()] = PreparedData{
Expand Down
132 changes: 132 additions & 0 deletions enginetest/column_alias_queries.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package enginetest

import (
"github.com/dolthub/vitess/go/sqltypes"

"github.com/dolthub/go-mysql-server/sql"
)

var ColumnAliasQueries = []QueryTest{
{
Query: `SELECT i AS cOl FROM mytable`,
ExpectedColumns: sql.Schema{
{
Name: "cOl",
Type: sql.Int64,
},
},
Expected: []sql.Row{
{int64(1)},
{int64(2)},
{int64(3)},
},
},
{
Query: `SELECT i AS cOl, s as COL FROM mytable`,
ExpectedColumns: sql.Schema{
{
Name: "cOl",
Type: sql.Int64,
},
{
Name: "COL",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
},
Expected: []sql.Row{
{int64(1), "first row"},
{int64(2), "second row"},
{int64(3), "third row"},
},
},
{
// TODO: this is actually inconsistent with MySQL, which doesn't allow column aliases in the where clause
Query: `SELECT i AS cOl, s as COL FROM mytable where cOl = 1`,
ExpectedColumns: sql.Schema{
{
Name: "cOl",
Type: sql.Int64,
},
{
Name: "COL",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
},
Expected: []sql.Row{
{int64(1), "first row"},
},
},
{
Query: `SELECT s as COL1, SUM(i) COL2 FROM mytable group by s order by cOL2`,
ExpectedColumns: sql.Schema{
{
Name: "COL1",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
{
Name: "COL2",
Type: sql.Float64,
},
},
// TODO: SUM should be integer typed for integers
Expected: []sql.Row{
{"first row", float64(1)},
{"second row", float64(2)},
{"third row", float64(3)},
},
},
{
Query: `SELECT s as COL1, SUM(i) COL2 FROM mytable group by col1 order by col2`,
ExpectedColumns: sql.Schema{
{
Name: "COL1",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
{
Name: "COL2",
Type: sql.Float64,
},
},
Expected: []sql.Row{
{"first row", float64(1)},
{"second row", float64(2)},
{"third row", float64(3)},
},
},
{
Query: `SELECT s as coL1, SUM(i) coL2 FROM mytable group by 1 order by 2`,
ExpectedColumns: sql.Schema{
{
Name: "coL1",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
{
Name: "coL2",
Type: sql.Float64,
},
},
Expected: []sql.Row{
{"first row", float64(1)},
{"second row", float64(2)},
{"third row", float64(3)},
},
},
{
Query: `SELECT s as Date, SUM(i) TimeStamp FROM mytable group by 1 order by 2`,
ExpectedColumns: sql.Schema{
{
Name: "Date",
Type: sql.MustCreateStringWithDefaults(sqltypes.VarChar, 20),
},
{
Name: "TimeStamp",
Type: sql.Float64,
},
},
Expected: []sql.Row{
{"first row", float64(1)},
{"second row", float64(2)},
{"third row", float64(3)},
},
},
}
124 changes: 124 additions & 0 deletions enginetest/create_table_queries.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
package enginetest

import "github.com/dolthub/go-mysql-server/sql"

var CreateTableQueries = []WriteQueryTest{
{
WriteQuery: `CREATE TABLE t1 (a INTEGER, b TEXT, c DATE, d TIMESTAMP, e VARCHAR(20), f BLOB NOT NULL, b1 BOOL, b2 BOOLEAN NOT NULL, g DATETIME, h CHAR(40))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int,\n `b` text,\n `c` date,\n `d` timestamp,\n `e` varchar(20),\n `f` blob NOT NULL,\n `b1` tinyint,\n `b2` tinyint NOT NULL,\n `g` datetime,\n `h` char(40)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER NOT NULL PRIMARY KEY, b VARCHAR(10) NOT NULL)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` varchar(10) NOT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER NOT NULL, b TEXT NOT NULL, c bool, primary key (a,b))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` text NOT NULL,\n `c` tinyint,\n PRIMARY KEY (`a`,`b`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1(a INTEGER NOT NULL, b TEXT NOT NULL, c bool, primary key (a,b))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` text NOT NULL,\n `c` tinyint,\n PRIMARY KEY (`a`,`b`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER, b TEXT NOT NULL COMMENT 'comment', c bool, primary key (a))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` text NOT NULL COMMENT 'comment',\n `c` tinyint,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER, create_time timestamp(6) NOT NULL DEFAULT NOW(6), primary key (a))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `create_time` timestamp NOT NULL DEFAULT (NOW(6)),\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 LIKE mytable`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` bigint NOT NULL,\n `s` varchar(20) NOT NULL COMMENT 'column s',\n PRIMARY KEY (`i`),\n KEY `idx_si` (`s`,`i`),\n KEY `mytable_i_s` (`i`,`s`),\n UNIQUE KEY `mytable_s` (`s`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (
pk bigint primary key,
v1 bigint default (2) comment 'hi there',
index idx_v1 (v1) comment 'index here'
)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `pk` bigint NOT NULL,\n `v1` bigint DEFAULT (2) COMMENT 'hi there',\n PRIMARY KEY (`pk`),\n KEY `idx_v1` (`v1`) COMMENT 'index here'\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `create table t1 like foo.other_table`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `text` text NOT NULL,\n `number` mediumint,\n PRIMARY KEY (`text`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER NOT NULL PRIMARY KEY, b VARCHAR(10) UNIQUE)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` varchar(10),\n PRIMARY KEY (`a`),\n UNIQUE KEY `b` (`b`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (a INTEGER NOT NULL PRIMARY KEY, b VARCHAR(10) UNIQUE KEY)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` varchar(10),\n PRIMARY KEY (`a`),\n UNIQUE KEY `b` (`b`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 SELECT * from mytable`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(3)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` bigint NOT NULL,\n `s` varchar(20) NOT NULL COMMENT 'column s',\n PRIMARY KEY (`i`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE mydb.t1 (a INTEGER NOT NULL PRIMARY KEY, b VARCHAR(10) NOT NULL)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE mydb.t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `a` int NOT NULL,\n `b` varchar(10) NOT NULL,\n PRIMARY KEY (`a`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (i int primary key, j int auto_increment unique)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` int NOT NULL,\n `j` int AUTO_INCREMENT,\n PRIMARY KEY (`i`),\n UNIQUE KEY `j` (`j`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (i int primary key, j int auto_increment, index (j))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` int NOT NULL,\n `j` int AUTO_INCREMENT,\n PRIMARY KEY (`i`),\n KEY `j` (`j`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (i int primary key, j int auto_increment, k int, unique(j,k))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` int NOT NULL,\n `j` int AUTO_INCREMENT,\n `k` int,\n PRIMARY KEY (`i`),\n UNIQUE KEY `jk` (`j`,`k`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (i int primary key, j int auto_increment, k int, index (j,k))`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `i` int NOT NULL,\n `j` int AUTO_INCREMENT,\n `k` int,\n PRIMARY KEY (`i`),\n KEY `jk` (`j`,`k`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
{
WriteQuery: `CREATE TABLE t1 (
pk int NOT NULL,
col1 blob DEFAULT (_utf8mb4'abc'),
col2 json DEFAULT (json_object(_utf8mb4'a',1)),
col3 text DEFAULT (_utf8mb4'abc'),
PRIMARY KEY (pk)
)`,
ExpectedWriteResult: []sql.Row{{sql.NewOkResult(0)}},
SelectQuery: "SHOW CREATE TABLE t1",
ExpectedSelect: []sql.Row{sql.Row{"t1", "CREATE TABLE `t1` (\n `pk` int NOT NULL,\n `col1` blob DEFAULT (\"abc\"),\n `col2` json DEFAULT (JSON_OBJECT(\"a\", 1)),\n `col3` text DEFAULT (\"abc\"),\n PRIMARY KEY (`pk`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"}},
},
}
Loading