mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
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
This commit is contained in:
@ -1096,9 +1096,9 @@ coerce_to_boolean(ParseState *pstate, Node *node,
|
||||
}
|
||||
|
||||
/*
|
||||
* coerce_to_specific_type()
|
||||
* Coerce an argument of a construct that requires a specific data type.
|
||||
* Also check that input is not a set.
|
||||
* coerce_to_specific_type_typmod()
|
||||
* Coerce an argument of a construct that requires a specific data type,
|
||||
* with a specific typmod. Also check that input is not a set.
|
||||
*
|
||||
* Returns the possibly-transformed node tree.
|
||||
*
|
||||
@ -1106,9 +1106,9 @@ coerce_to_boolean(ParseState *pstate, Node *node,
|
||||
* processing is wanted.
|
||||
*/
|
||||
Node *
|
||||
coerce_to_specific_type(ParseState *pstate, Node *node,
|
||||
Oid targetTypeId,
|
||||
const char *constructName)
|
||||
coerce_to_specific_type_typmod(ParseState *pstate, Node *node,
|
||||
Oid targetTypeId, int32 targetTypmod,
|
||||
const char *constructName)
|
||||
{
|
||||
Oid inputTypeId = exprType(node);
|
||||
|
||||
@ -1117,7 +1117,7 @@ coerce_to_specific_type(ParseState *pstate, Node *node,
|
||||
Node *newnode;
|
||||
|
||||
newnode = coerce_to_target_type(pstate, node, inputTypeId,
|
||||
targetTypeId, -1,
|
||||
targetTypeId, targetTypmod,
|
||||
COERCION_ASSIGNMENT,
|
||||
COERCE_IMPLICIT_CAST,
|
||||
-1);
|
||||
@ -1144,6 +1144,25 @@ coerce_to_specific_type(ParseState *pstate, Node *node,
|
||||
return node;
|
||||
}
|
||||
|
||||
/*
|
||||
* coerce_to_specific_type()
|
||||
* Coerce an argument of a construct that requires a specific data type.
|
||||
* Also check that input is not a set.
|
||||
*
|
||||
* Returns the possibly-transformed node tree.
|
||||
*
|
||||
* As with coerce_type, pstate may be NULL if no special unknown-Param
|
||||
* processing is wanted.
|
||||
*/
|
||||
Node *
|
||||
coerce_to_specific_type(ParseState *pstate, Node *node,
|
||||
Oid targetTypeId,
|
||||
const char *constructName)
|
||||
{
|
||||
return coerce_to_specific_type_typmod(pstate, node,
|
||||
targetTypeId, -1,
|
||||
constructName);
|
||||
}
|
||||
|
||||
/*
|
||||
* parser_coercion_errposition - report coercion error location, if possible
|
||||
|
Reference in New Issue
Block a user