Additional sequence checks for Galera cluster. @param thd thread handle @param seq sequence definition @param used_engine create used ENGINE= @retval false success @retval true failure */
| 5094 | @retval true failure |
| 5095 | */ |
| 5096 | bool wsrep_check_sequence(THD* thd, |
| 5097 | const sequence_definition *seq, |
| 5098 | const bool used_engine) |
| 5099 | { |
| 5100 | enum legacy_db_type db_type; |
| 5101 | const LEX_CSTRING *engine_name; |
| 5102 | |
| 5103 | DBUG_ASSERT(WSREP(thd)); |
| 5104 | |
| 5105 | if (used_engine) |
| 5106 | { |
| 5107 | db_type= thd->lex->create_info.db_type->db_type; |
| 5108 | // Currently any dynamic storage engine is not possible to identify |
| 5109 | // using DB_TYPE_XXXX and ENGINE=SEQUENCE is one of them. |
| 5110 | // Therefore, we get storage engine name from lex. |
| 5111 | engine_name= |
| 5112 | thd->lex->m_sql_cmd->option_storage_engine_name()->name(); |
| 5113 | } |
| 5114 | else |
| 5115 | { |
| 5116 | const handlerton *hton= ha_default_handlerton(thd); |
| 5117 | db_type= hton->db_type; |
| 5118 | engine_name= hton_name(hton); |
| 5119 | } |
| 5120 | |
| 5121 | // In Galera cluster we support only InnoDB sequences |
| 5122 | if (db_type != DB_TYPE_INNODB) |
| 5123 | { |
| 5124 | // (1) CREATE TABLE ... ENGINE=SEQUENCE OR |
| 5125 | // (2) ALTER TABLE ... ENGINE= OR |
| 5126 | // Note in ALTER TABLE table->s->sequence != nullptr |
| 5127 | // (3) CREATE SEQUENCE ... ENGINE= |
| 5128 | if ((thd->lex->sql_command == SQLCOM_CREATE_TABLE && |
| 5129 | lex_string_eq(engine_name, STRING_WITH_LEN("SEQUENCE"))) || |
| 5130 | (thd->lex->sql_command == SQLCOM_ALTER_TABLE) || |
| 5131 | (thd->lex->sql_command == SQLCOM_CREATE_SEQUENCE)) |
| 5132 | { |
| 5133 | my_error(ER_NOT_SUPPORTED_YET, MYF(0), |
| 5134 | "non-InnoDB sequences in Galera cluster"); |
| 5135 | push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, |
| 5136 | ER_NOT_SUPPORTED_YET, |
| 5137 | "ENGINE=%s not supported by Galera", |
| 5138 | engine_name->str); |
| 5139 | return(true); |
| 5140 | } |
| 5141 | } |
| 5142 | |
| 5143 | // In Galera cluster it is best to use INCREMENT BY 0 with CACHE |
| 5144 | // or NOCACHE |
| 5145 | if (seq && |
| 5146 | seq->increment && |
| 5147 | seq->cache) |
| 5148 | { |
| 5149 | my_error(ER_NOT_SUPPORTED_YET, MYF(0), |
| 5150 | "CACHE without INCREMENT BY 0 in Galera cluster"); |
| 5151 | return(true); |
| 5152 | } |
| 5153 |
no test coverage detected