pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Francisco Olarte <folarte@peoplecall.com>
To: Steven Hirsch <snhirsch@gmail.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Odd behavior with 'currval'
Date: Fri, 9 Feb 2018 16:47:10 +0100
Message-ID: <CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.2.20.1802081638250.5809@z87>
References: <alpine.DEB.2.20.1802081050480.5809@z87>
	<CA+bJJbw-V2_gCUkbFTAn5USXZ9jtHrzh9vVMbB7mwg_yrMDyvQ@mail.gmail.com>
	<alpine.DEB.2.20.1802081243130.5809@z87>
	<CAKFQuwYOid4vqN6abpxS=VrrYnt3PBnmvSF+Lk317cuL_jW32w@mail.gmail.com>
	<alpine.DEB.2.20.1802081443480.5809@z87>
	<CAKFQuwYCK1qXkmcO2e7az5ZDX=y5xBvJT-29zQNFSXuuvR1_pQ@mail.gmail.com>
	<CAKFQuwaY1N6hR258U8z0qd52RR5TJvg+aGc2rfgG_OAAaQpi0Q@mail.gmail.com>
	<alpine.DEB.2.20.1802081620300.5809@z87>
	<CAKFQuwaLWdEp64f0RWZbM-F-fzzE_Qe3mMXH_s7THJ=TR1A9iA@mail.gmail.com>
	<alpine.DEB.2.20.1802081638250.5809@z87>

Steven:

On Thu, Feb 8, 2018 at 10:52 PM, Steven Hirsch <snhirsch@gmail.com> wrote:

This may sound a bit harsh but:

> The culprit is in the JDBC domain, NOT PostgreSQL!  According to the
> documentation I found, the ResultSet 'getLong()' method returns a value of
> zero when it sees NULL as an input. Why the JDBC libs don't treat this as an
> invalid numeric conversion is beyond me.

No, that's not a JDBC problem, that's pilot error.

JDBC has behaved like these for ever, and you have had people chasing
ghosts ( not a biggie, we are used to this ) because, instead of
providing the real chunks you were running you kept saying "when I
select currval() I get 0" and similar things. If you had said "when I
do rs.getLong(col) I get 0", or pasted a relevant chunk of code, lots
of people here would have pointed that getLong returns a primitive
java long, so rs.getObject() is needed if you may get null. JDBC has
been doing this forever, and they probably do it because in many cases
this behaviour is useful.

This also raises suspicions about your sequence ownership problems, as
you may have being ( with your best intention ) pasting your code to
reproduce the problems instead of the real scripts from the database.

In general, when you run a code chunk for problem reporting, try to do
it with psql ( which everybody has and knows how it works ) and paste
the code / result directly, without much editing. This aids a lot. In
fact, if you do it you may have noticed your text in psql returned an
empty column in currval(null), which, knowgin it is int, means it was
null ( in a string you cannot easily distinguish empty from nulls in a
simple select ).

Anyway, you report was quite nice and showed you put quite a bit of
work in it, treat these as tips to make problem reporting / solving
easier, not just as criticism.

Francisco Olarte.




view thread (37+ messages)  latest in thread

Message-ID: <CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com>
Permalink:  ../CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com/
Also on:    postgresql.org/message-id/CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com

 · 

reply

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-general@postgresql.org
  Cc: folarte@peoplecall.com, snhirsch@gmail.com
  Subject: Re: Odd behavior with 'currval'
  In-Reply-To: <CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com>
  References: <alpine.DEB.2.20.1802081050480.5809@z87> <CA+bJJbw-V2_gCUkbFTAn5USXZ9jtHrzh9vVMbB7mwg_yrMDyvQ@mail.gmail.com> <alpine.DEB.2.20.1802081243130.5809@z87> <CAKFQuwYOid4vqN6abpxS=VrrYnt3PBnmvSF+Lk317cuL_jW32w@mail.gmail.com> <alpine.DEB.2.20.1802081443480.5809@z87> <CAKFQuwYCK1qXkmcO2e7az5ZDX=y5xBvJT-29zQNFSXuuvR1_pQ@mail.gmail.com> <CAKFQuwaY1N6hR258U8z0qd52RR5TJvg+aGc2rfgG_OAAaQpi0Q@mail.gmail.com> <alpine.DEB.2.20.1802081620300.5809@z87> <CAKFQuwaLWdEp64f0RWZbM-F-fzzE_Qe3mMXH_s7THJ=TR1A9iA@mail.gmail.com> <alpine.DEB.2.20.1802081638250.5809@z87> <CA+bJJbwDacAxT8LsPhFfFjpO6DaR7H-XFpyJ8nukSfOXsTdkwQ@mail.gmail.com>

* 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