From 9d88c5b8b40cce897b0a718584289f8ca331381e Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Tue, 23 Jan 2024 23:56:40 +0400 Subject: [PATCH] MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. The IDENT_sys doesn't include keywords, so the function with the keyword name can be created, but cannot be called. Moving keywords to new rules keyword_func_sp_var_and_label and keyword_func_sp_var_not_label so the functions with these names are allowed. --- mysql-test/main/parser.result | 16 +- mysql-test/main/sp.result | 73 ++++ mysql-test/main/sp.test | 38 ++ .../suite/compat/oracle/r/parser.result | 16 +- mysql-test/suite/funcs_1/r/storedproc.result | 150 ++++++-- mysql-test/suite/funcs_1/t/storedproc.test | 211 ++++++++++- .../suite/perfschema/r/digest_view.result | 50 +-- .../start_server_low_digest_sql_length.result | 4 +- sql/item_create.cc | 346 ++++++++++++++++++ sql/lex.h | 5 - sql/sql_yacc.yy | 243 ++++-------- 11 files changed, 897 insertions(+), 255 deletions(-) diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index 89732e20b40..bf9b8e4b137 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1507,7 +1507,7 @@ BEGIN NOT ATOMIC DECLARE history INT; SET history=10; SELECT history; END SELECT history FROM t1 SELECT history 'alias' FROM t1 SELECT history() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history.history() Error 1630 FUNCTION history.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history DATE FROM t1 @@ -1530,7 +1530,7 @@ BEGIN NOT ATOMIC DECLARE next INT; SET next=10; SELECT next; END SELECT next FROM t1 SELECT next 'alias' FROM t1 SELECT next() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next.next() Error 1630 FUNCTION next.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next DATE FROM t1 @@ -1577,7 +1577,7 @@ BEGIN NOT ATOMIC DECLARE previous INT; SET previous=10; SELECT previous; END SELECT previous FROM t1 SELECT previous 'alias' FROM t1 SELECT previous() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous.previous() Error 1630 FUNCTION previous.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous DATE FROM t1 @@ -1601,7 +1601,7 @@ BEGIN NOT ATOMIC DECLARE system INT; SET system=10; SELECT system; END SELECT system FROM t1 SELECT system 'alias' FROM t1 SELECT system() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system.system() Error 1630 FUNCTION system.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system DATE FROM t1 @@ -1624,7 +1624,7 @@ BEGIN NOT ATOMIC DECLARE system_time INT; SET system_time=10; SELECT system_time SELECT system_time FROM t1 SELECT system_time 'alias' FROM t1 SELECT system_time() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time.system_time() Error 1630 FUNCTION system_time.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time DATE FROM t1 @@ -1695,7 +1695,7 @@ BEGIN NOT ATOMIC DECLARE transaction INT; SET transaction=10; SELECT transaction SELECT transaction FROM t1 SELECT transaction 'alias' FROM t1 SELECT transaction() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction.transaction() Error 1630 FUNCTION transaction.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction DATE FROM t1 @@ -1741,7 +1741,7 @@ BEGIN NOT ATOMIC DECLARE versioning INT; SET versioning=10; SELECT versioning; E SELECT versioning FROM t1 SELECT versioning 'alias' FROM t1 SELECT versioning() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning.versioning() Error 1630 FUNCTION versioning.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning DATE FROM t1 @@ -1764,7 +1764,7 @@ BEGIN NOT ATOMIC DECLARE without INT; SET without=10; SELECT without; END SELECT without FROM t1 SELECT without 'alias' FROM t1 SELECT without() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without.without() Error 1630 FUNCTION without.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without DATE FROM t1 diff --git a/mysql-test/main/sp.result b/mysql-test/main/sp.result index 4e93973782f..f33fbc84f30 100644 --- a/mysql-test/main/sp.result +++ b/mysql-test/main/sp.result @@ -9008,4 +9008,77 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a r.a 1 SET SESSION log_slow_verbosity= @tmp; +# +# MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +# +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'empty' has the same name as a native function +SELECT empty('1'); +empty('1') +0 +Warnings: +Note 1585 This function 'empty' has the same name as a native function +DROP FUNCTION empty; +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +SELECT json_table('1'); +json_table('1') +0 +Warnings: +Note 1585 This function 'json_table' has the same name as a native function +DROP FUNCTION json_table; +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'nested' has the same name as a native function +SELECT nested('1'); +nested('1') +0 +Warnings: +Note 1585 This function 'nested' has the same name as a native function +DROP FUNCTION nested; +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +SELECT ordinality('1'); +ordinality('1') +0 +Warnings: +Note 1585 This function 'ordinality' has the same name as a native function +DROP FUNCTION ordinality; +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'path' has the same name as a native function +SELECT path('1'); +path('1') +0 +Warnings: +Note 1585 This function 'path' has the same name as a native function +DROP FUNCTION path; +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'fast' has the same name as a native function +SELECT fast('1'); +fast('1') +0 +Warnings: +Note 1585 This function 'fast' has the same name as a native function +DROP FUNCTION fast; +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +Warnings: +Note 1585 This function 'relay' has the same name as a native function +SELECT relay('1'); +relay('1') +0 +Warnings: +Note 1585 This function 'relay' has the same name as a native function +DROP FUNCTION relay; +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +Warnings: +Note 1585 This function 'database' has the same name as a native function +SELECT database(); +database() +test +DROP FUNCTION database; DROP TABLE t1; diff --git a/mysql-test/main/sp.test b/mysql-test/main/sp.test index cc244a20014..5a794e46cd2 100644 --- a/mysql-test/main/sp.test +++ b/mysql-test/main/sp.test @@ -10618,6 +10618,44 @@ BEGIN NOT ATOMIC DECLARE r ROW TYPE OF t1 DEFAULT (SELECT * FROM t1); SELECT r.a --delimiter ; SET SESSION log_slow_verbosity= @tmp; + +--echo # +--echo # MDEV-31616 Problems with a stored function EMPTY() on upgrade to 10.6. +--echo # +CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT empty('1'); +DROP FUNCTION empty; + +CREATE OR REPLACE FUNCTION json_table(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT json_table('1'); +DROP FUNCTION json_table; + +CREATE OR REPLACE FUNCTION nested(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT nested('1'); +DROP FUNCTION nested; + +CREATE OR REPLACE FUNCTION ordinality(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT ordinality('1'); +DROP FUNCTION ordinality; + +CREATE OR REPLACE FUNCTION path(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT path('1'); +DROP FUNCTION path; + + +CREATE OR REPLACE FUNCTION fast(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT fast('1'); +DROP FUNCTION fast; + +CREATE OR REPLACE FUNCTION relay(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0; +SELECT relay('1'); +DROP FUNCTION relay; + +CREATE OR REPLACE FUNCTION database() RETURNS int RETURN 333; +SELECT database(); +DROP FUNCTION database; + + # Cleanup DROP TABLE t1; diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 32ea444ea25..0944b7f39bd 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -84,7 +84,7 @@ DECLARE history INT; BEGIN history:=10; SELECT history; END SELECT history FROM t1 SELECT history 'alias' FROM t1 SELECT history() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history.history() Error 1630 FUNCTION history.history does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT history DATE FROM t1 @@ -106,7 +106,7 @@ DECLARE next INT; BEGIN next:=10; SELECT next; END SELECT next FROM t1 SELECT next 'alias' FROM t1 SELECT next() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next.next() Error 1630 FUNCTION next.next does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT next DATE FROM t1 @@ -151,7 +151,7 @@ DECLARE previous INT; BEGIN previous:=10; SELECT previous; END SELECT previous FROM t1 SELECT previous 'alias' FROM t1 SELECT previous() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous.previous() Error 1630 FUNCTION previous.previous does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT previous DATE FROM t1 @@ -174,7 +174,7 @@ DECLARE system INT; BEGIN system:=10; SELECT system; END SELECT system FROM t1 SELECT system 'alias' FROM t1 SELECT system() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system.system() Error 1630 FUNCTION system.system does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system DATE FROM t1 @@ -196,7 +196,7 @@ DECLARE system_time INT; BEGIN system_time:=10; SELECT system_time; END SELECT system_time FROM t1 SELECT system_time 'alias' FROM t1 SELECT system_time() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time.system_time() Error 1630 FUNCTION system_time.system_time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT system_time DATE FROM t1 @@ -264,7 +264,7 @@ DECLARE transaction INT; BEGIN transaction:=10; SELECT transaction; END SELECT transaction FROM t1 SELECT transaction 'alias' FROM t1 SELECT transaction() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction.transaction() Error 1630 FUNCTION transaction.transaction does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT transaction DATE FROM t1 @@ -308,7 +308,7 @@ DECLARE versioning INT; BEGIN versioning:=10; SELECT versioning; END SELECT versioning FROM t1 SELECT versioning 'alias' FROM t1 SELECT versioning() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning.versioning() Error 1630 FUNCTION versioning.versioning does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT versioning DATE FROM t1 @@ -330,7 +330,7 @@ DECLARE without INT; BEGIN without:=10; SELECT without; END SELECT without FROM t1 SELECT without 'alias' FROM t1 SELECT without() -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '()' at line 1 +Error 1630 FUNCTION test.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without.without() Error 1630 FUNCTION without.without does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual SELECT without DATE FROM t1 diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index c9f92d51210..3d33181c121 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -2088,9 +2088,11 @@ SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'cursor() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE database() -SELECT * from t1 where f2=f1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database() -SELECT * from t1 where f2=f1' at line 1 +SELECT 1; +CALL database(); +1 +1 +DROP PROCEDURE database; CREATE PROCEDURE databases() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'databases() @@ -2350,6 +2352,12 @@ CREATE PROCEDURE join() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'join() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE json_table() +SELECT 1; +CALL json_table(); +1 +1 +DROP PROCEDURE json_table; CREATE PROCEDURE key() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key() @@ -2470,6 +2478,12 @@ CREATE PROCEDURE natural() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'natural() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE nested() +SELECT 1; +CALL nested(); +1 +1 +DROP PROCEDURE nested; CREATE PROCEDURE not() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not() @@ -2509,6 +2523,12 @@ CREATE PROCEDURE order() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'order() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE ordinality() +SELECT 1; +CALL ordinality; +1 +1 +DROP PROCEDURE ordinality; CREATE PROCEDURE out() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'out() @@ -2521,6 +2541,12 @@ CREATE PROCEDURE outfile() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'outfile() SELECT * from t1 where f2=f1' at line 1 +CREATE PROCEDURE path() +SELECT 1; +CALL path(); +1 +1 +DROP PROCEDURE path; CREATE PROCEDURE precision() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'precision() @@ -2602,9 +2628,11 @@ SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'rlike() SELECT * from t1 where f2=f1' at line 1 CREATE PROCEDURE schema() -SELECT * from t1 where f2=f1; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schema() -SELECT * from t1 where f2=f1' at line 1 +SELECT 1; +CALL schema(); +1 +1 +DROP PROCEDURE schema; CREATE PROCEDURE schemas() SELECT * from t1 where f2=f1; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schemas() @@ -4204,9 +4232,6 @@ CREATE PROCEDURE sp1() database:BEGIN SELECT @x; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database:BEGIN -SELECT @x; -END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() databases:BEGIN @@ -4737,6 +4762,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +json_table:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() key:BEGIN SELECT @x; END// @@ -4977,6 +5007,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +nested:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() not:BEGIN SELECT @x; END// @@ -5057,6 +5092,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +ordinality:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() out:BEGIN SELECT @x; END// @@ -5081,6 +5121,11 @@ SELECT @x; END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() +path:BEGIN +SELECT @x; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() precision:BEGIN SELECT @x; END// @@ -5253,9 +5298,6 @@ CREATE PROCEDURE sp1() schema:BEGIN SELECT @x; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schema:BEGIN -SELECT @x; -END' at line 2 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() schemas:BEGIN @@ -7811,8 +7853,6 @@ CREATE PROCEDURE sp1() BEGIN declare database char; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database char; -END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN @@ -8278,6 +8318,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare json_table char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare key char; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key char; @@ -8488,6 +8533,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare nested char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare not char; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not char; @@ -8556,6 +8606,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare ordinality char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare out char; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'out char; @@ -8577,6 +8632,11 @@ END' at line 3 DROP PROCEDURE IF EXISTS sp1; CREATE PROCEDURE sp1() BEGIN +declare path char; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1() +BEGIN declare precision char; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'precision char; @@ -8745,11 +8805,7 @@ CREATE PROCEDURE sp1() BEGIN declare schema char; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schema char; -END' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1() BEGIN declare schemas char; @@ -9704,11 +9760,7 @@ BEGIN declare database condition for sqlstate '02000'; declare exit handler for database set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database condition for sqlstate '02000'; -declare exit handler for database se...' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN declare databases condition for sqlstate '02000'; @@ -10372,6 +10424,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare json_table condition for sqlstate '02000'; +declare exit handler for json_table set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare key condition for sqlstate '02000'; declare exit handler for key set @var2 = 1; END// @@ -10672,6 +10730,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare nested condition for sqlstate '02000'; +declare exit handler for nested set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare not condition for sqlstate '02000'; declare exit handler for not set @var2 = 1; END// @@ -10768,6 +10832,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare ordinality condition for sqlstate '02000'; +declare exit handler for ordinality set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare out condition for sqlstate '02000'; declare exit handler for out set @var2 = 1; END// @@ -10798,6 +10868,12 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare path condition for sqlstate '02000'; +declare exit handler for path set @var2 = 1; +END// +DROP PROCEDURE sp1; +CREATE PROCEDURE sp1( ) +BEGIN declare precision condition for sqlstate '02000'; declare exit handler for precision set @var2 = 1; END// @@ -11021,11 +11097,7 @@ BEGIN declare schema condition for sqlstate '02000'; declare exit handler for schema set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schema condition for sqlstate '02000'; -declare exit handler for schema set @v...' at line 3 DROP PROCEDURE IF EXISTS sp1; -Warnings: -Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN declare schemas condition for sqlstate '02000'; @@ -11974,8 +12046,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare database handler for sqlstate '02000' set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'database handler for sqlstate '02000' set @var2 = 1; -END' at line 3 +ERROR HY000: Unknown data type: 'handler' DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist @@ -12571,6 +12642,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare json_table handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare key handler for sqlstate '02000' set @var2 = 1; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'key handler for sqlstate '02000' set @var2 = 1; @@ -12841,6 +12917,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare nested handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare not handler for sqlstate '02000' set @var2 = 1; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'not handler for sqlstate '02000' set @var2 = 1; @@ -12930,6 +13011,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare ordinality handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare out handler for sqlstate '02000' set @var2 = 1; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'out handler for sqlstate '02000' set @var2 = 1; @@ -12957,6 +13043,11 @@ Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist CREATE PROCEDURE sp1( ) BEGIN +declare path handler for sqlstate '02000' set @var2 = 1; +END// +ERROR HY000: Unknown data type: 'handler' +CREATE PROCEDURE sp1( ) +BEGIN declare precision handler for sqlstate '02000' set @var2 = 1; END// ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'precision handler for sqlstate '02000' set @var2 = 1; @@ -13164,8 +13255,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare schema handler for sqlstate '02000' set @var2 = 1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'schema handler for sqlstate '02000' set @var2 = 1; -END' at line 3 +ERROR HY000: Unknown data type: 'handler' DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test index 8712919e430..e9c00742f01 100644 --- a/mysql-test/suite/funcs_1/t/storedproc.test +++ b/mysql-test/suite/funcs_1/t/storedproc.test @@ -1102,9 +1102,11 @@ CREATE PROCEDURE current_user() CREATE PROCEDURE cursor() SELECT * from t1 where f2=f1; ---error ER_PARSE_ERROR CREATE PROCEDURE database() - SELECT * from t1 where f2=f1; + SELECT 1; + +CALL database(); +DROP PROCEDURE database; --error ER_PARSE_ERROR CREATE PROCEDURE databases() @@ -1367,6 +1369,12 @@ CREATE PROCEDURE iterate() CREATE PROCEDURE join() SELECT * from t1 where f2=f1; +CREATE PROCEDURE json_table() + SELECT 1; + +CALL json_table(); +DROP PROCEDURE json_table; + --error ER_PARSE_ERROR CREATE PROCEDURE key() SELECT * from t1 where f2=f1; @@ -1487,6 +1495,13 @@ CREATE PROCEDURE modifies() CREATE PROCEDURE natural() SELECT * from t1 where f2=f1; +CREATE PROCEDURE nested() + SELECT 1; + +CALL nested(); + +DROP PROCEDURE nested; + --error ER_PARSE_ERROR CREATE PROCEDURE not() SELECT * from t1 where f2=f1; @@ -1527,6 +1542,13 @@ CREATE PROCEDURE or() CREATE PROCEDURE order() SELECT * from t1 where f2=f1; +CREATE PROCEDURE ordinality() + SELECT 1; + +CALL ordinality; + +DROP PROCEDURE ordinality; + --error ER_PARSE_ERROR CREATE PROCEDURE out() SELECT * from t1 where f2=f1; @@ -1539,6 +1561,13 @@ CREATE PROCEDURE outer() CREATE PROCEDURE outfile() SELECT * from t1 where f2=f1; +CREATE PROCEDURE path() + SELECT 1; + +CALL path(); + +DROP PROCEDURE path; + --error ER_PARSE_ERROR CREATE PROCEDURE precision() SELECT * from t1 where f2=f1; @@ -1619,9 +1648,11 @@ CREATE PROCEDURE right() CREATE PROCEDURE rlike() SELECT * from t1 where f2=f1; ---error ER_PARSE_ERROR CREATE PROCEDURE schema() - SELECT * from t1 where f2=f1; + SELECT 1; + +CALL schema(); +DROP PROCEDURE schema; --error ER_PARSE_ERROR CREATE PROCEDURE schemas() @@ -3481,7 +3512,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() database:BEGIN SELECT @x; @@ -4284,6 +4315,15 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; +CREATE PROCEDURE sp1() + json_table:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4644,6 +4684,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + nested:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4765,6 +4815,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + ordinality:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -4801,6 +4861,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() + path:BEGIN + SELECT @x; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -5066,7 +5136,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() schema:BEGIN SELECT @x; @@ -8938,7 +9008,7 @@ DROP PROCEDURE IF EXISTS sp1; --enable_warnings delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() BEGIN declare database char; @@ -9736,11 +9806,20 @@ BEGIN declare join char; END// delimiter ;// - --disable_warnings DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare json_table char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10101,6 +10180,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare nested char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10220,6 +10309,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare ordinality char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10256,6 +10355,16 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; --enable_warnings +delimiter //; + +CREATE PROCEDURE sp1() +BEGIN + declare path char; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1() @@ -10506,7 +10615,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1() BEGIN declare schema char; @@ -11624,7 +11733,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare database condition for sqlstate '02000'; @@ -12360,6 +12469,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare json_table condition for sqlstate '02000'; + declare exit handler for json_table set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12690,6 +12810,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare nested condition for sqlstate '02000'; + declare exit handler for nested set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12799,6 +12930,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare ordinality condition for sqlstate '02000'; + declare exit handler for ordinality set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -12832,6 +12974,17 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; + +CREATE PROCEDURE sp1( ) +BEGIN + declare path condition for sqlstate '02000'; + declare exit handler for path set @var2 = 1; +END// +delimiter ;// + +DROP PROCEDURE sp1; + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -13075,7 +13228,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare schema condition for sqlstate '02000'; @@ -14181,7 +14334,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR + CREATE PROCEDURE sp1( ) BEGIN declare database handler for sqlstate '02000' set @var2 = 1; @@ -14850,6 +15003,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare json_table handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15150,6 +15311,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare nested handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15250,6 +15419,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare ordinality handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15280,6 +15457,14 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; +delimiter //; +--error ER_UNKNOWN_DATA_TYPE +CREATE PROCEDURE sp1( ) +BEGIN + declare path handler for sqlstate '02000' set @var2 = 1; +END// +delimiter ;// + delimiter //; --error ER_PARSE_ERROR CREATE PROCEDURE sp1( ) @@ -15511,7 +15696,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR +--error ER_UNKNOWN_DATA_TYPE CREATE PROCEDURE sp1( ) BEGIN declare schema handler for sqlstate '02000' set @var2 = 1; diff --git a/mysql-test/suite/perfschema/r/digest_view.result b/mysql-test/suite/perfschema/r/digest_view.result index f3b5d9edcaa..cbaf9469829 100644 --- a/mysql-test/suite/perfschema/r/digest_view.result +++ b/mysql-test/suite/perfschema/r/digest_view.result @@ -191,17 +191,17 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test 6792f631a33c9aa30f74fc4a1ac00d0d EXPLAIN SELECT * FROM `test` . `v1` 1 -test 1a904f6e400d36fc3277347dc3dd7e3b EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test 84b4a595b190b7b2be65930719a5f217 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test c2fbbef6771c0d94bc0bda68b083c2ee EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 -test 89124df2148819b870c1d648f748b1ad EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 -test 02270358998b539b9b11f709b372eda9 SELECT * FROM `test` . `v1` 1 -test e42e0a8f9dd70f815fd3b1323ae4d07d SELECT * FROM `test` . `v1` WHERE `a` = ? 1 -test f549d4607e65f96ae2bc4dc4f70965dd SELECT * FROM `test` . `v1` WHERE `b` > ? 1 -test d0ca89f87d46b19d6823e9c3d8fcc4f3 SELECT `a` , `b` FROM `test` . `v1` 1 -test 3599e7d908d651cd2b3410656f0a9a85 SELECT `b` , `a` FROM `test` . `v1` 1 -test 579dc8800f4005f131faf0202bfd383f TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +test 370e7bef18915f6611ac6d260774b983 EXPLAIN SELECT * FROM `test` . `v1` 1 +test 234d37a98244d9c8e7ddc95d8d615b67 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test 3dbb0324b7aa42191a45415438f0664b EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test c4a754140ab2b645514868c727428aa0 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 1 +test 534e1e8b3fdd54ac7950a9c0c049d67b EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 1 +test 6b928d386834bf77fb56d6917a66b3b3 SELECT * FROM `test` . `v1` 1 +test 914e5e0b02604c846266f1941ca5c99c SELECT * FROM `test` . `v1` WHERE `a` = ? 1 +test e037e9baeb863981ceed07178b82d85c SELECT * FROM `test` . `v1` WHERE `b` > ? 1 +test 1e4dbc9041d1c2c6ef0aee7bb10a9712 SELECT `a` , `b` FROM `test` . `v1` 1 +test ce9abb5b3de1de61ca0c7bed9bd8e268 SELECT `b` , `a` FROM `test` . `v1` 1 +test 8117308957580606865e284265d48615 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP TABLE test.v1; CREATE VIEW test.v1 AS SELECT * FROM test.t1; EXPLAIN SELECT * from test.v1; @@ -248,19 +248,19 @@ SELECT SCHEMA_NAME, DIGEST, DIGEST_TEXT, COUNT_STAR FROM performance_schema.events_statements_summary_by_digest ORDER BY DIGEST_TEXT; SCHEMA_NAME DIGEST DIGEST_TEXT COUNT_STAR -test 1d9b60541940c07a0731da3a7e4b3710 CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 -test c3a18ebfa01b069ce0cbcf1d3c3a28fd DROP TABLE `test` . `v1` 1 -test 6792f631a33c9aa30f74fc4a1ac00d0d EXPLAIN SELECT * FROM `test` . `v1` 2 -test 1a904f6e400d36fc3277347dc3dd7e3b EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test 84b4a595b190b7b2be65930719a5f217 EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test c2fbbef6771c0d94bc0bda68b083c2ee EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 -test 89124df2148819b870c1d648f748b1ad EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 -test 02270358998b539b9b11f709b372eda9 SELECT * FROM `test` . `v1` 2 -test e42e0a8f9dd70f815fd3b1323ae4d07d SELECT * FROM `test` . `v1` WHERE `a` = ? 2 -test f549d4607e65f96ae2bc4dc4f70965dd SELECT * FROM `test` . `v1` WHERE `b` > ? 2 -test 279f05780dfbf44c1b9c444c4a3d7f81 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 -test d0ca89f87d46b19d6823e9c3d8fcc4f3 SELECT `a` , `b` FROM `test` . `v1` 2 -test 3599e7d908d651cd2b3410656f0a9a85 SELECT `b` , `a` FROM `test` . `v1` 2 -test 579dc8800f4005f131faf0202bfd383f TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 +test aacd39adbd408fe1250208d032ce0bed CREATE VIEW `test` . `v1` AS SELECT * FROM `test` . `t1` 1 +test b7905ad078429428effa41db5d58c43e DROP TABLE `test` . `v1` 1 +test 370e7bef18915f6611ac6d260774b983 EXPLAIN SELECT * FROM `test` . `v1` 2 +test 234d37a98244d9c8e7ddc95d8d615b67 EXPLAIN SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test 3dbb0324b7aa42191a45415438f0664b EXPLAIN SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test c4a754140ab2b645514868c727428aa0 EXPLAIN SELECT `a` , `b` FROM `test` . `v1` 2 +test 534e1e8b3fdd54ac7950a9c0c049d67b EXPLAIN SELECT `b` , `a` FROM `test` . `v1` 2 +test 6b928d386834bf77fb56d6917a66b3b3 SELECT * FROM `test` . `v1` 2 +test 914e5e0b02604c846266f1941ca5c99c SELECT * FROM `test` . `v1` WHERE `a` = ? 2 +test e037e9baeb863981ceed07178b82d85c SELECT * FROM `test` . `v1` WHERE `b` > ? 2 +test ac0e7e062fb2eecae26f4e432cde3dd3 SELECT SCHEMA_NAME , `DIGEST` , `DIGEST_TEXT` , `COUNT_STAR` FROM `performance_schema` . `events_statements_summary_by_digest` ORDER BY `DIGEST_TEXT` 1 +test 1e4dbc9041d1c2c6ef0aee7bb10a9712 SELECT `a` , `b` FROM `test` . `v1` 2 +test ce9abb5b3de1de61ca0c7bed9bd8e268 SELECT `b` , `a` FROM `test` . `v1` 2 +test 8117308957580606865e284265d48615 TRUNCATE TABLE `performance_schema` . `events_statements_summary_by_digest` 1 DROP VIEW test.v1; DROP TABLE test.t1; diff --git a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result index 3cca1764ec4..c2f2547ed49 100644 --- a/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result +++ b/mysql-test/suite/perfschema/r/start_server_low_digest_sql_length.result @@ -8,5 +8,5 @@ SELECT 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1 #################################### SELECT event_name, digest, digest_text, sql_text FROM events_statements_history_long; event_name digest digest_text sql_text -statement/sql/select bb82f2829bcdfd9ac1e53f7b27829d36 SELECT ? + ? + SELECT ... -statement/sql/truncate 86a7d96b41a68b8dfb6c94888bd3bb76 TRUNCATE TABLE truncat... +statement/sql/select 3ff8cd05d2991a9ac9b182801987d61e SELECT ? + ? + SELECT ... +statement/sql/truncate eddd22a5c210f96a5160acbb5d7563b3 TRUNCATE TABLE truncat... diff --git a/sql/item_create.cc b/sql/item_create.cc index 794e65a31a6..f15b343b127 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -127,6 +127,19 @@ protected: }; +class Create_func_addmonths : public Create_func_arg2 +{ +public: + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); + + static Create_func_addmonths s_singleton; + +protected: + Create_func_addmonths() = default; + virtual ~Create_func_addmonths() = default; +}; + + class Create_func_aes_encrypt : public Create_func_arg2 { public: @@ -258,6 +271,19 @@ protected: }; +class Create_func_collation : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_collation s_singleton; + +protected: + Create_func_collation() = default; + virtual ~Create_func_collation() = default; +}; + + class Create_func_chr : public Create_func_arg1 { public: @@ -345,6 +371,20 @@ protected: }; +class Create_func_coalesce : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_coalesce s_singleton; + +protected: + Create_func_coalesce() = default; + virtual ~Create_func_coalesce() = default; +}; + + class Create_func_compress : public Create_func_arg1 { public: @@ -472,6 +512,19 @@ protected: }; +class Create_func_database : public Create_func_arg0 +{ +public: + virtual Item *create_builder(THD *thd); + + static Create_func_database s_singleton; + +protected: + Create_func_database() = default; + virtual ~Create_func_database() = default; +}; + + class Create_func_nvl2 : public Create_func_arg3 { public: @@ -563,6 +616,22 @@ protected: }; +class Create_func_date_format : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_date_format s_singleton; + +protected: + Create_func_date_format() = default; + virtual ~Create_func_date_format() = default; +}; + + + + class Create_func_dayname : public Create_func_arg1 { public: @@ -1382,6 +1451,31 @@ protected: virtual ~Create_func_octet_length() = default; }; +class Create_func_old_password : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_old_password s_singleton; + +protected: + Create_func_old_password() = default; + virtual ~Create_func_old_password() = default; +}; + + +class Create_func_password : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_password s_singleton; + +protected: + Create_func_password() = default; + virtual ~Create_func_password() = default; +}; + #ifndef DBUG_OFF class Create_func_like_range_min : public Create_func_arg2 @@ -1630,6 +1724,32 @@ protected: }; +class Create_func_microsecond : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_microsecond s_singleton; + +protected: + Create_func_microsecond() = default; + virtual ~Create_func_microsecond() = default; +}; + + +class Create_func_mod : public Create_func_arg2 +{ +public: + virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2); + + static Create_func_mod s_singleton; + +protected: + Create_func_mod() = default; + virtual ~Create_func_mod() = default; +}; + + class Create_func_monthname : public Create_func_arg1 { public: @@ -1747,6 +1867,19 @@ protected: }; +class Create_func_quarter : public Create_func_arg1 +{ +public: + virtual Item *create_1_arg(THD *thd, Item *arg1); + + static Create_func_quarter s_singleton; + +protected: + Create_func_quarter() = default; + virtual ~Create_func_quarter() = default; +}; + + class Create_func_quote : public Create_func_arg1 { public: @@ -1888,6 +2021,19 @@ protected: }; +class Create_func_row_count : public Create_func_arg0 +{ +public: + virtual Item *create_builder(THD *thd); + + static Create_func_row_count s_singleton; + +protected: + Create_func_row_count() = default; + virtual ~Create_func_row_count() = default; +}; + + class Create_func_rpad : public Create_native_func { public: @@ -2349,6 +2495,20 @@ protected: }; +class Create_func_week : public Create_native_func +{ +public: + virtual Item *create_native(THD *thd, const LEX_CSTRING *name, + List *item_list); + + static Create_func_week s_singleton; + +protected: + Create_func_week() = default; + virtual ~Create_func_week() = default; +}; + + class Create_func_weekday : public Create_func_arg1 { public: @@ -2828,6 +2988,16 @@ Create_func_addtime::create_2_arg(THD *thd, Item *arg1, Item *arg2) } +Create_func_addmonths Create_func_addmonths::s_singleton; + +Item* +Create_func_addmonths::create_2_arg(THD *thd, Item *arg1, Item *arg2) +{ + return new (thd->mem_root) + Item_date_add_interval(thd, arg1, arg2, INTERVAL_MONTH, false); +} + + Create_func_aes_encrypt Create_func_aes_encrypt::s_singleton; Item* @@ -2957,6 +3127,15 @@ Create_func_ceiling::create_1_arg(THD *thd, Item *arg1) } +Create_func_collation Create_func_collation::s_singleton; + +Item* +Create_func_collation::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_collation(thd, arg1); +} + + Create_func_chr Create_func_chr::s_singleton; Item* @@ -3017,6 +3196,26 @@ Create_func_dyncol_json::create_1_arg(THD *thd, Item *arg1) return new (thd->mem_root) Item_func_dyncol_json(thd, arg1); } +Create_func_coalesce Create_func_coalesce::s_singleton; + +Item* +Create_func_coalesce::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + if (unlikely(arg_count < 1)) + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; + } + + return new (thd->mem_root) Item_func_coalesce(thd, *item_list); +} + Create_func_concat Create_func_concat::s_singleton; Item* @@ -3111,6 +3310,16 @@ Create_func_connection_id::create_builder(THD *thd) } +Create_func_database Create_func_database::s_singleton; + +Item* +Create_func_database::create_builder(THD *thd) +{ + thd->lex->safe_to_cache_query= 0; + return new (thd->mem_root) Item_func_database(thd); +} + + Create_func_nvl2 Create_func_nvl2::s_singleton; Item* @@ -3175,6 +3384,37 @@ Create_func_datediff::create_2_arg(THD *thd, Item *arg1, Item *arg2) return new (thd->mem_root) Item_func_minus(thd, i1, i2); } +Create_func_date_format Create_func_date_format::s_singleton; + +Item* +Create_func_date_format::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + return new (thd->mem_root) Item_func_date_format(thd, param_1, param_2); + } + case 3: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + Item *param_3= item_list->pop(); + return new (thd->mem_root) Item_func_date_format(thd, + param_1, param_2, param_3); + } + } + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + return NULL; +} + Create_func_dayname Create_func_dayname::s_singleton; @@ -4289,6 +4529,23 @@ Create_func_length::create_1_arg(THD *thd, Item *arg1) return new (thd->mem_root) Item_func_octet_length(thd, arg1); } +Create_func_old_password Create_func_old_password::s_singleton; + +Item* +Create_func_old_password::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_password(thd, arg1, + Item_func_password::OLD); +} + +Create_func_password Create_func_password::s_singleton; + +Item* +Create_func_password::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_password(thd, arg1); +} + Create_func_octet_length Create_func_octet_length::s_singleton; Item* @@ -4657,6 +4914,24 @@ Create_func_md5::create_1_arg(THD *thd, Item *arg1) } +Create_func_microsecond Create_func_microsecond::s_singleton; + +Item* +Create_func_microsecond::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_microsecond(thd, arg1); +} + + +Create_func_mod Create_func_mod::s_singleton; + +Item* +Create_func_mod::create_2_arg(THD *thd, Item *arg1, Item *arg2) +{ + return new (thd->mem_root) Item_func_mod(thd, arg1, arg2); +} + + Create_func_monthname Create_func_monthname::s_singleton; Item* @@ -4759,6 +5034,15 @@ Create_func_pow::create_2_arg(THD *thd, Item *arg1, Item *arg2) } +Create_func_quarter Create_func_quarter::s_singleton; + +Item* +Create_func_quarter::create_1_arg(THD *thd, Item *arg1) +{ + return new (thd->mem_root) Item_func_quarter(thd, arg1); +} + + Create_func_quote Create_func_quote::s_singleton; Item* @@ -4934,6 +5218,17 @@ Create_func_round::create_native(THD *thd, const LEX_CSTRING *name, } +Create_func_row_count Create_func_row_count::s_singleton; + +Item* +Create_func_row_count::create_builder(THD *thd) +{ + thd->lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); + thd->lex->safe_to_cache_query= 0; + return new (thd->mem_root) Item_func_row_count(thd); +} + + Create_func_rpad Create_func_rpad::s_singleton; Create_func_rpad_oracle Create_func_rpad_oracle::s_singleton; @@ -5391,6 +5686,43 @@ Create_func_version::create_builder(THD *thd) } +Create_func_week Create_func_week::s_singleton; + +Item* +Create_func_week::create_native(THD *thd, const LEX_CSTRING *name, + List *item_list) +{ + Item* func= NULL; + int arg_count= 0; + + if (item_list != NULL) + arg_count= item_list->elements; + + switch (arg_count) { + case 1: + { + Item *param_1= item_list->pop(); + func= new (thd->mem_root) Item_func_week(thd, param_1); + break; + } + case 2: + { + Item *param_1= item_list->pop(); + Item *param_2= item_list->pop(); + func= new (thd->mem_root) Item_func_week(thd, param_1, param_2); + break; + } + default: + { + my_error(ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT, MYF(0), name->str); + break; + } + } + + return func; +} + + Create_func_weekday Create_func_weekday::s_singleton; Item* @@ -5541,6 +5873,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("ABS") }, BUILDER(Create_func_abs)}, { { STRING_WITH_LEN("ACOS") }, BUILDER(Create_func_acos)}, { { STRING_WITH_LEN("ADDTIME") }, BUILDER(Create_func_addtime)}, + { { STRING_WITH_LEN("ADD_MONTHS") }, BUILDER(Create_func_addmonths)}, { { STRING_WITH_LEN("AES_DECRYPT") }, BUILDER(Create_func_aes_decrypt)}, { { STRING_WITH_LEN("AES_ENCRYPT") }, BUILDER(Create_func_aes_encrypt)}, { { STRING_WITH_LEN("ASIN") }, BUILDER(Create_func_asin)}, @@ -5556,7 +5889,9 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("CHARACTER_LENGTH") }, BUILDER(Create_func_char_length)}, { { STRING_WITH_LEN("CHAR_LENGTH") }, BUILDER(Create_func_char_length)}, { { STRING_WITH_LEN("CHR") }, BUILDER(Create_func_chr)}, + { { STRING_WITH_LEN("COALESCE") }, BUILDER(Create_func_coalesce)}, { { STRING_WITH_LEN("COERCIBILITY") }, BUILDER(Create_func_coercibility)}, + { { STRING_WITH_LEN("COLLATION") }, BUILDER(Create_func_collation)}, { { STRING_WITH_LEN("COLUMN_CHECK") }, BUILDER(Create_func_dyncol_check)}, { { STRING_WITH_LEN("COLUMN_EXISTS") }, BUILDER(Create_func_dyncol_exists)}, { { STRING_WITH_LEN("COLUMN_LIST") }, BUILDER(Create_func_dyncol_list)}, @@ -5571,7 +5906,9 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("COS") }, BUILDER(Create_func_cos)}, { { STRING_WITH_LEN("COT") }, BUILDER(Create_func_cot)}, { { STRING_WITH_LEN("CRC32") }, BUILDER(Create_func_crc32)}, + { { STRING_WITH_LEN("DATABASE") }, BUILDER(Create_func_database)}, { { STRING_WITH_LEN("DATEDIFF") }, BUILDER(Create_func_datediff)}, + { { STRING_WITH_LEN("DATE_FORMAT") }, BUILDER(Create_func_date_format)}, { { STRING_WITH_LEN("DAYNAME") }, BUILDER(Create_func_dayname)}, { { STRING_WITH_LEN("DAYOFMONTH") }, BUILDER(Create_func_dayofmonth)}, { { STRING_WITH_LEN("DAYOFWEEK") }, BUILDER(Create_func_dayofweek)}, @@ -5660,6 +5997,8 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("MASTER_GTID_WAIT") }, BUILDER(Create_func_master_gtid_wait)}, { { STRING_WITH_LEN("MASTER_POS_WAIT") }, BUILDER(Create_func_master_pos_wait)}, { { STRING_WITH_LEN("MD5") }, BUILDER(Create_func_md5)}, + { { STRING_WITH_LEN("MICROSECOND") }, BUILDER(Create_func_microsecond)}, + { { STRING_WITH_LEN("MOD") }, BUILDER(Create_func_mod)}, { { STRING_WITH_LEN("MONTHNAME") }, BUILDER(Create_func_monthname)}, { { STRING_WITH_LEN("NAME_CONST") }, BUILDER(Create_func_name_const)}, { { STRING_WITH_LEN("NVL") }, BUILDER(Create_func_ifnull)}, @@ -5667,12 +6006,15 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("NULLIF") }, BUILDER(Create_func_nullif)}, { { STRING_WITH_LEN("OCT") }, BUILDER(Create_func_oct)}, { { STRING_WITH_LEN("OCTET_LENGTH") }, BUILDER(Create_func_octet_length)}, + { { STRING_WITH_LEN("OLD_PASSWORD") }, BUILDER(Create_func_old_password)}, { { STRING_WITH_LEN("ORD") }, BUILDER(Create_func_ord)}, + { { STRING_WITH_LEN("PASSWORD") }, BUILDER(Create_func_password)}, { { STRING_WITH_LEN("PERIOD_ADD") }, BUILDER(Create_func_period_add)}, { { STRING_WITH_LEN("PERIOD_DIFF") }, BUILDER(Create_func_period_diff)}, { { STRING_WITH_LEN("PI") }, BUILDER(Create_func_pi)}, { { STRING_WITH_LEN("POW") }, BUILDER(Create_func_pow)}, { { STRING_WITH_LEN("POWER") }, BUILDER(Create_func_pow)}, + { { STRING_WITH_LEN("QUARTER") }, BUILDER(Create_func_quarter)}, { { STRING_WITH_LEN("QUOTE") }, BUILDER(Create_func_quote)}, { { STRING_WITH_LEN("REGEXP_INSTR") }, BUILDER(Create_func_regexp_instr)}, { { STRING_WITH_LEN("REGEXP_REPLACE") }, BUILDER(Create_func_regexp_replace)}, @@ -5686,11 +6028,14 @@ const Native_func_registry func_array[] = BUILDER(Create_func_replace_oracle)}, { { STRING_WITH_LEN("REVERSE") }, BUILDER(Create_func_reverse)}, { { STRING_WITH_LEN("ROUND") }, BUILDER(Create_func_round)}, + { { STRING_WITH_LEN("ROW_COUNT") }, BUILDER(Create_func_row_count)}, { { STRING_WITH_LEN("RPAD") }, BUILDER(Create_func_rpad)}, { { STRING_WITH_LEN("RPAD_ORACLE") }, BUILDER(Create_func_rpad_oracle)}, { { STRING_WITH_LEN("RTRIM") }, BUILDER(Create_func_rtrim)}, { { STRING_WITH_LEN("RTRIM_ORACLE") }, BUILDER(Create_func_rtrim_oracle)}, { { STRING_WITH_LEN("SEC_TO_TIME") }, BUILDER(Create_func_sec_to_time)}, + { { STRING_WITH_LEN("SCHEMA") }, BUILDER(Create_func_database)}, + { { STRING_WITH_LEN("SCHEMAS") }, BUILDER(Create_func_database)}, { { STRING_WITH_LEN("SHA") }, BUILDER(Create_func_sha)}, { { STRING_WITH_LEN("SHA1") }, BUILDER(Create_func_sha)}, { { STRING_WITH_LEN("SHA2") }, BUILDER(Create_func_sha2)}, @@ -5725,6 +6070,7 @@ const Native_func_registry func_array[] = { { STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)}, { { STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)}, { { STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)}, + { { STRING_WITH_LEN("WEEK") }, BUILDER(Create_func_week)}, { { STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)}, { { STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)}, #ifdef WITH_WSREP diff --git a/sql/lex.h b/sql/lex.h index c2b83e67ded..d6241c50b6a 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -81,7 +81,6 @@ SYMBOL symbols[] = { { "AUTHORS", SYM(AUTHORS_SYM)}, { "AUTO_INCREMENT", SYM(AUTO_INC)}, { "AUTOEXTEND_SIZE", SYM(AUTOEXTEND_SIZE_SYM)}, - { "AUTO", SYM(AUTO_SYM)}, { "AVG", SYM(AVG_SYM)}, { "AVG_ROW_LENGTH", SYM(AVG_ROW_LENGTH)}, { "BACKUP", SYM(BACKUP_SYM)}, @@ -426,7 +425,6 @@ SYMBOL symbols[] = { { "NCHAR", SYM(NCHAR_SYM)}, { "NESTED", SYM(NESTED_SYM)}, { "NEVER", SYM(NEVER_SYM)}, - { "NEW", SYM(NEW_SYM)}, { "NEXT", SYM(NEXT_SYM)}, { "NEXTVAL", SYM(NEXTVAL_SYM)}, { "NO", SYM(NO_SYM)}, @@ -682,7 +680,6 @@ SYMBOL symbols[] = { { "TRUE", SYM(TRUE_SYM)}, { "TRUNCATE", SYM(TRUNCATE_SYM)}, { "TYPE", SYM(TYPE_SYM)}, - { "TYPES", SYM(TYPES_SYM)}, { "UNBOUNDED", SYM(UNBOUNDED_SYM)}, { "UNCOMMITTED", SYM(UNCOMMITTED_SYM)}, { "UNDEFINED", SYM(UNDEFINED_SYM)}, @@ -748,7 +745,6 @@ SYMBOL symbols[] = { SYMBOL sql_functions[] = { { "ADDDATE", SYM(ADDDATE_SYM)}, - { "ADD_MONTHS", SYM(ADD_MONTHS_SYM)}, { "BIT_AND", SYM(BIT_AND)}, { "BIT_OR", SYM(BIT_OR)}, { "BIT_XOR", SYM(BIT_XOR)}, @@ -759,7 +755,6 @@ SYMBOL sql_functions[] = { { "CURTIME", SYM(CURTIME)}, { "DATE_ADD", SYM(DATE_ADD_INTERVAL)}, { "DATE_SUB", SYM(DATE_SUB_INTERVAL)}, - { "DATE_FORMAT", SYM(DATE_FORMAT_SYM)}, { "DENSE_RANK", SYM(DENSE_RANK_SYM)}, { "EXTRACT", SYM(EXTRACT_SYM)}, { "FIRST_VALUE", SYM(FIRST_VALUE_SYM)}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 92fd102bc1a..a4e3a4c6531 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -737,7 +737,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token ACTION /* SQL-2003-N */ %token ADMIN_SYM /* SQL-2003-N */ %token ADDDATE_SYM /* MYSQL-FUNC */ -%token ADD_MONTHS_SYM /* Oracle FUNC*/ %token AFTER_SYM /* SQL-2003-N */ %token AGAINST %token AGGREGATE_SYM @@ -750,7 +749,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token AUTHORS_SYM %token AUTOEXTEND_SIZE_SYM %token AUTO_INC -%token AUTO_SYM %token AVG_ROW_LENGTH %token AVG_SYM /* SQL-2003-N */ %token BACKUP_SYM @@ -812,7 +810,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token DATAFILE_SYM %token DATA_SYM /* SQL-2003-N */ %token DATETIME -%token DATE_FORMAT_SYM /* MYSQL-FUNC */ %token DATE_SYM /* SQL-2003-R, Oracle-R, PLSQL-R */ %token DAY_SYM /* SQL-2003-R */ %token DEALLOCATE_SYM /* SQL-2003-R */ @@ -963,7 +960,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token NATIONAL_SYM /* SQL-2003-R */ %token NCHAR_SYM /* SQL-2003-R */ %token NEVER_SYM /* MySQL */ -%token NEW_SYM /* SQL-2003-R */ %token NEXT_SYM /* SQL-2003-N */ %token NEXTVAL_SYM /* PostgreSQL sequence function */ %token NOCACHE_SYM @@ -1126,7 +1122,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token TRIGGERS_SYM %token TRIM_ORACLE %token TRUNCATE_SYM -%token TYPES_SYM %token TYPE_SYM /* SQL-2003-N */ %token UDF_RETURNS_SYM %token UNBOUNDED_SYM /* SQL-2011-N */ @@ -1317,6 +1312,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type IDENT_sys + ident_func ident label_ident sp_decl_ident @@ -1341,6 +1337,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); IDENT_cli ident_cli ident_cli_set_usual_case + ident_cli_func %type ident_sys_alloc @@ -1355,6 +1352,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); keyword_sp_block_section keyword_sp_decl keyword_sp_head + keyword_func_sp_var_and_label + keyword_func_sp_var_not_label keyword_sp_var_and_label keyword_sp_var_not_label keyword_sysvar_name @@ -10411,14 +10410,7 @@ substring_operands_special: discouraged. */ function_call_nonkeyword: - ADD_MONTHS_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, - INTERVAL_MONTH, 0); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | ADDDATE_SYM '(' expr ',' expr ')' + ADDDATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_date_add_interval(thd, $3, $5, INTERVAL_DAY, 0); @@ -10457,18 +10449,6 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | DATE_FORMAT_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DATE_FORMAT_SYM '(' expr ',' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_date_format(thd, $3, $5, $7); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | EXTRACT_SYM '(' interval FROM expr ')' { $$=new (thd->mem_root) Item_extract(thd, $3, $5); @@ -10593,13 +10573,6 @@ function_call_nonkeyword: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | - COLUMN_CHECK_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_dyncol_check(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | COLUMN_CREATE_SYM '(' dyncall_create_list ')' { @@ -10637,43 +10610,12 @@ function_call_conflict: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | COALESCE '(' expr_list ')' - { - $$= new (thd->mem_root) Item_func_coalesce(thd, *$3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | COLLATION_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_collation(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | DATABASE '(' ')' - { - $$= new (thd->mem_root) Item_func_database(thd); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - Lex->safe_to_cache_query=0; - } | IF_SYM '(' expr ',' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_if(thd, $3, $5, $7); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | FORMAT_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_format(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | FORMAT_SYM '(' expr ',' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_format(thd, $3, $5, $7); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } /* LAST_VALUE here conflicts with the definition for window functions. We have these 2 separate rules to remove the shift/reduce conflict. */ @@ -10695,25 +10637,12 @@ function_call_conflict: if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | MICROSECOND_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_microsecond(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | MOD_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_mod(thd, $3, $5); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | OLD_PASSWORD_SYM '(' expr ')' - { - $$= new (thd->mem_root) - Item_func_password(thd, $3, Item_func_password::OLD); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | PASSWORD_SYM '(' expr ')' { Item* i1; @@ -10722,12 +10651,6 @@ function_call_conflict: MYSQL_YYABORT; $$= i1; } - | QUARTER_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_quarter(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | REPEAT_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_repeat(thd, $3, $5); @@ -10740,38 +10663,12 @@ function_call_conflict: make_item_func_replace(thd, $3, $5, $7)))) MYSQL_YYABORT; } - | REVERSE_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_reverse(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | ROW_COUNT_SYM '(' ')' - { - $$= new (thd->mem_root) Item_func_row_count(thd); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - Lex->set_stmt_unsafe(LEX::BINLOG_STMT_UNSAFE_SYSTEM_FUNCTION); - Lex->safe_to_cache_query= 0; - } | TRUNCATE_SYM '(' expr ',' expr ')' { $$= new (thd->mem_root) Item_func_round(thd, $3, $5, 1); if (unlikely($$ == NULL)) MYSQL_YYABORT; } - | WEEK_SYM '(' expr ')' - { - $$= new (thd->mem_root) Item_func_week(thd, $3); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } - | WEEK_SYM '(' expr ',' expr ')' - { - $$= new (thd->mem_root) Item_func_week(thd, $3, $5); - if (unlikely($$ == NULL)) - MYSQL_YYABORT; - } | WEIGHT_STRING_SYM '(' expr opt_ws_levels ')' { $$= new (thd->mem_root) Item_func_weight_string(thd, $3, 0, 0, $4); @@ -10817,7 +10714,7 @@ function_call_conflict: in sql/item_create.cc */ function_call_generic: - IDENT_sys '(' + ident_func '(' { #ifdef HAVE_DLOPEN udf_func *udf= 0; @@ -15673,6 +15570,22 @@ IDENT_sys: } ; +ident_cli_func: + IDENT + | IDENT_QUOTED + | keyword_func_sp_var_and_label { $$= $1; } + | keyword_func_sp_var_not_label { $$= $1; } + ; + +ident_func: + ident_cli_func + { + if (unlikely(thd->to_ident_sys_alloc(&$$, &$1))) + MYSQL_YYABORT; + } + ; + + TEXT_STRING_sys: TEXT_STRING { @@ -15896,7 +15809,8 @@ non_reserved_keyword_udt: TODO: check if some of them can migrate to keyword_sp_var_and_label. */ keyword_sp_var_not_label: - ASCII_SYM + keyword_func_sp_var_not_label + | ASCII_SYM | BACKUP_SYM | BINLOG_SYM | BYTE_SYM @@ -15904,7 +15818,6 @@ keyword_sp_var_not_label: | CHECKSUM_SYM | CHECKPOINT_SYM | COLUMN_ADD_SYM - | COLUMN_CHECK_SYM | COLUMN_CREATE_SYM | COLUMN_DELETE_SYM | COLUMN_GET_SYM @@ -15916,7 +15829,6 @@ keyword_sp_var_not_label: | EXECUTE_SYM | FLUSH_SYM | FOLLOWING_SYM - | FORMAT_SYM | GET_SYM | HELP_SYM | HOST_SYM @@ -16070,29 +15982,21 @@ keyword_cast_type: ; -/* - These keywords are fine for both SP variable names and SP labels. -*/ -keyword_sp_var_and_label: - ACTION +keyword_func_sp_var_and_label: + ACTION | ACCOUNT_SYM - | ADDDATE_SYM - | ADD_MONTHS_SYM | ADMIN_SYM | AFTER_SYM | AGAINST | AGGREGATE_SYM | ALGORITHM_SYM | ALWAYS_SYM - | ANY_SYM | AT_SYM | ATOMIC_SYM | AUTHORS_SYM | AUTO_INC | AUTOEXTEND_SIZE_SYM - | AUTO_SYM | AVG_ROW_LENGTH - | AVG_SYM | BLOCK_SYM | BODY_MARIADB_SYM | BTREE_SYM @@ -16104,7 +16008,6 @@ keyword_sp_var_and_label: | CLIENT_SYM | CLASS_ORIGIN_SYM | COALESCE - | CODE_SYM | COLLATION_SYM | COLUMN_NAME_SYM | COLUMNS @@ -16130,16 +16033,15 @@ keyword_sp_var_and_label: | CURSOR_NAME_SYM | CYCLE_SYM | DATA_SYM + | DATABASE | DATAFILE_SYM - | DATE_FORMAT_SYM - | DAY_SYM | DEFINER_SYM | DELAY_KEY_WRITE_SYM | DES_KEY_FILE | DIAGNOSTICS_SYM + | DISCARD | DIRECTORY_SYM | DISABLE_SYM - | DISCARD | DISK_SYM | DUMPFILE | DUPLICATE_SYM @@ -16147,6 +16049,11 @@ keyword_sp_var_and_label: | ELSEIF_ORACLE_SYM | ELSIF_MARIADB_SYM | EMPTY_SYM + | EXPIRE_SYM + | EXPORT_SYM + | EXTENDED_SYM + | EXTENT_SIZE_SYM + | ENABLE_SYM | ENDS_SYM | ENGINE_SYM | ENGINES_SYM @@ -16159,29 +16066,21 @@ keyword_sp_var_and_label: | EXCEPTION_MARIADB_SYM | EXCHANGE_SYM | EXPANSION_SYM - | EXPIRE_SYM - | EXPORT_SYM - | EXTENDED_SYM - | EXTENT_SIZE_SYM | FAULTS_SYM | FAST_SYM - | FOUND_SYM - | ENABLE_SYM | FEDERATED_SYM - | FULL | FILE_SYM | FIRST_SYM + | FOUND_SYM + | FULL | GENERAL | GENERATED_SYM - | GET_FORMAT | GRANTS | GOTO_MARIADB_SYM | HASH_SYM | HARD_SYM | HISTORY_SYM | HOSTS_SYM - | HOUR_SYM - | ID_SYM | IDENTIFIED_SYM | IGNORE_SERVER_IDS_SYM | INCREMENT_SYM @@ -16199,9 +16098,7 @@ keyword_sp_var_and_label: | INVISIBLE_SYM | JSON_TABLE_SYM | KEY_BLOCK_SIZE - | LAST_VALUE | LAST_SYM - | LASTVAL_SYM | LEAVES | LESS_SYM | LEVEL_SYM @@ -16243,7 +16140,6 @@ keyword_sp_var_and_label: | MESSAGE_TEXT_SYM | MICROSECOND_SYM | MIGRATE_SYM - | MINUTE_SYM %ifdef MARIADB | MINUS_ORACLE_SYM %endif @@ -16252,7 +16148,6 @@ keyword_sp_var_and_label: | MODIFY_SYM | MODE_SYM | MONITOR_SYM - | MONTH_SYM | MUTEX_SYM | MYSQL_SYM | MYSQL_ERRNO_SYM @@ -16260,8 +16155,6 @@ keyword_sp_var_and_label: | NESTED_SYM | NEVER_SYM | NEXT_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 - | NEXTVAL_SYM - | NEW_SYM | NOCACHE_SYM | NOCYCLE_SYM | NOMINVALUE_SYM @@ -16277,7 +16170,6 @@ keyword_sp_var_and_label: | ONLINE_SYM | ONLY_SYM | ORDINALITY_SYM - | OVERLAPS_SYM | PACKAGE_MARIADB_SYM | PACK_KEYS_SYM | PAGE_SYM @@ -16309,10 +16201,10 @@ keyword_sp_var_and_label: | REDOFILE_SYM | REDUNDANT_SYM | RELAY - | RELAYLOG_SYM | RELAY_LOG_FILE_SYM | RELAY_LOG_POS_SYM | RELAY_THREAD + | RELAYLOG_SYM | RELOAD | REORGANIZE_SYM | REPEATABLE_SYM @@ -16327,20 +16219,15 @@ keyword_sp_var_and_label: | REVERSE_SYM | ROLLUP_SYM | ROUTINE_SYM + | ROW_COUNT_SYM | ROWCOUNT_SYM | ROWTYPE_MARIADB_SYM - | ROW_COUNT_SYM | ROW_FORMAT_SYM -%ifdef MARIADB - | ROWNUM_SYM -%endif | RTREE_SYM | SCHEDULE_SYM | SCHEMA_NAME_SYM - | SECOND_SYM | SEQUENCE_SYM | SERIALIZABLE_SYM - | SETVAL_SYM | SIMPLE_SYM | SHARE_SYM | SKIP_SYM @@ -16348,7 +16235,6 @@ keyword_sp_var_and_label: | SLOW | SNAPSHOT_SYM | SOFT_SYM - | SOUNDS_SYM | SOURCE_SYM | SQL_CACHE_SYM | SQL_BUFFER_RESULT @@ -16361,7 +16247,6 @@ keyword_sp_var_and_label: | STORAGE_SYM | STRING_SYM | SUBCLASS_ORIGIN_SYM - | SUBDATE_SYM | SUBJECT_SYM | SUBPARTITION_SYM | SUBPARTITIONS_SYM @@ -16369,9 +16254,6 @@ keyword_sp_var_and_label: | SUSPEND_SYM | SWAPS_SYM | SWITCHES_SYM -%ifdef MARIADB - | SYSDATE -%endif | SYSTEM | SYSTEM_TIME_SYM | TABLE_NAME_SYM @@ -16385,10 +16267,6 @@ keyword_sp_var_and_label: | TRANSACTIONAL_SYM | THREADS_SYM | TRIGGERS_SYM - | TRIM_ORACLE - | TIMESTAMP_ADD - | TIMESTAMP_DIFF - | TYPES_SYM | TYPE_SYM | UDF_RETURNS_SYM | UNCOMMITTED_SYM @@ -16397,23 +16275,61 @@ keyword_sp_var_and_label: | UNDOFILE_SYM | UNKNOWN_SYM | UNTIL_SYM - | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 | USE_FRM | VARIABLES | VERSIONING_SYM | VIEW_SYM | VIRTUAL_SYM | VISIBLE_SYM - | VALUE_SYM | WARNINGS | WAIT_SYM - | WEEK_SYM - | WEIGHT_STRING_SYM | WITHOUT | WORK_SYM | X509_SYM | XML_SYM | VIA_SYM + | WEEK_SYM + ; + +keyword_func_sp_var_not_label: + FORMAT_SYM + | COLUMN_CHECK_SYM + ; +/* + These keywords are fine for both SP variable names and SP labels. +*/ +keyword_sp_var_and_label: + keyword_func_sp_var_and_label + | ADDDATE_SYM + | ANY_SYM + | AVG_SYM + | CODE_SYM + | DAY_SYM + | GET_FORMAT + | HOUR_SYM + | ID_SYM + | LAST_VALUE + | LASTVAL_SYM + | MINUTE_SYM + | MONTH_SYM + | NEXTVAL_SYM + | OVERLAPS_SYM +%ifdef MARIADB + | ROWNUM_SYM +%endif + | SECOND_SYM + | SETVAL_SYM + | SOUNDS_SYM + | SUBDATE_SYM +%ifdef MARIADB + | SYSDATE +%endif + | TRIM_ORACLE + | TIMESTAMP_ADD + | TIMESTAMP_DIFF + | USER_SYM %prec PREC_BELOW_CONTRACTION_TOKEN2 + | VALUE_SYM + | WEIGHT_STRING_SYM ; @@ -16454,7 +16370,6 @@ reserved_keyword_udt_not_param_type: | CURRENT_USER | CURRENT_ROLE | CURTIME - | DATABASE | DATABASES | DATE_ADD_INTERVAL | DATE_SUB_INTERVAL