aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/analyze.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/parser/analyze.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/parser/analyze.c')
-rw-r--r--src/backend/parser/analyze.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c
index 48178bcb215..fd3dda8f17e 100644
--- a/src/backend/parser/analyze.c
+++ b/src/backend/parser/analyze.c
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: analyze.c,v 1.133 2000/01/26 05:56:41 momjian Exp $
+ * $Id: analyze.c,v 1.134 2000/01/27 18:11:35 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -247,7 +247,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
makeRangeTable(pstate, NULL, NULL);
setTargetTable(pstate, stmt->relname);
- qry->uniqueFlag = NULL;
+ qry->distinctClause = NIL;
/* fix where clause */
qry->qual = transformWhereClause(pstate, stmt->whereClause, NULL);
@@ -296,8 +296,6 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
/* set up a range table --- note INSERT target is not in it yet */
makeRangeTable(pstate, stmt->fromClause, &fromQual);
- qry->uniqueFlag = stmt->unique;
-
qry->targetList = transformTargetList(pstate, stmt->targetList);
qry->qual = transformWhereClause(pstate, stmt->whereClause, fromQual);
@@ -311,13 +309,13 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
stmt->groupClause,
qry->targetList);
- /* An InsertStmt has no sortClause, but we still call
- * transformSortClause because it also handles uniqueFlag.
- */
- qry->sortClause = transformSortClause(pstate,
- NIL,
- qry->targetList,
- qry->uniqueFlag);
+ /* An InsertStmt has no sortClause */
+ qry->sortClause = NIL;
+
+ qry->distinctClause = transformDistinctClause(pstate,
+ stmt->distinctClause,
+ qry->targetList,
+ & qry->sortClause);
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->hasAggs = pstate->p_hasAggs;
@@ -1312,8 +1310,6 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
/* set up a range table */
makeRangeTable(pstate, stmt->fromClause, &fromQual);
- qry->uniqueFlag = stmt->unique;
-
qry->into = stmt->into;
qry->isTemp = stmt->istemp;
qry->isPortal = FALSE;
@@ -1333,8 +1329,12 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
qry->sortClause = transformSortClause(pstate,
stmt->sortClause,
- qry->targetList,
- qry->uniqueFlag);
+ qry->targetList);
+
+ qry->distinctClause = transformDistinctClause(pstate,
+ stmt->distinctClause,
+ qry->targetList,
+ & qry->sortClause);
qry->hasSubLinks = pstate->p_hasSubLinks;
qry->hasAggs = pstate->p_hasAggs;
@@ -1558,9 +1558,9 @@ CheckSelectForUpdate(Query *qry)
{
if (qry->unionClause != NULL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with UNION/INTERSECT/EXCEPT clause");
- if (qry->uniqueFlag != NULL)
+ if (qry->distinctClause != NIL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with DISTINCT clause");
- if (qry->groupClause != NULL)
+ if (qry->groupClause != NIL)
elog(ERROR, "SELECT FOR UPDATE is not allowed with GROUP BY clause");
if (qry->hasAggs)
elog(ERROR, "SELECT FOR UPDATE is not allowed with AGGREGATE");