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

Function ATExecAlterColumnGenericOptions

src/backend/commands/tablecmds.c:15462–15565  ·  view source on GitHub ↗

* ALTER COLUMN .. OPTIONS ( ... ) * * Returns the address of the modified column */

Source from the content-addressed store, hash-verified

15460 * Returns the address of the modified column
15461 */
15462static ObjectAddress
15463ATExecAlterColumnGenericOptions(Relation rel,
15464 const char *colName,
15465 List *options,
15466 LOCKMODE lockmode)
15467{
15468 Relation ftrel;
15469 Relation attrel;
15470 ForeignServer *server;
15471 ForeignDataWrapper *fdw;
15472 HeapTuple tuple;
15473 HeapTuple newtuple;
15474 bool isnull;
15475 Datum repl_val[Natts_pg_attribute];
15476 bool repl_null[Natts_pg_attribute];
15477 bool repl_repl[Natts_pg_attribute];
15478 Datum datum;
15479 Form_pg_foreign_table fttableform;
15480 Form_pg_attribute atttableform;
15481 AttrNumber attnum;
15482 ObjectAddress address;
15483
15484 if (options == NIL)
15485 return InvalidObjectAddress;
15486
15487 /* First, determine FDW validator associated to the foreign table. */
15488 ftrel = table_open(ForeignTableRelationId, AccessShareLock);
15489 tuple = SearchSysCache1(FOREIGNTABLEREL, rel->rd_id);
15490 if (!HeapTupleIsValid(tuple))
15491 ereport(ERROR,
15492 (errcode(ERRCODE_UNDEFINED_OBJECT),
15493 errmsg("foreign table \"%s\" does not exist",
15494 RelationGetRelationName(rel))));
15495 fttableform = (Form_pg_foreign_table) GETSTRUCT(tuple);
15496 server = GetForeignServer(fttableform->ftserver);
15497 fdw = GetForeignDataWrapper(server->fdwid);
15498
15499 table_close(ftrel, AccessShareLock);
15500 ReleaseSysCache(tuple);
15501
15502 attrel = table_open(AttributeRelationId, RowExclusiveLock);
15503 tuple = SearchSysCacheAttName(RelationGetRelid(rel), colName);
15504 if (!HeapTupleIsValid(tuple))
15505 ereport(ERROR,
15506 (errcode(ERRCODE_UNDEFINED_COLUMN),
15507 errmsg("column \"%s\" of relation \"%s\" does not exist",
15508 colName, RelationGetRelationName(rel))));
15509
15510 /* Prevent them from altering a system attribute */
15511 atttableform = (Form_pg_attribute) GETSTRUCT(tuple);
15512 attnum = atttableform->attnum;
15513 if (attnum <= 0)
15514 ereport(ERROR,
15515 (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
15516 errmsg("cannot alter system column \"%s\"", colName)));
15517
15518
15519 /* Initialize buffers for new tuple values */

Callers 1

ATExecCmdFunction · 0.85

Calls 14

table_openFunction · 0.85
SearchSysCache1Function · 0.85
GetForeignServerFunction · 0.85
GetForeignDataWrapperFunction · 0.85
table_closeFunction · 0.85
ReleaseSysCacheFunction · 0.85
SearchSysCacheAttNameFunction · 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