Issue Details (XML | Word | Printable)

Key: CORE-5337
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Vlad Khorsun
Reporter: Simonov Denis
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Regression: The subquery in the insert list expressions ignore the changes made earlier in the same executable block.

Created: 24/Aug/16 01:32 PM   Updated: 26/Sep/16 07:02 PM
Component/s: None
Affects Version/s: 3.0.0
Fix Version/s: 3.0.1, 4.0 Alpha 1

QA Status: Done successfully


 Description  « Hide
WI-V6.3.0.32483 Firebird 3.0

CREATE TABLE TEST (
    ID INTEGER NOT NULL,
    VAL INTEGER NOT NULL
);

execute block
as
begin
  insert into test (id, val) values (1, 100);
  insert into test (id, val) values (2, (select val from test where id = 1));
end

The insert failed because a column definition includes validation constraints.
validation error for column "TEST"."VAL", value "*** null ***".

However, here is a code works without error.

execute block
as
declare v integer;
begin
  insert into test (id, val) values (1, 100);
  select val from test where id = 1 into :v;
  insert into test (id, val) values (2, :v);
end

This ticket is related with CORE-3362.

 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Vlad Khorsun added a comment - 21/Sep/16 09:45 AM
The issue occurs with the following conditions:
- PSQL block contains a few DML statements
- INSERT or UPDATE OR INSERT statement have subselect in VALUES expressions
- subselect queries table which was changed by some previous DML statement in the same PSQL block

Standalone subqueries are not affected.
INSERT INTO ... SELECT FROM are not affected.
UPDATE, DELETE and MERGE statements are not affected.

Vlad Khorsun added a comment - 21/Sep/16 09:47 AM
Fix is committed into master (v4).
Fix changes generated BLR code.
So, if affected code present in stored procedure\function\trigger - it should be recompiled to changes have effect.

Simonov Denis added a comment - 21/Sep/16 11:09 AM
Will this fix ported to 3.0.1?