psql \set case sensitive for boolean (OFF/off) - Mailing list pgsql-patches

From Michael Paesold
Subject psql \set case sensitive for boolean (OFF/off)
Date
Msg-id 016a01c49fca$59f2a1a0$ad01a8c0@zaphod
Whole thread Raw
Responses Re: psql \set case sensitive for boolean (OFF/off)
List 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

pgsql-patches by date:

Previous
From: "Michael Paesold"
Date:
Subject: Re: Fix for VACUUM in psql autocommit off
Next
From: "Michael Paesold"
Date:
Subject: Re: psql \set case sensitive for boolean (OFF/off)