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

Function dumpTable

src/bin/pg_dump/pg_dump.c:17183–17315  ·  view source on GitHub ↗

* dumpTable * write out to fout the declarations (not data) of a user-defined table */

Source from the content-addressed store, hash-verified

17181 * write out to fout the declarations (not data) of a user-defined table
17182 */
17183static void
17184dumpTable(Archive *fout, const TableInfo *tbinfo)
17185{
17186 DumpOptions *dopt = fout->dopt;
17187 DumpId tableAclDumpId = InvalidDumpId;
17188 char *namecopy;
17189
17190 /*
17191 * noop if we are not dumping anything about this table, or if we are
17192 * doing a data-only dump
17193 */
17194 if (!tbinfo->dobj.dump || dopt->dataOnly)
17195 return;
17196
17197 if (tbinfo->relkind == RELKIND_SEQUENCE)
17198 dumpSequence(fout, tbinfo);
17199 else
17200 dumpTableSchema(fout, tbinfo);
17201
17202 /* Handle the ACL here */
17203 namecopy = pg_strdup(fmtId(tbinfo->dobj.name));
17204 if (tbinfo->dobj.dump & DUMP_COMPONENT_ACL)
17205 {
17206 const char *objtype =
17207 (tbinfo->relkind == RELKIND_SEQUENCE) ? "SEQUENCE" : "TABLE";
17208
17209 tableAclDumpId =
17210 dumpACL(fout, tbinfo->dobj.dumpId, InvalidDumpId,
17211 objtype, namecopy, NULL,
17212 tbinfo->dobj.namespace->dobj.name, tbinfo->rolname,
17213 tbinfo->relacl, tbinfo->rrelacl,
17214 tbinfo->initrelacl, tbinfo->initrrelacl);
17215 }
17216
17217 /*
17218 * Handle column ACLs, if any. Note: we pull these with a separate query
17219 * rather than trying to fetch them during getTableAttrs, so that we won't
17220 * miss ACLs on system columns.
17221 */
17222 if (fout->remoteVersion >= 80400 && tbinfo->dobj.dump & DUMP_COMPONENT_ACL)
17223 {
17224 PQExpBuffer query = createPQExpBuffer();
17225 PGresult *res;
17226 int i;
17227
17228 if (fout->remoteVersion >= 90600)
17229 {
17230 PQExpBuffer acl_subquery = createPQExpBuffer();
17231 PQExpBuffer racl_subquery = createPQExpBuffer();
17232 PQExpBuffer initacl_subquery = createPQExpBuffer();
17233 PQExpBuffer initracl_subquery = createPQExpBuffer();
17234
17235 buildACLQueries(acl_subquery, racl_subquery, initacl_subquery,
17236 initracl_subquery, "at.attacl", "c.relowner", "'c'",
17237 dopt->binary_upgrade);
17238
17239 appendPQExpBuffer(query,
17240 "SELECT at.attname, "

Callers 1

dumpDumpableObjectFunction · 0.85

Calls 13

dumpSequenceFunction · 0.85
dumpTableSchemaFunction · 0.85
pg_strdupFunction · 0.85
fmtIdFunction · 0.85
dumpACLFunction · 0.85
createPQExpBufferFunction · 0.85
buildACLQueriesFunction · 0.85
appendPQExpBufferFunction · 0.85
destroyPQExpBufferFunction · 0.85
ExecuteSqlQueryFunction · 0.85
PQntuplesFunction · 0.85
PQgetvalueFunction · 0.85

Tested by

no test coverage detected