From f08b47122927084b2ba57c46069023c89be9b73d Mon Sep 17 00:00:00 2001 From: laishenghao Date: Mon, 12 Dec 2022 17:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=94=B1=E4=BA=8E=E7=A9=BA?= =?UTF-8?q?=E6=8C=87=E9=92=88=E5=AF=BC=E8=87=B4=E7=9A=841.1.0=E5=8D=87?= =?UTF-8?q?=E7=BA=A7=E5=88=B03.1.0=E5=90=8E=E5=AF=B9=E5=A4=96=E9=94=AE?= =?UTF-8?q?=E8=A1=A8=E8=BF=9B=E8=A1=8Cdelete=E6=93=8D=E4=BD=9C=E4=BA=A7?= =?UTF-8?q?=E7=94=9Fcore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/adt/ruleutils.cpp | 6 +++--- src/common/backend/utils/cache/relcache.cpp | 6 +++--- src/gausskernel/optimizer/rewrite/rewriteHandler.cpp | 8 +++----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/common/backend/utils/adt/ruleutils.cpp b/src/common/backend/utils/adt/ruleutils.cpp index bc9cdb3b2..e1f46cc79 100644 --- a/src/common/backend/utils/adt/ruleutils.cpp +++ b/src/common/backend/utils/adt/ruleutils.cpp @@ -1664,10 +1664,10 @@ static int get_table_attribute( isDefault = true; } Datum onUpdateExpr = fastgetattr(tup, Anum_pg_attrdef_adsrc_on_update, attrdefDesc->rd_att, &isnull); - if (onUpdateExpr && pg_strcasecmp(TextDatumGetCString(onUpdateExpr), "") == 0) { - isOnUpdate = false; - } else { + if (onUpdateExpr && pg_strcasecmp(TextDatumGetCString(onUpdateExpr), "") != 0) { isOnUpdate = true; + } else { + isOnUpdate = false; } if (attrdef->adnum == att_tup->attnum) { diff --git a/src/common/backend/utils/cache/relcache.cpp b/src/common/backend/utils/cache/relcache.cpp index a473457cb..a202f72c6 100644 --- a/src/common/backend/utils/cache/relcache.cpp +++ b/src/common/backend/utils/cache/relcache.cpp @@ -5665,10 +5665,10 @@ static void UpdatedColFetch(TupleConstr *constr, HeapTuple htup, Relation adrel, bool isnull = false; Datum val; val = fastgetattr(htup, Anum_pg_attrdef_adsrc_on_update, adrel->rd_att, &isnull); - if (val && pg_strcasecmp(TextDatumGetCString(val), "") == 0) { - updatedCol = false; - } else { + if (val && pg_strcasecmp(TextDatumGetCString(val), "") != 0) { updatedCol = true; + } else { + updatedCol = false; } } attrdef[attrdefIndex].has_on_update = updatedCol; diff --git a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp index 2e3de2ac6..6d1ff0c7b 100644 --- a/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp +++ b/src/gausskernel/optimizer/rewrite/rewriteHandler.cpp @@ -1173,13 +1173,11 @@ Node* build_column_default(Relation rel, int attrno, bool isInsertCmd, bool need * if adbin is not null character string, then doing convert adbin to expression. */ - if (needOnUpdate && (!isInsertCmd) && defval[ndef].has_on_update && + if (needOnUpdate && (!isInsertCmd) && defval[ndef].adbin_on_update != nullptr && pg_strcasecmp(defval[ndef].adbin_on_update, "") != 0) { expr = (Node*)stringToNode_skip_extern_fields(defval[ndef].adbin_on_update); - } else { - if (pg_strcasecmp(defval[ndef].adbin, "") != 0) { - expr = (Node*)stringToNode_skip_extern_fields(defval[ndef].adbin); - } + } else if (defval[ndef].adbin != nullptr && pg_strcasecmp(defval[ndef].adbin, "") != 0) { + expr = (Node*)stringToNode_skip_extern_fields(defval[ndef].adbin); } if (t_thrd.proc->workingVersionNum < LARGE_SEQUENCE_VERSION_NUM) { (void)check_sequence_return_numeric_walker(expr, &(u_sess->opt_cxt.nextval_default_expr_type));