-
-
Notifications
You must be signed in to change notification settings - Fork 233
Incorrect result of recursive CTE query when recursive member's SELECT list contains expression using self-referenced fields [CORE1373] #1791
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Commented by: @hvlad Solution is to create separate contexts (records) for current and next levels of recursive select. blr_recursive, <main context number>, <secondary context number>, <number of union's members> Therefore any stored objects (stored procedures, triggers, views, etc) with recursive CTE's must be recreated |
Modified by: @pcisarWorkflow: jira [ 12640 ] => Firebird [ 14230 ] |
Modified by: @pmakowski |
Commented by: @pmakowski Q/A test ok |
Modified by: @pmakowskistatus: Resolved [ 5 ] => Closed [ 6 ] |
Modified by: @pavel-zotovQA Status: No test |
Modified by: @pavel-zotovQA Status: No test => Done successfully |
Submitted by: @hvlad
Is related to QA219
RECREATE TABLE Phases
(Id INT NOT NULL PRIMARY KEY, ParentPhaseId INT);
CREATE GENERATOR GenPhases;
COMMIT;
INSERT INTO Phases VALUES(491, NULL);
INSERT INTO Phases VALUES(494, 491);
INSERT INTO Phases VALUES(495, 491);
INSERT INTO Phases VALUES(497, 494);
INSERT INTO Phases VALUES(498, NULL);
-- below i want to renumber Phases table and keep parent-child relation
SET GENERATOR GenPhases to 0;
COMMIT;
WITH RECURSIVE
Tree (OldPhaseId, OldParentPhaseId, NewPhaseId, NewParentPhaseId) AS
(
SELECT http://P.Id, P.ParentPhaseId, GEN_ID(GenPhases, 1), CAST(NULL AS INTEGER)
FROM Phases P
WHERE P.ParentPhaseId IS NULL
)
SELECT * FROM Tree;
-- results is
OLDPHASEID OLDPARENTPHASEID NEWPHASEID NEWPARENTPHASEID
491 <null> 1 <null>
494 491 2 2
497 494 3 3
495 491 4 4
498 <null> 5 <null>
-- while correct results must be
OLDPHASEID OLDPARENTPHASEID NEWPHASEID NEWPARENTPHASEID
491 <null> 1 <null>
494 491 2 1
497 494 3 2
495 491 4 1
498 <null> 5 <null>
Commits: 671e59e
The text was updated successfully, but these errors were encountered: