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

From Neil Conway
Subject boolean <=> text explicit casts
Date
Msg-id 1180379601.6648.33.camel@goldbach
Whole thread Raw
Responses Re: boolean <=> text explicit casts
List pgsql-patches
I noticed that SQL:2003 specifies explicit casts between "boolean" and
the character string types. Attached is a patch that implements them,
and adds some simple regression tests.

A few points worth noting:

(1) The SQL spec requires that text::boolean trim leading and trailing
whitespace from the input

(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. We currently truncate:

=> select true::boolean::varchar(3);
 varchar
---------
 TRU

Not sure offhand if there's an easy way to satisfy the spec's
requirement...

(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.

-Neil


Attachment

pgsql-patches by date:

Previous
From: Tom Lane
Date:
Subject: Re: Interval input: usec, msec
Next
From: Tom Lane
Date:
Subject: Re: boolean <=> text explicit casts