aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/explain.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2017-03-08 12:39:37 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2017-03-08 12:40:26 -0300
commitfcec6caafa2346b6c9d3ad5065e417733bd63cd9 (patch)
tree5a239cd7a7032d1b8dc8a4b558cc7eb740cde87f /src/backend/commands/explain.c
parent270d7dd8a5a7128fc2b859f3bf95e2c1fb45be79 (diff)
downloadpostgresql-fcec6caafa2346b6c9d3ad5065e417733bd63cd9.tar.gz
postgresql-fcec6caafa2346b6c9d3ad5065e417733bd63cd9.zip
Support XMLTABLE query expression
XMLTABLE is defined by the SQL/XML standard as a feature that allows turning XML-formatted data into relational form, so that it can be used as a <table primary> in the FROM clause of a query. This new construct provides significant simplicity and performance benefit for XML data processing; what in a client-side custom implementation was reported to take 20 minutes can be executed in 400ms using XMLTABLE. (The same functionality was said to take 10 seconds using nested PostgreSQL XPath function calls, and 5 seconds using XMLReader under PL/Python). The implemented syntax deviates slightly from what the standard requires. First, the standard indicates that the PASSING clause is optional and that multiple XML input documents may be given to it; we make it mandatory and accept a single document only. Second, we don't currently support a default namespace to be specified. This implementation relies on a new executor node based on a hardcoded method table. (Because the grammar is fixed, there is no extensibility in the current approach; further constructs can be implemented on top of this such as JSON_TABLE, but they require changes to core code.) Author: Pavel Stehule, Álvaro Herrera Extensively reviewed by: Craig Ringer Discussion: https://postgr.es/m/CAFj8pRAgfzMD-LoSmnMGybD0WsEznLHWap8DO79+-GTRAPR4qA@mail.gmail.com
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r--src/backend/commands/explain.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c
index c9e0a3e42d2..7a8d36c8db1 100644
--- a/src/backend/commands/explain.c
+++ b/src/backend/commands/explain.c
@@ -781,6 +781,7 @@ ExplainPreScanNode(PlanState *planstate, Bitmapset **rels_used)
case T_TidScan:
case T_SubqueryScan:
case T_FunctionScan:
+ case T_TableFuncScan:
case T_ValuesScan:
case T_CteScan:
case T_WorkTableScan:
@@ -926,6 +927,9 @@ ExplainNode(PlanState *planstate, List *ancestors,
case T_FunctionScan:
pname = sname = "Function Scan";
break;
+ case T_TableFuncScan:
+ pname = sname = "Table Function Scan";
+ break;
case T_ValuesScan:
pname = sname = "Values Scan";
break;
@@ -1103,6 +1107,7 @@ ExplainNode(PlanState *planstate, List *ancestors,
case T_TidScan:
case T_SubqueryScan:
case T_FunctionScan:
+ case T_TableFuncScan:
case T_ValuesScan:
case T_CteScan:
case T_WorkTableScan:
@@ -1416,6 +1421,20 @@ ExplainNode(PlanState *planstate, List *ancestors,
show_instrumentation_count("Rows Removed by Filter", 1,
planstate, es);
break;
+ case T_TableFuncScan:
+ if (es->verbose)
+ {
+ TableFunc *tablefunc = ((TableFuncScan *) plan)->tablefunc;
+
+ show_expression((Node *) tablefunc,
+ "Table Function Call", planstate, ancestors,
+ es->verbose, es);
+ }
+ show_scan_qual(plan->qual, "Filter", planstate, ancestors, es);
+ if (plan->qual)
+ show_instrumentation_count("Rows Removed by Filter", 1,
+ planstate, es);
+ break;
case T_TidScan:
{
/*
@@ -2593,6 +2612,11 @@ ExplainTargetRel(Plan *plan, Index rti, ExplainState *es)
objecttag = "Function Name";
}
break;
+ case T_TableFuncScan:
+ Assert(rte->rtekind == RTE_TABLEFUNC);
+ objectname = "xmltable";
+ objecttag = "Table Function Name";
+ break;
case T_ValuesScan:
Assert(rte->rtekind == RTE_VALUES);
break;