psql \set case sensitive for boolean (OFF/off)

From: "Michael Paesold" <mpaesold(at)gmx(dot)at>
To: <pgsql-patches(at)postgresql(dot)org>
Subject: psql \set case sensitive for boolean (OFF/off)
Date: 2004-09-21 11:01:30
Message-ID: 016a01c49fca$59f2a1a0$ad01a8c0@zaphod
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

psql is currently case sensitive for boolean values in \set, only "off" is
regarded as off, whereas "OFF" is regarded as on.

There is a comment in the code that explains, why other values than "off"
are always treated as true:
"for backwards compatibility, anything except "off" is taken as "true"

I would recommend to make this check at least case insensitive, because

a) Since SQL is case insensitive, the current behaviour is not what you
would expect.

b) I have stumbled over this myself (setting AUTOCOMMIT to 'OFF' and then
having problems because it was on)

c) I think there are other who were/will be bitten by this (recommendation
on general to use --set AUTOCOMMIT=OFF...)

I would change strcmp to strcasecmp in GetVariableBool in variable.c. For
the other functions (VariableEquals e.g.) I cannot speak, since I don't know
if the case sensitivity is needed.

Patch attached. Is strcasecmp ok, or should pg_strcasecmp be used here?

Best Regards,
Michael Paesold

Attachment Content-Type Size
psql-autocommit.diff application/octet-stream 3.2 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Michael Paesold 2004-09-21 11:20:36 Re: psql \set case sensitive for boolean (OFF/off)
Previous Message Shachar Shemesh 2004-09-21 10:08:18 Re: libpq and prepared statements progress for 8.0