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

Commitfd5437c

Browse files
committed
Fix breakage created by addition of separate 'acl pass' in pg_dump.
Also clean up incredibly poor style in TocIDRequired() usage.
1 parent5ca9687 commitfd5437c

File tree

4 files changed

+28
-30
lines changed

4 files changed

+28
-30
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 15 additions & 24 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.102 2005/01/23 00:03:54 tgl Exp $
18+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.103 2005/01/25 22:44:31 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -27,21 +27,14 @@
2727
#include"dumputils.h"
2828

2929
#include<ctype.h>
30-
#include<errno.h>
3130
#include<unistd.h>
3231

3332
#include"pqexpbuffer.h"
3433
#include"libpq/libpq-fs.h"
3534

3635

37-
typedefenum_teReqs_
38-
{
39-
REQ_SCHEMA=1,
40-
REQ_DATA=2,
41-
REQ_ALL=REQ_SCHEMA+REQ_DATA
42-
}teReqs;
43-
4436
constchar*progname;
37+
4538
staticchar*modulename=gettext_noop("archiver");
4639

4740

@@ -63,7 +56,7 @@ static void _becomeOwner(ArchiveHandle *AH, TocEntry *te);
6356
staticvoid_selectOutputSchema(ArchiveHandle*AH,constchar*schemaName);
6457
staticvoid_selectTablespace(ArchiveHandle*AH,constchar*tablespace);
6558

66-
staticteReqs_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolacl_pass);
59+
staticteReqs_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolinclude_acls);
6760
staticvoid_disableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
6861
staticvoid_enableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
6962
staticTocEntry*getTocEntryByDumpId(ArchiveHandle*AH,DumpIdid);
@@ -135,7 +128,6 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
135128
TocEntry*te=AH->toc->next;
136129
teReqsreqs;
137130
OutputContextsav;
138-
intimpliedDataOnly;
139131
booldefnDumped;
140132

141133
AH->ropt=ropt;
@@ -188,17 +180,16 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
188180
*/
189181
if (!ropt->dataOnly)
190182
{
191-
te=AH->toc->next;
192-
impliedDataOnly=1;
193-
while (te!=AH->toc)
183+
intimpliedDataOnly=1;
184+
185+
for (te=AH->toc->next;te!=AH->toc;te=te->next)
194186
{
195-
reqs=_tocEntryRequired(te,ropt,false);
187+
reqs=_tocEntryRequired(te,ropt,true);
196188
if ((reqs&REQ_SCHEMA)!=0)
197189
{/* It's schema, and it's wanted */
198190
impliedDataOnly=0;
199191
break;
200192
}
201-
te=te->next;
202193
}
203194
if (impliedDataOnly)
204195
{
@@ -232,7 +223,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
232223

233224
while (te!=AH->toc)
234225
{
235-
reqs=_tocEntryRequired(te,ropt, false);
226+
reqs=_tocEntryRequired(te,ropt, false/* needn't drop ACLs */);
236227
if (((reqs&REQ_SCHEMA)!=0)&&te->dropStmt)
237228
{
238229
/* We want the schema */
@@ -248,7 +239,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
248239
}
249240

250241
/*
251-
* Now process each TOC entry
242+
* Now process eachnon-ACLTOC entry
252243
*/
253244
te=AH->toc->next;
254245
while (te!=AH->toc)
@@ -709,7 +700,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
709700

710701
while (te!=AH->toc)
711702
{
712-
if (_tocEntryRequired(te,ropt,false)!=0)
703+
if (_tocEntryRequired(te,ropt,true)!=0)
713704
ahprintf(AH,"%d; %u %u %s %s %s %s\n",te->dumpId,
714705
te->catalogId.tableoid,te->catalogId.oid,
715706
te->desc,te->namespace ?te->namespace :"-",
@@ -1341,15 +1332,15 @@ getTocEntryByDumpId(ArchiveHandle *AH, DumpId id)
13411332
returnNULL;
13421333
}
13431334

1344-
int
1335+
teReqs
13451336
TocIDRequired(ArchiveHandle*AH,DumpIdid,RestoreOptions*ropt)
13461337
{
13471338
TocEntry*te=getTocEntryByDumpId(AH,id);
13481339

13491340
if (!te)
13501341
return0;
13511342

1352-
return_tocEntryRequired(te,ropt,false);
1343+
return_tocEntryRequired(te,ropt,true);
13531344
}
13541345

13551346
size_t
@@ -1971,16 +1962,16 @@ ReadToc(ArchiveHandle *AH)
19711962
}
19721963

19731964
staticteReqs
1974-
_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolacl_pass)
1965+
_tocEntryRequired(TocEntry*te,RestoreOptions*ropt,boolinclude_acls)
19751966
{
1976-
teReqsres=3;/* Schema = 1, Data = 2, Both = 3 */
1967+
teReqsres=REQ_ALL;
19771968

19781969
/* ENCODING objects are dumped specially, so always reject here */
19791970
if (strcmp(te->desc,"ENCODING")==0)
19801971
return0;
19811972

19821973
/* If it's an ACL, maybe ignore it */
1983-
if ((!acl_pass||ropt->aclsSkip)&&strcmp(te->desc,"ACL")==0)
1974+
if ((!include_acls||ropt->aclsSkip)&&strcmp(te->desc,"ACL")==0)
19841975
return0;
19851976

19861977
if (!ropt->create&&strcmp(te->desc,"DATABASE")==0)

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 9 additions & 2 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.62 2004/11/06 19:36:01 tgl Exp $
20+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.63 2005/01/25 22:44:31 tgl Exp $
2121
*
2222
*-------------------------------------------------------------------------
2323
*/
@@ -164,6 +164,13 @@ typedef enum
164164
STAGE_FINALIZING
165165
}ArchiverStage;
166166

167+
typedefenum
168+
{
169+
REQ_SCHEMA=1,
170+
REQ_DATA=2,
171+
REQ_ALL=REQ_SCHEMA+REQ_DATA
172+
}teReqs;
173+
167174
typedefstruct_archiveHandle
168175
{
169176
Archivepublic;/* Public part of archive */
@@ -321,7 +328,7 @@ extern void WriteToc(ArchiveHandle *AH);
321328
externvoidReadToc(ArchiveHandle*AH);
322329
externvoidWriteDataChunks(ArchiveHandle*AH);
323330

324-
externintTocIDRequired(ArchiveHandle*AH,DumpIdid,RestoreOptions*ropt);
331+
externteReqsTocIDRequired(ArchiveHandle*AH,DumpIdid,RestoreOptions*ropt);
325332
externboolcheckSeek(FILE*fp);
326333

327334
/*

‎src/bin/pg_dump/pg_backup_custom.c

Lines changed: 2 additions & 2 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.29 2004/03/03 21:28:54 tgl Exp $
22+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.30 2005/01/25 22:44:31 tgl Exp $
2323
*
2424
*-------------------------------------------------------------------------
2525
*/
@@ -442,7 +442,7 @@ _PrintTocData(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt)
442442

443443
while (id!=te->dumpId)
444444
{
445-
if ((TocIDRequired(AH,id,ropt)&2)!=0)
445+
if ((TocIDRequired(AH,id,ropt)&REQ_DATA)!=0)
446446
die_horribly(AH,modulename,
447447
"Dumping a specific TOC data block out of order is not supported"
448448
" without ID on this input stream (fseek required)\n");

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 2 additions & 2 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.46 2004/11/29 03:01:54 momjian Exp $
19+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.47 2005/01/25 22:44:31 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -1120,7 +1120,7 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
11201120
ahlog(AH,4,"skipping tar member %s\n",th->targetFile);
11211121

11221122
id=atoi(th->targetFile);
1123-
if ((TocIDRequired(AH,id,AH->ropt)&2)!=0)
1123+
if ((TocIDRequired(AH,id,AH->ropt)&REQ_DATA)!=0)
11241124
die_horribly(AH,modulename,"dumping data out of order is not supported in this archive format: "
11251125
"%s is required, but comes before %s in the archive file.\n",
11261126
th->targetFile,filename);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp