On tor, 2012-03-01 at 19:19 +0200, Peter Eisentraut wrote: > I think the best fix would be to rearrange _PrintFileData() so that it > doesn't use FH at all. Instead, we could define a separate > ArchiveHandle field IF that works more like OF, and then change > ahwrite() to use that.
Here is a patch that might fix this. I haven't been able to test this properly, so this is just from tracing the code. It looks like _PrintFileData() doesn't need to use FH at all, so it could use a local file handle variable instead. Could someone verify this please?
diff --git i/src/bin/pg_dump/pg_backup_files.c w/src/bin/pg_dump/pg_backup_files.c index a7fd91d..32b2a32 100644 --- i/src/bin/pg_dump/pg_backup_files.c +++ w/src/bin/pg_dump/pg_backup_files.c @@ -293,27 +293,32 @@ _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) { char buf[4096]; size_t cnt; +#ifdef HAVE_LIBZ + gzFile fh; +#else + FILE *fh; +#endif if (!filename) return; #ifdef HAVE_LIBZ - AH->FH = gzopen(filename, "rb"); + fh = gzopen(filename, "rb"); #else - AH->FH = fopen(filename, PG_BINARY_R); + fh = fopen(filename, PG_BINARY_R); #endif - if (AH->FH == NULL) + if (!fh) die_horribly(AH, modulename, "could not open input file \"%s\": %s\n", filename, strerror(errno)); - while ((cnt = GZREAD(buf, 1, 4095, AH->FH)) > 0) + while ((cnt = GZREAD(buf, 1, 4095, fh)) > 0) { buf[cnt] = '\0'; ahwrite(buf, 1, cnt, AH); } - if (GZCLOSE(AH->FH) != 0) + if (GZCLOSE(fh) != 0) die_horribly(AH, modulename, "could not close data file after reading\n"); }
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers