]> granicus.if.org Git - postgresql/commitdiff
Optimizer cleanup.
authorBruce Momjian <bruce@momjian.us>
Thu, 11 Feb 1999 17:00:49 +0000 (17:00 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 11 Feb 1999 17:00:49 +0000 (17:00 +0000)
src/backend/optimizer/path/joinutils.c
src/backend/optimizer/util/keys.c
src/backend/optimizer/util/ordering.c
src/backend/optimizer/util/pathnode.c
src/include/optimizer/keys.h
src/include/optimizer/ordering.h

index 61fb755d8ba185f5c8cb3307bbfe97a028bd032c..b9b277d69f52e9c5ed7d2df40f216ce91bb1ab98 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -214,12 +214,12 @@ match_paths_joinkeys(List *joinkeys,
        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)
                {
 
index 1177f6bbb209477f4195ac5c7cb62eb5be40784b..b82c807e7e0c465ae6f15847e4c0c7b0eadeed0c 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -118,7 +118,7 @@ extract_join_subkey(JoinKey *jk, int which_subkey)
  *
  */
 bool
-pathkeys_match(List *keys1, List *keys2, int *longer_key)
+pathkeys_match(List *keys1, List *keys2, int *better_key)
 {
        List       *key1,
                           *key2,
@@ -134,17 +134,17 @@ pathkeys_match(List *keys1, List *keys2, int *longer_key)
                         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;
                }
        }
@@ -156,15 +156,15 @@ pathkeys_match(List *keys1, List *keys2, int *longer_key)
         */
        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;
 }
 
index 8e5fb15baf24151f4aef52f432ae346dbdf5d864..412879e8c7e2205891dc85a52f9e36c399d3e512 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 #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--
@@ -28,23 +28,23 @@ static bool equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort);
 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;
        }
 
@@ -58,14 +58,14 @@ pathorder_match(PathOrder *path_ordering1,
        {
                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];
@@ -74,7 +74,7 @@ pathorder_match(PathOrder *path_ordering1,
        {
                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;
@@ -127,24 +127,24 @@ equal_merge_ordering(MergeOrder *merge_ordering1,
  *       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;
        }
        
@@ -157,13 +157,13 @@ equal_sortops_order(Oid *ordering1, Oid *ordering2, int *more_sort)
 
        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;
        }
        
index c86ab8a2aa02e6ecaf3efdfdd6b21575f73a823c..ed8576af64fe6fe920c34e37c5bb84a6e9dd438d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -157,16 +157,16 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
 {
        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);
@@ -177,7 +177,7 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
                                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);
@@ -186,9 +186,9 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
                }
 #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).
@@ -198,12 +198,12 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
                                 * 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;
@@ -212,12 +212,12 @@ better_path(Path *new_path, List *unique_paths, bool *is_new)
 
                                                                /* 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;
index a66fd2bc6bf7aec2c750cd8337435f741fde16a6..b1798b1c8cc1b6c21c92f06065728a2441b21f5b 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -18,7 +18,7 @@
 
 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 */
index acade2bc2fc2ac7c98e699c372fa1c54495e8bdb..1ff2cdbc4fba7b08c8da5b859c16a694b8a5e8bc 100644 (file)
@@ -6,7 +6,7 @@
  *
  * 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 $
  *
  *-------------------------------------------------------------------------
  */
@@ -16,7 +16,7 @@
 #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,