Re: About primary keys. - Mailing list pgsql-sql

From Tom Lane
Subject Re: About primary keys.
Date
Msg-id 18736.1060963060@sss.pgh.pa.us
Whole thread Raw
In response to Re: About primary keys.  (Tim Andersen <timander37@yahoo.com>)
Responses Re: About primary keys.  (Tim Andersen <timander37@yahoo.com>)
List pgsql-sql
Tim Andersen <timander37@yahoo.com> writes:
> The query I have so far only gets columns that are
> part of a primary key.
>        ...
>        and pga1.attnum = i.indkey[pga2.attnum-1];

This is wrong because you are looking at only one indkey position, and
the attribute could be in any position of the primary key.  I think
what you want is to drop pga2 from the query and instead use something
like
... and pga1.attnum in (i.indkey[0], i.indkey[1], i.indkey[2], ...)

(carrying it out to whatever you think is a reasonable upper bound on
the number of columns in a primary key --- the normal Postgres limit
is 32 keys but I can't believe anyone would use that many in practice).
        regards, tom lane


pgsql-sql by date:

Previous
From: Tim Andersen
Date:
Subject: Re: About primary keys.
Next
From: Tim Andersen
Date:
Subject: Re: About primary keys.