summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-06-13 08:25:16 +0400
committerAlexander Barkov <bar@mariadb.com>2018-06-13 08:25:16 +0400
commit4787913db0b49b4a48e337e6b76b8b6c8233a941 (patch)
tree2a6974b93e40772796d718617a5d3ae11d71f100
parentb52bb6eb82db8f3bff88efbf0876d364a3826cc1 (diff)
downloadmariadb-git-4787913db0b49b4a48e337e6b76b8b6c8233a941.tar.gz
MDEV-16464 Oracle Comp.: Sql-Error on "SELECT name, comment FROM mysql.proc"
-rw-r--r--mysql-test/suite/compat/oracle/r/parser.result51
-rw-r--r--mysql-test/suite/compat/oracle/t/parser.test48
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--sql/sql_yacc_ora.yy3
4 files changed, 102 insertions, 2 deletions
diff --git a/mysql-test/suite/compat/oracle/r/parser.result b/mysql-test/suite/compat/oracle/r/parser.result
index 28ed8eb8185..c8600c29bd4 100644
--- a/mysql-test/suite/compat/oracle/r/parser.result
+++ b/mysql-test/suite/compat/oracle/r/parser.result
@@ -448,3 +448,54 @@ BEGIN
SELECT precedes INTO precedes FROM DUAL;
END;
/
+#
+# MDEV-16464 Oracle Comp.: Sql-Error on "SELECT name, comment FROM mysql.proc"
+#
+SET sql_mode=ORACLE;
+SELECT name, comment FROM mysql.proc WHERE db='test';
+name comment
+CREATE TABLE comment (comment INT);
+SELECT comment FROM comment;
+comment
+SELECT comment comment FROM comment comment;
+comment
+SELECT comment AS comment FROM comment AS comment;
+comment
+DROP TABLE comment;
+DECLARE
+comment INT;
+BEGIN
+SELECT comment INTO comment FROM DUAL;
+END;
+/
+CREATE PROCEDURE comment COMMENT 'test' AS
+BEGIN
+SELECT 1;
+END;
+/
+BEGIN
+comment;
+END;
+/
+1
+1
+CALL comment();
+1
+1
+CALL comment;
+1
+1
+DROP PROCEDURE comment;
+CREATE FUNCTION comment RETURN INT COMMENT 'test' AS
+BEGIN
+RETURN 1;
+END;
+/
+Warnings:
+Note 1585 This function 'comment' has the same name as a native function
+SELECT test.comment() FROM DUAL;
+test.comment()
+1
+Warnings:
+Note 1585 This function 'comment' has the same name as a native function
+DROP FUNCTION comment;
diff --git a/mysql-test/suite/compat/oracle/t/parser.test b/mysql-test/suite/compat/oracle/t/parser.test
index a8f5eda7016..5b219e3bce3 100644
--- a/mysql-test/suite/compat/oracle/t/parser.test
+++ b/mysql-test/suite/compat/oracle/t/parser.test
@@ -208,3 +208,51 @@ END;
/
DELIMITER ;/
+
+
+--echo #
+--echo # MDEV-16464 Oracle Comp.: Sql-Error on "SELECT name, comment FROM mysql.proc"
+--echo #
+
+SET sql_mode=ORACLE;
+SELECT name, comment FROM mysql.proc WHERE db='test';
+
+CREATE TABLE comment (comment INT);
+SELECT comment FROM comment;
+SELECT comment comment FROM comment comment;
+SELECT comment AS comment FROM comment AS comment;
+DROP TABLE comment;
+
+DELIMITER /;
+DECLARE
+ comment INT;
+BEGIN
+ SELECT comment INTO comment FROM DUAL;
+END;
+/
+DELIMITER ;/
+
+DELIMITER /;
+CREATE PROCEDURE comment COMMENT 'test' AS
+BEGIN
+ SELECT 1;
+END;
+/
+BEGIN
+ comment;
+END;
+/
+DELIMITER ;/
+CALL comment();
+CALL comment;
+DROP PROCEDURE comment;
+
+DELIMITER /;
+CREATE FUNCTION comment RETURN INT COMMENT 'test' AS
+BEGIN
+ RETURN 1;
+END;
+/
+DELIMITER ;/
+SELECT test.comment() FROM DUAL;
+DROP FUNCTION comment;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b53a89ecc94..0d440bf0c2c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -1213,7 +1213,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
Keywords that have different reserved status in std/oracle modes.
*/
%token <kwd> BODY_SYM /* Oracle-R */
-%token <kwd> COMMENT_SYM
%token <kwd> ELSIF_SYM /* Oracle, reserved in PL/SQL*/
%token <kwd> GOTO_SYM /* Oracle, reserved in PL/SQL*/
%token <kwd> OTHERS_SYM /* SQL-2011-N */
@@ -1276,6 +1275,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> COLUMN_GET_SYM
%token <kwd> COLUMN_SYM /* SQL-2003-R */
%token <kwd> COLUMN_NAME_SYM /* SQL-2003-N */
+%token <kwd> COMMENT_SYM /* Oracle-R */
%token <kwd> COMMITTED_SYM /* SQL-2003-N */
%token <kwd> COMMIT_SYM /* SQL-2003-R */
%token <kwd> COMPACT_SYM
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index f0db33f67ae..8c4d1e897dc 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -607,7 +607,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
Keywords that have different reserved status in std/oracle modes.
*/
%token BODY_SYM /* Oracle-R */
-%token COMMENT_SYM
%token ELSIF_SYM /* Oracle, reserved in PL/SQL*/
%token GOTO_SYM /* Oracle, reserved in PL/SQL*/
%token OTHERS_SYM /* SQL-2011-N */
@@ -670,6 +669,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> COLUMN_GET_SYM
%token <kwd> COLUMN_SYM /* SQL-2003-R */
%token <kwd> COLUMN_NAME_SYM /* SQL-2003-N */
+%token <kwd> COMMENT_SYM /* Oracle-R */
%token <kwd> COMMITTED_SYM /* SQL-2003-N */
%token <kwd> COMMIT_SYM /* SQL-2003-R */
%token <kwd> COMPACT_SYM
@@ -15593,6 +15593,7 @@ keyword_sp_var_not_label:
| COLUMN_CREATE_SYM
| COLUMN_DELETE_SYM
| COLUMN_GET_SYM
+ | COMMENT_SYM
| DEALLOCATE_SYM
| EXAMINED_SYM
| EXCLUDE_SYM