X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 429525E46BF for ; Fri, 13 Aug 2004 00:57:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19377-03 for ; Fri, 13 Aug 2004 03:57:19 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 62E405E3F15 for ; Fri, 13 Aug 2004 00:57:09 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.11/8.12.11) with ESMTP id i7D3vCCr017799; Thu, 12 Aug 2004 23:57:12 -0400 (EDT) To: slane Cc: pgsql-admin@postgresql.org, Jamie Thomas Subject: Re: PG 7.2 varchar change In-reply-to: References: Comments: In-reply-to slane message dated "Thu, 12 Aug 2004 22:30:14 -0500" Date: Thu, 12 Aug 2004 23:57:11 -0400 Message-ID: <17798.1092369431@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/98 X-Sequence-Number: 14493 slane 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