Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id 6124C47622C for ; Mon, 20 May 2002 18:07:52 -0400 (EDT) Received: from shire.ontko.com (shire.ontko.com [199.164.165.1]) by postgresql.org (Postfix) with ESMTP id 62853475AC1 for ; Mon, 20 May 2002 16:58:10 -0400 (EDT) Received: from nick (bilbo.ontko.com [199.164.165.101]) by shire.ontko.com (8.9.3/8.9.3/Debian 8.9.3-21) with SMTP id PAA22390; Mon, 20 May 2002 15:58:12 -0500 X-Authentication-Warning: shire.ontko.com: Host bilbo.ontko.com [199.164.165.101] claimed to be nick Reply-To: From: "Nick Fankhauser" To: "pgsql-admin" Cc: "Ray Ontko" Subject: Is it safe to increase pg_attribute.atttypmod ? Date: Mon, 20 May 2002 15:56:42 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2911.0) Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200205/159 X-Sequence-Number: 4334 Hi- We need to increase the length of a varchar field, and couldn't find a way to do it using "alter table". Since the alternative is copying & re-creating a very large table, we starting poking around under the hood & found that pg_attribute.atttypmod seems to be always equal to the length plus 4 in the case of varchar fields. We created a test table and altered the varchar length on a field by increasing pg_attribute.atttypmod, and the length seemed to change and act as expected. The update to change a varchar(10) field to varchar(40) looked like this: update pg_attribute set atttypmod = 44 where attrelid = ( select oid from pg_class where relname = 'test' ) and attname = 'oldtest' ; Is this a smart thing to do? Are there other hidden related bits of data that will come back to haunt us later? -Nick -------------------------------------------------------------------------- Nick Fankhauser nickf@ontko.com Phone 1.765.935.4283 Fax 1.765.962.9788 Ray Ontko & Co. Software Consulting Services http://www.ontko.com/