diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2000-01-27 18:11:50 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2000-01-27 18:11:50 +0000 |
commit | dd979f66be20fc54aad06da743f788fbc505bbe1 (patch) | |
tree | 4d6b578e0afc7dc0198296940cd77c79c5eff66c /src/backend/rewrite/rewriteManip.c | |
parent | 3f0074e403ac3a145c5e43db3348f45fe084703d (diff) | |
download | postgresql-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/rewrite/rewriteManip.c')
-rw-r--r-- | src/backend/rewrite/rewriteManip.c | 21 |
1 files changed, 5 insertions, 16 deletions
diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 4d2960433e8..01f33ecf8f3 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,13 +7,14 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.43 2000/01/26 05:56:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.44 2000/01/27 18:11:37 tgl Exp $ * *------------------------------------------------------------------------- */ #include "postgres.h" #include "optimizer/clauses.h" +#include "optimizer/tlist.h" #include "parser/parsetree.h" #include "parser/parse_clause.h" #include "rewrite/rewriteManip.h" @@ -286,22 +287,10 @@ AddGroupClause(Query *parsetree, List *group_by, List *tlist) foreach(l, group_by) { GroupClause *groupclause = (GroupClause *) copyObject(lfirst(l)); - Index refnumber = groupclause->tleSortGroupRef; - TargetEntry *tle = NULL; - List *tl; + TargetEntry *tle = get_sortgroupclause_tle(groupclause, tlist); - /* Find and copy the groupclause's TLE in the old tlist */ - foreach(tl, tlist) - { - if (((TargetEntry *) lfirst(tl))->resdom->ressortgroupref == - refnumber) - { - tle = (TargetEntry *) copyObject(lfirst(tl)); - break; - } - } - if (tle == NULL) - elog(ERROR, "AddGroupClause(): GROUP BY entry not found in rules targetlist"); + /* copy the groupclause's TLE from the old tlist */ + tle = (TargetEntry *) copyObject(tle); /* The ressortgroupref number in the old tlist might be already * taken in the new tlist, so force assignment of a new number. |