!2624 【bugfixed】解决由于空指针导致的1.1.0升级到3.1.0后对外键表进行delete操作产生core的问题

Merge pull request !2624 from laishenghao/110up310
This commit is contained in:
opengauss-bot
2022-12-16 03:16:28 +00:00
committed by Gitee
3 changed files with 9 additions and 11 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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));