Re: SELECT CAST(123 AS char) -> 1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ken Johanson <pg-user(at)kensystem(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT CAST(123 AS char) -> 1
Date: 2008-02-16 16:15:31
Message-ID: 20058.1203178531@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ken Johanson <pg-user(at)kensystem(dot)com> writes:
> Tom Lane wrote:
>> Hm, good point, so really we ought to have a separate casting path for
>> numeric types to char(n). However, this section still doesn't offer
>> any support for the OP's desire to auto-size the result; it says
>> that you get an error if the result doesn't fit in the declared
>> length:
>>
>>> iv) Otherwise, an exception condition is raised: data exception-
>>> string data, right truncation.

> I don't believe the size is being declared in the OP's (subject line)
> example: SELECT CAST(123 AS char)

No, because section 6.1 still defines what "char" means, and it says
that means "char(1)".

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ken Johanson 2008-02-16 16:18:47 Re: Strict-typing benefits/costs
Previous Message Phoenix Kiula 2008-02-16 16:13:32 Re: Timestamp indexes (why ">" or "between" does not use index?)