[Commits] c776ed4d6ec: MDEV-19848 Server crashes in check_vcol_forward_refs upon INSERT DELAYED into table with long blob key

sachin.setiya at mariadb.com sachin.setiya at mariadb.com
Tue Jul 30 01:12:57 EEST 2019


revision-id: c776ed4d6ecf9a0393a8eb53cd6660ff3eb63758 (mariadb-10.4.5-153-gc776ed4d6ec)
parent(s): 4ca016237f1a1813c9e1ce9e4227c056c53896bb
author: Sachin
committer: Sachin
timestamp: 2019-07-30 03:42:21 +0530
message:

MDEV-19848 Server crashes in check_vcol_forward_refs upon INSERT DELAYED into table with long blob key

There are 2 issues

  1st:- in make_new_field when we & into new field flag we forget
  LONG_UNIQUE_HASH_FIELD Flag.

  2nd:- We are calling parse_vcol_defs on keyinfo , but they are not in right
  form. We should call setup_keyinfo_hash_all before calling parse_vcol_defs

---
 mysql-test/main/long_unique_bugs.result |  3 +++
 mysql-test/main/long_unique_bugs.test   |  8 ++++++++
 sql/field.cc                            |  2 +-
 sql/sql_insert.cc                       |  1 +
 sql/table.cc                            | 20 ++++++++++++++++++++
 sql/table.h                             |  2 ++
 6 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/mysql-test/main/long_unique_bugs.result b/mysql-test/main/long_unique_bugs.result
index 910e5e592e1..4e831bcff92 100644
--- a/mysql-test/main/long_unique_bugs.result
+++ b/mysql-test/main/long_unique_bugs.result
@@ -268,3 +268,6 @@ DROP TABLE t1, t2;
 create table t1(a int, unique(a) using hash);
 #BULK insert > 100 rows (MI_MIN_ROWS_TO_DISABLE_INDEXES)
 drop table t1;
+CREATE  TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM;
+INSERT DELAYED t1 () VALUES ();
+DROP TABLE t1;
diff --git a/mysql-test/main/long_unique_bugs.test b/mysql-test/main/long_unique_bugs.test
index da054e59f34..b9b10b3d6cd 100644
--- a/mysql-test/main/long_unique_bugs.test
+++ b/mysql-test/main/long_unique_bugs.test
@@ -334,3 +334,11 @@ while ($count)
 --eval $insert_stmt
 --enable_query_log
 drop table t1;
+
+#
+# MDEV-19848 Server crashes in check_vcol_forward_refs upon INSERT DELAYED into table with long blob key
+#
+CREATE  TABLE t1 (a BLOB, UNIQUE(a)) ENGINE=MyISAM;
+INSERT DELAYED t1 () VALUES ();
+# Cleanup
+DROP TABLE t1;
diff --git a/sql/field.cc b/sql/field.cc
index 621f0136bea..caae3bca430 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2326,7 +2326,7 @@ Field *Field::make_new_field(MEM_ROOT *root, TABLE *new_table,
   tmp->flags&= (NOT_NULL_FLAG | BLOB_FLAG | UNSIGNED_FLAG |
                 ZEROFILL_FLAG | BINARY_FLAG | ENUM_FLAG | SET_FLAG |
                 VERS_SYS_START_FLAG | VERS_SYS_END_FLAG |
-                VERS_UPDATE_UNVERSIONED_FLAG);
+                VERS_UPDATE_UNVERSIONED_FLAG | LONG_UNIQUE_HASH_FIELD);
   tmp->reset_fields();
   tmp->invisible= VISIBLE;
   return tmp;
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index f3a548d7265..a05bc934553 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -2623,6 +2623,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd)
   if (share->virtual_fields || share->default_expressions ||
       share->default_fields)
   {
+    table->setup_keyinfo_hash_all();
     bool error_reported= FALSE;
     if (unlikely(parse_vcol_defs(client_thd, client_thd->mem_root, copy,
                                  &error_reported)))
diff --git a/sql/table.cc b/sql/table.cc
index 48421c4051e..d859152f700 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -9039,6 +9039,26 @@ void re_setup_keyinfo_hash(KEY *key_info)
                key_info->ext_key_parts= 1;
   key_info->flags&= ~HA_NOSAME;
 }
+
+/*
+  call setup_keyinfo_hash for all keys in table
+ */
+void TABLE::setup_keyinfo_hash_all()
+{
+  for (uint i= 0; i < s->keys; i++)
+    if (key_info[i].algorithm == HA_KEY_ALG_LONG_HASH)
+      setup_keyinfo_hash(&key_info[i]);
+}
+
+/*
+  call re_setup_keyinfo_hash for all keys in table
+ */
+void TABLE::re_setup_keyinfo_hash_all()
+{
+  for (uint i= 0; i < s->keys; i++)
+    if (key_info[i].algorithm == HA_KEY_ALG_LONG_HASH)
+      re_setup_keyinfo_hash(&key_info[i]);
+}
 /**
   @brief clone of current handler.
   Creates a clone of handler used in update for
diff --git a/sql/table.h b/sql/table.h
index 42c017d63af..40ff7cdba29 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1596,6 +1596,8 @@ struct TABLE
   void vers_update_fields();
   void vers_update_end();
   void find_constraint_correlated_indexes();
+  void setup_keyinfo_hash_all();
+  void re_setup_keyinfo_hash_all();
   void clone_handler_for_update();
   void delete_update_handler();
 


More information about the commits mailing list