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

COMPUTED BY field is evaluated as NULL if used as an exception parameter directly [CORE4117] #4445

Closed
firebird-automations opened this issue Jun 14, 2013 · 11 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: GR (gr)

Is related to QA514

CREATE TABLE TEST (
ID INTEGER NOT NULL,
C COMPUTED BY (id * 10)
);

CREATE EXCEPTION EX 'TEXT ';

INSERT INTO TEST(ID)
VALUES (1);

COMMIT;

1. Exception with computed by field as parameter

CREATE OR ALTER TRIGGER TEST_TR FOR TEST
ACTIVE BEFORE UPDATE POSITION 0
as
begin
exception ex new.c;
end

update TEST
set id = 2;

-- returns error without field value

EX.
TEXT .
At trigger 'TEST_TR' line: 5, col: 3.

2. Exception with computed by field as a part of expression

CREATE OR ALTER TRIGGER TEST_TR FOR TEST
ACTIVE BEFORE UPDATE POSITION 0
as
begin
exception ex new.c + 0; -- any expression
end

update TEST
set id = 2;

-- returns correct error with field value

EX.
20.
At trigger 'TEST_TR' line: 5, col: 3.

Commits: ae68898 2148e24 FirebirdSQL/fbt-repository@20ddd7f FirebirdSQL/fbt-repository@2824f4e

====== Test Details ======

Confirmed wrong output in 2.5.2: no value between
"-EX_BAD_COMPUTED_FIELD_VALUE"
and
"At trigger 'TEST1_BU' line: ***, col: ***"

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

I don't see how OLD or NEW context references to COMPUTED fields should be valid -- it just seems wrong.

@firebird-automations
Copy link
Collaborator Author

Commented by: arni (arni)

Both OLD and NEW contexts work fine for computed fields.
Problem starts when computed field uses in simplest expression, as argument of exception e.g.
In this case value of new.c is not evaluated:

exception ex new.c;

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Dmitry Yemanov [ dimitr ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

Version: 2.5.2 Update 1 [ 10521 ]

Version: 2.1.5 Update 1 [ 10522 ]

Version: 2.5.1 [ 10333 ]

Version: 2.1.4 [ 10361 ]

Version: 2.5.0 [ 10221 ]

Version: 2.0.6 [ 10303 ]

Version: 3.0 Initial [ 10301 ]

Version: 2.1.3 [ 10302 ]

Version: 2.1.2 [ 10270 ]

Version: 2.0.5 [ 10222 ]

Version: 2.1.1 [ 10223 ]

Version: 2.1.0 [ 10041 ]

Version: 3.0 Alpha 1 [ 10331 ] =>

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

summary: Ignoring computed by field as Exception parameter => COMPUTED BY field is evaluated as NULL if used as an exception parameter directly

Version: 3.0 Initial [ 10301 ] =>

@firebird-automations
Copy link
Collaborator Author

Commented by: @dyemanov

Fixed in v2.1 and v2.5 branches, v3.0 is not affected.

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

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

resolution: Fixed [ 1 ]

Fix Version: 2.5.3 [ 10461 ]

Fix Version: 2.1.6 [ 10460 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA514 [ QA514 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

QA Status: Done successfully

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

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

Test Details: Confirmed wrong output in 2.5.2: no value between
"-EX_BAD_COMPUTED_FIELD_VALUE"
and
"At trigger 'TEST1_BU' line: ***, col: ***"

@firebird-automations
Copy link
Collaborator Author

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