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

Function AlterStorageServer

src/backend/commands/storagecmds.c:432–515  ·  view source on GitHub ↗

* Alter Storage Server */

Source from the content-addressed store, hash-verified

430 * Alter Storage Server
431 */
432ObjectAddress
433AlterStorageServer(AlterStorageServerStmt *stmt)
434{
435 Relation rel;
436 HeapTuple tp;
437 Datum repl_val[Natts_gp_storage_server];
438 bool repl_null[Natts_gp_storage_server];
439 bool repl_repl[Natts_gp_storage_server];
440 Oid srvId;
441 Form_gp_storage_server srvForm;
442 ObjectAddress address = {0};
443
444 rel = table_open(StorageServerRelationId, RowExclusiveLock);
445
446 tp = SearchSysCacheCopy1(STORAGESERVERNAME,
447 CStringGetDatum(stmt->servername));
448
449 if (!HeapTupleIsValid(tp))
450 ereport(ERROR,
451 (errcode(ERRCODE_UNDEFINED_OBJECT),
452 errmsg("storage server \"%s\" does not exist", stmt->servername)));
453
454 srvForm = (Form_gp_storage_server) GETSTRUCT(tp);
455 srvId = srvForm->oid;
456
457 /*
458 * Only owner or a superuser can ALTER a STORAGE SERVER.
459 */
460 if (!gp_storage_server_ownercheck(srvId, GetUserId()))
461 aclcheck_error(ACLCHECK_NOT_OWNER, OBJECT_STORAGE_SERVER,
462 stmt->servername);
463
464 memset(repl_val, 0, sizeof(repl_val));
465 memset(repl_null, false, sizeof(repl_null));
466 memset(repl_repl, false, sizeof(repl_repl));
467
468 if (stmt->options)
469 {
470 Datum datum;
471 bool isnull;
472
473 /* Extract the current srvoptions */
474 datum = SysCacheGetAttr(STORAGESERVEROID,
475 tp,
476 Anum_gp_storage_server_srvoptions,
477 &isnull);
478 if (isnull)
479 datum = PointerGetDatum(NULL);
480
481 /* Prepare the options array */
482 datum = transformStorageGenericOptions(StorageServerRelationId,
483 datum,
484 stmt->options);
485 if (PointerIsValid(DatumGetPointer(datum)))
486 repl_val[Anum_gp_storage_server_srvoptions - 1] = datum;
487 else
488 repl_null[Anum_gp_storage_server_srvoptions - 1] = true;
489

Callers 1

ProcessUtilitySlowFunction · 0.85

Calls 15

table_openFunction · 0.85
CStringGetDatumFunction · 0.85
GetUserIdFunction · 0.85
aclcheck_errorFunction · 0.85
SysCacheGetAttrFunction · 0.85
heap_modify_tupleFunction · 0.85
CatalogTupleUpdateFunction · 0.85
heap_freetupleFunction · 0.85

Tested by

no test coverage detected