From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Truncation of char, varchar, bit, varbit types |
Date: | 2001-05-19 10:33:40 |
Message-ID: | Pine.LNX.4.30.0105191219420.758-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I've sent this a few weeks ago and got support, I just wanted to issue the
final call.
SQL and Postgres differ in behaviour if the value of a char or varchar
type exceeds the declared length. Postgres cuts off the value, SQL
requires to raise an error.
In particular, the compliant behaviour is:
create table test (a varchar(4));
insert into test values ('ok');
[ok]
insert into test values ('not ok');
ERROR: value too long for type character varying(4)
insert into test values ('good ');
[truncates spaces that are too long]
I think this behaviour is desirable over the old one because it makes the
char and varchar types useful in the first place.
For bit types there is, of course, no such extra rule for spaces.
However, SQL requires that for fixed-width bit strings, the input value
must have as many digits as the declared length of the string. That is,
create table test (a bit(4));
insert into test values (b'101');
will fail. I think that's reasonable, too, because it avoids the
endianness issues.
Unless there are objections, I will make this happen.
--
Peter Eisentraut peter_e(at)gmx(dot)net http://funkturm.homeip.net/~peter
From | Date | Subject | |
---|---|---|---|
Next Message | Ondrej Palkovsky | 2001-05-19 10:56:48 | TRUNCATE doesn't follow referential integrity |
Previous Message | Peter Eisentraut | 2001-05-19 09:02:23 | Re: [COMMITTERS] pgsql/ oc/src/sgml/runtime.sgml rc/backend/uti ... |