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

Commit6faf802

Browse files
committed
Enable large file support.
Use off_t and size_t in pg_dump to handle file offset arithmetic correctly.
1 parent0d6f613 commit6faf802

File tree

14 files changed

+724
-247
lines changed

14 files changed

+724
-247
lines changed

‎configure‎

Lines changed: 467 additions & 0 deletions
Large diffs are not rendered by default.

‎configure.in‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $Header: /cvsroot/pgsql/configure.in,v 1.194 2002/07/27 20:10:03 petere Exp $
2+
dnl $Header: /cvsroot/pgsql/configure.in,v 1.195 2002/08/20 17:54:43 petere Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -971,6 +971,8 @@ AC_CHECK_FUNCS(atexit, [],
971971
[AC_CHECK_FUNCS(on_exit, [],
972972
[AC_MSG_ERROR([neither atexit() nor on_exit() found])])])
973973

974+
AC_FUNC_FSEEKO
975+
974976

975977
# This test makes sure that run tests work at all. Sometimes a shared
976978
# 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>])
11591161

11601162

11611163
PGAC_FUNC_POSIX_SIGNALS
1164+
if test $ac_cv_func_fseeko = yes; then
1165+
AC_SYS_LARGEFILE
1166+
fi
11621167

11631168

11641169
# Select semaphore implementation type.

‎doc/src/sgml/release.sgml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.148 2002/08/19 19:33:34 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.149 2002/08/20 17:54:44 petere Exp $
33
-->
44

55
<appendix id="release">
@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
2424
worries about funny characters.
2525
-->
2626
<literallayout><![CDATA[
27+
Files larger than 2 GB are now supported (if supported by the operating system)
2728
SERIAL no longer implies UNIQUE; specify explicitly if index is wanted
2829
pg_dump -n and -N options have been removed. The new behavior is like -n but knows about key words.
2930
CLUSTER is no longer hazardous to your schema

‎src/bin/pg_dump/pg_backup.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.21 2002/08/18 09:36:25 petere Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup.h,v 1.22 2002/08/20 17:54:44 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -144,7 +144,7 @@ extern void ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
144144
DataDumperPtrdumpFn,void*dumpArg);
145145

146146
/* Called to write *data* to the archive */
147-
externintWriteData(Archive*AH,constvoid*data,intdLen);
147+
externsize_tWriteData(Archive*AH,constvoid*data,size_tdLen);
148148

149149
/*
150150
extern intStartBlobs(Archive* AH);

‎src/bin/pg_dump/pg_backup_archiver.c‎

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.54 2002/08/18 09:36:25 petere Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.55 2002/08/20 17:54:44 petere Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -581,8 +581,8 @@ _enableTriggersIfNecessary(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt
581581
*/
582582

583583
/* Public */
584-
int
585-
WriteData(Archive*AHX,constvoid*data,intdLen)
584+
size_t
585+
WriteData(Archive*AHX,constvoid*data,size_tdLen)
586586
{
587587
ArchiveHandle*AH= (ArchiveHandle*)AHX;
588588

@@ -646,7 +646,7 @@ ArchiveEntry(Archive *AHX, const char *oid, const char *tag,
646646
(*AH->ArchiveEntryPtr) (AH,newToc);
647647

648648
/*
649-
* printf("New toc owned by '%s', oid %d\n", newToc->owner,
649+
* printf("New toc owned by '%s', oid %u\n", newToc->owner,
650650
* newToc->oidVal);
651651
*/
652652
}
@@ -814,15 +814,15 @@ EndRestoreBlob(ArchiveHandle *AH, Oid oid)
814814
if (AH->lo_buf_used>0)
815815
{
816816
/* Write remaining bytes from the LO buffer */
817-
intres;
817+
size_tres;
818818

819819
res=lo_write(AH->connection,AH->loFd, (void*)AH->lo_buf,AH->lo_buf_used);
820820

821-
ahlog(AH,5,"wrote remaining %d bytes of large object data (result = %d)\n",
822-
(int)AH->lo_buf_used,res);
821+
ahlog(AH,5,"wrote remaining %lu bytes of large object data (result = %lu)\n",
822+
(unsigned long)AH->lo_buf_used, (unsigned long)res);
823823
if (res!=AH->lo_buf_used)
824-
die_horribly(AH,modulename,"could not write to large object (result: %d, expected: %d)\n",
825-
res,AH->lo_buf_used);
824+
die_horribly(AH,modulename,"could not write to large object (result: %lu, expected: %lu)\n",
825+
(unsigned long)res, (unsigned long)AH->lo_buf_used);
826826
AH->lo_buf_used=0;
827827
}
828828

@@ -1202,31 +1202,35 @@ RestoringToDB(ArchiveHandle *AH)
12021202
int
12031203
ahwrite(constvoid*ptr,size_tsize,size_tnmemb,ArchiveHandle*AH)
12041204
{
1205-
intres;
1205+
size_tres;
12061206

12071207
if (AH->writingBlob)
12081208
{
1209-
if(AH->lo_buf_used+size*nmemb>AH->lo_buf_size) {
1210-
/* Split LO buffer */
1211-
intremaining=AH->lo_buf_size-AH->lo_buf_used;
1212-
intslack=nmemb*size-remaining;
1213-
1214-
memcpy((char*)AH->lo_buf+AH->lo_buf_used,ptr,remaining);
1215-
res=lo_write(AH->connection,AH->loFd,AH->lo_buf,AH->lo_buf_size);
1216-
ahlog(AH,5,"wrote %d bytes of large object data (result = %d)\n",
1217-
AH->lo_buf_size,res);
1218-
if (res!=AH->lo_buf_size)
1219-
die_horribly(AH,modulename,"could not write to large object (result: %d, expected: %d)\n",
1220-
res,AH->lo_buf_size);
1221-
memcpy(AH->lo_buf, (char*)ptr+remaining,slack);
1222-
AH->lo_buf_used=slack;
1223-
}else {
1224-
/* LO Buffer is still large enough, buffer it */
1225-
memcpy((char*)AH->lo_buf+AH->lo_buf_used,ptr,size*nmemb);
1226-
AH->lo_buf_used+=size*nmemb;
1227-
}
1228-
1229-
returnsize*nmemb;
1209+
if (AH->lo_buf_used+size*nmemb>AH->lo_buf_size)
1210+
{
1211+
/* Split LO buffer */
1212+
size_tremaining=AH->lo_buf_size-AH->lo_buf_used;
1213+
size_tslack=nmemb*size-remaining;
1214+
1215+
memcpy((char*)AH->lo_buf+AH->lo_buf_used,ptr,remaining);
1216+
res=lo_write(AH->connection,AH->loFd,AH->lo_buf,AH->lo_buf_size);
1217+
ahlog(AH,5,"wrote %lu bytes of large object data (result = %lu)\n",
1218+
(unsigned long)AH->lo_buf_size, (unsigned long)res);
1219+
if (res!=AH->lo_buf_size)
1220+
die_horribly(AH,modulename,
1221+
"could not write to large object (result: %lu, expected: %lu)\n",
1222+
(unsigned long)res, (unsigned long)AH->lo_buf_size);
1223+
memcpy(AH->lo_buf, (char*)ptr+remaining,slack);
1224+
AH->lo_buf_used=slack;
1225+
}
1226+
else
1227+
{
1228+
/* LO Buffer is still large enough, buffer it */
1229+
memcpy((char*)AH->lo_buf+AH->lo_buf_used,ptr,size*nmemb);
1230+
AH->lo_buf_used+=size*nmemb;
1231+
}
1232+
1233+
returnsize*nmemb;
12301234
}
12311235
elseif (AH->gzOut)
12321236
{
@@ -1255,8 +1259,8 @@ ahwrite(const void *ptr, size_t size, size_t nmemb, ArchiveHandle *AH)
12551259
{
12561260
res=fwrite((void*)ptr,size,nmemb,AH->OF);
12571261
if (res!=nmemb)
1258-
die_horribly(AH,modulename,"could not write to output file (%d != %d)\n",
1259-
res, (int)nmemb);
1262+
die_horribly(AH,modulename,"could not write to output file (%lu != %lu)\n",
1263+
(unsigned long)res, (unsigned long)nmemb);
12601264
returnres;
12611265
}
12621266
}
@@ -1376,7 +1380,7 @@ TocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt)
13761380
return_tocEntryRequired(te,ropt);
13771381
}
13781382

1379-
int
1383+
size_t
13801384
WriteInt(ArchiveHandle*AH,inti)
13811385
{
13821386
intb;
@@ -1434,10 +1438,10 @@ ReadInt(ArchiveHandle *AH)
14341438
returnres;
14351439
}
14361440

1437-
int
1441+
size_t
14381442
WriteStr(ArchiveHandle*AH,constchar*c)
14391443
{
1440-
intres;
1444+
size_tres;
14411445

14421446
if (c)
14431447
{
@@ -1477,7 +1481,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
14771481
{
14781482
FILE*fh;
14791483
charsig[6];/* More than enough */
1480-
intcnt;
1484+
size_tcnt;
14811485
intwantClose=0;
14821486

14831487
#if0
@@ -1510,7 +1514,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
15101514
if (ferror(fh))
15111515
die_horribly(AH,modulename,"could not read input file: %s\n",strerror(errno));
15121516
else
1513-
die_horribly(AH,modulename,"input file is too short (read %d, expected 5)\n",cnt);
1517+
die_horribly(AH,modulename,"input file is too short (read %lu, expected 5)\n",
1518+
(unsigned long)cnt);
15141519
}
15151520

15161521
/* Save it, just in case we need it later */
@@ -1563,7 +1568,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
15631568
}
15641569

15651570
/* If we can't seek, then mark the header as read */
1566-
if (fseek(fh,0,SEEK_SET)!=0)
1571+
if (fseeko(fh,0,SEEK_SET)!=0)
15671572
{
15681573
/*
15691574
* NOTE: Formats that use the looahead buffer can unset this in
@@ -1575,7 +1580,8 @@ _discoverArchiveFormat(ArchiveHandle *AH)
15751580
AH->lookaheadLen=0;/* Don't bother since we've reset the file */
15761581

15771582
#if0
1578-
write_msg(modulename,"read %d bytes into lookahead buffer\n",AH->lookaheadLen);
1583+
write_msg(modulename,"read %lu bytes into lookahead buffer\n",
1584+
(unsigned long)AH->lookaheadLen);
15791585
#endif
15801586

15811587
/* Close the file */
@@ -2305,7 +2311,8 @@ ReadHead(ArchiveHandle *AH)
23052311

23062312
AH->intSize= (*AH->ReadBytePtr) (AH);
23072313
if (AH->intSize>32)
2308-
die_horribly(AH,modulename,"sanity check on integer size (%d) failed\n",AH->intSize);
2314+
die_horribly(AH,modulename,"sanity check on integer size (%lu) failed\n",
2315+
(unsigned long)AH->intSize);
23092316

23102317
if (AH->intSize>sizeof(int))
23112318
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)
23682375
for (i=0;i <=AH->tocCount+1;i++)
23692376
{
23702377
/*
2371-
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
2378+
* printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
23722379
* te->oidVal);
23732380
*/
23742381
tea[i]=te;
@@ -2390,7 +2397,7 @@ _SortToc(ArchiveHandle *AH, TocSortCompareFn fn)
23902397
for (i=0;i <=AH->tocCount+1;i++)
23912398
{
23922399
/*
2393-
* printf("%d: %x (%x, %x) - %d\n", i, te, te->prev, te->next,
2400+
* printf("%d: %x (%x, %x) - %u\n", i, te, te->prev, te->next,
23942401
* te->oidVal);
23952402
*/
23962403
te=te->next;
@@ -2410,7 +2417,7 @@ _tocSortCompareByOIDNum(const void *p1, const void *p2)
24102417
Oidid2=te2->maxOidVal;
24112418
intcmpval;
24122419

2413-
/* printf("Comparing %d to %d\n", id1, id2); */
2420+
/* printf("Comparing %u to %u\n", id1, id2); */
24142421

24152422
cmpval=oidcmp(id1,id2);
24162423

‎src/bin/pg_dump/pg_backup_archiver.h‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
*
1919
* IDENTIFICATION
20-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.45 2002/08/10 16:57:31 petere Exp $
20+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.46 2002/08/20 17:54:44 petere Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -48,8 +48,8 @@ typedef struct _z_stream
4848
{
4949
void*next_in;
5050
void*next_out;
51-
intavail_in;
52-
intavail_out;
51+
size_tavail_in;
52+
size_tavail_out;
5353
}z_stream;
5454
typedefz_stream*z_streamp;
5555
#endif
@@ -86,7 +86,7 @@ typedef void (*ClosePtr) (struct _archiveHandle * AH);
8686
typedefvoid (*ArchiveEntryPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
8787

8888
typedefvoid (*StartDataPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
89-
typedefint (*WriteDataPtr) (struct_archiveHandle*AH,constvoid*data,intdLen);
89+
typedefsize_t (*WriteDataPtr) (struct_archiveHandle*AH,constvoid*data,size_tdLen);
9090
typedefvoid (*EndDataPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
9191

9292
typedefvoid (*StartBlobsPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
@@ -96,15 +96,15 @@ typedef void (*EndBlobsPtr) (struct _archiveHandle * AH, struct _tocEntry * te);
9696

9797
typedefint (*WriteBytePtr) (struct_archiveHandle*AH,constinti);
9898
typedefint (*ReadBytePtr) (struct_archiveHandle*AH);
99-
typedefint (*WriteBufPtr) (struct_archiveHandle*AH,constvoid*c,intlen);
100-
typedefint (*ReadBufPtr) (struct_archiveHandle*AH,void*buf,intlen);
99+
typedefsize_t (*WriteBufPtr) (struct_archiveHandle*AH,constvoid*c,size_tlen);
100+
typedefsize_t (*ReadBufPtr) (struct_archiveHandle*AH,void*buf,size_tlen);
101101
typedefvoid (*SaveArchivePtr) (struct_archiveHandle*AH);
102102
typedefvoid (*WriteExtraTocPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
103103
typedefvoid (*ReadExtraTocPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
104104
typedefvoid (*PrintExtraTocPtr) (struct_archiveHandle*AH,struct_tocEntry*te);
105105
typedefvoid (*PrintTocDataPtr) (struct_archiveHandle*AH,struct_tocEntry*te,RestoreOptions*ropt);
106106

107-
typedefint (*CustomOutPtr) (struct_archiveHandle*AH,constvoid*buf,intlen);
107+
typedefsize_t (*CustomOutPtr) (struct_archiveHandle*AH,constvoid*buf,size_tlen);
108108

109109
typedefint (*TocSortCompareFn) (constvoid*te1,constvoid*te2);
110110

@@ -147,7 +147,7 @@ typedef struct _archiveHandle
147147

148148
intdebugLevel;/* Used for logging (currently only by
149149
* --verbose) */
150-
intintSize;/* Size of an integer in the archive */
150+
size_tintSize;/* Size of an integer in the archive */
151151
ArchiveFormatformat;/* Archive format */
152152

153153
sqlparseInfosqlparse;
@@ -163,9 +163,9 @@ typedef struct _archiveHandle
163163
* already */
164164
char*lookahead;/* Buffer used when reading header to
165165
* discover format */
166-
intlookaheadSize;/* Size of allocated buffer */
167-
intlookaheadLen;/* Length of data in lookahead */
168-
intlookaheadPos;/* Current read position in lookahead
166+
size_tlookaheadSize;/* Size of allocated buffer */
167+
size_tlookaheadLen;/* Length of data in lookahead */
168+
off_tlookaheadPos;/* Current read position in lookahead
169169
* buffer */
170170

171171
ArchiveEntryPtrArchiveEntryPtr;/* Called for each metadata object */
@@ -230,8 +230,8 @@ typedef struct _archiveHandle
230230
RestoreOptions*ropt;/* Used to check restore options in
231231
* ahwrite etc */
232232
void*lo_buf;
233-
intlo_buf_used;
234-
intlo_buf_size;
233+
size_tlo_buf_used;
234+
size_tlo_buf_size;
235235
}ArchiveHandle;
236236

237237
typedefstruct_tocEntry
@@ -282,10 +282,10 @@ extern intTocIDRequired(ArchiveHandle *AH, int id, RestoreOptions *ropt);
282282
* Mandatory routines for each supported format
283283
*/
284284

285-
externintWriteInt(ArchiveHandle*AH,inti);
285+
externsize_tWriteInt(ArchiveHandle*AH,inti);
286286
externintReadInt(ArchiveHandle*AH);
287287
externchar*ReadStr(ArchiveHandle*AH);
288-
externintWriteStr(ArchiveHandle*AH,constchar*s);
288+
externsize_tWriteStr(ArchiveHandle*AH,constchar*s);
289289

290290
externvoidStartRestoreBlobs(ArchiveHandle*AH);
291291
externvoidStartRestoreBlob(ArchiveHandle*AH,Oidoid);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp