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

Function GetStorageUserMapping

src/backend/commands/storagecmds.c:138–182  ·  view source on GitHub ↗

* GetStorgeUserMapping - look up the storage 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

136 * PUBLIC mappings (userid == InvalidOid).
137 */
138StorageUserMapping *
139GetStorageUserMapping(Oid userid, Oid serverid)
140{
141 Datum datum;
142 HeapTuple tp;
143 bool isnull;
144 StorageUserMapping *um;
145
146 tp = SearchSysCache2(STORAGEUSERMAPPINGUSERSERVER,
147 ObjectIdGetDatum(userid),
148 ObjectIdGetDatum(serverid));
149
150 if (!HeapTupleIsValid(tp))
151 {
152 /* Not found for the specific user -- try PUBLIC */
153 tp = SearchSysCache2(STORAGEUSERMAPPINGUSERSERVER,
154 ObjectIdGetDatum(InvalidOid),
155 ObjectIdGetDatum(serverid));
156 }
157
158 if (!HeapTupleIsValid(tp))
159 ereport(ERROR,
160 (errcode(ERRCODE_UNDEFINED_OBJECT),
161 errmsg("storage user mapping not found for \"%s\"",
162 StorageMappingUserName(userid))));
163
164 um = (StorageUserMapping *) palloc(sizeof(StorageUserMapping));
165 um->umid = ((Form_gp_storage_user_mapping) GETSTRUCT(tp))->oid;
166 um->userid = userid;
167 um->serverid = serverid;
168
169 /* Extract the umoptions */
170 datum = SysCacheGetAttr(STORAGEUSERMAPPINGUSERSERVER,
171 tp,
172 Anum_gp_storage_user_mapping_umoptions,
173 &isnull);
174 if (isnull)
175 um->options = NIL;
176 else
177 um->options = untransformRelOptions(datum);
178
179 ReleaseSysCache(tp);
180
181 return um;
182}
183
184
185/*

Callers

nothing calls this directly

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