Avoid core dump in _outPathInfo() for Path without a parent RelOptInfo.
authorTom Lane
Sat, 18 Oct 2014 02:33:10 +0000 (22:33 -0400)
committerTom Lane
Sat, 18 Oct 2014 02:33:10 +0000 (22:33 -0400)
Nearly all Paths have parents, but a ResultPath representing an empty FROM
clause does not.  Avoid a core dump in such cases.  I believe this is only
a hazard for debugging usage, not for production, else we'd have heard
about it before.  Nonetheless, back-patch to 9.1 where the troublesome code
was introduced.  Noted while poking at bug #11703.

src/backend/nodes/outfuncs.c

index a08d9bbc0c9036e070e7708de03bcd474f0e8d31..12c8fed1ab9a8514a92dbe6bcea8e4014c92c6e2 100644 (file)
@@ -1470,7 +1470,10 @@ _outPathInfo(StringInfo str, const Path *node)
 {
    WRITE_ENUM_FIELD(pathtype, NodeTag);
    appendStringInfo(str, " :parent_relids ");
-   _outBitmapset(str, node->parent->relids);
+   if (node->parent)
+       _outBitmapset(str, node->parent->relids);
+   else
+       _outBitmapset(str, NULL);
    appendStringInfo(str, " :required_outer ");
    if (node->param_info)
        _outBitmapset(str, node->param_info->ppi_req_outer);