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/lex.h b/sql/lex.h index 3cf4db19f0772..3883b72ba54d7 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -432,6 +432,7 @@ SYMBOL symbols[] = { { "NEXT", SYM(NEXT_SYM)}, { "NEXTVAL", SYM(NEXTVAL_SYM)}, { "NO", SYM(NO_SYM)}, + { "NOCOPY", SYM(NOCOPY_SYM)}, { "NOMAXVALUE", SYM(NOMAXVALUE_SYM)}, { "NOMINVALUE", SYM(NOMINVALUE_SYM)}, { "NOCACHE", SYM(NOCACHE_SYM)}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 957f5f1330742..5073730dd0e0d 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 { @@ -727,6 +728,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token ELSIF_MARIADB_SYM // PLSQL-R %token EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R %token GOTO_MARIADB_SYM // Oracle-R +%token NOCOPY_SYM %token OTHERS_MARIADB_SYM // SQL-2011-N, PLSQL-R %token PACKAGE_MARIADB_SYM // Oracle-R %token RAISE_MARIADB_SYM // PLSQL-R @@ -1465,6 +1467,8 @@ 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 create_or_replace opt_if_not_exists @@ -7939,11 +7943,15 @@ opt_index_lock_algorithm: | alter_algorithm_option alter_lock_option ; +alter_algorithm_option_is_kwd: + DEFAULT { $$ = Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT; } + | NOCOPY_SYM { $$ = Alter_info::ALTER_TABLE_ALGORITHM_NOCOPY; } + ; + alter_algorithm_option: - ALGORITHM_SYM opt_equal DEFAULT + ALGORITHM_SYM opt_equal alter_algorithm_option_is_kwd { - Lex->alter_info.set_requested_algorithm( - Alter_info::ALTER_TABLE_ALGORITHM_DEFAULT); + Lex->alter_info.set_requested_algorithm($3); } | ALGORITHM_SYM opt_equal ident { @@ -19048,6 +19056,11 @@ sp_opt_default: } ; +sp_opt_nocopy: + _empty + | NOCOPY_SYM + ; + sp_opt_inout: _empty { $$= sp_variable::MODE_IN; } | sp_parameter_type @@ -19461,7 +19474,7 @@ sp_decl_variable_list_anchored: ; sp_param_name_and_mode: - sp_param_name sp_opt_inout + sp_param_name sp_opt_inout sp_opt_nocopy { $1->mode= $2; $$= $1;