mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder
row_log_table_get_pk_old_col(): For replacing a NULL value for a
column of the being-added primary key, look up the correct
default value, even if columns had been instantly reordered or
dropped earlier. This ought to have been broken ever since
commit 0e5a4ac253
(MDEV-15562).
This commit is contained in:
@ -343,6 +343,30 @@ UPDATE t1 SET b = 1;
|
|||||||
SET DEBUG_SYNC='now SIGNAL update';
|
SET DEBUG_SYNC='now SIGNAL update';
|
||||||
connection con2;
|
connection con2;
|
||||||
connection default;
|
connection default;
|
||||||
|
DROP TABLE t1;
|
||||||
|
#
|
||||||
|
# MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (a INT, b INT, c INT, col INT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 () VALUES ();
|
||||||
|
ALTER TABLE t1 DROP b, DROP c, DROP col;
|
||||||
|
ALTER TABLE t1 ADD COLUMN col INT;
|
||||||
|
ALTER TABLE t1 DROP a, DROP col, ADD COLUMN b INT;
|
||||||
|
connection con2;
|
||||||
|
SET SQL_MODE= '';
|
||||||
|
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR dml';
|
||||||
|
ALTER TABLE t1 ADD PRIMARY KEY(b);
|
||||||
|
connection default;
|
||||||
|
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
|
||||||
|
UPDATE t1 SET b = 1;
|
||||||
|
SET DEBUG_SYNC = 'now SIGNAL dml';
|
||||||
|
connection con2;
|
||||||
|
Warnings:
|
||||||
|
Warning 1265 Data truncated for column 'b' at row 1
|
||||||
|
connection default;
|
||||||
|
SELECT * FROM t1;
|
||||||
|
b
|
||||||
|
1
|
||||||
SET DEBUG_SYNC='RESET';
|
SET DEBUG_SYNC='RESET';
|
||||||
disconnect con2;
|
disconnect con2;
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -385,6 +385,32 @@ SET DEBUG_SYNC='now SIGNAL update';
|
|||||||
--reap
|
--reap
|
||||||
|
|
||||||
--connection default
|
--connection default
|
||||||
|
DROP TABLE t1;
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-21658 Error on online ADD PRIMARY KEY after instant DROP/reorder
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
CREATE TABLE t1 (a INT, b INT, c INT, col INT) ENGINE=InnoDB;
|
||||||
|
INSERT INTO t1 () VALUES ();
|
||||||
|
ALTER TABLE t1 DROP b, DROP c, DROP col;
|
||||||
|
ALTER TABLE t1 ADD COLUMN col INT;
|
||||||
|
ALTER TABLE t1 DROP a, DROP col, ADD COLUMN b INT;
|
||||||
|
|
||||||
|
--connection con2
|
||||||
|
SET SQL_MODE= '';
|
||||||
|
SET DEBUG_SYNC = 'row_log_table_apply1_before SIGNAL scanned WAIT_FOR dml';
|
||||||
|
send ALTER TABLE t1 ADD PRIMARY KEY(b);
|
||||||
|
|
||||||
|
--connection default
|
||||||
|
SET DEBUG_SYNC = 'now WAIT_FOR scanned';
|
||||||
|
UPDATE t1 SET b = 1;
|
||||||
|
SET DEBUG_SYNC = 'now SIGNAL dml';
|
||||||
|
--connection con2
|
||||||
|
reap;
|
||||||
|
--connection default
|
||||||
|
SELECT * FROM t1;
|
||||||
|
|
||||||
SET DEBUG_SYNC='RESET';
|
SET DEBUG_SYNC='RESET';
|
||||||
--disconnect con2
|
--disconnect con2
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
@ -1137,6 +1137,7 @@ row_log_table_get_pk_old_col(
|
|||||||
/** Maps an old table column of a PRIMARY KEY column.
|
/** Maps an old table column of a PRIMARY KEY column.
|
||||||
@param[in] ifield clustered index field in the new table (after
|
@param[in] ifield clustered index field in the new table (after
|
||||||
ALTER TABLE)
|
ALTER TABLE)
|
||||||
|
@param[in] index the clustered index of ifield
|
||||||
@param[in,out] dfield clustered index tuple field in the new table
|
@param[in,out] dfield clustered index tuple field in the new table
|
||||||
@param[in,out] heap memory heap for allocating dfield contents
|
@param[in,out] heap memory heap for allocating dfield contents
|
||||||
@param[in] rec clustered index leaf page record in the old
|
@param[in] rec clustered index leaf page record in the old
|
||||||
@ -1152,6 +1153,7 @@ static
|
|||||||
dberr_t
|
dberr_t
|
||||||
row_log_table_get_pk_col(
|
row_log_table_get_pk_col(
|
||||||
const dict_field_t* ifield,
|
const dict_field_t* ifield,
|
||||||
|
const dict_index_t* index,
|
||||||
dfield_t* dfield,
|
dfield_t* dfield,
|
||||||
mem_heap_t* heap,
|
mem_heap_t* heap,
|
||||||
const rec_t* rec,
|
const rec_t* rec,
|
||||||
@ -1175,14 +1177,19 @@ row_log_table_get_pk_col(
|
|||||||
return(DB_INVALID_NULL);
|
return(DB_INVALID_NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
ulint n_default_cols = i - DATA_N_SYS_COLS;
|
ulint new_i = dict_col_get_clust_pos(ifield->col, index);
|
||||||
|
|
||||||
|
if (UNIV_UNLIKELY(new_i >= log->defaults->n_fields)) {
|
||||||
|
ut_ad(0);
|
||||||
|
return DB_INVALID_NULL;
|
||||||
|
}
|
||||||
|
|
||||||
field = static_cast<const byte*>(
|
field = static_cast<const byte*>(
|
||||||
log->defaults->fields[n_default_cols].data);
|
log->defaults->fields[new_i].data);
|
||||||
if (!field) {
|
if (!field) {
|
||||||
return(DB_INVALID_NULL);
|
return(DB_INVALID_NULL);
|
||||||
}
|
}
|
||||||
len = log->defaults->fields[i - DATA_N_SYS_COLS].len;
|
len = log->defaults->fields[new_i].len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rec_offs_nth_extern(offsets, i)) {
|
if (rec_offs_nth_extern(offsets, i)) {
|
||||||
@ -1341,7 +1348,7 @@ row_log_table_get_pk(
|
|||||||
}
|
}
|
||||||
|
|
||||||
log->error = row_log_table_get_pk_col(
|
log->error = row_log_table_get_pk_col(
|
||||||
ifield, dfield, *heap,
|
ifield, new_index, dfield, *heap,
|
||||||
rec, offsets, i, zip_size, max_len,
|
rec, offsets, i, zip_size, max_len,
|
||||||
log);
|
log);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user