fix(plugin-postgresql): resolve effective schema when public does not exist#1665
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0e6eff53f7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return "SET search_path TO \(quotedIdentifier)" | ||
| } | ||
| return "SET search_path TO \(quotedIdentifier), public" | ||
| return "SET search_path TO \(quotedIdentifier)" |
There was a problem hiding this comment.
Preserve PostGIS lookup for spatial rendering
When a user switches to a non-public schema on a database where PostGIS is installed in public, this removes public from the session search path. The driver's own spatial rendering path still runs unqualified conversion SQL (PostGISSpatialRewrite.geometryConversionQuery / geographyConversionQuery use ST_AsEWKT(t::geometry)), so those internal PQexecParams conversions fail and the app falls back to raw EWKB hex for geometry/geography columns. Please either keep the extension schema available for these internal conversions or qualify/probe the PostGIS functions/types before dropping public.
Useful? React with 👍 / 👎.
…rch path and use USAGE-filtered fallback on Redshift
|
Follow-up from self-review (4f922c8):
|
Signed-off-by: Ngô Quốc Đạt <datlechin@gmail.com>
Fixes #1662
A PostgreSQL database with no
publicschema showed no tables and no schema selector. The user had to create an emptypublicschema to get the picker to appear.Two defects combined:
LibPQDriverCore.currentSchemawas hardcoded topublicand only updated whenSELECT current_schema()returned non-NULL. PostgreSQL returns NULL there when neitherpublicnor a$userschema exists (defaultsearch_pathis"$user", public), so every metadata query ran against a schema that does not exist.Changes:
connect()now falls back whencurrent_schema()is NULL: firstcurrent_schemas(false)[1](the first existing search_path entry, which honorsALTER ROLE/DATABASE SET search_path), then the first user schema alphabetically. On fallback it issuesSET search_pathso editor queries resolve to the same schema the sidebar shows. Runs beforeonPostConnect, so the metadata connection pool inherits the right schema.setSearchPathno longer appends, publicwhen switching schemas. Note: unqualified calls to extension functions installed inpublic(uuid-ossp, PostGIS) now require qualification after switching to another schema.public.CockroachDB and Redshift share
LibPQDriverCorebut always have apublicschema, so the fallback never triggers for them. No PluginKit types touched, no ABI change.Tests:
PostgreSQLSearchPathTests(updated for the new SET SQL), newPostgreSQLDefaultSchemaFallbackTestsandSchemaPickerVisibilityTests. All pass locally;swiftlint lint --strictclean.DBeaver had this same bug and fixed it the same way in 7.1.4 (reading the effective search_path instead of assuming
public).