From: Steven Hirsch <snhirsch@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Odd behavior with 'currval'
Date: Thu, 8 Feb 2018 14:51:00 -0500 (EST)
Message-ID: <alpine.DEB.2.20.1802081443480.5809@z87> (raw)
In-Reply-To: <CAKFQuwYOid4vqN6abpxS=VrrYnt3PBnmvSF+Lk317cuL_jW32w@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>
On Thu, 8 Feb 2018, David G. Johnston wrote:
> On Thu, Feb 8, 2018 at 10:58 AM, Steven Hirsch <snhirsch@gmail.com> wrote:
> On a hunch, I tried 'SELECT currval(NULL)' to see if it returned '0', but that too returns NULL.
> So, where is the '0' coming from when I do:
>
> SELECT currval( pg_get_serial_sequence('udm_asset_type_definition','def_id'))
>
> ? I've already established that the inner expression evaluates to NULL!
>
>
> This is indeed unusual...to be specific here pg_get_serial_sequence returns null in lieu of an error for
> being unable to locate the indicated sequence. currval is returning null because it is defined "STRICT" and
> so given a null input it will always return null. currval itself, when provided a non-null input, is going
> to error or provide a number (which should never be zero...).
> I'm wondering whether someone didn't like the fact that currval errors and instead wrote a overriding
> function that instead returns zero?
Do you mean "someone" on the PostgreSQL development team - or "someone" at
my end? I can assure you there are no overriding functions in either
of my databases. I just double-checked this. The only 'currval'
procedure is the one defined at installation (in public).
Looks like I may have encountered a legitimate bug?
--
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: snhirsch@gmail.com
Subject: Re: Odd behavior with 'currval'
In-Reply-To: <alpine.DEB.2.20.1802081443480.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>
* 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