Commit d7c1e0eb authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-5317 Compound statement / anonymous blocks

originally based on the patch by Antony T Curtis
parent a99af484
CREATE TABLE t1 (a INT PRIMARY KEY)|
BEGIN NOT ATOMIC
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
END|
SELECT * FROM t1|
a
1
2
3
PREPARE stmt FROM "BEGIN NOT ATOMIC
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (?);
END";
SET @val = 6|
EXECUTE stmt USING @val|
SELECT * FROM t1|
a
1
2
3
4
5
6
PREPARE stmt FROM "BEGIN NOT ATOMIC
DECLARE v_res INT;
SELECT COUNT(*) INTO v_res FROM t1;
SELECT 'Hello World', v_res INTO ?,?;
END"|
SET @val="", @val2=""|
EXECUTE stmt USING @val, @val2|
SELECT @val, @val2|
@val @val2
Hello World 6
DROP TABLE t1|
CREATE DATABASE mysqltest1|
CREATE PROCEDURE mysqltest1.sp1()
BEGIN
PREPARE stmt FROM "BEGIN NOT ATOMIC CREATE TABLE t1 AS SELECT DATABASE(); END";
EXECUTE stmt;
END|
CALL mysqltest1.sp1()|
SELECT * FROM mysqltest1.t1|
DATABASE()
mysqltest1
USE mysqltest1|
DROP DATABASE mysqltest1|
BEGIN NOT ATOMIC CREATE TABLE t1(a int); END|
ERROR 3D000: No database selected
BEGIN NOT ATOMIC SET @a=1; CREATE TABLE test.t1(a int); END|
USE test|
show tables|
Tables_in_test
t1
drop table t1|
/**/ if (select count(*) from information_schema.tables
where table_schema='test' and table_name='t1') = 0
then
create table t1 (a int);
end if|
show tables|
Tables_in_test
t1
/**/ if (select count(*) from information_schema.tables
where table_schema='test' and table_name='t1') = 0
then
create table t1 (a int);
end if|
show tables|
Tables_in_test
t1
case (select table_name from information_schema.tables where table_schema='test')
when 't1' then create table t2 (b int);
when 't2' then create table t3 (b int);
else signal sqlstate '42S02';
end case|
show tables|
Tables_in_test
t1
t2
case
when database() = 'test' then create table t3 (test text);
when now() < date'2001-02-03' then create table oops (machine time);
end case|
show tables|
Tables_in_test
t1
t2
t3
loop
create table t4 (a int);
end loop|
ERROR 42S01: Table 't4' already exists
show tables|
Tables_in_test
t1
t2
t3
t4
set @a=0;
repeat
set @a = @a + 1;
until @a > 5
end repeat|
select @a|
@a
6
/**/ while (select count(*) from information_schema.tables where table_schema='test')
do
select concat('drop table ', table_name) into @a
from information_schema.tables where table_schema='test' limit 1;
select @a as 'executing:';
prepare dt from @a;
execute dt;
end while|
executing: drop table t1
executing: drop table t2
executing: drop table t3
executing: drop table t4
......@@ -1269,7 +1269,7 @@ performance-schema-max-rwlock-instances -1
performance-schema-max-socket-classes 10
performance-schema-max-socket-instances -1
performance-schema-max-stage-classes 150
performance-schema-max-statement-classes 180
performance-schema-max-statement-classes 181
performance-schema-max-table-handles -1
performance-schema-max-table-instances -1
performance-schema-max-thread-classes 50
......
......@@ -116,7 +116,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -46,7 +46,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -36,8 +36,13 @@ TABLE performance_schema % NO NO
select digest_text, count_star
from performance_schema.events_statements_summary_by_digest
where digest_text like "%in_%_digest%";
<<<<<<< HEAD
digest_text count_star
SELECT ? AS in_master_digest 1
=======
digest digest_text count_star
22e44734c3711653c51372e129da5d7f SELECT ? AS in_master_digest 1
>>>>>>> MDEV-5317 Compound statement / anonymous blocks
insert into test.marker values (2);
**** On Slave ****
select * from test.marker;
......@@ -63,8 +68,13 @@ TABLE slave foo YES YES
select digest_text, count_star
from performance_schema.events_statements_summary_by_digest
where digest_text like "%in_%_digest%";
<<<<<<< HEAD
digest_text count_star
SELECT ? AS in_slave_digest 1
=======
digest digest_text count_star
ddeda363aafcef928734dcf9afe60d76 SELECT ? AS in_slave_digest 1
>>>>>>> MDEV-5317 Compound statement / anonymous blocks
**** On Master ****
delete from performance_schema.setup_objects
where object_schema='master';
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 0
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 0
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 0
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 0
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 0
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 0
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 0
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -93,7 +93,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -111,6 +111,7 @@ DROP TRIGGER trg;
####################################
SELECT SCHEMA_NAME, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
<<<<<<< HEAD
SCHEMA_NAME DIGEST_TEXT COUNT_STAR SUM_ROWS_AFFECTED SUM_WARNINGS SUM_ERRORS
statements_digest TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1 0 0 0
statements_digest SELECT ? FROM t1 1 0 0 0
......@@ -149,6 +150,46 @@ statements_digest DROP FUNCTION func 1 0 0 0
statements_digest CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @ ? := ? 1 0 0 0
statements_digest INSERT INTO t12 VALUES (?) 2 2 0 0
statements_digest DROP TRIGGER trg 1 0 0 0
=======
SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR SUM_ROWS_AFFECTED SUM_WARNINGS SUM_ERRORS
statements_digest a88df6e3c0760efe1288e012e305ac1b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1 0 0 0
statements_digest 6f98e578d7e016b83095e3ba47ee06a3 SELECT ? FROM t1 1 0 0 0
statements_digest 063d94a747f3086a8f52bef0ac0d95e6 SELECT ? FROM `t1` 1 0 0 0
statements_digest d981dbd1425e8f7a7ce9b11ee9b540a9 SELECT ?, ... FROM t1 2 0 0 0
statements_digest e3836f41d25ef0f12d2bfead9f9e4ba5 SELECT ? FROM t2 1 0 0 0
statements_digest 21c9de801f0e325050fd2adaf1dc1c82 SELECT ?, ... FROM t2 2 0 0 0
statements_digest 6c1b5c47bc04239226083501685023e0 INSERT INTO t1 VALUES (?) 1 1 0 0
statements_digest ced094851312b62e161ca6c52a93f253 INSERT INTO t2 VALUES (?) 1 1 0 0
statements_digest 523ba7a5e63133c3cf2d6117597d18a7 INSERT INTO t3 VALUES (...) 4 4 0 0
statements_digest 6192356916c06a3d9eacdfc909ceb15a INSERT INTO t4 VALUES (...) 1 1 0 0
statements_digest 794e70704f84d695e2668d59ecb68961 INSERT INTO t5 VALUES (...) 1 1 0 0
statements_digest d8daf9229bf069b2c2c83878d92ef9b5 INSERT INTO t1 VALUES (?) /* , ... */ 2 7 0 0
statements_digest 4d4e8facaea256c03b12e25e561102c1 INSERT INTO t3 VALUES (...) /* , ... */ 1 3 0 0
statements_digest b025e1fa9324e8d9655dddbcaf9942f4 INSERT INTO t5 VALUES (...) /* , ... */ 1 3 0 0
statements_digest 5dc73ac163595ff36a944dd8aa602b48 INSERT INTO t1 VALUES ( NULL ) 1 1 0 0
statements_digest 80040c738fbfc2bcf9b5ef31de57f5bf INSERT INTO t6 VALUES (...) 5 5 0 0
statements_digest aeb185ab9b6e9d5a49e47c8741b8acdf SELECT ? + ? 3 0 0 0
statements_digest d3804664eeee11407f3fcbd5c29a1f73 SELECT ? 1 0 0 0
statements_digest d2faa94bba9e4af44cd60fc19e56550d CREATE SCHEMA statements_digest_temp 2 2 0 0
statements_digest a43855a07cae52569ef7c23e74d6af53 DROP SCHEMA statements_digest_temp 2 0 0 0
statements_digest 2c73cd7777d8d43791b501798342cde8 SELECT ? FROM no_such_table 1 0 0 1
statements_digest f0eef43d84476d38fd70604bfb63a26b CREATE TABLE dup_table ( c CHARACTER (?) ) 2 0 0 1
statements_digest e6a2f4869cfc84d0dd108eb8faa4d42b DROP TABLE dup_table 1 0 0 0
statements_digest 4e12863e0b8eacace4f84a0d6ac05c88 INSERT INTO t11 VALUES (?) 1 1 1 0
statements_digest d3eda26b379bd56340ce84fe395dfff7 SHOW WARNINGS 1 0 0 0
statements_digest dae9ba207d784b1eca3ab3ffb65ec30e PREPARE stmt FROM ? 1 0 0 0
statements_digest a44f4b7d63039640a75344e008b73c9b EXECUTE stmt 2 0 0 0
statements_digest 36f2dd152298707b7e95ba425737d2cc DEALLOCATE PREPARE stmt 1 0 0 0
statements_digest ebbf2166ce31a1ba4f82798c6cab1beb CREATE PROCEDURE p1 ( ) BEGIN SELECT * FROM t12 ; END 1 0 0 0
statements_digest 065c14e52c473d62ef7153e689cb41da CALL p1 ( ) 2 0 0 0
statements_digest 5f3f9f3b85dbfc4802edbd55449a64b7 DROP PROCEDURE p1 1 0 0 0
statements_digest 456a6abc6e28fd9f0f731dc98cfaf419 CREATE FUNCTION `func` ( a INTEGER , b INTEGER ) RETURNS INTEGER (?) RETURN a + b 1 0 0 0
statements_digest a6fa9d3f94ed15f5a626da33430b7c95 SELECT func (...) 2 0 0 0
statements_digest 2bf3c4751ac825d34be28280f80bda97 DROP FUNCTION func 1 0 0 0
statements_digest a30279da2544f743746bfe467b9cc50b CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @ ? := ? 1 0 0 0
statements_digest a347955b86e599d7e0c4a4e3b2282fa2 INSERT INTO t12 VALUES (?) 2 2 0 0
statements_digest eb2873245de755d3d93312c48b850e7f DROP TRIGGER trg 1 0 0 0
>>>>>>> MDEV-5317 Compound statement / anonymous blocks
####################################
# CLEANUP
####################################
......
......@@ -123,6 +123,7 @@ DROP TRIGGER trg;
####################################
# QUERYING PS STATEMENT DIGEST
####################################
<<<<<<< HEAD
SELECT schema_name,digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
schema_name digest_text count_star
statements_digest TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1
......@@ -164,6 +165,49 @@ statements_digest INSERT INTO t12 VALUES (?) 2
statements_digest DROP TRIGGER trg 1
SELECT digest_text FROM performance_schema.events_statements_current;
digest_text
=======
SELECT schema_name, digest, digest_text, count_star FROM performance_schema.events_statements_summary_by_digest;
schema_name digest digest_text count_star
statements_digest a88df6e3c0760efe1288e012e305ac1b TRUNCATE TABLE performance_schema . events_statements_summary_by_digest 1
statements_digest 6f98e578d7e016b83095e3ba47ee06a3 SELECT ? FROM t1 1
statements_digest 063d94a747f3086a8f52bef0ac0d95e6 SELECT ? FROM `t1` 1
statements_digest d981dbd1425e8f7a7ce9b11ee9b540a9 SELECT ?, ... FROM t1 2
statements_digest e3836f41d25ef0f12d2bfead9f9e4ba5 SELECT ? FROM t2 1
statements_digest 21c9de801f0e325050fd2adaf1dc1c82 SELECT ?, ... FROM t2 2
statements_digest 6c1b5c47bc04239226083501685023e0 INSERT INTO t1 VALUES (?) 1
statements_digest ced094851312b62e161ca6c52a93f253 INSERT INTO t2 VALUES (?) 1
statements_digest 523ba7a5e63133c3cf2d6117597d18a7 INSERT INTO t3 VALUES (...) 4
statements_digest 6192356916c06a3d9eacdfc909ceb15a INSERT INTO t4 VALUES (...) 1
statements_digest 794e70704f84d695e2668d59ecb68961 INSERT INTO t5 VALUES (...) 1
statements_digest d8daf9229bf069b2c2c83878d92ef9b5 INSERT INTO t1 VALUES (?) /* , ... */ 2
statements_digest 4d4e8facaea256c03b12e25e561102c1 INSERT INTO t3 VALUES (...) /* , ... */ 1
statements_digest b025e1fa9324e8d9655dddbcaf9942f4 INSERT INTO t5 VALUES (...) /* , ... */ 1
statements_digest 5dc73ac163595ff36a944dd8aa602b48 INSERT INTO t1 VALUES ( NULL ) 1
statements_digest 80040c738fbfc2bcf9b5ef31de57f5bf INSERT INTO t6 VALUES (...) 5
statements_digest aeb185ab9b6e9d5a49e47c8741b8acdf SELECT ? + ? 3
statements_digest d3804664eeee11407f3fcbd5c29a1f73 SELECT ? 1
statements_digest d2faa94bba9e4af44cd60fc19e56550d CREATE SCHEMA statements_digest_temp 2
statements_digest a43855a07cae52569ef7c23e74d6af53 DROP SCHEMA statements_digest_temp 2
statements_digest 2c73cd7777d8d43791b501798342cde8 SELECT ? FROM no_such_table 1
statements_digest f0eef43d84476d38fd70604bfb63a26b CREATE TABLE dup_table ( c CHARACTER (?) ) 2
statements_digest e6a2f4869cfc84d0dd108eb8faa4d42b DROP TABLE dup_table 1
statements_digest 4e12863e0b8eacace4f84a0d6ac05c88 INSERT INTO t11 VALUES (?) 1
statements_digest d3eda26b379bd56340ce84fe395dfff7 SHOW WARNINGS 1
statements_digest dae9ba207d784b1eca3ab3ffb65ec30e PREPARE stmt FROM ? 1
statements_digest a44f4b7d63039640a75344e008b73c9b EXECUTE stmt 2
statements_digest 36f2dd152298707b7e95ba425737d2cc DEALLOCATE PREPARE stmt 1
statements_digest ebbf2166ce31a1ba4f82798c6cab1beb CREATE PROCEDURE p1 ( ) BEGIN SELECT * FROM t12 ; END 1
statements_digest 065c14e52c473d62ef7153e689cb41da CALL p1 ( ) 2
statements_digest 5f3f9f3b85dbfc4802edbd55449a64b7 DROP PROCEDURE p1 1
statements_digest 456a6abc6e28fd9f0f731dc98cfaf419 CREATE FUNCTION `func` ( a INTEGER , b INTEGER ) RETURNS INTEGER (?) RETURN a + b 1
statements_digest a6fa9d3f94ed15f5a626da33430b7c95 SELECT func (...) 2
statements_digest 2bf3c4751ac825d34be28280f80bda97 DROP FUNCTION func 1
statements_digest a30279da2544f743746bfe467b9cc50b CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @ ? := ? 1
statements_digest a347955b86e599d7e0c4a4e3b2282fa2 INSERT INTO t12 VALUES (?) 2
statements_digest eb2873245de755d3d93312c48b850e7f DROP TRIGGER trg 1
SELECT digest, digest_text FROM performance_schema.events_statements_current;
digest digest_text
>>>>>>> MDEV-5317 Compound statement / anonymous blocks
####################################
# CLEANUP
####################################
......
......@@ -6,7 +6,14 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
####################################
# QUERYING PS STATEMENT DIGEST
####################################
<<<<<<< HEAD
SELECT schema_name, digest_text, count_star FROM events_statements_summary_by_digest;
schema_name digest_text count_star
performance_schema TRUNCATE TABLE events_statements_summary_by_digest 1
performance_schema SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ... 1
=======
SELECT schema_name, digest, digest_text, count_star FROM events_statements_summary_by_digest;
schema_name digest digest_text count_star
performance_schema 70f9d0c8bf1936f2fb83118b3ae880f0 TRUNCATE TABLE events_statements_summary_by_digest 1
performance_schema 63f9aaeed7859671c6a42c75fcd43785 SELECT ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ? + ... 1
>>>>>>> MDEV-5317 Compound statement / anonymous blocks
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -65,7 +65,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
......@@ -64,7 +64,7 @@ performance_schema_max_rwlock_instances 5000
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
performance_schema_max_statement_classes 180
performance_schema_max_statement_classes 181
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
......
#
# MDEV-5317 Compound statement / anonymous blocks
#
delimiter |;
CREATE TABLE t1 (a INT PRIMARY KEY)|
BEGIN NOT ATOMIC
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
END|
SELECT * FROM t1|
PREPARE stmt FROM "BEGIN NOT ATOMIC
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (?);
END";
SET @val = 6|
EXECUTE stmt USING @val|
SELECT * FROM t1|
PREPARE stmt FROM "BEGIN NOT ATOMIC
DECLARE v_res INT;
SELECT COUNT(*) INTO v_res FROM t1;
SELECT 'Hello World', v_res INTO ?,?;
END"|
SET @val="", @val2=""|
EXECUTE stmt USING @val, @val2|
SELECT @val, @val2|
DROP TABLE t1|
#
# test for default database
#
# * SP db is different from the current db
CREATE DATABASE mysqltest1|
CREATE PROCEDURE mysqltest1.sp1()
BEGIN
PREPARE stmt FROM "BEGIN NOT ATOMIC CREATE TABLE t1 AS SELECT DATABASE(); END";
EXECUTE stmt;
END|
CALL mysqltest1.sp1()|
SELECT * FROM mysqltest1.t1|
USE mysqltest1|
DROP DATABASE mysqltest1|
# * no current db
--error ER_NO_DB_ERROR
BEGIN NOT ATOMIC CREATE TABLE t1(a int); END|
BEGIN NOT ATOMIC SET @a=1; CREATE TABLE test.t1(a int); END|
USE test|
show tables|
drop table t1|
# IF (without /**/ mysqltest treats if as its own command)
/**/ if (select count(*) from information_schema.tables
where table_schema='test' and table_name='t1') = 0
then
create table t1 (a int);
end if|
show tables|
/**/ if (select count(*) from information_schema.tables
where table_schema='test' and table_name='t1') = 0
then
create table t1 (a int);
end if|
show tables|
# CASE simple
case (select table_name from information_schema.tables where table_schema='test')
when 't1' then create table t2 (b int);
when 't2' then create table t3 (b int);
else signal sqlstate '42S02';
end case|
show tables|
# CASE searched
case
when database() = 'test' then create table t3 (test text);
when now() < date'2001-02-03' then create table oops (machine time);
end case|
show tables|
# LOOP
--error ER_TABLE_EXISTS_ERROR
loop
create table t4 (a int);
end loop|
show tables|
# REPEAT
set @a=0;
repeat
set @a = @a + 1;
until @a > 5
end repeat|
select @a|
# WHILE
--vertical_results
/**/ while (select count(*) from information_schema.tables where table_schema='test')
do
select concat('drop table ', table_name) into @a
from information_schema.tables where table_schema='test' limit 1;
select @a as 'executing:';
prepare dt from @a;
execute dt;
end while|
--horizontal_results
......@@ -75,6 +75,7 @@ static SYMBOL symbols[] = {
{ "ASCII", SYM(ASCII_SYM)},
{ "ASENSITIVE", SYM(ASENSITIVE_SYM)},
{ "AT", SYM(AT_SYM)},
{ "ATOMIC", SYM(ATOMIC_SYM)},
{ "AUTHORS", SYM(AUTHORS_SYM)},
{ "AUTO_INCREMENT", SYM(AUTO_INC)},
{ "AUTOEXTEND_SIZE", SYM(AUTOEXTEND_SIZE_SYM)},
......
......@@ -3706,6 +3706,7 @@ SHOW_VAR com_status_vars[]= {
{"check", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECK]), SHOW_LONG_STATUS},
{"checksum", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CHECKSUM]), SHOW_LONG_STATUS},
{"commit", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMMIT]), SHOW_LONG_STATUS},
{"compound_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_COMPOUND]), SHOW_LONG_STATUS},
{"create_db", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_DB]), SHOW_LONG_STATUS},
{"create_event", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_EVENT]), SHOW_LONG_STATUS},
{"create_function", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_CREATE_SPFUNCTION]), SHOW_LONG_STATUS},
......
......@@ -577,6 +577,7 @@ sp_head::sp_head()
:Query_arena(&main_mem_root, STMT_INITIALIZED_FOR_SP),
m_flags(0),
m_sp_cache_version(0),
m_creation_ctx(0),
unsafe_flags(0),
m_recursion_level(0),
m_next_cached_sp(0),
......@@ -1237,6 +1238,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
Switch query context. This has to be done early as this is sometimes
allocated trough sql_alloc
*/
if (m_creation_ctx)
saved_creation_ctx= m_creation_ctx->set_n_backup(thd);
/*
......@@ -1401,6 +1403,7 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
/* Restore query context. */
if (m_creation_ctx)
m_creation_ctx->restore_env(thd, saved_creation_ctx);
/* Restore arena. */
......@@ -2326,6 +2329,9 @@ sp_head::restore_lex(THD *thd)
procedures) to multiset of tables used by this routine.
*/
merge_table_list(thd, sublex->query_tables, sublex);
/* Merge lists of PS parameters. */
oldlex->param_list.append(&sublex->param_list);
if (! sublex->sp_lex_in_use)
{
sublex->sphead= NULL;
......
......@@ -94,6 +94,7 @@ enum enum_sql_command {
SQLCOM_SLAVE_ALL_START, SQLCOM_SLAVE_ALL_STOP,
SQLCOM_SHOW_EXPLAIN, SQLCOM_SHUTDOWN,
SQLCOM_CREATE_ROLE, SQLCOM_DROP_ROLE, SQLCOM_GRANT_ROLE, SQLCOM_REVOKE_ROLE,
SQLCOM_COMPOUND,
/*
When a command is added here, be sure it's also added in mysqld.cc
......
......@@ -503,7 +503,6 @@ void lex_start(THD *thd)
lex->duplicates= DUP_ERROR;
lex->ignore= 0;
lex->spname= NULL;
lex->sphead= NULL;
lex->spcont= NULL;
lex->proc_list.first= 0;
lex->escape_used= FALSE;
......@@ -559,8 +558,20 @@ void lex_end(LEX *lex)
}
reset_dynamic(&lex->plugins);
if (lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_PREPARE)
{
/*
Don't delete lex->sphead, it'll be needed for EXECUTE.
Note that of all statements that populate lex->sphead
only SQLCOM_COMPOUND can be PREPAREd
*/
DBUG_ASSERT(lex->sphead == 0 || lex->sql_command == SQLCOM_COMPOUND);
}
else
{
delete lex->sphead;
lex->sphead= NULL;
}
lex->mi.reset();
......@@ -2554,8 +2565,8 @@ void Query_tables_list::destroy_query_tables_list()
LEX::LEX()
: explain(NULL),
result(0), option_type(OPT_DEFAULT), is_lex_started(0),
limit_rows_examined_cnt(ULONGLONG_MAX)
result(0), option_type(OPT_DEFAULT), sphead(0),
is_lex_started(0), limit_rows_examined_cnt(ULONGLONG_MAX)
{
my_init_dynamic_array2(&plugins, sizeof(plugin_ref),
......@@ -2792,7 +2803,7 @@ uint8 LEX::get_effective_with_check(TABLE_LIST *view)
bool
LEX::copy_db_to(char **p_db, size_t *p_db_length) const
{
if (sphead)
if (sphead && sphead->m_name.str)
{
DBUG_ASSERT(sphead->m_db.str && sphead->m_db.length);
/*
......
......@@ -471,6 +471,7 @@ void init_update_queries(void)
CF_CAN_GENERATE_ROW_EVENTS |
CF_OPTIMIZER_TRACE; // (1)
sql_command_flags[SQLCOM_EXECUTE]= CF_CAN_GENERATE_ROW_EVENTS;
sql_command_flags[SQLCOM_COMPOUND]= CF_CAN_GENERATE_ROW_EVENTS;
/*
We don't want to change to statement based replication for these commands
......@@ -5074,6 +5075,14 @@ mysql_execute_command(THD *thd)
}
break;
}
case SQLCOM_COMPOUND:
DBUG_ASSERT(all_tables == 0);
DBUG_ASSERT(thd->in_sub_stmt == 0);
if (do_execute_sp(thd, lex->sphead))
goto error;
break;
case SQLCOM_ALTER_PROCEDURE:
case SQLCOM_ALTER_FUNCTION:
{
......
......@@ -2252,6 +2252,7 @@ static bool check_prepared_statement(Prepared_statement *stmt)
case SQLCOM_GRANT:
case SQLCOM_REVOKE:
case SQLCOM_KILL:
case SQLCOM_COMPOUND:
case SQLCOM_SHUTDOWN:
break;
......@@ -3287,6 +3288,7 @@ Prepared_statement::~Prepared_statement()
free_items();
if (lex)
{
delete lex->sphead;
delete lex->result;
delete (st_lex_local *) lex;
}
......@@ -3465,12 +3467,15 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len)
if (error == 0)
error= check_prepared_statement(this);
if (error)
{
/*
Currently CREATE PROCEDURE/TRIGGER/EVENT are prohibited in prepared
statements: ensure we have no memory leak here if by someone tries
to PREPARE stmt FROM "CREATE PROCEDURE ..."
let the following code know we're not in PS anymore,
the won't be any EXECUTE, so we need a full cleanup
*/
DBUG_ASSERT(lex->sphead == NULL || error != 0);
lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_PREPARE;
}
/* The order is important */
lex->unit.cleanup();
......
......@@ -236,6 +236,7 @@ static sp_head *make_sp_head(THD *thd, sp_name *name,
sp->reset_thd_mem_root(thd);
sp->init(lex);
sp->m_type= type;
if (name)
sp->init_sp_name(thd, name);
sp->m_chistics= &lex->sp_chistics;
lex->sphead= sp;
......@@ -244,6 +245,18 @@ static sp_head *make_sp_head(THD *thd, sp_name *name,
return sp;
}
static bool maybe_start_compound_statement(THD *thd)
{
if (!thd->lex->sphead)
{
if (!make_sp_head(thd, NULL, TYPE_ENUM_PROCEDURE))
return 1;
Lex->sp_chistics.suid= SP_IS_NOT_SUID;
Lex->sphead->set_body_start(thd, YYLIP->get_cpp_ptr());
}
return 0;
}
/**
Helper action for a case expression statement (the expr in 'CASE expr').
......@@ -950,6 +963,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ASCII_SYM /* MYSQL-FUNC */
%token ASENSITIVE_SYM /* FUTURE-USE */
%token AT_SYM /* SQL-2003-R */
%token ATOMIC_SYM /* SQL-2003-R */
%token AUTHORS_SYM
%token AUTOEXTEND_SIZE_SYM
%token AUTO_INC
......@@ -1757,7 +1771,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%type <NONE>
analyze_stmt_command
query verb_clause create change select do drop insert replace insert2
insert_values update delete truncate rename
insert_values update delete truncate rename compound_statement
show describe load alter optimize keycache preload flush
reset purge begin commit rollback savepoint release
slave master_def master_defs master_file_def slave_until_opts
......@@ -1822,9 +1836,10 @@ END_OF_INPUT
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
%type <NONE> sp_proc_stmt_statement sp_proc_stmt_return
%type <NONE> sp_proc_stmt_compound_ok
%type <NONE> sp_proc_stmt_if
%type <NONE> sp_labeled_control sp_unlabeled_control
%type <NONE> sp_labeled_block sp_unlabeled_block
%type <NONE> sp_labeled_block sp_unlabeled_block sp_unlabeled_block_not_atomic
%type <NONE> sp_proc_stmt_leave
%type <NONE> sp_proc_stmt_iterate
%type <NONE> sp_proc_stmt_open sp_proc_stmt_fetch sp_proc_stmt_close
......@@ -1934,9 +1949,10 @@ opt_end_of_input:
verb_clause:
statement
| begin
| compound_statement
;
/* Verb clauses, except begin */
/* Verb clauses, except begin and compound_statement */
statement:
alter
| analyze
......@@ -3548,22 +3564,31 @@ sp_opt_default:
sp_proc_stmt:
sp_proc_stmt_statement
| sp_proc_stmt_return
| sp_proc_stmt_if
| case_stmt_specification
| sp_labeled_block
| sp_unlabeled_block
| sp_labeled_control
| sp_unlabeled_control
| sp_proc_stmt_leave
| sp_proc_stmt_iterate
| sp_proc_stmt_open
| sp_proc_stmt_fetch
| sp_proc_stmt_close
| sp_proc_stmt_compound_ok
;
sp_proc_stmt_compound_ok:
sp_proc_stmt_if
| case_stmt_specification
| sp_unlabeled_block_not_atomic
| sp_unlabeled_control
;
sp_proc_stmt_if:
IF_SYM
{ Lex->sphead->new_cont_backpatch(NULL); }
{
if (maybe_start_compound_statement(thd))
MYSQL_YYABORT;
Lex->sphead->new_cont_backpatch(NULL);
}
sp_if END IF_SYM
{ Lex->sphead->do_cont_backpatch(); }
;
......@@ -3652,17 +3677,16 @@ sp_proc_stmt_return:
;
sp_unlabeled_control:
{ /* Unlabeled controls get an empty label. */
LEX *lex= Lex;
lex->spcont->push_label(thd, empty_lex_str,
lex->sphead->instructions());
{
if (maybe_start_compound_statement(thd))
MYSQL_YYABORT;
/* Unlabeled controls get an empty label. */
Lex->spcont->push_label(thd, empty_lex_str,
Lex->sphead->instructions());
}
sp_control_content
{
LEX *lex= Lex;
lex->sphead->backpatch(lex->spcont->pop_label());
Lex->sphead->backpatch(Lex->spcont->pop_label());
}
;
......@@ -3920,6 +3944,8 @@ sp_elseifs:
case_stmt_specification:
CASE_SYM
{
if (maybe_start_compound_statement(thd))
MYSQL_YYABORT;
/**
An example of the CASE statement in use is
......@@ -4141,9 +4167,6 @@ sp_labeled_block:
}
;
/* QQ This is just a dummy for grouping declarations and statements
together. No [[NOT] ATOMIC] yet, and we need to figure out how
make it coexist with the existing BEGIN COMMIT/ROLLBACK. */
sp_unlabeled_block:
BEGIN_SYM
{
......@@ -4153,6 +4176,17 @@ sp_unlabeled_block:
{ }
;
sp_unlabeled_block_not_atomic:
BEGIN_SYM not ATOMIC_SYM /* TODO: BEGIN ATOMIC (not -> opt_not) */
{
if (maybe_start_compound_statement(thd))
MYSQL_YYABORT;
Lex->name= empty_lex_str; // Unlabeled blocks get an empty label
}
sp_block_content
{ }
;
sp_block_content:
{
LEX *lex= Lex;
......@@ -14056,6 +14090,7 @@ keyword_sp:
| ALWAYS_SYM {}
| ANY_SYM {}
| AT_SYM {}
| ATOMIC_SYM {}
| AUTHORS_SYM {}
| AUTO_INC {}
| AUTOEXTEND_SIZE_SYM {}
......@@ -15572,6 +15607,16 @@ begin:
lex->start_transaction_opt= 0;
}
opt_work {}
;
compound_statement:
sp_proc_stmt_compound_ok
{
Lex->sql_command= SQLCOM_COMPOUND;
Lex->sphead->set_stmt_end(thd);
Lex->sphead->restore_thd_mem_root(thd);
}
;
opt_not:
/* nothing */ { $$= 0; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment