mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Implement SQL-standard WITH clauses, including WITH RECURSIVE.
There are some unimplemented aspects: recursive queries must use UNION ALL (should allow UNION too), and we don't have SEARCH or CYCLE clauses. These might or might not get done for 8.4, but even without them it's a pretty useful feature. There are also a couple of small loose ends and definitional quibbles, which I'll send a memo about to pgsql-hackers shortly. But let's land the patch now so we can get on with other development. Yoshiyuki Asaba, with lots of help from Tatsuo Ishii and Tom Lane
This commit is contained in:
@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994-5, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.178 2008/08/19 18:30:04 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.179 2008/10/04 21:56:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -429,6 +429,9 @@ explain_outNode(StringInfo str,
|
||||
case T_Append:
|
||||
pname = "Append";
|
||||
break;
|
||||
case T_RecursiveUnion:
|
||||
pname = "Recursive Union";
|
||||
break;
|
||||
case T_BitmapAnd:
|
||||
pname = "BitmapAnd";
|
||||
break;
|
||||
@ -537,6 +540,12 @@ explain_outNode(StringInfo str,
|
||||
case T_ValuesScan:
|
||||
pname = "Values Scan";
|
||||
break;
|
||||
case T_CteScan:
|
||||
pname = "CTE Scan";
|
||||
break;
|
||||
case T_WorkTableScan:
|
||||
pname = "WorkTable Scan";
|
||||
break;
|
||||
case T_Material:
|
||||
pname = "Materialize";
|
||||
break;
|
||||
@ -721,6 +730,40 @@ explain_outNode(StringInfo str,
|
||||
quote_identifier(valsname));
|
||||
}
|
||||
break;
|
||||
case T_CteScan:
|
||||
if (((Scan *) plan)->scanrelid > 0)
|
||||
{
|
||||
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
|
||||
es->rtable);
|
||||
|
||||
/* Assert it's on a non-self-reference CTE */
|
||||
Assert(rte->rtekind == RTE_CTE);
|
||||
Assert(!rte->self_reference);
|
||||
|
||||
appendStringInfo(str, " on %s",
|
||||
quote_identifier(rte->ctename));
|
||||
if (strcmp(rte->eref->aliasname, rte->ctename) != 0)
|
||||
appendStringInfo(str, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
}
|
||||
break;
|
||||
case T_WorkTableScan:
|
||||
if (((Scan *) plan)->scanrelid > 0)
|
||||
{
|
||||
RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid,
|
||||
es->rtable);
|
||||
|
||||
/* Assert it's on a self-reference CTE */
|
||||
Assert(rte->rtekind == RTE_CTE);
|
||||
Assert(rte->self_reference);
|
||||
|
||||
appendStringInfo(str, " on %s",
|
||||
quote_identifier(rte->ctename));
|
||||
if (strcmp(rte->eref->aliasname, rte->ctename) != 0)
|
||||
appendStringInfo(str, " %s",
|
||||
quote_identifier(rte->eref->aliasname));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -787,6 +830,8 @@ explain_outNode(StringInfo str,
|
||||
case T_SeqScan:
|
||||
case T_FunctionScan:
|
||||
case T_ValuesScan:
|
||||
case T_CteScan:
|
||||
case T_WorkTableScan:
|
||||
show_scan_qual(plan->qual,
|
||||
"Filter",
|
||||
((Scan *) plan)->scanrelid,
|
||||
@ -1071,6 +1116,9 @@ show_plan_tlist(Plan *plan,
|
||||
/* The tlist of an Append isn't real helpful, so suppress it */
|
||||
if (IsA(plan, Append))
|
||||
return;
|
||||
/* Likewise for RecursiveUnion */
|
||||
if (IsA(plan, RecursiveUnion))
|
||||
return;
|
||||
|
||||
/* Set up deparsing context */
|
||||
context = deparse_context_for_plan((Node *) outerPlan(plan),
|
||||
|
Reference in New Issue
Block a user