Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 78511d8

Browse files
committed
Optimizer fix for samekeys.
1 parent fe35ffe commit 78511d8

File tree

3 files changed

+5291
-5079
lines changed

3 files changed

+5291
-5079
lines changed

src/backend/optimizer/util/keys.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.11 1999/02/09 03:51:26 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.12 1999/02/09 06:30:39 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -108,25 +108,35 @@ extract_subkey(JoinKey *jk, int which_subkey)
108108
/*
109109
* samekeys--
110110
* 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.
113112
*
114113
* XXX It isn't necessary to check that each sublist exactly contain
115114
* the same elements because if the routine that built these
116115
* sublists together is correct, having one element in common
117116
* implies having all elements in common.
117+
* Huh? bjm
118118
*
119119
*/
120120
bool
121121
samekeys(List *keys1, List *keys2)
122122
{
123123
List *key1,
124-
*key2;
124+
*key2,
125+
*key1a,
126+
*key2a;
125127

126-
for (key1 = keys1, key2 = keys2; key1 != NIL && key2 != NIL;
128+
for (key1 = keys1, key2 = keys2;
129+
key1 != NIL && key2 != NIL;
127130
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)
129138
return false;
139+
}
130140

131141
/* Now the result should be true if list keys2 has at least as many
132142
* entries as keys1, ie, we did not fall off the end of keys2 first.

0 commit comments

Comments
 (0)