From: | Neil Conway <neilc(at)samurai(dot)com> |
---|---|
To: | pgsql-patches(at)postgresql(dot)org |
Subject: | boolean <=> text explicit casts |
Date: | 2007-05-28 19:13:21 |
Message-ID: | 1180379601.6648.33.camel@goldbach |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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 | Content-Type | Size |
---|---|---|
bool_text_cast-3.patch | text/x-patch | 6.4 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2007-05-28 19:38:42 | Re: boolean <=> text explicit casts |
Previous Message | Tom Lane | 2007-05-28 19:05:57 | Re: Interval input: usec, msec |