Refactor parser's generation of Var nodes.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 Dec 2019 16:16:42 +0000 (11:16 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 26 Dec 2019 16:16:42 +0000 (11:16 -0500)
commitb541e9accb28c90656388a3f827ca3a68dd2a308
treef0aa0a43e27556d05eeb0e847d7bcf066bf98637
parent044b319cd77c589507291f9591994093ad30931d
Refactor parser's generation of Var nodes.

Instead of passing around a pointer to the RangeTblEntry that
provides the desired column, pass a pointer to the associated
ParseNamespaceItem.  The RTE is trivially reachable from the nsitem,
and having the ParseNamespaceItem allows access to additional
information.  As proof of concept for that, add the rangetable index
to ParseNamespaceItem, and use that to get rid of RTERangeTablePosn
searches.

(I have in mind to teach the parser to generate some different
representation for Vars that are nullable by outer joins, and
keeping the necessary information in ParseNamespaceItems seems
like a reasonable approach to that.  But whether that ever
happens or not, this seems like good cleanup.)

Also refactor the code around scanRTEForColumn so that the
"fuzzy match" stuff does not leak out of parse_relation.c.

Discussion: https://postgr.es/m/26144.1576858373@sss.pgh.pa.us
src/backend/parser/analyze.c
src/backend/parser/parse_clause.c
src/backend/parser/parse_expr.c
src/backend/parser/parse_func.c
src/backend/parser/parse_node.c
src/backend/parser/parse_relation.c
src/backend/parser/parse_target.c
src/include/parser/parse_node.h
src/include/parser/parse_relation.h