EXECUTE command tag returns actual command

Started by Kris Jurkaover 22 years ago5 messagespatches
Jump to latest
#1Kris Jurka
books@ejurka.com

This patch makes the EXECUTE command's completion tag return the
completion tag of the actual statement executed. This allows the
correct update count to be returned for UPDATE/INSERT/DELETE
statements. Per discussion on hackers here:

http://archives.postgresql.org/pgsql-hackers/2004-03/msg00923.php

Kris Jurka

Attachments:

executetag.patchtext/plain; CHARSET=US-ASCII; NAME=executetag.patchDownload+9-9
#2Bruce Momjian
bruce@momjian.us
In reply to: Kris Jurka (#1)
Re: EXECUTE command tag returns actual command

Your patch has been added to the PostgreSQL unapplied patches list at:

http://momjian.postgresql.org/cgi-bin/pgpatches

I will try to apply it within the next 48 hours.

---------------------------------------------------------------------------

Kris Jurka wrote:

This patch makes the EXECUTE command's completion tag return the
completion tag of the actual statement executed. This allows the
correct update count to be returned for UPDATE/INSERT/DELETE
statements. Per discussion on hackers here:

http://archives.postgresql.org/pgsql-hackers/2004-03/msg00923.php

Kris Jurka

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#3Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#2)
Re: EXECUTE command tag returns actual command

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Your patch has been added to the PostgreSQL unapplied patches list at:

Kris Jurka wrote:

This patch makes the EXECUTE command's completion tag return the
completion tag of the actual statement executed.

While I don't have any strong reason to object to this, the reason
Kris wanted it was to help let the JDBC driver use "EXECUTE prepared-stmt"
as its basic mechanism for executing pre-prepared statements --- and
there are a couple reasons why he should abandon that idea in favor of
using V3-protocol Bind/Execute messages.

If he goes over to using Bind/Execute then the JDBC driver will have no
need for this patch. In that case we ought to stop and think whether
sticking to the existing behavior isn't the right thing to do; it wins
on backwards-compatibility grounds and we have no other use-cases saying
we should change.

Not a big complaint, but something to consider before applying.

regards, tom lane

PS: If you do apply, the EXECUTE reference page needs to have an
"Output" section added explaining that it returns a tag other than the
default "EXECUTE".

#4Bruce Momjian
bruce@momjian.us
In reply to: Kris Jurka (#1)
Re: [JDBC] EXECUTE command tag returns actual command

Patch applied. Thanks.

---------------------------------------------------------------------------

Kris Jurka wrote:

This patch makes the EXECUTE command's completion tag return the
completion tag of the actual statement executed. This allows the
correct update count to be returned for UPDATE/INSERT/DELETE
statements. Per discussion on hackers here:

http://archives.postgresql.org/pgsql-hackers/2004-03/msg00923.php

Kris Jurka

Content-Description:

[ Attachment, skipping... ]

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#3)
Re: [PATCHES] EXECUTE command tag returns actual command

Tom Lane wrote:

Bruce Momjian <pgman@candle.pha.pa.us> writes:

Your patch has been added to the PostgreSQL unapplied patches list at:

Kris Jurka wrote:

This patch makes the EXECUTE command's completion tag return the
completion tag of the actual statement executed.

While I don't have any strong reason to object to this, the reason
Kris wanted it was to help let the JDBC driver use "EXECUTE prepared-stmt"
as its basic mechanism for executing pre-prepared statements --- and
there are a couple reasons why he should abandon that idea in favor of
using V3-protocol Bind/Execute messages.

If he goes over to using Bind/Execute then the JDBC driver will have no
need for this patch. In that case we ought to stop and think whether
sticking to the existing behavior isn't the right thing to do; it wins
on backwards-compatibility grounds and we have no other use-cases saying
we should change.

Not a big complaint, but something to consider before applying.

regards, tom lane

PS: If you do apply, the EXECUTE reference page needs to have an
"Output" section added explaining that it returns a tag other than the
default "EXECUTE".

Nice:

test=> CREATE TABLE test(x int);
CREATE TABLE
test=> PREPARE x(int) AS INSERT INTO test VALUES ($1);
PREPARE
test=> EXECUTE x(3);
INSERT 17210 1

I have applied the attached patch that updates the EXECUTE docs to
mention the tag will match the PREPARE. Shame it is only available
after execute. If it could be known before, I could allow log_statement
to trigger printing depending on the type of tag.

I have also updated the log_statement docs to more clearly explain that
log_statement doesn't properly know what type of command is being
execute. log_statement does handle PREPARE properly though.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Attachments:

/bjm/difftext/plainDownload+17-15