1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-15 03:41:20 +03:00

Fix a number of places that made faulty assumptions about

what is_opclause will accept.
This commit is contained in:
Tom Lane
1999-02-15 01:06:59 +00:00
parent 5500039843
commit dec354ca97
6 changed files with 127 additions and 56 deletions

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.17 1999/02/13 23:16:15 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.18 1999/02/15 01:06:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -206,7 +206,7 @@ compute_selec(Query *root, List *clauses, List *or_selectivities)
Cost s1 = 0;
List *clause = lfirst(clauses);
if (clauses == NULL)
if (clause == NULL)
s1 = 1.0;
else if (IsA(clause, Param))
{
@@ -351,7 +351,7 @@ compute_selec(Query *root, List *clauses, List *or_selectivities)
* an 'or' clause, but rather that of the single clause.
*/
if (length(clauses) < 2)
if (lnext(clauses) == NIL)
return s1;
else
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.44 1999/02/13 23:16:16 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.45 1999/02/15 01:06:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -324,25 +324,25 @@ match_index_orclause(RelOptInfo *rel,
{
clause = lfirst(clist);
if (is_opclause(clause) &&
op_class(((Oper *) ((Expr *) clause)->oper)->opno,
xclass, index->relam) &&
((match_index_to_operand(indexkey,
(Expr *) get_leftop((Expr *) clause),
rel,
index) &&
IsA(get_rightop((Expr *) clause), Const)) ||
(match_index_to_operand(indexkey,
(Expr *) get_rightop((Expr *) clause),
rel,
index) &&
IsA(get_leftop((Expr *) clause), Const))))
lfirst(matching_indices) = lcons(index, lfirst(matching_indices));
if (is_opclause(clause))
{
Expr *left = (Expr *) get_leftop((Expr *) clause);
Expr *right = (Expr *) get_rightop((Expr *) clause);
if (left && right &&
op_class(((Oper *) ((Expr *) clause)->oper)->opno,
xclass, index->relam) &&
((IsA(right, Const) &&
match_index_to_operand(indexkey, left, rel, index)) ||
(IsA(left, Const) &&
match_index_to_operand(indexkey, right, rel, index))))
lfirst(matching_indices) = lcons(index,
lfirst(matching_indices));
}
matching_indices = lnext(matching_indices);
}
return index_list;
return index_list;
}
/****************************************************************************
@@ -1019,6 +1019,7 @@ clause_pred_clause_test(Expr *predicate, Node *clause)
/* Check the basic form; for now, only allow the simplest case */
if (!is_opclause(clause) ||
!IsA(clause_var, Var) ||
clause_const == NULL ||
!IsA(clause_const, Const) ||
!IsA(predicate->oper, Oper) ||
!IsA(pred_var, Var) ||