github.com/dolthub/go-mysql-server@v0.18.0/enginetest/queries/information_schema_queries.go (about)

     1  // Copyright 2022 Dolthub, Inc.
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package queries
    16  
    17  import (
    18  	"github.com/dolthub/vitess/go/sqltypes"
    19  
    20  	"github.com/dolthub/go-mysql-server/sql"
    21  	"github.com/dolthub/go-mysql-server/sql/types"
    22  )
    23  
    24  var InfoSchemaQueries = []QueryTest{
    25  	{
    26  		Query:    "SHOW PLUGINS",
    27  		Expected: []sql.Row{},
    28  	},
    29  	{
    30  		Query:    "SHOW KEYS FROM `columns` FROM `information_schema`;",
    31  		Expected: []sql.Row{},
    32  	},
    33  	{
    34  		Query: `SELECT 
    35       table_name, index_name, comment, non_unique, GROUP_CONCAT(column_name ORDER BY seq_in_index) AS COLUMNS 
    36     FROM information_schema.statistics 
    37     WHERE table_schema='mydb' AND table_name='mytable' AND index_name!="PRIMARY" 
    38     GROUP BY index_name;`,
    39  		ExpectedColumns: sql.Schema{
    40  			{
    41  				Name: "TABLE_NAME",
    42  				Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default),
    43  			},
    44  			{
    45  				Name: "INDEX_NAME",
    46  				Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default),
    47  			},
    48  			{
    49  				Name: "COMMENT",
    50  				Type: types.MustCreateString(sqltypes.VarChar, 8, sql.Collation_Information_Schema_Default),
    51  			},
    52  			{
    53  				Name: "NON_UNIQUE",
    54  				Type: types.Int32,
    55  			},
    56  			{
    57  				Name: "COLUMNS",
    58  				Type: types.Text,
    59  			},
    60  		},
    61  		Expected: []sql.Row{
    62  			{"mytable", "idx_si", "", 1, "s,i"},
    63  			{"mytable", "mytable_i_s", "", 1, "i,s"},
    64  			{"mytable", "mytable_s", "", 0, "s"},
    65  		},
    66  	},
    67  	{
    68  		Query: `select table_name from information_schema.tables where table_name = 'mytable' limit 1;`,
    69  		ExpectedColumns: sql.Schema{
    70  			{
    71  				Name: "TABLE_NAME",
    72  				Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default),
    73  			},
    74  		},
    75  		Expected: []sql.Row{{"mytable"}},
    76  	},
    77  	{
    78  		Query: `select table_catalog, table_schema, table_name from information_schema.tables where table_name = 'mytable' limit 1;`,
    79  		ExpectedColumns: sql.Schema{
    80  			{Name: "TABLE_CATALOG", Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default)},
    81  			{Name: "TABLE_SCHEMA", Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default)},
    82  			{Name: "TABLE_NAME", Type: types.MustCreateString(sqltypes.VarChar, 64, sql.Collation_Information_Schema_Default)},
    83  		},
    84  		Expected: []sql.Row{{"def", "mydb", "mytable"}},
    85  	},
    86  	{
    87  		Query: `select table_name from information_schema.tables where table_schema = 'information_schema' order by table_name;`,
    88  		Expected: []sql.Row{
    89  			{"administrable_role_authorizations"},
    90  			{"applicable_roles"},
    91  			{"character_sets"},
    92  			{"check_constraints"},
    93  			{"collations"},
    94  			{"collation_character_set_applicability"},
    95  			{"columns"},
    96  			{"columns_extensions"},
    97  			{"column_privileges"},
    98  			{"column_statistics"},
    99  			{"enabled_roles"},
   100  			{"engines"},
   101  			{"events"},
   102  			{"files"},
   103  			{"innodb_buffer_page"},
   104  			{"innodb_buffer_page_lru"},
   105  			{"innodb_buffer_pool_stats"},
   106  			{"innodb_cached_indexes"},
   107  			{"innodb_cmp"},
   108  			{"innodb_cmpmem"},
   109  			{"innodb_cmpmem_reset"},
   110  			{"innodb_cmp_per_index"},
   111  			{"innodb_cmp_per_index_reset"},
   112  			{"innodb_cmp_reset"},
   113  			{"innodb_columns"},
   114  			{"innodb_datafiles"},
   115  			{"innodb_fields"},
   116  			{"innodb_foreign"},
   117  			{"innodb_foreign_cols"},
   118  			{"innodb_ft_being_deleted"},
   119  			{"innodb_ft_config"},
   120  			{"innodb_ft_default_stopword"},
   121  			{"innodb_ft_deleted"},
   122  			{"innodb_ft_index_cache"},
   123  			{"innodb_ft_index_table"},
   124  			{"innodb_indexes"},
   125  			{"innodb_metrics"},
   126  			{"innodb_session_temp_tablespaces"},
   127  			{"innodb_tables"},
   128  			{"innodb_tablespaces"},
   129  			{"innodb_tablespaces_brief"},
   130  			{"innodb_tablestats"},
   131  			{"innodb_temp_table_info"},
   132  			{"innodb_trx"},
   133  			{"innodb_virtual"},
   134  			{"keywords"},
   135  			{"key_column_usage"},
   136  			{"optimizer_trace"},
   137  			{"parameters"},
   138  			{"partitions"},
   139  			{"plugins"},
   140  			{"processlist"},
   141  			{"profiling"},
   142  			{"referential_constraints"},
   143  			{"resource_groups"},
   144  			{"role_column_grants"},
   145  			{"role_routine_grants"},
   146  			{"role_table_grants"},
   147  			{"routines"},
   148  			{"schemata"},
   149  			{"schemata_extensions"},
   150  			{"schema_privileges"},
   151  			{"statistics"},
   152  			{"st_geometry_columns"},
   153  			{"st_spatial_reference_systems"},
   154  			{"st_units_of_measure"},
   155  			{"tables"},
   156  			{"tablespaces"},
   157  			{"tablespaces_extensions"},
   158  			{"tables_extensions"},
   159  			{"table_constraints"},
   160  			{"table_constraints_extensions"},
   161  			{"table_privileges"},
   162  			{"triggers"},
   163  			{"user_attributes"},
   164  			{"user_privileges"},
   165  			{"views"},
   166  			{"view_routine_usage"},
   167  			{"view_table_usage"},
   168  		},
   169  	},
   170  	{
   171  		Query: "SHOW TABLES",
   172  		Expected: []sql.Row{
   173  			{"myview"},
   174  			{"fk_tbl"},
   175  			{"mytable"},
   176  		},
   177  	},
   178  	{
   179  		Query: "SHOW FULL TABLES",
   180  		Expected: []sql.Row{
   181  			{"fk_tbl", "BASE TABLE"},
   182  			{"myview", "VIEW"},
   183  			{"mytable", "BASE TABLE"},
   184  		},
   185  	},
   186  	{
   187  		Query: "SHOW TABLES FROM foo",
   188  		Expected: []sql.Row{
   189  			{"othertable"},
   190  		},
   191  	},
   192  	{
   193  		Query: "SHOW TABLES LIKE '%table'",
   194  		Expected: []sql.Row{
   195  			{"mytable"},
   196  		},
   197  	},
   198  	{
   199  		Query: `SHOW COLUMNS FROM mytable`,
   200  		Expected: []sql.Row{
   201  			{"i", "bigint", "NO", "PRI", "NULL", ""},
   202  			{"s", "varchar(20)", "NO", "UNI", "NULL", ""},
   203  		},
   204  	},
   205  	{
   206  		Query: `DESCRIBE mytable`,
   207  		Expected: []sql.Row{
   208  			{"i", "bigint", "NO", "PRI", "NULL", ""},
   209  			{"s", "varchar(20)", "NO", "UNI", "NULL", ""},
   210  		},
   211  	},
   212  	{
   213  		Query: `DESC mytable`,
   214  		Expected: []sql.Row{
   215  			{"i", "bigint", "NO", "PRI", "NULL", ""},
   216  			{"s", "varchar(20)", "NO", "UNI", "NULL", ""},
   217  		},
   218  	},
   219  	{
   220  		Query: `SHOW COLUMNS FROM mytable WHERE Field = 'i'`,
   221  		Expected: []sql.Row{
   222  			{"i", "bigint", "NO", "PRI", "NULL", ""},
   223  		},
   224  	},
   225  	{
   226  		Query: `SHOW COLUMNS FROM mytable LIKE 'i'`,
   227  		Expected: []sql.Row{
   228  			{"i", "bigint", "NO", "PRI", "NULL", ""},
   229  		},
   230  	},
   231  	{
   232  		Query: `SHOW FULL COLUMNS FROM mytable`,
   233  		Expected: []sql.Row{
   234  			{"i", "bigint", nil, "NO", "PRI", "NULL", "", "", ""},
   235  			{"s", "varchar(20)", "utf8mb4_0900_bin", "NO", "UNI", "NULL", "", "", "column s"},
   236  		},
   237  	},
   238  	{
   239  		Query: "SHOW TABLES WHERE `Tables_in_mydb` = 'mytable'",
   240  		Expected: []sql.Row{
   241  			{"mytable"},
   242  		},
   243  	},
   244  	{
   245  		Query: `
   246  		SELECT
   247  			LOGFILE_GROUP_NAME, FILE_NAME, TOTAL_EXTENTS, INITIAL_SIZE, ENGINE, EXTRA
   248  		FROM INFORMATION_SCHEMA.FILES
   249  		WHERE FILE_TYPE = 'UNDO LOG'
   250  			AND FILE_NAME IS NOT NULL
   251  			AND LOGFILE_GROUP_NAME IS NOT NULL
   252  		GROUP BY LOGFILE_GROUP_NAME, FILE_NAME, ENGINE, TOTAL_EXTENTS, INITIAL_SIZE
   253  		ORDER BY LOGFILE_GROUP_NAME
   254  		`,
   255  		Expected: nil,
   256  	},
   257  	{
   258  		Query: `
   259  		SELECT DISTINCT
   260  			TABLESPACE_NAME, FILE_NAME, LOGFILE_GROUP_NAME, EXTENT_SIZE, INITIAL_SIZE, ENGINE
   261  		FROM INFORMATION_SCHEMA.FILES
   262  		WHERE FILE_TYPE = 'DATAFILE'
   263  		ORDER BY TABLESPACE_NAME, LOGFILE_GROUP_NAME
   264  		`,
   265  		Expected: nil,
   266  	},
   267  	{
   268  		Query: `
   269  		SELECT TABLE_NAME FROM information_schema.TABLES
   270  		WHERE TABLE_SCHEMA='mydb' AND (TABLE_TYPE='BASE TABLE' OR TABLE_TYPE='VIEW')
   271  		ORDER BY 1
   272  		`,
   273  		Expected: []sql.Row{
   274  			{"fk_tbl"},
   275  			{"mytable"},
   276  			{"myview"},
   277  		},
   278  	},
   279  	{
   280  		Query: `
   281  		SELECT COLUMN_NAME, DATA_TYPE FROM information_schema.COLUMNS
   282  		WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='mytable'
   283  		`,
   284  		Expected: []sql.Row{
   285  			{"s", "varchar"},
   286  			{"i", "bigint"},
   287  		},
   288  	},
   289  	{
   290  		Query: `
   291  		SELECT COLUMN_NAME FROM information_schema.COLUMNS
   292  		WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
   293  		GROUP BY COLUMN_NAME
   294  		`,
   295  		Expected: []sql.Row{
   296  			{"s"},
   297  			{"i"},
   298  		},
   299  	},
   300  	{
   301  		Query: `
   302  		SELECT COLUMN_NAME FROM information_schema.COLUMNS
   303  		WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
   304  		GROUP BY 1
   305  		`,
   306  		Expected: []sql.Row{
   307  			{"s"},
   308  			{"i"},
   309  		},
   310  	},
   311  	{
   312  		Query: `
   313  		SELECT COLUMN_NAME AS COLUMN_NAME FROM information_schema.COLUMNS
   314  		WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
   315  		GROUP BY 1
   316  		`,
   317  		Expected: []sql.Row{
   318  			{"s"},
   319  			{"i"},
   320  		},
   321  	},
   322  	{
   323  		Query: `SHOW INDEXES FROM mytaBLE`,
   324  		Expected: []sql.Row{
   325  			{"mytable", 0, "PRIMARY", 1, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   326  			{"mytable", 0, "mytable_s", 1, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   327  			{"mytable", 1, "mytable_i_s", 1, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   328  			{"mytable", 1, "mytable_i_s", 2, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   329  			{"mytable", 1, "idx_si", 1, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   330  			{"mytable", 1, "idx_si", 2, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   331  		},
   332  	},
   333  	{
   334  		Query: `SHOW KEYS FROM mytaBLE`,
   335  		Expected: []sql.Row{
   336  			{"mytable", 0, "PRIMARY", 1, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   337  			{"mytable", 0, "mytable_s", 1, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   338  			{"mytable", 1, "mytable_i_s", 1, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   339  			{"mytable", 1, "mytable_i_s", 2, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   340  			{"mytable", 1, "idx_si", 1, "s", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   341  			{"mytable", 1, "idx_si", 2, "i", nil, 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   342  		},
   343  	},
   344  	{
   345  		Query: `SHOW CREATE TABLE mytaBLE`,
   346  		Expected: []sql.Row{
   347  			{"mytable", "CREATE TABLE `mytable` (\n" +
   348  				"  `i` bigint NOT NULL,\n" +
   349  				"  `s` varchar(20) NOT NULL COMMENT 'column s',\n" +
   350  				"  PRIMARY KEY (`i`),\n" +
   351  				"  KEY `idx_si` (`s`,`i`),\n" +
   352  				"  KEY `mytable_i_s` (`i`,`s`),\n" +
   353  				"  UNIQUE KEY `mytable_s` (`s`)\n" +
   354  				") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
   355  		},
   356  	},
   357  	{
   358  		Query: `SHOW CREATE TABLE fk_TBL`,
   359  		Expected: []sql.Row{
   360  			{"fk_tbl", "CREATE TABLE `fk_tbl` (\n" +
   361  				"  `pk` bigint NOT NULL,\n" +
   362  				"  `a` bigint,\n" +
   363  				"  `b` varchar(20),\n" +
   364  				"  PRIMARY KEY (`pk`),\n" +
   365  				"  KEY `ab` (`a`,`b`),\n" +
   366  				"  CONSTRAINT `fk1` FOREIGN KEY (`a`,`b`) REFERENCES `mytable` (`i`,`s`) ON DELETE CASCADE\n" +
   367  				") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin"},
   368  		},
   369  	},
   370  	{
   371  
   372  		Query: "SELECT table_name, `auto_increment` FROM information_schema.tables " +
   373  			"WHERE TABLE_SCHEMA='mydb' AND TABLE_TYPE='BASE TABLE' ORDER BY 1",
   374  		Expected: []sql.Row{
   375  			{"fk_tbl", nil},
   376  			{"mytable", nil},
   377  		},
   378  	},
   379  	{
   380  		Query: "SHOW ENGINES",
   381  		Expected: []sql.Row{
   382  			{"InnoDB", "DEFAULT", "Supports transactions, row-level locking, and foreign keys", "YES", "YES", "YES"},
   383  		},
   384  	},
   385  	{
   386  		Query: "SELECT * FROM information_schema.table_constraints ORDER BY table_name, constraint_type;",
   387  		Expected: []sql.Row{
   388  			{"def", "mydb", "fk1", "mydb", "fk_tbl", "FOREIGN KEY", "YES"},
   389  			{"def", "mydb", "PRIMARY", "mydb", "fk_tbl", "PRIMARY KEY", "YES"},
   390  			{"def", "mydb", "PRIMARY", "mydb", "mytable", "PRIMARY KEY", "YES"},
   391  			{"def", "mydb", "mytable_s", "mydb", "mytable", "UNIQUE", "YES"},
   392  			{"def", "foo", "PRIMARY", "foo", "othertable", "PRIMARY KEY", "YES"},
   393  		},
   394  	},
   395  	{
   396  		Query:    "SELECT * FROM information_schema.check_constraints ORDER BY constraint_schema, constraint_name, check_clause ",
   397  		Expected: []sql.Row{},
   398  	},
   399  	{
   400  		Query: "SELECT * FROM information_schema.key_column_usage ORDER BY constraint_schema, table_name",
   401  		Expected: []sql.Row{
   402  			{"def", "foo", "PRIMARY", "def", "foo", "othertable", "text", 1, nil, nil, nil, nil},
   403  			{"def", "mydb", "PRIMARY", "def", "mydb", "fk_tbl", "pk", 1, nil, nil, nil, nil},
   404  			{"def", "mydb", "fk1", "def", "mydb", "fk_tbl", "a", 1, 1, "mydb", "mytable", "i"},
   405  			{"def", "mydb", "fk1", "def", "mydb", "fk_tbl", "b", 2, 2, "mydb", "mytable", "s"},
   406  			{"def", "mydb", "PRIMARY", "def", "mydb", "mytable", "i", 1, nil, nil, nil, nil},
   407  			{"def", "mydb", "mytable_s", "def", "mydb", "mytable", "s", 1, nil, nil, nil, nil},
   408  		},
   409  	},
   410  	{
   411  		Query: `
   412  				select CONCAT(tbl.table_schema, '.', tbl.table_name) as the_table,
   413  				       col.column_name, GROUP_CONCAT(kcu.column_name SEPARATOR ',') as pk
   414  				from information_schema.tables as tbl
   415  				join information_schema.columns as col
   416  				  on tbl.table_name = col.table_name
   417  				join information_schema.key_column_usage as kcu
   418  				  on tbl.table_name = kcu.table_name
   419  				join information_schema.table_constraints as tc
   420  				  on kcu.constraint_name = tc.constraint_name
   421  				where tbl.table_schema = 'mydb' and
   422  					  tbl.table_name = kcu.table_name and
   423  					  tc.constraint_type = 'PRIMARY KEY' and
   424  					  col.column_name like 'pk%'
   425  				group by the_table, col.column_name
   426  				`,
   427  		Expected: []sql.Row{
   428  			{"mydb.fk_tbl", "pk", "pk,pk,pk"},
   429  		},
   430  	},
   431  	{
   432  		Query:    `SELECT count(*) FROM information_schema.COLLATIONS`,
   433  		Expected: []sql.Row{{286}},
   434  	},
   435  	{
   436  		Query: `SELECT * FROM information_schema.COLLATIONS ORDER BY collation_name LIMIT 4`,
   437  		Expected: []sql.Row{
   438  			{"armscii8_bin", "armscii8", uint64(64), "", "Yes", uint32(1), "PAD SPACE"},
   439  			{"armscii8_general_ci", "armscii8", uint64(32), "Yes", "Yes", uint32(1), "PAD SPACE"},
   440  			{"ascii_bin", "ascii", uint64(65), "", "Yes", uint32(1), "PAD SPACE"},
   441  			{"ascii_general_ci", "ascii", uint64(11), "Yes", "Yes", uint32(1), "PAD SPACE"},
   442  		},
   443  	},
   444  	{
   445  		Query: `SELECT * FROM information_schema.COLLATION_CHARACTER_SET_APPLICABILITY ORDER BY collation_name LIMIT 4 `,
   446  		Expected: []sql.Row{
   447  			{"armscii8_bin", "armscii8"},
   448  			{"armscii8_general_ci", "armscii8"},
   449  			{"ascii_bin", "ascii"},
   450  			{"ascii_general_ci", "ascii"},
   451  		},
   452  	},
   453  	{
   454  		Query: `SELECT * FROM information_schema.ENGINES ORDER BY engine`,
   455  		Expected: []sql.Row{
   456  			{"InnoDB", "DEFAULT", "Supports transactions, row-level locking, and foreign keys", "YES", "YES", "YES"},
   457  		},
   458  	},
   459  	{
   460  		Query:    `SELECT * from information_schema.administrable_role_authorizations`,
   461  		Expected: []sql.Row{},
   462  	},
   463  	{
   464  		Query:    `SELECT * from information_schema.applicable_roles`,
   465  		Expected: []sql.Row{},
   466  	},
   467  	{
   468  		Query:    `SELECT * FROM information_schema.column_privileges`,
   469  		Expected: []sql.Row{},
   470  	},
   471  	{
   472  		Query:    `SELECT * FROM information_schema.optimizer_trace`,
   473  		Expected: []sql.Row{},
   474  	},
   475  	{
   476  		Query:    "SELECT * FROM information_schema.partitions",
   477  		Expected: []sql.Row{},
   478  	},
   479  	{
   480  		Query:    `SELECT * FROM information_schema.plugins`,
   481  		Expected: []sql.Row{},
   482  	},
   483  	{
   484  		Query:    `SELECT * FROM information_schema.profiling`,
   485  		Expected: []sql.Row{},
   486  	},
   487  	{
   488  		Query:    `SELECT * FROM information_schema.resource_groups`,
   489  		Expected: []sql.Row{},
   490  	},
   491  	{
   492  		Query:    `SELECT * FROM information_schema.role_column_grants`,
   493  		Expected: []sql.Row{},
   494  	},
   495  	{
   496  		Query:    `SELECT * FROM information_schema.role_routine_grants`,
   497  		Expected: []sql.Row{},
   498  	},
   499  	{
   500  		Query:    `SELECT * FROM information_schema.tablespaces`,
   501  		Expected: []sql.Row{},
   502  	},
   503  	{
   504  		Query:    `SELECT * FROM information_schema.tablespaces_extensions`,
   505  		Expected: []sql.Row{},
   506  	},
   507  	{
   508  		Query:    `SELECT * FROM information_schema.view_routine_usage`,
   509  		Expected: []sql.Row{},
   510  	},
   511  	{
   512  		Query:    `SELECT * FROM information_schema.view_table_usage`,
   513  		Expected: []sql.Row{},
   514  	},
   515  	{
   516  		Query:    `SELECT * from information_schema.innodb_buffer_page`,
   517  		Expected: []sql.Row{},
   518  	},
   519  	{
   520  		Query:    `SELECT * from information_schema.innodb_buffer_page_lru`,
   521  		Expected: []sql.Row{},
   522  	},
   523  	{
   524  		Query:    `SELECT * from information_schema.innodb_buffer_pool_stats`,
   525  		Expected: []sql.Row{},
   526  	},
   527  	{
   528  		Query:    `SELECT * from information_schema.innodb_cached_indexes`,
   529  		Expected: []sql.Row{},
   530  	},
   531  	{
   532  		Query:    `SELECT * from information_schema.innodb_cmp`,
   533  		Expected: []sql.Row{},
   534  	},
   535  	{
   536  		Query:    `SELECT * from information_schema.innodb_cmp_reset`,
   537  		Expected: []sql.Row{},
   538  	},
   539  	{
   540  		Query:    `SELECT * from information_schema.innodb_cmpmem`,
   541  		Expected: []sql.Row{},
   542  	},
   543  	{
   544  		Query:    `SELECT * from information_schema.innodb_cmpmem_reset`,
   545  		Expected: []sql.Row{},
   546  	},
   547  	{
   548  		Query:    `SELECT * from information_schema.innodb_cmp_per_index`,
   549  		Expected: []sql.Row{},
   550  	},
   551  	{
   552  		Query:    `SELECT * from information_schema.innodb_cmp_per_index_reset`,
   553  		Expected: []sql.Row{},
   554  	},
   555  	{
   556  		Query:    `SELECT * from information_schema.innodb_columns`,
   557  		Expected: []sql.Row{},
   558  	},
   559  	{
   560  		Query:    `SELECT * from information_schema.innodb_datafiles`,
   561  		Expected: []sql.Row{},
   562  	},
   563  	{
   564  		Query:    `SELECT * from information_schema.innodb_fields`,
   565  		Expected: []sql.Row{},
   566  	},
   567  	{
   568  		Query:    `SELECT * from information_schema.innodb_foreign`,
   569  		Expected: []sql.Row{},
   570  	},
   571  	{
   572  		Query:    `SELECT * from information_schema.innodb_foreign_cols`,
   573  		Expected: []sql.Row{},
   574  	},
   575  	{
   576  		Query:    `SELECT * from information_schema.innodb_ft_being_deleted`,
   577  		Expected: []sql.Row{},
   578  	},
   579  	{
   580  		Query:    `SELECT * from information_schema.innodb_ft_config`,
   581  		Expected: []sql.Row{},
   582  	},
   583  	{
   584  		Query:    `SELECT * from information_schema.innodb_ft_default_stopword`,
   585  		Expected: []sql.Row{},
   586  	},
   587  	{
   588  		Query:    `SELECT * from information_schema.innodb_ft_deleted`,
   589  		Expected: []sql.Row{},
   590  	},
   591  	{
   592  		Query:    `SELECT * from information_schema.innodb_ft_index_cache`,
   593  		Expected: []sql.Row{},
   594  	},
   595  	{
   596  		Query:    `SELECT * from information_schema.innodb_ft_index_table`,
   597  		Expected: []sql.Row{},
   598  	},
   599  	{
   600  		Query:    `SELECT * from information_schema.innodb_indexes`,
   601  		Expected: []sql.Row{},
   602  	},
   603  	{
   604  		Query:    `SELECT * from information_schema.innodb_metrics`,
   605  		Expected: []sql.Row{},
   606  	},
   607  	{
   608  		Query:    `SELECT * from information_schema.innodb_session_temp_tablespaces`,
   609  		Expected: []sql.Row{},
   610  	},
   611  	{
   612  		Query:    `SELECT * from information_schema.innodb_tables`,
   613  		Expected: []sql.Row{},
   614  	},
   615  	{
   616  		Query:    `SELECT * from information_schema.innodb_tablespaces`,
   617  		Expected: []sql.Row{},
   618  	},
   619  	{
   620  		Query:    `SELECT * from information_schema.innodb_tablespaces_brief`,
   621  		Expected: []sql.Row{},
   622  	},
   623  	{
   624  		Query:    `SELECT * from information_schema.innodb_tablestats`,
   625  		Expected: []sql.Row{},
   626  	},
   627  	{
   628  		Query:    `SELECT * from information_schema.innodb_temp_table_info`,
   629  		Expected: []sql.Row{},
   630  	},
   631  	{
   632  		Query:    `SELECT * from information_schema.innodb_trx`,
   633  		Expected: []sql.Row{},
   634  	},
   635  	{
   636  		Query:    `SELECT * from information_schema.innodb_virtual`,
   637  		Expected: []sql.Row{},
   638  	},
   639  	{
   640  		Query: `SELECT TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, SEQ_IN_INDEX, 'PRIMARY' AS PK_NAME 
   641  FROM INFORMATION_SCHEMA.STATISTICS WHERE TABLE_SCHEMA = 'mydb' AND INDEX_NAME='PRIMARY' ORDER BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME, SEQ_IN_INDEX;`,
   642  		Expected: []sql.Row{
   643  			{"mydb", "fk_tbl", "pk", 1, "PRIMARY"},
   644  			{"mydb", "mytable", "i", 1, "PRIMARY"},
   645  		},
   646  	},
   647  	{
   648  		Query:    "select * from information_schema.character_sets;",
   649  		Expected: []sql.Row{{"utf8mb4", "utf8mb4_0900_ai_ci", "UTF-8 Unicode", uint32(4)}},
   650  	},
   651  	{
   652  		Query: `show columns from fk_tbl from mydb`,
   653  		Expected: []sql.Row{
   654  			{"pk", "bigint", "NO", "PRI", "NULL", ""},
   655  			{"a", "bigint", "YES", "MUL", "NULL", ""},
   656  			{"b", "varchar(20)", "YES", "", "NULL", ""},
   657  		},
   658  	},
   659  	{
   660  		Query: "SELECT * FROM information_schema.referential_constraints where CONSTRAINT_SCHEMA = 'mydb'",
   661  		Expected: []sql.Row{
   662  			{"def", "mydb", "fk1", "def", "mydb", nil, "NONE", "NO ACTION", "CASCADE", "fk_tbl", "mytable"},
   663  		},
   664  	},
   665  	{
   666  		Query:    "SELECT count(*) FROM information_schema.keywords",
   667  		Expected: []sql.Row{{747}},
   668  	},
   669  	{
   670  		Query: "SELECT * FROM information_schema.st_spatial_reference_systems order by srs_id desc limit 10",
   671  		Expected: []sql.Row{
   672  			{`WGS 84 / TM 36 SE`, uint32(32766), `EPSG`, uint32(32766), `PROJCS["WGS 84 / TM 36 SE",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",36,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32766"]]`, nil},
   673  			{`WGS 84 / UPS South (N,E)`, uint32(32761), `EPSG`, uint32(32761), `PROJCS["WGS 84 / UPS South (N,E)",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Polar Stereographic (variant A)",AUTHORITY["EPSG","9810"]],PARAMETER["Latitude of natural origin",-90,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",0,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.994,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",2000000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",2000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["N",NORTH],AXIS["E",NORTH],AUTHORITY["EPSG","32761"]]`, nil},
   674  			{`WGS 84 / UTM zone 60S`, uint32(32760), `EPSG`, uint32(32760), `PROJCS["WGS 84 / UTM zone 60S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",177,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32760"]]`, nil},
   675  			{`WGS 84 / UTM zone 59S`, uint32(32759), `EPSG`, uint32(32759), `PROJCS["WGS 84 / UTM zone 59S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",171,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32759"]]`, nil},
   676  			{`WGS 84 / UTM zone 58S`, uint32(32758), `EPSG`, uint32(32758), `PROJCS["WGS 84 / UTM zone 58S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",165,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32758"]]`, nil},
   677  			{`WGS 84 / UTM zone 57S`, uint32(32757), `EPSG`, uint32(32757), `PROJCS["WGS 84 / UTM zone 57S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",159,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32757"]]`, nil},
   678  			{`WGS 84 / UTM zone 56S`, uint32(32756), `EPSG`, uint32(32756), `PROJCS["WGS 84 / UTM zone 56S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",153,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32756"]]`, nil},
   679  			{`WGS 84 / UTM zone 55S`, uint32(32755), `EPSG`, uint32(32755), `PROJCS["WGS 84 / UTM zone 55S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",147,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32755"]]`, nil},
   680  			{`WGS 84 / UTM zone 54S`, uint32(32754), `EPSG`, uint32(32754), `PROJCS["WGS 84 / UTM zone 54S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",141,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32754"]]`, nil},
   681  			{`WGS 84 / UTM zone 53S`, uint32(32753), `EPSG`, uint32(32753), `PROJCS["WGS 84 / UTM zone 53S",GEOGCS["WGS 84",DATUM["World Geodetic System 1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.017453292519943278,AUTHORITY["EPSG","9122"]],AXIS["Lat",NORTH],AXIS["Lon",EAST],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse Mercator",AUTHORITY["EPSG","9807"]],PARAMETER["Latitude of natural origin",0,AUTHORITY["EPSG","8801"]],PARAMETER["Longitude of natural origin",135,AUTHORITY["EPSG","8802"]],PARAMETER["Scale factor at natural origin",0.9996,AUTHORITY["EPSG","8805"]],PARAMETER["False easting",500000,AUTHORITY["EPSG","8806"]],PARAMETER["False northing",10000000,AUTHORITY["EPSG","8807"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["E",EAST],AXIS["N",NORTH],AUTHORITY["EPSG","32753"]]`, nil},
   682  		},
   683  	},
   684  	{
   685  		Query:    "SELECT count(*) FROM information_schema.st_units_of_measure",
   686  		Expected: []sql.Row{{47}},
   687  	},
   688  	{
   689  		Query:    "SELECT * FROM information_schema.schemata_extensions",
   690  		Expected: []sql.Row{{"def", "information_schema", ""}, {"def", "foo", ""}, {"def", "mydb", ""}},
   691  	},
   692  	{
   693  		Query:    `SELECT * FROM information_schema.columns_extensions where table_name = 'mytable'`,
   694  		Expected: []sql.Row{{"def", "mydb", "mytable", "i", nil, nil}, {"def", "mydb", "mytable", "s", nil, nil}},
   695  	},
   696  	{
   697  		Query:    `SELECT * FROM information_schema.table_constraints_extensions where table_name = 'fk_tbl'`,
   698  		Expected: []sql.Row{{"def", "mydb", "PRIMARY", "fk_tbl", nil, nil}, {"def", "mydb", "ab", "fk_tbl", nil, nil}},
   699  	},
   700  	{
   701  		Query:    `SELECT * FROM information_schema.tables_extensions where table_name = 'mytable'`,
   702  		Expected: []sql.Row{{"def", "mydb", "mytable", nil, nil}},
   703  	},
   704  	{
   705  		Query:    "SELECT table_rows FROM INFORMATION_SCHEMA.TABLES where table_name='mytable'",
   706  		Expected: []sql.Row{{uint64(3)}},
   707  	},
   708  	{
   709  		Query:    "select table_name from information_schema.tables where table_schema collate utf8_general_ci = 'information_schema' and table_name collate utf8_general_ci = 'parameters'",
   710  		Expected: []sql.Row{{"parameters"}},
   711  	},
   712  }
   713  
   714  var SkippedInfoSchemaQueries = []QueryTest{
   715  	{
   716  		// TODO: this query works in MySQL, but getting `Illegal mix of collations (utf8mb3_general_ci) and (utf8mb4_0900_bin)` error
   717  		Query: `
   718  		SELECT COLUMN_NAME AS COLUMN_NAME FROM information_schema.COLUMNS
   719  		WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
   720  		GROUP BY 1 HAVING SUBSTRING(COLUMN_NAME, 1, 1) = "s"
   721  		`,
   722  		Expected: []sql.Row{{"s"}},
   723  	},
   724  }
   725  
   726  var InfoSchemaScripts = []ScriptTest{
   727  	{
   728  		Name: "foreign key that references dropped table",
   729  		SetUpScript: []string{
   730  			"create table parent(a int primary key, b int);",
   731  			"create table child(c int primary key);",
   732  			"alter table child add foreign key (c) references parent(a);",
   733  		},
   734  		Assertions: []ScriptTestAssertion{
   735  			{
   736  				Query:    "select UNIQUE_CONSTRAINT_NAME from information_schema.referential_constraints where TABLE_NAME = 'child' and REFERENCED_TABLE_NAME = 'parent';",
   737  				Expected: []sql.Row{{"PRIMARY"}},
   738  			},
   739  			{
   740  				Query:    "select REFERENCED_COLUMN_NAME from information_schema.key_column_usage where TABLE_NAME = 'child' and REFERENCED_TABLE_NAME = 'parent';",
   741  				Expected: []sql.Row{{"a"}},
   742  			},
   743  			{
   744  				Query: "set foreign_key_checks=0;",
   745  			},
   746  			{
   747  				Query: "drop table parent;",
   748  			},
   749  			{
   750  				Query:    "insert into child values (1), (2);",
   751  				Expected: []sql.Row{{types.OkResult{RowsAffected: 2}}},
   752  			},
   753  			{
   754  				Query:    "select * from child;",
   755  				Expected: []sql.Row{{1}, {2}},
   756  			},
   757  			{
   758  				Query:    "delete from child;",
   759  				Expected: []sql.Row{{types.OkResult{RowsAffected: 2}}},
   760  			},
   761  			{
   762  				Query:    "select * from child;",
   763  				Expected: []sql.Row{},
   764  			},
   765  			{
   766  				Query: "set foreign_key_checks=1;",
   767  			},
   768  			{
   769  				Query:       "insert into child values (1), (2);",
   770  				ExpectedErr: sql.ErrForeignKeyNotResolved,
   771  			},
   772  			{
   773  				Query:    "select UNIQUE_CONSTRAINT_NAME from information_schema.referential_constraints where TABLE_NAME = 'child' and REFERENCED_TABLE_NAME = 'parent';",
   774  				Expected: []sql.Row{{nil}},
   775  			},
   776  			{
   777  				Query:    "select REFERENCED_COLUMN_NAME from information_schema.key_column_usage where TABLE_NAME = 'child' and REFERENCED_TABLE_NAME = 'parent';",
   778  				Expected: []sql.Row{{"a"}},
   779  			},
   780  		},
   781  	},
   782  	{
   783  		Name: "query does not use optimization rule on LIKE clause because info_schema db charset is utf8mb3",
   784  		SetUpScript: []string{
   785  			"CREATE TABLE t1 (a int, condition_choose varchar(10));",
   786  		},
   787  		Assertions: []ScriptTestAssertion{
   788  			{
   789  				Query:    "select column_name from information_schema.columns where column_name like 'condition%';",
   790  				Expected: []sql.Row{{"condition_choose"}},
   791  			},
   792  			{
   793  				Query:    "select column_name from information_schema.columns where column_name like '%condition%';",
   794  				Expected: []sql.Row{{"ACTION_CONDITION"}, {"condition_choose"}},
   795  			},
   796  		},
   797  	},
   798  	{
   799  		Name: "test databases created with non default collation and charset",
   800  		SetUpScript: []string{
   801  			"CREATE DATABASE test_db CHARACTER SET utf8mb3 COLLATE utf8mb3_bin;",
   802  			"USE test_db",
   803  			"CREATE TABLE small_table (a binary, b VARCHAR(50));",
   804  			"CREATE TABLE test_table (id INT PRIMARY KEY, col1 TEXT, col2 CHAR(20) CHARACTER SET latin1 COLLATE latin1_german1_ci) CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;",
   805  		},
   806  		Assertions: []ScriptTestAssertion{
   807  			{
   808  				Query: "SELECT table_schema, table_name, column_name, character_set_name, collation_name, column_type FROM information_schema.columns where table_schema = 'test_db' order by column_name",
   809  				Expected: []sql.Row{
   810  					{"test_db", "small_table", "a", nil, nil, "binary(1)"},
   811  					{"test_db", "small_table", "b", "utf8mb3", "utf8mb3_bin", "varchar(50)"},
   812  					{"test_db", "test_table", "col1", "utf8mb4", "utf8mb4_0900_bin", "text"},
   813  					{"test_db", "test_table", "col2", "latin1", "latin1_german1_ci", "char(20)"},
   814  					{"test_db", "test_table", "id", nil, nil, "int"},
   815  				},
   816  			},
   817  		},
   818  	},
   819  	{
   820  		Name: "information_schema.table_constraints ignores non-unique indexes",
   821  		SetUpScript: []string{
   822  			"CREATE TABLE t (pk int primary key, test_score int, height int)",
   823  			"CREATE INDEX myindex on t(test_score)",
   824  		},
   825  		Assertions: []ScriptTestAssertion{
   826  			{
   827  				Query: "SELECT * FROM information_schema.table_constraints where table_name='t' ORDER BY constraint_type,constraint_name",
   828  				Expected: []sql.Row{
   829  					{"def", "mydb", "PRIMARY", "mydb", "t", "PRIMARY KEY", "YES"},
   830  				},
   831  			},
   832  		},
   833  	},
   834  	{
   835  		Name: "information_schema.key_column_usage ignores non-unique indexes",
   836  		SetUpScript: []string{
   837  			"CREATE TABLE t (pk int primary key, test_score int, height int)",
   838  			"CREATE INDEX myindex on t(test_score)",
   839  		},
   840  		Assertions: []ScriptTestAssertion{
   841  			{
   842  				Query: "SELECT * FROM information_schema.key_column_usage where table_name='t'",
   843  				Expected: []sql.Row{
   844  					{"def", "mydb", "PRIMARY", "def", "mydb", "t", "pk", 1, nil, nil, nil, nil},
   845  				},
   846  			},
   847  		},
   848  	},
   849  	{
   850  		Name: "information_schema.key_column_usage works with composite foreign and primary keys",
   851  		SetUpScript: []string{
   852  			"CREATE TABLE ptable (pk int primary key, test_score int, height int)",
   853  			"CREATE INDEX myindex on ptable(test_score, height)",
   854  			"CREATE TABLE ptable2 (pk int primary key, test_score2 int, height2 int, CONSTRAINT fkr FOREIGN KEY (test_score2, height2) REFERENCES ptable(test_score,height));",
   855  
   856  			"CREATE TABLE atable (pk int, test_score int, height int, PRIMARY KEY (pk, test_score))",
   857  		},
   858  		Assertions: []ScriptTestAssertion{
   859  			{
   860  				Query: "SELECT * FROM information_schema.key_column_usage where table_name='ptable2' ORDER BY constraint_name",
   861  				Expected: []sql.Row{
   862  					{"def", "mydb", "fkr", "def", "mydb", "ptable2", "test_score2", 1, 1, "mydb", "ptable", "test_score"},
   863  					{"def", "mydb", "fkr", "def", "mydb", "ptable2", "height2", 2, 2, "mydb", "ptable", "height"},
   864  					{"def", "mydb", "PRIMARY", "def", "mydb", "ptable2", "pk", 1, nil, nil, nil, nil},
   865  				},
   866  			},
   867  			{
   868  				Query: "SELECT * FROM information_schema.key_column_usage where table_name='atable' ORDER BY constraint_name",
   869  				Expected: []sql.Row{
   870  					{"def", "mydb", "PRIMARY", "def", "mydb", "atable", "pk", 1, nil, nil, nil, nil},
   871  					{"def", "mydb", "PRIMARY", "def", "mydb", "atable", "test_score", 2, nil, nil, nil, nil},
   872  				},
   873  			},
   874  		},
   875  	},
   876  	{
   877  		Name: "information_schema.referential_constraints works with primary, non-unique and unique keys",
   878  		SetUpScript: []string{
   879  			"CREATE TABLE my_table (i int primary key, height int, weight int)",
   880  			"CREATE INDEX h on my_TABLE(height)",
   881  			"CREATE UNIQUE INDEX w on my_TABLE(weight)",
   882  			"CREATE TABLE ref_table (a int primary key, height int, weight int)",
   883  			"alter table ref_table add constraint fk_across_dbs_ref_pk foreign key (a) references my_table(i)",
   884  			"alter table ref_table add constraint fk_across_dbs_key foreign key (a) references my_table(height)",
   885  			"alter table ref_table add constraint fk_across_dbs_unique foreign key (a) references my_table(weight)",
   886  		},
   887  		Assertions: []ScriptTestAssertion{
   888  			{
   889  				Query: "SELECT * FROM information_schema.referential_constraints where constraint_schema = 'mydb' and table_name = 'ref_table'",
   890  				Expected: []sql.Row{
   891  					{"def", "mydb", "fk_across_dbs_ref_pk", "def", "mydb", "PRIMARY", "NONE", "NO ACTION", "NO ACTION", "ref_table", "my_table"},
   892  					{"def", "mydb", "fk_across_dbs_key", "def", "mydb", nil, "NONE", "NO ACTION", "NO ACTION", "ref_table", "my_table"},
   893  					{"def", "mydb", "fk_across_dbs_unique", "def", "mydb", "w", "NONE", "NO ACTION", "NO ACTION", "ref_table", "my_table"},
   894  				},
   895  			},
   896  		},
   897  	},
   898  	{
   899  		Name: "information_schema.triggers create trigger definer defined",
   900  		SetUpScript: []string{
   901  			"CREATE TABLE aa (x INT PRIMARY KEY, y INT)",
   902  			"CREATE DEFINER=`dolt`@`localhost` TRIGGER trigger1 BEFORE INSERT ON aa FOR EACH ROW SET NEW.x = NEW.x + 1",
   903  			"CREATE TRIGGER trigger2 BEFORE INSERT ON aa FOR EACH ROW SET NEW.y = NEW.y + 2",
   904  		},
   905  		Assertions: []ScriptTestAssertion{
   906  			{
   907  				Query: "SELECT trigger_name, event_object_table, definer FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_name = 'trigger1'",
   908  				Expected: []sql.Row{
   909  					{"trigger1", "aa", "dolt@localhost"},
   910  				},
   911  			},
   912  			{
   913  				Query: `SELECT trigger_catalog, trigger_schema, trigger_name, event_manipulation, event_object_catalog,
   914  event_object_schema, event_object_table, action_order, action_condition, action_statement, action_orientation, action_timing,
   915  action_reference_old_table, action_reference_new_table, action_reference_old_row, action_reference_new_row, sql_mode, definer,
   916  character_set_client, collation_connection, database_collation
   917  FROM INFORMATION_SCHEMA.TRIGGERS WHERE trigger_schema = 'mydb'`,
   918  				Expected: []sql.Row{
   919  					{"def", "mydb", "trigger1", "INSERT", "def", "mydb", "aa", 1, nil, "SET NEW.x = NEW.x + 1", "ROW", "BEFORE", nil, nil, "OLD", "NEW",
   920  						"NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES", "dolt@localhost", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
   921  					{"def", "mydb", "trigger2", "INSERT", "def", "mydb", "aa", 2, nil, "SET NEW.y = NEW.y + 2", "ROW", "BEFORE", nil, nil, "OLD", "NEW",
   922  						"NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES", "root@localhost", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
   923  				},
   924  			},
   925  		},
   926  	},
   927  	{
   928  		Name: "information_schema.statistics shows non unique index",
   929  		SetUpScript: []string{
   930  			"CREATE TABLE t (pk int primary key, test_score int, height int)",
   931  			"CREATE INDEX myindex on t(test_score)",
   932  			"INSERT INTO t VALUES (2,23,25), (3,24,26)",
   933  		},
   934  		Assertions: []ScriptTestAssertion{
   935  			{
   936  				Query: "SELECT * FROM information_schema.statistics where table_name='t'",
   937  				Expected: []sql.Row{
   938  					{"def", "mydb", "t", 1, "mydb", "myindex", 1, "test_score", "A", 0, nil, nil, "YES", "BTREE", "", "", "YES", nil},
   939  					{"def", "mydb", "t", 0, "mydb", "PRIMARY", 1, "pk", "A", 0, nil, nil, "", "BTREE", "", "", "YES", nil},
   940  				},
   941  			},
   942  		},
   943  	},
   944  	{
   945  		Name: "information_schema.columns shows default value",
   946  		SetUpScript: []string{
   947  			"CREATE TABLE t (pk int primary key, fname varchar(20), lname varchar(20), height int)",
   948  			"ALTER TABLE t CHANGE fname fname varchar(20) NOT NULL DEFAULT ''",
   949  			"ALTER TABLE t CHANGE lname lname varchar(20) NOT NULL DEFAULT 'ln'",
   950  			"ALTER TABLE t CHANGE height h int DEFAULT NULL",
   951  		},
   952  		Assertions: []ScriptTestAssertion{
   953  			{
   954  				Query: "SELECT table_name, column_name, column_default, is_nullable FROM information_schema.columns where table_name='t' order by 1,2",
   955  				Expected: []sql.Row{
   956  					{"t", "fname", "", "NO"},
   957  					{"t", "h", nil, "YES"},
   958  					{"t", "lname", "ln", "NO"},
   959  					{"t", "pk", nil, "NO"},
   960  				},
   961  			},
   962  		},
   963  	},
   964  	{
   965  		Name: "information_schema.columns shows default value with more types",
   966  		SetUpScript: []string{
   967  			"CREATE TABLE test_table (pk int primary key, col2 float NOT NULL DEFAULT 4.5, col3 double NOT NULL DEFAULT 3.14159, col4 datetime NULL DEFAULT '2008-04-22 16:16:16', col5 boolean NULL DEFAULT FALSE)",
   968  		},
   969  		Assertions: []ScriptTestAssertion{
   970  			{
   971  				Query: "SELECT table_name, column_name, column_default, is_nullable FROM information_schema.CoLuMnS where table_name='test_table'",
   972  				Expected: []sql.Row{
   973  					{"test_table", "pk", nil, "NO"},
   974  					{"test_table", "col2", "4.5", "NO"},
   975  					{"test_table", "col3", "3.14159", "NO"},
   976  					{"test_table", "col4", "2008-04-22 16:16:16", "YES"},
   977  					{"test_table", "col5", "0", "YES"},
   978  				},
   979  			},
   980  		},
   981  	},
   982  	{
   983  		Name: "information_schema.columns shows default value with more types",
   984  		SetUpScript: []string{
   985  			"CREATE TABLE test_table (pk int primary key, col2 float DEFAULT (length('he`Llo')), col3 int DEFAULT (greatest(`pk`, 2)), col4 int DEFAULT (5 + 5), col5 datetime default NOW(), create_time timestamp(6) NOT NULL DEFAULT NOW(6));",
   986  		},
   987  		Assertions: []ScriptTestAssertion{
   988  			{
   989  				Query: "SELECT table_name, column_name, column_default, is_nullable FROM information_schema.columns where table_name='test_table'",
   990  				Expected: []sql.Row{
   991  					{"test_table", "pk", nil, "NO"},
   992  					{"test_table", "col2", "length('he`Llo')", "YES"},
   993  					{"test_table", "col3", "greatest(`pk`,2)", "YES"},
   994  					{"test_table", "col4", "(5 + 5)", "YES"},
   995  					{"test_table", "col5", "CURRENT_TIMESTAMP", "YES"},
   996  					{"test_table", "create_time", "CURRENT_TIMESTAMP(6)", "NO"},
   997  				},
   998  			},
   999  		},
  1000  	},
  1001  	{
  1002  		Name: "information_schema.columns correctly shows numeric precision and scale for a wide variety of types",
  1003  		SetUpScript: []string{
  1004  			"CREATE TABLE `digits` (`c0` tinyint,`c1` tinyint unsigned,`c2` smallint,`c3` smallint unsigned,`c4` mediumint,`c5` mediumint unsigned,`c6` int,`c7` int unsigned,`c8` bigint,`c9` bigint unsigned,`c10` float,`c11` dec(5,2),`st` varchar(100))",
  1005  		},
  1006  		Assertions: []ScriptTestAssertion{
  1007  			{
  1008  				Query: "select column_name, numeric_precision, numeric_scale from information_schema.columns where table_name='digits' order by ordinal_position;",
  1009  				Expected: []sql.Row{
  1010  					{"c0", 3, 0},
  1011  					{"c1", 3, 0},
  1012  					{"c2", 5, 0},
  1013  					{"c3", 5, 0},
  1014  					{"c4", 7, 0},
  1015  					{"c5", 7, 0},
  1016  					{"c6", 10, 0},
  1017  					{"c7", 10, 0},
  1018  					{"c8", 19, 0},
  1019  					{"c9", 20, 0},
  1020  					{"c10", 12, nil},
  1021  					{"c11", 5, 2},
  1022  					{"st", nil, nil},
  1023  				},
  1024  			},
  1025  		},
  1026  	},
  1027  	{
  1028  		Name: "information_schema.routines",
  1029  		SetUpScript: []string{
  1030  			"CREATE PROCEDURE p1() COMMENT 'hi' DETERMINISTIC SELECT 6",
  1031  			"CREATE definer=`user` PROCEDURE p2() SQL SECURITY INVOKER SELECT 7",
  1032  			"CREATE PROCEDURE p21() SQL SECURITY DEFINER SELECT 8",
  1033  			"USE foo",
  1034  			"CREATE PROCEDURE p12() COMMENT 'hello' DETERMINISTIC SELECT 6",
  1035  		},
  1036  		Assertions: []ScriptTestAssertion{
  1037  			{
  1038  				Query: "SELECT specific_name, routine_catalog, routine_schema, routine_name, routine_type, " +
  1039  					"data_type, character_maximum_length, character_octet_length, numeric_precision, numeric_scale, " +
  1040  					"datetime_precision, character_set_name, collation_name, dtd_identifier, " +
  1041  					"routine_body, external_name, external_language, parameter_style, is_deterministic, " +
  1042  					"sql_data_access, sql_path, security_type, sql_mode, routine_comment, definer, " +
  1043  					"character_set_client, collation_connection, database_collation FROM information_schema.routines order by routine_name",
  1044  				Expected: []sql.Row{
  1045  					{"p1", "def", "mydb", "p1", "PROCEDURE", "", nil, nil, nil, nil, nil, nil, nil, nil, "SQL",
  1046  						nil, "SQL", "SQL", "YES", "CONTAINS SQL", nil, "DEFINER", "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1047  						"hi", "", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
  1048  					{"p12", "def", "foo", "p12", "PROCEDURE", "", nil, nil, nil, nil, nil, nil, nil, nil, "SQL",
  1049  						nil, "SQL", "SQL", "YES", "CONTAINS SQL", nil, "DEFINER", "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1050  						"hello", "", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
  1051  					{"p2", "def", "mydb", "p2", "PROCEDURE", "", nil, nil, nil, nil, nil, nil, nil, nil, "SQL",
  1052  						nil, "SQL", "SQL", "NO", "CONTAINS SQL", nil, "INVOKER", "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1053  						"", "user@%", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
  1054  					{"p21", "def", "mydb", "p21", "PROCEDURE", "", nil, nil, nil, nil, nil, nil, nil, nil, "SQL",
  1055  						nil, "SQL", "SQL", "NO", "CONTAINS SQL", nil, "DEFINER", "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1056  						"", "", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
  1057  				},
  1058  			},
  1059  		},
  1060  	},
  1061  	{
  1062  		Name: "information_schema.columns for view",
  1063  		SetUpScript: []string{
  1064  			"USE foo",
  1065  			"drop table othertable",
  1066  			"CREATE TABLE t (i int)",
  1067  			"CREATE VIEW v as select * from t",
  1068  		},
  1069  		Assertions: []ScriptTestAssertion{
  1070  			{
  1071  				Query: "SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE table_schema = 'foo'",
  1072  				Expected: []sql.Row{
  1073  					{"def", "foo", "t", "i", uint32(1), nil, "YES", "int", nil, nil, int64(10), int64(0), nil, nil, nil, "int", "", "", "insert,references,select,update", "", "", nil},
  1074  					{"def", "foo", "v", "", uint32(0), nil, "", nil, nil, nil, nil, nil, nil, "", "", "", "", "", "select", "", "", nil},
  1075  				},
  1076  			},
  1077  		},
  1078  	},
  1079  	{
  1080  		Name: "information_schema.columns with column key check for PRI and UNI",
  1081  		SetUpScript: []string{
  1082  			"CREATE TABLE about (id int unsigned NOT NULL AUTO_INCREMENT, uuid char(36) NOT NULL, " +
  1083  				"status varchar(255) NOT NULL DEFAULT 'draft', date_created timestamp DEFAULT NULL, date_updated timestamp DEFAULT NULL, " +
  1084  				"url_key varchar(255) NOT NULL, PRIMARY KEY (uuid), UNIQUE KEY about_url_key_unique (url_key), UNIQUE KEY id (id))",
  1085  		},
  1086  		Assertions: []ScriptTestAssertion{
  1087  			{
  1088  				Query: "SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, COLUMN_TYPE, COLUMN_KEY, CHARACTER_MAXIMUM_LENGTH, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'about'",
  1089  				Expected: []sql.Row{
  1090  					{"about", "id", nil, "NO", "int unsigned", "UNI", nil, "auto_increment"},
  1091  					{"about", "uuid", nil, "NO", "char(36)", "PRI", 36, ""},
  1092  					{"about", "status", "draft", "NO", "varchar(255)", "", 255, ""},
  1093  					{"about", "date_created", nil, "YES", "timestamp", "", nil, ""},
  1094  					{"about", "date_updated", nil, "YES", "timestamp", "", nil, ""},
  1095  					{"about", "url_key", nil, "NO", "varchar(255)", "UNI", 255, ""},
  1096  				},
  1097  			},
  1098  		},
  1099  	},
  1100  	{
  1101  		Name: "information_schema.columns with column key check for MUL",
  1102  		SetUpScript: []string{
  1103  			"create table new_table (id int, name varchar(30), cname varbinary(100));",
  1104  			"alter table new_table modify column id int NOT NULL, add key(id);",
  1105  		},
  1106  		Assertions: []ScriptTestAssertion{
  1107  			{
  1108  				Query: "SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE, COLUMN_TYPE, COLUMN_KEY, CHARACTER_MAXIMUM_LENGTH, EXTRA FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'new_table'",
  1109  				Expected: []sql.Row{
  1110  					{"new_table", "id", "NO", "int", "int", "MUL", nil, ""},
  1111  					{"new_table", "name", "YES", "varchar", "varchar(30)", "", 30, ""},
  1112  					{"new_table", "cname", "YES", "varbinary", "varbinary(100)", "", 100, ""},
  1113  				},
  1114  			},
  1115  		},
  1116  	},
  1117  	{
  1118  		Name: "information_schema.columns with column key check for MUL for only the first column of composite unique key",
  1119  		SetUpScript: []string{
  1120  			"create table comp_uni (pk int not null, c0 int, c1 int, primary key (pk), unique key c0c1 (c0, c1));",
  1121  		},
  1122  		Assertions: []ScriptTestAssertion{
  1123  			{
  1124  				Query: "SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, COLUMN_TYPE, COLUMN_KEY FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'comp_uni'",
  1125  				Expected: []sql.Row{
  1126  					{"comp_uni", "pk", "NO", "int", "PRI"},
  1127  					{"comp_uni", "c0", "YES", "int", "MUL"},
  1128  					{"comp_uni", "c1", "YES", "int", ""},
  1129  				},
  1130  			},
  1131  		},
  1132  	},
  1133  	{
  1134  		Name: "information_schema.columns with column key UNI is displayed as PRI if it cannot contain NULL values and there is no PRIMARY KEY in the table",
  1135  		SetUpScript: []string{
  1136  			"create table ptable (id int not null, id2 int not null, col1 bool, UNIQUE KEY unique_key (id), UNIQUE KEY unique_key2 (id2));",
  1137  		},
  1138  		Assertions: []ScriptTestAssertion{
  1139  			{
  1140  				Query: "SELECT TABLE_NAME, COLUMN_NAME, IS_NULLABLE, DATA_TYPE, COLUMN_TYPE, COLUMN_KEY FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'ptable'",
  1141  				Expected: []sql.Row{
  1142  					{"ptable", "id", "NO", "int", "int", "PRI"},
  1143  					{"ptable", "id2", "NO", "int", "int", "UNI"},
  1144  					{"ptable", "col1", "YES", "tinyint", "tinyint(1)", ""},
  1145  				},
  1146  			},
  1147  		},
  1148  	},
  1149  	{
  1150  		Name: "information_schema.columns with srs_id defined in spatial columns",
  1151  		SetUpScript: []string{
  1152  			"CREATE TABLE stable (geo GEOMETRY NOT NULL DEFAULT (POINT(2, 5)), line LINESTRING NOT NULL, pnt POINT SRID 4326, pol POLYGON NOT NULL SRID 0);",
  1153  		},
  1154  		Assertions: []ScriptTestAssertion{
  1155  			{
  1156  				Query: "SELECT TABLE_NAME, COLUMN_NAME, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, COLUMN_TYPE, COLUMN_KEY, SRS_ID FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'stable'",
  1157  				Expected: []sql.Row{
  1158  					{"stable", "geo", "point(2,5)", "NO", "geometry", "geometry", "", nil},
  1159  					{"stable", "line", nil, "NO", "linestring", "linestring", "", nil},
  1160  					{"stable", "pnt", nil, "YES", "point", "point", "", uint32(4326)},
  1161  					{"stable", "pol", nil, "NO", "polygon", "polygon", "", uint32(0)},
  1162  				},
  1163  			},
  1164  		},
  1165  	},
  1166  	{
  1167  		Name: "column specific tests information_schema.statistics table",
  1168  		SetUpScript: []string{
  1169  			`create table ptable (i int primary key, b blob, c char(10))`,
  1170  			`alter table ptable add unique index (c(3))`,
  1171  			`alter table ptable add unique index (b(4))`,
  1172  			`create index b_and_c on ptable (b(5), c(6))`,
  1173  			`insert into ptable values (0 , ('abc'), 'abc'), (1 , ('bcd'), 'bcdefg'), (2 , null, 'bceff')`,
  1174  		},
  1175  		Assertions: []ScriptTestAssertion{
  1176  			{
  1177  				Query: `select index_name, seq_in_index, column_name, sub_part from information_schema.statistics where table_schema = 'mydb' and table_name = 'ptable' ORDER BY INDEX_NAME`,
  1178  				Expected: []sql.Row{
  1179  					{"b", 1, "b", 4},
  1180  					{"b_and_c", 1, "b", 5},
  1181  					{"b_and_c", 2, "c", 6},
  1182  					{"c", 1, "c", 3},
  1183  					{"PRIMARY", 1, "i", nil},
  1184  				},
  1185  			},
  1186  			{
  1187  				// TODO: cardinality not supported
  1188  				Skip:     true,
  1189  				Query:    `select index_name, seq_in_index, column_name, cardinality, sub_part from information_schema.statistics where table_schema = 'mydb' and table_name = 'ptable' ORDER BY INDEX_NAME`,
  1190  				Expected: []sql.Row{{2}, {2}, {2}, {2}, {2}},
  1191  			},
  1192  			{
  1193  				Query: `SELECT seq_in_index, sub_part, index_name, index_type, CASE non_unique WHEN 0 THEN 'TRUE' ELSE 'FALSE' END AS is_unique, column_name
  1194  	FROM information_schema.statistics WHERE table_schema='mydb' AND table_name='ptable' ORDER BY index_name, seq_in_index;`,
  1195  				Expected: []sql.Row{
  1196  					{1, 4, "b", "BTREE", "TRUE", "b"},
  1197  					{1, 5, "b_and_c", "BTREE", "FALSE", "b"},
  1198  					{2, 6, "b_and_c", "BTREE", "FALSE", "c"},
  1199  					{1, 3, "c", "BTREE", "TRUE", "c"},
  1200  					{1, nil, "PRIMARY", "BTREE", "TRUE", "i"},
  1201  				},
  1202  			},
  1203  		},
  1204  	},
  1205  	{
  1206  		Name: "column specific tests on information_schema.columns table",
  1207  		SetUpScript: []string{
  1208  			`CREATE TABLE all_types (
  1209  pk int NOT NULL,
  1210  binary_1 binary(1) DEFAULT "1",
  1211  big_int bigint DEFAULT "1",
  1212  bit_2 bit(2) DEFAULT 2,
  1213  some_blob blob DEFAULT ("abc"),
  1214  char_1 char(1) DEFAULT "A",
  1215  some_date date DEFAULT "2022-02-22",
  1216  date_time datetime(6) DEFAULT "2022-02-22 22:22:21",
  1217  decimal_52 decimal(5,2) DEFAULT "994.45",
  1218  some_double double DEFAULT "1.1",
  1219  some_enum enum('s','m','l') DEFAULT "s",
  1220  some_float float DEFAULT "4.4",
  1221  some_geometry geometry srid 4326 DEFAULT (POINT(1, 2)),
  1222  some_int int DEFAULT "3",
  1223  some_json json DEFAULT (JSON_OBJECT("a", 1)),
  1224  line_string linestring DEFAULT (LINESTRING(POINT(0, 0),POINT(1, 2))),
  1225  long_blob longblob DEFAULT ("abc"),
  1226  long_text longtext DEFAULT ("abc"),
  1227  medium_blob mediumblob DEFAULT ("abc"),
  1228  medium_int mediumint DEFAULT "7",
  1229  medium_text mediumtext DEFAULT ("abc"),
  1230  some_point point DEFAULT (POINT(2, 2)),
  1231  some_polygon polygon DEFAULT NULL,
  1232  some_set set('one','two') DEFAULT "one,two",
  1233  small_int smallint DEFAULT "5",
  1234  some_text text DEFAULT ("abc"),
  1235  time_6 time(6) DEFAULT "11:59:59.000010",
  1236  time_stamp timestamp(6) DEFAULT (CURRENT_TIMESTAMP()),
  1237  tiny_blob tinyblob DEFAULT ("abc"),
  1238  tiny_int tinyint DEFAULT "4",
  1239  tiny_text tinytext DEFAULT ("abc"),
  1240  var_char varchar(255) DEFAULT "varchar value",
  1241  var_binary varbinary(255) DEFAULT "11111",
  1242  some_year year DEFAULT "2023",
  1243  PRIMARY KEY (pk)
  1244  ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_bin;`,
  1245  		},
  1246  		Assertions: []ScriptTestAssertion{
  1247  			{
  1248  				Query: `SELECT table_catalog, table_schema, table_name, column_name, ordinal_position
  1249  FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='all_types' ORDER BY ORDINAL_POSITION`,
  1250  				Expected: []sql.Row{
  1251  					{"def", "mydb", "all_types", "pk", uint32(1)},
  1252  					{"def", "mydb", "all_types", "binary_1", uint32(2)},
  1253  					{"def", "mydb", "all_types", "big_int", uint32(3)},
  1254  					{"def", "mydb", "all_types", "bit_2", uint32(4)},
  1255  					{"def", "mydb", "all_types", "some_blob", uint32(5)},
  1256  					{"def", "mydb", "all_types", "char_1", uint32(6)},
  1257  					{"def", "mydb", "all_types", "some_date", uint32(7)},
  1258  					{"def", "mydb", "all_types", "date_time", uint32(8)},
  1259  					{"def", "mydb", "all_types", "decimal_52", uint32(9)},
  1260  					{"def", "mydb", "all_types", "some_double", uint32(10)},
  1261  					{"def", "mydb", "all_types", "some_enum", uint32(11)},
  1262  					{"def", "mydb", "all_types", "some_float", uint32(12)},
  1263  					{"def", "mydb", "all_types", "some_geometry", uint32(13)},
  1264  					{"def", "mydb", "all_types", "some_int", uint32(14)},
  1265  					{"def", "mydb", "all_types", "some_json", uint32(15)},
  1266  					{"def", "mydb", "all_types", "line_string", uint32(16)},
  1267  					{"def", "mydb", "all_types", "long_blob", uint32(17)},
  1268  					{"def", "mydb", "all_types", "long_text", uint32(18)},
  1269  					{"def", "mydb", "all_types", "medium_blob", uint32(19)},
  1270  					{"def", "mydb", "all_types", "medium_int", uint32(20)},
  1271  					{"def", "mydb", "all_types", "medium_text", uint32(21)},
  1272  					{"def", "mydb", "all_types", "some_point", uint32(22)},
  1273  					{"def", "mydb", "all_types", "some_polygon", uint32(23)},
  1274  					{"def", "mydb", "all_types", "some_set", uint32(24)},
  1275  					{"def", "mydb", "all_types", "small_int", uint32(25)},
  1276  					{"def", "mydb", "all_types", "some_text", uint32(26)},
  1277  					{"def", "mydb", "all_types", "time_6", uint32(27)},
  1278  					{"def", "mydb", "all_types", "time_stamp", uint32(28)},
  1279  					{"def", "mydb", "all_types", "tiny_blob", uint32(29)},
  1280  					{"def", "mydb", "all_types", "tiny_int", uint32(30)},
  1281  					{"def", "mydb", "all_types", "tiny_text", uint32(31)},
  1282  					{"def", "mydb", "all_types", "var_char", uint32(32)},
  1283  					{"def", "mydb", "all_types", "var_binary", uint32(33)},
  1284  					{"def", "mydb", "all_types", "some_year", uint32(34)},
  1285  				},
  1286  			},
  1287  			{
  1288  				Query: `SELECT column_name, column_default, is_nullable, data_type, column_type, character_maximum_length, character_octet_length
  1289  FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='all_types' ORDER BY ORDINAL_POSITION`,
  1290  				Expected: []sql.Row{
  1291  					{"pk", nil, "NO", "int", "int", nil, nil},
  1292  					{"binary_1", "0x31", "YES", "binary", "binary(1)", 1, 1},
  1293  					{"big_int", "1", "YES", "bigint", "bigint", nil, nil},
  1294  					{"bit_2", "b'10'", "YES", "bit", "bit(2)", nil, nil},
  1295  					{"some_blob", "'abc'", "YES", "blob", "blob", 65535, 65535},
  1296  					{"char_1", "A", "YES", "char", "char(1)", 1, 4},
  1297  					{"some_date", "2022-02-22 00:00:00", "YES", "date", "date", nil, nil},
  1298  					{"date_time", "2022-02-22 22:22:21", "YES", "datetime", "datetime(6)", nil, nil},
  1299  					{"decimal_52", "994.45", "YES", "decimal", "decimal(5,2)", nil, nil},
  1300  					{"some_double", "1.1", "YES", "double", "double", nil, nil},
  1301  					{"some_enum", "s", "YES", "enum", "enum('s','m','l')", 1, 4},
  1302  					{"some_float", "4.4", "YES", "float", "float", nil, nil},
  1303  					{"some_geometry", "point(1,2)", "YES", "geometry", "geometry", nil, nil},
  1304  					{"some_int", "3", "YES", "int", "int", nil, nil},
  1305  					{"some_json", "json_object('a',1)", "YES", "json", "json", nil, nil},
  1306  					{"line_string", "linestring(point(0,0),point(1,2))", "YES", "linestring", "linestring", nil, nil},
  1307  					{"long_blob", "'abc'", "YES", "longblob", "longblob", 4294967295, 4294967295},
  1308  					{"long_text", "'abc'", "YES", "longtext", "longtext", 1073741823, 4294967295},
  1309  					{"medium_blob", "'abc'", "YES", "mediumblob", "mediumblob", 16777215, 16777215},
  1310  					{"medium_int", "7", "YES", "mediumint", "mediumint", nil, nil},
  1311  					{"medium_text", "'abc'", "YES", "mediumtext", "mediumtext", 4194303, 16777215},
  1312  					{"some_point", "point(2,2)", "YES", "point", "point", nil, nil},
  1313  					{"some_polygon", nil, "YES", "polygon", "polygon", nil, nil},
  1314  					{"some_set", "one,two", "YES", "set", "set('one','two')", 7, 28},
  1315  					{"small_int", "5", "YES", "smallint", "smallint", nil, nil},
  1316  					{"some_text", "'abc'", "YES", "text", "text", 16383, 65535},
  1317  					{"time_6", "11:59:59.000010", "YES", "time", "time(6)", nil, nil},
  1318  					{"time_stamp", "CURRENT_TIMESTAMP", "YES", "timestamp", "timestamp(6)", nil, nil},
  1319  					{"tiny_blob", "'abc'", "YES", "tinyblob", "tinyblob", 255, 255},
  1320  					{"tiny_int", "4", "YES", "tinyint", "tinyint", nil, nil},
  1321  					{"tiny_text", "'abc'", "YES", "tinytext", "tinytext", 63, 255},
  1322  					{"var_char", "varchar value", "YES", "varchar", "varchar(255)", 255, 1020},
  1323  					{"var_binary", "0x3131313131", "YES", "varbinary", "varbinary(255)", 255, 255},
  1324  					{"some_year", "2023", "YES", "year", "year", nil, nil},
  1325  				},
  1326  			},
  1327  			{
  1328  				Query: `SELECT column_name, column_type, numeric_precision, numeric_scale, datetime_precision, character_set_name, collation_name, column_key, extra, column_comment, generation_expression, srs_id
  1329  FROM information_schema.COLUMNS WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='all_types' ORDER BY ORDINAL_POSITION`,
  1330  				Expected: []sql.Row{
  1331  					{"pk", "int", 10, 0, nil, nil, nil, "PRI", "", "", "", nil},
  1332  					{"binary_1", "binary(1)", nil, nil, nil, nil, nil, "", "", "", "", nil},
  1333  					{"big_int", "bigint", 19, 0, nil, nil, nil, "", "", "", "", nil},
  1334  					{"bit_2", "bit(2)", 2, nil, nil, nil, nil, "", "", "", "", nil},
  1335  					{"some_blob", "blob", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1336  					{"char_1", "char(1)", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "", "", "", nil},
  1337  					{"some_date", "date", nil, nil, nil, nil, nil, "", "", "", "", nil},
  1338  					{"date_time", "datetime(6)", nil, nil, 0, nil, nil, "", "", "", "", nil},
  1339  					{"decimal_52", "decimal(5,2)", 5, 2, nil, nil, nil, "", "", "", "", nil},
  1340  					{"some_double", "double", 22, nil, nil, nil, nil, "", "", "", "", nil},
  1341  					{"some_enum", "enum('s','m','l')", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "", "", "", nil},
  1342  					{"some_float", "float", 12, nil, nil, nil, nil, "", "", "", "", nil},
  1343  					{"some_geometry", "geometry", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", uint32(4326)},
  1344  					{"some_int", "int", 10, 0, nil, nil, nil, "", "", "", "", nil},
  1345  					{"some_json", "json", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1346  					{"line_string", "linestring", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1347  					{"long_blob", "longblob", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1348  					{"long_text", "longtext", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "DEFAULT_GENERATED", "", "", nil},
  1349  					{"medium_blob", "mediumblob", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1350  					{"medium_int", "mediumint", 7, 0, nil, nil, nil, "", "", "", "", nil},
  1351  					{"medium_text", "mediumtext", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "DEFAULT_GENERATED", "", "", nil},
  1352  					{"some_point", "point", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1353  					{"some_polygon", "polygon", nil, nil, nil, nil, nil, "", "", "", "", nil},
  1354  					{"some_set", "set('one','two')", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "", "", "", nil},
  1355  					{"small_int", "smallint", 5, 0, nil, nil, nil, "", "", "", "", nil},
  1356  					{"some_text", "text", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "DEFAULT_GENERATED", "", "", nil},
  1357  					{"time_6", "time(6)", nil, nil, 6, nil, nil, "", "", "", "", nil},
  1358  					{"time_stamp", "timestamp(6)", nil, nil, 0, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1359  					{"tiny_blob", "tinyblob", nil, nil, nil, nil, nil, "", "DEFAULT_GENERATED", "", "", nil},
  1360  					{"tiny_int", "tinyint", 3, 0, nil, nil, nil, "", "", "", "", nil},
  1361  					{"tiny_text", "tinytext", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "DEFAULT_GENERATED", "", "", nil},
  1362  					{"var_char", "varchar(255)", nil, nil, nil, "utf8mb4", "utf8mb4_0900_bin", "", "", "", "", nil},
  1363  					{"var_binary", "varbinary(255)", nil, nil, nil, nil, nil, "", "", "", "", nil},
  1364  					{"some_year", "year", nil, nil, nil, nil, nil, "", "", "", "", nil},
  1365  				},
  1366  			},
  1367  		},
  1368  	},
  1369  	{
  1370  		Name: "column specific tests on information_schema.tables table",
  1371  		SetUpScript: []string{
  1372  			`create table bigtable (text varchar(20) primary key, number mediumint, pt point default (POINT(1,1)))`,
  1373  			`insert into bigtable values ('a',4,POINT(1,4)),('b',2,null),('c',0,null),('d',2,POINT(1, 2)),('e',2,POINT(1, 2))`,
  1374  			`create index bigtable_number on bigtable (number)`,
  1375  			`CREATE VIEW myview1 AS SELECT * FROM mytable`,
  1376  			`CREATE VIEW myview2 AS SELECT * FROM myview1 WHERE i = 1`,
  1377  		},
  1378  		Assertions: []ScriptTestAssertion{
  1379  			{
  1380  				Query: `SELECT table_catalog, table_schema, table_name, table_type, table_comment FROM information_schema.tables WHERE table_schema = 'mydb' and table_type IN ('VIEW') ORDER BY TABLE_NAME;`,
  1381  				Expected: []sql.Row{
  1382  					{"def", "mydb", "myview", "VIEW", "VIEW"},
  1383  					{"def", "mydb", "myview1", "VIEW", "VIEW"},
  1384  					{"def", "mydb", "myview2", "VIEW", "VIEW"},
  1385  				},
  1386  			},
  1387  			{
  1388  				Query: "SELECT table_rows as count FROM information_schema.TABLES WHERE TABLE_SCHEMA='mydb' AND TABLE_NAME='bigtable';",
  1389  				Expected: []sql.Row{
  1390  					{uint64(5)},
  1391  				},
  1392  			},
  1393  		},
  1394  	},
  1395  	{
  1396  		Name: "column specific tests on information_schema table, check and referential constraints",
  1397  		SetUpScript: []string{
  1398  			`CREATE TABLE checks (a INTEGER PRIMARY KEY, b INTEGER, c varchar(20))`,
  1399  			`ALTER TABLE checks ADD CONSTRAINT chk1 CHECK (B > 0)`,
  1400  			`ALTER TABLE checks ADD CONSTRAINT chk2 CHECK (b > 0) NOT ENFORCED`,
  1401  			`ALTER TABLE checks ADD CONSTRAINT chk3 CHECK (B > 1)`,
  1402  			`ALTER TABLE checks ADD CONSTRAINT chk4 CHECK (upper(C) = c)`,
  1403  
  1404  			`create table ptable (i int primary key, b blob, c char(10))`,
  1405  			`alter table ptable add index (c(3))`,
  1406  			`alter table ptable add unique index (b(4))`,
  1407  			`create index b_and_c on ptable (b(5), c(6))`,
  1408  			`ALTER TABLE ptable ADD CONSTRAINT ptable_checks FOREIGN KEY (i) REFERENCES checks(a)`,
  1409  		},
  1410  		Assertions: []ScriptTestAssertion{
  1411  			{
  1412  				Query: `SELECT TC.CONSTRAINT_NAME, CC.CHECK_CLAUSE, TC.ENFORCED 
  1413  FROM information_schema.TABLE_CONSTRAINTS TC, information_schema.CHECK_CONSTRAINTS CC 
  1414  WHERE TABLE_SCHEMA = 'mydb' AND TABLE_NAME = 'checks' AND TC.TABLE_SCHEMA = CC.CONSTRAINT_SCHEMA AND TC.CONSTRAINT_NAME = CC.CONSTRAINT_NAME AND TC.CONSTRAINT_TYPE = 'CHECK';`,
  1415  				Expected: []sql.Row{
  1416  					{"chk1", "(B > 0)", "YES"},
  1417  					{"chk2", "(b > 0)", "NO"},
  1418  					{"chk3", "(B > 1)", "YES"},
  1419  					{"chk4", "(upper(C) = c)", "YES"},
  1420  				},
  1421  			},
  1422  			{
  1423  				Query: `select * from information_schema.table_constraints where table_schema = 'mydb' and table_name = 'checks';`,
  1424  				Expected: []sql.Row{
  1425  					{"def", "mydb", "PRIMARY", "mydb", "checks", "PRIMARY KEY", "YES"},
  1426  					{"def", "mydb", "chk1", "mydb", "checks", "CHECK", "YES"},
  1427  					{"def", "mydb", "chk2", "mydb", "checks", "CHECK", "NO"},
  1428  					{"def", "mydb", "chk3", "mydb", "checks", "CHECK", "YES"},
  1429  					{"def", "mydb", "chk4", "mydb", "checks", "CHECK", "YES"},
  1430  				},
  1431  			},
  1432  			{
  1433  				Query: `select * from information_schema.check_constraints where constraint_schema = 'mydb';`,
  1434  				Expected: []sql.Row{
  1435  					{"def", "mydb", "chk1", "(B > 0)"},
  1436  					{"def", "mydb", "chk2", "(b > 0)"},
  1437  					{"def", "mydb", "chk3", "(B > 1)"},
  1438  					{"def", "mydb", "chk4", "(upper(C) = c)"},
  1439  				},
  1440  			},
  1441  			{
  1442  				Query: `select * from information_schema.table_constraints where table_schema = 'mydb' and table_name = 'ptable';`,
  1443  				Expected: []sql.Row{
  1444  					{"def", "mydb", "PRIMARY", "mydb", "ptable", "PRIMARY KEY", "YES"},
  1445  					{"def", "mydb", "b", "mydb", "ptable", "UNIQUE", "YES"},
  1446  					{"def", "mydb", "ptable_checks", "mydb", "ptable", "FOREIGN KEY", "YES"},
  1447  				},
  1448  			},
  1449  		},
  1450  	},
  1451  	{
  1452  		Name: "column specific tests on information_schema.routines table",
  1453  		SetUpScript: []string{
  1454  			`CREATE DEFINER=root@localhost PROCEDURE count_i_from_mytable(OUT total_i INT)
  1455      READS SQL DATA
  1456  BEGIN
  1457       SELECT SUM(i)
  1458       FROM mytable
  1459       INTO total_i;
  1460  END ;`,
  1461  		},
  1462  		Assertions: []ScriptTestAssertion{
  1463  			{
  1464  				Query: `select specific_name, routine_catalog, routine_schema, routine_name, routine_type, data_type,
  1465  routine_body, external_language, parameter_style, is_deterministic, sql_data_access, security_type, sql_mode, 
  1466  routine_comment, definer, character_set_client, collation_connection, database_collation
  1467  from information_schema.routines where routine_schema = 'mydb' and routine_type like 'PROCEDURE' order by routine_name;`,
  1468  				Expected: []sql.Row{
  1469  					{"count_i_from_mytable", "def", "mydb", "count_i_from_mytable", "PROCEDURE", "", "SQL", "SQL", "SQL", "NO",
  1470  						"READS SQL DATA", "DEFINER", "NO_ENGINE_SUBSTITUTION,ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES",
  1471  						"", "root@localhost", "utf8mb4", "utf8mb4_0900_bin", "utf8mb4_0900_bin"},
  1472  				},
  1473  			},
  1474  			{
  1475  				Query: `select routine_definition from information_schema.routines where routine_schema = 'mydb' and routine_type like 'PROCEDURE' order by routine_name;`,
  1476  				Expected: []sql.Row{
  1477  					{"BEGIN\n     SELECT SUM(i)\n     FROM mytable\n     INTO total_i;\nEND"},
  1478  				},
  1479  			},
  1480  		},
  1481  	},
  1482  	{
  1483  		Name: "column specific tests on information_schema.tables table",
  1484  		SetUpScript: []string{
  1485  			`create table bigtable (text varchar(20) primary key, number mediumint, pt point default (POINT(1,1)))`,
  1486  			`insert into bigtable values ('a',4,POINT(1,4)),('b',2,null),('c',0,null),('d',2,POINT(1, 2)),('e',2,POINT(1, 2))`,
  1487  			`create index bigtable_number on bigtable (number)`,
  1488  			`CREATE TABLE names (actor_id smallint PRIMARY KEY AUTO_INCREMENT, first_name varchar(45) NOT NULL);`,
  1489  			`INSERT INTO names (first_name) VALUES ('PENELOPE'), ('NICK'), ('JUNE');`,
  1490  			`CREATE VIEW myview1 AS SELECT * FROM myview WHERE i = 1`,
  1491  		},
  1492  		Assertions: []ScriptTestAssertion{
  1493  			{
  1494  				Query: `SELECT table_catalog, table_schema, table_name, table_type, engine, version, row_format, table_rows,
  1495  				auto_increment, table_collation, checksum, create_options, table_comment
  1496  				FROM information_schema.tables where table_schema = 'mydb' order by table_name`,
  1497  				Expected: []sql.Row{
  1498  					{"def", "mydb", "bigtable", "BASE TABLE", "InnoDB", 10, "Dynamic", uint64(5), nil, "utf8mb4_0900_bin", nil, "", ""},
  1499  					{"def", "mydb", "fk_tbl", "BASE TABLE", "InnoDB", 10, "Dynamic", uint64(0), nil, "utf8mb4_0900_bin", nil, "", ""},
  1500  					{"def", "mydb", "mytable", "BASE TABLE", "InnoDB", 10, "Dynamic", uint64(3), nil, "utf8mb4_0900_bin", nil, "", ""},
  1501  					{"def", "mydb", "myview", "VIEW", nil, nil, nil, nil, nil, nil, nil, nil, "VIEW"},
  1502  					{"def", "mydb", "myview1", "VIEW", nil, nil, nil, nil, nil, nil, nil, nil, "VIEW"},
  1503  					{"def", "mydb", "names", "BASE TABLE", "InnoDB", 10, "Dynamic", uint64(3), uint64(4), "utf8mb4_0900_bin", nil, "", ""},
  1504  				},
  1505  			},
  1506  			{
  1507  				Query: "SELECT table_comment,table_rows,auto_increment FROM information_schema.tables WHERE TABLE_NAME = 'names' AND TABLE_SCHEMA = 'mydb';",
  1508  				Expected: []sql.Row{
  1509  					{"", uint64(3), uint64(4)},
  1510  				},
  1511  			},
  1512  		},
  1513  	},
  1514  	{
  1515  		Name: "information_schema.views has definer and security information",
  1516  		SetUpScript: []string{
  1517  			"create view myview1 as select count(*) from mytable;",
  1518  			"CREATE ALGORITHM=TEMPTABLE DEFINER=UserName@localhost SQL SECURITY INVOKER VIEW myview2 AS SELECT * FROM myview WHERE i > 1;",
  1519  		},
  1520  		Assertions: []ScriptTestAssertion{
  1521  			{
  1522  				Query: "select * from information_schema.views where table_schema = 'mydb' order by table_name",
  1523  				Expected: []sql.Row{
  1524  					{"def", "mydb", "myview", "SELECT * FROM mytable", "NONE", "YES", "root@localhost", "DEFINER", "utf8mb4", "utf8mb4_0900_bin"},
  1525  					{"def", "mydb", "myview1", "select count(*) from mytable", "NONE", "NO", "root@localhost", "DEFINER", "utf8mb4", "utf8mb4_0900_bin"},
  1526  					{"def", "mydb", "myview2", "SELECT * FROM myview WHERE i > 1", "NONE", "NO", "UserName@localhost", "INVOKER", "utf8mb4", "utf8mb4_0900_bin"},
  1527  				},
  1528  			},
  1529  		},
  1530  	},
  1531  	{
  1532  		Name: "information_schema.schemata shows all column values",
  1533  		SetUpScript: []string{
  1534  			"CREATE DATABASE mydb1 COLLATE latin1_general_ci;",
  1535  			"CREATE DATABASE mydb2 COLLATE utf8mb3_general_ci;",
  1536  		},
  1537  		Assertions: []ScriptTestAssertion{
  1538  			{
  1539  				Query: "SELECT * FROM information_schema.schemata where schema_name like 'mydb%' order by schema_name",
  1540  				Expected: []sql.Row{
  1541  					{"def", "mydb", "utf8mb4", "utf8mb4_0900_bin", nil, "NO"},
  1542  					{"def", "mydb1", "latin1", "latin1_general_ci", nil, "NO"},
  1543  					{"def", "mydb2", "utf8mb3", "utf8mb3_general_ci", nil, "NO"},
  1544  				},
  1545  			},
  1546  		},
  1547  	},
  1548  	{
  1549  		Name: "information_schema.st_geometry_columns shows all column values",
  1550  		SetUpScript: []string{
  1551  			"CREATE TABLE spatial_table (id INT PRIMARY KEY, g GEOMETRY SRID 0, m MULTIPOINT, p POLYGON SRID 4326);",
  1552  		},
  1553  		Assertions: []ScriptTestAssertion{
  1554  			{
  1555  				Query: "SELECT * FROM information_schema.st_geometry_columns where table_schema = 'mydb' order by column_name",
  1556  				Expected: []sql.Row{
  1557  					{"def", "mydb", "spatial_table", "g", "", uint32(0), "geometry"},
  1558  					{"def", "mydb", "spatial_table", "m", nil, nil, "multipoint"},
  1559  					{"def", "mydb", "spatial_table", "p", "WGS 84", uint32(4326), "polygon"},
  1560  				},
  1561  			},
  1562  		},
  1563  	},
  1564  	{
  1565  		Name: "information_schema.parameters shows all column values",
  1566  		SetUpScript: []string{
  1567  			"CREATE PROCEDURE testabc(IN x DOUBLE, IN y FLOAT, OUT abc DECIMAL(5,1)) SELECT x*y INTO abc",
  1568  		},
  1569  		Assertions: []ScriptTestAssertion{
  1570  			{
  1571  				Query: "SELECT * FROM information_schema.parameters where specific_name = 'testabc'",
  1572  				Expected: []sql.Row{
  1573  					{"def", "mydb", "testabc", uint64(1), "IN", "x", "double", nil, nil, 22, 0, nil, nil, nil, "double", "PROCEDURE"},
  1574  					{"def", "mydb", "testabc", uint64(2), "IN", "y", "float", nil, nil, 12, 0, nil, nil, nil, "float", "PROCEDURE"},
  1575  					{"def", "mydb", "testabc", uint64(3), "OUT", "abc", "decimal", nil, nil, 5, 1, nil, nil, nil, "decimal(5,1)", "PROCEDURE"},
  1576  				},
  1577  			},
  1578  		},
  1579  	},
  1580  	{
  1581  
  1582  		Name:        "information_schema.st_spatial_reference_systems can be modified",
  1583  		SetUpScript: []string{},
  1584  		Assertions: []ScriptTestAssertion{
  1585  			{
  1586  				Query: "create or replace spatial reference system 1234 " +
  1587  					"organization 'test_org' identified by 1234 " +
  1588  					"definition 'test_definition' " +
  1589  					"description 'test_description'",
  1590  				ExpectedErrStr: "missing mandatory attribute NAME",
  1591  			},
  1592  			{
  1593  				Query: "create or replace spatial reference system 1234 " +
  1594  					"name 'test_name' " +
  1595  					"definition 'test_definition' " +
  1596  					"description 'test_description'",
  1597  				ExpectedErrStr: "missing mandatory attribute ORGANIZATION NAME",
  1598  			},
  1599  			{
  1600  				Query: "create or replace spatial reference system 1234 " +
  1601  					"name 'test_name' " +
  1602  					"organization 'test_org' identified by 1234 " +
  1603  					"description 'test_description'",
  1604  				ExpectedErrStr: "missing mandatory attribute DEFINITION",
  1605  			},
  1606  			{
  1607  				Query: "create or replace spatial reference system 1234 " +
  1608  					"name ' test_name ' " +
  1609  					"definition 'test_definition' " +
  1610  					"organization 'test_org' identified by 1234 " +
  1611  					"description 'test_description'",
  1612  				ExpectedErrStr: "the spatial reference system name can't be an empty string or start or end with whitespace",
  1613  			},
  1614  			{
  1615  				Query: "create or replace spatial reference system 1234 " +
  1616  					"name 'test_name' " +
  1617  					"definition 'test_definition' " +
  1618  					"organization ' test_org ' identified by 1234 " +
  1619  					"description 'test_description'",
  1620  				ExpectedErrStr: "the organization name can't be an empty string or start or end with whitespace",
  1621  			},
  1622  			{
  1623  				// TODO: can't reliably test this along with the prepared version as the information_schema is persisted between test runs
  1624  				Skip: true,
  1625  				Query: "create spatial reference system 1234 " +
  1626  					"name 'test_name' " +
  1627  					"organization 'test_org' identified by 1234 " +
  1628  					"definition 'test_definition' " +
  1629  					"description 'test_description'",
  1630  				Expected: []sql.Row{
  1631  					{types.NewOkResult(0)},
  1632  				},
  1633  			},
  1634  			{
  1635  				Query: "create or replace spatial reference system 1234 " +
  1636  					"name 'test_name' " +
  1637  					"organization 'test_org' identified by 1234 " +
  1638  					"definition 'test_definition' " +
  1639  					"description 'test_description'",
  1640  				Expected: []sql.Row{
  1641  					{types.NewOkResult(0)},
  1642  				},
  1643  			},
  1644  			{
  1645  				Query: "select srs_id, srs_name, organization, organization_coordsys_id, definition, description from information_schema.st_spatial_reference_systems where srs_id = 1234",
  1646  				Expected: []sql.Row{
  1647  					{uint32(1234), "test_name", "test_org", uint32(1234), "test_definition", "test_description"},
  1648  				},
  1649  			},
  1650  			{
  1651  				Query: "create spatial reference system if not exists 1234 " +
  1652  					"name 'new_test_name' " +
  1653  					"organization 'new_test_org' identified by 1234 " +
  1654  					"definition 'new_test_definition' " +
  1655  					"description 'new_test_description'",
  1656  				Expected: []sql.Row{
  1657  					{types.NewOkResult(0)},
  1658  				},
  1659  			},
  1660  			{
  1661  				Query: "select srs_id, srs_name, organization, organization_coordsys_id, definition, description from information_schema.st_spatial_reference_systems where srs_id = 1234",
  1662  				Expected: []sql.Row{
  1663  					{uint32(1234), "test_name", "test_org", uint32(1234), "test_definition", "test_description"},
  1664  				},
  1665  			},
  1666  		},
  1667  	},
  1668  }
  1669  
  1670  var SkippedInfoSchemaScripts = []ScriptTest{
  1671  	{
  1672  		Name: "information_schema.key_column_usage works with foreign key across different databases",
  1673  		SetUpScript: []string{
  1674  			"CREATE TABLE my_table (i int primary key, height int)",
  1675  			"CREATE DATABASE keydb",
  1676  			"USE keydb",
  1677  			"CREATE TABLE key_table (a int primary key, weight int)",
  1678  			"alter table key_table add constraint fk_across_dbs foreign key (a) references mydb.my_table(i)",
  1679  		},
  1680  		Assertions: []ScriptTestAssertion{
  1681  			{
  1682  				Query: "SELECT * FROM information_schema.key_column_usage where constraint_name = 'fk_across_dbs'",
  1683  				Expected: []sql.Row{
  1684  					{"def", "keydb", "fk_across_dbs", "def", "keydb", "key_table", "a", 1, 1, "mydb", "my_table", "i"},
  1685  				},
  1686  			},
  1687  		},
  1688  	},
  1689  }