List:Commits« Previous MessageNext Message »
From:Mayank Prasad Date:May 24 2012 4:04pm
Subject:bzr push into mysql-trunk branch (mayank.prasad:3885 to 3886) Bug#14069132
View as plain text  
 3886 Mayank Prasad	2012-05-24
      Bug#14069132 : STATEMENT DIGESTS DUPLICATE CALL STATEMENTS OF THE SAME NORMALIZED FORM
            
      Issue:
        During parsing of a call statement, tokens from sub statements were 
        getting considered as well because of which tokens collection of 
        'call statement' was getting affected. So, due to these extra unwanted 
        tokens, digest generated for call statement, was different from the 
        further calls of same call statement where sub statements were not 
        parsed again.
            
      Resolution:
        Restrict collection of token for only top-level statement. i.e. no 
        instrumentation for sub-statements.

    modified:
      mysql-test/suite/perfschema/include/digest_cleanup.inc
      mysql-test/suite/perfschema/include/digest_execution.inc
      mysql-test/suite/perfschema/include/digest_setup.inc
      mysql-test/suite/perfschema/r/digest_table_full.result
      mysql-test/suite/perfschema/r/start_server_no_digests.result
      mysql-test/suite/perfschema/r/statement_digest.result
      mysql-test/suite/perfschema/r/statement_digest_consumers.result
      mysql-test/suite/perfschema/r/statement_digest_consumers2.result
      sql/event_data_objects.cc
      sql/sp.cc
      sql/sp_instr.cc
      sql/sql_parse.cc
      sql/sql_partition.cc
      sql/sql_prepare.cc
      sql/sql_trigger.cc
 3885 Guilhem Bichot	2012-05-23
      Rename trigcond_if() to <if>(), it should be clearer
      for users who read EXPLAIN EXTENDED: triggered conditions
      work like the familiar IF() SQL function.
      <if>() is surrounded with <> to distinguish from
      the if() SQL function, to emphasize that this is optimizer-
      generated. Like Item_func_not_all is '<not>' and
      the SQL NOT in 'not'.

    modified:
      mysql-test/r/explain_json_all.result
      mysql-test/r/explain_json_none.result
      mysql-test/r/innodb_explain_json_non_select_all.result
      mysql-test/r/innodb_explain_json_non_select_none.result
      mysql-test/r/subquery_all.result
      mysql-test/r/subquery_all_bka.result
      mysql-test/r/subquery_all_bka_nixbnl.result
      mysql-test/r/subquery_mat.result
      mysql-test/r/subquery_mat_all.result
      mysql-test/r/subquery_mat_none.result
      mysql-test/r/subquery_nomat_nosj.result
      mysql-test/r/subquery_nomat_nosj_bka.result
      mysql-test/r/subquery_nomat_nosj_bka_nixbnl.result
      mysql-test/r/subquery_none.result
      mysql-test/r/subquery_none_bka.result
      mysql-test/r/subquery_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_all.result
      mysql-test/r/subquery_sj_all_bka.result
      mysql-test/r/subquery_sj_all_bka_nixbnl.result
      mysql-test/r/subquery_sj_all_bkaunique.result
      mysql-test/r/subquery_sj_dupsweed.result
      mysql-test/r/subquery_sj_dupsweed_bka.result
      mysql-test/r/subquery_sj_dupsweed_bka_nixbnl.result
      mysql-test/r/subquery_sj_dupsweed_bkaunique.result
      mysql-test/r/subquery_sj_firstmatch.result
      mysql-test/r/subquery_sj_firstmatch_bka.result
      mysql-test/r/subquery_sj_firstmatch_bka_nixbnl.result
      mysql-test/r/subquery_sj_firstmatch_bkaunique.result
      mysql-test/r/subquery_sj_loosescan.result
      mysql-test/r/subquery_sj_loosescan_bka.result
      mysql-test/r/subquery_sj_loosescan_bka_nixbnl.result
      mysql-test/r/subquery_sj_loosescan_bkaunique.result
      mysql-test/r/subquery_sj_mat.result
      mysql-test/r/subquery_sj_mat_bka.result
      mysql-test/r/subquery_sj_mat_bka_nixbnl.result
      mysql-test/r/subquery_sj_mat_bkaunique.result
      mysql-test/r/subquery_sj_mat_nosj.result
      mysql-test/r/subquery_sj_none.result
      mysql-test/r/subquery_sj_none_bka.result
      mysql-test/r/subquery_sj_none_bka_nixbnl.result
      mysql-test/r/subquery_sj_none_bkaunique.result
      mysql-test/suite/opt_trace/r/bugs_no_prot_all.result
      mysql-test/suite/opt_trace/r/bugs_no_prot_none.result
      mysql-test/suite/opt_trace/r/bugs_ps_prot_all.result
      mysql-test/suite/opt_trace/r/bugs_ps_prot_none.result
      mysql-test/suite/opt_trace/r/filesort_pq.result
      mysql-test/suite/opt_trace/r/general2_no_prot.result
      mysql-test/suite/opt_trace/r/general2_ps_prot.result
      mysql-test/suite/opt_trace/r/general_no_prot_all.result
      mysql-test/suite/opt_trace/r/general_no_prot_none.result
      mysql-test/suite/opt_trace/r/general_ps_prot_all.result
      mysql-test/suite/opt_trace/r/general_ps_prot_none.result
      mysql-test/suite/opt_trace/r/subquery_no_prot.result
      mysql-test/suite/opt_trace/r/subquery_ps_prot.result
      sql/item_cmpfunc.cc
      sql/item_cmpfunc.h
=== modified file 'mysql-test/suite/perfschema/include/digest_cleanup.inc'
--- a/mysql-test/suite/perfschema/include/digest_cleanup.inc	2012-04-06 10:12:40 +0000
+++ b/mysql-test/suite/perfschema/include/digest_cleanup.inc	2012-05-24 16:01:28 +0000
@@ -8,5 +8,7 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;
 --enable_warnings

=== modified file 'mysql-test/suite/perfschema/include/digest_execution.inc'
--- a/mysql-test/suite/perfschema/include/digest_execution.inc	2012-04-06 10:12:40 +0000
+++ b/mysql-test/suite/perfschema/include/digest_execution.inc	2012-05-24 16:01:28 +0000
@@ -91,10 +91,40 @@ DROP DATABASE statements_digest_temp;
 # captured.
 # -----------------------------------------------------------------------
 --ERROR ER_NO_SUCH_TABLE
-SELECT 1 from t11;
-create table t11 (c char(4));
+SELECT 1 FROM no_such_table;
+CREATE TABLE dup_table (c char(4));
 --ERROR ER_TABLE_EXISTS_ERROR
-create table t11 (c char(4));
-insert into t11 values("MySQL");
+CREATE TABLE dup_table (c char(4));
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 
+# -----------------------------------------------------------------------
+# Tests to show sub-statements for following statements are not
+# instrumented.
+#  - Prepared Statements
+#  - Stored Procedures/Functions.
+#  - Table Triggers
+# -----------------------------------------------------------------------
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+EXECUTE stmt;
+DEALLOCATE PREPARE stmt;
+
+DELIMITER //;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+DELIMITER ;//
+CALL p1();
+CALL p1();
+DROP PROCEDURE p1;
+
+DELIMITER //;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+DELIMITER ;//
+select func(3,4);
+select func(13,42);
+DROP FUNCTION func;
 
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;

=== modified file 'mysql-test/suite/perfschema/include/digest_setup.inc'
--- a/mysql-test/suite/perfschema/include/digest_setup.inc	2012-04-06 10:12:40 +0000
+++ b/mysql-test/suite/perfschema/include/digest_setup.inc	2012-05-24 16:01:28 +0000
@@ -18,5 +18,7 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 --enable_warnings
 

=== modified file 'mysql-test/suite/perfschema/r/digest_table_full.result'
--- a/mysql-test/suite/perfschema/r/digest_table_full.result	2012-05-23 05:02:04 +0000
+++ b/mysql-test/suite/perfschema/r/digest_table_full.result	2012-05-24 16:01:28 +0000
@@ -9,6 +9,8 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
 ####################################
 # EXECUTION
@@ -71,21 +73,46 @@ CREATE SCHEMA statements_digest_temp;
 DROP SCHEMA statements_digest_temp;
 CREATE DATABASE statements_digest_temp;
 DROP DATABASE statements_digest_temp;
-SELECT 1 from t11;
-ERROR 42S02: Table 'statements_digest.t11' doesn't exist
-create table t11 (c char(4));
-create table t11 (c char(4));
-ERROR 42S01: Table 't11' already exists
-insert into t11 values("MySQL");
+SELECT 1 FROM no_such_table;
+ERROR 42S02: Table 'statements_digest.no_such_table' doesn't exist
+CREATE TABLE dup_table (c char(4));
+CREATE TABLE dup_table (c char(4));
+ERROR 42S01: Table 'dup_table' already exists
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 Warnings:
 Warning	1265	Data truncated for column 'c' at row 1
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+c
+EXECUTE stmt;
+c
+DEALLOCATE PREPARE stmt;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+CALL p1();
+c
+CALL p1();
+c
+DROP PROCEDURE p1;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+select func(3,4);
+func(3,4)
+7
+select func(13,42);
+func(13,42)
+55
+DROP FUNCTION func;
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;
 ####################################
 # QUERYING PS STATEMENT DIGEST
 ####################################
 SELECT DIGEST, DIGEST_TEXT, COUNT_STAR, SUM_ROWS_AFFECTED, SUM_WARNINGS,
 SUM_ERRORS FROM performance_schema.events_statements_summary_by_digest;
 DIGEST	DIGEST_TEXT	COUNT_STAR	SUM_ROWS_AFFECTED	SUM_WARNINGS	SUM_ERRORS
-NULL	NULL	38	30	1	2
+NULL	NULL	55	32	1	2
 6c4650f18d00d7f69763f7c1836e872e	TRUNCATE TABLE performance_schema . events_statements_summary_by_digest  	1	0	0	0
 SHOW VARIABLES LIKE "performance_schema_digests_size";
 Variable_name	Value
@@ -102,4 +129,6 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;

=== modified file 'mysql-test/suite/perfschema/r/start_server_no_digests.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-04-06 10:12:40 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_digests.result	2012-05-24 16:01:28 +0000
@@ -9,6 +9,8 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
 ####################################
 # EXECUTION
@@ -71,14 +73,39 @@ CREATE SCHEMA statements_digest_temp;
 DROP SCHEMA statements_digest_temp;
 CREATE DATABASE statements_digest_temp;
 DROP DATABASE statements_digest_temp;
-SELECT 1 from t11;
-ERROR 42S02: Table 'statements_digest.t11' doesn't exist
-create table t11 (c char(4));
-create table t11 (c char(4));
-ERROR 42S01: Table 't11' already exists
-insert into t11 values("MySQL");
+SELECT 1 FROM no_such_table;
+ERROR 42S02: Table 'statements_digest.no_such_table' doesn't exist
+CREATE TABLE dup_table (c char(4));
+CREATE TABLE dup_table (c char(4));
+ERROR 42S01: Table 'dup_table' already exists
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 Warnings:
 Warning	1265	Data truncated for column 'c' at row 1
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+c
+EXECUTE stmt;
+c
+DEALLOCATE PREPARE stmt;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+CALL p1();
+c
+CALL p1();
+c
+DROP PROCEDURE p1;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+select func(3,4);
+func(3,4)
+7
+select func(13,42);
+func(13,42)
+55
+DROP FUNCTION func;
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;
 ####################################
 # QUERYING PS STATEMENT DIGEST
 ####################################
@@ -100,4 +127,6 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;

=== modified file 'mysql-test/suite/perfschema/r/statement_digest.result'
--- a/mysql-test/suite/perfschema/r/statement_digest.result	2012-05-23 05:02:04 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest.result	2012-05-24 16:01:28 +0000
@@ -9,6 +9,8 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 TRUNCATE TABLE performance_schema.events_statements_summary_by_digest;
 ####################################
 # EXECUTION
@@ -71,14 +73,39 @@ CREATE SCHEMA statements_digest_temp;
 DROP SCHEMA statements_digest_temp;
 CREATE DATABASE statements_digest_temp;
 DROP DATABASE statements_digest_temp;
-SELECT 1 from t11;
-ERROR 42S02: Table 'statements_digest.t11' doesn't exist
-create table t11 (c char(4));
-create table t11 (c char(4));
-ERROR 42S01: Table 't11' already exists
-insert into t11 values("MySQL");
+SELECT 1 FROM no_such_table;
+ERROR 42S02: Table 'statements_digest.no_such_table' doesn't exist
+CREATE TABLE dup_table (c char(4));
+CREATE TABLE dup_table (c char(4));
+ERROR 42S01: Table 'dup_table' already exists
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 Warnings:
 Warning	1265	Data truncated for column 'c' at row 1
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+c
+EXECUTE stmt;
+c
+DEALLOCATE PREPARE stmt;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+CALL p1();
+c
+CALL p1();
+c
+DROP PROCEDURE p1;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+select func(3,4);
+func(3,4)
+7
+select func(13,42);
+func(13,42)
+55
+DROP FUNCTION func;
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;
 ####################################
 # QUERYING PS STATEMENT DIGEST
 ####################################
@@ -105,10 +132,23 @@ bcb3fc3aa0ea73f20809e6525d41b95b	SELECT
 651e639ea4fee3b3dbee7f6f9fd44ca0	SELECT ?  	1	0	0	0
 7d2a54e6edd2117b661078941415d492	CREATE SCHEMA statements_digest_temp  	2	2	0	0
 131870b25daddd214b5c200444364bd2	DROP SCHEMA statements_digest_temp  	2	0	0	0
-249a5f8b104c00dedcc50d71449bba0d	SELECT ? FROM t11  	1	0	0	1
-72c49981fce5ac1ee4f4877119b825f5	CREATE TABLE t11 ( c CHARACTER (?) )  	2	0	0	1
+b0fd38c8c8ba0c583fbb4ba8f1700913	SELECT ? FROM no_such_table  	1	0	0	1
+82405affe63462139756f46ea36e519d	CREATE TABLE dup_table ( c CHARACTER (?) )  	2	0	0	1
+de657b9e0f2a65bbbfe94547ebcfebe5	DROP TABLE dup_table  	1	0	0	0
 21ccf832feb3cd3581d472f7225ec046	INSERT INTO t11 VALUES (?)  	1	1	1	0
 1965b72c3916198861e7286faeece568	SHOW WARNINGS  	1	0	0	0
+9e2523c476f7dadd9300cceb882f434b	PREPARE stmt FROM ?  	1	0	0	0
+6d8939f45fc7420164ce88e58a78968e	EXECUTE stmt  	2	0	0	0
+3233cf3d73bf0cd5c5cc69fab5b30ddf	DEALLOCATE PREPARE stmt  	1	0	0	0
+c11611c72fd535d2491e30c92a46dba2	CREATE PROCEDURE p1 ( ) BEGIN SELECT * FROM t12 ; END  	1	0	0	0
+594360f7221c898fb58af64d2867dea5	CALL p1 ( )  	2	0	0	0
+ec4a8c0368967dd4d9e4979d63204870	DROP PROCEDURE p1  	1	0	0	0
+22af63e8a85ae33a51d39946fa74c537	CREATE FUNCTION `func` ( a INTEGER , b INTEGER ) RETURNS INTEGER (?) RETURN a + b  	1	0	0	0
+c08a61e1b30bd73d60a0291fbf80cff0	SELECT func (...)  	2	0	0	0
+3df78ea379365800dd19ab9e35c7f8a5	DROP FUNCTION func  	1	0	0	0
+5499b14bde826af68fdf34c3c1310f47	CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @ ? := ?  	1	0	0	0
+8ec19a492733284c1444a7a804286800	INSERT INTO t12 VALUES (?)  	2	2	0	0
+25abe6e665794bc331965c048ea0bf5e	DROP TRIGGER trg  	1	0	0	0
 ####################################
 # CLEANUP
 ####################################
@@ -118,4 +158,6 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;

=== modified file 'mysql-test/suite/perfschema/r/statement_digest_consumers.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers.result	2012-05-23 05:02:04 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers.result	2012-05-24 16:01:28 +0000
@@ -9,6 +9,8 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 SELECT * FROM performance_schema.setup_consumers;
 NAME	ENABLED
 events_stages_current	YES
@@ -85,14 +87,39 @@ CREATE SCHEMA statements_digest_temp;
 DROP SCHEMA statements_digest_temp;
 CREATE DATABASE statements_digest_temp;
 DROP DATABASE statements_digest_temp;
-SELECT 1 from t11;
-ERROR 42S02: Table 'statements_digest.t11' doesn't exist
-create table t11 (c char(4));
-create table t11 (c char(4));
-ERROR 42S01: Table 't11' already exists
-insert into t11 values("MySQL");
+SELECT 1 FROM no_such_table;
+ERROR 42S02: Table 'statements_digest.no_such_table' doesn't exist
+CREATE TABLE dup_table (c char(4));
+CREATE TABLE dup_table (c char(4));
+ERROR 42S01: Table 'dup_table' already exists
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 Warnings:
 Warning	1265	Data truncated for column 'c' at row 1
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+c
+EXECUTE stmt;
+c
+DEALLOCATE PREPARE stmt;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+CALL p1();
+c
+CALL p1();
+c
+DROP PROCEDURE p1;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+select func(3,4);
+func(3,4)
+7
+select func(13,42);
+func(13,42)
+55
+DROP FUNCTION func;
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;
 ####################################
 # QUERYING PS STATEMENT DIGEST
 ####################################
@@ -118,10 +145,23 @@ bcb3fc3aa0ea73f20809e6525d41b95b	SELECT
 651e639ea4fee3b3dbee7f6f9fd44ca0	SELECT ?  	1
 7d2a54e6edd2117b661078941415d492	CREATE SCHEMA statements_digest_temp  	2
 131870b25daddd214b5c200444364bd2	DROP SCHEMA statements_digest_temp  	2
-249a5f8b104c00dedcc50d71449bba0d	SELECT ? FROM t11  	1
-72c49981fce5ac1ee4f4877119b825f5	CREATE TABLE t11 ( c CHARACTER (?) )  	2
+b0fd38c8c8ba0c583fbb4ba8f1700913	SELECT ? FROM no_such_table  	1
+82405affe63462139756f46ea36e519d	CREATE TABLE dup_table ( c CHARACTER (?) )  	2
+de657b9e0f2a65bbbfe94547ebcfebe5	DROP TABLE dup_table  	1
 21ccf832feb3cd3581d472f7225ec046	INSERT INTO t11 VALUES (?)  	1
 1965b72c3916198861e7286faeece568	SHOW WARNINGS  	1
+9e2523c476f7dadd9300cceb882f434b	PREPARE stmt FROM ?  	1
+6d8939f45fc7420164ce88e58a78968e	EXECUTE stmt  	2
+3233cf3d73bf0cd5c5cc69fab5b30ddf	DEALLOCATE PREPARE stmt  	1
+c11611c72fd535d2491e30c92a46dba2	CREATE PROCEDURE p1 ( ) BEGIN SELECT * FROM t12 ; END  	1
+594360f7221c898fb58af64d2867dea5	CALL p1 ( )  	2
+ec4a8c0368967dd4d9e4979d63204870	DROP PROCEDURE p1  	1
+22af63e8a85ae33a51d39946fa74c537	CREATE FUNCTION `func` ( a INTEGER , b INTEGER ) RETURNS INTEGER (?) RETURN a + b  	1
+c08a61e1b30bd73d60a0291fbf80cff0	SELECT func (...)  	2
+3df78ea379365800dd19ab9e35c7f8a5	DROP FUNCTION func  	1
+5499b14bde826af68fdf34c3c1310f47	CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @ ? := ?  	1
+8ec19a492733284c1444a7a804286800	INSERT INTO t12 VALUES (?)  	2
+25abe6e665794bc331965c048ea0bf5e	DROP TRIGGER trg  	1
 SELECT digest, digest_text FROM performance_schema.events_statements_current;
 digest	digest_text
 ####################################
@@ -133,4 +173,6 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;

=== modified file 'mysql-test/suite/perfschema/r/statement_digest_consumers2.result'
--- a/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	2012-04-06 10:12:40 +0000
+++ b/mysql-test/suite/perfschema/r/statement_digest_consumers2.result	2012-05-24 16:01:28 +0000
@@ -9,6 +9,8 @@ CREATE TABLE t3(a int, b int);
 CREATE TABLE t4(a int, b int);
 CREATE TABLE t5(a int, b int, c int);
 CREATE TABLE t6(a int, b int, c int, d int);
+CREATE TABLE t11 (c CHAR(4));
+CREATE TABLE t12 (c CHAR(4));
 SELECT * FROM performance_schema.setup_consumers;
 NAME	ENABLED
 events_stages_current	YES
@@ -85,14 +87,39 @@ CREATE SCHEMA statements_digest_temp;
 DROP SCHEMA statements_digest_temp;
 CREATE DATABASE statements_digest_temp;
 DROP DATABASE statements_digest_temp;
-SELECT 1 from t11;
-ERROR 42S02: Table 'statements_digest.t11' doesn't exist
-create table t11 (c char(4));
-create table t11 (c char(4));
-ERROR 42S01: Table 't11' already exists
-insert into t11 values("MySQL");
+SELECT 1 FROM no_such_table;
+ERROR 42S02: Table 'statements_digest.no_such_table' doesn't exist
+CREATE TABLE dup_table (c char(4));
+CREATE TABLE dup_table (c char(4));
+ERROR 42S01: Table 'dup_table' already exists
+DROP TABLE dup_table;
+INSERT INTO t11 VALUES("MySQL");
 Warnings:
 Warning	1265	Data truncated for column 'c' at row 1
+PREPARE stmt FROM "SELECT * FROM t12";
+EXECUTE stmt;
+c
+EXECUTE stmt;
+c
+DEALLOCATE PREPARE stmt;
+CREATE PROCEDURE p1() BEGIN SELECT * FROM t12; END//
+CALL p1();
+c
+CALL p1();
+c
+DROP PROCEDURE p1;
+CREATE FUNCTION `func`(a INT, b INT) RETURNS int(11) RETURN a+b //
+select func(3,4);
+func(3,4)
+7
+select func(13,42);
+func(13,42)
+55
+DROP FUNCTION func;
+CREATE TRIGGER trg BEFORE INSERT ON t12 FOR EACH ROW SET @a:=1;
+INSERT INTO t12 VALUES ("abc");
+INSERT INTO t12 VALUES ("def");
+DROP TRIGGER trg;
 ####################################
 # QUERYING PS STATEMENT DIGEST
 ####################################
@@ -110,4 +137,6 @@ DROP TABLE IF EXISTS t3;
 DROP TABLE IF EXISTS t4;
 DROP TABLE IF EXISTS t5;
 DROP TABLE IF EXISTS t6;
+DROP TABLE IF EXISTS t11;
+DROP TABLE IF EXISTS t12;
 DROP DATABASE IF EXISTS statements_digest;

=== modified file 'sql/event_data_objects.cc'
--- a/sql/event_data_objects.cc	2012-03-06 14:29:42 +0000
+++ b/sql/event_data_objects.cc	2012-05-24 16:01:28 +0000
@@ -1334,6 +1334,7 @@ Event_job_data::execute(THD *thd, bool d
 #endif
   List<Item> empty_item_list;
   bool ret= TRUE;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
 
   DBUG_ENTER("Event_job_data::execute");
 
@@ -1408,14 +1409,17 @@ Event_job_data::execute(THD *thd, bool d
     if (parser_state.init(thd, thd->query(), thd->query_length()))
       goto end;
 
+    thd->m_statement_psi= NULL;
     if (parse_sql(thd, & parser_state, creation_ctx))
     {
       sql_print_error("Event Scheduler: "
                       "%serror during compilation of %s.%s",
                       thd->is_fatal_error ? "fatal " : "",
                       (const char *) dbname.str, (const char *) name.str);
+      thd->m_statement_psi= parent_locker;
       goto end;
     }
+    thd->m_statement_psi= parent_locker;
   }
 
   {

=== modified file 'sql/sp.cc'
--- a/sql/sp.cc	2012-05-16 13:58:54 +0000
+++ b/sql/sp.cc	2012-05-24 16:01:28 +0000
@@ -747,6 +747,7 @@ static sp_head *sp_compile(THD *thd, Str
   sp_rcontext *sp_runtime_ctx_saved= thd->sp_runtime_ctx;
   Silence_deprecated_warning warning_handler;
   Parser_state parser_state;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
 
   thd->variables.sql_mode= sql_mode;
   thd->variables.select_limit= HA_POS_ERROR;
@@ -762,6 +763,7 @@ static sp_head *sp_compile(THD *thd, Str
   thd->push_internal_handler(&warning_handler);
   thd->sp_runtime_ctx= NULL;
 
+  thd->m_statement_psi= NULL;
   if (parse_sql(thd, & parser_state, creation_ctx) || thd->lex == NULL)
   {
     sp= thd->lex->sphead;
@@ -772,6 +774,7 @@ static sp_head *sp_compile(THD *thd, Str
   {
     sp= thd->lex->sphead;
   }
+  thd->m_statement_psi= parent_locker;
 
   thd->pop_internal_handler();
   thd->sp_runtime_ctx= sp_runtime_ctx_saved;

=== modified file 'sql/sp_instr.cc'
--- a/sql/sp_instr.cc	2012-05-16 13:58:54 +0000
+++ b/sql/sp_instr.cc	2012-05-24 16:01:28 +0000
@@ -443,6 +443,7 @@ bool sp_lex_instr::reset_lex_and_exec_co
 LEX *sp_lex_instr::parse_expr(THD *thd, sp_head *sp)
 {
   String sql_query;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
   sql_query.set_charset(system_charset_info);
 
   get_query(&sql_query);
@@ -495,7 +496,9 @@ LEX *sp_lex_instr::parse_expr(THD *thd,
 
   // Parse the just constructed SELECT-statement.
 
+  thd->m_statement_psi= NULL;
   bool parsing_failed= parse_sql(thd, &parser_state, NULL);
+  thd->m_statement_psi= parent_locker;
 
   if (!parsing_failed)
   {

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2012-05-23 05:02:04 +0000
+++ b/sql/sql_parse.cc	2012-05-24 16:01:28 +0000
@@ -6115,6 +6115,7 @@ bool mysql_test_parse_for_slave(THD *thd
 {
   LEX *lex= thd->lex;
   bool error= 0;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
   DBUG_ENTER("mysql_test_parse_for_slave");
 
   Parser_state parser_state;
@@ -6123,9 +6124,11 @@ bool mysql_test_parse_for_slave(THD *thd
     lex_start(thd);
     mysql_reset_thd_for_next_command(thd);
 
+    thd->m_statement_psi= NULL;
     if (!parse_sql(thd, & parser_state, NULL) &&
         all_tables_not_ok(thd, lex->select_lex.table_list.first))
       error= 1;                  /* Ignore question */
+    thd->m_statement_psi= parent_locker;
     thd->end_statement();
   }
   thd->cleanup_after_query();

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2012-05-09 16:47:39 +0000
+++ b/sql/sql_partition.cc	2012-05-24 16:01:28 +0000
@@ -4279,6 +4279,7 @@ bool mysql_unpack_partition(THD *thd,
     thd->variables.character_set_client;
   LEX *old_lex= thd->lex;
   LEX lex;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
   DBUG_ENTER("mysql_unpack_partition");
 
   thd->variables.character_set_client= system_charset_info;
@@ -4308,12 +4309,16 @@ bool mysql_unpack_partition(THD *thd,
   }
   part_info= lex.part_info;
   DBUG_PRINT("info", ("Parse: %s", part_buf));
+
+  thd->m_statement_psi= NULL;
   if (parse_sql(thd, & parser_state, NULL) ||
       part_info->fix_parser_data(thd))
   {
     thd->free_items();
+    thd->m_statement_psi= parent_locker;
     goto end;
   }
+  thd->m_statement_psi= parent_locker;
   /*
     The parsed syntax residing in the frm file can still contain defaults.
     The reason is that the frm file is sometimes saved outside of this

=== modified file 'sql/sql_prepare.cc'
--- a/sql/sql_prepare.cc	2012-05-17 20:54:59 +0000
+++ b/sql/sql_prepare.cc	2012-05-24 16:01:28 +0000
@@ -3057,7 +3057,10 @@ Execute_sql_statement::execute_server_co
   parser_state.m_lip.multi_statements= FALSE;
   lex_start(thd);
 
+  parent_locker= thd->m_statement_psi;
+  thd->m_statement_psi= NULL;
   error= parse_sql(thd, &parser_state, NULL) || thd->is_error();
+  thd->m_statement_psi= parent_locker;
 
   if (error)
     goto end;
@@ -3253,6 +3256,7 @@ bool Prepared_statement::prepare(const c
   bool error;
   Statement stmt_backup;
   Query_arena *old_stmt_arena;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
   DBUG_ENTER("Prepared_statement::prepare");
   /*
     If this is an SQLCOM_PREPARE, we also increase Com_prepare_sql.
@@ -3299,9 +3303,11 @@ bool Prepared_statement::prepare(const c
   lex_start(thd);
   lex->context_analysis_only|= CONTEXT_ANALYSIS_ONLY_PREPARE;
 
+  thd->m_statement_psi= NULL;
   error= parse_sql(thd, & parser_state, NULL) ||
     thd->is_error() ||
     init_param_array(this);
+  thd->m_statement_psi= parent_locker;
 
   lex->set_trg_event_type_for_tables();
 

=== modified file 'sql/sql_trigger.cc'
--- a/sql/sql_trigger.cc	2012-05-16 11:03:43 +0000
+++ b/sql/sql_trigger.cc	2012-05-24 16:01:28 +0000
@@ -1151,6 +1151,7 @@ bool Table_triggers_list::check_n_load(T
   LEX_STRING path;
   File_parser *parser;
   LEX_STRING save_db;
+  PSI_statement_locker *parent_locker= thd->m_statement_psi;
 
   DBUG_ENTER("Table_triggers_list::check_n_load");
 
@@ -1386,7 +1387,9 @@ bool Table_triggers_list::check_n_load(T
 
         Deprecated_trigger_syntax_handler error_handler;
         thd->push_internal_handler(&error_handler);
+        thd->m_statement_psi= NULL;
         bool parse_error= parse_sql(thd, & parser_state, creation_ctx);
+        thd->m_statement_psi= parent_locker;
         thd->pop_internal_handler();
 
         /*

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-trunk branch (mayank.prasad:3885 to 3886) Bug#14069132Mayank Prasad25 May