Issue Details (XML | Word | Printable)

Key: CORE-1419
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dmitry Yemanov
Reporter: Dmitry Yemanov
Votes: 0
Watchers: 0
Operations

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

Wrong current timestamp evaluation for selectable procedures

Created: 20/Aug/07 08:12 AM   Updated: 03/Apr/08 10:00 AM
Component/s: Engine
Affects Version/s: 1.0.3, 1.5.2, 1.5.3, 2.0.0, 1.5.4, 2.0.1, 2.1 Alpha 1, 2.1 Beta 1
Fix Version/s: 2.1 Beta 2, 2.0.4

Time Tracking:
Not Specified

Environment: WinXP SP2
Issue Links:
Relate
 


 Description  « Hide
In our implementation, CURRENT_DATE/TIME[STAMP] values are evaluated at the request (aka SQL statement) start time and are permanent for the duration of that request. This rule includes the nested calls (procedures and triggers) as well, i.e. they inherit the parent's timestamp, thus providing the stable date-time value for the entire call stack. However, this rule is broken for selectable procedures that evaluate current date-time values at every invocation.

Test case:

set term ^;

create procedure ts1 returns ( ts timestamp )
as
begin
  ts = current_timestamp;
  suspend;
end^

create procedure ts2 returns ( ts_self timestamp, ts_execute timestamp, ts_select timestamp )
as
  declare cnt int = 1000000;
begin
  ts_self = current_timestamp;
  execute procedure ts1 returning_values :ts_execute;
  select ts from ts1 into :ts_select;
  suspend;

  while (cnt > 0) do
    cnt = cnt - 1;

  ts_self = current_timestamp;
  execute procedure ts1 returning_values :ts_execute;
  select ts from ts1 into :ts_select;
  suspend;
end^

set term ;^

commit;

select cast(ts_self as varchar(50)), cast(ts_execute as varchar(50)), cast(ts_select as varchar(50)) from ts2;
-- values in all the rows and columns should be the same


 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Philippe Makowski added a comment - 03/Apr/08 10:00 AM
Q/A test ok and qmtest made