[GENERAL] atttypmod encoding

2011-02-09 Thread RW Shore
Catalog pg_attribute contains interesting type-specific information in
attribute atttypmod. Can someone verify that these encodings are correct?

CHAR and VARCHAR: 4 + the declared length. Example: CHAR(5) -> 9 in
atttypmod
NUMERIC(p,s): 4 + the long with p in the left-most 4 bytes and s in the
right-most


[GENERAL] Size of varchar in an array

2011-02-08 Thread RW Shore
I'm using the following type definition:
create type typedef.BASIC_PEDIGREE as (
DATE_ADDED TIMESTAMP,
DESCRIPTION VARCHAR(128) [10]
)\c

I understand that PostgreSQL doesn't enforce the array length [10]. However,
I'd like to write an application that can retrieve this length AND the size
of the varchar that makes up the array. I can't find these values anyplace
in the various system catalogs or views. Does PostgreSQL keep this
information someplace and if so where? If there's no way to retrieve (say)
the max size of the varchar, does this mean that PostgreSQL does not enforce
the max size of this field as well as not enforcing the array bounds?