From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | slane <slane(at)moyergroup(dot)com> |
Cc: | pgsql-admin(at)postgresql(dot)org, Jamie Thomas <jthomas(at)soliantconsulting(dot)com> |
Subject: | Re: PG 7.2 varchar change |
Date: | 2004-08-13 03:57:11 |
Message-ID: | 17798.1092369431@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
slane <slane(at)moyergroup(dot)com> writes:
> Heres the currently most alarming, a change that is recorded for 7.2:
> CHAR(), VARCHAR() now reject strings that are too long (Peter E)
> What does this mean? Or how do I find out what it means?
If in doubt, experiment.
In 7.1:
regression=# create table foo(f1 varchar(5));
CREATE
regression=# insert into foo values('1234567890');
INSERT 2913462 1
regression=# select * from foo;
f1
-------
12345
(1 row)
In 7.4:
regression=# create table foo(f1 varchar(5));
CREATE TABLE
regression=# insert into foo values('1234567890');
ERROR: value too long for type character varying(5)
7.4 follows the SQL spec (or our current understanding of it anyway):
strings will not be silently truncated. If you want to force truncation
to a particular length you can cast the string explicitly:
regression=# select 'way too long'::varchar(5);
varchar
---------
way t
(1 row)
That works the same in either version.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Browne | 2004-08-13 04:24:07 | Re: PG 7.2 varchar change |
Previous Message | slane | 2004-08-13 03:30:14 | PG 7.2 varchar change |