* 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
| 11078 | * calling ArchiveEntry() for the specified object. |
| 11079 | */ |
| 11080 | static void |
| 11081 | dumpComment(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. |
no test coverage detected