Re: Fix issuing of multiple command completions per command - Mailing list pgsql-patches

From Fernando Nasser
Subject Re: Fix issuing of multiple command completions per command
Date
Msg-id 3C7BD66B.EA529EC9@redhat.com
Whole thread Raw
In response to Fix issuing of multiple command completions per command  (Fernando Nasser <fnasser@redhat.com>)
Responses Re: Fix issuing of multiple command completions per command  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Tom Lane wrote:
>
> Fernando Nasser <fnasser@redhat.com> writes:
> > (Please note that "[PATCHES] Allow arbitrary levels of
> > analyze/rewriting" must be applied before this patch)
>
> Actually, it looks like you accidentally included that patch as part of
> this one.  Since Bruce already applied that patch, this one will not
> apply cleanly.
>

Oops!  I am attaching the corrected patch. Sorry.


> While this looks good as far as it goes, I don't think it
> resolves the problems exposed by Coax's recent complaint:
> http://archives.postgresql.org/pgsql-bugs/2002-02/msg00155.php
>

It would solve the completion tag part as it would send the INSERT.
Remember that you asked me to generate the tag based on the parse
tree (before the analyze/rewrite).

And I prevent a second command completion tag to clobber it.
We should ask him to try the patch.  Coax says he is not very
concerned with the CommandInfo -- the application needs the
right CommandTag.

But yes, this patch is to fix the tag part.  We can work together on
a follow-up patch to improve the CommandInfo part as well, but we
will have to change things around a bit, as you suggest.

> There are two remaining bogosities:
>
> 1. We need to get rid of the static variable CommandInfo that's
> manipulated by UpdateCommandInfo; static state is certainly going
> to be a bad idea in this context.
>

Humm, I believe it is only used from the Begin to the End calls.
It seems harmless to me, but it may indeed go away once
we rearrange things around to choose what is printed


> 2. EndCommand should *not* be issued until we have completed all the
> actions of the (rewritten) query.  Moving EndCommand into
> PerformPortalFetch, as you did here, is exactly the wrong direction.
> What we need is for EndCommand to be executed from pg_exec_query_string.
> That means that the tag auxiliary info (currently set up by
> UpdateCommandInfo) has to be passed out from ProcessQuery to
> pg_exec_query_string, which is the only place that can know when to send
> the command completion notice back to the client.
>

That was my first impression, but after I looked more deeply into it
I figured that this is the right thing to do (I explain it below).

And remember that there is still the 'Z'.  This completion will close
the
flow of data packets that may have been sent.  It is good for the
async processing as well as the application may process the data
while waiting for the 'Z' (otherwise it will not know that all the
data has arrived).


> As the comments in dest.h and dest.c point out, BeginCommand/EndCommand
> are fairly confused in purpose and usage right now.  Maybe rather than
> patching, we ought to decide what functionality we really need and do a
> major reconstruction job.
>

I think it was fine until rewriting of queries became more frequent.
It is actually still fine for plannable queries (with this patch
applied).

The way I see it is that this is a palnnable query thing where
Begin and End calls should open and close the flow of data.

For plannable queries we have:

BeginCommand()
<send data>
EndCommand()

It has to be properly adapted for utility queries and in that case
it has to be handled by pg_exec_query_string which is the one that
has a view of the utility processing as a whole (no sending of data
involved in this case either).



> One rather nasty issue that arises here is that I don't think
> pg_exec_query_string has enough knowledge to understand which of the
> queries produced by query rewriting corresponds to the "original" query.
> This is critical in order to figure out which command's auxiliary info
> is the right stuff to pass back to the client.  I suspect we will need
> to expand QueryRewrite's API to identify the "main" query in the
> returned query list.
>

For tags we avoided this issue when you asked me to use the parse tree
to
generate the completion tokens.  But I agree that we will probably have
to do exactly what you are saying if we want to control what is the
CommandInfo that will be printed with the CommandTag.

But consider also that the CommandInfo that corresponds to the data
stream was already sent.  And it is zero anyway if more than one row
is affected, isn't it?  Maybe it is not that broken after all
(with tis patch applied, I mean).


My suggestion is that we do this in stages.  Get the tags fixed (this
patch), as CREATE SCHEMAS gets very weird without it.  And that we
discuss
a little bit what to do with CommandInfo and create a patch for that.
Also, a single patch for both things will meddle with too much code.

--
Fernando Nasser
Red Hat Canada Ltd.                     E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9Index: src/backend/commands/command.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/command.c,v
retrieving revision 1.154
diff -c -p -r1.154 command.c
*** src/backend/commands/command.c    2002/02/19 20:11:12    1.154
--- src/backend/commands/command.c    2002/02/26 03:33:46
*************** PerformPortalFetch(char *name,
*** 230,246 ****
      SetScanCommandId(savedId);

      /*
       * Clean up and switch back to old context.
       */
      if (temp_desc)
          pfree(queryDesc);

      MemoryContextSwitchTo(oldcontext);
-
-     /*
-      * Note: the "end-of-command" tag is returned by higher-level utility
-      * code
-      */
  }

  /* --------------------------------
--- 230,246 ----
      SetScanCommandId(savedId);

      /*
+      * tell fe/be or whatever that we're done sending the data
+      */
+     EndCommand(tag, queryDesc->dest);
+
+     /*
       * Clean up and switch back to old context.
       */
      if (temp_desc)
          pfree(queryDesc);

      MemoryContextSwitchTo(oldcontext);
  }

  /* --------------------------------
Index: src/backend/commands/explain.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/commands/explain.c,v
retrieving revision 1.67
diff -c -p -r1.67 explain.c
*** src/backend/commands/explain.c    2001/10/25 05:49:25    1.67
--- src/backend/commands/explain.c    2002/02/26 03:33:46
***************
*** 19,24 ****
--- 19,25 ----
  #include "parser/parsetree.h"
  #include "rewrite/rewriteHandler.h"
  #include "tcop/pquery.h"
+ #include "utils/ps_status.h"
  #include "utils/relcache.h"

  typedef struct ExplainState
*************** ExplainOneQuery(Query *query, bool verbo
*** 113,118 ****
--- 114,121 ----
          struct timeval starttime;
          struct timeval endtime;

+         set_ps_display("SELECT");
+
          /*
           * Set up the instrumentation for the top node. This will cascade
           * during plan initialisation
*************** ExplainOneQuery(Query *query, bool verbo
*** 133,138 ****
--- 136,143 ----
          }
          totaltime = (double) endtime.tv_sec +
              (double) endtime.tv_usec / 1000000.0;
+
+         set_ps_display("EXPLAIN");
      }

      es = (ExplainState *) palloc(sizeof(ExplainState));
Index: src/backend/executor/functions.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/executor/functions.c,v
retrieving revision 1.47
diff -c -p -r1.47 functions.c
*** src/backend/executor/functions.c    2001/10/28 06:25:43    1.47
--- src/backend/executor/functions.c    2002/02/26 03:33:46
*************** postquel_getnext(execution_state *es)
*** 276,281 ****
--- 276,283 ----
           * Process a utility command. (create, destroy...)    DZ - 30-8-1996
           */
          ProcessUtility(es->qd->parsetree->utilityStmt, es->qd->dest);
+         /* We should not call EndCommand() here as we are inside a function
+          * call and command-complete reports should not be issued. */
          if (!LAST_POSTQUEL_COMMAND(es))
              CommandCounterIncrement();
          return (TupleTableSlot *) NULL;
Index: src/backend/executor/spi.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/executor/spi.c,v
retrieving revision 1.65
diff -c -p -r1.65 spi.c
*** src/backend/executor/spi.c    2002/02/14 15:24:08    1.65
--- src/backend/executor/spi.c    2002/02/26 03:33:46
*************** _SPI_execute(char *src, int tcount, _SPI
*** 1012,1017 ****
--- 1012,1019 ----
              if (plan == NULL)
              {
                  ProcessUtility(queryTree->utilityStmt, None);
+                 /* We don't need to call EndCommand() as we don't want to
+                  * send anything (dest = None) */
                  if (!islastquery)
                      CommandCounterIncrement();
                  else
*************** _SPI_execute_plan(_SPI_plan *plan, Datum
*** 1086,1091 ****
--- 1088,1095 ----
          if (queryTree->commandType == CMD_UTILITY)
          {
              ProcessUtility(queryTree->utilityStmt, None);
+             /* We don't need to call EndCommand() as we don't want to
+              * send anything (dest = None) */
              if (!islastquery)
                  CommandCounterIncrement();
              else
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/postgres.c,v
retrieving revision 1.247
diff -c -p -r1.247 postgres.c
*** src/backend/tcop/postgres.c    2002/02/23 01:31:36    1.247
--- src/backend/tcop/postgres.c    2002/02/26 03:33:47
***************
*** 64,69 ****
--- 64,78 ----

  #include "pgstat.h"

+ static char *CreateCommandTag(Node *parsetree);
+
+ /* Uncomment the following line if you want ps_status
+  * to be set for each individual query that may result from
+  * a rewrite as oposed to just the main (original) one
+  */
+ /* #define FINE_GRAIN_PROFILE 1 */
+
+
  /* ----------------
   *        global variables
   * ----------------
*************** pg_exec_query_string(char *query_string,
*** 634,639 ****
--- 643,650 ----
      foreach(parsetree_item, parsetree_list)
      {
          Node       *parsetree = (Node *) lfirst(parsetree_item);
+         char       *commandTag = NULL;
+         bool        isQueryStmt = false;
          bool        isTransactionStmt;
          List       *querytree_list,
                     *querytree_item;
*************** pg_exec_query_string(char *query_string,
*** 675,680 ****
--- 686,693 ----
                   * command ended. -cim 6/1/90
                   */
                  char       *tag = "*ABORT STATE*";
+
+                 set_ps_display(tag);

                  elog(NOTICE, "current transaction is aborted, "
                       "queries ignored until end of transaction block");
*************** pg_exec_query_string(char *query_string,
*** 702,708 ****

          /*
           * OK to analyze and rewrite this query.
!          *
           * Switch to appropriate context for constructing querytrees (again,
           * these must outlive the execution context).
           */
--- 715,737 ----

          /*
           * OK to analyze and rewrite this query.
!          */
!
!         /*
!          * First we set the command-completion tag to the main query
!          * (as opposed to each of the others that may have
!          * been generated by analyze and rewrite)
!          */
!         commandTag = CreateCommandTag(parsetree);
!
! #ifndef FINE_GRAIN_PROFILE
!         /*
!          * Set ps_status to the main query tag
!          */
!         set_ps_display(commandTag);
! #endif
!
!         /*
           * Switch to appropriate context for constructing querytrees (again,
           * these must outlive the execution context).
           */
*************** pg_exec_query_string(char *query_string,
*** 746,752 ****
--- 775,796 ----
                  else if (DebugLvl > 1)
                      elog(DEBUG, "ProcessUtility");

+ #ifdef FINE_GRAIN_PROFILE
+                 set_ps_display(CreateUtilityTag(querytree->utilityStmt));
+ #endif
                  ProcessUtility(querytree->utilityStmt, dest);
+
+                 /*
+                  * FETCHes, as plannable queries, take care of completion
+                  * themselves but we still have to do it for MOVEs as they
+                  * do not send data (and thus, do not send a completion).
+                  */
+                 if (nodeTag(parsetree) == T_FetchStmt)
+                 {
+                     FetchStmt  *stmt = (FetchStmt *) parsetree;
+                     if (!(stmt->ismove))
+                         isQueryStmt = true;  /* Don't do it twice */
+                 }
              }
              else
              {
*************** pg_exec_query_string(char *query_string,
*** 754,759 ****
--- 798,805 ----
                   * process a plannable query.
                   */
                  Plan       *plan;
+
+                 isQueryStmt = true;

                  plan = pg_plan_query(querytree);

*************** pg_exec_query_string(char *query_string,
*** 818,823 ****
--- 864,876 ----

          }                        /* end loop over queries generated from a
                                   * parsetree */
+
+         /*
+          * tell fe/be or whatever that we're done if we only processed
+          * utilities (plannable queries take care of completion themselves)
+          */
+         if (!isQueryStmt)
+             EndCommand(commandTag, dest);
      }                            /* end loop over parsetrees */

      /*
*************** assertTest(int val)
*** 2037,2039 ****
--- 2090,2354 ----
  #endif

  #endif
+
+
+ /* ----------------------------------------------------------------
+  *        CreateCommandTag
+  *
+  *        utility to get a string representation of the
+  *        command operation.
+  * ----------------------------------------------------------------
+  */
+ static char *
+ CreateCommandTag(Node *parsetree)
+ {
+     char       *tag = NULL;
+
+     switch (nodeTag(parsetree))
+     {
+         case T_InsertStmt:
+             tag = "INSERT";
+             break;
+
+         case T_DeleteStmt:
+             tag = "DELETE";
+             break;
+
+         case T_UpdateStmt:
+             tag = "UPDATE";
+             break;
+
+         case T_SelectStmt:
+             tag = "SELECT";
+             break;
+
+         case T_TransactionStmt:
+             {
+                 TransactionStmt *stmt = (TransactionStmt *) parsetree;
+
+                 switch (stmt->command)
+                 {
+                     case BEGIN_TRANS:
+                         tag = "BEGIN";
+                         break;
+
+                     case COMMIT:
+                         tag = "COMMIT";
+                         break;
+
+                     case ROLLBACK:
+                         tag = "ROLLBACK";
+                         break;
+                 }
+             }
+             break;
+
+         case T_ClosePortalStmt:
+             tag = "CLOSE";
+             break;
+
+         case T_FetchStmt:
+             {
+                 FetchStmt  *stmt = (FetchStmt *) parsetree;
+                 tag = (stmt->ismove) ? "MOVE" : "FETCH";
+             }
+             break;
+
+         case T_CreateStmt:
+             tag = "CREATE";
+             break;
+
+         case T_DropStmt:
+             tag = "DROP";
+             break;
+
+         case T_TruncateStmt:
+             tag = "TRUNCATE";
+             break;
+
+         case T_CommentStmt:
+             tag = "COMMENT";
+             break;
+
+         case T_CopyStmt:
+             tag = "COPY";
+             break;
+
+         case T_RenameStmt:
+             tag = "ALTER";
+             break;
+
+         case T_AlterTableStmt:
+             tag = "ALTER";
+             break;
+
+         case T_GrantStmt:
+             {
+                 GrantStmt  *stmt = (GrantStmt *) parsetree;
+                 tag = (stmt->is_grant) ? "GRANT" : "REVOKE";
+             }
+             break;
+
+         case T_DefineStmt:
+             tag = "CREATE";
+             break;
+
+         case T_ViewStmt:        /* CREATE VIEW */
+             tag = "CREATE";
+             break;
+
+         case T_ProcedureStmt:    /* CREATE FUNCTION */
+             tag = "CREATE";
+             break;
+
+         case T_IndexStmt:        /* CREATE INDEX */
+             tag = "CREATE";
+             break;
+
+         case T_RuleStmt:        /* CREATE RULE */
+             tag = "CREATE";
+             break;
+
+         case T_CreateSeqStmt:
+             tag = "CREATE";
+             break;
+
+         case T_RemoveAggrStmt:
+             tag = "DROP";
+             break;
+
+         case T_RemoveFuncStmt:
+             tag = "DROP";
+             break;
+
+         case T_RemoveOperStmt:
+             tag = "DROP";
+             break;
+
+         case T_VersionStmt:
+             tag = "CREATE VERSION";
+             break;
+
+         case T_CreatedbStmt:
+             tag = "CREATE DATABASE";
+             break;
+
+         case T_DropdbStmt:
+             tag = "DROP DATABASE";
+             break;
+
+         case T_NotifyStmt:
+             tag = "NOTIFY";
+             break;
+
+         case T_ListenStmt:
+             tag = "LISTEN";
+             break;
+
+         case T_UnlistenStmt:
+             tag = "UNLISTEN";
+             break;
+
+         case T_LoadStmt:
+             tag = "LOAD";
+             break;
+
+         case T_ClusterStmt:
+             tag = "CLUSTER";
+             break;
+
+         case T_VacuumStmt:
+             if (((VacuumStmt *) parsetree)->vacuum)
+                 tag = "VACUUM";
+             else
+                 tag = "ANALYZE";
+             break;
+
+         case T_ExplainStmt:
+             tag = "EXPLAIN";
+             break;
+
+ #ifdef NOT_USED
+         case T_RecipeStmt:
+             tag = "EXECUTE RECIPE";
+             break;
+ #endif
+
+         case T_VariableSetStmt:
+             tag = "SET VARIABLE";
+             break;
+
+         case T_VariableShowStmt:
+             tag = "SHOW VARIABLE";
+             break;
+
+         case T_VariableResetStmt:
+             tag = "RESET VARIABLE";
+             break;
+
+         case T_CreateTrigStmt:
+             tag = "CREATE";
+             break;
+
+         case T_DropTrigStmt:
+             tag = "DROP";
+             break;
+
+         case T_CreatePLangStmt:
+             tag = "CREATE";
+             break;
+
+         case T_DropPLangStmt:
+             tag = "DROP";
+             break;
+
+         case T_CreateUserStmt:
+             tag = "CREATE USER";
+             break;
+
+         case T_AlterUserStmt:
+             tag = "ALTER USER";
+             break;
+
+         case T_DropUserStmt:
+             tag = "DROP USER";
+             break;
+
+         case T_LockStmt:
+             tag = "LOCK TABLE";
+             break;
+
+         case T_ConstraintsSetStmt:
+             tag = "SET CONSTRAINTS";
+             break;
+
+         case T_CreateGroupStmt:
+             tag = "CREATE GROUP";
+             break;
+
+         case T_AlterGroupStmt:
+             tag = "ALTER GROUP";
+             break;
+
+         case T_DropGroupStmt:
+             tag = "DROP GROUP";
+             break;
+
+         case T_CheckPointStmt:
+             tag = "CHECKPOINT";
+             break;
+
+         case T_ReindexStmt:
+             tag = "REINDEX";
+             break;
+
+         default:
+             elog(DEBUG, "CreateUtilityTag: unknown utility operation type %d",
+                  nodeTag(parsetree));
+             tag = "???";
+             break;
+     }
+
+     return tag;
+ }
+
Index: src/backend/tcop/pquery.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/pquery.c,v
retrieving revision 1.46
diff -c -p -r1.46 pquery.c
*** src/backend/tcop/pquery.c    2001/10/25 05:49:43    1.46
--- src/backend/tcop/pquery.c    2002/02/26 03:33:47
*************** ProcessQuery(Query *parsetree,
*** 180,186 ****
      EState       *state;
      TupleDesc    attinfo;

!     set_ps_display(tag = CreateOperationTag(operation));

      /*
       * initialize portal/into relation status
--- 180,186 ----
      EState       *state;
      TupleDesc    attinfo;

!     tag = CreateOperationTag(operation);

      /*
       * initialize portal/into relation status
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/tcop/utility.c,v
retrieving revision 1.126
diff -c -p -r1.126 utility.c
*** src/backend/tcop/utility.c    2002/02/24 20:20:20    1.126
--- src/backend/tcop/utility.c    2002/02/26 03:33:47
***************
*** 44,50 ****
  #include "rewrite/rewriteRemove.h"
  #include "tcop/utility.h"
  #include "utils/acl.h"
- #include "utils/ps_status.h"
  #include "utils/syscache.h"
  #include "utils/temprel.h"
  #include "access/xlog.h"
--- 44,49 ----
*************** void
*** 138,144 ****
  ProcessUtility(Node *parsetree,
                 CommandDest dest)
  {
-     char       *commandTag = NULL;
      char       *relname;
      char       *relationName;

--- 137,142 ----
*************** ProcessUtility(Node *parsetree,
*** 155,171 ****
                  switch (stmt->command)
                  {
                      case BEGIN_TRANS:
-                         set_ps_display(commandTag = "BEGIN");
                          BeginTransactionBlock();
                          break;

                      case COMMIT:
-                         set_ps_display(commandTag = "COMMIT");
                          EndTransactionBlock();
                          break;

                      case ROLLBACK:
-                         set_ps_display(commandTag = "ROLLBACK");
                          UserAbortTransactionBlock();
                          break;
                  }
--- 153,166 ----
*************** ProcessUtility(Node *parsetree,
*** 180,187 ****
              {
                  ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree;

-                 set_ps_display(commandTag = "CLOSE");
-
                  PerformPortalClose(stmt->portalname, dest);
              }
              break;
--- 175,180 ----
*************** ProcessUtility(Node *parsetree,
*** 193,200 ****
                  bool        forward;
                  int            count;

-                 set_ps_display(commandTag = (stmt->ismove) ? "MOVE" : "FETCH");
-
                  SetQuerySnapshot();

                  forward = (bool) (stmt->direction == FORWARD);
--- 186,191 ----
*************** ProcessUtility(Node *parsetree,
*** 204,210 ****
                   */

                  count = stmt->howMany;
!                 PerformPortalFetch(portalName, forward, count, commandTag,
                                     (stmt->ismove) ? None : dest);        /* /dev/null for MOVE */
              }
              break;
--- 195,201 ----
                   */

                  count = stmt->howMany;
!                 PerformPortalFetch(portalName, forward, count,(stmt->ismove) ? "MOVE" : "FETCH",
                                     (stmt->ismove) ? None : dest);        /* /dev/null for MOVE */
              }
              break;
*************** ProcessUtility(Node *parsetree,
*** 215,222 ****
               *
               */
          case T_CreateStmt:
-             set_ps_display(commandTag = "CREATE");
-
              DefineRelation((CreateStmt *) parsetree, RELKIND_RELATION);

              /*
--- 206,211 ----
*************** ProcessUtility(Node *parsetree,
*** 234,241 ****
                  List       *args = stmt->names;
                  List       *arg;

-                 set_ps_display(commandTag = "DROP");
-
                  foreach(arg, args)
                  {
                      relname = strVal(lfirst(arg));
--- 223,228 ----
*************** ProcessUtility(Node *parsetree,
*** 296,303 ****
              {
                  Relation    rel;

-                 set_ps_display(commandTag = "TRUNCATE");
-
                  relname = ((TruncateStmt *) parsetree)->relName;
                  if (!allowSystemTableMods && IsSystemRelationName(relname))
                      elog(ERROR, "TRUNCATE cannot be used on system tables. '%s' is a system table",
--- 283,288 ----
*************** ProcessUtility(Node *parsetree,
*** 325,332 ****

                  statement = ((CommentStmt *) parsetree);

-                 set_ps_display(commandTag = "COMMENT");
-
                  CommentObject(statement->objtype, statement->objname,
                                statement->objproperty, statement->objlist,
                                statement->comment);
--- 310,315 ----
*************** ProcessUtility(Node *parsetree,
*** 337,344 ****
              {
                  CopyStmt   *stmt = (CopyStmt *) parsetree;

-                 set_ps_display(commandTag = "COPY");
-
                  if (stmt->direction != FROM)
                      SetQuerySnapshot();

--- 320,325 ----
*************** ProcessUtility(Node *parsetree,
*** 365,372 ****
              {
                  RenameStmt *stmt = (RenameStmt *) parsetree;

-                 set_ps_display(commandTag = "ALTER");
-
                  relname = stmt->relname;
                  if (!allowSystemTableMods && IsSystemRelationName(relname))
                      elog(ERROR, "ALTER TABLE: relation \"%s\" is a system catalog",
--- 346,351 ----
*************** ProcessUtility(Node *parsetree,
*** 413,420 ****
              {
                  AlterTableStmt *stmt = (AlterTableStmt *) parsetree;

-                 set_ps_display(commandTag = "ALTER");
-
                  /*
                   * Some or all of these functions are recursive to cover
                   * inherited things, so permission checks are done there.
--- 392,397 ----
*************** ProcessUtility(Node *parsetree,
*** 475,483 ****
              {
                  GrantStmt  *stmt = (GrantStmt *) parsetree;

-                 commandTag = stmt->is_grant ? "GRANT" : "REVOKE";
-                 set_ps_display(commandTag);
-
                  ExecuteGrantStmt(stmt);
              }
              break;
--- 452,457 ----
*************** ProcessUtility(Node *parsetree,
*** 491,498 ****
              {
                  DefineStmt *stmt = (DefineStmt *) parsetree;

-                 set_ps_display(commandTag = "CREATE");
-
                  switch (stmt->defType)
                  {
                      case OPERATOR:
--- 465,470 ----
*************** ProcessUtility(Node *parsetree,
*** 514,528 ****
              {
                  ViewStmt   *stmt = (ViewStmt *) parsetree;

-                 set_ps_display(commandTag = "CREATE");
-
                  DefineView(stmt->viewname, stmt->query);        /* retrieve parsetree */
              }
              break;

          case T_ProcedureStmt:    /* CREATE FUNCTION */
-             set_ps_display(commandTag = "CREATE");
-
              CreateFunction((ProcedureStmt *) parsetree);
              break;

--- 486,496 ----
*************** ProcessUtility(Node *parsetree,
*** 530,537 ****
              {
                  IndexStmt  *stmt = (IndexStmt *) parsetree;

-                 set_ps_display(commandTag = "CREATE");
-
                  relname = stmt->relname;
                  if (!allowSystemTableMods && IsSystemRelationName(relname))
                      elog(ERROR, "CREATE INDEX: relation \"%s\" is a system catalog",
--- 498,503 ----
*************** ProcessUtility(Node *parsetree,
*** 559,573 ****
                  aclcheck_result = pg_aclcheck(relname, GetUserId(), ACL_RULE);
                  if (aclcheck_result != ACLCHECK_OK)
                      elog(ERROR, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]);
-                 set_ps_display(commandTag = "CREATE");

                  DefineQueryRewrite(stmt);
              }
              break;

          case T_CreateSeqStmt:
-             set_ps_display(commandTag = "CREATE");
-
              DefineSequence((CreateSeqStmt *) parsetree);
              break;

--- 525,536 ----
*************** ProcessUtility(Node *parsetree,
*** 576,583 ****
                  RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree;
                  char       *typename = (char *) NULL;

-                 set_ps_display(commandTag = "DROP");
-
                  if (stmt->aggtype != NULL)
                      typename = TypeNameToInternalName((TypeName *) stmt->aggtype);

--- 539,544 ----
*************** ProcessUtility(Node *parsetree,
*** 589,596 ****
              {
                  RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree;

-                 set_ps_display(commandTag = "DROP");
-
                  RemoveFunction(stmt->funcname, stmt->args);
              }
              break;
--- 550,555 ----
*************** ProcessUtility(Node *parsetree,
*** 603,610 ****
                  char       *typename1 = (char *) NULL;
                  char       *typename2 = (char *) NULL;

-                 set_ps_display(commandTag = "DROP");
-
                  if (typenode1 != NULL)
                      typename1 = TypeNameToInternalName(typenode1);
                  if (typenode2 != NULL)
--- 562,567 ----
*************** ProcessUtility(Node *parsetree,
*** 622,629 ****
              {
                  CreatedbStmt *stmt = (CreatedbStmt *) parsetree;

-                 set_ps_display(commandTag = "CREATE DATABASE");
-
                  createdb(stmt->dbname, stmt->dbowner,
                           stmt->dbpath, stmt->dbtemplate,
                           stmt->encoding);
--- 579,584 ----
*************** ProcessUtility(Node *parsetree,
*** 634,641 ****
              {
                  DropdbStmt *stmt = (DropdbStmt *) parsetree;

-                 set_ps_display(commandTag = "DROP DATABASE");
-
                  dropdb(stmt->dbname);
              }
              break;
--- 589,594 ----
*************** ProcessUtility(Node *parsetree,
*** 645,652 ****
              {
                  NotifyStmt *stmt = (NotifyStmt *) parsetree;

-                 set_ps_display(commandTag = "NOTIFY");
-
                  Async_Notify(stmt->relname);
              }
              break;
--- 598,603 ----
*************** ProcessUtility(Node *parsetree,
*** 655,662 ****
              {
                  ListenStmt *stmt = (ListenStmt *) parsetree;

-                 set_ps_display(commandTag = "LISTEN");
-
                  Async_Listen(stmt->relname, MyProcPid);
              }
              break;
--- 606,611 ----
*************** ProcessUtility(Node *parsetree,
*** 665,672 ****
              {
                  UnlistenStmt *stmt = (UnlistenStmt *) parsetree;

-                 set_ps_display(commandTag = "UNLISTEN");
-
                  Async_Unlisten(stmt->relname, MyProcPid);
              }
              break;
--- 614,619 ----
*************** ProcessUtility(Node *parsetree,
*** 679,686 ****
              {
                  LoadStmt   *stmt = (LoadStmt *) parsetree;

-                 set_ps_display(commandTag = "LOAD");
-
                  closeAllVfds(); /* probably not necessary... */
                  load_file(stmt->filename);
              }
--- 626,631 ----
*************** ProcessUtility(Node *parsetree,
*** 690,697 ****
              {
                  ClusterStmt *stmt = (ClusterStmt *) parsetree;

-                 set_ps_display(commandTag = "CLUSTER");
-
                  relname = stmt->relname;
                  if (IsSystemRelationName(relname))
                      elog(ERROR, "CLUSTER: relation \"%s\" is a system catalog",
--- 635,640 ----
*************** ProcessUtility(Node *parsetree,
*** 704,715 ****
              break;

          case T_VacuumStmt:
-             if (((VacuumStmt *) parsetree)->vacuum)
-                 commandTag = "VACUUM";
-             else
-                 commandTag = "ANALYZE";
-             set_ps_display(commandTag);
-
              vacuum((VacuumStmt *) parsetree);
              break;

--- 647,652 ----
*************** ProcessUtility(Node *parsetree,
*** 717,724 ****
              {
                  ExplainStmt *stmt = (ExplainStmt *) parsetree;

-                 set_ps_display(commandTag = "EXPLAIN");
-
                  ExplainQuery(stmt->query, stmt->verbose, stmt->analyze, dest);
              }
              break;
--- 654,659 ----
*************** ProcessUtility(Node *parsetree,
*** 732,739 ****
              {
                  RecipeStmt *stmt = (RecipeStmt *) parsetree;

-                 set_ps_display(commandTag = "EXECUTE RECIPE");
-
                  beginRecipe(stmt);
              }
              break;
--- 667,672 ----
*************** ProcessUtility(Node *parsetree,
*** 747,753 ****
                  VariableSetStmt *n = (VariableSetStmt *) parsetree;

                  SetPGVariable(n->name, n->args);
-                 set_ps_display(commandTag = "SET VARIABLE");
              }
              break;

--- 680,685 ----
*************** ProcessUtility(Node *parsetree,
*** 756,762 ****
                  VariableShowStmt *n = (VariableShowStmt *) parsetree;

                  GetPGVariable(n->name);
-                 set_ps_display(commandTag = "SHOW VARIABLE");
              }
              break;

--- 688,693 ----
*************** ProcessUtility(Node *parsetree,
*** 765,771 ****
                  VariableResetStmt *n = (VariableResetStmt *) parsetree;

                  ResetPGVariable(n->name);
-                 set_ps_display(commandTag = "RESET VARIABLE");
              }
              break;

--- 696,701 ----
*************** ProcessUtility(Node *parsetree,
*** 773,786 ****
               * ******************************** TRIGGER statements *******************************
               */
          case T_CreateTrigStmt:
-             set_ps_display(commandTag = "CREATE");
-
              CreateTrigger((CreateTrigStmt *) parsetree);
              break;

          case T_DropTrigStmt:
-             set_ps_display(commandTag = "DROP");
-
              DropTrigger((DropTrigStmt *) parsetree);
              break;

--- 703,712 ----
*************** ProcessUtility(Node *parsetree,
*** 788,801 ****
               * ************* PROCEDURAL LANGUAGE statements *****************
               */
          case T_CreatePLangStmt:
-             set_ps_display(commandTag = "CREATE");
-
              CreateProceduralLanguage((CreatePLangStmt *) parsetree);
              break;

          case T_DropPLangStmt:
-             set_ps_display(commandTag = "DROP");
-
              DropProceduralLanguage((DropPLangStmt *) parsetree);
              break;

--- 714,723 ----
*************** ProcessUtility(Node *parsetree,
*** 804,860 ****
               *
               */
          case T_CreateUserStmt:
-             set_ps_display(commandTag = "CREATE USER");
-
              CreateUser((CreateUserStmt *) parsetree);
              break;

          case T_AlterUserStmt:
-             set_ps_display(commandTag = "ALTER USER");
-
              AlterUser((AlterUserStmt *) parsetree);
              break;

          case T_DropUserStmt:
-             set_ps_display(commandTag = "DROP USER");
-
              DropUser((DropUserStmt *) parsetree);
              break;

          case T_LockStmt:
-             set_ps_display(commandTag = "LOCK TABLE");
-
              LockTableCommand((LockStmt *) parsetree);
              break;

          case T_ConstraintsSetStmt:
-             set_ps_display(commandTag = "SET CONSTRAINTS");
-
              DeferredTriggerSetState((ConstraintsSetStmt *) parsetree);
              break;

          case T_CreateGroupStmt:
-             set_ps_display(commandTag = "CREATE GROUP");
-
              CreateGroup((CreateGroupStmt *) parsetree);
              break;

          case T_AlterGroupStmt:
-             set_ps_display(commandTag = "ALTER GROUP");
-
              AlterGroup((AlterGroupStmt *) parsetree, "ALTER GROUP");
              break;

          case T_DropGroupStmt:
-             set_ps_display(commandTag = "DROP GROUP");
-
              DropGroup((DropGroupStmt *) parsetree);
              break;

          case T_CheckPointStmt:
              {
-                 set_ps_display(commandTag = "CHECKPOINT");
-
                  if (!superuser())
                      elog(ERROR, "permission denied");
                  CreateCheckPoint(false);
--- 726,764 ----
*************** ProcessUtility(Node *parsetree,
*** 865,872 ****
              {
                  ReindexStmt *stmt = (ReindexStmt *) parsetree;

-                 set_ps_display(commandTag = "REINDEX");
-
                  switch (stmt->reindexType)
                  {
                      case INDEX:
--- 769,774 ----
*************** ProcessUtility(Node *parsetree,
*** 914,920 ****
      }

      /*
!      * tell fe/be or whatever that we're done.
       */
!     EndCommand(commandTag, dest);
  }
--- 816,823 ----
      }

      /*
!      * Note: the "end-of-command" tag is to be sent by the caller,
!      * if appropriate.
       */
!     return;
  }

pgsql-patches by date:

Previous
From: Thomas Lockhart
Date:
Subject: Re: minor doc patch for example in 'SET' docs
Next
From: Jonathan Eisler
Date:
Subject: psql domains