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
Index: src/backend/commands/prepare.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/commands/prepare.c,v
retrieving revision 1.25
diff -c -r1.25 prepare.c
*** src/backend/commands/prepare.c      7 Jan 2004 18:56:25 -0000       1.25
--- src/backend/commands/prepare.c      18 Apr 2004 08:15:59 -0000
***************
*** 106,112 ****
   * Implements the 'EXECUTE' utility statement.
   */
  void
! ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest)
  {
        PreparedStatement *entry;
        char       *query_string;
--- 106,112 ----
   * Implements the 'EXECUTE' utility statement.
   */
  void
! ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest, char *completionTag)
  {
        PreparedStatement *entry;
        char       *query_string;
***************
*** 188,194 ****
         */
        PortalStart(portal, paramLI);
  
!       (void) PortalRun(portal, FETCH_ALL, dest, dest, NULL);
  
        PortalDrop(portal, false);
  
--- 188,194 ----
         */
        PortalStart(portal, paramLI);
  
!       (void) PortalRun(portal, FETCH_ALL, dest, dest, completionTag);
  
        PortalDrop(portal, false);
  
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.211
diff -c -r1.211 utility.c
*** src/backend/tcop/utility.c  23 Mar 2004 19:35:17 -0000      1.211
--- src/backend/tcop/utility.c  18 Apr 2004 08:16:00 -0000
***************
*** 486,492 ****
                        break;
  
                case T_ExecuteStmt:
!                       ExecuteQuery((ExecuteStmt *) parsetree, dest);
                        break;
  
                case T_DeallocateStmt:
--- 486,492 ----
                        break;
  
                case T_ExecuteStmt:
!                       ExecuteQuery((ExecuteStmt *) parsetree, dest, completionTag);
                        break;
  
                case T_DeallocateStmt:
Index: src/include/commands/prepare.h
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/include/commands/prepare.h,v
retrieving revision 1.9
diff -c -r1.9 prepare.h
*** src/include/commands/prepare.h      29 Nov 2003 22:40:59 -0000      1.9
--- src/include/commands/prepare.h      18 Apr 2004 08:16:00 -0000
***************
*** 42,48 ****
  
  /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
  extern void PrepareQuery(PrepareStmt *stmt);
! extern void ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest);
  extern void DeallocateQuery(DeallocateStmt *stmt);
  extern void ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate);
  
--- 42,49 ----
  
  /* Utility statements PREPARE, EXECUTE, DEALLOCATE, EXPLAIN EXECUTE */
  extern void PrepareQuery(PrepareStmt *stmt);
! extern void ExecuteQuery(ExecuteStmt *stmt, DestReceiver *dest,
!                                          char *completionTag);
  extern void DeallocateQuery(DeallocateStmt *stmt);
  extern void ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate);
  
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to