MCPcopy Create free account
hub / github.com/apache/cloudberry / dumpComment

Function dumpComment

src/bin/pg_dump/pg_dump.c:11080–11152  ·  view source on GitHub ↗

* dumpComment -- * * This routine is used to dump any comments associated with the * object handed to this routine. The routine takes the object type * and object name (ready to print, except for schema decoration), plus * the namespace and owner of the object (for labeling the ArchiveEntry), * plus catalog ID and subid which are the lookup key for pg_description, * plus the dump ID for the

Source from the content-addressed store, hash-verified

11078 * calling ArchiveEntry() for the specified object.
11079 */
11080static void
11081dumpComment(Archive *fout, const char *type, const char *name,
11082 const char *namespace, const char *owner,
11083 CatalogId catalogId, int subid, DumpId dumpId)
11084{
11085 DumpOptions *dopt = fout->dopt;
11086 CommentItem *comments;
11087 int ncomments;
11088
11089 /* do nothing, if --no-comments is supplied */
11090 if (dopt->no_comments)
11091 return;
11092
11093 /* Comments are schema not data ... except blob comments are data */
11094 if (strcmp(type, "LARGE OBJECT") != 0)
11095 {
11096 if (dopt->dataOnly)
11097 return;
11098 }
11099 else
11100 {
11101 /* We do dump blob comments in binary-upgrade mode */
11102 if (dopt->schemaOnly && !dopt->binary_upgrade)
11103 return;
11104 }
11105
11106 /* Search for comments associated with catalogId, using table */
11107 ncomments = findComments(fout, catalogId.tableoid, catalogId.oid,
11108 &comments);
11109
11110 /* Is there one matching the subid? */
11111 while (ncomments > 0)
11112 {
11113 if (comments->objsubid == subid)
11114 break;
11115 comments++;
11116 ncomments--;
11117 }
11118
11119 /* If a comment exists, build COMMENT ON statement */
11120 if (ncomments > 0)
11121 {
11122 PQExpBuffer query = createPQExpBuffer();
11123 PQExpBuffer tag = createPQExpBuffer();
11124
11125 appendPQExpBuffer(query, "COMMENT ON %s ", type);
11126 if (namespace && *namespace)
11127 appendPQExpBuffer(query, "%s.", fmtId(namespace));
11128 appendPQExpBuffer(query, "%s IS ", name);
11129 appendStringLiteralAH(query, comments->descr, fout);
11130 appendPQExpBufferStr(query, ";\n");
11131
11132 appendPQExpBuffer(tag, "%s %s", type, name);
11133
11134 /*
11135 * We mark comments as SECTION_NONE because they really belong in the
11136 * same section as their parent, whether that is pre-data or
11137 * post-data.

Callers 15

dumpBlobFunction · 0.85
dumpPolicyFunction · 0.85
dumpPublicationFunction · 0.85
dumpSubscriptionFunction · 0.85
dumpNamespaceFunction · 0.85
dumpExtensionFunction · 0.85
dumpEnumTypeFunction · 0.85
dumpRangeTypeFunction · 0.85
dumpUndefinedTypeFunction · 0.85
dumpBaseTypeFunction · 0.85
dumpDomainFunction · 0.85
dumpCompositeTypeFunction · 0.85

Calls 8

findCommentsFunction · 0.85
createPQExpBufferFunction · 0.85
appendPQExpBufferFunction · 0.85
fmtIdFunction · 0.85
appendPQExpBufferStrFunction · 0.85
ArchiveEntryFunction · 0.85
createDumpIdFunction · 0.85
destroyPQExpBufferFunction · 0.85

Tested by

no test coverage detected