MXS-2264: Add support for RENAME TABLE

RENAME TABLE is now fully supported and works as expected. With the fix to
table versioning, the new table name will receive the latest version
number.
This commit is contained in:
Markus Mäkelä
2019-09-30 09:57:07 +03:00
parent 7767231c8f
commit b223e6eed3
3 changed files with 66 additions and 2 deletions

View File

@ -804,6 +804,13 @@ bool is_alter_table_statement(pcre2_code* alter_table_re, char* ptr, size_t len)
return rc > 0;
}
bool is_rename_table_statement(const char* sql)
{
int err = 0;
const char* pattern = "(?i)^\\s*rename\\s*table\\s*";
return mxs_pcre2_simple_match(pattern, sql, 0, &err) == MXS_PCRE2_MATCH;
}
/** Database name offset */
#define DBNM_OFF 8
@ -1006,7 +1013,10 @@ void Rpl::handle_query_event(REP_HEADER* hdr, uint8_t* ptr)
MXS_ERROR("Alter statement to table '%s' has no preceding create statement.", ident);
}
}
// TODO: Add COMMIT handling for non-transactional tables
else if (is_rename_table_statement(sql))
{
table_create_rename(db, sql, sql + len);
}
MXS_FREE(tmp);
}