Improved index support for \d and \di in psql - Mailing list pgsql-patches

From greg@turnstep.com
Subject Improved index support for \d and \di in psql
Date
Msg-id 3BF8EC90.1345.A2D95A@localhost
Whole thread Raw
Responses Re: Improved index support for \d and \di in psql
List pgsql-patches
-----BEGIN PGP SIGNED MESSAGE-----
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
greg@turnstep.com
PGP Key: 0x14964AC8 200111191050

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iQA/AwUBO/kqr7ybkGcUlkrIEQKzZQCfe3Bmbx3/c2YTOgifxK242KvyvSsAoPZf
vmVJtwAaYA2S4P0fqCaQR2Zm
=ZBN+
-----END PGP SIGNATURE-----

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File:  indexdetail2.patch
     Date:  19 Nov 2001, 11:23
     Size:  10939 bytes.
     Type:  Unknown

Attachment

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Patch to add Heimdal kerberos support
Next
From: "Greg Sabino Mullane"
Date:
Subject: Version checking when loading psql