Re: [pgadmin-hackers] Fwd: Re: Howto change column - Mailing list pgsql-general

From Tom Lane
Subject Re: [pgadmin-hackers] Fwd: Re: Howto change column
Date
Msg-id 5693.1005158532@sss.pgh.pa.us
Whole thread Raw
In response to Re: [pgadmin-hackers] Fwd: Re: Howto change column  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
List pgsql-general
Stephan Szabo <sszabo@megazone23.bigpanda.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

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: More Performance Questions
Next
From: "Peter Darley"
Date:
Subject: Re: More Performance Questions