Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Report: Online DDL shadow table self referencing foreign keys should reference shadow table #16204

Closed
shlomi-noach opened this issue Jun 17, 2024 · 0 comments · Fixed by #16205
Assignees
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Bug

Comments

@shlomi-noach
Copy link
Contributor

Overview of the Issue

In a vitess migration, we programmatically create a shadow table that is a duplicate of the original table, but with a another name. We take care of renaming any constraints as those must be unique across the schema and otherwise copy any foreign key definitions as-is.

However, in the case of a self-referencing foreign key, we must rename the referenced table name to match the shadow table. To illustrate, if we duplicate table t as _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_, then this statement:

create table t (id int primary key, i int, constraint f foreign key (i) references t (id))

Is today rewritten as:

create table _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id int primary key, i int, constraint f foreign key (i) references t (id))

But should turn into:

create table _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id int primary key, i int, constraint f foreign key (i) references _vt_vrp_6ace8bcef73211ea87e9f875a4d24e90_20200915120410_ (id))

Reproduction Steps

Run Online DDL vitess migration (e.g. add any column) on a self referencing foreign key table.

Binary Version

current, 20, 19, 18

Operating System and Environment details

-

Log Fragments

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Online DDL Online DDL (vitess/native/gh-ost/pt-osc) Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant