Skip to content

mysql: Support create table like #1569

@jasobrown-rs

Description

@jasobrown-rs

Description

create table <table_dest> like <table_src> allows you to create a new table with the schema of an existing table; no data is copied to the new table.

I think we have most of the building blocks required, but here's a brief list based on an initial survey:

  • parsing support
    • need nom-sql parsing support; seems to already be supported in sqlparser (I didn't look too closely, so this needs validation)
  • will need to filter out the target table if the source table is excluded/not included in the table replication set
  • We can get the schema of the source table from the Table service and/or reference it from MySqlBinlogConnector::table_schemas. We won't hit this statement with any degree of real frequency, so the once-in-a-blue-moon call to the Table service is fine (as long as it doesn't block any other replication activity).

The main work will probably be in try_non_ddl_action_from_query(), even though this is a DDL action 🤷; the function might need to be renamed. The reason why we end up in that function is due to the fact that the QueryEvent for the create table like does not have the StatusVarKey::UpdatedDbNames status var.

[0] MySQL 8.4 Reference Manual :: 15.1.20.3 CREATE TABLE ... LIKE Statement

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions