Re: [HACKERS] subselect and optimizer - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] subselect and optimizer
Date
Msg-id 199804131506.LAA17422@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] subselect and optimizer  ("Boersenspielteam" <boersenspiel@vocalweb.de>)
List pgsql-hackers
>
>
> > Here is the prune.c file from 6.2.1.  Please try it and let me know if
> > it fixes the problem:
>
> Nope, doesn't even compile ...
>
> ---
>
> gcc -I../../../include -I../../../backend -I/usr/include/curses -O2
> -Wall -Wmissing-prototypes -I../..    -c prune.c -o prune.o
> prune.c:39: conflicting types for `prune_joinrels'
> ../../../include/optimizer/paths.h:95: previous declaration of
> `prune_joinrels' prune.c: In function `prune_rel_paths': prune.c:127:
> `WARN' undeclared (first use this function) prune.c:127: (Each
> undeclared identifier is reported only once prune.c:127: for each
> function it appears in.)

OK, please try this patch.  It reverts us to 6.2.1 for this file only.
It may have to be cleaned up a little.  Not sure.  This is against the
current source tree, which is probably the same as 6.3.2 beta.

---------------------------------------------------------------------------


*** /pg/backend/optimizer/path/prune.c    Thu Apr  2 10:18:46 1998
--- /root/prune.c    Thu Apr  2 11:40:32 1998
***************
*** 7,13 ****
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/optimizer/path/prune.c,v 1.13 1998/04/02 07:27:15 vadim Exp $
   *
   *-------------------------------------------------------------------------
   */
--- 7,13 ----
   *
   *
   * IDENTIFICATION
!  *      $Header: /usr/local/cvsroot/pgsql/src/backend/optimizer/path/prune.c,v 1.6 1997/09/08 21:45:08 momjian Exp $
   *
   *-------------------------------------------------------------------------
   */
***************
*** 29,50 ****
  /*
   * prune-joinrels--
   *      Removes any redundant relation entries from a list of rel nodes
!  *      'rel-list'.  Obviosly, the first relation can't be a duplicate.
   *
   * Returns the resulting list.
   *
   */
! void
  prune_joinrels(List *rel_list)
  {
!     List       *i;

!     /*
!      * rel_list can shorten while running as duplicate relations are
!      * deleted
!      */
!     foreach(i, rel_list)
!         lnext(i) = prune_joinrel((Rel *) lfirst(i), lnext(i));
  }

  /*
--- 29,51 ----
  /*
   * prune-joinrels--
   *      Removes any redundant relation entries from a list of rel nodes
!  *      'rel-list'.
   *
   * Returns the resulting list.
   *
   */
! List       *
  prune_joinrels(List *rel_list)
  {
!     List       *temp_list = NIL;

!     if (rel_list != NIL)
!     {
!         temp_list = lcons(lfirst(rel_list),
!                    prune_joinrels(prune_joinrel((Rel *) lfirst(rel_list),
!                                                 lnext(rel_list))));
!     }
!     return (temp_list);
  }

  /*
***************
*** 62,85 ****
  prune_joinrel(Rel *rel, List *other_rels)
  {
      List       *i = NIL;
!     List       *result = NIL;

      foreach(i, other_rels)
      {
!         Rel       *other_rel = (Rel *) lfirst(i);
!
          if (same(rel->relids, other_rel->relids))
          {
              rel->pathlist = add_pathlist(rel,
                                           rel->pathlist,
                                           other_rel->pathlist);
          }
          else
          {
!             result = nconc(result, lcons(other_rel, NIL));
          }
      }
!     return (result);
  }

  /*
--- 63,89 ----
  prune_joinrel(Rel *rel, List *other_rels)
  {
      List       *i = NIL;
!     List       *t_list = NIL;
!     List       *temp_node = NIL;
!     Rel           *other_rel = (Rel *) NULL;

      foreach(i, other_rels)
      {
!         other_rel = (Rel *) lfirst(i);
          if (same(rel->relids, other_rel->relids))
          {
              rel->pathlist = add_pathlist(rel,
                                           rel->pathlist,
                                           other_rel->pathlist);
+             t_list = nconc(t_list, NIL);        /* XXX is this right ? */
          }
          else
          {
!             temp_node = lcons(other_rel, NIL);
!             t_list = nconc(t_list, temp_node);
          }
      }
!     return (t_list);
  }

  /*
***************
*** 120,126 ****
              rel->size = compute_joinrel_size(cheapest);
          }
          else
!             elog(ERROR, "non JoinPath called");
      }
  }

--- 124,130 ----
              rel->size = compute_joinrel_size(cheapest);
          }
          else
!             elog(WARN, "non JoinPath called");
      }
  }

***************
*** 135,141 ****
   * Returns the cheapest path.
   *
   */
! Path *
  prune_rel_path(Rel *rel, Path *unorderedpath)
  {
      Path       *cheapest = set_cheapest(rel, rel->pathlist);
--- 139,145 ----
   * Returns the cheapest path.
   *
   */
! Path       *
  prune_rel_path(Rel *rel, Path *unorderedpath)
  {
      Path       *cheapest = set_cheapest(rel, rel->pathlist);
***************
*** 166,172 ****
   *
   * Returns one pruned rel node list
   */
! List *
  merge_joinrels(List *rel_list1, List *rel_list2)
  {
      List       *xrel = NIL;
--- 170,176 ----
   *
   * Returns one pruned rel node list
   */
! List       *
  merge_joinrels(List *rel_list1, List *rel_list2)
  {
      List       *xrel = NIL;
***************
*** 192,226 ****
   *
   * Returns a new list of rel nodes
   */
! List *
  prune_oldrels(List *old_rels)
  {
      Rel           *rel;
      List       *joininfo_list,
!                *xjoininfo,
!                *i,
!                *temp_list = NIL;

!     foreach(i, old_rels)
!     {
!         rel = (Rel *) lfirst(i);
!         joininfo_list = rel->joininfo;

!         if (joininfo_list == NIL)
!             temp_list = lcons(rel, temp_list);
!         else
!         {
!             foreach(xjoininfo, joininfo_list)
!             {
!                 JInfo       *joininfo = (JInfo *) lfirst(xjoininfo);

!                 if (!joininfo->inactive)
!                 {
!                     temp_list = lcons(rel, temp_list);
!                     break;
!                 }
!             }
!         }
      }
!     return temp_list;
  }
--- 196,222 ----
   *
   * Returns a new list of rel nodes
   */
! List       *
  prune_oldrels(List *old_rels)
  {
      Rel           *rel;
      List       *joininfo_list,
!                *xjoininfo;

!     if (old_rels == NIL)
!         return (NIL);

!     rel = (Rel *) lfirst(old_rels);
!     joininfo_list = rel->joininfo;
!     if (joininfo_list == NIL)
!         return (lcons(rel, prune_oldrels(lnext(old_rels))));

!     foreach(xjoininfo, joininfo_list)
!     {
!         JInfo       *joininfo = (JInfo *) lfirst(xjoininfo);
!
!         if (!joininfo->inactive)
!             return (lcons(rel, prune_oldrels(lnext(old_rels))));
      }
!     return (prune_oldrels(lnext(old_rels)));
  }


--
Bruce Momjian                          |  830 Blythe Avenue
maillist@candle.pha.pa.us              |  Drexel Hill, Pennsylvania 19026
  +  If your life is a hard drive,     |  (610) 353-9879(w)
  +  Christ can be your backup.        |  (610) 853-3000(h)

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Broken makefile for docs
Next
From: The Hermit Hacker
Date:
Subject: still getting FATAL errors on btree's...