Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
cc11cfdd
Commit
cc11cfdd
authored
Apr 05, 1997
by
Vadim B. Mikheev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Now we can GROUP BY func_results.
parent
803a2b13
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
8 deletions
+44
-8
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+44
-8
No files found.
src/backend/parser/analyze.c
View file @
cc11cfdd
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.2
4 1997/04/02 04:00:55
vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.2
5 1997/04/05 06:29:03
vadim Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1545,17 +1545,17 @@ transformGroupClause(ParseState *pstate, List *grouplist, List *targetlist)
while
(
grouplist
!=
NIL
)
{
GroupClause
*
grpcl
=
makeNode
(
GroupClause
);
TargetEntry
*
restarget
;
Resdom
*
resdom
;
restarget
=
find_targetlist_entry
(
pstate
,
lfirst
(
grouplist
),
targetlist
);
if
(
restarget
==
NULL
)
elog
(
WARN
,
"The field being grouped by must appear in the target list"
);
if
(
nodeTag
(
restarget
->
expr
)
!=
T_Var
)
{
elog
(
WARN
,
"parser: can only specify attribute in group by"
);
}
grpcl
->
grpAttr
=
(
Var
*
)
restarget
->
expr
;
grpcl
->
grpOpoid
=
any_ordering_op
(
grpcl
->
grpAttr
->
vartype
);
grpcl
->
resdom
=
resdom
=
restarget
->
resdom
;
grpcl
->
grpOpoid
=
oprid
(
oper
(
"<"
,
resdom
->
restype
,
resdom
->
restype
,
false
));
if
(
glist
==
NIL
)
gl
=
glist
=
lcons
(
grpcl
,
NIL
);
else
{
...
...
@@ -2359,6 +2359,38 @@ contain_agg_clause(Node *clause)
return
FALSE
;
}
/*
* tleIsAggOrGroupCol -
* returns true if the TargetEntry is Agg or GroupCol.
*/
static
bool
tleIsAggOrGroupCol
(
TargetEntry
*
tle
,
List
*
groupClause
)
{
Node
*
expr
=
tle
->
expr
;
List
*
gl
;
if
(
expr
==
NULL
||
IsA
(
expr
,
Const
)
)
return
TRUE
;
foreach
(
gl
,
groupClause
)
{
GroupClause
*
grpcl
=
lfirst
(
gl
);
if
(
tle
->
resdom
->
resno
==
grpcl
->
resdom
->
resno
)
{
if
(
IsA
(
expr
,
Aggreg
)
)
elog
(
WARN
,
"parser: aggregates not allowed in GROUP BY clause"
);
return
TRUE
;
}
}
if
(
IsA
(
expr
,
Aggreg
)
)
return
TRUE
;
return
FALSE
;
}
#if 0 /* Now GroupBy contains resdom to enable Group By func_results */
/*
* exprIsAggOrGroupCol -
* returns true if the expression does not contain non-group columns.
...
...
@@ -2398,6 +2430,7 @@ exprIsAggOrGroupCol(Node *expr, List *groupClause)
return FALSE;
}
#endif
/*
* parseCheckAggregates -
...
...
@@ -2425,7 +2458,7 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
*/
foreach
(
tl
,
qry
->
targetList
)
{
TargetEntry
*
tle
=
lfirst
(
tl
);
if
(
!
exprIsAggOrGroupCol
(
tle
->
expr
,
qry
->
groupClause
))
if
(
!
tleIsAggOrGroupCol
(
tle
,
qry
->
groupClause
))
elog
(
WARN
,
"parser: illegal use of aggregates or non-group column in target list"
);
}
...
...
@@ -2434,9 +2467,12 @@ parseCheckAggregates(ParseState *pstate, Query *qry)
* the expression specified in the HAVING clause has the same restriction
* as those in the target list.
*/
/*
* Need to change here when we get HAVING works. Currently
* qry->havingQual is NULL. - vadim 04/05/97
if (!exprIsAggOrGroupCol(qry->havingQual, qry->groupClause))
elog(WARN,
"parser: illegal use of aggregates or non-group column in HAVING clause");
*/
return
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment