*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.18 1999/02/11 14:58:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.19 1999/02/11 17:00:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
foreach(i, paths)
{
Path *path = (Path *) lfirst(i);
- int more_sort;
+ int better_sort;
key_match = every_func(joinkeys, path->pathkeys, which_subkey);
- if (pathorder_match(ordering, path->pathorder, &more_sort) &&
- more_sort == 0 &&
+ if (pathorder_match(ordering, path->pathorder, &better_sort) &&
+ better_sort == 0 &&
length(joinkeys) == length(path->pathkeys) && key_match)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.15 1999/02/11 04:08:42 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.16 1999/02/11 17:00:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
*
*/
bool
-pathkeys_match(List *keys1, List *keys2, int *longer_key)
+pathkeys_match(List *keys1, List *keys2, int *better_key)
{
List *key1,
*key2,
key1a = lnext(key1a), key2a = lnext(key2a))
if (!equal(lfirst(key1a), lfirst(key2a)))
{
- *longer_key = 0;
+ *better_key = 0;
return false;
}
if (key1a != NIL && key2a == NIL)
{
- *longer_key = 1;
+ *better_key = 1;
return true;
}
if (key1a == NIL && key2a != NIL)
{
- *longer_key = 2;
+ *better_key = 2;
return true;
}
}
*/
if (key1 != NIL && key2 == NIL)
{
- *longer_key = 1;
+ *better_key = 1;
return true;
}
if (key1 == NIL && key2 != NIL)
{
- *longer_key = 2;
+ *better_key = 2;
return true;
}
- *longer_key = 0;
+ *better_key = 0;
return true;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.12 1999/02/11 14:58:58 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.13 1999/02/11 17:00:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/internal.h"
#include "optimizer/ordering.h"
-static bool equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort);
+static bool equal_sortops_order(Oid *ordering1, Oid *ordering2, int *better_sort);
/*
* equal-path-ordering--
bool
pathorder_match(PathOrder *path_ordering1,
PathOrder *path_ordering2,
- int *more_sort)
+ int *better_sort)
{
- *more_sort = 0;
+ *better_sort = 0;
if (path_ordering1 == path_ordering2)
return true;
if (!path_ordering2)
{
- *more_sort = 1;
+ *better_sort = 1;
return true;
}
if (!path_ordering1)
{
- *more_sort = 2;
+ *better_sort = 2;
return true;
}
{
return equal_sortops_order(path_ordering1->ord.sortop,
path_ordering2->ord.sortop,
- more_sort);
+ better_sort);
}
else if (path_ordering1->ordtype == MERGE_ORDER &&
path_ordering2->ordtype == SORTOP_ORDER)
{
if (!path_ordering2->ord.sortop)
{
- *more_sort = 1;
+ *better_sort = 1;
return true;
}
return path_ordering1->ord.merge->left_operator == path_ordering2->ord.sortop[0];
{
if (!path_ordering1->ord.sortop)
{
- *more_sort = 2;
+ *better_sort = 2;
return true;
}
return path_ordering1->ord.sortop[0] == path_ordering2->ord.merge->left_operator;
* Returns true iff the sort operators are in the same order.
*/
static bool
-equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort)
+equal_sortops_order(Oid *ordering1, Oid *ordering2, int *better_sort)
{
int i = 0;
- *more_sort = 0;
+ *better_sort = 0;
if (ordering1 == ordering2)
return true;
if (!ordering2)
{
- *more_sort = 1;
+ *better_sort = 1;
return true;
}
if (!ordering1)
{
- *more_sort = 2;
+ *better_sort = 2;
return true;
}
if (ordering1[i] != 0 && ordering2[i] == 0)
{
- *more_sort = 1;
+ *better_sort = 1;
return true;
}
if (ordering1[i] == 0 && ordering2[i] != 0)
{
- *more_sort = 2;
+ *better_sort = 2;
return true;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.27 1999/02/11 16:09:41 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.28 1999/02/11 17:00:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
{
Path *path = (Path *) NULL;
List *temp = NIL;
- int longer_key;
- int more_sort;
+ int better_key;
+ int better_sort;
foreach(temp, unique_paths)
{
path = (Path *) lfirst(temp);
#ifdef OPTDUP_DEBUG
- if (!pathkeys_match(new_path->pathkeys, path->pathkeys, &longer_key) ||
- longer_key != 0)
+ if (!pathkeys_match(new_path->pathkeys, path->pathkeys, &better_key) ||
+ better_key != 0)
{
printf("oldpath\n");
pprint(path->pathkeys);
length(lfirst(path->pathkeys)) < length(lfirst(new_path->pathkeys)))
sleep(0); /* set breakpoint here */
}
- if (!pathorder_match(new_path->pathorder, path->pathorder, &more_sort))
+ if (!pathorder_match(new_path->pathorder, path->pathorder, &better_sort))
{
printf("oldord\n");
pprint(path->pathorder);
}
#endif
- if (pathkeys_match(new_path->pathkeys, path->pathkeys, &longer_key))
+ if (pathkeys_match(new_path->pathkeys, path->pathkeys, &better_key))
{
- if (pathorder_match(new_path->pathorder, path->pathorder, &more_sort))
+ if (pathorder_match(new_path->pathorder, path->pathorder, &better_sort))
{
/*
* Replace pathkeys that match exactly, (1,2), (1,2).
* over unsorted keys in the same way.
*/
/* same keys, and new is cheaper, use it */
- if ((longer_key == 0 && more_sort == 0 &&
+ if ((better_key == 0 && better_sort == 0 &&
new_path->path_cost < path->path_cost) ||
/* new is better, and cheaper, use it */
- ((longer_key == 1 && more_sort != 2) ||
- (longer_key != 2 && more_sort == 1)) &&
+ ((better_key == 1 && better_sort != 2) ||
+ (better_key != 2 && better_sort == 1)) &&
new_path->path_cost <= path->path_cost)
{
*is_new = false;
/* same keys, new is more expensive, stop */
else if
- ((longer_key == 0 && more_sort == 0 &&
+ ((better_key == 0 && better_sort == 0 &&
new_path->path_cost >= path->path_cost) ||
/* old is better, and less expensive, stop */
- ((longer_key == 2 && more_sort != 1) ||
- (longer_key != 1 && more_sort == 2)) &&
+ ((better_key == 2 && better_sort != 1) ||
+ (better_key != 1 && better_sort == 2)) &&
new_path->path_cost >= path->path_cost)
{
*is_new = false;
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: keys.h,v 1.10 1999/02/11 04:08:44 momjian Exp $
+ * $Id: keys.h,v 1.11 1999/02/11 17:00:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
extern bool match_indexkey_operand(int indexkey, Var *operand, RelOptInfo *rel);
extern Var *extract_join_subkey(JoinKey *jk, int which_subkey);
-extern bool pathkeys_match(List *keys1, List *keys2, int *longer_key);
+extern bool pathkeys_match(List *keys1, List *keys2, int *better_key);
extern List *collect_index_pathkeys(int *index_keys, List *tlist);
#endif /* KEYS_H */
*
* Copyright (c) 1994, Regents of the University of California
*
- * $Id: ordering.h,v 1.11 1999/02/11 14:59:09 momjian Exp $
+ * $Id: ordering.h,v 1.12 1999/02/11 17:00:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
#include <nodes/relation.h>
extern bool pathorder_match(PathOrder *path_ordering1,
- PathOrder *path_ordering2, int *more_sort);
+ PathOrder *path_ordering2, int *better_sort);
extern bool equal_path_merge_ordering(Oid *path_ordering,
MergeOrder *merge_ordering);
extern bool equal_merge_ordering(MergeOrder *merge_ordering1,