From: Christopher Browne <cbbrowne@acm.org>
To: pgsql-admin@postgresql.org
Subject: Re: PG 7.2 varchar change
Date: Fri, 13 Aug 2004 00:24:07 -0400
Message-ID: <m3pt5v3btk.fsf@wolfe.cbbrowne.com> (raw)
References: <4001DEAF7DF9BD498B58B45051FBEA650146C600@25exch1.vicorpower.vicr.com>
<BD419FF6.1880F%slane@moyergroup.com>
Quoth slane@moyergroup.com (slane):
> Hello all:
>
> I am upgrading a web application from postgres 7.1.2 to 7.4.3 (too long in
> coming to that point, I know).
>
> I have sifted through the history files and identified a restricted number
> of changes that potentially impact the app, a few of which I don¹t
> understand.
>
> Here¹s the currently most alarming, a change that is recorded for 7.2:
>
> CHAR(), VARCHAR() now reject strings that are too long (Peter E)
Consider this example:
tutorial=# create table test_string (f1 varchar, f2 varchar(10));
CREATE TABLE
tutorial=# insert into test_string (f1, f2) values ('abc', 'def');
INSERT 2623360 1
tutorial=# insert into test_string (f1, f2) values ('abcdefghijklmnopqrstuvwxyz', 'def');
INSERT 2623361 1
tutorial=# insert into test_string (f1, f2) values ('abcdefghijklmnopqrstuvwxyz', 'abcdefghiasdfasdfa');
ERROR: value too long for type character varying(10)
If no maximum length is specified, PostgreSQL is free to stick a
goodly amount of data in the field.
But supposing you decide that a particular column is VARCHAR(10),
trying to stuff more than 10 characters into it will fail, as you see
above.
Doing similar with char:
tutorial=# create table test_chars (f1 char, f2 char(10));
CREATE TABLE
tutorial=# insert into test_chars (f1, f2) values ('abc', 'def');
ERROR: value too long for type character(1)
Does that illustrate what's going on? I hope so...
--
let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;;
http://www3.sympatico.ca/cbbrowne/spreadsheets.html
"Fashion is a form of ugliness so intolerable that we have to alter it
every six months." -- Oscar Wilde
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-admin@postgresql.org
Cc: cbbrowne@acm.org
Subject: Re: PG 7.2 varchar change
In-Reply-To: <m3pt5v3btk.fsf@wolfe.cbbrowne.com>
References: <4001DEAF7DF9BD498B58B45051FBEA650146C600@25exch1.vicorpower.vicr.com> <BD419FF6.1880F%slane@moyergroup.com> <m3pt5v3btk.fsf@wolfe.cbbrowne.com>
* 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