Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Affected rows are not counted for some update operations with views [CORE5241] #5520

Closed
firebird-issue-importer opened this issue May 16, 2016 · 5 comments

Comments

@firebird-issue-importer

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

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 16, 2016

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 16, 2016

Modified by: @dyemanov

reporter: Dmitry Yemanov [ dimitr ] => Boltik Evgeny [ bolt ]

Fix Version: 3.0.1 [ 10730 ]

Fix Version: 4.0 Alpha 1 [ 10731 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 17, 2016

Modified by: @dyemanov

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.5.6 [ 10721 ]

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 17, 2016

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Resolved [ 5 ]

QA Status: No test => Done successfully

@firebird-issue-importer
Copy link
Author

firebird-issue-importer commented May 17, 2016

Modified by: @pavel-zotov

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment