Re: [HACKERS] Re: [INTERFACES] retrieving varchar size - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Date
Msg-id 199804231736.NAA29768@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] Re: [INTERFACES] retrieving varchar size  (Hannu Krosing <hannu@trust.ee>)
List pgsql-hackers
>
> In the latter case, I would suggest an additional SQL command for open
> cursors,
> or a pseudo table for open cursor where you could do a simple select
> statement:
>
> DECLARE CURSOR FOO_CURSOR FOR SELECT * FROM MYTABLE;
>
> SELECT _FIELD_NAME,_FIELD_TYPE,_FIELD_SIZE FROM
> FOO_CURSOR_INFO_PSEUTOTABLE;

The information you want is in pg_attribute.atttypmod.  It is normally
-1, but is set for char() and varchar() fields, and includes the 4-byte
length.  See bin/psql/psql.c for a sample of its use.

--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Next
From: David Hartwig
Date:
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size