fix(redshift): list schemas via pg_namespace + has_schema_privilege#982
Merged
fix(redshift): list schemas via pg_namespace + has_schema_privilege#982
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
Fixes #971.
Summary
On Redshift, the schema switcher was empty for non-admin users — so users were stuck on whatever schema they connected with, with no way to switch.
Root cause
RedshiftPluginDriver.fetchSchemasqueriedinformation_schema.schemata. On Redshift this view returns only schemas the current user owns — Redshift diverges from PostgreSQL here, where USAGE alone is enough. Result: a typical role with USAGE on a few schemas saw zero entries in the dropdown.The
SET search_pathpath was already correct; the bug was upstream in the schema listing query.Repro (verified)
Redshift Serverless workgroup, non-admin role with
GRANT USAGE ON SCHEMA analytics, reporting:Fix
Single-file SQL swap in
Plugins/PostgreSQLDriverPlugin/RedshiftPluginDriver.swift:pg_namespacelists every schema in the database;has_schema_privilege(..., 'USAGE')filters to those the role can actually use. Same query works for admin (owner implicitly has USAGE) and non-admin alike.PostgreSQL's
fetchSchemasis intentionally untouched —information_schema.schematadoes the right thing on real Postgres, where USAGE is sufficient.Test plan