* Add the given nsitem/RTE as a top-level entry in the pstate's join list * and/or namespace list. (We assume caller has checked for any * namespace conflicts.) The nsitem is always marked as unconditionally * visible, that is, not LATERAL-only. */
| 2868 | * visible, that is, not LATERAL-only. |
| 2869 | */ |
| 2870 | void |
| 2871 | addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, |
| 2872 | bool addToJoinList, |
| 2873 | bool addToRelNameSpace, bool addToVarNameSpace) |
| 2874 | { |
| 2875 | if (addToJoinList) |
| 2876 | { |
| 2877 | RangeTblRef *rtr = makeNode(RangeTblRef); |
| 2878 | |
| 2879 | rtr->rtindex = nsitem->p_rtindex; |
| 2880 | pstate->p_joinlist = lappend(pstate->p_joinlist, rtr); |
| 2881 | } |
| 2882 | if (addToRelNameSpace || addToVarNameSpace) |
| 2883 | { |
| 2884 | /* Set the new nsitem's visibility flags correctly */ |
| 2885 | nsitem->p_rel_visible = addToRelNameSpace; |
| 2886 | nsitem->p_cols_visible = addToVarNameSpace; |
| 2887 | nsitem->p_lateral_only = false; |
| 2888 | nsitem->p_lateral_ok = true; |
| 2889 | pstate->p_namespace = lappend(pstate->p_namespace, nsitem); |
| 2890 | } |
| 2891 | } |
| 2892 | |
| 2893 | /* |
| 2894 | * expandRTE -- expand the columns of a rangetable entry |