Re: The comment of Primary key

From: "Dave Page" <dpage(at)vale-housing(dot)co(dot)uk>
To: <saito(at)inetrt(dot)skcapi(dot)co(dot)jp>
Cc: <pgadmin-hackers(at)postgresql(dot)org>
Subject: Re: The comment of Primary key
Date: 2003-09-18 08:02:28
Message-ID: 50187.80.177.99.193.1063872148.squirrel@ssl.vale-housing.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

It's rumoured that Hiroshi Saito once said:

> ----------------------------------------------------------------
> saito=# SELECT cls.oid, cls.relname as idxname, indrelid, indkey,
> indisclustered, indisunique, indisprimary, n.nspname,
> indnatts, tab.relname as tabname, indclass, description,
> pg_get_expr(indpred, indrelid, true) as indconstraint, contype,
> condeferrable, condeferred, amname
> FROM pg_index idx
> JOIN pg_class cls ON cls.oid=indexrelid
> JOIN pg_class tab ON tab.oid=indrelid
> JOIN pg_namespace n ON n.oid=tab.relnamespace
> JOIN pg_am am ON am.oid=cls.relam
> LEFT OUTER JOIN pg_description des ON (des.objoid=cls.oid AND
> des.objsubid = 0) LEFT OUTER JOIN pg_constraint con ON
> con.conrelid=indrelid AND conname=cls.relname
> WHERE cls.relname = 'MyTransaction_pkey';

Hi Hiroshi,

I don't have a system to test this on at the moment so I may have missed
something...
You are joining to pg_description using pg_class.oid. This will return the
comment for the table. Try joining to pg_constraint.oid so it uses the
pkey records oid.
Regards, Dave.

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message claus 2003-09-18 16:49:40 Strange Error in Server logfile
Previous Message Hiroshi Saito 2003-09-18 02:56:54 The comment of Primary key