Relation attrrel;
HeapTuple atttup;
Form_pg_attribute attStruct;
+ Datum valuesAtt[Natts_pg_attribute] = {0};
+ bool nullsAtt[Natts_pg_attribute] = {0};
+ bool replacesAtt[Natts_pg_attribute] = {0};
char attgenerated;
Oid attrdefOid;
ObjectAddress colobject,
attnum, RelationGetRelid(rel));
attStruct = (Form_pg_attribute) GETSTRUCT(atttup);
attgenerated = attStruct->attgenerated;
- if (!attStruct->atthasdef)
- {
- Datum valuesAtt[Natts_pg_attribute] = {0};
- bool nullsAtt[Natts_pg_attribute] = {0};
- bool replacesAtt[Natts_pg_attribute] = {0};
- valuesAtt[Anum_pg_attribute_atthasdef - 1] = BoolGetDatum(true);
- replacesAtt[Anum_pg_attribute_atthasdef - 1] = true;
+ valuesAtt[Anum_pg_attribute_atthasdef - 1] = BoolGetDatum(true);
+ replacesAtt[Anum_pg_attribute_atthasdef - 1] = true;
- atttup = heap_modify_tuple(atttup, RelationGetDescr(attrrel),
- valuesAtt, nullsAtt, replacesAtt);
+ atttup = heap_modify_tuple(atttup, RelationGetDescr(attrrel),
+ valuesAtt, nullsAtt, replacesAtt);
+
+ CatalogTupleUpdate(attrrel, &atttup->t_self, atttup);
- CatalogTupleUpdate(attrrel, &atttup->t_self, atttup);
- }
table_close(attrrel, RowExclusiveLock);
heap_freetuple(atttup);
* while raw defaults go into a list of RawColumnDefault structs that will
* be processed by AddRelationNewConstraints. (We can't deal with raw
* expressions until we can do transformExpr.)
- *
- * We can set the atthasdef flags now in the tuple descriptor; this just
- * saves StoreAttrDefault from having to do an immediate update of the
- * pg_attribute rows.
*/
rawDefaults = NIL;
cookedDefaults = NIL;
foreach(listptr, stmt->tableElts)
{
ColumnDef *colDef = lfirst(listptr);
- Form_pg_attribute attr;
attnum++;
- attr = TupleDescAttr(descriptor, attnum - 1);
-
if (colDef->raw_default != NULL)
{
RawColumnDefault *rawEnt;
rawEnt->raw_default = colDef->raw_default;
rawEnt->generated = colDef->generated;
rawDefaults = lappend(rawDefaults, rawEnt);
- attr->atthasdef = true;
}
else if (colDef->cooked_default != NULL)
{
cooked->inhcount = 0; /* ditto */
cooked->is_no_inherit = false;
cookedDefaults = lappend(cookedDefaults, cooked);
- attr->atthasdef = true;
}
-
- populate_compact_attribute(descriptor, attnum - 1);
}
/*
* and the later subcommands had been issued in new ALTER TABLE commands.
*
* We can skip this entirely for relations without storage, since Phase 3
- * is certainly not going to touch them. System attributes don't have
- * interesting defaults, either.
+ * is certainly not going to touch them.
*/
if (RELKIND_HAS_STORAGE(relkind))
{