From: electrotype <electrotype@gmail.com>
To: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?
Date: Wed, 9 Dec 2020 14:28:29 -0500
Message-ID: <c41792c8-7a94-2736-0316-dba3d1e7c885@gmail.com> (raw)
In-Reply-To: <CAKFQuwZQV8eguy50d5kJ5r4MKduaJk4mWmFG5tsnZ11-ov=n-g@mail.gmail.com>
References: <36689061-0844-2dfd-a4ee-8006d8a15ca9@gmail.com>
<CADK3HHL68fd+D_e-jGdx9J--hrwEx26-5a-V6fFf=OOLUTgApw@mail.gmail.com>
<1d0c8b21-25cc-2a3e-7f25-81f2de645f1e@gmail.com>
<CADK3HH+h60g5dmZq4qhESo1Q1yn-x4EGixYZbOGufc=tHFu-1A@mail.gmail.com>
<4ce0f5f5-d608-887b-b5ef-21ae187e3b58@gmail.com>
<CAKFQuwZQV8eguy50d5kJ5r4MKduaJk4mWmFG5tsnZ11-ov=n-g@mail.gmail.com>
Agreed.
>
> However, this isn't really the purview of JDBC - I'm doubting it does anything that would cause
> the order to be different than what is received, and the batch items are sent and results
> processed sequentially.
>
> The main question is whether any batch items are inserting multiple records themselves - i.e.,
> RETURNING * is producing multiple results. Whatever order RETURNING * produces is what the driver
> will capture - but it isn't responsible for guaranteeing that the order of multiple inserted
> records going in matches what comes out. PostgreSQL needs to make that claim. I don't see where
> it does (i've sent an email to see if adding such a claim to the documentation is proper). Done
> manually one can always do "WITH insert returning SELECT ORDER BY", but it doesn't seem workable
> for the driver to try and do that when adding the returning clause, which I presume is what is in
> scope here.
>
> David J.
>
Thank you, it's appreciated! I'm sure this clarification would help other developers too.
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: electrotype@gmail.com
Subject: Re: JDBC driver - is "getGeneratedKeys()" guaranteed to return the ids in the same order a batch insert was made?
In-Reply-To: <c41792c8-7a94-2736-0316-dba3d1e7c885@gmail.com>
References: <36689061-0844-2dfd-a4ee-8006d8a15ca9@gmail.com> <CADK3HHL68fd+D_e-jGdx9J--hrwEx26-5a-V6fFf=OOLUTgApw@mail.gmail.com> <1d0c8b21-25cc-2a3e-7f25-81f2de645f1e@gmail.com> <CADK3HH+h60g5dmZq4qhESo1Q1yn-x4EGixYZbOGufc=tHFu-1A@mail.gmail.com> <4ce0f5f5-d608-887b-b5ef-21ae187e3b58@gmail.com> <CAKFQuwZQV8eguy50d5kJ5r4MKduaJk4mWmFG5tsnZ11-ov=n-g@mail.gmail.com> <c41792c8-7a94-2736-0316-dba3d1e7c885@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