1996-07-09 06:22:35 +00:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* createplan.c
|
1999-08-22 20:15:04 +00:00
|
|
|
* Routines to create the desired plan for processing a query.
|
|
|
|
* Planning is complete, we just need to convert the selected
|
|
|
|
* Path into a Plan.
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
2000-01-26 05:58:53 +00:00
|
|
|
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
|
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
2000-06-18 22:44:35 +00:00
|
|
|
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.93 2000/06/18 22:44:07 tgl Exp $
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
1996-10-31 10:59:42 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "postgres.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
|
2000-06-15 03:33:12 +00:00
|
|
|
#include "catalog/pg_index.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
#include "nodes/makefuncs.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "nodes/nodeFuncs.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
#include "optimizer/clauses.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "optimizer/cost.h"
|
2000-01-09 00:26:47 +00:00
|
|
|
#include "optimizer/paths.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
#include "optimizer/planmain.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "optimizer/restrictinfo.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
#include "optimizer/tlist.h"
|
2000-05-23 16:56:37 +00:00
|
|
|
#include "parser/parse_expr.h"
|
1999-07-16 05:00:38 +00:00
|
|
|
#include "utils/lsyscache.h"
|
|
|
|
#include "utils/syscache.h"
|
1996-07-09 06:22:35 +00:00
|
|
|
|
|
|
|
|
1997-09-08 21:56:23 +00:00
|
|
|
static List *switch_outer(List *clauses);
|
2000-01-09 00:26:47 +00:00
|
|
|
static Scan *create_scan_node(Query *root, Path *best_path, List *tlist);
|
|
|
|
static Join *create_join_node(Query *root, JoinPath *best_path, List *tlist);
|
1998-09-01 04:40:42 +00:00
|
|
|
static SeqScan *create_seqscan_node(Path *best_path, List *tlist,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *scan_clauses);
|
2000-01-09 00:26:47 +00:00
|
|
|
static IndexScan *create_indexscan_node(Query *root, IndexPath *best_path,
|
2000-04-12 17:17:23 +00:00
|
|
|
List *tlist, List *scan_clauses);
|
1999-11-23 20:07:06 +00:00
|
|
|
static TidScan *create_tidscan_node(TidPath *best_path, List *tlist,
|
2000-04-12 17:17:23 +00:00
|
|
|
List *scan_clauses);
|
1999-05-25 22:43:53 +00:00
|
|
|
static NestLoop *create_nestloop_node(NestPath *best_path, List *tlist,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *clauses, Plan *outer_node, List *outer_tlist,
|
|
|
|
Plan *inner_node, List *inner_tlist);
|
1998-09-01 04:40:42 +00:00
|
|
|
static MergeJoin *create_mergejoin_node(MergePath *best_path, List *tlist,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *clauses, Plan *outer_node, List *outer_tlist,
|
|
|
|
Plan *inner_node, List *inner_tlist);
|
1998-09-01 04:40:42 +00:00
|
|
|
static HashJoin *create_hashjoin_node(HashPath *best_path, List *tlist,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *clauses, Plan *outer_node, List *outer_tlist,
|
|
|
|
Plan *inner_node, List *inner_tlist);
|
1999-08-09 01:01:42 +00:00
|
|
|
static List *fix_indxqual_references(List *indexquals, IndexPath *index_path);
|
2000-01-09 00:26:47 +00:00
|
|
|
static List *fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
|
2000-04-12 17:17:23 +00:00
|
|
|
Form_pg_index index);
|
2000-01-09 00:26:47 +00:00
|
|
|
static Node *fix_indxqual_operand(Node *node, int baserelid,
|
2000-04-12 17:17:23 +00:00
|
|
|
Form_pg_index index,
|
|
|
|
Oid *opclass);
|
1998-09-01 04:40:42 +00:00
|
|
|
static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid,
|
2000-04-12 17:17:23 +00:00
|
|
|
List *indxid, List *indxqual,
|
|
|
|
List *indxqualorig,
|
|
|
|
ScanDirection indexscandir);
|
1999-11-23 20:07:06 +00:00
|
|
|
static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid,
|
2000-04-12 17:17:23 +00:00
|
|
|
List *tideval);
|
1998-09-01 04:40:42 +00:00
|
|
|
static NestLoop *make_nestloop(List *qptlist, List *qpqual, Plan *lefttree,
|
1997-09-08 21:56:23 +00:00
|
|
|
Plan *righttree);
|
1998-09-01 04:40:42 +00:00
|
|
|
static HashJoin *make_hashjoin(List *tlist, List *qpqual,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *hashclauses, Plan *lefttree, Plan *righttree);
|
|
|
|
static Hash *make_hash(List *tlist, Var *hashkey, Plan *lefttree);
|
1998-09-01 04:40:42 +00:00
|
|
|
static MergeJoin *make_mergejoin(List *tlist, List *qpqual,
|
1999-03-01 00:10:44 +00:00
|
|
|
List *mergeclauses, Plan *righttree, Plan *lefttree);
|
2000-01-09 00:26:47 +00:00
|
|
|
static void copy_path_costsize(Plan *dest, Path *src);
|
|
|
|
static void copy_plan_costsize(Plan *dest, Plan *src);
|
2000-06-08 22:38:00 +00:00
|
|
|
static SeqScan *make_seqscan(List *qptlist, List *qpqual, Index scanrelid);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
1999-02-13 23:22:53 +00:00
|
|
|
* create_plan
|
1997-09-07 05:04:48 +00:00
|
|
|
* Creates the access plan for a query by tracing backwards through the
|
1999-02-13 23:22:53 +00:00
|
|
|
* desired chain of pathnodes, starting at the node 'best_path'. For
|
1997-09-07 05:04:48 +00:00
|
|
|
* every pathnode found:
|
|
|
|
* (1) Create a corresponding plan node containing appropriate id,
|
|
|
|
* target list, and qualification information.
|
1999-08-22 20:15:04 +00:00
|
|
|
* (2) Modify qual clauses of join nodes so that subplan attributes are
|
|
|
|
* referenced using relative values.
|
|
|
|
* (3) Target lists are not modified, but will be in setrefs.c.
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* best_path is the best access path
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1999-08-22 20:15:04 +00:00
|
|
|
* Returns the access plan.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1998-02-26 04:46:47 +00:00
|
|
|
Plan *
|
2000-01-09 00:26:47 +00:00
|
|
|
create_plan(Query *root, Path *best_path)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
2000-01-09 00:26:47 +00:00
|
|
|
List *tlist = best_path->parent->targetlist;
|
1997-09-08 02:41:22 +00:00
|
|
|
Plan *plan_node = (Plan *) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
switch (best_path->pathtype)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
case T_IndexScan:
|
|
|
|
case T_SeqScan:
|
1999-11-23 20:07:06 +00:00
|
|
|
case T_TidScan:
|
2000-01-09 00:26:47 +00:00
|
|
|
plan_node = (Plan *) create_scan_node(root, best_path, tlist);
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
|
|
|
case T_HashJoin:
|
|
|
|
case T_MergeJoin:
|
|
|
|
case T_NestLoop:
|
2000-01-09 00:26:47 +00:00
|
|
|
plan_node = (Plan *) create_join_node(root,
|
|
|
|
(JoinPath *) best_path,
|
|
|
|
tlist);
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
2000-01-09 00:26:47 +00:00
|
|
|
elog(ERROR, "create_plan: unknown pathtype %d",
|
|
|
|
best_path->pathtype);
|
1997-09-08 02:41:22 +00:00
|
|
|
break;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
|
1999-05-25 16:15:34 +00:00
|
|
|
#ifdef NOT_USED /* fix xfunc */
|
1997-09-07 05:04:48 +00:00
|
|
|
/* sort clauses by cost/(1-selectivity) -- JMH 2/26/92 */
|
|
|
|
if (XfuncMode != XFUNC_OFF)
|
|
|
|
{
|
|
|
|
set_qpqual((Plan) plan_node,
|
|
|
|
lisp_qsort(get_qpqual((Plan) plan_node),
|
|
|
|
xfunc_clause_compare));
|
|
|
|
if (XfuncMode != XFUNC_NOR)
|
|
|
|
/* sort the disjuncts within each clause by cost -- JMH 3/4/92 */
|
|
|
|
xfunc_disjunct_sort(plan_node->qpqual);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return plan_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
1999-02-13 23:22:53 +00:00
|
|
|
* create_scan_node
|
|
|
|
* Create a scan path for the parent relation of 'best_path'.
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
1999-02-13 23:22:53 +00:00
|
|
|
* tlist is the targetlist for the base relation scanned by 'best_path'
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
|
|
|
* Returns the scan node.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1997-09-08 02:41:22 +00:00
|
|
|
static Scan *
|
2000-01-09 00:26:47 +00:00
|
|
|
create_scan_node(Query *root, Path *best_path, List *tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Scan *node = NULL;
|
|
|
|
List *scan_clauses;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
1999-07-27 03:51:11 +00:00
|
|
|
* Extract the relevant restriction clauses from the parent relation;
|
|
|
|
* the executor must apply all these restrictions during the scan.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-02-07 04:41:04 +00:00
|
|
|
scan_clauses = get_actual_clauses(best_path->parent->baserestrictinfo);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
switch (best_path->pathtype)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
case T_SeqScan:
|
|
|
|
node = (Scan *) create_seqscan_node(best_path, tlist, scan_clauses);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_IndexScan:
|
2000-01-09 00:26:47 +00:00
|
|
|
node = (Scan *) create_indexscan_node(root,
|
|
|
|
(IndexPath *) best_path,
|
1997-09-08 02:41:22 +00:00
|
|
|
tlist,
|
|
|
|
scan_clauses);
|
|
|
|
break;
|
|
|
|
|
1999-11-23 20:07:06 +00:00
|
|
|
case T_TidScan:
|
|
|
|
node = (Scan *) create_tidscan_node((TidPath *) best_path,
|
2000-04-12 17:17:23 +00:00
|
|
|
tlist,
|
|
|
|
scan_clauses);
|
1999-11-23 20:07:06 +00:00
|
|
|
break;
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
default:
|
2000-01-15 02:59:43 +00:00
|
|
|
elog(ERROR, "create_scan_node: unknown node type: %d",
|
1997-09-08 02:41:22 +00:00
|
|
|
best_path->pathtype);
|
|
|
|
break;
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
1999-05-25 16:15:34 +00:00
|
|
|
* create_join_node
|
1999-02-13 23:22:53 +00:00
|
|
|
* Create a join path for 'best_path' and(recursively) paths for its
|
1997-09-07 05:04:48 +00:00
|
|
|
* inner and outer paths.
|
|
|
|
*
|
|
|
|
* 'tlist' is the targetlist for the join relation corresponding to
|
1999-02-13 23:22:53 +00:00
|
|
|
* 'best_path'
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
|
|
|
* Returns the join node.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1997-09-08 02:41:22 +00:00
|
|
|
static Join *
|
2000-01-09 00:26:47 +00:00
|
|
|
create_join_node(Query *root, JoinPath *best_path, List *tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Plan *outer_node;
|
|
|
|
List *outer_tlist;
|
|
|
|
Plan *inner_node;
|
|
|
|
List *inner_tlist;
|
|
|
|
List *clauses;
|
|
|
|
Join *retval = NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
outer_node = create_plan(root, best_path->outerjoinpath);
|
1997-09-07 05:04:48 +00:00
|
|
|
outer_tlist = outer_node->targetlist;
|
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
inner_node = create_plan(root, best_path->innerjoinpath);
|
1997-09-07 05:04:48 +00:00
|
|
|
inner_tlist = inner_node->targetlist;
|
|
|
|
|
2000-02-07 04:41:04 +00:00
|
|
|
clauses = get_actual_clauses(best_path->joinrestrictinfo);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
switch (best_path->path.pathtype)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
case T_MergeJoin:
|
|
|
|
retval = (Join *) create_mergejoin_node((MergePath *) best_path,
|
|
|
|
tlist,
|
|
|
|
clauses,
|
|
|
|
outer_node,
|
|
|
|
outer_tlist,
|
|
|
|
inner_node,
|
|
|
|
inner_tlist);
|
|
|
|
break;
|
|
|
|
case T_HashJoin:
|
|
|
|
retval = (Join *) create_hashjoin_node((HashPath *) best_path,
|
|
|
|
tlist,
|
|
|
|
clauses,
|
|
|
|
outer_node,
|
|
|
|
outer_tlist,
|
|
|
|
inner_node,
|
|
|
|
inner_tlist);
|
|
|
|
break;
|
|
|
|
case T_NestLoop:
|
1999-02-12 06:43:53 +00:00
|
|
|
retval = (Join *) create_nestloop_node((NestPath *) best_path,
|
1997-09-08 02:41:22 +00:00
|
|
|
tlist,
|
|
|
|
clauses,
|
|
|
|
outer_node,
|
|
|
|
outer_tlist,
|
|
|
|
inner_node,
|
|
|
|
inner_tlist);
|
|
|
|
break;
|
|
|
|
default:
|
2000-01-15 02:59:43 +00:00
|
|
|
elog(ERROR, "create_join_node: unknown node type: %d",
|
1997-09-08 02:41:22 +00:00
|
|
|
best_path->path.pathtype);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1999-07-27 03:51:11 +00:00
|
|
|
#ifdef NOT_USED
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
|
|
|
* * Expensive function pullups may have pulled local predicates *
|
1999-05-25 16:15:34 +00:00
|
|
|
* into this path node. Put them in the qpqual of the plan node. *
|
1997-09-08 02:41:22 +00:00
|
|
|
* JMH, 6/15/92
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
1999-02-03 20:15:53 +00:00
|
|
|
if (get_loc_restrictinfo(best_path) != NIL)
|
1997-09-07 05:04:48 +00:00
|
|
|
set_qpqual((Plan) retval,
|
|
|
|
nconc(get_qpqual((Plan) retval),
|
2000-04-12 17:17:23 +00:00
|
|
|
get_actual_clauses(get_loc_restrictinfo(best_path))));
|
1996-07-09 06:22:35 +00:00
|
|
|
#endif
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return retval;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* BASE-RELATION SCAN METHODS
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
1999-02-13 23:22:53 +00:00
|
|
|
* create_seqscan_node
|
|
|
|
* Returns a seqscan node for the base relation scanned by 'best_path'
|
|
|
|
* with restriction clauses 'scan_clauses' and targetlist 'tlist'.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
static SeqScan *
|
1997-09-08 21:56:23 +00:00
|
|
|
create_seqscan_node(Path *best_path, List *tlist, List *scan_clauses)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
2000-01-09 00:26:47 +00:00
|
|
|
SeqScan *scan_node;
|
|
|
|
Index scan_relid;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-07-27 03:51:11 +00:00
|
|
|
/* there should be exactly one base rel involved... */
|
2000-01-09 00:26:47 +00:00
|
|
|
Assert(length(best_path->parent->relids) == 1);
|
|
|
|
|
|
|
|
scan_relid = (Index) lfirsti(best_path->parent->relids);
|
1999-07-27 03:51:11 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
scan_node = make_seqscan(tlist,
|
|
|
|
scan_clauses,
|
1999-08-22 20:15:04 +00:00
|
|
|
scan_relid);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_path_costsize(&scan_node->plan, best_path);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return scan_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
1999-02-13 23:22:53 +00:00
|
|
|
* create_indexscan_node
|
|
|
|
* Returns a indexscan node for the base relation scanned by 'best_path'
|
|
|
|
* with restriction clauses 'scan_clauses' and targetlist 'tlist'.
|
1999-07-24 23:21:14 +00:00
|
|
|
*
|
1999-07-30 00:44:23 +00:00
|
|
|
* The indexqual of the path contains a sublist of implicitly-ANDed qual
|
|
|
|
* conditions for each scan of the index(es); if there is more than one
|
|
|
|
* scan then the retrieved tuple sets are ORed together. The indexqual
|
|
|
|
* and indexid lists must have the same length, ie, the number of scans
|
|
|
|
* that will occur. Note it is possible for a qual condition sublist
|
|
|
|
* to be empty --- then no index restrictions will be applied during that
|
|
|
|
* scan.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
static IndexScan *
|
2000-01-09 00:26:47 +00:00
|
|
|
create_indexscan_node(Query *root,
|
|
|
|
IndexPath *best_path,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *tlist,
|
|
|
|
List *scan_clauses)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1999-07-24 23:21:14 +00:00
|
|
|
List *indxqual = best_path->indexqual;
|
2000-01-23 02:07:00 +00:00
|
|
|
Index baserelid;
|
1999-07-24 23:21:14 +00:00
|
|
|
List *qpqual;
|
|
|
|
List *fixed_indxqual;
|
1997-09-08 02:41:22 +00:00
|
|
|
List *ixid;
|
1999-07-24 23:21:14 +00:00
|
|
|
IndexScan *scan_node;
|
|
|
|
bool lossy = false;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-07-27 03:51:11 +00:00
|
|
|
/* there should be exactly one base rel involved... */
|
|
|
|
Assert(length(best_path->path.parent->relids) == 1);
|
2000-01-23 02:07:00 +00:00
|
|
|
baserelid = lfirsti(best_path->path.parent->relids);
|
1999-07-27 03:51:11 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
/* check to see if any of the indices are lossy */
|
1997-09-07 05:04:48 +00:00
|
|
|
foreach(ixid, best_path->indexid)
|
|
|
|
{
|
1999-07-24 23:21:14 +00:00
|
|
|
HeapTuple indexTuple;
|
|
|
|
Form_pg_index index;
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
indexTuple = SearchSysCacheTuple(INDEXRELID,
|
|
|
|
ObjectIdGetDatum(lfirsti(ixid)),
|
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(indexTuple))
|
1999-05-10 00:46:32 +00:00
|
|
|
elog(ERROR, "create_plan: index %u not found", lfirsti(ixid));
|
1998-09-01 03:29:17 +00:00
|
|
|
index = (Form_pg_index) GETSTRUCT(indexTuple);
|
1997-09-07 05:04:48 +00:00
|
|
|
if (index->indislossy)
|
1999-07-24 23:21:14 +00:00
|
|
|
{
|
|
|
|
lossy = true;
|
|
|
|
break;
|
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1999-07-24 23:21:14 +00:00
|
|
|
* The qpqual list must contain all restrictions not automatically
|
1997-09-07 05:04:48 +00:00
|
|
|
* handled by the index. Note that for non-lossy indices, the
|
1999-08-12 04:32:54 +00:00
|
|
|
* predicates in the indxqual are checked fully by the index, while
|
|
|
|
* for lossy indices the indxqual predicates need to be double-checked
|
1997-09-07 05:04:48 +00:00
|
|
|
* after the index fetches the best-guess tuples.
|
1999-07-24 23:21:14 +00:00
|
|
|
*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Since the indexquals were generated from the restriction clauses given
|
|
|
|
* by scan_clauses, there will normally be some duplications between
|
|
|
|
* the lists. We get rid of the duplicates, then add back if lossy.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
1999-07-24 23:21:14 +00:00
|
|
|
if (length(indxqual) > 1)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1999-07-24 23:21:14 +00:00
|
|
|
/*
|
|
|
|
* Build an expression representation of the indexqual, expanding
|
2000-04-12 17:17:23 +00:00
|
|
|
* the implicit OR and AND semantics of the first- and
|
|
|
|
* second-level lists.
|
1999-07-24 23:21:14 +00:00
|
|
|
*/
|
|
|
|
List *orclauses = NIL;
|
|
|
|
List *orclause;
|
|
|
|
Expr *indxqual_expr;
|
|
|
|
|
|
|
|
foreach(orclause, indxqual)
|
|
|
|
orclauses = lappend(orclauses,
|
2000-01-09 00:26:47 +00:00
|
|
|
make_ands_explicit(lfirst(orclause)));
|
1999-07-24 23:21:14 +00:00
|
|
|
indxqual_expr = make_orclause(orclauses);
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
qpqual = set_difference(scan_clauses,
|
1999-07-24 23:21:14 +00:00
|
|
|
lcons(indxqual_expr, NIL));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (lossy)
|
2000-01-09 00:26:47 +00:00
|
|
|
qpqual = lappend(qpqual, copyObject(indxqual_expr));
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1999-07-24 23:21:14 +00:00
|
|
|
else if (indxqual != NIL)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Here, we can simply treat the first sublist as an independent
|
|
|
|
* set of qual expressions, since there is no top-level OR
|
|
|
|
* behavior.
|
1999-07-24 23:21:14 +00:00
|
|
|
*/
|
2000-01-09 00:26:47 +00:00
|
|
|
List *indxqual_list = lfirst(indxqual);
|
|
|
|
|
|
|
|
qpqual = set_difference(scan_clauses, indxqual_list);
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
if (lossy)
|
2000-01-09 00:26:47 +00:00
|
|
|
qpqual = nconc(qpqual, (List *) copyObject(indxqual_list));
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1999-07-24 23:21:14 +00:00
|
|
|
else
|
2000-01-09 00:26:47 +00:00
|
|
|
qpqual = scan_clauses;
|
1999-07-24 23:21:14 +00:00
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* The executor needs a copy with the indexkey on the left of each
|
|
|
|
* clause and with index attr numbers substituted for table ones.
|
1999-08-12 04:32:54 +00:00
|
|
|
*/
|
|
|
|
fixed_indxqual = fix_indxqual_references(indxqual, best_path);
|
|
|
|
|
1999-02-03 21:18:02 +00:00
|
|
|
scan_node = make_indexscan(tlist,
|
1999-05-25 16:15:34 +00:00
|
|
|
qpqual,
|
2000-01-23 02:07:00 +00:00
|
|
|
baserelid,
|
1999-05-25 16:15:34 +00:00
|
|
|
best_path->indexid,
|
|
|
|
fixed_indxqual,
|
2000-02-15 20:49:31 +00:00
|
|
|
indxqual,
|
|
|
|
best_path->indexscandir);
|
1999-04-30 04:04:27 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_path_costsize(&scan_node->scan.plan, &best_path->path);
|
2000-03-22 22:08:35 +00:00
|
|
|
/* use the indexscan-specific rows estimate, not the parent rel's */
|
|
|
|
scan_node->scan.plan.plan_rows = best_path->rows;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return scan_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1999-11-23 20:07:06 +00:00
|
|
|
static TidScan *
|
|
|
|
make_tidscan(List *qptlist,
|
2000-02-15 20:49:31 +00:00
|
|
|
List *qpqual,
|
2000-04-12 17:17:23 +00:00
|
|
|
Index scanrelid,
|
2000-02-15 20:49:31 +00:00
|
|
|
List *tideval)
|
1999-11-23 20:07:06 +00:00
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
TidScan *node = makeNode(TidScan);
|
|
|
|
Plan *plan = &node->scan.plan;
|
1999-11-23 20:07:06 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/* cost should be inserted by caller */
|
1999-11-23 20:07:06 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = qptlist;
|
|
|
|
plan->qual = qpqual;
|
|
|
|
plan->lefttree = NULL;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
node->scan.scanrelid = scanrelid;
|
2000-04-12 17:17:23 +00:00
|
|
|
node->tideval = copyObject(tideval); /* XXX do we really need a
|
|
|
|
* copy? */
|
1999-11-23 20:07:06 +00:00
|
|
|
node->needRescan = false;
|
|
|
|
node->scan.scanstate = (CommonScanState *) NULL;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* create_tidscan_node
|
|
|
|
* Returns a tidscan node for the base relation scanned by 'best_path'
|
|
|
|
* with restriction clauses 'scan_clauses' and targetlist 'tlist'.
|
|
|
|
*/
|
|
|
|
static TidScan *
|
|
|
|
create_tidscan_node(TidPath *best_path, List *tlist, List *scan_clauses)
|
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
TidScan *scan_node;
|
|
|
|
Index scan_relid;
|
2000-01-09 00:26:47 +00:00
|
|
|
|
|
|
|
/* there should be exactly one base rel involved... */
|
|
|
|
Assert(length(best_path->path.parent->relids) == 1);
|
|
|
|
|
|
|
|
scan_relid = (Index) lfirsti(best_path->path.parent->relids);
|
|
|
|
|
1999-11-23 20:07:06 +00:00
|
|
|
scan_node = make_tidscan(tlist,
|
2000-01-09 00:26:47 +00:00
|
|
|
scan_clauses,
|
|
|
|
scan_relid,
|
|
|
|
best_path->tideval);
|
1999-11-23 20:07:06 +00:00
|
|
|
|
|
|
|
if (best_path->unjoined_relids)
|
2000-04-12 17:17:23 +00:00
|
|
|
scan_node->needRescan = true;
|
2000-01-09 00:26:47 +00:00
|
|
|
|
|
|
|
copy_path_costsize(&scan_node->scan.plan, &best_path->path);
|
1999-11-23 20:07:06 +00:00
|
|
|
|
|
|
|
return scan_node;
|
|
|
|
}
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* JOIN METHODS
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
1999-08-22 20:15:04 +00:00
|
|
|
* A general note about join_references() processing in these routines:
|
|
|
|
* once we have changed a Var node to refer to a subplan output rather than
|
|
|
|
* the original relation, it is no longer equal() to an unmodified Var node
|
|
|
|
* for the same var. So, we cannot easily compare reference-adjusted qual
|
2000-04-12 17:17:23 +00:00
|
|
|
* clauses to clauses that have not been adjusted. Fortunately, that
|
1999-08-22 20:15:04 +00:00
|
|
|
* doesn't seem to be necessary; all the decisions are made before we do
|
|
|
|
* the reference adjustments.
|
|
|
|
*
|
|
|
|
* A cleaner solution would be to not call join_references() here at all,
|
|
|
|
* but leave it for setrefs.c to do at the end of plan tree construction.
|
|
|
|
* But that would make switch_outer() much more complicated, and some care
|
|
|
|
* would be needed to get setrefs.c to do the right thing with nestloop
|
|
|
|
* inner indexscan quals. So, we do subplan reference adjustment here for
|
|
|
|
* quals of join nodes (and *only* for quals of join nodes).
|
|
|
|
*
|
1996-07-09 06:22:35 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
static NestLoop *
|
1999-05-25 22:43:53 +00:00
|
|
|
create_nestloop_node(NestPath *best_path,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *tlist,
|
|
|
|
List *clauses,
|
|
|
|
Plan *outer_node,
|
|
|
|
List *outer_tlist,
|
|
|
|
Plan *inner_node,
|
|
|
|
List *inner_tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1999-08-10 02:58:56 +00:00
|
|
|
NestLoop *join_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
if (IsA(inner_node, IndexScan))
|
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
|
|
|
* An index is being used to reduce the number of tuples scanned
|
1999-08-10 02:58:56 +00:00
|
|
|
* in the inner relation. If there are join clauses being used
|
|
|
|
* with the index, we must update their outer-rel var nodes to
|
1999-08-22 20:15:04 +00:00
|
|
|
* refer to the outer side of the join.
|
1997-09-07 05:04:48 +00:00
|
|
|
*
|
1999-08-10 02:58:56 +00:00
|
|
|
* We can also remove those join clauses from the list of clauses
|
|
|
|
* that have to be checked as qpquals at the join node, but only
|
|
|
|
* if there's just one indexscan in the inner path (otherwise,
|
|
|
|
* several different sets of clauses are being ORed together).
|
|
|
|
*
|
|
|
|
* Note: if the index is lossy, the same clauses may also be getting
|
|
|
|
* checked as qpquals in the indexscan. We can still remove them
|
|
|
|
* from the nestloop's qpquals, but we gotta update the outer-rel
|
1999-08-22 20:15:04 +00:00
|
|
|
* vars in the indexscan's qpquals too.
|
|
|
|
*
|
|
|
|
* Note: we can safely do set_difference() against my clauses and
|
|
|
|
* join_references() because the innerscan is a primitive plan,
|
|
|
|
* and therefore has not itself done join_references renumbering
|
|
|
|
* of the vars in its quals.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
1999-08-10 02:58:56 +00:00
|
|
|
IndexScan *innerscan = (IndexScan *) inner_node;
|
|
|
|
List *indxqualorig = innerscan->indxqualorig;
|
|
|
|
|
|
|
|
/* No work needed if indxqual refers only to its own relation... */
|
|
|
|
if (NumRelids((Node *) indxqualorig) > 1)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
1999-08-22 20:15:04 +00:00
|
|
|
Index innerrel = innerscan->scan.scanrelid;
|
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* Remove redundant tests from my clauses, if possible. Note
|
|
|
|
* we must compare against indxqualorig not the "fixed"
|
|
|
|
* indxqual (which has index attnos instead of relation
|
|
|
|
* attnos, and may have been commuted as well).
|
1999-08-10 02:58:56 +00:00
|
|
|
*/
|
2000-04-12 17:17:23 +00:00
|
|
|
if (length(indxqualorig) == 1) /* single indexscan? */
|
1999-08-10 02:58:56 +00:00
|
|
|
clauses = set_difference(clauses, lfirst(indxqualorig));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
/* only refs to outer vars get changed in the inner indexqual */
|
1999-08-10 02:58:56 +00:00
|
|
|
innerscan->indxqualorig = join_references(indxqualorig,
|
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
NIL,
|
|
|
|
innerrel);
|
1999-08-10 02:58:56 +00:00
|
|
|
innerscan->indxqual = join_references(innerscan->indxqual,
|
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
NIL,
|
|
|
|
innerrel);
|
1999-08-12 04:32:54 +00:00
|
|
|
/* fix the inner qpqual too, if it has join clauses */
|
1999-08-10 02:58:56 +00:00
|
|
|
if (NumRelids((Node *) inner_node->qual) > 1)
|
|
|
|
inner_node->qual = join_references(inner_node->qual,
|
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
NIL,
|
|
|
|
innerrel);
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
1997-03-18 18:41:37 +00:00
|
|
|
}
|
1999-11-23 20:07:06 +00:00
|
|
|
else if (IsA(inner_node, TidScan))
|
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
TidScan *innerscan = (TidScan *) inner_node;
|
|
|
|
|
2000-06-18 22:44:35 +00:00
|
|
|
innerscan->tideval = join_references(innerscan->tideval,
|
|
|
|
outer_tlist,
|
|
|
|
inner_tlist,
|
|
|
|
innerscan->scan.scanrelid);
|
2000-04-12 17:17:23 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
else if (IsA_Join(inner_node))
|
1997-03-18 18:41:37 +00:00
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1999-08-22 20:15:04 +00:00
|
|
|
/*
|
|
|
|
* Materialize the inner join for speed reasons.
|
|
|
|
*
|
|
|
|
* XXX It is probably *not* always fastest to materialize an inner
|
2000-04-12 17:17:23 +00:00
|
|
|
* join --- how can we estimate whether this is a good thing to
|
|
|
|
* do?
|
1999-08-22 20:15:04 +00:00
|
|
|
*/
|
2000-06-18 22:44:35 +00:00
|
|
|
inner_node = (Plan *) make_material(inner_tlist,
|
|
|
|
inner_node);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
join_node = make_nestloop(tlist,
|
|
|
|
join_references(clauses,
|
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
inner_tlist,
|
|
|
|
(Index) 0),
|
1997-09-07 05:04:48 +00:00
|
|
|
outer_node,
|
|
|
|
inner_node);
|
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_path_costsize(&join_node->join, &best_path->path);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return join_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static MergeJoin *
|
1997-09-08 21:56:23 +00:00
|
|
|
create_mergejoin_node(MergePath *best_path,
|
|
|
|
List *tlist,
|
|
|
|
List *clauses,
|
|
|
|
Plan *outer_node,
|
|
|
|
List *outer_tlist,
|
|
|
|
Plan *inner_node,
|
|
|
|
List *inner_tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List *qpqual,
|
|
|
|
*mergeclauses;
|
|
|
|
MergeJoin *join_node;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-18 23:47:31 +00:00
|
|
|
mergeclauses = get_actual_clauses(best_path->path_mergeclauses);
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Remove the mergeclauses from the list of join qual clauses, leaving
|
|
|
|
* the list of quals that must be checked as qpquals. Set those
|
|
|
|
* clauses to contain INNER/OUTER var references.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-02-18 23:47:31 +00:00
|
|
|
qpqual = join_references(set_difference(clauses, mergeclauses),
|
1997-09-07 05:04:48 +00:00
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
inner_tlist,
|
|
|
|
(Index) 0);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now set the references in the mergeclauses and rearrange them so
|
|
|
|
* that the outer variable is always on the left.
|
|
|
|
*/
|
2000-02-18 23:47:31 +00:00
|
|
|
mergeclauses = switch_outer(join_references(mergeclauses,
|
1997-09-07 05:04:48 +00:00
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
inner_tlist,
|
|
|
|
(Index) 0));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
1999-08-16 02:17:58 +00:00
|
|
|
* Create explicit sort nodes for the outer and inner join paths if
|
1997-09-07 05:04:48 +00:00
|
|
|
* necessary. The sort cost was already accounted for in the path.
|
|
|
|
*/
|
|
|
|
if (best_path->outersortkeys)
|
2000-06-18 22:44:35 +00:00
|
|
|
outer_node = (Plan *)
|
|
|
|
make_sort_from_pathkeys(outer_tlist,
|
|
|
|
outer_node,
|
|
|
|
best_path->outersortkeys);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
if (best_path->innersortkeys)
|
2000-06-18 22:44:35 +00:00
|
|
|
inner_node = (Plan *)
|
|
|
|
make_sort_from_pathkeys(inner_tlist,
|
|
|
|
inner_node,
|
|
|
|
best_path->innersortkeys);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-08-04 16:44:31 +00:00
|
|
|
join_node = make_mergejoin(tlist,
|
1997-09-07 05:04:48 +00:00
|
|
|
qpqual,
|
|
|
|
mergeclauses,
|
|
|
|
inner_node,
|
|
|
|
outer_node);
|
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_path_costsize(&join_node->join, &best_path->jpath.path);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return join_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HashJoin *
|
1997-09-08 21:56:23 +00:00
|
|
|
create_hashjoin_node(HashPath *best_path,
|
|
|
|
List *tlist,
|
|
|
|
List *clauses,
|
|
|
|
Plan *outer_node,
|
|
|
|
List *outer_tlist,
|
|
|
|
Plan *inner_node,
|
|
|
|
List *inner_tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List *qpqual;
|
|
|
|
List *hashclauses;
|
|
|
|
HashJoin *join_node;
|
|
|
|
Hash *hash_node;
|
|
|
|
Var *innerhashkey;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
1999-08-10 02:58:56 +00:00
|
|
|
* NOTE: there will always be exactly one hashclause in the list
|
2000-04-12 17:17:23 +00:00
|
|
|
* best_path->path_hashclauses (cf. hash_inner_and_outer()). We
|
|
|
|
* represent it as a list anyway, for convenience with routines that
|
|
|
|
* want to work on lists of clauses.
|
1999-08-10 02:58:56 +00:00
|
|
|
*/
|
2000-02-18 23:47:31 +00:00
|
|
|
hashclauses = get_actual_clauses(best_path->path_hashclauses);
|
1999-08-10 02:58:56 +00:00
|
|
|
|
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Remove the hashclauses from the list of join qual clauses, leaving
|
|
|
|
* the list of quals that must be checked as qpquals. Set those
|
|
|
|
* clauses to contain INNER/OUTER var references.
|
1997-09-07 05:04:48 +00:00
|
|
|
*/
|
2000-02-18 23:47:31 +00:00
|
|
|
qpqual = join_references(set_difference(clauses, hashclauses),
|
1999-05-25 16:15:34 +00:00
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
inner_tlist,
|
|
|
|
(Index) 0);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Now set the references in the hashclauses and rearrange them so
|
|
|
|
* that the outer variable is always on the left.
|
|
|
|
*/
|
2000-02-18 23:47:31 +00:00
|
|
|
hashclauses = switch_outer(join_references(hashclauses,
|
1999-05-25 16:15:34 +00:00
|
|
|
outer_tlist,
|
1999-08-22 20:15:04 +00:00
|
|
|
inner_tlist,
|
|
|
|
(Index) 0));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-10 02:58:56 +00:00
|
|
|
/* Now the righthand op of the sole hashclause is the inner hash key. */
|
1997-09-07 05:04:48 +00:00
|
|
|
innerhashkey = get_rightop(lfirst(hashclauses));
|
|
|
|
|
1999-08-10 02:58:56 +00:00
|
|
|
/*
|
|
|
|
* Build the hash node and hash join node.
|
|
|
|
*/
|
1997-09-07 05:04:48 +00:00
|
|
|
hash_node = make_hash(inner_tlist, innerhashkey, inner_node);
|
|
|
|
join_node = make_hashjoin(tlist,
|
|
|
|
qpqual,
|
|
|
|
hashclauses,
|
|
|
|
outer_node,
|
|
|
|
(Plan *) hash_node);
|
1999-04-30 04:04:27 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_path_costsize(&join_node->join, &best_path->jpath.path);
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return join_node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
*
|
1997-09-07 05:04:48 +00:00
|
|
|
* SUPPORTING ROUTINES
|
1996-07-09 06:22:35 +00:00
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
1999-05-06 01:30:58 +00:00
|
|
|
/*
|
|
|
|
* fix_indxqual_references
|
2000-01-09 00:26:47 +00:00
|
|
|
* Adjust indexqual clauses to the form the executor's indexqual
|
|
|
|
* machinery needs.
|
|
|
|
*
|
|
|
|
* We have three tasks here:
|
2000-05-23 16:56:37 +00:00
|
|
|
* * Index keys must be represented by Var nodes with varattno set to the
|
2000-01-09 00:26:47 +00:00
|
|
|
* index's attribute number, not the attribute number in the original rel.
|
|
|
|
* * indxpath.c may have selected an index that is binary-compatible with
|
2000-02-03 06:12:19 +00:00
|
|
|
* the actual expression operator, but not exactly the same datatype.
|
|
|
|
* We must replace the expression's operator with the binary-compatible
|
|
|
|
* equivalent operator that the index will recognize.
|
2000-01-09 00:26:47 +00:00
|
|
|
* * If the index key is on the right, commute the clause to put it on the
|
|
|
|
* left. (Someday the executor might not need this, but for now it does.)
|
1999-05-06 01:30:58 +00:00
|
|
|
*
|
1999-08-09 01:01:42 +00:00
|
|
|
* This code used to be entirely bogus for multi-index scans. Now it keeps
|
|
|
|
* track of which index applies to each subgroup of index qual clauses...
|
|
|
|
*
|
|
|
|
* Returns a modified copy of the indexqual list --- the original is not
|
2000-04-04 01:21:48 +00:00
|
|
|
* changed. Note also that the copy shares no substructure with the
|
|
|
|
* original; this is needed in case there is a subplan in it (we need
|
|
|
|
* two separate copies of the subplan tree, or things will go awry).
|
1999-05-06 01:30:58 +00:00
|
|
|
*/
|
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
static List *
|
|
|
|
fix_indxqual_references(List *indexquals, IndexPath *index_path)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1999-08-09 01:01:42 +00:00
|
|
|
List *fixed_quals = NIL;
|
2000-01-09 00:26:47 +00:00
|
|
|
int baserelid = lfirsti(index_path->path.parent->relids);
|
1999-08-09 01:01:42 +00:00
|
|
|
List *indexids = index_path->indexid;
|
|
|
|
List *i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
foreach(i, indexquals)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
1999-08-09 01:01:42 +00:00
|
|
|
List *indexqual = lfirst(i);
|
|
|
|
Oid indexid = lfirsti(indexids);
|
|
|
|
HeapTuple indexTuple;
|
2000-01-09 00:26:47 +00:00
|
|
|
Oid relam;
|
1999-08-09 01:01:42 +00:00
|
|
|
Form_pg_index index;
|
1999-05-25 16:15:34 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
/* Get the relam from the index's pg_class entry */
|
|
|
|
indexTuple = SearchSysCacheTuple(RELOID,
|
|
|
|
ObjectIdGetDatum(indexid),
|
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(indexTuple))
|
|
|
|
elog(ERROR, "fix_indxqual_references: index %u not found in pg_class",
|
|
|
|
indexid);
|
|
|
|
relam = ((Form_pg_class) GETSTRUCT(indexTuple))->relam;
|
|
|
|
|
|
|
|
/* Need the index's pg_index entry for other stuff */
|
1999-08-09 01:01:42 +00:00
|
|
|
indexTuple = SearchSysCacheTuple(INDEXRELID,
|
|
|
|
ObjectIdGetDatum(indexid),
|
|
|
|
0, 0, 0);
|
|
|
|
if (!HeapTupleIsValid(indexTuple))
|
2000-01-09 00:26:47 +00:00
|
|
|
elog(ERROR, "fix_indxqual_references: index %u not found in pg_index",
|
1999-08-09 01:01:42 +00:00
|
|
|
indexid);
|
|
|
|
index = (Form_pg_index) GETSTRUCT(indexTuple);
|
1996-07-09 06:22:35 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
fixed_quals = lappend(fixed_quals,
|
1999-08-12 04:32:54 +00:00
|
|
|
fix_indxqual_sublist(indexqual,
|
2000-01-09 00:26:47 +00:00
|
|
|
baserelid,
|
|
|
|
relam,
|
1999-08-12 04:32:54 +00:00
|
|
|
index));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
indexids = lnext(indexids);
|
|
|
|
}
|
|
|
|
return fixed_quals;
|
|
|
|
}
|
1999-05-25 16:15:34 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
/*
|
|
|
|
* Fix the sublist of indexquals to be used in a particular scan.
|
|
|
|
*
|
1999-08-12 04:32:54 +00:00
|
|
|
* For each qual clause, commute if needed to put the indexkey operand on the
|
2000-05-23 16:56:37 +00:00
|
|
|
* left, and then fix its varattno. (We do not need to change the other side
|
2000-04-12 17:17:23 +00:00
|
|
|
* of the clause.) Also change the operator if necessary.
|
1999-08-09 01:01:42 +00:00
|
|
|
*/
|
|
|
|
static List *
|
2000-01-09 00:26:47 +00:00
|
|
|
fix_indxqual_sublist(List *indexqual, int baserelid, Oid relam,
|
1999-08-12 04:32:54 +00:00
|
|
|
Form_pg_index index)
|
1999-08-09 01:01:42 +00:00
|
|
|
{
|
|
|
|
List *fixed_qual = NIL;
|
|
|
|
List *i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
foreach(i, indexqual)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
1999-08-12 04:32:54 +00:00
|
|
|
Expr *clause = (Expr *) lfirst(i);
|
|
|
|
int relid;
|
|
|
|
AttrNumber attno;
|
|
|
|
Datum constval;
|
|
|
|
int flag;
|
1999-08-09 01:01:42 +00:00
|
|
|
Expr *newclause;
|
2000-01-09 00:26:47 +00:00
|
|
|
Oid opclass,
|
|
|
|
newopno;
|
1999-08-09 01:01:42 +00:00
|
|
|
|
1999-08-12 04:32:54 +00:00
|
|
|
if (!is_opclause((Node *) clause) ||
|
|
|
|
length(clause->args) != 2)
|
|
|
|
elog(ERROR, "fix_indxqual_sublist: indexqual clause is not binary opclause");
|
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* Which side is the indexkey on?
|
1999-08-12 04:32:54 +00:00
|
|
|
*
|
|
|
|
* get_relattval sets flag&SEL_RIGHT if the indexkey is on the LEFT.
|
|
|
|
*/
|
2000-01-09 00:26:47 +00:00
|
|
|
get_relattval((Node *) clause, baserelid,
|
1999-08-12 04:32:54 +00:00
|
|
|
&relid, &attno, &constval, &flag);
|
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* Make a copy that will become the fixed clause.
|
2000-04-04 01:21:48 +00:00
|
|
|
*
|
|
|
|
* We used to try to do a shallow copy here, but that fails if there
|
|
|
|
* is a subplan in the arguments of the opclause. So just do a
|
|
|
|
* full copy.
|
1999-08-12 04:32:54 +00:00
|
|
|
*/
|
2000-04-04 01:21:48 +00:00
|
|
|
newclause = (Expr *) copyObject((Node *) clause);
|
1999-08-09 01:01:42 +00:00
|
|
|
|
1999-08-12 04:32:54 +00:00
|
|
|
/* If the indexkey is on the right, commute the clause. */
|
|
|
|
if ((flag & SEL_RIGHT) == 0)
|
|
|
|
CommuteClause(newclause);
|
1999-08-09 01:01:42 +00:00
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* Now, determine which index attribute this is, change the
|
|
|
|
* indexkey operand as needed, and get the index opclass.
|
2000-01-09 00:26:47 +00:00
|
|
|
*/
|
1999-08-12 04:32:54 +00:00
|
|
|
lfirst(newclause->args) = fix_indxqual_operand(lfirst(newclause->args),
|
2000-01-09 00:26:47 +00:00
|
|
|
baserelid,
|
|
|
|
index,
|
|
|
|
&opclass);
|
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* Substitute the appropriate operator if the expression operator
|
|
|
|
* is merely binary-compatible with the index. This shouldn't
|
|
|
|
* fail, since indxpath.c found it before...
|
2000-01-09 00:26:47 +00:00
|
|
|
*/
|
|
|
|
newopno = indexable_operator(newclause, opclass, relam, true);
|
|
|
|
if (newopno == InvalidOid)
|
|
|
|
elog(ERROR, "fix_indxqual_sublist: failed to find substitute op");
|
2000-04-04 01:21:48 +00:00
|
|
|
((Oper *) newclause->oper)->opno = newopno;
|
1999-08-09 01:01:42 +00:00
|
|
|
|
|
|
|
fixed_qual = lappend(fixed_qual, newclause);
|
|
|
|
}
|
|
|
|
return fixed_qual;
|
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
static Node *
|
2000-01-09 00:26:47 +00:00
|
|
|
fix_indxqual_operand(Node *node, int baserelid, Form_pg_index index,
|
|
|
|
Oid *opclass)
|
1999-08-09 01:01:42 +00:00
|
|
|
{
|
2000-05-23 16:56:37 +00:00
|
|
|
/*
|
|
|
|
* We represent index keys by Var nodes having the varno of the base
|
|
|
|
* table but varattno equal to the index's attribute number (index
|
|
|
|
* column position). This is a bit hokey ... would be cleaner to use
|
|
|
|
* a special-purpose node type that could not be mistaken for a regular
|
|
|
|
* Var. But it will do for now.
|
|
|
|
*/
|
1999-08-09 01:01:42 +00:00
|
|
|
if (IsA(node, Var))
|
|
|
|
{
|
2000-05-23 16:56:37 +00:00
|
|
|
/* If it's a var, find which index key position it occupies */
|
2000-01-09 00:26:47 +00:00
|
|
|
if (((Var *) node)->varno == baserelid)
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
1999-08-09 01:01:42 +00:00
|
|
|
int varatt = ((Var *) node)->varattno;
|
|
|
|
int pos;
|
1999-05-25 16:15:34 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
for (pos = 0; pos < INDEX_MAX_KEYS; pos++)
|
|
|
|
{
|
|
|
|
if (index->indkey[pos] == varatt)
|
|
|
|
{
|
|
|
|
Node *newnode = copyObject(node);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
((Var *) newnode)->varattno = pos + 1;
|
2000-05-23 16:56:37 +00:00
|
|
|
/* return the correct opclass, too */
|
2000-01-09 00:26:47 +00:00
|
|
|
*opclass = index->indclass[pos];
|
1999-08-09 01:01:42 +00:00
|
|
|
return newnode;
|
|
|
|
}
|
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
}
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
/*
|
1999-08-12 04:32:54 +00:00
|
|
|
* Oops, this Var isn't the indexkey!
|
1999-08-09 01:01:42 +00:00
|
|
|
*/
|
1999-08-12 04:32:54 +00:00
|
|
|
elog(ERROR, "fix_indxqual_operand: var is not index attribute");
|
1999-07-29 02:48:05 +00:00
|
|
|
}
|
|
|
|
|
1999-08-09 01:01:42 +00:00
|
|
|
/*
|
2000-05-23 16:56:37 +00:00
|
|
|
* Else, it must be a func expression matching a functional index.
|
|
|
|
* Since we currently only support single-column functional indexes,
|
|
|
|
* the returned varattno must be 1.
|
1999-08-09 01:01:42 +00:00
|
|
|
*/
|
1999-07-29 02:48:05 +00:00
|
|
|
|
2000-05-23 16:56:37 +00:00
|
|
|
Assert(is_funcclause(node)); /* not a very thorough check, but easy */
|
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
/* indclass[0] is the only class of a functional index */
|
|
|
|
*opclass = index->indclass[0];
|
|
|
|
|
2000-05-23 16:56:37 +00:00
|
|
|
return (Node *) makeVar(baserelid, 1, exprType(node), -1, 0);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
/*
|
1999-02-13 23:22:53 +00:00
|
|
|
* switch_outer
|
1999-08-16 02:17:58 +00:00
|
|
|
* Given a list of merge or hash joinclauses, rearrange the elements within
|
|
|
|
* the clauses so the outer join variable is on the left and the inner is
|
|
|
|
* on the right. The original list is not touched; a modified list
|
1999-03-01 00:10:44 +00:00
|
|
|
* is returned.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
1997-09-08 02:41:22 +00:00
|
|
|
static List *
|
1997-09-08 21:56:23 +00:00
|
|
|
switch_outer(List *clauses)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List *t_list = NIL;
|
1999-03-01 00:10:44 +00:00
|
|
|
List *i;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
foreach(i, clauses)
|
1997-04-22 03:32:38 +00:00
|
|
|
{
|
1999-08-12 04:32:54 +00:00
|
|
|
Expr *clause = (Expr *) lfirst(i);
|
1999-08-16 02:17:58 +00:00
|
|
|
Var *op;
|
1999-08-09 01:01:42 +00:00
|
|
|
|
1999-05-25 16:15:34 +00:00
|
|
|
Assert(is_opclause((Node *) clause));
|
1999-08-16 02:17:58 +00:00
|
|
|
op = get_rightop(clause);
|
|
|
|
Assert(op && IsA(op, Var));
|
|
|
|
if (var_is_outer(op))
|
1997-09-07 05:04:48 +00:00
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
|
1999-05-25 16:15:34 +00:00
|
|
|
/*
|
|
|
|
* Duplicate just enough of the structure to allow commuting
|
1999-03-01 00:10:44 +00:00
|
|
|
* the clause without changing the original list. Could use
|
|
|
|
* copyObject, but a complete deep copy is overkill.
|
|
|
|
*/
|
1999-08-09 01:01:42 +00:00
|
|
|
Expr *temp;
|
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
temp = make_clause(clause->opType, clause->oper,
|
1999-08-12 04:32:54 +00:00
|
|
|
listCopy(clause->args));
|
1999-03-01 00:10:44 +00:00
|
|
|
/* Commute it --- note this modifies the temp node in-place. */
|
1999-08-12 04:32:54 +00:00
|
|
|
CommuteClause(temp);
|
1997-09-07 05:04:48 +00:00
|
|
|
t_list = lappend(t_list, temp);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
t_list = lappend(t_list, clause);
|
|
|
|
}
|
1998-09-01 03:29:17 +00:00
|
|
|
return t_list;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
/*
|
|
|
|
* Copy cost and size info from a Path node to the Plan node created from it.
|
|
|
|
* The executor won't use this info, but it's needed by EXPLAIN.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
copy_path_costsize(Plan *dest, Path *src)
|
|
|
|
{
|
|
|
|
if (src)
|
|
|
|
{
|
2000-02-15 20:49:31 +00:00
|
|
|
dest->startup_cost = src->startup_cost;
|
|
|
|
dest->total_cost = src->total_cost;
|
2000-01-09 00:26:47 +00:00
|
|
|
dest->plan_rows = src->parent->rows;
|
|
|
|
dest->plan_width = src->parent->width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-02-15 20:49:31 +00:00
|
|
|
dest->startup_cost = 0;
|
|
|
|
dest->total_cost = 0;
|
2000-01-09 00:26:47 +00:00
|
|
|
dest->plan_rows = 0;
|
|
|
|
dest->plan_width = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-30 04:04:27 +00:00
|
|
|
/*
|
|
|
|
* Copy cost and size info from a lower plan node to an inserted node.
|
|
|
|
* This is not critical, since the decisions have already been made,
|
|
|
|
* but it helps produce more reasonable-looking EXPLAIN output.
|
2000-02-03 06:12:19 +00:00
|
|
|
* (Some callers alter the info after copying it.)
|
1999-04-30 04:04:27 +00:00
|
|
|
*/
|
|
|
|
static void
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_plan_costsize(Plan *dest, Plan *src)
|
1999-04-30 04:04:27 +00:00
|
|
|
{
|
|
|
|
if (src)
|
|
|
|
{
|
2000-02-15 20:49:31 +00:00
|
|
|
dest->startup_cost = src->startup_cost;
|
|
|
|
dest->total_cost = src->total_cost;
|
2000-01-09 00:26:47 +00:00
|
|
|
dest->plan_rows = src->plan_rows;
|
1999-04-30 04:04:27 +00:00
|
|
|
dest->plan_width = src->plan_width;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2000-02-15 20:49:31 +00:00
|
|
|
dest->startup_cost = 0;
|
|
|
|
dest->total_cost = 0;
|
2000-01-09 00:26:47 +00:00
|
|
|
dest->plan_rows = 0;
|
1999-04-30 04:04:27 +00:00
|
|
|
dest->plan_width = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1996-07-09 06:22:35 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2000-06-18 22:44:35 +00:00
|
|
|
static SeqScan *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_seqscan(List *qptlist,
|
|
|
|
List *qpqual,
|
1999-08-22 20:15:04 +00:00
|
|
|
Index scanrelid)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
SeqScan *node = makeNode(SeqScan);
|
|
|
|
Plan *plan = &node->plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/* cost should be inserted by caller */
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = qptlist;
|
|
|
|
plan->qual = qpqual;
|
1999-08-22 20:15:04 +00:00
|
|
|
plan->lefttree = NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->righttree = NULL;
|
|
|
|
node->scanrelid = scanrelid;
|
|
|
|
node->scanstate = (CommonScanState *) NULL;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static IndexScan *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_indexscan(List *qptlist,
|
|
|
|
List *qpqual,
|
1997-09-07 05:04:48 +00:00
|
|
|
Index scanrelid,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *indxid,
|
1997-12-18 12:21:02 +00:00
|
|
|
List *indxqual,
|
2000-02-15 20:49:31 +00:00
|
|
|
List *indxqualorig,
|
|
|
|
ScanDirection indexscandir)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
IndexScan *node = makeNode(IndexScan);
|
|
|
|
Plan *plan = &node->scan.plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/* cost should be inserted by caller */
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = qptlist;
|
|
|
|
plan->qual = qpqual;
|
|
|
|
plan->lefttree = NULL;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
node->scan.scanrelid = scanrelid;
|
|
|
|
node->indxid = indxid;
|
|
|
|
node->indxqual = indxqual;
|
1998-11-22 10:48:45 +00:00
|
|
|
node->indxqualorig = indxqualorig;
|
2000-02-15 20:49:31 +00:00
|
|
|
node->indxorderdir = indexscandir;
|
1997-09-07 05:04:48 +00:00
|
|
|
node->scan.scanstate = (CommonScanState *) NULL;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static NestLoop *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_nestloop(List *qptlist,
|
|
|
|
List *qpqual,
|
|
|
|
Plan *lefttree,
|
|
|
|
Plan *righttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
NestLoop *node = makeNode(NestLoop);
|
|
|
|
Plan *plan = &node->join;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/* cost should be inserted by caller */
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = qptlist;
|
|
|
|
plan->qual = qpqual;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = righttree;
|
|
|
|
node->nlstate = (NestLoopState *) NULL;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static HashJoin *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_hashjoin(List *tlist,
|
|
|
|
List *qpqual,
|
|
|
|
List *hashclauses,
|
|
|
|
Plan *lefttree,
|
|
|
|
Plan *righttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
HashJoin *node = makeNode(HashJoin);
|
|
|
|
Plan *plan = &node->join;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/* cost should be inserted by caller */
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = qpqual;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = righttree;
|
|
|
|
node->hashclauses = hashclauses;
|
|
|
|
node->hashdone = false;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1997-09-08 02:41:22 +00:00
|
|
|
static Hash *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_hash(List *tlist, Var *hashkey, Plan *lefttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Hash *node = makeNode(Hash);
|
|
|
|
Plan *plan = &node->plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_plan_costsize(plan, lefttree);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For plausibility, make startup & total costs equal total cost of
|
2000-02-15 20:49:31 +00:00
|
|
|
* input plan; this only affects EXPLAIN display not decisions.
|
|
|
|
*/
|
|
|
|
plan->startup_cost = plan->total_cost;
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = NULL;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
node->hashkey = hashkey;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static MergeJoin *
|
1998-08-04 16:44:31 +00:00
|
|
|
make_mergejoin(List *tlist,
|
1997-09-08 21:56:23 +00:00
|
|
|
List *qpqual,
|
|
|
|
List *mergeclauses,
|
|
|
|
Plan *righttree,
|
|
|
|
Plan *lefttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
MergeJoin *node = makeNode(MergeJoin);
|
|
|
|
Plan *plan = &node->join;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/* cost should be inserted by caller */
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = qpqual;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = righttree;
|
|
|
|
node->mergeclauses = mergeclauses;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
2000-06-18 22:44:35 +00:00
|
|
|
/*
|
|
|
|
* To use make_sort directly, you must already have marked the tlist
|
|
|
|
* with reskey and reskeyop information. The keys had better be
|
|
|
|
* non-redundant, too (ie, there had better be tlist items marked with
|
|
|
|
* each key number from 1 to keycount), or the executor will get confused!
|
|
|
|
*/
|
1998-02-26 04:46:47 +00:00
|
|
|
Sort *
|
2000-06-18 22:44:35 +00:00
|
|
|
make_sort(List *tlist, Plan *lefttree, int keycount)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Sort *node = makeNode(Sort);
|
|
|
|
Plan *plan = &node->plan;
|
2000-02-15 20:49:31 +00:00
|
|
|
Path sort_path; /* dummy for result of cost_sort */
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
copy_plan_costsize(plan, lefttree); /* only care about copying size */
|
2000-02-15 20:49:31 +00:00
|
|
|
cost_sort(&sort_path, NIL, lefttree->plan_rows, lefttree->plan_width);
|
|
|
|
plan->startup_cost = sort_path.startup_cost + lefttree->total_cost;
|
|
|
|
plan->total_cost = sort_path.total_cost + lefttree->total_cost;
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = NIL;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
node->keycount = keycount;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
2000-06-18 22:44:35 +00:00
|
|
|
/*
|
|
|
|
* make_sort_from_pathkeys
|
|
|
|
* Create sort plan to sort according to given pathkeys
|
|
|
|
*
|
|
|
|
* 'tlist' is the target list of the input plan
|
|
|
|
* 'lefttree' is the node which yields input tuples
|
|
|
|
* 'pathkeys' is the list of pathkeys by which the result is to be sorted
|
|
|
|
*
|
|
|
|
* We must convert the pathkey information into reskey and reskeyop fields
|
|
|
|
* of resdom nodes in the sort plan's target list.
|
|
|
|
*/
|
|
|
|
Sort *
|
|
|
|
make_sort_from_pathkeys(List *tlist, Plan *lefttree, List *pathkeys)
|
|
|
|
{
|
|
|
|
List *sort_tlist;
|
|
|
|
List *i;
|
|
|
|
int numsortkeys = 0;
|
|
|
|
|
|
|
|
/* Create a new target list for the sort, with sort keys set. */
|
|
|
|
sort_tlist = new_unsorted_tlist(tlist);
|
|
|
|
|
|
|
|
foreach(i, pathkeys)
|
|
|
|
{
|
|
|
|
List *keysublist = (List *) lfirst(i);
|
|
|
|
PathKeyItem *pathkey = NULL;
|
|
|
|
Resdom *resdom = NULL;
|
|
|
|
List *j;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We can sort by any one of the sort key items listed in this
|
|
|
|
* sublist. For now, we take the first one that corresponds to an
|
|
|
|
* available Var in the sort_tlist.
|
|
|
|
*
|
|
|
|
* XXX if we have a choice, is there any way of figuring out which
|
|
|
|
* might be cheapest to execute? (For example, int4lt is likely
|
|
|
|
* much cheaper to execute than numericlt, but both might appear
|
|
|
|
* in the same pathkey sublist...) Not clear that we ever will
|
|
|
|
* have a choice in practice, so it may not matter.
|
|
|
|
*/
|
|
|
|
foreach(j, keysublist)
|
|
|
|
{
|
|
|
|
pathkey = lfirst(j);
|
|
|
|
Assert(IsA(pathkey, PathKeyItem));
|
|
|
|
resdom = tlist_member(pathkey->key, sort_tlist);
|
|
|
|
if (resdom)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!resdom)
|
|
|
|
elog(ERROR, "make_sort_from_pathkeys: cannot find tlist item to sort");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The resdom might be already marked as a sort key, if the
|
|
|
|
* pathkeys contain duplicate entries. (This can happen in
|
|
|
|
* scenarios where multiple mergejoinable clauses mention the same
|
|
|
|
* var, for example.) In that case the current pathkey is
|
|
|
|
* essentially a no-op, because only one value can be seen within
|
|
|
|
* any subgroup where it would be consulted. We can ignore it.
|
|
|
|
*/
|
|
|
|
if (resdom->reskey == 0)
|
|
|
|
{
|
|
|
|
/* OK, mark it as a sort key and set the sort operator regproc */
|
|
|
|
resdom->reskey = ++numsortkeys;
|
|
|
|
resdom->reskeyop = get_opcode(pathkey->sortop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Assert(numsortkeys > 0);
|
|
|
|
|
|
|
|
return make_sort(sort_tlist, lefttree, numsortkeys);
|
|
|
|
}
|
|
|
|
|
|
|
|
Material *
|
|
|
|
make_material(List *tlist, Plan *lefttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Material *node = makeNode(Material);
|
|
|
|
Plan *plan = &node->plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_plan_costsize(plan, lefttree);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* For plausibility, make startup & total costs equal total cost of
|
2000-06-18 22:44:35 +00:00
|
|
|
* input plan; this only affects EXPLAIN display not decisions.
|
|
|
|
*
|
|
|
|
* XXX shouldn't we charge some additional cost for materialization?
|
2000-02-15 20:49:31 +00:00
|
|
|
*/
|
|
|
|
plan->startup_cost = plan->total_cost;
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = NIL;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
Agg *
|
2000-02-15 20:49:31 +00:00
|
|
|
make_agg(List *tlist, List *qual, Plan *lefttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Agg *node = makeNode(Agg);
|
2000-02-15 20:49:31 +00:00
|
|
|
Plan *plan = &node->plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
copy_plan_costsize(plan, lefttree);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Charge one cpu_operator_cost per aggregate function per input
|
|
|
|
* tuple.
|
2000-02-15 20:49:31 +00:00
|
|
|
*/
|
|
|
|
plan->total_cost += cpu_operator_cost * plan->plan_rows *
|
|
|
|
(length(pull_agg_clause((Node *) tlist)) +
|
|
|
|
length(pull_agg_clause((Node *) qual)));
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/*
|
2000-02-15 20:49:31 +00:00
|
|
|
* We will produce a single output tuple if the input is not a Group,
|
|
|
|
* and a tuple per group otherwise. For now, estimate the number of
|
2000-04-12 17:17:23 +00:00
|
|
|
* groups as 10% of the number of tuples --- bogus, but how to do
|
|
|
|
* better? (Note we assume the input Group node is in "tuplePerGroup"
|
|
|
|
* mode, so it didn't reduce its row count already.)
|
2000-02-03 06:12:19 +00:00
|
|
|
*/
|
|
|
|
if (IsA(lefttree, Group))
|
2000-02-15 20:49:31 +00:00
|
|
|
plan->plan_rows *= 0.1;
|
2000-02-03 06:12:19 +00:00
|
|
|
else
|
2000-02-15 20:49:31 +00:00
|
|
|
{
|
|
|
|
plan->plan_rows = 1;
|
|
|
|
plan->startup_cost = plan->total_cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->qual = qual;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = (Plan *) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
Group *
|
1997-09-08 21:56:23 +00:00
|
|
|
make_group(List *tlist,
|
1997-09-07 05:04:48 +00:00
|
|
|
bool tuplePerGroup,
|
|
|
|
int ngrp,
|
1997-09-08 20:59:27 +00:00
|
|
|
AttrNumber *grpColIdx,
|
1999-08-21 03:49:17 +00:00
|
|
|
Plan *lefttree)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Group *node = makeNode(Group);
|
2000-02-15 20:49:31 +00:00
|
|
|
Plan *plan = &node->plan;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
copy_plan_costsize(plan, lefttree);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Charge one cpu_operator_cost per comparison per input tuple. We
|
|
|
|
* assume all columns get compared at most of the tuples.
|
2000-02-15 20:49:31 +00:00
|
|
|
*/
|
|
|
|
plan->total_cost += cpu_operator_cost * plan->plan_rows * ngrp;
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* If tuplePerGroup (which is named exactly backwards) is true, we
|
|
|
|
* will return all the input tuples, so the input node's row count is
|
|
|
|
* OK. Otherwise, we'll return only one tuple from each group. For
|
|
|
|
* now, estimate the number of groups as 10% of the number of tuples
|
|
|
|
* --- bogus, but how to do better?
|
2000-02-03 06:12:19 +00:00
|
|
|
*/
|
2000-04-12 17:17:23 +00:00
|
|
|
if (!tuplePerGroup)
|
2000-02-15 20:49:31 +00:00
|
|
|
plan->plan_rows *= 0.1;
|
|
|
|
|
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->qual = NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = (Plan *) NULL;
|
1997-09-07 05:04:48 +00:00
|
|
|
node->tuplePerGroup = tuplePerGroup;
|
|
|
|
node->numCols = ngrp;
|
|
|
|
node->grpColIdx = grpColIdx;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-01-27 18:11:50 +00:00
|
|
|
* distinctList is a list of SortClauses, identifying the targetlist items
|
|
|
|
* that should be considered by the Unique filter.
|
1996-07-09 06:22:35 +00:00
|
|
|
*/
|
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
Unique *
|
2000-01-27 18:11:50 +00:00
|
|
|
make_unique(List *tlist, Plan *lefttree, List *distinctList)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
Unique *node = makeNode(Unique);
|
|
|
|
Plan *plan = &node->plan;
|
2000-01-27 18:11:50 +00:00
|
|
|
int numCols = length(distinctList);
|
|
|
|
int keyno = 0;
|
|
|
|
AttrNumber *uniqColIdx;
|
|
|
|
List *slitem;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_plan_costsize(plan, lefttree);
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-15 20:49:31 +00:00
|
|
|
/*
|
2000-04-12 17:17:23 +00:00
|
|
|
* Charge one cpu_operator_cost per comparison per input tuple. We
|
|
|
|
* assume all columns get compared at most of the tuples.
|
2000-02-15 20:49:31 +00:00
|
|
|
*/
|
|
|
|
plan->total_cost += cpu_operator_cost * plan->plan_rows * numCols;
|
2000-04-12 17:17:23 +00:00
|
|
|
|
2000-02-03 06:12:19 +00:00
|
|
|
/*
|
|
|
|
* As for Group, we make the unsupported assumption that there will be
|
|
|
|
* 10% as many tuples out as in.
|
|
|
|
*/
|
|
|
|
plan->plan_rows *= 0.1;
|
2000-02-15 20:49:31 +00:00
|
|
|
|
1997-09-07 05:04:48 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = NIL;
|
|
|
|
plan->lefttree = lefttree;
|
|
|
|
plan->righttree = NULL;
|
2000-01-27 18:11:50 +00:00
|
|
|
|
2000-04-12 17:17:23 +00:00
|
|
|
/*
|
|
|
|
* convert SortClause list into array of attr indexes, as wanted by
|
|
|
|
* exec
|
|
|
|
*/
|
2000-01-27 18:11:50 +00:00
|
|
|
Assert(numCols > 0);
|
|
|
|
uniqColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);
|
|
|
|
|
|
|
|
foreach(slitem, distinctList)
|
|
|
|
{
|
2000-04-12 17:17:23 +00:00
|
|
|
SortClause *sortcl = (SortClause *) lfirst(slitem);
|
|
|
|
TargetEntry *tle = get_sortgroupclause_tle(sortcl, tlist);
|
2000-01-27 18:11:50 +00:00
|
|
|
|
|
|
|
uniqColIdx[keyno++] = tle->resdom->resno;
|
|
|
|
}
|
|
|
|
|
|
|
|
node->numCols = numCols;
|
|
|
|
node->uniqColIdx = uniqColIdx;
|
|
|
|
|
1998-09-01 03:29:17 +00:00
|
|
|
return node;
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
|
|
|
|
1999-08-22 20:15:04 +00:00
|
|
|
Result *
|
|
|
|
make_result(List *tlist,
|
|
|
|
Node *resconstantqual,
|
|
|
|
Plan *subplan)
|
|
|
|
{
|
|
|
|
Result *node = makeNode(Result);
|
|
|
|
Plan *plan = &node->plan;
|
|
|
|
|
|
|
|
#ifdef NOT_USED
|
|
|
|
tlist = generate_fjoin(tlist);
|
|
|
|
#endif
|
2000-01-09 00:26:47 +00:00
|
|
|
copy_plan_costsize(plan, subplan);
|
1999-08-22 20:15:04 +00:00
|
|
|
plan->state = (EState *) NULL;
|
|
|
|
plan->targetlist = tlist;
|
|
|
|
plan->qual = NIL;
|
|
|
|
plan->lefttree = subplan;
|
|
|
|
plan->righttree = NULL;
|
|
|
|
node->resconstantqual = resconstantqual;
|
|
|
|
node->resstate = NULL;
|
|
|
|
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
1997-12-18 12:54:45 +00:00
|
|
|
#ifdef NOT_USED
|
1998-02-26 04:46:47 +00:00
|
|
|
List *
|
1997-09-08 21:56:23 +00:00
|
|
|
generate_fjoin(List *tlist)
|
1996-07-09 06:22:35 +00:00
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List tlistP;
|
|
|
|
List newTlist = NIL;
|
|
|
|
List fjoinList = NIL;
|
|
|
|
int nIters = 0;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Break the target list into elements with Iter nodes, and those
|
|
|
|
* without them.
|
|
|
|
*/
|
|
|
|
foreach(tlistP, tlist)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List tlistElem;
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
tlistElem = lfirst(tlistP);
|
|
|
|
if (IsA(lsecond(tlistElem), Iter))
|
|
|
|
{
|
|
|
|
nIters++;
|
|
|
|
fjoinList = lappend(fjoinList, tlistElem);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
newTlist = lappend(newTlist, tlistElem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if we have an Iter node then we need to flatten.
|
|
|
|
*/
|
|
|
|
if (nIters > 0)
|
|
|
|
{
|
1997-09-08 02:41:22 +00:00
|
|
|
List *inner;
|
|
|
|
List *tempList;
|
|
|
|
Fjoin *fjoinNode;
|
|
|
|
DatumPtr results = (DatumPtr) palloc(nIters * sizeof(Datum));
|
|
|
|
BoolPtr alwaysDone = (BoolPtr) palloc(nIters * sizeof(bool));
|
1997-09-07 05:04:48 +00:00
|
|
|
|
|
|
|
inner = lfirst(fjoinList);
|
|
|
|
fjoinList = lnext(fjoinList);
|
|
|
|
fjoinNode = (Fjoin) MakeFjoin(false,
|
|
|
|
nIters,
|
|
|
|
inner,
|
|
|
|
results,
|
|
|
|
alwaysDone);
|
1999-02-15 02:04:58 +00:00
|
|
|
tempList = lcons(fjoinNode, fjoinList);
|
1997-09-07 05:04:48 +00:00
|
|
|
newTlist = lappend(newTlist, tempList);
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
1997-09-07 05:04:48 +00:00
|
|
|
return newTlist;
|
|
|
|
return tlist; /* do nothing for now - ay 10/94 */
|
1996-07-09 06:22:35 +00:00
|
|
|
}
|
1997-12-18 12:54:45 +00:00
|
|
|
|
1998-02-26 04:46:47 +00:00
|
|
|
#endif
|