Dumping SQL type names - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Dumping SQL type names
Date
Msg-id Pine.LNX.4.21.0007042122020.3542-100000@localhost.localdomain
Whole thread Raw
Responses Re: Dumping SQL type names
List pgsql-hackers
A while ago I suggested to create a backend internal function that takes
an internal type name and an atttypmod and formats it to a canonical SQL
type, to be used by pg_dump, psql, and anyone who feels like it.

I have it written now, here's an example of how it works. Any comments?


regression=# select c.relname, a.attname, format_type(t.typname, a.atttypmod)
from pg_class c, pg_attribute a, pg_type t
where c.oid=a.attrelid and t.oid=a.atttypid
and c.relname not like 'pg\_%' and a.attnum > 0
order by 1;
        relname         |    attname    |      format_type
-------------------------+---------------+------------------------a                       | aa            | texta_star
               | class         | character(1)a_star                  | aa            | integera_star                  |
a            | textabstime_tbl             | f1            | abstimeaggtest                 | a             |
smallintaggtest                | b             | realarrtest                 | a             | smallint[]arrtest
        | b             | integer[]arrtest                 | c             | name[]arrtest                 | d
  | text[]arrtest                 | e             | double precision[]arrtest                 | f             |
character(5)[]arrtest                | g             | character varying(5)[]b                       | aa            |
text
...

-- 
Peter Eisentraut                  Sernanders väg 10:115
peter_e@gmx.net                   75262 Uppsala
http://yi.org/peter-e/            Sweden




pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: zlib for pg_dump
Next
From: Peter Eisentraut
Date:
Subject: Re: [COMMITTERS] pgsql/doc/TODO.detail (alpha default distinct flock fsync function limit null pg_shadow primary)