pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nick Fankhauser <nickf@ontko.com>
To: pgsql-admin <pgsql-admin@postgresql.org>
Cc: Ray Ontko <rayo@ontko.com>
Subject: Is it safe to increase pg_attribute.atttypmod ?
Date: Mon, 20 May 2002 15:56:42 -0500
Message-ID: <NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.com> (raw)

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/




view thread (4+ messages)  latest in thread

Message-ID: <NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.com>
Permalink:  ../NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.com/
Also on:    postgresql.org/message-id/NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.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: nickf@ontko.com, rayo@ontko.com
  Subject: Re: Is it safe to increase pg_attribute.atttypmod ?
  In-Reply-To: <NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.com>
  References: <NEBBLAAHGLEEPCGOBHDGEEPDEPAA.nickf@ontko.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