[Commits] d2013e7: MDEV-18982 Partition pruning with column list causes syntax error in 10.4

IgorBabaev igor at mariadb.com
Fri Apr 5 02:36:26 EEST 2019


revision-id: d2013e73288c953a6cbcdddf9688584c0353535d (mariadb-10.4.3-159-gd2013e7)
parent(s): ae15f91f227015b3e1ad3f566db9396232cf0a3f
author: Igor Babaev
committer: Igor Babaev
timestamp: 2019-04-04 16:36:26 -0700
message:

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.

---
 mysql-test/main/partition_explicit_prune.result | 9 +++++++++
 mysql-test/main/partition_explicit_prune.test   | 9 +++++++++
 sql/sql_lex.cc                                  | 1 +
 sql/sql_lex.h                                   | 1 +
 sql/sql_yacc.yy                                 | 8 +++++++-
 sql/sql_yacc_ora.yy                             | 8 +++++++-
 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 650c8d2..1199bc2 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 b8b6e48..a516527 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 4dc6b94..3f28ab9 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 8d5c248..3d31453 100644
--- a/sql/sql_lex.h
+++ b/sql/sql_lex.h
@@ -1165,6 +1165,7 @@ class st_select_lex: public st_select_lex_node
   */
   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 5869f51..11634f4 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 39095bc..f5a4e55 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 {}


More information about the commits mailing list