summaryrefslogtreecommitdiff
path: root/mysql-test/main/statement-expr.test
blob: aab14963c5410e9315381bbe5eb4328da833d18b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Testing expressions of different kinds in various non-SELECT statements

--echo #
--echo # Start of 10.3 tests
--echo #

#
# Subselects in non-SELECT statements
#

CREATE TABLE t1 (id INT, id1 INT);
INSERT INTO t1 VALUES (1,7);
INSERT INTO t1 VALUES (1,8);
SELECT ROW(1,7) IN (SELECT id, id1 FROM t1 WHERE id1= 8);
EXECUTE IMMEDIATE 'SELECT ROW(1, 7) IN (SELECT id, id1 FROM t1 WHERE id1= 8)';
DROP TABLE t1;

--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE IMMEDIATE 'SELECT ?' USING (1 IN (SELECT * FROM t1));
--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE IMMEDIATE 'SELECT ?' USING (SELECT * FROM t1);


CREATE TABLE t1 (id INT);
INSERT INTO t1 VALUES (10);
CREATE PROCEDURE p1(a INT) BEGIN END;
CALL p1((1) IN (SELECT * FROM t1));
CALL p1(EXISTS (SELECT * FROM t1));
DROP PROCEDURE p1;
DROP TABLE t1;

--error ER_PARSE_ERROR
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=(1 IN (SELECT * FROM t1));
--error ER_PARSE_ERROR
SIGNAL SQLSTATE '01000' SET MYSQL_ERRNO=EXISTS (SELECT * FROM t1);

DELIMITER $$;
--error ER_PARSE_ERROR
BEGIN NOT ATOMIC
  DECLARE CONTINUE HANDLER FOR SQLWARNING
    RESIGNAL SET MYSQL_ERRNO=(1 IN (SELECT * FROM t1));
  SIGNAL SQLSTATE '01000';
END;
$$
--error ER_PARSE_ERROR
BEGIN NOT ATOMIC
  DECLARE CONTINUE HANDLER FOR SQLWARNING
    RESIGNAL SET MYSQL_ERRNO=EXISTS (SELECT * FROM t1);
  SIGNAL SQLSTATE '01000';
END;
$$
DELIMITER ;$$


--error ER_SUBQUERIES_NOT_SUPPORTED
PREPARE stmt FROM (1 IN (SELECT * FROM t1));
--error ER_SUBQUERIES_NOT_SUPPORTED
PREPARE stmt FROM EXISTS (SELECT * FROM t1);

--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE IMMEDIATE (1 IN (SELECT * FROM t1));
--error ER_SUBQUERIES_NOT_SUPPORTED
EXECUTE IMMEDIATE EXISTS (SELECT * FROM t1);

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

--error ER_SUBQUERIES_NOT_SUPPORTED
PURGE BINARY LOGS BEFORE (1 IN (SELECT * FROM t1));
--error ER_SUBQUERIES_NOT_SUPPORTED
PURGE BINARY LOGS BEFORE EXISTS (SELECT * FROM t1);

CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2),(3);
DO 1 IN (SELECT * FROM t1);
DO EXISTS (SELECT * FROM t1);
DROP TABLE t1;