From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@postgresql.org
Subject: pgsql: Support XMLTABLE query expression
Date: Wed, 08 Mar 2017 15:42:33 +0000
Message-ID: <E1cldjV-0000Sc-5V@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
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
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/fcec6caafa2346b6c9d3ad5065e417733bd63cd9
Modified Files
--------------
contrib/pg_stat_statements/pg_stat_statements.c | 12 +
doc/src/sgml/func.sgml | 203 ++++++++-
src/backend/commands/explain.c | 24 +
src/backend/executor/Makefile | 3 +-
src/backend/executor/execAmi.c | 6 +
src/backend/executor/execProcnode.c | 14 +
src/backend/executor/nodeTableFuncscan.c | 502 +++++++++++++++++++++
src/backend/nodes/copyfuncs.c | 91 ++++
src/backend/nodes/equalfuncs.c | 60 +++
src/backend/nodes/makefuncs.c | 8 +-
src/backend/nodes/nodeFuncs.c | 66 +++
src/backend/nodes/outfuncs.c | 73 ++++
src/backend/nodes/print.c | 4 +
src/backend/nodes/readfuncs.c | 47 ++
src/backend/optimizer/path/allpaths.c | 37 ++
src/backend/optimizer/path/costsize.c | 81 ++++
src/backend/optimizer/plan/createplan.c | 77 +++-
src/backend/optimizer/plan/initsplan.c | 2 +
src/backend/optimizer/plan/planner.c | 37 +-
src/backend/optimizer/plan/setrefs.c | 14 +
src/backend/optimizer/plan/subselect.c | 6 +
src/backend/optimizer/prep/prepjointree.c | 6 +
src/backend/optimizer/util/pathnode.c | 26 ++
src/backend/optimizer/util/plancat.c | 6 +-
src/backend/optimizer/util/relnode.c | 5 +-
src/backend/parser/analyze.c | 9 +
src/backend/parser/gram.y | 189 +++++++-
src/backend/parser/parse_clause.c | 245 ++++++++++-
src/backend/parser/parse_coerce.c | 33 +-
src/backend/parser/parse_relation.c | 79 +++-
src/backend/parser/parse_target.c | 7 +
src/backend/rewrite/rewriteHandler.c | 4 +
src/backend/utils/adt/ruleutils.c | 133 +++++-
src/backend/utils/adt/xml.c | 558 +++++++++++++++++++++++-
src/include/catalog/catversion.h | 2 +-
src/include/executor/nodeTableFuncscan.h | 24 +
src/include/executor/tablefunc.h | 67 +++
src/include/nodes/execnodes.h | 25 ++
src/include/nodes/nodes.h | 5 +
src/include/nodes/parsenodes.h | 39 ++
src/include/nodes/plannodes.h | 10 +
src/include/nodes/primnodes.h | 22 +
src/include/optimizer/cost.h | 5 +
src/include/optimizer/pathnode.h | 4 +
src/include/parser/kwlist.h | 3 +
src/include/parser/parse_coerce.h | 4 +
src/include/parser/parse_relation.h | 5 +
src/include/utils/xml.h | 3 +
src/test/regress/expected/xml.out | 504 +++++++++++++++++++++
src/test/regress/expected/xml_1.out | 475 ++++++++++++++++++++
src/test/regress/expected/xml_2.out | 504 +++++++++++++++++++++
src/test/regress/sql/xml.sql | 288 ++++++++++++
52 files changed, 4606 insertions(+), 50 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: alvherre@alvh.no-ip.org
Subject: Re: pgsql: Support XMLTABLE query expression
In-Reply-To: <E1cldjV-0000Sc-5V@gemulon.postgresql.org>
References: <E1cldjV-0000Sc-5V@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox