Index: src/bin/pg_dump/pg_backup_db.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v retrieving revision 1.66 diff -c -r1.66 pg_backup_db.c *** src/bin/pg_dump/pg_backup_db.c 15 Oct 2005 02:49:38 -0000 1.66 --- src/bin/pg_dump/pg_backup_db.c 21 Jan 2006 19:54:56 -0000 *************** *** 292,297 **** --- 292,298 ---- PGconn *conn = AH->connection; PGresult *res; char errStmt[DB_MAX_ERR_STMT]; + int wsoffset = 0; /* fprintf(stderr, "Executing: '%s'\n\n", qry->data); */ res = PQexec(conn, qry->data); *************** *** 306,311 **** --- 307,317 ---- } else { + /* Catch that this is a failed copy command, and + * set pgCopyIn accordingly */ + while (isspace(qry->data[wsoffset])) wsoffset++; + if (strncasecmp(qry->data+wsoffset,"COPY ",5) == 0) AH->pgCopyIn = -1; + strncpy(errStmt, qry->data, DB_MAX_ERR_STMT); if (errStmt[DB_MAX_ERR_STMT - 1] != '\0') { *************** *** 317,322 **** --- 323,330 ---- warn_or_die_horribly(AH, modulename, "%s: %s Command was: %s\n", desc, PQerrorMessage(AH->connection), errStmt); + + if (AH->pgCopyIn == -1) write_msg(NULL, "COPY failed, skipping COPY data.\n"); } } *************** *** 389,395 **** *--------- */ ! if (PQputline(AH->connection, AH->pgCopyBuf->data) != 0) die_horribly(AH, modulename, "error returned by PQputline\n"); resetPQExpBuffer(AH->pgCopyBuf); --- 397,405 ---- *--------- */ ! /* If this is a failed copy command (pgCopyIn == -1) then just ! * fall through */ ! if (AH->pgCopyIn == 1 && PQputline(AH->connection, AH->pgCopyBuf->data) != 0) die_horribly(AH, modulename, "error returned by PQputline\n"); resetPQExpBuffer(AH->pgCopyBuf); *************** *** 400,406 **** if (isEnd) { ! if (PQendcopy(AH->connection) != 0) die_horribly(AH, modulename, "error returned by PQendcopy\n"); AH->pgCopyIn = 0; --- 410,418 ---- if (isEnd) { ! /* If this is a failed copy command (pgCopyIn == -1) then just ! * fall through */ ! if (AH->pgCopyIn == 1 && PQendcopy(AH->connection) != 0) die_horribly(AH, modulename, "error returned by PQendcopy\n"); AH->pgCopyIn = 0; *************** *** 615,621 **** /* Could switch between command and COPY IN mode at each line */ while (qry < eos) { ! if (AH->pgCopyIn) qry = _sendCopyLine(AH, qry, eos); else qry = _sendSQLLine(AH, qry, eos); --- 627,637 ---- /* Could switch between command and COPY IN mode at each line */ while (qry < eos) { ! /* If this is a working COPY *or* a failed COPY, call ! * _sendCopyLine to handle the incoming data from the COPY ! * command, it will just circular-file the data if we're ! * running a failed COPY. */ ! if (AH->pgCopyIn == 1 || AH->pgCopyIn == -1) qry = _sendCopyLine(AH, qry, eos); else qry = _sendSQLLine(AH, qry, eos);