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

Commitd42cf5a

Browse files
committed
Add per-user and per-database connection limit options.
This patch also includes preliminary update of pg_dumpall for roles.Petr Jelinek, with review by Bruce Momjian and Tom Lane.
1 parentb125877 commitd42cf5a

File tree

30 files changed

+783
-180
lines changed

30 files changed

+783
-180
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.109 2005/07/26 16:38:25 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.110 2005/07/31 17:19:16 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -1018,6 +1018,16 @@
10181018
</entry>
10191019
</row>
10201020

1021+
<row>
1022+
<entry><structfield>rolconnlimit</structfield></entry>
1023+
<entry><type>int4</type></entry>
1024+
<entry></entry>
1025+
<entry>
1026+
For roles that can log in, this sets maximum number of concurrent
1027+
connections this role can make. -1 means no limit.
1028+
</entry>
1029+
</row>
1030+
10211031
<row>
10221032
<entry><structfield>rolpassword</structfield></entry>
10231033
<entry><type>text</type></entry>
@@ -1921,6 +1931,16 @@
19211931
</entry>
19221932
</row>
19231933

1934+
<row>
1935+
<entry><structfield>datconnlimit</structfield></entry>
1936+
<entry><type>int4</type></entry>
1937+
<entry></entry>
1938+
<entry>
1939+
Sets maximum number of concurrent connections that can be made
1940+
to this database. -1 means no limit.
1941+
</entry>
1942+
</row>
1943+
19241944
<row>
19251945
<entry><structfield>datlastsysoid</structfield></entry>
19261946
<entry><type>oid</type></entry>
@@ -4811,6 +4831,16 @@
48114831
</entry>
48124832
</row>
48134833

4834+
<row>
4835+
<entry><structfield>rolconnlimit</structfield></entry>
4836+
<entry><type>int4</type></entry>
4837+
<entry></entry>
4838+
<entry>
4839+
For roles that can log in, this sets maximum number of concurrent
4840+
connections this role can make. -1 means no limit.
4841+
</entry>
4842+
</row>
4843+
48144844
<row>
48154845
<entry><structfield>rolpassword</structfield></entry>
48164846
<entry><type>text</type></entry>

‎doc/src/sgml/ref/alter_database.sgml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.15 2005/01/05 14:22:39 petere Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_database.sgml,v 1.16 2005/07/31 17:19:16 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -20,6 +20,12 @@ PostgreSQL documentation
2020

2121
<refsynopsisdiv>
2222
<synopsis>
23+
ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> [ [ WITH ] <replaceable class="PARAMETER">option</replaceable> [ ... ] ]
24+
25+
where <replaceable class="PARAMETER">option</replaceable> can be:
26+
27+
CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
28+
2329
ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> SET <replaceable>parameter</replaceable> { TO | = } { <replaceable>value</replaceable> | DEFAULT }
2430
ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>parameter</replaceable>
2531

@@ -38,7 +44,12 @@ ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <repla
3844
</para>
3945

4046
<para>
41-
The first two forms change the session default for a run-time
47+
The first form changes certain per-database settings. (See below for
48+
details.) Only the database owner or a superuser can change these settings.
49+
</para>
50+
51+
<para>
52+
The second and third forms change the session default for a run-time
4253
configuration variable for a <productname>PostgreSQL</productname>
4354
database. Whenever a new session is subsequently started in that
4455
database, the specified value becomes the session default value.
@@ -51,7 +62,7 @@ ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <repla
5162
</para>
5263

5364
<para>
54-
Thethird form changes the name of the database. Only the database
65+
Thefourth form changes the name of the database. Only the database
5566
owner or a superuser can rename a database; non-superuser owners must
5667
also have the
5768
<literal>CREATEDB</literal> privilege. The current database cannot
@@ -60,7 +71,7 @@ ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <repla
6071
</para>
6172

6273
<para>
63-
Thefourth form changes the owner of the database. Only a superuser
74+
Thefifth form changes the owner of the database. Only a superuser
6475
can change the database's owner.
6576
</para>
6677
</refsect1>
@@ -78,6 +89,16 @@ ALTER DATABASE <replaceable class="PARAMETER">name</replaceable> OWNER TO <repla
7889
</listitem>
7990
</varlistentry>
8091

92+
<varlistentry>
93+
<term><replaceable class="parameter">connlimit</replaceable></term>
94+
<listitem>
95+
<para>
96+
How many concurrent connections can be made
97+
to this database. -1 means no limit.
98+
</para>
99+
</listitem>
100+
</varlistentry>
101+
81102
<varlistentry>
82103
<term><replaceable>parameter</replaceable></term>
83104
<term><replaceable>value</replaceable></term>

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

Lines changed: 3 additions & 1 deletion
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.1 2005/07/26 23:24:02 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_role.sgml,v 1.2 2005/07/31 17:19:17 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -30,6 +30,7 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
3030
| CREATEUSER | NOCREATEUSER
3131
| INHERIT | NOINHERIT
3232
| LOGIN | NOLOGIN
33+
| CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
3334
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>'
3435
| VALID UNTIL '<replaceable class="PARAMETER">timestamp</replaceable>'
3536

@@ -118,6 +119,7 @@ ALTER ROLE <replaceable class="PARAMETER">name</replaceable> RESET <replaceable>
118119
<term><literal>NOINHERIT</literal></term>
119120
<term><literal>LOGIN</literal></term>
120121
<term><literal>NOLOGIN</literal></term>
122+
<term><literal>CONNECTION LIMIT</literal> <replaceable class="parameter">connlimit</replaceable></term>
121123
<term><literal>PASSWORD</> <replaceable class="parameter">password</replaceable></term>
122124
<term><literal>ENCRYPTED</></term>
123125
<term><literal>UNENCRYPTED</></term>

‎doc/src/sgml/ref/alter_user.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_user.sgml,v 1.38 2005/07/26 23:24:02 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_user.sgml,v 1.39 2005/07/31 17:19:17 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -30,6 +30,7 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
3030
| CREATEUSER | NOCREATEUSER
3131
| INHERIT | NOINHERIT
3232
| LOGIN | NOLOGIN
33+
| CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
3334
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>'
3435
| VALID UNTIL '<replaceable class="PARAMETER">timestamp</replaceable>'
3536

‎doc/src/sgml/ref/create_database.sgml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.43 2004/10/29 03:17:22 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_database.sgml,v 1.44 2005/07/3117:19:17 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -24,7 +24,8 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
2424
[ [ WITH ] [ OWNER [=] <replaceable class="parameter">dbowner</replaceable> ]
2525
[ TEMPLATE [=] <replaceable class="parameter">template</replaceable> ]
2626
[ ENCODING [=] <replaceable class="parameter">encoding</replaceable> ]
27-
[ TABLESPACE [=] <replaceable class="parameter">tablespace</replaceable> ] ]
27+
[ TABLESPACE [=] <replaceable class="parameter">tablespace</replaceable> ]
28+
[ CONNECTION LIMIT [=] <replaceable class="parameter">connlimit</replaceable> ] ]
2829
</synopsis>
2930
</refsynopsisdiv>
3031

@@ -123,6 +124,16 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
123124
</para>
124125
</listitem>
125126
</varlistentry>
127+
128+
<varlistentry>
129+
<term><replaceable class="parameter">connlimit</replaceable></term>
130+
<listitem>
131+
<para>
132+
How many concurrent connections can be made
133+
to this database. -1 (the default) means no limit.
134+
</para>
135+
</listitem>
136+
</varlistentry>
126137
</variablelist>
127138

128139
<para>
@@ -161,6 +172,13 @@ CREATE DATABASE <replaceable class="PARAMETER">name</replaceable>
161172
We recommend that databases used as templates be treated as read-only.
162173
See <xref linkend="manage-ag-templatedbs"> for more information.
163174
</para>
175+
176+
<para>
177+
The <literal>CONNECTION LIMIT</> option is only enforced approximately;
178+
if two new sessions start at about the same time when just one
179+
connection <quote>slot</> remains for the database, it is possible that
180+
both will fail. Also, the limit is not enforced against superusers.
181+
</para>
164182
</refsect1>
165183

166184
<refsect1>

‎doc/src/sgml/ref/create_role.sgml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_role.sgml,v 1.1 2005/07/26 23:24:02 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_role.sgml,v 1.2 2005/07/31 17:19:17 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -30,6 +30,7 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
3030
| CREATEUSER | NOCREATEUSER
3131
| INHERIT | NOINHERIT
3232
| LOGIN | NOLOGIN
33+
| CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
3334
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>'
3435
| VALID UNTIL '<replaceable class="PARAMETER">timestamp</replaceable>'
3536
| IN ROLE <replaceable class="PARAMETER">rolename</replaceable> [, ...]
@@ -172,6 +173,16 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
172173
</listitem>
173174
</varlistentry>
174175

176+
<varlistentry>
177+
<term><literal>CONNECTION LIMIT</literal> <replaceable class="parameter">connlimit</replaceable></term>
178+
<listitem>
179+
<para>
180+
If role can log in, this specifies how many concurrent connections
181+
the role can make. -1 (the default) means no limit.
182+
</para>
183+
</listitem>
184+
</varlistentry>
185+
175186
<varlistentry>
176187
<term><literal>PASSWORD</> <replaceable class="parameter">password</replaceable></term>
177188
<listitem>
@@ -327,6 +338,13 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
327338
the same functionality as <command>CREATE ROLE</command> (in fact,
328339
it calls this command) but can be run from the command shell.
329340
</para>
341+
342+
<para>
343+
The <literal>CONNECTION LIMIT</> option is only enforced approximately;
344+
if two new sessions start at about the same time when just one
345+
connection <quote>slot</> remains for the role, it is possible that
346+
both will fail. Also, the limit is never enforced for superusers.
347+
</para>
330348
</refsect1>
331349

332350
<refsect1>

‎doc/src/sgml/ref/create_user.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/ref/create_user.sgml,v 1.37 2005/07/26 23:24:02 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/ref/create_user.sgml,v 1.38 2005/07/31 17:19:17 tgl Exp $
33
PostgreSQL documentation
44
-->
55

@@ -30,6 +30,7 @@ where <replaceable class="PARAMETER">option</replaceable> can be:
3030
| CREATEUSER | NOCREATEUSER
3131
| INHERIT | NOINHERIT
3232
| LOGIN | NOLOGIN
33+
| CONNECTION LIMIT <replaceable class="PARAMETER">connlimit</replaceable>
3334
| [ ENCRYPTED | UNENCRYPTED ] PASSWORD '<replaceable class="PARAMETER">password</replaceable>'
3435
| VALID UNTIL '<replaceable class="PARAMETER">timestamp</replaceable>'
3536
| IN ROLE <replaceable class="PARAMETER">rolename</replaceable> [, ...]

‎src/backend/access/transam/twophase.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
*$PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.8 2005/07/04 04:51:44 tgl Exp $
10+
*$PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.9 2005/07/31 17:19:17 tgl Exp $
1111
*
1212
* NOTES
1313
*Each global transaction is associated with a global transaction
@@ -272,6 +272,7 @@ MarkAsPreparing(TransactionId xid, const char *gid,
272272
gxact->proc.xmin=InvalidTransactionId;
273273
gxact->proc.pid=0;
274274
gxact->proc.databaseId=databaseid;
275+
gxact->proc.roleId=owner;
275276
gxact->proc.lwWaiting= false;
276277
gxact->proc.lwExclusive= false;
277278
gxact->proc.lwWaitLink=NULL;

‎src/backend/catalog/system_views.sql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.17 2005/07/26 16:38:26 tgl Exp $
6+
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.18 2005/07/31 17:19:17 tgl Exp $
77
*/
88

99
CREATEVIEWpg_rolesAS
@@ -15,6 +15,7 @@ CREATE VIEW pg_roles AS
1515
rolcreatedb,
1616
rolcatupdate,
1717
rolcanlogin,
18+
rolconnlimit,
1819
'********'::textas rolpassword,
1920
rolvaliduntil,
2021
rolconfig,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp