"Rajat Katyal" <rajatk@intelesoftech.com> writes:
> Whenever i try to insert the data, size of which is greater than that of co=
> lumn datatype size, I got the exception value too long for.....=20
> However this was not in postgresql7.2.
IIRC, older versions would just silently truncate the data to the
specified column width. We concluded that that was not per spec.
7.3 and later make you do it the SQL-spec way, which is to explicitly
truncate the data. You can do that with a substring operation or by
casting, for instance
INSERT INTO foo VALUES('an overly long string'::varchar(10));
It's a tad inconsistent that explicit and implicit casts to varchar(N)
act differently, but that's what the SQL spec says to do, AFAICS.
I guess it's reasonable --- the old behavior could result in unintended
data loss.
regards, tom lane