Commit f831d4ac authored by Alvaro Herrera's avatar Alvaro Herrera

Add ArchiveOpts to pass options to ArchiveEntry

The ArchiveEntry function has a number of arguments that can be
considered optional.  Split them out into a separate struct, to make the
API more flexible for changes.

Author: Dmitry Dolgov
Discussion: https://postgr.es/m/CA+q6zcXRxPE+qp6oerQWJ3zS061WPOhdxeMrdc-Yf-2V5vsrEw@mail.gmail.com
parent 456e3718
......@@ -77,7 +77,7 @@ static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
static void _getObjectDescription(PQExpBuffer buf, TocEntry *te,
ArchiveHandle *AH);
static void _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData);
static char *replace_line_endings(const char *str);
static char *sanitize_line(const char *str, bool want_hyphen);
static void _doSetFixedOutputState(ArchiveHandle *AH);
static void _doSetSessionAuth(ArchiveHandle *AH, const char *user);
static void _reconnectToDB(ArchiveHandle *AH, const char *dbname);
......@@ -1066,17 +1066,8 @@ WriteData(Archive *AHX, const void *data, size_t dLen)
/* Public */
TocEntry *
ArchiveEntry(Archive *AHX,
CatalogId catalogId, DumpId dumpId,
const char *tag,
const char *namespace,
const char *tablespace,
const char *owner,
const char *desc, teSection section,
const char *defn,
const char *dropStmt, const char *copyStmt,
const DumpId *deps, int nDeps,
DataDumperPtr dumpFn, void *dumpArg)
ArchiveEntry(Archive *AHX, CatalogId catalogId, DumpId dumpId,
ArchiveOpts *opts)
{
ArchiveHandle *AH = (ArchiveHandle *) AHX;
TocEntry *newToc;
......@@ -1094,22 +1085,22 @@ ArchiveEntry(Archive *AHX,
newToc->catalogId = catalogId;
newToc->dumpId = dumpId;
newToc->section = section;
newToc->section = opts->section;
newToc->tag = pg_strdup(tag);
newToc->namespace = namespace ? pg_strdup(namespace) : NULL;
newToc->tablespace = tablespace ? pg_strdup(tablespace) : NULL;
newToc->owner = pg_strdup(owner);
newToc->desc = pg_strdup(desc);
newToc->defn = pg_strdup(defn);
newToc->dropStmt = pg_strdup(dropStmt);
newToc->copyStmt = copyStmt ? pg_strdup(copyStmt) : NULL;
newToc->tag = pg_strdup(opts->tag);
newToc->namespace = opts->namespace ? pg_strdup(opts->namespace) : NULL;
newToc->tablespace = opts->tablespace ? pg_strdup(opts->tablespace) : NULL;
newToc->owner = opts->owner ? pg_strdup(opts->owner) : NULL;
newToc->desc = pg_strdup(opts->description);
newToc->defn = opts->createStmt ? pg_strdup(opts->createStmt) : NULL;
newToc->dropStmt = opts->dropStmt ? pg_strdup(opts->dropStmt) : NULL;
newToc->copyStmt = opts->copyStmt ? pg_strdup(opts->copyStmt) : NULL;
if (nDeps > 0)
if (opts->nDeps > 0)
{
newToc->dependencies = (DumpId *) pg_malloc(nDeps * sizeof(DumpId));
memcpy(newToc->dependencies, deps, nDeps * sizeof(DumpId));
newToc->nDeps = nDeps;
newToc->dependencies = (DumpId *) pg_malloc(opts->nDeps * sizeof(DumpId));
memcpy(newToc->dependencies, opts->deps, opts->nDeps * sizeof(DumpId));
newToc->nDeps = opts->nDeps;
}
else
{
......@@ -1117,9 +1108,9 @@ ArchiveEntry(Archive *AHX,
newToc->nDeps = 0;
}
newToc->dataDumper = dumpFn;
newToc->dataDumperArg = dumpArg;
newToc->hadDumper = dumpFn ? true : false;
newToc->dataDumper = opts->dumpFn;
newToc->dataDumperArg = opts->dumpArg;
newToc->hadDumper = opts->dumpFn ? true : false;
newToc->formatData = NULL;
newToc->dataLength = 0;
......@@ -1152,7 +1143,7 @@ PrintTOCSummary(Archive *AHX)
ahprintf(AH, ";\n; Archive created at %s\n", stamp_str);
ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
replace_line_endings(AH->archdbname),
sanitize_line(AH->archdbname, false),
AH->tocCount, AH->compression);
switch (AH->format)
......@@ -1197,21 +1188,10 @@ PrintTOCSummary(Archive *AHX)
char *sanitized_owner;
/*
* As in _printTocEntry(), sanitize strings that might contain
* newlines, to ensure that each logical output line is in fact
* one physical output line. This prevents confusion when the
* file is read by "pg_restore -L". Note that we currently don't
* bother to quote names, meaning that the name fields aren't
* automatically parseable. "pg_restore -L" doesn't care because
* it only examines the dumpId field, but someday we might want to
* try harder.
*/
sanitized_name = replace_line_endings(te->tag);
if (te->namespace)
sanitized_schema = replace_line_endings(te->namespace);
else
sanitized_schema = pg_strdup("-");
sanitized_owner = replace_line_endings(te->owner);
*/
sanitized_name = sanitize_line(te->tag, false);
sanitized_schema = sanitize_line(te->namespace, true);
sanitized_owner = sanitize_line(te->owner, false);
ahprintf(AH, "%d; %u %u %s %s %s %s\n", te->dumpId,
te->catalogId.tableoid, te->catalogId.oid,
......@@ -3577,21 +3557,9 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
}
}
/*
* Zap any line endings embedded in user-supplied fields, to prevent
* corruption of the dump (which could, in the worst case, present an
* SQL injection vulnerability if someone were to incautiously load a
* dump containing objects with maliciously crafted names).
*/
sanitized_name = replace_line_endings(te->tag);
if (te->namespace)
sanitized_schema = replace_line_endings(te->namespace);
else
sanitized_schema = pg_strdup("-");
if (!ropt->noOwner)
sanitized_owner = replace_line_endings(te->owner);
else
sanitized_owner = pg_strdup("-");
sanitized_name = sanitize_line(te->tag, false);
sanitized_schema = sanitize_line(te->namespace, true);
sanitized_owner = sanitize_line(ropt->noOwner ? NULL : te->owner, true);
ahprintf(AH, "-- %sName: %s; Type: %s; Schema: %s; Owner: %s",
pfx, sanitized_name, te->desc, sanitized_schema,
......@@ -3605,7 +3573,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
{
char *sanitized_tablespace;
sanitized_tablespace = replace_line_endings(te->tablespace);
sanitized_tablespace = sanitize_line(te->tablespace, false);
ahprintf(AH, "; Tablespace: %s", sanitized_tablespace);
free(sanitized_tablespace);
}
......@@ -3629,7 +3597,7 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
}
else
{
if (strlen(te->defn) > 0)
if (te->defn && strlen(te->defn) > 0)
ahprintf(AH, "%s\n\n", te->defn);
}
......@@ -3640,7 +3608,8 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
* with DROP commands must appear in one list or the other.
*/
if (!ropt->noOwner && !ropt->use_setsessauth &&
strlen(te->owner) > 0 && strlen(te->dropStmt) > 0)
te->owner && strlen(te->owner) > 0 &&
te->dropStmt && strlen(te->dropStmt) > 0)
{
if (strcmp(te->desc, "AGGREGATE") == 0 ||
strcmp(te->desc, "BLOB") == 0 ||
......@@ -3713,16 +3682,30 @@ _printTocEntry(ArchiveHandle *AH, TocEntry *te, bool isData)
}
/*
* Sanitize a string to be included in an SQL comment or TOC listing,
* by replacing any newlines with spaces.
* The result is a freshly malloc'd string.
* Sanitize a string to be included in an SQL comment or TOC listing, by
* replacing any newlines with spaces. This ensures each logical output line
* is in fact one physical output line, to prevent corruption of the dump
* (which could, in the worst case, present an SQL injection vulnerability
* if someone were to incautiously load a dump containing objects with
* maliciously crafted names).
*
* The result is a freshly malloc'd string. If the input string is NULL,
* return a malloc'ed empty string, unless want_hyphen, in which case return a
* malloc'ed hyphen.
*
* Note that we currently don't bother to quote names, meaning that the name
* fields aren't automatically parseable. "pg_restore -L" doesn't care because
* it only examines the dumpId field, but someday we might want to try harder.
*/
static char *
replace_line_endings(const char *str)
sanitize_line(const char *str, bool want_hyphen)
{
char *result;
char *s;
if (!str)
return pg_strdup(want_hyphen ? "-" : "");
result = pg_strdup(str);
for (s = result; *s != '\0'; s++)
......
......@@ -405,17 +405,27 @@ extern void on_exit_close_archive(Archive *AHX);
extern void warn_or_exit_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt,...) pg_attribute_printf(3, 4);
/* Options for ArchiveEntry */
typedef struct _archiveOpts
{
const char *tag;
const char *namespace;
const char *tablespace;
const char *owner;
const char *description;
teSection section;
const char *createStmt;
const char *dropStmt;
const char *copyStmt;
const DumpId *deps;
int nDeps;
DataDumperPtr dumpFn;
void *dumpArg;
} ArchiveOpts;
#define ARCHIVE_OPTS(...) &(ArchiveOpts){__VA_ARGS__}
/* Called to add a TOC entry */
extern TocEntry *ArchiveEntry(Archive *AHX,
CatalogId catalogId, DumpId dumpId,
const char *tag,
const char *namespace, const char *tablespace,
const char *owner,
const char *desc, teSection section,
const char *defn,
const char *dropStmt, const char *copyStmt,
const DumpId *deps, int nDeps,
DataDumperPtr dumpFn, void *dumpArg);
extern TocEntry *ArchiveEntry(Archive *AHX, CatalogId catalogId,
DumpId dumpId, ArchiveOpts *opts);
extern void WriteTOC(ArchiveHandle *AH);
extern void ReadTOC(ArchiveHandle *AH);
......
......@@ -2135,12 +2135,16 @@ dumpTableData(Archive *fout, TableDataInfo *tdinfo)
TocEntry *te;
te = ArchiveEntry(fout, tdinfo->dobj.catId, tdinfo->dobj.dumpId,
tbinfo->dobj.name, tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
"TABLE DATA", SECTION_DATA,
"", "", copyStmt,
&(tbinfo->dobj.dumpId), 1,
dumpFn, tdinfo);
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "TABLE DATA",
.section = SECTION_DATA,
.copyStmt = copyStmt,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1,
.dumpFn = dumpFn,
.dumpArg = tdinfo));
/*
* Set the TocEntry's dataLength in case we are doing a parallel dump
......@@ -2184,19 +2188,14 @@ refreshMatViewData(Archive *fout, TableDataInfo *tdinfo)
ArchiveEntry(fout,
tdinfo->dobj.catId, /* catalog ID */
tdinfo->dobj.dumpId, /* dump ID */
tbinfo->dobj.name, /* Name */
tbinfo->dobj.namespace->dobj.name, /* Namespace */
NULL, /* Tablespace */
tbinfo->rolname, /* Owner */
"MATERIALIZED VIEW DATA", /* Desc */
SECTION_POST_DATA, /* Section */
q->data, /* Create */
"", /* Del */
NULL, /* Copy */
tdinfo->dobj.dependencies, /* Deps */
tdinfo->dobj.nDeps, /* # Deps */
NULL, /* Dumper */
NULL); /* Dumper Arg */
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "MATERIALIZED VIEW DATA",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.deps = tdinfo->dobj.dependencies,
.nDeps = tdinfo->dobj.nDeps));
destroyPQExpBuffer(q);
}
......@@ -2722,19 +2721,12 @@ dumpDatabase(Archive *fout)
ArchiveEntry(fout,
dbCatId, /* catalog ID */
dbDumpId, /* dump ID */
datname, /* Name */
NULL, /* Namespace */
NULL, /* Tablespace */
dba, /* Owner */
"DATABASE", /* Desc */
SECTION_PRE_DATA, /* Section */
creaQry->data, /* Create */
delQry->data, /* Del */
NULL, /* Copy */
NULL, /* Deps */
0, /* # Deps */
NULL, /* Dumper */
NULL); /* Dumper Arg */
ARCHIVE_OPTS(.tag = datname,
.owner = dba,
.description = "DATABASE",
.section = SECTION_PRE_DATA,
.createStmt = creaQry->data,
.dropStmt = delQry->data));
/* Compute correct tag for archive entry */
appendPQExpBuffer(labelq, "DATABASE %s", qdatname);
......@@ -2762,11 +2754,13 @@ dumpDatabase(Archive *fout)
appendPQExpBufferStr(dbQry, ";\n");
ArchiveEntry(fout, nilCatalogId, createDumpId(),
labelq->data, NULL, NULL, dba,
"COMMENT", SECTION_NONE,
dbQry->data, "", NULL,
&(dbDumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = labelq->data,
.owner = dba,
.description = "COMMENT",
.section = SECTION_NONE,
.createStmt = dbQry->data,
.deps = &dbDumpId,
.nDeps = 1));
}
}
else
......@@ -2789,11 +2783,13 @@ dumpDatabase(Archive *fout)
emitShSecLabels(conn, shres, seclabelQry, "DATABASE", datname);
if (seclabelQry->len > 0)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
labelq->data, NULL, NULL, dba,
"SECURITY LABEL", SECTION_NONE,
seclabelQry->data, "", NULL,
&(dbDumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = labelq->data,
.owner = dba,
.description = "SECURITY LABEL",
.section = SECTION_NONE,
.createStmt = seclabelQry->data,
.deps = &dbDumpId,
.nDeps = 1));
destroyPQExpBuffer(seclabelQry);
PQclear(shres);
}
......@@ -2859,11 +2855,13 @@ dumpDatabase(Archive *fout)
if (creaQry->len > 0)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
datname, NULL, NULL, dba,
"DATABASE PROPERTIES", SECTION_PRE_DATA,
creaQry->data, delQry->data, NULL,
&(dbDumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = datname,
.owner = dba,
.description = "DATABASE PROPERTIES",
.section = SECTION_PRE_DATA,
.createStmt = creaQry->data,
.dropStmt = delQry->data,
.deps = &dbDumpId));
/*
* pg_largeobject comes from the old system intact, so set its
......@@ -2904,11 +2902,10 @@ dumpDatabase(Archive *fout)
atooid(PQgetvalue(lo_res, 0, i_relminmxid)),
LargeObjectRelationId);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
"pg_largeobject", NULL, NULL, "",
"pg_largeobject", SECTION_PRE_DATA,
loOutQry->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = "pg_largeobject",
.description = "pg_largeobject",
.section = SECTION_PRE_DATA,
.createStmt = loOutQry->data));
PQclear(lo_res);
......@@ -3014,11 +3011,10 @@ dumpEncoding(Archive *AH)
appendPQExpBufferStr(qry, ";\n");
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"ENCODING", NULL, NULL, "",
"ENCODING", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = "ENCODING",
.description = "ENCODING",
.section = SECTION_PRE_DATA,
.createStmt = qry->data));
destroyPQExpBuffer(qry);
}
......@@ -3041,11 +3037,10 @@ dumpStdStrings(Archive *AH)
stdstrings);
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"STDSTRINGS", NULL, NULL, "",
"STDSTRINGS", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = "STDSTRINGS",
.description = "STDSTRINGS",
.section = SECTION_PRE_DATA,
.createStmt = qry->data));
destroyPQExpBuffer(qry);
}
......@@ -3097,11 +3092,10 @@ dumpSearchPath(Archive *AH)
write_msg(NULL, "saving search_path = %s\n", path->data);
ArchiveEntry(AH, nilCatalogId, createDumpId(),
"SEARCHPATH", NULL, NULL, "",
"SEARCHPATH", SECTION_PRE_DATA,
qry->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = "SEARCHPATH",
.description = "SEARCHPATH",
.section = SECTION_PRE_DATA,
.createStmt = qry->data));
/* Also save it in AH->searchpath, in case we're doing plain text dump */
AH->searchpath = pg_strdup(qry->data);
......@@ -3273,13 +3267,12 @@ dumpBlob(Archive *fout, BlobInfo *binfo)
if (binfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, binfo->dobj.catId, binfo->dobj.dumpId,
binfo->dobj.name,
NULL, NULL,
binfo->rolname,
"BLOB", SECTION_PRE_DATA,
cquery->data, dquery->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = binfo->dobj.name,
.owner = binfo->rolname,
.description = "BLOB",
.section = SECTION_PRE_DATA,
.createStmt = cquery->data,
.dropStmt = dquery->data));
/* Dump comment if any */
if (binfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -3577,14 +3570,14 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
*/
if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
polinfo->dobj.name,
polinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"ROW SECURITY", SECTION_POST_DATA,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = polinfo->dobj.name,
.namespace = polinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "ROW SECURITY",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
destroyPQExpBuffer(query);
return;
......@@ -3633,14 +3626,13 @@ dumpPolicy(Archive *fout, PolicyInfo *polinfo)
if (polinfo->dobj.dump & DUMP_COMPONENT_POLICY)
ArchiveEntry(fout, polinfo->dobj.catId, polinfo->dobj.dumpId,
tag,
polinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"POLICY", SECTION_POST_DATA,
query->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = polinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "POLICY",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.dropStmt = delqry->data));
free(tag);
destroyPQExpBuffer(query);
......@@ -3807,14 +3799,12 @@ dumpPublication(Archive *fout, PublicationInfo *pubinfo)
appendPQExpBufferStr(query, "');\n");
ArchiveEntry(fout, pubinfo->dobj.catId, pubinfo->dobj.dumpId,
pubinfo->dobj.name,
NULL,
NULL,
pubinfo->rolname,
"PUBLICATION", SECTION_POST_DATA,
query->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = pubinfo->dobj.name,
.owner = pubinfo->rolname,
.description = "PUBLICATION",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.dropStmt = delq->data));
if (pubinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, "PUBLICATION", qpubname,
......@@ -3950,14 +3940,11 @@ dumpPublicationTable(Archive *fout, PublicationRelInfo *pubrinfo)
* done by table drop.
*/
ArchiveEntry(fout, pubrinfo->dobj.catId, pubrinfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
"",
"PUBLICATION TABLE", SECTION_POST_DATA,
query->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.description = "PUBLICATION TABLE",
.section = SECTION_POST_DATA,
.createStmt = query->data));
free(tag);
destroyPQExpBuffer(query);
......@@ -4143,14 +4130,12 @@ dumpSubscription(Archive *fout, SubscriptionInfo *subinfo)
appendPQExpBufferStr(query, ");\n");
ArchiveEntry(fout, subinfo->dobj.catId, subinfo->dobj.dumpId,
subinfo->dobj.name,
NULL,
NULL,
subinfo->rolname,
"SUBSCRIPTION", SECTION_POST_DATA,
query->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = subinfo->dobj.name,
.owner = subinfo->rolname,
.description = "SUBSCRIPTION",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.dropStmt = delq->data));
if (subinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, "SUBSCRIPTION", qsubname,
......@@ -9377,11 +9362,14 @@ dumpComment(Archive *fout, const char *type, const char *name,
* post-data.
*/
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data, namespace, NULL, owner,
"COMMENT", SECTION_NONE,
query->data, "", NULL,
&(dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = namespace,
.owner = owner,
.description = "COMMENT",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &dumpId,
.nDeps = 1));
destroyPQExpBuffer(query);
destroyPQExpBuffer(tag);
......@@ -9443,13 +9431,14 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
appendPQExpBufferStr(query, ";\n");
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data,
tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
"COMMENT", SECTION_NONE,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "COMMENT",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
}
else if (objsubid > 0 && objsubid <= tbinfo->numatts)
{
......@@ -9467,13 +9456,14 @@ dumpTableComment(Archive *fout, TableInfo *tbinfo,
appendPQExpBufferStr(query, ";\n");
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data,
tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
"COMMENT", SECTION_NONE,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "COMMENT",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
}
comments++;
......@@ -9750,11 +9740,10 @@ dumpDumpableObject(Archive *fout, DumpableObject *dobj)
TocEntry *te;
te = ArchiveEntry(fout, dobj->catId, dobj->dumpId,
dobj->name, NULL, NULL, "",
"BLOBS", SECTION_DATA,
"", "", NULL,
NULL, 0,
dumpBlobs, NULL);
ARCHIVE_OPTS(.tag = dobj->name,
.description = "BLOBS",
.section = SECTION_DATA,
.dumpFn = dumpBlobs));
/*
* Set the TocEntry's dataLength in case we are doing a
......@@ -9822,13 +9811,12 @@ dumpNamespace(Archive *fout, NamespaceInfo *nspinfo)
if (nspinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, nspinfo->dobj.catId, nspinfo->dobj.dumpId,
nspinfo->dobj.name,
NULL, NULL,
nspinfo->rolname,
"SCHEMA", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = nspinfo->dobj.name,
.owner = nspinfo->rolname,
.description = "SCHEMA",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Schema Comments and Security Labels */
if (nspinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -9958,13 +9946,11 @@ dumpExtension(Archive *fout, ExtensionInfo *extinfo)
if (extinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, extinfo->dobj.catId, extinfo->dobj.dumpId,
extinfo->dobj.name,
NULL, NULL,
"",
"EXTENSION", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = extinfo->dobj.name,
.description = "EXTENSION",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Extension Comments and Security Labels */
if (extinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10108,14 +10094,13 @@ dumpEnumType(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10235,14 +10220,13 @@ dumpRangeType(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10308,14 +10292,13 @@ dumpUndefinedType(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10590,14 +10573,13 @@ dumpBaseType(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Type Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10747,14 +10729,13 @@ dumpDomain(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"DOMAIN", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "DOMAIN",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Domain Comments and Security Labels */
if (tyinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -10969,14 +10950,13 @@ dumpCompositeType(Archive *fout, TypeInfo *tyinfo)
if (tyinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tyinfo->dobj.catId, tyinfo->dobj.dumpId,
tyinfo->dobj.name,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"TYPE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tyinfo->dobj.name,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Type Comments and Security Labels */
......@@ -11105,13 +11085,14 @@ dumpCompositeTypeColComments(Archive *fout, TypeInfo *tyinfo)
appendPQExpBufferStr(query, ";\n");
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
tyinfo->dobj.namespace->dobj.name,
NULL, tyinfo->rolname,
"COMMENT", SECTION_NONE,
query->data, "", NULL,
&(tyinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = target->data,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "COMMENT",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &(tyinfo->dobj.dumpId),
.nDeps = 1));
}
comments++;
......@@ -11160,14 +11141,12 @@ dumpShellType(Archive *fout, ShellTypeInfo *stinfo)
if (stinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, stinfo->dobj.catId, stinfo->dobj.dumpId,
stinfo->dobj.name,
stinfo->dobj.namespace->dobj.name,
NULL,
stinfo->baseType->rolname,
"SHELL TYPE", SECTION_PRE_DATA,
q->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = stinfo->dobj.name,
.namespace = stinfo->dobj.namespace->dobj.name,
.owner = stinfo->baseType->rolname,
.description = "SHELL TYPE",
.section = SECTION_PRE_DATA,
.createStmt = q->data));
destroyPQExpBuffer(q);
}
......@@ -11272,12 +11251,13 @@ dumpProcLang(Archive *fout, ProcLangInfo *plang)
if (plang->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, plang->dobj.catId, plang->dobj.dumpId,
plang->dobj.name,
NULL, NULL, plang->lanowner,
"PROCEDURAL LANGUAGE", SECTION_PRE_DATA,
defqry->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = plang->dobj.name,
.owner = plang->lanowner,
.description = "PROCEDURAL LANGUAGE",
.section = SECTION_PRE_DATA,
.createStmt = defqry->data,
.dropStmt = delqry->data,
));
/* Dump Proc Lang Comments and Security Labels */
if (plang->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -11942,14 +11922,13 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
if (finfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, finfo->dobj.catId, finfo->dobj.dumpId,
funcsig_tag,
finfo->dobj.namespace->dobj.name,
NULL,
finfo->rolname,
keyword, SECTION_PRE_DATA,
q->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = funcsig_tag,
.namespace = finfo->dobj.namespace->dobj.name,
.owner = finfo->rolname,
.description = keyword,
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delqry->data));
/* Dump Function Comments and Security Labels */
if (finfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -12077,12 +12056,11 @@ dumpCast(Archive *fout, CastInfo *cast)
if (cast->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, cast->dobj.catId, cast->dobj.dumpId,
labelq->data,
NULL, NULL, "",
"CAST", SECTION_PRE_DATA,
defqry->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = labelq->data,
.description = "CAST",
.section = SECTION_PRE_DATA,
.createStmt = defqry->data,
.dropStmt = delqry->data));
/* Dump Cast Comments */
if (cast->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -12205,12 +12183,13 @@ dumpTransform(Archive *fout, TransformInfo *transform)
if (transform->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, transform->dobj.catId, transform->dobj.dumpId,
labelq->data,
NULL, NULL, "",
"TRANSFORM", SECTION_PRE_DATA,
defqry->data, delqry->data, NULL,
transform->dobj.dependencies, transform->dobj.nDeps,
NULL, NULL);
ARCHIVE_OPTS(.tag = labelq->data,
.description = "TRANSFORM",
.section = SECTION_PRE_DATA,
.createStmt = defqry->data,
.dropStmt = delqry->data,
.deps = transform->dobj.dependencies,
.nDeps = transform->dobj.nDeps));
/* Dump Transform Comments */
if (transform->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -12418,14 +12397,13 @@ dumpOpr(Archive *fout, OprInfo *oprinfo)
if (oprinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, oprinfo->dobj.catId, oprinfo->dobj.dumpId,
oprinfo->dobj.name,
oprinfo->dobj.namespace->dobj.name,
NULL,
oprinfo->rolname,
"OPERATOR", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = oprinfo->dobj.name,
.namespace = oprinfo->dobj.namespace->dobj.name,
.owner = oprinfo->rolname,
.description = "OPERATOR",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Operator Comments */
if (oprinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -12588,14 +12566,11 @@ dumpAccessMethod(Archive *fout, AccessMethodInfo *aminfo)
if (aminfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, aminfo->dobj.catId, aminfo->dobj.dumpId,
aminfo->dobj.name,
NULL,
NULL,
"",
"ACCESS METHOD", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = aminfo->dobj.name,
.description = "ACCESS METHOD",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Access Method Comments */
if (aminfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -12954,14 +12929,13 @@ dumpOpclass(Archive *fout, OpclassInfo *opcinfo)
if (opcinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, opcinfo->dobj.catId, opcinfo->dobj.dumpId,
opcinfo->dobj.name,
opcinfo->dobj.namespace->dobj.name,
NULL,
opcinfo->rolname,
"OPERATOR CLASS", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = opcinfo->dobj.name,
.namespace = opcinfo->dobj.namespace->dobj.name,
.owner = opcinfo->rolname,
.description = "OPERATOR CLASS",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Operator Class Comments */
if (opcinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -13221,14 +13195,13 @@ dumpOpfamily(Archive *fout, OpfamilyInfo *opfinfo)
if (opfinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, opfinfo->dobj.catId, opfinfo->dobj.dumpId,
opfinfo->dobj.name,
opfinfo->dobj.namespace->dobj.name,
NULL,
opfinfo->rolname,
"OPERATOR FAMILY", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = opfinfo->dobj.name,
.namespace = opfinfo->dobj.namespace->dobj.name,
.owner = opfinfo->rolname,
.description = "OPERATOR FAMILY",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Operator Family Comments */
if (opfinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -13364,14 +13337,13 @@ dumpCollation(Archive *fout, CollInfo *collinfo)
if (collinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, collinfo->dobj.catId, collinfo->dobj.dumpId,
collinfo->dobj.name,
collinfo->dobj.namespace->dobj.name,
NULL,
collinfo->rolname,
"COLLATION", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = collinfo->dobj.name,
.namespace = collinfo->dobj.namespace->dobj.name,
.owner = collinfo->rolname,
.description = "COLLATION",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Collation Comments */
if (collinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -13459,14 +13431,13 @@ dumpConversion(Archive *fout, ConvInfo *convinfo)
if (convinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, convinfo->dobj.catId, convinfo->dobj.dumpId,
convinfo->dobj.name,
convinfo->dobj.namespace->dobj.name,
NULL,
convinfo->rolname,
"CONVERSION", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = convinfo->dobj.name,
.namespace = convinfo->dobj.namespace->dobj.name,
.owner = convinfo->rolname,
.description = "CONVERSION",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Conversion Comments */
if (convinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -13948,14 +13919,13 @@ dumpAgg(Archive *fout, AggInfo *agginfo)
if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, agginfo->aggfn.dobj.catId,
agginfo->aggfn.dobj.dumpId,
aggsig_tag,
agginfo->aggfn.dobj.namespace->dobj.name,
NULL,
agginfo->aggfn.rolname,
"AGGREGATE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = aggsig_tag,
.namespace = agginfo->aggfn.dobj.namespace->dobj.name,
.owner = agginfo->aggfn.rolname,
.description = "AGGREGATE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Aggregate Comments */
if (agginfo->aggfn.dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14046,14 +14016,12 @@ dumpTSParser(Archive *fout, TSParserInfo *prsinfo)
if (prsinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, prsinfo->dobj.catId, prsinfo->dobj.dumpId,
prsinfo->dobj.name,
prsinfo->dobj.namespace->dobj.name,
NULL,
"",
"TEXT SEARCH PARSER", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = prsinfo->dobj.name,
.namespace = prsinfo->dobj.namespace->dobj.name,
.description = "TEXT SEARCH PARSER",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Parser Comments */
if (prsinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14126,14 +14094,13 @@ dumpTSDictionary(Archive *fout, TSDictInfo *dictinfo)
if (dictinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, dictinfo->dobj.catId, dictinfo->dobj.dumpId,
dictinfo->dobj.name,
dictinfo->dobj.namespace->dobj.name,
NULL,
dictinfo->rolname,
"TEXT SEARCH DICTIONARY", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = dictinfo->dobj.name,
.namespace = dictinfo->dobj.namespace->dobj.name,
.owner = dictinfo->rolname,
.description = "TEXT SEARCH DICTIONARY",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Dictionary Comments */
if (dictinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14187,14 +14154,12 @@ dumpTSTemplate(Archive *fout, TSTemplateInfo *tmplinfo)
if (tmplinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tmplinfo->dobj.catId, tmplinfo->dobj.dumpId,
tmplinfo->dobj.name,
tmplinfo->dobj.namespace->dobj.name,
NULL,
"",
"TEXT SEARCH TEMPLATE", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tmplinfo->dobj.name,
.namespace = tmplinfo->dobj.namespace->dobj.name,
.description = "TEXT SEARCH TEMPLATE",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Template Comments */
if (tmplinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14307,14 +14272,13 @@ dumpTSConfig(Archive *fout, TSConfigInfo *cfginfo)
if (cfginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, cfginfo->dobj.catId, cfginfo->dobj.dumpId,
cfginfo->dobj.name,
cfginfo->dobj.namespace->dobj.name,
NULL,
cfginfo->rolname,
"TEXT SEARCH CONFIGURATION", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = cfginfo->dobj.name,
.namespace = cfginfo->dobj.namespace->dobj.name,
.owner = cfginfo->rolname,
.description = "TEXT SEARCH CONFIGURATION",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Configuration Comments */
if (cfginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14373,14 +14337,12 @@ dumpForeignDataWrapper(Archive *fout, FdwInfo *fdwinfo)
if (fdwinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, fdwinfo->dobj.catId, fdwinfo->dobj.dumpId,
fdwinfo->dobj.name,
NULL,
NULL,
fdwinfo->rolname,
"FOREIGN DATA WRAPPER", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = fdwinfo->dobj.name,
.owner = fdwinfo->rolname,
.description = "FOREIGN DATA WRAPPER",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Foreign Data Wrapper Comments */
if (fdwinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14464,14 +14426,12 @@ dumpForeignServer(Archive *fout, ForeignServerInfo *srvinfo)
if (srvinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, srvinfo->dobj.catId, srvinfo->dobj.dumpId,
srvinfo->dobj.name,
NULL,
NULL,
srvinfo->rolname,
"SERVER", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = srvinfo->dobj.name,
.owner = srvinfo->rolname,
.description = "SERVER",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Foreign Server Comments */
if (srvinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -14582,14 +14542,13 @@ dumpUserMappings(Archive *fout,
usename, servername);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data,
namespace,
NULL,
owner,
"USER MAPPING", SECTION_PRE_DATA,
q->data, delq->data, NULL,
&dumpId, 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = namespace,
.owner = owner,
.description = "USER MAPPING",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
}
PQclear(res);
......@@ -14661,14 +14620,13 @@ dumpDefaultACL(Archive *fout, DefaultACLInfo *daclinfo)
if (daclinfo->dobj.dump & DUMP_COMPONENT_ACL)
ArchiveEntry(fout, daclinfo->dobj.catId, daclinfo->dobj.dumpId,
tag->data,
daclinfo->dobj.namespace ? daclinfo->dobj.namespace->dobj.name : NULL,
NULL,
daclinfo->defaclrole,
"DEFAULT ACL", SECTION_POST_DATA,
q->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = daclinfo->dobj.namespace ?
daclinfo->dobj.namespace->dobj.name : NULL,
.owner = daclinfo->defaclrole,
.description = "DEFAULT ACL",
.section = SECTION_POST_DATA,
.createStmt = q->data));
destroyPQExpBuffer(tag);
destroyPQExpBuffer(q);
......@@ -14760,13 +14718,14 @@ dumpACL(Archive *fout, CatalogId objCatId, DumpId objDumpId,
appendPQExpBuffer(tag, "%s %s", type, name);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data, nspname,
NULL,
owner ? owner : "",
"ACL", SECTION_NONE,
sql->data, "", NULL,
&(objDumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = nspname,
.owner = owner,
.description = "ACL",
.section = SECTION_NONE,
.createStmt = sql->data,
.deps = &objDumpId,
.nDeps = 1));
destroyPQExpBuffer(tag);
}
......@@ -14848,11 +14807,14 @@ dumpSecLabel(Archive *fout, const char *type, const char *name,
appendPQExpBuffer(tag, "%s %s", type, name);
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tag->data, namespace, NULL, owner,
"SECURITY LABEL", SECTION_NONE,
query->data, "", NULL,
&(dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag->data,
.namespace = namespace,
.owner = owner,
.description = "SECURITY LABEL",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &dumpId,
.nDeps = 1));
destroyPQExpBuffer(tag);
}
......@@ -14928,13 +14890,14 @@ dumpTableSecLabel(Archive *fout, TableInfo *tbinfo, const char *reltypename)
appendPQExpBuffer(target, "%s %s", reltypename,
fmtId(tbinfo->dobj.name));
ArchiveEntry(fout, nilCatalogId, createDumpId(),
target->data,
tbinfo->dobj.namespace->dobj.name,
NULL, tbinfo->rolname,
"SECURITY LABEL", SECTION_NONE,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = target->data,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "SECURITY LABEL",
.section = SECTION_NONE,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
}
destroyPQExpBuffer(query);
destroyPQExpBuffer(target);
......@@ -16012,16 +15975,16 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
(tbinfo->relkind == RELKIND_VIEW) ? NULL : tbinfo->reltablespace,
tbinfo->rolname,
reltypename,
tbinfo->postponed_def ?
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.tablespace = (tbinfo->relkind == RELKIND_VIEW) ?
NULL : tbinfo->reltablespace,
.owner = tbinfo->rolname,
.description = reltypename,
.section = tbinfo->postponed_def ?
SECTION_POST_DATA : SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Table Comments */
......@@ -16092,14 +16055,13 @@ dumpAttrDef(Archive *fout, AttrDefInfo *adinfo)
if (adinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, adinfo->dobj.catId, adinfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"DEFAULT", SECTION_PRE_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "DEFAULT",
.section = SECTION_PRE_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
free(tag);
destroyPQExpBuffer(q);
......@@ -16241,14 +16203,14 @@ dumpIndex(Archive *fout, IndxInfo *indxinfo)
if (indxinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, indxinfo->dobj.catId, indxinfo->dobj.dumpId,
indxinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
indxinfo->tablespace,
tbinfo->rolname,
"INDEX", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = indxinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.tablespace = indxinfo->tablespace,
.owner = tbinfo->rolname,
.description = "INDEX",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
if (indstatcolsarray)
free(indstatcolsarray);
......@@ -16290,14 +16252,11 @@ dumpIndexAttach(Archive *fout, IndexAttachInfo *attachinfo)
fmtQualifiedDumpable(attachinfo->partitionIdx));
ArchiveEntry(fout, attachinfo->dobj.catId, attachinfo->dobj.dumpId,
attachinfo->dobj.name,
attachinfo->dobj.namespace->dobj.name,
NULL,
"",
"INDEX ATTACH", SECTION_POST_DATA,
q->data, "", NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = attachinfo->dobj.name,
.namespace = attachinfo->dobj.namespace->dobj.name,
.description = "INDEX ATTACH",
.section = SECTION_POST_DATA,
.createStmt = q->data));
destroyPQExpBuffer(q);
}
......@@ -16345,14 +16304,13 @@ dumpStatisticsExt(Archive *fout, StatsExtInfo *statsextinfo)
if (statsextinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, statsextinfo->dobj.catId,
statsextinfo->dobj.dumpId,
statsextinfo->dobj.name,
statsextinfo->dobj.namespace->dobj.name,
NULL,
statsextinfo->rolname,
"STATISTICS", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = statsextinfo->dobj.name,
.namespace = statsextinfo->dobj.namespace->dobj.name,
.owner = statsextinfo->rolname,
.description = "STATISTICS",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
/* Dump Statistics Comments */
if (statsextinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......@@ -16506,14 +16464,14 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
indxinfo->tablespace,
tbinfo->rolname,
"CONSTRAINT", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.tablespace = indxinfo->tablespace,
.owner = tbinfo->rolname,
.description = "CONSTRAINT",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
}
else if (coninfo->contype == 'f')
{
......@@ -16546,14 +16504,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"FK CONSTRAINT", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "FK CONSTRAINT",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
}
else if (coninfo->contype == 'c' && tbinfo)
{
......@@ -16578,14 +16535,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"CHECK CONSTRAINT", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "CHECK CONSTRAINT",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
}
}
else if (coninfo->contype == 'c' && tbinfo == NULL)
......@@ -16611,14 +16567,13 @@ dumpConstraint(Archive *fout, ConstraintInfo *coninfo)
if (coninfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, coninfo->dobj.catId, coninfo->dobj.dumpId,
tag,
tyinfo->dobj.namespace->dobj.name,
NULL,
tyinfo->rolname,
"CHECK CONSTRAINT", SECTION_POST_DATA,
q->data, delq->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tyinfo->dobj.namespace->dobj.name,
.owner = tyinfo->rolname,
.description = "CHECK CONSTRAINT",
.section = SECTION_POST_DATA,
.createStmt = q->data,
.dropStmt = delq->data));
}
}
else
......@@ -16885,14 +16840,13 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tbinfo->dobj.catId, tbinfo->dobj.dumpId,
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"SEQUENCE", SECTION_PRE_DATA,
query->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "SEQUENCE",
.section = SECTION_PRE_DATA,
.createStmt = query->data,
.dropStmt = delqry->data));
/*
* If the sequence is owned by a table column, emit the ALTER for it as a
......@@ -16926,14 +16880,14 @@ dumpSequence(Archive *fout, TableInfo *tbinfo)
if (tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"SEQUENCE OWNED BY", SECTION_PRE_DATA,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "SEQUENCE OWNED BY",
.section = SECTION_PRE_DATA,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
}
}
......@@ -16994,14 +16948,14 @@ dumpSequenceData(Archive *fout, TableDataInfo *tdinfo)
if (tdinfo->dobj.dump & DUMP_COMPONENT_DATA)
ArchiveEntry(fout, nilCatalogId, createDumpId(),
tbinfo->dobj.name,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"SEQUENCE SET", SECTION_DATA,
query->data, "", NULL,
&(tbinfo->dobj.dumpId), 1,
NULL, NULL);
ARCHIVE_OPTS(.tag = tbinfo->dobj.name,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "SEQUENCE SET",
.section = SECTION_DATA,
.createStmt = query->data,
.deps = &(tbinfo->dobj.dumpId),
.nDeps = 1));
PQclear(res);
......@@ -17193,14 +17147,13 @@ dumpTrigger(Archive *fout, TriggerInfo *tginfo)
if (tginfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, tginfo->dobj.catId, tginfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"TRIGGER", SECTION_POST_DATA,
query->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "TRIGGER",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.dropStmt = delqry->data));
if (tginfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, trigprefix->data, qtabname,
......@@ -17282,12 +17235,12 @@ dumpEventTrigger(Archive *fout, EventTriggerInfo *evtinfo)
if (evtinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, evtinfo->dobj.catId, evtinfo->dobj.dumpId,
evtinfo->dobj.name, NULL, NULL,
evtinfo->evtowner,
"EVENT TRIGGER", SECTION_POST_DATA,
query->data, delqry->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = evtinfo->dobj.name,
.owner = evtinfo->evtowner,
.description = "EVENT TRIGGER",
.section = SECTION_POST_DATA,
.createStmt = query->data,
.dropStmt = delqry->data));
if (evtinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
dumpComment(fout, "EVENT TRIGGER", qevtname,
......@@ -17440,14 +17393,13 @@ dumpRule(Archive *fout, RuleInfo *rinfo)
if (rinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)
ArchiveEntry(fout, rinfo->dobj.catId, rinfo->dobj.dumpId,
tag,
tbinfo->dobj.namespace->dobj.name,
NULL,
tbinfo->rolname,
"RULE", SECTION_POST_DATA,
cmd->data, delcmd->data, NULL,
NULL, 0,
NULL, NULL);
ARCHIVE_OPTS(.tag = tag,
.namespace = tbinfo->dobj.namespace->dobj.name,
.owner = tbinfo->rolname,
.description = "RULE",
.section = SECTION_POST_DATA,
.createStmt = cmd->data,
.dropStmt = delcmd->data));
/* Dump rule comments */
if (rinfo->dobj.dump & DUMP_COMPONENT_COMMENT)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment