Re: CommandStatus from insert returning when using a portal. - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: CommandStatus from insert returning when using a portal.
Date
Msg-id CAKFQuwa97UN65V0YME1Wcz3-szFDENj-zpduQA=XcCPV0PMG7Q@mail.gmail.com
Whole thread Raw
In response to Re: CommandStatus from insert returning when using a portal.  (chap@anastigmatix.net)
Responses Re: CommandStatus from insert returning when using a portal.
List pgsql-hackers
On Fri, Jul 14, 2023 at 11:34 AM <chap@anastigmatix.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.

pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: sslinfo extension - add notbefore and notafter timestamps
Next
From: Erik Rijkers
Date:
Subject: Re: PG 16 draft release notes ready