Re: CommandStatus from insert returning when using a portal.

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: chap(at)anastigmatix(dot)net
Cc: Dave Cramer <davecramer(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: CommandStatus from insert returning when using a portal.
Date: 2023-07-14 19:06:19
Message-ID: CAKFQuwa97UN65V0YME1Wcz3-szFDENj-zpduQA=XcCPV0PMG7Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 14, 2023 at 11:34 AM <chap(at)anastigmatix(dot)net> wrote:

> On 2023-07-12 21:30, David G. Johnston wrote:
> > Right, and executeUpdate is the wrong API method to use, in the
> > PostgreSQL
> > world, when executing insert/update/delete with the non-SQL-standard
> > returning clause. ... ISTM that you are trying to make user-error less
> > painful.
>
> In Dave's Java reproducer, no user-error has been made, because the user
> supplied a plain INSERT with the RETURN_GENERATED_KEYS option, and the
> RETURNING clause has been added by the JDBC driver. So the user expects
> executeUpdate to be the right method, and return the row count, and
> getGeneratedKeys() to then return the rows.
>
>
That makes more sense, though I don't understand how the original desire of
having the count appear before the actual rows would materially
benefit that feature.

I agree that the documented contract of the insert command tag says it
reports the size of the entire tuple store maintained by the server during
the transaction instead of just the most recent count on subsequent fetches.

David J.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2023-07-14 19:29:42 Re: PG 16 draft release notes ready
Previous Message Daniel Gustafsson 2023-07-14 18:50:52 Re: sslinfo extension - add notbefore and notafter timestamps