fix reviewer comment

This commit is contained in:
lvhui
2022-08-29 20:21:34 -07:00
parent efbb94ce44
commit d5fb9fb1ac

View File

@ -12995,13 +12995,6 @@ static void ATExecAlterColumnType(AlteredTableInfo* tab, Relation rel, AlterTabl
Node* update_expr = NULL;
bool flagDropOnUpdateTimestamp = false;
bool existOnUpdateTimestamp = false;
/* def->constraints maybe is null when execute sql(alter table x alter column type new_type) */
if (cmd->subtype == AT_AlterColumnType && def->constraints && def->constraints->head) {
Constraint* temp_cons = (Constraint*)lfirst(def->constraints->head);
if (temp_cons->contype == CONSTR_DEFAULT && temp_cons->update_expr != NULL) {
update_expr = temp_cons->update_expr;
}
}
attrelation = heap_open(AttributeRelationId, RowExclusiveLock);
@ -13327,6 +13320,14 @@ static void ATExecAlterColumnType(AlteredTableInfo* tab, Relation rel, AlterTabl
RemoveStatistics<'c'>(RelationGetRelid(rel), attnum);
}
/* def->constraints maybe is null when execute sql(alter table x alter column type new_type) */
if (cmd->subtype == AT_AlterColumnType && def->constraints && def->constraints->head) {
Constraint* temp_cons = (Constraint*)lfirst(def->constraints->head);
if (temp_cons->contype == CONSTR_DEFAULT && temp_cons->update_expr != NULL) {
update_expr = temp_cons->update_expr;
}
}
/* when the default expr is NULL and on update expr exist, the defaultexpr should be NULL.
* because the build_column_default maybe return the on update expr. */
if (rel->rd_att->constr && rel->rd_att->constr->num_defval > 0) {