~ubuntu-branches/ubuntu/hardy/postgresql-8.4/hardy-backports

« back to all changes in this revision

Viewing changes to src/backend/optimizer/path/joinrels.c

  • Committer: Package Import Robot
  • Author(s): Ubuntu Archive Auto-Backport
  • Date: 2011-10-27 06:13:09 UTC
  • mfrom: (5.3.14 sid)
  • Revision ID: package-import@ubuntu.com-20111027061309-zc27cjc6hu8yp0z0
Tags: 8.4.9-1~hardy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "optimizer/joininfo.h"
18
18
#include "optimizer/pathnode.h"
19
19
#include "optimizer/paths.h"
 
20
#include "utils/memutils.h"
20
21
 
21
22
 
22
23
static List *make_rels_by_clause_joins(PlannerInfo *root,
947
948
}
948
949
 
949
950
/*
950
 
 * Mark a rel as proven empty.
 
951
 * Mark a relation as proven empty.
 
952
 *
 
953
 * During GEQO planning, this can get invoked more than once on the same
 
954
 * baserel struct, so it's worth checking to see if the rel is already marked
 
955
 * dummy.
 
956
 *
 
957
 * Also, when called during GEQO join planning, we are in a short-lived
 
958
 * memory context.  We must make sure that the dummy path attached to a
 
959
 * baserel survives the GEQO cycle, else the baserel is trashed for future
 
960
 * GEQO cycles.  On the other hand, when we are marking a joinrel during GEQO,
 
961
 * we don't want the dummy path to clutter the main planning context.  Upshot
 
962
 * is that the best solution is to explicitly make the dummy path in the same
 
963
 * context the given RelOptInfo is in.
951
964
 */
952
965
static void
953
966
mark_dummy_rel(RelOptInfo *rel)
954
967
{
 
968
        MemoryContext oldcontext;
 
969
 
 
970
        /* Already marked? */
 
971
        if (is_dummy_rel(rel))
 
972
                return;
 
973
 
 
974
        /* No, so choose correct context to make the dummy path in */
 
975
        oldcontext = MemoryContextSwitchTo(GetMemoryChunkContext(rel));
 
976
 
955
977
        /* Set dummy size estimate */
956
978
        rel->rows = 0;
957
979
 
963
985
 
964
986
        /* Set or update cheapest_total_path */
965
987
        set_cheapest(rel);
 
988
 
 
989
        MemoryContextSwitchTo(oldcontext);
966
990
}
967
991
 
968
992