Received: from u1.abs.net (root@u1.abs.net [207.114.0.131]) by hub.org (8.8.8/8.7.5) with ESMTP id VAA22463 for ; Thu, 23 Apr 1998 21:14:37 -0400 (EDT) Received: from insightdist.com (nobody@localhost) by u1.abs.net (8.8.5/8.8.5) with UUCP id UAA26123 for pgsql-hackers@postgreSQL.org; Thu, 23 Apr 1998 20:59:31 -0400 (EDT) X-Authentication-Warning: u1.abs.net: nobody set sender to insightdist.com!byronn using -f Received: by insightdist.com (AIX 3.2/UCB 5.64/4.03) id AA25225; Thu, 23 Apr 1998 20:55:15 -0400 Received: from ppp0_ceodev by ceodev (AIX 4.1/UCB 5.64/4.03) id AA46042; Thu, 23 Apr 1998 20:43:04 -0400 Message-Id: <353FDE5F.30748CC1@insightdist.com> Date: Thu, 23 Apr 1998 20:35:43 -0400 From: Byron Nikolaidis X-Mailer: Mozilla 4.05 [en] (Win95; I) Mime-Version: 1.0 To: Bruce Momjian Cc: Hannu Krosing , daveh@insightdist.com, pgsql-hackers@postgreSQL.org, pgsql-interfaces@postgreSQL.org Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size References: <199804232117.RAA11218@candle.pha.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. Byron