Index: doc/src/sgml/libpq.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/libpq.sgml,v
retrieving revision 1.106
diff -c -r1.106 libpq.sgml
*** doc/src/sgml/libpq.sgml	19 Jan 2003 00:13:28 -0000	1.106
--- doc/src/sgml/libpq.sgml	20 Jan 2003 01:49:21 -0000
***************
*** 698,709 ****
  int PQbackendPID(const PGconn *conn);
         </synopsis>
         The backend <acronym>PID</acronym> is useful for debugging
!        purposes and for comparison
!        to NOTIFY messages (which include the <acronym>PID</acronym> of
!        the notifying backend).
!        Note that the <acronym>PID</acronym> belongs to a process
!        executing on the database
!        server host, not the local host!
        </para>
       </listitem>
  
--- 698,708 ----
  int PQbackendPID(const PGconn *conn);
         </synopsis>
         The backend <acronym>PID</acronym> is useful for debugging
!        purposes and for comparison to <command>NOTIFY</command>
!        messages (which include the <acronym>PID</acronym> of the
!        notifying backend).  Note that the <acronym>PID</acronym>
!        belongs to a process executing on the database server host, not
!        the local host!
        </para>
       </listitem>
  
***************
*** 814,826 ****
   </listitem>
  </itemizedlist>
  
! If  the result status is <literal>PGRES_TUPLES_OK</literal>, then the
! routines described below can be  used  to  retrieve  the
! rows returned by the query.  Note that a SELECT command that
! happens to retrieve zero rows still shows <literal>PGRES_TUPLES_OK</literal>.
! <literal>PGRES_COMMAND_OK</literal> is for commands that can never return rows
! (INSERT, UPDATE, etc.). A response of <literal>PGRES_EMPTY_QUERY</literal> often
! exposes a bug in the client software.
  </para>
  </listitem>
  
--- 813,826 ----
   </listitem>
  </itemizedlist>
  
! If the result status is <literal>PGRES_TUPLES_OK</literal>, then the
! routines described below can be used to retrieve the rows returned by
! the query.  Note that a <command>SELECT</command> command that happens
! to retrieve zero rows still shows <literal>PGRES_TUPLES_OK</literal>.
! <literal>PGRES_COMMAND_OK</literal> is for commands that can never
! return rows (<command>INSERT</command>, <command>UPDATE</command>,
! etc.). A response of <literal>PGRES_EMPTY_QUERY</literal> often
! indicates a bug in the client software.
  </para>
  </listitem>
  
***************
*** 1239,1274 ****
  char * PQcmdTuples(PGresult *res);
  </synopsis>
            If the <acronym>SQL</acronym> command that generated the
! 	  <structname>PGresult</structname> was INSERT, UPDATE or DELETE, this returns a
! 	  string containing the number of rows affected.  If the
!           command was anything else, it returns the empty string.
  </para>
  </listitem>
  
  <listitem>
  <para>
  <function>PQoidValue</function>
!           Returns the object ID of the inserted row, if the
! 	  <acronym>SQL</acronym> command was an INSERT
! 	  that inserted exactly one row into a table that has OIDs.
!           Otherwise, returns <literal>InvalidOid</literal>.
  <synopsis>
  Oid PQoidValue(const PGresult *res);
  </synopsis>
!           The type <type>Oid</type> and the constant <literal>InvalidOid</literal>
!           will be defined if you include the <application>libpq</application>
!           header file. They will both be some integer type.
  </para>
  </listitem>
  
  <listitem>
  <para>
  <function>PQoidStatus</function>
!           Returns a string with the object ID of the inserted row, if the
! 	  <acronym>SQL</acronym> command was an INSERT.
! 	  (The string will be <literal>0</> if the INSERT did not insert exactly one
! 	  row, or if the target table does not have OIDs.)  If the command
! 	  was not an INSERT, returns an empty string.
  <synopsis>
  char * PQoidStatus(const PGresult *res);
  </synopsis>
--- 1239,1279 ----
  char * PQcmdTuples(PGresult *res);
  </synopsis>
            If the <acronym>SQL</acronym> command that generated the
! 	  <structname>PGresult</structname> was <command>INSERT</command>,
! 	  <command>UPDATE</command>, <command>DELETE</command>,
! 	  <command>MOVE</command>, or <command>FETCH</command> this
! 	  returns a string containing the number of rows affected.  If the
! 	  command was anything else, it returns the empty string.
  </para>
  </listitem>
  
  <listitem>
  <para>
  <function>PQoidValue</function>
!       Returns the object ID of the inserted row, if the
!       <acronym>SQL</acronym> command was an <command>INSERT</command>
!       that inserted exactly one row into a table that has OIDs.
!       Otherwise, returns <literal>InvalidOid</literal>.
  <synopsis>
  Oid PQoidValue(const PGresult *res);
  </synopsis>
!           The type <type>Oid</type> and the constant
!       <literal>InvalidOid</literal> will be defined if you include the
!       <application>libpq</application> header file. They will both be
!       some integer type.
  </para>
  </listitem>
  
  <listitem>
  <para>
  <function>PQoidStatus</function>
!       Returns a string with the object ID
!       of the inserted row, if the <acronym>SQL</acronym> command
!       was an <command>INSERT</command>.  (The string will be
!       <literal>0</> if the <command>INSERT</command> did not
!       insert exactly one row, or if the target table does not have
!       OIDs.)  If the command was not an <command>INSERT</command>,
!       returns an empty string.
  <synopsis>
  char * PQoidStatus(const PGresult *res);
  </synopsis>
***************
*** 1526,1532 ****
  <function>PQconsumeInput</function> to read the input.  It can then call
  <function>PQisBusy</function>, followed by <function>PQgetResult</function>
  if <function>PQisBusy</function> returns false (0).  It can also call
! <function>PQnotifies</function> to detect NOTIFY messages (see <xref linkend="libpq-notify">).
  </para>
  
  <para>
--- 1531,1538 ----
  <function>PQconsumeInput</function> to read the input.  It can then call
  <function>PQisBusy</function>, followed by <function>PQgetResult</function>
  if <function>PQisBusy</function> returns false (0).  It can also call
! <function>PQnotifies</function> to detect <command>NOTIFY</command>
! messages (see <xref linkend="libpq-notify">).
  </para>
  
  <para>
***************
*** 1696,1708 ****
  <function>PQnotifies()</function> does not actually read backend data; it just
  returns messages previously absorbed by another <application>libpq</application>
  function.  In prior releases of <application>libpq</application>, the only way
! to ensure timely receipt of NOTIFY messages was to constantly submit queries,
  even empty ones, and then check <function>PQnotifies()</function> after each
  <function>PQexec()</function>.  While this still works, it is
  deprecated as a waste of processing power.
  </para>
  <para>
! A better way to check for NOTIFY
  messages when you have no useful queries to make is to call
  <function>PQconsumeInput()</function>, then check
  <function>PQnotifies()</function>.
--- 1702,1714 ----
  <function>PQnotifies()</function> does not actually read backend data; it just
  returns messages previously absorbed by another <application>libpq</application>
  function.  In prior releases of <application>libpq</application>, the only way
! to ensure timely receipt of <command>NOTIFY</command> messages was to constantly submit queries,
  even empty ones, and then check <function>PQnotifies()</function> after each
  <function>PQexec()</function>.  While this still works, it is
  deprecated as a waste of processing power.
  </para>
  <para>
! A better way to check for <command>NOTIFY</command>
  messages when you have no useful queries to make is to call
  <function>PQconsumeInput()</function>, then check
  <function>PQnotifies()</function>.
Index: doc/src/sgml/protocol.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/protocol.sgml,v
retrieving revision 1.24
diff -c -r1.24 protocol.sgml
*** doc/src/sgml/protocol.sgml	22 Mar 2002 19:20:21 -0000	1.24
--- doc/src/sgml/protocol.sgml	20 Jan 2003 01:35:14 -0000
***************
*** 1335,1340 ****
--- 1335,1354 ----
  	<literal>UPDATE <Replaceable>rows</Replaceable></literal> where
          <Replaceable>rows</Replaceable> is the number of rows updated.
  </Para>
+ 
+        <para>
+         For a <command>MOVE</command> command, the tag is
+         <literal>MOVE <replaceable>rows</replaceable></literal> where
+         <replaceable>rows</replaceable> is the number of rows the
+         cursor's position has been changed by.
+        </para>
+ 
+        <para>
+         For a <command>FETCH</command> command, the tag is
+         <literal>FETCH <replaceable>rows</replaceable></literal> where
+         <replaceable>rows</replaceable> is the number of rows that
+         have been retrieved from the cursor.
+        </para>
  </ListItem>
  </VarListEntry>
  </VariableList>
Index: doc/src/sgml/ref/execute.sgml
===================================================================
RCS file: /var/lib/cvs/pgsql-server/doc/src/sgml/ref/execute.sgml,v
retrieving revision 1.2
diff -c -r1.2 execute.sgml
*** doc/src/sgml/ref/execute.sgml	19 Jan 2003 00:13:29 -0000	1.2
--- doc/src/sgml/ref/execute.sgml	20 Jan 2003 01:42:24 -0000
***************
*** 100,106 ****
    <para>
     Like <command>SELECT INTO</command>, <command>EXECUTE</command> can
     be used to store the results of executing the query in a table by
!    specifying an INTO clause. For more information on this behabior,
     consult the reference for <xref linkend="sql-selectinto">.
    </para>
  
--- 100,106 ----
    <para>
     Like <command>SELECT INTO</command>, <command>EXECUTE</command> can
     be used to store the results of executing the query in a table by
!    specifying an INTO clause. For more information on this behavior,
     consult the reference for <xref linkend="sql-selectinto">.
    </para>
  
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.189
diff -c -r1.189 utility.c
*** src/backend/tcop/utility.c	10 Jan 2003 22:03:28 -0000	1.189
--- src/backend/tcop/utility.c	20 Jan 2003 01:14:26 -0000
***************
*** 255,261 ****
  	switch (nodeTag(parsetree))
  	{
  			/*
! 			 * ******************************** transactions ********************************
  			 */
  		case T_TransactionStmt:
  			{
--- 255,261 ----
  	switch (nodeTag(parsetree))
  	{
  			/*
! 			 * ******************** transactions ********************
  			 */
  		case T_TransactionStmt:
  			{
Index: src/interfaces/libpq/fe-exec.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/interfaces/libpq/fe-exec.c,v
retrieving revision 1.124
diff -c -r1.124 fe-exec.c
*** src/interfaces/libpq/fe-exec.c	7 Jan 2003 22:23:17 -0000	1.124
--- src/interfaces/libpq/fe-exec.c	20 Jan 2003 01:14:46 -0000
***************
*** 2272,2278 ****
  
  /*
    PQoidValue -
! 		a perhaps preferable form of the above which just returns
  	an Oid type
  */
  Oid
--- 2272,2278 ----
  
  /*
    PQoidValue -
! 	a perhaps preferable form of the above which just returns
  	an Oid type
  */
  Oid
***************
*** 2300,2352 ****
  
  /*
     PQcmdTuples -
! 	if the last command was an INSERT/UPDATE/DELETE, return number
! 	of inserted/affected tuples, if not, return ""
  */
  char *
  PQcmdTuples(PGresult *res)
  {
  	char		noticeBuf[128];
  
  	if (!res)
  		return "";
  
! 	if (strncmp(res->cmdStatus, "INSERT", 6) == 0 ||
! 		strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
! 		strncmp(res->cmdStatus, "UPDATE", 6) == 0)
  	{
! 		char	   *p = res->cmdStatus + 6;
! 
! 		if (*p == 0)
! 		{
! 			if (res->noticeHook)
! 			{
! 				snprintf(noticeBuf, sizeof(noticeBuf),
! 						 libpq_gettext("could not interpret result from server: %s\n"),
! 						 res->cmdStatus);
! 				DONOTICE(res, noticeBuf);
! 			}
! 			return "";
! 		}
  		p++;
! 		if (*(res->cmdStatus) != 'I')	/* UPDATE/DELETE */
! 			return p;
  		while (*p != ' ' && *p)
! 			p++;				/* INSERT: skip oid */
! 		if (*p == 0)
  		{
! 			if (res->noticeHook)
! 			{
! 				snprintf(noticeBuf, sizeof(noticeBuf),
! 						 libpq_gettext("no row count available\n"));
! 				DONOTICE(res, noticeBuf);
! 			}
! 			return "";
  		}
! 		p++;
! 		return p;
  	}
! 	return "";
  }
  
  /*
--- 2300,2353 ----
  
  /*
     PQcmdTuples -
! 	If the last command was an INSERT/UPDATE/DELETE/MOVE/FETCH, return a
! 	string containing the number of inserted/affected tuples. If not,
! 	return "".
! 
! 	XXX: this should probably return an int
  */
  char *
  PQcmdTuples(PGresult *res)
  {
  	char		noticeBuf[128];
+ 	char		*p;
  
  	if (!res)
  		return "";
  
! 	if (strncmp(res->cmdStatus, "INSERT ", 7) == 0)
  	{
! 		p = res->cmdStatus + 6;
  		p++;
! 		/* INSERT: skip oid */
  		while (*p != ' ' && *p)
! 			p++;
! 	}
! 	else if (strncmp(res->cmdStatus, "DELETE ", 7) == 0 ||
! 			 strncmp(res->cmdStatus, "UPDATE ", 7) == 0)
! 		p = res->cmdStatus + 6;
! 	else if (strncmp(res->cmdStatus, "FETCH ", 6) == 0)
! 		p = res->cmdStatus + 5;
! 	else if (strncmp(res->cmdStatus, "MOVE ", 5) == 0)
! 		p = res->cmdStatus + 4;
! 	else
! 		return "";
! 
! 	p++;
! 
! 	if (*p == 0)
! 	{
! 		if (res->noticeHook)
  		{
! 			snprintf(noticeBuf, sizeof(noticeBuf),
! 					 libpq_gettext("could not interpret result from server: %s\n"),
! 					 res->cmdStatus);
! 			DONOTICE(res, noticeBuf);
  		}
! 		return "";
  	}
! 
! 	return p;
  }
  
  /*
