aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/backend/tcop/utility.c4
-rw-r--r--src/interfaces/libpq/fe-exec.c69
2 files changed, 37 insertions, 36 deletions
diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c
index b48550428f6..db7dc0945cd 100644
--- a/src/backend/tcop/utility.c
+++ b/src/backend/tcop/utility.c
@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.192 2003/02/13 05:20:01 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.193 2003/02/19 03:59:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -254,7 +254,7 @@ ProcessUtility(Node *parsetree,
switch (nodeTag(parsetree))
{
/*
- * ******************************** transactions ********************************
+ * ******************** transactions ********************
*/
case T_TransactionStmt:
{
diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c
index 858c4339c46..bc18aeaf087 100644
--- a/src/interfaces/libpq/fe-exec.c
+++ b/src/interfaces/libpq/fe-exec.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.124 2003/01/07 22:23:17 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.125 2003/02/19 03:59:02 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2272,7 +2272,7 @@ PQoidStatus(const PGresult *res)
/*
PQoidValue -
- a perhaps preferable form of the above which just returns
+ a perhaps preferable form of the above which just returns
an Oid type
*/
Oid
@@ -2300,53 +2300,54 @@ PQoidValue(const PGresult *res)
/*
PQcmdTuples -
- if the last command was an INSERT/UPDATE/DELETE, return number
- of inserted/affected tuples, if not, return ""
+ 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", 6) == 0 ||
- strncmp(res->cmdStatus, "DELETE", 6) == 0 ||
- strncmp(res->cmdStatus, "UPDATE", 6) == 0)
+ if (strncmp(res->cmdStatus, "INSERT ", 7) == 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 = res->cmdStatus + 6;
p++;
- if (*(res->cmdStatus) != 'I') /* UPDATE/DELETE */
- return p;
+ /* INSERT: skip oid */
while (*p != ' ' && *p)
- p++; /* INSERT: skip oid */
- if (*p == 0)
+ 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)
{
- if (res->noticeHook)
- {
- snprintf(noticeBuf, sizeof(noticeBuf),
- libpq_gettext("no row count available\n"));
- DONOTICE(res, noticeBuf);
- }
- return "";
+ snprintf(noticeBuf, sizeof(noticeBuf),
+ libpq_gettext("could not interpret result from server: %s\n"),
+ res->cmdStatus);
+ DONOTICE(res, noticeBuf);
}
- p++;
- return p;
+ return "";
}
- return "";
+
+ return p;
}
/*