Re: 0/1 vs true/false - Mailing list pgsql-general

From Greg Stark
Subject Re: 0/1 vs true/false
Date
Msg-id 877k68r261.fsf@stark.dyndns.tv
Whole thread Raw
In response to Re: 0/1 vs true/false  (Franco Bruno Borghesi <franco@akyasociados.com.ar>)
List pgsql-general
Franco Bruno Borghesi <franco@akyasociados.com.ar> writes:

> This makes me wonder, what about 't' and 'f'?... will they disappear in
> newer versions of postgreSQL?

Nothing to do with the spec, but can I toss one comment in here:

 Having booleans printed as 't' and 'f' is the single most annoying thing in
 all of postgres.

I swear it has caused more bugs in my code than any single factor. The problem
is that any language driver that just treats all columns as text -- which is
presumably most if not all -- will receive the column as 't' and 'f'. Both of
which evaluate to true in virtually every language.

If it printed booleans as 0 and 1 then pretty much every language would be
able to interpret them properly.

Instead I have to have =='f' and =='t' strewn throughout my code everywhere
making it harder to read and extremely fragile. If I forget one anywhere I
silently get subtly broken semantics.

This problem might be reduced with the binary protocol since the language
drivers will be able to ship boolean values in binary format and allocate
variables of the appropriate type in the language. But still a lot of drivers
will just bind everything as text anyways, and the goal when casting values to
text should be to pick values that get interpreted appropriately.

--
greg

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: SAP DB: The unsung Open Source DB
Next
From: "Madhavi Daroor"
Date:
Subject: Parse Error neaer NullOrder