mirror of
https://github.com/postgres/postgres.git
synced 2025-06-27 23:21:58 +03:00
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...
This commit is contained in:
@ -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.
|
||||
|
Reference in New Issue
Block a user