Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDEV-34316 Ignore the NOCOPY keyword in stored routine parameters when sql_mode=ORACLE #3517

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions mysql-test/suite/compat/oracle/r/sp-param.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
121 changes: 121 additions & 0 deletions mysql-test/suite/compat/oracle/t/sp-param.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 ;$$
1 change: 1 addition & 0 deletions sql/lex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)},
Expand Down
21 changes: 17 additions & 4 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -727,6 +728,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize);
%token <kwd> ELSIF_MARIADB_SYM // PLSQL-R
%token <kwd> EXCEPTION_ORACLE_SYM // SQL-2003-N, PLSQL-R
%token <kwd> GOTO_MARIADB_SYM // Oracle-R
%token <kwd> NOCOPY_SYM
%token <kwd> OTHERS_MARIADB_SYM // SQL-2011-N, PLSQL-R
%token <kwd> PACKAGE_MARIADB_SYM // Oracle-R
%token <kwd> RAISE_MARIADB_SYM // PLSQL-R
Expand Down Expand Up @@ -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_table_algo_val> alter_algorithm_option_is_kwd

%type <object_ddl_options>
create_or_replace
opt_if_not_exists
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -19048,6 +19056,11 @@ sp_opt_default:
}
;

sp_opt_nocopy:
_empty
| NOCOPY_SYM
;

sp_opt_inout:
_empty { $$= sp_variable::MODE_IN; }
| sp_parameter_type
Expand Down Expand Up @@ -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;
Expand Down