pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <jconway2@home.com>
To: Peter Eisentraut <peter_e@gmx.net>
To: pgsql-sql@postgresql.org
Subject: Re: Truncation of char, varchar, bit, varbit types (fwd)
Date: Sat, 19 May 2001 18:26:07 -0700
Message-ID: <020d01c0e0cb$d8c0a2a0$0205a8c0@jecw2k1> (raw)
References: <Pine.LNX.4.30.0105200234090.758-100000@peter.localdomain>

> Implementation proposal as information for the user community.  Speak now
> or...
<snip>

FWIW . . .

> insert into test values ('not ok');
> ERROR:  value too long for type character varying(4)

/*
 * MSSQL 7
 */
create table test (a varchar(4));
The command(s) completed successfully.

insert into test values ('not ok');
Server: Msg 8152, Level 16, State 9, Line 1
String or binary data would be truncated.
The statement has been terminated.

/*
 * Oracle 8.1.6
 */
SQL> create table test (a varchar(4));
Table created.
SQL> insert into test values ('not ok');
insert into test values ('not ok')
            *
ERROR at line 1:
ORA-01401: inserted value too large for column

> insert into test values ('good    ');
> [truncates spaces that are too long]

/*
 * MSSQL 7
 */
insert into test values ('good    ');
(1 row(s) affected)
select datalength(a) from test;

-----------
4

(1 row(s) affected)

/*
 * Oracle 8.1.6
 */
SQL> insert into test values ('good    ');
insert into test values ('good    ')
            *
ERROR at line 1:
ORA-01401: inserted value too large for column

>
> I think this behaviour is desirable over the old one because it makes the
> char and varchar types useful in the first place.

I agree with your assessment. There are implications for people porting
Oracle applications however.

Regards,

-- Joe





view thread (3+ messages)  latest in thread

Message-ID: <020d01c0e0cb$d8c0a2a0$0205a8c0@jecw2k1>
Permalink:  ../020d01c0e0cb$d8c0a2a0$0205a8c0@jecw2k1/
Also on:    postgresql.org/message-id/020d01c0e0cb$d8c0a2a0$0205a8c0@jecw2k1

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jconway2@home.com, peter_e@gmx.net
  Subject: Re: Truncation of char, varchar, bit, varbit types (fwd)
  In-Reply-To: <020d01c0e0cb$d8c0a2a0$0205a8c0@jecw2k1>

* 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