X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 4FDABD1E8B9 for ; Sat, 28 Feb 2004 15:52:10 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 55635-04 for ; Sat, 28 Feb 2004 11:52:12 -0400 (AST) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id 5E542D1E8CA for ; Sat, 28 Feb 2004 11:52:08 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i1SFq9Mp028034; Sat, 28 Feb 2004 10:52:09 -0500 (EST) To: "Rajat Katyal" Cc: pgsql-general@postgresql.org Subject: Re: value too long error In-reply-to: <000a01c3fdc8$8adf1c70$2105a8c0@coffee> References: <000a01c3fdc8$8adf1c70$2105a8c0@coffee> Comments: In-reply-to "Rajat Katyal" message dated "Sat, 28 Feb 2004 12:30:25 +0530" Date: Sat, 28 Feb 2004 10:52:08 -0500 Message-ID: <28033.1077983528@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/1250 X-Sequence-Number: 57961 "Rajat Katyal" 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