Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
postgres-lambda-diff
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakob Huber
postgres-lambda-diff
Commits
5529b783
Commit
5529b783
authored
26 years ago
by
Bruce Momjian
Browse files
Options
Downloads
Patches
Plain Diff
Move HAVING function to proper file.
parent
11c09127
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/backend/optimizer/plan/planner.c
+1
-107
1 addition, 107 deletions
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/setrefs.c
+108
-1
108 additions, 1 deletion
src/backend/optimizer/plan/setrefs.c
src/include/optimizer/planmain.h
+2
-2
2 additions, 2 deletions
src/include/optimizer/planmain.h
with
111 additions
and
110 deletions
src/backend/optimizer/plan/planner.c
+
1
−
107
View file @
5529b783
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.2
6
1998/04/1
3 21:07:09
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.2
7
1998/04/1
5 15:29:41
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -58,112 +58,6 @@ make_groupPlan(List **tlist, bool tuplePerGroup,
...
@@ -58,112 +58,6 @@ make_groupPlan(List **tlist, bool tuplePerGroup,
* Query optimizer entry point
* 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
*
Plan
*
planner
(
Query
*
parse
)
planner
(
Query
*
parse
)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/backend/optimizer/plan/setrefs.c
+
108
−
1
View file @
5529b783
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.2
0
1998/0
3/30 16:36:1
4 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.2
1
1998/0
4/15 15:29:4
4 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -934,3 +934,110 @@ del_agg_clause(Node *clause)
...
@@ -934,3 +934,110 @@ del_agg_clause(Node *clause)
}
}
return
NULL
;
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
;
}
}
This diff is collapsed.
Click to expand it.
src/include/optimizer/planmain.h
+
2
−
2
View file @
5529b783
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: planmain.h,v 1.1
1
1998/0
2/26 04:42:20
momjian Exp $
* $Id: planmain.h,v 1.1
2
1998/0
4/15 15:29:57
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -64,6 +64,6 @@ extern void set_result_tlist_references(Result *resultNode);
...
@@ -64,6 +64,6 @@ extern void set_result_tlist_references(Result *resultNode);
extern
List
*
set_agg_tlist_references
(
Agg
*
aggNode
);
extern
List
*
set_agg_tlist_references
(
Agg
*
aggNode
);
extern
void
set_agg_agglist_references
(
Agg
*
aggNode
);
extern
void
set_agg_agglist_references
(
Agg
*
aggNode
);
extern
void
del_agg_tlist_references
(
List
*
tlist
);
extern
void
del_agg_tlist_references
(
List
*
tlist
);
extern
List
*
check_having_qual_for_aggs
(
Node
*
clause
,
List
*
subplanTargetList
);
#endif
/* PLANMAIN_H */
#endif
/* PLANMAIN_H */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment