Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 6796F1337B82 for ; Fri, 22 Apr 2011 14:19:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 27184-02 for ; Fri, 22 Apr 2011 17:19:15 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id 24A181337B4E for ; Fri, 22 Apr 2011 14:19:14 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Fri, 22 Apr 2011 12:19:14 -0500 Message-Id: <4DB17239020000250003CBF2@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Fri, 22 Apr 2011 12:19:05 -0500 From: "Kevin Grittner" To: "Jon Nelson" , "Tom Lane" Cc: Subject: Re: database introspection error References: <24590.1303403331@sss.pgh.pa.us> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-5 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201104/182 X-Sequence-Number: 30101 Jon Nelson wrote: > Would the following query be more (most?) correct, assuming the > oid of the table is known? It doesn't seem to work for indexes on expressions. Try this: create table t (id int not null primary key, txt text); create index t_weird on t ((substring(txt, 1, id))); create index t_txt_notnull on t (txt) where txt is not null; SELECT i.relname as relname, ix.indisunique, ix.indexprs, ix.indpred, a.attname as column_name FROM pg_class t, pg_class i, pg_index ix, pg_attribute a WHERE t.oid = ix.indrelid and i.oid = ix.indexrelid and a.attrelid = t.oid and a.attnum = ANY(ix.indkey) and t.relkind = 'r' and t.oid = (select oid from pg_class where relname = 't') ORDER BY t.relname, i.relname ; -Kevin