Skip to content

Commit b31a909

Browse files
authored
Allow DB owner to set session var defaults in DB (#20858)
Fixes DOC-14457 Also updated the `ALTER DATABASE ... RESET` description to fix an inaccuracy, and backported that change to all supported versions v23.2+
1 parent 4251b66 commit b31a909

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

src/current/v23.2/alter-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
#### Required privileges
355355

src/current/v24.1/alter-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
{% include {{page.version.version}}/sql/show-default-session-variables-for-role.md %}
355355

src/current/v24.3/alter-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
{% include {{page.version.version}}/sql/show-default-session-variables-for-role.md %}
355355

src/current/v25.2/alter-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
{% include {{page.version.version}}/sql/show-default-session-variables-for-role.md %}
355355

src/current/v25.3/alter-database.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
{% include {{page.version.version}}/sql/show-default-session-variables-for-role.md %}
355355

src/current/v25.4/alter-database.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,13 +349,13 @@ For usage, see [Synopsis](#synopsis).
349349

350350
### `RESET {session variable}`
351351

352-
`ALTER DATABASE ... RESET {session variable}` resets a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for a database to its default value for the client session.
352+
`ALTER DATABASE ... RESET {session variable}` clears a database-level override of a [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) so that future sessions use the default value.
353353

354354
{% include {{page.version.version}}/sql/show-default-session-variables-for-role.md %}
355355

356356
#### Required privileges
357357

358-
No [privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) are required to reset a session setting.
358+
To reset default session variable values for a database with `ALTER DATABASE ... RESET {session variable}`, the user must be a member of the [`admin` role]({% link {{ page.version.version }}/security-reference/authorization.md %}#admin-role) or the [owner]({% link {{ page.version.version }}/security-reference/authorization.md %}#object-ownership) of the target database.
359359

360360
#### Parameters
361361

@@ -379,7 +379,9 @@ In CockroachDB, the following are aliases for `ALTER DATABASE ... RESET {session
379379

380380
#### Required privileges
381381

382-
To set the `role` session variable, the current user must be a member of the `admin` role, or a member of the target role.
382+
To set default session variable values for a database with `ALTER DATABASE ... SET {session variable}`, the user must be a member of the [`admin` role]({% link {{ page.version.version }}/security-reference/authorization.md %}#admin-role) or the [owner]({% link {{ page.version.version }}/security-reference/authorization.md %}#object-ownership) of the target database.
383+
384+
Additionally, to set the `role` session variable, the current user must be a member of the `admin` role or a member of the target role.
383385

384386
All other session variables do not require [privileges]({% link {{ page.version.version }}/security-reference/authorization.md %}#managing-privileges) to modify.
385387

src/current/v25.4/alter-role.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Password creation and alteration is supported only in secure clusters.
2323

2424
- To alter an [`admin` role]({% link {{ page.version.version }}/security-reference/authorization.md %}#admin-role), the user must be a member of the `admin` role.
2525
- To alter other roles, the user must be a member of the `admin` role or have the [`CREATEROLE`]({% link {{ page.version.version }}/create-role.md %}#create-a-role-that-can-create-other-roles-and-manage-authentication-methods-for-the-new-roles) [role option](#role-options).
26+
- {% include_cached new-in.html version="v25.4" %} For [per-database defaults](#set-default-session-variable-values-for-a-specific-database), the [owner]({% link {{ page.version.version }}/security-reference/authorization.md %}#object-ownership) of a database can execute `ALTER ROLE ALL IN DATABASE ... {SET|RESET}` for that database (in addition to users who meet the general requirements above).
2627

2728
## Synopsis
2829

@@ -228,6 +229,8 @@ SHOW statement_timeout;
228229

229230
In the following example, the `root` user creates a database named `movr`, and sets the default value of the `timezone` [session variable]({% link {{ page.version.version }}/set-vars.md %}#supported-variables) for all roles in that database.
230231

232+
{% include_cached new-in.html version="v25.4" %} The [owner]({% link {{ page.version.version }}/security-reference/authorization.md %}#object-ownership) of a database can also execute `ALTER ROLE ALL IN DATABASE ... {SET|RESET}` for that database.
233+
231234
~~~ sql
232235
CREATE DATABASE IF NOT EXISTS movr;
233236
~~~

0 commit comments

Comments
 (0)