8
8
*
9
9
*
10
10
* IDENTIFICATION
11
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.38 2000/03/17 02:36:17 tgl Exp $
11
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.39 2000/03/23 07:38:30 tgl Exp $
12
12
*
13
13
*-------------------------------------------------------------------------
14
14
*/
@@ -93,11 +93,7 @@ refnameRangeTableEntries(ParseState *pstate, char *refname)
93
93
if (strcmp (rte -> eref -> relname , refname ) == 0 )
94
94
rteList = lappend (rteList , rte );
95
95
}
96
- /* only allow correlated columns in WHERE clause */
97
- if (pstate -> p_in_where_clause )
98
- pstate = pstate -> parentParseState ;
99
- else
100
- break ;
96
+ pstate = pstate -> parentParseState ;
101
97
}
102
98
return rteList ;
103
99
}
@@ -117,16 +113,15 @@ refnameRangeTableEntry(ParseState *pstate, char *refname)
117
113
if (strcmp (rte -> eref -> relname , refname ) == 0 )
118
114
return rte ;
119
115
}
120
- /* only allow correlated columns in WHERE clause */
121
- if (pstate -> p_in_where_clause )
122
- pstate = pstate -> parentParseState ;
123
- else
124
- break ;
116
+ pstate = pstate -> parentParseState ;
125
117
}
126
118
return NULL ;
127
119
}
128
120
129
- /* given refname, return id of variable; position starts with 1 */
121
+ /* given refname, return RT index (starting with 1) of the relation,
122
+ * and optionally get its nesting depth (0 = current). If sublevels_up
123
+ * is NULL, only consider rels at the current nesting level.
124
+ */
130
125
int
131
126
refnameRangeTablePosn (ParseState * pstate , char * refname , int * sublevels_up )
132
127
{
@@ -147,13 +142,9 @@ refnameRangeTablePosn(ParseState *pstate, char *refname, int *sublevels_up)
147
142
return index ;
148
143
index ++ ;
149
144
}
150
- /* only allow correlated columns in WHERE clause */
151
- if (pstate -> p_in_where_clause )
152
- {
153
- pstate = pstate -> parentParseState ;
154
- if (sublevels_up )
155
- (* sublevels_up )++ ;
156
- }
145
+ pstate = pstate -> parentParseState ;
146
+ if (sublevels_up )
147
+ (* sublevels_up )++ ;
157
148
else
158
149
break ;
159
150
}
@@ -168,9 +159,8 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
168
159
{
169
160
List * et ;
170
161
List * rtable ;
171
- RangeTblEntry * rte_result ;
162
+ RangeTblEntry * rte_result = NULL ;
172
163
173
- rte_result = NULL ;
174
164
while (pstate != NULL )
175
165
{
176
166
if (pstate -> p_is_rule )
@@ -226,11 +216,10 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
226
216
rte_result = rte ;
227
217
}
228
218
229
- /* only allow correlated columns in WHERE clause */
230
- if (pstate -> p_in_where_clause && rte_result == NULL )
231
- pstate = pstate -> parentParseState ;
232
- else
233
- break ;
219
+ if (rte_result != NULL )
220
+ break ; /* found */
221
+
222
+ pstate = pstate -> parentParseState ;
234
223
}
235
224
return rte_result ;
236
225
}
0 commit comments