Skip to content

Commit 9b7424f

Browse files
author
Sreeharsha Ramanavarapu
committed
Bug #27460607: INCORRECT BEHAVIOR OF IODKU WHEN
INSERT SELECT's SOURCE TABLE IS EMPTY Issue: ------ When the VALUES part of ON DUPLICATE KEY UPDATE contains a BLOB value, it is handled using the LEX::insert_update_values_map. The issue in this bug is similar to the one in Bug #25361251. LEX::insert_update_values_map is initialized but not freed. This is because in an INSERT...SELECT statement, if the SELECT part doesn't produce any rows, write_record() isn't called. Solution: --------- As part of the fix for Bug #25361251, I added LEX::clear_values_map() to write_record(). But a better place to do the cleanup would be the end of the functions Sql_cmd_insert_select::execute and Sql_cmd_insert::execute. This will make the design more similar to 8.0/trunk of having LEX::clear_values_map() at the end of Sql_cmd_dml::execute().
1 parent f9f98f7 commit 9b7424f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sql/sql_insert.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -1902,7 +1902,6 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, COPY_INFO *update)
19021902
thd->get_transaction()->mark_modified_non_trans_table(
19031903
Transaction_ctx::STMT);
19041904
free_root(&mem_root, MYF(0));
1905-
thd->lex->clear_values_map();
19061905
DBUG_RETURN(trg_error);
19071906

19081907
err:
@@ -1922,7 +1921,6 @@ int write_record(THD *thd, TABLE *table, COPY_INFO *info, COPY_INFO *update)
19221921
my_safe_afree(key, table->s->max_unique_length, MAX_KEY_LENGTH);
19231922
table->column_bitmaps_set(save_read_set, save_write_set);
19241923
free_root(&mem_root, MYF(0));
1925-
thd->lex->clear_values_map();
19261924
DBUG_RETURN(1);
19271925
}
19281926

@@ -3130,6 +3128,8 @@ bool Sql_cmd_insert::execute(THD *thd)
31303128
DBUG_ASSERT(!debug_sync_set_action(current_thd,
31313129
STRING_WITH_LEN(act)));
31323130
};);
3131+
3132+
thd->lex->clear_values_map();
31333133
return res;
31343134
}
31353135

@@ -3223,6 +3223,7 @@ bool Sql_cmd_insert_select::execute(THD *thd)
32233223
thd->first_successful_insert_id_in_cur_stmt=
32243224
thd->first_successful_insert_id_in_prev_stmt;
32253225

3226+
thd->lex->clear_values_map();
32263227
return res;
32273228
}
32283229

0 commit comments

Comments
 (0)