You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Submitted by: @dyemanov
Is related to QA161
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
Commits: 8d6f5c8 8aaef3c
The text was updated successfully, but these errors were encountered: