29 #include "utils/fmgroids.h"
47 Node *expr,
bool is_internal,
bool add_column_mode)
53 static bool nulls[4] = {
false,
false,
false,
false};
82 defobject.
classId = AttrDefaultRelationId;
102 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
105 attgenerated = attStruct->attgenerated;
106 if (!attStruct->atthasdef)
114 Datum valuesAtt[Natts_pg_attribute] = {0};
115 bool nullsAtt[Natts_pg_attribute] = {0};
116 bool replacesAtt[Natts_pg_attribute] = {0};
118 bool missingIsNull =
true;
120 valuesAtt[Anum_pg_attribute_atthasdef - 1] =
true;
121 replacesAtt[Anum_pg_attribute_atthasdef - 1] =
true;
123 if (rel->
rd_rel->relkind == RELKIND_RELATION && add_column_mode &&
141 missingval = (
Datum) 0;
148 defAttStruct->atttypid,
149 defAttStruct->attlen,
150 defAttStruct->attbyval,
151 defAttStruct->attalign));
154 valuesAtt[Anum_pg_attribute_atthasmissing - 1] = !missingIsNull;
155 replacesAtt[Anum_pg_attribute_atthasmissing - 1] =
true;
156 valuesAtt[Anum_pg_attribute_attmissingval - 1] = missingval;
157 replacesAtt[Anum_pg_attribute_attmissingval - 1] =
true;
158 nullsAtt[Anum_pg_attribute_attmissingval - 1] = missingIsNull;
161 valuesAtt, nullsAtt, replacesAtt);
177 colobject.
classId = RelationRelationId;
225 Anum_pg_attrdef_adrelid,
229 Anum_pg_attrdef_adnum,
242 object.classId = AttrDefaultRelationId;
243 object.objectId = attrtuple->oid;
244 object.objectSubId = 0;
255 if (complain && !found)
256 elog(
ERROR,
"could not find attrdef tuple for relation %u attnum %d",
293 elog(
ERROR,
"could not find tuple for attrdef %u", attrdefId);
314 elog(
ERROR,
"cache lookup failed for attribute %d of relation %u",
349 Anum_pg_attrdef_adrelid,
354 Anum_pg_attrdef_adnum,
365 result = atdform->oid;
401 result.
classId = RelationRelationId;
ArrayType * construct_array(Datum *elems, int nelems, Oid elmtype, int elmlen, bool elmbyval, char elmalign)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
Oid GetNewOidWithIndex(Relation relation, Oid indexId, AttrNumber oidcolumn)
void performDeletion(const ObjectAddress *object, DropBehavior behavior, int flags)
void recordDependencyOnSingleRelExpr(const ObjectAddress *depender, Node *expr, Oid relId, DependencyType behavior, DependencyType self_behavior, bool reverse_self)
#define PERFORM_DELETION_INTERNAL
ExprState * ExecPrepareExpr(Expr *node, EState *estate)
EState * CreateExecutorState(void)
void FreeExecutorState(EState *estate)
#define GetPerTupleExprContext(estate)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
HeapTuple heap_modify_tuple(HeapTuple tuple, TupleDesc tupleDesc, const Datum *replValues, const bool *replIsnull, const bool *doReplace)
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define HeapTupleIsValid(tuple)
void CatalogTupleUpdate(Relation heapRel, ItemPointer otid, HeapTuple tup)
void CatalogTupleInsert(Relation heapRel, HeapTuple tup)
void CatalogTupleDelete(Relation heapRel, ItemPointer tid)
#define AccessExclusiveLock
void pfree(void *pointer)
#define InvokeObjectPostCreateHookArg(classId, objectId, subId, is_internal)
const ObjectAddress InvalidObjectAddress
char * nodeToString(const void *obj)
void RemoveAttrDefaultById(Oid attrdefId)
Oid GetAttrDefaultOid(Oid relid, AttrNumber attnum)
Oid StoreAttrDefault(Relation rel, AttrNumber attnum, Node *expr, bool is_internal, bool add_column_mode)
ObjectAddress GetAttrDefaultColumnAddress(Oid attrdefoid)
void RemoveAttrDefault(Oid relid, AttrNumber attnum, DropBehavior behavior, bool complain, bool internal)
FormData_pg_attrdef * Form_pg_attrdef
FormData_pg_attribute * Form_pg_attribute
void recordDependencyOn(const ObjectAddress *depender, const ObjectAddress *referenced, DependencyType behavior)
Expr * expression_planner(Expr *expr)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
#define SearchSysCacheCopy2(cacheId, key1, key2)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
#define TupleDescAttr(tupdesc, i)