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

Commit7fcdb5e

Browse files
committed
pg_dump: store unused attribs as NULL instead of '\0'
Commitf831d4a changed pg_dump to emit (and pg_restore tounderstand) NULLs for unused members in ArchiveEntry structs, as a sideeffect of some code beautification. That broke pg_restore of dumpsgenerated with older pg_dump, however, so it was reverted in19455c9. Since the archiver version number has been bumped in3b925e9, we can put it back.Author: Dmitry DolgovDiscussion:https://postgr.es/m/CA+q6zcXx0XHqLsFJLaUU2j5BDiBAHig=YRoBC_YVq7VJGvzBEA@mail.gmail.com
1 parent60bbf07 commit7fcdb5e

File tree

3 files changed

+16
-58
lines changed

3 files changed

+16
-58
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,10 +1087,10 @@ ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId,
10871087
newToc->namespace=opts->namespace ?pg_strdup(opts->namespace) :NULL;
10881088
newToc->tablespace=opts->tablespace ?pg_strdup(opts->tablespace) :NULL;
10891089
newToc->tableam=opts->tableam ?pg_strdup(opts->tableam) :NULL;
1090-
newToc->owner=pg_strdup(opts->owner);
1090+
newToc->owner=opts->owner ?pg_strdup(opts->owner) :NULL;
10911091
newToc->desc=pg_strdup(opts->description);
1092-
newToc->defn=pg_strdup(opts->createStmt);
1093-
newToc->dropStmt=pg_strdup(opts->dropStmt);
1092+
newToc->defn=opts->createStmt ?pg_strdup(opts->createStmt) :NULL;
1093+
newToc->dropStmt=opts->dropStmt ?pg_strdup(opts->dropStmt) :NULL;
10941094
newToc->copyStmt=opts->copyStmt ?pg_strdup(opts->copyStmt) :NULL;
10951095

10961096
if (opts->nDeps>0)
@@ -3621,7 +3621,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
36213621
}
36223622
else
36233623
{
3624-
if (strlen(te->defn)>0)
3624+
if (te->defn&&strlen(te->defn)>0)
36253625
ahprintf(AH,"%s\n\n",te->defn);
36263626
}
36273627

@@ -3632,7 +3632,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
36323632
* with DROP commands must appear in one list or the other.
36333633
*/
36343634
if (!ropt->noOwner&& !ropt->use_setsessauth&&
3635-
strlen(te->owner)>0&&strlen(te->dropStmt)>0)
3635+
te->owner&&strlen(te->owner)>0&&
3636+
te->dropStmt&&strlen(te->dropStmt)>0)
36363637
{
36373638
if (strcmp(te->desc,"AGGREGATE")==0||
36383639
strcmp(te->desc,"BLOB")==0||

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,7 @@ typedef z_stream *z_streamp;
9696
* behavior */
9797
#defineK_VERS_1_14 MAKE_ARCHIVE_VERSION(1, 14, 0)/* add tableam */
9898

99-
/*
100-
* Current archive version number (the format we can output)
101-
*
102-
* Note: If you update the current archive version, consider
103-
* https://postgr.es/m/20190227123217.GA27552@alvherre.pgsql
104-
*/
99+
/* Current archive version number (the format we can output) */
105100
#defineK_VERS_MAJOR 1
106101
#defineK_VERS_MINOR 14
107102
#defineK_VERS_REV 0

‎src/bin/pg_dump/pg_dump.c

Lines changed: 9 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,8 +2244,6 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
22442244
.owner = tbinfo->rolname,
22452245
.description = "TABLE DATA",
22462246
.section = SECTION_DATA,
2247-
.createStmt = "",
2248-
.dropStmt = "",
22492247
.copyStmt = copyStmt,
22502248
.deps = &(tbinfo->dobj.dumpId),
22512249
.nDeps = 1,
@@ -2300,7 +2298,6 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo)
23002298
.description = "MATERIALIZED VIEW DATA",
23012299
.section = SECTION_POST_DATA,
23022300
.createStmt = q->data,
2303-
.dropStmt = "",
23042301
.deps = tdinfo->dobj.dependencies,
23052302
.nDeps = tdinfo->dobj.nDeps));
23062303

@@ -2865,7 +2862,6 @@ dumpDatabase(Archive *fout)
28652862
.description = "COMMENT",
28662863
.section = SECTION_NONE,
28672864
.createStmt = dbQry->data,
2868-
.dropStmt = "",
28692865
.deps = &dbDumpId,
28702866
.nDeps = 1));
28712867
}
@@ -2895,7 +2891,6 @@ dumpDatabase(Archive *fout)
28952891
.description = "SECURITY LABEL",
28962892
.section = SECTION_NONE,
28972893
.createStmt = seclabelQry->data,
2898-
.dropStmt = "",
28992894
.deps = &dbDumpId,
29002895
.nDeps = 1));
29012896
destroyPQExpBuffer(seclabelQry);
@@ -3012,10 +3007,8 @@ dumpDatabase(Archive *fout)
30123007
ArchiveEntry(fout, nilCatalogId, createDumpId(),
30133008
ARCHIVE_OPTS(.tag = "pg_largeobject",
30143009
.description = "pg_largeobject",
3015-
.owner = "",
30163010
.section = SECTION_PRE_DATA,
3017-
.createStmt = loOutQry->data,
3018-
.dropStmt = ""));
3011+
.createStmt = loOutQry->data));
30193012

30203013
PQclear(lo_res);
30213014

@@ -3122,10 +3115,8 @@ dumpEncoding(Archive *AH)
31223115
ArchiveEntry(AH, nilCatalogId, createDumpId(),
31233116
ARCHIVE_OPTS(.tag = "ENCODING",
31243117
.description = "ENCODING",
3125-
.owner = "",
31263118
.section = SECTION_PRE_DATA,
3127-
.createStmt = qry->data,
3128-
.dropStmt = ""));
3119+
.createStmt = qry->data));
31293120

31303121
destroyPQExpBuffer(qry);
31313122
}
@@ -3149,10 +3140,8 @@ dumpStdStrings(Archive *AH)
31493140
ArchiveEntry(AH, nilCatalogId, createDumpId(),
31503141
ARCHIVE_OPTS(.tag = "STDSTRINGS",
31513142
.description = "STDSTRINGS",
3152-
.owner = "",
31533143
.section = SECTION_PRE_DATA,
3154-
.createStmt = qry->data,
3155-
.dropStmt = ""));
3144+
.createStmt = qry->data));
31563145

31573146
destroyPQExpBuffer(qry);
31583147
}
@@ -3205,10 +3194,8 @@ dumpSearchPath(Archive *AH)
32053194
ArchiveEntry(AH, nilCatalogId, createDumpId(),
32063195
ARCHIVE_OPTS(.tag = "SEARCHPATH",
32073196
.description = "SEARCHPATH",
3208-
.owner = "",
32093197
.section = SECTION_PRE_DATA,
3210-
.createStmt = qry->data,
3211-
.dropStmt = ""));
3198+
.createStmt = qry->data));
32123199

32133200
/* Also save it in AH->searchpath, in case we're doing plain text dump */
32143201
AH->searchpath = pg_strdup(qry->data);
@@ -3684,7 +3671,6 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
36843671
.description = "ROW SECURITY",
36853672
.section = SECTION_POST_DATA,
36863673
.createStmt = query->data,
3687-
.dropStmt = "",
36883674
.deps = &(tbinfo->dobj.dumpId),
36893675
.nDeps = 1));
36903676

@@ -4051,10 +4037,8 @@ dumpPublicationTable(Archive *fout, PublicationRelInfo *pubrinfo)
40514037
ARCHIVE_OPTS(.tag = tag,
40524038
.namespace = tbinfo->dobj.namespace->dobj.name,
40534039
.description = "PUBLICATION TABLE",
4054-
.owner = "",
40554040
.section = SECTION_POST_DATA,
4056-
.createStmt = query->data,
4057-
.dropStmt = ""));
4041+
.createStmt = query->data));
40584042

40594043
free(tag);
40604044
destroyPQExpBuffer(query);
@@ -9502,7 +9486,6 @@ dumpComment(Archive *fout, const char *type, const char *name,
95029486
.description = "COMMENT",
95039487
.section = SECTION_NONE,
95049488
.createStmt = query->data,
9505-
.dropStmt = "",
95069489
.deps = &dumpId,
95079490
.nDeps = 1));
95089491

@@ -9572,7 +9555,6 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
95729555
.description = "COMMENT",
95739556
.section = SECTION_NONE,
95749557
.createStmt = query->data,
9575-
.dropStmt = "",
95769558
.deps = &(tbinfo->dobj.dumpId),
95779559
.nDeps = 1));
95789560
}
@@ -9598,7 +9580,6 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
95989580
.description = "COMMENT",
95999581
.section = SECTION_NONE,
96009582
.createStmt = query->data,
9601-
.dropStmt = "",
96029583
.deps = &(tbinfo->dobj.dumpId),
96039584
.nDeps = 1));
96049585
}
@@ -9879,11 +9860,8 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
98799860
te = ArchiveEntry(fout, dobj->catId, dobj->dumpId,
98809861
ARCHIVE_OPTS(.tag = dobj->name,
98819862
.description = "BLOBS",
9882-
.owner = "",
98839863
.section = SECTION_DATA,
9884-
.dumpFn = dumpBlobs,
9885-
.createStmt = "",
9886-
.dropStmt = ""));
9864+
.dumpFn = dumpBlobs));
98879865

98889866
/*
98899867
* Set the TocEntry's dataLength in case we are doing a
@@ -10088,7 +10066,6 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
1008810066
ArchiveEntry(fout, extinfo->dobj.catId, extinfo->dobj.dumpId,
1008910067
ARCHIVE_OPTS(.tag = extinfo->dobj.name,
1009010068
.description = "EXTENSION",
10091-
.owner = "",
1009210069
.section = SECTION_PRE_DATA,
1009310070
.createStmt = q->data,
1009410071
.dropStmt = delq->data));
@@ -11232,7 +11209,6 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo)
1123211209
.description = "COMMENT",
1123311210
.section = SECTION_NONE,
1123411211
.createStmt = query->data,
11235-
.dropStmt = "",
1123611212
.deps = &(tyinfo->dobj.dumpId),
1123711213
.nDeps = 1));
1123811214
}
@@ -11288,8 +11264,7 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
1128811264
.owner = stinfo->baseType->rolname,
1128911265
.description = "SHELL TYPE",
1129011266
.section = SECTION_PRE_DATA,
11291-
.createStmt = q->data,
11292-
.dropStmt = ""));
11267+
.createStmt = q->data));
1129311268

1129411269
destroyPQExpBuffer(q);
1129511270
}
@@ -12234,7 +12209,6 @@ dumpCast(Archive *fout, CastInfo *cast)
1223412209
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
1223512210
ARCHIVE_OPTS(.tag = labelq->data,
1223612211
.description = "CAST",
12237-
.owner = "",
1223812212
.section = SECTION_PRE_DATA,
1223912213
.createStmt = defqry->data,
1224012214
.dropStmt = delqry->data));
@@ -12362,7 +12336,6 @@ dumpTransform(Archive *fout, TransformInfo *transform)
1236212336
ArchiveEntry(fout, transform->dobj.catId, transform->dobj.dumpId,
1236312337
ARCHIVE_OPTS(.tag = labelq->data,
1236412338
.description = "TRANSFORM",
12365-
.owner = "",
1236612339
.section = SECTION_PRE_DATA,
1236712340
.createStmt = defqry->data,
1236812341
.dropStmt = delqry->data,
@@ -12749,7 +12722,6 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo)
1274912722
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
1275012723
ARCHIVE_OPTS(.tag = aminfo->dobj.name,
1275112724
.description = "ACCESS METHOD",
12752-
.owner = "",
1275312725
.section = SECTION_PRE_DATA,
1275412726
.createStmt = q->data,
1275512727
.dropStmt = delq->data));
@@ -14211,7 +14183,6 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
1421114183
ARCHIVE_OPTS(.tag = prsinfo->dobj.name,
1421214184
.namespace = prsinfo->dobj.namespace->dobj.name,
1421314185
.description = "TEXT SEARCH PARSER",
14214-
.owner = "",
1421514186
.section = SECTION_PRE_DATA,
1421614187
.createStmt = q->data,
1421714188
.dropStmt = delq->data));
@@ -14350,7 +14321,6 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
1435014321
ARCHIVE_OPTS(.tag = tmplinfo->dobj.name,
1435114322
.namespace = tmplinfo->dobj.namespace->dobj.name,
1435214323
.description = "TEXT SEARCH TEMPLATE",
14353-
.owner = "",
1435414324
.section = SECTION_PRE_DATA,
1435514325
.createStmt = q->data,
1435614326
.dropStmt = delq->data));
@@ -14819,8 +14789,7 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
1481914789
.owner = daclinfo->defaclrole,
1482014790
.description = "DEFAULT ACL",
1482114791
.section = SECTION_POST_DATA,
14822-
.createStmt = q->data,
14823-
.dropStmt = ""));
14792+
.createStmt = q->data));
1482414793

1482514794
destroyPQExpBuffer(tag);
1482614795
destroyPQExpBuffer(q);
@@ -14916,7 +14885,6 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
1491614885
.description = "ACL",
1491714886
.section = SECTION_NONE,
1491814887
.createStmt = sql->data,
14919-
.dropStmt = "",
1492014888
.deps = &objDumpId,
1492114889
.nDeps = 1));
1492214890
destroyPQExpBuffer(tag);
@@ -15006,7 +14974,6 @@ dumpSecLabel(Archive *fout, const char *type, const char *name,
1500614974
.description = "SECURITY LABEL",
1500714975
.section = SECTION_NONE,
1500814976
.createStmt = query->data,
15009-
.dropStmt = "",
1501014977
.deps = &dumpId,
1501114978
.nDeps = 1));
1501214979
destroyPQExpBuffer(tag);
@@ -15090,7 +15057,6 @@ dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
1509015057
.description = "SECURITY LABEL",
1509115058
.section = SECTION_NONE,
1509215059
.createStmt = query->data,
15093-
.dropStmt = "",
1509415060
.deps = &(tbinfo->dobj.dumpId),
1509515061
.nDeps = 1));
1509615062
}
@@ -16438,10 +16404,8 @@ dumpIndexAttach(Archive *fout, IndexAttachInfo *attachinfo)
1643816404
ARCHIVE_OPTS(.tag = attachinfo->dobj.name,
1643916405
.namespace = attachinfo->dobj.namespace->dobj.name,
1644016406
.description = "INDEX ATTACH",
16441-
.owner = "",
1644216407
.section = SECTION_POST_DATA,
16443-
.createStmt = q->data,
16444-
.dropStmt = ""));
16408+
.createStmt = q->data));
1644516409

1644616410
destroyPQExpBuffer(q);
1644716411
}
@@ -17071,7 +17035,6 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
1707117035
.description = "SEQUENCE OWNED BY",
1707217036
.section = SECTION_PRE_DATA,
1707317037
.createStmt = query->data,
17074-
.dropStmt = "",
1707517038
.deps = &(tbinfo->dobj.dumpId),
1707617039
.nDeps = 1));
1707717040
}
@@ -17140,7 +17103,6 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
1714017103
.description = "SEQUENCE SET",
1714117104
.section = SECTION_DATA,
1714217105
.createStmt = query->data,
17143-
.dropStmt = "",
1714417106
.deps = &(tbinfo->dobj.dumpId),
1714517107
.nDeps = 1));
1714617108

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp