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

This commit is contained in:
teooooozhang
2022-09-01 21:02:59 +08:00
parent 053e438804
commit 491cbeebdb
4 changed files with 92 additions and 13 deletions

View File

@ -2141,10 +2141,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;
}
}
/*
@ -2434,9 +2437,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) {
@ -2646,9 +2654,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 */