Skip to content

Commit

Permalink
MDEV-31777 ER_GET_ERRNO upon online alter on CONNECT table
Browse files Browse the repository at this point in the history
Forbid Online for CONNECT.
  • Loading branch information
FooBarrior authored and vuvova committed Aug 15, 2023
1 parent 44ca37e commit 30c965f
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 17 deletions.
5 changes: 4 additions & 1 deletion sql/handler.h
Expand Up @@ -371,7 +371,10 @@ enum chf_create_flags {
/* Implements SELECT ... FOR UPDATE SKIP LOCKED */
#define HA_CAN_SKIP_LOCKED (1ULL << 61)

#define HA_LAST_TABLE_FLAG HA_CAN_SKIP_LOCKED
/* This engine is not compatible with Online ALTER TABLE */
#define HA_NO_ONLINE_ALTER (1ULL << 62)

#define HA_LAST_TABLE_FLAG HA_NO_ONLINE_ALTER


/* bits in index_flags(index_number) for what you can do with index */
Expand Down
36 changes: 21 additions & 15 deletions sql/sql_table.cc
Expand Up @@ -9908,14 +9908,19 @@ bool online_alter_check_autoinc(const THD *thd, const Alter_info *alter_info,
static
const char *online_alter_check_supported(const THD *thd,
const Alter_info *alter_info,
const TABLE *table, bool *online)
const TABLE *table,
const TABLE *new_table, bool *online)
{
DBUG_ASSERT(*online);

*online= thd->locked_tables_mode != LTM_LOCK_TABLES && !table->s->tmp_table;
if (!*online)
return NULL;

*online= (new_table->file->ha_table_flags() & HA_NO_ONLINE_ALTER) == 0;
if (!*online)
return new_table->file->engine_name()->str;

*online= table->s->sequence == NULL;
if (!*online)
return "SEQUENCE";
Expand Down Expand Up @@ -11023,20 +11028,6 @@ do_continue:;
if (fk_prepare_copy_alter_table(thd, table, alter_info, &alter_ctx))
goto err_new_table_cleanup;

if (online)
{
const char *reason= online_alter_check_supported(thd, alter_info, table,
&online);
if (reason &&
alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE)
{
DBUG_ASSERT(!online);
my_error(ER_ALTER_OPERATION_NOT_SUPPORTED_REASON, MYF(0),
"LOCK=NONE", reason, "LOCK=SHARED");
goto err_new_table_cleanup;
}
}

if (!table->s->tmp_table)
{
// If EXCLUSIVE lock is requested, upgrade already.
Expand Down Expand Up @@ -11108,6 +11099,21 @@ do_continue:;
thd->session_tracker.state_change.mark_as_changed(thd);
}

if (online)
{
const char *reason= online_alter_check_supported(thd, alter_info, table,
new_table,
&online);
if (reason &&
alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE)
{
DBUG_ASSERT(!online);
my_error(ER_ALTER_OPERATION_NOT_SUPPORTED_REASON, MYF(0),
"LOCK=NONE", reason, "LOCK=SHARED");
goto err_new_table_cleanup;
}
}

/*
Note: In case of MERGE table, we do not attach children. We do not
copy data for MERGE tables. Only the children have data.
Expand Down
2 changes: 1 addition & 1 deletion storage/connect/ha_connect.cc
Expand Up @@ -1174,7 +1174,7 @@ ulonglong ha_connect::table_flags() const
// HA_FAST_KEY_READ | causes error when sorting (???)
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN |
HA_REUSES_FILE_NAMES;
HA_REUSES_FILE_NAMES | HA_NO_ONLINE_ALTER;
ha_connect *hp= (ha_connect*)this;
PTOS pos= hp->GetTableOptionStruct();

Expand Down
8 changes: 8 additions & 0 deletions storage/connect/mysql-test/connect/r/alter.result
Expand Up @@ -272,3 +272,11 @@ line
2Two
3Three
DROP TABLE t1, t2;
# MDEV-31777 ER_GET_ERRNO upon online alter with concurrent DML on
# CONNECT table
CREATE TABLE t (a INT) ENGINE=CONNECT TABLE_TYPE=DOS;
Warnings:
Warning 1105 No file name. Table will use t.dos
ALTER TABLE t FORCE, ALGORITHM=COPY, LOCK=NONE;
ERROR 0A000: LOCK=NONE is not supported. Reason: CONNECT. Try LOCK=SHARED
DROP TABLE t;
8 changes: 8 additions & 0 deletions storage/connect/mysql-test/connect/t/alter.test
Expand Up @@ -133,6 +133,14 @@ SELECT * from t2;

DROP TABLE t1, t2;


--echo # MDEV-31777 ER_GET_ERRNO upon online alter with concurrent DML on
--echo # CONNECT table
CREATE TABLE t (a INT) ENGINE=CONNECT TABLE_TYPE=DOS;
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
ALTER TABLE t FORCE, ALGORITHM=COPY, LOCK=NONE;
DROP TABLE t;

#
# Clean up
#
Expand Down

0 comments on commit 30c965f

Please sign in to comment.