summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-04-04 16:36:26 -0700
committerIgor Babaev <igor@askmonty.org>2019-04-04 16:36:26 -0700
commitd2013e73288c953a6cbcdddf9688584c0353535d (patch)
treeaf93870bb10b7eb6e1c4f7ca278a7c5fa01eb3d2
parentae15f91f227015b3e1ad3f566db9396232cf0a3f (diff)
downloadmariadb-git-d2013e73288c953a6cbcdddf9688584c0353535d.tar.gz
MDEV-18982 Partition pruning with column list causes syntax error in 10.4
A syntax error was reported for any INSERT statement with explicit partition selection it if i used a column list. Fixed by saving the parsing place before parsing the clause for explicit partition selection and restoring it when the clause has been parsed.
-rw-r--r--mysql-test/main/partition_explicit_prune.result9
-rw-r--r--mysql-test/main/partition_explicit_prune.test9
-rw-r--r--sql/sql_lex.cc1
-rw-r--r--sql/sql_lex.h1
-rw-r--r--sql/sql_yacc.yy8
-rw-r--r--sql/sql_yacc_ora.yy8
6 files changed, 34 insertions, 2 deletions
diff --git a/mysql-test/main/partition_explicit_prune.result b/mysql-test/main/partition_explicit_prune.result
index 650c8d268c7..1199bc263d3 100644
--- a/mysql-test/main/partition_explicit_prune.result
+++ b/mysql-test/main/partition_explicit_prune.result
@@ -1897,3 +1897,12 @@ SELECT * FROM t1 PARTITION (p0);
i
UNLOCK TABLES;
DROP TABLE t1, t2;
+#
+# MDEV-18982: INSERT using explicit patition pruning with column list
+#
+create table t1 (a int) partition by hash(a);
+insert into t1 partition (p0) (a) values (1);
+select * from t1;
+a
+1
+drop table t1;
diff --git a/mysql-test/main/partition_explicit_prune.test b/mysql-test/main/partition_explicit_prune.test
index b8b6e480ce9..a516527c055 100644
--- a/mysql-test/main/partition_explicit_prune.test
+++ b/mysql-test/main/partition_explicit_prune.test
@@ -877,3 +877,12 @@ UNLOCK TABLES;
# Cleanup
DROP TABLE t1, t2;
+
+--echo #
+--echo # MDEV-18982: INSERT using explicit patition pruning with column list
+--echo #
+
+create table t1 (a int) partition by hash(a);
+insert into t1 partition (p0) (a) values (1);
+select * from t1;
+drop table t1;
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 4dc6b94465d..3f28ab91b9a 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -2381,6 +2381,7 @@ void st_select_lex::init_query()
first_natural_join_processing= 1;
first_cond_optimization= 1;
parsing_place= NO_MATTER;
+ save_parsing_place= NO_MATTER;
exclude_from_table_unique_test= no_wrap_view_item= FALSE;
nest_level= 0;
link_next= 0;
diff --git a/sql/sql_lex.h b/sql/sql_lex.h
index 8d5c2484cbf..3d314537822 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1165,6 +1165,7 @@ public:
*/
uint hidden_bit_fields;
enum_parsing_place parsing_place; /* where we are parsing expression */
+ enum_parsing_place save_parsing_place;
enum_parsing_place context_analysis_place; /* where we are in prepare */
bool with_sum_func; /* sum function indicator */
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 5869f51cb1c..11634f47e1b 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -12052,6 +12052,8 @@ use_partition:
PARTITION_SYM '(' using_list ')' have_partitioning
{
$$= $3;
+ Select->parsing_place= Select->save_parsing_place;
+ Select->save_parsing_place= NO_MATTER;
}
;
@@ -13347,13 +13349,17 @@ insert2:
;
insert_table:
+ {
+ Select->save_parsing_place= Select->parsing_place;
+ }
table_name_with_opt_use_partition
{
LEX *lex=Lex;
//lex->field_list.empty();
lex->many_values.empty();
lex->insert_list=0;
- };
+ }
+ ;
insert_field_spec:
insert_values {}
diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy
index 39095bc8e88..f5a4e55b66f 100644
--- a/sql/sql_yacc_ora.yy
+++ b/sql/sql_yacc_ora.yy
@@ -12174,6 +12174,8 @@ use_partition:
PARTITION_SYM '(' using_list ')' have_partitioning
{
$$= $3;
+ Select->parsing_place= Select->save_parsing_place;
+ Select->save_parsing_place= NO_MATTER;
}
;
@@ -13485,13 +13487,17 @@ insert2:
;
insert_table:
+ {
+ Select->save_parsing_place= Select->parsing_place;
+ }
table_name_with_opt_use_partition
{
LEX *lex=Lex;
//lex->field_list.empty();
lex->many_values.empty();
lex->insert_list=0;
- };
+ }
+ ;
insert_field_spec:
insert_values {}