Apply table/schema filters when fetching FK constraints#30
Open
teknogeek0 wants to merge 1 commit into
Open
Conversation
schema_list_fk_constraints ignored its SourceFilters parameter, fetching all FK constraints regardless of --exclude-table or --exclude-schema filters. This caused the post-restore constraint step to fail when either the referencing or referenced table was absent from the target. Add listSourceFKConstraintsSQL[] with filter-aware variants matching the pattern used by listSourceIndexesSQL. The EXCL variant excludes any FK constraint where either the referencing or the referenced table is in an excluded schema or table list. Add a filtering test covering both the excluded-schema and excluded-table cases.
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.
Summary
schema_list_fk_constraintsaccepted aSourceFilters *parameter but never used it, causing all FK constraints to be fetched regardless of--exclude-tableor--exclude-schemafiltersALTER TABLE ... ADD CONSTRAINT ... FOREIGN KEYstep failedChanges
listSourceFKConstraintsSQL[]with filter-aware SQL variants following the same pattern aslistSourceIndexesSQLfilter_exclude_schemaandfilter_exclude_table, skipping constraints where either side is excludedfilter_include_only_tableprepareFiltersis already idempotent (filters->preparedguard), so calling it from bothschema_list_all_indexesandschema_list_fk_constraintsin the same session is safeTest plan
foo.tbl_ref_target(excluded by table filter) andfoo.tbl_with_fk_to_excluded_tbl(FK referencing the excluded table) to the filtering test fixture5-fk-constraints.sqlverifies both the excluded-schema and excluded-table FK scenarios result in count 0 on the targetDOCKER=podman PGVERSION=16 make tests) passes