1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-27 23:21:58 +03:00

It seems the regression tests don't cover copy in/out at all, so

code that I had assumed was working had not been tested.  Naturally,
it was broken ...

Tom Lane
This commit is contained in:
Bruce Momjian
1998-05-06 23:53:48 +00:00
parent edbd51395c
commit 1c2d9cb637
4 changed files with 69 additions and 27 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.50 1998/05/06 23:51:13 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.51 1998/05/06 23:53:38 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@ -748,7 +748,8 @@ PQexec(PGconn *conn, const char *query)
return NULL;
/* For backwards compatibility, return the last result if there are
* more than one.
* more than one. We have to stop if we see copy in/out, however.
* We will resume parsing when application calls PQendcopy.
*/
lastResult = NULL;
while ((result = PQgetResult(conn)) != NULL)
@ -756,6 +757,9 @@ PQexec(PGconn *conn, const char *query)
if (lastResult)
PQclear(lastResult);
lastResult = result;
if (result->resultStatus == PGRES_COPY_IN ||
result->resultStatus == PGRES_COPY_OUT)
break;
}
return lastResult;
}
@ -950,7 +954,7 @@ PQputline(PGconn *conn, const char *s)
{
if (conn && conn->sock >= 0)
{
(void) pqPuts(s, conn);
(void) pqPutnchar(s, strlen(s), conn);
}
}
@ -988,7 +992,7 @@ PQendcopy(PGconn *conn)
result = PQgetResult(conn);
/* Expecting a successful result */
if (result->resultStatus == PGRES_COMMAND_OK)
if (result && result->resultStatus == PGRES_COMMAND_OK)
{
PQclear(result);
return 0;