From c7704c7ef41a542349f432036f6c8a6bae79bfd3 Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Mon, 5 Oct 2026 12:45:19 +0300 Subject: [PATCH] do_save_blob(): don't store the previous row's BLOB on OOM do_save_blob() ignored the result of copy->tmp.copy(). When the reallocation fails, copy->tmp keeps its old buffer, so the previous row's BLOB value was stored into the destination field. The error is already raised by my_malloc(MY_WME), but end_write() does not check thd->is_error() after copy_fields(), so the stale row was still written to the temporary table. The fix resets the destination field and returns when the copy fails. --- sql/field_conv.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sql/field_conv.cc b/sql/field_conv.cc index b4e2c03013c..9fc8f1aa025 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -357,7 +357,11 @@ static void do_save_blob(Copy_field *copy) char buff[MAX_FIELD_WIDTH]; String res(buff,sizeof(buff),copy->tmp.charset()); copy->from_field->val_str(&res); - copy->tmp.copy(res); + if (copy->tmp.copy(res)) + { + copy->to_field->reset(); // OOM, error already raised + return; + } ((Field_blob *) copy->to_field)->store(copy->tmp.ptr(), copy->tmp.length(), copy->tmp.charset());