diff --git a/src/gausskernel/runtime/executor/execUtils.cpp b/src/gausskernel/runtime/executor/execUtils.cpp index c157b3b9c805429934ec897e5cfe3de1e5daa65d..cdee958a7dce97d88c8df638c2a6efccfcfdecf9 100644 --- a/src/gausskernel/runtime/executor/execUtils.cpp +++ b/src/gausskernel/runtime/executor/execUtils.cpp @@ -2805,10 +2805,10 @@ void PthreadRwLockInit(pthread_rwlock_t* rwlock, pthread_rwlockattr_t *attr) /* * Get defaulted value of specific type */ -Datum GetTypeZeroValue(Form_pg_attribute att_tup) +Datum GetTypeZeroValue(Form_pg_attribute att_tup, bool can_ignore) { if (u_sess->hook_cxt.getTypeZeroValueHook != NULL) { - return ((getTypeZeroValueFunc)(u_sess->hook_cxt.getTypeZeroValueHook))(att_tup); + return ((getTypeZeroValueFunc)(u_sess->hook_cxt.getTypeZeroValueHook))(att_tup, can_ignore); } Datum result; switch (att_tup->atttypid) { @@ -2970,7 +2970,7 @@ Datum GetTypeZeroValue(Form_pg_attribute att_tup) * Replace tuple from the slot with a new one. The new tuple will replace null column with defaulted values according to * its type. */ -Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot *slot) +Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot *slot, bool canIgnore) { /* find out all null column first */ int natts = tupleDesc->natts; @@ -2989,7 +2989,7 @@ Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot *slot) int attrChk; for (attrChk = 1; attrChk <= natts; attrChk++) { if (tupleDesc->attrs[attrChk - 1].attnotnull && tableam_tslot_attisnull(slot, attrChk)) { - values[attrChk - 1] = GetTypeZeroValue(&tupleDesc->attrs[attrChk - 1]); + values[attrChk - 1] = GetTypeZeroValue(&tupleDesc->attrs[attrChk - 1], canIgnore); replaces[attrChk - 1] = true; } } diff --git a/src/gausskernel/runtime/executor/nodeModifyTable.cpp b/src/gausskernel/runtime/executor/nodeModifyTable.cpp index 00beaa1d9f9a54aaf55a353bc66360845a544736..dc4556c59ae85f5f3689b85462a19e42ce442f0a 100644 --- a/src/gausskernel/runtime/executor/nodeModifyTable.cpp +++ b/src/gausskernel/runtime/executor/nodeModifyTable.cpp @@ -1203,7 +1203,8 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple TupleTableSlot *tmp_slot = state->mt_insert_constr_slot == NULL ? slot : state->mt_insert_constr_slot; if (!ExecConstraints(result_rel_info, tmp_slot, estate, false, replaceNull)) { if (u_sess->utils_cxt.sql_ignore_strategy_val == SQL_OVERWRITE_NULL) { - tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot); + bool can_ignore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; + tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot, can_ignore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, tmp_slot, estate); @@ -1248,7 +1249,8 @@ TupleTableSlot* ExecInsertT(ModifyTableState* state, TupleTableSlot* slot, Tuple TupleTableSlot *tmp_slot = state->mt_insert_constr_slot == NULL ? slot : state->mt_insert_constr_slot; if (!ExecConstraints(result_rel_info, tmp_slot, estate, true, replaceNull)) { if (u_sess->utils_cxt.sql_ignore_strategy_val == SQL_OVERWRITE_NULL) { - tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot); + bool canIgnore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; + tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot, canIgnore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, tmp_slot, estate, true); @@ -2250,7 +2252,8 @@ TupleTableSlot* ExecUpdate(ItemPointer tupleid, TupleTableSlot *tmp_slot = node->mt_insert_constr_slot == NULL ? slot : node->mt_insert_constr_slot; if (!ExecConstraints(result_rel_info, tmp_slot, estate, false, CheckPluginReplaceNull())) { if (u_sess->utils_cxt.sql_ignore_strategy_val == SQL_OVERWRITE_NULL) { - tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot); + bool can_ignore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; + tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot, can_ignore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, tmp_slot, estate); @@ -2311,7 +2314,8 @@ lreplace: TupleTableSlot *tmp_slot = node->mt_update_constr_slot == NULL ? slot : node->mt_update_constr_slot; if (!ExecConstraints(result_rel_info, tmp_slot, estate, false, CheckPluginReplaceNull())) { if (u_sess->utils_cxt.sql_ignore_strategy_val == SQL_OVERWRITE_NULL) { - tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot); + bool canIgnore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; + tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot, canIgnore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, tmp_slot, estate); diff --git a/src/gausskernel/runtime/opfusion/opfusion_insert.cpp b/src/gausskernel/runtime/opfusion/opfusion_insert.cpp index 81be5e743016feb3784b04e624c28a0df96356d3..70765928f7f1f63b9d205902a33001b7b314e0ff 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_insert.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_insert.cpp @@ -333,7 +333,9 @@ unsigned long InsertFusion::ExecInsert(Relation rel, ResultRelInfo* result_rel_i partRel); return 0; } - tuple = ReplaceTupleNullCol(RelationGetDescr(result_rel_info->ri_RelationDesc), m_local.m_reslot); + bool can_ignore = m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore; + tuple = + ReplaceTupleNullCol(RelationGetDescr(result_rel_info->ri_RelationDesc), m_local.m_reslot, can_ignore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, m_local.m_reslot, m_c_local.m_estate, true); @@ -832,7 +834,8 @@ TupleTableSlot* insert_real(ModifyTableState* state, TupleTableSlot* slot, EStat /* do nothing */ } else if (!ExecConstraints(result_rel_info, tmp_slot, estate, true)) { if (u_sess->utils_cxt.sql_ignore_strategy_val == SQL_OVERWRITE_NULL) { - tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot); + bool canIgnore = estate->es_plannedstmt && estate->es_plannedstmt->hasIgnore; + tuple = ReplaceTupleNullCol(RelationGetDescr(result_relation_desc), tmp_slot, canIgnore); /* * Double check constraints in case that new val in column with not null constraints * violated check constraints diff --git a/src/gausskernel/runtime/opfusion/opfusion_update.cpp b/src/gausskernel/runtime/opfusion/opfusion_update.cpp index 10aae0eadc29e508e632bae02dfadc9d1e299e5a..3ecc91f268ca1d2c90cfce0c931b8c2cc26b3368 100644 --- a/src/gausskernel/runtime/opfusion/opfusion_update.cpp +++ b/src/gausskernel/runtime/opfusion/opfusion_update.cpp @@ -404,7 +404,9 @@ lreplace: if (u_sess->utils_cxt.sql_ignore_strategy_val != SQL_OVERWRITE_NULL) { break; } - tup = ReplaceTupleNullCol(RelationGetDescr(result_rel_info->ri_RelationDesc), m_local.m_reslot); + bool can_ignore = m_c_local.m_estate->es_plannedstmt && m_c_local.m_estate->es_plannedstmt->hasIgnore; + tup = ReplaceTupleNullCol(RelationGetDescr(result_rel_info->ri_RelationDesc), m_local.m_reslot, + can_ignore); /* Double check constraints in case that new val in column with not null constraints * violated check constraints */ ExecConstraints(result_rel_info, m_local.m_reslot, m_c_local.m_estate); diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index 94559077f097ac8021357e4eb71fe61f10f0a734..b00565f835e564d831cd8508b1a77528f850c76d 100755 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -733,8 +733,7 @@ extern void ExecSimpleRelationDelete(EState *estate, EPQState *epqstate, TupleTa FakeRelationPartition *relAndPart); extern void CheckCmdReplicaIdentity(Relation rel, CmdType cmd); extern void GetFakeRelAndPart(EState *estate, Relation rel, TupleTableSlot *slot, FakeRelationPartition *relAndPart); -extern Datum GetTypeZeroValue(Form_pg_attribute att_tup); -extern Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot* slot); +extern Tuple ReplaceTupleNullCol(TupleDesc tupleDesc, TupleTableSlot* slot, bool canIgnore = false); extern Datum ExecEvalArrayRef(ArrayRefExprState* astate, ExprContext* econtext, bool* isNull, ExprDoneCond* isDone); extern int ResourceOwnerForgetIfExistPthreadMutex(ResourceOwner owner, pthread_mutex_t* pMutex, bool trace); diff --git a/src/include/parser/parse_expr.h b/src/include/parser/parse_expr.h index fd8b6b2d36bce2d570df3643518d25005824ebd5..40713c8aee0f61550a7dc799b767c4532163117b 100644 --- a/src/include/parser/parse_expr.h +++ b/src/include/parser/parse_expr.h @@ -37,8 +37,8 @@ extern void AddStartWithTargetRelInfo(ParseState* pstate, Node* relNode, extern void AdaptSWSelectStmt(ParseState *pstate, SelectStmt *stmt); extern bool IsQuerySWCBRewrite(Query *query); extern bool IsSWCBRewriteRTE(RangeTblEntry *rte); -extern Datum GetTypeZeroValue(Form_pg_attribute att_tup); -typedef Datum (*getTypeZeroValueFunc)(Form_pg_attribute att_tup); +extern Datum GetTypeZeroValue(Form_pg_attribute att_tup, bool can_ignore = false); +typedef Datum (*getTypeZeroValueFunc)(Form_pg_attribute att_tup, bool can_ignore); extern PlannedStmt* getCursorStreamFromFuncArg(Node* node, CursorExpression** ce = NULL); #endif /* PARSE_EXPR_H */