From 8ccb721fef00c7ca86a42f62084e161438d948ac Mon Sep 17 00:00:00 2001 From: "sts-kokseng.wong" Date: Mon, 30 Sep 2024 11:27:45 +0800 Subject: [PATCH] The revision corresponds to the review comments. 1. Move the unit tests into the compat/oracle suite, sp-param.test file. 2. Remove the added unit test file and result file. 3. Add type, Alter_info::enum_alter_table_algorithm, into the union. 4. Remove the extra switch case --- mysql-test/main/sp-ignore_nocopy.result | 103 --------------- mysql-test/main/sp-ignore_nocopy.test | 121 ------------------ .../suite/compat/oracle/r/sp-param.result | 104 +++++++++++++++ .../suite/compat/oracle/t/sp-param.test | 121 ++++++++++++++++++ sql/sql_yacc.yy | 22 +--- 5 files changed, 230 insertions(+), 241 deletions(-) delete mode 100644 mysql-test/main/sp-ignore_nocopy.result delete mode 100644 mysql-test/main/sp-ignore_nocopy.test diff --git a/mysql-test/main/sp-ignore_nocopy.result b/mysql-test/main/sp-ignore_nocopy.result deleted file mode 100644 index 267b6d41ae1d0..0000000000000 --- a/mysql-test/main/sp-ignore_nocopy.result +++ /dev/null @@ -1,103 +0,0 @@ -# -# MDEV-34316 sql_mode=ORACLE: Ignore the NOCOPY keyword in stored routine parameters -# -# -# sql_mode=DEFAULT. Test with function, IN NOCOPY -# -CREATE OR REPLACE FUNCTION example_func(IN NOCOPY p_in INT) RETURNS INT -BEGIN -RETURN 0; -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 'NOCOPY p_in INT) RETURNS INT -BEGIN -RETURN 0; -END' at line 1 -# -# sql_mode=DEFAULT. Test with function, OUT NOCOPY -# -CREATE OR REPLACE FUNCTION example_func(OUT NOCOPY p_out INT) RETURNS INT -BEGIN -RETURN 0; -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 'NOCOPY p_out INT) RETURNS INT -BEGIN -RETURN 0; -END' at line 1 -# -# sql_mode=DEFAULT. Test with function, INOUT NOCOPY -# -CREATE OR REPLACE FUNCTION example_func(INOUT NOCOPY p_inout INT) RETURNS INT -BEGIN -RETURN 0; -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 'NOCOPY p_inout INT) RETURNS INT -BEGIN -RETURN 0; -END' at line 1 -# -# sql_mode=DEFAULT. Test with procedure, IN NOCOPY -# -CREATE OR REPLACE PROCEDURE example_proc(IN NOCOPY p_in INT) -BEGIN -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 'NOCOPY p_in INT) -BEGIN -END' at line 1 -# -# sql_mode=DEFAULT. Test with procedure, OUT NOCOPY -# -CREATE OR REPLACE PROCEDURE example_proc(OUT NOCOPY p_out INT) -BEGIN -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 'NOCOPY p_out INT) -BEGIN -END' at line 1 -# -# sql_mode=DEFAULT. Test with procedure, INOUT NOCOPY -# -CREATE OR REPLACE PROCEDURE example_proc(INOUT NOCOPY p_inout INT) -BEGIN -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 'NOCOPY p_inout INT) -BEGIN -END' at line 1 -SET sql_mode=ORACLE; -# -# sql_mode=ORACLE. Test with function -# -CREATE OR REPLACE FUNCTION example_func( -p_in1 IN VARCHAR(255), -p_in2 IN NOCOPY VARCHAR(255), -p_out1 OUT INT, -p_out2 OUT NOCOPY INT, -p_in_out1 IN OUT VARCHAR(255), -p_in_out2 IN OUT NOCOPY VARCHAR(255), -p_in_out3 INOUT NUMBER, -p_in_out4 INOUT NOCOPY NUMBER) RETURN NUMBER AS -BEGIN -RETURN 0; -END; -$$ -DROP FUNCTION example_func; -# -# sql_mode=ORACLE. Test with procedure -# -CREATE OR REPLACE PROCEDURE example_proc( -p_in1 IN VARCHAR(255), -p_in2 IN NOCOPY VARCHAR(255), -p_out1 OUT INT, -p_out2 OUT NOCOPY INT, -p_in_out1 IN OUT VARCHAR(255), -p_in_out2 IN OUT NOCOPY VARCHAR(255), -p_in_out3 INOUT NUMBER, -p_in_out4 INOUT NOCOPY NUMBER) AS -BEGIN -END; -$$ -DROP PROCEDURE example_proc; diff --git a/mysql-test/main/sp-ignore_nocopy.test b/mysql-test/main/sp-ignore_nocopy.test deleted file mode 100644 index 18bbae6ec25c2..0000000000000 --- a/mysql-test/main/sp-ignore_nocopy.test +++ /dev/null @@ -1,121 +0,0 @@ ---echo # ---echo # MDEV-34316 sql_mode=ORACLE: Ignore the NOCOPY keyword in stored routine parameters ---echo # - -DELIMITER $$; - ---echo # ---echo # sql_mode=DEFAULT. Test with function, IN NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE FUNCTION example_func(IN NOCOPY p_in INT) RETURNS INT -BEGIN - RETURN 0; -END; -$$ - ---echo # ---echo # sql_mode=DEFAULT. Test with function, OUT NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE FUNCTION example_func(OUT NOCOPY p_out INT) RETURNS INT -BEGIN - RETURN 0; -END; -$$ - ---echo # ---echo # sql_mode=DEFAULT. Test with function, INOUT NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE FUNCTION example_func(INOUT NOCOPY p_inout INT) RETURNS INT -BEGIN - RETURN 0; -END; -$$ - ---echo # ---echo # sql_mode=DEFAULT. Test with procedure, IN NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE PROCEDURE example_proc(IN NOCOPY p_in INT) -BEGIN -END; -$$ - ---echo # ---echo # sql_mode=DEFAULT. Test with procedure, OUT NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE PROCEDURE example_proc(OUT NOCOPY p_out INT) -BEGIN -END; -$$ - ---echo # ---echo # sql_mode=DEFAULT. Test with procedure, INOUT NOCOPY ---echo # - ---error ER_PARSE_ERROR -CREATE OR REPLACE PROCEDURE example_proc(INOUT NOCOPY p_inout INT) -BEGIN -END; -$$ - -DELIMITER ;$$ - -SET sql_mode=ORACLE; - ---echo # ---echo # sql_mode=ORACLE. Test with function ---echo # - -DELIMITER $$; - -CREATE OR REPLACE FUNCTION example_func( - p_in1 IN VARCHAR(255), - p_in2 IN NOCOPY VARCHAR(255), - p_out1 OUT INT, - p_out2 OUT NOCOPY INT, - p_in_out1 IN OUT VARCHAR(255), - p_in_out2 IN OUT NOCOPY VARCHAR(255), - p_in_out3 INOUT NUMBER, - p_in_out4 INOUT NOCOPY NUMBER) RETURN NUMBER AS -BEGIN - RETURN 0; -END; - -$$ - -DELIMITER ;$$ - -DROP FUNCTION example_func; - ---echo # ---echo # sql_mode=ORACLE. Test with procedure ---echo # - -DELIMITER $$; - -CREATE OR REPLACE PROCEDURE example_proc( - p_in1 IN VARCHAR(255), - p_in2 IN NOCOPY VARCHAR(255), - p_out1 OUT INT, - p_out2 OUT NOCOPY INT, - p_in_out1 IN OUT VARCHAR(255), - p_in_out2 IN OUT NOCOPY VARCHAR(255), - p_in_out3 INOUT NUMBER, - p_in_out4 INOUT NOCOPY NUMBER) AS -BEGIN -END; - -$$ - -DELIMITER ;$$ - -DROP PROCEDURE example_proc; diff --git a/mysql-test/suite/compat/oracle/r/sp-param.result b/mysql-test/suite/compat/oracle/r/sp-param.result index c72b3716735b5..c839b81c7bac9 100644 --- a/mysql-test/suite/compat/oracle/r/sp-param.result +++ b/mysql-test/suite/compat/oracle/r/sp-param.result @@ -423,3 +423,107 @@ ERROR 22001: Data too long for column 'pin' at row 0 DROP PROCEDURE p2; DROP FUNCTION f1; ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; +# +# MDEV-34316 sql_mode=ORACLE: Ignore the NOCOPY keyword in stored routine parameters +# +SET sql_mode=ORACLE; +# +# sql_mode=ORACLE. Test with function +# +CREATE OR REPLACE FUNCTION example_func( +p_in1 IN VARCHAR(255), +p_in2 IN NOCOPY VARCHAR(255), +p_out1 OUT INT, +p_out2 OUT NOCOPY INT, +p_in_out1 IN OUT VARCHAR(255), +p_in_out2 IN OUT NOCOPY VARCHAR(255), +p_in_out3 INOUT NUMBER, +p_in_out4 INOUT NOCOPY NUMBER) RETURN NUMBER AS +BEGIN +RETURN 0; +END; +/ +DROP FUNCTION example_func; +# +# sql_mode=ORACLE. Test with procedure +# +CREATE OR REPLACE PROCEDURE example_proc( +p_in1 IN VARCHAR(255), +p_in2 IN NOCOPY VARCHAR(255), +p_out1 OUT INT, +p_out2 OUT NOCOPY INT, +p_in_out1 IN OUT VARCHAR(255), +p_in_out2 IN OUT NOCOPY VARCHAR(255), +p_in_out3 INOUT NUMBER, +p_in_out4 INOUT NOCOPY NUMBER) AS +BEGIN +END; +/ +DROP PROCEDURE example_proc; +SET sql_mode=DEFAULT; +# +# sql_mode=DEFAULT to perform the negative test case. Test with function, IN NOCOPY +# +CREATE OR REPLACE FUNCTION example_func(IN NOCOPY p_in INT) RETURNS INT +BEGIN +RETURN 0; +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 'NOCOPY p_in INT) RETURNS INT +BEGIN +RETURN 0; +END' at line 1 +# +# sql_mode=DEFAULT to perform the negative test case. Test with function, OUT NOCOPY +# +CREATE OR REPLACE FUNCTION example_func(OUT NOCOPY p_out INT) RETURNS INT +BEGIN +RETURN 0; +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 'NOCOPY p_out INT) RETURNS INT +BEGIN +RETURN 0; +END' at line 1 +# +# sql_mode=DEFAULT to perform the negative test case. Test with function, INOUT NOCOPY +# +CREATE OR REPLACE FUNCTION example_func(INOUT NOCOPY p_inout INT) RETURNS INT +BEGIN +RETURN 0; +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 'NOCOPY p_inout INT) RETURNS INT +BEGIN +RETURN 0; +END' at line 1 +# +# sql_mode=DEFAULT to perform the negative test case. Test with procedure, IN NOCOPY +# +CREATE OR REPLACE PROCEDURE example_proc(IN NOCOPY p_in INT) +BEGIN +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 'NOCOPY p_in INT) +BEGIN +END' at line 1 +# +# sql_mode=DEFAULT to perform the negative test case. Test with procedure, OUT NOCOPY +# +CREATE OR REPLACE PROCEDURE example_proc(OUT NOCOPY p_out INT) +BEGIN +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 'NOCOPY p_out INT) +BEGIN +END' at line 1 +# +# sql_mode=DEFAULT to perform the negative test case. Test with procedure, INOUT NOCOPY +# +CREATE OR REPLACE PROCEDURE example_proc(INOUT NOCOPY p_inout INT) +BEGIN +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 'NOCOPY p_inout INT) +BEGIN +END' at line 1 diff --git a/mysql-test/suite/compat/oracle/t/sp-param.test b/mysql-test/suite/compat/oracle/t/sp-param.test index b8931b6ea925d..a4fa6e3d96c32 100644 --- a/mysql-test/suite/compat/oracle/t/sp-param.test +++ b/mysql-test/suite/compat/oracle/t/sp-param.test @@ -365,3 +365,124 @@ DROP PROCEDURE p2; DROP FUNCTION f1; --source include/test_db_charset_restore.inc + +--echo # +--echo # MDEV-34316 sql_mode=ORACLE: Ignore the NOCOPY keyword in stored routine parameters +--echo # + +SET sql_mode=ORACLE; + +--echo # +--echo # sql_mode=ORACLE. Test with function +--echo # + +DELIMITER /; + +CREATE OR REPLACE FUNCTION example_func( + p_in1 IN VARCHAR(255), + p_in2 IN NOCOPY VARCHAR(255), + p_out1 OUT INT, + p_out2 OUT NOCOPY INT, + p_in_out1 IN OUT VARCHAR(255), + p_in_out2 IN OUT NOCOPY VARCHAR(255), + p_in_out3 INOUT NUMBER, + p_in_out4 INOUT NOCOPY NUMBER) RETURN NUMBER AS +BEGIN + RETURN 0; +END; +/ + +DELIMITER ;/ + +DROP FUNCTION example_func; + +--echo # +--echo # sql_mode=ORACLE. Test with procedure +--echo # + +DELIMITER /; + +CREATE OR REPLACE PROCEDURE example_proc( + p_in1 IN VARCHAR(255), + p_in2 IN NOCOPY VARCHAR(255), + p_out1 OUT INT, + p_out2 OUT NOCOPY INT, + p_in_out1 IN OUT VARCHAR(255), + p_in_out2 IN OUT NOCOPY VARCHAR(255), + p_in_out3 INOUT NUMBER, + p_in_out4 INOUT NOCOPY NUMBER) AS +BEGIN +END; +/ + +DELIMITER ;/ + +DROP PROCEDURE example_proc; + +SET sql_mode=DEFAULT; +DELIMITER $$; + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with function, IN NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE FUNCTION example_func(IN NOCOPY p_in INT) RETURNS INT +BEGIN + RETURN 0; +END; +$$ + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with function, OUT NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE FUNCTION example_func(OUT NOCOPY p_out INT) RETURNS INT +BEGIN + RETURN 0; +END; +$$ + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with function, INOUT NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE FUNCTION example_func(INOUT NOCOPY p_inout INT) RETURNS INT +BEGIN + RETURN 0; +END; +$$ + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with procedure, IN NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE PROCEDURE example_proc(IN NOCOPY p_in INT) +BEGIN +END; +$$ + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with procedure, OUT NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE PROCEDURE example_proc(OUT NOCOPY p_out INT) +BEGIN +END; +$$ + +--echo # +--echo # sql_mode=DEFAULT to perform the negative test case. Test with procedure, INOUT NOCOPY +--echo # + +--error ER_PARSE_ERROR +CREATE OR REPLACE PROCEDURE example_proc(INOUT NOCOPY p_inout INT) +BEGIN +END; +$$ + +DELIMITER ;$$ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3e737b5ea2edd..1295aef6ac2d4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -332,6 +332,7 @@ void _CONCAT_UNDERSCORED(turn_parser_debug_on,yyparse)() enum vers_kind_t vers_range_unit; enum Column_definition::enum_column_versioning vers_column_versioning; enum plsql_cursor_attr_t plsql_cursor_attr; + enum Alter_info::enum_alter_table_algorithm alter_table_algo_val; privilege_t privilege; struct { @@ -1467,7 +1468,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); opt_recursive opt_format_xid opt_for_portion_of_time_clause ignorability -%type alter_algorithm_option_is_kwd +%type alter_algorithm_option_is_kwd %type create_or_replace @@ -7943,27 +7944,14 @@ opt_index_lock_algorithm: ; alter_algorithm_option_is_kwd: - DEFAULT { $$ = 0; } - | NOCOPY_SYM { $$ = 1; } + DEFAULT { $$ = Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; } + | NOCOPY_SYM { $$ = Alter_info::ALTER_TABLE_ALGORITHM_NOCOPY; } ; - alter_algorithm_option: ALGORITHM_SYM opt_equal alter_algorithm_option_is_kwd { - Alter_info::enum_alter_table_algorithm algoType; - switch ($3) { - case 0: - algoType = Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; - break; - case 1: - algoType = Alter_info::ALTER_TABLE_ALGORITHM_NOCOPY; - break; - default: - algoType = Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; - } - - Lex->alter_info.set_requested_algorithm(algoType); + Lex->alter_info.set_requested_algorithm($3); } | ALGORITHM_SYM opt_equal ident {