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

Commit942a2e9

Browse files
committed
Fix testing of partial-index predicates to work correctly in cases where
varno of index's relation is not 1. This embarrassing oversight pointedout by Dmitry Tkach 12-Jul-02.
1 parent59097af commit942a2e9

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.119 2002/06/2020:29:29 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.120 2002/07/13 19:20:34 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -35,6 +35,7 @@
3535
#include"parser/parse_coerce.h"
3636
#include"parser/parse_expr.h"
3737
#include"parser/parse_oper.h"
38+
#include"rewrite/rewriteManip.h"
3839
#include"utils/builtins.h"
3940
#include"utils/fmgroids.h"
4041
#include"utils/lsyscache.h"
@@ -79,7 +80,7 @@ static bool match_clause_to_indexkey(RelOptInfo *rel, IndexOptInfo *index,
7980
intindexkey,Oidopclass,
8081
Expr*clause,booljoin);
8182
staticboolpred_test(List*predicate_list,List*restrictinfo_list,
82-
List*joininfo_list);
83+
List*joininfo_list,intrelvarno);
8384
staticboolpred_test_restrict_list(Expr*predicate,List*restrictinfo_list);
8485
staticboolpred_test_recurse_clause(Expr*predicate,Node*clause);
8586
staticboolpred_test_recurse_pred(Expr*predicate,Node*clause);
@@ -153,7 +154,8 @@ create_index_paths(Query *root, RelOptInfo *rel)
153154
* predicate test.
154155
*/
155156
if (index->indpred!=NIL)
156-
if (!pred_test(index->indpred,restrictinfo_list,joininfo_list))
157+
if (!pred_test(index->indpred,restrictinfo_list,joininfo_list,
158+
lfirsti(rel->relids)))
157159
continue;
158160

159161
/*
@@ -957,7 +959,8 @@ indexable_operator(Expr *clause, Oid opclass, bool indexkey_on_left)
957959
* to CNF format). --Nels, Jan '93
958960
*/
959961
staticbool
960-
pred_test(List*predicate_list,List*restrictinfo_list,List*joininfo_list)
962+
pred_test(List*predicate_list,List*restrictinfo_list,List*joininfo_list,
963+
intrelvarno)
961964
{
962965
List*pred;
963966

@@ -980,6 +983,18 @@ pred_test(List *predicate_list, List *restrictinfo_list, List *joininfo_list)
980983
return false;/* no restriction clauses: the test must
981984
* fail */
982985

986+
/*
987+
* The predicate as stored in the index definition will use varno 1
988+
* for its Vars referencing the indexed relation. If the indexed
989+
* relation isn't varno 1 in the query, we must adjust the predicate
990+
* to make the Vars match, else equal() won't work.
991+
*/
992+
if (relvarno!=1)
993+
{
994+
predicate_list=copyObject(predicate_list);
995+
ChangeVarNodes((Node*)predicate_list,1,relvarno,0);
996+
}
997+
983998
foreach(pred,predicate_list)
984999
{
9851000
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp