RE: Truncation of char, varchar types

From: Mike Mascari <mascarm(at)mascari(dot)com>
To: "'Zeugswetter Andreas SB'" <ZeugswetterA(at)wien(dot)spardat(dot)at>, "'Peter Eisentraut'" <peter_e(at)gmx(dot)net>, PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: Truncation of char, varchar types
Date: 2001-04-10 16:41:59
Message-ID: 01C0C1BB.A329E1D0.mascarm@mascari.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

This is what I get in Oracle 8:

SQL> CREATE TABLE test (value VARCHAR (10));

Table created.

SQL> INSERT INTO test VALUES ('Mike Mascari');
INSERT INTO test VALUES ('Mike Mascari')
*
ERROR at line 1:
ORA-01401: inserted value too large for column

SQL> quit

Of course, if the standard is ambiguous, retaining backwards
compatibility sure would be nice.

FWIW,

Mike Mascari
mascarm(at)mascari(dot)com

-----Original Message-----
From: Zeugswetter Andreas SB [SMTP:ZeugswetterA(at)wien(dot)spardat(dot)at]
Sent: Tuesday, April 10, 2001 6:47 AM
To: 'Peter Eisentraut'; PostgreSQL Development
Subject: AW: [HACKERS] Truncation of char, varchar types

> 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2001-04-10 17:05:51 Re: Truncation of char, varchar types
Previous Message Alvar Freude 2001-04-10 16:39:38 Re: Indexes not used in 7.1RC4: Bug?