Skip to content

Commit cbcb080

Browse files
committed
MDEV-37328 Assertion failure in make_empty_rec upon CONVERT PARTITION
ALTER TABLE ... CONVERT invokes build_frm_image() three times on the same data structures. The latter should not increment create_info->null_bits on every invocation.
1 parent 03dd699 commit cbcb080

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

mysql-test/suite/parts/r/alter_table.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,4 +383,15 @@ disconnect con1;
383383
connection default;
384384
drop user u@localhost;
385385
drop database db;
386+
#
387+
# MDEV-37328 Assertion failure in make_empty_rec upon CONVERT PARTITION
388+
#
389+
create table t (f1 int, f2 int, f3 int, f4 int, f5 int, f6 int, f7 int) engine=myisam
390+
partition by list (f3) (
391+
partition p0 values in (null,0),
392+
partition p1 values in (1,2,3),
393+
partition p2 default
394+
);
395+
alter table t convert partition p0 to table tp;
396+
drop table if exists tp, t;
386397
# End of 10.11 tests

mysql-test/suite/parts/t/alter_table.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,4 +347,16 @@ alter table t1 convert table tp to partition p2 values less than (1000);
347347
drop user u@localhost;
348348
drop database db;
349349

350+
--echo #
351+
--echo # MDEV-37328 Assertion failure in make_empty_rec upon CONVERT PARTITION
352+
--echo #
353+
create table t (f1 int, f2 int, f3 int, f4 int, f5 int, f6 int, f7 int) engine=myisam
354+
partition by list (f3) (
355+
partition p0 values in (null,0),
356+
partition p1 values in (1,2,3),
357+
partition p2 default
358+
);
359+
alter table t convert partition p0 to table tp;
360+
drop table if exists tp, t;
361+
350362
--echo # End of 10.11 tests

sql/unireg.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,8 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
288288
DBUG_ENTER("build_frm_image");
289289

290290
/* If fixed row records, we need one bit to check for deleted rows */
291-
if (!(create_info->table_options & HA_OPTION_PACK_RECORD))
292-
create_info->null_bits++;
293-
data_offset= (create_info->null_bits + 7) / 8;
291+
bool need_deleted_bit= !(create_info->table_options & HA_OPTION_PACK_RECORD);
292+
data_offset= (create_info->null_bits + need_deleted_bit + 7) / 8;
294293

295294
error= pack_vcols(thd, &vcols,
296295
create_fields, create_info->check_constraint_list);

0 commit comments

Comments
 (0)