7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/pathkey.c,v 1.2 1999/02/19 02: 05:15 momjian Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/pathkey.c,v 1.3 1999/02/19 05:18:05 momjian Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
28
28
29
29
static int match_pathkey_joinkeys (List * pathkey , List * joinkeys ,
30
30
int outer_or_inner );
31
- static bool every_func (List * joinkeys , List * pathkey ,
31
+ static bool joinkeys_pathkeys_match (List * joinkeys , List * pathkey ,
32
32
int outer_or_inner );
33
33
static List * new_join_pathkey (List * subkeys , List * considered_subkeys ,
34
34
List * join_rel_tlist , List * joinclauses );
@@ -40,7 +40,7 @@ static List *new_matching_subkeys(Var *subkey, List *considered_subkeys,
40
40
****************************************************************************/
41
41
42
42
/*
43
- * match_pathkeys_joinkeys
43
+ * order_joinkeys_by_pathkeys
44
44
* Attempts to match the keys of a path against the keys of join clauses.
45
45
* This is done by looking for a matching join key in 'joinkeys' for
46
46
* every path key in the list 'path.keys'. If there is a matching join key
@@ -69,7 +69,7 @@ static List *new_matching_subkeys(Var *subkey, List *considered_subkeys,
69
69
* in matchedJoinClausesPtr. - ay 11/94
70
70
*/
71
71
List *
72
- match_pathkeys_joinkeys (List * pathkeys ,
72
+ order_joinkeys_by_pathkeys (List * pathkeys ,
73
73
List * joinkeys ,
74
74
List * joinclauses ,
75
75
int outer_or_inner ,
@@ -92,21 +92,18 @@ match_pathkeys_joinkeys(List *pathkeys,
92
92
List * xjoinkey = nth (matched_joinkey_index , joinkeys );
93
93
List * joinclause = nth (matched_joinkey_index , joinclauses );
94
94
95
- matched_joinkeys = lcons (xjoinkey , matched_joinkeys );
96
- matched_joinclauses = lcons (joinclause , matched_joinclauses );
97
-
98
- joinkeys = LispRemove (xjoinkey , joinkeys );
95
+ matched_joinkeys = lappend (matched_joinkeys , xjoinkey );
96
+ matched_joinclauses = lappend (matched_joinclauses , joinclause );
99
97
}
100
98
else
99
+ {
100
+ * matchedJoinClausesPtr = NIL ;
101
101
return NIL ;
102
-
102
+ }
103
103
}
104
- if (matched_joinkeys == NULL ||
105
- length (matched_joinkeys ) != length (pathkeys ))
106
- return NIL ;
107
104
108
- * matchedJoinClausesPtr = nreverse ( matched_joinclauses ) ;
109
- return nreverse ( matched_joinkeys ) ;
105
+ * matchedJoinClausesPtr = matched_joinclauses ;
106
+ return matched_joinkeys ;
110
107
}
111
108
112
109
@@ -144,7 +141,7 @@ match_pathkey_joinkeys(List *pathkey,
144
141
145
142
146
143
/*
147
- * match_paths_joinkeys
144
+ * get_cheapest_path_for_joinkeys
148
145
* Attempts to find a path in 'paths' whose keys match a set of join
149
146
* keys 'joinkeys'. To match,
150
147
* 1. the path node ordering must equal 'ordering'.
@@ -165,31 +162,27 @@ match_pathkey_joinkeys(List *pathkey,
165
162
* Find the cheapest path that matches the join keys
166
163
*/
167
164
Path *
168
- match_paths_joinkeys (List * joinkeys ,
169
- PathOrder * ordering ,
170
- List * paths ,
171
- int outer_or_inner )
165
+ get_cheapest_path_for_joinkeys (List * joinkeys ,
166
+ PathOrder * ordering ,
167
+ List * paths ,
168
+ int outer_or_inner )
172
169
{
173
170
Path * matched_path = NULL ;
174
- bool key_match = false;
175
171
List * i = NIL ;
176
172
177
173
foreach (i , paths )
178
174
{
179
175
Path * path = (Path * ) lfirst (i );
180
- int better_sort ;
176
+ int better_sort , better_key ;
181
177
182
- key_match = every_func (joinkeys , path -> pathkeys , outer_or_inner );
183
-
184
- if (pathorder_match (ordering , path -> pathorder , & better_sort ) &&
185
- better_sort == 0 &&
186
- length (joinkeys ) == length (path -> pathkeys ) && key_match )
178
+ if (joinkeys_pathkeys_match (joinkeys , path -> pathkeys , outer_or_inner ) &&
179
+ length (joinkeys ) == length (path -> pathkeys ) &&
180
+ pathorder_match (ordering , path -> pathorder , & better_sort ) &&
181
+ better_sort == 0 )
187
182
{
188
183
if (matched_path )
189
- {
190
184
if (path -> path_cost < matched_path -> path_cost )
191
185
matched_path = path ;
192
- }
193
186
else
194
187
matched_path = path ;
195
188
}
@@ -253,10 +246,10 @@ extract_path_keys(List *joinkeys,
253
246
254
247
255
248
/*
256
- * every_func
249
+ * joinkeys_pathkeys_match
257
250
*/
258
251
static bool
259
- every_func (List * joinkeys , List * pathkey , int outer_or_inner )
252
+ joinkeys_pathkeys_match (List * joinkeys , List * pathkey , int outer_or_inner )
260
253
{
261
254
JoinKey * xjoinkey ;
262
255
Var * temp ;
0 commit comments