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

Function dbms_assert_schema_name

gpcontrib/orafce/assert.c:249–313  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

247 ****************************************************************/
248
249Datum
250dbms_assert_schema_name(PG_FUNCTION_ARGS)
251{
252 Oid namespaceId;
253 AclResult aclresult;
254 text *sname;
255 char *nspname;
256 List *names;
257
258 if (PG_ARGISNULL(0))
259 INVALID_SCHEMA_NAME_EXCEPTION();
260
261 sname = PG_GETARG_TEXT_P(0);
262 if (EMPTY_STR(sname))
263 INVALID_SCHEMA_NAME_EXCEPTION();
264
265 nspname = text_to_cstring(sname);
266
267#if PG_VERSION_NUM >= 160000
268
269 names = stringToQualifiedNameList(nspname, NULL);
270
271#else
272
273 names = stringToQualifiedNameList(nspname);
274
275#endif
276
277 if (list_length(names) != 1)
278 INVALID_SCHEMA_NAME_EXCEPTION();
279
280#if PG_VERSION_NUM >= 120000
281
282 namespaceId = GetSysCacheOid(NAMESPACENAME, Anum_pg_namespace_oid,
283 CStringGetDatum(strVal(linitial(names))),
284 0, 0, 0);
285
286#else
287
288 namespaceId = GetSysCacheOid(NAMESPACENAME,
289 CStringGetDatum(strVal(linitial(names))),
290 0, 0, 0);
291
292#endif
293
294
295 if (!OidIsValid(namespaceId))
296 INVALID_SCHEMA_NAME_EXCEPTION();
297
298#if PG_VERSION_NUM >= 160000
299
300 aclresult = object_aclcheck(NamespaceRelationId,namespaceId, GetUserId(),
301 ACL_USAGE);
302
303#else
304
305 aclresult = pg_namespace_aclcheck(namespaceId, GetUserId(), ACL_USAGE);
306

Callers

nothing calls this directly

Calls 7

text_to_cstringFunction · 0.85
list_lengthFunction · 0.85
GetSysCacheOidFunction · 0.85
CStringGetDatumFunction · 0.85
GetUserIdFunction · 0.85
pg_namespace_aclcheckFunction · 0.85

Tested by

no test coverage detected