From d5fb9fb1acd738dbd112581e9de0c3cab31e07b3 Mon Sep 17 00:00:00 2001 From: lvhui Date: Mon, 29 Aug 2022 20:21:34 -0700 Subject: [PATCH] fix reviewer comment --- src/gausskernel/optimizer/commands/tablecmds.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gausskernel/optimizer/commands/tablecmds.cpp b/src/gausskernel/optimizer/commands/tablecmds.cpp index 677932f75..0463912c9 100644 --- a/src/gausskernel/optimizer/commands/tablecmds.cpp +++ b/src/gausskernel/optimizer/commands/tablecmds.cpp @@ -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) {