Commit 876ab037 authored by Marko Mäkelä's avatar Marko Mäkelä

Disable instant ADD/DROP/reorder if indexed virtual columns exist

This works around a crash in purge.
parent 83afd52e
......@@ -7,22 +7,30 @@ ROW_FORMAT=REDUNDANT;
INSERT INTO t4 SET i=1;
ALTER TABLE t4 ADD INDEX(v), LOCK=NONE;
ALTER TABLE t4 ADD COLUMN k INT, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: online rebuild with indexed virtual columns. Try LOCK=SHARED
ALTER TABLE t4 DROP k, LOCK=NONE;
ERROR 42000: Can't DROP COLUMN `k`; check that it exists
ALTER TABLE t4 DROP INDEX v, LOCK=NONE;
INSERT INTO t3 SET i=1;
ALTER TABLE t3 ADD INDEX(v), LOCK=NONE;
ALTER TABLE t3 ADD COLUMN k INT, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: online rebuild with indexed virtual columns. Try LOCK=SHARED
ALTER TABLE t3 DROP k, LOCK=NONE;
ERROR 42000: Can't DROP COLUMN `k`; check that it exists
ALTER TABLE t3 DROP INDEX v, LOCK=NONE;
INSERT INTO t2 SET i=1;
ALTER TABLE t2 ADD INDEX(v), LOCK=NONE;
ALTER TABLE t2 ADD COLUMN k INT, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: online rebuild with indexed virtual columns. Try LOCK=SHARED
ALTER TABLE t2 DROP k, LOCK=NONE;
ERROR 42000: Can't DROP COLUMN `k`; check that it exists
ALTER TABLE t2 DROP INDEX v, LOCK=NONE;
INSERT INTO t1 SET i=1;
ALTER TABLE t1 ADD INDEX(v), LOCK=NONE;
ALTER TABLE t1 ADD COLUMN k INT, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: online rebuild with indexed virtual columns. Try LOCK=SHARED
ALTER TABLE t1 DROP k, LOCK=NONE;
ERROR 42000: Can't DROP COLUMN `k`; check that it exists
ALTER TABLE t1 DROP INDEX v, LOCK=NONE;
connect ddl,localhost,root,,test;
connection default;
......
......@@ -14,7 +14,10 @@ while ($n)
{
eval INSERT INTO t$n SET i=1;
eval ALTER TABLE t$n ADD INDEX(v), LOCK=NONE;
# MDEV-17468 FIXME: Fix this, and remove the 2 --error below.
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
eval ALTER TABLE t$n ADD COLUMN k INT, LOCK=NONE;
--error ER_CANT_DROP_FIELD_OR_KEY
eval ALTER TABLE t$n DROP k, LOCK=NONE;
eval ALTER TABLE t$n DROP INDEX v, LOCK=NONE;
dec $n;
......
......@@ -1059,6 +1059,21 @@ innobase_fts_check_doc_id_col(
return(false);
}
#if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
static bool has_virtual_index(const dict_table_t& table)
{
const dict_index_t* index = table.indexes.start;
ut_ad(!index->has_virtual());
while ((index = index->indexes.next) != NULL) {
if (index->has_virtual()) {
ut_ad(table.n_v_cols);
return true;
}
}
return false;
}
#endif
/** Check if InnoDB supports a particular alter table in-place
@param altered_table TABLE object for new version of table.
@param ha_alter_info Structure describing changes to be done
......@@ -1240,6 +1255,9 @@ ha_innobase::check_if_supported_inplace_alter(
const bool supports_instant = m_prebuilt->table->supports_instant()
&& instant_alter_column_possible(ha_alter_info, table)
#if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
&& !has_virtual_index(*m_prebuilt->table)
#endif
#if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this
&& !m_prebuilt->table->fts
&& !innobase_fulltext_exist(altered_table)
......@@ -5700,6 +5718,9 @@ prepare_inplace_alter_table_dict(
if (ctx->need_rebuild() && user_table->supports_instant()
&& instant_alter_column_possible(ha_alter_info, old_table)
#if 1 // MDEV-17468: fix bugs with indexed virtual columns & remove this
&& !has_virtual_index(*user_table)
#endif
#if 1 // MDEV-17459: adjust fts_fetch_doc_from_rec() and friends; remove this
&& !user_table->fts
&& !innobase_fulltext_exist(altered_table)
......
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