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

Function AlterUserMapping

src/backend/commands/foreigncmds.c:1362–1462  ·  view source on GitHub ↗

* Alter user mapping */

Source from the content-addressed store, hash-verified

1360 * Alter user mapping
1361 */
1362ObjectAddress
1363AlterUserMapping(AlterUserMappingStmt *stmt)
1364{
1365 Relation rel;
1366 HeapTuple tp;
1367 Datum repl_val[Natts_pg_user_mapping];
1368 bool repl_null[Natts_pg_user_mapping];
1369 bool repl_repl[Natts_pg_user_mapping];
1370 Oid useId;
1371 Oid umId;
1372 ForeignServer *srv;
1373 ObjectAddress address;
1374 RoleSpec *role = (RoleSpec *) stmt->user;
1375
1376 rel = table_open(UserMappingRelationId, RowExclusiveLock);
1377
1378 if (role->roletype == ROLESPEC_PUBLIC)
1379 useId = ACL_ID_PUBLIC;
1380 else
1381 useId = get_rolespec_oid(stmt->user, false);
1382
1383 srv = GetForeignServerByName(stmt->servername, false);
1384
1385 umId = GetSysCacheOid2(USERMAPPINGUSERSERVER, Anum_pg_user_mapping_oid,
1386 ObjectIdGetDatum(useId),
1387 ObjectIdGetDatum(srv->serverid));
1388 if (!OidIsValid(umId))
1389 ereport(ERROR,
1390 (errcode(ERRCODE_UNDEFINED_OBJECT),
1391 errmsg("user mapping for \"%s\" does not exist for server \"%s\"",
1392 MappingUserName(useId), stmt->servername)));
1393
1394 user_mapping_ddl_aclcheck(useId, srv->serverid, stmt->servername);
1395
1396 tp = SearchSysCacheCopy1(USERMAPPINGOID, ObjectIdGetDatum(umId));
1397
1398 if (!HeapTupleIsValid(tp))
1399 elog(ERROR, "cache lookup failed for user mapping %u", umId);
1400
1401 memset(repl_val, 0, sizeof(repl_val));
1402 memset(repl_null, false, sizeof(repl_null));
1403 memset(repl_repl, false, sizeof(repl_repl));
1404
1405 if (stmt->options)
1406 {
1407 ForeignDataWrapper *fdw;
1408 Datum datum;
1409 bool isnull;
1410
1411 /*
1412 * Process the options.
1413 */
1414
1415 fdw = GetForeignDataWrapper(srv->fdwid);
1416
1417 datum = SysCacheGetAttr(USERMAPPINGUSERSERVER,
1418 tp,
1419 Anum_pg_user_mapping_umoptions,

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

table_openFunction · 0.85
get_rolespec_oidFunction · 0.85
GetForeignServerByNameFunction · 0.85
ObjectIdGetDatumFunction · 0.85
GetForeignDataWrapperFunction · 0.85
SysCacheGetAttrFunction · 0.85
transformGenericOptionsFunction · 0.85
heap_modify_tupleFunction · 0.85
CatalogTupleUpdateFunction · 0.85
heap_freetupleFunction · 0.85

Tested by

no test coverage detected