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

Re: column length?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Mark McArthey" <mcarthey(at)execpc(dot)com>
Cc: "PgSQL Novice" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: column length?
Date: 2001-10-24 03:33:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
"Mark McArthey" <mcarthey(at)execpc(dot)com> writes:
> I am wondering how the column length is determined.  The attached output is
> for my test table.  Running '\d player' shows me that the columns are
> varchar(20), but the attlen is listed as -1.  Where does the value '20' come
> from?

attlen = -1 is a generic value indicating "variable length type".  All
columns of varchar type will have attlen = -1 (as will all columns of
any other variable-length datatype).  The gold is hidden in the
atttypmod column, which has a datatype-specific interpretation.
For varchar columns, atttypmod is interpreted as "max chars plus 4".
(The plus-4 is a historical wart.)  See
src/backend/utils/adt/format_type.c for info about the interpretation of
typmod for other datatypes.

			regards, tom lane

In response to

pgsql-novice by date

Next:From: Daniel BautistaDate: 2001-10-24 13:29:24
Subject: current and beta versions
Previous:From: Jochem van DietenDate: 2001-10-23 23:08:57
Subject: Re: Performance question (PostgreSQL 7.1.3)

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