pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kevin Grittner <Kevin.Grittner@wicourts.gov>
To: Jon Nelson <jnelson+pgsql@jamponi.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@postgresql.org
Subject: Re: database introspection error
Date: Fri, 22 Apr 2011 12:19:05 -0500
Message-ID: <4DB17239020000250003CBF2@gw.wicourts.gov> (raw)
In-Reply-To: <BANLkTik-DoXEhya3pCJv=0v-wAR+qwz9oQ@mail.gmail.com>
References: <BANLkTineAbe68mrzpuF7VY5Ag5MGqc+_cQ@mail.gmail.com>
	<24590.1303403331@sss.pgh.pa.us>
	<BANLkTik-DoXEhya3pCJv=0v-wAR+qwz9oQ@mail.gmail.com>

Jon Nelson <jnelson+pgsql@jamponi.net> 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



view thread (5+ messages)  latest in thread

Message-ID: <4DB17239020000250003CBF2@gw.wicourts.gov>
Permalink:  ../4DB17239020000250003CBF2@gw.wicourts.gov/
Also on:    postgresql.org/message-id/4DB17239020000250003CBF2@gw.wicourts.gov

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: Kevin.Grittner@wicourts.gov, jnelson+pgsql@jamponi.net, tgl@sss.pgh.pa.us
  Subject: Re: database introspection error
  In-Reply-To: <4DB17239020000250003CBF2@gw.wicourts.gov>
  References: <BANLkTineAbe68mrzpuF7VY5Ag5MGqc+_cQ@mail.gmail.com> <24590.1303403331@sss.pgh.pa.us> <BANLkTik-DoXEhya3pCJv=0v-wAR+qwz9oQ@mail.gmail.com> <4DB17239020000250003CBF2@gw.wicourts.gov>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox