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

Commitfc5c577

Browse files
committed
Allow fseeko in pg_dump only if fseeko() will work for all supported file
sizes.
1 parent2908a83 commitfc5c577

File tree

6 files changed

+41
-13
lines changed

6 files changed

+41
-13
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.71 2002/10/09 16:20:25 momjian Exp $
14+
* $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.72 2002/10/25 01:33:17 momjian Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -290,7 +290,7 @@ flagInhAttrs(TableInfo *tblinfo, int numTables,
290290
* attr with the same name, then only dump it if:
291291
*
292292
* - it is NOT NULL and zero parents are NOT NULL
293-
* OR
293+
* OR
294294
* - it has a default value AND the default value does not match
295295
* all parent default values, or no parents specify a default.
296296
*

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 27 additions & 1 deletion
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.59 2002/10/22 19:15:23 momjian Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.60 2002/10/25 01:33:17 momjian Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -2338,6 +2338,32 @@ ReadHead(ArchiveHandle *AH)
23382338
}
23392339

23402340

2341+
/*
2342+
* checkSeek
2343+
* check to see if fseek can be performed.
2344+
*/
2345+
2346+
bool
2347+
checkSeek(FILE*fp)
2348+
{
2349+
2350+
if (fseek(fp,0,SEEK_CUR)!=0)
2351+
return false;
2352+
elseif (sizeof(off_t)>sizeof(long))
2353+
/*
2354+
*At this point, off_t is too large for long, so we return
2355+
*based on whether an off_t version of fseek is available.
2356+
*/
2357+
#ifdefHAVE_FSEEKO
2358+
return true;
2359+
#else
2360+
return false;
2361+
#endif
2362+
else
2363+
returntrue;
2364+
}
2365+
2366+
23412367
staticvoid
23422368
_SortToc(ArchiveHandle*AH,TocSortCompareFnfn)
23432369
{

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 3 additions & 1 deletion
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.48 2002/10/22 19:15:23 momjian Exp $
20+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.49 2002/10/25 01:33:17 momjian Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -27,6 +27,7 @@
2727

2828
#include"postgres_fe.h"
2929

30+
#include<stdio.h>
3031
#include<time.h>
3132
#include<errno.h>
3233

@@ -284,6 +285,7 @@ extern void ReadToc(ArchiveHandle *AH);
284285
externvoidWriteDataChunks(ArchiveHandle*AH);
285286

286287
externintTocIDRequired(ArchiveHandle*AH,intid,RestoreOptions*ropt);
288+
externboolcheckSeek(FILE*fp);
287289

288290
/*
289291
* Mandatory routines for each supported format

‎src/bin/pg_dump/pg_backup_custom.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*
2020
*
2121
* IDENTIFICATION
22-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.22 2002/10/22 19:15:23 momjian Exp $
22+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.23 2002/10/25 01:33:17 momjian Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -179,7 +179,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
179179
if (!AH->FH)
180180
die_horribly(AH,modulename,"could not open archive file %s: %s\n",AH->fSpec,strerror(errno));
181181

182-
ctx->hasSeek=(fseeko(AH->FH,0,SEEK_CUR)==0);
182+
ctx->hasSeek=checkSeek(AH->FH);
183183
}
184184
else
185185
{
@@ -190,7 +190,7 @@ InitArchiveFmt_Custom(ArchiveHandle *AH)
190190
if (!AH->FH)
191191
die_horribly(AH,modulename,"could not open archive file %s: %s\n",AH->fSpec,strerror(errno));
192192

193-
ctx->hasSeek=(fseeko(AH->FH,0,SEEK_CUR)==0);
193+
ctx->hasSeek=checkSeek(AH->FH);
194194

195195
ReadHead(AH);
196196
ReadToc(AH);

‎src/bin/pg_dump/pg_backup_files.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
*
2222
* IDENTIFICATION
23-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.20 2002/10/22 19:15:23 momjian Exp $
23+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.21 2002/10/25 01:33:17 momjian Exp $
2424
*
2525
*-------------------------------------------------------------------------
2626
*/
@@ -129,7 +129,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
129129
if (AH->FH==NULL)
130130
die_horribly(NULL,modulename,"could not open output file: %s\n",strerror(errno));
131131

132-
ctx->hasSeek=(fseeko(AH->FH,0,SEEK_CUR)==0);
132+
ctx->hasSeek=checkSeek(AH->FH);
133133

134134
if (AH->compression<0||AH->compression>9)
135135
AH->compression=Z_DEFAULT_COMPRESSION;
@@ -147,7 +147,7 @@ InitArchiveFmt_Files(ArchiveHandle *AH)
147147
if (AH->FH==NULL)
148148
die_horribly(NULL,modulename,"could not open input file: %s\n",strerror(errno));
149149

150-
ctx->hasSeek=(fseeko(AH->FH,0,SEEK_CUR)==0);
150+
ctx->hasSeek=checkSeek(AH->FH);
151151

152152
ReadHead(AH);
153153
ReadToc(AH);

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.31 2002/10/22 19:15:23 momjian Exp $
19+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.32 2002/10/25 01:33:17 momjian Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -190,7 +190,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
190190
*/
191191
/* setvbuf(ctx->tarFH, NULL, _IONBF, 0); */
192192

193-
ctx->hasSeek=(fseeko(ctx->tarFH,0,SEEK_CUR)==0);
193+
ctx->hasSeek=checkSeek(ctx->tarFH);
194194

195195
if (AH->compression<0||AH->compression>9)
196196
AH->compression=Z_DEFAULT_COMPRESSION;
@@ -227,7 +227,7 @@ InitArchiveFmt_Tar(ArchiveHandle *AH)
227227

228228
ctx->tarFHpos=0;
229229

230-
ctx->hasSeek=(fseeko(ctx->tarFH,0,SEEK_CUR)==0);
230+
ctx->hasSeek=checkSeek(ctx->tarFH);
231231

232232
/*
233233
* Forcibly unmark the header as read since we use the lookahead

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp