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

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

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: hannu(at)trust(dot)ee (Hannu Krosing)
Cc: byronn(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-23 16:45:42
Message-ID: 199804231645.MAA26157@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-interfaces
> 
> Byron Nikolaidis wrote:
> > 
> > Hello,
> > 
> > I was wondering if it would be possible, in the Postgres backend, to
> > send back the defined column size for the varchar data type (and
> > possibly the char() type, i.e., bpchar) on a query?  Currently, it just
> > sends back -1 for the size, which makes it difficult in the frontend
> > (i.e., odbc driver) to determine what the size of the column is.
> 
> While the right solution to this is of course getting the size from 
> backend, there exists a workaround now (assuming that the query is not 
> too expensive). While ASCII cursors always hide the varchar sizes, 
> binary ones return the size in actual data (by zero-padding the 
> returned data to max size), so one can determine the actual max 
> sizes by opening the query in binary cursor and then examining 
> enough records to get one non-null field for each varchar field.

As of 6.3, this is only true of char() fields.  Varchar() is now
variable length.

-- 
Bruce Momjian                          |  830 Blythe Avenue
maillist(at)candle(dot)pha(dot)pa(dot)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)

In response to

Responses

pgsql-hackers by date

Next:From: Zeugswetter Andreas SARZDate: 1998-04-23 17:18:06
Subject: Using mmap instead of shmem
Previous:From: Bruce MomjianDate: 1998-04-23 16:36:45
Subject: Re: [HACKERS] retrieving varchar size

pgsql-interfaces by date

Next:From: Hannu KrosingDate: 1998-04-23 17:28:39
Subject: Re: [HACKERS] Re: [INTERFACES] retrieving varchar size
Previous:From: Bruce MomjianDate: 1998-04-23 16:36:45
Subject: Re: [HACKERS] retrieving varchar size

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