column length? - Mailing list pgsql-novice

From Mark McArthey
Subject column length?
Date
Msg-id CGEFKOCNLBFDGLJODOGIMEJECDAA.mcarthey@execpc.com
Whole thread Raw
Responses Re: column length?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
Hi all,
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?
Thanks!
Mark

> psql -E

=# \d player
********* QUERY *********
SELECT relhasindex, relkind, relchecks, reltriggers, relhasrules
FROM pg_class WHERE relname='player'
*************************

********* QUERY *********
SELECT a.attname, t.typname, a.attlen, a.atttypmod, a.attnotnull,
a.atthasdef, a
.attnum
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = 'player'
AND a.attnum > 0 AND a.attrelid = c.oid AND a.atttypid = t.oid
ORDER BY a.attnum
*************************

Table "player"
Attribute |    Type     | Modifier
-----------+-------------+----------
name      | varchar(20) |
password  | varchar(20) |


=# \i query1.sql
relhasindex | relkind | relchecks | reltriggers | relhasrules
-------------+---------+-----------+-------------+-------------
f           | r       |         0 |           0 | f
(1 row)

markm=# \i query2.sql
attname  | typname | attlen | atttypmod | attnotnull | atthasdef | attnum
----------+---------+--------+-----------+------------+-----------+--------
name     | varchar |     -1 |        24 | f          | f         |      1
password | varchar |     -1 |        24 | f          | f         |      2
(2 rows)



pgsql-novice by date:

Previous
From: "Mark McArthey"
Date:
Subject: dynamic #include's?
Next
From: Jochem van Dieten
Date:
Subject: Re: Performance question (PostgreSQL 7.1.3)