@@ -5343,18 +5343,21 @@ int mysql_create_table_no_lock(THD *thd, const LEX_CSTRING *db,
5343
5343
#ifdef WITH_WSREP
5344
5344
/* * Additional sequence checks for Galera cluster.
5345
5345
5346
- @param thd thread handle
5347
- @param seq sequence definition
5346
+ @param thd thread handle
5347
+ @param seq sequence definition
5348
+ @param used_engine create used ENGINE=
5348
5349
@retval false success
5349
5350
@retval true failure
5350
5351
*/
5351
- bool wsrep_check_sequence (THD* thd, const sequence_definition *seq)
5352
+ bool wsrep_check_sequence (THD* thd,
5353
+ const sequence_definition *seq,
5354
+ const bool used_engine)
5352
5355
{
5353
5356
enum legacy_db_type db_type;
5354
5357
5355
5358
DBUG_ASSERT (WSREP (thd));
5356
5359
5357
- if (thd-> lex -> create_info . used_fields & HA_CREATE_USED_ENGINE )
5360
+ if (used_engine )
5358
5361
{
5359
5362
db_type= thd->lex ->create_info .db_type ->db_type ;
5360
5363
}
@@ -5385,6 +5388,57 @@ bool wsrep_check_sequence(THD* thd, const sequence_definition *seq)
5385
5388
5386
5389
return (false );
5387
5390
}
5391
+
5392
+ /* * Additional CREATE TABLE/SEQUENCE checks for Galera cluster.
5393
+
5394
+ @param thd thread handle
5395
+ @param wsrep_ctas CREATE TABLE AS SELECT ?
5396
+ @param used_engine CREATE TABLE ... ENGINE = ?
5397
+ @param create_info Create information
5398
+
5399
+ @retval false Galera cluster does support used clause
5400
+ @retval true Galera cluster does not support used clause
5401
+ */
5402
+ static
5403
+ bool wsrep_check_support (THD* thd,
5404
+ const bool wsrep_ctas,
5405
+ const bool used_engine,
5406
+ const HA_CREATE_INFO* create_info)
5407
+ {
5408
+ /* CREATE TABLE ... AS SELECT */
5409
+ if (wsrep_ctas &&
5410
+ thd->variables .wsrep_trx_fragment_size > 0 )
5411
+ {
5412
+ my_message (ER_NOT_ALLOWED_COMMAND,
5413
+ " CREATE TABLE AS SELECT is not supported with streaming replication" ,
5414
+ MYF (0 ));
5415
+ return true ;
5416
+ }
5417
+ /* CREATE TABLE .. WITH SYSTEM VERSIONING AS SELECT
5418
+ is not supported in Galera cluster.
5419
+ */
5420
+ if (wsrep_ctas &&
5421
+ create_info->versioned ())
5422
+ {
5423
+ my_error (ER_NOT_SUPPORTED_YET, MYF (0 ),
5424
+ " SYSTEM VERSIONING AS SELECT in Galera cluster" );
5425
+ return true ;
5426
+ }
5427
+ /*
5428
+ CREATE TABLE ... ENGINE=SEQUENCE is not supported in
5429
+ Galera cluster.
5430
+ CREATE SEQUENCE ... ENGINE=xxx Galera cluster supports
5431
+ only InnoDB-sequences.
5432
+ */
5433
+ if (((used_engine && create_info->db_type &&
5434
+ (create_info->db_type ->db_type == DB_TYPE_SEQUENCE ||
5435
+ create_info->db_type ->db_type >= DB_TYPE_FIRST_DYNAMIC)) ||
5436
+ thd->lex ->sql_command == SQLCOM_CREATE_SEQUENCE) &&
5437
+ wsrep_check_sequence (thd, create_info->seq_create_info , used_engine))
5438
+ return true ;
5439
+
5440
+ return false ;
5441
+ }
5388
5442
#endif /* WITH_WSREP */
5389
5443
5390
5444
/* *
@@ -5442,15 +5496,6 @@ bool mysql_create_table(THD *thd, TABLE_LIST *create_table,
5442
5496
if (!opt_explicit_defaults_for_timestamp)
5443
5497
promote_first_timestamp_column (&alter_info->create_list );
5444
5498
5445
- #ifdef WITH_WSREP
5446
- if (thd->lex ->sql_command == SQLCOM_CREATE_SEQUENCE &&
5447
- WSREP (thd) && wsrep_thd_is_local_toi (thd))
5448
- {
5449
- if (wsrep_check_sequence (thd, create_info->seq_create_info ))
5450
- DBUG_RETURN (true );
5451
- }
5452
- #endif /* WITH_WSREP */
5453
-
5454
5499
/* We can abort create table for any table type */
5455
5500
thd->abort_on_warning = thd->is_strict_mode ();
5456
5501
@@ -9764,6 +9809,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
9764
9809
TODO: this design is obsolete and will be removed.
9765
9810
*/
9766
9811
int table_kind= check_if_log_table (table_list, FALSE , NullS);
9812
+ const bool used_engine= create_info->used_fields & HA_CREATE_USED_ENGINE;
9767
9813
9768
9814
if (table_kind)
9769
9815
{
@@ -9775,7 +9821,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
9775
9821
}
9776
9822
9777
9823
/* Disable alter of log tables to unsupported engine */
9778
- if ((create_info-> used_fields & HA_CREATE_USED_ENGINE ) &&
9824
+ if ((used_engine ) &&
9779
9825
(!create_info->db_type || /* unknown engine */
9780
9826
!(create_info->db_type ->flags & HTON_SUPPORT_LOG_TABLES)))
9781
9827
{
@@ -9826,7 +9872,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
9826
9872
if we can support implementing storage engine.
9827
9873
*/
9828
9874
if (WSREP (thd) && table && table->s ->sequence &&
9829
- wsrep_check_sequence (thd, thd->lex ->create_info .seq_create_info ))
9875
+ wsrep_check_sequence (thd, thd->lex ->create_info .seq_create_info , used_engine ))
9830
9876
DBUG_RETURN (TRUE );
9831
9877
#endif /* WITH_WSREP */
9832
9878
@@ -10285,12 +10331,10 @@ do_continue:;
10285
10331
#endif
10286
10332
10287
10333
#ifdef WITH_WSREP
10334
+ // ALTER TABLE for sequence object, check can we support it
10288
10335
if (table->s ->sequence && WSREP (thd) &&
10289
- wsrep_thd_is_local_toi (thd))
10290
- {
10291
- if (wsrep_check_sequence (thd, create_info->seq_create_info ))
10336
+ wsrep_check_sequence (thd, create_info->seq_create_info , used_engine))
10292
10337
DBUG_RETURN (TRUE );
10293
- }
10294
10338
#endif /* WITH_WSREP */
10295
10339
10296
10340
/*
@@ -11744,17 +11788,11 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
11744
11788
#endif
11745
11789
11746
11790
#ifdef WITH_WSREP
11747
- if (wsrep_ctas)
11791
+ if (WSREP (thd) &&
11792
+ wsrep_check_support (thd, wsrep_ctas, used_engine, &create_info))
11748
11793
{
11749
- if (thd->variables .wsrep_trx_fragment_size > 0 )
11750
- {
11751
- my_message (
11752
- ER_NOT_ALLOWED_COMMAND,
11753
- " CREATE TABLE AS SELECT is not supported with streaming replication" ,
11754
- MYF (0 ));
11755
- res= 1 ;
11756
- goto end_with_restore_list;
11757
- }
11794
+ res= 1 ;
11795
+ goto end_with_restore_list;
11758
11796
}
11759
11797
#endif /* WITH_WSREP */
11760
11798
@@ -11906,6 +11944,7 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
11906
11944
create_table->table_name , create_table->db ))
11907
11945
goto end_with_restore_list;
11908
11946
11947
+ #ifdef WITH_WSREP
11909
11948
/*
11910
11949
In STATEMENT format, we probably have to replicate also temporary
11911
11950
tables, like mysql replication does. Also check if the requested
@@ -11914,15 +11953,15 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
11914
11953
if (WSREP (thd))
11915
11954
{
11916
11955
handlerton *orig_ht= create_info.db_type ;
11956
+
11917
11957
if (!check_engine (thd, create_table->db .str ,
11918
11958
create_table->table_name .str ,
11919
11959
&create_info) &&
11920
11960
(!thd->is_current_stmt_binlog_format_row () ||
11921
11961
!create_info.tmp_table ()))
11922
11962
{
11923
- #ifdef WITH_WSREP
11924
11963
if (thd->lex ->sql_command == SQLCOM_CREATE_SEQUENCE &&
11925
- wsrep_check_sequence (thd, lex->create_info .seq_create_info ))
11964
+ wsrep_check_sequence (thd, lex->create_info .seq_create_info , used_engine ))
11926
11965
DBUG_RETURN (true );
11927
11966
11928
11967
WSREP_TO_ISOLATION_BEGIN_ALTER (create_table->db .str , create_table->table_name .str ,
@@ -11932,13 +11971,14 @@ bool Sql_cmd_create_table_like::execute(THD *thd)
11932
11971
res= true ;
11933
11972
goto end_with_restore_list;
11934
11973
}
11935
- #endif /* WITH_WSREP */
11936
11974
}
11937
11975
// check_engine will set db_type to NULL if e.g. TEMPORARY is
11938
11976
// not supported by the storage engine, this case is checked
11939
11977
// again in mysql_create_table
11940
11978
create_info.db_type = orig_ht;
11941
11979
}
11980
+ #endif /* WITH_WSREP */
11981
+
11942
11982
/* Regular CREATE TABLE */
11943
11983
res= mysql_create_table (thd, create_table, &create_info, &alter_info);
11944
11984
}
0 commit comments