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 $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 Developers, please strive to achieve this order:
dnl
......@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [],
[AC_CHECK_FUNCS(on_exit, [],
[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
# 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>])
PGAC_FUNC_POSIX_SIGNALS
if test $ac_cv_func_fseeko = yes; then
AC_SYS_LARGEFILE
fi
# 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">
......@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters.
-->
<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
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
......
......@@ -15,7 +15,7 @@
*
*
* 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,
DataDumperPtr dumpFn, void *dumpArg);
/* 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);
......
......@@ -15,7 +15,7 @@
*
*
* 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
*/
/* Public */
int
WriteData(Archive *AHX, const void *data, int dLen)
size_t
WriteData(Archive *AHX, const void *data, size_t dLen)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
......@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
(*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);
*/
}
......@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
if (AH->lo_buf_used > 0)
{
/* 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);
ahlog(AH, 5, "wrote remaining %d bytes of large object data (result = %d)\n",
(int)AH->lo_buf_used, res);
ahlog(AH, 5, "wrote remaining %lu bytes of large object data (result = %lu)\n",
(unsigned long) AH->lo_buf_used, (unsigned long) res);
if (res != AH->lo_buf_used)
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n",
res, AH->lo_buf_used);
die_horribly(AH, modulename, "could not write to large object (result: %lu, expected: %lu)\n",
(unsigned long) res, (unsigned long) AH->lo_buf_used);
AH->lo_buf_used = 0;
}
......@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH)
int
ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{
int res;
size_t res;
if (AH->writingBlob)
{
if(AH->lo_buf_used + size * nmemb > AH->lo_buf_size) {
/* Split LO buffer */
int remaining = AH->lo_buf_size - AH->lo_buf_used;
int 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);
ahlog(AH, 5, "wrote %d bytes of large object data (result = %d)\n",
AH->lo_buf_size, res);
if (res != AH->lo_buf_size)
die_horribly(AH, modulename, "could not write to large object (result: %d, expected: %d)\n",
res, AH->lo_buf_size);
memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
AH->lo_buf_used = slack;
} else {
/* LO Buffer is still large enough, buffer it */
memcpy((char *)AH->lo_buf + AH->lo_buf_used, ptr, size * nmemb);
AH->lo_buf_used += size * nmemb;
}
return size * nmemb;
if (AH->lo_buf_used + size * nmemb > AH->lo_buf_size)
{
/* Split LO buffer */
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);
ahlog(AH, 5, "wrote %lu bytes of large object data (result = %lu)\n",
(unsigned long) AH->lo_buf_size, (unsigned long) res);
if (res != AH->lo_buf_size)
die_horribly(AH, modulename,
"could not write to large object (result: %lu, expected: %lu)\n",
(unsigned long) res, (unsigned long) AH->lo_buf_size);
memcpy(AH->lo_buf, (char *)ptr + remaining, slack);
AH->lo_buf_used = slack;
}
else
{
/* LO Buffer is still large enough, buffer it */
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)
{
......@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
{
res = fwrite((void *) ptr, size, nmemb, AH->OF);
if (res != nmemb)
die_horribly(AH, modulename, "could not write to output file (%d != %d)\n",
res, (int) nmemb);
die_horribly(AH, modulename, "could not write to output file (%lu != %lu)\n",
(unsigned long) res, (unsigned long) nmemb);
return res;
}
}
......@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
return _tocEntryRequired(te, ropt);
}
int
size_t
WriteInt(ArchiveHandle *AH, int i)
{
int b;
......@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH)
return res;
}
int
size_t
WriteStr(ArchiveHandle *AH, const char *c)
{
int res;
size_t res;
if (c)
{
......@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
{
FILE *fh;
char sig[6]; /* More than enough */
int cnt;
size_t cnt;
int wantClose = 0;
#if 0
......@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
if (ferror(fh))
die_horribly(AH, modulename, "could not read input file: %s\n", strerror(errno));
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 */
......@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
}
/* 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
......@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
AH->lookaheadLen = 0; /* Don't bother since we've reset the file */
#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
/* Close the file */
......@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH)
AH->intSize = (*AH->ReadBytePtr) (AH);
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))
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)
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);
*/
tea[i] = te;
......@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
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 = te->next;
......@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
Oid id2 = te2->maxOidVal;
int cmpval;
/* printf("Comparing %d to %d\n", id1, id2); */
/* printf("Comparing %u to %u\n", id1, id2); */
cmpval = oidcmp(id1, id2);
......
......@@ -17,7 +17,7 @@
*
*
* 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
{
void *next_in;
void *next_out;
int avail_in;
int avail_out;
size_t avail_in;
size_t avail_out;
} z_stream;
typedef z_stream *z_streamp;
#endif
......@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH);
typedef void (*ArchiveEntryPtr) (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 (*StartBlobsPtr) (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 (*ReadBytePtr) (struct _archiveHandle * AH);
typedef int (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, int len);
typedef int (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, int len);
typedef size_t (*WriteBufPtr) (struct _archiveHandle * AH, const void *c, size_t len);
typedef size_t (*ReadBufPtr) (struct _archiveHandle * AH, void *buf, size_t len);
typedef void (*SaveArchivePtr) (struct _archiveHandle * AH);
typedef void (*WriteExtraTocPtr) (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 (*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);
......@@ -147,7 +147,7 @@ typedef struct _archiveHandle
int debugLevel; /* Used for logging (currently only by
* --verbose) */
int intSize; /* Size of an integer in the archive */
size_t intSize; /* Size of an integer in the archive */
ArchiveFormat format; /* Archive format */
sqlparseInfo sqlparse;
......@@ -163,9 +163,9 @@ typedef struct _archiveHandle
* already */
char *lookahead; /* Buffer used when reading header to
* discover format */
int lookaheadSize; /* Size of allocated buffer */
int lookaheadLen; /* Length of data in lookahead */
int lookaheadPos; /* Current read position in lookahead
size_t lookaheadSize; /* Size of allocated buffer */
size_t lookaheadLen; /* Length of data in lookahead */
off_t lookaheadPos; /* Current read position in lookahead
* buffer */
ArchiveEntryPtr ArchiveEntryPtr; /* Called for each metadata object */
......@@ -230,8 +230,8 @@ typedef struct _archiveHandle
RestoreOptions *ropt; /* Used to check restore options in
* ahwrite etc */
void *lo_buf;
int lo_buf_used;
int lo_buf_size;
size_t lo_buf_used;
size_t lo_buf_size;
} ArchiveHandle;
typedef struct _tocEntry
......@@ -282,10 +282,10 @@ extern int TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
* 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 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 StartRestoreBlob(ArchiveHandle *AH, Oid oid);
......
......@@ -19,15 +19,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.19 2002/05/29 01:38:56 tgl 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.
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.20 2002/08/20 17:54:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -44,12 +36,12 @@
static void _ArchiveEntry(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 int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len);
static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
......@@ -79,16 +71,16 @@ typedef struct
z_streamp zp;
char *zlibOut;
char *zlibIn;
int inSize;
size_t inSize;
int hasSeek;
int filePos;
int dataStart;
off_t filePos;
off_t dataStart;
} lclContext;
typedef struct
{
int dataPos;
int dataLen;
off_t dataPos;
size_t dataLen;
} lclTocEntry;
......@@ -99,7 +91,7 @@ typedef struct
static void _readBlockHeader(ArchiveHandle *AH, int *type, int *id);
static void _StartDataCompressor(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 char *modulename = gettext_noop("custom archiver");
......@@ -156,8 +148,8 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n");
if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n");
/*
* zlibOutSize is the buffer size we tell zlib it can output to. We
......@@ -188,7 +180,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH)
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
......@@ -201,7 +193,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
if (!AH->FH)
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);
ReadToc(AH);
......@@ -285,7 +277,8 @@ _PrintExtraToc(ArchiveHandle *AH, TocEntry *te)
{
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)
* Mandatory.
*
*/
static int
_WriteData(ArchiveHandle *AH, const void *data, int dLen)
static size_t
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{
lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp;
......@@ -334,7 +327,7 @@ _WriteData(ArchiveHandle *AH, const void *data, int dLen)
while (zp->avail_in != 0)
{
/* printf("Deflating %d bytes\n", dLen); */
/* printf("Deflating %lu bytes\n", (unsigned long) dLen); */
_DoDeflate(AH, ctx, 0);
}
return dLen;
......@@ -486,7 +479,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
/* 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));
_readBlockHeader(AH, &blkType, &id);
......@@ -532,9 +525,9 @@ _PrintData(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
z_streamp zp = ctx->zp;
int blkLen;
size_t blkLen;
char *in = ctx->zlibIn;
int cnt;
size_t cnt;
#ifdef HAVE_LIBZ
int res;
......@@ -573,7 +566,9 @@ _PrintData(ArchiveHandle *AH)
cnt = fread(in, 1, blkLen, AH->FH);
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;
......@@ -683,9 +678,9 @@ static void
_skipData(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
int blkLen;
size_t blkLen;
char *in = ctx->zlibIn;
int cnt;
size_t cnt;
blkLen = ReadInt(AH);
while (blkLen != 0)
......@@ -699,7 +694,9 @@ _skipData(ArchiveHandle *AH)
}
cnt = fread(in, 1, blkLen, AH->FH);
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;
......@@ -761,16 +758,18 @@ _ReadByte(ArchiveHandle *AH)
* These routines are only used to read & write headers & TOC.
*
*/
static int
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{
lclContext *ctx = (lclContext *) AH->formatData;
int res;
size_t res;
res = fwrite(buf, 1, len, AH->FH);
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;
return res;
......@@ -785,11 +784,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
* These routines are only used to read & write headers & TOC.
*
*/
static int
_ReadBuf(ArchiveHandle *AH, void *buf, int len)
static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{
lclContext *ctx = (lclContext *) AH->formatData;
int res;
size_t res;
res = fread(buf, 1, len, AH->FH);
ctx->filePos += res;
......@@ -816,12 +815,12 @@ static void
_CloseArchive(ArchiveHandle *AH)
{
lclContext *ctx = (lclContext *) AH->formatData;
int tpos;
off_t tpos;
if (AH->mode == archModeWrite)
{
WriteHead(AH);
tpos = ftell(AH->FH);
tpos = ftello(AH->FH);
WriteToc(AH);
ctx->dataStart = _getFilePos(AH, ctx);
WriteDataChunks(AH);
......@@ -834,7 +833,7 @@ _CloseArchive(ArchiveHandle *AH)
*/
if (ctx->hasSeek)
{
fseek(AH->FH, tpos, SEEK_SET);
fseeko(AH->FH, tpos, SEEK_SET);
WriteToc(AH);
}
}
......@@ -853,14 +852,14 @@ _CloseArchive(ArchiveHandle *AH)
/*
* Get the current position in the archive file.
*/
static int
static off_t
_getFilePos(ArchiveHandle *AH, lclContext *ctx)
{
int pos;
off_t pos;
if (ctx->hasSeek)
{
pos = ftell(AH->FH);
pos = ftello(AH->FH);
if (pos != ctx->filePos)
{
write_msg(modulename, "WARNING: ftell mismatch with expected position -- ftell ignored\n");
......@@ -957,8 +956,8 @@ _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush)
if (zp->avail_out < zlibOutSize)
{
/*
* printf("Wrote %d byte deflated chunk\n", zlibOutSize -
* zp->avail_out);
* printf("Wrote %lu byte deflated chunk\n", (unsigned long) (zlibOutSize -
* zp->avail_out));
*/
WriteInt(AH, zlibOutSize - zp->avail_out);
if (fwrite(out, 1, zlibOutSize - zp->avail_out, AH->FH) != (zlibOutSize - zp->avail_out))
......
......@@ -5,7 +5,7 @@
* Implements the basic DB functions used by the archiver.
*
* 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 @@
#include "pg_backup_archiver.h"
#include "pg_backup_db.h"
#include <unistd.h> /* for getopt() */
#include <unistd.h>
#include <ctype.h>
#ifdef HAVE_TERMIOS_H
......@@ -347,7 +347,7 @@ _executeSqlCommand(ArchiveHandle *AH, PGconn *conn, PQExpBuffer qry, char *desc)
static char *
_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 sPos = 0; /* Last pos of a slash char */
int isEnd = 0;
......@@ -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 */
int
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, int bufLen)
ExecuteSqlCommandBuf(ArchiveHandle *AH, void *qryv, size_t bufLen)
{
char *qry = (char *) qryv;
char *eos = qry + bufLen;
......
......@@ -2,14 +2,14 @@
* Definitions for pg_backup_db.c
*
* 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 */
extern void FixupBlobRefs(ArchiveHandle *AH, TocEntry *te);
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 InsertBlobXref(ArchiveHandle *AH, Oid old, Oid new);
......
......@@ -20,15 +20,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.16 2002/05/29 01:38:56 tgl 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.
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.17 2002/08/20 17:54:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -38,12 +30,12 @@
static void _ArchiveEntry(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 int _WriteByte(ArchiveHandle *AH, const int i);
static int _ReadByte(ArchiveHandle *);
static int _WriteBuf(ArchiveHandle *AH, const void *buf, int len);
static int _ReadBuf(ArchiveHandle *AH, void *buf, int len);
static size_t _WriteBuf(ArchiveHandle *AH, const void *buf, size_t len);
static size_t _ReadBuf(ArchiveHandle *AH, void *buf, size_t len);
static void _CloseArchive(ArchiveHandle *AH);
static void _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
static void _WriteExtraToc(ArchiveHandle *AH, TocEntry *te);
......@@ -60,7 +52,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
typedef struct
{
int hasSeek;
int filePos;
off_t filePos;
FILE *blobToc;
} lclContext;
......@@ -116,8 +108,8 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
/* Initialize LO buffering */
AH->lo_buf_size = LOBBUFSIZE;
AH->lo_buf = (void *)malloc(LOBBUFSIZE);
if(AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n");
if (AH->lo_buf == NULL)
die_horribly(AH, modulename, "out of memory\n");
/*
* Now open the TOC file
......@@ -137,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL)
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)
AH->compression = Z_DEFAULT_COMPRESSION;
......@@ -155,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
if (AH->FH == NULL)
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);
ReadToc(AH);
......@@ -255,8 +247,8 @@ _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)
{
lclTocEntry *tctx = (lclTocEntry *) AH->currToc->formatData;
......@@ -284,7 +276,7 @@ static void
_PrintFileData(ArchiveHandle *AH, char *filename, RestoreOptions *ropt)
{
char buf[4096];
int cnt;
size_t cnt;
if (!filename)
return;
......@@ -332,8 +324,8 @@ _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char fname[K_STD_BUF_SIZE])
{
lclContext *ctx = (lclContext *) AH->formatData;
char blobTe[K_STD_BUF_SIZE];
int fpos;
int eos;
size_t fpos;
size_t eos;
if (fgets(&blobTe[0], K_STD_BUF_SIZE - 1, ctx->blobToc) != NULL)
{
......@@ -413,11 +405,11 @@ _ReadByte(ArchiveHandle *AH)
return res;
}
static int
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{
lclContext *ctx = (lclContext *) AH->formatData;
int res;
size_t res;
res = fwrite(buf, 1, len, AH->FH);
if (res != len)
......@@ -427,11 +419,11 @@ _WriteBuf(ArchiveHandle *AH, const void *buf, int len)
return res;
}
static int
_ReadBuf(ArchiveHandle *AH, void *buf, int len)
static size_t
_ReadBuf(ArchiveHandle *AH, void *buf, size_t len)
{
lclContext *ctx = (lclContext *) AH->formatData;
int res;
size_t res;
res = fread(buf, 1, len, AH->FH);
ctx->filePos += res;
......
......@@ -17,16 +17,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.9 2002/05/10 22:36:26 tgl 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.
*
* $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_null.c,v 1.10 2002/08/20 17:54:44 petere Exp $
*
*-------------------------------------------------------------------------
*/
......@@ -38,10 +29,10 @@
#include <string.h>
#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 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 _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt);
......@@ -75,8 +66,8 @@ InitArchiveFmt_Null(ArchiveHandle *AH)
* As at V1.3, this is only called for COPY FROM dfata, and BLOB data
*------
*/
static int
_WriteData(ArchiveHandle *AH, const void *data, int dLen)
static size_t
_WriteData(ArchiveHandle *AH, const void *data, size_t dLen)
{
/* Just send it to output */
ahwrite(data, 1, dLen, AH);
......@@ -112,8 +103,8 @@ _WriteByte(ArchiveHandle *AH, const int i)
return 0;
}
static int
_WriteBuf(ArchiveHandle *AH, const void *buf, int len)
static size_t
_WriteBuf(ArchiveHandle *AH, const void *buf, size_t len)
{
/* Don't do anything */
return len;
......
This diff is collapsed.
......@@ -22,7 +22,7 @@
*
*
* 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)
int i;
int loFd;
char buf[loBufSize];
int cnt;
size_t cnt;
Oid blobOid;
if (g_verbose)
......
......@@ -8,7 +8,7 @@
* 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.
*
* $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
......@@ -720,6 +720,23 @@ extern int fdatasync(int fildes);
/* Define exactly one of these symbols to select shared-mem implementation */
#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