Re: CAST truncates without warning - Mailing list pgsql-general

From Tom Lane
Subject Re: CAST truncates without warning
Date
Msg-id 12704.1084488635@sss.pgh.pa.us
Whole thread Raw
In response to CAST truncates without warning  (Mike G <mike@thegodshalls.com>)
List pgsql-general
Mike G <mike@thegodshalls.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
orerror 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

pgsql-general by date:

Previous
From: Mike G
Date:
Subject: CAST truncates without warning
Next
From: "Jeffrey W. Baker"
Date:
Subject: Re: pg_xlog becomes extremely large during CREATE INDEX