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

Function GetUserMapping

src/backend/foreign/foreign.c:301–345  ·  view source on GitHub ↗

* GetUserMapping - look up the user mapping. * * If no mapping is found for the supplied user, we also look for * PUBLIC mappings (userid == InvalidOid). */

Source from the content-addressed store, hash-verified

299 * PUBLIC mappings (userid == InvalidOid).
300 */
301UserMapping *
302GetUserMapping(Oid userid, Oid serverid)
303{
304 Datum datum;
305 HeapTuple tp;
306 bool isnull;
307 UserMapping *um;
308
309 tp = SearchSysCache2(USERMAPPINGUSERSERVER,
310 ObjectIdGetDatum(userid),
311 ObjectIdGetDatum(serverid));
312
313 if (!HeapTupleIsValid(tp))
314 {
315 /* Not found for the specific user -- try PUBLIC */
316 tp = SearchSysCache2(USERMAPPINGUSERSERVER,
317 ObjectIdGetDatum(InvalidOid),
318 ObjectIdGetDatum(serverid));
319 }
320
321 if (!HeapTupleIsValid(tp))
322 ereport(ERROR,
323 (errcode(ERRCODE_UNDEFINED_OBJECT),
324 errmsg("user mapping not found for \"%s\"",
325 MappingUserName(userid))));
326
327 um = (UserMapping *) palloc(sizeof(UserMapping));
328 um->umid = ((Form_pg_user_mapping) GETSTRUCT(tp))->oid;
329 um->userid = userid;
330 um->serverid = serverid;
331
332 /* Extract the umoptions */
333 datum = SysCacheGetAttr(USERMAPPINGUSERSERVER,
334 tp,
335 Anum_pg_user_mapping_umoptions,
336 &isnull);
337 if (isnull)
338 um->options = NIL;
339 else
340 um->options = untransformRelOptions(datum);
341
342 ReleaseSysCache(tp);
343
344 return um;
345}
346
347List *
348GetForeignServerSegsByRelId(Oid relid)

Callers 11

postgresBeginForeignScanFunction · 0.85
create_foreign_modifyFunction · 0.85
get_connect_stringFunction · 0.85
PxfGetOptionsFunction · 0.85

Calls 8

SearchSysCache2Function · 0.85
ObjectIdGetDatumFunction · 0.85
SysCacheGetAttrFunction · 0.85
untransformRelOptionsFunction · 0.85
ReleaseSysCacheFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50
pallocFunction · 0.50

Tested by

no test coverage detected