Commit 6faf8024 authored by Peter Eisentraut's avatar Peter Eisentraut

Enable large file support.

Use off_t and size_t in pg_dump to handle file offset arithmetic correctly.
parent 0d6f6138
This diff is collapsed.
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
dnl $Header: /cvsroot/pgsql/configure.in,v 1.194 2002/07/27 20:10:03 petere Exp $ dnl $Header: /cvsroot/pgsql/configure.in,v 1.195 2002/08/20 17:54:43 petere Exp $
dnl dnl
dnl Developers, please strive to achieve this order: dnl Developers, please strive to achieve this order:
dnl dnl
...@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [], ...@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [],
[AC_CHECK_FUNCS(on_exit, [], [AC_CHECK_FUNCS(on_exit, [],
[AC_MSG_ERROR([neither atexit() nor on_exit() found])])]) [AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
AC_FUNC_FSEEKO
# This test makes sure that run tests work at all. Sometimes a shared # This test makes sure that run tests work at all. Sometimes a shared
# library is found by the linker, but the runtime linker can't find it. # library is found by the linker, but the runtime linker can't find it.
...@@ -1159,6 +1161,9 @@ AC_CHECK_TYPES([sig_atomic_t], [], [], [#include <signal.h>]) ...@@ -1159,6 +1161,9 @@ AC_CHECK_TYPES([sig_atomic_t], [], [], [#include <signal.h>])
PGAC_FUNC_POSIX_SIGNALS PGAC_FUNC_POSIX_SIGNALS
if test $ac_cv_func_fseeko = yes; then
AC_SYS_LARGEFILE
fi
# Select semaphore implementation type. # Select semaphore implementation type.
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.148 2002/08/19 19:33:34 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.149 2002/08/20 17:54:44 petere Exp $
--> -->
<appendix id="release"> <appendix id="release">
...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without ...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters. worries about funny characters.
--> -->
<literallayout><![CDATA[ <literallayout><![CDATA[
Files larger than 2 GB are now supported (if supported by the operating system)
SERIAL no longer implies UNIQUE; specify explicitly if index is wanted SERIAL no longer implies UNIQUE; specify explicitly if index is wanted
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words. pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
CLUSTER is no longer hazardous to your schema CLUSTER is no longer hazardous to your schema
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.21 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.22 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -144,7 +144,7 @@ extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag, ...@@ -144,7 +144,7 @@ extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
DataDumperPtr dumpFn, void *dumpArg); DataDumperPtr dumpFn, void *dumpArg);
/* Called to write *data* to the archive */ /* Called to write *data* to the archive */
extern int WriteData(Archive *AH, const void *data, int dLen); extern size_t WriteData(Archive *AH, const void *data, size_t dLen);
/* /*
extern int StartBlobs(Archive* AH); extern int StartBlobs(Archive* AH);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.54 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.55 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -581,8 +581,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt ...@@ -581,8 +581,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
*/ */
/* Public */ /* Public */
int size_t
WriteData(Archive *AHX, const void *data, int dLen) WriteData(Archive *AHX, const void *data, size_t dLen)
{ {
ArchiveHandle *AH = (ArchiveHandle *) AHX; ArchiveHandle *AH = (ArchiveHandle *) AHX;
...@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag, ...@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
(*AH->ArchiveEntryPtr) (AH, newToc); (*AH->ArchiveEntryPtr) (AH, newToc);
/* /*
* printf("New toc owned by '%s', oid %d\n", newToc->owner, * printf("New toc owned by '%s', oid %u\n", newToc->owner,
* newToc->oidVal); * newToc->oidVal);
*/ */
} }
...@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid) ...@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
if (AH->lo_buf_used > 0) if (AH->lo_buf_used > 0)
{ {
/* Write remaining bytes from the LO buffer */ /* Write remaining bytes from the LO buffer */
int res; size_t res;
res = lo_write(AH->connection, AH->loFd, (void *) AH->lo_buf, AH->lo_buf_used); res = lo_write(AH->connection, AH->loFd, (void *) AH->lo_buf, AH->lo_buf_used);
ahlog(AH, 5, "wrote remaining %d bytes of large object data (result = %d)\n", ahlog(AH, 5, "wrote remaining %lu bytes of large object data (result = %lu)\n",
(int)AH->lo_buf_used, res); (unsigned long) AH->lo_buf_used, (unsigned long) res);
if (res != AH->lo_buf_used) if (res != AH->lo_buf_used)
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n", die_horribly(AH, modulename, "could not write to large object (result: %lu, expected: %lu)\n",
res, AH->lo_buf_used); (unsigned long) res, (unsigned long) AH->lo_buf_used);
AH->lo_buf_used = 0; AH->lo_buf_used = 0;
} }
...@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH) ...@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH)
int int
ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
int res; size_t res;
if (AH->writingBlob) if (AH->writingBlob)
{ {
if(AH->lo_buf_used + size * nmemb > AH->lo_buf_size) { if (AH->lo_buf_used + size * nmemb > AH->lo_buf_size)
/* Split LO buffer */ {
int remaining = AH->lo_buf_size - AH->lo_buf_used; /* Split LO buffer */
int slack = nmemb * size - remaining; size_t remaining = AH->lo_buf_size - AH->lo_buf_used;
size_t slack = nmemb * size - remaining;
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, remaining);
res = lo_write(AH->connection, AH->loFd, AH->lo_buf, AH->lo_buf_size); memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, remaining);
ahlog(AH, 5, "wrote %d bytes of large object data (result = %d)\n", res = lo_write(AH->connection, AH->loFd, AH->lo_buf, AH->lo_buf_size);
AH->lo_buf_size, res); ahlog(AH, 5, "wrote %lu bytes of large object data (result = %lu)\n",
if (res != AH->lo_buf_size) (unsigned long) AH->lo_buf_size, (unsigned long) res);
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n", if (res != AH->lo_buf_size)
res, AH->lo_buf_size); die_horribly(AH, modulename,
memcpy(AH->lo_buf, (char *)ptr + remaining, slack); "could not write to large object (result: %lu, expected: %lu)\n",
AH->lo_buf_used = slack; (unsigned long) res, (unsigned long) AH->lo_buf_size);
} else { memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
/* LO Buffer is still large enough, buffer it */ AH->lo_buf_used = slack;
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb); }
AH->lo_buf_used += size * nmemb; else
} {
/* LO Buffer is still large enough, buffer it */
return size * nmemb; memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb);
AH->lo_buf_used += size * nmemb;
}
return size * nmemb;
} }
else if (AH->gzOut) else if (AH->gzOut)
{ {
...@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH) ...@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{ {
res = fwrite((void *) ptr, size, nmemb, AH->OF); res = fwrite((void *) ptr, size, nmemb, AH->OF);
if (res != nmemb) if (res != nmemb)
die_horribly(AH, modulename, "could not write to output file (%d != %d)\n", die_horribly(AH, modulename, "could not write to output file (%lu != %lu)\n",
res, (int) nmemb); (unsigned long) res, (unsigned long) nmemb);
return res; return res;
} }
} }
...@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt) ...@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
return _tocEntryRequired(te, ropt); return _tocEntryRequired(te, ropt);
} }
int size_t
WriteInt(ArchiveHandle *AH, int i) WriteInt(ArchiveHandle *AH, int i)
{ {
int b; int b;
...@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH) ...@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH)
return res; return res;
} }
int size_t
WriteStr(ArchiveHandle *AH, const char *c) WriteStr(ArchiveHandle *AH, const char *c)
{ {
int res; size_t res;
if (c) if (c)
{ {
...@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
{ {
FILE *fh; FILE *fh;
char sig[6]; /* More than enough */ char sig[6]; /* More than enough */
int cnt; size_t cnt;
int wantClose = 0; int wantClose = 0;
#if 0 #if 0
...@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
if (ferror(fh)) if (ferror(fh))
die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno)); die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno));
else else
die_horribly(AH, modulename, "input file is too short (read %d, expected 5)\n", cnt); die_horribly(AH, modulename, "input file is too short (read %lu, expected 5)\n",
(unsigned long) cnt);
} }
/* Save it, just in case we need it later */ /* Save it, just in case we need it later */
...@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
} }
/* If we can't seek, then mark the header as read */ /* If we can't seek, then mark the header as read */
if (fseek(fh, 0, SEEK_SET) != 0) if (fseeko(fh, 0, SEEK_SET) != 0)
{ {
/* /*
* NOTE: Formats that use the looahead buffer can unset this in * NOTE: Formats that use the looahead buffer can unset this in
...@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH) ...@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */ AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
#if 0 #if 0
write_msg(modulename, "read %d bytes into lookahead buffer\n", AH->lookaheadLen); write_msg(modulename, "read %lu bytes into lookahead buffer\n",
(unsigned long) AH->lookaheadLen);
#endif #endif
/* Close the file */ /* Close the file */
...@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH) ...@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH)
AH->intSize = (*AH->ReadBytePtr) (AH); AH->intSize = (*AH->ReadBytePtr) (AH);
if (AH->intSize > 32) if (AH->intSize > 32)
die_horribly(AH, modulename, "sanity check on integer size (%d) failed\n", AH->intSize); die_horribly(AH, modulename, "sanity check on integer size (%lu) failed\n",
(unsigned long) AH->intSize);
if (AH->intSize > sizeof(int)) if (AH->intSize > sizeof(int))
write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n"); write_msg(modulename, "WARNING: archive was made on a machine with larger integers, some operations may fail\n");
...@@ -2368,7 +2375,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) ...@@ -2368,7 +2375,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
for (i = 0; i <= AH->tocCount + 1; i++) for (i = 0; i <= AH->tocCount + 1; i++)
{ {
/* /*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
* te->oidVal); * te->oidVal);
*/ */
tea[i] = te; tea[i] = te;
...@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn) ...@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
for (i = 0; i <= AH->tocCount + 1; i++) for (i = 0; i <= AH->tocCount + 1; i++)
{ {
/* /*
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next, * printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
* te->oidVal); * te->oidVal);
*/ */
te = te->next; te = te->next;
...@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2) ...@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
Oid id2 = te2->maxOidVal; Oid id2 = te2->maxOidVal;
int cmpval; int cmpval;
/* printf("Comparing %d to %d\n", id1, id2); */ /* printf("Comparing %u to %u\n", id1, id2); */
cmpval = oidcmp(id1, id2); cmpval = oidcmp(id1, id2);
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.45 2002/08/10 16:57:31 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.46 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -48,8 +48,8 @@ typedef struct _z_stream ...@@ -48,8 +48,8 @@ typedef struct _z_stream
{ {
void *next_in; void *next_in;
void *next_out; void *next_out;
int avail_in; size_t avail_in;
int avail_out; size_t avail_out;
} z_stream; } z_stream;
typedef z_stream *z_streamp; typedef z_stream *z_streamp;
#endif #endif
...@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH); ...@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*ArchiveEntryPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*StartDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef int (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, int dLen); typedef size_t (*WriteDataPtr) (struct _archiveHandle * AH, const void *data, size_t dLen);
typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*EndDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*StartBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
...@@ -96,15 +96,15 @@ typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te); ...@@ -96,15 +96,15 @@ typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i); typedef int (*WriteBytePtr) (struct _archiveHandle * AH, const int i);
typedef int (*ReadBytePtr) (struct _archiveHandle * AH); typedef int (*ReadBytePtr) (struct _archiveHandle * AH);
typedef int (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, int len); typedef size_t (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
typedef int (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, int len); typedef size_t (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
typedef void (*SaveArchivePtr) (struct _archiveHandle * AH); typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*WriteExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*ReadExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te); typedef void (*PrintExtraTocPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt); typedef void (*PrintTocDataPtr) (struct _archiveHandle * AH, struct _tocEntry * te, RestoreOptions *ropt);
typedef int (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, int len); typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
typedef int (*TocSortCompareFn) (const void *te1, const void *te2); typedef int (*TocSortCompareFn) (const void *te1, const void *te2);
...@@ -147,7 +147,7 @@ typedef struct _archiveHandle ...@@ -147,7 +147,7 @@ typedef struct _archiveHandle
int debugLevel; /* Used for logging (currently only by int debugLevel; /* Used for logging (currently only by
* --verbose) */ * --verbose) */
int intSize; /* Size of an integer in the archive */ size_t intSize; /* Size of an integer in the archive */
ArchiveFormat format; /* Archive format */ ArchiveFormat format; /* Archive format */
sqlparseInfo sqlparse; sqlparseInfo sqlparse;
...@@ -163,9 +163,9 @@ typedef struct _archiveHandle ...@@ -163,9 +163,9 @@ typedef struct _archiveHandle
* already */ * already */
char *lookahead; /* Buffer used when reading header to char *lookahead; /* Buffer used when reading header to
* discover format */ * discover format */
int lookaheadSize; /* Size of allocated buffer */ size_t lookaheadSize; /* Size of allocated buffer */
int lookaheadLen; /* Length of data in lookahead */ size_t lookaheadLen; /* Length of data in lookahead */
int lookaheadPos; /* Current read position in lookahead off_t lookaheadPos; /* Current read position in lookahead
* buffer */ * buffer */
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */ ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
...@@ -230,8 +230,8 @@ typedef struct _archiveHandle ...@@ -230,8 +230,8 @@ typedef struct _archiveHandle
RestoreOptions *ropt; /* Used to check restore options in RestoreOptions *ropt; /* Used to check restore options in
* ahwrite etc */ * ahwrite etc */
void *lo_buf; void *lo_buf;
int lo_buf_used; size_t lo_buf_used;
int lo_buf_size; size_t lo_buf_size;
} ArchiveHandle; } ArchiveHandle;
typedef struct _tocEntry typedef struct _tocEntry
...@@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt); ...@@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
* Mandatory routines for each supported format * Mandatory routines for each supported format
*/ */
extern int WriteInt(ArchiveHandle *AH, int i); extern size_t WriteInt(ArchiveHandle *AH, int i);
extern int ReadInt(ArchiveHandle *AH); extern int ReadInt(ArchiveHandle *AH);
extern char *ReadStr(ArchiveHandle *AH); extern char *ReadStr(ArchiveHandle *AH);
extern int WriteStr(ArchiveHandle *AH, const char *s); extern size_t WriteStr(ArchiveHandle *AH, const char *s);
extern void StartRestoreBlobs(ArchiveHandle *AH); extern void StartRestoreBlobs(ArchiveHandle *AH);
extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid); extern void StartRestoreBlob(ArchiveHandle *AH, Oid oid);
......
...@@ -19,15 +19,7 @@ ...@@ -19,15 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.19 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.20 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -44,12 +36,12 @@ ...@@ -44,12 +36,12 @@
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len); static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
...@@ -79,16 +71,16 @@ typedef struct ...@@ -79,16 +71,16 @@ typedef struct
z_streamp zp; z_streamp zp;
char *zlibOut; char *zlibOut;
char *zlibIn; char *zlibIn;
int inSize; size_t inSize;
int hasSeek; int hasSeek;
int filePos; off_t filePos;
int dataStart; off_t dataStart;
} lclContext; } lclContext;
typedef struct typedef struct
{ {
int dataPos; off_t dataPos;
int dataLen; size_t dataLen;
} lclTocEntry; } lclTocEntry;
...@@ -99,7 +91,7 @@ typedef struct ...@@ -99,7 +91,7 @@ typedef struct
static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id); static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id);
static void _StartDataCompressor(ArchiveHandle *AH, TocEntry *te); static void _StartDataCompressor(ArchiveHandle *AH, TocEntry *te);
static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te); static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te);
static int _getFilePos(ArchiveHandle *AH, lclContext *ctx); static off_t _getFilePos(ArchiveHandle *AH, lclContext *ctx);
static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush); static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
static char *modulename = gettext_noop("custom archiver"); static char *modulename = gettext_noop("custom archiver");
...@@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
/* Initialize LO buffering */ /* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE); AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL) if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n"); die_horribly(AH, modulename, "out of memory\n");
/* /*
* zlibOutSize is the buffer size we tell zlib it can output to. We * zlibOutSize is the buffer size we tell zlib it can output to. We
...@@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH) if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno)); die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
} }
else else
...@@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH) ...@@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH) if (!AH->FH)
die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno)); die_horribly(AH, modulename, "could not open archive file %s: %s\n", AH->fSpec, strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
ReadHead(AH); ReadHead(AH);
ReadToc(AH); ReadToc(AH);
...@@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te) ...@@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{ {
lclTocEntry *ctx = (lclTocEntry *) te->formatData; lclTocEntry *ctx = (lclTocEntry *) te->formatData;
ahprintf(AH, "-- Data Pos: %d (Length %d)\n", ctx->dataPos, ctx->dataLen); ahprintf(AH, "-- Data Pos: " INT64_FORMAT " (Length %lu)\n",
(int64) ctx->dataPos, (unsigned long) ctx->dataLen);
} }
/* /*
...@@ -323,8 +316,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te) ...@@ -323,8 +316,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
* Mandatory. * Mandatory.
* *
*/ */
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp; z_streamp zp = ctx->zp;
...@@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen) ...@@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen)
while (zp->avail_in != 0) while (zp->avail_in != 0)
{ {
/* printf("Deflating %d bytes\n", dLen); */ /* printf("Deflating %lu bytes\n", (unsigned long) dLen); */
_DoDeflate(AH, ctx, 0); _DoDeflate(AH, ctx, 0);
} }
return dLen; return dLen;
...@@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt) ...@@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* Grab it */ /* Grab it */
if (fseek(AH->FH, tctx->dataPos, SEEK_SET) != 0) if (fseeko(AH->FH, tctx->dataPos, SEEK_SET) != 0)
die_horribly(AH, modulename, "error during file seek: %s\n", strerror(errno)); die_horribly(AH, modulename, "error during file seek: %s\n", strerror(errno));
_readBlockHeader(AH, &blkType, &id); _readBlockHeader(AH, &blkType, &id);
...@@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH) ...@@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp; z_streamp zp = ctx->zp;
int blkLen; size_t blkLen;
char *in = ctx->zlibIn; char *in = ctx->zlibIn;
int cnt; size_t cnt;
#ifdef HAVE_LIBZ #ifdef HAVE_LIBZ
int res; int res;
...@@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH) ...@@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt); die_horribly(AH, modulename,
"could not read data block - expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -683,9 +678,9 @@ static void ...@@ -683,9 +678,9 @@ static void
_skipData(ArchiveHandle *AH) _skipData(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int blkLen; size_t blkLen;
char *in = ctx->zlibIn; char *in = ctx->zlibIn;
int cnt; size_t cnt;
blkLen = ReadInt(AH); blkLen = ReadInt(AH);
while (blkLen != 0) while (blkLen != 0)
...@@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH) ...@@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH)
} }
cnt = fread(in, 1, blkLen, AH->FH); cnt = fread(in, 1, blkLen, AH->FH);
if (cnt != blkLen) if (cnt != blkLen)
die_horribly(AH, modulename, "could not read data block - expected %d, got %d\n", blkLen, cnt); die_horribly(AH, modulename,
"could not read data block - expected %lu, got %lu\n",
(unsigned long) blkLen, (unsigned long) cnt);
ctx->filePos += blkLen; ctx->filePos += blkLen;
...@@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH) ...@@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH)
* These routines are only used to read & write headers & TOC. * These routines are only used to read & write headers & TOC.
* *
*/ */
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
die_horribly(AH, modulename, "write error in _WriteBuf (%d != %d)\n", res, len); die_horribly(AH, modulename,
"write error in _WriteBuf (%lu != %lu)\n",
(unsigned long) res, (unsigned long) len);
ctx->filePos += res; ctx->filePos += res;
return res; return res;
...@@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
* These routines are only used to read & write headers & TOC. * These routines are only used to read & write headers & TOC.
* *
*/ */
static int static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, int len) _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fread(buf, 1, len, AH->FH); res = fread(buf, 1, len, AH->FH);
ctx->filePos += res; ctx->filePos += res;
...@@ -816,12 +815,12 @@ static void ...@@ -816,12 +815,12 @@ static void
_CloseArchive(ArchiveHandle *AH) _CloseArchive(ArchiveHandle *AH)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int tpos; off_t tpos;
if (AH->mode == archModeWrite) if (AH->mode == archModeWrite)
{ {
WriteHead(AH); WriteHead(AH);
tpos = ftell(AH->FH); tpos = ftello(AH->FH);
WriteToc(AH); WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx); ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH); WriteDataChunks(AH);
...@@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH)
*/ */
if (ctx->hasSeek) if (ctx->hasSeek)
{ {
fseek(AH->FH, tpos, SEEK_SET); fseeko(AH->FH, tpos, SEEK_SET);
WriteToc(AH); WriteToc(AH);
} }
} }
...@@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH) ...@@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH)
/* /*
* Get the current position in the archive file. * Get the current position in the archive file.
*/ */
static int static off_t
_getFilePos(ArchiveHandle *AH, lclContext *ctx) _getFilePos(ArchiveHandle *AH, lclContext *ctx)
{ {
int pos; off_t pos;
if (ctx->hasSeek) if (ctx->hasSeek)
{ {
pos = ftell(AH->FH); pos = ftello(AH->FH);
if (pos != ctx->filePos) if (pos != ctx->filePos)
{ {
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n"); write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n");
...@@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush) ...@@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
if (zp->avail_out < zlibOutSize) if (zp->avail_out < zlibOutSize)
{ {
/* /*
* printf("Wrote %d byte deflated chunk\n", zlibOutSize - * printf("Wrote %lu byte deflated chunk\n", (unsigned long) (zlibOutSize -
* zp->avail_out); * zp->avail_out));
*/ */
WriteInt(AH, zlibOutSize - zp->avail_out); WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out)) if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver. * Implements the basic DB functions used by the archiver.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.37 2002/08/18 09:36:25 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.c,v 1.38 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
#include "pg_backup_db.h" #include "pg_backup_db.h"
#include <unistd.h> /* for getopt() */ #include <unistd.h>
#include <ctype.h> #include <ctype.h>
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
...@@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc) ...@@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
static char * static char *
_sendCopyLine(ArchiveHandle *AH, char *qry, char *eos) _sendCopyLine(ArchiveHandle *AH, char *qry, char *eos)
{ {
int loc; /* Location of next newline */ size_t loc; /* Location of next newline */
int pos = 0; /* Current position */ int pos = 0; /* Current position */
int sPos = 0; /* Last pos of a slash char */ int sPos = 0; /* Last pos of a slash char */
int isEnd = 0; int isEnd = 0;
...@@ -549,7 +549,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos) ...@@ -549,7 +549,7 @@ _sendSQLLine(ArchiveHandle *AH, char *qry, char *eos)
/* Convenience function to send one or more queries. Monitors result to handle COPY statements */ /* Convenience function to send one or more queries. Monitors result to handle COPY statements */
int int
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen) ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
{ {
char *qry = (char *) qryv; char *qry = (char *) qryv;
char *eos = qry + bufLen; char *eos = qry + bufLen;
......
...@@ -2,14 +2,14 @@ ...@@ -2,14 +2,14 @@
* Definitions for pg_backup_db.c * Definitions for pg_backup_db.c
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.7 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_db.h,v 1.8 2002/08/20 17:54:44 petere Exp $
*/ */
#define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */ #define BLOB_XREF_TABLE "pg_dump_blob_xref" /* MUST be lower case */
extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te); extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te);
extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob); extern int ExecuteSqlCommand(ArchiveHandle *AH, PQExpBuffer qry, char *desc, bool use_blob);
extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, int bufLen); extern int ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qry, size_t bufLen);
extern void CreateBlobXrefTable(ArchiveHandle *AH); extern void CreateBlobXrefTable(ArchiveHandle *AH);
extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new); extern void InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new);
......
...@@ -20,15 +20,7 @@ ...@@ -20,15 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.16 2002/05/29 01:38:56 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.17 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,12 +30,12 @@ ...@@ -38,12 +30,12 @@
static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te); static void _ArchiveEntry(ArchiveHandle *AH, TocEntry *te);
static void _StartData(ArchiveHandle *AH, TocEntry *te); static void _StartData(ArchiveHandle *AH, TocEntry *te);
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *); static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len); static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te); static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
...@@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te); ...@@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
typedef struct typedef struct
{ {
int hasSeek; int hasSeek;
int filePos; off_t filePos;
FILE *blobToc; FILE *blobToc;
} lclContext; } lclContext;
...@@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
/* Initialize LO buffering */ /* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE; AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE); AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL) if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n"); die_horribly(AH, modulename, "out of memory\n");
/* /*
* Now open the TOC file * Now open the TOC file
...@@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno)); die_horribly(NULL, modulename, "could not open output file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
if (AH->compression < 0 || AH->compression > 9) if (AH->compression < 0 || AH->compression > 9)
AH->compression = Z_DEFAULT_COMPRESSION; AH->compression = Z_DEFAULT_COMPRESSION;
...@@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH) ...@@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL) if (AH->FH == NULL)
die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno)); die_horribly(NULL, modulename, "could not open input file: %s\n", strerror(errno));
ctx->hasSeek = (fseek(AH->FH, 0, SEEK_CUR) == 0); ctx->hasSeek = (fseeko(AH->FH, 0, SEEK_CUR) == 0);
ReadHead(AH); ReadHead(AH);
ReadToc(AH); ReadToc(AH);
...@@ -255,8 +247,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te) ...@@ -255,8 +247,8 @@ _StartData(ArchiveHandle *AH, TocEntry *te)
} }
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData; lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
...@@ -284,7 +276,7 @@ static void ...@@ -284,7 +276,7 @@ static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt) _PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
{ {
char buf[4096]; char buf[4096];
int cnt; size_t cnt;
if (!filename) if (!filename)
return; return;
...@@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE]) ...@@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE])
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
char blobTe[K_STD_BUF_SIZE]; char blobTe[K_STD_BUF_SIZE];
int fpos; size_t fpos;
int eos; size_t eos;
if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL) if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL)
{ {
...@@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH) ...@@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH)
return res; return res;
} }
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fwrite(buf, 1, len, AH->FH); res = fwrite(buf, 1, len, AH->FH);
if (res != len) if (res != len)
...@@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len) ...@@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
return res; return res;
} }
static int static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, int len) _ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{ {
lclContext *ctx = (lclContext *) AH->formatData; lclContext *ctx = (lclContext *) AH->formatData;
int res; size_t res;
res = fread(buf, 1, len, AH->FH); res = fread(buf, 1, len, AH->FH);
ctx->filePos += res; ctx->filePos += res;
......
...@@ -17,16 +17,7 @@ ...@@ -17,16 +17,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.9 2002/05/10 22:36:26 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.10 2002/08/20 17:54:44 petere Exp $
*
* Modifications - 09-Jul-2000 - pjw@rhyme.com.au
*
* Initial version.
*
* Modifications - 04-Jan-2001 - pjw@rhyme.com.au
*
* - Check results of IO routines more carefully.
*
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -38,10 +29,10 @@ ...@@ -38,10 +29,10 @@
#include <string.h> #include <string.h>
#include <unistd.h> /* for dup */ #include <unistd.h> /* for dup */
static int _WriteData(ArchiveHandle *AH, const void *data, int dLen); static size_t _WriteData(ArchiveHandle *AH, const void *data, size_t dLen);
static void _EndData(ArchiveHandle *AH, TocEntry *te); static void _EndData(ArchiveHandle *AH, TocEntry *te);
static int _WriteByte(ArchiveHandle *AH, const int i); static int _WriteByte(ArchiveHandle *AH, const int i);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len); static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH); static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt); static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
...@@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH) ...@@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH)
* As at V1.3, this is only called for COPY FROM dfata, and BLOB data * As at V1.3, this is only called for COPY FROM dfata, and BLOB data
*------ *------
*/ */
static int static size_t
_WriteData(ArchiveHandle *AH, const void *data, int dLen) _WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{ {
/* Just send it to output */ /* Just send it to output */
ahwrite(data, 1, dLen, AH); ahwrite(data, 1, dLen, AH);
...@@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i) ...@@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i)
return 0; return 0;
} }
static int static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, int len) _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{ {
/* Don't do anything */ /* Don't do anything */
return len; return len;
......
This diff is collapsed.
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.287 2002/08/19 19:33:35 tgl Exp $ * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.288 2002/08/20 17:54:44 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1302,7 +1302,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal) ...@@ -1302,7 +1302,7 @@ dumpBlobs(Archive *AH, char *junkOid, void *junkVal)
int i; int i;
int loFd; int loFd;
char buf[loBufSize]; char buf[loBufSize];
int cnt; size_t cnt;
Oid blobOid; Oid blobOid;
if (g_verbose) if (g_verbose)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: pg_config.h.in,v 1.27 2002/08/13 20:40:44 momjian Exp $ * $Id: pg_config.h.in,v 1.28 2002/08/20 17:54:45 petere Exp $
*/ */
#ifndef PG_CONFIG_H #ifndef PG_CONFIG_H
...@@ -720,6 +720,23 @@ extern int fdatasync(int fildes); ...@@ -720,6 +720,23 @@ extern int fdatasync(int fildes);
/* Define exactly one of these symbols to select shared-mem implementation */ /* Define exactly one of these symbols to select shared-mem implementation */
#undef USE_SYSV_SHARED_MEMORY #undef USE_SYSV_SHARED_MEMORY
/* Define to 1 to make fseeko visible on some hosts. */
#undef _LARGEFILE_SOURCE
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#undef HAVE_FSEEKO
#ifndef HAVE_FSEEKO
#define fseeko(a, b, c) fseek((a), (b), (c))
#define ftello(a) ftell((a))
#endif
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
/* /*
*------------------------------------------------------------------------ *------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment