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

OLD/NEW.RDB$DB_KEY returns incorrect result in triggers [CORE1797] #2223

Closed
firebird-automations opened this issue Mar 21, 2008 · 11 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Maslov Pavel (macel)

Is related to QA340

Votes: 1

create or alter trigger testtable$trig1 for testtable
active after insert or update position 0
as
begin
insert into pooltable(id) values(new.rdb$db_key);
end

Commits: c25b340

@firebird-automations
Copy link
Collaborator Author

Commented by: Veselin Pavlov (pavlov_v)

I wanted to report the same issue but my use case is the following:

insert into TABLE_A(id) values (:id)
returning RDB$DB_KEY into :t_dbkey;

and "t_dbkey" is always null.

Tested with Firebird 2.1 RC2 and RC1

@firebird-automations
Copy link
Collaborator Author

Modified by: @dyemanov

assignee: Adriano dos Santos Fernandes [ asfernandes ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @asfernandes

We have two different problems here.

Test case for the original bug report in V2.0.3:

-------------------------
SQL> create table t (n integer)!
SQL> create table x (c char(8) character set octets)!
SQL> create trigger t_ai for t after insert
CON> as
CON> begin
CON> insert into x values (new.rdb$db_key);
CON> end!
SQL> insert into t values (1) returning rdb$db_key!

DB_KEY

8200000001000000

SQL> select rdb$db_key from t!

DB_KEY

8200000001000000

SQL> select * from x!

C

8200000001000000

SQL> insert into t values (2) returning rdb$db_key!

DB_KEY

8200000002000000

SQL> select rdb$db_key from t!

DB_KEY

8200000001000000
8200000002000000

SQL> select * from x!

C

8200000001000000
8200000001000000
-------------------------

You see in the last select, RDB$DB_KEY in after insert trigger returned incorrect value.

In V2.1 it returns NULL. Both are incorrect, but V2.0.3 is more problematic here.

About the problem with RETURNING, I'll create another ticket.

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

Version: 2.0.3 [ 10200 ]

summary: new.rdb$db_key returns NULL in after insert\update trigger => new.rdb$db_key returns incorrect result in after insert\update trigger

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

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

resolution: Fixed [ 1 ]

Fix Version: 2.5 Alpha 1 [ 10224 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @asfernandes

summary: new.rdb$db_key returns incorrect result in after insert\update trigger => OLD/NEW.RDB$DB_KEY returns incorrect result in triggers

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

Link: This issue is related to QA340 [ QA340 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @pcisar

QA test added.

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

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

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test

@firebird-automations
Copy link
Collaborator Author

Modified by: @pavel-zotov

QA Status: No test => Done successfully

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