Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C0B68632F3D for ; Mon, 2 Mar 2009 05:35:48 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 79923-09 for ; Mon, 2 Mar 2009 05:35:38 -0400 (AST) X-Greylist: delayed 00:24:57.369512 by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id 1C605632987 for ; Mon, 2 Mar 2009 05:35:38 -0400 (AST) Received: from 219-89-241-75.adsl.xtra.co.nz ([219.89.241.75] helo=[192.168.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1Le4AR-0008T4-Ty; Mon, 02 Mar 2009 22:10:32 +1300 Message-ID: <49ABA286.7000707@opencloud.com> Date: Mon, 02 Mar 2009 22:10:30 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.19 (X11/20090105) MIME-Version: 1.0 To: DGPickett CC: pgsql-jdbc@postgresql.org Subject: Re: ResultSetMetaData.getColumnDisplaySize returns 2147483647 ? References: <095cddc9-bca7-41a5-84a8-0faca7adadc2@f11g2000vbf.googlegroups.com> <3c7f373b-77e6-4860-984e-101af492abe3@f37g2000vbf.googlegroups.com> <8b19844a-98d4-4967-9426-3ddeec6f8559@a39g2000yqc.googlegroups.com> In-Reply-To: <8b19844a-98d4-4967-9426-3ddeec6f8559@a39g2000yqc.googlegroups.com> X-Enigmail-Version: 0.95.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/1 X-Sequence-Number: 19331 DGPickett wrote: > Yes, I see it comes up over and over: > > http://archives.postgresql.org/pgsql-hackers/2007-06/msg00428.php > > The discussions about char versus byte were nice, but the method name > says "Display" and the api doc says "characters", so if you have > Nvarchar(20) in a 16 bit unicode context, the storage needs 40 bytes > (plus a length) and the right return is 20. Nobody expects or wants > the gratuitous expense of dynamic sizing, just the obvious max so they > can typeset text output. JAVA hides the code for wide characters, and > we do not want it bring it back into the light. Except that the backend is not written in Java, and neither are all the other frontends. To some extent, this is a case of the JDBC interface not being flexible enough about the metadata (or often not even documenting what it's meant to mean!) - so we are stuck trying to provide the best fit we can from the data the server gives us. Asking the server to conform to JDBC's particular idea of how the metadata should look, at the expense of other interfaces, seems a bit unreasonable. If you have a better idea about how the JDBC driver can map the information coming from the backend to the JDBC metadata interfaces, a patch would be great. Or you could change the calling code to bounds-check the metadata results before it goes off and tries to allocate the entire heap for one column in one row .. -O