-
Notifications
You must be signed in to change notification settings - Fork 2
Fix CREATE EXTENSION on PG16+ for non-superuser installs (#14) #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jnasbyupgrade
merged 19 commits into
Postgres-Extensions:master
from
jnasbyupgrade:fix/issue-14-clean
Aug 12, 2026
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a630263
Grant owner role WITH SET so CREATE EXTENSION works on PG16+ non-supe…
jnasbyupgrade 1f37236
test: assert installer gets SET-enabled membership in owner role (iss…
jnasbyupgrade 9582bbd
Rebase issue-14 fix onto master's test/build refactor
jnasbyupgrade 56448d3
ci: restructure pg-upgrade-test matrix to avoid crossing the PG16 bou…
jnasbyupgrade 1466e5c
Fix root cause of a real NOTICE, not just suppress it; tighten CI com…
jnasbyupgrade 98cff1c
Revert %TYPE removal (intentional); suppress both known NOTICEs in th…
jnasbyupgrade a3a078f
Drop the %TYPE explanatory comment -- it's a common idiom, not an ove…
jnasbyupgrade 49b0386
Fix a real regression: GRANT requires ADMIN OPTION even for a no-op r…
jnasbyupgrade 30ef622
Fix regression test to check pg_has_role, not a raw pg_auth_members row
jnasbyupgrade 93bbc3f
Don't SET client_min_messages in the install script; that's test/buil…
jnasbyupgrade c2c255b
Fix a deeper pre-16 bug, allow genuine non-superuser installs, add re…
jnasbyupgrade cc0fc95
README: fix wrong symptom for the pg_upgrade SET-enabled-grant limita…
jnasbyupgrade 102a508
Fold non-superuser install testing into the normal suite, drop the ex…
jnasbyupgrade b2339fc
Address review: error message style, \gexec, comment sizing; correct …
jnasbyupgrade 4a48e65
Use a real ERRCODE; fix a comment that dodged the linter's letter, no…
jnasbyupgrade 6d9510d
Merge remote-tracking branch 'upstream/master' into fix/issue-14-clean
jnasbyupgrade 10bc55a
Fold in the stable-pseudo-version fixes now that #42 merged to master
jnasbyupgrade 5fc603a
Merge upstream/master (linter tightened to flag 2+ stacked dashes)
jnasbyupgrade da2c48e
sql/test_factory.sql: clarify current_user is unquoted in the RAISE m…
jnasbyupgrade File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,50 @@ | ||
| /* | ||
| * Genuine no-op: nothing in this extension has changed since 0.5.0 yet. | ||
| * This file exists purely so ALTER EXTENSION test_factory UPDATE has an | ||
| * edge to follow at all -- Postgres's version-graph resolution requires | ||
| * an actual sql/test_factory--<from>--<to>.sql file to exist for a | ||
| * transition, regardless of whether its content would be a no-op | ||
| * (confirmed directly: without this file, ALTER EXTENSION UPDATE fails | ||
| * outright with "has no update path from version 0.5.0 to version | ||
| * stable", even though nothing would actually need to change). See | ||
| * ../ai/RELEASE.md's `stable` pseudo-version workflow: every subsequent | ||
| * SQL-touching PR adds whatever ALTER .../CREATE OR REPLACE ... statements | ||
| * are needed here to bring an install on 0.5.0 up to that change. | ||
| * https://github.com/Postgres-Extensions/test_factory/issues/14: whoever | ||
| * originally installed 0.5.0 never automatically got SET-enabled (PG16+) | ||
| * or even plain (pre-16) membership in test_factory__owner -- that's the | ||
| * bug, and it applies just as much to an already-existing 0.5.0 install | ||
| * as to a fresh one (see sql/test_factory.sql's own comment for the fresh | ||
| * case). This grants it retroactively, so whoever runs this update -- and | ||
| * anyone else who later needs to SET ROLE test_factory__owner -- has it. | ||
| * | ||
| * No object in this extension changed between 0.5.0 and here, so unlike | ||
| * the fresh-install script, there's nothing to create or alter AS | ||
| * test_factory__owner, and so no role to switch to or restore. | ||
| */ | ||
| DO $body$ | ||
| BEGIN | ||
| IF current_setting('server_version_num')::int >= 160000 THEN | ||
| IF NOT pg_has_role(current_user, 'test_factory__owner', 'SET') THEN | ||
| BEGIN | ||
| EXECUTE format('GRANT test_factory__owner TO %I WITH SET TRUE', current_user); | ||
| EXCEPTION | ||
| WHEN insufficient_privilege THEN | ||
| RAISE EXCEPTION | ||
| 'role "%" lacks SET-enabled membership in "test_factory__owner", and lacks ADMIN OPTION to grant it to itself' | ||
| , current_user | ||
| USING ERRCODE = 'insufficient_privilege' | ||
| , HINT = format( | ||
| 'Ask a superuser, or a role with ADMIN OPTION on "test_factory__owner", to run: %s' | ||
| , format('GRANT test_factory__owner TO %I WITH SET TRUE;', current_user) | ||
| ); | ||
| END; | ||
| END IF; | ||
| ELSIF NOT pg_has_role(current_user, 'test_factory__owner', 'MEMBER') THEN | ||
| BEGIN | ||
| EXECUTE format('GRANT test_factory__owner TO %I', current_user); | ||
| EXCEPTION | ||
| WHEN insufficient_privilege THEN | ||
| RAISE EXCEPTION | ||
| 'role "%" is not a member of "test_factory__owner", and lacks ADMIN OPTION to grant it to itself' | ||
| , current_user | ||
| USING ERRCODE = 'insufficient_privilege' | ||
| , HINT = format( | ||
| 'Ask a superuser, or a role with ADMIN OPTION on "test_factory__owner", to run: %s' | ||
| , format('GRANT test_factory__owner TO %I;', current_user) | ||
| ); | ||
| END; | ||
| END IF; | ||
| END | ||
| $body$; | ||
|
|
||
| -- vi: expandtab ts=2 sw=2 |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,3 @@ | ||
| \set ECHO none | ||
| psql:sql/test_factory.sql:49: ERROR: pg_extension_config_dump() can only be called from an SQL script executed by CREATE EXTENSION | ||
| psql:sql/test_factory.sql:50: ERROR: pg_extension_config_dump() can only be called from an SQL script executed by CREATE EXTENSION | ||
| psql:sql/test_factory.sql:88: NOTICE: type reference _tf._test_factory.set_name%TYPE converted to text | ||
| psql:sql/test_factory.sql:110: NOTICE: type reference _tf._test_factory.set_name%TYPE converted to text | ||
| psql:sql/test_factory.sql:116: NOTICE: type reference _tf._test_factory.set_name%TYPE converted to text | ||
| psql:sql/test_factory.sql:130: ERROR: pg_extension_config_dump() can only be called from an SQL script executed by CREATE EXTENSION | ||
| psql:sql/test_factory.sql:131: ERROR: pg_extension_config_dump() can only be called from an SQL script executed by CREATE EXTENSION |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.