aboutsummaryrefslogtreecommitdiff
path: root/src/backend/nodes/copyfuncs.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2007-01-20 20:45:41 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2007-01-20 20:45:41 +0000
commitf41803bb39bc2949db200116a609fd242d0ec221 (patch)
tree2c81bcf712ab8b46133c2f50bbee34b2b3ea7129 /src/backend/nodes/copyfuncs.c
parent2b7334d4877ba445003f96b0bb7eed4e7078a39b (diff)
downloadpostgresql-f41803bb39bc2949db200116a609fd242d0ec221.tar.gz
postgresql-f41803bb39bc2949db200116a609fd242d0ec221.zip
Refactor planner's pathkeys data structure to create a separate, explicit
representation of equivalence classes of variables. This is an extensive rewrite, but it brings a number of benefits: * planner no longer fails in the presence of "incomplete" operator families that don't offer operators for every possible combination of datatypes. * avoid generating and then discarding redundant equality clauses. * remove bogus assumption that derived equalities always use operators named "=". * mergejoins can work with a variety of sort orders (e.g., descending) now, instead of tying each mergejoinable operator to exactly one sort order. * better recognition of redundant sort columns. * can make use of equalities appearing underneath an outer join.
Diffstat (limited to 'src/backend/nodes/copyfuncs.c')
-rw-r--r--src/backend/nodes/copyfuncs.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c
index 4943bb20297..7b003dc095c 100644
--- a/src/backend/nodes/copyfuncs.c
+++ b/src/backend/nodes/copyfuncs.c
@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.361 2007/01/10 18:06:02 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.362 2007/01/20 20:45:38 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1284,16 +1284,18 @@ _copyFromExpr(FromExpr *from)
*/
/*
- * _copyPathKeyItem
+ * _copyPathKey
*/
-static PathKeyItem *
-_copyPathKeyItem(PathKeyItem *from)
+static PathKey *
+_copyPathKey(PathKey *from)
{
- PathKeyItem *newnode = makeNode(PathKeyItem);
+ PathKey *newnode = makeNode(PathKey);
- COPY_NODE_FIELD(key);
- COPY_SCALAR_FIELD(sortop);
- COPY_SCALAR_FIELD(nulls_first);
+ /* EquivalenceClasses are never moved, so just shallow-copy the pointer */
+ COPY_SCALAR_FIELD(pk_eclass);
+ COPY_SCALAR_FIELD(pk_opfamily);
+ COPY_SCALAR_FIELD(pk_strategy);
+ COPY_SCALAR_FIELD(pk_nulls_first);
return newnode;
}
@@ -1316,21 +1318,15 @@ _copyRestrictInfo(RestrictInfo *from)
COPY_BITMAPSET_FIELD(left_relids);
COPY_BITMAPSET_FIELD(right_relids);
COPY_NODE_FIELD(orclause);
+ /* EquivalenceClasses are never copied, so shallow-copy the pointers */
+ COPY_SCALAR_FIELD(parent_ec);
COPY_SCALAR_FIELD(eval_cost);
COPY_SCALAR_FIELD(this_selec);
- COPY_SCALAR_FIELD(mergejoinoperator);
- COPY_SCALAR_FIELD(left_sortop);
- COPY_SCALAR_FIELD(right_sortop);
- COPY_SCALAR_FIELD(mergeopfamily);
-
- /*
- * Do not copy pathkeys, since they'd not be canonical in a copied query
- */
- newnode->left_pathkey = NIL;
- newnode->right_pathkey = NIL;
-
- COPY_SCALAR_FIELD(left_mergescansel);
- COPY_SCALAR_FIELD(right_mergescansel);
+ COPY_NODE_FIELD(mergeopfamilies);
+ /* EquivalenceClasses are never copied, so shallow-copy the pointers */
+ COPY_SCALAR_FIELD(left_ec);
+ COPY_SCALAR_FIELD(right_ec);
+ COPY_SCALAR_FIELD(outer_is_left);
COPY_SCALAR_FIELD(hashjoinoperator);
COPY_SCALAR_FIELD(left_bucketsize);
COPY_SCALAR_FIELD(right_bucketsize);
@@ -3033,8 +3029,8 @@ copyObject(void *from)
/*
* RELATION NODES
*/
- case T_PathKeyItem:
- retval = _copyPathKeyItem(from);
+ case T_PathKey:
+ retval = _copyPathKey(from);
break;
case T_RestrictInfo:
retval = _copyRestrictInfo(from);