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
CREATE OR ALTER PROCEDURE HIDDEN_VARS
RETURNS (OUT_A INT, OUT_B1 INT, OUT_B2 INT)
AS
DECLARE A INT;
DECLARE C CURSOR FOR
(SELECT COALESCE( (SELECT COUNT(*) FROM RDB$RELATIONS), -1) FROM RDB$DATABASE);
DECLARE B INT = 0;
BEGIN
OUT_B1 = B;
OPEN C;
FETCH C INTO :A;
CLOSE C;
OUT_A = A;
OUT_B2 = B;
B = B + 1;
SUSPEND;
END
Results of first execution:
OUT_A OUT_B1 OUT_B2
353 0 353
Variable B was changed when cursor was fetched !
Second and all subsequent executions:
OUT_A OUT_B1 OUT_B2
353 354 353
Value of variable B keeped after procedure execution !
PSQL module could be affected by this bug if
- it contains variable declaration after cursor declaration, and
- cursor query contains COALESCE (and probably other simple CASE equivalents)
Notes:
1. As workaround one could try to declare cursors after all variables.
2. The bug affected generated BLR so it is necessary to recompile correspondig procedures\triggers using fixed engine.
3. FB3 seems not affected because of massive changes in related DSQL code.
Submitted by: @hvlad
Is related to QA608
Consider following procedure:
CREATE OR ALTER PROCEDURE HIDDEN_VARS
RETURNS (OUT_A INT, OUT_B1 INT, OUT_B2 INT)
AS
DECLARE A INT;
DECLARE C CURSOR FOR
(SELECT COALESCE( (SELECT COUNT(*) FROM RDB$RELATIONS), -1) FROM RDB$DATABASE);
DECLARE B INT = 0;
BEGIN
OUT_B1 = B;
OPEN C;
FETCH C INTO :A;
CLOSE C;
OUT_A = A;
OUT_B2 = B;
B = B + 1;
SUSPEND;
END
Results of first execution:
OUT_A OUT_B1 OUT_B2
353 0 353
Variable B was changed when cursor was fetched !
Second and all subsequent executions:
OUT_A OUT_B1 OUT_B2
353 354 353
Value of variable B keeped after procedure execution !
Commits: 650007a FirebirdSQL/fbt-repository@6396dfa FirebirdSQL/fbt-repository@402f4fe
The text was updated successfully, but these errors were encountered: