* transformFromClause - * Process the FROM clause and add items to the query's range table, * joinlist, and namespace. * * Note: we assume that the pstate's p_rtable, p_joinlist, and p_namespace * lists were initialized to NIL when the pstate was created. * We will add onto any entries already present --- this is needed for rule * processing, as well as for UPDATE and DELETE. */
| 131 | * processing, as well as for UPDATE and DELETE. |
| 132 | */ |
| 133 | void |
| 134 | transformFromClause(ParseState *pstate, List *frmList) |
| 135 | { |
| 136 | ListCell *fl; |
| 137 | |
| 138 | /* |
| 139 | * The grammar will have produced a list of RangeVars, RangeSubselects, |
| 140 | * RangeFunctions, and/or JoinExprs. Transform each one (possibly adding |
| 141 | * entries to the rtable), check for duplicate refnames, and then add it |
| 142 | * to the joinlist and namespace. |
| 143 | * |
| 144 | * Note we must process the items left-to-right for proper handling of |
| 145 | * LATERAL references. |
| 146 | */ |
| 147 | foreach(fl, frmList) |
| 148 | { |
| 149 | Node *n = lfirst(fl); |
| 150 | ParseNamespaceItem *nsitem; |
| 151 | List *namespace; |
| 152 | |
| 153 | n = transformFromClauseItem(pstate, n, |
| 154 | &nsitem, |
| 155 | &namespace); |
| 156 | |
| 157 | checkNameSpaceConflicts(pstate, pstate->p_namespace, namespace); |
| 158 | |
| 159 | /* Mark the new namespace items as visible only to LATERAL */ |
| 160 | setNamespaceLateralState(namespace, true, true); |
| 161 | |
| 162 | pstate->p_joinlist = lappend(pstate->p_joinlist, n); |
| 163 | pstate->p_namespace = list_concat(pstate->p_namespace, namespace); |
| 164 | } |
| 165 | |
| 166 | /* |
| 167 | * We're done parsing the FROM list, so make all namespace items |
| 168 | * unconditionally visible. Note that this will also reset lateral_only |
| 169 | * for any namespace items that were already present when we were called; |
| 170 | * but those should have been that way already. |
| 171 | */ |
| 172 | setNamespaceLateralState(pstate->p_namespace, false, true); |
| 173 | } |
| 174 | |
| 175 | /* |
| 176 | * winref_checkspec_walker |
no test coverage detected