|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.11 1999/02/0903:51:26 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.12 1999/02/0906:30:39 momjian Exp $ |
11 | 11 | *
|
12 | 12 | *-------------------------------------------------------------------------
|
13 | 13 | */
|
@@ -108,25 +108,35 @@ extract_subkey(JoinKey *jk, int which_subkey)
|
108 | 108 | /*
|
109 | 109 | * samekeys--
|
110 | 110 | * Returns t iff two sets of path keys are equivalent. They are
|
111 |
| - * equivalent if the first subkey (var node) within each sublist of |
112 |
| - * list 'keys1' is contained within the corresponding sublist of 'keys2'. |
| 111 | + * equivalent if the first Var nodes match the second Var nodes. |
113 | 112 | *
|
114 | 113 | * XXXIt isn't necessary to check that each sublist exactly contain
|
115 | 114 | *the same elements because if the routine that built these
|
116 | 115 | *sublists together is correct, having one element in common
|
117 | 116 | *implies having all elements in common.
|
| 117 | + *Huh? bjm |
118 | 118 | *
|
119 | 119 | */
|
120 | 120 | bool
|
121 | 121 | samekeys(List*keys1,List*keys2)
|
122 | 122 | {
|
123 | 123 | List*key1,
|
124 |
| -*key2; |
| 124 | +*key2, |
| 125 | +*key1a, |
| 126 | +*key2a; |
125 | 127 |
|
126 |
| -for (key1=keys1,key2=keys2;key1!=NIL&&key2!=NIL; |
| 128 | +for (key1=keys1,key2=keys2; |
| 129 | +key1!=NIL&&key2!=NIL; |
127 | 130 | key1=lnext(key1),key2=lnext(key2))
|
128 |
| -if (!member(lfirst((List*)lfirst(key1)),lfirst(key2))) |
| 131 | +{ |
| 132 | +for (key1a=lfirst(key1),key2a=lfirst(key2); |
| 133 | +key1a!=NIL&&key2a!=NIL; |
| 134 | +key1a=lnext(key1a),key2a=lnext(key2a)) |
| 135 | +if (!equal(lfirst(key1a),lfirst(key2a))) |
| 136 | +return false; |
| 137 | +if (key1a!=NIL) |
129 | 138 | return false;
|
| 139 | +} |
130 | 140 |
|
131 | 141 | /* Now the result should be true if list keys2 has at least as many
|
132 | 142 | * entries as keys1, ie, we did not fall off the end of keys2 first.
|
|