Affected rows are not counted for some update operations with views [CORE5241] #5520
Labels
affect-version: 2.1.7
affect-version: 2.5.0
affect-version: 2.5.1
affect-version: 2.5.2 Update 1
affect-version: 2.5.2
affect-version: 2.5.3 Update 1
affect-version: 2.5.3
affect-version: 2.5.4
affect-version: 2.5.5
affect-version: 3.0.0
affect-version: 4.0 Initial
component: engine
fix-version: 2.5.6
fix-version: 3.0.1
fix-version: 4.0 Alpha 1
priority: major
qa: done successfully
type: bug
Submitted by: Boltik Evgeny (bolt)
Partially caused by the old bugfix CORE578 which is totally wrong for PSQL with many updates, partially due to the changed rules for view updates in v2.0. The issue is not visible for DSQL updates and for single updates inside a PSQL block, it manifests itself only for multiple updates.
Simplified test case:
recreate table tbl (col int);
recreate view vtbl11 as select col from tbl;
recreate view vtbl12 as select col from vtbl11;
insert into tbl values (1);
commit;
set term ^;
execute block returns (out int)
as
begin
update tbl set col = 2;
out = row_count;
suspend;
update vtbl11 set col = 2;
out = row_count;
suspend;
update vtbl12 set col = 2;
out = row_count;
suspend;
end^
-- returns {1, 1, 1} - as expected
recreate trigger t_vtbl11 for vtbl11 before update as begin end^
recreate trigger t_vtbl12 for vtbl12 before update as begin end^
execute block returns (out int)
as
begin
update tbl set col = 2;
out = row_count;
suspend;
update vtbl11 set col = 2;
out = row_count;
suspend;
update vtbl12 set col = 2;
out = row_count;
suspend;
end^
-- wrongly returns {1, 0, 0}
execute block returns (out int)
as
begin
update vtbl11 set col = 2;
out = row_count;
suspend;
update vtbl12 set col = 2;
out = row_count;
suspend;
update tbl set col = 2;
out = row_count;
suspend;
end^
-- wrongly returns {1, 0, 1}
Correct ROW_COUNT is returned for real tables, for naturally updatable views and sometimes for the first trigger-backed view (if no tables were updated beforehand). All other views are "pseudo-updated" correctly but zero ROW_COUNT is returned. It doesn't make any difference whether a trigger performs something useful or not.
Additionally, wrong ROW_COUNT calculation makes UPDATE OR INSERT failing for trigger-backed views.
Commits: 9d0e4cb 5f19de8 9f3a009
The text was updated successfully, but these errors were encountered: