Skip site navigation (1) Skip section navigation (2)

Improved index support for \d and \di in psql

From: greg(at)turnstep(dot)com
To: pgsql-patches(at)postgresql(dot)org
Subject: Improved index support for \d and \di in psql
Date: 2001-11-19 16:27:12
Message-ID: 3BF8EC90.1345.A2D95A@localhost (view raw, whole thread or download thread mbox)
Lists: pgsql-patches
Hash: SHA1

Here is a better version that allows psql to view functional and 
partial indexes. (btw, my previous problem regarding the 
partial-index predicate was an extra comma in a select statement)

I've used pg_get_indexdef (in most cases) for the advanced index 
information, and put it in the SQL rather than having C 
try and parse the string apart.

I also looked in the documentation, but did not find any spots 
that need changing. The only thing that seemd to mention 
"\d" in docs is the release notes and 
sgml/ref/psql-ref.sgml, which is very vague and has no examples 
that need changing. Perhaps that example section should be 
expanded a bit?

Here is what the psql output looks like after the patch:

(table with a normal, a functional, and a partial index)

template1=# \d foo

                Table "foo"
 Column |         Type          | Modifiers
- --------+-----------------------+-----------
 foo    | integer               |
 bar    | integer               |
 baz    | character varying(20) |
Indexes: abc btree (foo) WHERE (foo < 100),
         funky btree (lower(baz)),
         simple btree (foo)

(all indexes now list waht table they belong to)

template1=# \di

         List of relations
  Name  | Type  |  Owner   | Table
- --------+-------+----------+-------
 abc    | index | postgres | foo
 four   | index | postgres | ftest
 funky  | index | postgres | foo
 one    | index | postgres | ftest
 simple | index | postgres | foo
 three  | index | postgres | ftest
 two    | index | postgres | ftest

(a partial index)

template1=# \d abc

   Index "abc"
 Column |  Type
- --------+---------
 foo    | integer
btree for table "foo" WHERE (foo < 100)

(a functional index - much improved over just showing 'lower')

template1=# \d funky

    Index "funky"
    Column    | Type
- --------------+------
 (lower(baz)) | text
btree for table "foo"

Greg Sabino Mullane
PGP Key: 0x14964AC8 200111191050



Attachment: indexdetail2.patch
Description: application/octet-stream (10.7 KB)


pgsql-patches by date

Next:From: Greg Sabino MullaneDate: 2001-11-19 18:47:51
Subject: Version checking when loading psql
Previous:From: Weiping HeDate: 2001-11-17 16:33:26
Subject: the new patches for zh_CN NLS

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group