mirror of
https://github.com/MariaDB/server.git
synced 2025-01-27 01:04:19 +01:00
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
This commit is contained in:
parent
224f923761
commit
063bc007b7
3 changed files with 53 additions and 0 deletions
4
mysql-test/innodb_bug34300.result
Normal file
4
mysql-test/innodb_bug34300.result
Normal file
|
@ -0,0 +1,4 @@
|
|||
f4 f8
|
||||
xxx zzz
|
||||
f4 f8
|
||||
xxx zzz
|
30
mysql-test/innodb_bug34300.test
Normal file
30
mysql-test/innodb_bug34300.test
Normal file
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue