From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kris Jurka <books@ejurka.com>
Cc: Sylvain Leroux <sl20@wanadoo.fr>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Using BigInteger as argument to AbstractJdbc2Statement.setObject
Date: Tue, 11 Aug 2009 09:50:25 -0400
Message-ID: <8312.1249998625@sss.pgh.pa.us> (raw)
In-Reply-To: <alpine.BSO.2.00.0908110034590.10664@leary.csoft.net>
References: <4A79587F.6010603@wanadoo.fr>
<4A79694F.9060404@opencloud.com>
<4A798325.4030607@wanadoo.fr>
<4A798682.9080204@opencloud.com>
<4A7ADF53.2070203@wanadoo.fr>
<alpine.BSO.2.00.0908110034590.10664@leary.csoft.net>
Kris Jurka <books@ejurka.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, books@ejurka.com, sl20@wanadoo.fr
Subject: Re: Using BigInteger as argument to AbstractJdbc2Statement.setObject
In-Reply-To: <8312.1249998625@sss.pgh.pa.us>
References: <4A79587F.6010603@wanadoo.fr> <4A79694F.9060404@opencloud.com> <4A798325.4030607@wanadoo.fr> <4A798682.9080204@opencloud.com> <4A7ADF53.2070203@wanadoo.fr> <alpine.BSO.2.00.0908110034590.10664@leary.csoft.net> <8312.1249998625@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox