pg.ddx.io pgsql-admin@postgresql.org mailing list archivehelp / color / mirror / Atom feed
From: Steve Lane <slane@soliantconsulting.com>
To: pgsql-admin@postgresql.org
Cc: Jamie Thomas <jthomas@soliantconsulting.com>
Subject: Re: PG 7.2 varchar change
Date: Thu, 12 Aug 2004 23:32:41 -0500
Message-ID: <BD41AE99.18DBE%slane@soliantconsulting.com> (raw)
In-Reply-To: <17798.1092369431@sss.pgh.pa.us>
Thanks, Tom, that's very helpful. One more clarification: if the underlying
column has no express length limit (for example, it was defined as type
'text'), is this issue moot?
-- sgl
> From: Tom Lane <tgl@sss.pgh.pa.us>
> Date: Thu, 12 Aug 2004 23:57:11 -0400
> To: slane <slane@moyergroup.com>
> Cc: pgsql-admin@postgresql.org, Jamie Thomas <jthomas@soliantconsulting.com>
> Subject: Re: [ADMIN] PG 7.2 varchar change
>
> slane <slane@moyergroup.com> writes:
>> 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)
>> 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
>
view thread (5+ messages) latest in thread
Message-ID: <BD41AE99.18DBE%slane@soliantconsulting.com> Permalink: ../BD41AE99.18DBE%25slane@soliantconsulting.com/ Also on: postgresql.org/message-id/BD41AE99.18DBE%slane@soliantconsulting.com ·
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 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: slane@soliantconsulting.com, jthomas@soliantconsulting.com Subject: Re: PG 7.2 varchar change In-Reply-To: <BD41AE99.18DBE%slane@soliantconsulting.com> References: <17798.1092369431@sss.pgh.pa.us> <BD41AE99.18DBE%slane@soliantconsulting.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