Skip to content

fix(postgres): resolve view definition lookup for qualified view names#400

Merged
debba merged 2 commits into
mainfrom
fix/postgres-view-definition-regclass-cast
Jun 30, 2026
Merged

fix(postgres): resolve view definition lookup for qualified view names#400
debba merged 2 commits into
mainfrom
fix/postgres-view-definition-regclass-cast

Conversation

@debba

@debba debba commented Jun 30, 2026

Copy link
Copy Markdown
Collaborator

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 ::regclass cast was applied to a parameter the server treated as regclass rather 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 text first and then to regclass:

SELECT pg_get_viewdef(($1::text)::regclass, true) as definition

This makes the parameter bind as text, after which regclass resolution runs on the qualified name as intended.

Testing

  • Opened a PostgreSQL connection and viewed the definition of schema-qualified views, which now load correctly.

…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.
@kilo-code-bot

kilo-code-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • src-tauri/src/drivers/postgres/mod.rs - 1 line changed (fix for view definition lookup)

Fix these issues in Kilo Cloud


Reviewed by laguna-xs.2-20260421:free · Input: 457.6K · Output: 2.9K · Cached: 66.7K

@debba debba merged commit f98b7a8 into main Jun 30, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant