Re: [HACKERS] psql \d command - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] psql \d command
Date
Msg-id m0zWI0s-000EBPC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to psql \d command  ("Jose' Soares" <jose@sferacarta.com>)
List pgsql-hackers
>
> Hi all,
>
> I see now \d shows indexes, I tried to display index structure but it
> show the wrong
> length of fields:
>
> [...]
>
> hygea=> \d figure_pkey
>
> Table    = figure_pkey
> +----------------------------------+----------------------------------+-------+
> |              Field               |              Type                |
> Length|
> +----------------------------------+----------------------------------+-------+
> it should be:
> | azienda                          | char()
> |    -4 |<<-- 11
> | tipo                             | char()
> |    -4 |<<-- 02
> | gruppo                           | char()
> |    -4 |<<-- 02
> | inizio_attivita                  | date
> |     4 |<<-- 04
> +----------------------------------+----------------------------------+-------+

    The  atttypmod  value  off  all  index  attributes  is  0  in
    pg_attribute.  That's the reason  why  \d  shows  this.  This
    information  is  not  required  for indices because the datum
    given to the index access methods comes from the heap  tuples
    and  it  must  already  have  the  correct size if it reaches
    there.

    For data types of variable size, an  atttypmod  value  of  -1
    means  variable, a value of n means size = n-4 (4 is the size
    of the variable length datum header VARHDRSZ).  Don't  worry,
    you  cannot  select  from  an  index  directly, so it doesn't
    matter. But psql might get enhanced for  6.5  to  lookup  the
    atttypmod  of the indexed field in the table instead of using
    that from the index.

    BTW: You might also want to look at the pg_indexes view.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

pgsql-hackers by date:

Previous
From: "Jose' Soares"
Date:
Subject: Re: [HACKERS] Re: [INTERFACES] Odbc parser error
Next
From: "Philippe Rochat (RSR: 318 17 93)"
Date:
Subject: Time format ? (Really microsecond ??)