Thread: sigh .. another bug in the JDBC driver (ResultSetMetaData.getColumnDisplaySize)

Hi,

here's just another annoying bug in the JDBC driver:

ResultSetMetaData.getColumnDisplaySize() returns the length of the
*column label*, but it is expected to return the max width of the column!

Sorry, I don't have a fix right now, maybe I get around writing one today
or so ..

kind regards,

-- 
Jens Glaser     Am Holderstrauch 13, 36041 Fulda, 0661/9429507    jens@jens.de



On Mon, Aug 02, 1999 at 07:23:07PM +0000, Jens Glaser wrote:
> Hi,
> 
> here's just another annoying bug in the JDBC driver:
> 
> ResultSetMetaData.getColumnDisplaySize() returns the length of the
> *column label*, but it is expected to return the max width of the column!
> 

Hmm, the Zope Python interface suffers from the same problem (and the
same work around): lack of column width info, substituting the column
label length.

> Sorry, I don't have a fix right now, maybe I get around writing one today
> or so ..

Let me know how you solve it, I'll need to take a crack at it for mine
as well.

Ross
-- 
Ross J. Reedstrom, Ph.D., <reedstrm@rice.edu> 
NSBRI Research Scientist/Programmer
Computer and Information Technology Institute
Rice University, 6100 S. Main St.,  Houston, TX 77005


On Mon, 2 Aug 1999, Jens Glaser wrote:

> Hi,
> 
> here's just another annoying bug in the JDBC driver:
> 
> ResultSetMetaData.getColumnDisplaySize() returns the length of the
> *column label*, but it is expected to return the max width of the column!

It's already on my list of things for 6.6.

--      Peter T Mount peter@retep.org.uk     Main Homepage: http://www.retep.org.uk
PostgreSQL JDBC Faq: http://www.retep.org.uk/postgresJava PDF Generator: http://www.retep.org.uk/pdf



"Ross J. Reedstrom" wrote:
> 
> On Mon, Aug 02, 1999 at 07:23:07PM +0000, Jens Glaser wrote:
> > Hi,
> >
> > here's just another annoying bug in the JDBC driver:
> >
> > ResultSetMetaData.getColumnDisplaySize() returns the length of the
> > *column label*, but it is expected to return the max width of the column!
> >
> 
> Hmm, the Zope Python interface suffers from the same problem (and the
> same work around): lack of column width info, substituting the column
> label length.

I'm not sure that this info is available through libpq but it appeared
at 
least to protocol level in about 6.4 for variable length fields (it has 
always been there for fixed width of course). At least ODBC drivers do
use it.

-------Hannu


[INTERFACES] embedded sql

From
nico@clubdelphi.com (Nicolas Aragon)
Date:
Hello,

I can't find in the docs the reference for "declare cursor" or "fetch"
sentences that I've seen passed to pqlib in the samples. 

In particular, I would like to know if I could execute a query and
fetch the tuples as needed. 

TIA,
 Nico



Re: [INTERFACES] embedded sql

From
Herouth Maoz
Date:
At 18:41 +0300 on 03/08/1999, Nicolas Aragon wrote:


> I can't find in the docs the reference for "declare cursor" or "fetch"
> sentences that I've seen passed to pqlib in the samples.
>
> In particular, I would like to know if I could execute a query and
> fetch the tuples as needed.

It's not embedded SQL, it's just SQL. The documentation is right where all
the other SQL statements are. For example, in section l (ell, not one) of
the manpages.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma




Hi,

On Mon, 2 Aug 1999, Ross J. Reedstrom wrote:
> > Sorry, I don't have a fix right now, maybe I get around writing one today
> > or so ..
> 
> Let me know how you solve it, I'll need to take a crack at it for mine
> as well.

I've put together a patch, which you can find on my website:
http://www.jens.de/kontor/.

Here's the new routine:
 /**  * What is the column's normal maximum width in characters?  *  * @param column the first column is 1, the second
is2, etc.  * @return the maximum width  * @exception SQLException if a database access error occurs  */ public int
getColumnDisplaySize(intcolumn) throws SQLException {   Field f = getField(column);   String type_name =
f.getTypeName();  int sql_type = f.getSQLType();   int typmod = f.mod;
 
   // I looked at other JDBC implementations and couldn't find a consistent   // interpretation of the "display size"
fornumeric values, so this is our's   // FIXME: currently, only types with a SQL92 or SQL3 pendant are implemented -
jens@jens.de
   // fixed length data types   if (type_name.equals( "int2"      ))  return 6;  // -32768 to +32768 (5 digits and a
sign)  if (type_name.equals( "int4"      )    || type_name.equals( "oid"       ))  return 11; // -2147483648 to
+2147483647  if (type_name.equals( "int8"      ))  return 20; // -9223372036854775808 to +9223372036854775807   if
(type_name.equals("money"     ))  return 12; // MONEY=DECIMAL(9,2)   if (type_name.equals( "float4"    ))  return 11;
//I checked it out and wasn't able to produce more than 11 digits   if (type_name.equals( "float8"    ))  return 20; //
dito,20   if (type_name.equals( "char"      ))  return 1;   if (type_name.equals( "bool"      ))  return 1;   if
(type_name.equals("date"      ))  return 14; // "01/01/4713 BC" - "31/12/32767 AD"   if (type_name.equals( "time"
)) return 8;  // 00:00:00-23:59:59   if (type_name.equals( "timestamp" ))  return 22; // hhmmm ... the output looks
likethis: 1999-08-03 22:22:08+02
 
   // variable length fields   typmod -= 4;   if (type_name.equals( "bpchar"    )    || type_name.equals( "varchar"
)) return typmod; // VARHDRSZ=sizeof(int32)=4   if (type_name.equals( "numeric"   ))  return ( (typmod >>16) & 0xffff)
                                       + 1 + ( typmod        & 0xffff); // DECIMAL(p,s) = (p digits).(s digits)
 
   // if we don't know better   return f.length; }

-- 
Jens Glaser     Am Holderstrauch 13, 36041 Fulda, 0661/9429507    jens@jens.de