Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad511a3

Browse files
committed
sort_inner_and_outer needs a check to ensure that it's consumed all the
mergeclauses in RIGHT/FULL join cases, just like the other routines have.I'm not quite sure why I thought it didn't need one --- but NickFankhauser's recent bug report proves that it does.
1 parent8bf1e09 commitad511a3

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

‎src/backend/optimizer/path/joinpath.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.66 2001/10/25 05:49:32 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.67 2001/11/11 19:18:54 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -150,9 +150,31 @@ sort_inner_and_outer(Query *root,
150150
List*mergeclause_list,
151151
JoinTypejointype)
152152
{
153+
booluseallclauses;
153154
List*all_pathkeys;
154155
List*i;
155156

157+
/*
158+
* If we are doing a right or full join, we must use *all* the
159+
* mergeclauses as join clauses, else we will not have a valid plan.
160+
*/
161+
switch (jointype)
162+
{
163+
caseJOIN_INNER:
164+
caseJOIN_LEFT:
165+
useallclauses= false;
166+
break;
167+
caseJOIN_RIGHT:
168+
caseJOIN_FULL:
169+
useallclauses= true;
170+
break;
171+
default:
172+
elog(ERROR,"sort_inner_and_outer: unexpected join type %d",
173+
(int)jointype);
174+
useallclauses= false;/* keep compiler quiet */
175+
break;
176+
}
177+
156178
/*
157179
* Each possible ordering of the available mergejoin clauses will
158180
* generate a differently-sorted result path at essentially the same
@@ -212,6 +234,11 @@ sort_inner_and_outer(Query *root,
212234
mergeclause_list);
213235
Assert(cur_mergeclauses!=NIL);
214236

237+
/* Forget it if can't use all the clauses in right/full join */
238+
if (useallclauses&&
239+
length(cur_mergeclauses)!=length(mergeclause_list))
240+
continue;
241+
215242
/*
216243
* Build sort pathkeys for both sides.
217244
*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp