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

Function ATExecCookedColumnDefault

src/backend/commands/tablecmds.c:9460–9484  ·  view source on GitHub ↗

* Add a pre-cooked default expression. * * Return the address of the affected column. */

Source from the content-addressed store, hash-verified

9458 * Return the address of the affected column.
9459 */
9460static ObjectAddress
9461ATExecCookedColumnDefault(Relation rel, AttrNumber attnum,
9462 Node *newDefault)
9463{
9464 ObjectAddress address;
9465
9466 /* We assume no checking is required */
9467
9468 /*
9469 * Remove any old default for the column. We use RESTRICT here for
9470 * safety, but at present we do not expect anything to depend on the
9471 * default. (In ordinary cases, there could not be a default in place
9472 * anyway, but it's possible when combining LIKE with inheritance.)
9473 */
9474 RemoveAttrDefault(RelationGetRelid(rel), attnum, DROP_RESTRICT, false,
9475 true);
9476
9477 (void) StoreAttrDefault(rel, attnum, newDefault,
9478 NULL, NULL, NULL, /* missing val stuff */
9479 true, false);
9480
9481 ObjectAddressSubSet(address, RelationRelationId,
9482 RelationGetRelid(rel), attnum);
9483 return address;
9484}
9485
9486/*
9487 * ALTER TABLE ALTER COLUMN ADD IDENTITY

Callers 1

ATExecCmdFunction · 0.85

Calls 2

RemoveAttrDefaultFunction · 0.85
StoreAttrDefaultFunction · 0.85

Tested by

no test coverage detected