Re: [pgadmin-hackers] Fwd: Re: Howto change column

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Jean-Michel POURE <jm(dot)poure(at)freesurf(dot)fr>, pgsql-general(at)postgresql(dot)org
Subject: Re: [pgadmin-hackers] Fwd: Re: Howto change column
Date: 2001-11-07 18:42:12
Message-ID: 5693.1005158532@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> For the text types I think it's generally length+4. For numeric, I think
> it's precision*65536+scale. The best way to find out is probably to
> declare a column of the target type and check.

Or experiment with format_type(), or read the source code for same.
For example:

regression=# select oid from pg_type where typname = 'numeric';
oid
------
1700
(1 row)

regression=# select format_type(1700, 10 * 65536 + 7);
format_type
---------------
numeric(10,3)
(1 row)

Looks like there's an offset of 4 for numeric, too. But a look into
src/backend/utils/adt/format_type.c gives the exact recipe ...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Darley 2001-11-07 19:07:31 Re: More Performance Questions
Previous Message Gordan Bobic 2001-11-07 18:26:08 Re: More Performance Questions