summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2014-08-18 21:36:11 +0200
committerSergei Golubchik <serg@mariadb.org>2014-10-10 22:27:39 +0200
commitd7c1e0ebbd272d6198733e8a71f1c16548733262 (patch)
tree3dcc2742c491e01b9eed59aac53b713b1a122985
parenta99af484cd9360c2cea92798bcde594adcf23b7e (diff)
downloadmariadb-git-d7c1e0ebbd272d6198733e8a71f1c16548733262.tar.gz
MDEV-5317 Compound statement / anonymous blocks
originally based on the patch by Antony T Curtis
-rw-r--r--mysql-test/r/compound.result121
-rw-r--r--mysql-test/r/mysqld--help.result2
-rw-r--r--mysql-test/suite/perfschema/r/ortho_iter.result2
-rw-r--r--mysql-test/suite/perfschema/r/privilege_table_io.result2
-rw-r--r--mysql-test/suite/perfschema/r/rpl_gtid_func.result10
-rw-r--r--mysql-test/suite/perfschema/r/start_server_disable_idle.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_disable_stages.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_disable_statements.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_disable_waits.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_innodb.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_account.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_cond_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_cond_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_file_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_file_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_host.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_mutex_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_setup_actors.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_setup_objects.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_socket_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_socket_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_stage_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_stages_history.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_statements_history.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_table_hdl.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_table_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_thread_class.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_thread_inst.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_user.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_waits_history.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_off.result2
-rw-r--r--mysql-test/suite/perfschema/r/start_server_on.result2
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest.result41
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest_consumers.result44
-rw-r--r--mysql-test/suite/perfschema/r/statement_digest_long_query.result7
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_off.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result2
-rw-r--r--mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result2
-rw-r--r--mysql-test/t/compound.test115
-rw-r--r--sql/lex.h1
-rw-r--r--sql/mysqld.cc1
-rw-r--r--sql/sp_head.cc10
-rw-r--r--sql/sql_cmd.h1
-rw-r--r--sql/sql_lex.cc23
-rw-r--r--sql/sql_parse.cc9
-rw-r--r--sql/sql_prepare.cc17
-rw-r--r--sql/sql_yacc.yy83
87 files changed, 523 insertions, 106 deletions
diff --git a/mysql-test/r/compound.result b/mysql-test/r/compound.result
new file mode 100644
index 00000000000..84c3cdbfc04
--- /dev/null
+++ b/mysql-test/r/compound.result
@@ -0,0 +1,121 @@
+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
diff --git a/mysql-test/r/mysqld--help.result b/mysql-test/r/mysqld--help.result
index 80ba45be72a..de424375ea4 100644
--- a/mysql-test/r/mysqld--help.result
+++ b/mysql-test/r/mysqld--help.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/ortho_iter.result b/mysql-test/suite/perfschema/r/ortho_iter.result
index bef2759da41..8f90c924344 100644
--- a/mysql-test/suite/perfschema/r/ortho_iter.result
+++ b/mysql-test/suite/perfschema/r/ortho_iter.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/privilege_table_io.result b/mysql-test/suite/perfschema/r/privilege_table_io.result
index 838d17e61fe..3fdf7a2dab1 100644
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/rpl_gtid_func.result b/mysql-test/suite/perfschema/r/rpl_gtid_func.result
index 86c8347addd..edb724aa2a3 100644
--- a/mysql-test/suite/perfschema/r/rpl_gtid_func.result
+++ b/mysql-test/suite/perfschema/r/rpl_gtid_func.result
@@ -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';
diff --git a/mysql-test/suite/perfschema/r/start_server_disable_idle.result b/mysql-test/suite/perfschema/r/start_server_disable_idle.result
index b27ecd52226..fc2dac1b00b 100644
--- a/mysql-test/suite/perfschema/r/start_server_disable_idle.result
+++ b/mysql-test/suite/perfschema/r/start_server_disable_idle.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_disable_stages.result b/mysql-test/suite/perfschema/r/start_server_disable_stages.result
index 0b8e00a5653..ae428299508 100644
--- a/mysql-test/suite/perfschema/r/start_server_disable_stages.result
+++ b/mysql-test/suite/perfschema/r/start_server_disable_stages.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_disable_statements.result b/mysql-test/suite/perfschema/r/start_server_disable_statements.result
index 8e8d1498b9f..d69d74d68f3 100644
--- a/mysql-test/suite/perfschema/r/start_server_disable_statements.result
+++ b/mysql-test/suite/perfschema/r/start_server_disable_statements.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_disable_waits.result b/mysql-test/suite/perfschema/r/start_server_disable_waits.result
index d4b02dedc2c..c4bd0cfa1fe 100644
--- a/mysql-test/suite/perfschema/r/start_server_disable_waits.result
+++ b/mysql-test/suite/perfschema/r/start_server_disable_waits.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_innodb.result b/mysql-test/suite/perfschema/r/start_server_innodb.result
index 0d7ea7d6294..a4ac22f19fc 100644
--- a/mysql-test/suite/perfschema/r/start_server_innodb.result
+++ b/mysql-test/suite/perfschema/r/start_server_innodb.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_account.result b/mysql-test/suite/perfschema/r/start_server_no_account.result
index b9ec719ed58..a2d235c5f9c 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_account.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_account.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result
index 4fac77bc0cc..9d938ce80dc 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
index 75cd54776eb..209c3b24e8c 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_class.result b/mysql-test/suite/perfschema/r/start_server_no_file_class.result
index 9922fcaa016..aeaeb867045 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result
index 6e8735f6a1f..cb427c77524 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_host.result b/mysql-test/suite/perfschema/r/start_server_no_host.result
index f5dae7c61d9..378eca3cad9 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_host.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_host.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
index 4b3c8790b58..1af074ab4b9 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
index 92ec4cf61fc..a52951d1093 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
index e4ac0d0fa8b..ecff607ba23 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
index 3bba543f3b8..35e535b815f 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
index 2c3ef382fb9..8902aade191 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
index 0b49b4d055a..6afe6fb9828 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result
index 9cf73c2b78d..1ba0e485dea 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
index 6da66d6ee75..0c84ce0e8f9 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result
index 532935bb0ff..b8cdcc5d487 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result
index 360571bc326..17e1abce444 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
index d458e3da9b1..ffee34f560f 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result
index 2682ea22f88..e023660cdae 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result
index 9568e9ad56b..d493d6ed731 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
index c189d9a5024..aac8eb245fa 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result
index a440cfe3302..546fa8682e2 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result
index d9c945ea8cb..c184be8945a 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
index f5ce5bebb51..9cc57fb9103 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_user.result b/mysql-test/suite/perfschema/r/start_server_no_user.result
index 53cb0051f97..dd8eb530816 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_user.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_user.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result
index 125274550eb..531a7146ca6 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result
index 50212863574..026c9fd9bfe 100644
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_off.result b/mysql-test/suite/perfschema/r/start_server_off.result
index 08847829579..1cf31e6339a 100644
--- a/mysql-test/suite/perfschema/r/start_server_off.result
+++ b/mysql-test/suite/perfschema/r/start_server_off.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/start_server_on.result b/mysql-test/suite/perfschema/r/start_server_on.result
index 0d7ea7d6294..a4ac22f19fc 100644
--- a/mysql-test/suite/perfschema/r/start_server_on.result
+++ b/mysql-test/suite/perfschema/r/start_server_on.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/statement_digest.result b/mysql-test/suite/perfschema/r/statement_digest.result
index a7983e5baaa..2f87e29d5ad 100644
--- a/mysql-test/suite/perfschema/r/statement_digest.result
+++ b/mysql-test/suite/perfschema/r/statement_digest.result
@@ -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
####################################
diff --git a/mysql-test/suite/perfschema/r/statement_digest_consumers.result b/mysql-test/suite/perfschema/r/statement_digest_consumers.result
index 8c5696bb139..42454ebae77 100644
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers.result
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result
@@ -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
####################################
diff --git a/mysql-test/suite/perfschema/r/statement_digest_long_query.result b/mysql-test/suite/perfschema/r/statement_digest_long_query.result
index 8bc7a877bda..13b2e8e8281 100644
--- a/mysql-test/suite/perfschema/r/statement_digest_long_query.result
+++ b/mysql-test/suite/perfschema/r/statement_digest_long_query.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
index ea2980e5755..755521428be 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
index f51e8383019..22a7f1bdf45 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
index a7844b6b0e6..79c6d7a21dd 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
index 4d089c810a1..4992b55b0a5 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
index 23bd1294445..4ae199c129b 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
index 7edfc3824bb..a59c4f794d5 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
index 99d2e7d4655..38d4b185c72 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
index f8c660bd932..c5a0bd0d4d5 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_off.result b/mysql-test/suite/perfschema/r/table_aggregate_off.result
index 73ed3550a77..99bd574607e 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_off.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_off.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
index 3906c6f6b84..712ca9f4c2a 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
index 0b579f54a66..8c58b76cec1 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
index e137525e5b0..5b834ea27d8 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
index 799555b685e..5e24f459a93 100644
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
index bf920a30af3..a7a61e6f16a 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
index d100f2a5e08..05299d114a0 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
index a5d046f154c..5326c7062c0 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
index 413a566fefb..d5e978f3d5e 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
index 4a5e7aeede1..4ce6a41fb78 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
index 25ba676993a..bc6c4d796da 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
index 41292e5913e..f229a372ab1 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
index fc7c523ed8c..105008d44be 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
index 210928a0c04..7e09ef0e726 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
index 9df65066d45..3b53ea621c8 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
index a9109fa42d2..26de58126d6 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
index 542b020f77a..9eddd4e4272 100644
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
index ece0dadebd0..f6831d72302 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
index 956540b9327..3b97128675c 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
index 72f0240c6be..1a95ca86544 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
index a93cc1b6499..011faa3e388 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
index 0e1b7032af6..ea8151276e7 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
index fb1fd8fb207..a4de57aebbe 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
index f97272634b9..a52fb516a23 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
index ddf8ef7bf9d..4d22b83a9eb 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
index 588a378024a..19cef9fca2b 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
index 76c466d48cc..2824a073edf 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
index 2450456355a..a8085acb6bf 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
@@ -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
diff --git a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
index 72b46a2820b..be935a809e1 100644
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
@@ -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
diff --git a/mysql-test/t/compound.test b/mysql-test/t/compound.test
new file mode 100644
index 00000000000..7140fe9ad3f
--- /dev/null
+++ b/mysql-test/t/compound.test
@@ -0,0 +1,115 @@
+#
+# 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
diff --git a/sql/lex.h b/sql/lex.h
index 6834e4b3b19..41be9b2673d 100644
--- a/sql/lex.h
+++ b/sql/lex.h
@@ -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)},
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 3e6907403cc..6f0cbc24e63 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -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},
diff --git a/sql/sp_head.cc b/sql/sp_head.cc
index 71502200841..3d1b7b662db 100644
--- a/sql/sp_head.cc
+++ b/sql/sp_head.cc
@@ -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,7 +1238,8 @@ 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
*/
- saved_creation_ctx= m_creation_ctx->set_n_backup(thd);
+ if (m_creation_ctx)
+ saved_creation_ctx= m_creation_ctx->set_n_backup(thd);
/*
We have to save/restore this info when we are changing call level to
@@ -1401,7 +1403,8 @@ sp_head::execute(THD *thd, bool merge_da_on_success)
/* Restore query context. */
- m_creation_ctx->restore_env(thd, saved_creation_ctx);
+ 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;
diff --git a/sql/sql_cmd.h b/sql/sql_cmd.h
index 231db2a1d8c..09b3d927d92 100644
--- a/sql/sql_cmd.h
+++ b/sql/sql_cmd.h
@@ -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
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index b09184d6836..43bc288380a 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.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);
- delete lex->sphead;
- lex->sphead= NULL;
+ 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);
/*
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index bc5fa3a9e2a..584d6fcbfa2 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -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 @@ create_sp_error:
}
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:
{
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 9f195b93e23..7c51bbf6426 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -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);
- /*
- 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 ..."
- */
- DBUG_ASSERT(lex->sphead == NULL || error != 0);
+ if (error)
+ {
+ /*
+ let the following code know we're not in PS anymore,
+ the won't be any EXECUTE, so we need a full cleanup
+ */
+ lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_PREPARE;
+ }
+
/* The order is important */
lex->unit.cleanup();
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 517c98fd06b..828e9e3a367 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -236,7 +236,8 @@ static sp_head *make_sp_head(THD *thd, sp_name *name,
sp->reset_thd_mem_root(thd);
sp->init(lex);
sp->m_type= type;
- sp->init_sp_name(thd, name);
+ 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; }