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.