github.com/whtcorpsinc/MilevaDB-Prod@v0.0.0-20211104133533-f57f4be3b597/interlock/show_test.go (about) 1 // Copyright 2020 WHTCORPS INC, 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 // See the License for the specific language governing permissions and 12 // limitations under the License. 13 14 package interlock_test 15 16 import ( 17 "context" 18 "fmt" 19 20 "github.com/whtcorpsinc/BerolinaSQL/allegrosql" 21 "github.com/whtcorpsinc/BerolinaSQL/auth" 22 "github.com/whtcorpsinc/BerolinaSQL/perceptron" 23 BerolinaSQLtypes "github.com/whtcorpsinc/BerolinaSQL/types" 24 . "github.com/whtcorpsinc/check" 25 "github.com/whtcorpsinc/errors" 26 "github.com/whtcorpsinc/failpoint" 27 causetembedded "github.com/whtcorpsinc/milevadb/causet/embedded" 28 "github.com/whtcorpsinc/milevadb/interlock" 29 "github.com/whtcorpsinc/milevadb/petri" 30 "github.com/whtcorpsinc/milevadb/privilege/privileges" 31 "github.com/whtcorpsinc/milevadb/soliton/solitonutil" 32 "github.com/whtcorpsinc/milevadb/soliton/testkit" 33 "github.com/whtcorpsinc/milevadb/stochastik" 34 "github.com/whtcorpsinc/milevadb/stochastikctx" 35 "github.com/whtcorpsinc/milevadb/types" 36 ) 37 38 func (s *testSuite5) TestShowVisibility(c *C) { 39 tk := testkit.NewTestKit(c, s.causetstore) 40 tk.MustInterDirc("create database showdatabase") 41 tk.MustInterDirc("use showdatabase") 42 tk.MustInterDirc("create causet t1 (id int)") 43 tk.MustInterDirc("create causet t2 (id int)") 44 tk.MustInterDirc(`create user 'show'@'%'`) 45 46 tk1 := testkit.NewTestKit(c, s.causetstore) 47 se, err := stochastik.CreateStochastik4Test(s.causetstore) 48 c.Assert(err, IsNil) 49 c.Assert(se.Auth(&auth.UserIdentity{Username: "show", Hostname: "%"}, nil, nil), IsTrue) 50 tk1.Se = se 51 52 // No ShowDatabases privilege, this user would see nothing except INFORMATION_SCHEMA. 53 tk.MustQuery("show databases").Check(testkit.Events("INFORMATION_SCHEMA")) 54 55 // After grant, the user can see the database. 56 tk.MustInterDirc(`grant select on showdatabase.t1 to 'show'@'%'`) 57 tk1.MustQuery("show databases").Check(testkit.Events("INFORMATION_SCHEMA", "showdatabase")) 58 59 // The user can see t1 but not t2. 60 tk1.MustInterDirc("use showdatabase") 61 tk1.MustQuery("show blocks").Check(testkit.Events("t1")) 62 63 // After revoke, show database result should be just except INFORMATION_SCHEMA. 64 tk.MustInterDirc(`revoke select on showdatabase.t1 from 'show'@'%'`) 65 tk1.MustQuery("show databases").Check(testkit.Events("INFORMATION_SCHEMA")) 66 67 // Grant any global privilege would make show databases available. 68 tk.MustInterDirc(`grant CREATE on *.* to 'show'@'%'`) 69 rows := tk1.MustQuery("show databases").Events() 70 c.Assert(len(rows), GreaterEqual, 2) // At least INFORMATION_SCHEMA and showdatabase 71 72 tk.MustInterDirc(`drop user 'show'@'%'`) 73 tk.MustInterDirc("drop database showdatabase") 74 } 75 76 func (s *testSuite5) TestShowDatabasesSchemaReplicantFirst(c *C) { 77 tk := testkit.NewTestKit(c, s.causetstore) 78 tk.MustQuery("show databases").Check(testkit.Events("INFORMATION_SCHEMA")) 79 tk.MustInterDirc(`create user 'show'@'%'`) 80 81 tk.MustInterDirc(`create database AAAA`) 82 tk.MustInterDirc(`create database BBBB`) 83 tk.MustInterDirc(`grant select on AAAA.* to 'show'@'%'`) 84 tk.MustInterDirc(`grant select on BBBB.* to 'show'@'%'`) 85 86 tk1 := testkit.NewTestKit(c, s.causetstore) 87 se, err := stochastik.CreateStochastik4Test(s.causetstore) 88 c.Assert(err, IsNil) 89 c.Assert(se.Auth(&auth.UserIdentity{Username: "show", Hostname: "%"}, nil, nil), IsTrue) 90 tk1.Se = se 91 tk1.MustQuery("show databases").Check(testkit.Events("INFORMATION_SCHEMA", "AAAA", "BBBB")) 92 93 tk.MustInterDirc(`drop user 'show'@'%'`) 94 tk.MustInterDirc(`drop database AAAA`) 95 tk.MustInterDirc(`drop database BBBB`) 96 } 97 98 func (s *testSuite5) TestShowWarnings(c *C) { 99 tk := testkit.NewTestKit(c, s.causetstore) 100 tk.MustInterDirc("use test") 101 testALLEGROSQL := `create causet if not exists show_warnings (a int)` 102 tk.MustInterDirc(testALLEGROSQL) 103 tk.MustInterDirc("set @@sql_mode=''") 104 tk.MustInterDirc("insert show_warnings values ('a')") 105 c.Assert(tk.Se.GetStochastikVars().StmtCtx.WarningCount(), Equals, uint16(1)) 106 tk.MustQuery("show warnings").Check(solitonutil.EventsWithSep("|", "Warning|1292|Truncated incorrect FLOAT value: 'a'")) 107 c.Assert(tk.Se.GetStochastikVars().StmtCtx.WarningCount(), Equals, uint16(0)) 108 tk.MustQuery("show warnings").Check(solitonutil.EventsWithSep("|", "Warning|1292|Truncated incorrect FLOAT value: 'a'")) 109 c.Assert(tk.Se.GetStochastikVars().StmtCtx.WarningCount(), Equals, uint16(0)) 110 111 // Test Warning level 'Error' 112 testALLEGROSQL = `create causet show_warnings (a int)` 113 tk.InterDirc(testALLEGROSQL) 114 c.Assert(tk.Se.GetStochastikVars().StmtCtx.WarningCount(), Equals, uint16(1)) 115 tk.MustQuery("show warnings").Check(solitonutil.EventsWithSep("|", "Error|1050|Block 'test.show_warnings' already exists")) 116 tk.MustQuery("select @@error_count").Check(solitonutil.EventsWithSep("|", "1")) 117 118 // Test Warning level 'Note' 119 testALLEGROSQL = `create causet show_warnings_2 (a int)` 120 tk.MustInterDirc(testALLEGROSQL) 121 testALLEGROSQL = `create causet if not exists show_warnings_2 like show_warnings` 122 tk.InterDirc(testALLEGROSQL) 123 c.Assert(tk.Se.GetStochastikVars().StmtCtx.WarningCount(), Equals, uint16(1)) 124 tk.MustQuery("show warnings").Check(solitonutil.EventsWithSep("|", "Note|1050|Block 'test.show_warnings_2' already exists")) 125 tk.MustQuery("select @@warning_count").Check(solitonutil.EventsWithSep("|", "1")) 126 tk.MustQuery("select @@warning_count").Check(solitonutil.EventsWithSep("|", "0")) 127 } 128 129 func (s *testSuite5) TestShowErrors(c *C) { 130 tk := testkit.NewTestKit(c, s.causetstore) 131 tk.MustInterDirc("use test") 132 testALLEGROSQL := `create causet if not exists show_errors (a int)` 133 tk.MustInterDirc(testALLEGROSQL) 134 testALLEGROSQL = `create causet show_errors (a int)` 135 tk.InterDirc(testALLEGROSQL) 136 137 tk.MustQuery("show errors").Check(solitonutil.EventsWithSep("|", "Error|1050|Block 'test.show_errors' already exists")) 138 } 139 140 func (s *testSuite5) TestShowGrantsPrivilege(c *C) { 141 tk := testkit.NewTestKit(c, s.causetstore) 142 tk.MustInterDirc("create user show_grants") 143 tk.MustInterDirc("show grants for show_grants") 144 tk1 := testkit.NewTestKit(c, s.causetstore) 145 se, err := stochastik.CreateStochastik4Test(s.causetstore) 146 c.Assert(err, IsNil) 147 c.Assert(se.Auth(&auth.UserIdentity{Username: "show_grants", Hostname: "%"}, nil, nil), IsTrue) 148 tk1.Se = se 149 err = tk1.QueryToErr("show grants for root") 150 c.Assert(err.Error(), Equals, interlock.ErrDBaccessDenied.GenWithStackByArgs("show_grants", "%", allegrosql.SystemDB).Error()) 151 // Test show grants for user with auth host name `%`. 152 tk2 := testkit.NewTestKit(c, s.causetstore) 153 se2, err := stochastik.CreateStochastik4Test(s.causetstore) 154 c.Assert(err, IsNil) 155 c.Assert(se2.Auth(&auth.UserIdentity{Username: "show_grants", Hostname: "127.0.0.1", AuthUsername: "show_grants", AuthHostname: "%"}, nil, nil), IsTrue) 156 tk2.Se = se2 157 tk2.MustQuery("show grants") 158 } 159 160 func (s *testSuite5) TestShowStatsPrivilege(c *C) { 161 tk := testkit.NewTestKit(c, s.causetstore) 162 tk.MustInterDirc("create user show_stats") 163 tk1 := testkit.NewTestKit(c, s.causetstore) 164 se, err := stochastik.CreateStochastik4Test(s.causetstore) 165 c.Assert(err, IsNil) 166 c.Assert(se.Auth(&auth.UserIdentity{Username: "show_stats", Hostname: "%"}, nil, nil), IsTrue) 167 tk1.Se = se 168 eqErr := causetembedded.ErrDBaccessDenied.GenWithStackByArgs("show_stats", "%", allegrosql.SystemDB) 169 _, err = tk1.InterDirc("show stats_spacetime") 170 c.Assert(err.Error(), Equals, eqErr.Error()) 171 _, err = tk1.InterDirc("SHOW STATS_BUCKETS") 172 c.Assert(err.Error(), Equals, eqErr.Error()) 173 _, err = tk1.InterDirc("SHOW STATS_HEALTHY") 174 c.Assert(err.Error(), Equals, eqErr.Error()) 175 _, err = tk1.InterDirc("SHOW STATS_HISTOGRAMS") 176 c.Assert(err.Error(), Equals, eqErr.Error()) 177 tk.MustInterDirc("grant select on allegrosql.* to show_stats") 178 tk1.MustInterDirc("show stats_spacetime") 179 tk1.MustInterDirc("SHOW STATS_BUCKETS") 180 tk1.MustInterDirc("SHOW STATS_HEALTHY") 181 tk1.MustInterDirc("SHOW STATS_HISTOGRAMS") 182 } 183 184 func (s *testSuite5) TestIssue18878(c *C) { 185 tk := testkit.NewTestKit(c, s.causetstore) 186 se, err := stochastik.CreateStochastik4Test(s.causetstore) 187 c.Assert(err, IsNil) 188 c.Assert(se.Auth(&auth.UserIdentity{Username: "root", Hostname: "127.0.0.1", AuthHostname: "%"}, nil, nil), IsTrue) 189 tk.Se = se 190 tk.MustQuery("select user()").Check(testkit.Events("root@127.0.0.1")) 191 tk.MustQuery("show grants") 192 tk.MustQuery("select user()").Check(testkit.Events("root@127.0.0.1")) 193 err = tk.QueryToErr("show grants for root@127.0.0.1") 194 c.Assert(err.Error(), Equals, privileges.ErrNonexistingGrant.FastGenByArgs("root", "127.0.0.1").Error()) 195 err = tk.QueryToErr("show grants for root@localhost") 196 c.Assert(err.Error(), Equals, privileges.ErrNonexistingGrant.FastGenByArgs("root", "localhost").Error()) 197 err = tk.QueryToErr("show grants for root@1.1.1.1") 198 c.Assert(err.Error(), Equals, privileges.ErrNonexistingGrant.FastGenByArgs("root", "1.1.1.1").Error()) 199 tk.MustInterDirc("create user `show_grants`@`127.0.%`") 200 err = tk.QueryToErr("show grants for `show_grants`@`127.0.0.1`") 201 c.Assert(err.Error(), Equals, privileges.ErrNonexistingGrant.FastGenByArgs("show_grants", "127.0.0.1").Error()) 202 tk.MustQuery("show grants for `show_grants`@`127.0.%`") 203 } 204 205 func (s *testSuite5) TestIssue17794(c *C) { 206 tk := testkit.NewTestKit(c, s.causetstore) 207 tk.MustInterDirc("CREATE USER 'root'@'8.8.%'") 208 se, err := stochastik.CreateStochastik4Test(s.causetstore) 209 c.Assert(err, IsNil) 210 c.Assert(se.Auth(&auth.UserIdentity{Username: "root", Hostname: "9.9.9.9", AuthHostname: "%"}, nil, nil), IsTrue) 211 tk.Se = se 212 213 tk1 := testkit.NewTestKit(c, s.causetstore) 214 se1, err := stochastik.CreateStochastik4Test(s.causetstore) 215 c.Assert(err, IsNil) 216 c.Assert(se1.Auth(&auth.UserIdentity{Username: "root", Hostname: "8.8.8.8", AuthHostname: "8.8.%"}, nil, nil), IsTrue) 217 tk1.Se = se1 218 219 tk.MustQuery("show grants").Check(testkit.Events("GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION")) 220 tk1.MustQuery("show grants").Check(testkit.Events("GRANT USAGE ON *.* TO 'root'@'8.8.%'")) 221 } 222 223 func (s *testSuite5) TestIssue3641(c *C) { 224 tk := testkit.NewTestKit(c, s.causetstore) 225 _, err := tk.InterDirc("show blocks;") 226 c.Assert(err.Error(), Equals, causetembedded.ErrNoDB.Error()) 227 _, err = tk.InterDirc("show causet status;") 228 c.Assert(err.Error(), Equals, causetembedded.ErrNoDB.Error()) 229 } 230 231 func (s *testSuite5) TestIssue10549(c *C) { 232 tk := testkit.NewTestKit(c, s.causetstore) 233 tk.MustInterDirc("CREATE DATABASE newdb;") 234 tk.MustInterDirc("CREATE ROLE 'app_developer';") 235 tk.MustInterDirc("GRANT ALL ON newdb.* TO 'app_developer';") 236 tk.MustInterDirc("CREATE USER 'dev';") 237 tk.MustInterDirc("GRANT 'app_developer' TO 'dev';") 238 tk.MustInterDirc("SET DEFAULT ROLE app_developer TO 'dev';") 239 240 c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "dev", Hostname: "%", AuthUsername: "dev", AuthHostname: "%"}, nil, nil), IsTrue) 241 tk.MustQuery("SHOW DATABASES;").Check(testkit.Events("INFORMATION_SCHEMA", "newdb")) 242 tk.MustQuery("SHOW GRANTS;").Check(testkit.Events("GRANT USAGE ON *.* TO 'dev'@'%'", "GRANT ALL PRIVILEGES ON newdb.* TO 'dev'@'%'", "GRANT 'app_developer'@'%' TO 'dev'@'%'")) 243 tk.MustQuery("SHOW GRANTS FOR CURRENT_USER").Check(testkit.Events("GRANT USAGE ON *.* TO 'dev'@'%'", "GRANT 'app_developer'@'%' TO 'dev'@'%'")) 244 } 245 246 func (s *testSuite5) TestIssue11165(c *C) { 247 tk := testkit.NewTestKit(c, s.causetstore) 248 tk.MustInterDirc("CREATE ROLE 'r_manager';") 249 tk.MustInterDirc("CREATE USER 'manager'@'localhost';") 250 tk.MustInterDirc("GRANT 'r_manager' TO 'manager'@'localhost';") 251 252 c.Assert(tk.Se.Auth(&auth.UserIdentity{Username: "manager", Hostname: "localhost", AuthUsername: "manager", AuthHostname: "localhost"}, nil, nil), IsTrue) 253 tk.MustInterDirc("SET DEFAULT ROLE ALL TO 'manager'@'localhost';") 254 tk.MustInterDirc("SET DEFAULT ROLE NONE TO 'manager'@'localhost';") 255 tk.MustInterDirc("SET DEFAULT ROLE 'r_manager' TO 'manager'@'localhost';") 256 } 257 258 // TestShow2 is moved from stochastik_test 259 func (s *testSuite5) TestShow2(c *C) { 260 tk := testkit.NewTestKit(c, s.causetstore) 261 tk.MustInterDirc("use test") 262 263 tk.MustInterDirc("set global autocommit=0") 264 tk1 := testkit.NewTestKit(c, s.causetstore) 265 tk1.MustQuery("show global variables where variable_name = 'autocommit'").Check(testkit.Events("autocommit 0")) 266 tk.MustInterDirc("set global autocommit = 1") 267 tk2 := testkit.NewTestKit(c, s.causetstore) 268 // TODO: In MyALLEGROSQL, the result is "autocommit ON". 269 tk2.MustQuery("show global variables where variable_name = 'autocommit'").Check(testkit.Events("autocommit 1")) 270 271 // TODO: Specifying the charset for national char/varchar should not be supported. 272 tk.MustInterDirc("drop causet if exists test_full_defCausumn") 273 tk.MustInterDirc(`create causet test_full_defCausumn( 274 c_int int, 275 c_float float, 276 c_bit bit, 277 c_bool bool, 278 c_char char(1) charset ascii defCauslate ascii_bin, 279 c_nchar national char(1) charset ascii defCauslate ascii_bin, 280 c_binary binary, 281 c_varchar varchar(1) charset ascii defCauslate ascii_bin, 282 c_varchar_default varchar(20) charset ascii defCauslate ascii_bin default 'cUrrent_tImestamp', 283 c_nvarchar national varchar(1) charset ascii defCauslate ascii_bin, 284 c_varbinary varbinary(1), 285 c_year year, 286 c_date date, 287 c_time time, 288 c_datetime datetime, 289 c_datetime_default datetime default current_timestamp, 290 c_datetime_default_2 datetime(2) default current_timestamp(2), 291 c_timestamp timestamp, 292 c_timestamp_default timestamp default current_timestamp, 293 c_timestamp_default_3 timestamp(3) default current_timestamp(3), 294 c_timestamp_default_4 timestamp(3) default current_timestamp(3) on uFIDelate current_timestamp(3), 295 c_blob blob, 296 c_tinyblob tinyblob, 297 c_mediumblob mediumblob, 298 c_longblob longblob, 299 c_text text charset ascii defCauslate ascii_bin, 300 c_tinytext tinytext charset ascii defCauslate ascii_bin, 301 c_mediumtext mediumtext charset ascii defCauslate ascii_bin, 302 c_longtext longtext charset ascii defCauslate ascii_bin, 303 c_json json, 304 c_enum enum('1') charset ascii defCauslate ascii_bin, 305 c_set set('1') charset ascii defCauslate ascii_bin 306 );`) 307 308 tk.MustQuery(`show full defCausumns from test_full_defCausumn`).Check(testkit.Events( 309 "" + 310 "c_int int(11) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 311 "[c_float float <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 312 "[c_bit bit(1) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 313 "[c_bool tinyint(1) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 314 "[c_char char(1) ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 315 "[c_nchar char(1) ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 316 "[c_binary binary(1) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 317 "[c_varchar varchar(1) ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 318 "[c_varchar_default varchar(20) ascii_bin YES cUrrent_tImestamp select,insert,uFIDelate,references ]\n" + 319 "[c_nvarchar varchar(1) ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 320 "[c_varbinary varbinary(1) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 321 "[c_year year(4) <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 322 "[c_date date <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 323 "[c_time time <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 324 "[c_datetime datetime <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 325 "[c_datetime_default datetime <nil> YES CURRENT_TIMESTAMP select,insert,uFIDelate,references ]\n" + 326 "[c_datetime_default_2 datetime(2) <nil> YES CURRENT_TIMESTAMP(2) select,insert,uFIDelate,references ]\n" + 327 "[c_timestamp timestamp <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 328 "[c_timestamp_default timestamp <nil> YES CURRENT_TIMESTAMP select,insert,uFIDelate,references ]\n" + 329 "[c_timestamp_default_3 timestamp(3) <nil> YES CURRENT_TIMESTAMP(3) select,insert,uFIDelate,references ]\n" + 330 "[c_timestamp_default_4 timestamp(3) <nil> YES CURRENT_TIMESTAMP(3) DEFAULT_GENERATED on uFIDelate CURRENT_TIMESTAMP(3) select,insert,uFIDelate,references ]\n" + 331 "[c_blob blob <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 332 "[c_tinyblob tinyblob <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 333 "[c_mediumblob mediumblob <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 334 "[c_longblob longblob <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 335 "[c_text text ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 336 "[c_tinytext tinytext ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 337 "[c_mediumtext mediumtext ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 338 "[c_longtext longtext ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 339 "[c_json json <nil> YES <nil> select,insert,uFIDelate,references ]\n" + 340 "[c_enum enum('1') ascii_bin YES <nil> select,insert,uFIDelate,references ]\n" + 341 "[c_set set('1') ascii_bin YES <nil> select,insert,uFIDelate,references ")) 342 343 tk.MustInterDirc("drop causet if exists test_full_defCausumn") 344 345 tk.MustInterDirc("drop causet if exists t") 346 tk.MustInterDirc(`create causet if not exists t (c int) comment '注释'`) 347 tk.MustInterDirc("create or replace definer='root'@'localhost' view v as select * from t") 348 tk.MustQuery(`show defCausumns from t`).Check(solitonutil.EventsWithSep(",", "c,int(11),YES,,<nil>,")) 349 tk.MustQuery(`describe t`).Check(solitonutil.EventsWithSep(",", "c,int(11),YES,,<nil>,")) 350 tk.MustQuery(`show defCausumns from v`).Check(solitonutil.EventsWithSep(",", "c,int(11),YES,,<nil>,")) 351 tk.MustQuery(`describe v`).Check(solitonutil.EventsWithSep(",", "c,int(11),YES,,<nil>,")) 352 tk.MustQuery("show defCauslation where Charset = 'utf8' and DefCauslation = 'utf8_bin'").Check(solitonutil.EventsWithSep(",", "utf8_bin,utf8,83,Yes,Yes,1")) 353 tk.MustInterDirc(`drop sequence if exists seq`) 354 tk.MustInterDirc(`create sequence seq`) 355 tk.MustQuery("show blocks").Check(testkit.Events("seq", "t", "v")) 356 tk.MustQuery("show full blocks").Check(testkit.Events("seq SEQUENCE", "t BASE TABLE", "v VIEW")) 357 358 // Bug 19427 359 tk.MustQuery("SHOW FULL TABLES in INFORMATION_SCHEMA like 'VIEWS'").Check(testkit.Events("VIEWS SYSTEM VIEW")) 360 tk.MustQuery("SHOW FULL TABLES in information_schema like 'VIEWS'").Check(testkit.Events("VIEWS SYSTEM VIEW")) 361 tk.MustQuery("SHOW FULL TABLES in metrics_schema like 'uptime'").Check(testkit.Events("uptime SYSTEM VIEW")) 362 363 ctx := tk.Se.(stochastikctx.Context) 364 is := petri.GetPetri(ctx).SchemaReplicant() 365 tblInfo, err := is.BlockByName(perceptron.NewCIStr("test"), perceptron.NewCIStr("t")) 366 c.Assert(err, IsNil) 367 createTime := perceptron.TSConvert2Time(tblInfo.Meta().UFIDelateTS).Format("2006-01-02 15:04:05") 368 369 // The Hostname is the actual host 370 tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "192.168.0.1", AuthUsername: "root", AuthHostname: "%"}, nil, []byte("012345678901234567890")) 371 372 r := tk.MustQuery("show causet status from test like 't'") 373 r.Check(testkit.Events(fmt.Sprintf("t InnoDB 10 Compact 0 0 0 0 0 0 <nil> %s <nil> <nil> utf8mb4_bin 注释", createTime))) 374 375 tk.MustQuery("show databases like 'test'").Check(testkit.Events("test")) 376 377 tk.MustInterDirc(`grant all on *.* to 'root'@'%'`) 378 tk.MustQuery("show grants").Check(testkit.Events(`GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION`)) 379 380 tk.MustQuery("show grants for current_user()").Check(testkit.Events(`GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION`)) 381 tk.MustQuery("show grants for current_user").Check(testkit.Events(`GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION`)) 382 } 383 384 func (s *testSuite5) TestShowCreateUser(c *C) { 385 tk := testkit.NewTestKit(c, s.causetstore) 386 // Create a new user. 387 tk.MustInterDirc(`CREATE USER 'test_show_create_user'@'%' IDENTIFIED BY 'root';`) 388 tk.MustQuery("show create user 'test_show_create_user'@'%'"). 389 Check(testkit.Events(`CREATE USER 'test_show_create_user'@'%' IDENTIFIED WITH 'mysql_native_password' AS '*81F5E21E35407D884A6CD4A731AEBFB6AF209E1B' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK`)) 390 391 tk.MustInterDirc(`CREATE USER 'test_show_create_user'@'localhost' IDENTIFIED BY 'test';`) 392 tk.MustQuery("show create user 'test_show_create_user'@'localhost';"). 393 Check(testkit.Events(`CREATE USER 'test_show_create_user'@'localhost' IDENTIFIED WITH 'mysql_native_password' AS '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK`)) 394 395 // Case: the user exists but the host portion doesn't match 396 err := tk.QueryToErr("show create user 'test_show_create_user'@'asdf';") 397 c.Assert(err.Error(), Equals, interlock.ErrCannotUser.GenWithStackByArgs("SHOW CREATE USER", "'test_show_create_user'@'asdf'").Error()) 398 399 // Case: a user that doesn't exist 400 err = tk.QueryToErr("show create user 'aaa'@'localhost';") 401 c.Assert(err.Error(), Equals, interlock.ErrCannotUser.GenWithStackByArgs("SHOW CREATE USER", "'aaa'@'localhost'").Error()) 402 403 tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "127.0.0.1", AuthUsername: "root", AuthHostname: "%"}, nil, nil) 404 rows := tk.MustQuery("show create user current_user") 405 rows.Check(testkit.Events("CREATE USER 'root'@'127.0.0.1' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK")) 406 407 rows = tk.MustQuery("show create user current_user()") 408 rows.Check(testkit.Events("CREATE USER 'root'@'127.0.0.1' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK")) 409 410 tk.MustInterDirc("create user 'check_priv'") 411 412 // "show create user" for other user requires the SELECT privilege on allegrosql database. 413 tk1 := testkit.NewTestKit(c, s.causetstore) 414 tk1.MustInterDirc("use allegrosql") 415 succ := tk1.Se.Auth(&auth.UserIdentity{Username: "check_priv", Hostname: "127.0.0.1", AuthUsername: "test_show", AuthHostname: "asdf"}, nil, nil) 416 c.Assert(succ, IsTrue) 417 err = tk1.QueryToErr("show create user 'root'@'%'") 418 c.Assert(err, NotNil) 419 420 // "show create user" for current user doesn't check privileges. 421 rows = tk1.MustQuery("show create user current_user") 422 rows.Check(testkit.Events("CREATE USER 'check_priv'@'127.0.0.1' IDENTIFIED WITH 'mysql_native_password' AS '' REQUIRE NONE PASSWORD EXPIRE DEFAULT ACCOUNT UNLOCK")) 423 } 424 425 func (s *testSuite5) TestUnprivilegedShow(c *C) { 426 427 tk := testkit.NewTestKit(c, s.causetstore) 428 tk.MustInterDirc("CREATE DATABASE testshow") 429 tk.MustInterDirc("USE testshow") 430 tk.MustInterDirc("CREATE TABLE t1 (a int)") 431 tk.MustInterDirc("CREATE TABLE t2 (a int)") 432 433 tk.MustInterDirc(`CREATE USER 'lowprivuser'`) // no grants 434 435 tk.Se.Auth(&auth.UserIdentity{Username: "lowprivuser", Hostname: "192.168.0.1", AuthUsername: "lowprivuser", AuthHostname: "%"}, nil, []byte("012345678901234567890")) 436 rs, err := tk.InterDirc("SHOW TABLE STATUS FROM testshow") 437 c.Assert(err, IsNil) 438 c.Assert(rs, NotNil) 439 440 tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "192.168.0.1", AuthUsername: "root", AuthHostname: "%"}, nil, []byte("012345678901234567890")) 441 tk.MustInterDirc("GRANT ALL ON testshow.t1 TO 'lowprivuser'") 442 tk.Se.Auth(&auth.UserIdentity{Username: "lowprivuser", Hostname: "192.168.0.1", AuthUsername: "lowprivuser", AuthHostname: "%"}, nil, []byte("012345678901234567890")) 443 444 ctx := tk.Se.(stochastikctx.Context) 445 is := petri.GetPetri(ctx).SchemaReplicant() 446 tblInfo, err := is.BlockByName(perceptron.NewCIStr("testshow"), perceptron.NewCIStr("t1")) 447 c.Assert(err, IsNil) 448 createTime := perceptron.TSConvert2Time(tblInfo.Meta().UFIDelateTS).Format("2006-01-02 15:04:05") 449 450 tk.MustQuery("show causet status from testshow").Check(testkit.Events(fmt.Sprintf("t1 InnoDB 10 Compact 0 0 0 0 0 0 <nil> %s <nil> <nil> utf8mb4_bin ", createTime))) 451 452 } 453 454 func (s *testSuite5) TestDefCauslation(c *C) { 455 tk := testkit.NewTestKit(c, s.causetstore) 456 tk.MustInterDirc("use test") 457 458 rs, err := tk.InterDirc("show defCauslation;") 459 c.Assert(err, IsNil) 460 fields := rs.Fields() 461 c.Assert(fields[0].DeferredCauset.Tp, Equals, allegrosql.TypeVarchar) 462 c.Assert(fields[1].DeferredCauset.Tp, Equals, allegrosql.TypeVarchar) 463 c.Assert(fields[2].DeferredCauset.Tp, Equals, allegrosql.TypeLonglong) 464 c.Assert(fields[3].DeferredCauset.Tp, Equals, allegrosql.TypeVarchar) 465 c.Assert(fields[4].DeferredCauset.Tp, Equals, allegrosql.TypeVarchar) 466 c.Assert(fields[5].DeferredCauset.Tp, Equals, allegrosql.TypeLonglong) 467 } 468 469 func (s *testSuite5) TestShowBlockStatus(c *C) { 470 tk := testkit.NewTestKit(c, s.causetstore) 471 472 tk.MustInterDirc("use test") 473 tk.MustInterDirc(`drop causet if exists t;`) 474 tk.MustInterDirc(`create causet t(a bigint);`) 475 476 tk.Se.Auth(&auth.UserIdentity{Username: "root", Hostname: "192.168.0.1", AuthUsername: "root", AuthHostname: "%"}, nil, []byte("012345678901234567890")) 477 478 // It's not easy to test the result contents because every time the test runs, "Create_time" changed. 479 tk.MustInterDirc("show causet status;") 480 rs, err := tk.InterDirc("show causet status;") 481 c.Assert(errors.ErrorStack(err), Equals, "") 482 c.Assert(rs, NotNil) 483 rows, err := stochastik.GetEvents4Test(context.Background(), tk.Se, rs) 484 c.Assert(errors.ErrorStack(err), Equals, "") 485 err = rs.Close() 486 c.Assert(errors.ErrorStack(err), Equals, "") 487 488 for i := range rows { 489 event := rows[i] 490 c.Assert(event.GetString(0), Equals, "t") 491 c.Assert(event.GetString(1), Equals, "InnoDB") 492 c.Assert(event.GetInt64(2), Equals, int64(10)) 493 c.Assert(event.GetString(3), Equals, "Compact") 494 } 495 tk.MustInterDirc(`drop causet if exists tp;`) 496 tk.MustInterDirc(`create causet tp (a int) 497 partition by range(a) 498 ( partition p0 values less than (10), 499 partition p1 values less than (20), 500 partition p2 values less than (maxvalue) 501 );`) 502 rs, err = tk.InterDirc("show causet status from test like 'tp';") 503 c.Assert(errors.ErrorStack(err), Equals, "") 504 rows, err = stochastik.GetEvents4Test(context.Background(), tk.Se, rs) 505 c.Assert(errors.ErrorStack(err), Equals, "") 506 c.Assert(rows[0].GetString(16), Equals, "partitioned") 507 } 508 509 func (s *testSuite5) TestShowSlow(c *C) { 510 tk := testkit.NewTestKit(c, s.causetstore) 511 // The test result is volatile, because 512 // 1. Slow queries is stored in petri, which may be affected by other tests. 513 // 2. DefCauslecting slow queries is a asynchronous process, check immediately may not get the expected result. 514 // 3. Make slow query like "select sleep(1)" would slow the CI. 515 // So, we just cover the code but do not check the result. 516 tk.MustQuery(`admin show slow recent 3`) 517 tk.MustQuery(`admin show slow top 3`) 518 tk.MustQuery(`admin show slow top internal 3`) 519 tk.MustQuery(`admin show slow top all 3`) 520 } 521 522 func (s *testSuite5) TestShowOpenBlocks(c *C) { 523 tk := testkit.NewTestKit(c, s.causetstore) 524 tk.MustQuery("show open blocks") 525 tk.MustQuery("show open blocks in test") 526 } 527 528 func (s *testSuite5) TestShowCreateBlock(c *C) { 529 tk := testkit.NewTestKit(c, s.causetstore) 530 531 tk.MustInterDirc("use test") 532 tk.MustInterDirc("drop causet if exists t1") 533 tk.MustInterDirc("create causet t1(a int,b int)") 534 tk.MustInterDirc("drop view if exists v1") 535 tk.MustInterDirc("create or replace definer=`root`@`127.0.0.1` view v1 as select * from t1") 536 tk.MustQuery("show create causet v1").Check(solitonutil.EventsWithSep("|", "v1|CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` ALLEGROALLEGROSQL SECURITY DEFINER VIEW `v1` (`a`, `b`) AS SELECT `test`.`t1`.`a`,`test`.`t1`.`b` FROM `test`.`t1` ")) 537 tk.MustQuery("show create view v1").Check(solitonutil.EventsWithSep("|", "v1|CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` ALLEGROALLEGROSQL SECURITY DEFINER VIEW `v1` (`a`, `b`) AS SELECT `test`.`t1`.`a`,`test`.`t1`.`b` FROM `test`.`t1` ")) 538 tk.MustInterDirc("drop view v1") 539 tk.MustInterDirc("drop causet t1") 540 541 tk.MustInterDirc("drop view if exists v") 542 tk.MustInterDirc("create or replace definer=`root`@`127.0.0.1` view v as select JSON_MERGE('{}', '{}') as defCaus;") 543 tk.MustQuery("show create view v").Check(solitonutil.EventsWithSep("|", "v|CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` ALLEGROALLEGROSQL SECURITY DEFINER VIEW `v` (`defCaus`) AS SELECT JSON_MERGE('{}', '{}') AS `defCaus` ")) 544 tk.MustInterDirc("drop view if exists v") 545 546 tk.MustInterDirc("drop causet if exists t1") 547 tk.MustInterDirc("create causet t1(a int,b int)") 548 tk.MustInterDirc("create or replace definer=`root`@`127.0.0.1` view v1 as select avg(a),t1.* from t1 group by a") 549 tk.MustQuery("show create view v1").Check(solitonutil.EventsWithSep("|", "v1|CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` ALLEGROALLEGROSQL SECURITY DEFINER VIEW `v1` (`avg(a)`, `a`, `b`) AS SELECT AVG(`a`),`test`.`t1`.`a`,`test`.`t1`.`b` FROM `test`.`t1` GROUP BY `a` ")) 550 tk.MustInterDirc("drop view v1") 551 tk.MustInterDirc("create or replace definer=`root`@`127.0.0.1` view v1 as select a+b, t1.* , a as c from t1") 552 tk.MustQuery("show create view v1").Check(solitonutil.EventsWithSep("|", "v1|CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`127.0.0.1` ALLEGROALLEGROSQL SECURITY DEFINER VIEW `v1` (`a+b`, `a`, `b`, `c`) AS SELECT `a`+`b`,`test`.`t1`.`a`,`test`.`t1`.`b`,`a` AS `c` FROM `test`.`t1` ")) 553 tk.MustInterDirc("drop causet t1") 554 tk.MustInterDirc("drop view v1") 555 556 // For issue #9211 557 tk.MustInterDirc("create causet t(c int, b int as (c + 1))ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;") 558 tk.MustQuery("show create causet `t`").Check(solitonutil.EventsWithSep("|", 559 ""+ 560 "t CREATE TABLE `t` (\n"+ 561 " `c` int(11) DEFAULT NULL,\n"+ 562 " `b` int(11) GENERATED ALWAYS AS (`c` + 1) VIRTUAL\n"+ 563 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 564 )) 565 566 tk.MustInterDirc("drop causet t") 567 tk.MustInterDirc("create causet t(c int, b int as (c + 1) not null)ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;") 568 tk.MustQuery("show create causet `t`").Check(solitonutil.EventsWithSep("|", 569 ""+ 570 "t CREATE TABLE `t` (\n"+ 571 " `c` int(11) DEFAULT NULL,\n"+ 572 " `b` int(11) GENERATED ALWAYS AS (`c` + 1) VIRTUAL NOT NULL\n"+ 573 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 574 )) 575 tk.MustInterDirc("drop causet t") 576 tk.MustInterDirc("create causet t ( a char(10) charset utf8 defCauslate utf8_bin, b char(10) as (rtrim(a)));") 577 tk.MustQuery("show create causet `t`").Check(solitonutil.EventsWithSep("|", 578 ""+ 579 "t CREATE TABLE `t` (\n"+ 580 " `a` char(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,\n"+ 581 " `b` char(10) GENERATED ALWAYS AS (rtrim(`a`)) VIRTUAL\n"+ 582 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 583 )) 584 tk.MustInterDirc("drop causet t") 585 586 tk.MustInterDirc(`drop causet if exists different_charset`) 587 tk.MustInterDirc(`create causet different_charset(ch1 varchar(10) charset utf8, ch2 varchar(10) charset binary);`) 588 tk.MustQuery(`show create causet different_charset`).Check(solitonutil.EventsWithSep("|", 589 ""+ 590 "different_charset CREATE TABLE `different_charset` (\n"+ 591 " `ch1` varchar(10) CHARACTER SET utf8 COLLATE utf8_bin DEFAULT NULL,\n"+ 592 " `ch2` varbinary(10) DEFAULT NULL\n"+ 593 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 594 )) 595 596 tk.MustInterDirc("drop causet if exists t") 597 tk.MustInterDirc("create causet `t` (\n" + 598 "`a` timestamp not null default current_timestamp,\n" + 599 "`b` timestamp(3) default current_timestamp(3),\n" + 600 "`c` datetime default current_timestamp,\n" + 601 "`d` datetime(4) default current_timestamp(4),\n" + 602 "`e` varchar(20) default 'cUrrent_tImestamp',\n" + 603 "`f` datetime(2) default current_timestamp(2) on uFIDelate current_timestamp(2),\n" + 604 "`g` timestamp(2) default current_timestamp(2) on uFIDelate current_timestamp(2))") 605 tk.MustQuery("show create causet `t`").Check(solitonutil.EventsWithSep("|", 606 ""+ 607 "t CREATE TABLE `t` (\n"+ 608 " `a` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\n"+ 609 " `b` timestamp(3) DEFAULT CURRENT_TIMESTAMP(3),\n"+ 610 " `c` datetime DEFAULT CURRENT_TIMESTAMP,\n"+ 611 " `d` datetime(4) DEFAULT CURRENT_TIMESTAMP(4),\n"+ 612 " `e` varchar(20) DEFAULT 'cUrrent_tImestamp',\n"+ 613 " `f` datetime(2) DEFAULT CURRENT_TIMESTAMP(2) ON UFIDelATE CURRENT_TIMESTAMP(2),\n"+ 614 " `g` timestamp(2) DEFAULT CURRENT_TIMESTAMP(2) ON UFIDelATE CURRENT_TIMESTAMP(2)\n"+ 615 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 616 )) 617 tk.MustInterDirc("drop causet t") 618 619 tk.MustInterDirc("create causet t (a int, b int) shard_row_id_bits = 4 pre_split_regions=3;") 620 tk.MustQuery("show create causet `t`").Check(solitonutil.EventsWithSep("|", 621 ""+ 622 "t CREATE TABLE `t` (\n"+ 623 " `a` int(11) DEFAULT NULL,\n"+ 624 " `b` int(11) DEFAULT NULL\n"+ 625 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin/*!90000 SHARD_ROW_ID_BITS=4 PRE_SPLIT_REGIONS=3 */", 626 )) 627 tk.MustInterDirc("drop causet t") 628 629 tk.MustInterDirc("CREATE TABLE `log` (" + 630 "`LOG_ID` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT," + 631 "`ROUND_ID` bigint(20) UNSIGNED NOT NULL," + 632 "`USER_ID` int(10) UNSIGNED NOT NULL," + 633 "`USER_IP` int(10) UNSIGNED DEFAULT NULL," + 634 "`END_TIME` datetime NOT NULL," + 635 "`USER_TYPE` int(11) DEFAULT NULL," + 636 "`APP_ID` int(11) DEFAULT NULL," + 637 "PRIMARY KEY (`LOG_ID`,`END_TIME`)," + 638 "KEY `IDX_EndTime` (`END_TIME`)," + 639 "KEY `IDX_RoundId` (`ROUND_ID`)," + 640 "KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)" + 641 ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488 " + 642 "PARTITION BY RANGE ( month(`end_time`) ) (" + 643 "PARTITION `p1` VALUES LESS THAN (2)," + 644 "PARTITION `p2` VALUES LESS THAN (3)," + 645 "PARTITION `p3` VALUES LESS THAN (4)," + 646 "PARTITION `p4` VALUES LESS THAN (5)," + 647 "PARTITION `p5` VALUES LESS THAN (6)," + 648 "PARTITION `p6` VALUES LESS THAN (7)," + 649 "PARTITION `p7` VALUES LESS THAN (8)," + 650 "PARTITION `p8` VALUES LESS THAN (9)," + 651 "PARTITION `p9` VALUES LESS THAN (10)," + 652 "PARTITION `p10` VALUES LESS THAN (11)," + 653 "PARTITION `p11` VALUES LESS THAN (12)," + 654 "PARTITION `p12` VALUES LESS THAN (MAXVALUE))") 655 tk.MustQuery("show create causet log").Check(solitonutil.EventsWithSep("|", 656 "log CREATE TABLE `log` (\n"+ 657 " `LOG_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n"+ 658 " `ROUND_ID` bigint(20) unsigned NOT NULL,\n"+ 659 " `USER_ID` int(10) unsigned NOT NULL,\n"+ 660 " `USER_IP` int(10) unsigned DEFAULT NULL,\n"+ 661 " `END_TIME` datetime NOT NULL,\n"+ 662 " `USER_TYPE` int(11) DEFAULT NULL,\n"+ 663 " `APP_ID` int(11) DEFAULT NULL,\n"+ 664 " PRIMARY KEY (`LOG_ID`,`END_TIME`),\n"+ 665 " KEY `IDX_EndTime` (`END_TIME`),\n"+ 666 " KEY `IDX_RoundId` (`ROUND_ID`),\n"+ 667 " KEY `IDX_UserId_EndTime` (`USER_ID`,`END_TIME`)\n"+ 668 ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=505488\n"+ 669 "PARTITION BY RANGE ( MONTH(`end_time`) ) (\n"+ 670 " PARTITION `p1` VALUES LESS THAN (2),\n"+ 671 " PARTITION `p2` VALUES LESS THAN (3),\n"+ 672 " PARTITION `p3` VALUES LESS THAN (4),\n"+ 673 " PARTITION `p4` VALUES LESS THAN (5),\n"+ 674 " PARTITION `p5` VALUES LESS THAN (6),\n"+ 675 " PARTITION `p6` VALUES LESS THAN (7),\n"+ 676 " PARTITION `p7` VALUES LESS THAN (8),\n"+ 677 " PARTITION `p8` VALUES LESS THAN (9),\n"+ 678 " PARTITION `p9` VALUES LESS THAN (10),\n"+ 679 " PARTITION `p10` VALUES LESS THAN (11),\n"+ 680 " PARTITION `p11` VALUES LESS THAN (12),\n"+ 681 " PARTITION `p12` VALUES LESS THAN (MAXVALUE)\n"+ 682 ")")) 683 684 // for issue #11831 685 tk.MustInterDirc("create causet ttt4(a varchar(123) default null defCauslate utf8mb4_unicode_ci)engine=innodb default charset=utf8mb4 defCauslate=utf8mb4_unicode_ci;") 686 tk.MustQuery("show create causet `ttt4`").Check(solitonutil.EventsWithSep("|", 687 ""+ 688 "ttt4 CREATE TABLE `ttt4` (\n"+ 689 " `a` varchar(123) COLLATE utf8mb4_unicode_ci DEFAULT NULL\n"+ 690 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", 691 )) 692 tk.MustInterDirc("create causet ttt5(a varchar(123) default null)engine=innodb default charset=utf8mb4 defCauslate=utf8mb4_bin;") 693 tk.MustQuery("show create causet `ttt5`").Check(solitonutil.EventsWithSep("|", 694 ""+ 695 "ttt5 CREATE TABLE `ttt5` (\n"+ 696 " `a` varchar(123) DEFAULT NULL\n"+ 697 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 698 )) 699 700 // for memex index 701 tk.MustInterDirc("drop causet if exists t;") 702 tk.MustInterDirc("create causet t(a int, b real);") 703 tk.MustInterDirc("alter causet t add index expr_idx((a*b+1));") 704 tk.MustQuery("show create causet t;").Check(solitonutil.EventsWithSep("|", 705 ""+ 706 "t CREATE TABLE `t` (\n"+ 707 " `a` int(11) DEFAULT NULL,\n"+ 708 " `b` double DEFAULT NULL,\n"+ 709 " KEY `expr_idx` ((`a` * `b` + 1))\n"+ 710 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 711 )) 712 713 // Fix issue #15175, show create causet sequence_name. 714 tk.MustInterDirc("drop sequence if exists seq") 715 tk.MustInterDirc("create sequence seq") 716 tk.MustQuery("show create causet seq;").Check(testkit.Events("seq CREATE SEQUENCE `seq` start with 1 minvalue 1 maxvalue 9223372036854775806 increment by 1 cache 1000 nocycle ENGINE=InnoDB")) 717 718 // Test for issue #15633, 'binary' defCauslation should be ignored in the result of 'show create causet'. 719 tk.MustInterDirc(`drop causet if exists binary_defCauslate`) 720 tk.MustInterDirc(`create causet binary_defCauslate(a varchar(10)) default defCauslate=binary;`) 721 tk.MustQuery(`show create causet binary_defCauslate`).Check(solitonutil.EventsWithSep("|", 722 ""+ 723 "binary_defCauslate CREATE TABLE `binary_defCauslate` (\n"+ 724 " `a` varbinary(10) DEFAULT NULL\n"+ 725 ") ENGINE=InnoDB DEFAULT CHARSET=binary", // binary defCauslate is ignored 726 )) 727 tk.MustInterDirc(`drop causet if exists binary_defCauslate`) 728 tk.MustInterDirc(`create causet binary_defCauslate(a varchar(10)) default charset=binary defCauslate=binary;`) 729 tk.MustQuery(`show create causet binary_defCauslate`).Check(solitonutil.EventsWithSep("|", 730 ""+ 731 "binary_defCauslate CREATE TABLE `binary_defCauslate` (\n"+ 732 " `a` varbinary(10) DEFAULT NULL\n"+ 733 ") ENGINE=InnoDB DEFAULT CHARSET=binary", // binary defCauslate is ignored 734 )) 735 tk.MustInterDirc(`drop causet if exists binary_defCauslate`) 736 tk.MustInterDirc(`create causet binary_defCauslate(a varchar(10)) default charset=utf8mb4 defCauslate=utf8mb4_bin;`) 737 tk.MustQuery(`show create causet binary_defCauslate`).Check(solitonutil.EventsWithSep("|", 738 ""+ 739 "binary_defCauslate CREATE TABLE `binary_defCauslate` (\n"+ 740 " `a` varchar(10) DEFAULT NULL\n"+ 741 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", // non-binary defCauslate is kept. 742 )) 743 // Test for issue #17 in bug competition, default num and sequence should be shown without quote. 744 tk.MustInterDirc(`drop causet if exists default_num`) 745 tk.MustInterDirc("create causet default_num(a int default 11)") 746 tk.MustQuery("show create causet default_num").Check(solitonutil.EventsWithSep("|", 747 ""+ 748 "default_num CREATE TABLE `default_num` (\n"+ 749 " `a` int(11) DEFAULT 11\n"+ 750 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 751 )) 752 tk.MustInterDirc(`drop causet if exists default_varchar`) 753 tk.MustInterDirc("create causet default_varchar(a varchar(10) default \"haha\")") 754 tk.MustQuery("show create causet default_varchar").Check(solitonutil.EventsWithSep("|", 755 ""+ 756 "default_varchar CREATE TABLE `default_varchar` (\n"+ 757 " `a` varchar(10) DEFAULT 'haha'\n"+ 758 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 759 )) 760 tk.MustInterDirc(`drop causet if exists default_sequence`) 761 tk.MustInterDirc("create causet default_sequence(a int default nextval(seq))") 762 tk.MustQuery("show create causet default_sequence").Check(solitonutil.EventsWithSep("|", 763 ""+ 764 "default_sequence CREATE TABLE `default_sequence` (\n"+ 765 " `a` int(11) DEFAULT nextval(`test`.`seq`)\n"+ 766 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 767 )) 768 769 // MilevaDB defaults (and only supports) foreign_key_checks=0 770 // This means that the child causet can be created before the parent causet. 771 // This behavior is required for mysqldump restores. 772 tk.MustInterDirc(`DROP TABLE IF EXISTS parent, child`) 773 tk.MustInterDirc(`CREATE TABLE child (id INT NOT NULL PRIMARY KEY auto_increment, parent_id INT NOT NULL, INDEX par_ind (parent_id), CONSTRAINT child_ibfk_1 FOREIGN KEY (parent_id) REFERENCES parent(id))`) 774 tk.MustInterDirc(`CREATE TABLE parent ( id INT NOT NULL PRIMARY KEY auto_increment )`) 775 tk.MustQuery(`show create causet child`).Check(solitonutil.EventsWithSep("|", 776 ""+ 777 "child CREATE TABLE `child` (\n"+ 778 " `id` int(11) NOT NULL AUTO_INCREMENT,\n"+ 779 " `parent_id` int(11) NOT NULL,\n"+ 780 " PRIMARY KEY (`id`),\n"+ 781 " KEY `par_ind` (`parent_id`),\n"+ 782 " CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`)\n"+ 783 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 784 )) 785 786 // Test Foreign keys + ON DELETE / ON UFIDelATE 787 tk.MustInterDirc(`DROP TABLE child`) 788 tk.MustInterDirc(`CREATE TABLE child (id INT NOT NULL PRIMARY KEY auto_increment, parent_id INT NOT NULL, INDEX par_ind (parent_id), CONSTRAINT child_ibfk_1 FOREIGN KEY (parent_id) REFERENCES parent(id) ON DELETE SET NULL ON UFIDelATE CASCADE)`) 789 tk.MustQuery(`show create causet child`).Check(solitonutil.EventsWithSep("|", 790 ""+ 791 "child CREATE TABLE `child` (\n"+ 792 " `id` int(11) NOT NULL AUTO_INCREMENT,\n"+ 793 " `parent_id` int(11) NOT NULL,\n"+ 794 " PRIMARY KEY (`id`),\n"+ 795 " KEY `par_ind` (`parent_id`),\n"+ 796 " CONSTRAINT `child_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `parent` (`id`) ON DELETE SET NULL ON UFIDelATE CASCADE\n"+ 797 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 798 )) 799 800 } 801 802 func (s *testAutoRandomSuite) TestShowCreateBlockAutoRandom(c *C) { 803 tk := testkit.NewTestKit(c, s.causetstore) 804 tk.MustInterDirc("use test") 805 806 // Basic show create causet. 807 tk.MustInterDirc("create causet auto_random_tbl1 (a bigint primary key auto_random(3), b varchar(255))") 808 tk.MustQuery("show create causet `auto_random_tbl1`").Check(solitonutil.EventsWithSep("|", 809 ""+ 810 "auto_random_tbl1 CREATE TABLE `auto_random_tbl1` (\n"+ 811 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(3) */,\n"+ 812 " `b` varchar(255) DEFAULT NULL,\n"+ 813 " PRIMARY KEY (`a`)\n"+ 814 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 815 )) 816 817 // Implicit auto_random value should be shown explicitly. 818 tk.MustInterDirc("create causet auto_random_tbl2 (a bigint auto_random primary key, b char)") 819 tk.MustQuery("show create causet auto_random_tbl2").Check(solitonutil.EventsWithSep("|", 820 ""+ 821 "auto_random_tbl2 CREATE TABLE `auto_random_tbl2` (\n"+ 822 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 823 " `b` char(1) DEFAULT NULL,\n"+ 824 " PRIMARY KEY (`a`)\n"+ 825 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 826 )) 827 828 // Special version comment can be shown in MilevaDB with new version. 829 tk.MustInterDirc("create causet auto_random_tbl3 (a bigint /*T![auto_rand] auto_random */ primary key)") 830 tk.MustQuery("show create causet auto_random_tbl3").Check(solitonutil.EventsWithSep("|", 831 ""+ 832 "auto_random_tbl3 CREATE TABLE `auto_random_tbl3` (\n"+ 833 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 834 " PRIMARY KEY (`a`)\n"+ 835 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 836 )) 837 // Test show auto_random causet option. 838 tk.MustInterDirc("create causet auto_random_tbl4 (a bigint primary key auto_random(5), b varchar(255)) auto_random_base = 100") 839 tk.MustQuery("show create causet `auto_random_tbl4`").Check(solitonutil.EventsWithSep("|", 840 ""+ 841 "auto_random_tbl4 CREATE TABLE `auto_random_tbl4` (\n"+ 842 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 843 " `b` varchar(255) DEFAULT NULL,\n"+ 844 " PRIMARY KEY (`a`)\n"+ 845 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=100 */", 846 )) 847 // Test implicit auto_random with auto_random causet option. 848 tk.MustInterDirc("create causet auto_random_tbl5 (a bigint auto_random primary key, b char) auto_random_base 50") 849 tk.MustQuery("show create causet auto_random_tbl5").Check(solitonutil.EventsWithSep("|", 850 ""+ 851 "auto_random_tbl5 CREATE TABLE `auto_random_tbl5` (\n"+ 852 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 853 " `b` char(1) DEFAULT NULL,\n"+ 854 " PRIMARY KEY (`a`)\n"+ 855 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=50 */", 856 )) 857 // Test auto_random causet option already with special comment. 858 tk.MustInterDirc("create causet auto_random_tbl6 (a bigint /*T![auto_rand] auto_random */ primary key) auto_random_base 200") 859 tk.MustQuery("show create causet auto_random_tbl6").Check(solitonutil.EventsWithSep("|", 860 ""+ 861 "auto_random_tbl6 CREATE TABLE `auto_random_tbl6` (\n"+ 862 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 863 " PRIMARY KEY (`a`)\n"+ 864 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_rand_base] AUTO_RANDOM_BASE=200 */", 865 )) 866 } 867 868 // Override testAutoRandomSuite to test auto id cache. 869 func (s *testAutoRandomSuite) TestAutoIdCache(c *C) { 870 tk := testkit.NewTestKit(c, s.causetstore) 871 tk.MustInterDirc("use test") 872 873 tk.MustInterDirc("drop causet if exists t") 874 tk.MustInterDirc("create causet t(a int auto_increment key) auto_id_cache = 10") 875 tk.MustQuery("show create causet t").Check(solitonutil.EventsWithSep("|", 876 ""+ 877 "t CREATE TABLE `t` (\n"+ 878 " `a` int(11) NOT NULL AUTO_INCREMENT,\n"+ 879 " PRIMARY KEY (`a`)\n"+ 880 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=10 */", 881 )) 882 tk.MustInterDirc("drop causet if exists t") 883 tk.MustInterDirc("create causet t(a int auto_increment unique, b int key) auto_id_cache 100") 884 tk.MustQuery("show create causet t").Check(solitonutil.EventsWithSep("|", 885 ""+ 886 "t CREATE TABLE `t` (\n"+ 887 " `a` int(11) NOT NULL AUTO_INCREMENT,\n"+ 888 " `b` int(11) NOT NULL,\n"+ 889 " PRIMARY KEY (`b`),\n"+ 890 " UNIQUE KEY `a` (`a`)\n"+ 891 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=100 */", 892 )) 893 tk.MustInterDirc("drop causet if exists t") 894 tk.MustInterDirc("create causet t(a int key) auto_id_cache 5") 895 tk.MustQuery("show create causet t").Check(solitonutil.EventsWithSep("|", 896 ""+ 897 "t CREATE TABLE `t` (\n"+ 898 " `a` int(11) NOT NULL,\n"+ 899 " PRIMARY KEY (`a`)\n"+ 900 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin /*T![auto_id_cache] AUTO_ID_CACHE=5 */", 901 )) 902 } 903 904 func (s *testAutoRandomSuite) TestAutoRandomBase(c *C) { 905 c.Assert(failpoint.Enable("github.com/whtcorpsinc/milevadb/spacetime/autoid/mockAutoIDChange", `return(true)`), IsNil) 906 defer func() { 907 c.Assert(failpoint.Disable("github.com/whtcorpsinc/milevadb/spacetime/autoid/mockAutoIDChange"), IsNil) 908 }() 909 910 tk := testkit.NewTestKit(c, s.causetstore) 911 tk.MustInterDirc("set @@allow_auto_random_explicit_insert = true") 912 tk.MustInterDirc("use test") 913 914 tk.MustInterDirc("drop causet if exists t") 915 tk.MustInterDirc("create causet t (a bigint primary key auto_random(5), b int unique key auto_increment) auto_random_base = 100, auto_increment = 100") 916 tk.MustQuery("show create causet t").Check(solitonutil.EventsWithSep("|", 917 ""+ 918 "t CREATE TABLE `t` (\n"+ 919 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 920 " `b` int(11) NOT NULL AUTO_INCREMENT,\n"+ 921 " PRIMARY KEY (`a`),\n"+ 922 " UNIQUE KEY `b` (`b`)\n"+ 923 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=100 /*T![auto_rand_base] AUTO_RANDOM_BASE=100 */", 924 )) 925 926 tk.MustInterDirc("insert into t(`a`) values (1000)") 927 tk.MustQuery("show create causet t").Check(solitonutil.EventsWithSep("|", 928 ""+ 929 "t CREATE TABLE `t` (\n"+ 930 " `a` bigint(20) NOT NULL /*T![auto_rand] AUTO_RANDOM(5) */,\n"+ 931 " `b` int(11) NOT NULL AUTO_INCREMENT,\n"+ 932 " PRIMARY KEY (`a`),\n"+ 933 " UNIQUE KEY `b` (`b`)\n"+ 934 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=5100 /*T![auto_rand_base] AUTO_RANDOM_BASE=6001 */", 935 )) 936 } 937 938 func (s *testSuite5) TestShowEscape(c *C) { 939 tk := testkit.NewTestKit(c, s.causetstore) 940 941 tk.MustInterDirc("use test") 942 tk.MustInterDirc("drop causet if exists `t``abl\"e`") 943 tk.MustInterDirc("create causet `t``abl\"e`(`c``olum\"n` int(11) primary key)") 944 tk.MustQuery("show create causet `t``abl\"e`").Check(solitonutil.EventsWithSep("|", 945 ""+ 946 "t`abl\"e CREATE TABLE `t``abl\"e` (\n"+ 947 " `c``olum\"n` int(11) NOT NULL,\n"+ 948 " PRIMARY KEY (`c``olum\"n`)\n"+ 949 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 950 )) 951 952 // ANSI_QUOTES will change the SHOW output 953 tk.MustInterDirc("set @old_sql_mode=@@sql_mode") 954 tk.MustInterDirc("set sql_mode=ansi_quotes") 955 tk.MustQuery("show create causet \"t`abl\"\"e\"").Check(solitonutil.EventsWithSep("|", 956 ""+ 957 "t`abl\"e CREATE TABLE \"t`abl\"\"e\" (\n"+ 958 " \"c`olum\"\"n\" int(11) NOT NULL,\n"+ 959 " PRIMARY KEY (\"c`olum\"\"n\")\n"+ 960 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin", 961 )) 962 963 tk.MustInterDirc("rename causet \"t`abl\"\"e\" to t") 964 tk.MustInterDirc("set sql_mode=@old_sql_mode") 965 } 966 967 func (s *testSuite5) TestShowBuiltin(c *C) { 968 tk := testkit.NewTestKit(c, s.causetstore) 969 res := tk.MustQuery("show builtins;") 970 c.Assert(res, NotNil) 971 rows := res.Events() 972 c.Assert(268, Equals, len(rows)) 973 c.Assert("abs", Equals, rows[0][0].(string)) 974 c.Assert("yearweek", Equals, rows[267][0].(string)) 975 } 976 977 func (s *testSuite5) TestShowClusterConfig(c *C) { 978 tk := testkit.NewTestKit(c, s.causetstore) 979 tk.MustInterDirc("use test") 980 981 var confItems [][]types.Causet 982 var confErr error 983 var confFunc interlock.TestShowClusterConfigFunc = func() ([][]types.Causet, error) { 984 return confItems, confErr 985 } 986 tk.Se.SetValue(interlock.TestShowClusterConfigKey, confFunc) 987 strs2Items := func(strs ...string) []types.Causet { 988 items := make([]types.Causet, 0, len(strs)) 989 for _, s := range strs { 990 items = append(items, types.NewStringCauset(s)) 991 } 992 return items 993 } 994 confItems = append(confItems, strs2Items("milevadb", "127.0.0.1:1111", "log.level", "info")) 995 confItems = append(confItems, strs2Items("fidel", "127.0.0.1:2222", "log.level", "info")) 996 confItems = append(confItems, strs2Items("einsteindb", "127.0.0.1:3333", "log.level", "info")) 997 tk.MustQuery("show config").Check(testkit.Events( 998 "milevadb 127.0.0.1:1111 log.level info", 999 "fidel 127.0.0.1:2222 log.level info", 1000 "einsteindb 127.0.0.1:3333 log.level info")) 1001 tk.MustQuery("show config where type='milevadb'").Check(testkit.Events( 1002 "milevadb 127.0.0.1:1111 log.level info")) 1003 tk.MustQuery("show config where type like '%ti%'").Check(testkit.Events( 1004 "milevadb 127.0.0.1:1111 log.level info", 1005 "einsteindb 127.0.0.1:3333 log.level info")) 1006 1007 confErr = fmt.Errorf("something unknown error") 1008 c.Assert(tk.QueryToErr("show config"), ErrorMatches, confErr.Error()) 1009 } 1010 1011 func (s *testSerialSuite1) TestShowCreateBlockWithIntegerDisplayLengthWarnings(c *C) { 1012 BerolinaSQLtypes.MilevaDBStrictIntegerDisplayWidth = true 1013 defer func() { 1014 BerolinaSQLtypes.MilevaDBStrictIntegerDisplayWidth = false 1015 }() 1016 tk := testkit.NewTestKit(c, s.causetstore) 1017 tk.MustInterDirc("use test") 1018 1019 tk.MustInterDirc("drop causet if exists t") 1020 tk.MustInterDirc("create causet t(a int(2), b varchar(2))") 1021 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1022 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1023 " `a` int DEFAULT NULL,\n" + 1024 " `b` varchar(2) DEFAULT NULL\n" + 1025 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1026 1027 tk.MustInterDirc("drop causet if exists t") 1028 tk.MustInterDirc("create causet t(a bigint(10), b bigint)") 1029 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1030 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1031 " `a` bigint DEFAULT NULL,\n" + 1032 " `b` bigint DEFAULT NULL\n" + 1033 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1034 1035 tk.MustInterDirc("drop causet if exists t") 1036 tk.MustInterDirc("create causet t(a tinyint(5), b tinyint(2), c tinyint)") 1037 // Here it will occur 2 warnings. 1038 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.", 1039 "Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1040 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1041 " `a` tinyint DEFAULT NULL,\n" + 1042 " `b` tinyint DEFAULT NULL,\n" + 1043 " `c` tinyint DEFAULT NULL\n" + 1044 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1045 1046 tk.MustInterDirc("drop causet if exists t") 1047 tk.MustInterDirc("create causet t(a smallint(5), b smallint)") 1048 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1049 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1050 " `a` smallint DEFAULT NULL,\n" + 1051 " `b` smallint DEFAULT NULL\n" + 1052 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1053 1054 tk.MustInterDirc("drop causet if exists t") 1055 tk.MustInterDirc("create causet t(a mediumint(5), b mediumint)") 1056 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1057 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1058 " `a` mediumint DEFAULT NULL,\n" + 1059 " `b` mediumint DEFAULT NULL\n" + 1060 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1061 1062 tk.MustInterDirc("drop causet if exists t") 1063 tk.MustInterDirc("create causet t(a int1(1), b int2(2), c int3, d int4, e int8)") 1064 tk.MustQuery("show warnings").Check(testkit.Events("Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.", 1065 "Warning 1064 You have an error in your ALLEGROALLEGROSQL syntax; check the manual that corresponds to your MilevaDB version for the right syntax to use [BerolinaSQL:1681]Integer display width is deprecated and will be removed in a future release.")) 1066 tk.MustQuery("show create causet t").Check(testkit.Events("t CREATE TABLE `t` (\n" + 1067 " `a` tinyint DEFAULT NULL,\n" + 1068 " `b` smallint DEFAULT NULL,\n" + 1069 " `c` mediumint DEFAULT NULL,\n" + 1070 " `d` int DEFAULT NULL,\n" + 1071 " `e` bigint DEFAULT NULL\n" + 1072 ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin")) 1073 }