Skip to content

fix(redshift): list schemas via pg_namespace + has_schema_privilege#982

Merged
datlechin merged 1 commit intomainfrom
fix/redshift-empty-schema-list
May 4, 2026
Merged

fix(redshift): list schemas via pg_namespace + has_schema_privilege#982
datlechin merged 1 commit intomainfrom
fix/redshift-empty-schema-list

Conversation

@datlechin
Copy link
Copy Markdown
Member

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.fetchSchemas queried information_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_path path 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:

-- old query (information_schema.schemata)
(0 rows)

-- new query (pg_namespace + has_schema_privilege)
analytics
public
reporting

Fix

Single-file SQL swap in Plugins/PostgreSQLDriverPlugin/RedshiftPluginDriver.swift:

SELECT nspname FROM pg_namespace
WHERE nspname NOT LIKE 'pg_%'
  AND nspname <> 'information_schema'
  AND has_schema_privilege(current_user, nspname, 'USAGE')
ORDER BY nspname

pg_namespace lists 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 fetchSchemas is intentionally untouched — information_schema.schemata does the right thing on real Postgres, where USAGE is sufficient.

Test plan

  • Connect to a Redshift cluster as a non-admin role with USAGE on a subset of schemas
  • Open ⌘K schema switcher
  • Confirm all USAGE-granted schemas appear (previously empty)
  • Switch to one of them, confirm sidebar refreshes to that schema's tables
  • Connect as admin, confirm schema list still complete
  • Connect to a real PostgreSQL instance, confirm its schema list still complete (untouched code path)

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit 56cacc8 into main May 4, 2026
2 checks passed
@datlechin datlechin deleted the fix/redshift-empty-schema-list branch May 4, 2026 07:02
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.

Redshift don't allow switching schemas

1 participant