Conversation
chlunde
force-pushed
the
worktree-issue-440-extension-schema
branch
4 times, most recently
from
September 3, 2026 21:08
b0f5a07 to
be4e952
Compare
ExtensionParameters.Schema has been accepted by the CRD since the resource was introduced, but no reconciler code read it, so every extension landed in the connection's default schema. Non-relocatable extensions such as postgis cannot be moved afterwards, which made schema-scoped installs impossible through the provider. Create now appends SCHEMA to CREATE EXTENSION. Observe reads the installed schema from pg_namespace.nspname and compares it verbatim, so quoted identifiers round-trip; an unset schema is late-initialised like version. Update moves relocatable extensions with ALTER EXTENSION SET SCHEMA and lets the engine's error surface for non-relocatable ones. Update re-observes first so a version-only mismatch still issues no statement. The e2e ltree example now installs into my-schema and the check asserts the schema of both example extensions. Fixes crossplane-contrib#440 Signed-off-by: Carl Henrik Lunde <chlunde@ifi.uio.no>
chlunde
force-pushed
the
worktree-issue-440-extension-schema
branch
from
September 3, 2026 21:08
be4e952 to
1a9ae45
Compare
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.
Description of your changes
spec.forProvider.schemaonExtensionwas accepted by the CRD but never read. Every extension landed in the connection's default schema, and non-relocatable extensions (postgis) cannot be moved afterwards.CreateappendsSCHEMA <name>toCREATE EXTENSION.Observereadspg_namespace.nspnamenext toextversion, compares it verbatim with the spec, and late-initialisesschemalikeversion.Updatemoves relocatable extensions withALTER EXTENSION … SET SCHEMA. For non-relocatable ones the engine'sdoes not support SET SCHEMAsurfaces inSynced. Update re-observes first, so a version-only mismatch still issues no statement.Semantics worth a reviewer's attention:
Createwith postgres'schema "x" does not exist.QuoteIdentifier) andnspnameon read round-trip mixed case, spaces and hyphens.schemalate-initialise to their current schema (usuallypublic); nothing moves.schemaset but ignored will now try to move the extension. Relocatable: it moves. Non-relocatable:Synced=Falsewith the engine error until the spec matches reality. Before upgrading, compare specs againstSELECT extname, extnamespace::regnamespace FROM pg_extensionand fix or dropschemawhere they disagree.Fixes #440
I have:
make reviewableto ensure this PR is ready for review. (Locally asGOTOOLCHAIN=go1.26.1 make lint,make test,make check-diff; the pinned golangci-lint build panics under Go 1.27.)How has this code been tested
reconciler_test.go, both trees): Observe schema mismatch, Create statement with version and quoted schema, Update no-op when the schema matches andALTER EXTENSION … SET SCHEMAwhen it differs.ltreeexample now installs intomy-schema;check_extension_testassertshstore=public ltree=my-schemafrompg_extension. Stockpostgres:18image, no new dependencies.worktree-custom-db-scripts,cluster/local/scripts/postgres-issue-440-extension-schema/) againstimresamu/postgis:18-3.6(postgres 18, postgis 3.6.1), both cluster and namespaced passes:gis, hstore →"Mixed Case", schema-less pg_trgm →publicand late-initschema: public; ltree → missing schema stays not Ready withschema "nope" does not exist.Readywith an unchanged transition time.ALTER EXTENSION hstore SET SCHEMA publicis reverted by Update.schema: publicgivesSynced=Falsewithdoes not support SET SCHEMA; patching back recovers.DB_TYPES=postgresql make e2egreen on both passes (cluster 118 s, namespaced 111 s), temporary testsi440: PASSon both.