From d42cf5a42a42689f68bc1ee1200aca75f954b1fd Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 31 Jul 2005 17:19:22 +0000 Subject: 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. --- doc/src/sgml/catalogs.sgml | 32 +++++++++++++++++++++++++++++++- doc/src/sgml/ref/alter_database.sgml | 29 +++++++++++++++++++++++++---- doc/src/sgml/ref/alter_role.sgml | 4 +++- doc/src/sgml/ref/alter_user.sgml | 3 ++- doc/src/sgml/ref/create_database.sgml | 22 ++++++++++++++++++++-- doc/src/sgml/ref/create_role.sgml | 20 +++++++++++++++++++- doc/src/sgml/ref/create_user.sgml | 3 ++- 7 files changed, 102 insertions(+), 11 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 0c8ed68195d..d8ec4f9f658 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,6 +1,6 @@ @@ -1018,6 +1018,16 @@ + + rolconnlimit + int4 + + + For roles that can log in, this sets maximum number of concurrent + connections this role can make. -1 means no limit. + + + rolpassword text @@ -1921,6 +1931,16 @@ + + datconnlimit + int4 + + + Sets maximum number of concurrent connections that can be made + to this database. -1 means no limit. + + + datlastsysoid oid @@ -4811,6 +4831,16 @@ + + rolconnlimit + int4 + + + For roles that can log in, this sets maximum number of concurrent + connections this role can make. -1 means no limit. + + + rolpassword text diff --git a/doc/src/sgml/ref/alter_database.sgml b/doc/src/sgml/ref/alter_database.sgml index c209308716a..03333d3d99b 100644 --- a/doc/src/sgml/ref/alter_database.sgml +++ b/doc/src/sgml/ref/alter_database.sgml @@ -1,5 +1,5 @@ @@ -20,6 +20,12 @@ PostgreSQL documentation +ALTER DATABASE name [ [ WITH ] option [ ... ] ] + +where option can be: + + CONNECTION LIMIT connlimit + ALTER DATABASE name SET parameter { TO | = } { value | DEFAULT } ALTER DATABASE name RESET parameter @@ -38,7 +44,12 @@ ALTER DATABASE name OWNER TO - The first two forms change the session default for a run-time + The first form changes certain per-database settings. (See below for + details.) Only the database owner or a superuser can change these settings. + + + + The second and third forms change the session default for a run-time configuration variable for a PostgreSQL database. Whenever a new session is subsequently started in that database, the specified value becomes the session default value. @@ -51,7 +62,7 @@ ALTER DATABASE name OWNER TO - The third form changes the name of the database. Only the database + The fourth form changes the name of the database. Only the database owner or a superuser can rename a database; non-superuser owners must also have the CREATEDB privilege. The current database cannot @@ -60,7 +71,7 @@ ALTER DATABASE name OWNER TO - The fourth form changes the owner of the database. Only a superuser + The fifth form changes the owner of the database. Only a superuser can change the database's owner. @@ -78,6 +89,16 @@ ALTER DATABASE name OWNER TO + + connlimit + + + How many concurrent connections can be made + to this database. -1 means no limit. + + + + parameter value diff --git a/doc/src/sgml/ref/alter_role.sgml b/doc/src/sgml/ref/alter_role.sgml index 3e87cf01763..7ebd8014f29 100644 --- a/doc/src/sgml/ref/alter_role.sgml +++ b/doc/src/sgml/ref/alter_role.sgml @@ -1,5 +1,5 @@ @@ -30,6 +30,7 @@ where option can be: | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN + | CONNECTION LIMIT connlimit | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' @@ -118,6 +119,7 @@ ALTER ROLE name RESET NOINHERIT LOGIN NOLOGIN + CONNECTION LIMIT connlimit PASSWORD password ENCRYPTED UNENCRYPTED diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml index 2844a63d083..d5dc3f1fca3 100644 --- a/doc/src/sgml/ref/alter_user.sgml +++ b/doc/src/sgml/ref/alter_user.sgml @@ -1,5 +1,5 @@ @@ -30,6 +30,7 @@ where option can be: | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN + | CONNECTION LIMIT connlimit | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml index edb98b784b9..b4bd2d57398 100644 --- a/doc/src/sgml/ref/create_database.sgml +++ b/doc/src/sgml/ref/create_database.sgml @@ -1,5 +1,5 @@ @@ -24,7 +24,8 @@ CREATE DATABASE name [ [ WITH ] [ OWNER [=] dbowner ] [ TEMPLATE [=] template ] [ ENCODING [=] encoding ] - [ TABLESPACE [=] tablespace ] ] + [ TABLESPACE [=] tablespace ] + [ CONNECTION LIMIT [=] connlimit ] ] @@ -123,6 +124,16 @@ CREATE DATABASE name + + + connlimit + + + How many concurrent connections can be made + to this database. -1 (the default) means no limit. + + + @@ -161,6 +172,13 @@ CREATE DATABASE name We recommend that databases used as templates be treated as read-only. See for more information. + + + The CONNECTION LIMIT option is only enforced approximately; + if two new sessions start at about the same time when just one + connection slot remains for the database, it is possible that + both will fail. Also, the limit is not enforced against superusers. + diff --git a/doc/src/sgml/ref/create_role.sgml b/doc/src/sgml/ref/create_role.sgml index 598888528fb..4cff62a6ec6 100644 --- a/doc/src/sgml/ref/create_role.sgml +++ b/doc/src/sgml/ref/create_role.sgml @@ -1,5 +1,5 @@ @@ -30,6 +30,7 @@ where option can be: | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN + | CONNECTION LIMIT connlimit | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' | IN ROLE rolename [, ...] @@ -172,6 +173,16 @@ where option can be: + + CONNECTION LIMIT connlimit + + + If role can log in, this specifies how many concurrent connections + the role can make. -1 (the default) means no limit. + + + + PASSWORD password @@ -327,6 +338,13 @@ where option can be: the same functionality as CREATE ROLE (in fact, it calls this command) but can be run from the command shell. + + + The CONNECTION LIMIT option is only enforced approximately; + if two new sessions start at about the same time when just one + connection slot remains for the role, it is possible that + both will fail. Also, the limit is never enforced for superusers. + diff --git a/doc/src/sgml/ref/create_user.sgml b/doc/src/sgml/ref/create_user.sgml index 68d37bbd86d..44d52cd779a 100644 --- a/doc/src/sgml/ref/create_user.sgml +++ b/doc/src/sgml/ref/create_user.sgml @@ -1,5 +1,5 @@ @@ -30,6 +30,7 @@ where option can be: | CREATEUSER | NOCREATEUSER | INHERIT | NOINHERIT | LOGIN | NOLOGIN + | CONNECTION LIMIT connlimit | [ ENCRYPTED | UNENCRYPTED ] PASSWORD 'password' | VALID UNTIL 'timestamp' | IN ROLE rolename [, ...] -- cgit v1.2.3