diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index a1c6e86a129..2394c958b47 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -1349,3 +1349,334 @@ SET GLOBAL a=10; END; $$ ERROR HY000: Unknown system variable 'a' +# +# MDEV-16202 Latest changes made erroneously some keywords reserved in sql_mode=ORACLE +# +CREATE PROCEDURE p1(name VARCHAR(64), pattern TEXT) +BEGIN +DECLARE query TEXT DEFAULT REPLACE(pattern, 'name', name); +DECLARE CONTINUE HANDLER FOR SQLEXCEPTION +BEGIN +SHOW ERRORS; +END; +SELECT query AS ''; +EXECUTE IMMEDIATE query; +END; +$$ +CREATE PROCEDURE p2(name VARCHAR(64)) +BEGIN +CALL p1(name, 'BEGIN NOT ATOMIC DECLARE name INT; SET name=10; SELECT name; END'); +EXECUTE IMMEDIATE REPLACE('CREATE TABLE t1 (name INT)', 'name', name); +CALL p1(name, 'SELECT name FROM t1'); +CALL p1(name, 'SELECT name ''alias'' FROM t1'); +CALL p1(name, 'SELECT name()'); +CALL p1(name, 'SELECT name.name()'); +CALL p1(name, 'SELECT name DATE FROM t1'); +CALL p1(name, 'SELECT name HISTORY FROM t1'); +CALL p1(name, 'SELECT name NEXT FROM t1'); +CALL p1(name, 'SELECT name PERIOD FROM t1'); +CALL p1(name, 'SELECT name PREVIOUS FROM t1'); +CALL p1(name, 'SELECT name SYSTEM FROM t1'); +CALL p1(name, 'SELECT name SYSTEM_TIME FROM t1'); +CALL p1(name, 'SELECT name TIME FROM t1'); +CALL p1(name, 'SELECT name TIMESTAMP FROM t1'); +CALL p1(name, 'SELECT name TRANSACTION FROM t1'); +CALL p1(name, 'SELECT name VALUE FROM t1'); +CALL p1(name, 'SELECT name VERSIONING FROM t1'); +CALL p1(name, 'SELECT name WITHOUT FROM t1'); +DROP TABLE t1; +END; +$$ +CALL p2('date'); +BEGIN NOT ATOMIC DECLARE date INT; SET date=10; SELECT date; END +10 +SELECT date FROM t1 +SELECT date 'alias' FROM t1 +Error 1525 Incorrect DATE value: 'alias' +SELECT date() +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 +SELECT date.date() +Error 1630 FUNCTION date.date does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT date DATE FROM t1 +SELECT date HISTORY FROM t1 +SELECT date NEXT FROM t1 +SELECT date PERIOD FROM t1 +SELECT date PREVIOUS FROM t1 +SELECT date SYSTEM FROM t1 +SELECT date SYSTEM_TIME FROM t1 +SELECT date TIME FROM t1 +SELECT date TIMESTAMP FROM t1 +SELECT date TRANSACTION FROM t1 +SELECT date VALUE FROM t1 +SELECT date VERSIONING FROM t1 +SELECT date WITHOUT FROM t1 +CALL p2('history'); +BEGIN NOT ATOMIC DECLARE history INT; SET history=10; SELECT history; END +10 +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 +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 +SELECT history HISTORY FROM t1 +SELECT history NEXT FROM t1 +SELECT history PERIOD FROM t1 +SELECT history PREVIOUS FROM t1 +SELECT history SYSTEM FROM t1 +SELECT history SYSTEM_TIME FROM t1 +SELECT history TIME FROM t1 +SELECT history TIMESTAMP FROM t1 +SELECT history TRANSACTION FROM t1 +SELECT history VALUE FROM t1 +SELECT history VERSIONING FROM t1 +SELECT history WITHOUT FROM t1 +CALL p2('next'); +BEGIN NOT ATOMIC DECLARE next INT; SET next=10; SELECT next; END +10 +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 +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 +SELECT next HISTORY FROM t1 +SELECT next NEXT FROM t1 +SELECT next PERIOD FROM t1 +SELECT next PREVIOUS FROM t1 +SELECT next SYSTEM FROM t1 +SELECT next SYSTEM_TIME FROM t1 +SELECT next TIME FROM t1 +SELECT next TIMESTAMP FROM t1 +SELECT next TRANSACTION FROM t1 +SELECT next VALUE FROM t1 +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 'FROM t1' at line 1 +SELECT next VERSIONING FROM t1 +SELECT next WITHOUT FROM t1 +CALL p2('period'); +BEGIN NOT ATOMIC DECLARE period INT; SET period=10; SELECT period; END +10 +SELECT period FROM t1 +SELECT period 'alias' FROM t1 +SELECT period() +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 +SELECT period.period() +Error 1630 FUNCTION period.period does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT period DATE FROM t1 +SELECT period HISTORY FROM t1 +SELECT period NEXT FROM t1 +SELECT period PERIOD FROM t1 +SELECT period PREVIOUS FROM t1 +SELECT period SYSTEM FROM t1 +SELECT period SYSTEM_TIME FROM t1 +SELECT period TIME FROM t1 +SELECT period TIMESTAMP FROM t1 +SELECT period TRANSACTION FROM t1 +SELECT period VALUE FROM t1 +SELECT period VERSIONING FROM t1 +SELECT period WITHOUT FROM t1 +CALL p2('previous'); +BEGIN NOT ATOMIC DECLARE previous INT; SET previous=10; SELECT previous; END +10 +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 +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 +SELECT previous HISTORY FROM t1 +SELECT previous NEXT FROM t1 +SELECT previous PERIOD FROM t1 +SELECT previous PREVIOUS FROM t1 +SELECT previous SYSTEM FROM t1 +SELECT previous SYSTEM_TIME FROM t1 +SELECT previous TIME FROM t1 +SELECT previous TIMESTAMP FROM t1 +SELECT previous TRANSACTION FROM t1 +SELECT previous VALUE FROM t1 +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 'FROM t1' at line 1 +SELECT previous VERSIONING FROM t1 +SELECT previous WITHOUT FROM t1 +CALL p2('system'); +BEGIN NOT ATOMIC DECLARE system INT; SET system=10; SELECT system; END +10 +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 +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 +SELECT system HISTORY FROM t1 +SELECT system NEXT FROM t1 +SELECT system PERIOD FROM t1 +SELECT system PREVIOUS FROM t1 +SELECT system SYSTEM FROM t1 +SELECT system SYSTEM_TIME FROM t1 +SELECT system TIME FROM t1 +SELECT system TIMESTAMP FROM t1 +SELECT system TRANSACTION FROM t1 +SELECT system VALUE FROM t1 +SELECT system VERSIONING FROM t1 +SELECT system WITHOUT FROM t1 +CALL p2('system_time'); +BEGIN NOT ATOMIC DECLARE system_time INT; SET system_time=10; SELECT system_time; END +10 +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 +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 +SELECT system_time HISTORY FROM t1 +SELECT system_time NEXT FROM t1 +SELECT system_time PERIOD FROM t1 +SELECT system_time PREVIOUS FROM t1 +SELECT system_time SYSTEM FROM t1 +SELECT system_time SYSTEM_TIME FROM t1 +SELECT system_time TIME FROM t1 +SELECT system_time TIMESTAMP FROM t1 +SELECT system_time TRANSACTION FROM t1 +SELECT system_time VALUE FROM t1 +SELECT system_time VERSIONING FROM t1 +SELECT system_time WITHOUT FROM t1 +CALL p2('time'); +BEGIN NOT ATOMIC DECLARE time INT; SET time=10; SELECT time; END +10 +SELECT time FROM t1 +SELECT time 'alias' FROM t1 +Error 1525 Incorrect TIME value: 'alias' +SELECT 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 +SELECT time.time() +Error 1630 FUNCTION time.time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT time DATE FROM t1 +SELECT time HISTORY FROM t1 +SELECT time NEXT FROM t1 +SELECT time PERIOD FROM t1 +SELECT time PREVIOUS FROM t1 +SELECT time SYSTEM FROM t1 +SELECT time SYSTEM_TIME FROM t1 +SELECT time TIME FROM t1 +SELECT time TIMESTAMP FROM t1 +SELECT time TRANSACTION FROM t1 +SELECT time VALUE FROM t1 +SELECT time VERSIONING FROM t1 +SELECT time WITHOUT FROM t1 +CALL p2('timestamp'); +BEGIN NOT ATOMIC DECLARE timestamp INT; SET timestamp=10; SELECT timestamp; END +10 +SELECT timestamp FROM t1 +SELECT timestamp 'alias' FROM t1 +Error 1525 Incorrect DATETIME value: 'alias' +SELECT timestamp() +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 +SELECT timestamp.timestamp() +Error 1630 FUNCTION timestamp.timestamp does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT timestamp DATE FROM t1 +SELECT timestamp HISTORY FROM t1 +SELECT timestamp NEXT FROM t1 +SELECT timestamp PERIOD FROM t1 +SELECT timestamp PREVIOUS FROM t1 +SELECT timestamp SYSTEM FROM t1 +SELECT timestamp SYSTEM_TIME FROM t1 +SELECT timestamp TIME FROM t1 +SELECT timestamp TIMESTAMP FROM t1 +SELECT timestamp TRANSACTION FROM t1 +SELECT timestamp VALUE FROM t1 +SELECT timestamp VERSIONING FROM t1 +SELECT timestamp WITHOUT FROM t1 +CALL p2('transaction'); +BEGIN NOT ATOMIC DECLARE transaction INT; SET transaction=10; SELECT transaction; END +10 +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 +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 +SELECT transaction HISTORY FROM t1 +SELECT transaction NEXT FROM t1 +SELECT transaction PERIOD FROM t1 +SELECT transaction PREVIOUS FROM t1 +SELECT transaction SYSTEM FROM t1 +SELECT transaction SYSTEM_TIME FROM t1 +SELECT transaction TIME FROM t1 +SELECT transaction TIMESTAMP FROM t1 +SELECT transaction TRANSACTION FROM t1 +SELECT transaction VALUE FROM t1 +SELECT transaction VERSIONING FROM t1 +SELECT transaction WITHOUT FROM t1 +CALL p2('value'); +BEGIN NOT ATOMIC DECLARE value INT; SET value=10; SELECT value; END +10 +SELECT value FROM t1 +SELECT value 'alias' FROM t1 +SELECT value() +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 +SELECT value.value() +Error 1630 FUNCTION value.value does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT value DATE FROM t1 +SELECT value HISTORY FROM t1 +SELECT value NEXT FROM t1 +SELECT value PERIOD FROM t1 +SELECT value PREVIOUS FROM t1 +SELECT value SYSTEM FROM t1 +SELECT value SYSTEM_TIME FROM t1 +SELECT value TIME FROM t1 +SELECT value TIMESTAMP FROM t1 +SELECT value TRANSACTION FROM t1 +SELECT value VALUE FROM t1 +SELECT value VERSIONING FROM t1 +SELECT value WITHOUT FROM t1 +CALL p2('versioning'); +BEGIN NOT ATOMIC DECLARE versioning INT; SET versioning=10; SELECT versioning; END +10 +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 +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 +SELECT versioning HISTORY FROM t1 +SELECT versioning NEXT FROM t1 +SELECT versioning PERIOD FROM t1 +SELECT versioning PREVIOUS FROM t1 +SELECT versioning SYSTEM FROM t1 +SELECT versioning SYSTEM_TIME FROM t1 +SELECT versioning TIME FROM t1 +SELECT versioning TIMESTAMP FROM t1 +SELECT versioning TRANSACTION FROM t1 +SELECT versioning VALUE FROM t1 +SELECT versioning VERSIONING FROM t1 +SELECT versioning WITHOUT FROM t1 +CALL p2('without'); +BEGIN NOT ATOMIC DECLARE without INT; SET without=10; SELECT without; END +10 +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 +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 +SELECT without HISTORY FROM t1 +SELECT without NEXT FROM t1 +SELECT without PERIOD FROM t1 +SELECT without PREVIOUS FROM t1 +SELECT without SYSTEM FROM t1 +SELECT without SYSTEM_TIME FROM t1 +SELECT without TIME FROM t1 +SELECT without TIMESTAMP FROM t1 +SELECT without TRANSACTION FROM t1 +SELECT without VALUE FROM t1 +SELECT without VERSIONING FROM t1 +SELECT without WITHOUT FROM t1 +DROP PROCEDURE p2; +DROP PROCEDURE p1; diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 1f176c6afc5..8faab613a0c 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -1379,3 +1379,67 @@ BEGIN NOT ATOMIC END; $$ DELIMITER ;$$ + + +--echo # +--echo # MDEV-16202 Latest changes made erroneously some keywords reserved in sql_mode=ORACLE +--echo # + + +DELIMITER $$; +CREATE PROCEDURE p1(name VARCHAR(64), pattern TEXT) +BEGIN + DECLARE query TEXT DEFAULT REPLACE(pattern, 'name', name); + DECLARE CONTINUE HANDLER FOR SQLEXCEPTION + BEGIN + SHOW ERRORS; + END; + SELECT query AS ''; + EXECUTE IMMEDIATE query; +END; +$$ + +CREATE PROCEDURE p2(name VARCHAR(64)) +BEGIN + CALL p1(name, 'BEGIN NOT ATOMIC DECLARE name INT; SET name=10; SELECT name; END'); + EXECUTE IMMEDIATE REPLACE('CREATE TABLE t1 (name INT)', 'name', name); + CALL p1(name, 'SELECT name FROM t1'); + CALL p1(name, 'SELECT name ''alias'' FROM t1'); + CALL p1(name, 'SELECT name()'); + CALL p1(name, 'SELECT name.name()'); + CALL p1(name, 'SELECT name DATE FROM t1'); + CALL p1(name, 'SELECT name HISTORY FROM t1'); + CALL p1(name, 'SELECT name NEXT FROM t1'); + CALL p1(name, 'SELECT name PERIOD FROM t1'); + CALL p1(name, 'SELECT name PREVIOUS FROM t1'); + CALL p1(name, 'SELECT name SYSTEM FROM t1'); + CALL p1(name, 'SELECT name SYSTEM_TIME FROM t1'); + CALL p1(name, 'SELECT name TIME FROM t1'); + CALL p1(name, 'SELECT name TIMESTAMP FROM t1'); + CALL p1(name, 'SELECT name TRANSACTION FROM t1'); + CALL p1(name, 'SELECT name VALUE FROM t1'); + CALL p1(name, 'SELECT name VERSIONING FROM t1'); + CALL p1(name, 'SELECT name WITHOUT FROM t1'); + DROP TABLE t1; +END; +$$ +DELIMITER ;$$ + +--disable_column_names +CALL p2('date'); +CALL p2('history'); +CALL p2('next'); +CALL p2('period'); +CALL p2('previous'); +CALL p2('system'); +CALL p2('system_time'); +CALL p2('time'); +CALL p2('timestamp'); +CALL p2('transaction'); +CALL p2('value'); +CALL p2('versioning'); +CALL p2('without'); +--enable_column_names + +DROP PROCEDURE p2; +DROP PROCEDURE p1; diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result index 29588a68045..ac04f4070e9 100644 --- a/mysql-test/suite/compat/oracle/r/parser.result +++ b/mysql-test/suite/compat/oracle/r/parser.result @@ -16,3 +16,335 @@ SET GLOBAL a=10; END; $$ ERROR HY000: Unknown system variable 'a' +# +# MDEV-16202 Latest changes made erroneously some keywords reserved in sql_mode=ORACLE +# +CREATE PROCEDURE p1(name VARCHAR(64), pattern TEXT) AS +query TEXT DEFAULT REPLACE(pattern, 'name', name); +BEGIN +SELECT query AS ''; +EXECUTE IMMEDIATE query; +EXCEPTION +WHEN OTHERS THEN +BEGIN +SHOW ERRORS; +END; +END; +$$ +CREATE PROCEDURE p2(name VARCHAR(64)) AS +BEGIN +CALL p1(name, 'DECLARE name INT; BEGIN name:=10; SELECT name; END'); +EXECUTE IMMEDIATE REPLACE('CREATE TABLE t1 (name INT)', 'name', name); +CALL p1(name, 'SELECT name FROM t1'); +CALL p1(name, 'SELECT name ''alias'' FROM t1'); +CALL p1(name, 'SELECT name()'); +CALL p1(name, 'SELECT name.name()'); +CALL p1(name, 'SELECT name DATE FROM t1'); +CALL p1(name, 'SELECT name HISTORY FROM t1'); +CALL p1(name, 'SELECT name NEXT FROM t1'); +CALL p1(name, 'SELECT name PERIOD FROM t1'); +CALL p1(name, 'SELECT name PREVIOUS FROM t1'); +CALL p1(name, 'SELECT name SYSTEM FROM t1'); +CALL p1(name, 'SELECT name SYSTEM_TIME FROM t1'); +CALL p1(name, 'SELECT name TIME FROM t1'); +CALL p1(name, 'SELECT name TIMESTAMP FROM t1'); +CALL p1(name, 'SELECT name TRANSACTION FROM t1'); +CALL p1(name, 'SELECT name VALUE FROM t1'); +CALL p1(name, 'SELECT name VERSIONING FROM t1'); +CALL p1(name, 'SELECT name WITHOUT FROM t1'); +DROP TABLE t1; +END; +$$ +CALL p2('date'); +DECLARE date INT; BEGIN date:=10; SELECT date; END +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 'INT; BEGIN date:=10; SELECT date; END' at line 1 +SELECT date FROM t1 +SELECT date 'alias' FROM t1 +Error 1525 Incorrect DATE value: 'alias' +SELECT date() +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 +SELECT date.date() +Error 1630 FUNCTION date.date does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT date DATE FROM t1 +SELECT date HISTORY FROM t1 +SELECT date NEXT FROM t1 +SELECT date PERIOD FROM t1 +SELECT date PREVIOUS FROM t1 +SELECT date SYSTEM FROM t1 +SELECT date SYSTEM_TIME FROM t1 +SELECT date TIME FROM t1 +SELECT date TIMESTAMP FROM t1 +SELECT date TRANSACTION FROM t1 +SELECT date VALUE FROM t1 +SELECT date VERSIONING FROM t1 +SELECT date WITHOUT FROM t1 +CALL p2('history'); +DECLARE history INT; BEGIN history:=10; SELECT history; END +10 +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 +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 +SELECT history HISTORY FROM t1 +SELECT history NEXT FROM t1 +SELECT history PERIOD FROM t1 +SELECT history PREVIOUS FROM t1 +SELECT history SYSTEM FROM t1 +SELECT history SYSTEM_TIME FROM t1 +SELECT history TIME FROM t1 +SELECT history TIMESTAMP FROM t1 +SELECT history TRANSACTION FROM t1 +SELECT history VALUE FROM t1 +SELECT history VERSIONING FROM t1 +SELECT history WITHOUT FROM t1 +CALL p2('next'); +DECLARE next INT; BEGIN next:=10; SELECT next; END +10 +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 +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 +SELECT next HISTORY FROM t1 +SELECT next NEXT FROM t1 +SELECT next PERIOD FROM t1 +SELECT next PREVIOUS FROM t1 +SELECT next SYSTEM FROM t1 +SELECT next SYSTEM_TIME FROM t1 +SELECT next TIME FROM t1 +SELECT next TIMESTAMP FROM t1 +SELECT next TRANSACTION FROM t1 +SELECT next VALUE FROM t1 +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 'FROM t1' at line 1 +SELECT next VERSIONING FROM t1 +SELECT next WITHOUT FROM t1 +CALL p2('period'); +DECLARE period INT; BEGIN period:=10; SELECT period; END +10 +SELECT period FROM t1 +SELECT period 'alias' FROM t1 +SELECT period() +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 +SELECT period.period() +Error 1630 FUNCTION period.period does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT period DATE FROM t1 +SELECT period HISTORY FROM t1 +SELECT period NEXT FROM t1 +SELECT period PERIOD FROM t1 +SELECT period PREVIOUS FROM t1 +SELECT period SYSTEM FROM t1 +SELECT period SYSTEM_TIME FROM t1 +SELECT period TIME FROM t1 +SELECT period TIMESTAMP FROM t1 +SELECT period TRANSACTION FROM t1 +SELECT period VALUE FROM t1 +SELECT period VERSIONING FROM t1 +SELECT period WITHOUT FROM t1 +CALL p2('previous'); +DECLARE previous INT; BEGIN previous:=10; SELECT previous; END +10 +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 +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 +SELECT previous HISTORY FROM t1 +SELECT previous NEXT FROM t1 +SELECT previous PERIOD FROM t1 +SELECT previous PREVIOUS FROM t1 +SELECT previous SYSTEM FROM t1 +SELECT previous SYSTEM_TIME FROM t1 +SELECT previous TIME FROM t1 +SELECT previous TIMESTAMP FROM t1 +SELECT previous TRANSACTION FROM t1 +SELECT previous VALUE FROM t1 +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 'FROM t1' at line 1 +SELECT previous VERSIONING FROM t1 +SELECT previous WITHOUT FROM t1 +CALL p2('system'); +DECLARE system INT; BEGIN system:=10; SELECT system; END +10 +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 +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 +SELECT system HISTORY FROM t1 +SELECT system NEXT FROM t1 +SELECT system PERIOD FROM t1 +SELECT system PREVIOUS FROM t1 +SELECT system SYSTEM FROM t1 +SELECT system SYSTEM_TIME FROM t1 +SELECT system TIME FROM t1 +SELECT system TIMESTAMP FROM t1 +SELECT system TRANSACTION FROM t1 +SELECT system VALUE FROM t1 +SELECT system VERSIONING FROM t1 +SELECT system WITHOUT FROM t1 +CALL p2('system_time'); +DECLARE system_time INT; BEGIN system_time:=10; SELECT system_time; END +10 +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 +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 +SELECT system_time HISTORY FROM t1 +SELECT system_time NEXT FROM t1 +SELECT system_time PERIOD FROM t1 +SELECT system_time PREVIOUS FROM t1 +SELECT system_time SYSTEM FROM t1 +SELECT system_time SYSTEM_TIME FROM t1 +SELECT system_time TIME FROM t1 +SELECT system_time TIMESTAMP FROM t1 +SELECT system_time TRANSACTION FROM t1 +SELECT system_time VALUE FROM t1 +SELECT system_time VERSIONING FROM t1 +SELECT system_time WITHOUT FROM t1 +CALL p2('time'); +DECLARE time INT; BEGIN time:=10; SELECT time; END +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 'INT; BEGIN time:=10; SELECT time; END' at line 1 +SELECT time FROM t1 +SELECT time 'alias' FROM t1 +Error 1525 Incorrect TIME value: 'alias' +SELECT 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 +SELECT time.time() +Error 1630 FUNCTION time.time does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT time DATE FROM t1 +SELECT time HISTORY FROM t1 +SELECT time NEXT FROM t1 +SELECT time PERIOD FROM t1 +SELECT time PREVIOUS FROM t1 +SELECT time SYSTEM FROM t1 +SELECT time SYSTEM_TIME FROM t1 +SELECT time TIME FROM t1 +SELECT time TIMESTAMP FROM t1 +SELECT time TRANSACTION FROM t1 +SELECT time VALUE FROM t1 +SELECT time VERSIONING FROM t1 +SELECT time WITHOUT FROM t1 +CALL p2('timestamp'); +DECLARE timestamp INT; BEGIN timestamp:=10; SELECT timestamp; END +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 'INT; BEGIN timestamp:=10; SELECT timestamp; END' at line 1 +SELECT timestamp FROM t1 +SELECT timestamp 'alias' FROM t1 +Error 1525 Incorrect DATETIME value: 'alias' +SELECT timestamp() +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 +SELECT timestamp.timestamp() +Error 1630 FUNCTION timestamp.timestamp does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT timestamp DATE FROM t1 +SELECT timestamp HISTORY FROM t1 +SELECT timestamp NEXT FROM t1 +SELECT timestamp PERIOD FROM t1 +SELECT timestamp PREVIOUS FROM t1 +SELECT timestamp SYSTEM FROM t1 +SELECT timestamp SYSTEM_TIME FROM t1 +SELECT timestamp TIME FROM t1 +SELECT timestamp TIMESTAMP FROM t1 +SELECT timestamp TRANSACTION FROM t1 +SELECT timestamp VALUE FROM t1 +SELECT timestamp VERSIONING FROM t1 +SELECT timestamp WITHOUT FROM t1 +CALL p2('transaction'); +DECLARE transaction INT; BEGIN transaction:=10; SELECT transaction; END +10 +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 +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 +SELECT transaction HISTORY FROM t1 +SELECT transaction NEXT FROM t1 +SELECT transaction PERIOD FROM t1 +SELECT transaction PREVIOUS FROM t1 +SELECT transaction SYSTEM FROM t1 +SELECT transaction SYSTEM_TIME FROM t1 +SELECT transaction TIME FROM t1 +SELECT transaction TIMESTAMP FROM t1 +SELECT transaction TRANSACTION FROM t1 +SELECT transaction VALUE FROM t1 +SELECT transaction VERSIONING FROM t1 +SELECT transaction WITHOUT FROM t1 +CALL p2('value'); +DECLARE value INT; BEGIN value:=10; SELECT value; END +10 +SELECT value FROM t1 +SELECT value 'alias' FROM t1 +SELECT value() +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 +SELECT value.value() +Error 1630 FUNCTION value.value does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual +SELECT value DATE FROM t1 +SELECT value HISTORY FROM t1 +SELECT value NEXT FROM t1 +SELECT value PERIOD FROM t1 +SELECT value PREVIOUS FROM t1 +SELECT value SYSTEM FROM t1 +SELECT value SYSTEM_TIME FROM t1 +SELECT value TIME FROM t1 +SELECT value TIMESTAMP FROM t1 +SELECT value TRANSACTION FROM t1 +SELECT value VALUE FROM t1 +SELECT value VERSIONING FROM t1 +SELECT value WITHOUT FROM t1 +CALL p2('versioning'); +DECLARE versioning INT; BEGIN versioning:=10; SELECT versioning; END +10 +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 +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 +SELECT versioning HISTORY FROM t1 +SELECT versioning NEXT FROM t1 +SELECT versioning PERIOD FROM t1 +SELECT versioning PREVIOUS FROM t1 +SELECT versioning SYSTEM FROM t1 +SELECT versioning SYSTEM_TIME FROM t1 +SELECT versioning TIME FROM t1 +SELECT versioning TIMESTAMP FROM t1 +SELECT versioning TRANSACTION FROM t1 +SELECT versioning VALUE FROM t1 +SELECT versioning VERSIONING FROM t1 +SELECT versioning WITHOUT FROM t1 +CALL p2('without'); +DECLARE without INT; BEGIN without:=10; SELECT without; END +10 +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 +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 +SELECT without HISTORY FROM t1 +SELECT without NEXT FROM t1 +SELECT without PERIOD FROM t1 +SELECT without PREVIOUS FROM t1 +SELECT without SYSTEM FROM t1 +SELECT without SYSTEM_TIME FROM t1 +SELECT without TIME FROM t1 +SELECT without TIMESTAMP FROM t1 +SELECT without TRANSACTION FROM t1 +SELECT without VALUE FROM t1 +SELECT without VERSIONING FROM t1 +SELECT without WITHOUT FROM t1 +DROP PROCEDURE p2; +DROP PROCEDURE p1; diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test index 5aa37c1cd33..c0048e26fa8 100644 --- a/mysql-test/suite/compat/oracle/t/parser.test +++ b/mysql-test/suite/compat/oracle/t/parser.test @@ -22,3 +22,68 @@ BEGIN END; $$ DELIMITER ;$$ + + +--echo # +--echo # MDEV-16202 Latest changes made erroneously some keywords reserved in sql_mode=ORACLE +--echo # + + +DELIMITER $$; +CREATE PROCEDURE p1(name VARCHAR(64), pattern TEXT) AS + query TEXT DEFAULT REPLACE(pattern, 'name', name); +BEGIN + SELECT query AS ''; + EXECUTE IMMEDIATE query; +EXCEPTION + WHEN OTHERS THEN + BEGIN + SHOW ERRORS; + END; +END; +$$ + +CREATE PROCEDURE p2(name VARCHAR(64)) AS +BEGIN + CALL p1(name, 'DECLARE name INT; BEGIN name:=10; SELECT name; END'); + EXECUTE IMMEDIATE REPLACE('CREATE TABLE t1 (name INT)', 'name', name); + CALL p1(name, 'SELECT name FROM t1'); + CALL p1(name, 'SELECT name ''alias'' FROM t1'); + CALL p1(name, 'SELECT name()'); + CALL p1(name, 'SELECT name.name()'); + CALL p1(name, 'SELECT name DATE FROM t1'); + CALL p1(name, 'SELECT name HISTORY FROM t1'); + CALL p1(name, 'SELECT name NEXT FROM t1'); + CALL p1(name, 'SELECT name PERIOD FROM t1'); + CALL p1(name, 'SELECT name PREVIOUS FROM t1'); + CALL p1(name, 'SELECT name SYSTEM FROM t1'); + CALL p1(name, 'SELECT name SYSTEM_TIME FROM t1'); + CALL p1(name, 'SELECT name TIME FROM t1'); + CALL p1(name, 'SELECT name TIMESTAMP FROM t1'); + CALL p1(name, 'SELECT name TRANSACTION FROM t1'); + CALL p1(name, 'SELECT name VALUE FROM t1'); + CALL p1(name, 'SELECT name VERSIONING FROM t1'); + CALL p1(name, 'SELECT name WITHOUT FROM t1'); + DROP TABLE t1; +END; +$$ +DELIMITER ;$$ + +--disable_column_names +CALL p2('date'); +CALL p2('history'); +CALL p2('next'); +CALL p2('period'); +CALL p2('previous'); +CALL p2('system'); +CALL p2('system_time'); +CALL p2('time'); +CALL p2('timestamp'); +CALL p2('transaction'); +CALL p2('value'); +CALL p2('versioning'); +CALL p2('without'); +--enable_column_names + +DROP PROCEDURE p2; +DROP PROCEDURE p1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2fed95aa387..adb5343a252 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1220,17 +1220,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COMMENT_SYM %token ELSIF_SYM /* Oracle, reserved in PL/SQL*/ %token GOTO_SYM /* Oracle, reserved in PL/SQL*/ -%token HISTORY_SYM /* MYSQL */ %token OTHERS_SYM /* SQL-2011-N */ %token PACKAGE_SYM /* Oracle-R */ -%token PERIOD_SYM /* SQL-2011-R */ %token RAISE_SYM /* Oracle-PLSQL-R */ %token ROWTYPE_SYM /* Oracle-PLSQL-R */ -%token SYSTEM /* SQL-2011-R */ -%token SYSTEM_TIME_SYM /* SQL-2011-R */ -%token VERSIONING_SYM /* SQL-2011-R */ %token WINDOW_SYM -%token WITHOUT /* SQL-2003-R */ /* Non-reserved keywords @@ -1376,6 +1370,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token HASH_SYM %token HELP_SYM %token HIGH_PRIORITY +%token HISTORY_SYM /* MYSQL */ %token HOST_SYM %token HOSTS_SYM %token HOUR_SYM /* SQL-2003-R */ @@ -1493,6 +1488,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PARTITIONS_SYM %token PARTITIONING_SYM %token PASSWORD_SYM +%token PERIOD_SYM /* SQL-2011-R */ %token PERSISTENT_SYM %token PHASE_SYM %token PLUGINS_SYM @@ -1598,6 +1594,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token SUSPEND_SYM %token SWAPS_SYM %token SWITCHES_SYM +%token SYSTEM /* SQL-2011-R */ +%token SYSTEM_TIME_SYM /* SQL-2011-R */ %token TABLES %token TABLESPACE %token TABLE_CHECKSUM_SYM @@ -1634,6 +1632,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token VALUE_SYM /* SQL-2003-R */ %token VARCHAR2 /* Oracle */ %token VARIABLES +%token VERSIONING_SYM /* SQL-2011-R */ %token VIA_SYM %token VIEW_SYM /* SQL-2003-N */ %token VIRTUAL_SYM @@ -1642,6 +1641,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token WEEK_SYM %token WEIGHT_STRING_SYM %token WITHIN +%token WITHOUT /* SQL-2003-R */ %token WORK_SYM /* SQL-2003-N */ %token WRAPPER_SYM %token WRITE_SYM /* SQL-2003-N */ diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index c112c215c20..4d209f1aa8a 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -606,17 +606,11 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token COMMENT_SYM %token ELSIF_SYM /* Oracle, reserved in PL/SQL*/ %token GOTO_SYM /* Oracle, reserved in PL/SQL*/ -%token HISTORY_SYM /* MYSQL */ %token OTHERS_SYM /* SQL-2011-N */ %token PACKAGE_SYM /* Oracle-R */ -%token PERIOD_SYM /* SQL-2011-R */ %token RAISE_SYM /* Oracle-PLSQL-R */ %token ROWTYPE_SYM /* Oracle-PLSQL-R */ -%token SYSTEM /* SQL-2011-R */ -%token SYSTEM_TIME_SYM /* SQL-2011-R */ -%token VERSIONING_SYM /* SQL-2011-R */ %token WINDOW_SYM -%token WITHOUT /* SQL-2003-R */ /* Non-reserved keywords @@ -762,6 +756,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token HASH_SYM %token HELP_SYM %token HIGH_PRIORITY +%token HISTORY_SYM /* MYSQL */ %token HOST_SYM %token HOSTS_SYM %token HOUR_SYM /* SQL-2003-R */ @@ -879,6 +874,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PARTITIONS_SYM %token PARTITIONING_SYM %token PASSWORD_SYM +%token PERIOD_SYM /* SQL-2011-R */ %token PERSISTENT_SYM %token PHASE_SYM %token PLUGINS_SYM @@ -984,6 +980,8 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token SUSPEND_SYM %token SWAPS_SYM %token SWITCHES_SYM +%token SYSTEM /* SQL-2011-R */ +%token SYSTEM_TIME_SYM /* SQL-2011-R */ %token TABLES %token TABLESPACE %token TABLE_CHECKSUM_SYM @@ -1020,6 +1018,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token VALUE_SYM /* SQL-2003-R */ %token VARCHAR2 /* Oracle */ %token VARIABLES +%token VERSIONING_SYM /* SQL-2011-R */ %token VIA_SYM %token VIEW_SYM /* SQL-2003-N */ %token VIRTUAL_SYM @@ -1028,6 +1027,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token WEEK_SYM %token WEIGHT_STRING_SYM %token WITHIN +%token WITHOUT /* SQL-2003-R */ %token WORK_SYM /* SQL-2003-N */ %token WRAPPER_SYM %token WRITE_SYM /* SQL-2003-N */ @@ -15102,8 +15102,6 @@ keyword: xxx := 10; */ keyword_directly_assignable: - - ASCII_SYM | BACKUP_SYM | BINLOG_SYM @@ -15125,12 +15123,14 @@ keyword_directly_assignable: | FORMAT_SYM | GET_SYM | HELP_SYM + | HISTORY_SYM | HOST_SYM | INSTALL_SYM | OPTION | OPTIONS_SYM | OWNER_SYM | PARSER_SYM + | PERIOD_SYM | PORT_SYM | PRECEDING_SYM | PREPARE_SYM @@ -15147,11 +15147,15 @@ keyword_directly_assignable: | START_SYM | STOP_SYM | STORED_SYM + | SYSTEM + | SYSTEM_TIME_SYM | TIES_SYM | UNICODE_SYM | UNINSTALL_SYM | UNBOUNDED_SYM + | VERSIONING_SYM | WITHIN + | WITHOUT | WRAPPER_SYM | XA_SYM | UPGRADE_SYM