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

Commit1ef62bb

Browse files
committed
- Fix compiler warning in pg_restore
- Fix handling of {data/schema}-only restores when using a full backup file; prior version was restoring schema in data-only restores. Added enum to make code easier to understand.
1 parent7cc8af5 commit1ef62bb

File tree

3 files changed

+40
-20
lines changed

3 files changed

+40
-20
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 34 additions & 17 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.35 2001/10/2505:49:52 momjian Exp $
18+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.36 2001/11/04 04:05:36 pjw Exp $
1919
*
2020
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2121
*
@@ -57,6 +57,11 @@
5757
* - Make allowance for data entries that did not have a data dumper
5858
*routine (eg. SEQUENCE SET)
5959
*
60+
* Modifications - 01-Nov-2001 - pjw@rhyme.com.au
61+
* - Fix handling of {data/schema}-only restores when using a full
62+
* backup file; prior version was restoring schema in data-only
63+
*restores. Added enum to make code easier to understand.
64+
*
6065
*-------------------------------------------------------------------------
6166
*/
6267

@@ -70,6 +75,12 @@
7075
#include"pqexpbuffer.h"
7176
#include"libpq/libpq-fs.h"
7277

78+
typedefenum_teReqs_ {
79+
REQ_SCHEMA=1,
80+
REQ_DATA=2,
81+
REQ_ALL=REQ_SCHEMA+REQ_DATA
82+
}teReqs;
83+
7384
staticvoid_SortToc(ArchiveHandle*AH,TocSortCompareFnfn);
7485
staticint_tocSortCompareByOIDNum(constvoid*p1,constvoid*p2);
7586
staticint_tocSortCompareByIDNum(constvoid*p1,constvoid*p2);
@@ -80,7 +91,7 @@ static int_printTocEntry(ArchiveHandle *AH, TocEntry *te, RestoreOptions *ropt,
8091
staticvoid_reconnectAsOwner(ArchiveHandle*AH,constchar*dbname,TocEntry*te);
8192
staticvoid_reconnectAsUser(ArchiveHandle*AH,constchar*dbname,constchar*user);
8293

83-
staticint_tocEntryRequired(TocEntry*te,RestoreOptions*ropt);
94+
staticteReqs_tocEntryRequired(TocEntry*te,RestoreOptions*ropt);
8495
staticvoid_disableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
8596
staticvoid_enableTriggersIfNecessary(ArchiveHandle*AH,TocEntry*te,RestoreOptions*ropt);
8697
staticTocEntry*_getTocEntry(ArchiveHandle*AH,intid);
@@ -155,7 +166,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
155166
{
156167
ArchiveHandle*AH= (ArchiveHandle*)AHX;
157168
TocEntry*te=AH->toc->next;
158-
intreqs;
169+
teReqsreqs;
159170
OutputContextsav;
160171
intimpliedDataOnly;
161172
booldefnDumped;
@@ -221,7 +232,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
221232
while (te!=AH->toc)
222233
{
223234
reqs=_tocEntryRequired(te,ropt);
224-
if ((reqs&1)!=0)
235+
if ((reqs&REQ_SCHEMA)!=0)
225236
{/* It's schema, and it's wanted */
226237
impliedDataOnly=0;
227238
break;
@@ -258,7 +269,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
258269
while (te!=AH->toc)
259270
{
260271
reqs=_tocEntryRequired(te,ropt);
261-
if (((reqs&1)!=0)&&te->dropStmt)
272+
if (((reqs&REQ_SCHEMA)!=0)&&te->dropStmt)
262273
{
263274
/* We want the schema */
264275
ahlog(AH,1,"dropping %s %s\n",te->desc,te->name);
@@ -292,7 +303,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
292303

293304
defnDumped= false;
294305

295-
if ((reqs&1)!=0)/* We want the schema */
306+
if ((reqs&REQ_SCHEMA)!=0)/* We want the schema */
296307
{
297308
/* Reconnect if necessary */
298309
_reconnectAsOwner(AH,NULL,te);
@@ -312,7 +323,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
312323
/*
313324
* If we have a data component, then process it
314325
*/
315-
if ((reqs&2)!=0)
326+
if ((reqs&REQ_DATA)!=0)
316327
{
317328
/*
318329
* hadDumper will be set if there is genuine data component
@@ -325,7 +336,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
325336
/*
326337
* If we can output the data, then restore it.
327338
*/
328-
if (AH->PrintTocDataPtr!=NULL&& (reqs&2)!=0)
339+
if (AH->PrintTocDataPtr!=NULL&& (reqs&REQ_DATA)!=0)
329340
{
330341
#ifndefHAVE_LIBZ
331342
if (AH->compression!=0)
@@ -415,7 +426,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
415426

416427
reqs=_tocEntryRequired(te,ropt);
417428

418-
if ((reqs&2)!=0)/* We loaded the data */
429+
if ((reqs&REQ_DATA)!=0)/* We loaded the data */
419430
{
420431
ahlog(AH,1,"fixing up large object cross-reference for %s\n",te->name);
421432
FixupBlobRefs(AH,te->name);
@@ -1840,10 +1851,10 @@ ReadToc(ArchiveHandle *AH)
18401851
}
18411852
}
18421853

1843-
staticint
1854+
staticteReqs
18441855
_tocEntryRequired(TocEntry*te,RestoreOptions*ropt)
18451856
{
1846-
intres=3;/* Schema = 1, Data = 2, Both = 3 */
1857+
teReqsres=3;/* Schema = 1, Data = 2, Both = 3 */
18471858

18481859
/* If it's an ACL, maybe ignore it */
18491860
if (ropt->aclsSkip&&strcmp(te->desc,"ACL")==0)
@@ -1887,21 +1898,27 @@ _tocEntryRequired(TocEntry *te, RestoreOptions *ropt)
18871898
return0;
18881899
}
18891900

1890-
/* Special Case: If 'SEQUENCE SET' then it is considered a data entry */
1891-
if (strcmp(te->desc,"SEQUENCE SET")==0)
1892-
res=res&2;
1901+
/* Check if we had a dataDumper. Indicates if the entry is schema or data */
1902+
if (!te->hadDumper) {
1903+
/* Special Case: If 'SEQUENCE SET' then it is considered a data entry */
1904+
if (strcmp(te->desc,"SEQUENCE SET")==0) {
1905+
res=res&REQ_DATA;
1906+
}else {
1907+
res=res& ~REQ_DATA;
1908+
}
1909+
}
18931910

18941911
/* Mask it if we only want schema */
18951912
if (ropt->schemaOnly)
1896-
res=res&1;
1913+
res=res&REQ_SCHEMA;
18971914

18981915
/* Mask it we only want data */
18991916
if (ropt->dataOnly)
1900-
res=res&2;
1917+
res=res&REQ_DATA;
19011918

19021919
/* Mask it if we don't have a schema contribition */
19031920
if (!te->defn||strlen(te->defn)==0)
1904-
res=res&2;
1921+
res=res&~REQ_SCHEMA;
19051922

19061923
/* Finally, if we used a list, limit based on that as well */
19071924
if (ropt->limitToList&& !ropt->idWanted[te->id-1])

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 2 additions & 2 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.39 2001/10/28 06:25:58 momjian Exp $
20+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.h,v 1.40 2001/11/04 04:05:36 pjw Exp $
2121
*
2222
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
2323
*-Initial version.
@@ -68,7 +68,7 @@ typedef z_stream *z_streamp;
6868

6969
#defineK_VERS_MAJOR 1
7070
#defineK_VERS_MINOR 5
71-
#defineK_VERS_REV6
71+
#defineK_VERS_REV7
7272

7373
/* Data block types */
7474
#defineBLK_DATA 1

‎src/bin/pg_dump/pg_restore.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
*
3636
* IDENTIFICATION
37-
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.27 2001/10/2505:49:53 momjian Exp $
37+
*$Header: /cvsroot/pgsql/src/bin/pg_dump/pg_restore.c,v 1.28 2001/11/04 04:05:36 pjw Exp $
3838
*
3939
* Modifications - 28-Jun-2000 - pjw@rhyme.com.au
4040
*
@@ -67,6 +67,9 @@
6767
#include<termios.h>
6868
#endif
6969

70+
/* FreeBSD 4.3 seems to put getopt in unistd.h */
71+
#include<unistd.h>
72+
7073
#ifdefHAVE_GETOPT_H
7174
#include<getopt.h>
7275
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp