Skip to content

Commit 092f25c

Browse files
author
Ramil Kalimullin
committed
Fix for bug#49465: valgrind warnings and incorrect live checksum...
Problem: inserting a record we don't set unused null bits in the record buffer if no default field values used. That may lead to wrong live checksum calculation. Fix: set unused null bits in the record buffer in such cases.
1 parent 8d329aa commit 092f25c

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

mysql-test/r/myisam.result

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,4 +1883,19 @@ CHECK TABLE t1;
18831883
Table Op Msg_type Msg_text
18841884
test.t1 check status OK
18851885
DROP TABLE t1;
1886+
#
1887+
# Bug #49465: valgrind warnings and incorrect live checksum...
1888+
#
1889+
CREATE TABLE t1(
1890+
a VARCHAR(1), b VARCHAR(1), c VARCHAR(1),
1891+
f VARCHAR(1), g VARCHAR(1), h VARCHAR(1),
1892+
i VARCHAR(1), j VARCHAR(1), k VARCHAR(1)) CHECKSUM=1;
1893+
INSERT INTO t1 VALUES('', '', '', '', '', '', '', '', '');
1894+
CHECKSUM TABLE t1 QUICK;
1895+
Table Checksum
1896+
test.t1 467455460
1897+
CHECKSUM TABLE t1 EXTENDED;
1898+
Table Checksum
1899+
test.t1 467455460
1900+
DROP TABLE t1;
18861901
End of 5.0 tests

mysql-test/t/myisam.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,4 +1225,18 @@ SELECT a FROM t1;
12251225
CHECK TABLE t1;
12261226
DROP TABLE t1;
12271227

1228+
1229+
--echo #
1230+
--echo # Bug #49465: valgrind warnings and incorrect live checksum...
1231+
--echo #
1232+
CREATE TABLE t1(
1233+
a VARCHAR(1), b VARCHAR(1), c VARCHAR(1),
1234+
f VARCHAR(1), g VARCHAR(1), h VARCHAR(1),
1235+
i VARCHAR(1), j VARCHAR(1), k VARCHAR(1)) CHECKSUM=1;
1236+
INSERT INTO t1 VALUES('', '', '', '', '', '', '', '', '');
1237+
CHECKSUM TABLE t1 QUICK;
1238+
CHECKSUM TABLE t1 EXTENDED;
1239+
DROP TABLE t1;
1240+
1241+
12281242
--echo End of 5.0 tests

sql/sql_insert.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,12 +787,21 @@ bool mysql_insert(THD *thd,TABLE_LIST *table_list,
787787
restore_record(table,s->default_values); // Get empty record
788788
else
789789
{
790+
TABLE_SHARE *share= table->s;
791+
790792
/*
791793
Fix delete marker. No need to restore rest of record since it will
792794
be overwritten by fill_record() anyway (and fill_record() does not
793795
use default values in this case).
794796
*/
795-
table->record[0][0]= table->s->default_values[0];
797+
table->record[0][0]= share->default_values[0];
798+
799+
/* Fix undefined null_bits. */
800+
if (share->null_bytes > 1 && share->last_null_bit_pos)
801+
{
802+
table->record[0][share->null_bytes - 1]=
803+
share->default_values[share->null_bytes - 1];
804+
}
796805
}
797806
if (fill_record_n_invoke_before_triggers(thd, table->field, *values, 0,
798807
table->triggers,

0 commit comments

Comments
 (0)