head	1.21;
access;
symbols
	release_4_2:1.21
	aix_ok:1.21
	Version_2_1:1.11
	C_Demo_1:1.8
	Retrieve_x_qual:1.6
	Retrieve_x_all:1.5
	Retrieve_x_1:1.4;
locks; strict;
comment	@ * @;


1.21
date	92.11.23.22.54.05;	author joey;	state Exp;
branches;
next	1.20;

1.20
date	92.03.31.23.13.22;	author mer;	state Exp;
branches;
next	1.19;

1.19
date	91.11.17.20.39.50;	author mer;	state Exp;
branches;
next	1.18;

1.18
date	91.11.15.16.27.28;	author hong;	state Exp;
branches;
next	1.17;

1.17
date	91.11.02.21.42.36;	author hong;	state Exp;
branches;
next	1.16;

1.16
date	91.07.17.23.47.06;	author hong;	state Exp;
branches;
next	1.15;

1.15
date	91.05.29.23.11.48;	author hong;	state Exp;
branches;
next	1.14;

1.14
date	91.05.08.15.10.19;	author hong;	state Exp;
branches;
next	1.13;

1.13
date	91.04.27.14.17.26;	author hong;	state Exp;
branches;
next	1.12;

1.12
date	91.04.25.04.18.21;	author hong;	state Exp;
branches;
next	1.11;

1.11
date	90.10.15.14.55.06;	author choi;	state Exp;
branches;
next	1.10;

1.10
date	90.09.25.16.36.21;	author kemnitz;	state Exp;
branches;
next	1.9;

1.9
date	89.09.29.14.45.12;	author hong;	state Exp;
branches;
next	1.8;

1.8
date	89.09.05.17.17.43;	author mao;	state C_Demo_1;
branches;
next	1.7;

1.7
date	89.08.23.16.03.50;	author ong;	state Exp;
branches;
next	1.6;

1.6
date	89.08.04.14.27.33;	author goh;	state Exp;
branches;
next	1.5;

1.5
date	89.08.04.13.23.37;	author goh;	state Exp;
branches;
next	1.4;

1.4
date	89.08.01.14.40.22;	author goh;	state Exp;
branches;
next	1.3;

1.3
date	89.07.25.17.35.45;	author ong;	state Exp;
branches;
next	1.2;

1.2
date	89.07.20.10.46.29;	author ong;	state Exp;
branches;
next	1.1;

1.1
date	89.07.10.15.17.39;	author ong;	state Exp;
branches;
next	;


desc
@stuff for plan pruning
@


1.21
log
@don't prune if relation's pruneable flag is false!
@
text
@/*     
 *      FILE
 *     	prune
 *     
 *      DESCRIPTION
 *     	Routines to prune redundant paths and relations
 *     
 */

/* RcsId("$Header: /usr/local/dev/postgres/newtree/src/backend/planner/path/RCS/prune.c,v 1.20 1992/03/31 23:13:22 mer Exp $"); */

/*     
 *      EXPORTS
 *     		prune-joinrels
 *     		prune-rel-paths
 *     		prune-rel-path
 */

#include "nodes/pg_lisp.h"
#include "nodes/relation.h"
#include "nodes/relation.a.h"

#include "planner/internal.h"
#include "planner/pathnode.h"
#include "planner/prune.h"

extern int testFlag;
/*    
 *    	prune-joinrels
 *    
 *    	Removes any redundant relation entries from a list of rel nodes
 *    	'rel-list'.
 *    
 *    	Returns the resulting list. 
 *    
 */

/*  .. find-join-paths, prune-joinrels    */

LispValue
prune_joinrels(rel_list)
     LispValue rel_list ;
{
     LispValue temp_list = LispNil;
     if( consp(rel_list) ) {
	  temp_list = lispCons(CAR(rel_list),
			    prune_joinrels(prune_joinrel((Rel)CAR(rel_list),
							  CDR(rel_list))));
     } 
     return(temp_list);

}  /* function end  */

/*    
 *    	prune-joinrel
 *    
 *    	Prunes those relations from 'other-rels' that are redundant with
 *    	'rel'.  A relation is redundant if it is built up of the same
 *    	relations as 'rel'.  Paths for the redundant relation are merged into
 *    	the pathlist of 'rel'.
 *    
 *    	Returns a list of non-redundant relations, and sets the pathlist field
 *    	of 'rel' appropriately.
 *    
 */

/*  .. prune-joinrels, merge_joinrels */

LispValue
prune_joinrel(rel,other_rels)
     Rel rel;
     List other_rels ;
{
     /*  XXX was mapcan   */
     
     LispValue i = LispNil;
     LispValue t_list = LispNil;
     LispValue temp_node = LispNil;
     Rel other_rel = (Rel)NULL;
     
     foreach(i,other_rels) {
	 other_rel = (Rel)CAR(i);
	 if(same(get_relids(rel),get_relids(other_rel))) {
	     set_pathlist(rel,add_pathlist(rel,
					     get_pathlist(rel),
					     get_pathlist(other_rel)));
	     t_list = nconc(t_list, LispNil);  /* XXX is this right ? */
	 } 
	 else {
	     temp_node = lispCons((LispValue)other_rel,LispNil);
	     t_list = nconc(t_list,temp_node);
	 } 
     }
     return(t_list);
 }  /* function end  */

/*    
 *    	prune-rel-paths
 *    
 *    	For each relation entry in 'rel-list' (which corresponds to a join
 *    	relation), set pointers to the unordered path and cheapest paths
 *    	(if the unordered path isn't the cheapest, it is pruned), and
 *    	reset the relation's size field to reflect the join.
 *    
 *    	Returns nothing of interest.
 *    
 */

/*  .. find-join-paths   */

void
prune_rel_paths(rel_list)
     List rel_list ;
{
    LispValue x = LispNil;
    LispValue y = LispNil;
    Path path;
    Rel rel = (Rel)NULL;
    JoinPath cheapest = (JoinPath)NULL;
    
    foreach(x, rel_list) {
	rel = (Rel)CAR(x);
	foreach(y, get_pathlist(rel)) {
	    path = (Path)CAR(y);
	    if(!get_p_ordering(path)) {
		break;
	      }	    
	  }
	cheapest = (JoinPath)prune_rel_path(rel, path);
	if(IsA(cheapest,JoinPath))
	{
	  set_size(rel,compute_joinrel_size(cheapest));
	}
	else
	  printf( "WARN: non JoinPath called. \n");
    }
}  /* function end  */

/* ------------------------------
 *	mergepath_contain_redundant_sorts
 *
 *	return true if path contains redundant sorts, i.e.,
 *	a sort on an already ordered relation
 *	note: current this routine is not used because
 *	we forbidden any explicit sorts since hashjoins
 *	can always do better.
 * -------------------------------
 */
bool
mergepath_contain_redundant_sorts(path)
MergePath path;
{
    MergeOrder morder;
    Path innerpath, outerpath;
    List outerorder, innerorder;
    List outerkeys, innerkeys;

    if(get_outersortkeys(path) || get_innersortkeys(path))
	return true;  /* a temporary hack to reduce plan space */
    else return false;

#if 0
    morder = (MergeOrder)get_p_ordering(path);
    outerpath = get_outerjoinpath(path);
    outerorder = get_p_ordering(outerpath);
    outerkeys = get_keys(outerpath);
    if(outerorder && 
	get_left_operator(morder) ==
	(IsA(outerorder,MergeOrder)?get_left_operator(outerorder):
	 CInteger(CAR(outerorder))) &&
	get_outersortkeys(path) &&
	outerkeys &&
	CAR(outerkeys) &&
	member(CAR(CAR(get_outersortkeys(path))),
	      CAR(outerkeys)))
	return true;
    innerpath = get_innerjoinpath(path);
    innerorder = get_p_ordering(innerpath);
    innerkeys = get_keys(innerpath);
    if(innerorder &&
	get_right_operator(morder) ==
	(IsA(innerorder,MergeOrder)?get_right_operator(innerorder):
	 CInteger(CAR(innerorder))) &&
	get_innersortkeys(path) &&
	innerkeys &&
	CAR(innerkeys) &&
	member(CAR(CAR(get_innersortkeys(path))),
	      CAR(innerkeys)))
	return true;
    return false;
#endif
}

/* --------------------------------------
 *	path_contain_rotated_mergepaths
 *
 *	return true if two paths are virtually the same except on
 *	the order of a mergejoin, such two paths should always
 *	have the same cost.
 * --------------------------------------
 */
bool
path_contain_rotated_mergepaths(p1, p2)
Path p1, p2;
{
    Path p;
    if(p1 == NULL || p2 == NULL) return NULL;
    if(IsA(p1,MergePath) && IsA(p2,MergePath)) {
       if(equal((Node)get_outerjoinpath((JoinPath)p1),
		(Node)get_innerjoinpath((JoinPath)p2)) &&
           equal((Node)get_innerjoinpath((JoinPath)p1),
		 (Node)get_outerjoinpath((JoinPath)p2)))
          return true;
      }
    if(IsA(p1,JoinPath) && IsA(p2,JoinPath)) {
       return path_contain_rotated_mergepaths(get_outerjoinpath((JoinPath)p1),
                                              get_outerjoinpath((JoinPath)p2)) ||
              path_contain_rotated_mergepaths(get_innerjoinpath((JoinPath)p1),
                                              get_innerjoinpath((JoinPath)p2));
      }
    return false;
}


/* --------------------------------------
 *	path_contain_redundant_indexscans
 *
 *	return true if path contains obviously useless indexscans, i.e.,
 *	if indxqual is nil and the order is not later utilized
 * --------------------------------------
 */
bool
path_contain_redundant_indexscans(path, order_expected)
Path path;
bool order_expected;
{
    if(IsA(path,MergePath)) {
        return path_contain_redundant_indexscans(get_outerjoinpath((JoinPath)path), 
				!get_outersortkeys((MergePath)path)) ||
               path_contain_redundant_indexscans(get_innerjoinpath((JoinPath)path), 
				!get_innersortkeys((MergePath)path));
      }
    if(IsA(path,HashPath)) {
        return path_contain_redundant_indexscans(get_outerjoinpath((JoinPath)path), 
						 false) ||
               path_contain_redundant_indexscans(get_innerjoinpath((JoinPath)path), 
						 false);
      }
    if(IsA(path,JoinPath)) {
        if(!IsA(get_innerjoinpath((JoinPath)path),IndexPath) &&
            !IsA(get_innerjoinpath((JoinPath)path),JoinPath) &&
            length(get_relids(get_parent((Path)get_innerjoinpath((JoinPath)path)))) == 1)
           return true;
        return path_contain_redundant_indexscans(get_outerjoinpath((JoinPath)path), 
						 order_expected) ||
               path_contain_redundant_indexscans(get_innerjoinpath((JoinPath)path), 
						 false);
      }
    if(IsA(path,IndexPath)) {
        return lispNullp(get_indexqual((IndexPath)path)) && !order_expected;
      }
    return false;
}

/* ----------------------------------------------
 *	test_prune_unnecessary_paths
 *
 *	prune paths of rel for tests, only meant to be called with
 *	testFlag is set.
 * -----------------------------------------------
 */
void
test_prune_unnecessary_paths(rel)
Rel rel;
{
     LispValue x, y;
     Path path, path1;
     List newpathlist = LispNil;
     List prunelist = LispNil;
     /* done in path generation, match_unsorted_outer and match_unsorted_inner
     foreach(x, get_pathlist(rel)) {
	 path = (Path)CAR(x);
	 if(IsA(path,MergePath)) {
	     if(mergepath_contain_redundant_sorts(path))
	     continue;
	   }
	 newpathlist = nappend1(newpathlist, path);
      }
     */
     foreach(x, get_pathlist(rel)) {
	 path = (Path)CAR(x);
	 if(!path_contain_redundant_indexscans(path,
			    (length(get_relids(get_parent(path))) !=
			     length(_base_relation_list_)))) {
	     newpathlist = nappend1(newpathlist, (LispValue)path);
	   }
       }
     foreach(x, newpathlist) {
	 path = (Path)CAR(x);
	 foreach(y, CDR(x)) {
	     path1 = (Path)CAR(y);
	     if(equal((Node)path, (Node)path1) ||
		 path_contain_rotated_mergepaths(path, path1))
		 prunelist = nappend1(prunelist, (LispValue)path1);
	   }
       }
     newpathlist = nset_difference(newpathlist, prunelist);
     set_pathlist(rel, newpathlist);
}

/*    
 *    	prune-rel-path
 *    
 *    	Compares the unordered path for a relation with the cheapest path  if
 *    	the unordered path is not cheapest, it is pruned.
 *    
 *    	Resets the pointers in 'rel' for unordered and cheapest paths.
 *    
 *    	Returns the cheapest path.
 *    
 */

/*  .. find-rel-paths, prune-rel-paths	 */

Path
prune_rel_path(rel,unorderedpath)
     Rel rel ;
     Path unorderedpath ;
{
     Path cheapest = set_cheapest(rel,get_pathlist(rel));

     /* don't prune if not pruneable  -- JMH, 11/23/92 */
     if(!(eq(unorderedpath,cheapest)) && !testFlag
	&& get_pruneable(rel)) {

	  set_unorderedpath(rel,(PathPtr)NULL);
	  set_pathlist(rel,LispRemove((LispValue)unorderedpath,
				      get_pathlist(rel)));

     } else {

	  set_unorderedpath(rel,(PathPtr)unorderedpath);

     } 

     if(testFlag) {
	 test_prune_unnecessary_paths(rel);
       }
     
     return(cheapest);

}  /* function end  */


/*
 *      merge-joinrels
 *
 *      Given two lists of rel nodes that are already
 *      pruned, merge them into one pruned rel node list
 *
 *      'rel-list1' and
 *      'rel-list2' are the rel node lists
 *
 *      Returns one pruned rel node list
 */

/* .. find-join-paths
*/
LispValue
merge_joinrels(rel_list1,rel_list2)
LispValue rel_list1, rel_list2;
{
    LispValue xrel = LispNil;

    foreach(xrel,rel_list1) {
        Rel rel = (Rel)CAR(xrel);
        rel_list2 = prune_joinrel(rel,rel_list2);
    }
    return(append(rel_list1, rel_list2));
}

/*
 *	prune_oldrels
 *
 *	If all the joininfo's in a rel node are inactive,
 *	that means that this node has been joined into
 *	other nodes in all possible ways, therefore
 *	this node can be discarded.  If not, it will cause
 *	extra complexity of the optimizer.
 *
 *	old_rels is a list of rel nodes
 *	
 *	Returns a new list of rel nodes
 */

/* .. find_join_paths
*/
LispValue
prune_oldrels(old_rels)
LispValue old_rels;
{
     Rel rel;
     LispValue joininfo_list, xjoininfo;

     if(old_rels == LispNil)
	  return(LispNil);

     rel = (Rel)CAR(old_rels);
     joininfo_list = get_joininfo(rel);
     if(joininfo_list == LispNil)
	 return(lispCons((LispValue)rel, prune_oldrels(CDR(old_rels))));
     foreach(xjoininfo, joininfo_list) {
	 JInfo joininfo = (JInfo)CAR(xjoininfo);
	 if(!joininfo_inactive(joininfo))
	      return(lispCons((LispValue)rel, prune_oldrels(CDR(old_rels))));
      }
     return(prune_oldrels(CDR(old_rels)));
}
@


1.20
log
@change accessor functions into macros
@
text
@d10 1
a10 1
/* RcsId("$Header: /users/mer/pg/src/planner/path/RCS/prune.c,v 1.19 1991/11/17 20:39:50 mer Exp mer $"); */
d332 3
a334 1
     if(!(eq(unorderedpath,cheapest)) && !testFlag) {
@


1.19
log
@prototyping
@
text
@d10 1
a10 1
/* RcsId("$Header: /users/mer/postgres/src/planner/path/RCS/prune.c,v 1.18 1991/11/15 16:27:28 hong Exp mer $"); */
d131 1
d133 1
d252 1
a252 1
            length(get_relids(get_parent(get_innerjoinpath((JoinPath)path)))) == 1)
d334 1
a334 1
	  set_unorderedpath(rel,(Path)NULL);
d340 1
a340 1
	  set_unorderedpath(rel,unorderedpath);
@


1.18
log
@planner prototyping
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.17 91/11/02 21:42:36 hong Exp $"); */
d90 1
a90 1
	     temp_node = lispCons(other_rel,LispNil);
d207 4
a210 2
       if(equal(get_outerjoinpath((JoinPath)p1), get_innerjoinpath((JoinPath)p2)) &&
           equal(get_innerjoinpath((JoinPath)p1), get_outerjoinpath((JoinPath)p2)))
d293 1
a293 1
	     newpathlist = nappend1(newpathlist, path);
d300 1
a300 1
	     if(equal(path, path1) ||
d302 1
a302 1
		 prunelist = nappend1(prunelist, path1);
d333 2
a334 1
	  set_pathlist(rel,LispRemove(unorderedpath,get_pathlist(rel)));
d407 1
a407 1
	 return(lispCons(rel, prune_oldrels(CDR(old_rels))));
d411 1
a411 1
	      return(lispCons(rel, prune_oldrels(CDR(old_rels))));
@


1.17
log
@cleaned up bushy tree plan generation code.
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.16 91/07/17 23:47:06 hong Exp Locker: hong $"); */
d47 1
a47 1
			    prune_joinrels(prune_joinrel(CAR(rel_list),
d71 2
a72 1
     LispValue rel,other_rels ;
d207 2
a208 2
       if(equal(get_outerjoinpath(p1), get_innerjoinpath(p2)) &&
           equal(get_innerjoinpath(p1), get_outerjoinpath(p2)))
d212 4
a215 4
       return path_contain_rotated_mergepaths(get_outerjoinpath(p1),
                                              get_outerjoinpath(p2)) ||
              path_contain_rotated_mergepaths(get_innerjoinpath(p1),
                                              get_innerjoinpath(p2));
d234 4
a237 4
        return path_contain_redundant_indexscans(get_outerjoinpath(path), 
				!get_outersortkeys(path)) ||
               path_contain_redundant_indexscans(get_innerjoinpath(path), 
				!get_innersortkeys(path));
d240 1
a240 1
        return path_contain_redundant_indexscans(get_outerjoinpath(path), 
d242 1
a242 1
               path_contain_redundant_indexscans(get_innerjoinpath(path), 
d246 3
a248 3
        if(!IsA(get_innerjoinpath(path),IndexPath) &&
            !IsA(get_innerjoinpath(path),JoinPath) &&
            length(get_relids(get_parent(get_innerjoinpath(path)))) == 1)
d250 1
a250 1
        return path_contain_redundant_indexscans(get_outerjoinpath(path), 
d252 1
a252 1
               path_contain_redundant_indexscans(get_innerjoinpath(path), 
d256 1
a256 1
        return lispNullp(get_indexqual(path)) && !order_expected;
d330 1
a330 1
	  set_unorderedpath(rel,LispNil);
d369 1
a369 1
        LispValue rel = CAR(xrel);
@


1.16
log
@to get rid of a compile warning
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.15 91/05/29 23:11:48 hong Exp $"); */
d41 1
a41 1
prune_joinrels (rel_list)
d45 4
a48 4
     if ( consp (rel_list) ) {
	  temp_list = lispCons (CAR (rel_list),
			    prune_joinrels (prune_joinrel(CAR (rel_list),
							  CDR (rel_list))));
d70 1
a70 1
prune_joinrel (rel,other_rels)
d82 4
a85 4
	 if(same (get_relids (rel),get_relids (other_rel))) {
	     set_pathlist (rel,add_pathlist (rel,
					     get_pathlist (rel),
					     get_pathlist (other_rel)));
d111 1
a111 1
prune_rel_paths (rel_list)
d114 3
a116 3
    LispValue temp = LispNil;
    LispValue temp2 = LispNil;
    LispValue temp3 = LispNil;
d120 5
a124 5
    foreach (temp, rel_list) { 	/* XXX Lisp find_if_not function used  */
	rel = (Rel)CAR(temp);
	foreach (temp2,get_pathlist(rel)) {
	    if (!get_p_ordering(CAR(temp2))) {
		temp3 = CAR(temp2);
d126 5
a130 5
	    }	    
	}
	cheapest = (JoinPath)prune_rel_path (rel,temp3);
	if (IsA(cheapest,JoinPath))
	  set_size (rel,compute_joinrel_size (cheapest));
d136 10
d155 1
a155 1
    if (get_outersortkeys(path) || get_innersortkeys(path))
d164 1
a164 1
    if (outerorder && 
d177 1
a177 1
    if (innerorder &&
d191 8
d204 3
a206 3
    if (p1 == NULL || p2 == NULL) return NULL;
    if (IsA(p1,MergePath) && IsA(p2,MergePath)) {
       if (equal(get_outerjoinpath(p1), get_innerjoinpath(p2)) &&
d210 1
a210 1
    if (IsA(p1,JoinPath) && IsA(p2,JoinPath)) {
d219 8
d232 1
a232 1
    if (IsA(path,MergePath)) {
d238 1
a238 1
    if (IsA(path,HashPath)) {
d244 2
a245 2
    if (IsA(path,JoinPath)) {
        if (!IsA(get_innerjoinpath(path),IndexPath) &&
d254 1
a254 1
    if (IsA(path,IndexPath)) {
d260 46
d321 1
a321 1
prune_rel_path (rel,unorderedpath)
d325 1
a325 1
     Path cheapest = set_cheapest (rel,get_pathlist (rel));
d327 1
a327 1
     if (!(eq (unorderedpath,cheapest)) && !testFlag) {
d329 2
a330 2
	  set_unorderedpath (rel,LispNil);
	  set_pathlist (rel,LispRemove(unorderedpath,get_pathlist (rel)));
d334 1
a334 1
	  set_unorderedpath (rel,unorderedpath);
d338 2
a339 35
     if (testFlag) {
	 LispValue x, y;
	 Path path, path1;
	 List newpathlist = LispNil;
	 List prunelist = LispNil;
	 List newlist;
         foreach (x, get_pathlist(rel)) {
	     path = (Path)CAR(x);
	     if (IsA(path,MergePath)) {
		 if (mergepath_contain_redundant_sorts(path))
		 continue;
	       }
	     newpathlist = nappend1(newpathlist, path);
	  }
	 newlist = LispNil;
	 foreach (x, newpathlist) {
	     path = (Path)CAR(x);
	     if (!path_contain_redundant_indexscans(path,
				(length(get_relids(get_parent(path))) !=
				 length(_query_relation_list_)))) {
		 newlist = nappend1(newlist, path);
	       }
	   }
	 newpathlist = newlist;
	 foreach (x, newpathlist) {
	     path = (Path)CAR(x);
	     foreach (y, CDR(x)) {
		 path1 = (Path)CAR(y);
		 if (equal(path, path1) ||
		     path_contain_rotated_mergepaths(path, path1))
		     prunelist = nappend1(prunelist, path1);
	       }
	   }
	 newpathlist = nset_difference(newpathlist, prunelist);
	 set_pathlist(rel, newpathlist);
a346 1
#ifdef _xprs_
d362 1
a362 1
merge_joinrels (rel_list1,rel_list2)
d367 1
a367 1
    foreach (xrel,rel_list1) {
d369 1
a369 1
        rel_list2 = prune_joinrel (rel,rel_list2);
d371 1
a371 1
    return (append (rel_list1, rel_list2));
d391 1
a391 1
prune_oldrels (old_rels)
d397 2
a398 2
     if (old_rels == LispNil)
	  return (LispNil);
d402 3
a404 3
     if (joininfo_list == LispNil)
	 return (lispCons (rel, prune_oldrels (CDR(old_rels))));
     foreach (xjoininfo, joininfo_list) {
d406 2
a407 2
	 if (!joininfo_inactive(joininfo))
	      return (lispCons (rel, prune_oldrels (CDR(old_rels))));
a410 1
#endif /* _xprs */
@


1.15
log
@some changes that only affect my experiments
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.14 91/05/08 15:10:19 hong Exp $"); */
d149 1
d178 1
@


1.14
log
@added some special code for wei's experiments
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.13 91/04/27 14:17:26 hong Exp $"); */
d145 4
d292 2
a293 1
		 if (path_contain_rotated_mergepaths(path, path1))
@


1.13
log
@added some special code for my experiments, no affect to anyone else
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.12 91/04/25 04:18:21 hong Exp $"); */
d23 1
a53 1

d136 92
d259 36
@


1.12
log
@added a special case for my experiments only
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.11 90/10/15 14:55:06 choi Exp Locker: hong $"); */
d157 1
a157 1
     if (!(eq (unorderedpath,cheapest))) {
d160 1
a160 2
	  if (!testFlag)
	      set_pathlist (rel,LispRemove(unorderedpath,get_pathlist (rel)));
@


1.11
log
@changed remove() to LispRemove(). (posix)
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.10 90/09/25 16:36:21 kemnitz Exp Locker: choi $"); */
d26 1
d160 2
a161 1
	  set_pathlist (rel,LispRemove(unorderedpath,get_pathlist (rel)));
@


1.10
log
@Updating from revision 1.9 to revision 1.10
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.10 90/08/14 11:10:11 cimarron Exp $"); */
d159 1
a159 1
	  set_pathlist (rel,remove(unorderedpath,get_pathlist (rel)));
@


1.9
log
@added in bushy tree stuffs.
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.8 89/09/05 17:17:43 mao C_Demo_1 Locker: hong $"); */
d19 4
a22 3
#include "pg_lisp.h"
#include "relation.h"
#include "relation.a.h"
a24 2


@


1.8
log
@Working version of C-only demo
@
text
@d10 1
a10 1
/* RcsId("$Header: RCS/prune.c,v 1.7 89/08/23 16:03:50 ong Exp Locker: ong $"); */
d21 1
d67 1
a67 1
/*  .. prune-joinrels */
d171 68
@


1.7
log
@planner supports all but rules and mergesort
@
text
@d10 1
a10 1
/* RcsId("$Header: /n/postgres/a/postgres/ong/postgres/src/planner/path/RCS/prune.c,v 1.6 89/08/04 14:27:33 goh Exp $"); */
@


1.6
log
@reorganised header files
@
text
@a0 1

d10 1
a10 1
/* RcsId("$Header: prune.c,v 1.5 89/08/04 13:23:37 goh Locked $"); */
d74 1
a74 1
     LispValue other_rel = LispNil;
d77 14
a90 12

     foreach(other_rel,other_rels) {
	  if(same (get_relids (rel),get_relids (other_rel))) {
	       set_pathlist (rel,add_pathlist (rel,
					       get_pathlist (rel),
					       get_pathlist (other_rel)));
	       t_list = nconc(t_list, LispNil);  /* XXX is this right ? */
	  } 
	  else {
	       temp_node = lispCons(other_rel,LispNil);
	       t_list = nconc(t_list,temp_node);
	  } 
d93 1
a93 1
}  /* function end  */
d116 2
a117 2
    Rel rel;
    Path cheapest;
d122 1
a122 1
	    if (!get_ordering(CAR(temp2))) {
d127 5
a131 2
	cheapest = prune_rel_path (rel,temp3);
	set_size (rel,compute_joinrel_size (cheapest));
d159 1
a159 1
	  set_pathlist (rel,LispDelete(unorderedpath,get_pathlist (rel)));
@


1.5
log
@checkin for retrieve (x.all)
@
text
@d11 1
a11 1
/* RcsId("$Header: prune.c,v 1.4 89/08/01 14:40:22 goh Locked $"); */
d20 1
d22 2
a23 4
#include "pathnode.h"
#include "prune.h"

#define foreach(elt,list)     for(elt=list;elt!=LispNil;elt=CDR(elt))
@


1.4
log
@retrieve (x=1) checkin
@
text
@d11 1
a11 1
/* RcsId("$Header: prune.c,v 1.3 89/07/25 17:35:45 ong Exp $"); */
d111 1
a111 1
LispValue rel_list ;
d113 17
a129 8
     LispValue rel = LispNil;
     foreach (rel, rel_list) {
	  /* XXX - let form, maybe incorrect */
	  /* XXX Lisp find_if_not function used  */
	  Path cheapest = 
	    prune_rel_path (rel,find_if_not (get_ordering(get_pathlist(rel))));
	  set_size (rel,compute_joinrel_size (cheapest));
     }
a150 1
     /* XXX - let form, maybe incorrect */
d152 1
d154 1
d157 3
a159 2
     } 
     else {
d161 1
@


1.3
log
@Phase III
@
text
@d11 1
a11 1
/* RcsId("$Header: prune.c,v 1.2 89/07/20 10:46:29 ong Locked $"); */
d88 1
a88 1
	       temp_node = list (other_rel);
d138 3
a140 2
prune_rel_path (rel,unordered_path)
     LispValue rel,unordered_path ;
d144 3
a146 3
     if (!(eq (unordered_path,cheapest))) {
	  set_unordered_path (rel,LispNil);
	  set_pathlist (rel,LispDelete(unordered_path,get_pathlist (rel)));
d149 1
a149 1
	  set_unordered_path (rel,unordered_path);
@


1.2
log
@Phase II checkin
@
text
@d11 1
a11 1
/* RcsId("$Header: prune.c,v 1.1 89/07/10 15:17:39 ong Locked $"); */
d110 1
a110 1
*prune_rel_paths (rel_list)
@


1.1
log
@Initial revision
@
text
@d11 1
a11 1
/* RcsId("$Header: prune.c,v 1.1 89/04/27 21:04:30 ong Locked $"); */
d20 3
a23 2
#include "pg_lisp.h"

a25 2
extern LispValue prune_joinrel();
extern LispValue prune_rel_path();
d27 1
d117 1
a117 1
	  LispValue cheapest = 
d137 1
a137 1
LispValue
d142 1
a142 1
     LispValue cheapest = set_cheapest (rel,get_pathlist (rel));
d145 1
a145 1
	  set_pathlist (rel,delete (unordered_path,get_pathlist (rel)));
@
