aboutsummaryrefslogtreecommitdiff
path: root/src/include/nodes
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-09-17 13:16:32 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-09-17 13:16:32 -0400
commita552e3bc502ee679b0b8ff19e69b7b69890c0613 (patch)
tree5245c36facf5d07cb286f7fb1dcbd8e9d63c7900 /src/include/nodes
parent3ea7e015f37afd615234d94181840b8e6e44e6ed (diff)
downloadpostgresql-a552e3bc502ee679b0b8ff19e69b7b69890c0613.tar.gz
postgresql-a552e3bc502ee679b0b8ff19e69b7b69890c0613.zip
Fix parsetree representation of XMLTABLE(XMLNAMESPACES(DEFAULT ...)).
The original coding for XMLTABLE thought it could represent a default namespace by a T_String Value node with a null string pointer. That's not okay, though; in particular outfuncs.c/readfuncs.c are not on board with such a representation, meaning you'll get a null pointer crash if you try to store a view or rule containing this construct. To fix, change the parsetree representation so that we have a NULL list element, instead of a bogus Value node. This isn't really a functional limitation since default XML namespaces aren't yet implemented in the executor; you'd just get "DEFAULT namespace is not supported" anyway. But crashes are not nice, so back-patch to v10 where this syntax was added. Ordinarily we'd consider a parsetree representation change to be un-backpatchable; but since existing releases would crash on the way to storing such constructs, there can't be any existing views/rules to be incompatible with. Per report from Andrey Lepikhov. Discussion: https://postgr.es/m/3690074f-abd2-56a9-144a-aa5545d7a291@postgrespro.ru
Diffstat (limited to 'src/include/nodes')
-rw-r--r--src/include/nodes/execnodes.h4
-rw-r--r--src/include/nodes/primnodes.h7
2 files changed, 7 insertions, 4 deletions
diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h
index 78d276bf884..b2490779c21 100644
--- a/src/include/nodes/execnodes.h
+++ b/src/include/nodes/execnodes.h
@@ -1476,8 +1476,8 @@ typedef struct TableFuncScanState
ExprState *rowexpr; /* state for row-generating expression */
List *colexprs; /* state for column-generating expression */
List *coldefexprs; /* state for column default expressions */
- List *ns_names; /* list of str nodes with namespace names */
- List *ns_uris; /* list of states of namespace uri exprs */
+ List *ns_names; /* same as TableFunc.ns_names */
+ List *ns_uris; /* list of states of namespace URI exprs */
Bitmapset *notnulls; /* nullability flag for each output column */
void *opaque; /* table builder private space */
const struct TableFuncRoutine *routine; /* table builder methods */
diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h
index 8c536a8d38d..02288c84124 100644
--- a/src/include/nodes/primnodes.h
+++ b/src/include/nodes/primnodes.h
@@ -75,12 +75,15 @@ typedef struct RangeVar
/*
* TableFunc - node for a table function, such as XMLTABLE.
+ *
+ * Entries in the ns_names list are either string Value nodes containing
+ * literal namespace names, or NULL pointers to represent DEFAULT.
*/
typedef struct TableFunc
{
NodeTag type;
- List *ns_uris; /* list of namespace uri */
- List *ns_names; /* list of namespace names */
+ List *ns_uris; /* list of namespace URI expressions */
+ List *ns_names; /* list of namespace names or NULL */
Node *docexpr; /* input document expression */
Node *rowexpr; /* row filter expression */
List *colnames; /* column names (list of String) */