From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Ken Johanson <pg-user(at)kensystem(dot)com>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: SELECT CAST(123 AS char) -> 1 |
Date: | 2008-02-13 18:27:09 |
Message-ID: | 47B3367D.6050808@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Tom Lane wrote:
> Richard Huxton <dev(at)archonet(dot)com> writes:
>> [ proof that cast(123 as char) actually produces varchar in mysql ]
>
> Egad. I wonder if they think this is a feature?
Well, presumably its what all the other "convenient" (for Ken's
particular problem) databases do. The only alternative I could see would
be to use a varchar while casting values and then check lengths at the
end before re-casting to e.g. char(6).
Interestingly, it must have some lookup table mapping numeric types to
lengths of varchar because a standard int gives you varchar(11) whereas
an expression that pushes you beyond 32 bits gives varchar(32) and a
tinyint gives you varchar(4). Clearly some thought has gone into this.
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Fuhr | 2008-02-13 18:57:19 | Re: Order of SUBSTR and UPPER in statement |
Previous Message | Tom Lane | 2008-02-13 18:09:26 | Re: SELECT CAST(123 AS char) -> 1 |