1
0
mirror of https://github.com/MariaDB/server.git synced 2026-10-23 18:49:29 +03:00

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.
This commit is contained in:
Aleksey Midenkov
2026-10-05 12:45:19 +03:00
parent bb3a52fabf
commit c7704c7ef4

View File

@@ -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());