Commit d2914449 authored by vasil's avatar vasil

branches/5.1:

Fix Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1

Copy the BLOB fields, that are stored internally, to a safe place
(prebuilt->blob_heap) when converting a row from InnoDB format to
MySQL format in row_sel_store_mysql_rec().

The bug was introduced in:

 ------------------------------------------------------------------------
 r587 | osku | 2006-05-23 15:35:58 +0300 (Tue, 23 May 2006) | 3 lines
 
 Optimize BLOB selects by using prebuilt->blob_heap directly instead of first
 reading BLOB data to a temporary heap and then copying it to
 prebuilt->blob_heap.
 ------------------------------------------------------------------------

Approved by:	Heikki
parent 3334a68d
f4 f8
xxx zzz
f4 f8
xxx zzz
#
# Bug#34300 Tinyblob & tinytext fields currupted after export/import and alter in 5.1
# http://bugs.mysql.com/34300
#
-- source include/have_innodb.inc
-- disable_query_log
-- disable_result_log
SET @@max_allowed_packet=16777216;
DROP TABLE IF EXISTS bug34300;
CREATE TABLE bug34300 (
f4 TINYTEXT,
f6 MEDIUMTEXT,
f8 TINYBLOB
) ENGINE=InnoDB;
INSERT INTO bug34300 VALUES ('xxx', repeat('a', 8459264), 'zzz');
-- enable_result_log
SELECT f4, f8 FROM bug34300;
ALTER TABLE bug34300 ADD COLUMN (f10 INT);
SELECT f4, f8 FROM bug34300;
DROP TABLE bug34300;
......@@ -2643,6 +2643,25 @@ row_sel_store_mysql_rec(
data = rec_get_nth_field(rec, offsets,
templ->rec_field_no, &len);
if (UNIV_UNLIKELY(templ->type == DATA_BLOB)
&& len != UNIV_SQL_NULL) {
/* It is a BLOB field locally stored in the
InnoDB record: we MUST copy its contents to
prebuilt->blob_heap here because later code
assumes all BLOB values have been copied to a
safe place. */
if (prebuilt->blob_heap == NULL) {
prebuilt->blob_heap = mem_heap_create(
UNIV_PAGE_SIZE);
}
data = memcpy(mem_heap_alloc(
prebuilt->blob_heap, len),
data, len);
}
}
if (len != UNIV_SQL_NULL) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment