mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Clean up handling of variable-free qual clauses. System now does the
right thing with variable-free clauses that contain noncachable functions, such as 'WHERE random() < 0.5' --- these are evaluated once per potential output tuple. Expressions that contain only Params are now candidates to be indexscan quals --- for example, 'var = ($1 + 1)' can now be indexed. Cope with RelabelType nodes atop potential indexscan variables --- this oversight prevents 7.0.* from recognizing some potentially indexscanable situations.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.38 2000/06/08 22:37:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.39 2000/08/13 02:50:04 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -123,7 +123,7 @@ clauselist_selectivity(Query *root,
|
||||
Selectivity s2;
|
||||
|
||||
/*
|
||||
* See if it looks like a restriction clause with a Const or Param
|
||||
* See if it looks like a restriction clause with a pseudoconstant
|
||||
* on one side. (Anything more complicated than that might not
|
||||
* behave in the simple way we are expecting.)
|
||||
*
|
||||
@@ -146,7 +146,7 @@ clauselist_selectivity(Query *root,
|
||||
|
||||
other = (flag & SEL_RIGHT) ? get_rightop((Expr *) clause) :
|
||||
get_leftop((Expr *) clause);
|
||||
if (IsA(other, Const) || IsA(other, Param))
|
||||
if (is_pseudo_constant_clause((Node *) other))
|
||||
{
|
||||
Oid opno = ((Oper *) ((Expr *) clause)->oper)->opno;
|
||||
RegProcedure oprrest = get_oprrest(opno);
|
||||
@@ -533,6 +533,13 @@ clause_selectivity(Query *root,
|
||||
*/
|
||||
s1 = 1.0;
|
||||
}
|
||||
else if (IsA(clause, RelabelType))
|
||||
{
|
||||
/* Not sure this case is needed, but it can't hurt */
|
||||
s1 = clause_selectivity(root,
|
||||
((RelabelType *) clause)->arg,
|
||||
varRelid);
|
||||
}
|
||||
|
||||
return s1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user