From: | Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk> |
---|---|
To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: WITH RECUSIVE patches 0723 |
Date: | 2008-07-28 15:20:13 |
Message-ID: | 877ib6rq6q.fsf@news-spur.riddles.org.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
>>>>> "Tatsuo" == Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
Tatsuo> Included patches from Yoshiyuki should fix 1) and 2). I also
Tatsuo> add your SQLs to the regression test. Thanks.
I think it needs this change in addition; without it, incorrect
results are returned when you reference a recursive view from within
the recursive query, due to the RecursionScan nodes becoming linked to
the wrong tuplestores.
The testcase for this would be something like
create view v0 as
with recursive t1(id) as (values (1)
union all select id+1 from t1 where id < 5)
select * from t1;
with recursive t(id) as (select * from v0
union all select id+1 from t where t.id < 8)
select count(*) from t;
-- expected output is 30, not 5
*** src/backend/executor/nodeRecursion.c~ Mon Jul 28 14:41:38 2008
--- src/backend/executor/nodeRecursion.c Mon Jul 28 15:22:55 2008
***************
*** 124,129 ****
--- 124,130 ----
ExecInitRecursion(Recursion *node, EState *estate, int eflags)
{
RecursionState *recursionstate;
+ Tuplestorestate **save_tuplestorestate;
/* check for unsupported flags */
Assert(!(eflags & EXEC_FLAG_MARK));
***************
*** 149,154 ****
--- 150,156 ----
/*
* Save the reference for the working table to share
*/
+ save_tuplestorestate = estate->es_tuplestorestate;
estate->es_tuplestorestate = &recursionstate->working_table;
/*
***************
*** 196,201 ****
--- 198,205 ----
ExecAssignResultTypeFromTL(&recursionstate->ss.ps);
ExecAssignScanProjectionInfo(&recursionstate->ss);
+ estate->es_tuplestorestate = save_tuplestorestate;
+
return recursionstate;
}
--
Andrew (irc:RhodiumToad)
From | Date | Subject | |
---|---|---|---|
Next Message | Hiroshi Saito | 2008-07-28 15:31:42 | Re: Do we really want to migrate plproxy and citext intoPG core distribution? |
Previous Message | Asko Oja | 2008-07-28 15:11:38 | Re: Do we really want to migrate plproxy and citext into PG core distribution? |
From | Date | Subject | |
---|---|---|---|
Next Message | Greg Smith | 2008-07-28 15:59:12 | Re: [PATCHES] odd output in restore mode |
Previous Message | Tom Lane | 2008-07-28 14:56:31 | Re: WITH RECUSIVE patches 0723 |