Re: boolean <=> text explicit casts - Mailing list pgsql-patches

From Tom Lane
Subject Re: boolean <=> text explicit casts
Date
Msg-id 8305.1180381122@sss.pgh.pa.us
Whole thread Raw
In response to boolean <=> text explicit casts  (Neil Conway <neilc@samurai.com>)
Responses Re: boolean <=> text explicit casts  (Neil Conway <neilc@samurai.com>)
Re: boolean <=> text explicit casts  (Neil Conway <neilc@samurai.com>)
List pgsql-patches
Neil Conway <neilc@samurai.com> writes:
> (2) The spec also requires that boolean::varchar(n) should raise an
> error if "n" is not large enough to accomodate the textual
> representation of the boolean value.

Really?  That's in direct contradiction to the "normal" spec-required
behavior of casting to varchar(n).  I'd suggest ignoring it on the
grounds that the SQL committee have forgotten what they wrote
themselves.

> (3) The spec suggests that true/false should be upper-cased when
> converted to text, so that's what I've implemented, but one could argue
> that converting to lower-case would be more consistent with PG's general
> approach to case folding.

hm, +1 for lower case myself, but not dead set on it.

More generally, I'm really hoping to get rid of bespoke text<->whatever
cast functions in favor of using datatypes' I/O functions.  To what
extent can we make the boolean I/O functions serve for this?  It seems
relatively painless on the input side --- just allow whitespace --- but
I suppose we can't change boolout's historical result of "t"/"f" without
causing problems.

Also, invoking btrim() seems an exceedingly expensive way of ignoring a
bit of whitespace.  I suppose inefficiency in a seldom-used cast
function does not matter, but please don't do it that way in boolin.

            regards, tom lane

pgsql-patches by date:

Previous
From: Neil Conway
Date:
Subject: boolean <=> text explicit casts
Next
From: Heikki Linnakangas
Date:
Subject: Re: Seq scans status update