From dd979f66be20fc54aad06da743f788fbc505bbe1 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 27 Jan 2000 18:11:50 +0000 Subject: 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... --- src/backend/optimizer/util/tlist.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) (limited to 'src/backend/optimizer/util/tlist.c') 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; +} -- cgit v1.2.3