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
5529b783
Commit
5529b783
authored
Apr 15, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move HAVING function to proper file.
parent
11c09127
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
111 additions
and
110 deletions
+111
-110
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/planner.c
+1
-107
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/setrefs.c
+108
-1
src/include/optimizer/planmain.h
src/include/optimizer/planmain.h
+2
-2
No files found.
src/backend/optimizer/plan/planner.c
View file @
5529b783
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.2
6 1998/04/13 21:07:09
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.2
7 1998/04/15 15:29:41
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -58,112 +58,6 @@ make_groupPlan(List **tlist, bool tuplePerGroup,
* Query optimizer entry point
*
*****************************************************************************/
static
List
*
check_having_qual_for_aggs
(
Node
*
clause
,
List
*
subplanTargetList
)
{
List
*
t
;
List
*
agg_list
=
NIL
;
if
(
IsA
(
clause
,
Var
))
{
TargetEntry
*
subplanVar
;
/*
* Ha! A Var node!
*/
subplanVar
=
match_varid
((
Var
*
)
clause
,
subplanTargetList
);
/*
* Change the varno & varattno fields of the var node.
*
*/
((
Var
*
)
clause
)
->
varattno
=
subplanVar
->
resdom
->
resno
;
return
NIL
;
}
else
if
(
is_funcclause
(
clause
)
||
not_clause
(
clause
)
||
or_clause
(
clause
)
||
and_clause
(
clause
))
{
/*
* This is a function. Recursively call this routine for its
* arguments...
*/
foreach
(
t
,
((
Expr
*
)
clause
)
->
args
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
return
agg_list
;
}
else
if
(
IsA
(
clause
,
Aggreg
))
{
return
lcons
(
clause
,
check_having_qual_for_aggs
(((
Aggreg
*
)
clause
)
->
target
,
subplanTargetList
));
}
else
if
(
IsA
(
clause
,
ArrayRef
))
{
ArrayRef
*
aref
=
(
ArrayRef
*
)
clause
;
/*
* This is an arrayref. Recursively call this routine for its
* expression and its index expression...
*/
foreach
(
t
,
aref
->
refupperindexpr
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
foreach
(
t
,
aref
->
reflowerindexpr
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
aref
->
refexpr
,
subplanTargetList
));
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
aref
->
refassgnexpr
,
subplanTargetList
));
return
agg_list
;
}
else
if
(
is_opclause
(
clause
))
{
/*
* This is an operator. Recursively call this routine for both its
* left and right operands
*/
Node
*
left
=
(
Node
*
)
get_leftop
((
Expr
*
)
clause
);
Node
*
right
=
(
Node
*
)
get_rightop
((
Expr
*
)
clause
);
if
(
left
!=
(
Node
*
)
NULL
)
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
left
,
subplanTargetList
));
if
(
right
!=
(
Node
*
)
NULL
)
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
right
,
subplanTargetList
));
return
agg_list
;
}
else
if
(
IsA
(
clause
,
Param
)
||
IsA
(
clause
,
Const
))
{
/* do nothing! */
return
NIL
;
}
else
{
/*
* Ooops! we can not handle that!
*/
elog
(
ERROR
,
"check_having_qual_for_aggs: Can not handle this having_qual!
\n
"
);
return
NIL
;
}
}
Plan
*
planner
(
Query
*
parse
)
{
...
...
src/backend/optimizer/plan/setrefs.c
View file @
5529b783
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.2
0 1998/03/30 16:36:1
4 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.2
1 1998/04/15 15:29:4
4 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -934,3 +934,110 @@ del_agg_clause(Node *clause)
}
return
NULL
;
}
List
*
check_having_qual_for_aggs
(
Node
*
clause
,
List
*
subplanTargetList
)
{
List
*
t
;
List
*
agg_list
=
NIL
;
if
(
IsA
(
clause
,
Var
))
{
TargetEntry
*
subplanVar
;
/*
* Ha! A Var node!
*/
subplanVar
=
match_varid
((
Var
*
)
clause
,
subplanTargetList
);
/*
* Change the varno & varattno fields of the var node.
*
*/
((
Var
*
)
clause
)
->
varattno
=
subplanVar
->
resdom
->
resno
;
return
NIL
;
}
else
if
(
is_funcclause
(
clause
)
||
not_clause
(
clause
)
||
or_clause
(
clause
)
||
and_clause
(
clause
))
{
/*
* This is a function. Recursively call this routine for its
* arguments...
*/
foreach
(
t
,
((
Expr
*
)
clause
)
->
args
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
return
agg_list
;
}
else
if
(
IsA
(
clause
,
Aggreg
))
{
return
lcons
(
clause
,
check_having_qual_for_aggs
(((
Aggreg
*
)
clause
)
->
target
,
subplanTargetList
));
}
else
if
(
IsA
(
clause
,
ArrayRef
))
{
ArrayRef
*
aref
=
(
ArrayRef
*
)
clause
;
/*
* This is an arrayref. Recursively call this routine for its
* expression and its index expression...
*/
foreach
(
t
,
aref
->
refupperindexpr
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
foreach
(
t
,
aref
->
reflowerindexpr
)
{
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
lfirst
(
t
),
subplanTargetList
));
}
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
aref
->
refexpr
,
subplanTargetList
));
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
aref
->
refassgnexpr
,
subplanTargetList
));
return
agg_list
;
}
else
if
(
is_opclause
(
clause
))
{
/*
* This is an operator. Recursively call this routine for both its
* left and right operands
*/
Node
*
left
=
(
Node
*
)
get_leftop
((
Expr
*
)
clause
);
Node
*
right
=
(
Node
*
)
get_rightop
((
Expr
*
)
clause
);
if
(
left
!=
(
Node
*
)
NULL
)
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
left
,
subplanTargetList
));
if
(
right
!=
(
Node
*
)
NULL
)
agg_list
=
nconc
(
agg_list
,
check_having_qual_for_aggs
(
right
,
subplanTargetList
));
return
agg_list
;
}
else
if
(
IsA
(
clause
,
Param
)
||
IsA
(
clause
,
Const
))
{
/* do nothing! */
return
NIL
;
}
else
{
/*
* Ooops! we can not handle that!
*/
elog
(
ERROR
,
"check_having_qual_for_aggs: Can not handle this having_qual!
\n
"
);
return
NIL
;
}
}
src/include/optimizer/planmain.h
View file @
5529b783
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: planmain.h,v 1.1
1 1998/02/26 04:42:20
momjian Exp $
* $Id: planmain.h,v 1.1
2 1998/04/15 15:29:57
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -64,6 +64,6 @@ extern void set_result_tlist_references(Result *resultNode);
extern
List
*
set_agg_tlist_references
(
Agg
*
aggNode
);
extern
void
set_agg_agglist_references
(
Agg
*
aggNode
);
extern
void
del_agg_tlist_references
(
List
*
tlist
);
extern
List
*
check_having_qual_for_aggs
(
Node
*
clause
,
List
*
subplanTargetList
);
#endif
/* PLANMAIN_H */
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