From 8911823f65a6557ce66ea5f8aecd55b115a85606 Mon Sep 17 00:00:00 2001 From: Alexey Botchkov Date: Sat, 16 Jul 2022 16:54:03 +0400 Subject: =?UTF-8?q?MDEV-26546=20SIGSEGV's=20in=20spider=5Fdb=5Fconnect=20o?= =?UTF-8?q?n=20SHOW=20TABLE=20and=20spider=5Fdb=E2=80=A6=20=E2=80=A6=5Fmba?= =?UTF-8?q?se::connect=20(and=20SIGSEGV's=20in=20check=5Fvcol=5Fforward=5F?= =?UTF-8?q?refs=20and=20inline=5Fmysql=5Fmutex=5Flock)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Not the SPIDER issue - happens to INSERT DELAYED. the field::make_new_field does't copy the LONG_UNIQUE_HASH_FIELD flag to the new field. Though the Delayed_insert::get_local_table copies the field->vcol_info for this field. Ad a result the parse_vcol_defs doesn't create the expression for that column so the field->vcol_info->expr is NULL. Which leads to crash. Backported fix for this from 10.5 - the flagg added in the Delayed_insert::get_local_table. Another problem with the USING HASH key is thst the parse_vcol_defs modifies the table->keys content. Then the same parse_vcol_defs is called on the table copy that has keys already modified. Backported fix for that from 10.5 - key copying added tot the Delayed_insert::get_local_table. Finally - the created copy has to clear the expr_arena as this table is not in the thd->open_tables list so won't be cleared automatically. --- sql/sql_insert.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sql/sql_insert.cc') diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 7e848b3906e..085bb4ac764 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1288,6 +1288,10 @@ values_loop_end: thd->lex->current_select->first_cond_optimization= 0; } +#ifndef EMBEDDED_LIBRARY + if (lock_type == TL_WRITE_DELAYED && table->expr_arena) + table->expr_arena->free_items(); +#endif DBUG_RETURN(FALSE); abort: @@ -1304,6 +1308,8 @@ abort: */ for (Field **ptr= table_list->table->field ; *ptr ; ptr++) (*ptr)->free(); + if (table_list->table->expr_arena) + table_list->table->expr_arena->free_items(); } #endif if (table != NULL) @@ -2663,6 +2669,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) (*field)->invisible= (*org_field)->invisible; (*field)->orig_table= copy; // Remove connection (*field)->move_field_offset(adjust_ptrs); // Point at copy->record[0] + (*field)->flags|= ((*org_field)->flags & LONG_UNIQUE_HASH_FIELD); memdup_vcol(client_thd, (*field)->vcol_info); memdup_vcol(client_thd, (*field)->default_value); memdup_vcol(client_thd, (*field)->check_constraint); @@ -2671,6 +2678,10 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) } *field=0; + if (copy_keys_from_share(copy, client_thd->mem_root)) + goto error; + + if (share->virtual_fields || share->default_expressions || share->default_fields) { -- cgit v1.2.1