Re: How does psql actually implement the \d commands

From: "Albe Laurenz" <laurenz(dot)albe(at)wien(dot)gv(dot)at>
To: "Andrew Falanga *EXTERN*" <af300wsm(at)gmail(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: How does psql actually implement the \d commands
Date: 2008-04-09 11:51:57
Message-ID: D960CB61B694CF459DCFB4B0128514C201FA5AC0@exadv11.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Andrew Falanga wrote:
>
> I know about the -E option to psql and did that to get the following,
> which is what psql does for a \d <tablename>:
>
> ********* QUERY **********
> SELECT c.oid,
> n.nspname,
> c.relname
> FROM pg_catalog.pg_class c
> LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
> WHERE pg_catalog.pg_table_is_visible(c.oid)
> AND c.relname ~ '^(personaldata)$'
> ORDER BY 2, 3;
> **************************
>
> ********* QUERY **********
> SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
> FROM pg_catalog.pg_class WHERE oid = '17408'
> **************************
>
> ********* QUERY **********
> SELECT a.attname,
> pg_catalog.format_type(a.atttypid, a.atttypmod),
> (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d
> WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND
> a.atthasdef),
> a.attnotnull, a.attnum
> FROM pg_catalog.pg_attribute a
> WHERE a.attrelid = '17408' AND a.attnum > 0 AND NOT a.attisdropped
> ORDER BY a.attnum
> **************************
>
> ********* QUERY **********
> SELECT c.relname FROM pg_catalog.pg_class c, pg_catalog.pg_inherits i
> WHERE c.oid=i.inhparent AND i.inhrelid = '17408' ORDER BY inhseqno ASC
> **************************
>
> Now, I tried to execute these queries one at a time and they failed,
> somewhat miserably. In what order does PostgreSQL actually execute
> them? Are they implemented as sub-queries? If so, in what order are
> they executed?

They do not fail here, and they should not fail.
They should be executed as above, in this order.

What are the miserable error messages you get?

Yours,
Laurenz Albe

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivano Luberti 2008-04-09 12:29:12 begin transaction locks out other connections
Previous Message Markus Wollny 2008-04-09 11:49:22 Re: tsvector_update_trigger throws error "column is not of tsvector type"