You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug#35476172: MySQL server fails when executing query
The problem here is when a partition clause in a CREATE TABLE statement
contains a subquery.
This is not valid syntax, however our problem here is that the subquery
is attached to the main query expression of the SQL command.
If this CREATE TABLE statement also contains a source query expression
for initial population of the table, this query expression will be
resolved before the table is created. But the mentioned subquery is an
incomplete structure and the resolving may thus fail.
The fix for the problem is to disallow subqueries in partition
expressions by clearing the member LEX::expr_allows_subselect while
contextualizing the partition expression. This means that such invalid
expressions will cause a syntax error.
Also renamed the expr_allows_subselect member to the more standard
looking expr_allows_subquery.
Change-Id: I40796351e37561404d372a10cd8e960c18535512
Copy file name to clipboardExpand all lines: mysql-test/r/partition_error.result
+29-1
Original file line number
Diff line number
Diff line change
@@ -1476,7 +1476,8 @@ ERROR HY000: This partition function is not allowed
1476
1476
create table t1 (a int)
1477
1477
partition by range (a + (select count(*) from t1))
1478
1478
(partition p1 values less than (1));
1479
-
ERROR HY000: This partition function is not allowed
1479
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(select count(*) from t1))
1480
+
(partition p1 values less than (1))' at line 2
1480
1481
create table t1 (a char(10))
1481
1482
partition by hash (extractvalue(a,'a'));
1482
1483
ERROR HY000: This partition function is not allowed
@@ -1938,3 +1939,30 @@ Warning 4095 Delimiter ':' in position 2 in datetime value '00:00:00' at row 1 i
1938
1939
Warning 1441 Datetime function: from_days field overflow
1939
1940
DROP TABLE t1;
1940
1941
SET sql_mode=default;
1942
+
# Bug#35476172: MySQL server fails when executing query
1943
+
CREATE TABLE t0(c1 INTEGER);
1944
+
CREATE TABLE t1(c3 INTEGER)
1945
+
PARTITION BY HASH ((SELECT c1 FROM t0));
1946
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0))' at line 2
1947
+
CREATE TABLE t1(c3 INTEGER)
1948
+
PARTITION BY HASH ((SELECT c1 FROM t0))
1949
+
AS TABLE t0;
1950
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0))
1951
+
AS TABLE t0' at line 2
1952
+
CREATE TABLE t1(c3 INTEGER)
1953
+
PARTITION BY RANGE ((SELECT c1 FROM t0)) (PARTITION a1 VALUES LESS THAN (1));
1954
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0)) (PARTITION a1 VALUES LESS THAN (1))' at line 2
1955
+
CREATE TABLE t1(c3 INTEGER)
1956
+
PARTITION BY RANGE ((SELECT c1 FROM t0)) (PARTITION a1 VALUES LESS THAN (1))
1957
+
AS TABLE t0;
1958
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0)) (PARTITION a1 VALUES LESS THAN (1))
1959
+
AS TABLE t0' at line 2
1960
+
CREATE TABLE t1(c3 INTEGER)
1961
+
PARTITION BY LIST ((SELECT c1 FROM t0)) (PARTITION p0 VALUES IN (0));
1962
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0)) (PARTITION p0 VALUES IN (0))' at line 2
1963
+
CREATE TABLE t1(c3 INTEGER)
1964
+
PARTITION BY LIST ((SELECT c1 FROM t0)) (PARTITION p0 VALUES IN (0))
1965
+
AS TABLE t0;
1966
+
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(SELECT c1 FROM t0)) (PARTITION p0 VALUES IN (0))
0 commit comments