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 78DC85E46C1 for ; Fri, 13 Aug 2004 02:11:36 -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 32745-10 for ; Fri, 13 Aug 2004 05:11:30 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6EB095E37CB for ; Fri, 13 Aug 2004 02:11:30 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i7D5BTiG037907 for ; Fri, 13 Aug 2004 05:11:29 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i7D4o0vQ033852 for pgsql-admin@postgresql.org; Fri, 13 Aug 2004 04:50:00 GMT From: Christopher Browne X-Newsgroups: comp.databases.postgresql.admin Subject: Re: PG 7.2 varchar change Date: Fri, 13 Aug 2004 00:24:07 -0400 Organization: cbbrowne Computing Inc Lines: 45 Message-ID: References: <4001DEAF7DF9BD498B58B45051FBEA650146C600@25exch1.vicorpower.vicr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@news.hub.org X-message-flag: Outlook is rather hackable, isn't it? X-Home-Page: http://www.cbbrowne.com/info/ X-Affero: http://svcs.affero.net/rm.php?r=cbbrowne User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) Cancel-Lock: sha1:+hgkDyNFBfSrDaIcgzPW9ZT8Nac= To: pgsql-admin@postgresql.org 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/99 X-Sequence-Number: 14494 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