aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util/tlist.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-01-27 18:11:50 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-01-27 18:11:50 +0000
commitdd979f66be20fc54aad06da743f788fbc505bbe1 (patch)
tree4d6b578e0afc7dc0198296940cd77c79c5eff66c /src/backend/optimizer/util/tlist.c
parent3f0074e403ac3a145c5e43db3348f45fe084703d (diff)
downloadpostgresql-dd979f66be20fc54aad06da743f788fbc505bbe1.tar.gz
postgresql-dd979f66be20fc54aad06da743f788fbc505bbe1.zip
Redesign DISTINCT ON as discussed in pgsql-sql 1/25/00: syntax is now
SELECT DISTINCT ON (expr [, expr ...]) targetlist ... and there is a check to make sure that the user didn't specify an ORDER BY that's incompatible with the DISTINCT operation. Reimplement nodeUnique and nodeGroup to use the proper datatype-specific equality function for each column being compared --- they used to do bitwise comparisons or convert the data to text strings and strcmp(). (To add insult to injury, they'd look up the conversion functions once for each tuple...) Parse/plan representation of DISTINCT is now a list of SortClause nodes. initdb forced by querytree change...
Diffstat (limited to 'src/backend/optimizer/util/tlist.c')
-rw-r--r--src/backend/optimizer/util/tlist.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c
index 8edf44190a4..b4c745b25f3 100644
--- a/src/backend/optimizer/util/tlist.c
+++ b/src/backend/optimizer/util/tlist.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.42 2000/01/26 05:56:40 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.43 2000/01/27 18:11:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -217,15 +217,16 @@ get_expr(TargetEntry *tle)
}
/*
- * get_sortgroupclause_expr
+ * get_sortgroupclause_tle
* Find the targetlist entry matching the given SortClause
- * (or GroupClause) by ressortgroupref, and return its expression.
+ * (or GroupClause) by ressortgroupref, and return it.
*
* Because GroupClause is typedef'd as SortClause, either kind of
* node can be passed without casting.
*/
-Node *
-get_sortgroupclause_expr(SortClause *sortClause, List *targetList)
+TargetEntry *
+get_sortgroupclause_tle(SortClause *sortClause,
+ List *targetList)
{
Index refnumber = sortClause->tleSortGroupRef;
List *l;
@@ -235,9 +236,25 @@ get_sortgroupclause_expr(SortClause *sortClause, List *targetList)
TargetEntry *tle = (TargetEntry *) lfirst(l);
if (tle->resdom->ressortgroupref == refnumber)
- return tle->expr;
+ return tle;
}
- elog(ERROR, "get_sortgroupclause_expr: ORDER/GROUP BY expression not found in targetlist");
+ elog(ERROR, "get_sortgroupclause_tle: ORDER/GROUP BY expression not found in targetlist");
return NULL; /* keep compiler quiet */
}
+
+/*
+ * get_sortgroupclause_expr
+ * Find the targetlist entry matching the given SortClause
+ * (or GroupClause) by ressortgroupref, and return its expression.
+ *
+ * Because GroupClause is typedef'd as SortClause, either kind of
+ * node can be passed without casting.
+ */
+Node *
+get_sortgroupclause_expr(SortClause *sortClause, List *targetList)
+{
+ TargetEntry *tle = get_sortgroupclause_tle(sortClause, targetList);
+
+ return tle->expr;
+}