Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2eda8df

Browse files
committed
Make it possibly to specify GUC params per user and per database.
Create a new catalog pg_db_role_setting where they are now stored, and betterencapsulate the code that deals with settings into its realm. The olddatconfig and rolconfig columns are removed.psql has gained a \drds command to display the settings.Backwards compatibility warning: while the backwards-compatible system viewsstill have the config columns, they no longer completely represent theconfiguration for a user or database.Catalog version bumped.
1 parent07cefdf commit2eda8df

32 files changed

+738
-279
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.208 2009/10/05 19:24:32 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.209 2009/10/07 22:14:14 alvherre Exp $ -->
22
<!--
33
Documentation of the system catalogs, directed toward PostgreSQL developers
44
-->
@@ -203,6 +203,11 @@
203203
<entry>query rewrite rules</entry>
204204
</row>
205205

206+
<row>
207+
<entry><link linkend="catalog-pg-db-role-setting"><structname>pg_db_role_setting</structname></link></entry>
208+
<entry>per-role and per-database settings</entry>
209+
</row>
210+
206211
<row>
207212
<entry><link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link></entry>
208213
<entry>dependencies on shared objects</entry>
@@ -2136,13 +2141,6 @@
21362141
</entry>
21372142
</row>
21382143

2139-
<row>
2140-
<entry><structfield>datconfig</structfield></entry>
2141-
<entry><type>text[]</type></entry>
2142-
<entry></entry>
2143-
<entry>Session defaults for run-time configuration variables</entry>
2144-
</row>
2145-
21462144
<row>
21472145
<entry><structfield>datacl</structfield></entry>
21482146
<entry><type>aclitem[]</type></entry>
@@ -4106,6 +4104,65 @@
41064104

41074105
</sect1>
41084106

4107+
<sect1 id="catalog-pg-db-role-setting">
4108+
<title><structname>pg_db_role_setting</structname></title>
4109+
4110+
<indexterm zone="catalog-pg-db-role-setting">
4111+
<primary>pg_db_role_setting</primary>
4112+
</indexterm>
4113+
4114+
<para>
4115+
The catalog <structname>pg_db_role_setting</structname> records the default
4116+
values that have been set for run-time configuration variables,
4117+
for each role and database combination.
4118+
</para>
4119+
4120+
<para>
4121+
Unlike most system catalogs, <structname>pg_db_role_setting</structname>
4122+
is shared across all databases of a cluster: there is only one
4123+
copy of <structname>pg_db_role_setting</structname> per cluster, not
4124+
one per database.
4125+
</para>
4126+
4127+
<table>
4128+
<title><structname>pg_db_role_setting</> Columns</title>
4129+
4130+
<tgroup cols="4">
4131+
<thead>
4132+
<row>
4133+
<entry>Name</entry>
4134+
<entry>Type</entry>
4135+
<entry>References</entry>
4136+
<entry>Description</entry>
4137+
</row>
4138+
</thead>
4139+
4140+
<tbody>
4141+
<row>
4142+
<entry><structfield>setdatabase</structfield></entry>
4143+
<entry><type>oid</type></entry>
4144+
<entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
4145+
<entry>The OID of the database the setting is applicable to, or zero if not database-specific</entry>
4146+
</row>
4147+
4148+
<row>
4149+
<entry><structfield>setrole</structfield></entry>
4150+
<entry><type>oid</type></entry>
4151+
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
4152+
<entry>The OID of the role the setting is applicable to, or zero if not role-specific</entry>
4153+
</row>
4154+
4155+
<row>
4156+
<entry><structfield>setconfig</structfield></entry>
4157+
<entry><type>text[]</type></entry>
4158+
<entry></entry>
4159+
<entry>Defaults for run-time configuration variables</entry>
4160+
</row>
4161+
</tbody>
4162+
</tgroup>
4163+
</table>
4164+
</sect1>
4165+
41094166

41104167
<sect1 id="catalog-pg-shdepend">
41114168
<title><structname>pg_shdepend</structname></title>
@@ -6557,13 +6614,6 @@
65576614
NULL if no expiration</entry>
65586615
</row>
65596616

6560-
<row>
6561-
<entry><structfield>rolconfig</structfield></entry>
6562-
<entry><type>text[]</type></entry>
6563-
<entry></entry>
6564-
<entry>Session defaults for run-time configuration variables</entry>
6565-
</row>
6566-
65676617
<row>
65686618
<entry><structfield>oid</structfield></entry>
65696619
<entry><type>oid</type></entry>

‎doc/src/sgml/ref/alter_role.sgml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_role.sgml,v 1.14 2009/09/19 10:23:26 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_role.sgml,v 1.15 2009/10/07 22:14:16 alvherre Exp $
33
PostgreSQL documentation
44
-->
55

@@ -37,10 +37,10 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replace
3737

3838
ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable>new_name</replaceable>
3939

40-
ALTER ROLE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
41-
ALTER ROLE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
42-
ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>configuration_parameter</replaceable>
43-
ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET ALL
40+
ALTER ROLE <replaceable class="PARAMETER">name</replaceable>[ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ]SET <replaceable>configuration_parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
41+
ALTER ROLE <replaceable class="PARAMETER">name</replaceable>[ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ]SET <replaceable>configuration_parameter</replaceable> FROM CURRENT
42+
ALTER ROLE <replaceable class="PARAMETER">name</replaceable>[ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ]RESET <replaceable>configuration_parameter</replaceable>
43+
ALTER ROLE <replaceable class="PARAMETER">name</replaceable>[ IN DATABASE <replaceable class="PARAMETER">database_name</replaceable> ]RESET ALL
4444
</synopsis>
4545
</refsynopsisdiv>
4646

@@ -80,14 +80,16 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET ALL
8080
</para>
8181

8282
<para>
83-
The remaining variants change a role's session default for a
84-
specified configuration variable. Whenever the role subsequently
83+
The remaining variants change a role's session default for a configuration variable
84+
for all databases or, when the <literal>IN DATABASE</literal> clause is specified,
85+
for the named database. Whenever the role subsequently
8586
starts a new session, the specified value becomes the session
8687
default, overriding whatever setting is present in
8788
<filename>postgresql.conf</> or has been received from the postgres
8889
command line. This only happens at login time, so configuration
8990
settings associated with a role to which you've <xref
90-
linkend="sql-set-role" endterm="sql-set-role-title"> will be ignored.
91+
linkend="sql-set-role" endterm="sql-set-role-title"> will be ignored. Settings set to
92+
a role directly are overridden by any database specific settings attached to a role.
9193
Superusers can change anyone's session defaults. Roles having
9294
<literal>CREATEROLE</> privilege can change defaults for non-superuser
9395
roles. Certain variables cannot be set this way, or can only be
@@ -145,6 +147,15 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET ALL
145147
</listitem>
146148
</varlistentry>
147149

150+
<varlistentry>
151+
<term><replaceable>database_name</replaceable></term>
152+
<listitem>
153+
<para>
154+
The name of the database the configuration variable should be set in.
155+
</para>
156+
</listitem>
157+
</varlistentry>
158+
148159
<varlistentry>
149160
<term><replaceable>configuration_parameter</replaceable></term>
150161
<term><replaceable>value</replaceable></term>
@@ -159,6 +170,8 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET ALL
159170
<literal>RESET ALL</literal> to clear all role-specific settings.
160171
<literal>SET FROM CURRENT</> saves the session's current value of
161172
the parameter as the role-specific value.
173+
If used in conjunction with <literal>IN DATABASE</literal>, the configuration
174+
parameter is set or removed for the given role and database only.
162175
</para>
163176

164177
<para>
@@ -207,8 +220,8 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET ALL
207220
It is also possible to tie a
208221
session default to a specific database rather than to a role; see
209222
<xref linkend="sql-alterdatabase" endterm="sql-alterdatabase-title">.
210-
Role-specific settings overridedatabase-specific
211-
ones if there is a conflict.
223+
If there is a conflict, database-role-specific settings overriderole-specific
224+
ones, which in turn override database-specific ones.
212225
</para>
213226
</refsect1>
214227

@@ -261,6 +274,15 @@ ALTER ROLE miriam CREATEROLE CREATEDB;
261274

262275
<programlisting>
263276
ALTER ROLE worker_bee SET maintenance_work_mem = 100000;
277+
</programlisting>
278+
</para>
279+
280+
<para>
281+
Give a role a non-default, database-specific setting of the
282+
<xref linkend="guc-client-min-messages"> parameter:
283+
284+
<programlisting>
285+
ALTER ROLE fred IN DATABASE devel SET client_min_messages = DEBUG;
264286
</programlisting>
265287
</para>
266288
</refsect1>

‎src/backend/catalog/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for backend/catalog
44
#
5-
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.72 2009/10/05 19:24:34 tgl Exp $
5+
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.73 2009/10/07 22:14:16 alvherre Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -13,7 +13,7 @@ include $(top_builddir)/src/Makefile.global
1313
OBJS = catalog.o dependency.o heap.o index.o indexing.o namespace.o aclchk.o\
1414
pg_aggregate.o pg_constraint.o pg_conversion.o pg_depend.o pg_enum.o\
1515
pg_inherits.o pg_largeobject.o pg_namespace.o pg_operator.o pg_proc.o\
16-
pg_shdepend.o pg_type.o storage.o toasting.o
16+
pg_db_role_setting.opg_shdepend.o pg_type.o storage.o toasting.o
1717

1818
BKIFILES = postgres.bki postgres.description postgres.shdescription
1919

@@ -32,7 +32,7 @@ POSTGRES_BKI_SRCS = $(addprefix $(top_srcdir)/src/include/catalog/,\
3232
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
3333
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
3434
pg_enum.h pg_namespace.h pg_conversion.h pg_depend.h \
35-
pg_database.h pg_tablespace.h pg_pltemplate.h \
35+
pg_database.hpg_db_role_setting.hpg_tablespace.h pg_pltemplate.h \
3636
pg_authid.h pg_auth_members.h pg_shdepend.h pg_shdescription.h \
3737
pg_ts_config.h pg_ts_config_map.h pg_ts_dict.h \
3838
pg_ts_parser.h pg_ts_template.h \

‎src/backend/catalog/catalog.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.83 2009/06/1114:48:54 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/catalog/catalog.c,v 1.84 2009/10/07 22:14:18 alvherre Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -31,6 +31,7 @@
3131
#include"catalog/pg_database.h"
3232
#include"catalog/pg_namespace.h"
3333
#include"catalog/pg_pltemplate.h"
34+
#include"catalog/pg_db_role_setting.h"
3435
#include"catalog/pg_shdepend.h"
3536
#include"catalog/pg_shdescription.h"
3637
#include"catalog/pg_tablespace.h"
@@ -306,7 +307,8 @@ IsSharedRelation(Oid relationId)
306307
relationId==PLTemplateRelationId||
307308
relationId==SharedDescriptionRelationId||
308309
relationId==SharedDependRelationId||
309-
relationId==TableSpaceRelationId)
310+
relationId==TableSpaceRelationId||
311+
relationId==DbRoleSettingRelationId)
310312
return true;
311313
/* These are their indexes (see indexing.h) */
312314
if (relationId==AuthIdRolnameIndexId||
@@ -320,15 +322,18 @@ IsSharedRelation(Oid relationId)
320322
relationId==SharedDependDependerIndexId||
321323
relationId==SharedDependReferenceIndexId||
322324
relationId==TablespaceOidIndexId||
323-
relationId==TablespaceNameIndexId)
325+
relationId==TablespaceNameIndexId||
326+
relationId==DbRoleSettingDatidRolidIndexId)
324327
return true;
325328
/* These are their toast tables and toast indexes (see toasting.h) */
326329
if (relationId==PgAuthidToastTable||
327330
relationId==PgAuthidToastIndex||
328331
relationId==PgDatabaseToastTable||
329332
relationId==PgDatabaseToastIndex||
330333
relationId==PgShdescriptionToastTable||
331-
relationId==PgShdescriptionToastIndex)
334+
relationId==PgShdescriptionToastIndex||
335+
relationId==PgDbRoleSettingToastTable||
336+
relationId==PgDbRoleSettingToastIndex)
332337
return true;
333338
return false;
334339
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp