*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.101 2004/02/03 17:34:03 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.102 2004/03/02 16:42:20 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "optimizer/pathnode.h"
#include "optimizer/paths.h"
#include "optimizer/restrictinfo.h"
+#include "optimizer/tlist.h"
#include "parser/parse_expr.h"
#include "parser/parse_oper.h"
#include "parser/parsetree.h"
return true;
}
+ /*
+ * GROUP BY guarantees uniqueness if all the grouped columns appear in
+ * the output. In our implementation this means checking they are non
+ * resjunk columns.
+ */
+ if (query->groupClause)
+ {
+ List *gl;
+
+ foreach(gl, query->groupClause)
+ {
+ GroupClause *grpcl = (GroupClause *) lfirst(gl);
+ TargetEntry *tle = get_sortgroupclause_tle(grpcl,
+ query->targetList);
+
+ if (tle->resdom->resjunk)
+ break;
+ }
+ if (!gl) /* got to the end? */
+ return true;
+ }
+
/*
* XXX Are there any other cases in which we can easily see the result
* must be distinct?