AW: Truncation of char, varchar types - Mailing list pgsql-hackers

From Zeugswetter Andreas SB
Subject AW: Truncation of char, varchar types
Date
Msg-id 11C1E6749A55D411A9670001FA68796336827F@sdexcsrv1.f000.d0188.sd.spardat.at
Whole thread Raw
Responses Re: AW: Truncation of char, varchar types  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-hackers
> Excessively long values are currently silently truncated when they are
> inserted into char or varchar fields.  This makes the entire notion of
> specifying a length limit for these types kind of useless, IMO.  Needless
> to say, it's also not in compliance with SQL.

To quote Tom "paragraph and verse please" :-)

> How do people feel about changing this to raise an error in this
> situation?

Can't do.

> Does anybody rely on silent truncation?

Yes, iirc the only thing you are allowed to do is issue a warning,
but the truncation is allowed and must succeed. 
(checked in Informix and Oracle)

The appropriate SQLSTATE is: "01004" String data, right truncation
note that class 01 is a "success with warning".

Andreas


pgsql-hackers by date:

Previous
From: Alvar Freude
Date:
Subject: Indexes not used in 7.1RC4: Bug?
Next
From: Alessio Bragadini
Date:
Subject: Re: Truncation of char, varchar types