From 4fb23b2982ac06f6fa87dc11c41459b61a73ca38 Mon Sep 17 00:00:00 2001 From: Jackson Date: Sun, 3 Mar 2024 19:09:42 +0800 Subject: [PATCH 1/2] pick 'chore: stable bvt case result abort statement query_type (#14569)' in 1.1 --- .../statement_query_type/regression.result | 22 + .../cases/statement_query_type/regression.sql | 31 + .../statement_query_type.result | 701 ------------------ .../statement_query_type.sql | 352 --------- .../statement_query_type_1.result | 187 +++++ .../statement_query_type_1.sql | 156 ++++ .../statement_query_type_2.result | 111 +++ .../statement_query_type_2.sql | 96 +++ .../statement_query_type_3.result | 104 +++ .../statement_query_type_3.sql | 90 +++ .../statement_query_type_1.result | 98 +++ .../statement_query_type_1.sql | 5 + .../statement_query_type_2.result | 68 ++ .../statement_query_type_2.sql | 5 + .../statement_query_type_3.result | 61 ++ .../statement_query_type_3.sql | 5 + 16 files changed, 1039 insertions(+), 1053 deletions(-) create mode 100644 test/distributed/cases/statement_query_type/regression.result create mode 100644 test/distributed/cases/statement_query_type/regression.sql delete mode 100644 test/distributed/cases/statement_query_type/statement_query_type.result delete mode 100644 test/distributed/cases/statement_query_type/statement_query_type.sql create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_1.result create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_1.sql create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_2.result create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_2.sql create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_3.result create mode 100644 test/distributed/cases/statement_query_type/statement_query_type_3.sql create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_1.result create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_1.sql create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_2.result create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_2.sql create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_3.result create mode 100644 test/distributed/cases/zz_statement_query_type/statement_query_type_3.sql diff --git a/test/distributed/cases/statement_query_type/regression.result b/test/distributed/cases/statement_query_type/regression.result new file mode 100644 index 000000000000..94c61b5d6b5b --- /dev/null +++ b/test/distributed/cases/statement_query_type/regression.result @@ -0,0 +1,22 @@ +drop account if exists bvt_query_type_reg; +create account if not exists `bvt_query_type_reg` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; +create database statement_query_type; +begin; +use statement_query_type; +create table test_table(col1 int,col2 varchar); +create view test_view as select * from test_table; +show create view test_view; +View Create View +test_view create view test_view as select * from test_table; +show collation like 'utf8mb4_general_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +show collation like 'utf8mb4_general_ci%'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +load data infile '$resources/load_data/test.csv' into table test_table fields terminated by ','; +insert into test_table values (1,'a'),(2,'b'),(3,'c'); +update test_table set col2='xxx' where col1=1; +delete from test_table where col1=3; +rollback ; +drop account if exists bvt_query_type_reg; diff --git a/test/distributed/cases/statement_query_type/regression.sql b/test/distributed/cases/statement_query_type/regression.sql new file mode 100644 index 000000000000..3ce927480806 --- /dev/null +++ b/test/distributed/cases/statement_query_type/regression.sql @@ -0,0 +1,31 @@ +-- prepare account +drop account if exists bvt_query_type_reg; +create account if not exists `bvt_query_type_reg` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; + +-- Login account +-- @session:id=1&user=bvt_query_type_reg:admin:accountadmin&password=123456 + +create database statement_query_type; + +begin; +use statement_query_type; +create table test_table(col1 int,col2 varchar); +create view test_view as select * from test_table; +-- issue #7789 +show create view test_view; +show collation like 'utf8mb4_general_ci'; +show collation like 'utf8mb4_general_ci%'; +-- issue end +load data infile '$resources/load_data/test.csv' into table test_table fields terminated by ','; +insert into test_table values (1,'a'),(2,'b'),(3,'c'); +-- issue #7789 +update test_table set col2='xxx' where col1=1; +delete from test_table where col1=3; +-- issue end +rollback ; + +-- @session +-- END + +-- cleanup +drop account if exists bvt_query_type_reg; diff --git a/test/distributed/cases/statement_query_type/statement_query_type.result b/test/distributed/cases/statement_query_type/statement_query_type.result deleted file mode 100644 index adbae35b6672..000000000000 --- a/test/distributed/cases/statement_query_type/statement_query_type.result +++ /dev/null @@ -1,701 +0,0 @@ -drop account if exists bvt_query_type; -create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; -create database statement_query_type; -begin; -commit; -start transaction; -rollback; -drop database if exists test_db; -create database test_db; -use test_db; -drop table if exists test_table; -create table test_table( -col1 int, -col2 varchar -); -create view test_view as select * from test_table; -show create database test_db; -Database Create Database -test_db CREATE DATABASE `test_db` -show create table test_table; -Table Create Table -test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) -show create view test_view; -View Create View character_set_client collation_connection -test_view create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci -show triggers; -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -show procedure status; -Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation -show config; -1 -show events; -1 -show plugins; -1 -show profiles; -1 -show privileges; -1 -show tables; -Tables_in_test_db -test_table -test_view -show collation like 'utf8mb4_general_ci'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -show collation like 'utf8mb4_general_ci%'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -show index from test_table; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Index_params Visible Expression -values row(1,1), row(2,2), row(3,3) order by column_0 desc; -column_0 column_1 -3 3 -2 2 -1 1 -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -1 2 -1 2 -select * from unnest('{"a":1}') as f; -col seq key path index value this -UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -update test_table set col2='xxx' where col1=1; -delete from test_table where col1=3; -create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -internal error: do not have privilege to execute the statement -create role test_role; -create user user_name identified by 'password'; -create database if not exists db1; -grant create table,drop table on database *.* to test_role; -revoke test_role from user_name; -drop user user_name; -drop role test_role; -drop account test_account; -internal error: do not have privilege to execute the statement -drop database db1; -create database db2; -create table table_2( -col1 int, -col2 varchar -); -create view view_2 as select * from table_2; -create index index_table_2 on table_2(col1); -drop index index_table_2 on table_2; -drop view view_2; -drop table table_2; -drop database db2; -prepare s1 from select * from test_table where col1=?; -set @a=2; -execute s1 using @a; -col1 col2 -2 b -deallocate prepare s1; -select sleep(15); -sleep(15) -0 -drop table if exists test_01; -create table test_01(a int, b varchar); -show create table test_01; -Table Create Table -test_01 CREATE TABLE `test_01` (\n`a` INT DEFAULT NULL,\n`b` VARCHAR(65535) DEFAULT NULL\n) -insert into test_01 values (1,'a'); -insert into test_01 values (2,'b'); -update test_01 set a=100 where b='b'; -select * from test_01; -a b -1 a -100 b -select * from test_01; -a b -1 a -100 b -explain select * from test_01; -QUERY PLAN -Project - -> Table Scan on test_db.test_01 -delete from test_01 where a=1; -truncate table test_01; -drop table test_01; -drop database test_db; -use statement_query_type; -create database test_db; -begin; -use test_db; -create table test_table( -col1 int, -col2 varchar -); -create view test_view as select * from test_table; -show create database test_db; -Database Create Database -test_db CREATE DATABASE `test_db` -show create table test_table; -Table Create Table -test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) -show triggers; -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -show procedure status; -Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation -show config; -1 -show events; -1 -show plugins; -1 -show profiles; -1 -show privileges; -1 -show tables; -Tables_in_test_db -test_table -test_view -show index from test_table; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Index_params Visible Expression -values row(1,1), row(2,2), row(3,3) order by column_0 desc; -column_0 column_1 -3 3 -2 2 -1 1 -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -1 2 -1 2 -select * from unnest('{"a":1}') as f; -col seq key path index value this -UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -insert into test_table values (4,'d'); -create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -internal error: do not have privilege to execute the statement -create role test_role; -internal error: administrative command is unsupported in transactions -create user user_name identified by 'password'; -internal error: administrative command is unsupported in transactions -create database if not exists db1; -internal error: CREATE/DROP of database is not supported in transactions -grant create table,drop table on database *.* to test_role; -internal error: administrative command is unsupported in transactions -revoke test_role from user_name; -internal error: administrative command is unsupported in transactions -drop user user_name; -internal error: administrative command is unsupported in transactions -drop role test_role; -internal error: administrative command is unsupported in transactions -drop account test_account; -internal error: do not have privilege to execute the statement -drop database db1; -internal error: CREATE/DROP of database is not supported in transactions -create database db2; -internal error: CREATE/DROP of database is not supported in transactions -create table table_2( -col1 int, -col2 varchar -); -create view view_2 as select * from table_2; -create index index_table_2 on table_2(col1); -drop index index_table_2 on table_2; -drop view view_2; -drop table table_2; -drop database db2; -internal error: CREATE/DROP of database is not supported in transactions -prepare s1 from select * from test_table where col1=?; -set @a=2; -execute s1 using @a; -col1 col2 -2 b -deallocate prepare s1; -rollback; -use system; -select sleep(1); -sleep(1) -0 -select sleep(15); -sleep(15) -0 -select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="external_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count <1 order by request_at desc limit 104; -statement query_type sql_source_type -select sleep(1) DQL external_sql -use system Other external_sql -rollback TCL external_sql -deallocate prepare s1 Other external_sql -execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other external_sql -set @a=2 Other external_sql -prepare s1 from select * from test_table where col1=? Other external_sql -drop database db2 DDL external_sql -drop table table_2 DDL external_sql -drop view view_2 DDL external_sql -drop index index_table_2 on table_2 DDL external_sql -create index index_table_2 on table_2(col1) DDL external_sql -create view view_2 as select * from table_2 DDL external_sql -create table table_2(\ncol1 int,\ncol2 varchar\n) DDL external_sql -create database db2 DDL external_sql -drop database db1 DDL external_sql -drop account test_account DCL external_sql -drop role test_role DCL external_sql -drop user user_name DCL external_sql -revoke test_role from user_name DCL external_sql -grant create table,drop table on database *.* to test_role DCL external_sql -create database if not exists db1 DDL external_sql -create user user_name identified by '******' DCL external_sql -create role test_role DCL external_sql -create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL external_sql -values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL external_sql -show index from test_table Other external_sql -show tables Other external_sql -show privileges Other external_sql -show profiles Other external_sql -show plugins Other external_sql -show events Other external_sql -show config Other external_sql -show procedure status Other external_sql -show triggers Other external_sql -show create table test_table Other external_sql -show create database test_db Other external_sql -create view test_view as select * from test_table DDL external_sql -create table test_table(\ncol1 int,\ncol2 varchar\n) DDL external_sql -use test_db Other external_sql -begin TCL external_sql -create database test_db DDL external_sql -use statement_query_type Other external_sql -drop database test_db DDL external_sql -drop table test_01 DDL external_sql -truncate table test_01 DDL external_sql -delete from test_01 where a=1 DML external_sql -explain select * from test_01 Other external_sql -update test_01 set a=100 where b='b' DML external_sql -show create table test_01 Other external_sql -create table test_01(a int, b varchar) DDL external_sql -drop table if exists test_01 DDL external_sql -select sleep(15) DQL external_sql -deallocate prepare s1 Other external_sql -execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other external_sql -set @a=2 Other external_sql -prepare s1 from select * from test_table where col1=? Other external_sql -drop database db2 DDL external_sql -drop table table_2 DDL external_sql -drop view view_2 DDL external_sql -drop index index_table_2 on table_2 DDL external_sql -create index index_table_2 on table_2(col1) DDL external_sql -create view view_2 as select * from table_2 DDL external_sql -create table table_2(\ncol1 int,\ncol2 varchar\n) DDL external_sql -create database db2 DDL external_sql -drop database db1 DDL external_sql -drop account test_account DCL external_sql -drop role test_role DCL external_sql -drop user user_name DCL external_sql -revoke test_role from user_name DCL external_sql -grant create table,drop table on database *.* to test_role DCL external_sql -create database if not exists db1 DDL external_sql -create user user_name identified by '******' DCL external_sql -create role test_role DCL external_sql -create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL external_sql -delete from test_table where col1=3 DML external_sql -update test_table set col2='xxx' where col1=1 DML external_sql -insert into test_table values (1,'a'),(2,'b'),(3,'c') DML external_sql -values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL external_sql -show index from test_table Other external_sql -show collation like 'utf8mb4_general_ci%' Other external_sql -show collation like 'utf8mb4_general_ci' Other external_sql -show tables Other external_sql -show privileges Other external_sql -show profiles Other external_sql -show plugins Other external_sql -show events Other external_sql -show config Other external_sql -show procedure status Other external_sql -show triggers Other external_sql -show create view test_view Other external_sql -show create table test_table Other external_sql -show create database test_db Other external_sql -create view test_view as select * from test_table DDL external_sql -create table test_table(\ncol1 int,\ncol2 varchar\n) DDL external_sql -drop table if exists test_table DDL external_sql -use test_db Other external_sql -create database test_db DDL external_sql -drop database if exists test_db DDL external_sql -rollback TCL external_sql -start transaction TCL external_sql -commit TCL external_sql -begin TCL external_sql -create database statement_query_type DDL external_sql -/* cloud_user */ use statement_query_type; -/* cloud_user */ begin; -/* cloud_user */ commit; -/* cloud_user */ start transaction; -/* cloud_user */ rollback; -/* cloud_user */ drop database if exists test_db; -/* cloud_user */ create database test_db; -/* cloud_user */ use test_db; -/* cloud_user */ drop table if exists test_table; -/* cloud_user */ create table test_table(col1 int,col2 varchar); -/* cloud_user */ create view test_view as select * from test_table; -/* cloud_user */ show create database test_db; -Database Create Database -test_db CREATE DATABASE `test_db` -/* cloud_user */ show create table test_table; -Table Create Table -test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) -/* cloud_user */ show create view test_view; -View Create View character_set_client collation_connection -test_view /* cloud_user */ create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci -/* cloud_user */ show triggers; -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -/* cloud_user */ show procedure status; -Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation -/* cloud_user */ show config; -1 -/* cloud_user */ show events; -1 -/* cloud_user */ show plugins; -1 -/* cloud_user */ show profiles; -1 -/* cloud_user */ show privileges; -1 -/* cloud_user */ show tables; -Tables_in_test_db -test_table -test_view -/* cloud_user */ show collation like 'utf8mb4_general_ci'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -/* cloud_user */ show collation like 'utf8mb4_general_ci%'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -/* cloud_user */ show index from test_table; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Index_params Visible Expression -/* cloud_user */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; -column_0 column_1 -3 3 -2 2 -1 1 -/* cloud_user */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -1 2 -1 2 -/* cloud_user */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); -/* cloud_user */ update test_table set col2='xxx' where col1=1; -/* cloud_user */ delete from test_table where col1=3; -/* cloud_user */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -/* cloud_user */ create role test_role; -/* cloud_user */ create user user_name identified by 'password'; -/* cloud_user */ create database if not exists db1; -/* cloud_user */ grant create table,drop table on database *.* to test_role; -/* cloud_user */ revoke test_role from user_name; -/* cloud_user */ drop user user_name; -/* cloud_user */ drop role test_role; -/* cloud_user */ drop account test_account; -/* cloud_user */ drop database db1; -/* cloud_user */ create database db2; -/* cloud_user */ create table table_2(col1 int,col2 varchar); -/* cloud_user */ create view view_2 as select * from table_2; -/* cloud_user */ create index index_table_2 on table_2(col1); -/* cloud_user */ drop index index_table_2 on table_2; -/* cloud_user */ drop view view_2; -/* cloud_user */ drop table table_2; -/* cloud_user */ drop database db2; -/* cloud_user */ select * from unnest('{"a":1}') as f; -col seq key path index value this -UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} -/* cloud_user */ prepare s1 from select * from test_table where col1=?; -/* cloud_user */ set @a=2; -/* cloud_user */ execute s1 using @a; -col1 col2 -2 b -/* cloud_user */ deallocate prepare s1; -/* cloud_user */ drop table if exists test_01; -/* cloud_user */ create table test_01(a int, b varchar); -/* cloud_user */ show create table test_01; -Table Create Table -test_01 CREATE TABLE `test_01` (\n`a` INT DEFAULT NULL,\n`b` VARCHAR(65535) DEFAULT NULL\n) -/* cloud_user */ insert into test_01 values (1,'a'); -/* cloud_user */ insert into test_01 values (2,'b'); -/* cloud_user */ update test_01 set a=100 where b='b'; -/* cloud_user */ select * from test_01; -a b -1 a -100 b -/* cloud_user */ explain select * from test_01; -QUERY PLAN -Project - -> Table Scan on test_db.test_01 -/* cloud_user */ delete from test_01 where a=1; -/* cloud_user */ truncate table test_01; -/* cloud_user */ drop table test_01; -/* cloud_user */ use system; -/* cloud_user */ drop database test_db; -/* cloud_user */ select sleep(1); -sleep(1) -0 -select sleep(30); -sleep(30) -0 -/* cloud_user */ select statement,query_type,sql_source_type from system.statement_info where user="dump" and sql_source_type="cloud_user_sql" and status != "Running" and statement not like '%mo_ctl%' order by request_at desc limit 67; -statement query_type sql_source_type -select sleep(1) DQL cloud_user_sql -drop database test_db DDL cloud_user_sql -use system Other cloud_user_sql -drop table test_01 DDL cloud_user_sql -truncate table test_01 DDL cloud_user_sql -delete from test_01 where a=1 DML cloud_user_sql -explain select * from test_01 Other cloud_user_sql -select * from test_01 DQL cloud_user_sql -update test_01 set a=100 where b='b' DML cloud_user_sql -insert into test_01 values (2,'b') DML cloud_user_sql -insert into test_01 values (1,'a') DML cloud_user_sql -show create table test_01 Other cloud_user_sql -create table test_01(a int, b varchar) DDL cloud_user_sql -drop table if exists test_01 DDL cloud_user_sql -deallocate prepare s1 Other cloud_user_sql -execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other cloud_user_sql -set @a=2 Other cloud_user_sql -prepare s1 from select * from test_table where col1=? Other cloud_user_sql -select * from unnest('{"a":1}') as f DQL cloud_user_sql -drop database db2 DDL cloud_user_sql -drop table table_2 DDL cloud_user_sql -drop view view_2 DDL cloud_user_sql -drop index index_table_2 on table_2 DDL cloud_user_sql -create index index_table_2 on table_2(col1) DDL cloud_user_sql -create view view_2 as select * from table_2 DDL cloud_user_sql -create table table_2(col1 int,col2 varchar) DDL cloud_user_sql -create database db2 DDL cloud_user_sql -drop database db1 DDL cloud_user_sql -drop account test_account DCL cloud_user_sql -drop role test_role DCL cloud_user_sql -drop user user_name DCL cloud_user_sql -revoke test_role from user_name DCL cloud_user_sql -grant create table,drop table on database *.* to test_role DCL cloud_user_sql -create database if not exists db1 DDL cloud_user_sql -create user user_name identified by '******' DCL cloud_user_sql -create role test_role DCL cloud_user_sql -create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL cloud_user_sql -delete from test_table where col1=3 DML cloud_user_sql -update test_table set col2='xxx' where col1=1 DML cloud_user_sql -insert into test_table values (1,'a'),(2,'b'),(3,'c') DML cloud_user_sql -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2 DQL cloud_user_sql -values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL cloud_user_sql -show index from test_table Other cloud_user_sql -show collation like 'utf8mb4_general_ci%' Other cloud_user_sql -show collation like 'utf8mb4_general_ci' Other cloud_user_sql -show tables Other cloud_user_sql -show privileges Other cloud_user_sql -show profiles Other cloud_user_sql -show plugins Other cloud_user_sql -show events Other cloud_user_sql -show config Other cloud_user_sql -show procedure status Other cloud_user_sql -show triggers Other cloud_user_sql -show create view test_view Other cloud_user_sql -show create table test_table Other cloud_user_sql -show create database test_db Other cloud_user_sql -create view test_view as select * from test_table DDL cloud_user_sql -create table test_table(col1 int,col2 varchar) DDL cloud_user_sql -drop table if exists test_table DDL cloud_user_sql -use test_db Other cloud_user_sql -create database test_db DDL cloud_user_sql -drop database if exists test_db DDL cloud_user_sql -rollback TCL cloud_user_sql -start transaction TCL cloud_user_sql -commit TCL cloud_user_sql -begin TCL cloud_user_sql -use statement_query_type Other cloud_user_sql -/* cloud_nonuser */ use statement_query_type; -/* cloud_nonuser */ begin; -/* cloud_nonuser */ commit; -/* cloud_nonuser */ start transaction; -/* cloud_nonuser */ rollback; -/* cloud_nonuser */ drop database if exists test_db; -/* cloud_nonuser */ create database test_db; -/* cloud_nonuser */ use test_db; -/* cloud_nonuser */ drop table if exists test_table; -/* cloud_nonuser */ create table test_table(col1 int,col2 varchar); -/* cloud_nonuser */ create view test_view as select * from test_table; -/* cloud_nonuser */ show create database test_db; -Database Create Database -test_db CREATE DATABASE `test_db` -/* cloud_nonuser */ show create table test_table; -Table Create Table -test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) -/* cloud_nonuser */ show create view test_view; -View Create View character_set_client collation_connection -test_view /* cloud_nonuser */ create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci -/* cloud_nonuser */ show triggers; -Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation -/* cloud_nonuser */ show procedure status; -Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation -/* cloud_nonuser */ show config; -1 -/* cloud_nonuser */ show events; -1 -/* cloud_nonuser */ show plugins; -1 -/* cloud_nonuser */ show profiles; -1 -/* cloud_nonuser */ show privileges; -1 -/* cloud_nonuser */ show tables; -Tables_in_test_db -test_table -test_view -/* cloud_nonuser */ show collation like 'utf8mb4_general_ci'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -/* cloud_nonuser */ show collation like 'utf8mb4_general_ci%'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -/* cloud_nonuser */ show index from test_table; -Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Index_params Visible Expression -/* cloud_nonuser */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; -column_0 column_1 -3 3 -2 2 -1 1 -/* cloud_nonuser */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -1 2 -1 2 -/* cloud_nonuser */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); -/* cloud_nonuser */ update test_table set col2='xxx' where col1=1; -/* cloud_nonuser */ delete from test_table where col1=3; -/* cloud_nonuser */ select sleep(5); -sleep(5) -0 -/* cloud_nonuser */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -/* cloud_nonuser */ create role test_role; -/* cloud_nonuser */ create user user_name identified by 'password'; -/* cloud_nonuser */ create database if not exists db1; -/* cloud_nonuser */ grant create table,drop table on database *.* to test_role; -/* cloud_nonuser */ revoke test_role from user_name; -/* cloud_nonuser */ drop user user_name; -/* cloud_nonuser */ drop role test_role; -/* cloud_nonuser */ drop account test_account; -/* cloud_nonuser */ drop database db1; -/* cloud_nonuser */ create database db2; -/* cloud_nonuser */ create table table_2(col1 int,col2 varchar); -/* cloud_nonuser */ create view view_2 as select * from table_2; -/* cloud_nonuser */ create index index_table_2 on table_2(col1); -/* cloud_nonuser */ drop index index_table_2 on table_2; -/* cloud_nonuser */ drop view view_2; -/* cloud_nonuser */ drop table table_2; -/* cloud_nonuser */ drop database db2; -/* cloud_nonuser */ prepare s1 from select * from test_table where col1=?; -/* cloud_nonuser */ set @a=2; -/* cloud_nonuser */ execute s1 using @a; -col1 col2 -2 b -/* cloud_nonuser */ deallocate prepare s1; -/* cloud_nonuser */ drop table if exists test_01; -/* cloud_nonuser */ create table test_01(a int, b varchar); -/* cloud_nonuser */ show create table test_01; -Table Create Table -test_01 CREATE TABLE `test_01` (\n`a` INT DEFAULT NULL,\n`b` VARCHAR(65535) DEFAULT NULL\n) -/* cloud_nonuser */ insert into test_01 values (1,'a'); -/* cloud_nonuser */ insert into test_01 values (2,'b'); -/* cloud_nonuser */ update test_01 set a=100 where b='b'; -/* cloud_nonuser */ select * from unnest('{"a":1}') as f; -col seq key path index value this -UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} -/* cloud_nonuser */ select * from test_01; -a b -1 a -100 b -/* cloud_nonuser */ explain select * from test_01; -QUERY PLAN -Project - -> Table Scan on test_db.test_01 -/* cloud_nonuser */ delete from test_01 where a=1; -/* cloud_nonuser */ truncate table test_01; -/* cloud_nonuser */ drop table test_01; -/* cloud_nonuser */ use system; -/* cloud_nonuser */ drop database test_db; -/* cloud_nonuser */ select sleep(2); -sleep(2) -0 -select sleep(30); -sleep(30) -0 -/* cloud_nonuser */ select statement,query_type,sql_source_type from system.statement_info where user="dump" and sql_source_type="cloud_nonuser_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count = 0 order by request_at desc limit 68; -statement query_type sql_source_type -select sleep(2) DQL cloud_nonuser_sql -drop database test_db DDL cloud_nonuser_sql -use system Other cloud_nonuser_sql -drop table test_01 DDL cloud_nonuser_sql -truncate table test_01 DDL cloud_nonuser_sql -delete from test_01 where a=1 DML cloud_nonuser_sql -explain select * from test_01 Other cloud_nonuser_sql -update test_01 set a=100 where b='b' DML cloud_nonuser_sql -show create table test_01 Other cloud_nonuser_sql -create table test_01(a int, b varchar) DDL cloud_nonuser_sql -drop table if exists test_01 DDL cloud_nonuser_sql -deallocate prepare s1 Other cloud_nonuser_sql -execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other cloud_nonuser_sql -set @a=2 Other cloud_nonuser_sql -prepare s1 from select * from test_table where col1=? Other cloud_nonuser_sql -drop database db2 DDL cloud_nonuser_sql -drop table table_2 DDL cloud_nonuser_sql -drop view view_2 DDL cloud_nonuser_sql -drop index index_table_2 on table_2 DDL cloud_nonuser_sql -create index index_table_2 on table_2(col1) DDL cloud_nonuser_sql -create view view_2 as select * from table_2 DDL cloud_nonuser_sql -create table table_2(col1 int,col2 varchar) DDL cloud_nonuser_sql -create database db2 DDL cloud_nonuser_sql -drop database db1 DDL cloud_nonuser_sql -drop account test_account DCL cloud_nonuser_sql -drop role test_role DCL cloud_nonuser_sql -drop user user_name DCL cloud_nonuser_sql -revoke test_role from user_name DCL cloud_nonuser_sql -grant create table,drop table on database *.* to test_role DCL cloud_nonuser_sql -create database if not exists db1 DDL cloud_nonuser_sql -create user user_name identified by '******' DCL cloud_nonuser_sql -create role test_role DCL cloud_nonuser_sql -create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL cloud_nonuser_sql -select sleep(5) DQL cloud_nonuser_sql -delete from test_table where col1=3 DML cloud_nonuser_sql -update test_table set col2='xxx' where col1=1 DML cloud_nonuser_sql -insert into test_table values (1,'a'),(2,'b'),(3,'c') DML cloud_nonuser_sql -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2 DQL cloud_nonuser_sql -values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL cloud_nonuser_sql -show index from test_table Other cloud_nonuser_sql -show collation like 'utf8mb4_general_ci%' Other cloud_nonuser_sql -show collation like 'utf8mb4_general_ci' Other cloud_nonuser_sql -show tables Other cloud_nonuser_sql -show privileges Other cloud_nonuser_sql -show profiles Other cloud_nonuser_sql -show plugins Other cloud_nonuser_sql -show events Other cloud_nonuser_sql -show config Other cloud_nonuser_sql -show procedure status Other cloud_nonuser_sql -show triggers Other cloud_nonuser_sql -show create view test_view Other cloud_nonuser_sql -show create table test_table Other cloud_nonuser_sql -show create database test_db Other cloud_nonuser_sql -create view test_view as select * from test_table DDL cloud_nonuser_sql -create table test_table(col1 int,col2 varchar) DDL cloud_nonuser_sql -drop table if exists test_table DDL cloud_nonuser_sql -use test_db Other cloud_nonuser_sql -create database test_db DDL cloud_nonuser_sql -drop database if exists test_db DDL cloud_nonuser_sql -rollback TCL cloud_nonuser_sql -start transaction TCL cloud_nonuser_sql -commit TCL cloud_nonuser_sql -begin TCL cloud_nonuser_sql -use statement_query_type Other cloud_nonuser_sql -begin; -use statement_query_type; -create table test_table(col1 int,col2 varchar); -create view test_view as select * from test_table; -show create view test_view; -View Create View character_set_client collation_connection -test_view create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci -show collation like 'utf8mb4_general_ci'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -show collation like 'utf8mb4_general_ci%'; -Collation Charset Id Default Compiled Sortlen Pad_attribute -utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE -load data infile '$resources/load_data/test.csv' into table test_table; -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -update test_table set col2='xxx' where col1=1; -delete from test_table where col1=3; -rollback ; -drop account if exists bvt_query_type; diff --git a/test/distributed/cases/statement_query_type/statement_query_type.sql b/test/distributed/cases/statement_query_type/statement_query_type.sql deleted file mode 100644 index 1bc04a95ab65..000000000000 --- a/test/distributed/cases/statement_query_type/statement_query_type.sql +++ /dev/null @@ -1,352 +0,0 @@ --- prepare -drop account if exists bvt_query_type; -create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; - --- CASE: part 1 --- @session:id=1&user=bvt_query_type:admin:accountadmin&password=123456 -create database statement_query_type; - --- test TCL sql -begin; -commit; -start transaction; -rollback; - --- test DQL sql -drop database if exists test_db; -create database test_db; -use test_db; -drop table if exists test_table; -create table test_table( -col1 int, -col2 varchar -); -create view test_view as select * from test_table; -show create database test_db; -show create table test_table; -show create view test_view; -show triggers; -show procedure status; -show config; -show events; -show plugins; -show profiles; -show privileges; -show tables; -show collation like 'utf8mb4_general_ci'; -show collation like 'utf8mb4_general_ci%'; -show index from test_table; -values row(1,1), row(2,2), row(3,3) order by column_0 desc; -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -select * from unnest('{"a":1}') as f; - - --- test DML sql -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -update test_table set col2='xxx' where col1=1; -delete from test_table where col1=3; - - --- test DCL sql -create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -create role test_role; -create user user_name identified by 'password'; -create database if not exists db1; -grant create table,drop table on database *.* to test_role; -revoke test_role from user_name; -drop user user_name; -drop role test_role; -drop account test_account; -drop database db1; - - --- test DDL type -create database db2; -create table table_2( -col1 int, -col2 varchar -); -create view view_2 as select * from table_2; -create index index_table_2 on table_2(col1); - -drop index index_table_2 on table_2; -drop view view_2; -drop table table_2; -drop database db2; - - --- test other type -prepare s1 from select * from test_table where col1=?; -set @a=2; -execute s1 using @a; -deallocate prepare s1; - - --- test DDL and DQL -select sleep(15); -drop table if exists test_01; -create table test_01(a int, b varchar); -show create table test_01; -insert into test_01 values (1,'a'); -insert into test_01 values (2,'b'); -update test_01 set a=100 where b='b'; -select * from test_01; -select * from test_01; -explain select * from test_01; -delete from test_01 where a=1; -truncate table test_01; -drop table test_01; -drop database test_db; - - --- test sql executes in a transaction -use statement_query_type; -create database test_db; -begin; -use test_db; -create table test_table( -col1 int, -col2 varchar -); -create view test_view as select * from test_table; -show create database test_db; -show create table test_table; -show triggers; -show procedure status; -show config; -show events; -show plugins; -show profiles; -show privileges; -show tables; -show index from test_table; -values row(1,1), row(2,2), row(3,3) order by column_0 desc; -WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; -select * from unnest('{"a":1}') as f; - -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -insert into test_table values (4,'d'); - -create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -create role test_role; -create user user_name identified by 'password'; -create database if not exists db1; -grant create table,drop table on database *.* to test_role; -revoke test_role from user_name; -drop user user_name; -drop role test_role; -drop account test_account; -drop database db1; - -create database db2; -create table table_2( -col1 int, -col2 varchar -); -create view view_2 as select * from table_2; -create index index_table_2 on table_2(col1); - -drop index index_table_2 on table_2; -drop view view_2; -drop table table_2; -drop database db2; - -prepare s1 from select * from test_table where col1=?; -set @a=2; -execute s1 using @a; -deallocate prepare s1; -rollback; - -use system; -select sleep(1); --- @session - --- RESULT CHECK: part 1 -select sleep(15); -select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="external_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count <1 order by request_at desc limit 104; --- @bvt:issue - --- CASE: part 2 --- test cloud_user_sql type -/* cloud_user */ use statement_query_type; -/* cloud_user */ begin; -/* cloud_user */ commit; -/* cloud_user */ start transaction; -/* cloud_user */ rollback; - -/* cloud_user */ drop database if exists test_db; -/* cloud_user */ create database test_db; -/* cloud_user */ use test_db; -/* cloud_user */ drop table if exists test_table; -/* cloud_user */ create table test_table(col1 int,col2 varchar); -/* cloud_user */ create view test_view as select * from test_table; -/* cloud_user */ show create database test_db; -/* cloud_user */ show create table test_table; -/* cloud_user */ show create view test_view; -/* cloud_user */ show triggers; -/* cloud_user */ show procedure status; -/* cloud_user */ show config; -/* cloud_user */ show events; -/* cloud_user */ show plugins; -/* cloud_user */ show profiles; -/* cloud_user */ show privileges; -/* cloud_user */ show tables; -/* cloud_user */ show collation like 'utf8mb4_general_ci'; -/* cloud_user */ show collation like 'utf8mb4_general_ci%'; -/* cloud_user */ show index from test_table; -/* cloud_user */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; -/* cloud_user */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; - -/* cloud_user */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); -/* cloud_user */ update test_table set col2='xxx' where col1=1; -/* cloud_user */ delete from test_table where col1=3; - -/* cloud_user */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -/* cloud_user */ create role test_role; -/* cloud_user */ create user user_name identified by 'password'; -/* cloud_user */ create database if not exists db1; -/* cloud_user */ grant create table,drop table on database *.* to test_role; -/* cloud_user */ revoke test_role from user_name; -/* cloud_user */ drop user user_name; -/* cloud_user */ drop role test_role; -/* cloud_user */ drop account test_account; -/* cloud_user */ drop database db1; - -/* cloud_user */ create database db2; -/* cloud_user */ create table table_2(col1 int,col2 varchar); -/* cloud_user */ create view view_2 as select * from table_2; -/* cloud_user */ create index index_table_2 on table_2(col1); - -/* cloud_user */ drop index index_table_2 on table_2; -/* cloud_user */ drop view view_2; -/* cloud_user */ drop table table_2; -/* cloud_user */ drop database db2; - -/* cloud_user */ select * from unnest('{"a":1}') as f; -/* cloud_user */ prepare s1 from select * from test_table where col1=?; -/* cloud_user */ set @a=2; -/* cloud_user */ execute s1 using @a; -/* cloud_user */ deallocate prepare s1; - -/* cloud_user */ drop table if exists test_01; -/* cloud_user */ create table test_01(a int, b varchar); -/* cloud_user */ show create table test_01; -/* cloud_user */ insert into test_01 values (1,'a'); -/* cloud_user */ insert into test_01 values (2,'b'); -/* cloud_user */ update test_01 set a=100 where b='b'; -/* cloud_user */ select * from test_01; -/* cloud_user */ explain select * from test_01; -/* cloud_user */ delete from test_01 where a=1; -/* cloud_user */ truncate table test_01; -/* cloud_user */ drop table test_01; -/* cloud_user */ use system; -/* cloud_user */ drop database test_db; - -/* cloud_user */ select sleep(1); - --- RESULT CHECK: part 2 --- @session:id=1&user=bvt_query_type:admin:accountadmin&password=123456 -select sleep(30); --- @session -/* cloud_user */ select statement,query_type,sql_source_type from system.statement_info where user="dump" and sql_source_type="cloud_user_sql" and status != "Running" and statement not like '%mo_ctl%' order by request_at desc limit 67; - --- CASE: part 3 --- test cloud_no_user_sql type -/* cloud_nonuser */ use statement_query_type; -/* cloud_nonuser */ begin; -/* cloud_nonuser */ commit; -/* cloud_nonuser */ start transaction; -/* cloud_nonuser */ rollback; - -/* cloud_nonuser */ drop database if exists test_db; -/* cloud_nonuser */ create database test_db; -/* cloud_nonuser */ use test_db; -/* cloud_nonuser */ drop table if exists test_table; -/* cloud_nonuser */ create table test_table(col1 int,col2 varchar); -/* cloud_nonuser */ create view test_view as select * from test_table; -/* cloud_nonuser */ show create database test_db; -/* cloud_nonuser */ show create table test_table; -/* cloud_nonuser */ show create view test_view; -/* cloud_nonuser */ show triggers; -/* cloud_nonuser */ show procedure status; -/* cloud_nonuser */ show config; -/* cloud_nonuser */ show events; -/* cloud_nonuser */ show plugins; -/* cloud_nonuser */ show profiles; -/* cloud_nonuser */ show privileges; -/* cloud_nonuser */ show tables; -/* cloud_nonuser */ show collation like 'utf8mb4_general_ci'; -/* cloud_nonuser */ show collation like 'utf8mb4_general_ci%'; -/* cloud_nonuser */ show index from test_table; -/* cloud_nonuser */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; -/* cloud_nonuser */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; - -/* cloud_nonuser */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); -/* cloud_nonuser */ update test_table set col2='xxx' where col1=1; -/* cloud_nonuser */ delete from test_table where col1=3; -/* cloud_nonuser */ select sleep(5); - -/* cloud_nonuser */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; -/* cloud_nonuser */ create role test_role; -/* cloud_nonuser */ create user user_name identified by 'password'; -/* cloud_nonuser */ create database if not exists db1; -/* cloud_nonuser */ grant create table,drop table on database *.* to test_role; -/* cloud_nonuser */ revoke test_role from user_name; -/* cloud_nonuser */ drop user user_name; -/* cloud_nonuser */ drop role test_role; -/* cloud_nonuser */ drop account test_account; -/* cloud_nonuser */ drop database db1; - -/* cloud_nonuser */ create database db2; -/* cloud_nonuser */ create table table_2(col1 int,col2 varchar); -/* cloud_nonuser */ create view view_2 as select * from table_2; -/* cloud_nonuser */ create index index_table_2 on table_2(col1); - -/* cloud_nonuser */ drop index index_table_2 on table_2; -/* cloud_nonuser */ drop view view_2; -/* cloud_nonuser */ drop table table_2; -/* cloud_nonuser */ drop database db2; - -/* cloud_nonuser */ prepare s1 from select * from test_table where col1=?; -/* cloud_nonuser */ set @a=2; -/* cloud_nonuser */ execute s1 using @a; -/* cloud_nonuser */ deallocate prepare s1; - -/* cloud_nonuser */ drop table if exists test_01; -/* cloud_nonuser */ create table test_01(a int, b varchar); -/* cloud_nonuser */ show create table test_01; -/* cloud_nonuser */ insert into test_01 values (1,'a'); -/* cloud_nonuser */ insert into test_01 values (2,'b'); -/* cloud_nonuser */ update test_01 set a=100 where b='b'; -/* cloud_nonuser */ select * from unnest('{"a":1}') as f; -/* cloud_nonuser */ select * from test_01; -/* cloud_nonuser */ explain select * from test_01; -/* cloud_nonuser */ delete from test_01 where a=1; -/* cloud_nonuser */ truncate table test_01; -/* cloud_nonuser */ drop table test_01; -/* cloud_nonuser */ use system; -/* cloud_nonuser */ drop database test_db; -/* cloud_nonuser */ select sleep(2); - --- RESULT CHECK: part 3 --- @session:id=1&user=bvt_query_type:admin:accountadmin&password=123456 -select sleep(30); --- @session -/* cloud_nonuser */ select statement,query_type,sql_source_type from system.statement_info where user="dump" and sql_source_type="cloud_nonuser_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count = 0 order by request_at desc limit 68; - --- CASE: last -begin; -use statement_query_type; -create table test_table(col1 int,col2 varchar); -create view test_view as select * from test_table; -show create view test_view; -show collation like 'utf8mb4_general_ci'; -show collation like 'utf8mb4_general_ci%'; -load data infile '$resources/load_data/test.csv' into table test_table; -insert into test_table values (1,'a'),(2,'b'),(3,'c'); -update test_table set col2='xxx' where col1=1; -delete from test_table where col1=3; -rollback ; - --- cleanup -drop account if exists bvt_query_type; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_1.result b/test/distributed/cases/statement_query_type/statement_query_type_1.result new file mode 100644 index 000000000000..6e8257932a66 --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_1.result @@ -0,0 +1,187 @@ +drop account if exists bvt_query_type_part1; +create account if not exists `bvt_query_type_part1` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; +create database statement_query_type; +begin; +commit; +start transaction; +rollback; +drop database if exists test_db; +create database test_db; +use test_db; +drop table if exists test_table; +create table test_table( +col1 int, +col2 varchar +); +create view test_view as select * from test_table; +show create database test_db; +Database Create Database +test_db CREATE DATABASE `test_db` +show create table test_table; +Table Create Table +test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) +show create view test_view; +View Create View +test_view create view test_view as select * from test_table; +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +show procedure status; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +show config; +1 +show events; +1 +show plugins; +1 +show profiles; +1 +show privileges; +1 +show tables; +Tables_in_test_db +test_table +test_view +show collation like 'utf8mb4_general_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +show collation like 'utf8mb4_general_ci%'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +show index from test_table; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +values row(1,1), row(2,2), row(3,3) order by column_0 desc; +column_0 column_1 +3 3 +2 2 +1 1 +WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +1 2 +1 2 +select * from unnest('{"a":1}') as f; +col seq key path index value this +UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} +insert into test_table values (1,'a'),(2,'b'),(3,'c'); +update test_table set col2='xxx' where col1=1; +create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +internal error: do not have privilege to execute the statement +create role test_role; +create user user_name identified by 'password'; +create database if not exists db1; +grant create table,drop table on database *.* to test_role; +revoke test_role from user_name; +drop user user_name; +drop role test_role; +drop account test_account; +internal error: do not have privilege to execute the statement +drop database db1; +create database db2; +create table table_2( +col1 int, +col2 varchar +); +create view view_2 as select * from table_2; +create index index_table_2 on table_2(col1); +drop index index_table_2 on table_2; +drop view view_2; +drop table table_2; +drop database db2; +drop table if exists test_01; +create table test_01(a int, b varchar); +show create table test_01; +Table Create Table +test_01 CREATE TABLE `test_01` (\n`a` INT DEFAULT NULL,\n`b` VARCHAR(65535) DEFAULT NULL\n) +explain select * from test_01; +QUERY PLAN +Project + -> Table Scan on test_db.test_01 +delete from test_01 where a=1; +truncate table test_01; +drop table test_01; +drop database test_db; +use statement_query_type; +create database test_db; +begin; +use test_db; +create table test_table( +col1 int, +col2 varchar +); +create view test_view as select * from test_table; +show create database test_db; +Database Create Database +test_db CREATE DATABASE `test_db` +show create table test_table; +Table Create Table +test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) +show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +show procedure status; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +show config; +1 +show events; +1 +show plugins; +1 +show profiles; +1 +show privileges; +1 +show tables; +Tables_in_test_db +test_table +test_view +show index from test_table; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +values row(1,1), row(2,2), row(3,3) order by column_0 desc; +column_0 column_1 +3 3 +2 2 +1 1 +WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +1 2 +1 2 +select * from unnest('{"a":1}') as f; +col seq key path index value this +UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} +create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +internal error: do not have privilege to execute the statement +create role test_role; +internal error: administrative command is unsupported in transactions +create user user_name identified by 'password'; +internal error: administrative command is unsupported in transactions +create database if not exists db1; +internal error: CREATE/DROP of database is not supported in transactions +grant create table,drop table on database *.* to test_role; +internal error: administrative command is unsupported in transactions +revoke test_role from user_name; +internal error: administrative command is unsupported in transactions +drop user user_name; +internal error: administrative command is unsupported in transactions +drop role test_role; +internal error: administrative command is unsupported in transactions +drop account test_account; +internal error: do not have privilege to execute the statement +drop database db1; +internal error: CREATE/DROP of database is not supported in transactions +create database db2; +internal error: CREATE/DROP of database is not supported in transactions +create table table_2( +col1 int, +col2 varchar +); +create view view_2 as select * from table_2; +create index index_table_2 on table_2(col1); +drop index index_table_2 on table_2; +drop view view_2; +drop table table_2; +drop database db2; +internal error: CREATE/DROP of database is not supported in transactions +prepare s1 from select * from test_table where col1=?; +set @a=2; +execute s1 using @a; +col1 col2 +deallocate prepare s1; +rollback; +use system; +drop account if exists bvt_query_type_part1; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_1.sql b/test/distributed/cases/statement_query_type/statement_query_type_1.sql new file mode 100644 index 000000000000..434161446fc6 --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_1.sql @@ -0,0 +1,156 @@ +-- prepare +drop account if exists bvt_query_type_part1; +create account if not exists `bvt_query_type_part1` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; + +-- Login bvt_query_type_part1 account +-- @session:id=1&user=bvt_query_type_part1:admin:accountadmin&password=123456 + +-- CASE: part 1 +create database statement_query_type; + +-- test TCL sql +begin; +commit; +start transaction; +rollback; + +-- test DQL sql +drop database if exists test_db; +create database test_db; +use test_db; +drop table if exists test_table; +create table test_table( +col1 int, +col2 varchar +); +create view test_view as select * from test_table; +show create database test_db; +show create table test_table; +show create view test_view; +show triggers; +show procedure status; +show config; +show events; +show plugins; +show profiles; +show privileges; +show tables; +show collation like 'utf8mb4_general_ci'; +show collation like 'utf8mb4_general_ci%'; +show index from test_table; +values row(1,1), row(2,2), row(3,3) order by column_0 desc; +WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +select * from unnest('{"a":1}') as f; + + +-- test DML sql +insert into test_table values (1,'a'),(2,'b'),(3,'c'); +update test_table set col2='xxx' where col1=1; + + +-- test DCL sql +create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +create role test_role; +create user user_name identified by 'password'; +create database if not exists db1; +grant create table,drop table on database *.* to test_role; +revoke test_role from user_name; +drop user user_name; +drop role test_role; +drop account test_account; +drop database db1; + + +-- test DDL type +create database db2; +create table table_2( +col1 int, +col2 varchar +); +create view view_2 as select * from table_2; +create index index_table_2 on table_2(col1); + +drop index index_table_2 on table_2; +drop view view_2; +drop table table_2; +drop database db2; + +-- test DDL and DQL +drop table if exists test_01; +create table test_01(a int, b varchar); +show create table test_01; +explain select * from test_01; +delete from test_01 where a=1; +truncate table test_01; +drop table test_01; +drop database test_db; + + +-- test sql executes in a transaction +use statement_query_type; +create database test_db; +begin; +use test_db; +create table test_table( +col1 int, +col2 varchar +); +create view test_view as select * from test_table; +show create database test_db; +show create table test_table; +show triggers; +show procedure status; +show config; +show events; +show plugins; +show profiles; +show privileges; +show tables; +show index from test_table; +values row(1,1), row(2,2), row(3,3) order by column_0 desc; +WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +select * from unnest('{"a":1}') as f; + +create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +create role test_role; +create user user_name identified by 'password'; +create database if not exists db1; +grant create table,drop table on database *.* to test_role; +revoke test_role from user_name; +drop user user_name; +drop role test_role; +drop account test_account; +drop database db1; + +create database db2; +create table table_2( +col1 int, +col2 varchar +); +create view view_2 as select * from table_2; +create index index_table_2 on table_2(col1); + +drop index index_table_2 on table_2; +drop view view_2; +drop table table_2; +drop database db2; + +prepare s1 from select * from test_table where col1=?; +set @a=2; +execute s1 using @a; +deallocate prepare s1; +rollback; + +use system; +-- END part 1 +-- --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +-- @session +-- END + +-- +-- TIPs: DO NOT run this case multiple times in 15s +-- + +-- cleanup +drop account if exists bvt_query_type_part1; \ No newline at end of file diff --git a/test/distributed/cases/statement_query_type/statement_query_type_2.result b/test/distributed/cases/statement_query_type/statement_query_type_2.result new file mode 100644 index 000000000000..d4922d90f687 --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_2.result @@ -0,0 +1,111 @@ +drop account if exists bvt_query_type; +create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; +create database statement_query_type; +/* cloud_user */ use statement_query_type; +/* cloud_user */ begin; +/* cloud_user */ commit; +/* cloud_user */ start transaction; +/* cloud_user */ rollback; +/* cloud_user */ drop database if exists test_db; +/* cloud_user */ create database test_db; +/* cloud_user */ use test_db; +/* cloud_user */ drop table if exists test_table; +/* cloud_user */ create table test_table(col1 int,col2 varchar); +/* cloud_user */ create view test_view as select * from test_table; +/* cloud_user */ show create database test_db; +Database Create Database +test_db CREATE DATABASE `test_db` +/* cloud_user */ show create table test_table; +Table Create Table +test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) +/* cloud_user */ show create view test_view; +View Create View +test_view /* cloud_user */ create view test_view as select * from test_table; +/* cloud_user */ show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +/* cloud_user */ show procedure status; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +/* cloud_user */ show config; +1 +/* cloud_user */ show events; +1 +/* cloud_user */ show plugins; +1 +/* cloud_user */ show profiles; +1 +/* cloud_user */ show privileges; +1 +/* cloud_user */ show tables; +Tables_in_test_db +test_table +test_view +/* cloud_user */ show collation like 'utf8mb4_general_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +/* cloud_user */ show collation like 'utf8mb4_general_ci%'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +/* cloud_user */ show index from test_table; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +/* cloud_user */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; +column_0 column_1 +3 3 +2 2 +1 1 +/* cloud_user */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +1 2 +1 2 +/* cloud_user */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); +/* cloud_user */ update test_table set col2='xxx' where col1=1; +/* cloud_user */ delete from test_table where col1=3; +/* cloud_user */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +internal error: do not have privilege to execute the statement +/* cloud_user */ create role test_role; +/* cloud_user */ create user user_name identified by 'password'; +/* cloud_user */ create database if not exists db1; +/* cloud_user */ grant create table,drop table on database *.* to test_role; +/* cloud_user */ revoke test_role from user_name; +/* cloud_user */ drop user user_name; +/* cloud_user */ drop role test_role; +/* cloud_user */ drop account test_account; +internal error: do not have privilege to execute the statement +/* cloud_user */ drop database db1; +/* cloud_user */ create database db2; +/* cloud_user */ create table table_2(col1 int,col2 varchar); +/* cloud_user */ create view view_2 as select * from table_2; +/* cloud_user */ create index index_table_2 on table_2(col1); +/* cloud_user */ drop index index_table_2 on table_2; +/* cloud_user */ drop view view_2; +/* cloud_user */ drop table table_2; +/* cloud_user */ drop database db2; +/* cloud_user */ select * from unnest('{"a":1}') as f; +col seq key path index value this +UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} +/* cloud_user */ prepare s1 from select * from test_table where col1=?; +/* cloud_user */ set @a=2; +/* cloud_user */ execute s1 using @a; +col1 col2 +2 b +/* cloud_user */ deallocate prepare s1; +/* cloud_user */ drop table if exists test_01; +/* cloud_user */ create table test_01(a int, b varchar); +/* cloud_user */ show create table test_01; +Table Create Table +test_01 CREATE TABLE `test_01` (\n`a` INT DEFAULT NULL,\n`b` VARCHAR(65535) DEFAULT NULL\n) +/* cloud_user */ insert into test_01 values (1,'a'); +/* cloud_user */ insert into test_01 values (2,'b'); +/* cloud_user */ update test_01 set a=100 where b='b'; +/* cloud_user */ select * from test_01; +a b +1 a +100 b +/* cloud_user */ explain select * from test_01; +QUERY PLAN +Project + -> Table Scan on test_db.test_01 +/* cloud_user */ delete from test_01 where a=1; +/* cloud_user */ truncate table test_01; +/* cloud_user */ drop table test_01; +/* cloud_user */ use system; +/* cloud_user */ drop database test_db; +drop account if exists bvt_query_type; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_2.sql b/test/distributed/cases/statement_query_type/statement_query_type_2.sql new file mode 100644 index 000000000000..7a99ff3769ee --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_2.sql @@ -0,0 +1,96 @@ +-- prepare +drop account if exists bvt_query_type; +create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; + +-- Login bvt_query_type account +-- @session:id=1&user=bvt_query_type:admin:accountadmin&password=123456 + +create database statement_query_type; +-- CASE: part 2 +-- test cloud_user_sql type +/* cloud_user */ use statement_query_type; +/* cloud_user */ begin; +/* cloud_user */ commit; +/* cloud_user */ start transaction; +/* cloud_user */ rollback; + +/* cloud_user */ drop database if exists test_db; +/* cloud_user */ create database test_db; +/* cloud_user */ use test_db; +/* cloud_user */ drop table if exists test_table; +/* cloud_user */ create table test_table(col1 int,col2 varchar); +/* cloud_user */ create view test_view as select * from test_table; +/* cloud_user */ show create database test_db; +/* cloud_user */ show create table test_table; +/* cloud_user */ show create view test_view; +/* cloud_user */ show triggers; +/* cloud_user */ show procedure status; +/* cloud_user */ show config; +/* cloud_user */ show events; +/* cloud_user */ show plugins; +/* cloud_user */ show profiles; +/* cloud_user */ show privileges; +/* cloud_user */ show tables; +/* cloud_user */ show collation like 'utf8mb4_general_ci'; +/* cloud_user */ show collation like 'utf8mb4_general_ci%'; +/* cloud_user */ show index from test_table; +/* cloud_user */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; +/* cloud_user */ WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; + +/* cloud_user */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); +/* cloud_user */ update test_table set col2='xxx' where col1=1; +/* cloud_user */ delete from test_table where col1=3; + +/* cloud_user */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +/* cloud_user */ create role test_role; +/* cloud_user */ create user user_name identified by 'password'; +/* cloud_user */ create database if not exists db1; +/* cloud_user */ grant create table,drop table on database *.* to test_role; +/* cloud_user */ revoke test_role from user_name; +/* cloud_user */ drop user user_name; +/* cloud_user */ drop role test_role; +/* cloud_user */ drop account test_account; +/* cloud_user */ drop database db1; + +/* cloud_user */ create database db2; +/* cloud_user */ create table table_2(col1 int,col2 varchar); +/* cloud_user */ create view view_2 as select * from table_2; +/* cloud_user */ create index index_table_2 on table_2(col1); + +/* cloud_user */ drop index index_table_2 on table_2; +/* cloud_user */ drop view view_2; +/* cloud_user */ drop table table_2; +/* cloud_user */ drop database db2; + +/* cloud_user */ select * from unnest('{"a":1}') as f; +/* cloud_user */ prepare s1 from select * from test_table where col1=?; +/* cloud_user */ set @a=2; +/* cloud_user */ execute s1 using @a; +/* cloud_user */ deallocate prepare s1; + +/* cloud_user */ drop table if exists test_01; +/* cloud_user */ create table test_01(a int, b varchar); +/* cloud_user */ show create table test_01; +/* cloud_user */ insert into test_01 values (1,'a'); +/* cloud_user */ insert into test_01 values (2,'b'); +/* cloud_user */ update test_01 set a=100 where b='b'; +/* cloud_user */ select * from test_01; +/* cloud_user */ explain select * from test_01; +/* cloud_user */ delete from test_01 where a=1; +/* cloud_user */ truncate table test_01; +/* cloud_user */ drop table test_01; +/* cloud_user */ use system; +/* cloud_user */ drop database test_db; + +-- END part 2 +-- --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +-- @session +-- END + +-- +-- TIPs: DO NOT run this case multiple times in 15s +-- + +-- cleanup +drop account if exists bvt_query_type; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_3.result b/test/distributed/cases/statement_query_type/statement_query_type_3.result new file mode 100644 index 000000000000..f9a048bf7777 --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_3.result @@ -0,0 +1,104 @@ +drop account if exists bvt_query_type; +create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; +create database statement_query_type; +/* cloud_nonuser */ use statement_query_type; +/* cloud_nonuser */ begin; +/* cloud_nonuser */ commit; +/* cloud_nonuser */ start transaction; +/* cloud_nonuser */ rollback; +/* cloud_nonuser */ drop database if exists test_db; +/* cloud_nonuser */ create database test_db; +/* cloud_nonuser */ use test_db; +/* cloud_nonuser */ drop table if exists test_table; +/* cloud_nonuser */ create table test_table(col1 int,col2 varchar); +/* cloud_nonuser */ show create table test_table; +Table Create Table +test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) +/* cloud_nonuser */ create view test_view as select * from test_table; +/* cloud_nonuser */ show create database test_db; +Database Create Database +test_db CREATE DATABASE `test_db` +/* cloud_nonuser */ show create table test_table; +Table Create Table +test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) +/* cloud_nonuser */ show create view test_view; +View Create View +test_view /* cloud_nonuser */ create view test_view as select * from test_table; +/* cloud_nonuser */ show triggers; +Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation +/* cloud_nonuser */ show procedure status; +Db Name Type Definer Modified Created Security_type Comment character_set_client collation_connection Database Collation +/* cloud_nonuser */ show config; +1 +/* cloud_nonuser */ show events; +1 +/* cloud_nonuser */ show plugins; +1 +/* cloud_nonuser */ show profiles; +1 +/* cloud_nonuser */ show privileges; +1 +/* cloud_nonuser */ show tables; +Tables_in_test_db +test_table +test_view +/* cloud_nonuser */ show collation like 'utf8mb4_general_ci'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +/* cloud_nonuser */ show collation like 'utf8mb4_general_ci%'; +Collation Charset Id Default Compiled Sortlen Pad_attribute +utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE +/* cloud_nonuser */ show index from test_table; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression +/* cloud_nonuser */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; +column_0 column_1 +3 3 +2 2 +1 1 +/* cloud_nonuser */ WITH cte1 AS (SELECT sleep(1)),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; +sleep(1) 2 +0 2 +/* cloud_nonuser */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); +/* cloud_nonuser */ update test_table set col2='xxx' where col1=1; +/* cloud_nonuser */ delete from test_table where col1=3; +/* cloud_nonuser */ explain select * from test_table; +QUERY PLAN +Project + -> Table Scan on test_db.test_table +/* cloud_nonuser */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +internal error: do not have privilege to execute the statement +/* cloud_nonuser */ create role test_role; +/* cloud_nonuser */ create user user_name identified by 'password'; +/* cloud_nonuser */ create database if not exists db1; +/* cloud_nonuser */ grant create table,drop table on database *.* to test_role; +/* cloud_nonuser */ revoke test_role from user_name; +/* cloud_nonuser */ drop user user_name; +/* cloud_nonuser */ drop role test_role; +/* cloud_nonuser */ drop account test_account; +internal error: do not have privilege to execute the statement +/* cloud_nonuser */ drop database db1; +/* cloud_nonuser */ create database db2; +/* cloud_nonuser */ create table table_2(col1 int,col2 varchar); +/* cloud_nonuser */ create view view_2 as select * from table_2; +/* cloud_nonuser */ create index index_table_2 on table_2(col1); +/* cloud_nonuser */ drop index index_table_2 on table_2; +/* cloud_nonuser */ drop view view_2; +/* cloud_nonuser */ drop table table_2; +/* cloud_nonuser */ drop database db2; +/* cloud_nonuser */ prepare s1 from select * from test_table where col1=?; +/* cloud_nonuser */ set @a=2; +/* cloud_nonuser */ execute s1 using @a; +col1 col2 +2 b +/* cloud_nonuser */ deallocate prepare s1; +/* cloud_nonuser */ truncate table test_table; +/* cloud_nonuser */ drop table test_table; +/* cloud_nonuser */ select sleep(1), * from unnest('{"a":1}') as f; +sleep(1) col seq key path index value this +0 UNNEST_DEFAULT 0 a $.a null 1 {"a": 1} +/* cloud_nonuser */ use system; +/* cloud_nonuser */ drop database test_db; +select sleep(15); +sleep(15) +0 +drop account if exists bvt_query_type; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_3.sql b/test/distributed/cases/statement_query_type/statement_query_type_3.sql new file mode 100644 index 000000000000..81c1837f5e7b --- /dev/null +++ b/test/distributed/cases/statement_query_type/statement_query_type_3.sql @@ -0,0 +1,90 @@ +-- prepare +drop account if exists bvt_query_type; +create account if not exists `bvt_query_type` ADMIN_NAME 'admin' IDENTIFIED BY '123456'; + +-- Login bvt_query_type account +-- @session:id=1&user=bvt_query_type:admin:accountadmin&password=123456 + +create database statement_query_type; +-- CASE: part 3 +-- test cloud_no_user_sql type +/* cloud_nonuser */ use statement_query_type; +/* cloud_nonuser */ begin; +/* cloud_nonuser */ commit; +/* cloud_nonuser */ start transaction; +/* cloud_nonuser */ rollback; + +/* cloud_nonuser */ drop database if exists test_db; +/* cloud_nonuser */ create database test_db; +/* cloud_nonuser */ use test_db; +/* cloud_nonuser */ drop table if exists test_table; +/* cloud_nonuser */ create table test_table(col1 int,col2 varchar); +/* cloud_nonuser */ show create table test_table; +/* cloud_nonuser */ create view test_view as select * from test_table; +/* cloud_nonuser */ show create database test_db; +/* cloud_nonuser */ show create table test_table; +/* cloud_nonuser */ show create view test_view; +/* cloud_nonuser */ show triggers; +/* cloud_nonuser */ show procedure status; +/* cloud_nonuser */ show config; +/* cloud_nonuser */ show events; +/* cloud_nonuser */ show plugins; +/* cloud_nonuser */ show profiles; +/* cloud_nonuser */ show privileges; +/* cloud_nonuser */ show tables; +/* cloud_nonuser */ show collation like 'utf8mb4_general_ci'; +/* cloud_nonuser */ show collation like 'utf8mb4_general_ci%'; +/* cloud_nonuser */ show index from test_table; +/* cloud_nonuser */ values row(1,1), row(2,2), row(3,3) order by column_0 desc; +/* cloud_nonuser */ WITH cte1 AS (SELECT sleep(1)),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2; + +/* cloud_nonuser */ insert into test_table values (1,'a'),(2,'b'),(3,'c'); +/* cloud_nonuser */ update test_table set col2='xxx' where col1=1; +/* cloud_nonuser */ delete from test_table where col1=3; +/* cloud_nonuser */ explain select * from test_table; + +/* cloud_nonuser */ create account test_account admin_name = 'test_name' identified by '111' open comment 'tenant_test'; +/* cloud_nonuser */ create role test_role; +/* cloud_nonuser */ create user user_name identified by 'password'; +/* cloud_nonuser */ create database if not exists db1; +/* cloud_nonuser */ grant create table,drop table on database *.* to test_role; +/* cloud_nonuser */ revoke test_role from user_name; +/* cloud_nonuser */ drop user user_name; +/* cloud_nonuser */ drop role test_role; +/* cloud_nonuser */ drop account test_account; +/* cloud_nonuser */ drop database db1; + +/* cloud_nonuser */ create database db2; +/* cloud_nonuser */ create table table_2(col1 int,col2 varchar); +/* cloud_nonuser */ create view view_2 as select * from table_2; +/* cloud_nonuser */ create index index_table_2 on table_2(col1); + +/* cloud_nonuser */ drop index index_table_2 on table_2; +/* cloud_nonuser */ drop view view_2; +/* cloud_nonuser */ drop table table_2; +/* cloud_nonuser */ drop database db2; + +/* cloud_nonuser */ prepare s1 from select * from test_table where col1=?; +/* cloud_nonuser */ set @a=2; +/* cloud_nonuser */ execute s1 using @a; +/* cloud_nonuser */ deallocate prepare s1; +/* cloud_nonuser */ truncate table test_table; +/* cloud_nonuser */ drop table test_table; + +/* cloud_nonuser */ select sleep(1), * from unnest('{"a":1}') as f; +/* cloud_nonuser */ use system; +/* cloud_nonuser */ drop database test_db; + +-- END part 3 +-- --+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ + +-- @session +-- END ALL bvt_query_type query + +-- +-- TIPs: DO NOT run this case multiple times in 15s +-- +select sleep(15); + +-- cleanup +drop account if exists bvt_query_type; diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_1.result b/test/distributed/cases/zz_statement_query_type/statement_query_type_1.result new file mode 100644 index 000000000000..4c7eeb85347f --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_1.result @@ -0,0 +1,98 @@ +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type_part1" and sql_source_type="external_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count <1 order by request_at desc limit 96; +statement query_type sql_source_type +use system Other external_sql +rollback TCL external_sql +deallocate prepare s1 Other external_sql +execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other external_sql +set @a=2 Other external_sql +prepare s1 from select * from test_table where col1=? Other external_sql +drop database db2 DDL external_sql +drop table table_2 DDL external_sql +drop view view_2 DDL external_sql +drop index index_table_2 on table_2 DDL external_sql +create index index_table_2 on table_2(col1) DDL external_sql +create view view_2 as select * from table_2 DDL external_sql +create table table_2(\ncol1 int,\ncol2 varchar\n) DDL external_sql +create database db2 DDL external_sql +drop database db1 DDL external_sql +drop account test_account DCL external_sql +drop role test_role DCL external_sql +drop user user_name DCL external_sql +revoke test_role from user_name DCL external_sql +grant create table,drop table on database *.* to test_role DCL external_sql +create database if not exists db1 DDL external_sql +create user user_name identified by '******' DCL external_sql +create role test_role DCL external_sql +create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL external_sql +values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL external_sql +show index from test_table Other external_sql +show tables Other external_sql +show privileges Other external_sql +show profiles Other external_sql +show plugins Other external_sql +show events Other external_sql +show config Other external_sql +show procedure status Other external_sql +show triggers Other external_sql +show create table test_table Other external_sql +show create database test_db Other external_sql +create view test_view as select * from test_table DDL external_sql +create table test_table(\ncol1 int,\ncol2 varchar\n) DDL external_sql +use test_db Other external_sql +begin TCL external_sql +create database test_db DDL external_sql +use statement_query_type Other external_sql +drop database test_db DDL external_sql +drop table test_01 DDL external_sql +truncate table test_01 DDL external_sql +delete from test_01 where a=1 DML external_sql +explain select * from test_01 Other external_sql +show create table test_01 Other external_sql +create table test_01(a int, b varchar) DDL external_sql +drop table if exists test_01 DDL external_sql +drop database db2 DDL external_sql +drop table table_2 DDL external_sql +drop view view_2 DDL external_sql +drop index index_table_2 on table_2 DDL external_sql +create index index_table_2 on table_2(col1) DDL external_sql +create view view_2 as select * from table_2 DDL external_sql +create table table_2(\ncol1 int,\ncol2 varchar\n) DDL external_sql +create database db2 DDL external_sql +drop database db1 DDL external_sql +drop account test_account DCL external_sql +drop role test_role DCL external_sql +drop user user_name DCL external_sql +revoke test_role from user_name DCL external_sql +grant create table,drop table on database *.* to test_role DCL external_sql +create database if not exists db1 DDL external_sql +create user user_name identified by '******' DCL external_sql +create role test_role DCL external_sql +create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL external_sql +update test_table set col2='xxx' where col1=1 DML external_sql +insert into test_table values (1,'a'),(2,'b'),(3,'c') DML external_sql +values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL external_sql +show index from test_table Other external_sql +show collation like 'utf8mb4_general_ci%' Other external_sql +show collation like 'utf8mb4_general_ci' Other external_sql +show tables Other external_sql +show privileges Other external_sql +show profiles Other external_sql +show plugins Other external_sql +show events Other external_sql +show config Other external_sql +show procedure status Other external_sql +show triggers Other external_sql +show create view test_view Other external_sql +show create table test_table Other external_sql +show create database test_db Other external_sql +create view test_view as select * from test_table DDL external_sql +create table test_table(\ncol1 int,\ncol2 varchar\n) DDL external_sql +drop table if exists test_table DDL external_sql +use test_db Other external_sql +create database test_db DDL external_sql +drop database if exists test_db DDL external_sql +rollback TCL external_sql +start transaction TCL external_sql +commit TCL external_sql +begin TCL external_sql +create database statement_query_type DDL external_sql diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_1.sql b/test/distributed/cases/zz_statement_query_type/statement_query_type_1.sql new file mode 100644 index 000000000000..0b038067feba --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_1.sql @@ -0,0 +1,5 @@ +-- check result at the end of bvt. +-- check result of statement_query_type/statement_query_type_1.sql + +-- RESULT CHECK: part 1 +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type_part1" and sql_source_type="external_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count <1 order by request_at desc limit 96; diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_2.result b/test/distributed/cases/zz_statement_query_type/statement_query_type_2.result new file mode 100644 index 000000000000..26a949a75748 --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_2.result @@ -0,0 +1,68 @@ +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="cloud_user_sql" and status != "Running" and statement not like '%mo_ctl%' order by request_at desc limit 66; +statement query_type sql_source_type +drop database test_db DDL cloud_user_sql +use system Other cloud_user_sql +drop table test_01 DDL cloud_user_sql +truncate table test_01 DDL cloud_user_sql +delete from test_01 where a=1 DML cloud_user_sql +explain select * from test_01 Other cloud_user_sql +select * from test_01 DQL cloud_user_sql +update test_01 set a=100 where b='b' DML cloud_user_sql +insert into test_01 values (2,'b') DML cloud_user_sql +insert into test_01 values (1,'a') DML cloud_user_sql +show create table test_01 Other cloud_user_sql +create table test_01(a int, b varchar) DDL cloud_user_sql +drop table if exists test_01 DDL cloud_user_sql +deallocate prepare s1 Other cloud_user_sql +execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other cloud_user_sql +set @a=2 Other cloud_user_sql +prepare s1 from select * from test_table where col1=? Other cloud_user_sql +select * from unnest('{"a":1}') as f DQL cloud_user_sql +drop database db2 DDL cloud_user_sql +drop table table_2 DDL cloud_user_sql +drop view view_2 DDL cloud_user_sql +drop index index_table_2 on table_2 DDL cloud_user_sql +create index index_table_2 on table_2(col1) DDL cloud_user_sql +create view view_2 as select * from table_2 DDL cloud_user_sql +create table table_2(col1 int,col2 varchar) DDL cloud_user_sql +create database db2 DDL cloud_user_sql +drop database db1 DDL cloud_user_sql +drop account test_account DCL cloud_user_sql +drop role test_role DCL cloud_user_sql +drop user user_name DCL cloud_user_sql +revoke test_role from user_name DCL cloud_user_sql +grant create table,drop table on database *.* to test_role DCL cloud_user_sql +create database if not exists db1 DDL cloud_user_sql +create user user_name identified by '******' DCL cloud_user_sql +create role test_role DCL cloud_user_sql +create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL cloud_user_sql +delete from test_table where col1=3 DML cloud_user_sql +update test_table set col2='xxx' where col1=1 DML cloud_user_sql +insert into test_table values (1,'a'),(2,'b'),(3,'c') DML cloud_user_sql +WITH cte1 AS (SELECT 1),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2 DQL cloud_user_sql +values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL cloud_user_sql +show index from test_table Other cloud_user_sql +show collation like 'utf8mb4_general_ci%' Other cloud_user_sql +show collation like 'utf8mb4_general_ci' Other cloud_user_sql +show tables Other cloud_user_sql +show privileges Other cloud_user_sql +show profiles Other cloud_user_sql +show plugins Other cloud_user_sql +show events Other cloud_user_sql +show config Other cloud_user_sql +show procedure status Other cloud_user_sql +show triggers Other cloud_user_sql +show create view test_view Other cloud_user_sql +show create table test_table Other cloud_user_sql +show create database test_db Other cloud_user_sql +create view test_view as select * from test_table DDL cloud_user_sql +create table test_table(col1 int,col2 varchar) DDL cloud_user_sql +drop table if exists test_table DDL cloud_user_sql +use test_db Other cloud_user_sql +create database test_db DDL cloud_user_sql +drop database if exists test_db DDL cloud_user_sql +rollback TCL cloud_user_sql +start transaction TCL cloud_user_sql +commit TCL cloud_user_sql +begin TCL cloud_user_sql +use statement_query_type Other cloud_user_sql diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_2.sql b/test/distributed/cases/zz_statement_query_type/statement_query_type_2.sql new file mode 100644 index 000000000000..4fa2fd69795e --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_2.sql @@ -0,0 +1,5 @@ +-- check result at the end of bvt. +-- check result of statement_query_type/statement_query_type_2.sql + +-- RESULT CHECK: part 2 +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="cloud_user_sql" and status != "Running" and statement not like '%mo_ctl%' order by request_at desc limit 66; diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_3.result b/test/distributed/cases/zz_statement_query_type/statement_query_type_3.result new file mode 100644 index 000000000000..c4621cfa7d90 --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_3.result @@ -0,0 +1,61 @@ +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="cloud_nonuser_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count = 0 order by request_at desc limit 59; +statement query_type sql_source_type +drop database test_db DDL cloud_nonuser_sql +use system Other cloud_nonuser_sql +select sleep(1), * from unnest('{"a":1}') as f DQL cloud_nonuser_sql +drop table test_table DDL cloud_nonuser_sql +truncate table test_table DDL cloud_nonuser_sql +deallocate prepare s1 Other cloud_nonuser_sql +execute s1 using @a // prepare s1 from select * from test_table where col1=? ; set @a=2 Other cloud_nonuser_sql +set @a=2 Other cloud_nonuser_sql +prepare s1 from select * from test_table where col1=? Other cloud_nonuser_sql +drop database db2 DDL cloud_nonuser_sql +drop table table_2 DDL cloud_nonuser_sql +drop view view_2 DDL cloud_nonuser_sql +drop index index_table_2 on table_2 DDL cloud_nonuser_sql +create index index_table_2 on table_2(col1) DDL cloud_nonuser_sql +create view view_2 as select * from table_2 DDL cloud_nonuser_sql +create table table_2(col1 int,col2 varchar) DDL cloud_nonuser_sql +create database db2 DDL cloud_nonuser_sql +drop database db1 DDL cloud_nonuser_sql +drop account test_account DCL cloud_nonuser_sql +drop role test_role DCL cloud_nonuser_sql +drop user user_name DCL cloud_nonuser_sql +revoke test_role from user_name DCL cloud_nonuser_sql +grant create table,drop table on database *.* to test_role DCL cloud_nonuser_sql +create database if not exists db1 DDL cloud_nonuser_sql +create user user_name identified by '******' DCL cloud_nonuser_sql +create role test_role DCL cloud_nonuser_sql +create account test_account admin_name = 'test_name' identified by '******' open comment 'tenant_test' DCL cloud_nonuser_sql +explain select * from test_table Other cloud_nonuser_sql +delete from test_table where col1=3 DML cloud_nonuser_sql +update test_table set col2='xxx' where col1=1 DML cloud_nonuser_sql +insert into test_table values (1,'a'),(2,'b'),(3,'c') DML cloud_nonuser_sql +WITH cte1 AS (SELECT sleep(1)),cte2 AS (SELECT 2) SELECT * FROM cte1 join cte2 DQL cloud_nonuser_sql +values row(1,1), row(2,2), row(3,3) order by column_0 desc DQL cloud_nonuser_sql +show index from test_table Other cloud_nonuser_sql +show collation like 'utf8mb4_general_ci%' Other cloud_nonuser_sql +show collation like 'utf8mb4_general_ci' Other cloud_nonuser_sql +show tables Other cloud_nonuser_sql +show privileges Other cloud_nonuser_sql +show profiles Other cloud_nonuser_sql +show plugins Other cloud_nonuser_sql +show events Other cloud_nonuser_sql +show config Other cloud_nonuser_sql +show procedure status Other cloud_nonuser_sql +show triggers Other cloud_nonuser_sql +show create view test_view Other cloud_nonuser_sql +show create table test_table Other cloud_nonuser_sql +show create database test_db Other cloud_nonuser_sql +create view test_view as select * from test_table DDL cloud_nonuser_sql +show create table test_table Other cloud_nonuser_sql +create table test_table(col1 int,col2 varchar) DDL cloud_nonuser_sql +drop table if exists test_table DDL cloud_nonuser_sql +use test_db Other cloud_nonuser_sql +create database test_db DDL cloud_nonuser_sql +drop database if exists test_db DDL cloud_nonuser_sql +rollback TCL cloud_nonuser_sql +start transaction TCL cloud_nonuser_sql +commit TCL cloud_nonuser_sql +begin TCL cloud_nonuser_sql +use statement_query_type Other cloud_nonuser_sql diff --git a/test/distributed/cases/zz_statement_query_type/statement_query_type_3.sql b/test/distributed/cases/zz_statement_query_type/statement_query_type_3.sql new file mode 100644 index 000000000000..ea60c6484876 --- /dev/null +++ b/test/distributed/cases/zz_statement_query_type/statement_query_type_3.sql @@ -0,0 +1,5 @@ +-- check result at the end of bvt. +-- check result of statement_query_type/statement_query_type_3.sql + +-- RESULT CHECK: part 3 +select statement,query_type,sql_source_type from system.statement_info where account="bvt_query_type" and sql_source_type="cloud_nonuser_sql" and status != "Running" and statement not like '%mo_ctl%' and aggr_count = 0 order by request_at desc limit 59; From a1946b71ed55238c7196ca3f4118f01966e64c65 Mon Sep 17 00:00:00 2001 From: Jackson Date: Thu, 11 Apr 2024 20:39:34 +0800 Subject: [PATCH 2/2] adapt result of `show create view` --- test/distributed/cases/statement_query_type/regression.result | 4 ++-- .../cases/statement_query_type/statement_query_type_1.result | 4 ++-- .../cases/statement_query_type/statement_query_type_2.result | 4 ++-- .../cases/statement_query_type/statement_query_type_3.result | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/distributed/cases/statement_query_type/regression.result b/test/distributed/cases/statement_query_type/regression.result index 94c61b5d6b5b..abff2f86675d 100644 --- a/test/distributed/cases/statement_query_type/regression.result +++ b/test/distributed/cases/statement_query_type/regression.result @@ -6,8 +6,8 @@ use statement_query_type; create table test_table(col1 int,col2 varchar); create view test_view as select * from test_table; show create view test_view; -View Create View -test_view create view test_view as select * from test_table; +View Create View character_set_client collation_connection +test_view create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci show collation like 'utf8mb4_general_ci'; Collation Charset Id Default Compiled Sortlen Pad_attribute utf8mb4_general_ci utf8mb4 45 Yes 1 PAD SPACE diff --git a/test/distributed/cases/statement_query_type/statement_query_type_1.result b/test/distributed/cases/statement_query_type/statement_query_type_1.result index 6e8257932a66..6c6169addbd1 100644 --- a/test/distributed/cases/statement_query_type/statement_query_type_1.result +++ b/test/distributed/cases/statement_query_type/statement_query_type_1.result @@ -21,8 +21,8 @@ show create table test_table; Table Create Table test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) show create view test_view; -View Create View -test_view create view test_view as select * from test_table; +View Create View character_set_client collation_connection +test_view create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci show triggers; Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation show procedure status; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_2.result b/test/distributed/cases/statement_query_type/statement_query_type_2.result index d4922d90f687..9e8bcf465431 100644 --- a/test/distributed/cases/statement_query_type/statement_query_type_2.result +++ b/test/distributed/cases/statement_query_type/statement_query_type_2.result @@ -19,8 +19,8 @@ test_db CREATE DATABASE `test_db` Table Create Table test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) /* cloud_user */ show create view test_view; -View Create View -test_view /* cloud_user */ create view test_view as select * from test_table; +View Create View character_set_client collation_connection +test_view /* cloud_user */ create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci /* cloud_user */ show triggers; Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation /* cloud_user */ show procedure status; diff --git a/test/distributed/cases/statement_query_type/statement_query_type_3.result b/test/distributed/cases/statement_query_type/statement_query_type_3.result index f9a048bf7777..f89414d6aacc 100644 --- a/test/distributed/cases/statement_query_type/statement_query_type_3.result +++ b/test/distributed/cases/statement_query_type/statement_query_type_3.result @@ -22,8 +22,8 @@ test_db CREATE DATABASE `test_db` Table Create Table test_table CREATE TABLE `test_table` (\n`col1` INT DEFAULT NULL,\n`col2` VARCHAR(65535) DEFAULT NULL\n) /* cloud_nonuser */ show create view test_view; -View Create View -test_view /* cloud_nonuser */ create view test_view as select * from test_table; +View Create View character_set_client collation_connection +test_view /* cloud_nonuser */ create view test_view as select * from test_table; utf8mb4 utf8mb4_general_ci /* cloud_nonuser */ show triggers; Trigger Event Table Statement Timing Created sql_mode Definer character_set_client collation_connection Database Collation /* cloud_nonuser */ show procedure status;