Re: [HACKERS] psql \d command

From: jwieck(at)debis(dot)com (Jan Wieck)
To: jose(at)sferacarta(dot)com (Jose' Soares)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] psql \d command
Date: 1998-10-22 10:30:38
Message-ID: m0zWI0s-000EBPC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)debis(dot)com (Jan Wieck) #

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Philippe Rochat (RSR: 318 17 93) 1998-10-22 10:37:35 Time format ? (Really microsecond ??)
Previous Message Jan Wieck 1998-10-22 08:53:10 Re: [HACKERS] What about LIMIT in SELECT ?