pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Rajat Katyal <rajatk@intelesoftech.com>
Cc: pgsql-general@postgresql.org
Subject: Re: value too long error
Date: Sat, 28 Feb 2004 10:52:08 -0500
Message-ID: <28033.1077983528@sss.pgh.pa.us> (raw)
In-Reply-To: <000a01c3fdc8$8adf1c70$2105a8c0@coffee>
References: <000a01c3fdc8$8adf1c70$2105a8c0@coffee>

"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



view thread (10+ messages)  latest in thread

Message-ID: <28033.1077983528@sss.pgh.pa.us>
Permalink:  ../28033.1077983528@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/28033.1077983528@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, rajatk@intelesoftech.com
  Subject: Re: value too long error
  In-Reply-To: <28033.1077983528@sss.pgh.pa.us>
  References: <000a01c3fdc8$8adf1c70$2105a8c0@coffee> <28033.1077983528@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox