From 92d2af292b3ace4d350e7008b886e20eb47fce1c Mon Sep 17 00:00:00 2001 From: Andres Taylor Date: Sun, 5 Mar 2023 09:21:08 +0100 Subject: [PATCH] [bug fix] USING planning on information_schema (#12542) * [planner] Schema information on the information_schema views (#11941) * add info_schema information Signed-off-by: Andres Taylor * add SchemaInformation handling for info_schema tables Signed-off-by: Andres Taylor * fix bad test query Signed-off-by: Andres Taylor * add support for information_schema on mysql 5.7 Signed-off-by: Andres Taylor * columns sorted just like mysql, and tests for 5.7 Signed-off-by: Andres Taylor * test: skip test that should not run Signed-off-by: Andres Taylor Signed-off-by: Andres Taylor * Fix for USING when column names not lower cased (#12379) Signed-off-by: Andres Taylor --------- Signed-off-by: Andres Taylor --- go/vt/sqlparser/ast_funcs.go | 92 +- go/vt/sqlparser/keywords.go | 2 + go/vt/vtgate/planbuilder/plan_test.go | 13 +- .../planbuilder/testdata/filter_cases.json | 21 +- .../planbuilder/testdata/from_cases.json | 7 +- .../planbuilder/testdata/select_cases.json | 13 +- .../testdata/sysschema_default.json | 14 +- .../testdata/systemtables_cases57.json | 1880 +++++++++++++++++ ...s_cases.json => systemtables_cases80.json} | 675 ++++-- .../planbuilder/testdata/union_cases.json | 5 +- .../testdata/unsupported_cases.json | 16 +- go/vt/vtgate/semantics/analyzer.go | 2 +- go/vt/vtgate/semantics/analyzer_test.go | 11 + go/vt/vtgate/semantics/derived_table.go | 4 +- go/vt/vtgate/semantics/early_rewriter.go | 3 +- go/vt/vtgate/semantics/info_schema.go | 1710 +++++++++++++++ .../vtgate/semantics/info_schema_gen_test.go | 228 ++ go/vt/vtgate/semantics/table_collector.go | 21 +- 18 files changed, 4460 insertions(+), 257 deletions(-) create mode 100644 go/vt/vtgate/planbuilder/testdata/systemtables_cases57.json rename go/vt/vtgate/planbuilder/testdata/{systemtables_cases.json => systemtables_cases80.json} (74%) create mode 100644 go/vt/vtgate/semantics/info_schema.go create mode 100644 go/vt/vtgate/semantics/info_schema_gen_test.go diff --git a/go/vt/sqlparser/ast_funcs.go b/go/vt/sqlparser/ast_funcs.go index 8ece274978..b9a1ea1b6d 100644 --- a/go/vt/sqlparser/ast_funcs.go +++ b/go/vt/sqlparser/ast_funcs.go @@ -210,97 +210,101 @@ func (ct *ColumnType) DescribeType() string { // SQLType returns the sqltypes type code for the given column func (ct *ColumnType) SQLType() querypb.Type { - switch strings.ToLower(ct.Type) { - case keywordStrings[TINYINT]: - if ct.Unsigned { + return SQLTypeToQueryType(ct.Type, ct.Unsigned) +} + +func SQLTypeToQueryType(typeName string, unsigned bool) querypb.Type { + switch keywordVals[strings.ToLower(typeName)] { + case TINYINT: + if unsigned { return sqltypes.Uint8 } return sqltypes.Int8 - case keywordStrings[SMALLINT]: - if ct.Unsigned { + case SMALLINT: + if unsigned { return sqltypes.Uint16 } return sqltypes.Int16 - case keywordStrings[MEDIUMINT]: - if ct.Unsigned { + case MEDIUMINT: + if unsigned { return sqltypes.Uint24 } return sqltypes.Int24 - case keywordStrings[INT], keywordStrings[INTEGER]: - if ct.Unsigned { + case INT, INTEGER: + if unsigned { return sqltypes.Uint32 } return sqltypes.Int32 - case keywordStrings[BIGINT]: - if ct.Unsigned { + case BIGINT: + if unsigned { return sqltypes.Uint64 } return sqltypes.Int64 - case keywordStrings[BOOL], keywordStrings[BOOLEAN]: + case BOOL, BOOLEAN: return sqltypes.Uint8 - case keywordStrings[TEXT]: + case TEXT: return sqltypes.Text - case keywordStrings[TINYTEXT]: + case TINYTEXT: return sqltypes.Text - case keywordStrings[MEDIUMTEXT]: + case MEDIUMTEXT: return sqltypes.Text - case keywordStrings[LONGTEXT]: + case LONGTEXT: return sqltypes.Text - case keywordStrings[BLOB]: + case BLOB: return sqltypes.Blob - case keywordStrings[TINYBLOB]: + case TINYBLOB: return sqltypes.Blob - case keywordStrings[MEDIUMBLOB]: + case MEDIUMBLOB: return sqltypes.Blob - case keywordStrings[LONGBLOB]: + case LONGBLOB: return sqltypes.Blob - case keywordStrings[CHAR]: + case CHAR: return sqltypes.Char - case keywordStrings[VARCHAR]: + case VARCHAR: return sqltypes.VarChar - case keywordStrings[BINARY]: + case BINARY: return sqltypes.Binary - case keywordStrings[VARBINARY]: + case VARBINARY: return sqltypes.VarBinary - case keywordStrings[DATE]: + case DATE: return sqltypes.Date - case keywordStrings[TIME]: + case TIME: return sqltypes.Time - case keywordStrings[DATETIME]: + case DATETIME: return sqltypes.Datetime - case keywordStrings[TIMESTAMP]: + case TIMESTAMP: return sqltypes.Timestamp - case keywordStrings[YEAR]: + case YEAR: return sqltypes.Year - case keywordStrings[FLOAT_TYPE]: + case FLOAT_TYPE: return sqltypes.Float32 - case keywordStrings[DOUBLE]: + case DOUBLE: return sqltypes.Float64 - case keywordStrings[DECIMAL]: + case DECIMAL, DECIMAL_TYPE: return sqltypes.Decimal - case keywordStrings[BIT]: + case BIT: return sqltypes.Bit - case keywordStrings[ENUM]: + case ENUM: return sqltypes.Enum - case keywordStrings[SET]: + case SET: return sqltypes.Set - case keywordStrings[JSON]: + case JSON: return sqltypes.TypeJSON - case keywordStrings[GEOMETRY]: + case GEOMETRY: return sqltypes.Geometry - case keywordStrings[POINT]: + case POINT: return sqltypes.Geometry - case keywordStrings[LINESTRING]: + case LINESTRING: return sqltypes.Geometry - case keywordStrings[POLYGON]: + case POLYGON: return sqltypes.Geometry - case keywordStrings[GEOMETRYCOLLECTION]: + case GEOMETRYCOLLECTION: return sqltypes.Geometry - case keywordStrings[MULTIPOINT]: + case MULTIPOINT: return sqltypes.Geometry - case keywordStrings[MULTILINESTRING]: + case MULTILINESTRING: return sqltypes.Geometry - case keywordStrings[MULTIPOLYGON]: + case MULTIPOLYGON: return sqltypes.Geometry } return sqltypes.Null diff --git a/go/vt/sqlparser/keywords.go b/go/vt/sqlparser/keywords.go index ec980a05c6..d0a152f907 100644 --- a/go/vt/sqlparser/keywords.go +++ b/go/vt/sqlparser/keywords.go @@ -687,6 +687,7 @@ var keywords = []keyword{ // keywordStrings contains the reverse mapping of token to keyword strings var keywordStrings = map[int]string{} +var keywordVals = map[string]int{} // keywordLookupTable is a perfect hash map that maps **case insensitive** keyword names to their ids var keywordLookupTable *caseInsensitiveTable @@ -735,6 +736,7 @@ func init() { panic(fmt.Sprintf("keyword %q must be lowercase in table", kw.name)) } keywordStrings[kw.id] = kw.name + keywordVals[kw.name] = kw.id } keywordLookupTable = buildCaseInsensitiveTable(keywords) diff --git a/go/vt/vtgate/planbuilder/plan_test.go b/go/vt/vtgate/planbuilder/plan_test.go index 0b60ca73b0..96ac5cf964 100644 --- a/go/vt/vtgate/planbuilder/plan_test.go +++ b/go/vt/vtgate/planbuilder/plan_test.go @@ -31,6 +31,8 @@ import ( "github.com/stretchr/testify/require" + "vitess.io/vitess/go/vt/servenv" + vtgatepb "vitess.io/vitess/go/vt/proto/vtgate" "vitess.io/vitess/go/test/utils" @@ -252,7 +254,16 @@ func TestPlan(t *testing.T) { testFile(t, "flush_cases_no_default_keyspace.json", testOutputTempDir, vschemaWrapper, false) testFile(t, "show_cases_no_default_keyspace.json", testOutputTempDir, vschemaWrapper, false) testFile(t, "stream_cases.json", testOutputTempDir, vschemaWrapper, false) - testFile(t, "systemtables_cases.json", testOutputTempDir, vschemaWrapper, false) + testFile(t, "systemtables_cases80.json", testOutputTempDir, vschemaWrapper, false) +} + +func TestSystemTables57(t *testing.T) { + // first we move everything to use 5.7 logic + servenv.SetMySQLServerVersionForTest("5.7") + defer servenv.SetMySQLServerVersionForTest("") + vschemaWrapper := &vschemaWrapper{v: loadSchema(t, "vschemas/schema.json", true)} + testOutputTempDir := makeTestOutput(t) + testFile(t, "systemtables_cases57.json", testOutputTempDir, vschemaWrapper, false) } func TestSysVarSetDisabled(t *testing.T) { diff --git a/go/vt/vtgate/planbuilder/testdata/filter_cases.json b/go/vt/vtgate/planbuilder/testdata/filter_cases.json index 5ba0fea900..242d447cc4 100644 --- a/go/vt/vtgate/planbuilder/testdata/filter_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/filter_cases.json @@ -4381,7 +4381,7 @@ { "comment": "SelectDBA with uncorrelated subqueries", "query": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", "Instructions": { @@ -4395,6 +4395,25 @@ "Query": "select t.table_schema from information_schema.`tables` as t where t.table_schema in (select c.column_name from information_schema.`columns` as c)", "Table": "information_schema.`tables`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select t.table_schema from information_schema.tables as t where t.table_schema in (select c.column_name from information_schema.columns as c)", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select t.table_schema from information_schema.`tables` as t where 1 != 1", + "Query": "select t.table_schema from information_schema.`tables` as t where t.table_schema in (select c.column_name from information_schema.`columns` as c)", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.columns", + "information_schema.tables" + ] } }, { diff --git a/go/vt/vtgate/planbuilder/testdata/from_cases.json b/go/vt/vtgate/planbuilder/testdata/from_cases.json index f9c88a765f..bfef302f98 100644 --- a/go/vt/vtgate/planbuilder/testdata/from_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/from_cases.json @@ -587,6 +587,7 @@ "plan": "table disabled has been disabled" }, { + "comment": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "query": "select second_user.foo.col from second_user.foo join user on second_user.foo.id = user.id where second_user.foo.col = 42", "v3-plan": { "QueryType": "SELECT", @@ -623,6 +624,7 @@ } }, { + "comment": "select user.music.foo from user.music join user on user.music.id = user.id where user.music.col = 42", "query": "select user.music.foo from user.music join user on user.music.id = user.id where user.music.col = 42", "v3-plan": { "QueryType": "SELECT", @@ -3001,6 +3003,7 @@ ] }, "TablesUsed": [ + "information_schema.a", "main.unsharded" ] } @@ -3076,6 +3079,7 @@ ] }, "TablesUsed": [ + "information_schema.a", "main.unsharded" ] } @@ -6160,6 +6164,7 @@ } }, { + "comment": "select * from (select bar as push_it from (select foo as bar from (select id as foo from user) as t1) as t2) as t3 where push_it = 12", "query": "select * from (select bar as push_it from (select foo as bar from (select id as foo from user) as t1) as t2) as t3 where push_it = 12", "v3-plan": { "QueryType": "SELECT", @@ -6203,4 +6208,4 @@ ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/select_cases.json b/go/vt/vtgate/planbuilder/testdata/select_cases.json index 664e945c60..aadbc7840c 100644 --- a/go/vt/vtgate/planbuilder/testdata/select_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/select_cases.json @@ -2535,6 +2535,7 @@ } }, { + "comment": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "query": "(select id from unsharded) union (select id from unsharded_auto) order by id limit 5", "v3-plan": { "QueryType": "SELECT", @@ -3295,6 +3296,7 @@ "plan": "syntax error at position 41 near 'into'" }, { + "comment": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "query": "select (select u.id from user as u where u.id = 1), a.id from user as a where a.id = 1", "v3-plan": { "QueryType": "SELECT", @@ -3416,6 +3418,7 @@ } }, { + "comment": "((((select 1))))", "query": "((((select 1))))", "v3-plan": { "QueryType": "SELECT", @@ -3585,6 +3588,7 @@ } }, { + "comment": "select (select col from user limit 1) as a from user join user_extra order by a", "query": "select (select col from user limit 1) as a from user join user_extra order by a", "v3-plan": { "QueryType": "SELECT", @@ -3716,6 +3720,7 @@ } }, { + "comment": "select t.a from (select (select col from user limit 1) as a from user join user_extra) t", "query": "select t.a from (select (select col from user limit 1) as a from user join user_extra) t", "v3-plan": { "QueryType": "SELECT", @@ -3860,6 +3865,7 @@ } }, { + "comment": "select (select col from user where user_extra.id = 4 limit 1) as a from user join user_extra", "query": "select (select col from user where user_extra.id = 4 limit 1) as a from user join user_extra", "plan": "unsupported: cross-shard correlated subquery" }, @@ -4462,6 +4468,7 @@ } }, { + "comment": "select user.id, trim(leading 'x' from user.name) from user", "query": "select user.id, trim(leading 'x' from user.name) from user", "v3-plan": { "QueryType": "SELECT", @@ -4571,6 +4578,7 @@ "Table": "dual" }, "TablesUsed": [ + "information_schema.TABLES", "main.dual" ] } @@ -4613,6 +4621,7 @@ } }, { + "comment": "select (select id from user order by id limit 1) from user_extra", "query": "select (select id from user order by id limit 1) from user_extra", "v3-plan": { "QueryType": "SELECT", @@ -7687,6 +7696,7 @@ } }, { + "comment": "select user.a, t.b from user join (select id, count(*) b, req from user_extra group by req, id) as t on user.id = t.id", "query": "select user.a, t.b from user join (select id, count(*) b, req from user_extra group by req, id) as t on user.id = t.id", "v3-plan": "unsupported: filtering on results of cross-shard subquery", "gen4-plan": { @@ -7765,6 +7775,7 @@ "gen4-plan": "unsupported: JOIN not supported between derived tables" }, { + "comment": "SELECT music.id FROM (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other JOIN music ON other.maxt = music.id", "query": "SELECT music.id FROM (SELECT MAX(id) as maxt FROM music WHERE music.user_id = 5) other JOIN music ON other.maxt = music.id", "v3-plan": { "QueryType": "SELECT", @@ -7909,4 +7920,4 @@ ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/sysschema_default.json b/go/vt/vtgate/planbuilder/testdata/sysschema_default.json index 2d12dd815c..275a6720e2 100644 --- a/go/vt/vtgate/planbuilder/testdata/sysschema_default.json +++ b/go/vt/vtgate/planbuilder/testdata/sysschema_default.json @@ -69,7 +69,11 @@ "Query": "select t.table_schema, t.table_name, c.column_name, c.column_type from information_schema.`tables` as t, information_schema.`columns` as c where t.table_schema = :__vtschemaname and c.table_schema = :__vtschemaname and c.table_schema = t.table_schema and c.table_name = t.table_name order by t.table_schema asc, t.table_name asc, c.column_name asc", "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"user\")]", "Table": "information_schema.`columns`, information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.columns", + "information_schema.tables" + ] } }, { @@ -107,6 +111,7 @@ "Table": "dual" }, "TablesUsed": [ + "information_schema.schemata", "main.dual" ] } @@ -144,7 +149,10 @@ "Query": "select x.`1` from (select 1 from information_schema.schemata where schema_name = :__vtschemaname limit 1) as x", "SysTableTableSchema": "[VARCHAR(\"MyDatabase\")]", "Table": "information_schema.schemata" - } + }, + "TablesUsed": [ + "information_schema.schemata" + ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/systemtables_cases57.json b/go/vt/vtgate/planbuilder/testdata/systemtables_cases57.json new file mode 100644 index 0000000000..17441749e3 --- /dev/null +++ b/go/vt/vtgate/planbuilder/testdata/systemtables_cases57.json @@ -0,0 +1,1880 @@ +[ + { + "comment": "Single information_schema query", + "query": "select TABLE_NAME from information_schema.TABLES", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select TABLE_NAME from information_schema.TABLES", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`TABLES` where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`TABLES`", + "Table": "information_schema.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select TABLE_NAME from information_schema.TABLES", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`TABLES` where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`TABLES`", + "Table": "information_schema.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "',' join information_schema", + "query": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b where 1 != 1", + "Query": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b", + "Table": "information_schema.`TABLES`, information_schema.`COLUMNS`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select a.ENGINE, b.DATA_TYPE from information_schema.TABLES as a, information_schema.COLUMNS as b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b where 1 != 1", + "Query": "select a.`ENGINE`, b.DATA_TYPE from information_schema.`TABLES` as a, information_schema.`COLUMNS` as b", + "Table": "information_schema.`COLUMNS`, information_schema.`TABLES`" + }, + "TablesUsed": [ + "information_schema.COLUMNS", + "information_schema.TABLES" + ] + } + }, + { + "comment": "information schema query that uses table_schema", + "query": "select column_name from information_schema.columns where table_schema = (select schema())", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select column_name from information_schema.columns where table_schema = (select schema())", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.`columns` where 1 != 1", + "Query": "select column_name from information_schema.`columns` where table_schema = schema()", + "Table": "information_schema.`columns`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select column_name from information_schema.columns where table_schema = (select schema())", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.`columns` where 1 != 1", + "Query": "select column_name from information_schema.`columns` where table_schema = schema()", + "Table": "information_schema.`columns`" + }, + "TablesUsed": [ + "information_schema.columns" + ] + } + }, + { + "comment": "information schema join", + "query": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", + "v3-plan": "symbol `tables`.TABLE_SCHEMA not found", + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select tables.TABLE_SCHEMA, files.`STATUS` from information_schema.tables join information_schema.files", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select `tables`.TABLE_SCHEMA, files.`STATUS` from information_schema.`tables`, information_schema.files where 1 != 1", + "Query": "select `tables`.TABLE_SCHEMA, files.`STATUS` from information_schema.`tables`, information_schema.files", + "Table": "information_schema.`tables`, information_schema.files" + }, + "TablesUsed": [ + "information_schema.files", + "information_schema.tables" + ] + } + }, + { + "comment": "access to qualified column names in information_schema", + "query": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from information_schema.`COLUMNS` where 1 != 1", + "Query": "select * from information_schema.`COLUMNS` where information_schema.`COLUMNS`.COLUMN_NAME = 'toto'", + "Table": "information_schema.`COLUMNS`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select * from information_schema.COLUMNS where information_schema.COLUMNS.COLUMN_NAME='toto'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE, COLUMN_KEY, EXTRA, `PRIVILEGES`, COLUMN_COMMENT, GENERATION_EXPRESSION from information_schema.`COLUMNS` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_NAME, COLLATION_NAME, COLUMN_TYPE, COLUMN_KEY, EXTRA, `PRIVILEGES`, COLUMN_COMMENT, GENERATION_EXPRESSION from information_schema.`COLUMNS` where `COLUMNS`.COLUMN_NAME = 'toto'", + "Table": "information_schema.`COLUMNS`" + }, + "TablesUsed": [ + "information_schema.COLUMNS" + ] + } + }, + { + "comment": "union of information_schema", + "query": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`columns` where 1 != 1 union select table_schema from information_schema.`tables` where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`columns` union select table_schema from information_schema.`tables`", + "Table": "information_schema.`columns`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select TABLE_NAME from information_schema.columns union select table_schema from information_schema.tables", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`columns` where 1 != 1 union select table_schema from information_schema.`tables` where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`columns` union select table_schema from information_schema.`tables`", + "Table": "information_schema.`columns`" + }, + "TablesUsed": [ + "information_schema.columns", + "information_schema.tables" + ] + } + }, + { + "comment": "union between information_schema tables that should not be merged", + "query": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", + "Instructions": { + "OperatorType": "Distinct", + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from information_schema.`tables` where 1 != 1", + "Query": "select * from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from information_schema.`tables` where 1 != 1", + "Query": "select * from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"main\")]", + "Table": "information_schema.`tables`" + } + ] + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", + "Instructions": { + "OperatorType": "Distinct", + "Collations": [ + "(0:21)", + "(1:22)", + "(2:23)", + "(3:24)", + "(4:25)", + "5: binary", + "(6:26)", + "7: binary", + "8: binary", + "9: binary", + "10: binary", + "11: binary", + "12: binary", + "13: binary", + "(14:27)", + "(15:28)", + "(16:29)", + "(17:30)", + "18: binary", + "(19:31)", + "(20:32)" + ], + "ResultColumns": 21, + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1", + "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1", + "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"main\")]", + "Table": "information_schema.`tables`" + } + ] + } + ] + }, + "TablesUsed": [ + "information_schema.tables" + ] + } + }, + { + "comment": "Select from information schema query with two tables that route should be merged", + "query": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1", + "Query": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.COLUMN_NAME = 'id' and KCU.REFERENCED_TABLE_SCHEMA = 'test' and KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc", + "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]", + "SysTableTableSchema": "[VARCHAR(\"test\")]", + "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT RC.CONSTRAINT_NAME, ORDINAL_POSITION FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.COLUMN_NAME = 'id' AND KCU.REFERENCED_TABLE_SCHEMA = 'test' AND KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC where 1 != 1", + "Query": "select RC.CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.COLUMN_NAME = 'id' and KCU.REFERENCED_TABLE_SCHEMA = 'test' and KCU.CONSTRAINT_NAME = 'data_type_table_id_fkey' and KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc", + "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]", + "SysTableTableSchema": "[VARCHAR(\"test\")]", + "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS" + }, + "TablesUsed": [ + "information_schema.KEY_COLUMN_USAGE", + "information_schema.REFERENTIAL_CONSTRAINTS" + ] + } + }, + { + "comment": "Select from information schema query with three tables such that route for 2 should be merged but not for the last.", + "query": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "L:0,R:0", + "TableName": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS_INFORMATION_SCHEMA.`TABLES`", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select KCU.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where 1 != 1", + "Query": "select KCU.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU join INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC on KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME where KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.TABLE_NAME = :KCU_TABLE_NAME1 order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc", + "SysTableTableName": "[KCU_TABLE_NAME1:VARCHAR(\"data_type_table\"), KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]", + "SysTableTableSchema": "[VARCHAR(\"test\")]", + "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select S.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as S where 1 != 1", + "Query": "select S.TABLE_NAME from INFORMATION_SCHEMA.`TABLES` as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :S_TABLE_NAME", + "SysTableTableName": "[S_TABLE_NAME:VARCHAR(\"sc\")]", + "SysTableTableSchema": "[VARCHAR(\"test\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT KCU.`TABLE_NAME`, S.`TABLE_NAME` FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.`TABLES` AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select KCU.TABLE_NAME, S.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.`TABLES` as S where 1 != 1", + "Query": "select KCU.TABLE_NAME, S.TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.`TABLES` as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :S_TABLE_NAME and KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.TABLE_NAME = :KCU_TABLE_NAME1 and KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc", + "SysTableTableName": "[KCU_TABLE_NAME1:VARCHAR(\"data_type_table\"), KCU_TABLE_NAME:VARCHAR(\"data_type_table\"), S_TABLE_NAME:VARCHAR(\"sc\")]", + "SysTableTableSchema": "[VARCHAR(\"test\"), VARCHAR(\"test\")]", + "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS, INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.KEY_COLUMN_USAGE", + "information_schema.REFERENTIAL_CONSTRAINTS", + "information_schema.TABLES" + ] + } + }, + { + "comment": "information_schema.routines", + "query": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select routine_name as `name`, routine_definition as definition from information_schema.routines where 1 != 1", + "Query": "select routine_name as `name`, routine_definition as definition from information_schema.routines where ROUTINE_SCHEMA = :__vtschemaname and ROUTINE_TYPE = 'PROCEDURE'", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.routines" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select routine_name as `name`, routine_definition as definition from information_schema.routines where 1 != 1", + "Query": "select routine_name as `name`, routine_definition as definition from information_schema.routines where ROUTINE_SCHEMA = :__vtschemaname and ROUTINE_TYPE = 'PROCEDURE'", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.routines" + }, + "TablesUsed": [ + "information_schema.routines" + ] + } + }, + { + "comment": "information_schema table sizes", + "query": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select sum(data_length + index_length) as size from information_schema.`TABLES` where 1 != 1", + "Query": "select sum(data_length + index_length) as size from information_schema.`TABLES` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select sum(data_length + index_length) as size from information_schema.`TABLES` where 1 != 1", + "Query": "select sum(data_length + index_length) as size from information_schema.`TABLES` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "information_schema referential contraints", + "query": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where 1 != 1", + "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu join information_schema.referential_constraints as rc on kcu.constraint_name = rc.constraint_name where kcu.table_schema = :__vtschemaname and rc.constraint_schema = :__vtschemaname and kcu.referenced_column_name is not null order by ordinal_position asc", + "SysTableTableSchema": "[:v1, :v2]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT kcu.constraint_name constraint_name, kcu.column_name column_name, kcu.referenced_table_name referenced_table_name, kcu.referenced_column_name referenced_column_name, kcu.ordinal_position ordinal_position, kcu.table_name table_name, rc.delete_rule delete_rule, rc.update_rule update_rule FROM information_schema.key_column_usage AS kcu INNER JOIN information_schema.referential_constraints AS rc ON kcu.constraint_name = rc.constraint_name WHERE kcu.table_schema = ? AND rc.constraint_schema = ? AND kcu.referenced_column_name IS NOT NULL ORDER BY ordinal_position", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu, information_schema.referential_constraints as rc where 1 != 1", + "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu, information_schema.referential_constraints as rc where kcu.table_schema = :__vtschemaname and kcu.referenced_column_name is not null and rc.constraint_schema = :__vtschemaname and kcu.constraint_name = rc.constraint_name order by ordinal_position asc", + "SysTableTableSchema": "[:v1, :v2]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] + } + }, + { + "comment": "rails query", + "query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where 1 != 1", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name and rc.constraint_schema = database() and rc.table_name = :rc_table_name", + "SysTableTableName": "[fk_table_name:VARCHAR(\":vtg1\"), rc_table_name:VARCHAR(\":vtg1\")]", + "Table": "information_schema.referential_constraints, information_schema.key_column_usage" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as name, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = ':vtg1' and rc.constraint_schema = database() and rc.table_name = ':vtg1'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = database() and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name", + "SysTableTableName": "[fk_table_name:VARCHAR(\":vtg1\"), rc_table_name:VARCHAR(\":vtg1\")]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] + } + }, + { + "comment": "rails_query 2", + "query": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from information_schema.schemata where 1 != 1", + "Query": "select * from information_schema.schemata where schema_name = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\")]", + "Table": "information_schema.schemata" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH from information_schema.schemata where 1 != 1", + "Query": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH from information_schema.schemata where schema_name = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\")]", + "Table": "information_schema.schemata" + }, + "TablesUsed": [ + "information_schema.schemata" + ] + } + }, + { + "comment": "rails_query 3", + "query": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_comment from information_schema.`tables` where 1 != 1", + "Query": "select table_comment from information_schema.`tables` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"schema_name\")]", + "Table": "information_schema.`tables`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_comment from information_schema.`tables` where 1 != 1", + "Query": "select table_comment from information_schema.`tables` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"schema_name\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables" + ] + } + }, + { + "comment": "rails_query 4", + "query": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where 1 != 1", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc join information_schema.key_column_usage as fk using (constraint_schema, constraint_name) where fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name and rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name", + "SysTableTableName": "[fk_table_name:VARCHAR(\"table_name\"), rc_table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"table_schema\")]", + "Table": "information_schema.referential_constraints, information_schema.key_column_usage" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT fk.referenced_table_name AS 'to_table', fk.referenced_column_name AS 'primary_key',fk.column_name AS 'column',fk.constraint_name AS 'name',rc.update_rule AS 'on_update',rc.delete_rule AS 'on_delete' FROM information_schema.referential_constraints rc JOIN information_schema.key_column_usage fk USING (constraint_schema, constraint_name) WHERE fk.referenced_column_name IS NOT NULL AND fk.table_schema = 'table_schema' AND fk.table_name = 'table_name' AND rc.constraint_schema = 'table_schema' AND rc.table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name", + "SysTableTableName": "[fk_table_name:VARCHAR(\"table_name\"), rc_table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"table_schema\")]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] + } + }, + { + "comment": "rails_query 6", + "query": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.statistics where 1 != 1", + "Query": "select column_name from information_schema.statistics where index_name = 'PRIMARY' and table_schema = :__vtschemaname and table_name = :table_name order by seq_in_index asc", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.statistics" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.statistics where 1 != 1", + "Query": "select column_name from information_schema.statistics where index_name = 'PRIMARY' and table_schema = :__vtschemaname and table_name = :table_name order by seq_in_index asc", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.statistics" + }, + "TablesUsed": [ + "information_schema.statistics" + ] + } + }, + { + "comment": "rails_query 7", + "query": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select generation_expression from information_schema.`columns` where 1 != 1", + "Query": "select generation_expression from information_schema.`columns` where table_schema = :__vtschemaname and table_name = :table_name and column_name = 'column_name'", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`columns`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select generation_expression from information_schema.`columns` where 1 != 1", + "Query": "select generation_expression from information_schema.`columns` where table_schema = :__vtschemaname and table_name = :table_name and column_name = 'column_name'", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`columns`" + }, + "TablesUsed": [ + "information_schema.columns" + ] + } + }, + { + "comment": "rails_query 8", + "query": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select id from information_schema.`processlist` where 1 != 1", + "Query": "select id from information_schema.`processlist` where info like '% FOR UPDATE'", + "Table": "information_schema.`processlist`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select id from information_schema.`processlist` where 1 != 1", + "Query": "select id from information_schema.`processlist` where info like '% FOR UPDATE'", + "Table": "information_schema.`processlist`" + }, + "TablesUsed": [ + "information_schema.processlist" + ] + } + }, + { + "comment": "rails_query 9", + "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`tables`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables" + ] + } + }, + { + "comment": "rails_query 10", + "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery where _subquery.table_type = 'table_type' and _subquery.table_name = :_subquery_table_name", + "SysTableTableName": "[_subquery_table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`tables`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery WHERE _subquery.table_type = 'table_type' AND _subquery.table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname and table_type = 'table_type' and table_name = 'table_name') as _subquery", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables" + ] + } + }, + { + "comment": "system schema in where clause of information_schema query", + "query": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select count(*) from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select count(*) from INFORMATION_SCHEMA.`TABLES` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"foo\")]", + "SysTableTableSchema": "[VARCHAR(\"performance_schema\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select count(*) from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select count(*) from INFORMATION_SCHEMA.`TABLES` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"foo\")]", + "SysTableTableSchema": "[VARCHAR(\"performance_schema\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "subquery of information_schema with itself", + "query": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", + "v3-plan": "symbol `TABLES`.`CHECKSUM` not found", + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select TABLES.CHECKSUM from information_schema.`TABLES` where `TABLE_NAME` in (select `TABLE_NAME` from information_schema.`COLUMNS`)", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select `TABLES`.`CHECKSUM` from information_schema.`TABLES` where 1 != 1", + "Query": "select `TABLES`.`CHECKSUM` from information_schema.`TABLES` where TABLE_NAME in (select TABLE_NAME from information_schema.`COLUMNS`)", + "Table": "information_schema.`TABLES`" + }, + "TablesUsed": [ + "information_schema.COLUMNS", + "information_schema.TABLES" + ] + } + }, + { + "comment": "query trying to query two different keyspaces at the same time", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "information_schema query using database() func", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "table_schema predicate the wrong way around", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "table_name predicate against a routed table", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME", + "SysTableTableName": "[TABLE_NAME:VARCHAR(\"route1\")]", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME", + "SysTableTableName": "[TABLE_NAME:VARCHAR(\"route1\")]", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "information_schema query with additional predicates", + "query": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and DATA_FREE = 42", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT `TABLE_NAME` FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and DATA_FREE = 42", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_NAME from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and DATA_FREE = 42", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "able to isolate table_schema value even when hidden inside of ORs", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and (DATA_FREE = 42 or TABLE_SCHEMA = 'ks') and (DATA_FREE = 42 or `CHECKSUM` = 'value')", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and DATA_FREE = 42) OR (TABLE_SCHEMA = 'ks' and CHECKSUM = 'value')", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and (DATA_FREE = 42 or TABLE_SCHEMA = 'ks') and (DATA_FREE = 42 or `CHECKSUM` = 'value')", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + }, + { + "comment": "expand star with information schema", + "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select x.table_name from (select a.* from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", + "Query": "select x.table_name from (select a.* from information_schema.key_column_usage as a) as x", + "Table": "information_schema.key_column_usage" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", + "Query": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a) as x", + "Table": "information_schema.key_column_usage" + }, + "TablesUsed": [ + "information_schema.key_column_usage" + ] + } + }, + { + "comment": "expand star with information schema in a derived table", + "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "L:0", + "JoinVars": { + "x_COLUMN_NAME": 1 + }, + "TableName": "information_schema.key_column_usage_`user`", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select x.table_name, x.COLUMN_NAME from (select a.* from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", + "Query": "select x.table_name, x.COLUMN_NAME from (select a.* from information_schema.key_column_usage as a) as x", + "Table": "information_schema.key_column_usage" + }, + { + "OperatorType": "Route", + "Variant": "EqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select 1 from `user` where 1 != 1", + "Query": "select 1 from `user` where `user`.id = :x_COLUMN_NAME", + "Table": "`user`", + "Values": [ + ":x_COLUMN_NAME" + ], + "Vindex": "user_index" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.`COLUMN_NAME` = user.id", + "Instructions": { + "OperatorType": "Join", + "Variant": "Join", + "JoinColumnIndexes": "L:0", + "JoinVars": { + "x_COLUMN_NAME": 0 + }, + "TableName": "information_schema.key_column_usage_`user`", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", + "Query": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a) as x", + "Table": "information_schema.key_column_usage" + }, + { + "OperatorType": "Route", + "Variant": "EqualUnique", + "Keyspace": { + "Name": "user", + "Sharded": true + }, + "FieldQuery": "select 1 from `user` where 1 != 1", + "Query": "select 1 from `user` where `user`.id = :x_COLUMN_NAME", + "Table": "`user`", + "Values": [ + ":x_COLUMN_NAME" + ], + "Vindex": "user_index" + } + ] + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "user.user" + ] + } + }, + { + "comment": "join of information_schema queries with select stars exprs", + "query": "select a.*, b.* from information_schema.a a, information_schema.b b", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select a.*, b.* from information_schema.a a, information_schema.b b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.*, b.* from information_schema.a as a, information_schema.b as b where 1 != 1", + "Query": "select a.*, b.* from information_schema.a as a, information_schema.b as b", + "Table": "information_schema.a, information_schema.b" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select a.*, b.* from information_schema.a a, information_schema.b b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.*, b.* from information_schema.a as a, information_schema.b as b where 1 != 1", + "Query": "select a.*, b.* from information_schema.a as a, information_schema.b as b", + "Table": "information_schema.a, information_schema.b" + }, + "TablesUsed": [ + "information_schema.a", + "information_schema.b" + ] + } + }, + { + "comment": "join two routes with SysTableTableName entries in LHS and RHS", + "query": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.table_name from (select * from information_schema.key_column_usage as a where 1 != 1) as a join (select * from information_schema.referential_constraints where 1 != 1) as b where 1 != 1", + "Query": "select a.table_name from (select * from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a join (select * from information_schema.referential_constraints where table_name = :table_name) as b", + "SysTableTableName": "[a_table_name:VARCHAR(\"users\"), table_name:VARCHAR(\"users\")]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select a.table_name from (select * from information_schema.key_column_usage a where a.table_name = 'users') a join (select * from information_schema.referential_constraints where table_name = 'users') b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where 1 != 1) as b where 1 != 1", + "Query": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where table_name = :table_name) as b", + "SysTableTableName": "[a_table_name:VARCHAR(\"users\"), table_name:VARCHAR(\"users\")]", + "Table": "information_schema.key_column_usage, information_schema.referential_constraints" + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] + } + }, + { + "comment": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "v3-plan": "unsupported: cross-shard query with aggregates", + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select sum(found) from (select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)) as t where 1 != 1", + "Query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] + } + }, + { + "comment": "union as a derived table", + "query": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "Instructions": { + "OperatorType": "SimpleProjection", + "Columns": [ + 0 + ], + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"music\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.views where 1 != 1", + "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1", + "SysTableTableSchema": "[VARCHAR(\"music\")]", + "Table": "information_schema.views" + } + ] + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select found from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select found from (select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)) as t where 1 != 1", + "Query": "select found from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] + } + }, + { + "comment": "merge system schema queries as long as they have any same table_schema", + "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "Instructions": { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.views where 1 != 1", + "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"user\")]", + "Table": "information_schema.views" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)", + "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] + } + }, + { + "comment": "merge system schema queries as long as they have any same table_name", + "query": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "Instructions": { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.views where 1 != 1", + "Query": "select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"user\")]", + "Table": "information_schema.views" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_schema = 'music' and table_schema = 'Music' union all (select 1 as found from information_schema.views where table_schema = 'music' and table_schema = 'user' limit 1)", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1 union all (select 1 as found from information_schema.views where 1 != 1)", + "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)", + "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] + } + }, + { + "comment": "merge union subquery with outer query referencing the same system schemas", + "query": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", + "Instructions": { + "OperatorType": "Subquery", + "Variant": "PulloutExists", + "PulloutVars": [ + "__sq_has_values1", + "__sq1" + ], + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name2 and table_name = :table_name3", + "SysTableTableName": "[table_name2:VARCHAR(\"music\"), table_name3:VARCHAR(\"Music\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.views where 1 != 1", + "Query": "select 1 as found from information_schema.views where table_name = :table_name4 and table_name = :table_name5 limit 1", + "SysTableTableName": "[table_name4:VARCHAR(\"music\"), table_name5:VARCHAR(\"user\")]", + "Table": "information_schema.views" + } + ] + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name and table_name = :table_name1 and :__sq_has_values1", + "SysTableTableName": "[table_name1:VARCHAR(\"Music\"), table_name:VARCHAR(\"music\")]", + "Table": "information_schema.`tables`" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' and exists (select 1 as found from information_schema.`tables` where table_name = 'music' and table_name = 'Music' union all (select 1 as found from information_schema.views where table_name = 'music' and table_name = 'user' limit 1))", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select 1 as found from information_schema.`tables` where 1 != 1", + "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name and table_name = :table_name1 and exists (select 1 as found from information_schema.`tables` where table_name = :table_name2 and table_name = :table_name3 union all (select 1 as found from information_schema.views where table_name = :table_name4 and table_name = :table_name5 limit 1))", + "SysTableTableName": "[table_name1:VARCHAR(\"Music\"), table_name2:VARCHAR(\"music\"), table_name3:VARCHAR(\"Music\"), table_name4:VARCHAR(\"music\"), table_name5:VARCHAR(\"user\"), table_name:VARCHAR(\"music\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] + } + }, + { + "comment": "merge even one side have schema name in derived table", + "query": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", + "Instructions": { + "OperatorType": "SimpleProjection", + "Columns": [ + 0 + ], + "Inputs": [ + { + "OperatorType": "Distinct", + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`tables` as t where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"a\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_NAME from information_schema.`columns` where 1 != 1", + "Query": "select TABLE_NAME from information_schema.`columns`", + "Table": "information_schema.`columns`" + } + ] + } + ] + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select * from (select TABLE_NAME from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select TABLE_NAME from information_schema.columns) dt", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select dt.TABLE_NAME from (select TABLE_NAME from information_schema.`tables` as t where 1 != 1 union select TABLE_NAME from information_schema.`columns` where 1 != 1) as dt where 1 != 1", + "Query": "select dt.TABLE_NAME from (select TABLE_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname union select TABLE_NAME from information_schema.`columns`) as dt", + "SysTableTableSchema": "[VARCHAR(\"a\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.columns", + "information_schema.tables" + ] + } + }, + { + "comment": "merge even one side have schema name in subquery", + "query": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", + "v3-plan": { + "QueryType": "SELECT", + "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", + "Instructions": { + "OperatorType": "Subquery", + "Variant": "PulloutIn", + "PulloutVars": [ + "__sq_has_values1", + "__sq1" + ], + "Inputs": [ + { + "OperatorType": "Distinct", + "Inputs": [ + { + "OperatorType": "Concatenate", + "Inputs": [ + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select COLUMN_NAME from information_schema.`tables` as t where 1 != 1", + "Query": "select COLUMN_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"a\")]", + "Table": "information_schema.`tables`" + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select COLUMN_NAME from information_schema.`columns` where 1 != 1", + "Query": "select COLUMN_NAME from information_schema.`columns`", + "Table": "information_schema.`columns`" + } + ] + } + ] + }, + { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select COLLATION_NAME from information_schema.`COLUMNS` as t where 1 != 1", + "Query": "select COLLATION_NAME from information_schema.`COLUMNS` as t where :__sq_has_values1 = 1 and COLUMN_NAME in ::__sq1", + "Table": "information_schema.`COLUMNS`" + } + ] + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select `COLLATION_NAME` from information_schema.`COLUMNS` t where `COLUMN_NAME` in (select `COLUMN_NAME` from information_schema.tables t where t.TABLE_SCHEMA = 'a' union select `COLUMN_NAME` from information_schema.columns)", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select COLLATION_NAME from information_schema.`COLUMNS` as t where 1 != 1", + "Query": "select COLLATION_NAME from information_schema.`COLUMNS` as t where COLUMN_NAME in (select COLUMN_NAME from information_schema.`tables` as t where t.TABLE_SCHEMA = :__vtschemaname union select COLUMN_NAME from information_schema.`columns`)", + "SysTableTableSchema": "[VARCHAR(\"a\")]", + "Table": "information_schema.`COLUMNS`" + }, + "TablesUsed": [ + "information_schema.COLUMNS", + "information_schema.columns", + "information_schema.tables" + ] + } + }, + { + "comment": "table_schema OR predicate\n# It is unsupported because we do not route queries to multiple keyspaces right now", + "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", + "v3-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'", + "Table": "INFORMATION_SCHEMA.`TABLES`" + } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] + } + } +] diff --git a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.json b/go/vt/vtgate/planbuilder/testdata/systemtables_cases80.json similarity index 74% rename from go/vt/vtgate/planbuilder/testdata/systemtables_cases.json rename to go/vt/vtgate/planbuilder/testdata/systemtables_cases80.json index 235fc1c398..9d4c8e81e8 100644 --- a/go/vt/vtgate/planbuilder/testdata/systemtables_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/systemtables_cases80.json @@ -2,7 +2,7 @@ { "comment": "Single information_schema query", "query": "select col from information_schema.foo", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select col from information_schema.foo", "Instructions": { @@ -16,12 +16,13 @@ "Query": "select col from information_schema.foo", "Table": "information_schema.foo" } - } + }, + "gen4-plan": "symbol col not found" }, { "comment": "',' join information_schema", "query": "select a.id,b.id from information_schema.a as a, information_schema.b as b", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select a.id,b.id from information_schema.a as a, information_schema.b as b", "Instructions": { @@ -35,12 +36,13 @@ "Query": "select a.id, b.id from information_schema.a as a, information_schema.b as b", "Table": "information_schema.a, information_schema.b" } - } + }, + "gen4-plan": "symbol a.id not found" }, { "comment": "information schema query that uses table_schema", "query": "select column_name from information_schema.columns where table_schema = (select schema())", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select column_name from information_schema.columns where table_schema = (select schema())", "Instructions": { @@ -54,6 +56,24 @@ "Query": "select column_name from information_schema.`columns` where table_schema = schema()", "Table": "information_schema.`columns`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select column_name from information_schema.columns where table_schema = (select schema())", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.`columns` where 1 != 1", + "Query": "select column_name from information_schema.`columns` where table_schema = schema()", + "Table": "information_schema.`columns`" + }, + "TablesUsed": [ + "information_schema.columns" + ] } }, { @@ -87,13 +107,17 @@ "FieldQuery": "select * from information_schema.a, information_schema.b where 1 != 1", "Query": "select * from information_schema.a, information_schema.b", "Table": "information_schema.a, information_schema.b" - } + }, + "TablesUsed": [ + "information_schema.a", + "information_schema.b" + ] } }, { "comment": "access to unqualified column names in information_schema", "query": "select * from information_schema.a where b=10", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select * from information_schema.a where b=10", "Instructions": { @@ -107,7 +131,8 @@ "Query": "select * from information_schema.a where b = 10", "Table": "information_schema.a" } - } + }, + "gen4-plan": "symbol b not found" }, { "comment": "access to qualified column names in information_schema", @@ -127,26 +152,12 @@ "Table": "information_schema.a" } }, - "gen4-plan": { - "QueryType": "SELECT", - "Original": "select * from information_schema.a where information_schema.a.b=10", - "Instructions": { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select * from information_schema.a where 1 != 1", - "Query": "select * from information_schema.a where a.b = 10", - "Table": "information_schema.a" - } - } + "gen4-plan": "symbol information_schema.a.b not found" }, { "comment": "union of information_schema", "query": "select * from information_schema.a union select * from information_schema.b", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select * from information_schema.a union select * from information_schema.b", "Instructions": { @@ -160,6 +171,25 @@ "Query": "select * from information_schema.a union select * from information_schema.b", "Table": "information_schema.a" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select * from information_schema.a union select * from information_schema.b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select * from information_schema.a where 1 != 1 union select * from information_schema.b where 1 != 1", + "Query": "select * from information_schema.a union select * from information_schema.b", + "Table": "information_schema.a" + }, + "TablesUsed": [ + "information_schema.a", + "information_schema.b" + ] } }, { @@ -208,6 +238,30 @@ "Original": "select * from information_schema.tables where table_schema = 'user' union select * from information_schema.tables where table_schema = 'main'", "Instructions": { "OperatorType": "Distinct", + "Collations": [ + "(0:21)", + "(1:22)", + "(2:23)", + "(3:24)", + "(4:25)", + "5: binary", + "(6:26)", + "7: binary", + "8: binary", + "9: binary", + "10: binary", + "11: binary", + "12: binary", + "13: binary", + "(14:27)", + "(15:28)", + "(16:29)", + "(17:30)", + "18: binary", + "(19:31)", + "(20:32)" + ], + "ResultColumns": 21, "Inputs": [ { "OperatorType": "Concatenate", @@ -219,8 +273,8 @@ "Name": "main", "Sharded": false }, - "FieldQuery": "select * from information_schema.`tables` where 1 != 1", - "Query": "select distinct * from information_schema.`tables` where table_schema = :__vtschemaname", + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1", + "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname", "SysTableTableSchema": "[VARCHAR(\"user\")]", "Table": "information_schema.`tables`" }, @@ -231,15 +285,18 @@ "Name": "main", "Sharded": false }, - "FieldQuery": "select * from information_schema.`tables` where 1 != 1", - "Query": "select distinct * from information_schema.`tables` where table_schema = :__vtschemaname", + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where 1 != 1", + "Query": "select distinct TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT, weight_string(TABLE_CATALOG), weight_string(TABLE_SCHEMA), weight_string(TABLE_NAME), weight_string(TABLE_TYPE), weight_string(`ENGINE`), weight_string(`ROW_FORMAT`), weight_string(CREATE_TIME), weight_string(UPDATE_TIME), weight_string(CHECK_TIME), weight_string(TABLE_COLLATION), weight_string(CREATE_OPTIONS), weight_string(TABLE_COMMENT) from information_schema.`tables` where table_schema = :__vtschemaname", "SysTableTableSchema": "[VARCHAR(\"main\")]", "Table": "information_schema.`tables`" } ] } ] - } + }, + "TablesUsed": [ + "information_schema.tables" + ] } }, { @@ -277,7 +334,11 @@ "SysTableTableName": "[KCU_TABLE_NAME:VARCHAR(\"data_type_table\")]", "SysTableTableSchema": "[VARCHAR(\"test\")]", "Table": "INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS" - } + }, + "TablesUsed": [ + "information_schema.KEY_COLUMN_USAGE", + "information_schema.REFERENTIAL_CONSTRAINTS" + ] } }, { @@ -321,28 +382,12 @@ ] } }, - "gen4-plan": { - "QueryType": "SELECT", - "Original": "SELECT KCU.DELETE_RULE, S.UPDATE_RULE FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KCU INNER JOIN INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS AS RC ON KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME, INFORMATION_SCHEMA.K AS S WHERE KCU.TABLE_SCHEMA = 'test' AND KCU.TABLE_NAME = 'data_type_table' AND KCU.TABLE_NAME = 'data_type_table' AND S.TABLE_SCHEMA = 'test' AND S.TABLE_NAME = 'sc' ORDER BY KCU.CONSTRAINT_NAME, KCU.COLUMN_NAME", - "Instructions": { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select KCU.DELETE_RULE, S.UPDATE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.K as S where 1 != 1", - "Query": "select KCU.DELETE_RULE, S.UPDATE_RULE from INFORMATION_SCHEMA.KEY_COLUMN_USAGE as KCU, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS as RC, INFORMATION_SCHEMA.K as S where S.TABLE_SCHEMA = :__vtschemaname and S.TABLE_NAME = :S_TABLE_NAME and KCU.TABLE_SCHEMA = :__vtschemaname and KCU.TABLE_NAME = :KCU_TABLE_NAME and KCU.TABLE_NAME = :KCU_TABLE_NAME1 and KCU.CONSTRAINT_NAME = RC.CONSTRAINT_NAME order by KCU.CONSTRAINT_NAME asc, KCU.COLUMN_NAME asc", - "SysTableTableName": "[KCU_TABLE_NAME1:VARCHAR(\"data_type_table\"), KCU_TABLE_NAME:VARCHAR(\"data_type_table\"), S_TABLE_NAME:VARCHAR(\"sc\")]", - "SysTableTableSchema": "[VARCHAR(\"test\"), VARCHAR(\"test\")]", - "Table": "INFORMATION_SCHEMA.K, INFORMATION_SCHEMA.KEY_COLUMN_USAGE, INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS" - } - } + "gen4-plan": "symbol KCU.DELETE_RULE not found" }, { "comment": "information_schema.routines", "query": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", "Instructions": { @@ -357,12 +402,31 @@ "SysTableTableSchema": "[:v1]", "Table": "information_schema.routines" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT routine_name AS name, routine_definition AS definition FROM information_schema.routines WHERE ROUTINE_SCHEMA = ? AND ROUTINE_TYPE = 'PROCEDURE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select routine_name as `name`, routine_definition as definition from information_schema.routines where 1 != 1", + "Query": "select routine_name as `name`, routine_definition as definition from information_schema.routines where ROUTINE_SCHEMA = :__vtschemaname and ROUTINE_TYPE = 'PROCEDURE'", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.routines" + }, + "TablesUsed": [ + "information_schema.routines" + ] } }, { "comment": "information_schema table sizes", "query": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", "Instructions": { @@ -377,6 +441,25 @@ "SysTableTableSchema": "[:v1]", "Table": "information_schema.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT SUM(data_length + index_length) as size FROM information_schema.TABLES WHERE table_schema = ?", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select sum(data_length + index_length) as size from information_schema.`TABLES` where 1 != 1", + "Query": "select sum(data_length + index_length) as size from information_schema.`TABLES` where table_schema = :__vtschemaname", + "SysTableTableSchema": "[:v1]", + "Table": "information_schema.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { @@ -412,7 +495,11 @@ "Query": "select kcu.constraint_name as constraint_name, kcu.column_name as column_name, kcu.referenced_table_name as referenced_table_name, kcu.referenced_column_name as referenced_column_name, kcu.ordinal_position as ordinal_position, kcu.table_name as table_name, rc.delete_rule as delete_rule, rc.update_rule as update_rule from information_schema.key_column_usage as kcu, information_schema.referential_constraints as rc where kcu.table_schema = :__vtschemaname and kcu.referenced_column_name is not null and rc.constraint_schema = :__vtschemaname and kcu.constraint_name = rc.constraint_name order by ordinal_position asc", "SysTableTableSchema": "[:v1, :v2]", "Table": "information_schema.key_column_usage, information_schema.referential_constraints" - } + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] } }, { @@ -445,16 +532,20 @@ "Sharded": false }, "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1", - "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = database() and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = database() and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = database() and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name", "SysTableTableName": "[fk_table_name:VARCHAR(\":vtg1\"), rc_table_name:VARCHAR(\":vtg1\")]", "Table": "information_schema.key_column_usage, information_schema.referential_constraints" - } + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] } }, { "comment": "rails_query 2", "query": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", "Instructions": { @@ -469,12 +560,31 @@ "SysTableTableSchema": "[VARCHAR(\"user\")]", "Table": "information_schema.schemata" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM information_schema.schemata WHERE schema_name = 'user'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH, DEFAULT_ENCRYPTION from information_schema.schemata where 1 != 1", + "Query": "select CATALOG_NAME, SCHEMA_NAME, DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME, SQL_PATH, DEFAULT_ENCRYPTION from information_schema.schemata where schema_name = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\")]", + "Table": "information_schema.schemata" + }, + "TablesUsed": [ + "information_schema.schemata" + ] } }, { "comment": "rails_query 3", "query": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", "Instructions": { @@ -490,6 +600,26 @@ "SysTableTableSchema": "[VARCHAR(\"schema_name\")]", "Table": "information_schema.`tables`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_comment FROM information_schema.tables WHERE table_schema = 'schema_name' AND table_name = 'table_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_comment from information_schema.`tables` where 1 != 1", + "Query": "select table_comment from information_schema.`tables` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"schema_name\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables" + ] } }, { @@ -523,11 +653,15 @@ "Sharded": false }, "FieldQuery": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where 1 != 1", - "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name", + "Query": "select fk.referenced_table_name as to_table, fk.referenced_column_name as primary_key, fk.column_name as `column`, fk.constraint_name as `name`, rc.update_rule as on_update, rc.delete_rule as on_delete from information_schema.referential_constraints as rc, information_schema.key_column_usage as fk where rc.constraint_schema = :__vtschemaname and rc.table_name = :rc_table_name and fk.referenced_column_name is not null and fk.table_schema = :__vtschemaname and fk.table_name = :fk_table_name and rc.constraint_schema = fk.constraint_schema and rc.constraint_name = fk.constraint_name", "SysTableTableName": "[fk_table_name:VARCHAR(\"table_name\"), rc_table_name:VARCHAR(\"table_name\")]", "SysTableTableSchema": "[VARCHAR(\"table_schema\"), VARCHAR(\"table_schema\")]", "Table": "information_schema.key_column_usage, information_schema.referential_constraints" - } + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] } }, { @@ -561,17 +695,21 @@ "Sharded": false }, "FieldQuery": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc, information_schema.table_constraints as tc where 1 != 1", - "Query": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc, information_schema.table_constraints as tc where cc.constraint_schema = :__vtschemaname and tc.table_schema = :__vtschemaname and tc.table_name = :tc_table_name", + "Query": "select cc.constraint_name as `name`, cc.check_clause as expression from information_schema.check_constraints as cc, information_schema.table_constraints as tc where cc.constraint_schema = :__vtschemaname and tc.table_schema = :__vtschemaname and tc.table_name = :tc_table_name and cc.constraint_schema = tc.constraint_schema and cc.constraint_name = tc.constraint_name", "SysTableTableName": "[tc_table_name:VARCHAR(\"table_name\")]", "SysTableTableSchema": "[VARCHAR(\"constraint_schema\"), VARCHAR(\"table_schema\")]", "Table": "information_schema.check_constraints, information_schema.table_constraints" - } + }, + "TablesUsed": [ + "information_schema.check_constraints", + "information_schema.table_constraints" + ] } }, { "comment": "rails_query 6", "query": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", "Instructions": { @@ -587,12 +725,32 @@ "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", "Table": "information_schema.statistics" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT column_name FROM information_schema.statistics WHERE index_name = 'PRIMARY' AND table_schema = 'table_schema' AND table_name = 'table_name' ORDER BY seq_in_index", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select column_name from information_schema.statistics where 1 != 1", + "Query": "select column_name from information_schema.statistics where index_name = 'PRIMARY' and table_schema = :__vtschemaname and table_name = :table_name order by seq_in_index asc", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.statistics" + }, + "TablesUsed": [ + "information_schema.statistics" + ] } }, { "comment": "rails_query 7", "query": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", "Instructions": { @@ -608,12 +766,32 @@ "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", "Table": "information_schema.`columns`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT generation_expression FROM information_schema.columns WHERE table_schema = 'table_schema' AND table_name = 'table_name' AND column_name = 'column_name'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select generation_expression from information_schema.`columns` where 1 != 1", + "Query": "select generation_expression from information_schema.`columns` where table_schema = :__vtschemaname and table_name = :table_name and column_name = 'column_name'", + "SysTableTableName": "[table_name:VARCHAR(\"table_name\")]", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`columns`" + }, + "TablesUsed": [ + "information_schema.columns" + ] } }, { "comment": "rails_query 8", "query": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", "Instructions": { @@ -627,12 +805,30 @@ "Query": "select id from information_schema.`processlist` where info like '% FOR UPDATE'", "Table": "information_schema.`processlist`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT id FROM information_schema.processlist WHERE info LIKE '% FOR UPDATE'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select id from information_schema.`processlist` where 1 != 1", + "Query": "select id from information_schema.`processlist` where info like '% FOR UPDATE'", + "Table": "information_schema.`processlist`" + }, + "TablesUsed": [ + "information_schema.processlist" + ] } }, { "comment": "rails_query 9", "query": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", "Instructions": { @@ -647,6 +843,25 @@ "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", "Table": "information_schema.`tables`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT table_name FROM (SELECT * FROM information_schema.tables WHERE table_schema = 'table_schema') _subquery", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname) as _subquery", + "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", + "Table": "information_schema.`tables`" + }, + "TablesUsed": [ + "information_schema.tables" + ] } }, { @@ -679,17 +894,20 @@ "Name": "main", "Sharded": false }, - "FieldQuery": "select table_name from (select * from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", - "Query": "select table_name from (select * from information_schema.`tables` where table_schema = :__vtschemaname and table_type = 'table_type' and table_name = 'table_name') as _subquery", + "FieldQuery": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where 1 != 1) as _subquery where 1 != 1", + "Query": "select table_name from (select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from information_schema.`tables` where table_schema = :__vtschemaname and table_type = 'table_type' and table_name = 'table_name') as _subquery", "SysTableTableSchema": "[VARCHAR(\"table_schema\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables" + ] } }, { "comment": "two predicates specifying the database for the same table work if the database is the same", "query": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc WHERE cc.constraint_schema = 'a' AND cc.table_schema = 'a'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT cc.constraint_name AS 'name' FROM information_schema.check_constraints cc WHERE cc.constraint_schema = 'a' AND cc.table_schema = 'a'", "Instructions": { @@ -704,12 +922,13 @@ "SysTableTableSchema": "[VARCHAR(\"a\"), VARCHAR(\"a\")]", "Table": "information_schema.check_constraints" } - } + }, + "gen4-plan": "symbol cc.table_schema not found" }, { "comment": "system schema in where clause of information_schema query", "query": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", "Instructions": { @@ -725,12 +944,32 @@ "SysTableTableSchema": "[VARCHAR(\"performance_schema\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'performance_schema' AND table_name = 'foo'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select count(*) from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select count(*) from INFORMATION_SCHEMA.`TABLES` where table_schema = :__vtschemaname and table_name = :table_name", + "SysTableTableName": "[table_name:VARCHAR(\"foo\")]", + "SysTableTableSchema": "[VARCHAR(\"performance_schema\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { "comment": "subquery of information_schema with itself", "query": "select * from information_schema.a where id in (select * from information_schema.b)", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select * from information_schema.a where id in (select * from information_schema.b)", "Instructions": { @@ -744,12 +983,13 @@ "Query": "select * from information_schema.a where id in (select * from information_schema.b)", "Table": "information_schema.a" } - } + }, + "gen4-plan": "symbol id not found" }, { "comment": "query trying to query two different keyspaces at the same time", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", "Instructions": { @@ -764,12 +1004,31 @@ "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'user' AND TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"main\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { "comment": "information_schema query using database() func", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", "Instructions": { @@ -783,12 +1042,30 @@ "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = database()", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = database()", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { "comment": "table_schema predicate the wrong way around", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", "Instructions": { @@ -803,12 +1080,31 @@ "SysTableTableSchema": "[VARCHAR(\"ks\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE 'ks' = TABLE_SCHEMA", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { "comment": "table_name predicate against a routed table", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", "Instructions": { @@ -824,12 +1120,32 @@ "SysTableTableSchema": "[VARCHAR(\"ks\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' AND TABLE_NAME = 'route1'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = :__vtschemaname and TABLE_NAME = :TABLE_NAME", + "SysTableTableName": "[TABLE_NAME:VARCHAR(\"route1\")]", + "SysTableTableSchema": "[VARCHAR(\"ks\")]", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } }, { "comment": "information_schema query with additional predicates", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and other_column = 42", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' and other_column = 42", "Instructions": { @@ -844,12 +1160,13 @@ "SysTableTableSchema": "[VARCHAR(\"ks\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } - } + }, + "gen4-plan": "symbol other_column not found" }, { "comment": "able to isolate table_schema value even when hidden inside of ORs", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and other_column = 42) OR (TABLE_SCHEMA = 'ks' and foobar = 'value')", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE (TABLE_SCHEMA = 'ks' and other_column = 42) OR (TABLE_SCHEMA = 'ks' and foobar = 'value')", "Instructions": { @@ -864,12 +1181,13 @@ "SysTableTableSchema": "[VARCHAR(\"ks\")]", "Table": "INFORMATION_SCHEMA.`TABLES`" } - } + }, + "gen4-plan": "symbol other_column not found" }, { "comment": "expand star with information schema", "query": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", "Instructions": { @@ -883,6 +1201,24 @@ "Query": "select x.table_name from (select a.* from information_schema.key_column_usage as a) as x", "Table": "information_schema.key_column_usage" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", + "Query": "select x.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a) as x", + "Table": "information_schema.key_column_usage" + }, + "TablesUsed": [ + "information_schema.key_column_usage" + ] } }, { @@ -929,55 +1265,12 @@ ] } }, - "gen4-plan": { - "QueryType": "SELECT", - "Original": "select x.table_name from (select a.* from information_schema.key_column_usage a) x join user on x.id = user.id", - "Instructions": { - "OperatorType": "Join", - "Variant": "Join", - "JoinColumnIndexes": "L:1", - "JoinVars": { - "x_id": 0 - }, - "TableName": "information_schema.key_column_usage_`user`", - "Inputs": [ - { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select x.id, x.table_name from (select a.* from information_schema.key_column_usage as a where 1 != 1) as x where 1 != 1", - "Query": "select x.id, x.table_name from (select a.* from information_schema.key_column_usage as a) as x", - "Table": "information_schema.key_column_usage" - }, - { - "OperatorType": "Route", - "Variant": "EqualUnique", - "Keyspace": { - "Name": "user", - "Sharded": true - }, - "FieldQuery": "select 1 from `user` where 1 != 1", - "Query": "select 1 from `user` where `user`.id = :x_id", - "Table": "`user`", - "Values": [ - ":x_id" - ], - "Vindex": "user_index" - } - ] - }, - "TablesUsed": [ - "user.user" - ] - } + "gen4-plan": "symbol x.id not found" }, { "comment": "join of information_schema queries with select stars exprs", "query": "select a.*, b.* from information_schema.a a, information_schema.b b", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "select a.*, b.* from information_schema.a a, information_schema.b b", "Instructions": { @@ -991,6 +1284,25 @@ "Query": "select a.*, b.* from information_schema.a as a, information_schema.b as b", "Table": "information_schema.a, information_schema.b" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "select a.*, b.* from information_schema.a a, information_schema.b b", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select a.*, b.* from information_schema.a as a, information_schema.b as b where 1 != 1", + "Query": "select a.*, b.* from information_schema.a as a, information_schema.b as b", + "Table": "information_schema.a, information_schema.b" + }, + "TablesUsed": [ + "information_schema.a", + "information_schema.b" + ] } }, { @@ -1022,14 +1334,19 @@ "Name": "main", "Sharded": false }, - "FieldQuery": "select a.table_name from (select * from information_schema.key_column_usage as a where 1 != 1) as a, (select * from information_schema.referential_constraints where 1 != 1) as b where 1 != 1", - "Query": "select a.table_name from (select * from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a, (select * from information_schema.referential_constraints where table_name = :table_name) as b", + "FieldQuery": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where 1 != 1) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where 1 != 1) as b where 1 != 1", + "Query": "select a.table_name from (select a.CONSTRAINT_CATALOG, a.CONSTRAINT_SCHEMA, a.CONSTRAINT_NAME, a.TABLE_CATALOG, a.TABLE_SCHEMA, a.TABLE_NAME, a.COLUMN_NAME, a.ORDINAL_POSITION, a.POSITION_IN_UNIQUE_CONSTRAINT, a.REFERENCED_TABLE_SCHEMA, a.REFERENCED_TABLE_NAME, a.REFERENCED_COLUMN_NAME from information_schema.key_column_usage as a where a.table_name = :a_table_name) as a, (select CONSTRAINT_CATALOG, CONSTRAINT_SCHEMA, CONSTRAINT_NAME, UNIQUE_CONSTRAINT_CATALOG, UNIQUE_CONSTRAINT_SCHEMA, UNIQUE_CONSTRAINT_NAME, MATCH_OPTION, UPDATE_RULE, DELETE_RULE, TABLE_NAME, REFERENCED_TABLE_NAME from information_schema.referential_constraints where table_name = :table_name) as b", "SysTableTableName": "[a_table_name:VARCHAR(\"users\"), table_name:VARCHAR(\"users\")]", "Table": "information_schema.key_column_usage, information_schema.referential_constraints" - } + }, + "TablesUsed": [ + "information_schema.key_column_usage", + "information_schema.referential_constraints" + ] } }, { + "comment": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = 'music' union all (select 1 as found from information_schema.views where table_schema = 'music' limit 1)) as t", "v3-plan": "unsupported: cross-shard query with aggregates", "gen4-plan": { @@ -1046,7 +1363,11 @@ "Query": "select sum(found) from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t", "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] } }, { @@ -1107,7 +1428,11 @@ "Query": "select found from (select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)) as t", "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"music\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] } }, { @@ -1160,7 +1485,11 @@ "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)", "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] } }, { @@ -1213,7 +1542,11 @@ "Query": "select 1 as found from information_schema.`tables` where table_schema = :__vtschemaname union all (select 1 as found from information_schema.views where table_schema = :__vtschemaname limit 1)", "SysTableTableSchema": "[VARCHAR(\"music\"), VARCHAR(\"Music\"), VARCHAR(\"music\"), VARCHAR(\"user\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] } }, { @@ -1288,7 +1621,11 @@ "Query": "select 1 as found from information_schema.`tables` where table_name = :table_name and table_name = :table_name1 and exists (select 1 as found from information_schema.`tables` where table_name = :table_name2 and table_name = :table_name3 union all (select 1 as found from information_schema.views where table_name = :table_name4 and table_name = :table_name5 limit 1))", "SysTableTableName": "[table_name1:VARCHAR(\"Music\"), table_name2:VARCHAR(\"music\"), table_name3:VARCHAR(\"Music\"), table_name4:VARCHAR(\"music\"), table_name5:VARCHAR(\"user\"), table_name:VARCHAR(\"music\")]", "Table": "information_schema.`tables`" - } + }, + "TablesUsed": [ + "information_schema.tables", + "information_schema.views" + ] } }, { @@ -1339,22 +1676,7 @@ ] } }, - "gen4-plan": { - "QueryType": "SELECT", - "Original": "select id from (select id from information_schema.table t where t.schema_name = 'a' union select id from information_schema.columns) dt", - "Instructions": { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select id from (select id from information_schema.`table` as t where 1 != 1 union select id from information_schema.`columns` where 1 != 1) as dt where 1 != 1", - "Query": "select id from (select id from information_schema.`table` as t where t.schema_name = :__vtschemaname union select id from information_schema.`columns`) as dt", - "SysTableTableSchema": "[VARCHAR(\"a\")]", - "Table": "information_schema.`table`" - } - } + "gen4-plan": "symbol id not found" }, { "comment": "merge even one side have schema name in subquery", @@ -1417,49 +1739,18 @@ ] } }, - "gen4-plan": { - "QueryType": "SELECT", - "Original": "select id from information_schema.random t where t.col in (select id from information_schema.table t where t.schema_name = 'a' union select id from information_schema.columns)", - "Instructions": { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select id from information_schema.random as t where 1 != 1", - "Query": "select id from information_schema.random as t where t.col in (select id from information_schema.`table` as t where t.schema_name = :__vtschemaname union select id from information_schema.`columns`)", - "SysTableTableSchema": "[VARCHAR(\"a\")]", - "Table": "information_schema.random" - } - } + "gen4-plan": "symbol id not found" }, { "comment": "systable union query in derived table with constraint on outside (star projection)", "query": "select * from (select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `constraint_name` = 'primary'", "v3-plan": "symbol constraint_name not found in table or subquery", - "gen4-plan": { - "QueryType": "SELECT", - "Original": "select * from (select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select * from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `constraint_name` = 'primary'", - "Instructions": { - "OperatorType": "Route", - "Variant": "DBA", - "Keyspace": { - "Name": "main", - "Sharded": false - }, - "FieldQuery": "select * from (select * from information_schema.key_column_usage as kcu where 1 != 1 union select * from information_schema.key_column_usage as kcu where 1 != 1) as kcu where 1 != 1", - "Query": "select * from (select * from information_schema.key_column_usage as kcu where kcu.table_schema = :__vtschemaname and kcu.table_name = :kcu_table_name and constraint_name = 'primary' union select * from information_schema.key_column_usage as kcu where kcu.table_schema = :__vtschemaname and kcu.table_name = :kcu_table_name1 and constraint_name = 'primary') as kcu", - "SysTableTableName": "[kcu_table_name1:VARCHAR(\"music\"), kcu_table_name:VARCHAR(\"user_extra\")]", - "SysTableTableSchema": "[VARCHAR(\"user\"), VARCHAR(\"user\")]", - "Table": "information_schema.key_column_usage" - } - } + "gen4-plan": "can't push predicates on concatenate" }, { "comment": "table_schema OR predicate\n# It is unsupported because we do not route queries to multiple keyspaces right now", "query": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", - "plan": { + "v3-plan": { "QueryType": "SELECT", "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", "Instructions": { @@ -1473,6 +1764,24 @@ "Query": "select * from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'", "Table": "INFORMATION_SCHEMA.`TABLES`" } + }, + "gen4-plan": { + "QueryType": "SELECT", + "Original": "SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'ks' OR TABLE_SCHEMA = 'main'", + "Instructions": { + "OperatorType": "Route", + "Variant": "DBA", + "Keyspace": { + "Name": "main", + "Sharded": false + }, + "FieldQuery": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where 1 != 1", + "Query": "select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE, `ENGINE`, VERSION, `ROW_FORMAT`, TABLE_ROWS, `AVG_ROW_LENGTH`, DATA_LENGTH, MAX_DATA_LENGTH, INDEX_LENGTH, DATA_FREE, `AUTO_INCREMENT`, CREATE_TIME, UPDATE_TIME, CHECK_TIME, TABLE_COLLATION, `CHECKSUM`, CREATE_OPTIONS, TABLE_COMMENT from INFORMATION_SCHEMA.`TABLES` where TABLE_SCHEMA = 'ks' or TABLE_SCHEMA = 'main'", + "Table": "INFORMATION_SCHEMA.`TABLES`" + }, + "TablesUsed": [ + "information_schema.TABLES" + ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/union_cases.json b/go/vt/vtgate/planbuilder/testdata/union_cases.json index e32d28c862..c527b69de7 100644 --- a/go/vt/vtgate/planbuilder/testdata/union_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/union_cases.json @@ -660,6 +660,7 @@ ] }, "TablesUsed": [ + "information_schema.a", "main.unsharded" ] } @@ -739,6 +740,7 @@ ] }, "TablesUsed": [ + "information_schema.a", "main.unsharded" ] } @@ -2286,6 +2288,7 @@ "plan": "can't do ORDER BY on top of UNION" }, { + "comment": "select 1 from (select id+42 as foo from user union select 1+id as foo from unsharded) as t", "query": "select 1 from (select id+42 as foo from user union select 1+id as foo from unsharded) as t", "v3-plan": "unsupported: expression on results of a cross-shard subquery", "gen4-plan": { @@ -2340,4 +2343,4 @@ ] } } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json index 7e908b958f..1c49a7368f 100644 --- a/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json +++ b/go/vt/vtgate/planbuilder/testdata/unsupported_cases.json @@ -273,26 +273,32 @@ "plan": "unsupported: REPLACE INTO with sharded schema" }, { + "comment": "select keyspace_id from user_index where id = 1 and id = 2", "query": "select keyspace_id from user_index where id = 1 and id = 2", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (multiple filters)" }, { + "comment": "select keyspace_id from user_index where func(id)", "query": "select keyspace_id from user_index where func(id)", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (not a comparison)" }, { + "comment": "select keyspace_id from user_index where id > 1", "query": "select keyspace_id from user_index where id > 1", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (not equality)" }, { + "comment": "select keyspace_id from user_index where 1 = id", "query": "select keyspace_id from user_index where 1 = id", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (lhs is not a column)" }, { + "comment": "select keyspace_id from user_index where keyspace_id = 1", "query": "select keyspace_id from user_index where keyspace_id = 1", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (lhs is not id)" }, { + "comment": "select keyspace_id from user_index where id = id+1", "query": "select keyspace_id from user_index where id = id+1", "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (rhs is not a value)" }, @@ -307,6 +313,7 @@ "plan": "unsupported: where clause for vindex function must be of the form id = or id in(,...) (where clause missing)" }, { + "comment": "select func(keyspace_id) from user_index where id = :id", "query": "select func(keyspace_id) from user_index where id = :id", "plan": "unsupported: expression on results of a vindex function" }, @@ -392,11 +399,6 @@ "query": "select distinct a, b as a from user", "plan": "generating order by clause: ambiguous symbol reference: a" }, - { - "comment": "subquery of information_schema with itself and star expression in outer select", - "query": "select a.*, u.id from information_schema.a a, user u where a.id in (select * from information_schema.b)", - "plan": "unsupported: '*' expression in cross-shard query" - }, { "comment": "outer and inner subquery route reference the same \"uu.id\" name\n# but they refer to different things. The first reference is to the outermost query,\n# and the second reference is to the innermost 'from' subquery.\n# This query will never work as the inner derived table is only selecting one of the column", "query": "select id2 from user uu where id in (select id from user where id = uu.id and user.col in (select col from (select id from user_extra where user_id = 5) uu where uu.user_id = uu.id))", @@ -449,7 +451,7 @@ "comment": "systable union query in derived table with constraint on outside (without star projection)", "query": "select id from (select id from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'user_extra' union select id from `information_schema`.`key_column_usage` `kcu` where `kcu`.`table_schema` = 'user' and `kcu`.`table_name` = 'music') `kcu` where `id` = 'primary'", "v3-plan": "unsupported: filtering on results of cross-shard subquery", - "gen4-plan": "can't push predicates on concatenate" + "gen4-plan": "symbol id not found" }, { "comment": "insert having subquery in row values", @@ -471,4 +473,4 @@ "query": "select get_lock('xyz', 10), 1 from dual", "plan": "unsupported: lock function and other expression in same select query" } -] \ No newline at end of file +] diff --git a/go/vt/vtgate/semantics/analyzer.go b/go/vt/vtgate/semantics/analyzer.go index ba30f0392c..a0e1ec2eba 100644 --- a/go/vt/vtgate/semantics/analyzer.go +++ b/go/vt/vtgate/semantics/analyzer.go @@ -63,7 +63,7 @@ func newAnalyzer(dbName string, si SchemaInformation) *analyzer { // Analyze analyzes the parsed query. func Analyze(statement sqlparser.Statement, currentDb string, si SchemaInformation) (*SemTable, error) { - analyzer := newAnalyzer(currentDb, si) + analyzer := newAnalyzer(currentDb, newSchemaInfo(si)) // Analysis for initial scope err := analyzer.analyze(statement) diff --git a/go/vt/vtgate/semantics/analyzer_test.go b/go/vt/vtgate/semantics/analyzer_test.go index f7bfe3b04f..d67a960fd9 100644 --- a/go/vt/vtgate/semantics/analyzer_test.go +++ b/go/vt/vtgate/semantics/analyzer_test.go @@ -75,6 +75,17 @@ func TestBindingSingleTablePositive(t *testing.T) { } } +func TestInformationSchemaColumnInfo(t *testing.T) { + stmt, semTable := parseAndAnalyze(t, "select table_comment, file_name from information_schema.`TABLES`, information_schema.`FILES`", "d") + + sel, _ := stmt.(*sqlparser.Select) + tables := SingleTableSet(0) + files := SingleTableSet(1) + + assert.Equal(t, tables, semTable.RecursiveDeps(extract(sel, 0))) + assert.Equal(t, files, semTable.DirectDeps(extract(sel, 1))) +} + func TestBindingSingleAliasedTablePositive(t *testing.T) { queries := []string{ "select col from tabl as X", diff --git a/go/vt/vtgate/semantics/derived_table.go b/go/vt/vtgate/semantics/derived_table.go index f6bf7da334..7379fa43f4 100644 --- a/go/vt/vtgate/semantics/derived_table.go +++ b/go/vt/vtgate/semantics/derived_table.go @@ -17,6 +17,8 @@ limitations under the License. package semantics import ( + "strings" + vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/sqlparser" "vitess.io/vitess/go/vt/vterrors" @@ -70,7 +72,7 @@ func createDerivedTableForExpressions(expressions sqlparser.SelectExprs, cols sq func (dt *DerivedTable) dependencies(colName string, org originable) (dependencies, error) { directDeps := org.tableSetFor(dt.ASTNode) for i, name := range dt.columnNames { - if name != colName { + if !strings.EqualFold(name, colName) { continue } _, recursiveDeps, qt := org.depsForExpr(dt.cols[i]) diff --git a/go/vt/vtgate/semantics/early_rewriter.go b/go/vt/vtgate/semantics/early_rewriter.go index 84b27cb8e6..32e67fd864 100644 --- a/go/vt/vtgate/semantics/early_rewriter.go +++ b/go/vt/vtgate/semantics/early_rewriter.go @@ -18,6 +18,7 @@ package semantics import ( "strconv" + "strings" vtrpcpb "vitess.io/vitess/go/vt/proto/vtrpc" "vitess.io/vitess/go/vt/sqlparser" @@ -238,7 +239,7 @@ func rewriteJoinUsing( usingCols = map[string]TableSet{} } for _, col := range tbl.getColumns() { - _, found := usingCols[col.Name] + _, found := usingCols[strings.ToLower(col.Name)] if found { tblName, err := tbl.Name() if err != nil { diff --git a/go/vt/vtgate/semantics/info_schema.go b/go/vt/vtgate/semantics/info_schema.go new file mode 100644 index 0000000000..f834bb52f3 --- /dev/null +++ b/go/vt/vtgate/semantics/info_schema.go @@ -0,0 +1,1710 @@ +/* +Copyright 2022 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package semantics + +import ( + "strings" + + "vitess.io/vitess/go/mysql/collations" + "vitess.io/vitess/go/vt/key" + "vitess.io/vitess/go/vt/proto/query" + topodatapb "vitess.io/vitess/go/vt/proto/topodata" + "vitess.io/vitess/go/vt/servenv" + "vitess.io/vitess/go/vt/sqlparser" + "vitess.io/vitess/go/vt/vtgate/vindexes" +) + +func createCol(name string, typ int) vindexes.Column { + return vindexes.Column{Name: sqlparser.NewIdentifierCI(name), Type: query.Type(typ)} +} + +// getInfoSchema57 returns a map of all information_schema tables and their columns with types +// To recreate this information from MySQL, you can run the test in info_schema_gen_test.go +func getInfoSchema57() map[string][]vindexes.Column { + infSchema := map[string][]vindexes.Column{} + var cols []vindexes.Column + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_COLLATE_NAME", 6165)) + cols = append(cols, createCol("DESCRIPTION", 6165)) + cols = append(cols, createCol("MAXLEN", 265)) + infSchema["CHARACTER_SETS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + infSchema["COLLATION_CHARACTER_SET_APPLICABILITY"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("ID", 265)) + cols = append(cols, createCol("IS_DEFAULT", 6165)) + cols = append(cols, createCol("IS_COMPILED", 6165)) + cols = append(cols, createCol("SORTLEN", 265)) + infSchema["COLLATIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["COLUMN_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 265)) + cols = append(cols, createCol("COLUMN_DEFAULT", 6163)) + cols = append(cols, createCol("IS_NULLABLE", 6165)) + cols = append(cols, createCol("DATA_TYPE", 6165)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 265)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 265)) + cols = append(cols, createCol("NUMERIC_PRECISION", 265)) + cols = append(cols, createCol("NUMERIC_SCALE", 265)) + cols = append(cols, createCol("DATETIME_PRECISION", 265)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("COLUMN_TYPE", 6163)) + cols = append(cols, createCol("COLUMN_KEY", 6165)) + cols = append(cols, createCol("EXTRA", 6165)) + cols = append(cols, createCol("PRIVILEGES", 6165)) + cols = append(cols, createCol("COLUMN_COMMENT", 6165)) + cols = append(cols, createCol("GENERATION_EXPRESSION", 6163)) + infSchema["COLUMNS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("SUPPORT", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + cols = append(cols, createCol("TRANSACTIONS", 6165)) + cols = append(cols, createCol("XA", 6165)) + cols = append(cols, createCol("SAVEPOINTS", 6165)) + infSchema["ENGINES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("EVENT_CATALOG", 6165)) + cols = append(cols, createCol("EVENT_SCHEMA", 6165)) + cols = append(cols, createCol("EVENT_NAME", 6165)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("TIME_ZONE", 6165)) + cols = append(cols, createCol("EVENT_BODY", 6165)) + cols = append(cols, createCol("EVENT_DEFINITION", 6163)) + cols = append(cols, createCol("EVENT_TYPE", 6165)) + cols = append(cols, createCol("EXECUTE_AT", 2064)) + cols = append(cols, createCol("INTERVAL_VALUE", 6165)) + cols = append(cols, createCol("INTERVAL_FIELD", 6165)) + cols = append(cols, createCol("SQL_MODE", 6165)) + cols = append(cols, createCol("STARTS", 2064)) + cols = append(cols, createCol("ENDS", 2064)) + cols = append(cols, createCol("STATUS", 6165)) + cols = append(cols, createCol("ON_COMPLETION", 6165)) + cols = append(cols, createCol("CREATED", 2064)) + cols = append(cols, createCol("LAST_ALTERED", 2064)) + cols = append(cols, createCol("LAST_EXECUTED", 2064)) + cols = append(cols, createCol("EVENT_COMMENT", 6165)) + cols = append(cols, createCol("ORIGINATOR", 265)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["EVENTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("FILE_ID", 265)) + cols = append(cols, createCol("FILE_NAME", 6165)) + cols = append(cols, createCol("FILE_TYPE", 6165)) + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("LOGFILE_GROUP_NAME", 6165)) + cols = append(cols, createCol("LOGFILE_GROUP_NUMBER", 265)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("FULLTEXT_KEYS", 6165)) + cols = append(cols, createCol("DELETED_ROWS", 265)) + cols = append(cols, createCol("UPDATE_COUNT", 265)) + cols = append(cols, createCol("FREE_EXTENTS", 265)) + cols = append(cols, createCol("TOTAL_EXTENTS", 265)) + cols = append(cols, createCol("EXTENT_SIZE", 265)) + cols = append(cols, createCol("INITIAL_SIZE", 265)) + cols = append(cols, createCol("MAXIMUM_SIZE", 265)) + cols = append(cols, createCol("AUTOEXTEND_SIZE", 265)) + cols = append(cols, createCol("CREATION_TIME", 2064)) + cols = append(cols, createCol("LAST_UPDATE_TIME", 2064)) + cols = append(cols, createCol("LAST_ACCESS_TIME", 2064)) + cols = append(cols, createCol("RECOVER_TIME", 265)) + cols = append(cols, createCol("TRANSACTION_COUNTER", 265)) + cols = append(cols, createCol("VERSION", 265)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("TABLE_ROWS", 265)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 265)) + cols = append(cols, createCol("DATA_LENGTH", 265)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 265)) + cols = append(cols, createCol("INDEX_LENGTH", 265)) + cols = append(cols, createCol("DATA_FREE", 265)) + cols = append(cols, createCol("CREATE_TIME", 2064)) + cols = append(cols, createCol("UPDATE_TIME", 2064)) + cols = append(cols, createCol("CHECK_TIME", 2064)) + cols = append(cols, createCol("CHECKSUM", 265)) + cols = append(cols, createCol("STATUS", 6165)) + cols = append(cols, createCol("EXTRA", 6165)) + infSchema["FILES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("VARIABLE_NAME", 6165)) + cols = append(cols, createCol("VARIABLE_VALUE", 6165)) + infSchema["GLOBAL_STATUS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("VARIABLE_NAME", 6165)) + cols = append(cols, createCol("VARIABLE_VALUE", 6165)) + infSchema["GLOBAL_VARIABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 265)) + cols = append(cols, createCol("BLOCK_ID", 265)) + cols = append(cols, createCol("SPACE", 265)) + cols = append(cols, createCol("PAGE_NUMBER", 265)) + cols = append(cols, createCol("PAGE_TYPE", 6165)) + cols = append(cols, createCol("FLUSH_TYPE", 265)) + cols = append(cols, createCol("FIX_COUNT", 265)) + cols = append(cols, createCol("IS_HASHED", 6165)) + cols = append(cols, createCol("NEWEST_MODIFICATION", 265)) + cols = append(cols, createCol("OLDEST_MODIFICATION", 265)) + cols = append(cols, createCol("ACCESS_TIME", 265)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("NUMBER_RECORDS", 265)) + cols = append(cols, createCol("DATA_SIZE", 265)) + cols = append(cols, createCol("COMPRESSED_SIZE", 265)) + cols = append(cols, createCol("PAGE_STATE", 6165)) + cols = append(cols, createCol("IO_FIX", 6165)) + cols = append(cols, createCol("IS_OLD", 6165)) + cols = append(cols, createCol("FREE_PAGE_CLOCK", 265)) + infSchema["INNODB_BUFFER_PAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 265)) + cols = append(cols, createCol("LRU_POSITION", 265)) + cols = append(cols, createCol("SPACE", 265)) + cols = append(cols, createCol("PAGE_NUMBER", 265)) + cols = append(cols, createCol("PAGE_TYPE", 6165)) + cols = append(cols, createCol("FLUSH_TYPE", 265)) + cols = append(cols, createCol("FIX_COUNT", 265)) + cols = append(cols, createCol("IS_HASHED", 6165)) + cols = append(cols, createCol("NEWEST_MODIFICATION", 265)) + cols = append(cols, createCol("OLDEST_MODIFICATION", 265)) + cols = append(cols, createCol("ACCESS_TIME", 265)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("NUMBER_RECORDS", 265)) + cols = append(cols, createCol("DATA_SIZE", 265)) + cols = append(cols, createCol("COMPRESSED_SIZE", 265)) + cols = append(cols, createCol("COMPRESSED", 6165)) + cols = append(cols, createCol("IO_FIX", 6165)) + cols = append(cols, createCol("IS_OLD", 6165)) + cols = append(cols, createCol("FREE_PAGE_CLOCK", 265)) + infSchema["INNODB_BUFFER_PAGE_LRU"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 265)) + cols = append(cols, createCol("POOL_SIZE", 265)) + cols = append(cols, createCol("FREE_BUFFERS", 265)) + cols = append(cols, createCol("DATABASE_PAGES", 265)) + cols = append(cols, createCol("OLD_DATABASE_PAGES", 265)) + cols = append(cols, createCol("MODIFIED_DATABASE_PAGES", 265)) + cols = append(cols, createCol("PENDING_DECOMPRESS", 265)) + cols = append(cols, createCol("PENDING_READS", 265)) + cols = append(cols, createCol("PENDING_FLUSH_LRU", 265)) + cols = append(cols, createCol("PENDING_FLUSH_LIST", 265)) + cols = append(cols, createCol("PAGES_MADE_YOUNG", 265)) + cols = append(cols, createCol("PAGES_NOT_MADE_YOUNG", 265)) + cols = append(cols, createCol("PAGES_MADE_YOUNG_RATE", 1036)) + cols = append(cols, createCol("PAGES_MADE_NOT_YOUNG_RATE", 1036)) + cols = append(cols, createCol("NUMBER_PAGES_READ", 265)) + cols = append(cols, createCol("NUMBER_PAGES_CREATED", 265)) + cols = append(cols, createCol("NUMBER_PAGES_WRITTEN", 265)) + cols = append(cols, createCol("PAGES_READ_RATE", 1036)) + cols = append(cols, createCol("PAGES_CREATE_RATE", 1036)) + cols = append(cols, createCol("PAGES_WRITTEN_RATE", 1036)) + cols = append(cols, createCol("NUMBER_PAGES_GET", 265)) + cols = append(cols, createCol("HIT_RATE", 265)) + cols = append(cols, createCol("YOUNG_MAKE_PER_THOUSAND_GETS", 265)) + cols = append(cols, createCol("NOT_YOUNG_MAKE_PER_THOUSAND_GETS", 265)) + cols = append(cols, createCol("NUMBER_PAGES_READ_AHEAD", 265)) + cols = append(cols, createCol("NUMBER_READ_AHEAD_EVICTED", 265)) + cols = append(cols, createCol("READ_AHEAD_RATE", 1036)) + cols = append(cols, createCol("READ_AHEAD_EVICTED_RATE", 1036)) + cols = append(cols, createCol("LRU_IO_TOTAL", 265)) + cols = append(cols, createCol("LRU_IO_CURRENT", 265)) + cols = append(cols, createCol("UNCOMPRESS_TOTAL", 265)) + cols = append(cols, createCol("UNCOMPRESS_CURRENT", 265)) + infSchema["INNODB_BUFFER_POOL_STATS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("database_name", 6165)) + cols = append(cols, createCol("table_name", 6165)) + cols = append(cols, createCol("index_name", 6165)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_PER_INDEX"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("database_name", 6165)) + cols = append(cols, createCol("table_name", 6165)) + cols = append(cols, createCol("index_name", 6165)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_PER_INDEX_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("buffer_pool_instance", 263)) + cols = append(cols, createCol("pages_used", 263)) + cols = append(cols, createCol("pages_free", 263)) + cols = append(cols, createCol("relocation_ops", 265)) + cols = append(cols, createCol("relocation_time", 263)) + infSchema["INNODB_CMPMEM"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("buffer_pool_instance", 263)) + cols = append(cols, createCol("pages_used", 263)) + cols = append(cols, createCol("pages_free", 263)) + cols = append(cols, createCol("relocation_ops", 265)) + cols = append(cols, createCol("relocation_time", 263)) + infSchema["INNODB_CMPMEM_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("DOC_ID", 265)) + infSchema["INNODB_FT_BEING_DELETED"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("KEY", 6165)) + cols = append(cols, createCol("VALUE", 6165)) + infSchema["INNODB_FT_CONFIG"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("value", 6165)) + infSchema["INNODB_FT_DEFAULT_STOPWORD"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("DOC_ID", 265)) + infSchema["INNODB_FT_DELETED"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("WORD", 6165)) + cols = append(cols, createCol("FIRST_DOC_ID", 265)) + cols = append(cols, createCol("LAST_DOC_ID", 265)) + cols = append(cols, createCol("DOC_COUNT", 265)) + cols = append(cols, createCol("DOC_ID", 265)) + cols = append(cols, createCol("POSITION", 265)) + infSchema["INNODB_FT_INDEX_CACHE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("WORD", 6165)) + cols = append(cols, createCol("FIRST_DOC_ID", 265)) + cols = append(cols, createCol("LAST_DOC_ID", 265)) + cols = append(cols, createCol("DOC_COUNT", 265)) + cols = append(cols, createCol("DOC_ID", 265)) + cols = append(cols, createCol("POSITION", 265)) + infSchema["INNODB_FT_INDEX_TABLE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("requesting_trx_id", 6165)) + cols = append(cols, createCol("requested_lock_id", 6165)) + cols = append(cols, createCol("blocking_trx_id", 6165)) + cols = append(cols, createCol("blocking_lock_id", 6165)) + infSchema["INNODB_LOCK_WAITS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("lock_id", 6165)) + cols = append(cols, createCol("lock_trx_id", 6165)) + cols = append(cols, createCol("lock_mode", 6165)) + cols = append(cols, createCol("lock_type", 6165)) + cols = append(cols, createCol("lock_table", 6165)) + cols = append(cols, createCol("lock_index", 6165)) + cols = append(cols, createCol("lock_space", 265)) + cols = append(cols, createCol("lock_page", 265)) + cols = append(cols, createCol("lock_rec", 265)) + cols = append(cols, createCol("lock_data", 6165)) + infSchema["INNODB_LOCKS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("SUBSYSTEM", 6165)) + cols = append(cols, createCol("COUNT", 265)) + cols = append(cols, createCol("MAX_COUNT", 265)) + cols = append(cols, createCol("MIN_COUNT", 265)) + cols = append(cols, createCol("AVG_COUNT", 1036)) + cols = append(cols, createCol("COUNT_RESET", 265)) + cols = append(cols, createCol("MAX_COUNT_RESET", 265)) + cols = append(cols, createCol("MIN_COUNT_RESET", 265)) + cols = append(cols, createCol("AVG_COUNT_RESET", 1036)) + cols = append(cols, createCol("TIME_ENABLED", 2064)) + cols = append(cols, createCol("TIME_DISABLED", 2064)) + cols = append(cols, createCol("TIME_ELAPSED", 265)) + cols = append(cols, createCol("TIME_RESET", 2064)) + cols = append(cols, createCol("STATUS", 6165)) + cols = append(cols, createCol("TYPE", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + infSchema["INNODB_METRICS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("POS", 265)) + cols = append(cols, createCol("MTYPE", 263)) + cols = append(cols, createCol("PRTYPE", 263)) + cols = append(cols, createCol("LEN", 263)) + infSchema["INNODB_SYS_COLUMNS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("PATH", 6165)) + infSchema["INNODB_SYS_DATAFILES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("INDEX_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("POS", 263)) + infSchema["INNODB_SYS_FIELDS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 6165)) + cols = append(cols, createCol("FOR_NAME", 6165)) + cols = append(cols, createCol("REF_NAME", 6165)) + cols = append(cols, createCol("N_COLS", 263)) + cols = append(cols, createCol("TYPE", 263)) + infSchema["INNODB_SYS_FOREIGN"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 6165)) + cols = append(cols, createCol("FOR_COL_NAME", 6165)) + cols = append(cols, createCol("REF_COL_NAME", 6165)) + cols = append(cols, createCol("POS", 263)) + infSchema["INNODB_SYS_FOREIGN_COLS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("INDEX_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("TYPE", 263)) + cols = append(cols, createCol("N_FIELDS", 263)) + cols = append(cols, createCol("PAGE_NO", 263)) + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("MERGE_THRESHOLD", 263)) + infSchema["INNODB_SYS_INDEXES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("FLAG", 263)) + cols = append(cols, createCol("N_COLS", 263)) + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("FILE_FORMAT", 6165)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("ZIP_PAGE_SIZE", 263)) + cols = append(cols, createCol("SPACE_TYPE", 6165)) + infSchema["INNODB_SYS_TABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("FLAG", 263)) + cols = append(cols, createCol("FILE_FORMAT", 6165)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("PAGE_SIZE", 263)) + cols = append(cols, createCol("ZIP_PAGE_SIZE", 263)) + cols = append(cols, createCol("SPACE_TYPE", 6165)) + cols = append(cols, createCol("FS_BLOCK_SIZE", 263)) + cols = append(cols, createCol("FILE_SIZE", 265)) + cols = append(cols, createCol("ALLOCATED_SIZE", 265)) + infSchema["INNODB_SYS_TABLESPACES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("STATS_INITIALIZED", 6165)) + cols = append(cols, createCol("NUM_ROWS", 265)) + cols = append(cols, createCol("CLUST_INDEX_SIZE", 265)) + cols = append(cols, createCol("OTHER_INDEX_SIZE", 265)) + cols = append(cols, createCol("MODIFIED_COUNTER", 265)) + cols = append(cols, createCol("AUTOINC", 265)) + cols = append(cols, createCol("REF_COUNT", 263)) + infSchema["INNODB_SYS_TABLESTATS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("POS", 263)) + cols = append(cols, createCol("BASE_POS", 263)) + infSchema["INNODB_SYS_VIRTUAL"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 265)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("N_COLS", 263)) + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("PER_TABLE_TABLESPACE", 6165)) + cols = append(cols, createCol("IS_COMPRESSED", 6165)) + infSchema["INNODB_TEMP_TABLE_INFO"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("trx_id", 6165)) + cols = append(cols, createCol("trx_state", 6165)) + cols = append(cols, createCol("trx_started", 2064)) + cols = append(cols, createCol("trx_requested_lock_id", 6165)) + cols = append(cols, createCol("trx_wait_started", 2064)) + cols = append(cols, createCol("trx_weight", 265)) + cols = append(cols, createCol("trx_mysql_thread_id", 265)) + cols = append(cols, createCol("trx_query", 6165)) + cols = append(cols, createCol("trx_operation_state", 6165)) + cols = append(cols, createCol("trx_tables_in_use", 265)) + cols = append(cols, createCol("trx_tables_locked", 265)) + cols = append(cols, createCol("trx_lock_structs", 265)) + cols = append(cols, createCol("trx_lock_memory_bytes", 265)) + cols = append(cols, createCol("trx_rows_locked", 265)) + cols = append(cols, createCol("trx_rows_modified", 265)) + cols = append(cols, createCol("trx_concurrency_tickets", 265)) + cols = append(cols, createCol("trx_isolation_level", 6165)) + cols = append(cols, createCol("trx_unique_checks", 263)) + cols = append(cols, createCol("trx_foreign_key_checks", 263)) + cols = append(cols, createCol("trx_last_foreign_key_error", 6165)) + cols = append(cols, createCol("trx_adaptive_hash_latched", 263)) + cols = append(cols, createCol("trx_adaptive_hash_timeout", 265)) + cols = append(cols, createCol("trx_is_read_only", 263)) + cols = append(cols, createCol("trx_autocommit_non_locking", 263)) + infSchema["INNODB_TRX"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 265)) + cols = append(cols, createCol("POSITION_IN_UNIQUE_CONSTRAINT", 265)) + cols = append(cols, createCol("REFERENCED_TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("REFERENCED_TABLE_NAME", 6165)) + cols = append(cols, createCol("REFERENCED_COLUMN_NAME", 6165)) + infSchema["KEY_COLUMN_USAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("QUERY", 6163)) + cols = append(cols, createCol("TRACE", 6163)) + cols = append(cols, createCol("MISSING_BYTES_BEYOND_MAX_MEM_SIZE", 263)) + cols = append(cols, createCol("INSUFFICIENT_PRIVILEGES", 257)) + infSchema["OPTIMIZER_TRACE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPECIFIC_CATALOG", 6165)) + cols = append(cols, createCol("SPECIFIC_SCHEMA", 6165)) + cols = append(cols, createCol("SPECIFIC_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 263)) + cols = append(cols, createCol("PARAMETER_MODE", 6165)) + cols = append(cols, createCol("PARAMETER_NAME", 6165)) + cols = append(cols, createCol("DATA_TYPE", 6165)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 263)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 263)) + cols = append(cols, createCol("NUMERIC_PRECISION", 265)) + cols = append(cols, createCol("NUMERIC_SCALE", 263)) + cols = append(cols, createCol("DATETIME_PRECISION", 265)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("DTD_IDENTIFIER", 6163)) + cols = append(cols, createCol("ROUTINE_TYPE", 6165)) + infSchema["PARAMETERS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("PARTITION_NAME", 6165)) + cols = append(cols, createCol("SUBPARTITION_NAME", 6165)) + cols = append(cols, createCol("PARTITION_ORDINAL_POSITION", 265)) + cols = append(cols, createCol("SUBPARTITION_ORDINAL_POSITION", 265)) + cols = append(cols, createCol("PARTITION_METHOD", 6165)) + cols = append(cols, createCol("SUBPARTITION_METHOD", 6165)) + cols = append(cols, createCol("PARTITION_EXPRESSION", 6163)) + cols = append(cols, createCol("SUBPARTITION_EXPRESSION", 6163)) + cols = append(cols, createCol("PARTITION_DESCRIPTION", 6163)) + cols = append(cols, createCol("TABLE_ROWS", 265)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 265)) + cols = append(cols, createCol("DATA_LENGTH", 265)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 265)) + cols = append(cols, createCol("INDEX_LENGTH", 265)) + cols = append(cols, createCol("DATA_FREE", 265)) + cols = append(cols, createCol("CREATE_TIME", 2064)) + cols = append(cols, createCol("UPDATE_TIME", 2064)) + cols = append(cols, createCol("CHECK_TIME", 2064)) + cols = append(cols, createCol("CHECKSUM", 265)) + cols = append(cols, createCol("PARTITION_COMMENT", 6165)) + cols = append(cols, createCol("NODEGROUP", 6165)) + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + infSchema["PARTITIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("PLUGIN_NAME", 6165)) + cols = append(cols, createCol("PLUGIN_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_STATUS", 6165)) + cols = append(cols, createCol("PLUGIN_TYPE", 6165)) + cols = append(cols, createCol("PLUGIN_TYPE_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_LIBRARY", 6165)) + cols = append(cols, createCol("PLUGIN_LIBRARY_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_AUTHOR", 6165)) + cols = append(cols, createCol("PLUGIN_DESCRIPTION", 6163)) + cols = append(cols, createCol("PLUGIN_LICENSE", 6165)) + cols = append(cols, createCol("LOAD_OPTION", 6165)) + infSchema["PLUGINS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 265)) + cols = append(cols, createCol("USER", 6165)) + cols = append(cols, createCol("HOST", 6165)) + cols = append(cols, createCol("DB", 6165)) + cols = append(cols, createCol("COMMAND", 6165)) + cols = append(cols, createCol("TIME", 263)) + cols = append(cols, createCol("STATE", 6165)) + cols = append(cols, createCol("INFO", 6163)) + infSchema["PROCESSLIST"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("QUERY_ID", 263)) + cols = append(cols, createCol("SEQ", 263)) + cols = append(cols, createCol("STATE", 6165)) + cols = append(cols, createCol("DURATION", 18)) + cols = append(cols, createCol("CPU_USER", 18)) + cols = append(cols, createCol("CPU_SYSTEM", 18)) + cols = append(cols, createCol("CONTEXT_VOLUNTARY", 263)) + cols = append(cols, createCol("CONTEXT_INVOLUNTARY", 263)) + cols = append(cols, createCol("BLOCK_OPS_IN", 263)) + cols = append(cols, createCol("BLOCK_OPS_OUT", 263)) + cols = append(cols, createCol("MESSAGES_SENT", 263)) + cols = append(cols, createCol("MESSAGES_RECEIVED", 263)) + cols = append(cols, createCol("PAGE_FAULTS_MAJOR", 263)) + cols = append(cols, createCol("PAGE_FAULTS_MINOR", 263)) + cols = append(cols, createCol("SWAPS", 263)) + cols = append(cols, createCol("SOURCE_FUNCTION", 6165)) + cols = append(cols, createCol("SOURCE_FILE", 6165)) + cols = append(cols, createCol("SOURCE_LINE", 263)) + infSchema["PROFILING"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("MATCH_OPTION", 6165)) + cols = append(cols, createCol("UPDATE_RULE", 6165)) + cols = append(cols, createCol("DELETE_RULE", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("REFERENCED_TABLE_NAME", 6165)) + infSchema["REFERENTIAL_CONSTRAINTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPECIFIC_NAME", 6165)) + cols = append(cols, createCol("ROUTINE_CATALOG", 6165)) + cols = append(cols, createCol("ROUTINE_SCHEMA", 6165)) + cols = append(cols, createCol("ROUTINE_NAME", 6165)) + cols = append(cols, createCol("ROUTINE_TYPE", 6165)) + cols = append(cols, createCol("DATA_TYPE", 6165)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 263)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 263)) + cols = append(cols, createCol("NUMERIC_PRECISION", 265)) + cols = append(cols, createCol("NUMERIC_SCALE", 263)) + cols = append(cols, createCol("DATETIME_PRECISION", 265)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("DTD_IDENTIFIER", 6163)) + cols = append(cols, createCol("ROUTINE_BODY", 6165)) + cols = append(cols, createCol("ROUTINE_DEFINITION", 6163)) + cols = append(cols, createCol("EXTERNAL_NAME", 6165)) + cols = append(cols, createCol("EXTERNAL_LANGUAGE", 6165)) + cols = append(cols, createCol("PARAMETER_STYLE", 6165)) + cols = append(cols, createCol("IS_DETERMINISTIC", 6165)) + cols = append(cols, createCol("SQL_DATA_ACCESS", 6165)) + cols = append(cols, createCol("SQL_PATH", 6165)) + cols = append(cols, createCol("SECURITY_TYPE", 6165)) + cols = append(cols, createCol("CREATED", 2064)) + cols = append(cols, createCol("LAST_ALTERED", 2064)) + cols = append(cols, createCol("SQL_MODE", 6165)) + cols = append(cols, createCol("ROUTINE_COMMENT", 6163)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["ROUTINES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["SCHEMA_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CATALOG_NAME", 6165)) + cols = append(cols, createCol("SCHEMA_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_COLLATION_NAME", 6165)) + cols = append(cols, createCol("SQL_PATH", 6165)) + infSchema["SCHEMATA"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("VARIABLE_NAME", 6165)) + cols = append(cols, createCol("VARIABLE_VALUE", 6165)) + infSchema["SESSION_STATUS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("VARIABLE_NAME", 6165)) + cols = append(cols, createCol("VARIABLE_VALUE", 6165)) + infSchema["SESSION_VARIABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("NON_UNIQUE", 265)) + cols = append(cols, createCol("INDEX_SCHEMA", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("SEQ_IN_INDEX", 265)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("COLLATION", 6165)) + cols = append(cols, createCol("CARDINALITY", 265)) + cols = append(cols, createCol("SUB_PART", 265)) + cols = append(cols, createCol("PACKED", 6165)) + cols = append(cols, createCol("NULLABLE", 6165)) + cols = append(cols, createCol("INDEX_TYPE", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + cols = append(cols, createCol("INDEX_COMMENT", 6165)) + infSchema["STATISTICS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("CONSTRAINT_TYPE", 6165)) + infSchema["TABLE_CONSTRAINTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["TABLE_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("TABLE_TYPE", 6165)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("VERSION", 265)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("TABLE_ROWS", 265)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 265)) + cols = append(cols, createCol("DATA_LENGTH", 265)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 265)) + cols = append(cols, createCol("INDEX_LENGTH", 265)) + cols = append(cols, createCol("DATA_FREE", 265)) + cols = append(cols, createCol("AUTO_INCREMENT", 265)) + cols = append(cols, createCol("CREATE_TIME", 2064)) + cols = append(cols, createCol("UPDATE_TIME", 2064)) + cols = append(cols, createCol("CHECK_TIME", 2064)) + cols = append(cols, createCol("TABLE_COLLATION", 6165)) + cols = append(cols, createCol("CHECKSUM", 265)) + cols = append(cols, createCol("CREATE_OPTIONS", 6165)) + cols = append(cols, createCol("TABLE_COMMENT", 6165)) + infSchema["TABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("TABLESPACE_TYPE", 6165)) + cols = append(cols, createCol("LOGFILE_GROUP_NAME", 6165)) + cols = append(cols, createCol("EXTENT_SIZE", 265)) + cols = append(cols, createCol("AUTOEXTEND_SIZE", 265)) + cols = append(cols, createCol("MAXIMUM_SIZE", 265)) + cols = append(cols, createCol("NODEGROUP_ID", 265)) + cols = append(cols, createCol("TABLESPACE_COMMENT", 6165)) + infSchema["TABLESPACES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TRIGGER_CATALOG", 6165)) + cols = append(cols, createCol("TRIGGER_SCHEMA", 6165)) + cols = append(cols, createCol("TRIGGER_NAME", 6165)) + cols = append(cols, createCol("EVENT_MANIPULATION", 6165)) + cols = append(cols, createCol("EVENT_OBJECT_CATALOG", 6165)) + cols = append(cols, createCol("EVENT_OBJECT_SCHEMA", 6165)) + cols = append(cols, createCol("EVENT_OBJECT_TABLE", 6165)) + cols = append(cols, createCol("ACTION_ORDER", 265)) + cols = append(cols, createCol("ACTION_CONDITION", 6163)) + cols = append(cols, createCol("ACTION_STATEMENT", 6163)) + cols = append(cols, createCol("ACTION_ORIENTATION", 6165)) + cols = append(cols, createCol("ACTION_TIMING", 6165)) + cols = append(cols, createCol("ACTION_REFERENCE_OLD_TABLE", 6165)) + cols = append(cols, createCol("ACTION_REFERENCE_NEW_TABLE", 6165)) + cols = append(cols, createCol("ACTION_REFERENCE_OLD_ROW", 6165)) + cols = append(cols, createCol("ACTION_REFERENCE_NEW_ROW", 6165)) + cols = append(cols, createCol("CREATED", 2064)) + cols = append(cols, createCol("SQL_MODE", 6165)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["TRIGGERS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["USER_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("VIEW_DEFINITION", 6163)) + cols = append(cols, createCol("CHECK_OPTION", 6165)) + cols = append(cols, createCol("IS_UPDATABLE", 6165)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("SECURITY_TYPE", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + infSchema["VIEWS"] = cols + + return infSchema +} + +// getInfoSchema80 returns a map of all information_schema tables and their columns with types +// To recreate this information from MySQL, you can run the test in info_schema_gen_test.go +func getInfoSchema80() map[string][]vindexes.Column { + infSchema := map[string][]vindexes.Column{} + var cols []vindexes.Column + cols = append(cols, createCol("USER", 6165)) + cols = append(cols, createCol("HOST", 6165)) + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("GRANTEE_HOST", 6165)) + cols = append(cols, createCol("ROLE_NAME", 6165)) + cols = append(cols, createCol("ROLE_HOST", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + cols = append(cols, createCol("IS_DEFAULT", 6165)) + cols = append(cols, createCol("IS_MANDATORY", 6165)) + infSchema["ADMINISTRABLE_ROLE_AUTHORIZATIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("USER", 6165)) + cols = append(cols, createCol("HOST", 6165)) + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("GRANTEE_HOST", 6165)) + cols = append(cols, createCol("ROLE_NAME", 6165)) + cols = append(cols, createCol("ROLE_HOST", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + cols = append(cols, createCol("IS_DEFAULT", 6165)) + cols = append(cols, createCol("IS_MANDATORY", 6165)) + infSchema["APPLICABLE_ROLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_COLLATE_NAME", 6165)) + cols = append(cols, createCol("DESCRIPTION", 6165)) + cols = append(cols, createCol("MAXLEN", 776)) + infSchema["CHARACTER_SETS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("CHECK_CLAUSE", 6163)) + infSchema["CHECK_CONSTRAINTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + infSchema["COLLATION_CHARACTER_SET_APPLICABILITY"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("ID", 778)) + cols = append(cols, createCol("IS_DEFAULT", 6165)) + cols = append(cols, createCol("IS_COMPILED", 6165)) + cols = append(cols, createCol("SORTLEN", 776)) + cols = append(cols, createCol("PAD_ATTRIBUTE", 2074)) + infSchema["COLLATIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["COLUMN_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SCHEMA_NAME", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("HISTOGRAM", 2078)) + infSchema["COLUMN_STATISTICS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 776)) + cols = append(cols, createCol("COLUMN_DEFAULT", 6163)) + cols = append(cols, createCol("IS_NULLABLE", 6165)) + cols = append(cols, createCol("DATA_TYPE", 6163)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 265)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 265)) + cols = append(cols, createCol("NUMERIC_PRECISION", 778)) + cols = append(cols, createCol("NUMERIC_SCALE", 778)) + cols = append(cols, createCol("DATETIME_PRECISION", 776)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("COLUMN_TYPE", 6163)) + cols = append(cols, createCol("COLUMN_KEY", 2074)) + cols = append(cols, createCol("EXTRA", 6165)) + cols = append(cols, createCol("PRIVILEGES", 6165)) + cols = append(cols, createCol("COLUMN_COMMENT", 6163)) + cols = append(cols, createCol("GENERATION_EXPRESSION", 6163)) + cols = append(cols, createCol("SRS_ID", 776)) + infSchema["COLUMNS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("ENGINE_ATTRIBUTE", 2078)) + cols = append(cols, createCol("SECONDARY_ENGINE_ATTRIBUTE", 2078)) + infSchema["COLUMNS_EXTENSIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ROLE_NAME", 6165)) + cols = append(cols, createCol("ROLE_HOST", 6165)) + cols = append(cols, createCol("IS_DEFAULT", 6165)) + cols = append(cols, createCol("IS_MANDATORY", 6165)) + infSchema["ENABLED_ROLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("SUPPORT", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + cols = append(cols, createCol("TRANSACTIONS", 6165)) + cols = append(cols, createCol("XA", 6165)) + cols = append(cols, createCol("SAVEPOINTS", 6165)) + infSchema["ENGINES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("EVENT_CATALOG", 6165)) + cols = append(cols, createCol("EVENT_SCHEMA", 6165)) + cols = append(cols, createCol("EVENT_NAME", 6165)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("TIME_ZONE", 6165)) + cols = append(cols, createCol("EVENT_BODY", 6165)) + cols = append(cols, createCol("EVENT_DEFINITION", 6163)) + cols = append(cols, createCol("EVENT_TYPE", 6165)) + cols = append(cols, createCol("EXECUTE_AT", 2064)) + cols = append(cols, createCol("INTERVAL_VALUE", 6165)) + cols = append(cols, createCol("INTERVAL_FIELD", 2074)) + cols = append(cols, createCol("SQL_MODE", 2075)) + cols = append(cols, createCol("STARTS", 2064)) + cols = append(cols, createCol("ENDS", 2064)) + cols = append(cols, createCol("STATUS", 2074)) + cols = append(cols, createCol("ON_COMPLETION", 6165)) + cols = append(cols, createCol("CREATED", 2061)) + cols = append(cols, createCol("LAST_ALTERED", 2061)) + cols = append(cols, createCol("LAST_EXECUTED", 2064)) + cols = append(cols, createCol("EVENT_COMMENT", 6165)) + cols = append(cols, createCol("ORIGINATOR", 776)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["EVENTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("FILE_ID", 265)) + cols = append(cols, createCol("FILE_NAME", 6163)) + cols = append(cols, createCol("FILE_TYPE", 6165)) + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6167)) + cols = append(cols, createCol("TABLE_SCHEMA", 10264)) + cols = append(cols, createCol("TABLE_NAME", 10264)) + cols = append(cols, createCol("LOGFILE_GROUP_NAME", 6165)) + cols = append(cols, createCol("LOGFILE_GROUP_NUMBER", 265)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("FULLTEXT_KEYS", 10264)) + cols = append(cols, createCol("DELETED_ROWS", 10264)) + cols = append(cols, createCol("UPDATE_COUNT", 10264)) + cols = append(cols, createCol("FREE_EXTENTS", 265)) + cols = append(cols, createCol("TOTAL_EXTENTS", 265)) + cols = append(cols, createCol("EXTENT_SIZE", 265)) + cols = append(cols, createCol("INITIAL_SIZE", 265)) + cols = append(cols, createCol("MAXIMUM_SIZE", 265)) + cols = append(cols, createCol("AUTOEXTEND_SIZE", 265)) + cols = append(cols, createCol("CREATION_TIME", 10264)) + cols = append(cols, createCol("LAST_UPDATE_TIME", 10264)) + cols = append(cols, createCol("LAST_ACCESS_TIME", 10264)) + cols = append(cols, createCol("RECOVER_TIME", 10264)) + cols = append(cols, createCol("TRANSACTION_COUNTER", 10264)) + cols = append(cols, createCol("VERSION", 265)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("TABLE_ROWS", 10264)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 10264)) + cols = append(cols, createCol("DATA_LENGTH", 10264)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 10264)) + cols = append(cols, createCol("INDEX_LENGTH", 10264)) + cols = append(cols, createCol("DATA_FREE", 265)) + cols = append(cols, createCol("CREATE_TIME", 10264)) + cols = append(cols, createCol("UPDATE_TIME", 10264)) + cols = append(cols, createCol("CHECK_TIME", 10264)) + cols = append(cols, createCol("CHECKSUM", 10264)) + cols = append(cols, createCol("STATUS", 6165)) + cols = append(cols, createCol("EXTRA", 6165)) + infSchema["FILES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 778)) + cols = append(cols, createCol("BLOCK_ID", 778)) + cols = append(cols, createCol("SPACE", 778)) + cols = append(cols, createCol("PAGE_NUMBER", 778)) + cols = append(cols, createCol("PAGE_TYPE", 6165)) + cols = append(cols, createCol("FLUSH_TYPE", 778)) + cols = append(cols, createCol("FIX_COUNT", 778)) + cols = append(cols, createCol("IS_HASHED", 6165)) + cols = append(cols, createCol("NEWEST_MODIFICATION", 778)) + cols = append(cols, createCol("OLDEST_MODIFICATION", 778)) + cols = append(cols, createCol("ACCESS_TIME", 778)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("NUMBER_RECORDS", 778)) + cols = append(cols, createCol("DATA_SIZE", 778)) + cols = append(cols, createCol("COMPRESSED_SIZE", 778)) + cols = append(cols, createCol("PAGE_STATE", 6165)) + cols = append(cols, createCol("IO_FIX", 6165)) + cols = append(cols, createCol("IS_OLD", 6165)) + cols = append(cols, createCol("FREE_PAGE_CLOCK", 778)) + cols = append(cols, createCol("IS_STALE", 6165)) + infSchema["INNODB_BUFFER_PAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 778)) + cols = append(cols, createCol("LRU_POSITION", 778)) + cols = append(cols, createCol("SPACE", 778)) + cols = append(cols, createCol("PAGE_NUMBER", 778)) + cols = append(cols, createCol("PAGE_TYPE", 6165)) + cols = append(cols, createCol("FLUSH_TYPE", 778)) + cols = append(cols, createCol("FIX_COUNT", 778)) + cols = append(cols, createCol("IS_HASHED", 6165)) + cols = append(cols, createCol("NEWEST_MODIFICATION", 778)) + cols = append(cols, createCol("OLDEST_MODIFICATION", 778)) + cols = append(cols, createCol("ACCESS_TIME", 778)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("NUMBER_RECORDS", 778)) + cols = append(cols, createCol("DATA_SIZE", 778)) + cols = append(cols, createCol("COMPRESSED_SIZE", 778)) + cols = append(cols, createCol("COMPRESSED", 6165)) + cols = append(cols, createCol("IO_FIX", 6165)) + cols = append(cols, createCol("IS_OLD", 6165)) + cols = append(cols, createCol("FREE_PAGE_CLOCK", 778)) + infSchema["INNODB_BUFFER_PAGE_LRU"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("POOL_ID", 778)) + cols = append(cols, createCol("POOL_SIZE", 778)) + cols = append(cols, createCol("FREE_BUFFERS", 778)) + cols = append(cols, createCol("DATABASE_PAGES", 778)) + cols = append(cols, createCol("OLD_DATABASE_PAGES", 778)) + cols = append(cols, createCol("MODIFIED_DATABASE_PAGES", 778)) + cols = append(cols, createCol("PENDING_DECOMPRESS", 778)) + cols = append(cols, createCol("PENDING_READS", 778)) + cols = append(cols, createCol("PENDING_FLUSH_LRU", 778)) + cols = append(cols, createCol("PENDING_FLUSH_LIST", 778)) + cols = append(cols, createCol("PAGES_MADE_YOUNG", 778)) + cols = append(cols, createCol("PAGES_NOT_MADE_YOUNG", 778)) + cols = append(cols, createCol("PAGES_MADE_YOUNG_RATE", 1035)) + cols = append(cols, createCol("PAGES_MADE_NOT_YOUNG_RATE", 1035)) + cols = append(cols, createCol("NUMBER_PAGES_READ", 778)) + cols = append(cols, createCol("NUMBER_PAGES_CREATED", 778)) + cols = append(cols, createCol("NUMBER_PAGES_WRITTEN", 778)) + cols = append(cols, createCol("PAGES_READ_RATE", 1035)) + cols = append(cols, createCol("PAGES_CREATE_RATE", 1035)) + cols = append(cols, createCol("PAGES_WRITTEN_RATE", 1035)) + cols = append(cols, createCol("NUMBER_PAGES_GET", 778)) + cols = append(cols, createCol("HIT_RATE", 778)) + cols = append(cols, createCol("YOUNG_MAKE_PER_THOUSAND_GETS", 778)) + cols = append(cols, createCol("NOT_YOUNG_MAKE_PER_THOUSAND_GETS", 778)) + cols = append(cols, createCol("NUMBER_PAGES_READ_AHEAD", 778)) + cols = append(cols, createCol("NUMBER_READ_AHEAD_EVICTED", 778)) + cols = append(cols, createCol("READ_AHEAD_RATE", 1035)) + cols = append(cols, createCol("READ_AHEAD_EVICTED_RATE", 1035)) + cols = append(cols, createCol("LRU_IO_TOTAL", 778)) + cols = append(cols, createCol("LRU_IO_CURRENT", 778)) + cols = append(cols, createCol("UNCOMPRESS_TOTAL", 778)) + cols = append(cols, createCol("UNCOMPRESS_CURRENT", 778)) + infSchema["INNODB_BUFFER_POOL_STATS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE_ID", 776)) + cols = append(cols, createCol("INDEX_ID", 778)) + cols = append(cols, createCol("N_CACHED_PAGES", 778)) + infSchema["INNODB_CACHED_INDEXES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("database_name", 6165)) + cols = append(cols, createCol("table_name", 6165)) + cols = append(cols, createCol("index_name", 6165)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_PER_INDEX"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("database_name", 6165)) + cols = append(cols, createCol("table_name", 6165)) + cols = append(cols, createCol("index_name", 6165)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_PER_INDEX_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("compress_ops", 263)) + cols = append(cols, createCol("compress_ops_ok", 263)) + cols = append(cols, createCol("compress_time", 263)) + cols = append(cols, createCol("uncompress_ops", 263)) + cols = append(cols, createCol("uncompress_time", 263)) + infSchema["INNODB_CMP_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("buffer_pool_instance", 263)) + cols = append(cols, createCol("pages_used", 263)) + cols = append(cols, createCol("pages_free", 263)) + cols = append(cols, createCol("relocation_ops", 265)) + cols = append(cols, createCol("relocation_time", 263)) + infSchema["INNODB_CMPMEM"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("page_size", 263)) + cols = append(cols, createCol("buffer_pool_instance", 263)) + cols = append(cols, createCol("pages_used", 263)) + cols = append(cols, createCol("pages_free", 263)) + cols = append(cols, createCol("relocation_ops", 265)) + cols = append(cols, createCol("relocation_time", 263)) + infSchema["INNODB_CMPMEM_RESET"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("POS", 778)) + cols = append(cols, createCol("MTYPE", 263)) + cols = append(cols, createCol("PRTYPE", 263)) + cols = append(cols, createCol("LEN", 263)) + cols = append(cols, createCol("HAS_DEFAULT", 263)) + cols = append(cols, createCol("DEFAULT_VALUE", 6163)) + infSchema["INNODB_COLUMNS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE", 10262)) + cols = append(cols, createCol("PATH", 6165)) + infSchema["INNODB_DATAFILES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("INDEX_ID", 10262)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("POS", 778)) + infSchema["INNODB_FIELDS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 6165)) + cols = append(cols, createCol("FOR_NAME", 6165)) + cols = append(cols, createCol("REF_NAME", 6165)) + cols = append(cols, createCol("N_COLS", 265)) + cols = append(cols, createCol("TYPE", 778)) + infSchema["INNODB_FOREIGN"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 6165)) + cols = append(cols, createCol("FOR_COL_NAME", 6165)) + cols = append(cols, createCol("REF_COL_NAME", 6165)) + cols = append(cols, createCol("POS", 776)) + infSchema["INNODB_FOREIGN_COLS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("DOC_ID", 778)) + infSchema["INNODB_FT_BEING_DELETED"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("KEY", 6165)) + cols = append(cols, createCol("VALUE", 6165)) + infSchema["INNODB_FT_CONFIG"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("value", 6165)) + infSchema["INNODB_FT_DEFAULT_STOPWORD"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("DOC_ID", 778)) + infSchema["INNODB_FT_DELETED"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("WORD", 6165)) + cols = append(cols, createCol("FIRST_DOC_ID", 778)) + cols = append(cols, createCol("LAST_DOC_ID", 778)) + cols = append(cols, createCol("DOC_COUNT", 778)) + cols = append(cols, createCol("DOC_ID", 778)) + cols = append(cols, createCol("POSITION", 778)) + infSchema["INNODB_FT_INDEX_CACHE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("WORD", 6165)) + cols = append(cols, createCol("FIRST_DOC_ID", 778)) + cols = append(cols, createCol("LAST_DOC_ID", 778)) + cols = append(cols, createCol("DOC_COUNT", 778)) + cols = append(cols, createCol("DOC_ID", 778)) + cols = append(cols, createCol("POSITION", 778)) + infSchema["INNODB_FT_INDEX_TABLE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("INDEX_ID", 778)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("TYPE", 263)) + cols = append(cols, createCol("N_FIELDS", 263)) + cols = append(cols, createCol("PAGE_NO", 263)) + cols = append(cols, createCol("SPACE", 263)) + cols = append(cols, createCol("MERGE_THRESHOLD", 263)) + infSchema["INNODB_INDEXES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("SUBSYSTEM", 6165)) + cols = append(cols, createCol("COUNT", 265)) + cols = append(cols, createCol("MAX_COUNT", 265)) + cols = append(cols, createCol("MIN_COUNT", 265)) + cols = append(cols, createCol("AVG_COUNT", 1035)) + cols = append(cols, createCol("COUNT_RESET", 265)) + cols = append(cols, createCol("MAX_COUNT_RESET", 265)) + cols = append(cols, createCol("MIN_COUNT_RESET", 265)) + cols = append(cols, createCol("AVG_COUNT_RESET", 1035)) + cols = append(cols, createCol("TIME_ENABLED", 2064)) + cols = append(cols, createCol("TIME_DISABLED", 2064)) + cols = append(cols, createCol("TIME_ELAPSED", 265)) + cols = append(cols, createCol("TIME_RESET", 2064)) + cols = append(cols, createCol("STATUS", 6165)) + cols = append(cols, createCol("TYPE", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + infSchema["INNODB_METRICS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 776)) + cols = append(cols, createCol("SPACE", 776)) + cols = append(cols, createCol("PATH", 6165)) + cols = append(cols, createCol("SIZE", 778)) + cols = append(cols, createCol("STATE", 6165)) + cols = append(cols, createCol("PURPOSE", 6165)) + infSchema["INNODB_SESSION_TEMP_TABLESPACES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("FLAG", 263)) + cols = append(cols, createCol("N_COLS", 263)) + cols = append(cols, createCol("SPACE", 265)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("ZIP_PAGE_SIZE", 776)) + cols = append(cols, createCol("SPACE_TYPE", 6165)) + cols = append(cols, createCol("INSTANT_COLS", 263)) + infSchema["INNODB_TABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE", 776)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("FLAG", 776)) + cols = append(cols, createCol("ROW_FORMAT", 6165)) + cols = append(cols, createCol("PAGE_SIZE", 776)) + cols = append(cols, createCol("ZIP_PAGE_SIZE", 776)) + cols = append(cols, createCol("SPACE_TYPE", 6165)) + cols = append(cols, createCol("FS_BLOCK_SIZE", 776)) + cols = append(cols, createCol("FILE_SIZE", 778)) + cols = append(cols, createCol("ALLOCATED_SIZE", 778)) + cols = append(cols, createCol("AUTOEXTEND_SIZE", 778)) + cols = append(cols, createCol("SERVER_VERSION", 6165)) + cols = append(cols, createCol("SPACE_VERSION", 776)) + cols = append(cols, createCol("ENCRYPTION", 6165)) + cols = append(cols, createCol("STATE", 6165)) + infSchema["INNODB_TABLESPACES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPACE", 10262)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("PATH", 6165)) + cols = append(cols, createCol("FLAG", 10262)) + cols = append(cols, createCol("SPACE_TYPE", 6165)) + infSchema["INNODB_TABLESPACES_BRIEF"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("STATS_INITIALIZED", 6165)) + cols = append(cols, createCol("NUM_ROWS", 778)) + cols = append(cols, createCol("CLUST_INDEX_SIZE", 778)) + cols = append(cols, createCol("OTHER_INDEX_SIZE", 778)) + cols = append(cols, createCol("MODIFIED_COUNTER", 778)) + cols = append(cols, createCol("AUTOINC", 778)) + cols = append(cols, createCol("REF_COUNT", 263)) + infSchema["INNODB_TABLESTATS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("NAME", 6165)) + cols = append(cols, createCol("N_COLS", 776)) + cols = append(cols, createCol("SPACE", 776)) + infSchema["INNODB_TEMP_TABLE_INFO"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("trx_id", 778)) + cols = append(cols, createCol("trx_state", 6165)) + cols = append(cols, createCol("trx_started", 2064)) + cols = append(cols, createCol("trx_requested_lock_id", 6165)) + cols = append(cols, createCol("trx_wait_started", 2064)) + cols = append(cols, createCol("trx_weight", 778)) + cols = append(cols, createCol("trx_mysql_thread_id", 778)) + cols = append(cols, createCol("trx_query", 6165)) + cols = append(cols, createCol("trx_operation_state", 6165)) + cols = append(cols, createCol("trx_tables_in_use", 778)) + cols = append(cols, createCol("trx_tables_locked", 778)) + cols = append(cols, createCol("trx_lock_structs", 778)) + cols = append(cols, createCol("trx_lock_memory_bytes", 778)) + cols = append(cols, createCol("trx_rows_locked", 778)) + cols = append(cols, createCol("trx_rows_modified", 778)) + cols = append(cols, createCol("trx_concurrency_tickets", 778)) + cols = append(cols, createCol("trx_isolation_level", 6165)) + cols = append(cols, createCol("trx_unique_checks", 263)) + cols = append(cols, createCol("trx_foreign_key_checks", 263)) + cols = append(cols, createCol("trx_last_foreign_key_error", 6165)) + cols = append(cols, createCol("trx_adaptive_hash_latched", 263)) + cols = append(cols, createCol("trx_adaptive_hash_timeout", 778)) + cols = append(cols, createCol("trx_is_read_only", 263)) + cols = append(cols, createCol("trx_autocommit_non_locking", 263)) + cols = append(cols, createCol("trx_schedule_weight", 778)) + infSchema["INNODB_TRX"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_ID", 778)) + cols = append(cols, createCol("POS", 776)) + cols = append(cols, createCol("BASE_POS", 776)) + infSchema["INNODB_VIRTUAL"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 776)) + cols = append(cols, createCol("POSITION_IN_UNIQUE_CONSTRAINT", 776)) + cols = append(cols, createCol("REFERENCED_TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("REFERENCED_TABLE_NAME", 6165)) + cols = append(cols, createCol("REFERENCED_COLUMN_NAME", 6165)) + infSchema["KEY_COLUMN_USAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("WORD", 6165)) + cols = append(cols, createCol("RESERVED", 263)) + infSchema["KEYWORDS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("QUERY", 6165)) + cols = append(cols, createCol("TRACE", 6165)) + cols = append(cols, createCol("MISSING_BYTES_BEYOND_MAX_MEM_SIZE", 263)) + cols = append(cols, createCol("INSUFFICIENT_PRIVILEGES", 257)) + infSchema["OPTIMIZER_TRACE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPECIFIC_CATALOG", 6165)) + cols = append(cols, createCol("SPECIFIC_SCHEMA", 6165)) + cols = append(cols, createCol("SPECIFIC_NAME", 6165)) + cols = append(cols, createCol("ORDINAL_POSITION", 778)) + cols = append(cols, createCol("PARAMETER_MODE", 6165)) + cols = append(cols, createCol("PARAMETER_NAME", 6165)) + cols = append(cols, createCol("DATA_TYPE", 6163)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 265)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 265)) + cols = append(cols, createCol("NUMERIC_PRECISION", 776)) + cols = append(cols, createCol("NUMERIC_SCALE", 265)) + cols = append(cols, createCol("DATETIME_PRECISION", 776)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("DTD_IDENTIFIER", 6163)) + cols = append(cols, createCol("ROUTINE_TYPE", 2074)) + infSchema["PARAMETERS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("PARTITION_NAME", 6165)) + cols = append(cols, createCol("SUBPARTITION_NAME", 6165)) + cols = append(cols, createCol("PARTITION_ORDINAL_POSITION", 776)) + cols = append(cols, createCol("SUBPARTITION_ORDINAL_POSITION", 776)) + cols = append(cols, createCol("PARTITION_METHOD", 6165)) + cols = append(cols, createCol("SUBPARTITION_METHOD", 6165)) + cols = append(cols, createCol("PARTITION_EXPRESSION", 6165)) + cols = append(cols, createCol("SUBPARTITION_EXPRESSION", 6165)) + cols = append(cols, createCol("PARTITION_DESCRIPTION", 6163)) + cols = append(cols, createCol("TABLE_ROWS", 778)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 778)) + cols = append(cols, createCol("DATA_LENGTH", 778)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 778)) + cols = append(cols, createCol("INDEX_LENGTH", 778)) + cols = append(cols, createCol("DATA_FREE", 778)) + cols = append(cols, createCol("CREATE_TIME", 2061)) + cols = append(cols, createCol("UPDATE_TIME", 2064)) + cols = append(cols, createCol("CHECK_TIME", 2064)) + cols = append(cols, createCol("CHECKSUM", 265)) + cols = append(cols, createCol("PARTITION_COMMENT", 6163)) + cols = append(cols, createCol("NODEGROUP", 6165)) + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + infSchema["PARTITIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("PLUGIN_NAME", 6165)) + cols = append(cols, createCol("PLUGIN_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_STATUS", 6165)) + cols = append(cols, createCol("PLUGIN_TYPE", 6165)) + cols = append(cols, createCol("PLUGIN_TYPE_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_LIBRARY", 6165)) + cols = append(cols, createCol("PLUGIN_LIBRARY_VERSION", 6165)) + cols = append(cols, createCol("PLUGIN_AUTHOR", 6165)) + cols = append(cols, createCol("PLUGIN_DESCRIPTION", 6165)) + cols = append(cols, createCol("PLUGIN_LICENSE", 6165)) + cols = append(cols, createCol("LOAD_OPTION", 6165)) + infSchema["PLUGINS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("ID", 778)) + cols = append(cols, createCol("USER", 6165)) + cols = append(cols, createCol("HOST", 6165)) + cols = append(cols, createCol("DB", 6165)) + cols = append(cols, createCol("COMMAND", 6165)) + cols = append(cols, createCol("TIME", 263)) + cols = append(cols, createCol("STATE", 6165)) + cols = append(cols, createCol("INFO", 6165)) + infSchema["PROCESSLIST"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("QUERY_ID", 263)) + cols = append(cols, createCol("SEQ", 263)) + cols = append(cols, createCol("STATE", 6165)) + cols = append(cols, createCol("DURATION", 18)) + cols = append(cols, createCol("CPU_USER", 18)) + cols = append(cols, createCol("CPU_SYSTEM", 18)) + cols = append(cols, createCol("CONTEXT_VOLUNTARY", 263)) + cols = append(cols, createCol("CONTEXT_INVOLUNTARY", 263)) + cols = append(cols, createCol("BLOCK_OPS_IN", 263)) + cols = append(cols, createCol("BLOCK_OPS_OUT", 263)) + cols = append(cols, createCol("MESSAGES_SENT", 263)) + cols = append(cols, createCol("MESSAGES_RECEIVED", 263)) + cols = append(cols, createCol("PAGE_FAULTS_MAJOR", 263)) + cols = append(cols, createCol("PAGE_FAULTS_MINOR", 263)) + cols = append(cols, createCol("SWAPS", 263)) + cols = append(cols, createCol("SOURCE_FUNCTION", 6165)) + cols = append(cols, createCol("SOURCE_FILE", 6165)) + cols = append(cols, createCol("SOURCE_LINE", 263)) + infSchema["PROFILING"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("UNIQUE_CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("MATCH_OPTION", 2074)) + cols = append(cols, createCol("UPDATE_RULE", 2074)) + cols = append(cols, createCol("DELETE_RULE", 2074)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("REFERENCED_TABLE_NAME", 6165)) + infSchema["REFERENTIAL_CONSTRAINTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("RESOURCE_GROUP_NAME", 6165)) + cols = append(cols, createCol("RESOURCE_GROUP_TYPE", 2074)) + cols = append(cols, createCol("RESOURCE_GROUP_ENABLED", 257)) + cols = append(cols, createCol("VCPU_IDS", 10260)) + cols = append(cols, createCol("THREAD_PRIORITY", 263)) + infSchema["RESOURCE_GROUPS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTOR", 6165)) + cols = append(cols, createCol("GRANTOR_HOST", 6165)) + cols = append(cols, createCol("GRANTEE", 6167)) + cols = append(cols, createCol("GRANTEE_HOST", 6167)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6167)) + cols = append(cols, createCol("TABLE_NAME", 6167)) + cols = append(cols, createCol("COLUMN_NAME", 6167)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 2075)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["ROLE_COLUMN_GRANTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTOR", 6165)) + cols = append(cols, createCol("GRANTOR_HOST", 6165)) + cols = append(cols, createCol("GRANTEE", 6167)) + cols = append(cols, createCol("GRANTEE_HOST", 6167)) + cols = append(cols, createCol("SPECIFIC_CATALOG", 6165)) + cols = append(cols, createCol("SPECIFIC_SCHEMA", 6167)) + cols = append(cols, createCol("SPECIFIC_NAME", 6167)) + cols = append(cols, createCol("ROUTINE_CATALOG", 6165)) + cols = append(cols, createCol("ROUTINE_SCHEMA", 6167)) + cols = append(cols, createCol("ROUTINE_NAME", 6167)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 2075)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["ROLE_ROUTINE_GRANTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTOR", 6165)) + cols = append(cols, createCol("GRANTOR_HOST", 6165)) + cols = append(cols, createCol("GRANTEE", 6167)) + cols = append(cols, createCol("GRANTEE_HOST", 6167)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6167)) + cols = append(cols, createCol("TABLE_NAME", 6167)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 2075)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["ROLE_TABLE_GRANTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SPECIFIC_NAME", 6165)) + cols = append(cols, createCol("ROUTINE_CATALOG", 6165)) + cols = append(cols, createCol("ROUTINE_SCHEMA", 6165)) + cols = append(cols, createCol("ROUTINE_NAME", 6165)) + cols = append(cols, createCol("ROUTINE_TYPE", 2074)) + cols = append(cols, createCol("DATA_TYPE", 6163)) + cols = append(cols, createCol("CHARACTER_MAXIMUM_LENGTH", 265)) + cols = append(cols, createCol("CHARACTER_OCTET_LENGTH", 265)) + cols = append(cols, createCol("NUMERIC_PRECISION", 776)) + cols = append(cols, createCol("NUMERIC_SCALE", 776)) + cols = append(cols, createCol("DATETIME_PRECISION", 776)) + cols = append(cols, createCol("CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("COLLATION_NAME", 6165)) + cols = append(cols, createCol("DTD_IDENTIFIER", 6163)) + cols = append(cols, createCol("ROUTINE_BODY", 6165)) + cols = append(cols, createCol("ROUTINE_DEFINITION", 6163)) + cols = append(cols, createCol("EXTERNAL_NAME", 10264)) + cols = append(cols, createCol("EXTERNAL_LANGUAGE", 6165)) + cols = append(cols, createCol("PARAMETER_STYLE", 6165)) + cols = append(cols, createCol("IS_DETERMINISTIC", 6165)) + cols = append(cols, createCol("SQL_DATA_ACCESS", 2074)) + cols = append(cols, createCol("SQL_PATH", 10264)) + cols = append(cols, createCol("SECURITY_TYPE", 2074)) + cols = append(cols, createCol("CREATED", 2061)) + cols = append(cols, createCol("LAST_ALTERED", 2061)) + cols = append(cols, createCol("SQL_MODE", 2075)) + cols = append(cols, createCol("ROUTINE_COMMENT", 6163)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["ROUTINES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["SCHEMA_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CATALOG_NAME", 6165)) + cols = append(cols, createCol("SCHEMA_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_CHARACTER_SET_NAME", 6165)) + cols = append(cols, createCol("DEFAULT_COLLATION_NAME", 6165)) + cols = append(cols, createCol("SQL_PATH", 10264)) + cols = append(cols, createCol("DEFAULT_ENCRYPTION", 2074)) + infSchema["SCHEMATA"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CATALOG_NAME", 6165)) + cols = append(cols, createCol("SCHEMA_NAME", 6165)) + cols = append(cols, createCol("OPTIONS", 6165)) + infSchema["SCHEMATA_EXTENSIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("SRS_NAME", 6165)) + cols = append(cols, createCol("SRS_ID", 776)) + cols = append(cols, createCol("GEOMETRY_TYPE_NAME", 6163)) + infSchema["ST_GEOMETRY_COLUMNS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("SRS_NAME", 6165)) + cols = append(cols, createCol("SRS_ID", 776)) + cols = append(cols, createCol("ORGANIZATION", 6165)) + cols = append(cols, createCol("ORGANIZATION_COORDSYS_ID", 776)) + cols = append(cols, createCol("DEFINITION", 6165)) + cols = append(cols, createCol("DESCRIPTION", 6165)) + infSchema["ST_SPATIAL_REFERENCE_SYSTEMS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("UNIT_NAME", 6165)) + cols = append(cols, createCol("UNIT_TYPE", 6165)) + cols = append(cols, createCol("CONVERSION_FACTOR", 1036)) + cols = append(cols, createCol("DESCRIPTION", 6165)) + infSchema["ST_UNITS_OF_MEASURE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("NON_UNIQUE", 263)) + cols = append(cols, createCol("INDEX_SCHEMA", 6165)) + cols = append(cols, createCol("INDEX_NAME", 6165)) + cols = append(cols, createCol("SEQ_IN_INDEX", 776)) + cols = append(cols, createCol("COLUMN_NAME", 6165)) + cols = append(cols, createCol("COLLATION", 6165)) + cols = append(cols, createCol("CARDINALITY", 265)) + cols = append(cols, createCol("SUB_PART", 265)) + cols = append(cols, createCol("PACKED", 10264)) + cols = append(cols, createCol("NULLABLE", 6165)) + cols = append(cols, createCol("INDEX_TYPE", 6165)) + cols = append(cols, createCol("COMMENT", 6165)) + cols = append(cols, createCol("INDEX_COMMENT", 6165)) + cols = append(cols, createCol("IS_VISIBLE", 6165)) + cols = append(cols, createCol("EXPRESSION", 6163)) + infSchema["STATISTICS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("CONSTRAINT_TYPE", 6165)) + cols = append(cols, createCol("ENFORCED", 6165)) + infSchema["TABLE_CONSTRAINTS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("CONSTRAINT_CATALOG", 6165)) + cols = append(cols, createCol("CONSTRAINT_SCHEMA", 6165)) + cols = append(cols, createCol("CONSTRAINT_NAME", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("ENGINE_ATTRIBUTE", 2078)) + cols = append(cols, createCol("SECONDARY_ENGINE_ATTRIBUTE", 2078)) + infSchema["TABLE_CONSTRAINTS_EXTENSIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["TABLE_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("TABLE_TYPE", 2074)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("VERSION", 263)) + cols = append(cols, createCol("ROW_FORMAT", 2074)) + cols = append(cols, createCol("TABLE_ROWS", 778)) + cols = append(cols, createCol("AVG_ROW_LENGTH", 778)) + cols = append(cols, createCol("DATA_LENGTH", 778)) + cols = append(cols, createCol("MAX_DATA_LENGTH", 778)) + cols = append(cols, createCol("INDEX_LENGTH", 778)) + cols = append(cols, createCol("DATA_FREE", 778)) + cols = append(cols, createCol("AUTO_INCREMENT", 778)) + cols = append(cols, createCol("CREATE_TIME", 2061)) + cols = append(cols, createCol("UPDATE_TIME", 2064)) + cols = append(cols, createCol("CHECK_TIME", 2064)) + cols = append(cols, createCol("TABLE_COLLATION", 6165)) + cols = append(cols, createCol("CHECKSUM", 265)) + cols = append(cols, createCol("CREATE_OPTIONS", 6165)) + cols = append(cols, createCol("TABLE_COMMENT", 6163)) + infSchema["TABLES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("ENGINE_ATTRIBUTE", 2078)) + cols = append(cols, createCol("SECONDARY_ENGINE_ATTRIBUTE", 2078)) + infSchema["TABLES_EXTENSIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + cols = append(cols, createCol("ENGINE", 6165)) + cols = append(cols, createCol("TABLESPACE_TYPE", 6165)) + cols = append(cols, createCol("LOGFILE_GROUP_NAME", 6165)) + cols = append(cols, createCol("EXTENT_SIZE", 778)) + cols = append(cols, createCol("AUTOEXTEND_SIZE", 778)) + cols = append(cols, createCol("MAXIMUM_SIZE", 778)) + cols = append(cols, createCol("NODEGROUP_ID", 778)) + cols = append(cols, createCol("TABLESPACE_COMMENT", 6165)) + infSchema["TABLESPACES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLESPACE_NAME", 6165)) + cols = append(cols, createCol("ENGINE_ATTRIBUTE", 2078)) + infSchema["TABLESPACES_EXTENSIONS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TRIGGER_CATALOG", 6165)) + cols = append(cols, createCol("TRIGGER_SCHEMA", 6165)) + cols = append(cols, createCol("TRIGGER_NAME", 6165)) + cols = append(cols, createCol("EVENT_MANIPULATION", 2074)) + cols = append(cols, createCol("EVENT_OBJECT_CATALOG", 6165)) + cols = append(cols, createCol("EVENT_OBJECT_SCHEMA", 6165)) + cols = append(cols, createCol("EVENT_OBJECT_TABLE", 6165)) + cols = append(cols, createCol("ACTION_ORDER", 776)) + cols = append(cols, createCol("ACTION_CONDITION", 10264)) + cols = append(cols, createCol("ACTION_STATEMENT", 6163)) + cols = append(cols, createCol("ACTION_ORIENTATION", 6165)) + cols = append(cols, createCol("ACTION_TIMING", 2074)) + cols = append(cols, createCol("ACTION_REFERENCE_OLD_TABLE", 10264)) + cols = append(cols, createCol("ACTION_REFERENCE_NEW_TABLE", 10264)) + cols = append(cols, createCol("ACTION_REFERENCE_OLD_ROW", 6165)) + cols = append(cols, createCol("ACTION_REFERENCE_NEW_ROW", 6165)) + cols = append(cols, createCol("CREATED", 2061)) + cols = append(cols, createCol("SQL_MODE", 2075)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + cols = append(cols, createCol("DATABASE_COLLATION", 6165)) + infSchema["TRIGGERS"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("USER", 6167)) + cols = append(cols, createCol("HOST", 6167)) + cols = append(cols, createCol("ATTRIBUTE", 6163)) + infSchema["USER_ATTRIBUTES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("GRANTEE", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("PRIVILEGE_TYPE", 6165)) + cols = append(cols, createCol("IS_GRANTABLE", 6165)) + infSchema["USER_PRIVILEGES"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("SPECIFIC_CATALOG", 6165)) + cols = append(cols, createCol("SPECIFIC_SCHEMA", 6165)) + cols = append(cols, createCol("SPECIFIC_NAME", 6165)) + infSchema["VIEW_ROUTINE_USAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("VIEW_CATALOG", 6165)) + cols = append(cols, createCol("VIEW_SCHEMA", 6165)) + cols = append(cols, createCol("VIEW_NAME", 6165)) + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + infSchema["VIEW_TABLE_USAGE"] = cols + cols = []vindexes.Column{} + cols = append(cols, createCol("TABLE_CATALOG", 6165)) + cols = append(cols, createCol("TABLE_SCHEMA", 6165)) + cols = append(cols, createCol("TABLE_NAME", 6165)) + cols = append(cols, createCol("VIEW_DEFINITION", 6163)) + cols = append(cols, createCol("CHECK_OPTION", 2074)) + cols = append(cols, createCol("IS_UPDATABLE", 2074)) + cols = append(cols, createCol("DEFINER", 6165)) + cols = append(cols, createCol("SECURITY_TYPE", 6165)) + cols = append(cols, createCol("CHARACTER_SET_CLIENT", 6165)) + cols = append(cols, createCol("COLLATION_CONNECTION", 6165)) + infSchema["VIEWS"] = cols + + return infSchema +} + +type infoSchemaWithColumns struct { + inner SchemaInformation + infoSchemaData map[string][]vindexes.Column +} + +// newSchemaInfo returns a SchemaInformation that has the column information for all info_schema tables +func newSchemaInfo(inner SchemaInformation) SchemaInformation { + version := servenv.MySQLServerVersion() + var infoSchema map[string][]vindexes.Column + if strings.HasPrefix(version, "5.7") { + infoSchema = getInfoSchema57() + } else { + infoSchema = getInfoSchema80() + } + return &infoSchemaWithColumns{inner: inner, infoSchemaData: infoSchema} +} + +// FindTableOrVindex implements the SchemaInformation interface +func (i *infoSchemaWithColumns) FindTableOrVindex(tbl sqlparser.TableName) (*vindexes.Table, vindexes.Vindex, string, topodatapb.TabletType, key.Destination, error) { + if !strings.EqualFold(tbl.Qualifier.String(), "information_schema") { + return i.inner.FindTableOrVindex(tbl) + } + + ks := vindexes.Keyspace{ + Name: "information_schema", + Sharded: false, + } + cols := i.infoSchemaData[strings.ToUpper(tbl.Name.String())] + vtbl := &vindexes.Table{ + Type: "View", + Name: sqlparser.NewIdentifierCS(tbl.Name.String()), + Keyspace: &ks, + Columns: cols, + ColumnListAuthoritative: true, + } + return vtbl, nil, "", topodatapb.TabletType_UNKNOWN, nil, nil +} + +// ConnCollation implements the SchemaInformation interface +func (i *infoSchemaWithColumns) ConnCollation() collations.ID { + return i.inner.ConnCollation() +} diff --git a/go/vt/vtgate/semantics/info_schema_gen_test.go b/go/vt/vtgate/semantics/info_schema_gen_test.go new file mode 100644 index 0000000000..c5fe012385 --- /dev/null +++ b/go/vt/vtgate/semantics/info_schema_gen_test.go @@ -0,0 +1,228 @@ +/* +Copyright 2022 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package semantics + +import ( + "database/sql" + "fmt" + "regexp" + "strings" + "testing" + + _ "github.com/go-sql-driver/mysql" + "github.com/stretchr/testify/require" + + "vitess.io/vitess/go/vt/sqlparser" +) + +func TestGenerateInfoSchemaMap(t *testing.T) { + t.Skip("run manually to re-create the content of the getInfoSchema functions") + b := new(strings.Builder) + + db, err := sql.Open("mysql", "root@tcp(127.0.0.1:3306)/test") + require.NoError(t, err) + defer db.Close() + + for _, tbl := range informationSchemaTables80 { + b.WriteString("cols = []vindexes.Column{}\n") + result, err := db.Query(fmt.Sprintf("show columns from information_schema.`%s`", tbl)) + require.NoError(t, err) + defer result.Close() + for result.Next() { + var r row + result.Scan(&r.Field, &r.Type, &r.Null, &r.Key, &r.Default, &r.Extra) + allString := re.FindStringSubmatch(r.Type) + var typ string + if allString == nil { + typ = r.Type + } else { + typ = allString[1] + } + unsigned := false + if idx := strings.Index(typ, "unsigned"); idx > 0 { + typ = typ[:idx-1] + unsigned = true + } + i2 := sqlparser.SQLTypeToQueryType(typ, unsigned) + if int(i2) == 0 { + t.Fatalf("%s %s", tbl, r.Field) + } + b.WriteString(fmt.Sprintf("cols = append(cols, createCol(\"%s\", %d))\n", r.Field, int(i2))) + } + b.WriteString(fmt.Sprintf("infSchema[\"%s\"] = cols\n", tbl)) + } + + fmt.Println(b.String()) +} + +var ( + informationSchemaTables57 = []string{ + "CHARACTER_SETS", + "COLLATION_CHARACTER_SET_APPLICABILITY", + "COLLATIONS", + "COLUMN_PRIVILEGES", + "COLUMNS", + "ENGINES", + "EVENTS", + "FILES", + "GLOBAL_STATUS", + "GLOBAL_VARIABLES", + "INNODB_BUFFER_PAGE", + "INNODB_BUFFER_PAGE_LRU", + "INNODB_BUFFER_POOL_STATS", + "INNODB_CMP", + "INNODB_CMP_PER_INDEX", + "INNODB_CMP_PER_INDEX_RESET", + "INNODB_CMP_RESET", + "INNODB_CMPMEM", + "INNODB_CMPMEM_RESET", + "INNODB_FT_BEING_DELETED", + "INNODB_FT_CONFIG", + "INNODB_FT_DEFAULT_STOPWORD", + "INNODB_FT_DELETED", + "INNODB_FT_INDEX_CACHE", + "INNODB_FT_INDEX_TABLE", + "INNODB_LOCK_WAITS", + "INNODB_LOCKS", + "INNODB_METRICS", + "INNODB_SYS_COLUMNS", + "INNODB_SYS_DATAFILES", + "INNODB_SYS_FIELDS", + "INNODB_SYS_FOREIGN", + "INNODB_SYS_FOREIGN_COLS", + "INNODB_SYS_INDEXES", + "INNODB_SYS_TABLES", + "INNODB_SYS_TABLESPACES", + "INNODB_SYS_TABLESTATS", + "INNODB_SYS_VIRTUAL", + "INNODB_TEMP_TABLE_INFO", + "INNODB_TRX", + "KEY_COLUMN_USAGE", + "OPTIMIZER_TRACE", + "PARAMETERS", + "PARTITIONS", + "PLUGINS", + "PROCESSLIST", + "PROFILING", + "REFERENTIAL_CONSTRAINTS", + "ROUTINES", + "SCHEMA_PRIVILEGES", + "SCHEMATA", + "SESSION_STATUS", + "SESSION_VARIABLES", + "STATISTICS", + "TABLE_CONSTRAINTS", + "TABLE_PRIVILEGES", + "TABLES", + "TABLESPACES", + "TRIGGERS", + "USER_PRIVILEGES", + "VIEWS", + } + informationSchemaTables80 = []string{ + "ADMINISTRABLE_ROLE_AUTHORIZATIONS", + "APPLICABLE_ROLES", + "CHARACTER_SETS", + "CHECK_CONSTRAINTS", + "COLLATION_CHARACTER_SET_APPLICABILITY", + "COLLATIONS", + "COLUMN_PRIVILEGES", + "COLUMN_STATISTICS", + "COLUMNS", + "COLUMNS_EXTENSIONS", + "ENABLED_ROLES", + "ENGINES", + "EVENTS", + "FILES", + "INNODB_BUFFER_PAGE", + "INNODB_BUFFER_PAGE_LRU", + "INNODB_BUFFER_POOL_STATS", + "INNODB_CACHED_INDEXES", + "INNODB_CMP", + "INNODB_CMP_PER_INDEX", + "INNODB_CMP_PER_INDEX_RESET", + "INNODB_CMP_RESET", + "INNODB_CMPMEM", + "INNODB_CMPMEM_RESET", + "INNODB_COLUMNS", + "INNODB_DATAFILES", + "INNODB_FIELDS", + "INNODB_FOREIGN", + "INNODB_FOREIGN_COLS", + "INNODB_FT_BEING_DELETED", + "INNODB_FT_CONFIG", + "INNODB_FT_DEFAULT_STOPWORD", + "INNODB_FT_DELETED", + "INNODB_FT_INDEX_CACHE", + "INNODB_FT_INDEX_TABLE", + "INNODB_INDEXES", + "INNODB_METRICS", + "INNODB_SESSION_TEMP_TABLESPACES", + "INNODB_TABLES", + "INNODB_TABLESPACES", + "INNODB_TABLESPACES_BRIEF", + "INNODB_TABLESTATS", + "INNODB_TEMP_TABLE_INFO", + "INNODB_TRX", + "INNODB_VIRTUAL", + "KEY_COLUMN_USAGE", + "KEYWORDS", + "OPTIMIZER_TRACE", + "PARAMETERS", + "PARTITIONS", + "PLUGINS", + "PROCESSLIST", + "PROFILING", + "REFERENTIAL_CONSTRAINTS", + "RESOURCE_GROUPS", + "ROLE_COLUMN_GRANTS", + "ROLE_ROUTINE_GRANTS", + "ROLE_TABLE_GRANTS", + "ROUTINES", + "SCHEMA_PRIVILEGES", + "SCHEMATA", + "SCHEMATA_EXTENSIONS", + "ST_GEOMETRY_COLUMNS", + "ST_SPATIAL_REFERENCE_SYSTEMS", + "ST_UNITS_OF_MEASURE", + "STATISTICS", + "TABLE_CONSTRAINTS", + "TABLE_CONSTRAINTS_EXTENSIONS", + "TABLE_PRIVILEGES", + "TABLES", + "TABLES_EXTENSIONS", + "TABLESPACES", + "TABLESPACES_EXTENSIONS", + "TRIGGERS", + "USER_ATTRIBUTES", + "USER_PRIVILEGES", + "VIEW_ROUTINE_USAGE", + "VIEW_TABLE_USAGE", + "VIEWS", + } +) + +type row struct { + Field string + Type string + Null string + Key any + Default any + Extra any +} + +var re = regexp.MustCompile(`(.*)\((.*)\)`) diff --git a/go/vt/vtgate/semantics/table_collector.go b/go/vt/vtgate/semantics/table_collector.go index aa8b4eebf9..8266287abe 100644 --- a/go/vt/vtgate/semantics/table_collector.go +++ b/go/vt/vtgate/semantics/table_collector.go @@ -84,19 +84,16 @@ func (tc *tableCollector) up(cursor *sqlparser.Cursor) error { case sqlparser.TableName: var tbl *vindexes.Table var vindex vindexes.Vindex - var isInfSchema bool - if sqlparser.SystemSchema(t.Qualifier.String()) { - isInfSchema = true - } else { - var err error - tbl, vindex, _, _, _, err = tc.si.FindTableOrVindex(t) - if err != nil { - return err - } - if tbl == nil && vindex != nil { - tbl = newVindexTable(t.Name) - } + isInfSchema := sqlparser.SystemSchema(t.Qualifier.String()) + var err error + tbl, vindex, _, _, _, err = tc.si.FindTableOrVindex(t) + if err != nil { + return err } + if tbl == nil && vindex != nil { + tbl = newVindexTable(t.Name) + } + scope := tc.scoper.currentScope() tableInfo := tc.createTable(t, node, tbl, isInfSchema, vindex)