Skip to content

Commit 556a40d

Browse files
committed
MDEV-35229 NOCOPY has become reserved word bringing wide incompatibility
This patch was suggested by Sergei Golubchik. It reverts the second patch from the PR: commit fa5eeb4 Fixed ALTER TABLE NOCOPY keyword failure and adds NOCOPY_SYM into keyword_func_sp_var_and_label. The price is one extra shift/recuce conflict in yy_oracle.yy. This should to tolerable.
1 parent 8c0a260 commit 556a40d

File tree

6 files changed

+290
-36
lines changed

6 files changed

+290
-36
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
eval CREATE TABLE $keyword (a INT);
2+
eval DROP TABLE $keyword;
3+
4+
eval CREATE TABLE t1 ($keyword int);
5+
eval SELECT $keyword AS $keyword FROM t1 AS $keyword;
6+
eval DROP TABLE t1;
7+
8+
9+
eval CREATE TABLE $keyword ($keyword INT);
10+
eval CREATE TRIGGER $keyword AFTER INSERT ON $keyword FOR EACH ROW BEGIN END;
11+
eval DROP TRIGGER $keyword;
12+
eval DROP TABLE $keyword;
13+
14+
eval PREPARE $keyword FROM 'select 1';
15+
eval EXECUTE $keyword;
16+
eval DEALLOCATE PREPARE $keyword;

mysql-test/main/parser.result

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2264,3 +2264,54 @@ $$
22642264
#
22652265
# End of 10.6 tests
22662266
#
2267+
#
2268+
# Start of 11.7 tests
2269+
#
2270+
#
2271+
# MDEV-35229 NOCOPY has become reserved word bringing wide incompatibility
2272+
#
2273+
CREATE TABLE nocopy (a INT);
2274+
DROP TABLE nocopy;
2275+
CREATE TABLE t1 (nocopy int);
2276+
SELECT nocopy AS nocopy FROM t1 AS nocopy;
2277+
nocopy
2278+
DROP TABLE t1;
2279+
CREATE TABLE nocopy (nocopy INT);
2280+
CREATE TRIGGER nocopy AFTER INSERT ON nocopy FOR EACH ROW BEGIN END;
2281+
DROP TRIGGER nocopy;
2282+
DROP TABLE nocopy;
2283+
PREPARE nocopy FROM 'select 1';
2284+
EXECUTE nocopy;
2285+
1
2286+
1
2287+
DEALLOCATE PREPARE nocopy;
2288+
CREATE FUNCTION nocopy (nocopy INT) RETURNS INT RETURN nocopy;
2289+
Warnings:
2290+
Note 1585 This function 'nocopy' has the same name as a native function
2291+
SELECT nocopy(1);
2292+
nocopy(1)
2293+
1
2294+
Warnings:
2295+
Note 1585 This function 'nocopy' has the same name as a native function
2296+
DROP FUNCTION nocopy;
2297+
CREATE PROCEDURE nocopy (nocopy INT) SELECT nocopy;
2298+
CALL nocopy(1);
2299+
nocopy
2300+
1
2301+
DROP PROCEDURE nocopy;
2302+
BEGIN NOT ATOMIC
2303+
DECLARE nocopy INT DEFAULT 1;
2304+
nocopy:
2305+
WHILE 1 DO
2306+
BEGIN
2307+
SELECT nocopy;
2308+
LEAVE nocopy;
2309+
END;
2310+
END WHILE;
2311+
END;
2312+
$$
2313+
nocopy
2314+
1
2315+
#
2316+
# End of 11.7 tests
2317+
#

mysql-test/main/parser.test

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2067,3 +2067,49 @@ DELIMITER ;$$
20672067
--echo #
20682068
--echo # End of 10.6 tests
20692069
--echo #
2070+
2071+
2072+
--echo #
2073+
--echo # Start of 11.7 tests
2074+
--echo #
2075+
2076+
--echo #
2077+
--echo # MDEV-35229 NOCOPY has become reserved word bringing wide incompatibility
2078+
--echo #
2079+
2080+
--let $keyword=nocopy
2081+
--source include/keyword_non_reserved.inc
2082+
2083+
# Statements like "CREATE FUNCTION nocopy" and "SELECT nocopy()" below
2084+
# erroneously prints a warning:
2085+
# This function 'nocopy' has the same name as a native function
2086+
# Though it's not really a function, it's just a keyword.
2087+
# This warning is not printed with ps protocol. Let's disable ps protocol.
2088+
2089+
--disable_ps_protocol
2090+
CREATE FUNCTION nocopy (nocopy INT) RETURNS INT RETURN nocopy;
2091+
SELECT nocopy(1);
2092+
DROP FUNCTION nocopy;
2093+
--enable_ps_protocol
2094+
2095+
CREATE PROCEDURE nocopy (nocopy INT) SELECT nocopy;
2096+
CALL nocopy(1);
2097+
DROP PROCEDURE nocopy;
2098+
2099+
DELIMITER $$;
2100+
BEGIN NOT ATOMIC
2101+
DECLARE nocopy INT DEFAULT 1;
2102+
nocopy:
2103+
WHILE 1 DO
2104+
BEGIN
2105+
SELECT nocopy;
2106+
LEAVE nocopy;
2107+
END;
2108+
END WHILE;
2109+
END;
2110+
$$
2111+
DELIMITER ;$$
2112+
2113+
--echo #
2114+
--echo # End of 11.7 tests
2115+
--echo #

mysql-test/suite/compat/oracle/r/sp-param.result

Lines changed: 84 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -469,10 +469,7 @@ BEGIN
469469
RETURN 0;
470470
END;
471471
$$
472-
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
473-
BEGIN
474-
RETURN 0;
475-
END' at line 1
472+
ERROR HY000: Unknown data type: 'p_in'
476473
#
477474
# sql_mode=DEFAULT to perform the negative test case. Test with function, OUT NOCOPY
478475
#
@@ -481,10 +478,7 @@ BEGIN
481478
RETURN 0;
482479
END;
483480
$$
484-
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
485-
BEGIN
486-
RETURN 0;
487-
END' at line 1
481+
ERROR HY000: Unknown data type: 'p_out'
488482
#
489483
# sql_mode=DEFAULT to perform the negative test case. Test with function, INOUT NOCOPY
490484
#
@@ -493,37 +487,107 @@ BEGIN
493487
RETURN 0;
494488
END;
495489
$$
496-
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
497-
BEGIN
498-
RETURN 0;
499-
END' at line 1
490+
ERROR HY000: Unknown data type: 'p_inout'
500491
#
501492
# sql_mode=DEFAULT to perform the negative test case. Test with procedure, IN NOCOPY
502493
#
503494
CREATE OR REPLACE PROCEDURE example_proc(IN NOCOPY p_in INT)
504495
BEGIN
505496
END;
506497
$$
507-
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)
508-
BEGIN
509-
END' at line 1
498+
ERROR HY000: Unknown data type: 'p_in'
510499
#
511500
# sql_mode=DEFAULT to perform the negative test case. Test with procedure, OUT NOCOPY
512501
#
513502
CREATE OR REPLACE PROCEDURE example_proc(OUT NOCOPY p_out INT)
514503
BEGIN
515504
END;
516505
$$
517-
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)
518-
BEGIN
519-
END' at line 1
506+
ERROR HY000: Unknown data type: 'p_out'
520507
#
521508
# sql_mode=DEFAULT to perform the negative test case. Test with procedure, INOUT NOCOPY
522509
#
523510
CREATE OR REPLACE PROCEDURE example_proc(INOUT NOCOPY p_inout INT)
524511
BEGIN
525512
END;
526513
$$
527-
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)
514+
ERROR HY000: Unknown data type: 'p_inout'
515+
#
516+
# MDEV-35229 NOCOPY has become reserved word bringing wide incompatibility
517+
#
518+
SET sql_mode=ORACLE;
519+
CREATE TABLE nocopy (a INT);
520+
DROP TABLE nocopy;
521+
CREATE TABLE t1 (nocopy int);
522+
SELECT nocopy AS nocopy FROM t1 AS nocopy;
523+
nocopy
524+
DROP TABLE t1;
525+
CREATE TABLE nocopy (nocopy INT);
526+
CREATE TRIGGER nocopy AFTER INSERT ON nocopy FOR EACH ROW BEGIN END;
527+
DROP TRIGGER nocopy;
528+
DROP TABLE nocopy;
529+
PREPARE nocopy FROM 'select 1';
530+
EXECUTE nocopy;
531+
1
532+
1
533+
DEALLOCATE PREPARE nocopy;
534+
CREATE FUNCTION nocopy (nocopy INT) RETURN INT AS
535+
BEGIN
536+
RETURN nocopy;
537+
END;
538+
$$
539+
Warnings:
540+
Note 1585 This function 'nocopy' has the same name as a native function
541+
SELECT nocopy(1);
542+
nocopy(1)
543+
1
544+
Warnings:
545+
Note 1585 This function 'nocopy' has the same name as a native function
546+
DROP FUNCTION nocopy;
547+
CREATE FUNCTION nocopy (nocopy nocopy INT) RETURN INT AS
548+
BEGIN
549+
RETURN nocopy;
550+
END;
551+
$$
552+
Warnings:
553+
Note 1585 This function 'nocopy' has the same name as a native function
554+
SELECT nocopy(1);
555+
nocopy(1)
556+
1
557+
Warnings:
558+
Note 1585 This function 'nocopy' has the same name as a native function
559+
DROP FUNCTION nocopy;
560+
CREATE PROCEDURE nocopy (nocopy INT) AS
561+
BEGIN
562+
SELECT nocopy;
563+
END;
564+
$$
565+
CALL nocopy(1);
566+
nocopy
567+
1
568+
DROP PROCEDURE nocopy;
569+
CREATE PROCEDURE nocopy (nocopy nocopy INT) AS
570+
BEGIN
571+
SELECT nocopy;
572+
END;
573+
$$
574+
CALL nocopy(1);
575+
nocopy
576+
1
577+
DROP PROCEDURE nocopy;
578+
DECLARE
579+
nocopy INT := 1;
528580
BEGIN
529-
END' at line 1
581+
<<nocopy>>
582+
WHILE 1
583+
LOOP
584+
SELECT nocopy;
585+
LEAVE nocopy;
586+
END LOOP;
587+
END;
588+
$$
589+
nocopy
590+
1
591+
#
592+
# End of 11.7 tests
593+
#

0 commit comments

Comments
 (0)