Skip to content

Reject GRANT/REVOKE ON ALL in temporary schemas - #40468

Merged
SangJunBak merged 2 commits into
mainfrom
jun/sql-364-grant-mz-temp
Nov 11, 2026
Merged

SangJunBak merged 2 commits into
mainfrom
jun/sql-364-grant-mz-temp

Conversation

@SangJunBak

@SangJunBak SangJunBak commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

For RBAC handling around the temporary schema mz_temp, for the most part we throw a SQL error by detecting if it's temporary. However we missed the case for the GRANT/REVOKE ON ALL command.

Motivation

Closes: SQL-364

Description

  • Throws a SQL error for GRANT/REVOKE ON ALL ... IN SCHEMA mz_temp statements
  • Adds a SLT case next to the other error checking cases surrounding RBAC and temporary schemas

@linear-code

linear-code Bot commented Nov 4, 2026

Copy link
Copy Markdown

SQL-364

@SangJunBak
SangJunBak force-pushed the jun/sql-364-grant-mz-temp branch from 0ecb3cc to ade5043 Compare November 4, 2026 14:26
@SangJunBak

Copy link
Copy Markdown
Contributor Author

Part of me feels like rather than return an explicit mz_temp namespace, we should just filter it out wherever we get schemas and we throw an error like "mz_temp does not exist" similar to Postgres. This way we don't have to always keep temporary schemas in mind if we were to create a new RBAC command. This would lead to less descriptive errors however.

@SangJunBak
SangJunBak marked this pull request as ready for review November 4, 2026 14:57
@SangJunBak
SangJunBak requested a review from a team as a code owner November 4, 2026 14:57

@ggevay ggevay left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! One question inline

Comment thread src/sql/src/plan/statement/acl.rs Outdated
.iter()
.any(|schema| schema.schema_spec().is_temporary())
{
sql_bail!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that this also rejects the statement when the session already has temporary tables? On main, CREATE TEMP TABLE t; GRANT SELECT ON ALL TABLES IN SCHEMA mz_temp TO PUBLIC grants on t, so this changes behavior beyond fixing the panic. Rejecting looks fine to me, but could you mention it in the description and make the code comment state that rule? It currently gives only the panic as the reason. A test with a temporary table would then pin the rule: no case in this file creates one, so all three new cases take the no-temporary-schema path.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it was unintentional! I decided to go the route of accepting it if the temporary schema exists, similar to postgres. This also means changing the error message to be the same as postgres as per #40468 (comment)

…cking

- Throws a SQL error for `GRANT/REVOKE ON ALL ... IN SCHEMA mz_temp` statements
- Adds a SLT case next to the other error checking cases surrounding RBAC and temporary schemas
`GRANT/REVOKE ... ON ALL ... IN SCHEMA mz_temp` applies to the
connection's own temporary items again, as it did before the temporary
schema became lazily created. A connection that has not created a
temporary item yet gets `unknown schema 'mz_temp'`, which matches
PostgreSQL for `pg_temp`, instead of a coordinator panic.

The new test creates temporary tables on two connections and checks that
the grant and revoke only touch the issuing connection's table.
@SangJunBak
SangJunBak force-pushed the jun/sql-364-grant-mz-temp branch from ade5043 to ade9ab6 Compare November 10, 2026 20:59
@SangJunBak
SangJunBak merged commit fab8b6a into main Nov 11, 2026
86 checks passed
@SangJunBak
SangJunBak deleted the jun/sql-364-grant-mz-temp branch November 11, 2026 15:16
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.

2 participants