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

Function getOperators

src/bin/pg_dump/pg_dump.c:6173–6246  ·  view source on GitHub ↗

* getOperators: * read all operators in the system catalogs and return them in the * OprInfo* structure * * numOprs is set to the number of operators read in */

Source from the content-addressed store, hash-verified

6171 * numOprs is set to the number of operators read in
6172 */
6173OprInfo *
6174getOperators(Archive *fout, int *numOprs)
6175{
6176 PGresult *res;
6177 int ntups;
6178 int i;
6179 PQExpBuffer query = createPQExpBuffer();
6180 OprInfo *oprinfo;
6181 int i_tableoid;
6182 int i_oid;
6183 int i_oprname;
6184 int i_oprnamespace;
6185 int i_rolname;
6186 int i_oprkind;
6187 int i_oprcode;
6188
6189 /*
6190 * find all operators, including builtin operators; we filter out
6191 * system-defined operators at dump-out time.
6192 */
6193
6194 appendPQExpBuffer(query, "SELECT tableoid, oid, oprname, "
6195 "oprnamespace, "
6196 "(%s oprowner) AS rolname, "
6197 "oprkind, "
6198 "oprcode::oid AS oprcode "
6199 "FROM pg_operator",
6200 username_subquery);
6201
6202 res = ExecuteSqlQuery(fout, query->data, PGRES_TUPLES_OK);
6203
6204 ntups = PQntuples(res);
6205 *numOprs = ntups;
6206
6207 oprinfo = (OprInfo *) pg_malloc(ntups * sizeof(OprInfo));
6208
6209 i_tableoid = PQfnumber(res, "tableoid");
6210 i_oid = PQfnumber(res, "oid");
6211 i_oprname = PQfnumber(res, "oprname");
6212 i_oprnamespace = PQfnumber(res, "oprnamespace");
6213 i_rolname = PQfnumber(res, "rolname");
6214 i_oprkind = PQfnumber(res, "oprkind");
6215 i_oprcode = PQfnumber(res, "oprcode");
6216
6217 for (i = 0; i < ntups; i++)
6218 {
6219 oprinfo[i].dobj.objType = DO_OPERATOR;
6220 oprinfo[i].dobj.catId.tableoid = atooid(PQgetvalue(res, i, i_tableoid));
6221 oprinfo[i].dobj.catId.oid = atooid(PQgetvalue(res, i, i_oid));
6222 AssignDumpId(&oprinfo[i].dobj);
6223 oprinfo[i].dobj.name = pg_strdup(PQgetvalue(res, i, i_oprname));
6224 oprinfo[i].dobj.namespace =
6225 findNamespace(atooid(PQgetvalue(res, i, i_oprnamespace)));
6226 oprinfo[i].rolname = pg_strdup(PQgetvalue(res, i, i_rolname));
6227 oprinfo[i].oprkind = (PQgetvalue(res, i, i_oprkind))[0];
6228 oprinfo[i].oprcode = atooid(PQgetvalue(res, i, i_oprcode));
6229
6230 /* Decide whether we want to dump it */

Callers 1

getSchemaDataFunction · 0.85

Calls 13

createPQExpBufferFunction · 0.85
appendPQExpBufferFunction · 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
findNamespaceFunction · 0.85
selectDumpableObjectFunction · 0.85
PQclearFunction · 0.85

Tested by

no test coverage detected