Affected rows are not counted for some update operations with views
-------------------------------------------------------------------

                 Key: CORE-5241
                 URL: http://tracker.firebirdsql.org/browse/CORE-5241
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 3.0.0, 4.0 Initial, 2.5.5, 2.5.4, 2.5.3 Update 1, 2.1.7, 
2.5.3, 2.5.2 Update 1, 2.5.2, 2.5.1, 2.5.0
            Reporter: Dmitry Yemanov


Partially caused by the old bugfix CORE-578 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.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to