* dumpTable * write out to fout the declarations (not data) of a user-defined table */
| 17181 | * write out to fout the declarations (not data) of a user-defined table |
| 17182 | */ |
| 17183 | static void |
| 17184 | dumpTable(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, " |
no test coverage detected