Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 84A7363385A for ; Tue, 11 Aug 2009 10:50:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 50780-03 for ; Tue, 11 Aug 2009 13:50:28 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id A5ED2633859 for ; Tue, 11 Aug 2009 10:50:28 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n7BDoPCN008313; Tue, 11 Aug 2009 09:50:26 -0400 (EDT) To: Kris Jurka cc: Sylvain Leroux , pgsql-jdbc@postgresql.org Subject: Re: Using BigInteger as argument to AbstractJdbc2Statement.setObject In-reply-to: References: <4A79587F.6010603@wanadoo.fr> <4A79694F.9060404@opencloud.com> <4A798325.4030607@wanadoo.fr> <4A798682.9080204@opencloud.com> <4A7ADF53.2070203@wanadoo.fr> Comments: In-reply-to Kris Jurka message dated "Tue, 11 Aug 2009 01:07:29 -0400" Date: Tue, 11 Aug 2009 09:50:25 -0400 Message-ID: <8312.1249998625@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200908/17 X-Sequence-Number: 19866 Kris Jurka writes: > On Thu, 6 Aug 2009, Sylvain Leroux wrote: >> That's what I have done now: setBigInteger will choose the narrowest integer >> representation. NUMERIC will still be used when no integer type is wide >> enough to hold the value. > I don't think this is a great idea. Changing behavior based on the value > of the parameter will just lead to unpredictable behavior as the size > boundaries are crossed. For what it's worth, if you type a bare integer constant in a SQL command, the backend will take it to be int4, int8, or numeric depending on size. It's been that way for a long time and we've had few complaints, in part because the set of implicit casts is designed expecting that behavior. So I'm not sure that mirroring that behavior on the JDBC side is a bad thing. (However, if the proposed patch is also mixing int2 into the picture, that *would* be a bad thing. Stick to int4 or larger.) > 1) Always map BigInteger -> numeric. This would break a lot of things. The backend's implicit casts are designed to upcast int to numeric when context demands, but not the reverse. regards, tom lane