sql: add TEMPORARY database privilege and fix temp table privilege checking#165992
Conversation
|
😎 Merged successfully - details. |
960370f to
bcaee6f
Compare
⚪ Sysbench [SQL, 3node, oltp_read_write]
Reproducebenchdiff binaries: mkdir -p benchdiff/bcaee6f/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/bcaee6f7f340b008a60cc1ba39c47cd417bfd477/bin/pkg_sql_tests benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/SQL/3node/oltp_read_write$ --old=3adb876 --new=bcaee6f --memprofile ./pkg/sql/tests⚪ Sysbench [KV, 3node, oltp_read_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/bcaee6f/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/bcaee6f7f340b008a60cc1ba39c47cd417bfd477/bin/pkg_sql_tests benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_read_only$ --old=3adb876 --new=bcaee6f --memprofile ./pkg/sql/tests🔴 Sysbench [KV, 3node, oltp_write_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/bcaee6f/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/bcaee6f7f340b008a60cc1ba39c47cd417bfd477/bin/pkg_sql_tests benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/bcaee6f/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_write_only$ --old=3adb876 --new=bcaee6f --memprofile ./pkg/sql/testsArtifactsdownload: mkdir -p new
gcloud storage cp gs://cockroach-microbench-ci/artifacts/bcaee6f7f340b008a60cc1ba39c47cd417bfd477/23228184745-1/\* new/
mkdir -p old
gcloud storage cp gs://cockroach-microbench-ci/artifacts/3adb876f73cd66afdc7713bae1eb14a228d325ef/23228184745-1/\* old/built with commit: bcaee6f7f340b008a60cc1ba39c47cd417bfd477 |
bcaee6f to
276440d
Compare
⚪ Sysbench [SQL, 3node, oltp_read_write]
Reproducebenchdiff binaries: mkdir -p benchdiff/276440d/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/276440dbba809506bab505712755bc8d0bac449d/bin/pkg_sql_tests benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/SQL/3node/oltp_read_write$ --old=3adb876 --new=276440d --memprofile ./pkg/sql/tests⚪ Sysbench [KV, 3node, oltp_read_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/276440d/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/276440dbba809506bab505712755bc8d0bac449d/bin/pkg_sql_tests benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_read_only$ --old=3adb876 --new=276440d --memprofile ./pkg/sql/tests⚪ Sysbench [KV, 3node, oltp_write_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/276440d/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/276440dbba809506bab505712755bc8d0bac449d/bin/pkg_sql_tests benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/276440d/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_write_only$ --old=3adb876 --new=276440d --memprofile ./pkg/sql/testsArtifactsdownload: mkdir -p new
gcloud storage cp gs://cockroach-microbench-ci/artifacts/276440dbba809506bab505712755bc8d0bac449d/23229657213-1/\* new/
mkdir -p old
gcloud storage cp gs://cockroach-microbench-ci/artifacts/3adb876f73cd66afdc7713bae1eb14a228d325ef/23229657213-1/\* old/built with commit: 276440dbba809506bab505712755bc8d0bac449d |
…ecking This commit adds a new TEMPORARY database privilege that controls whether a user can create temporary tables and views. This aligns CockroachDB with PostgreSQL's privilege model where TEMPORARY is a database-level privilege granted to PUBLIC by default. The privilege check is version-gated on V26_2 so that during mixed-version clusters the old behavior (checking CREATE on the schema) is preserved. Key changes: - Add TEMPORARY to the privilege kind enum and wire it through the privilege system. - In the optbuilder's resolveSchemaForCreate, check TEMPORARY on the database instead of CREATE on the schema for temp objects after V26_2. - Handle TEMPORARY privilege specially in optCatalog.CheckPrivilege to resolve against the database descriptor. - Add logic tests for the new privilege behavior with skipif/onlyif for mixed-version configs. Release note (sql change): Added TEMPORARY database privilege that controls whether users can create temporary tables and views. This privilege is granted to the public role by default on new databases, matching PostgreSQL behavior. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
Add a cluster version migration (V26_2_GrantTemporaryToPublic) that grants the TEMPORARY privilege to the public role on all existing databases. This ensures that existing databases match the behavior of newly created databases where PUBLIC has TEMPORARY by default. The migration iterates over all database descriptors and adds the TEMPORARY privilege to the public role if it is not already present. Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
276440d to
d256406
Compare
⚪ Sysbench [SQL, 3node, oltp_read_write]
Reproducebenchdiff binaries: mkdir -p benchdiff/d256406/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/d256406140a7ce6a0aeabf1cb62e74ef7691217a/bin/pkg_sql_tests benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/SQL/3node/oltp_read_write$ --old=3adb876 --new=d256406 --memprofile ./pkg/sql/tests⚪ Sysbench [KV, 3node, oltp_read_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/d256406/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/d256406140a7ce6a0aeabf1cb62e74ef7691217a/bin/pkg_sql_tests benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_read_only$ --old=3adb876 --new=d256406 --memprofile ./pkg/sql/tests⚪ Sysbench [KV, 3node, oltp_write_only]
Reproducebenchdiff binaries: mkdir -p benchdiff/d256406/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/d256406140a7ce6a0aeabf1cb62e74ef7691217a/bin/pkg_sql_tests benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/d256406/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
mkdir -p benchdiff/3adb876/bin/1058449141
gcloud storage cp gs://cockroach-microbench-ci/builds/3adb876f73cd66afdc7713bae1eb14a228d325ef/bin/pkg_sql_tests benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_tests
chmod +x benchdiff/3adb876/bin/1058449141/cockroachdb_cockroach_pkg_sql_testsbenchdiff command: # NB: for best (most stable) results, also add a suitable `--benchtime` that
# results in ~1s to ~5s of benchmark runs. For example, if ops average ~3ms, a
# benchtime of `1000x` is appropriate.
#
# Some benchmarks (in particular BenchmarkSysbench) output additional memory
# profiles covering only the execution (excluding the setup/teardown) - those
# should be preferred for analysis since they more closely correspond to what's
# reported as B/op and alloc/op.
benchdiff --run=^BenchmarkSysbench/KV/3node/oltp_write_only$ --old=3adb876 --new=d256406 --memprofile ./pkg/sql/testsArtifactsdownload: mkdir -p new
gcloud storage cp gs://cockroach-microbench-ci/artifacts/d256406140a7ce6a0aeabf1cb62e74ef7691217a/23231140061-1/\* new/
mkdir -p old
gcloud storage cp gs://cockroach-microbench-ci/artifacts/3adb876f73cd66afdc7713bae1eb14a228d325ef/23231140061-1/\* old/built with commit: d256406140a7ce6a0aeabf1cb62e74ef7691217a |
fqazi
left a comment
There was a problem hiding this comment.
@fqazi partially reviewed 45 files and made 1 comment.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on shghasemi).
|
TFTR! /trunk merge |
Summary
This PR fixes #165984 —
CREATE TEMP TABLEincorrectly requiredCREATEprivilege on thepublicschema, and CockroachDB was missing PostgreSQL'sTEMPORARYdatabase privilege.Commit 1: Add TEMPORARY privilege and fix temp table privilege checking
TEMPORARYprivilege kind (withTEMPas a parser alias), valid on database objects.TEMPORARYtoPUBLICby default on newly created databases, matching PostgreSQL.CREATE-on-schema check for temp objects; the execution-time code checksTEMPORARYon the database instead.SHOW GRANTS ON DATABASEoutput.Commit 2: Migration to grant TEMPORARY to PUBLIC on existing databases
V26_2_GrantTemporaryToPublic.TEMPORARYtoPUBLICwhere missing.Fixes: #165984