Issue Details (XML | Word | Printable)

Key: CORE-1797
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano dos Santos Fernandes
Reporter: Maslov Pavel
Votes: 1
Watchers: 1
Operations

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

OLD/NEW.RDB$DB_KEY returns incorrect result in triggers

Created: 21/Mar/08 02:47 AM   Updated: 21/Apr/11 08:03 AM
Component/s: Engine
Affects Version/s: 2.0.3, 2.5 Initial, 2.1 RC2
Fix Version/s: 2.5 Alpha 1

Time Tracking:
Not Specified

Issue Links:
Relate
 

Planning Status: Unspecified


 Description  « Hide
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

 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Veselin Pavlov added a comment - 21/Mar/08 03:38 AM - edited
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

Adriano dos Santos Fernandes added a comment - 21/Mar/08 12:59 PM
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.

Pavel Cisar added a comment - 21/Apr/11 08:03 AM
QA test added.