*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.188 2005/08/28 22:47:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/path/indxpath.c,v 1.190 2005/09/24 22:54:36 tgl Exp $
*
*-------------------------------------------------------------------------
*/
Relids outer_relids);
static List *find_clauses_for_join(PlannerInfo *root, RelOptInfo *rel,
Relids outer_relids, bool isouterjoin);
-static bool match_variant_ordering(PlannerInfo *root,
- IndexOptInfo *index,
- List *restrictclauses,
- ScanDirection *indexscandir);
+static ScanDirection match_variant_ordering(PlannerInfo *root,
+ IndexOptInfo *index,
+ List *restrictclauses);
static List *identify_ignorable_ordering_cols(PlannerInfo *root,
IndexOptInfo *index,
List *restrictclauses);
root->query_pathkeys != NIL &&
pathkeys_useful_for_ordering(root, useful_pathkeys) == 0)
{
- ScanDirection indexscandir;
+ ScanDirection scandir;
- if (match_variant_ordering(root, index, restrictclauses,
- &indexscandir))
+ scandir = match_variant_ordering(root, index, restrictclauses);
+ if (!ScanDirectionIsNoMovement(scandir))
{
ipath = create_index_path(root, index,
restrictclauses,
root->query_pathkeys,
- indexscandir,
+ scandir,
false);
result = lappend(result, ipath);
}
/*
* Examine each joinclause in the joininfo list to see if it matches any
* key of any index. If so, add the clause's other rels to the result.
- * (Note: we consider only actual participants, not extraneous rels
- * possibly mentioned in required_relids.)
*/
foreach(l, rel->joininfo)
{
RestrictInfo *joininfo = (RestrictInfo *) lfirst(l);
Relids other_rels;
- other_rels = bms_difference(joininfo->clause_relids, rel->relids);
+ other_rels = bms_difference(joininfo->required_relids, rel->relids);
if (matches_any_index(joininfo, rel, other_rels))
outer_relids = bms_join(outer_relids, other_rels);
else
* 'restrictclauses' is the list of sublists of restriction clauses
* matching the columns of the index (NIL if none)
*
- * Returns TRUE if able to match the requested query pathkeys, FALSE if not.
- * In the TRUE case, sets '*indexscandir' to either ForwardScanDirection or
- * BackwardScanDirection to indicate the proper scan direction.
+ * If able to match the requested query pathkeys, returns either
+ * ForwardScanDirection or BackwardScanDirection to indicate the proper index
+ * scan direction. If no match, returns NoMovementScanDirection.
*/
-static bool
+static ScanDirection
match_variant_ordering(PlannerInfo *root,
IndexOptInfo *index,
- List *restrictclauses,
- ScanDirection *indexscandir)
+ List *restrictclauses)
{
List *ignorables;
* won't cope.
*/
if (index->relam != BTREE_AM_OID)
- return false;
+ return NoMovementScanDirection;
/*
* Figure out which index columns can be optionally ignored because
* they have an equality constraint. This is the same set for either
if (ignorables &&
match_index_to_query_keys(root, index, ForwardScanDirection,
ignorables))
- {
- *indexscandir = ForwardScanDirection;
- return true;
- }
+ return ForwardScanDirection;
+
if (match_index_to_query_keys(root, index, BackwardScanDirection,
ignorables))
- {
- *indexscandir = BackwardScanDirection;
- return true;
- }
- return false;
+ return BackwardScanDirection;
+
+ return NoMovementScanDirection;
}
/*