Skip to content

Commit 30c965f

Browse files
FooBarriorvuvova
authored andcommitted
MDEV-31777 ER_GET_ERRNO upon online alter on CONNECT table
Forbid Online for CONNECT.
1 parent 44ca37e commit 30c965f

File tree

5 files changed

+42
-17
lines changed

5 files changed

+42
-17
lines changed

sql/handler.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,10 @@ enum chf_create_flags {
371371
/* Implements SELECT ... FOR UPDATE SKIP LOCKED */
372372
#define HA_CAN_SKIP_LOCKED (1ULL << 61)
373373

374-
#define HA_LAST_TABLE_FLAG HA_CAN_SKIP_LOCKED
374+
/* This engine is not compatible with Online ALTER TABLE */
375+
#define HA_NO_ONLINE_ALTER (1ULL << 62)
376+
377+
#define HA_LAST_TABLE_FLAG HA_NO_ONLINE_ALTER
375378

376379

377380
/* bits in index_flags(index_number) for what you can do with index */

sql/sql_table.cc

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9908,14 +9908,19 @@ bool online_alter_check_autoinc(const THD *thd, const Alter_info *alter_info,
99089908
static
99099909
const char *online_alter_check_supported(const THD *thd,
99109910
const Alter_info *alter_info,
9911-
const TABLE *table, bool *online)
9911+
const TABLE *table,
9912+
const TABLE *new_table, bool *online)
99129913
{
99139914
DBUG_ASSERT(*online);
99149915

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

9920+
*online= (new_table->file->ha_table_flags() & HA_NO_ONLINE_ALTER) == 0;
9921+
if (!*online)
9922+
return new_table->file->engine_name()->str;
9923+
99199924
*online= table->s->sequence == NULL;
99209925
if (!*online)
99219926
return "SEQUENCE";
@@ -11023,20 +11028,6 @@ do_continue:;
1102311028
if (fk_prepare_copy_alter_table(thd, table, alter_info, &alter_ctx))
1102411029
goto err_new_table_cleanup;
1102511030

11026-
if (online)
11027-
{
11028-
const char *reason= online_alter_check_supported(thd, alter_info, table,
11029-
&online);
11030-
if (reason &&
11031-
alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE)
11032-
{
11033-
DBUG_ASSERT(!online);
11034-
my_error(ER_ALTER_OPERATION_NOT_SUPPORTED_REASON, MYF(0),
11035-
"LOCK=NONE", reason, "LOCK=SHARED");
11036-
goto err_new_table_cleanup;
11037-
}
11038-
}
11039-
1104011031
if (!table->s->tmp_table)
1104111032
{
1104211033
// If EXCLUSIVE lock is requested, upgrade already.
@@ -11108,6 +11099,21 @@ do_continue:;
1110811099
thd->session_tracker.state_change.mark_as_changed(thd);
1110911100
}
1111011101

11102+
if (online)
11103+
{
11104+
const char *reason= online_alter_check_supported(thd, alter_info, table,
11105+
new_table,
11106+
&online);
11107+
if (reason &&
11108+
alter_info->requested_lock == Alter_info::ALTER_TABLE_LOCK_NONE)
11109+
{
11110+
DBUG_ASSERT(!online);
11111+
my_error(ER_ALTER_OPERATION_NOT_SUPPORTED_REASON, MYF(0),
11112+
"LOCK=NONE", reason, "LOCK=SHARED");
11113+
goto err_new_table_cleanup;
11114+
}
11115+
}
11116+
1111111117
/*
1111211118
Note: In case of MERGE table, we do not attach children. We do not
1111311119
copy data for MERGE tables. Only the children have data.

storage/connect/ha_connect.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1174,7 +1174,7 @@ ulonglong ha_connect::table_flags() const
11741174
// HA_FAST_KEY_READ | causes error when sorting (???)
11751175
HA_NO_TRANSACTIONS | HA_DUPLICATE_KEY_NOT_IN_ORDER |
11761176
HA_NO_BLOBS | HA_MUST_USE_TABLE_CONDITION_PUSHDOWN |
1177-
HA_REUSES_FILE_NAMES;
1177+
HA_REUSES_FILE_NAMES | HA_NO_ONLINE_ALTER;
11781178
ha_connect *hp= (ha_connect*)this;
11791179
PTOS pos= hp->GetTableOptionStruct();
11801180

storage/connect/mysql-test/connect/r/alter.result

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,11 @@ line
272272
2Two
273273
3Three
274274
DROP TABLE t1, t2;
275+
# MDEV-31777 ER_GET_ERRNO upon online alter with concurrent DML on
276+
# CONNECT table
277+
CREATE TABLE t (a INT) ENGINE=CONNECT TABLE_TYPE=DOS;
278+
Warnings:
279+
Warning 1105 No file name. Table will use t.dos
280+
ALTER TABLE t FORCE, ALGORITHM=COPY, LOCK=NONE;
281+
ERROR 0A000: LOCK=NONE is not supported. Reason: CONNECT. Try LOCK=SHARED
282+
DROP TABLE t;

storage/connect/mysql-test/connect/t/alter.test

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ SELECT * from t2;
133133

134134
DROP TABLE t1, t2;
135135

136+
137+
--echo # MDEV-31777 ER_GET_ERRNO upon online alter with concurrent DML on
138+
--echo # CONNECT table
139+
CREATE TABLE t (a INT) ENGINE=CONNECT TABLE_TYPE=DOS;
140+
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
141+
ALTER TABLE t FORCE, ALGORITHM=COPY, LOCK=NONE;
142+
DROP TABLE t;
143+
136144
#
137145
# Clean up
138146
#

0 commit comments

Comments
 (0)