From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Rajat Katyal" <rajatk(at)intelesoftech(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: value too long error |
Date: | 2004-02-28 15:52:08 |
Message-ID: | 28033.1077983528@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Rajat Katyal" <rajatk(at)intelesoftech(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2004-02-28 15:57:25 | Re: PostgreSQL insert speed tests |
Previous Message | Richard Huxton | 2004-02-28 15:03:54 | Re: value too long error |