From: | Dave Cramer <davecramer(at)gmail(dot)com> |
---|---|
To: | chap(at)anastigmatix(dot)net |
Cc: | "David G(dot) Johnston" <david(dot)g(dot)johnston(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 18:47:52 |
Message-ID: | CADK3HHLkxOQ-aYy8rss1PzSCie=phPz1iX3V0_tpKcys5eKN+g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Fri, 14 Jul 2023 at 14:34, <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.
>
> I've seen a possibly even more interesting result using pgjdbc-ng with
> protocol.trace=true:
>
> FetchSize=0
> <P<D<S
> > 1.>t.>T$>Z*
> <B<E<S
> > 2.>D.>D.>C.>Z*
> executeUpdate result: 2
> ids: 1 2
>
> FetchSize=1
> <B<E<H
> > 2.>D.>s*
> executeUpdate result: -1
> ids: 3 <E<H
> > D.>s*
> 4 <E<H
> > C*
> <C<S
> > 3.>Z*
>
> FetchSize=2
> <B<E<H
> > 2.>D.>D.>s*
> executeUpdate result: -1
> ids: 5 6 <E<H
> > C*
> <C<S
> > 3.>Z*
>
> FetchSize=3
> <B<E<H
> > 2.>D.>D.>C*
> <C<S
> > 3.>Z*
> executeUpdate result: 2
> ids: 7 8
>
>
> Unless there's some interleaving of trace and stdout messages happening
> here, I think pgjdbc-ng is not even collecting all the returned rows
> in the suspended-cursor case before executeUpdate returns, but keeping
> the cursor around for getGeneratedKeys() to use, so executeUpdate
> returns -1 before even having seen the later command complete, and would
> still do that even if the command complete message had the right count.
>
My guess is that pgjdbc-ng sees the -1 and doesn't bother looking any
further
Either way pgjdbc-ng is a dead project so I'm not so concerned about it.
Dave
>
> Regards,
> -Chap
>
From | Date | Subject | |
---|---|---|---|
Next Message | Daniel Gustafsson | 2023-07-14 18:50:52 | Re: sslinfo extension - add notbefore and notafter timestamps |
Previous Message | Cary Huang | 2023-07-14 18:41:01 | Re: sslinfo extension - add notbefore and notafter timestamps |