*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.8 2005/09/11 00:36:35 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.101.4.9 2006/02/05 20:59:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* mode with libpq.
*/
if (te->copyStmt && strlen(te->copyStmt) > 0)
+ {
ahprintf(AH, "%s", te->copyStmt);
+ AH->writingCopyData = true;
+ }
(*AH->PrintTocDataPtr) (AH, te, ropt);
+ AH->writingCopyData = false;
+
/*
* If we just restored blobs, fix references in
* previously-loaded tables; otherwise, if we
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.62.4.1 2005/01/25 22:44:47 tgl Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.62.4.2 2006/02/05 20:59:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
int blobTxActive; /* Flag set if TX active on blobConnection */
int connectToDB; /* Flag to indicate if direct DB
* connection is required */
- int pgCopyIn; /* Currently in libpq 'COPY IN' mode. */
+ bool writingCopyData; /* True when we are sending COPY data */
+ bool pgCopyIn; /* Currently in libpq 'COPY IN' mode. */
PQExpBuffer pgCopyBuf; /* Left-over data from incomplete lines in
* COPY IN */
* Implements the basic DB functions used by the archiver.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.61.4.1 2005/07/27 05:15:03 neilc Exp $
+ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.61.4.2 2006/02/05 20:59:06 tgl Exp $
*
*-------------------------------------------------------------------------
*/
if (conn != AH->connection)
die_horribly(AH, modulename, "COPY command executed in non-primary connection\n");
- AH->pgCopyIn = 1;
+ AH->pgCopyIn = true;
}
else
{
*---------
*/
- if (PQputline(AH->connection, AH->pgCopyBuf->data) != 0)
+ if (AH->pgCopyIn && PQputline(AH->connection, AH->pgCopyBuf->data) != 0)
die_horribly(AH, modulename, "error returned by PQputline\n");
resetPQExpBuffer(AH->pgCopyBuf);
if (isEnd)
{
- if (PQendcopy(AH->connection) != 0)
+ if (AH->pgCopyIn && PQendcopy(AH->connection) != 0)
die_horribly(AH, modulename, "error returned by PQendcopy\n");
- AH->pgCopyIn = 0;
+ AH->pgCopyIn = false;
}
return qry + loc + 1;
/* Could switch between command and COPY IN mode at each line */
while (qry < eos)
{
- if (AH->pgCopyIn)
+ /* If we are in CopyIn mode *or* if the upper-layers believe we're doing
+ * a COPY then call sendCopyLine. If we're not actually in CopyIn mode
+ * the sendCopyLine will just dump the data coming in */
+ if (AH->pgCopyIn || AH->writingCopyData)
qry = _sendCopyLine(AH, qry, eos);
else
qry = _sendSQLLine(AH, qry, eos);