Re: Order of generated keys during inserts

Dave Cramer <[email protected]> Fri, 18 Oct 2019 05:53:56 +0200
Newsgroups gmane.comp.db.postgresql.jdbc
Message-ID <CADK3HH+=3wD5qu86yYKevpfm5BTvuxypd_GW9cATsRfC_1=gNg@mail.gmail.com>
--000000000000340086059527497d
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Wed, 16 Oct 2019 at 20:26, Andrei Tsibets <[email protected]> wrote:

> Hello,
>
> I=E2=80=99m doing multiple inserts into PostgreSQL using *executeBatch*, =
and then
> retrieving generated primary keys via *getGeneratedKeys()*.
> The question is: is it save to match inserts with retuned keys by order?
> Is it guaranteed that generated keys are ordered according
> to the order in which commands were added to the batch?
>

They should be but we make no such guarantee.


Dave Cramer

[email protected]
www.postgresintl.com

--000000000000340086059527497d
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Wed, 16 Oct 2019 at 20:26, Andrei =
Tsibets &lt;<a href=3D"mailto:[email protected]">[email protected]</a=
>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><di=
v style=3D"overflow-wrap: break-word;">Hello,<div><br></div><div>I=E2=80=99=
m doing multiple inserts into PostgreSQL using=C2=A0<i>executeBatch</i>, an=
d then retrieving generated primary keys via <i>getGeneratedKeys()</i>.</di=
v><div>The question is: is it save to match inserts with retuned keys by or=
der? Is it guaranteed that generated keys are ordered according</div>to the=
 order in which commands were added to the batch?</div></blockquote><div><b=
r></div><div>They should be but we make no such guarantee.</div><div><br></=
div><br clear=3D"all"><div><div dir=3D"ltr" class=3D"gmail_signature"><div =
dir=3D"ltr"><div>Dave Cramer<br><br><a href=3D"mailto:[email protected]=
m" target=3D"_blank">[email protected]</a></div></div></div></div><div=
><a href=3D"http://www.postgresintl.com" target=3D"_blank">www.postgresintl=
.com</a></div><div><br></div></div></div>

--000000000000340086059527497d--