Commit 0b7c49e7 authored by Marko Mäkelä's avatar Marko Mäkelä

btr_index_rec_validate(): Account for instant ADD COLUMN

parent 4f1375e3
CREATE TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB CREATE TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB
PARTITION BY KEY() PARTITIONS 3; ROW_FORMAT=REDUNDANT PARTITION BY KEY() PARTITIONS 3;
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5); INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5);
SET @saved_dbug= @@SESSION.debug_dbug; SET @saved_dbug= @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_commit_inplace_fail_2'; SET DEBUG_DBUG='+d,ib_commit_inplace_fail_2';
ALTER TABLE t1 ADD COLUMN c CHAR(3) DEFAULT 'lie'; ALTER TABLE t1 ADD COLUMN c CHAR(3) DEFAULT 'lie';
ERROR HY000: Internal error: Injected error! ERROR HY000: Internal error: Injected error!
SET DEBUG_DBUG= @saved_dbug; SET DEBUG_DBUG= @saved_dbug;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
BEGIN; BEGIN;
UPDATE t1 SET b=a+1; UPDATE t1 SET b=a+1;
INSERT INTO t1 VALUES (0,1); INSERT INTO t1 VALUES (0,1);
...@@ -22,6 +25,9 @@ SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1'; ...@@ -22,6 +25,9 @@ SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1';
ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT -42; ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT -42;
ERROR HY000: Internal error: Injected error! ERROR HY000: Internal error: Injected error!
SET DEBUG_DBUG= @saved_dbug; SET DEBUG_DBUG= @saved_dbug;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
BEGIN; BEGIN;
DELETE FROM t1; DELETE FROM t1;
INSERT INTO t1 VALUES (1,2,'foo'); INSERT INTO t1 VALUES (1,2,'foo');
...@@ -34,7 +40,7 @@ t1 CREATE TABLE `t1` ( ...@@ -34,7 +40,7 @@ t1 CREATE TABLE `t1` (
`c` char(3) DEFAULT 'lie', `c` char(3) DEFAULT 'lie',
PRIMARY KEY (`a`), PRIMARY KEY (`a`),
KEY `b` (`b`) KEY `b` (`b`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=REDUNDANT
PARTITION BY KEY () PARTITION BY KEY ()
PARTITIONS 3 PARTITIONS 3
DROP TABLE t1; DROP TABLE t1;
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
--source include/have_partition.inc --source include/have_partition.inc
CREATE TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB CREATE TABLE t1(a INT PRIMARY KEY, b INT, KEY(b)) ENGINE=InnoDB
PARTITION BY KEY() PARTITIONS 3; ROW_FORMAT=REDUNDANT PARTITION BY KEY() PARTITIONS 3;
INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5); INSERT INTO t1 (a) VALUES (1),(2),(3),(4),(5);
SET @saved_dbug= @@SESSION.debug_dbug; SET @saved_dbug= @@SESSION.debug_dbug;
SET DEBUG_DBUG='+d,ib_commit_inplace_fail_2'; SET DEBUG_DBUG='+d,ib_commit_inplace_fail_2';
--error ER_INTERNAL_ERROR --error ER_INTERNAL_ERROR
ALTER TABLE t1 ADD COLUMN c CHAR(3) DEFAULT 'lie'; ALTER TABLE t1 ADD COLUMN c CHAR(3) DEFAULT 'lie';
SET DEBUG_DBUG= @saved_dbug; SET DEBUG_DBUG= @saved_dbug;
CHECK TABLE t1;
BEGIN; BEGIN;
UPDATE t1 SET b=a+1; UPDATE t1 SET b=a+1;
INSERT INTO t1 VALUES (0,1); INSERT INTO t1 VALUES (0,1);
...@@ -20,6 +21,7 @@ SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1'; ...@@ -20,6 +21,7 @@ SET DEBUG_DBUG='+d,ib_commit_inplace_fail_1';
--error ER_INTERNAL_ERROR --error ER_INTERNAL_ERROR
ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT -42; ALTER TABLE t1 ADD COLUMN d INT NOT NULL DEFAULT -42;
SET DEBUG_DBUG= @saved_dbug; SET DEBUG_DBUG= @saved_dbug;
CHECK TABLE t1;
BEGIN; BEGIN;
DELETE FROM t1; DELETE FROM t1;
INSERT INTO t1 VALUES (1,2,'foo'); INSERT INTO t1 VALUES (1,2,'foo');
......
...@@ -4659,8 +4659,6 @@ btr_index_rec_validate( ...@@ -4659,8 +4659,6 @@ btr_index_rec_validate(
and page on error */ and page on error */
{ {
ulint len; ulint len;
ulint n;
ulint i;
const page_t* page; const page_t* page;
mem_heap_t* heap = NULL; mem_heap_t* heap = NULL;
ulint offsets_[REC_OFFS_NORMAL_SIZE]; ulint offsets_[REC_OFFS_NORMAL_SIZE];
...@@ -4691,31 +4689,34 @@ btr_index_rec_validate( ...@@ -4691,31 +4689,34 @@ btr_index_rec_validate(
return(FALSE); return(FALSE);
} }
n = dict_index_get_n_fields(index); if (!page_is_comp(page)) {
const ulint n_rec_fields = rec_get_n_fields_old(rec);
if (!page_is_comp(page) if (n_rec_fields == DICT_FLD__SYS_INDEXES__MERGE_THRESHOLD
&& (rec_get_n_fields_old(rec) != n && index->id == DICT_INDEXES_ID) {
/* a record for older SYS_INDEXES table /* A record for older SYS_INDEXES table
(missing merge_threshold column) is acceptable. */ (missing merge_threshold column) is acceptable. */
&& !(index->id == DICT_INDEXES_ID } else if (n_rec_fields < index->n_core_fields
&& rec_get_n_fields_old(rec) == n - 1))) { || n_rec_fields > index->n_fields) {
btr_index_rec_validate_report(page, rec, index); btr_index_rec_validate_report(page, rec, index);
ib::error() << "Has " << rec_get_n_fields_old(rec) ib::error() << "Has " << rec_get_n_fields_old(rec)
<< " fields, should have " << n; << " fields, should have "
<< index->n_core_fields << ".."
<< index->n_fields;
if (dump_on_error) { if (dump_on_error) {
fputs("InnoDB: corrupt record ", stderr); fputs("InnoDB: corrupt record ", stderr);
rec_print_old(stderr, rec); rec_print_old(stderr, rec);
putc('\n', stderr); putc('\n', stderr);
}
return(FALSE);
} }
return(FALSE);
} }
offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page), offsets = rec_get_offsets(rec, index, offsets, page_is_leaf(page),
ULINT_UNDEFINED, &heap); ULINT_UNDEFINED, &heap);
for (i = 0; i < n; i++) { for (unsigned i = 0; i < index->n_fields; i++) {
dict_field_t* field = dict_index_get_nth_field(index, i); dict_field_t* field = dict_index_get_nth_field(index, i);
ulint fixed_size = dict_col_get_fixed_size( ulint fixed_size = dict_col_get_fixed_size(
dict_field_get_col(field), dict_field_get_col(field),
......
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