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

Function getNamespaces

src/bin/pg_dump/pg_dump.c:5680–5802  ·  view source on GitHub ↗

* getNamespaces: * read all namespaces in the system catalogs and return them in the * NamespaceInfo* structure * * numNamespaces is set to the number of namespaces read in */

Source from the content-addressed store, hash-verified

5678 * numNamespaces is set to the number of namespaces read in
5679 */
5680NamespaceInfo *
5681getNamespaces(Archive *fout, int *numNamespaces)
5682{
5683 DumpOptions *dopt = fout->dopt;
5684 PGresult *res;
5685 int ntups;
5686 int i;
5687 PQExpBuffer query;
5688 NamespaceInfo *nsinfo;
5689 int i_tableoid;
5690 int i_oid;
5691 int i_nspname;
5692 int i_rolname;
5693 int i_nspacl;
5694 int i_rnspacl;
5695 int i_initnspacl;
5696 int i_initrnspacl;
5697
5698 query = createPQExpBuffer();
5699
5700 /*
5701 * we fetch all namespaces including system ones, so that every object we
5702 * read in can be linked to a containing namespace.
5703 */
5704 if (fout->remoteVersion >= 90600)
5705 {
5706 PQExpBuffer acl_subquery = createPQExpBuffer();
5707 PQExpBuffer racl_subquery = createPQExpBuffer();
5708 PQExpBuffer init_acl_subquery = createPQExpBuffer();
5709 PQExpBuffer init_racl_subquery = createPQExpBuffer();
5710
5711 buildACLQueries(acl_subquery, racl_subquery, init_acl_subquery,
5712 init_racl_subquery, "n.nspacl", "n.nspowner", "'n'",
5713 dopt->binary_upgrade);
5714
5715 appendPQExpBuffer(query, "SELECT n.tableoid, n.oid, n.nspname, "
5716 "(%s nspowner) AS rolname, "
5717 "%s as nspacl, "
5718 "%s as rnspacl, "
5719 "%s as initnspacl, "
5720 "%s as initrnspacl "
5721 "FROM pg_namespace n "
5722 "LEFT JOIN pg_init_privs pip "
5723 "ON (n.oid = pip.objoid "
5724 "AND pip.classoid = 'pg_namespace'::regclass "
5725 "AND pip.objsubid = 0",
5726 username_subquery,
5727 acl_subquery->data,
5728 racl_subquery->data,
5729 init_acl_subquery->data,
5730 init_racl_subquery->data);
5731
5732 appendPQExpBufferStr(query, ") ");
5733
5734 destroyPQExpBuffer(acl_subquery);
5735 destroyPQExpBuffer(racl_subquery);
5736 destroyPQExpBuffer(init_acl_subquery);
5737 destroyPQExpBuffer(init_racl_subquery);

Callers 1

getSchemaDataFunction · 0.85

Calls 15

createPQExpBufferFunction · 0.85
buildACLQueriesFunction · 0.85
appendPQExpBufferFunction · 0.85
appendPQExpBufferStrFunction · 0.85
destroyPQExpBufferFunction · 0.85
ExecuteSqlQueryFunction · 0.85
PQntuplesFunction · 0.85
pg_mallocFunction · 0.85
PQfnumberFunction · 0.85
PQgetvalueFunction · 0.85
AssignDumpIdFunction · 0.85
pg_strdupFunction · 0.85

Tested by

no test coverage detected