fix(postgres): resolve view definition lookup for qualified view names#400
Merged
Conversation
…efinitions pg_get_viewdef was called with $1::regclass directly. Because the parameter is sent through the extended query protocol, the cast was applied to a parameter whose type the server inferred as regclass, which fails for the bound text value. Cast the parameter to text first and then to regclass ($1::text)::regclass so the qualified view name is resolved correctly.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (1 files)
Fix these issues in Kilo Cloud Reviewed by laguna-xs.2-20260421:free · Input: 457.6K · Output: 2.9K · Cached: 66.7K |
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
Fetching a PostgreSQL view definition could fail because of how the view name parameter was passed to
pg_get_viewdef.The query used
pg_get_viewdef($1::regclass, true). Since the value is sent through the extended query protocol as a bound parameter, the::regclasscast was applied to a parameter the server treated asregclassrather than to the text we actually send. For schema-qualified view names this caused the lookup to fail instead of resolving the view.Fix
Cast the bound parameter to
textfirst and then toregclass:This makes the parameter bind as text, after which
regclassresolution runs on the qualified name as intended.Testing