Skip to content

Fix CREATE EXTENSION on PG16+ without a superuser (RDS/Aurora) (#14)#18

Open
jnasbyupgrade wants to merge 3 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix/issue-14-clean
Open

Fix CREATE EXTENSION on PG16+ without a superuser (RDS/Aurora) (#14)#18
jnasbyupgrade wants to merge 3 commits into
Postgres-Extensions:masterfrom
jnasbyupgrade:fix/issue-14-clean

Conversation

@jnasbyupgrade

@jnasbyupgrade jnasbyupgrade commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

CREATE EXTENSION test_factory fails on PostgreSQL 16+ when installed by a non-superuser role:

ERROR:  must be able to SET ROLE "test_factory__owner"

As of PG16, CREATE ROLE no longer grants the creating role a SET-enabled membership in the new role, so the install's SET ROLE test_factory__owner is rejected. A superuser bypasses the check, so this only surfaces for non-superuser installs (e.g. RDS/Aurora).

Fix: after creating the role, grant it back to the installing role WITH SET, gated on PG16+ (pre-16 GRANT ... TO already permits SET ROLE). The grant is unconditional so it also covers the case where the role already existed.

The failure can't be reproduced under pg_regress, which runs as a superuser, so the added test instead asserts the SET-enabled membership the fix establishes.

Fixes #14

🤖 Generated with Claude Code

Adds the Claude Code GitHub Actions workflows: `claude.yml` (@claude
mentions) and `claude-code-review.yml` (auto-review on PRs from the
jnasbyupgrade fork via pull_request_target, gated to that fork).
Requires the `CLAUDE_CODE_OAUTH_TOKEN` secret on this repo and the
Claude GitHub App granted access. Part of enabling Claude Code review
across the postgresql-extensions repos.

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5b9df93a-c4e9-4e12-9cd7-e30a47e4b9d1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

jnasbyupgrade and others added 2 commits July 14, 2026 17:25
…ruser

As of PG16, CREATE ROLE no longer grants the creating role a SET-enabled
membership in the new role, so the install's `SET ROLE test_factory__owner`
fails unless the current role is a superuser (which bypasses the check). This
surfaces only on non-superuser installs (e.g. RDS/Aurora).

Grant the role back to the installing role WITH SET, gated on PG16+ (pre-16
GRANT already permits SET ROLE). Unconditional, so it also covers a
pre-existing role where CREATE ROLE was a no-op.

Fixes Postgres-Extensions#14

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Postgres-Extensions#14)

The failure can't be reproduced under pg_regress, which runs as a superuser
that bypasses the SET ROLE check. Instead assert the state the fix establishes:
after install the installing role holds a SET-enabled membership in
test_factory__owner (PG16+; skipped with identical output pre-16).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jnasbyupgrade added a commit to jnasbyupgrade/test_factory that referenced this pull request Jul 15, 2026
eb84bc6 Stamp 2.1.0
9fbe6f4 Fix results ordering, control file whitespace, ENABLE_* override, debug levels (#31)
88bb4f2 Add Claude Code GitHub Actions workflows (#41)
af5bbbb ci: pass repo owners to run-tests.yml for fork-account matching (#40)
c7928af Fix repo-root guard to work inside a git worktree (#39)
b062fca ci: point reusable test workflow at @master
b6cdbfd Add CI workflows and multi-session PR guard (#33)
1ba0987 Stamp 2.0.3
1931cbe Fix pgxntool-sync remote and make it runnable without make (#37)
8176304 Stamp 2.0.2
3e142ab Fix parse_control_file: remove comments before stripping quotes (#27)
cacc301 Stamp 2.0.1
bf1db6b Fix bash 3.2 / Linux compatibility issues (#26)
62d0fcb Fix broken ifeq for --load-language=plpgsql on PG < 13 (#24)
121f0b3 Stamp 2.0.0
ad3ca7e Remove .source support; add test/install, test/build, and verify-results (Postgres-Extensions#18)
c010cf8 Fix bash 3.2 compatibility (#23)
abeb9d3 Remove .source file support from pg_regress integration (#22)
08c1879 Stamp 1.1.2
6e0dad2 Fix double --dbname bug that defeated unique test database names
639756c Stamp 1.1.1
6ba3176 Fix pg_tle exception handler and empty upgrade files (Postgres-Extensions#15)
3b8cb2a Stamp 1.1.0
550a901 Remove commit.md (maintained in pgxntool-test)
d73ca93 Add unique test database names to prevent conflicts (Postgres-Extensions#13)
9b344be Add update-setup-files.sh for 3-way merging after pgxntool-sync (Postgres-Extensions#12)
ab7f6e2 Stamp 1.0.0
3a571ba Add pg_tle support and modernize test infrastructure (Postgres-Extensions#11)
b96ea6d Add support for Claude code; build and doc improvements (Postgres-Extensions#9)
e9c24de Fix pg_regress on versions > 12 (Postgres-Extensions#5)
REVERT: bed3604 Fix pg_regress on versions > 12 (Postgres-Extensions#5) (Postgres-Extensions#6)

git-subtree-dir: pgxntool
git-subtree-split: eb84bc6e87e21f2ced11ff1b8ddb4028b7c67c8f
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.

CREATE EXTENSION fails on PG16+ without a superuser (RDS/Aurora): must be able to SET ROLE "test_factory__owner"

1 participant