fix: Allow proper filtering with --where in parent-child relationships#885
Open
antoniocunh wants to merge 2 commits intopercona:3.xfrom
Open
fix: Allow proper filtering with --where in parent-child relationships#885antoniocunh wants to merge 2 commits intopercona:3.xfrom
antoniocunh wants to merge 2 commits intopercona:3.xfrom
Conversation
1b6e8e3 to
fcd17c0
Compare
svetasmirnova
requested changes
Nov 13, 2024
Collaborator
svetasmirnova
left a comment
There was a problem hiding this comment.
Please add a test case.
Author
|
I would appreciate it if you could run the CI to confirm that everything is working correctly. :) |
Collaborator
|
Thank you for the update. There are instructions how to run tests in CONTRIBUTING.md I myself run following snippet: Replace paths to relevant for your system. |
svetasmirnova
requested changes
Dec 25, 2024
Collaborator
svetasmirnova
left a comment
There was a problem hiding this comment.
In my case, test fails when tries to load t/pt-online-schema-change/samples/basic_with_fks_diff_ids.sql:
$ ptmaster < t/pt-online-schema-change/samples/basic_with_fks_diff_ids.sql
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1054 (42S22) at line 45: Unknown column 'city_id' in 'field list'
Please correct this SQL file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Description:
When using the --where filter in pt-online-schema-change, an error occurs when the filter is applied to a parent table (e.g., city), and the tool attempts to propagate changes to related child tables (e.g., address). Specifically, the --where condition is applied to the parent table, but the tool erroneously tries to apply this filter to child tables that do not contain the referenced column. This causes an error, as the columns in the child tables do not exist, leading to a failure during the operation.
The issue arises because pt-online-schema-change tries to apply the filter to the child tables, where the column being referenced in the --where condition (e.g., status in city) does not exist. This behavior prevents the tool from successfully executing the change and results in the error, particularly in relationships with foreign keys between the tables.
Example SQL:
In this example, the tables city and address are related via a foreign key (city_id in address referencing id in city). If a --where filter is applied to the city table, pt-online-schema-change might incorrectly attempt to apply this filter to the address table as well, causing an error because the status column (referenced in the --where condition) does not exist in the child table.
Note: Unfortunately, I was unable to run the tests locally, so I have not included any test commits with this pull request. If this issue doesn't seem relevant, could you please provide guidance on resolving this locally so that I can run the tests correctly?