| 1124 | #endif |
| 1125 | |
| 1126 | bool Sql_cmd_alter_sequence::execute(THD *thd) |
| 1127 | { |
| 1128 | int error= 0; |
| 1129 | int trapped_errors= 0; |
| 1130 | LEX *lex= thd->lex; |
| 1131 | TABLE_LIST *first_table= lex->query_tables; |
| 1132 | TABLE *table; |
| 1133 | sequence_definition *new_seq= lex->create_info.seq_create_info; |
| 1134 | uint saved_used_fields= new_seq->used_fields; |
| 1135 | SEQUENCE *seq; |
| 1136 | No_such_table_error_handler no_such_table_handler; |
| 1137 | DBUG_ENTER("Sql_cmd_alter_sequence::execute"); |
| 1138 | { |
| 1139 | #if defined(HAVE_REPLICATION) |
| 1140 | /* No wakeup():s of subsequent commits is allowed in this function. */ |
| 1141 | wait_for_commit_raii suspend_wfc(thd); |
| 1142 | #endif |
| 1143 | |
| 1144 | if (check_access(thd, ALTER_ACL, first_table->db.str, |
| 1145 | &first_table->grant.privilege, |
| 1146 | &first_table->grant.m_internal, |
| 1147 | 0, 0)) |
| 1148 | DBUG_RETURN(TRUE); /* purecov: inspected */ |
| 1149 | |
| 1150 | if (check_grant(thd, ALTER_ACL, first_table, FALSE, 1, FALSE)) |
| 1151 | DBUG_RETURN(TRUE); /* purecov: inspected */ |
| 1152 | |
| 1153 | #ifdef WITH_WSREP |
| 1154 | if (WSREP(thd) && wsrep_thd_is_local(thd)) |
| 1155 | { |
| 1156 | const bool used_engine= lex->create_info.used_fields & HA_CREATE_USED_ENGINE; |
| 1157 | if (wsrep_check_sequence(thd, new_seq, used_engine)) |
| 1158 | DBUG_RETURN(TRUE); |
| 1159 | |
| 1160 | if (wsrep_to_isolation_begin(thd, first_table->db.str, |
| 1161 | first_table->table_name.str, |
| 1162 | first_table)) |
| 1163 | { |
| 1164 | DBUG_RETURN(TRUE); |
| 1165 | } |
| 1166 | } |
| 1167 | #endif /* WITH_WSREP */ |
| 1168 | |
| 1169 | if (new_seq->used_fields & seq_field_used_as) |
| 1170 | { |
| 1171 | /* This should have been prevented during parsing. */ |
| 1172 | DBUG_ASSERT(!(new_seq->used_fields - seq_field_used_as)); |
| 1173 | |
| 1174 | first_table->lock_type= TL_READ_NO_INSERT; |
| 1175 | first_table->mdl_request.set_type(MDL_SHARED_NO_WRITE); |
| 1176 | Alter_info alter_info; |
| 1177 | alter_info.flags= ALTER_CHANGE_COLUMN; |
| 1178 | if (new_seq->prepare_sequence_fields(&alter_info.create_list, true)) |
| 1179 | DBUG_RETURN(TRUE); |
| 1180 | Table_specification_st create_info; |
| 1181 | create_info.init(); |
| 1182 | create_info.alter_info= &alter_info; |
| 1183 | if (if_exists()) |
nothing calls this directly
no test coverage detected