sizes.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.71 2002/10/09 16:20:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.72 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
* attr with the same name, then only dump it if:
*
* - it is NOT NULL and zero parents are NOT NULL
- * OR
+ * OR
* - it has a default value AND the default value does not match
* all parent default values, or no parents specify a default.
*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.59 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.60 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
}
+/*
+ * checkSeek
+ * check to see if fseek can be performed.
+ */
+
+bool
+checkSeek(FILE *fp)
+{
+
+ if (fseek(fp, 0, SEEK_CUR) != 0)
+ return false;
+ else if (sizeof(off_t) > sizeof(long))
+ /*
+ * At this point, off_t is too large for long, so we return
+ * based on whether an off_t version of fseek is available.
+ */
+#ifdef HAVE_FSEEKO
+ return true;
+#else
+ return false;
+#endif
+ else
+ return true;
+}
+
+
static void
_SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.48 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.49 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "postgres_fe.h"
+#include <stdio.h>
#include <time.h>
#include <errno.h>
extern void WriteDataChunks(ArchiveHandle *AH);
extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
+extern bool checkSeek(FILE *fp);
/*
* Mandatory routines for each supported format
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.22 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.23 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
- ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(AH->FH);
}
else
{
if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
- ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(AH->FH);
ReadHead(AH);
ReadToc(AH);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.20 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.21 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno));
- ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(AH->FH);
if (AH->compression < 0 || AH->compression > 9)
AH->compression = Z_DEFAULT_COMPRESSION;
if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno));
- ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(AH->FH);
ReadHead(AH);
ReadToc(AH);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.31 2002/10/22 19:15:23 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.32 2002/10/25 01:33:17 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*/
/* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */
- ctx->hasSeek = (fseeko(ctx->tarFH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(ctx->tarFH);
if (AH->compression < 0 || AH->compression > 9)
AH->compression = Z_DEFAULT_COMPRESSION;
ctx->tarFHpos = 0;
- ctx->hasSeek = (fseeko(ctx->tarFH, 0, SEEK_CUR) == 0);
+ ctx->hasSeek = checkSeek(ctx->tarFH);
/*
* Forcibly unmark the header as read since we use the lookahead