-
Notifications
You must be signed in to change notification settings - Fork 2
Restore sql/test_factory--0.5.0.sql to its true historical content #41
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
Closed
jnasbyupgrade
wants to merge
5
commits into
Postgres-Extensions:issue-14-clean
from
jnasbyupgrade:fix/restore-0.5.0-mess
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
39b14a0
Restore sql/test_factory--0.5.0.sql to its true historical content
jnasbyupgrade 3f3fa4a
Fix the root cause of the 0.5.0 mess: sit at the `stable` pseudo-version
jnasbyupgrade fd839b3
bin/test_existing: fix version assertion for the stable pseudo-version
jnasbyupgrade 08eae2e
Gitignore the stable pseudo-version's generated SQL files
jnasbyupgrade 9204e5a
sql/test_factory--0.5.0--stable.sql: fix a comment lifted from the wr…
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 |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| /* | ||
| * 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: this pattern also matches the update scripts the comment above it says are exempt.
The added comment states:
But in gitignore glob syntax
*matches any run of characters except/, sosql/*--stable.sqlalso matchessql/test_factory--0.5.0--stable.sql(with*=test_factory--0.5.0) — the very file this PR adds. It's harmless right now only because that file is already tracked (git doesn't apply.gitignoreto tracked paths), but the next release's analogous update script (e.g.sql/test_factory--0.6.0--stable.sql, or a futuretest_factory_pgtapone) would be silently skipped bygit add, shipping a distribution with no upgrade path and no error anywhere.A negation line after it fixes this —
sql/*--*--stable.sqlrequires two separate---delimited segments beforestable.sql, so it matches only<ext>--<version>--stable.sqlupdate scripts, not the single-segment<ext>--stable.sqlfiles this rule is meant to ignore: