!3609 on update current_timestamp特性对并发update修复

Merge pull request !3609 from 吕辉/update
This commit is contained in:
opengauss_bot
2023-06-26 06:15:53 +00:00
committed by Gitee
6 changed files with 63 additions and 8 deletions

View File

@ -2200,14 +2200,6 @@ TupleTableSlot* ExecUpdate(ItemPointer tupleid,
bool update_indexes = false;
LockTupleMode lockmode;
/* acquire Form_pg_attrdef ad_on_update */
if (result_relation_desc->rd_att->constr && result_relation_desc->rd_att->constr->has_on_update) {
bool update_fix_result = ExecComputeStoredUpdateExpr(result_rel_info, estate, slot, tuple, CMD_UPDATE, tupleid, oldPartitionOid, bucketid);
if (!update_fix_result) {
tuple = slot->tts_tuple;
}
}
/*
* Check the constraints of the tuple
*
@ -2220,6 +2212,14 @@ TupleTableSlot* ExecUpdate(ItemPointer tupleid,
Assert(RELATION_HAS_BUCKET(result_relation_desc) == (bucketid != InvalidBktId));
lreplace:
/* acquire Form_pg_attrdef ad_on_update */
if (result_relation_desc->rd_att->constr && result_relation_desc->rd_att->constr->has_on_update) {
bool update_fix_result = ExecComputeStoredUpdateExpr(result_rel_info, estate, slot, tuple, CMD_UPDATE, tupleid, oldPartitionOid, bucketid);
if (!update_fix_result) {
tuple = slot->tts_tuple;
}
}
/*
* Compute stored generated columns
*/

View File

@ -0,0 +1,25 @@
create database mysql_test dbcompatibility 'B';
\c mysql_test
create table tb666(c1 timestamp default current_timestamp on update current_timestamp, c2 int, c3 timestamp generated always as(c1+c2) stored);
insert into tb666 values(default, 1);
select * from tb666;
c1 | c2 | c3
--------------------------------+----+--------------------------------
--?.*
(1 row)
begin;
update tb666 set c2 = 2;
select * from tb666;
c1 | c2 | c3
---------------------------------+----+--------------------------------
--?.*
(1 row)
select pg_sleep(2);
pg_sleep
----------
(1 row)
commit;

View File

@ -0,0 +1,14 @@
select pg_sleep(2);
pg_sleep
----------
(1 row)
\c mysql_test
update tb666 set c2 = 3;
select * from tb666;
c1 | c2 | c3
---------------------------------+----+---------------------------------
--?.*
(1 row)

View File

@ -1089,3 +1089,5 @@ test: user_host_test
# test for new_expr_by_flatten
test: enable_expr_fusion_flatten
# test for on update timestamp and generated column
test: on_update_session1 on_update_session2

View File

@ -0,0 +1,10 @@
create database mysql_test dbcompatibility 'B';
\c mysql_test
create table tb666(c1 timestamp default current_timestamp on update current_timestamp, c2 int, c3 timestamp generated always as(c1+c2) stored);
insert into tb666 values(default, 1);
select * from tb666;
begin;
update tb666 set c2 = 2;
select * from tb666;
select pg_sleep(2);
commit;

View File

@ -0,0 +1,4 @@
select pg_sleep(2);
\c mysql_test
update tb666 set c2 = 3;
select * from tb666;