In PSQL modules with declared cursors engine could assign value to the wrong 
variable
-------------------------------------------------------------------------------------

                 Key: CORE-4233
                 URL: http://tracker.firebirdsql.org/browse/CORE-4233
             Project: Firebird Core
          Issue Type: Bug
          Components: Engine
    Affects Versions: 2.5.2 Update 1
            Reporter: Vlad Khorsun


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 !


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
LIMITED TIME SALE - Full Year of Microsoft Training For Just $49.99!
1,500+ hours of tutorials including VisualStudio 2012, Windows 8, SharePoint
2013, SQL 2012, MVC 4, more. BEST VALUE: New Multi-Library Power Pack includes
Mobile, Cloud, Java, and UX Design. Lowest price ever! Ends 9/22/13. 
http://pubads.g.doubleclick.net/gampad/clk?id=64545871&iu=/4140/ostg.clktrk
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to