Thread: Per database connection limit buglet

Per database connection limit buglet

From
"Dave Page"
Date:
It's possible to set a per-database connection limit of < -1, which seems bogus:

gator:~ dpage$ /usr/local/pgsql84/bin/psql -p 5433 postgres
psql (8.4devel)
Type "help" for help.

postgres=# create database test with connection limit = -999;
CREATE DATABASE
postgres=# select datname, datconnlimit from pg_database;
  datname  | datconnlimit
-----------+--------------
 template1 |           -1
 template0 |           -1
 postgres  |           50
 foo       |           45
 test      |         -999
(5 rows)

8.3 seems similarly afflicted - I haven't tested any further back.

--
Dave Page
EnterpriseDB UK:   http://www.enterprisedb.com

Re: Per database connection limit buglet

From
Heikki Linnakangas
Date:
Dave Page wrote:
> It's possible to set a per-database connection limit of < -1, which seems bogus:

Yeah. That's simple to fix, but I'm having trouble wordsmithing the
error message. This is what I came up with:

invalid connection limit %d (must be -1, meaning no limit, or greater)

Any better suggestions?

I also note that you can set it to INT_MAX, while max_connections is
limited to INT_MAX/4, but I'm inclined to leave that alone.

> 8.3 seems similarly afflicted - I haven't tested any further back.

Hmm, I don't think this should be backported, since it doesn't cause any
  actual problems. We'd just risk breaking people's scripts that use
-999 to mean "no limit". (they will be broken when they upgrade to 8.4
anyway, of course, but that's fine)

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Re: Per database connection limit buglet

From
Dave Page
Date:
On Mon, Jan 26, 2009 at 12:26 PM, Heikki Linnakangas
<heikki.linnakangas@enterprisedb.com> wrote:
> Dave Page wrote:
>>
>> It's possible to set a per-database connection limit of < -1, which seems
>> bogus:
>
> Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
> message. This is what I came up with:
>
> invalid connection limit %d (must be -1, meaning no limit, or greater)
>
> Any better suggestions?

Perhaps drop the 'meaning no limit'? Less helpful perhaps (but that's
what the manual is for), but it sounds better

--
Dave Page
EnterpriseDB UK:   http://www.enterprisedb.com

Re: Per database connection limit buglet

From
tomas@tuxteam.de
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Jan 26, 2009 at 02:26:05PM +0200, Heikki Linnakangas wrote:
> Dave Page wrote:
>> It's possible to set a per-database connection limit of < -1, which seems
>> bogus:
>
> Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
> message. This is what I came up with:
>
> invalid connection limit %d (must be -1, meaning no limit, or greater)
>
> Any better suggestions?

Maybe

   invalid connection limit %d (must be positive or -1, for "unlimited")

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD4DBQFJfbYXBcgs9XrR2kYRApUkAJ9V/aYLn37zyDeS7dqTwZqgLfqoVgCYokPR
52vaXe/OrDwdKFlN4vElSQ==
=XS2a
-----END PGP SIGNATURE-----

Re: Per database connection limit buglet

From
Heikki Linnakangas
Date:
tomas@tuxteam.de wrote:
> On Mon, Jan 26, 2009 at 02:26:05PM +0200, Heikki Linnakangas wrote:
>> Dave Page wrote:
>>> It's possible to set a per-database connection limit of < -1, which seems
>>> bogus:
>> Yeah. That's simple to fix, but I'm having trouble wordsmithing the error
>> message. This is what I came up with:
>>
>> invalid connection limit %d (must be -1, meaning no limit, or greater)
>>
>> Any better suggestions?
>
> Maybe
>
>    invalid connection limit %d (must be positive or -1, for "unlimited")

Hmm, that sounds better, but it can also be 0.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

Re: Per database connection limit buglet

From
tomas@tuxteam.de
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, Jan 26, 2009 at 03:16:37PM +0200, Heikki Linnakangas wrote:
[...]
>> Maybe
>>    invalid connection limit %d (must be positive or -1, for "unlimited")
>
> Hmm, that sounds better, but it can also be 0.

Oops. "nonnegative", then. Creeping unreadability, again?

Regards
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFJfcmLBcgs9XrR2kYRAtQRAKCCG5Zn6mKfzFJyRPeanH80t0a7HgCeL5r8
rzthpyajTrBYEppMnZFPeC4=
=NqZ9
-----END PGP SIGNATURE-----

Re: Per database connection limit buglet

From
Alvaro Herrera
Date:
Heikki Linnakangas wrote:
> Dave Page wrote:
>> It's possible to set a per-database connection limit of < -1, which seems bogus:
>
> Yeah. That's simple to fix, but I'm having trouble wordsmithing the
> error message. This is what I came up with:
>
> invalid connection limit %d (must be -1, meaning no limit, or greater)

Split it up:

errmsg("invalid connection limit %d"),
errdetail("Limit must be a non-negative number, or -1 for no limit.")

or maybe

errdetail("Valid values are -1 for no limit, or a non-negative number.")

--
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

Re: Per database connection limit buglet

From
Tom Lane
Date:
Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
> Dave Page wrote:
>> It's possible to set a per-database connection limit of < -1, which seems bogus:

> Yeah. That's simple to fix, but I'm having trouble wordsmithing the
> error message. This is what I came up with:

Why does it need to be anything except GUC's standard "invalid value"
message?  I really don't believe that this case is worth making
translators deal with an additional string.

            regards, tom lane

Re: Per database connection limit buglet

From
Heikki Linnakangas
Date:
Tom Lane wrote:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
>> Dave Page wrote:
>>> It's possible to set a per-database connection limit of < -1, which seems bogus:
>
>> Yeah. That's simple to fix, but I'm having trouble wordsmithing the
>> error message. This is what I came up with:
>
> Why does it need to be anything except GUC's standard "invalid value"
> message?  I really don't believe that this case is worth making
> translators deal with an additional string.

I guess. The message in guc.c seems a bit cumbersome, though, so I did
create a new message for it. It's now simply "invalid connection limit: %d".

The check was missing from per-user connection limits, fixed that too.

--
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com