From b541e9accb28c90656388a3f827ca3a68dd2a308 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 26 Dec 2019 11:16:42 -0500 Subject: 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/parse_node.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'src/backend/parser/parse_node.c') diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index bc832e79dcb..3936b60b750 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -180,27 +180,6 @@ pcb_error_callback(void *arg) } -/* - * make_var - * Build a Var node for an attribute identified by RTE and attrno - */ -Var * -make_var(ParseState *pstate, RangeTblEntry *rte, int attrno, int location) -{ - Var *result; - int vnum, - sublevels_up; - Oid vartypeid; - int32 type_mod; - Oid varcollid; - - vnum = RTERangeTablePosn(pstate, rte, &sublevels_up); - get_rte_attribute_type(rte, attrno, &vartypeid, &type_mod, &varcollid); - result = makeVar(vnum, attrno, vartypeid, type_mod, varcollid, sublevels_up); - result->location = location; - return result; -} - /* * transformContainerType() * Identify the types involved in a subscripting operation for container -- cgit v1.2.3