Skip to content

Commit 2f88bd2

Browse files
committed
MDEV-20634 Report disallowed subquery errors as such (instead of parse error)
1 parent b9dea91 commit 2f88bd2

21 files changed

+133
-136
lines changed

mysql-test/main/ps.result

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4547,7 +4547,7 @@ DEALLOCATE PREPARE stmt;
45474547
#
45484548
PREPARE stmt FROM 'SELECT ? FROM DUAL';
45494549
EXECUTE stmt USING (SELECT 1);
4550-
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 'SELECT 1)' at line 1
4550+
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
45514551
DEALLOCATE PREPARE stmt;
45524552
CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
45534553
PREPARE stmt FROM 'SELECT ? FROM DUAL';
@@ -4746,7 +4746,7 @@ ERROR 21000: Operand should contain 1 column(s)
47464746
# Testing disallowed expressions in USING
47474747
#
47484748
EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING (SELECT 1);
4749-
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 'SELECT 1)' at line 1
4749+
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
47504750
CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
47514751
EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING f1();
47524752
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
@@ -4932,9 +4932,9 @@ ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2
49324932
PREPARE stmt FROM CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL');
49334933
ERROR HY000: Illegal mix of collations (latin1_swedish_ci,COERCIBLE) and (latin2_general_ci,COERCIBLE) for operation 'concat'
49344934
EXECUTE IMMEDIATE (SELECT 'SELECT 1');
4935-
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 'SELECT 'SELECT 1')' at line 1
4935+
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
49364936
PREPARE stmt FROM (SELECT 'SELECT 1');
4937-
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 'SELECT 'SELECT 1')' at line 1
4937+
ERROR 42000: PREPARE..FROM does not support subqueries or stored functions
49384938
EXECUTE IMMEDIATE a;
49394939
ERROR 42S22: Unknown column 'a' in 'field list'
49404940
PREPARE stmt FROM a;

mysql-test/main/ps.test

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4042,7 +4042,7 @@ DEALLOCATE PREPARE stmt;
40424042
--echo #
40434043

40444044
PREPARE stmt FROM 'SELECT ? FROM DUAL';
4045-
--error ER_PARSE_ERROR
4045+
--error ER_SUBQUERIES_NOT_SUPPORTED
40464046
EXECUTE stmt USING (SELECT 1);
40474047
DEALLOCATE PREPARE stmt;
40484048

@@ -4221,7 +4221,7 @@ EXECUTE IMMEDIATE 'SELECT ?' USING ROW(1,2);
42214221
--echo # Testing disallowed expressions in USING
42224222
--echo #
42234223

4224-
--error ER_PARSE_ERROR
4224+
--error ER_SUBQUERIES_NOT_SUPPORTED
42254225
EXECUTE IMMEDIATE 'SELECT ? FROM DUAL' USING (SELECT 1);
42264226

42274227
CREATE FUNCTION f1() RETURNS VARCHAR(10) RETURN 'test';
@@ -4394,9 +4394,9 @@ EXECUTE IMMEDIATE CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL');
43944394
--error ER_CANT_AGGREGATE_2COLLATIONS
43954395
PREPARE stmt FROM CONCAT(_latin1'SELECT 1 AS c FROM ', _latin2 'DUAL');
43964396

4397-
--error ER_PARSE_ERROR
4397+
--error ER_SUBQUERIES_NOT_SUPPORTED
43984398
EXECUTE IMMEDIATE (SELECT 'SELECT 1');
4399-
--error ER_PARSE_ERROR
4399+
--error ER_SUBQUERIES_NOT_SUPPORTED
44004400
PREPARE stmt FROM (SELECT 'SELECT 1');
44014401

44024402
--error ER_BAD_FIELD_ERROR

mysql-test/main/statement-expr.result

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8)
1212
0
1313
DROP TABLE t1;
1414
EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1));
15-
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 'SELECT * FROM t1))' at line 1
15+
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
1616
EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1);
17-
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 'SELECT * FROM t1)' at line 1
17+
ERROR 42000: EXECUTE..USING does not support subqueries or stored functions
1818
CREATE TABLE t1 (id INT);
1919
INSERT INTO t1 VALUES (10);
2020
CREATE PROCEDURE p1(a INT) BEGIN END;
@@ -45,21 +45,21 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
4545
SIGNAL SQLSTATE '01000';
4646
END' at line 3
4747
PREPARE stmt FROM (1 IN (SELECT * FROM t1));
48-
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 'SELECT * FROM t1))' at line 1
48+
ERROR 42000: PREPARE..FROM does not support subqueries or stored functions
4949
PREPARE stmt FROM EXISTS (SELECT * FROM t1);
50-
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 '(SELECT * FROM t1)' at line 1
50+
ERROR 42000: PREPARE..FROM does not support subqueries or stored functions
5151
EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1));
52-
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 'SELECT * FROM t1))' at line 1
52+
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
5353
EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1);
54-
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 '(SELECT * FROM t1)' at line 1
54+
ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
5555
GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO;
5656
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 '(1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO' at line 1
5757
GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO;
5858
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 'EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO' at line 1
5959
PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1));
60-
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 'SELECT * FROM t1))' at line 1
60+
ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions
6161
PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1);
62-
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 '(SELECT * FROM t1)' at line 1
62+
ERROR 42000: PURGE..BEFORE does not support subqueries or stored functions
6363
CREATE TABLE t1 (a INT);
6464
INSERT INTO t1 VALUES (1),(2),(3);
6565
DO 1 IN (SELECT * FROM t1);

mysql-test/main/statement-expr.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ SELECT ROW(1,7) IN (SELECT id, id1 FROM t1 WHERE id1= 8);
1515
EXECUTE IMMEDIATE 'SELECT ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8)';
1616
DROP TABLE t1;
1717

18-
--error ER_PARSE_ERROR
18+
--error ER_SUBQUERIES_NOT_SUPPORTED
1919
EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1));
20-
--error ER_PARSE_ERROR
20+
--error ER_SUBQUERIES_NOT_SUPPORTED
2121
EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1);
2222

2323

@@ -52,24 +52,24 @@ $$
5252
DELIMITER ;$$
5353

5454

55-
--error ER_PARSE_ERROR
55+
--error ER_SUBQUERIES_NOT_SUPPORTED
5656
PREPARE stmt FROM (1 IN (SELECT * FROM t1));
57-
--error ER_PARSE_ERROR
57+
--error ER_SUBQUERIES_NOT_SUPPORTED
5858
PREPARE stmt FROM EXISTS (SELECT * FROM t1);
5959

60-
--error ER_PARSE_ERROR
60+
--error ER_SUBQUERIES_NOT_SUPPORTED
6161
EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1));
62-
--error ER_PARSE_ERROR
62+
--error ER_SUBQUERIES_NOT_SUPPORTED
6363
EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1);
6464

6565
--error ER_PARSE_ERROR
6666
GET DIAGNOSTICS CONDITION (1 IN (SELECT * FROM t1)) @errno=MYSQL_ERRNO;
6767
--error ER_PARSE_ERROR
6868
GET DIAGNOSTICS CONDITION EXISTS (SELECT * FROM t1) @errno=MYSQL_ERRNO;
6969

70-
--error ER_PARSE_ERROR
70+
--error ER_SUBQUERIES_NOT_SUPPORTED
7171
PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1));
72-
--error ER_PARSE_ERROR
72+
--error ER_SUBQUERIES_NOT_SUPPORTED
7373
PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1);
7474

7575
CREATE TABLE t1 (a INT);

mysql-test/main/subselect.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
8383
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
8484
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 'PROCEDURE ANALYSE(1))' at line 1
8585
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
86-
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 'SELECT 1))' at line 1
86+
ERROR 42000: PROCEDURE does not support subqueries or stored functions
8787
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
8888
ERROR 42S22: Unknown column 'a' in 'field list'
8989
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -1133,7 +1133,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
11331133
CREATE TABLE t1 (a int, KEY(a));
11341134
HANDLER t1 OPEN;
11351135
HANDLER t1 READ a=((SELECT 1));
1136-
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 'SELECT 1))' at line 1
1136+
ERROR 42000: HANDLER..READ does not support subqueries or stored functions
11371137
HANDLER t1 CLOSE;
11381138
drop table t1;
11391139
create table t1 (a int);

mysql-test/main/subselect.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ SELECT 1 IN (SELECT 1);
5656
SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
5757
-- error ER_PARSE_ERROR
5858
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
59-
-- error ER_PARSE_ERROR
59+
-- error ER_SUBQUERIES_NOT_SUPPORTED
6060
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
6161
-- error ER_BAD_FIELD_ERROR
6262
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
@@ -623,7 +623,7 @@ set @a:=(SELECT a from t1);
623623

624624
CREATE TABLE t1 (a int, KEY(a));
625625
HANDLER t1 OPEN;
626-
-- error ER_PARSE_ERROR
626+
-- error ER_SUBQUERIES_NOT_SUPPORTED
627627
HANDLER t1 READ a=((SELECT 1));
628628
HANDLER t1 CLOSE;
629629
drop table t1;

mysql-test/main/subselect_no_exists_to_in.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
8787
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
8888
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 'PROCEDURE ANALYSE(1))' at line 1
8989
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
90-
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 'SELECT 1))' at line 1
90+
ERROR 42000: PROCEDURE does not support subqueries or stored functions
9191
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
9292
ERROR 42S22: Unknown column 'a' in 'field list'
9393
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -1137,7 +1137,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
11371137
CREATE TABLE t1 (a int, KEY(a));
11381138
HANDLER t1 OPEN;
11391139
HANDLER t1 READ a=((SELECT 1));
1140-
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 'SELECT 1))' at line 1
1140+
ERROR 42000: HANDLER..READ does not support subqueries or stored functions
11411141
HANDLER t1 CLOSE;
11421142
drop table t1;
11431143
create table t1 (a int);

mysql-test/main/subselect_no_mat.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
9090
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
9191
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 'PROCEDURE ANALYSE(1))' at line 1
9292
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
93-
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 'SELECT 1))' at line 1
93+
ERROR 42000: PROCEDURE does not support subqueries or stored functions
9494
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
9595
ERROR 42S22: Unknown column 'a' in 'field list'
9696
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -1140,7 +1140,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
11401140
CREATE TABLE t1 (a int, KEY(a));
11411141
HANDLER t1 OPEN;
11421142
HANDLER t1 READ a=((SELECT 1));
1143-
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 'SELECT 1))' at line 1
1143+
ERROR 42000: HANDLER..READ does not support subqueries or stored functions
11441144
HANDLER t1 CLOSE;
11451145
drop table t1;
11461146
create table t1 (a int);

mysql-test/main/subselect_no_opts.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
8686
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
8787
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 'PROCEDURE ANALYSE(1))' at line 1
8888
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
89-
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 'SELECT 1))' at line 1
89+
ERROR 42000: PROCEDURE does not support subqueries or stored functions
9090
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
9191
ERROR 42S22: Unknown column 'a' in 'field list'
9292
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -1136,7 +1136,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
11361136
CREATE TABLE t1 (a int, KEY(a));
11371137
HANDLER t1 OPEN;
11381138
HANDLER t1 READ a=((SELECT 1));
1139-
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 'SELECT 1))' at line 1
1139+
ERROR 42000: HANDLER..READ does not support subqueries or stored functions
11401140
HANDLER t1 CLOSE;
11411141
drop table t1;
11421142
create table t1 (a int);

mysql-test/main/subselect_no_scache.result

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ SELECT 1 FROM (SELECT 1 as a) b WHERE 1 IN (SELECT (SELECT a));
8989
select (SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE(1));
9090
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 'PROCEDURE ANALYSE(1))' at line 1
9191
SELECT 1 FROM (SELECT 1) a PROCEDURE ANALYSE((SELECT 1));
92-
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 'SELECT 1))' at line 1
92+
ERROR 42000: PROCEDURE does not support subqueries or stored functions
9393
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NULL;
9494
ERROR 42S22: Unknown column 'a' in 'field list'
9595
SELECT (SELECT 1) as a FROM (SELECT 1) b WHERE (SELECT a) IS NOT NULL;
@@ -1139,7 +1139,7 @@ ERROR 42S02: Table 'test.t1' doesn't exist
11391139
CREATE TABLE t1 (a int, KEY(a));
11401140
HANDLER t1 OPEN;
11411141
HANDLER t1 READ a=((SELECT 1));
1142-
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 'SELECT 1))' at line 1
1142+
ERROR 42000: HANDLER..READ does not support subqueries or stored functions
11431143
HANDLER t1 CLOSE;
11441144
drop table t1;
11451145
create table t1 (a int);

0 commit comments

Comments
 (0)