3499 Jon Olav Hauglid 2011-10-14 [merge]
WL#2111 Stored Procedures: Implement GET DIAGNOSTICS
Merged from mysql-trunk-wl2111-new
Text conflict in sql/sql_yacc.yy
added:
mysql-test/r/get_diagnostics.result
mysql-test/t/get_diagnostics.test
sql/sql_get_diagnostics.cc
sql/sql_get_diagnostics.h
unittest/gunit/get_diagnostics-t.cc
modified:
mysql-test/r/mysqld--help-notwin.result
mysql-test/r/mysqld--help-win.result
mysql-test/r/sp.result
mysql-test/suite/perfschema/r/ortho_iter.result
mysql-test/suite/perfschema/r/privilege_table_io.result
mysql-test/suite/perfschema/r/start_server_innodb.result
mysql-test/suite/perfschema/r/start_server_no_account.result
mysql-test/suite/perfschema/r/start_server_no_cond_class.result
mysql-test/suite/perfschema/r/start_server_no_cond_inst.result
mysql-test/suite/perfschema/r/start_server_no_file_class.result
mysql-test/suite/perfschema/r/start_server_no_file_inst.result
mysql-test/suite/perfschema/r/start_server_no_host.result
mysql-test/suite/perfschema/r/start_server_no_mutex_class.result
mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result
mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result
mysql-test/suite/perfschema/r/start_server_no_setup_actors.result
mysql-test/suite/perfschema/r/start_server_no_setup_objects.result
mysql-test/suite/perfschema/r/start_server_no_socket_class.result
mysql-test/suite/perfschema/r/start_server_no_socket_inst.result
mysql-test/suite/perfschema/r/start_server_no_stage_class.result
mysql-test/suite/perfschema/r/start_server_no_stages_history.result
mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result
mysql-test/suite/perfschema/r/start_server_no_statements_history.result
mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result
mysql-test/suite/perfschema/r/start_server_no_table_hdl.result
mysql-test/suite/perfschema/r/start_server_no_table_inst.result
mysql-test/suite/perfschema/r/start_server_no_thread_class.result
mysql-test/suite/perfschema/r/start_server_no_thread_inst.result
mysql-test/suite/perfschema/r/start_server_no_user.result
mysql-test/suite/perfschema/r/start_server_no_waits_history.result
mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result
mysql-test/suite/perfschema/r/start_server_off.result
mysql-test/suite/perfschema/r/start_server_on.result
mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_off.result
mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result
mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result
mysql-test/suite/rpl/r/rpl_stm_user_variables.result
mysql-test/suite/rpl/t/rpl_stm_user_variables.test
mysql-test/t/sp.test
sql/CMakeLists.txt
sql/item.cc
sql/item.h
sql/item_create.cc
sql/lex.h
sql/mysqld.cc
sql/share/errmsg-utf8.txt
sql/sql_cmd.h
sql/sql_error.cc
sql/sql_error.h
sql/sql_lex.h
sql/sql_parse.cc
sql/sql_yacc.yy
unittest/gunit/CMakeLists.txt
3498 Bjorn Munch 2011-10-14
Bug #13016347 FAILURE AT CHECK-WARNINGS FOR WINDOWS ON DAILY-TRUNK
Give up solving the problem completely
Let it happen, but then catch the case based on output,
and pretend we did get exit code 62
modified:
mysql-test/mysql-test-run.pl
=== added file 'mysql-test/r/get_diagnostics.result'
--- a/mysql-test/r/get_diagnostics.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/r/get_diagnostics.result 2011-10-14 15:38:24 +0000
@@ -0,0 +1,802 @@
+#
+# WL#2111: GET DIAGNOSTICS tests
+#
+#
+# Test reserved keywords: GET
+#
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1 (get INT);
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'get INT)' at line 1
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE get INT DEFAULT 1;
+END|
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'get INT DEFAULT 1;
+END' at line 3
+# Quoting
+CREATE TABLE t1 (`get` INT);
+INSERT INTO t1 (`get`) values (1);
+SELECT `get` FROM t1 WHERE `get` = 1;
+get
+1
+DROP TABLE t1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE `get` INT DEFAULT 1;
+SELECT `get`;
+END|
+CALL p1();
+`get`
+1
+DROP PROCEDURE p1;
+#
+# Test non-reserved keywords: CURRENT, DIAGNOSTICS, NUMBER, RETURNED_SQLSTATE
+#
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+CREATE TABLE t1 (current INT, diagnostics INT, number INT, returned_sqlstate INT);
+INSERT INTO t1 (current, diagnostics, number, returned_sqlstate) values (1,2,3,4);
+SELECT current, diagnostics, number, returned_sqlstate FROM t1 WHERE number = 3;
+current diagnostics number returned_sqlstate
+1 2 3 4
+SELECT `current`, `number` FROM t1 WHERE `current` = 1 AND `number` = 3;
+current number
+1 3
+DROP TABLE t1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE current INT DEFAULT 1;
+DECLARE diagnostics INT DEFAULT 2;
+DECLARE number INT DEFAULT 3;
+DECLARE returned_sqlstate INT DEFAULT 4;
+SELECT current, diagnostics, number, returned_sqlstate;
+END|
+CALL p1();
+current diagnostics number returned_sqlstate
+1 2 3 4
+DROP PROCEDURE p1;
+#
+# Test GET DIAGNOSTICS syntax
+#
+DROP PROCEDURE IF EXISTS p1;
+GET;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET CURRENT;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET CURRENT DIAGNOSTICS;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+
+# Statement information syntax
+
+GET DIAGNOSTICS @var;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS var;
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+GET DIAGNOSTICS var;
+END|
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS var;
+END|
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
+END' at line 4
+GET DIAGNOSTICS @var =;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS @var = INVALID;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID' at line 1
+GET DIAGNOSTICS @var = MORE;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'MORE' at line 1
+GET DIAGNOSTICS @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS @var = INVALID,;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID,' at line 1
+GET DIAGNOSTICS @var1 = NUMBER, @var2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS @var1 = NUMBER, @var2 = INVALID;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID' at line 1
+GET DIAGNOSTICS @@var1 = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@var1 = NUMBER' at line 1
+GET DIAGNOSTICS @var1 = NUMBER, @@var2 = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@var2 = NUMBER' at line 1
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS var = INVALID;
+END|
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID;
+END' at line 4
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var CONDITION FOR SQLSTATE '12345';
+GET DIAGNOSTICS var = NUMBER;
+END|
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS var = NUMBER, var1 = ROW_COUNT;
+END|
+ERROR 42000: Undeclared variable: var1
+GET DIAGNOSTICS @var = NUMBER;
+GET DIAGNOSTICS @var = ROW_COUNT;
+GET DIAGNOSTICS @var1 = NUMBER, @var2 = ROW_COUNT;
+GET DIAGNOSTICS @var1 = ROW_COUNT, @var2 = NUMBER;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+DECLARE var1 INT;
+DECLARE var2 INT;
+GET DIAGNOSTICS var = NUMBER;
+GET DIAGNOSTICS var = ROW_COUNT;
+GET DIAGNOSTICS var1 = NUMBER, var2 = ROW_COUNT;
+GET DIAGNOSTICS var1 = ROW_COUNT, var2 = NUMBER;
+END|
+DROP PROCEDURE p1;
+
+# Condition information syntax
+
+GET DIAGNOSTICS CONDITION;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION a;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION 1;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION 1 @var;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION 1 var;
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+GET DIAGNOSTICS CONDITION 1 var;
+END|
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS CONDITION 1 var;
+END|
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ';
+END' at line 4
+GET DIAGNOSTICS CONDITION 1 @var =;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION 1 @var = INVALID;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID' at line 1
+GET DIAGNOSTICS CONDITION 1 @var = NUMBER;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NUMBER' at line 1
+GET DIAGNOSTICS CONDITION 1 @var = INVALID,;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID,' at line 1
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2 = INVALID;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID' at line 1
+GET DIAGNOSTICS CONDITION 1 @@var1 = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@var1 = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @@var2 = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@var2 = CLASS_ORIGIN' at line 1
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS CONDITION 1 var = INVALID;
+END|
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INVALID;
+END' at line 4
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var CONDITION FOR SQLSTATE '12345';
+GET DIAGNOSTICS CONDITION 1 var = NUMBER;
+END|
+ERROR 42000: Undeclared variable: var
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS CONDITION 1 var = CLASS_ORIGIN, var1 = SUBCLASS_ORIGIN;
+END|
+ERROR 42000: Undeclared variable: var1
+GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2 = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var1 = SUBCLASS_ORIGIN, @var2 = CLASS_ORIGIN;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+DECLARE var1 INT;
+DECLARE var2 INT;
+GET DIAGNOSTICS CONDITION 1 var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 var = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 var1 = CLASS_ORIGIN, var2 = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 var1 = SUBCLASS_ORIGIN, var2 = CLASS_ORIGIN;
+END|
+DROP PROCEDURE p1;
+# Condition number expression
+GET DIAGNOSTICS CONDITION -1 @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-1 @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION 1+1 @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '+1 @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION ? @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '? @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION (1) @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(1) @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION p1() @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '() @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION ABS(2) @var = CLASS_ORIGIN;
+ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(2) @var = CLASS_ORIGIN' at line 1
+GET DIAGNOSTICS CONDITION 1.1 @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION "1" @var = CLASS_ORIGIN;
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+GET DIAGNOSTICS CONDITION 9999 @var = CLASS_ORIGIN;
+Warnings:
+Error 1753 Invalid condition number
+GET DIAGNOSTICS CONDITION NULL @var = CLASS_ORIGIN;
+Warnings:
+Error 1753 Invalid condition number
+Error 1753 Invalid condition number
+GET DIAGNOSTICS CONDITION a @var = CLASS_ORIGIN;
+Warnings:
+Error 1753 Invalid condition number
+Error 1753 Invalid condition number
+Error 1054 Unknown column 'a' in 'field list'
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+SET @cond = 1;
+GET DIAGNOSTICS CONDITION @cond @var1 = CLASS_ORIGIN;
+Warnings:
+Error 1753 Invalid condition number
+SET @cond = "invalid";
+GET DIAGNOSTICS CONDITION @cond @var1 = CLASS_ORIGIN;
+Warnings:
+Error 1753 Invalid condition number
+Error 1753 Invalid condition number
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE cond INT DEFAULT 1;
+DECLARE var INT;
+GET DIAGNOSTICS CONDITION cond var = CLASS_ORIGIN;
+END|
+DROP PROCEDURE p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE cond TEXT;
+DECLARE var INT;
+GET DIAGNOSTICS CONDITION cond var = CLASS_ORIGIN;
+END|
+CALL p1();
+DROP PROCEDURE p1;
+#
+# Test GET DIAGNOSTICS runtime
+#
+
+# GET DIAGNOSTICS cannot be the object of a PREPARE statement.
+
+PREPARE stmt FROM "GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN";
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+PREPARE stmt FROM "GET DIAGNOSTICS @var = NUMBER";
+ERROR HY000: This command is not supported in the prepared statement protocol yet
+
+# GET DIAGNOSTICS does not clear the diagnostics area.
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+GET DIAGNOSTICS @var = NUMBER;
+SHOW WARNINGS;
+Level Code Message
+Warning 1292 Truncated incorrect DECIMAL value: ''
+#
+# If GET DIAGNOSTICS itself causes an error, an error message is appended.
+#
+SELECT CAST(-19999999999999999999 AS SIGNED);
+CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+GET DIAGNOSTICS CONDITION 99999 @var = CLASS_ORIGIN;
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+Error 1753 Invalid condition number
+SHOW WARNINGS;
+Level Code Message
+Warning 1292 Truncated incorrect DECIMAL value: ''
+Error 1753 Invalid condition number
+
+# Statement information runtime
+
+SELECT CAST(-19999999999999999999 AS SIGNED),
+CAST(-19999999999999999999 AS SIGNED);
+CAST(-19999999999999999999 AS SIGNED) CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808 -9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+Warning 1292 Truncated incorrect DECIMAL value: ''
+GET DIAGNOSTICS @var = NUMBER;
+SELECT @var;
+@var
+2
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+GET DIAGNOSTICS @var = NUMBER;
+SELECT @var;
+@var
+0
+SELECT 1;
+1
+1
+GET DIAGNOSTICS @var = ROW_COUNT;
+SELECT @var;
+@var
+-1
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+GET DIAGNOSTICS @var = ROW_COUNT;
+SELECT @var;
+@var
+3
+DROP TABLE t1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE number INT;
+DECLARE row_count INT;
+SELECT CAST(-19999999999999999999 AS SIGNED),
+CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS number = NUMBER;
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+GET DIAGNOSTICS row_count = ROW_COUNT;
+DROP TABLE t1;
+SELECT number, row_count;
+END|
+CALL p1();
+CAST(-19999999999999999999 AS SIGNED) CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808 -9223372036854775808
+number row_count
+2 3
+DROP PROCEDURE p1;
+
+# Condition information runtime
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+GET DIAGNOSTICS CONDITION 1
+@class_origin = CLASS_ORIGIN,
+@subclass_origin = SUBCLASS_ORIGIN,
+@constraint_catalog = CONSTRAINT_CATALOG,
+@constraint_schema = CONSTRAINT_SCHEMA,
+@constraint_name = CONSTRAINT_NAME,
+@catalog_name = CATALOG_NAME,
+@schema_name = SCHEMA_NAME,
+@table_name = TABLE_NAME,
+@column_name = COLUMN_NAME,
+@cursor_name = CURSOR_NAME,
+@message_text = MESSAGE_TEXT,
+@mysql_errno = MYSQL_ERRNO,
+@returned_sqlstate = RETURNED_SQLSTATE;
+SELECT
+@class_origin,
+@subclass_origin,
+@constraint_catalog,
+@constraint_schema,
+@constraint_name,
+@catalog_name,
+@schema_name,
+@table_name,
+@column_name,
+@cursor_name,
+@message_text,
+@mysql_errno,
+@returned_sqlstate;
+@class_origin ISO 9075
+@subclass_origin ISO 9075
+@constraint_catalog
+@constraint_schema
+@constraint_name
+@catalog_name
+@schema_name
+@table_name
+@column_name
+@cursor_name
+@message_text Truncated incorrect DECIMAL value: ''
+@mysql_errno 1292
+@returned_sqlstate 22007
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE class_origin TEXT DEFAULT "a";
+DECLARE subclass_origin TEXT DEFAULT "a";
+DECLARE constraint_catalog TEXT DEFAULT "a";
+DECLARE constraint_schema TEXT DEFAULT "a";
+DECLARE constraint_name TEXT DEFAULT "a";
+DECLARE catalog_name TEXT DEFAULT "a";
+DECLARE schema_name TEXT DEFAULT "a";
+DECLARE table_name TEXT DEFAULT "a";
+DECLARE column_name TEXT DEFAULT "a";
+DECLARE cursor_name TEXT DEFAULT "a";
+DECLARE message_text TEXT DEFAULT "a";
+DECLARE mysql_errno INT DEFAULT 1;
+DECLARE returned_sqlstate TEXT DEFAULT "a";
+SELECT CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS CONDITION 1
+class_origin = CLASS_ORIGIN,
+subclass_origin = SUBCLASS_ORIGIN,
+constraint_catalog = CONSTRAINT_CATALOG,
+constraint_schema = CONSTRAINT_SCHEMA,
+constraint_name = CONSTRAINT_NAME,
+catalog_name = CATALOG_NAME,
+schema_name = SCHEMA_NAME,
+table_name = TABLE_NAME,
+column_name = COLUMN_NAME,
+cursor_name = CURSOR_NAME,
+message_text = MESSAGE_TEXT,
+mysql_errno = MYSQL_ERRNO,
+returned_sqlstate = RETURNED_SQLSTATE;
+SELECT
+class_origin,
+subclass_origin,
+constraint_catalog,
+constraint_schema,
+constraint_name,
+catalog_name,
+schema_name,
+table_name,
+column_name,
+cursor_name,
+message_text,
+mysql_errno,
+returned_sqlstate;
+END|
+CALL p1();
+CAST(-19999999999999999999 AS SIGNED) -9223372036854775808
+class_origin ISO 9075
+subclass_origin ISO 9075
+constraint_catalog
+constraint_schema
+constraint_name
+catalog_name
+schema_name
+table_name
+column_name
+cursor_name
+message_text Truncated incorrect DECIMAL value: ''
+mysql_errno 1292
+returned_sqlstate 22007
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect DECIMAL value: ''
+DROP PROCEDURE p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE errno1 INT;
+DECLARE errno2 INT;
+DECLARE msg1 TEXT;
+DECLARE msg2 TEXT;
+SELECT CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS CONDITION 99999 msg1 = MESSAGE_TEXT;
+GET DIAGNOSTICS CONDITION 1 errno1 = MYSQL_ERRNO, msg1 = MESSAGE_TEXT;
+GET DIAGNOSTICS CONDITION 2 errno2 = MYSQL_ERRNO, msg2 = MESSAGE_TEXT;
+SELECT errno1, msg1, errno2, msg2;
+END|
+CALL p1();
+CAST(-19999999999999999999 AS SIGNED) -9223372036854775808
+errno1 1292
+msg1 Truncated incorrect DECIMAL value: ''
+errno2 1753
+msg2 Invalid condition number
+Warnings:
+Level Warning
+Code 1292
+Message Truncated incorrect DECIMAL value: ''
+Level Error
+Code 1753
+Message Invalid condition number
+DROP PROCEDURE p1;
+
+# Interaction with SIGNAL
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE errno INT DEFAULT 0;
+DECLARE msg TEXT DEFAULT "foo";
+DECLARE cond CONDITION FOR SQLSTATE "01234";
+DECLARE CONTINUE HANDLER for 1012
+BEGIN
+GET DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO, msg = MESSAGE_TEXT;
+END;
+SIGNAL cond SET MESSAGE_TEXT = "Signal message", MYSQL_ERRNO = 1012;
+SELECT errno, msg;
+END|
+CALL p1();
+errno 1012
+msg Signal message
+DROP PROCEDURE p1;
+CREATE PROCEDURE p1()
+BEGIN
+SIGNAL SQLSTATE '77777' SET MYSQL_ERRNO = 1000, MESSAGE_TEXT='ÁÂÃÅÄ';
+END|
+CALL p1();
+ERROR 77777: ÁÂÃÅÄ
+GET DIAGNOSTICS CONDITION 1
+@mysql_errno = MYSQL_ERRNO, @message_text = MESSAGE_TEXT,
+@returned_sqlstate = RETURNED_SQLSTATE, @class_origin = CLASS_ORIGIN;
+SELECT @mysql_errno, @message_text, @returned_sqlstate, @class_origin;
+@mysql_errno 1000
+@message_text ÁÂÃÅRE p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE cond CONDITION FOR SQLSTATE '12345';
+SIGNAL cond SET
+CLASS_ORIGIN = 'CLASS_ORIGIN text',
+SUBCLASS_ORIGIN = 'SUBCLASS_ORIGIN text',
+CONSTRAINT_CATALOG = 'CONSTRAINT_CATALOG text',
+CONSTRAINT_SCHEMA = 'CONSTRAINT_SCHEMA text',
+CONSTRAINT_NAME = 'CONSTRAINT_NAME text',
+CATALOG_NAME = 'CATALOG_NAME text',
+SCHEMA_NAME = 'SCHEMA_NAME text',
+TABLE_NAME = 'TABLE_NAME text',
+COLUMN_NAME = 'COLUMN_NAME text',
+CURSOR_NAME = 'CURSOR_NAME text',
+MESSAGE_TEXT = 'MESSAGE_TEXT text',
+MYSQL_ERRNO = 54321;
+END|
+CALL p1();
+ERROR 12345: MESSAGE_TEXT text
+GET DIAGNOSTICS CONDITION 1
+@class_origin = CLASS_ORIGIN,
+@subclass_origin = SUBCLASS_ORIGIN,
+@constraint_catalog = CONSTRAINT_CATALOG,
+@constraint_schema = CONSTRAINT_SCHEMA,
+@constraint_name = CONSTRAINT_NAME,
+@catalog_name = CATALOG_NAME,
+@schema_name = SCHEMA_NAME,
+@table_name = TABLE_NAME,
+@column_name = COLUMN_NAME,
+@cursor_name = CURSOR_NAME,
+@message_text = MESSAGE_TEXT,
+@mysql_errno = MYSQL_ERRNO,
+@returned_sqlstate = RETURNED_SQLSTATE;
+SELECT
+@class_origin,
+@subclass_origin,
+@constraint_catalog,
+@constraint_schema,
+@constraint_name,
+@catalog_name,
+@schema_name,
+@table_name,
+@column_name,
+@cursor_name,
+@message_text,
+@mysql_errno,
+@returned_sqlstate;
+@class_origin CLASS_ORIGIN text
+@subclass_origin SUBCLASS_ORIGIN text
+@constraint_catalog CONSTRAINT_CATALOG text
+@constraint_schema CONSTRAINT_SCHEMA text
+@constraint_name CONSTRAINT_NAME text
+@catalog_name CATALOG_NAME text
+@schema_name SCHEMA_NAME text
+@table_name TABLE_NAME text
+@column_name COLUMN_NAME text
+@cursor_name CURSOR_NAME text
+@message_text MESSAGE_TEXT text
+@mysql_errno 54321
+@returned_sqlstate 12345
+DROP PROCEDURE p1;
+#
+# Demonstration
+#
+
+# The same statement information item can be used multiple times.
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE var INT;
+GET DIAGNOSTICS var = NUMBER, @var = NUMBER;
+SELECT var, @var;
+END|
+CALL p1();
+var @var
+1 1
+DROP PROCEDURE p1;
+
+# Setting TABLE_NAME is currently not implemented.
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v VARCHAR(64);
+DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+GET DIAGNOSTICS CONDITION 1 v = TABLE_NAME;
+DROP TABLE no_such_table;
+SELECT v;
+END|
+CALL p1();
+v
+
+DROP PROCEDURE p1;
+
+# Message is truncated to fit into target. No truncation warning.
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE v CHAR(1);
+CREATE TABLE IF NOT EXISTS t1 (a INT);
+GET DIAGNOSTICS CONDITION 1 v = MESSAGE_TEXT;
+SELECT v;
+END|
+CREATE TABLE t1 (a INT);
+CALL p1();
+v
+T
+Warnings:
+Note 1050 Table 't1' already exists
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+# Returns number of rows updated by the UPDATE statements.
+
+CREATE PROCEDURE p1(IN param INT)
+LANGUAGE SQL
+BEGIN
+DECLARE v INT DEFAULT 0;
+DECLARE rcount_each INT;
+DECLARE rcount_total INT DEFAULT 0;
+WHILE v < 5 DO
+UPDATE t1 SET a = a * 1.1 WHERE b = param;
+GET DIAGNOSTICS rcount_each = ROW_COUNT;
+SET rcount_total = rcount_total + rcount_each;
+SET v = v + 1;
+END WHILE;
+SELECT rcount_total;
+END|
+CREATE TABLE t1 (a REAL, b INT);
+INSERT INTO t1 VALUES (1.1, 1);
+CALL p1(1);
+rcount_total
+5
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+# GET DIAGNOSTICS doesn't clear the diagnostics area.
+
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE CONTINUE HANDLER FOR SQLWARNING
+BEGIN
+GET CURRENT DIAGNOSTICS CONDITION 1 @x = RETURNED_SQLSTATE;
+SIGNAL SQLSTATE '01002';
+GET CURRENT DIAGNOSTICS CONDITION 1 @y = RETURNED_SQLSTATE;
+END;
+SIGNAL SQLSTATE '01001';
+SELECT @x, @y;
+END|
+CALL p1();
+@x @y
+01001 01002
+Warnings:
+Warning 1642 Unhandled user-defined warning condition
+DROP PROCEDURE p1;
+
+# Using OUT and INOUT parameters as the target variables.
+
+CREATE PROCEDURE p1(OUT number INT, INOUT message TEXT)
+BEGIN
+DECLARE warn CONDITION FOR SQLSTATE "01234";
+DECLARE CONTINUE HANDLER FOR SQLWARNING
+BEGIN
+GET DIAGNOSTICS number = NUMBER;
+GET DIAGNOSTICS CONDITION 1 message = MESSAGE_TEXT;
+END;
+SELECT message;
+SIGNAL warn SET MESSAGE_TEXT = "inout parameter";
+END|
+SET @var1 = 0;
+SET @var2 = "message text";
+CALL p1(@var1, @var2);
+message
+message text
+SELECT @var1, @var2;
+@var1 @var2
+1 inout parameter
+DROP PROCEDURE p1;
+
+# Using an IN parameter as the target variable.
+
+CREATE PROCEDURE p1(IN number INT)
+BEGIN
+SELECT number;
+GET DIAGNOSTICS number = NUMBER;
+SELECT number;
+END|
+SET @var1 = 9999;
+CALL p1(@var1);
+number
+9999
+number
+0
+SELECT @var1;
+@var1
+9999
+DROP PROCEDURE p1;
+
+# Using GET DIAGNOSTICS in a stored function.
+
+CREATE FUNCTION f1() RETURNS TEXT
+BEGIN
+DECLARE message TEXT;
+DECLARE warn CONDITION FOR SQLSTATE "01234";
+DECLARE CONTINUE HANDLER FOR SQLWARNING
+BEGIN
+GET DIAGNOSTICS CONDITION 1 message = MESSAGE_TEXT;
+END;
+SIGNAL warn SET MESSAGE_TEXT = "message text";
+return message;
+END|
+SELECT f1();
+f1()
+message text
+DROP FUNCTION f1;
+
+# Using GET DIAGNOSTICS in a trigger.
+
+CREATE TABLE t1 (a INT);
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+DECLARE var INT DEFAULT row_count();
+GET DIAGNOSTICS @var1 = ROW_COUNT;
+SET @var2 = var;
+END|
+SET @var1 = 9999, @var2 = 9999;
+INSERT INTO t1 VALUES (1), (2);
+SELECT @var1, @var2;
+@var1 @var2
+0 0
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+# GET DIAGNOSTICS does not reset ROW_COUNT
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+GET DIAGNOSTICS @var1 = ROW_COUNT;
+GET DIAGNOSTICS @var2 = ROW_COUNT;
+SELECT @var1, @var2;
+@var1 @var2
+1 1
+DROP TABLE t1;
+
+# Items are UTF8 (utf8_general_ci default collation)
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+CAST(-19999999999999999999 AS SIGNED)
+-9223372036854775808
+Warnings:
+Warning 1292 Truncated incorrect DECIMAL value: ''
+GET DIAGNOSTICS CONDITION 1 @var1 = MESSAGE_TEXT, @var2 = CLASS_ORIGIN;
+SELECT CHARSET(@var1), COLLATION(@var1), COERCIBILITY(@var1);
+CHARSET(@var1) COLLATION(@var1) COERCIBILITY(@var1)
+utf8 utf8_general_ci 2
+SELECT CHARSET(@var2), COLLATION(@var2), COERCIBILITY(@var2);
+CHARSET(@var2) COLLATION(@var2) COERCIBILITY(@var2)
+utf8 utf8_general_ci 2
+#
+# Command statistics
+#
+FLUSH STATUS;
+SHOW STATUS LIKE 'Com%get_diagnostics';
+Variable_name Value
+Com_get_diagnostics 0
+GET DIAGNOSTICS @var1 = NUMBER;
+SHOW STATUS LIKE 'Com%get_diagnostics';
+Variable_name Value
+Com_get_diagnostics 1
=== modified file 'mysql-test/r/mysqld--help-notwin.result'
--- a/mysql-test/r/mysqld--help-notwin.result 2011-10-13 07:54:52 +0000
+++ b/mysql-test/r/mysqld--help-notwin.result 2011-10-13 12:33:08 +0000
@@ -978,7 +978,7 @@ performance-schema-max-rwlock-instances
performance-schema-max-socket-classes 10
performance-schema-max-socket-instances 1000
performance-schema-max-stage-classes 150
-performance-schema-max-statement-classes 165
+performance-schema-max-statement-classes 166
performance-schema-max-table-handles 10000
performance-schema-max-table-instances 1000
performance-schema-max-thread-classes 50
=== modified file 'mysql-test/r/mysqld--help-win.result'
--- a/mysql-test/r/mysqld--help-win.result 2011-10-13 07:54:52 +0000
+++ b/mysql-test/r/mysqld--help-win.result 2011-10-13 12:33:08 +0000
@@ -982,7 +982,7 @@ performance-schema-max-rwlock-instances
performance-schema-max-socket-classes 10
performance-schema-max-socket-instances 1000
performance-schema-max-stage-classes 150
-performance-schema-max-statement-classes 165
+performance-schema-max-statement-classes 166
performance-schema-max-table-handles 10000
performance-schema-max-table-instances 1000
performance-schema-max-thread-classes 50
=== modified file 'mysql-test/r/sp.result'
--- a/mysql-test/r/sp.result 2011-10-14 15:04:41 +0000
+++ b/mysql-test/r/sp.result 2011-10-14 15:38:24 +0000
@@ -7470,7 +7470,7 @@ b
DROP TABLE t1;
DROP PROCEDURE p1;
-# End of 5.5 test
+# End of 5.5 tests
#
# Bug#12663165 SP DEAD CODE REMOVAL DOESN'T UNDERSTAND CONTINUE HANDLERS
#
@@ -7491,3 +7491,26 @@ SELECT f1();
f1()
1
DROP FUNCTION f1;
+#
+# WL#2111: Add non-reserved ROW_COUNT keyword.
+#
+DROP PROCEDURE IF EXISTS p1;
+CREATE PROCEDURE p1()
+BEGIN
+DECLARE row_count INT DEFAULT 1;
+SELECT row_count;
+SELECT row_count();
+ROW_COUNT: WHILE row_count > 0 DO
+SET row_count = row_count - 1;
+END WHILE ROW_COUNT;
+SELECT ROW_COUNT;
+END|
+CALL p1();
+row_count
+1
+row_count()
+-1
+ROW_COUNT
+0
+DROP PROCEDURE p1;
+# End of 5.6 tests
=== modified file 'mysql-test/suite/perfschema/r/ortho_iter.result'
--- a/mysql-test/suite/perfschema/r/ortho_iter.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/ortho_iter.result 2011-08-29 14:33:10 +0000
@@ -114,7 +114,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/privilege_table_io.result'
--- a/mysql-test/suite/perfschema/r/privilege_table_io.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/privilege_table_io.result 2011-08-29 14:33:10 +0000
@@ -39,7 +39,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_innodb.result'
--- a/mysql-test/suite/perfschema/r/start_server_innodb.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_innodb.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_account.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_account.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_account.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_cond_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_cond_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_file_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_file_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_file_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_host.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_host.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_host.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_mutex_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_rwlock_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_actors.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_actors.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_setup_objects.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_setup_objects.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 0
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_socket_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_socket_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 0
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stage_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stage_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stage_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 0
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_stages_history_long.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_statements_history_long.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_hdl.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_hdl.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 0
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_table_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_table_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_table_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 0
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_class.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_class.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_class.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 0
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_thread_inst.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_thread_inst.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_user.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_user.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_user.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_waits_history.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result'
--- a/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_no_waits_history_long.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_off.result'
--- a/mysql-test/suite/perfschema/r/start_server_off.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_off.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/start_server_on.result'
--- a/mysql-test/suite/perfschema/r/start_server_on.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/start_server_on.result 2011-08-29 14:33:10 +0000
@@ -88,7 +88,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_global_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -59,7 +59,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -58,7 +58,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -59,7 +59,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_hist_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -58,7 +58,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_off.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_off.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_off.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_aggregate_thread_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_global_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_hist_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_io_aggregate_thread_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_global_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -61,7 +61,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_hist_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -60,7 +60,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_2u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_2t.result 2011-08-29 14:33:10 +0000
@@ -63,7 +63,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result'
--- a/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result 2011-08-11 03:11:58 +0000
+++ b/mysql-test/suite/perfschema/r/table_lock_aggregate_thread_4u_3t.result 2011-08-29 14:33:10 +0000
@@ -62,7 +62,7 @@ performance_schema_max_rwlock_instances
performance_schema_max_socket_classes 10
performance_schema_max_socket_instances 1000
performance_schema_max_stage_classes 150
-performance_schema_max_statement_classes 165
+performance_schema_max_statement_classes 166
performance_schema_max_table_handles 1000
performance_schema_max_table_instances 500
performance_schema_max_thread_classes 50
=== modified file 'mysql-test/suite/rpl/r/rpl_stm_user_variables.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_user_variables.result 2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_user_variables.result 2011-07-15 14:41:07 +0000
@@ -213,4 +213,50 @@ ERROR 23000: Duplicate entry '2147483647
include/diff_tables.inc [master:t1,slave:t1]
DROP TRIGGER tr1;
DROP TABLE t1;
+
+# The GET DIAGNOSTICS itself is not replicated, but it can set
+# variables which can be used in statements that are replicated.
+
+include/rpl_reset.inc
+CREATE TABLE t1 (a INT, b INT);
+GET DIAGNOSTICS @var1 = NUMBER;
+INSERT INTO t1 VALUES (@var1, 0), (@var1, 0);
+CREATE PROCEDURE p1()
+LANGUAGE SQL
+BEGIN
+DECLARE count INT;
+UPDATE t1 SET b = 2 WHERE a = 0;
+GET DIAGNOSTICS count = ROW_COUNT;
+INSERT INTO t1 VALUES (1, count);
+END|
+CALL p1();
+# On slave, check if the statement was replicated.
+SELECT * FROM t1 ORDER BY a;
+a b
+0 2
+0 2
+1 2
+# Show events and cleanup
+show binlog events from <binlog_start>;
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT, b INT)
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # User var # # @`var1`=0
+master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (@var1, 0), (@var1, 0)
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Query # # use `test`; CREATE DEFINER=`root`@`localhost` PROCEDURE `p1`()
+BEGIN
+DECLARE count INT;
+UPDATE t1 SET b = 2 WHERE a = 0;
+GET DIAGNOSTICS count = ROW_COUNT;
+INSERT INTO t1 VALUES (1, count);
+END
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; UPDATE t1 SET b = 2 WHERE a = 0
+master-bin.000001 # Query # # COMMIT
+master-bin.000001 # Query # # BEGIN
+master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1, NAME_CONST('count',2))
+master-bin.000001 # Query # # COMMIT
+DROP TABLE t1;
+DROP PROCEDURE p1;
include/rpl_end.inc
=== modified file 'mysql-test/suite/rpl/t/rpl_stm_user_variables.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_user_variables.test 2010-12-19 17:22:30 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_user_variables.test 2011-07-15 14:41:07 +0000
@@ -167,4 +167,43 @@ DROP TABLE t1;
-- sync_slave_with_master
+--echo
+--echo # The GET DIAGNOSTICS itself is not replicated, but it can set
+--echo # variables which can be used in statements that are replicated.
+--echo
+
+--source include/rpl_reset.inc
+connection master;
+
+CREATE TABLE t1 (a INT, b INT);
+GET DIAGNOSTICS @var1 = NUMBER;
+INSERT INTO t1 VALUES (@var1, 0), (@var1, 0);
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+LANGUAGE SQL
+BEGIN
+ DECLARE count INT;
+ UPDATE t1 SET b = 2 WHERE a = 0;
+ GET DIAGNOSTICS count = ROW_COUNT;
+ INSERT INTO t1 VALUES (1, count);
+END|
+DELIMITER ;|
+
+CALL p1();
+
+-- sync_slave_with_master
+
+connection slave;
+--echo # On slave, check if the statement was replicated.
+SELECT * FROM t1 ORDER BY a;
+
+connection master;
+--echo # Show events and cleanup
+--source include/show_binlog_events.inc
+DROP TABLE t1;
+DROP PROCEDURE p1;
+
+-- sync_slave_with_master
+
--source include/rpl_end.inc
=== added file 'mysql-test/t/get_diagnostics.test'
--- a/mysql-test/t/get_diagnostics.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/t/get_diagnostics.test 2011-07-29 10:22:38 +0000
@@ -0,0 +1,869 @@
+--echo #
+--echo # WL#2111: GET DIAGNOSTICS tests
+--echo #
+
+--echo #
+--echo # Test reserved keywords: GET
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+CREATE TABLE t1 (get INT);
+
+DELIMITER |;
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE get INT DEFAULT 1;
+END|
+DELIMITER ;|
+
+--echo # Quoting
+
+CREATE TABLE t1 (`get` INT);
+INSERT INTO t1 (`get`) values (1);
+SELECT `get` FROM t1 WHERE `get` = 1;
+DROP TABLE t1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE `get` INT DEFAULT 1;
+ SELECT `get`;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Test non-reserved keywords: CURRENT, DIAGNOSTICS, NUMBER, RETURNED_SQLSTATE
+--echo #
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+CREATE TABLE t1 (current INT, diagnostics INT, number INT, returned_sqlstate INT);
+INSERT INTO t1 (current, diagnostics, number, returned_sqlstate) values (1,2,3,4);
+SELECT current, diagnostics, number, returned_sqlstate FROM t1 WHERE number = 3;
+SELECT `current`, `number` FROM t1 WHERE `current` = 1 AND `number` = 3;
+DROP TABLE t1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE current INT DEFAULT 1;
+ DECLARE diagnostics INT DEFAULT 2;
+ DECLARE number INT DEFAULT 3;
+ DECLARE returned_sqlstate INT DEFAULT 4;
+ SELECT current, diagnostics, number, returned_sqlstate;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Test GET DIAGNOSTICS syntax
+--echo #
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+--error ER_PARSE_ERROR
+GET;
+--error ER_PARSE_ERROR
+GET CURRENT;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS;
+--error ER_PARSE_ERROR
+GET CURRENT DIAGNOSTICS;
+
+--echo
+--echo # Statement information syntax
+--echo
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var;
+
+--error ER_SP_UNDECLARED_VAR
+GET DIAGNOSTICS var;
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ GET DIAGNOSTICS var;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS var;
+END|
+DELIMITER ;|
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var =;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var = INVALID;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var = MORE;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var = INVALID,;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var1 = NUMBER, @var2;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var1 = NUMBER, @var2 = INVALID;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @@var1 = NUMBER;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS @var1 = NUMBER, @@var2 = NUMBER;
+
+DELIMITER |;
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS var = INVALID;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var CONDITION FOR SQLSTATE '12345';
+ GET DIAGNOSTICS var = NUMBER;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS var = NUMBER, var1 = ROW_COUNT;
+END|
+DELIMITER ;|
+
+GET DIAGNOSTICS @var = NUMBER;
+GET DIAGNOSTICS @var = ROW_COUNT;
+GET DIAGNOSTICS @var1 = NUMBER, @var2 = ROW_COUNT;
+GET DIAGNOSTICS @var1 = ROW_COUNT, @var2 = NUMBER;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ DECLARE var1 INT;
+ DECLARE var2 INT;
+ GET DIAGNOSTICS var = NUMBER;
+ GET DIAGNOSTICS var = ROW_COUNT;
+ GET DIAGNOSTICS var1 = NUMBER, var2 = ROW_COUNT;
+ GET DIAGNOSTICS var1 = ROW_COUNT, var2 = NUMBER;
+END|
+DELIMITER ;|
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Condition information syntax
+--echo
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION a;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1;
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var;
+
+--error ER_SP_UNDECLARED_VAR
+GET DIAGNOSTICS CONDITION 1 var;
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ GET DIAGNOSTICS CONDITION 1 var;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS CONDITION 1 var;
+END|
+DELIMITER ;|
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var =;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var = INVALID;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var = NUMBER;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var = INVALID,;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2 = INVALID;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @@var1 = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @@var2 = CLASS_ORIGIN;
+
+DELIMITER |;
+--error ER_PARSE_ERROR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS CONDITION 1 var = INVALID;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var CONDITION FOR SQLSTATE '12345';
+ GET DIAGNOSTICS CONDITION 1 var = NUMBER;
+END|
+DELIMITER ;|
+
+DELIMITER |;
+--error ER_SP_UNDECLARED_VAR
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS CONDITION 1 var = CLASS_ORIGIN, var1 = SUBCLASS_ORIGIN;
+END|
+DELIMITER ;|
+
+GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var1 = CLASS_ORIGIN, @var2 = SUBCLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION 1 @var1 = SUBCLASS_ORIGIN, @var2 = CLASS_ORIGIN;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ DECLARE var1 INT;
+ DECLARE var2 INT;
+ GET DIAGNOSTICS CONDITION 1 var = CLASS_ORIGIN;
+ GET DIAGNOSTICS CONDITION 1 var = SUBCLASS_ORIGIN;
+ GET DIAGNOSTICS CONDITION 1 var1 = CLASS_ORIGIN, var2 = SUBCLASS_ORIGIN;
+ GET DIAGNOSTICS CONDITION 1 var1 = SUBCLASS_ORIGIN, var2 = CLASS_ORIGIN;
+END|
+DELIMITER ;|
+
+DROP PROCEDURE p1;
+
+--echo # Condition number expression
+
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION -1 @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION 1+1 @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION ? @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION (1) @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION p1() @var = CLASS_ORIGIN;
+--error ER_PARSE_ERROR
+GET DIAGNOSTICS CONDITION ABS(2) @var = CLASS_ORIGIN;
+
+# Unfortunate side effects...
+GET DIAGNOSTICS CONDITION 1.1 @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION "1" @var = CLASS_ORIGIN;
+
+# Reset warnings
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+
+GET DIAGNOSTICS CONDITION 9999 @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION NULL @var = CLASS_ORIGIN;
+GET DIAGNOSTICS CONDITION a @var = CLASS_ORIGIN;
+
+# Reset warnings
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+
+SET @cond = 1;
+GET DIAGNOSTICS CONDITION @cond @var1 = CLASS_ORIGIN;
+
+SET @cond = "invalid";
+GET DIAGNOSTICS CONDITION @cond @var1 = CLASS_ORIGIN;
+
+# Reset warnings
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE cond INT DEFAULT 1;
+ DECLARE var INT;
+ GET DIAGNOSTICS CONDITION cond var = CLASS_ORIGIN;
+END|
+DELIMITER ;|
+
+DROP PROCEDURE p1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE cond TEXT;
+ DECLARE var INT;
+ GET DIAGNOSTICS CONDITION cond var = CLASS_ORIGIN;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Test GET DIAGNOSTICS runtime
+--echo #
+
+--echo
+--echo # GET DIAGNOSTICS cannot be the object of a PREPARE statement.
+--echo
+
+--error ER_UNSUPPORTED_PS
+PREPARE stmt FROM "GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN";
+--error ER_UNSUPPORTED_PS
+PREPARE stmt FROM "GET DIAGNOSTICS @var = NUMBER";
+
+--echo
+--echo # GET DIAGNOSTICS does not clear the diagnostics area.
+--echo
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS @var = NUMBER;
+SHOW WARNINGS;
+
+--echo #
+--echo # If GET DIAGNOSTICS itself causes an error, an error message is appended.
+--echo #
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS CONDITION 99999 @var = CLASS_ORIGIN;
+SHOW WARNINGS;
+
+--echo
+--echo # Statement information runtime
+--echo
+
+SELECT CAST(-19999999999999999999 AS SIGNED),
+ CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS @var = NUMBER;
+SELECT @var;
+
+SELECT COUNT(max_questions) INTO @var FROM mysql.user;
+GET DIAGNOSTICS @var = NUMBER;
+SELECT @var;
+
+SELECT 1;
+GET DIAGNOSTICS @var = ROW_COUNT;
+SELECT @var;
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1),(2),(3);
+GET DIAGNOSTICS @var = ROW_COUNT;
+SELECT @var;
+DROP TABLE t1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE number INT;
+ DECLARE row_count INT;
+
+ SELECT CAST(-19999999999999999999 AS SIGNED),
+ CAST(-19999999999999999999 AS SIGNED);
+
+ GET DIAGNOSTICS number = NUMBER;
+
+ CREATE TABLE t1 (a INT);
+ INSERT INTO t1 VALUES (1),(2),(3);
+ GET DIAGNOSTICS row_count = ROW_COUNT;
+ DROP TABLE t1;
+
+ SELECT number, row_count;
+
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Condition information runtime
+--echo
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+
+GET DIAGNOSTICS CONDITION 1
+ @class_origin = CLASS_ORIGIN,
+ @subclass_origin = SUBCLASS_ORIGIN,
+ @constraint_catalog = CONSTRAINT_CATALOG,
+ @constraint_schema = CONSTRAINT_SCHEMA,
+ @constraint_name = CONSTRAINT_NAME,
+ @catalog_name = CATALOG_NAME,
+ @schema_name = SCHEMA_NAME,
+ @table_name = TABLE_NAME,
+ @column_name = COLUMN_NAME,
+ @cursor_name = CURSOR_NAME,
+ @message_text = MESSAGE_TEXT,
+ @mysql_errno = MYSQL_ERRNO,
+ @returned_sqlstate = RETURNED_SQLSTATE;
+
+--vertical_results
+SELECT
+ @class_origin,
+ @subclass_origin,
+ @constraint_catalog,
+ @constraint_schema,
+ @constraint_name,
+ @catalog_name,
+ @schema_name,
+ @table_name,
+ @column_name,
+ @cursor_name,
+ @message_text,
+ @mysql_errno,
+ @returned_sqlstate;
+--horizontal_results
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE class_origin TEXT DEFAULT "a";
+ DECLARE subclass_origin TEXT DEFAULT "a";
+ DECLARE constraint_catalog TEXT DEFAULT "a";
+ DECLARE constraint_schema TEXT DEFAULT "a";
+ DECLARE constraint_name TEXT DEFAULT "a";
+ DECLARE catalog_name TEXT DEFAULT "a";
+ DECLARE schema_name TEXT DEFAULT "a";
+ DECLARE table_name TEXT DEFAULT "a";
+ DECLARE column_name TEXT DEFAULT "a";
+ DECLARE cursor_name TEXT DEFAULT "a";
+ DECLARE message_text TEXT DEFAULT "a";
+ DECLARE mysql_errno INT DEFAULT 1;
+ DECLARE returned_sqlstate TEXT DEFAULT "a";
+
+ SELECT CAST(-19999999999999999999 AS SIGNED);
+
+ GET DIAGNOSTICS CONDITION 1
+ class_origin = CLASS_ORIGIN,
+ subclass_origin = SUBCLASS_ORIGIN,
+ constraint_catalog = CONSTRAINT_CATALOG,
+ constraint_schema = CONSTRAINT_SCHEMA,
+ constraint_name = CONSTRAINT_NAME,
+ catalog_name = CATALOG_NAME,
+ schema_name = SCHEMA_NAME,
+ table_name = TABLE_NAME,
+ column_name = COLUMN_NAME,
+ cursor_name = CURSOR_NAME,
+ message_text = MESSAGE_TEXT,
+ mysql_errno = MYSQL_ERRNO,
+ returned_sqlstate = RETURNED_SQLSTATE;
+
+ SELECT
+ class_origin,
+ subclass_origin,
+ constraint_catalog,
+ constraint_schema,
+ constraint_name,
+ catalog_name,
+ schema_name,
+ table_name,
+ column_name,
+ cursor_name,
+ message_text,
+ mysql_errno,
+ returned_sqlstate;
+END|
+DELIMITER ;|
+
+--vertical_results
+CALL p1();
+--horizontal_results
+
+DROP PROCEDURE p1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE errno1 INT;
+ DECLARE errno2 INT;
+ DECLARE msg1 TEXT;
+ DECLARE msg2 TEXT;
+
+ SELECT CAST(-19999999999999999999 AS SIGNED);
+ GET DIAGNOSTICS CONDITION 99999 msg1 = MESSAGE_TEXT;
+
+ GET DIAGNOSTICS CONDITION 1 errno1 = MYSQL_ERRNO, msg1 = MESSAGE_TEXT;
+ GET DIAGNOSTICS CONDITION 2 errno2 = MYSQL_ERRNO, msg2 = MESSAGE_TEXT;
+
+ SELECT errno1, msg1, errno2, msg2;
+END|
+DELIMITER ;|
+
+--vertical_results
+CALL p1();
+--horizontal_results
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Interaction with SIGNAL
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE errno INT DEFAULT 0;
+ DECLARE msg TEXT DEFAULT "foo";
+ DECLARE cond CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER for 1012
+ BEGIN
+ GET DIAGNOSTICS CONDITION 1 errno = MYSQL_ERRNO, msg = MESSAGE_TEXT;
+ END;
+
+ SIGNAL cond SET MESSAGE_TEXT = "Signal message", MYSQL_ERRNO = 1012;
+
+ SELECT errno, msg;
+END|
+DELIMITER ;|
+
+--vertical_results
+CALL p1();
+--horizontal_results
+
+DROP PROCEDURE p1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ SIGNAL SQLSTATE '77777' SET MYSQL_ERRNO = 1000, MESSAGE_TEXT='ÁÂÃÅÄ';
+END|
+DELIMITER ;|
+
+--error 1000
+CALL p1();
+
+GET DIAGNOSTICS CONDITION 1
+ @mysql_errno = MYSQL_ERRNO, @message_text = MESSAGE_TEXT,
+ @returned_sqlstate = RETURNED_SQLSTATE, @class_origin = CLASS_ORIGIN;
+
+--vertical_results
+SELECT @mysql_errno, @message_text, @returned_sqlstate, @class_origin;
+--horizontal_results
+
+DROP PROCEDURE p1;
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE cond CONDITION FOR SQLSTATE '12345';
+ SIGNAL cond SET
+ CLASS_ORIGIN = 'CLASS_ORIGIN text',
+ SUBCLASS_ORIGIN = 'SUBCLASS_ORIGIN text',
+ CONSTRAINT_CATALOG = 'CONSTRAINT_CATALOG text',
+ CONSTRAINT_SCHEMA = 'CONSTRAINT_SCHEMA text',
+ CONSTRAINT_NAME = 'CONSTRAINT_NAME text',
+ CATALOG_NAME = 'CATALOG_NAME text',
+ SCHEMA_NAME = 'SCHEMA_NAME text',
+ TABLE_NAME = 'TABLE_NAME text',
+ COLUMN_NAME = 'COLUMN_NAME text',
+ CURSOR_NAME = 'CURSOR_NAME text',
+ MESSAGE_TEXT = 'MESSAGE_TEXT text',
+ MYSQL_ERRNO = 54321;
+END|
+DELIMITER ;|
+
+--error 54321
+CALL p1();
+
+GET DIAGNOSTICS CONDITION 1
+ @class_origin = CLASS_ORIGIN,
+ @subclass_origin = SUBCLASS_ORIGIN,
+ @constraint_catalog = CONSTRAINT_CATALOG,
+ @constraint_schema = CONSTRAINT_SCHEMA,
+ @constraint_name = CONSTRAINT_NAME,
+ @catalog_name = CATALOG_NAME,
+ @schema_name = SCHEMA_NAME,
+ @table_name = TABLE_NAME,
+ @column_name = COLUMN_NAME,
+ @cursor_name = CURSOR_NAME,
+ @message_text = MESSAGE_TEXT,
+ @mysql_errno = MYSQL_ERRNO,
+ @returned_sqlstate = RETURNED_SQLSTATE;
+
+--vertical_results
+SELECT
+ @class_origin,
+ @subclass_origin,
+ @constraint_catalog,
+ @constraint_schema,
+ @constraint_name,
+ @catalog_name,
+ @schema_name,
+ @table_name,
+ @column_name,
+ @cursor_name,
+ @message_text,
+ @mysql_errno,
+ @returned_sqlstate;
+--horizontal_results
+
+DROP PROCEDURE p1;
+
+--echo #
+--echo # Demonstration
+--echo #
+
+--echo
+--echo # The same statement information item can be used multiple times.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE var INT;
+ GET DIAGNOSTICS var = NUMBER, @var = NUMBER;
+ SELECT var, @var;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Setting TABLE_NAME is currently not implemented.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE v VARCHAR(64);
+ DECLARE CONTINUE HANDLER FOR SQLEXCEPTION
+ GET DIAGNOSTICS CONDITION 1 v = TABLE_NAME;
+ DROP TABLE no_such_table;
+ SELECT v;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Message is truncated to fit into target. No truncation warning.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE v CHAR(1);
+ CREATE TABLE IF NOT EXISTS t1 (a INT);
+ GET DIAGNOSTICS CONDITION 1 v = MESSAGE_TEXT;
+ SELECT v;
+END|
+DELIMITER ;|
+
+CREATE TABLE t1 (a INT);
+CALL p1();
+DROP TABLE t1;
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Returns number of rows updated by the UPDATE statements.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1(IN param INT)
+LANGUAGE SQL
+BEGIN
+ DECLARE v INT DEFAULT 0;
+ DECLARE rcount_each INT;
+ DECLARE rcount_total INT DEFAULT 0;
+ WHILE v < 5 DO
+ UPDATE t1 SET a = a * 1.1 WHERE b = param;
+ GET DIAGNOSTICS rcount_each = ROW_COUNT;
+ SET rcount_total = rcount_total + rcount_each;
+ SET v = v + 1;
+ END WHILE;
+ SELECT rcount_total;
+END|
+DELIMITER ;|
+
+CREATE TABLE t1 (a REAL, b INT);
+INSERT INTO t1 VALUES (1.1, 1);
+CALL p1(1);
+DROP TABLE t1;
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # GET DIAGNOSTICS doesn't clear the diagnostics area.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ GET CURRENT DIAGNOSTICS CONDITION 1 @x = RETURNED_SQLSTATE;
+ SIGNAL SQLSTATE '01002';
+ GET CURRENT DIAGNOSTICS CONDITION 1 @y = RETURNED_SQLSTATE;
+ END;
+ SIGNAL SQLSTATE '01001';
+ SELECT @x, @y;
+END|
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Using OUT and INOUT parameters as the target variables.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1(OUT number INT, INOUT message TEXT)
+BEGIN
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ GET DIAGNOSTICS number = NUMBER;
+ GET DIAGNOSTICS CONDITION 1 message = MESSAGE_TEXT;
+ END;
+ SELECT message;
+ SIGNAL warn SET MESSAGE_TEXT = "inout parameter";
+END|
+DELIMITER ;|
+
+SET @var1 = 0;
+SET @var2 = "message text";
+CALL p1(@var1, @var2);
+SELECT @var1, @var2;
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Using an IN parameter as the target variable.
+--echo
+
+DELIMITER |;
+CREATE PROCEDURE p1(IN number INT)
+BEGIN
+ SELECT number;
+ GET DIAGNOSTICS number = NUMBER;
+ SELECT number;
+END|
+DELIMITER ;|
+
+SET @var1 = 9999;
+CALL p1(@var1);
+SELECT @var1;
+
+DROP PROCEDURE p1;
+
+--echo
+--echo # Using GET DIAGNOSTICS in a stored function.
+--echo
+
+DELIMITER |;
+CREATE FUNCTION f1() RETURNS TEXT
+BEGIN
+ DECLARE message TEXT;
+ DECLARE warn CONDITION FOR SQLSTATE "01234";
+ DECLARE CONTINUE HANDLER FOR SQLWARNING
+ BEGIN
+ GET DIAGNOSTICS CONDITION 1 message = MESSAGE_TEXT;
+ END;
+ SIGNAL warn SET MESSAGE_TEXT = "message text";
+ return message;
+END|
+DELIMITER ;|
+
+SELECT f1();
+
+DROP FUNCTION f1;
+
+--echo
+--echo # Using GET DIAGNOSTICS in a trigger.
+--echo
+
+CREATE TABLE t1 (a INT);
+
+DELIMITER |;
+CREATE TRIGGER trg1 BEFORE INSERT ON t1 FOR EACH ROW
+BEGIN
+ DECLARE var INT DEFAULT row_count();
+ GET DIAGNOSTICS @var1 = ROW_COUNT;
+ SET @var2 = var;
+END|
+DELIMITER ;|
+
+SET @var1 = 9999, @var2 = 9999;
+INSERT INTO t1 VALUES (1), (2);
+SELECT @var1, @var2;
+
+DROP TRIGGER trg1;
+DROP TABLE t1;
+
+--echo
+--echo # GET DIAGNOSTICS does not reset ROW_COUNT
+--echo
+
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1);
+GET DIAGNOSTICS @var1 = ROW_COUNT;
+GET DIAGNOSTICS @var2 = ROW_COUNT;
+SELECT @var1, @var2;
+DROP TABLE t1;
+
+--echo
+--echo # Items are UTF8 (utf8_general_ci default collation)
+--echo
+
+SELECT CAST(-19999999999999999999 AS SIGNED);
+GET DIAGNOSTICS CONDITION 1 @var1 = MESSAGE_TEXT, @var2 = CLASS_ORIGIN;
+SELECT CHARSET(@var1), COLLATION(@var1), COERCIBILITY(@var1);
+SELECT CHARSET(@var2), COLLATION(@var2), COERCIBILITY(@var2);
+
+--echo #
+--echo # Command statistics
+--echo #
+
+FLUSH STATUS;
+SHOW STATUS LIKE 'Com%get_diagnostics';
+GET DIAGNOSTICS @var1 = NUMBER;
+SHOW STATUS LIKE 'Com%get_diagnostics';
=== modified file 'mysql-test/t/sp.test'
--- a/mysql-test/t/sp.test 2011-10-14 15:04:41 +0000
+++ b/mysql-test/t/sp.test 2011-10-14 15:38:24 +0000
@@ -8877,7 +8877,7 @@ DROP TABLE t1;
DROP PROCEDURE p1;
--echo
---echo # End of 5.5 test
+--echo # End of 5.5 tests
--echo #
@@ -8907,3 +8907,32 @@ delimiter ;$
SELECT f1();
DROP FUNCTION f1;
+
+--echo #
+--echo # WL#2111: Add non-reserved ROW_COUNT keyword.
+--echo #
+
+--disable_warnings
+DROP PROCEDURE IF EXISTS p1;
+--enable_warnings
+
+DELIMITER |;
+
+CREATE PROCEDURE p1()
+BEGIN
+ DECLARE row_count INT DEFAULT 1;
+ SELECT row_count;
+ SELECT row_count();
+ ROW_COUNT: WHILE row_count > 0 DO
+ SET row_count = row_count - 1;
+ END WHILE ROW_COUNT;
+ SELECT ROW_COUNT;
+END|
+
+DELIMITER ;|
+
+CALL p1();
+
+DROP PROCEDURE p1;
+
+--echo # End of 5.6 tests
=== modified file 'sql/CMakeLists.txt'
--- a/sql/CMakeLists.txt 2011-09-21 11:01:41 +0000
+++ b/sql/CMakeLists.txt 2011-10-13 12:33:08 +0000
@@ -112,6 +112,7 @@ SET(SQL_SHARED_SOURCES
sql_derived.cc
sql_do.cc
sql_error.cc
+ sql_get_diagnostics.cc
sql_handler.cc
sql_help.cc
sql_insert.cc
=== modified file 'sql/item.cc'
--- a/sql/item.cc 2011-10-07 12:44:17 +0000
+++ b/sql/item.cc 2011-10-13 12:33:08 +0000
@@ -891,11 +891,26 @@ Item *Item_static_float_func::safe_chars
Item *Item_string::safe_charset_converter(const CHARSET_INFO *tocs)
{
+ return charset_converter(tocs, true);
+}
+
+
+/**
+ Convert a string item into the requested character set.
+
+ @param tocs Character set to to convert the string to.
+ @param lossless Whether data loss is acceptable.
+
+ @return A new item representing the converted string.
+*/
+Item *Item_string::charset_converter(const CHARSET_INFO *tocs, bool lossless)
+{
Item_string *conv;
uint conv_errors;
char *ptr;
String tmp, cstr, *ostr= val_str(&tmp);
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
+ conv_errors= lossless && conv_errors;
if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(),
cstr.charset(),
collation.derivation)))
=== modified file 'sql/item.h'
--- a/sql/item.h 2011-10-13 07:54:52 +0000
+++ b/sql/item.h 2011-10-13 12:33:08 +0000
@@ -2344,6 +2344,7 @@ public:
str_value.length(), collation.collation);
}
Item *safe_charset_converter(const CHARSET_INFO *tocs);
+ Item *charset_converter(const CHARSET_INFO *tocs, bool lossless);
inline void append(char *str, uint length)
{
str_value.append(str, length);
=== modified file 'sql/item_create.cc'
--- a/sql/item_create.cc 2011-09-22 10:42:10 +0000
+++ b/sql/item_create.cc 2011-10-13 12:33:08 +0000
@@ -2033,19 +2033,6 @@ protected:
};
-class Create_func_row_count : public Create_func_arg0
-{
-public:
- virtual Item *create(THD *thd);
-
- static Create_func_row_count s_singleton;
-
-protected:
- Create_func_row_count() {}
- virtual ~Create_func_row_count() {}
-};
-
-
class Create_func_rpad : public Create_func_arg3
{
public:
@@ -4809,18 +4796,6 @@ Create_func_round::create_native(THD *th
}
-Create_func_row_count Create_func_row_count::s_singleton;
-
-Item*
-Create_func_row_count::create(THD *thd)
-{
- DBUG_ENTER("Create_func_row_count::create");
- thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
- thd->lex->safe_to_cache_query= 0;
- DBUG_RETURN(new (thd->mem_root) Item_func_row_count());
-}
-
-
Create_func_rpad Create_func_rpad::s_singleton;
Item*
@@ -5482,7 +5457,6 @@ static Native_func_registry func_array[]
{ { C_STRING_WITH_LEN("RELEASE_LOCK") }, BUILDER(Create_func_release_lock)},
{ { C_STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)},
{ { C_STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)},
- { { C_STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)},
{ { C_STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)},
{ { C_STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)},
{ { C_STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)},
=== modified file 'sql/lex.h'
--- a/sql/lex.h 2011-08-19 13:24:24 +0000
+++ b/sql/lex.h 2011-08-29 14:33:10 +0000
@@ -142,6 +142,7 @@ static SYMBOL symbols[] = {
{ "CREATE", SYM(CREATE)},
{ "CROSS", SYM(CROSS)},
{ "CUBE", SYM(CUBE_SYM)},
+ { "CURRENT", SYM(CURRENT_SYM)},
{ "CURRENT_DATE", SYM(CURDATE)},
{ "CURRENT_TIME", SYM(CURTIME)},
{ "CURRENT_TIMESTAMP", SYM(NOW_SYM)},
@@ -172,6 +173,7 @@ static SYMBOL symbols[] = {
{ "DESCRIBE", SYM(DESCRIBE)},
{ "DES_KEY_FILE", SYM(DES_KEY_FILE)},
{ "DETERMINISTIC", SYM(DETERMINISTIC_SYM)},
+ { "DIAGNOSTICS", SYM(DIAGNOSTICS_SYM)},
{ "DIRECTORY", SYM(DIRECTORY_SYM)},
{ "DISABLE", SYM(DISABLE_SYM)},
{ "DISCARD", SYM(DISCARD)},
@@ -235,6 +237,7 @@ static SYMBOL symbols[] = {
{ "GEOMETRY", SYM(GEOMETRY_SYM)},
{ "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)},
{ "GET_FORMAT", SYM(GET_FORMAT)},
+ { "GET", SYM(GET_SYM)},
{ "GLOBAL", SYM(GLOBAL_SYM)},
{ "GRANT", SYM(GRANT)},
{ "GRANTS", SYM(GRANTS)},
@@ -385,6 +388,7 @@ static SYMBOL symbols[] = {
{ "NOT", SYM(NOT_SYM)},
{ "NO_WRITE_TO_BINLOG", SYM(NO_WRITE_TO_BINLOG)},
{ "NULL", SYM(NULL_SYM)},
+ { "NUMBER", SYM(NUMBER_SYM)},
{ "NUMERIC", SYM(NUMERIC_SYM)},
{ "NVARCHAR", SYM(NVARCHAR_SYM)},
{ "OFFSET", SYM(OFFSET_SYM)},
@@ -467,6 +471,7 @@ static SYMBOL symbols[] = {
{ "RESTORE", SYM(RESTORE_SYM)},
{ "RESTRICT", SYM(RESTRICT)},
{ "RESUME", SYM(RESUME_SYM)},
+ { "RETURNED_SQLSTATE",SYM(RETURNED_SQLSTATE_SYM)},
{ "RETURN", SYM(RETURN_SYM)},
{ "RETURNS", SYM(RETURNS_SYM)},
{ "REVERSE", SYM(REVERSE_SYM)},
@@ -477,6 +482,7 @@ static SYMBOL symbols[] = {
{ "ROLLUP", SYM(ROLLUP_SYM)},
{ "ROUTINE", SYM(ROUTINE_SYM)},
{ "ROW", SYM(ROW_SYM)},
+ { "ROW_COUNT", SYM(ROW_COUNT_SYM)},
{ "ROWS", SYM(ROWS_SYM)},
{ "ROW_FORMAT", SYM(ROW_FORMAT_SYM)},
{ "RTREE", SYM(RTREE_SYM)},
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2011-10-06 11:06:34 +0000
+++ b/sql/mysqld.cc 2011-10-13 12:33:08 +0000
@@ -3060,6 +3060,7 @@ SHOW_VAR com_status_vars[]= {
{"empty_query", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EMPTY_QUERY]), SHOW_LONG_STATUS},
{"execute_sql", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_EXECUTE]), SHOW_LONG_STATUS},
{"flush", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_FLUSH]), SHOW_LONG_STATUS},
+ {"get_diagnostics", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GET_DIAGNOSTICS]), SHOW_LONG_STATUS},
{"grant", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_GRANT]), SHOW_LONG_STATUS},
{"ha_close", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_CLOSE]), SHOW_LONG_STATUS},
{"ha_open", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_HA_OPEN]), SHOW_LONG_STATUS},
=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt 2011-10-13 14:01:50 +0000
+++ b/sql/share/errmsg-utf8.txt 2011-10-14 15:38:24 +0000
@@ -6594,3 +6594,7 @@ ER_PLUGIN_NO_INSTALL
ER_FULLTEXT_NOT_SUPPORTED_WITH_PARTITIONING
eng "FULLTEXT index is not supported for partitioned tables."
swe "FULLTEXT index stöds ej för partitionerade tabeller."
+
+ER_DA_INVALID_CONDITION_NUMBER 35000
+ eng "Invalid condition number"
+ por "Número de condição inválido"
=== modified file 'sql/sql_cmd.h'
--- a/sql/sql_cmd.h 2011-06-30 15:50:45 +0000
+++ b/sql/sql_cmd.h 2011-07-15 12:56:32 +0000
@@ -87,7 +87,8 @@ enum enum_sql_command {
SQLCOM_ALTER_DB_UPGRADE,
SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
- SQLCOM_SHOW_RELAYLOG_EVENTS,
+ SQLCOM_SHOW_RELAYLOG_EVENTS,
+ SQLCOM_GET_DIAGNOSTICS,
/*
When a command is added here, be sure it's also added in mysqld.cc
=== modified file 'sql/sql_error.cc'
--- a/sql/sql_error.cc 2011-10-14 15:04:41 +0000
+++ b/sql/sql_error.cc 2011-10-14 15:38:24 +0000
@@ -93,8 +93,7 @@ This file contains the implementation of
(#6) The statements SHOW WARNINGS and SHOW ERRORS display the content of
the warning list.
- (#7) The GET DIAGNOSTICS statement (planned, not implemented yet) will
- also read the content of:
+ (#7) The GET DIAGNOSTICS statement reads the content of:
- the top level statement condition area (when executed in a query),
- a sub statement (when executed in a stored program)
and return the data stored in a Sql_condition.
@@ -145,7 +144,7 @@ This file contains the implementation of
(#6) (SHOW WARNINGS) produces data in the 'error_message_charset_info' CHARSET
- (#7) (GET DIAGNOSTICS) is not implemented.
+ (#7) (GET DIAGNOSTICS) is implemented.
(#8) (RESIGNAL) produces data internally in UTF8 (see #3)
@@ -166,9 +165,6 @@ This file contains the implementation of
In practice, this means changing the type of the message text to
'<UTF8 String 128 class> Sql_condition::m_message_text', and is a direct
consequence of WL#751.
-
- - Implement (#9) (GET DIAGNOSTICS).
- See WL#2111 (Stored Procedures: Implement GET DIAGNOSTICS)
*/
Sql_condition::Sql_condition()
@@ -281,6 +277,8 @@ Sql_condition::set(uint sql_errno, const
memcpy(m_returned_sqlstate, sqlstate, SQLSTATE_LENGTH);
m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
+ set_class_origin();
+ set_subclass_origin();
set_builtin_message_text(msg);
m_level= level;
}
@@ -318,6 +316,65 @@ Sql_condition::set_sqlstate(const char*
m_returned_sqlstate[SQLSTATE_LENGTH]= '\0';
}
+static LEX_CSTRING sqlstate_origin[]= {
+ { STRING_WITH_LEN("ISO 9075") },
+ { STRING_WITH_LEN("MySQL") }
+};
+
+void
+Sql_condition::set_class_origin()
+{
+ char cls[2];
+ LEX_CSTRING *origin;
+
+ /* Let CLASS = the first two letters of RETURNED_SQLSTATE. */
+ cls[0]= m_returned_sqlstate[0];
+ cls[1]= m_returned_sqlstate[1];
+
+ /* Only digits and upper case latin letter are allowed. */
+ DBUG_ASSERT(my_isdigit(&my_charset_latin1, cls[0]) ||
+ my_isupper(&my_charset_latin1, cls[0]));
+
+ DBUG_ASSERT(my_isdigit(&my_charset_latin1, cls[1]) ||
+ my_isupper(&my_charset_latin1, cls[1]));
+
+ /*
+ If CLASS[1] is any of: 0 1 2 3 4 A B C D E F G H
+ and CLASS[2] is any of: 0-9 A-Z
+ */
+ if (((cls[0] >= '0' && cls[0] <= '4') || (cls[0] >= 'A' && cls[0] <= 'H')) &&
+ ((cls[1] >= '0' && cls[1] <= '9') || (cls[1] >= 'A' && cls[1] <= 'Z')))
+ /* then let CLASS_ORIGIN = 'ISO 9075'. */
+ origin= &sqlstate_origin[0];
+ else
+ /* let CLASS_ORIGIN = 'MySQL'. */
+ origin= &sqlstate_origin[1];
+
+ m_class_origin.set_ascii(origin->str, origin->length);
+}
+
+void
+Sql_condition::set_subclass_origin()
+{
+ LEX_CSTRING *origin;
+
+ DBUG_ASSERT(! m_class_origin.is_empty());
+
+ /*
+ Let SUBCLASS = the next three letters of RETURNED_SQLSTATE.
+ If CLASS_ORIGIN = 'ISO 9075' or SUBCLASS = '000'
+ */
+ if (! memcmp(m_class_origin.ptr(), STRING_WITH_LEN("ISO 9075")) ||
+ ! memcmp(m_returned_sqlstate+2, STRING_WITH_LEN("000")))
+ /* then let SUBCLASS_ORIGIN = 'ISO 9075'. */
+ origin= &sqlstate_origin[0];
+ else
+ /* let SUBCLASS_ORIGIN = 'MySQL'. */
+ origin= &sqlstate_origin[1];
+
+ m_subclass_origin.set_ascii(origin->str, origin->length);
+}
+
Diagnostics_area::Diagnostics_area()
: m_main_wi(0, false)
{
=== modified file 'sql/sql_error.h'
--- a/sql/sql_error.h 2011-09-20 12:13:07 +0000
+++ b/sql/sql_error.h 2011-10-14 15:38:24 +0000
@@ -81,7 +81,7 @@ private:
The interface of Sql_condition is mostly private, by design,
so that only the following code:
- various raise_error() or raise_warning() methods in class THD,
- - the implementation of SIGNAL / RESIGNAL
+ - the implementation of SIGNAL / RESIGNAL / GET DIAGNOSTICS
- catch / re-throw of SQL conditions in stored procedures (sp_rcontext)
is allowed to create / modify a SQL condition.
Enforcing this policy prevents confusion, since the only public
@@ -95,6 +95,7 @@ private:
friend class Sql_cmd_signal;
friend class Sql_cmd_resignal;
friend class sp_rcontext;
+ friend class Condition_information_item;
/**
Default constructor.
@@ -149,6 +150,12 @@ private:
/** Set the SQLSTATE of this condition. */
void set_sqlstate(const char* sqlstate);
+ /** Set the CLASS_ORIGIN of this condition. */
+ void set_class_origin();
+
+ /** Set the SUBCLASS_ORIGIN of this condition. */
+ void set_subclass_origin();
+
/**
Clear this SQL condition.
*/
@@ -403,6 +410,14 @@ private:
ulong error_count() const
{ return m_warn_count[(uint) Sql_condition::WARN_LEVEL_ERROR]; }
+ /**
+ The number of conditions (errors, warnings and notes) in the list.
+ */
+ uint cond_count() const
+ {
+ return m_warn_list.elements();
+ }
+
/** Id of the warning information area. */
ulonglong id() const { return m_warn_id; }
@@ -706,6 +721,9 @@ public:
ulong warn_count() const
{ return get_warning_info()->warn_count(); }
+ uint cond_count() const
+ { return get_warning_info()->cond_count(); }
+
Sql_condition_iterator sql_conditions() const
{ return get_warning_info()->m_warn_list; }
=== added file 'sql/sql_get_diagnostics.cc'
--- a/sql/sql_get_diagnostics.cc 1970-01-01 00:00:00 +0000
+++ b/sql/sql_get_diagnostics.cc 2011-08-17 13:16:26 +0000
@@ -0,0 +1,342 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#include "sql_list.h" // Sql_alloc, List, List_iterator
+#include "sql_cmd.h" // Sql_cmd
+#include "sql_class.h" // Diagnostics_area
+#include "sql_get_diagnostics.h" // Sql_cmd_get_diagnostics
+
+/**
+ Execute this GET DIAGNOSTICS statement.
+
+ @param thd The current thread.
+
+ @remark Errors or warnings occurring during the execution of the GET
+ DIAGNOSTICS statement should not affect the diagnostics area
+ of a previous statement as the diagnostics information there
+ would be wiped out. Thus, in order to preserve the contents
+ of the diagnostics area from which information is being
+ retrieved, the GET DIAGNOSTICS statement is executed under
+ a separate diagnostics area. If any errors or warnings occur
+ during the execution of the GET DIAGNOSTICS statement, these
+ error or warnings (conditions) are appended to the list of
+ the original diagnostics area. The only exception to this is
+ fatal errors, which must always cause the statement to fail.
+
+ @retval false on success.
+ @retval true on error
+*/
+
+bool
+Sql_cmd_get_diagnostics::execute(THD *thd)
+{
+ bool rv;
+ Diagnostics_area new_stmt_da(thd->query_id, false);
+ Diagnostics_area *save_stmt_da= thd->get_stmt_da();
+ DBUG_ENTER("Sql_cmd_get_diagnostics::execute");
+
+ /* Disable the unneeded read-only mode of the original DA. */
+ save_stmt_da->set_warning_info_read_only(false);
+
+ /* Set new diagnostics area, execute statement and restore. */
+ thd->set_stmt_da(&new_stmt_da);
+ rv= m_info->aggregate(thd, save_stmt_da);
+ thd->set_stmt_da(save_stmt_da);
+
+ /* Bail out early if statement succeeded. */
+ if (! rv)
+ {
+ thd->get_stmt_da()->set_ok_status(0, 0, NULL);
+ DBUG_RETURN(false);
+ }
+
+ /* Statement failed, retrieve the error information for propagation. */
+ uint sql_errno= new_stmt_da.sql_errno();
+ const char *message= new_stmt_da.message();
+ const char *sqlstate= new_stmt_da.get_sqlstate();
+
+ /* In case of a fatal error, set it into the original DA.*/
+ if (thd->is_fatal_error)
+ {
+ save_stmt_da->set_error_status(sql_errno, message, sqlstate, NULL);
+ DBUG_RETURN(true);
+ }
+
+ /* Otherwise, just append the new error as a exception condition. */
+ save_stmt_da->push_warning(thd, sql_errno, sqlstate,
+ Sql_condition::WARN_LEVEL_ERROR,
+ message);
+
+ /* Appending might have failed. */
+ if (! (rv= thd->is_error()))
+ thd->get_stmt_da()->set_ok_status(0, 0, NULL);
+
+ DBUG_RETURN(rv);
+}
+
+
+/**
+ Set a value for this item.
+
+ @param thd The current thread.
+ @param value The obtained value.
+
+ @retval false on success.
+ @retval true on error.
+*/
+
+bool
+Diagnostics_information_item::set_value(THD *thd, Item **value)
+{
+ bool rv;
+ Settable_routine_parameter *srp;
+ DBUG_ENTER("Diagnostics_information_item::set_value");
+
+ /* Get a settable reference to the target. */
+ srp= m_target->get_settable_routine_parameter();
+
+ DBUG_ASSERT(srp);
+
+ /* Set variable/parameter value. */
+ rv= srp->set_value(thd, thd->spcont, value);
+
+ DBUG_RETURN(rv);
+}
+
+
+/**
+ Obtain statement information in the context of a given diagnostics area.
+
+ @param thd The current thread.
+ @param da The diagnostics area.
+
+ @retval false on success.
+ @retval true on error
+*/
+
+bool
+Statement_information::aggregate(THD *thd, const Diagnostics_area *da)
+{
+ bool rv= false;
+ Statement_information_item *stmt_info_item;
+ List_iterator<Statement_information_item> it(*m_items);
+ DBUG_ENTER("Statement_information::aggregate");
+
+ /*
+ Each specified target gets the value of each given
+ information item obtained from the diagnostics area.
+ */
+ while ((stmt_info_item= it++))
+ {
+ if ((rv= evaluate(thd, stmt_info_item, da)))
+ break;
+ }
+
+ DBUG_RETURN(rv);
+}
+
+
+/**
+ Obtain the value of this statement information item in the context of
+ a given diagnostics area.
+
+ @param thd The current thread.
+ @param da The diagnostics area.
+
+ @retval Item representing the value.
+ @retval NULL on error.
+*/
+
+Item *
+Statement_information_item::get_value(THD *thd, const Diagnostics_area *da)
+{
+ Item *value= NULL;
+ DBUG_ENTER("Statement_information_item::get_value");
+
+ switch (m_name)
+ {
+ /*
+ The number of condition areas that have information. That is,
+ the number of errors and warnings within the diagnostics area.
+ */
+ case NUMBER:
+ {
+ ulong count= da->cond_count();
+ value= new (thd->mem_root) Item_uint(count);
+ break;
+ }
+ /*
+ Number that shows how many rows were directly affected by
+ a data-change statement (INSERT, UPDATE, DELETE, MERGE,
+ REPLACE, LOAD).
+ */
+ case ROW_COUNT:
+ value= new (thd->mem_root) Item_int(thd->get_row_count_func());
+ break;
+ }
+
+ DBUG_RETURN(value);
+}
+
+
+/**
+ Obtain condition information in the context of a given diagnostics area.
+
+ @param thd The current thread.
+ @param da The diagnostics area.
+
+ @retval false on success.
+ @retval true on error
+*/
+
+bool
+Condition_information::aggregate(THD *thd, const Diagnostics_area *da)
+{
+ bool rv= false;
+ longlong cond_number;
+ const Sql_condition *cond= NULL;
+ Condition_information_item *cond_info_item;
+ Diagnostics_area::Sql_condition_iterator it_conds= da->sql_conditions();
+ List_iterator_fast<Condition_information_item> it_items(*m_items);
+ DBUG_ENTER("Condition_information::aggregate");
+
+ /* Prepare the expression for evaluation. */
+ if (!m_cond_number_expr->fixed &&
+ m_cond_number_expr->fix_fields(thd, &m_cond_number_expr))
+ DBUG_RETURN(true);
+
+ cond_number= m_cond_number_expr->val_int();
+
+ /*
+ Limit to the number of available conditions. Warning_info::warn_count()
+ is not used because it indicates the number of condition regardless of
+ @@max_error_count, which prevents conditions from being pushed, but not
+ counted.
+ */
+ if (cond_number < 1 || (ulonglong) cond_number > da->cond_count())
+ {
+ my_error(ER_DA_INVALID_CONDITION_NUMBER, MYF(0));
+ DBUG_RETURN(true);
+ }
+
+ /* Advance to the requested condition. */
+ while (cond_number--)
+ cond= it_conds++;
+
+ DBUG_ASSERT(cond);
+
+ /* Evaluate the requested information in the context of the condition. */
+ while ((cond_info_item= it_items++))
+ {
+ if ((rv= evaluate(thd, cond_info_item, cond)))
+ break;
+ }
+
+ DBUG_RETURN(rv);
+}
+
+
+/**
+ Create an UTF-8 string item to represent a condition item string.
+
+ @remark The string might not have a associated charset. For example,
+ this can be the case if the server does not or fails to process
+ the error message file.
+
+ @remark See "Design notes about Sql_condition::m_message_text." in sql_error.cc
+
+ @return Pointer to an string item, NULL on failure.
+*/
+
+Item *
+Condition_information_item::make_utf8_string_item(THD *thd, const String *str)
+{
+ /* Default is utf8 character set and utf8_general_ci collation. */
+ const CHARSET_INFO *to_cs= &my_charset_utf8_general_ci;
+ /* If a charset was not set, assume that no conversion is needed. */
+ const CHARSET_INFO *from_cs= str->charset() ? str->charset() : to_cs;
+ Item_string *item= new Item_string(str->ptr(), str->length(), from_cs);
+ /* If necessary, convert the string (ignoring errors), then copy it over. */
+ return item ? item->charset_converter(to_cs, false) : NULL;
+}
+
+
+/**
+ Obtain the value of this condition information item in the context of
+ a given condition.
+
+ @param thd The current thread.
+ @param da The diagnostics area.
+
+ @retval Item representing the value.
+ @retval NULL on error.
+*/
+
+Item *
+Condition_information_item::get_value(THD *thd, const Sql_condition *cond)
+{
+ String str;
+ Item *value= NULL;
+ DBUG_ENTER("Condition_information_item::get_value");
+
+ switch (m_name)
+ {
+ case CLASS_ORIGIN:
+ value= make_utf8_string_item(thd, &(cond->m_class_origin));
+ break;
+ case SUBCLASS_ORIGIN:
+ value= make_utf8_string_item(thd, &(cond->m_subclass_origin));
+ break;
+ case CONSTRAINT_CATALOG:
+ value= make_utf8_string_item(thd, &(cond->m_constraint_catalog));
+ break;
+ case CONSTRAINT_SCHEMA:
+ value= make_utf8_string_item(thd, &(cond->m_constraint_schema));
+ break;
+ case CONSTRAINT_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_constraint_name));
+ break;
+ case CATALOG_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_catalog_name));
+ break;
+ case SCHEMA_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_schema_name));
+ break;
+ case TABLE_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_table_name));
+ break;
+ case COLUMN_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_column_name));
+ break;
+ case CURSOR_NAME:
+ value= make_utf8_string_item(thd, &(cond->m_cursor_name));
+ break;
+ case MESSAGE_TEXT:
+ value= make_utf8_string_item(thd, &(cond->m_message_text));
+ break;
+ case MYSQL_ERRNO:
+ value= new (thd->mem_root) Item_uint(cond->m_sql_errno);
+ break;
+ case RETURNED_SQLSTATE:
+ str.set_ascii(cond->get_sqlstate(), strlen(cond->get_sqlstate()));
+ value= make_utf8_string_item(thd, &str);
+ break;
+ }
+
+ DBUG_RETURN(value);
+}
+
=== added file 'sql/sql_get_diagnostics.h'
--- a/sql/sql_get_diagnostics.h 1970-01-01 00:00:00 +0000
+++ b/sql/sql_get_diagnostics.h 2011-08-17 13:16:26 +0000
@@ -0,0 +1,320 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+#ifndef SQL_GET_DIAGNOSTICS_H
+#define SQL_GET_DIAGNOSTICS_H
+
+/** Diagnostics information forward reference. */
+class Diagnostics_information;
+
+
+/**
+ Sql_cmd_get_diagnostics represents a GET DIAGNOSTICS statement.
+
+ The GET DIAGNOSTICS statement retrieves exception or completion
+ condition information from a diagnostics area, usually pertaining
+ to the last non-diagnostic SQL statement that was executed.
+*/
+class Sql_cmd_get_diagnostics : public Sql_cmd
+{
+public:
+ /**
+ Constructor, used to represent a GET DIAGNOSTICS statement.
+
+ @param info Diagnostics information to be obtained.
+ */
+ Sql_cmd_get_diagnostics(Diagnostics_information *info)
+ : m_info(info)
+ {}
+
+ virtual enum_sql_command sql_command_code() const
+ {
+ return SQLCOM_GET_DIAGNOSTICS;
+ }
+
+ virtual bool execute(THD *thd);
+
+private:
+ /** The information to be obtained. */
+ Diagnostics_information *m_info;
+};
+
+
+/**
+ Represents the diagnostics information to be obtained.
+
+ Diagnostic information is made available through statement
+ information and condition information items.
+*/
+class Diagnostics_information : public Sql_alloc
+{
+public:
+ /**
+ Which diagnostics area to access.
+ Only CURRENT is supported for now.
+ */
+ enum Which_area
+ {
+ /** Access the first diagnostics area. */
+ CURRENT_AREA
+ };
+
+ /** Set which diagnostics area to access. */
+ void set_which_da(Which_area area)
+ { m_area= area; }
+
+ /** Get which diagnostics area to access. */
+ Which_area get_which_da(void) const
+ { return m_area; }
+
+ /**
+ Aggregate diagnostics information.
+
+ @param thd The current thread.
+ @param da The diagnostics area.
+
+ @retval false on success.
+ @retval true on error
+ */
+ virtual bool aggregate(THD *thd, const Diagnostics_area *da) = 0;
+
+protected:
+ /**
+ Diagnostics_information objects are allocated in thd->mem_root.
+ Do not rely on the destructor for any cleanup.
+ */
+ virtual ~Diagnostics_information()
+ {
+ DBUG_ASSERT(false);
+ }
+
+ /**
+ Evaluate a diagnostics information item in a specific context.
+
+ @param thd The current thread.
+ @param diag_item The diagnostics information item.
+ @param ctx The context to evaluate the item.
+
+ @retval false on success.
+ @retval true on error.
+ */
+ template <typename Diag_item, typename Context>
+ bool evaluate(THD *thd, Diag_item *diag_item, Context ctx)
+ {
+ Item *value;
+
+ /* Get this item's value. */
+ if (! (value= diag_item->get_value(thd, ctx)))
+ return true;
+
+ /* Set variable/parameter value. */
+ return diag_item->set_value(thd, &value);
+ }
+
+private:
+ /** Which diagnostics area to access. */
+ Which_area m_area;
+};
+
+
+/**
+ A diagnostics information item. Used to associate a specific
+ diagnostics information item to a target variable.
+*/
+class Diagnostics_information_item : public Sql_alloc
+{
+public:
+ /**
+ Set a value for this item.
+
+ @param thd The current thread.
+ @param value The obtained value.
+
+ @retval false on success.
+ @retval true on error.
+ */
+ bool set_value(THD *thd, Item **value);
+
+protected:
+ /**
+ Constructor, used to represent a diagnostics information item.
+
+ @param target A target that gets the value of this item.
+ */
+ Diagnostics_information_item(Item *target)
+ : m_target(target)
+ {}
+
+ /**
+ Diagnostics_information_item objects are allocated in thd->mem_root.
+ Do not rely on the destructor for any cleanup.
+ */
+ virtual ~Diagnostics_information_item()
+ {
+ DBUG_ASSERT(false);
+ }
+
+private:
+ /** The target variable that will receive the value of this item. */
+ Item *m_target;
+};
+
+
+/**
+ A statement information item.
+*/
+class Statement_information_item : public Diagnostics_information_item
+{
+public:
+ /** The name of a statement information item. */
+ enum Name
+ {
+ NUMBER,
+ ROW_COUNT
+ };
+
+ /**
+ Constructor, used to represent a statement information item.
+
+ @param name The name of this item.
+ @param target A target that gets the value of this item.
+ */
+ Statement_information_item(Name name, Item *target)
+ : Diagnostics_information_item(target), m_name(name)
+ {}
+
+ /** Obtain value of this statement information item. */
+ Item *get_value(THD *thd, const Diagnostics_area *da);
+
+private:
+ /** The name of this statement information item. */
+ Name m_name;
+};
+
+
+/**
+ Statement information.
+
+ @remark Provides information about the execution of a statement.
+*/
+class Statement_information : public Diagnostics_information
+{
+public:
+ /**
+ Constructor, used to represent the statement information of a
+ GET DIAGNOSTICS statement.
+
+ @param items List of requested statement information items.
+ */
+ Statement_information(List<Statement_information_item> *items)
+ : m_items(items)
+ {}
+
+ /** Obtain statement information in the context of a diagnostics area. */
+ bool aggregate(THD *thd, const Diagnostics_area *da);
+
+private:
+ /* List of statement information items. */
+ List<Statement_information_item> *m_items;
+};
+
+
+/**
+ A condition information item.
+*/
+class Condition_information_item : public Diagnostics_information_item
+{
+public:
+ /**
+ The name of a condition information item.
+ */
+ enum Name
+ {
+ CLASS_ORIGIN,
+ SUBCLASS_ORIGIN,
+ CONSTRAINT_CATALOG,
+ CONSTRAINT_SCHEMA,
+ CONSTRAINT_NAME,
+ CATALOG_NAME,
+ SCHEMA_NAME,
+ TABLE_NAME,
+ COLUMN_NAME,
+ CURSOR_NAME,
+ MESSAGE_TEXT,
+ MYSQL_ERRNO,
+ RETURNED_SQLSTATE
+ };
+
+ /**
+ Constructor, used to represent a condition information item.
+
+ @param name The name of this item.
+ @param target A target that gets the value of this item.
+ */
+ Condition_information_item(Name name, Item *target)
+ : Diagnostics_information_item(target), m_name(name)
+ {}
+
+ /** Obtain value of this condition information item. */
+ Item *get_value(THD *thd, const Sql_condition *cond);
+
+private:
+ /** The name of this condition information item. */
+ Name m_name;
+
+ /** Create an string item to represent a condition item string. */
+ Item *make_utf8_string_item(THD *thd, const String *str);
+};
+
+
+/**
+ Condition information.
+
+ @remark Provides information about conditions raised during the
+ execution of a statement.
+*/
+class Condition_information : public Diagnostics_information
+{
+public:
+ /**
+ Constructor, used to represent the condition information of a
+ GET DIAGNOSTICS statement.
+
+ @param cond_number_expr Number that identifies the diagnostic condition.
+ @param items List of requested condition information items.
+ */
+ Condition_information(Item *cond_number_expr,
+ List<Condition_information_item> *items)
+ : m_cond_number_expr(cond_number_expr), m_items(items)
+ {}
+
+ /** Obtain condition information in the context of a diagnostics area. */
+ bool aggregate(THD *thd, const Diagnostics_area *da);
+
+private:
+ /**
+ Number that identifies the diagnostic condition for which
+ information is to be obtained.
+ */
+ Item *m_cond_number_expr;
+
+ /** List of condition information items. */
+ List<Condition_information_item> *m_items;
+};
+
+#endif
+
=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h 2011-09-29 10:42:53 +0000
+++ b/sql/sql_lex.h 2011-10-13 12:33:08 +0000
@@ -116,6 +116,7 @@ struct sys_var_with_base
#include "lex_symbol.h"
#if MYSQL_LEX
#include "item_func.h" /* Cast_target used in sql_yacc.h */
+#include "sql_get_diagnostics.h" /* Types used in sql_yacc.h */
#include "sql_yacc.h"
#define LEX_YYSTYPE YYSTYPE *
#else
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2011-10-13 14:01:50 +0000
+++ b/sql/sql_parse.cc 2011-10-14 15:38:24 +0000
@@ -433,6 +433,9 @@ void init_update_queries(void)
sql_command_flags[SQLCOM_INSTALL_PLUGIN]= CF_CHANGES_DATA;
sql_command_flags[SQLCOM_UNINSTALL_PLUGIN]= CF_CHANGES_DATA;
+ /* Does not change the contents of the diagnostics area. */
+ sql_command_flags[SQLCOM_GET_DIAGNOSTICS]= CF_DIAGNOSTIC_STMT;
+
/*
(1): without it, in "CALL some_proc((subq))", subquery would not be
traced.
@@ -4600,6 +4603,7 @@ create_sp_error:
/* fall through */
case SQLCOM_SIGNAL:
case SQLCOM_RESIGNAL:
+ case SQLCOM_GET_DIAGNOSTICS:
DBUG_ASSERT(lex->m_sql_cmd != NULL);
res= lex->m_sql_cmd->execute(thd);
break;
=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy 2011-10-14 15:04:41 +0000
+++ b/sql/sql_yacc.yy 2011-10-14 15:38:24 +0000
@@ -58,6 +58,7 @@
#include "sql_partition_admin.h" // Sql_cmd_alter_table_*_part.
#include "sql_handler.h" // Sql_cmd_handler_*
#include "sql_signal.h"
+#include "sql_get_diagnostics.h" // Sql_cmd_get_diagnostics
#include "event_parse_data.h"
#include <myisam.h>
#include <myisammrg.h>
@@ -539,6 +540,58 @@ set_trigger_new_row(THD *thd, LEX_STRING
/**
+ Create an object to represent a SP variable in the Item-hierarchy.
+
+ @param thd The current thread.
+ @param name The SP variable name.
+ @param spvar The SP variable (optional).
+ @param start_in_q Start position of the SP variable name in the query.
+ @param end_in_q End position of the SP variable name in the query.
+
+ @remark If spvar is not specified, the name is used to search for the
+ variable in the parse-time context. If the variable does not
+ exist, a error is set and NULL is returned to the caller.
+
+ @return An Item_splocal object representing the SP variable, or NULL on error.
+*/
+static Item_splocal*
+create_item_for_sp_var(THD *thd, LEX_STRING name, sp_variable *spvar,
+ const char *start_in_q, const char *end_in_q)
+{
+ Item_splocal *item;
+ LEX *lex= thd->lex;
+ uint pos_in_q, len_in_q;
+ sp_pcontext *spc = lex->spcont;
+
+ /* If necessary, look for the variable. */
+ if (spc && !spvar)
+ spvar= spc->find_variable(name, false);
+
+ if (!spvar)
+ {
+ my_error(ER_SP_UNDECLARED_VAR, MYF(0), name.str);
+ return NULL;
+ }
+
+ DBUG_ASSERT(spc && spvar);
+
+ /* Position and length of the SP variable name in the query. */
+ pos_in_q= start_in_q - lex->sphead->m_tmp_query;
+ len_in_q= end_in_q - start_in_q;
+
+ item= new (thd->mem_root)
+ Item_splocal(name, spvar->offset, spvar->type, pos_in_q, len_in_q);
+
+#ifndef DBUG_OFF
+ if (item)
+ item->m_sp= lex->sphead;
+#endif
+
+ return item;
+}
+
+
+/**
Helper to resolve the SQL:2003 Syntax exception 1) in <in predicate>.
See SQL:2003, Part 2, section 8.4 <in predicate>, Note 184, page 383.
This function returns the proper item for the SQL expression
@@ -775,6 +828,14 @@ static bool add_create_index (LEX *lex,
enum Foreign_key::fk_option m_fk_option;
enum enum_yes_no_unknown m_yes_no_unk;
Diag_condition_item_name diag_condition_item_name;
+ Diagnostics_information::Which_area diag_area;
+ Diagnostics_information *diag_info;
+ Statement_information_item *stmt_info_item;
+ Statement_information_item::Name stmt_info_item_name;
+ List<Statement_information_item> *stmt_info_list;
+ Condition_information_item *cond_info_item;
+ Condition_information_item::Name cond_info_item_name;
+ List<Condition_information_item> *cond_info_list;
}
%{
@@ -900,6 +961,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token CROSS /* SQL-2003-R */
%token CUBE_SYM /* SQL-2003-R */
%token CURDATE /* MYSQL-FUNC */
+%token CURRENT_SYM /* SQL-2003-R */
%token CURRENT_USER /* SQL-2003-R */
%token CURSOR_SYM /* SQL-2003-R */
%token CURSOR_NAME_SYM /* SQL-2003-N */
@@ -930,6 +992,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token DESCRIBE /* SQL-2003-R */
%token DES_KEY_FILE
%token DETERMINISTIC_SYM /* SQL-2003-R */
+%token DIAGNOSTICS_SYM /* SQL-2003-N */
%token DIRECTORY_SYM
%token DISABLE_SYM
%token DISCARD
@@ -994,6 +1057,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token GEOMETRYCOLLECTION
%token GEOMETRY_SYM
%token GET_FORMAT /* MYSQL-FUNC */
+%token GET_SYM /* SQL-2003-R */
%token GLOBAL_SYM /* SQL-2003-R */
%token GRANT /* SQL-2003-R */
%token GRANTS
@@ -1151,6 +1215,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token NO_WRITE_TO_BINLOG
%token NULL_SYM /* SQL-2003-R */
%token NUM
+%token NUMBER_SYM /* SQL-2003-N */
%token NUMERIC_SYM /* SQL-2003-R */
%token NVARCHAR_SYM
%token OFFSET_SYM
@@ -1238,6 +1303,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token RESTORE_SYM
%token RESTRICT
%token RESUME_SYM
+%token RETURNED_SQLSTATE_SYM /* SQL-2003-N */
%token RETURNS_SYM /* SQL-2003-R */
%token RETURN_SYM /* SQL-2003-R */
%token REVERSE_SYM
@@ -1249,6 +1315,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
%token ROWS_SYM /* SQL-2003-R */
%token ROW_FORMAT_SYM
%token ROW_SYM /* SQL-2003-R */
+%token ROW_COUNT_SYM /* SQL-2003-N */
%token RTREE_SYM
%token SAVEPOINT_SYM /* SQL-2003-R */
%token SCHEDULE_SYM
@@ -1494,6 +1561,8 @@ bool my_yyoverflow(short **a, YYSTYPE **
function_call_generic
function_call_conflict
signal_allowed_expr
+ simple_target_specification
+ condition_number
%type <item_num>
NUM_literal
@@ -1616,7 +1685,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
key_using_alg
part_column_list
server_def server_options_list server_option
- definer_opt no_definer definer
+ definer_opt no_definer definer get_diagnostics
END_OF_INPUT
%type <NONE> call sp_proc_stmts sp_proc_stmts1 sp_proc_stmt
@@ -1641,6 +1710,15 @@ END_OF_INPUT
%type <NONE> signal_stmt resignal_stmt
%type <diag_condition_item_name> signal_condition_information_item_name
+%type <diag_area> which_area;
+%type <diag_info> diagnostics_information;
+%type <stmt_info_item> statement_information_item;
+%type <stmt_info_item_name> statement_information_item_name;
+%type <stmt_info_list> statement_information;
+%type <cond_info_item> condition_information_item;
+%type <cond_info_item_name> condition_information_item_name;
+%type <cond_info_list> condition_information;
+
%type <NONE>
'-' '+' '*' '/' '%' '(' ')'
',' '!' '{' '}' '&' '|' AND_SYM OR_SYM OR_OR_SYM BETWEEN_SYM CASE_SYM
@@ -1741,6 +1819,7 @@ statement:
| drop
| execute
| flush
+ | get_diagnostics
| grant
| handler
| help
@@ -3145,6 +3224,151 @@ resignal_stmt:
}
;
+get_diagnostics:
+ GET_SYM which_area DIAGNOSTICS_SYM diagnostics_information
+ {
+ Diagnostics_information *info= $4;
+
+ info->set_which_da($2);
+
+ Lex->sql_command= SQLCOM_GET_DIAGNOSTICS;
+ Lex->m_sql_cmd= new (YYTHD->mem_root) Sql_cmd_get_diagnostics(info);
+
+ if (Lex->m_sql_cmd == NULL)
+ MYSQL_YYABORT;
+ }
+ ;
+
+which_area:
+ /* If <which area> is not specified, then CURRENT is implicit. */
+ { $$= Diagnostics_information::CURRENT_AREA; }
+ | CURRENT_SYM
+ { $$= Diagnostics_information::CURRENT_AREA; }
+ ;
+
+diagnostics_information:
+ statement_information
+ {
+ $$= new (YYTHD->mem_root) Statement_information($1);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ | CONDITION_SYM condition_number condition_information
+ {
+ $$= new (YYTHD->mem_root) Condition_information($2, $3);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ ;
+
+statement_information:
+ statement_information_item
+ {
+ $$= new (YYTHD->mem_root) List<Statement_information_item>;
+ if ($$ == NULL || $$->push_back($1))
+ MYSQL_YYABORT;
+ }
+ | statement_information ',' statement_information_item
+ {
+ if ($1->push_back($3))
+ MYSQL_YYABORT;
+ $$= $1;
+ }
+ ;
+
+statement_information_item:
+ simple_target_specification EQ statement_information_item_name
+ {
+ $$= new (YYTHD->mem_root) Statement_information_item($3, $1);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+
+simple_target_specification:
+ ident
+ {
+ Lex_input_stream *lip= &YYTHD->m_parser_state->m_lip;
+ $$= create_item_for_sp_var(YYTHD, $1, NULL,
+ lip->get_tok_start(), lip->get_ptr());
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ | '@' ident_or_text
+ {
+ $$= new (YYTHD->mem_root) Item_func_get_user_var($2);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+ ;
+
+statement_information_item_name:
+ NUMBER_SYM
+ { $$= Statement_information_item::NUMBER; }
+ | ROW_COUNT_SYM
+ { $$= Statement_information_item::ROW_COUNT; }
+ ;
+
+/*
+ Only a limited subset of <expr> are allowed in GET DIAGNOSTICS
+ <condition number>, same subset as for SIGNAL/RESIGNAL.
+*/
+condition_number:
+ signal_allowed_expr
+ { $$= $1; }
+ ;
+
+condition_information:
+ condition_information_item
+ {
+ $$= new (YYTHD->mem_root) List<Condition_information_item>;
+ if ($$ == NULL || $$->push_back($1))
+ MYSQL_YYABORT;
+ }
+ | condition_information ',' condition_information_item
+ {
+ if ($1->push_back($3))
+ MYSQL_YYABORT;
+ $$= $1;
+ }
+ ;
+
+condition_information_item:
+ simple_target_specification EQ condition_information_item_name
+ {
+ $$= new (YYTHD->mem_root) Condition_information_item($3, $1);
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ }
+
+condition_information_item_name:
+ CLASS_ORIGIN_SYM
+ { $$= Condition_information_item::CLASS_ORIGIN; }
+ | SUBCLASS_ORIGIN_SYM
+ { $$= Condition_information_item::SUBCLASS_ORIGIN; }
+ | CONSTRAINT_CATALOG_SYM
+ { $$= Condition_information_item::CONSTRAINT_CATALOG; }
+ | CONSTRAINT_SCHEMA_SYM
+ { $$= Condition_information_item::CONSTRAINT_SCHEMA; }
+ | CONSTRAINT_NAME_SYM
+ { $$= Condition_information_item::CONSTRAINT_NAME; }
+ | CATALOG_NAME_SYM
+ { $$= Condition_information_item::CATALOG_NAME; }
+ | SCHEMA_NAME_SYM
+ { $$= Condition_information_item::SCHEMA_NAME; }
+ | TABLE_NAME_SYM
+ { $$= Condition_information_item::TABLE_NAME; }
+ | COLUMN_NAME_SYM
+ { $$= Condition_information_item::COLUMN_NAME; }
+ | CURSOR_NAME_SYM
+ { $$= Condition_information_item::CURSOR_NAME; }
+ | MESSAGE_TEXT_SYM
+ { $$= Condition_information_item::MESSAGE_TEXT; }
+ | MYSQL_ERRNO_SYM
+ { $$= Condition_information_item::MYSQL_ERRNO; }
+ | RETURNED_SQLSTATE_SYM
+ { $$= Condition_information_item::RETURNED_SQLSTATE; }
+ ;
+
sp_decl_idents:
ident
{
@@ -8656,6 +8880,14 @@ function_call_conflict:
if ($$ == NULL)
MYSQL_YYABORT;
}
+ | ROW_COUNT_SYM '(' ')'
+ {
+ $$= new (YYTHD->mem_root) Item_func_row_count();
+ if ($$ == NULL)
+ MYSQL_YYABORT;
+ Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION);
+ Lex->safe_to_cache_query= 0;
+ }
| TRUNCATE_SYM '(' expr ',' expr ')'
{
$$= new (YYTHD->mem_root) Item_func_round($3,$5,1);
@@ -10123,29 +10355,13 @@ limit_option:
ident
{
Item_splocal *splocal;
- THD *thd= YYTHD;
- LEX *lex= thd->lex;
- Lex_input_stream *lip= & thd->m_parser_state->m_lip;
- sp_variable *spv;
- sp_pcontext *spc = lex->spcont;
- if (spc && (spv = spc->find_variable($1, false)))
- {
- splocal= new (thd->mem_root)
- Item_splocal($1, spv->offset, spv->type,
- lip->get_tok_start() - lex->sphead->m_tmp_query,
- lip->get_ptr() - lip->get_tok_start());
- if (splocal == NULL)
- MYSQL_YYABORT;
-#ifndef DBUG_OFF
- splocal->m_sp= lex->sphead;
-#endif
- lex->safe_to_cache_query=0;
- }
- else
- {
- my_error(ER_SP_UNDECLARED_VAR, MYF(0), $1.str);
+ Lex_input_stream *lip= &YYTHD->m_parser_state->m_lip;
+
+ splocal= create_item_for_sp_var(YYTHD, $1, NULL,
+ lip->get_tok_start(), lip->get_ptr());
+ if (splocal == NULL)
MYSQL_YYABORT;
- }
+ Lex->safe_to_cache_query= 0;
if (splocal->type() != Item::INT_ITEM)
{
my_error(ER_WRONG_SPVAR_TYPE_IN_LIMIT, MYF(0));
@@ -12165,11 +12381,12 @@ simple_ident:
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
- Lex_input_stream *lip= YYLIP;
sp_variable *spv;
sp_pcontext *spc = lex->spcont;
if (spc && (spv = spc->find_variable($1, false)))
{
+ Lex_input_stream *lip= &thd->m_parser_state->m_lip;
+
/* We're compiling a stored procedure and found a variable */
if (! lex->parsing_options.allows_variable)
{
@@ -12177,17 +12394,11 @@ simple_ident:
MYSQL_YYABORT;
}
- Item_splocal *splocal;
- splocal= new (thd->mem_root)
- Item_splocal($1, spv->offset, spv->type,
- lip->get_tok_start_prev() - lex->sphead->m_tmp_query,
- lip->get_tok_end() - lip->get_tok_start_prev());
- if (splocal == NULL)
+ $$= create_item_for_sp_var(thd, $1, spv,
+ lip->get_tok_start_prev(),
+ lip->get_tok_end());
+ if ($$ == NULL)
MYSQL_YYABORT;
-#ifndef DBUG_OFF
- splocal->m_sp= lex->sphead;
-#endif
- $$= splocal;
lex->safe_to_cache_query=0;
}
else
@@ -12714,6 +12925,11 @@ keyword_sp:
| CONTRIBUTORS_SYM {}
| CPU_SYM {}
| CUBE_SYM {}
+ /*
+ Although a reserved keyword in SQL:2003 (and :2008),
+ not reserved in MySQL per WL#2111 specification.
+ */
+ | CURRENT_SYM {}
| CURSOR_NAME_SYM {}
| DATA_SYM {}
| DATAFILE_SYM {}
@@ -12723,6 +12939,7 @@ keyword_sp:
| DEFINER_SYM {}
| DELAY_KEY_WRITE_SYM {}
| DES_KEY_FILE {}
+ | DIAGNOSTICS_SYM {}
| DIRECTORY_SYM {}
| DISABLE_SYM {}
| DISCARD {}
@@ -12835,6 +13052,7 @@ keyword_sp:
| NO_WAIT_SYM {}
| NODEGROUP_SYM {}
| NONE_SYM {}
+ | NUMBER_SYM {}
| NVARCHAR_SYM {}
| OFFSET_SYM {}
| OLD_PASSWORD {}
@@ -12878,11 +13096,13 @@ keyword_sp:
| REPLICATION {}
| RESOURCES {}
| RESUME_SYM {}
+ | RETURNED_SQLSTATE_SYM {}
| RETURNS_SYM {}
| REVERSE_SYM {}
| ROLLUP_SYM {}
| ROUTINE_SYM {}
| ROWS_SYM {}
+ | ROW_COUNT_SYM {}
| ROW_FORMAT_SYM {}
| ROW_SYM {}
| RTREE_SYM {}
=== modified file 'unittest/gunit/CMakeLists.txt'
--- a/unittest/gunit/CMakeLists.txt 2011-09-06 08:43:08 +0000
+++ b/unittest/gunit/CMakeLists.txt 2011-10-13 12:33:08 +0000
@@ -248,6 +248,7 @@ SET(SERVER_TESTS
my_decimal
opt_range
opt_trace
+ get_diagnostics
)
FOREACH(test ${TESTS})
=== added file 'unittest/gunit/get_diagnostics-t.cc'
--- a/unittest/gunit/get_diagnostics-t.cc 1970-01-01 00:00:00 +0000
+++ b/unittest/gunit/get_diagnostics-t.cc 2011-08-17 13:16:26 +0000
@@ -0,0 +1,467 @@
+/* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+// First include (the generated) my_config.h, to get correct platform defines,
+// then gtest.h (before any other MySQL headers), to avoid min() macros etc ...
+#include "my_config.h"
+#include <gtest/gtest.h>
+
+#include "test_utils.h"
+
+#include "item.h"
+#include "sql_get_diagnostics.h"
+
+namespace {
+
+using my_testing::Server_initializer;
+using my_testing::Mock_error_handler;
+
+class GetDiagnosticsTest : public ::testing::Test
+{
+protected:
+ static void SetUpTestCase()
+ {
+ Server_initializer::SetUpTestCase();
+ }
+
+ static void TearDownTestCase()
+ {
+ Server_initializer::TearDownTestCase();
+ }
+
+ virtual void SetUp()
+ {
+ initializer.SetUp();
+ }
+
+ virtual void TearDown()
+ {
+ initializer.TearDown();
+ }
+
+ THD *thd() { return initializer.thd(); }
+
+ Server_initializer initializer;
+};
+
+
+class FailHelper
+{
+public:
+ void fail(const char *message)
+ {
+ FAIL() << message;
+ }
+};
+
+
+LEX_STRING var_name1= {C_STRING_WITH_LEN("var1")};
+LEX_STRING var_name2= {C_STRING_WITH_LEN("var2")};
+
+
+class MockDiagInfoItem : public Diagnostics_information_item
+{
+public:
+ MockDiagInfoItem(Item *target, int value)
+ : Diagnostics_information_item(target), m_value(value)
+ {}
+
+ Item *get_value(THD *thd, const Diagnostics_area *da)
+ {
+ return new (thd->mem_root) Item_int(m_value);
+ }
+
+private:
+ int m_value;
+};
+
+
+class MockDiagInfo : public Diagnostics_information,
+ private FailHelper
+{
+public:
+ MockDiagInfo(List<MockDiagInfoItem> *items)
+ : m_items(items)
+ {}
+
+protected:
+ bool aggregate(THD *thd, const Diagnostics_area *da)
+ {
+ bool rv= false;
+ MockDiagInfoItem *diag_info_item;
+ List_iterator<MockDiagInfoItem> it(*m_items);
+
+ while ((diag_info_item= it++))
+ {
+ if ((rv= evaluate(thd, diag_info_item, da)))
+ break;
+ }
+
+ return rv;
+ }
+
+ ~MockDiagInfo()
+ {
+ fail("MockDiagInfo destructor invoked.");
+ }
+
+private:
+ List<MockDiagInfoItem> *m_items;
+};
+
+
+// GET [CURRENT] DIAGNOSTICS @var1 = 1, @var2 = 2;
+TEST_F(GetDiagnosticsTest, Cmd)
+{
+ Item *var;
+ Sql_cmd *cmd;
+ MockDiagInfo *info;
+ MockDiagInfoItem *diag_info_item;
+ List<MockDiagInfoItem> items;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ // set var1 item
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ diag_info_item= new (mem_root) MockDiagInfoItem(var, 1);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // set var2 item
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ diag_info_item= new (mem_root) MockDiagInfoItem(var, 2);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // Information list and command
+ info= new (mem_root) MockDiagInfo(&items);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ EXPECT_FALSE(cmd->execute(thd()));
+ EXPECT_TRUE(thd()->get_stmt_da()->is_ok());
+
+ // check var1 value
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(1, var->val_int());
+
+ // check var2 value
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(2, var->val_int());
+}
+
+
+// Verifies death with a DBUG_ASSERT if target item is not settable.
+//
+// Although Google Test recommends DeathTest suffix for classes used
+// in death tests, this is not done to avoid the server being started
+// more than once.
+#if GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)
+TEST_F(GetDiagnosticsTest, DieWhenUnsettableItem)
+{
+ Item *var;
+ Sql_cmd *cmd;
+ MockDiagInfo *info;
+ MockDiagInfoItem *diag_info_item;
+ List<MockDiagInfoItem> items;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ ::testing::FLAGS_gtest_death_test_style= "threadsafe";
+
+ // Unsettable item
+ var= new (mem_root) Item_int(1);
+ diag_info_item= new (mem_root) MockDiagInfoItem(var, 1);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // Information list and command
+ info= new (mem_root) MockDiagInfo(&items);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ EXPECT_DEATH(cmd->execute(thd()), ".*Assertion.*srp.*");
+}
+#endif // GTEST_HAS_DEATH_TEST && !defined(DBUG_OFF)
+
+
+class MockDiagInfoError : public Diagnostics_information
+{
+public:
+ MockDiagInfoError(bool fatal_error)
+ : m_fatal_error(fatal_error)
+ {}
+
+protected:
+ bool aggregate(THD *thd, const Diagnostics_area *)
+ {
+ myf flag= m_fatal_error ? MYF(ME_FATALERROR) : MYF(0);
+ my_message_sql(ER_UNKNOWN_ERROR, "Unknown error", flag);
+ return thd->is_error();
+ }
+
+private:
+ bool m_fatal_error;
+};
+
+
+// GET DIAGNOSTICS itself causes an error.
+TEST_F(GetDiagnosticsTest, Error)
+{
+ Sql_cmd *cmd;
+ MockDiagInfoError *info;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ // Pre-existing warning
+ push_warning_printf(thd(), Sql_condition::WARN_LEVEL_WARN,
+ WARN_DATA_TRUNCATED, "Data truncated");
+
+ // Simulate GET DIAGNOSTICS as a new command separated
+ // from the one that generated the warning
+ thd()->reset_for_next_command();
+
+ // Error bound "information" and command
+ info= new (mem_root) MockDiagInfoError(false);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ initializer.set_expected_error(ER_UNKNOWN_ERROR);
+
+ // Should succeed, not a fatal error
+ EXPECT_FALSE(cmd->execute(thd()));
+ EXPECT_TRUE(thd()->get_stmt_da()->is_ok());
+
+ // New condition for the error
+ EXPECT_EQ(1U, thd()->get_stmt_da()->statement_warn_count());
+
+ // Counted as a error
+ EXPECT_EQ(1U, thd()->get_stmt_da()->error_count());
+
+ // Error is appended
+ EXPECT_EQ(2U, thd()->get_stmt_da()->warn_count());
+}
+
+
+// GET DIAGNOSTICS itself causes a fatal error.
+TEST_F(GetDiagnosticsTest, FatalError)
+{
+ Sql_cmd *cmd;
+ MockDiagInfoError *info;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ // Pre-existing warning
+ push_warning_printf(thd(), Sql_condition::WARN_LEVEL_WARN,
+ WARN_DATA_TRUNCATED, "Data truncated");
+
+ // Simulate GET DIAGNOSTICS as a new command separated
+ // from the one that generated the warning
+ thd()->reset_for_next_command();
+
+ // Error bound "information" and command
+ info= new (mem_root) MockDiagInfoError(true);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ initializer.set_expected_error(ER_UNKNOWN_ERROR);
+
+ // Should not succeed due to a fatal error
+ EXPECT_TRUE(cmd->execute(thd()));
+ EXPECT_TRUE(thd()->get_stmt_da()->is_error());
+
+ // No new condition for the error
+ EXPECT_EQ(0U, thd()->get_stmt_da()->error_count());
+
+ // Fatal error is set, not appended
+ EXPECT_EQ(1U, thd()->get_stmt_da()->warn_count());
+}
+
+
+// GET [CURRENT] DIAGNOSTICS @var1 = NUMBER, @var2 = ROW_COUNT;
+TEST_F(GetDiagnosticsTest, StatementInformation)
+{
+ Item *var;
+ Sql_cmd *cmd;
+ Statement_information *info;
+ Statement_information_item *diag_info_item;
+ List<Statement_information_item> items;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ // NUMBER = 1 warning
+ thd()->raise_warning(ER_UNKNOWN_ERROR);
+ // ROW_COUNT = 5
+ thd()->set_row_count_func(5U);
+
+ // var1 will receive the value of NUMBER
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ diag_info_item= new (mem_root)
+ Statement_information_item(Statement_information_item::NUMBER, var);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // var2 will receive the value of ROW_COUNT
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ diag_info_item= new (mem_root)
+ Statement_information_item(Statement_information_item::ROW_COUNT, var);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // Information list and command
+ info= new (mem_root) Statement_information(&items);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ EXPECT_FALSE(cmd->execute(thd()));
+ EXPECT_TRUE(thd()->get_stmt_da()->is_ok());
+
+ // check var1 value
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(1U, var->val_uint());
+
+ // check var2 value
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(5U, var->val_int());
+}
+
+
+// GET DIAGNOSTICS CONDITION 1 @var1 = MYSQL_ERRNO, @var2 = MESSAGE_TEXT;
+TEST_F(GetDiagnosticsTest, ConditionInformation)
+{
+ Item *var;
+ String str;
+ Sql_cmd *cmd;
+ Condition_information *info;
+ Condition_information_item *diag_info_item;
+ List<Condition_information_item> items;
+ MEM_ROOT *mem_root= thd()->mem_root;
+
+ // Pre-existing error
+ my_message_sql(ER_UNKNOWN_ERROR, "Unknown error", MYF(0));
+
+ // Simulate GET DIAGNOSTICS as a new command separated
+ // from the one that generated the error
+ thd()->reset_for_next_command();
+
+ // var1 will receive the value of MYSQL_ERRNO
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ diag_info_item= new (mem_root)
+ Condition_information_item(Condition_information_item::MYSQL_ERRNO, var);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // var2 will receive the value of MESSAGE_TEXT
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ diag_info_item= new (mem_root)
+ Condition_information_item(Condition_information_item::MESSAGE_TEXT, var);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // condition number (1)
+ var= new (mem_root) Item_uint(1);
+
+ // Information list and command
+ info= new (mem_root) Condition_information(var, &items);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ EXPECT_FALSE(cmd->execute(thd()));
+ EXPECT_TRUE(thd()->get_stmt_da()->is_ok());
+
+ // check var1 value
+ var= new (mem_root) Item_func_get_user_var(var_name1);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(ulonglong (ER_UNKNOWN_ERROR), var->val_uint());
+
+ // check var2 value
+ var= new (mem_root) Item_func_get_user_var(var_name2);
+ EXPECT_FALSE(var->fix_fields(thd(), &var));
+ EXPECT_EQ(&str, var->val_str(&str));
+ EXPECT_STREQ("Unknown error", str.c_ptr_safe());
+}
+
+
+Item *get_cond_info_item(THD *thd,
+ uint number,
+ Condition_information_item::Name name)
+{
+ Item *var;
+ Sql_cmd *cmd;
+ Condition_information *info;
+ Condition_information_item *diag_info_item;
+ List<Condition_information_item> items;
+ MEM_ROOT *mem_root= thd->mem_root;
+ LEX_STRING var_name= {C_STRING_WITH_LEN("get_cond_info_item")};
+
+ // Simulate GET DIAGNOSTICS as a new command
+ thd->reset_for_next_command();
+
+ // var1 will receive the value of MYSQL_ERRNO
+ var= new (mem_root) Item_func_get_user_var(var_name);
+ diag_info_item= new (mem_root) Condition_information_item(name, var);
+ EXPECT_FALSE(items.push_back(diag_info_item));
+
+ // condition number
+ var= new (mem_root) Item_uint(number);
+
+ // Information list and command
+ info= new (mem_root) Condition_information(var, &items);
+ info->set_which_da(Diagnostics_information::CURRENT_AREA);
+ cmd= new (mem_root) Sql_cmd_get_diagnostics(info);
+
+ EXPECT_FALSE(cmd->execute(thd));
+ EXPECT_TRUE(thd->get_stmt_da()->is_ok());
+
+ // make a user var item
+ var= new (mem_root) Item_func_get_user_var(var_name);
+ EXPECT_FALSE(var->fix_fields(thd, &var));
+
+ return var;
+}
+
+
+// GET DIAGNOSTICS CONDITION 1 @var = CLASS_ORIGIN;
+// GET DIAGNOSTICS CONDITION 1 @var = SUBCLASS_ORIGIN;
+TEST_F(GetDiagnosticsTest, ConditionInformationClassOrigin)
+{
+ Item *var;
+ String str;
+
+ // "MySQL" origin
+ push_warning_printf(thd(), Sql_condition::WARN_LEVEL_WARN,
+ ER_XAER_NOTA, "Unknown XID");
+
+ // "ISO 9075" origin
+ push_warning_printf(thd(), Sql_condition::WARN_LEVEL_WARN,
+ ER_UNKNOWN_ERROR, "Unknown error");
+
+ // Condition 1 CLASS_ORIGIN
+ var= get_cond_info_item(thd(), 1, Condition_information_item::CLASS_ORIGIN);
+ EXPECT_EQ(&str, var->val_str(&str));
+ EXPECT_STREQ("MySQL", str.c_ptr_safe());
+
+ // Condition 1 SUBCLASS_ORIGIN
+ var= get_cond_info_item(thd(), 1, Condition_information_item::SUBCLASS_ORIGIN);
+ EXPECT_EQ(&str, var->val_str(&str));
+ EXPECT_STREQ("MySQL", str.c_ptr_safe());
+
+ // Condition 2 CLASS_ORIGIN
+ var= get_cond_info_item(thd(), 2, Condition_information_item::CLASS_ORIGIN);
+ EXPECT_EQ(&str, var->val_str(&str));
+ EXPECT_STREQ("ISO 9075", str.c_ptr_safe());
+
+ // Condition 2 CLASS_ORIGIN
+ var= get_cond_info_item(thd(), 2, Condition_information_item::SUBCLASS_ORIGIN);
+ EXPECT_EQ(&str, var->val_str(&str));
+ EXPECT_STREQ("ISO 9075", str.c_ptr_safe());
+}
+
+
+}
No bundle (reason: useless for push emails).| Thread |
|---|
| • bzr push into mysql-trunk branch (jon.hauglid:3498 to 3499) WL#2111 | Jon Olav Hauglid | 17 Oct |