mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Check that connection limit is within valid range. IOW, not < -1.
It's missing in older versions too, but it doesn't seem worth back-porting. All negative are just harmlessly treated as "no limit", and tightening the check might even brake an application that relies on it.
This commit is contained in:
parent
cb629f7225
commit
4265ed9f4e
@ -13,7 +13,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.218 2009/01/20 18:59:37 heikki Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.219 2009/01/30 17:24:47 heikki Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -244,7 +244,13 @@ createdb(const CreatedbStmt *stmt)
|
|||||||
dbctype = strVal(dctype->arg);
|
dbctype = strVal(dctype->arg);
|
||||||
|
|
||||||
if (dconnlimit && dconnlimit->arg)
|
if (dconnlimit && dconnlimit->arg)
|
||||||
|
{
|
||||||
dbconnlimit = intVal(dconnlimit->arg);
|
dbconnlimit = intVal(dconnlimit->arg);
|
||||||
|
if (dbconnlimit < -1)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("invalid connection limit: %d", dbconnlimit)));
|
||||||
|
}
|
||||||
|
|
||||||
/* obtain OID of proposed owner */
|
/* obtain OID of proposed owner */
|
||||||
if (dbowner)
|
if (dbowner)
|
||||||
@ -1319,7 +1325,13 @@ AlterDatabase(AlterDatabaseStmt *stmt, bool isTopLevel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dconnlimit)
|
if (dconnlimit)
|
||||||
|
{
|
||||||
connlimit = intVal(dconnlimit->arg);
|
connlimit = intVal(dconnlimit->arg);
|
||||||
|
if (connlimit < -1)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("invalid connection limit: %d", connlimit)));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get the old tuple. We don't need a lock on the database per se,
|
* Get the old tuple. We don't need a lock on the database per se,
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.185 2009/01/22 20:16:02 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/user.c,v 1.186 2009/01/30 17:24:47 heikki Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -242,7 +242,13 @@ CreateRole(CreateRoleStmt *stmt)
|
|||||||
if (dcanlogin)
|
if (dcanlogin)
|
||||||
canlogin = intVal(dcanlogin->arg) != 0;
|
canlogin = intVal(dcanlogin->arg) != 0;
|
||||||
if (dconnlimit)
|
if (dconnlimit)
|
||||||
|
{
|
||||||
connlimit = intVal(dconnlimit->arg);
|
connlimit = intVal(dconnlimit->arg);
|
||||||
|
if (connlimit < -1)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("invalid connection limit: %d", connlimit)));
|
||||||
|
}
|
||||||
if (daddroleto)
|
if (daddroleto)
|
||||||
addroleto = (List *) daddroleto->arg;
|
addroleto = (List *) daddroleto->arg;
|
||||||
if (drolemembers)
|
if (drolemembers)
|
||||||
@ -533,7 +539,13 @@ AlterRole(AlterRoleStmt *stmt)
|
|||||||
if (dcanlogin)
|
if (dcanlogin)
|
||||||
canlogin = intVal(dcanlogin->arg);
|
canlogin = intVal(dcanlogin->arg);
|
||||||
if (dconnlimit)
|
if (dconnlimit)
|
||||||
|
{
|
||||||
connlimit = intVal(dconnlimit->arg);
|
connlimit = intVal(dconnlimit->arg);
|
||||||
|
if (connlimit < -1)
|
||||||
|
ereport(ERROR,
|
||||||
|
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
|
||||||
|
errmsg("invalid connection limit: %d", connlimit)));
|
||||||
|
}
|
||||||
if (drolemembers)
|
if (drolemembers)
|
||||||
rolemembers = (List *) drolemembers->arg;
|
rolemembers = (List *) drolemembers->arg;
|
||||||
if (dvalidUntil)
|
if (dvalidUntil)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user