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

Re: [HACKERS] Re: [INTERFACES] retrieving varchar size

From: Byron Nikolaidis <byronn(at)insightdist(dot)com>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Cc: Hannu Krosing <hannu(at)trust(dot)ee>, daveh(at)insightdist(dot)com, pgsql-hackers(at)postgreSQL(dot)org, pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Date: 1998-04-24 00:35:43
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-interfaces

Bruce Momjian wrote:

> Can't you do:
>         select atttypmod from pg_attribute
>         where attrelid = 10003 and attname = 'col1';
> That will give the length + 4 bytes.

The problem with that theory is this.  If the frontend application just
executes some random query, such as "select * from table", you really do not
know anything about what is coming back. You must rely on the little bit of
information the protocol gives you.  In the case of Postgres, it gives you
the fieldname, datatype, and size for each column in the result.
Unfortunately, for varchar and char(n), the size reports -1.  This is not
very helpful for describing the result set.

Your above example works fine (in fact we use that already) when you know the
table and column name, as in metadata functions such as SQLColumns() in the
ODBC driver.


In response to


pgsql-hackers by date

Next:From: The Hermit HackerDate: 1998-04-24 00:48:59
Subject: Re: [HACKERS] AIX needs a new port maintainer.
Previous:From: Bruce MomjianDate: 1998-04-24 00:06:17
Subject: Re: [HACKERS] AIX needs a new port maintainer.

pgsql-interfaces by date

Next:From: Henry B. HotzDate: 1998-04-24 01:24:52
Subject: Re: [DOCS] ODBC Doc
Previous:From: Michael MossDate: 1998-04-24 00:14:38
Subject: Re: [INTERFACES] Can't connect with ODBC

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