Skip to content

Give the test role schema rights only, never a database-level grant - #64

Open
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:grant-schema-only
Open

Give the test role schema rights only, never a database-level grant#64
jnasbyupgrade wants to merge 1 commit into
Postgres-Extensions:masterfrom
jnasbyupgrade:grant-schema-only

Conversation

@jnasbyupgrade

Copy link
Copy Markdown
Contributor

The docs claim any role with rights on the target schema can install count_nulls, but the suite never tested that: use_test_user.sql granted the test role CREATE on the whole database, and the test role then created and owned every schema it used, so a regression making the install depend on database-level CREATE would have passed unnoticed. The connecting role now creates every schema the harness needs — the extension's target schema and _null_count_test — and grants the test role USAGE and CREATE on that one schema, so the test role holds nothing on the database on any path.

Granting only CREATE turns out to be silently useless rather than an error: CREATE EXTENSION puts "<target>", pg_temp on search_path, search_path skips a schema the role cannot USAGE, and the extension is then built in pg_temp and lost at disconnect while CREATE EXTENSION still reports success — so count_nulls_install_extension() now checks the functions actually landed in the target schema, and the docs say USAGE and CREATE rather than CREATE alone.

The docs say any role with rights on the target schema can install
count_nulls, but the suite never tested that: use_test_user.sql granted
the test role CREATE on the whole database, and the test role then
created and owned every schema it used. A regression making the install
depend on database-level CREATE would have passed unnoticed.

The connecting role now creates every schema the harness needs and
grants the test role USAGE and CREATE on that one schema, so the test
role holds nothing on the database on any path.
count_nulls_install_extension() is split from the schema creation, which
moves to count_nulls_prepare_test_schema() on the connecting role's side
of the switch; test/deps.sql likewise creates _null_count_test, which
was the only remaining reason the test role needed database CREATE.

Granting the target schema is what a caller must now supply, so the
grant stays inside count_nulls_prepare_test_user(): that is where the
role is guaranteed to exist, and a grant issued before it would fail on
a cluster that has never run the suite.

Installing with CREATE but not USAGE is silently useless rather than an
error - CREATE EXTENSION puts "<target>, pg_temp" on search_path,
search_path drops a schema the role cannot USAGE, and the whole
extension is then built in pg_temp and lost at disconnect while CREATE
EXTENSION still reports success. count_nulls_install_extension() now
checks that the functions actually landed in the target schema, and the
docs say USAGE and CREATE rather than CREATE alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 4, 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: Team

Run ID: f9b12ccc-31cf-4344-8ba5-5d9edfe63088

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

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.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Claude finished @jnasbyupgrade's task in 5m 37s —— View job


Claude is reviewing this PR

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.

1 participant