Re: CAST truncates without warning

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mike G <mike(at)thegodshalls(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: CAST truncates without warning
Date: 2004-05-13 22:50:35
Message-ID: 12704.1084488635@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike G <mike(at)thegodshalls(dot)com> writes:
> If a column, data type text, with 22 characters of data, is then CAST(column_name as varchar(20)) shouldn't a warning or error be generated?

No. This is per SQL spec.

You will get a warning if you assign the value to a varchar(20) table
column *without* any explicit cast. This is also per SQL spec.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jeffrey W. Baker 2004-05-13 22:54:52 Re: pg_xlog becomes extremely large during CREATE INDEX
Previous Message Mike G 2004-05-13 20:44:15 CAST truncates without warning