Tim Andersen <[EMAIL PROTECTED]> 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 ---------------------------(end of broadcast)--------------------------- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faqs/FAQ.html