!2114 issue修复:ignore_hint在update时唯一约束检查错误问题处理

Merge pull request !2114 from zhangzhixian/issue_ignore_update
This commit is contained in:
opengauss-bot
2022-09-19 02:58:13 +00:00
committed by Gitee
4 changed files with 92 additions and 13 deletions

View File

@ -2213,10 +2213,13 @@ lreplace:
estate->es_plannedstmt->hasIgnore &&
!ExecCheckIndexConstraints(slot, estate, result_relation_desc, partition, &isgpi, bucketid,
&conflictInfo, &conflictPartOid, &conflictBucketid)) {
ereport(WARNING,
(errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
// check whether the conflicted info is the update tuple. If not, report warning and return.
if (!ItemPointerEquals(&conflictInfo.conflictTid, tupleid)) {
ereport(WARNING,
(errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
}
}
/*
@ -2506,9 +2509,14 @@ lreplace:
if (can_ignore &&
!ExecCheckIndexConstraints(slot, estate, fake_relation, partition, &isgpi, bucketid,
&conflictInfo, &conflictPartOid, &conflictBucketid)) {
ereport(WARNING, (errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
// check whether the conflicted info is the update tuple. If not, report warning and return.
bool is_same_pointer = ItemPointerEquals(&conflictInfo.conflictTid, tupleid);
if (!is_same_pointer || oldPartitionOid != conflictPartOid) {
ereport(WARNING,
(errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
}
}
if (result_relation_desc->rd_isblockchain) {
@ -2718,9 +2726,14 @@ lreplace:
if (can_ignore &&
!ExecCheckIndexConstraints(slot, estate, fake_insert_relation, insert_partition, &isgpi,
bucketid, &conflictInfo, &conflictPartOid, &conflictBucketid)) {
ereport(WARNING, (errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
// check whether the conflicted info is the update tuple. If not, report warning and return.
bool is_same_pointer = ItemPointerEquals(&conflictInfo.conflictTid, tupleid);
if (!is_same_pointer || oldPartitionOid != conflictPartOid) {
ereport(WARNING,
(errmsg("duplicate key value violates unique constraint in table \"%s\"",
RelationGetRelationName(result_relation_desc))));
return NULL;
}
}
/* delete the old tuple */