Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit74096ed

Browse files
committed
Fix pg_dump on win32 to properly dump files larger than 2Gb when using
binary dump formats.
1 parentbc959b7 commit74096ed

File tree

6 files changed

+59
-41
lines changed

6 files changed

+59
-41
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.141 2007/02/01 19:10:28 momjian Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.142 2007/02/19 15:05:06 mha Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1311,24 +1311,24 @@ TocIDRequired(ArchiveHandle *AH, DumpId id, RestoreOptions *ropt)
13111311
}
13121312

13131313
size_t
1314-
WriteOffset(ArchiveHandle*AH,off_to,intwasSet)
1314+
WriteOffset(ArchiveHandle*AH,pgoff_to,intwasSet)
13151315
{
13161316
intoff;
13171317

13181318
/* Save the flag */
13191319
(*AH->WriteBytePtr) (AH,wasSet);
13201320

1321-
/* Write outoff_t smallest byte first, prevents endian mismatch */
1322-
for (off=0;off<sizeof(off_t);off++)
1321+
/* Write outpgoff_t smallest byte first, prevents endian mismatch */
1322+
for (off=0;off<sizeof(pgoff_t);off++)
13231323
{
13241324
(*AH->WriteBytePtr) (AH,o&0xFF);
13251325
o >>=8;
13261326
}
1327-
returnsizeof(off_t)+1;
1327+
returnsizeof(pgoff_t)+1;
13281328
}
13291329

13301330
int
1331-
ReadOffset(ArchiveHandle*AH,off_t*o)
1331+
ReadOffset(ArchiveHandle*AH,pgoff_t*o)
13321332
{
13331333
inti;
13341334
intoff;
@@ -1348,8 +1348,8 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
13481348
elseif (i==0)
13491349
returnK_OFFSET_NO_DATA;
13501350

1351-
/* Cast tooff_t because it was written as an int. */
1352-
*o= (off_t)i;
1351+
/* Cast topgoff_t because it was written as an int. */
1352+
*o= (pgoff_t)i;
13531353
returnK_OFFSET_POS_SET;
13541354
}
13551355

@@ -1379,8 +1379,8 @@ ReadOffset(ArchiveHandle *AH, off_t *o)
13791379
*/
13801380
for (off=0;off<AH->offSize;off++)
13811381
{
1382-
if (off<sizeof(off_t))
1383-
*o |= ((off_t) ((*AH->ReadBytePtr) (AH))) << (off*8);
1382+
if (off<sizeof(pgoff_t))
1383+
*o |= ((pgoff_t) ((*AH->ReadBytePtr) (AH))) << (off*8);
13841384
else
13851385
{
13861386
if ((*AH->ReadBytePtr) (AH)!=0)
@@ -1647,7 +1647,7 @@ _allocAH(const char *FileSpec, const ArchiveFormat fmt,
16471647
AH->createDate=time(NULL);
16481648

16491649
AH->intSize=sizeof(int);
1650-
AH->offSize=sizeof(off_t);
1650+
AH->offSize=sizeof(pgoff_t);
16511651
if (FileSpec)
16521652
{
16531653
AH->fSpec=strdup(FileSpec);
@@ -2768,11 +2768,11 @@ checkSeek(FILE *fp)
27682768

27692769
if (fseeko(fp,0,SEEK_CUR)!=0)
27702770
return false;
2771-
elseif (sizeof(off_t)>sizeof(long))
2771+
elseif (sizeof(pgoff_t)>sizeof(long))
27722772

27732773
/*
2774-
* At this point,off_t is too large for long, so we return based on
2775-
* whether anoff_t version of fseek is available.
2774+
* At this point,pgoff_t is too large for long, so we return based on
2775+
* whether anpgoff_t version of fseek is available.
27762776
*/
27772777
#ifdefHAVE_FSEEKO
27782778
return true;

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.74 2007/01/25 03:30:43 momjian Exp $
20+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.75 2007/02/19 15:05:06 mha Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -199,7 +199,7 @@ typedef struct _archiveHandle
199199
* format */
200200
size_tlookaheadSize;/* Size of allocated buffer */
201201
size_tlookaheadLen;/* Length of data in lookahead */
202-
off_tlookaheadPos;/* Current read position in lookahead buffer */
202+
pgoff_tlookaheadPos;/* Current read position in lookahead buffer */
203203

204204
ArchiveEntryPtrArchiveEntryPtr;/* Called for each metadata object */
205205
StartDataPtrStartDataPtr;/* Called when table data is about to be
@@ -332,8 +332,8 @@ extern intReadInt(ArchiveHandle *AH);
332332
externchar*ReadStr(ArchiveHandle*AH);
333333
externsize_tWriteStr(ArchiveHandle*AH,constchar*s);
334334

335-
intReadOffset(ArchiveHandle*,off_t*);
336-
size_tWriteOffset(ArchiveHandle*,off_t,int);
335+
intReadOffset(ArchiveHandle*,pgoff_t*);
336+
size_tWriteOffset(ArchiveHandle*,pgoff_t,int);
337337

338338
externvoidStartRestoreBlobs(ArchiveHandle*AH);
339339
externvoidStartRestoreBlob(ArchiveHandle*AH,Oidoid);

‎src/bin/pg_dump/pg_backup_custom.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.36 2006/10/04 00:30:05 momjian Exp $
22+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.37 2007/02/19 15:05:06 mha Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -70,14 +70,14 @@ typedef struct
7070
char*zlibIn;
7171
size_tinSize;
7272
inthasSeek;
73-
off_tfilePos;
74-
off_tdataStart;
73+
pgoff_tfilePos;
74+
pgoff_tdataStart;
7575
}lclContext;
7676

7777
typedefstruct
7878
{
7979
intdataState;
80-
off_tdataPos;
80+
pgoff_tdataPos;
8181
}lclTocEntry;
8282

8383

@@ -88,7 +88,7 @@ typedef struct
8888
staticvoid_readBlockHeader(ArchiveHandle*AH,int*type,int*id);
8989
staticvoid_StartDataCompressor(ArchiveHandle*AH,TocEntry*te);
9090
staticvoid_EndDataCompressor(ArchiveHandle*AH,TocEntry*te);
91-
staticoff_t_getFilePos(ArchiveHandle*AH,lclContext*ctx);
91+
staticpgoff_t_getFilePos(ArchiveHandle*AH,lclContext*ctx);
9292
staticint_DoDeflate(ArchiveHandle*AH,lclContext*ctx,intflush);
9393

9494
staticchar*modulename=gettext_noop("custom archiver");
@@ -791,7 +791,7 @@ static void
791791
_CloseArchive(ArchiveHandle*AH)
792792
{
793793
lclContext*ctx= (lclContext*)AH->formatData;
794-
off_ttpos;
794+
pgoff_ttpos;
795795

796796
if (AH->mode==archModeWrite)
797797
{
@@ -827,10 +827,10 @@ _CloseArchive(ArchiveHandle *AH)
827827
/*
828828
* Get the current position in the archive file.
829829
*/
830-
staticoff_t
830+
staticpgoff_t
831831
_getFilePos(ArchiveHandle*AH,lclContext*ctx)
832832
{
833-
off_tpos;
833+
pgoff_tpos;
834834

835835
if (ctx->hasSeek)
836836
{
@@ -841,7 +841,7 @@ _getFilePos(ArchiveHandle *AH, lclContext *ctx)
841841

842842
/*
843843
* Prior to 1.7 (pg7.3) we relied on the internally maintained
844-
* pointer. Now we rely onoff_t always. pos = ctx->filePos;
844+
* pointer. Now we rely onpgoff_t always. pos = ctx->filePos;
845845
*/
846846
}
847847
}

‎src/bin/pg_dump/pg_backup_files.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* IDENTIFICATION
23-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.30 2007/02/08 11:10:27 petere Exp $
23+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.31 2007/02/19 15:05:06 mha Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -51,7 +51,7 @@ static void _EndBlobs(ArchiveHandle *AH, TocEntry *te);
5151
typedefstruct
5252
{
5353
inthasSeek;
54-
off_tfilePos;
54+
pgoff_tfilePos;
5555
FILE*blobToc;
5656
}lclContext;
5757

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.56 2006/11/01 15:59:26 tgl Exp $
19+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.57 2007/02/19 15:05:06 mha Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -67,30 +67,30 @@ typedef struct
6767
FILE*tmpFH;
6868
char*targetFile;
6969
charmode;
70-
off_tpos;
71-
off_tfileLen;
70+
pgoff_tpos;
71+
pgoff_tfileLen;
7272
ArchiveHandle*AH;
7373
}TAR_MEMBER;
7474

7575
/*
7676
* Maximum file size for a tar member: The limit inherent in the
7777
* format is 2^33-1 bytes (nearly 8 GB). But we don't want to exceed
78-
* what we can represent by anoff_t.
78+
* what we can represent by anpgoff_t.
7979
*/
8080
#ifdefINT64_IS_BUSTED
8181
#defineMAX_TAR_MEMBER_FILELEN INT_MAX
8282
#else
83-
#defineMAX_TAR_MEMBER_FILELEN (((int64) 1 << Min(33, sizeof(off_t)*8 - 1)) - 1)
83+
#defineMAX_TAR_MEMBER_FILELEN (((int64) 1 << Min(33, sizeof(pgoff_t)*8 - 1)) - 1)
8484
#endif
8585

8686
typedefstruct
8787
{
8888
inthasSeek;
89-
off_tfilePos;
89+
pgoff_tfilePos;
9090
TAR_MEMBER*blobToc;
9191
FILE*tarFH;
92-
off_ttarFHpos;
93-
off_ttarNextMember;
92+
pgoff_ttarFHpos;
93+
pgoff_ttarNextMember;
9494
TAR_MEMBER*FH;
9595
intisSpecialScript;
9696
TAR_MEMBER*scriptTH;
@@ -1048,7 +1048,7 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10481048
FILE*tmp=th->tmpFH;/* Grab it for convenience */
10491049
charbuf[32768];
10501050
size_tcnt;
1051-
off_tlen=0;
1051+
pgoff_tlen=0;
10521052
size_tres;
10531053
size_ti,
10541054
pad;
@@ -1061,7 +1061,7 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10611061

10621062
/*
10631063
* Some compilers with throw a warning knowing this test can never be true
1064-
* becauseoff_t can't exceed the compared maximum.
1064+
* becausepgoff_t can't exceed the compared maximum.
10651065
*/
10661066
if (th->fileLen>MAX_TAR_MEMBER_FILELEN)
10671067
die_horribly(AH,modulename,"archive member too large for tar format\n");
@@ -1197,7 +1197,7 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
11971197
chk;
11981198
size_tlen;
11991199
unsigned longullen;
1200-
off_thPos;
1200+
pgoff_thPos;
12011201
boolgotBlock= false;
12021202

12031203
while (!gotBlock)

‎src/bin/pg_dump/pg_dump.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.132 2007/01/23 17:54:50 tgl Exp $
9+
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump.h,v 1.133 2007/02/19 15:05:06 mha Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -16,6 +16,24 @@
1616

1717
#include"postgres_fe.h"
1818

19+
/*
20+
* WIN32 does not provide 64-bit off_t, but does provide the functions operating
21+
* with 64-bit offsets.
22+
*/
23+
#ifdefWIN32
24+
#definepgoff_t __int64
25+
#undef fseeko
26+
#undef ftello
27+
#ifdefWIN32_ONLY_COMPILER
28+
#definefseeko(stream,offset,origin) _fseeki64(stream, offset, origin)
29+
#defineftello(stream) _ftelli64(stream)
30+
#else
31+
#definefseeko(stream,offset,origin) fseeko64(stream, offset, origin)
32+
#defineftello(stream) ftello64(stream)
33+
#endif
34+
#else
35+
#definepgoff_t off_t
36+
#endif
1937

2038
/*
2139
* pg_dump uses two different mechanisms for identifying database objects:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp