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
d404f100
Commit
d404f100
authored
Dec 22, 1997
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for select 1=1 or 2=2, select 1=1 and 2=2, and select sum(2+2).
parent
78a055a6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
69 additions
and
56 deletions
+69
-56
src/backend/commands/defind.c
src/backend/commands/defind.c
+2
-4
src/backend/executor/nodeAgg.c
src/backend/executor/nodeAgg.c
+13
-0
src/backend/optimizer/path/xfunc.c
src/backend/optimizer/path/xfunc.c
+4
-4
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planmain.c
+26
-11
src/backend/optimizer/plan/planner.c
src/backend/optimizer/plan/planner.c
+4
-26
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/setrefs.c
+10
-1
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/clauses.c
+3
-3
src/backend/optimizer/util/var.c
src/backend/optimizer/util/var.c
+3
-3
src/backend/parser/parse_agg.c
src/backend/parser/parse_agg.c
+2
-2
src/backend/parser/parser.c
src/backend/parser/parser.c
+2
-2
No files found.
src/backend/commands/defind.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.1
7 1997/09/18 20:20:20
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.1
8 1997/12/22 05:41:49
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -385,9 +385,7 @@ CheckPredExpr(Node *predicate, List *rangeTable, Oid baseRelOid)
...
@@ -385,9 +385,7 @@ CheckPredExpr(Node *predicate, List *rangeTable, Oid baseRelOid)
CheckPredClause
((
Expr
*
)
predicate
,
rangeTable
,
baseRelOid
);
CheckPredClause
((
Expr
*
)
predicate
,
rangeTable
,
baseRelOid
);
return
;
return
;
}
}
else
if
(
or_clause
(
predicate
))
else
if
(
or_clause
(
predicate
)
||
and_clause
(
predicate
))
clauses
=
((
Expr
*
)
predicate
)
->
args
;
else
if
(
and_clause
(
predicate
))
clauses
=
((
Expr
*
)
predicate
)
->
args
;
clauses
=
((
Expr
*
)
predicate
)
->
args
;
else
else
elog
(
WARN
,
"Unsupported partial-index predicate expression type"
);
elog
(
WARN
,
"Unsupported partial-index predicate expression type"
);
...
...
src/backend/executor/nodeAgg.c
View file @
d404f100
...
@@ -534,6 +534,19 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
...
@@ -534,6 +534,19 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
outerPlan
=
outerPlan
(
node
);
outerPlan
=
outerPlan
(
node
);
ExecInitNode
(
outerPlan
,
estate
,
(
Plan
*
)
node
);
ExecInitNode
(
outerPlan
,
estate
,
(
Plan
*
)
node
);
/*
* Result runs in its own context, but make it use our aggregates
* fix for 'select sum(2+2)'
*/
if
(
nodeTag
(
outerPlan
)
==
T_Result
)
{
((
Result
*
)
outerPlan
)
->
resstate
->
cstate
.
cs_ProjInfo
->
pi_exprContext
->
ecxt_values
=
econtext
->
ecxt_values
;
((
Result
*
)
outerPlan
)
->
resstate
->
cstate
.
cs_ProjInfo
->
pi_exprContext
->
ecxt_nulls
=
econtext
->
ecxt_nulls
;
}
/* ----------------
/* ----------------
* initialize tuple type.
* initialize tuple type.
* ----------------
* ----------------
...
...
src/backend/optimizer/path/xfunc.c
View file @
d404f100
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.
8 1997/12/11 17:36:2
9 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.
9 1997/12/22 05:41:5
9 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -451,7 +451,7 @@ xfunc_local_expense(LispValue clause)
...
@@ -451,7 +451,7 @@ xfunc_local_expense(LispValue clause)
(
LispValue
)
get_funcargs
(
clause
)));
(
LispValue
)
get_funcargs
(
clause
)));
else
if
(
fast_not_clause
(
clause
))
else
if
(
fast_not_clause
(
clause
))
return
(
xfunc_local_expense
(
lsecond
(
clause
)));
return
(
xfunc_local_expense
(
lsecond
(
clause
)));
else
if
(
fast_or_clause
(
clause
))
else
if
(
fast_or_clause
(
clause
)
||
fast_and_clause
(
clause
)
)
{
{
/* find cost of evaluating each disjunct */
/* find cost of evaluating each disjunct */
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
...
@@ -845,7 +845,7 @@ xfunc_find_references(LispValue clause)
...
@@ -845,7 +845,7 @@ xfunc_find_references(LispValue clause)
}
}
else
if
(
fast_not_clause
(
clause
))
else
if
(
fast_not_clause
(
clause
))
return
(
xfunc_find_references
(
lsecond
(
clause
)));
return
(
xfunc_find_references
(
lsecond
(
clause
)));
else
if
(
fast_or_clause
(
clause
))
else
if
(
fast_or_clause
(
clause
)
||
fast_and_clause
(
clause
)
)
{
{
/* string together result of all operands of OR */
/* string together result of all operands of OR */
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
...
@@ -1186,7 +1186,7 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */
...
@@ -1186,7 +1186,7 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */
xfunc_fixvars
(
lfirst
(
tmpclause
),
rel
,
varno
);
xfunc_fixvars
(
lfirst
(
tmpclause
),
rel
,
varno
);
else
if
(
fast_not_clause
(
clause
))
else
if
(
fast_not_clause
(
clause
))
xfunc_fixvars
(
lsecond
(
clause
),
rel
,
varno
);
xfunc_fixvars
(
lsecond
(
clause
),
rel
,
varno
);
else
if
(
fast_or_clause
(
clause
))
else
if
(
fast_or_clause
(
clause
)
||
fast_and_clause
(
clause
)
)
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
for
(
tmpclause
=
lnext
(
clause
);
tmpclause
!=
LispNil
;
tmpclause
=
lnext
(
tmpclause
))
tmpclause
=
lnext
(
tmpclause
))
xfunc_fixvars
(
lfirst
(
tmpclause
),
rel
,
varno
);
xfunc_fixvars
(
lfirst
(
tmpclause
),
rel
,
varno
);
...
...
src/backend/optimizer/plan/planmain.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.1
2 1997/12/20 07:59:25
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.1
3 1997/12/22 05:42:04
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -69,7 +69,7 @@ query_planner(Query *root,
...
@@ -69,7 +69,7 @@ query_planner(Query *root,
List
*
qual
)
List
*
qual
)
{
{
List
*
constant_qual
=
NIL
;
List
*
constant_qual
=
NIL
;
List
*
flattened
_tlist
=
NIL
;
List
*
var_only
_tlist
=
NIL
;
List
*
level_tlist
=
NIL
;
List
*
level_tlist
=
NIL
;
Plan
*
subplan
=
(
Plan
*
)
NULL
;
Plan
*
subplan
=
(
Plan
*
)
NULL
;
...
@@ -109,16 +109,12 @@ query_planner(Query *root,
...
@@ -109,16 +109,12 @@ query_planner(Query *root,
* Create a target list that consists solely of (resdom var) target
* Create a target list that consists solely of (resdom var) target
* list entries, i.e., contains no arbitrary expressions.
* list entries, i.e., contains no arbitrary expressions.
*/
*/
flattened_tlist
=
flatten_tlist
(
tlist
);
var_only_tlist
=
flatten_tlist
(
tlist
);
if
(
flattened_tlist
)
if
(
var_only_tlist
)
{
level_tlist
=
var_only_tlist
;
level_tlist
=
flattened_tlist
;
}
else
else
{
/* from old code. the logic is beyond me. - ay 2/95 */
/* from old code. the logic is beyond me. - ay 2/95 */
level_tlist
=
tlist
;
level_tlist
=
tlist
;
}
/*
/*
* A query may have a non-variable target list and a non-variable
* A query may have a non-variable target list and a non-variable
...
@@ -126,7 +122,7 @@ query_planner(Query *root,
...
@@ -126,7 +122,7 @@ query_planner(Query *root,
* all-new tuples, or - the query is a replace (a scan must still be
* all-new tuples, or - the query is a replace (a scan must still be
* done in this case).
* done in this case).
*/
*/
if
(
flattened
_tlist
==
NULL
&&
qual
==
NULL
)
if
(
var_only
_tlist
==
NULL
&&
qual
==
NULL
)
{
{
switch
(
command_type
)
switch
(
command_type
)
...
@@ -192,11 +188,30 @@ query_planner(Query *root,
...
@@ -192,11 +188,30 @@ query_planner(Query *root,
return
(
plan
);
return
(
plan
);
}
}
/*
* fix up the flattened target list of the plan root node so that
* expressions are evaluated. this forces expression evaluations that
* may involve expensive function calls to be delayed to the very last
* stage of query execution. this could be bad. but it is joey's
* responsibility to optimally push these expressions down the plan
* tree. -- Wei
*
* But now nothing to do if there are GroupBy and/or Aggregates: 1.
* make_groupPlan fixes tlist; 2. flatten_tlist_vars does nothing with
* aggregates fixing only other entries (i.e. - GroupBy-ed and so
* fixed by make_groupPlan). - vadim 04/05/97
*/
if
(
root
->
groupClause
==
NULL
&&
root
->
qry_aggs
==
NULL
)
{
subplan
->
targetlist
=
flatten_tlist_vars
(
tlist
,
subplan
->
targetlist
);
}
#ifdef NOT_USED
/*
/*
* Destructively modify the query plan's targetlist to add fjoin lists
* Destructively modify the query plan's targetlist to add fjoin lists
* to flatten functions that return sets of base types
* to flatten functions that return sets of base types
*/
*/
#ifdef NOT_USED
subplan
->
targetlist
=
generate_fjoin
(
subplan
->
targetlist
);
subplan
->
targetlist
=
generate_fjoin
(
subplan
->
targetlist
);
#endif
#endif
...
...
src/backend/optimizer/plan/planner.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.1
4 1997/12/20 07:59:27
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.1
5 1997/12/22 05:42:08
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -74,7 +74,6 @@ planner(Query *parse)
...
@@ -74,7 +74,6 @@ planner(Query *parse)
List
*
rangetable
=
parse
->
rtable
;
List
*
rangetable
=
parse
->
rtable
;
char
*
uniqueflag
=
parse
->
uniqueFlag
;
char
*
uniqueflag
=
parse
->
uniqueFlag
;
List
*
sortclause
=
parse
->
sortClause
;
List
*
sortclause
=
parse
->
sortClause
;
Agg
*
aggplan
=
NULL
;
Plan
*
result_plan
=
(
Plan
*
)
NULL
;
Plan
*
result_plan
=
(
Plan
*
)
NULL
;
...
@@ -141,7 +140,7 @@ planner(Query *parse)
...
@@ -141,7 +140,7 @@ planner(Query *parse)
*/
*/
if
(
parse
->
qry_aggs
)
if
(
parse
->
qry_aggs
)
{
{
aggplan
=
make_agg
(
tlist
,
result_plan
=
(
Plan
*
)
make_agg
(
tlist
,
parse
->
qry_numAgg
,
parse
->
qry_numAgg
,
parse
->
qry_aggs
,
parse
->
qry_aggs
,
result_plan
);
result_plan
);
...
@@ -153,29 +152,8 @@ planner(Query *parse)
...
@@ -153,29 +152,8 @@ planner(Query *parse)
* pointers, after a few dozen's of copying, they're not the same
* pointers, after a few dozen's of copying, they're not the same
* as those in the target list.)
* as those in the target list.)
*/
*/
set_agg_tlist_references
(
aggplan
);
set_agg_tlist_references
((
Agg
*
)
result_plan
);
set_agg_agglist_references
(
aggplan
);
set_agg_agglist_references
((
Agg
*
)
result_plan
);
result_plan
=
(
Plan
*
)
aggplan
;
}
/*
* fix up the flattened target list of the plan root node so that
* expressions are evaluated. this forces expression evaluations that
* may involve expensive function calls to be delayed to the very last
* stage of query execution. this could be bad. but it is joey's
* responsibility to optimally push these expressions down the plan
* tree. -- Wei
*
* But now nothing to do if there are GroupBy and/or Aggregates: 1.
* make_groupPlan fixes tlist; 2. flatten_tlist_vars does nothing with
* aggregates fixing only other entries (i.e. - GroupBy-ed and so
* fixed by make_groupPlan). - vadim 04/05/97
*/
if
(
parse
->
groupClause
==
NULL
&&
aggplan
==
NULL
)
{
result_plan
->
targetlist
=
flatten_tlist_vars
(
tlist
,
result_plan
->
targetlist
);
}
}
/*
/*
...
...
src/backend/optimizer/plan/setrefs.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.
9 1997/12/20 07:59:28
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.
10 1997/12/22 05:42:10
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -329,6 +329,15 @@ replace_clause_joinvar_refs(Expr *clause,
...
@@ -329,6 +329,15 @@ replace_clause_joinvar_refs(Expr *clause,
{
{
return
((
List
*
)
clause
);
return
((
List
*
)
clause
);
}
}
else
if
(
and_clause
((
Node
*
)
clause
))
{
List
*
andclause
=
replace_subclause_joinvar_refs
(((
Expr
*
)
clause
)
->
args
,
outer_tlist
,
inner_tlist
);
return
((
List
*
)
make_andclause
(
andclause
));
}
else
if
(
or_clause
((
Node
*
)
clause
))
else
if
(
or_clause
((
Node
*
)
clause
))
{
{
List
*
orclause
=
List
*
orclause
=
...
...
src/backend/optimizer/util/clauses.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.1
2 1997/09/25 12:48:15 vadim
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.1
3 1997/12/22 05:42:14 momjian
Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -431,7 +431,7 @@ contains_not(Node *clause)
...
@@ -431,7 +431,7 @@ contains_not(Node *clause)
if
(
not_clause
(
clause
))
if
(
not_clause
(
clause
))
return
(
true
);
return
(
true
);
if
(
or_clause
(
clause
))
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
List
*
a
;
List
*
a
;
...
@@ -518,7 +518,7 @@ fix_opid(Node *clause)
...
@@ -518,7 +518,7 @@ fix_opid(Node *clause)
{
{
;
;
}
}
else
if
(
or_clause
(
clause
))
else
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
fix_opids
(((
Expr
*
)
clause
)
->
args
);
fix_opids
(((
Expr
*
)
clause
)
->
args
);
}
}
...
...
src/backend/optimizer/util/var.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.
6 1997/09/08 21:45:5
6 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.
7 1997/12/22 05:42:1
6 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -85,7 +85,7 @@ contain_var_clause(Node *clause)
...
@@ -85,7 +85,7 @@ contain_var_clause(Node *clause)
return
contain_var_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
return
contain_var_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
else
if
(
single_node
(
clause
))
else
if
(
single_node
(
clause
))
return
FALSE
;
return
FALSE
;
else
if
(
or_clause
(
clause
))
else
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
List
*
temp
;
List
*
temp
;
...
@@ -156,7 +156,7 @@ pull_var_clause(Node *clause)
...
@@ -156,7 +156,7 @@ pull_var_clause(Node *clause)
retval
=
pull_var_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
retval
=
pull_var_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
else
if
(
single_node
(
clause
))
else
if
(
single_node
(
clause
))
retval
=
NIL
;
retval
=
NIL
;
else
if
(
or_clause
(
clause
))
else
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
List
*
temp
;
List
*
temp
;
...
...
src/backend/parser/parse_agg.c
View file @
d404f100
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.
3 1997/11/26 03:42:37
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_agg.c,v 1.
4 1997/12/22 05:42:19
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -108,7 +108,7 @@ contain_agg_clause(Node *clause)
...
@@ -108,7 +108,7 @@ contain_agg_clause(Node *clause)
return
contain_agg_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
return
contain_agg_clause
(((
Iter
*
)
clause
)
->
iterexpr
);
else
if
(
single_node
(
clause
))
else
if
(
single_node
(
clause
))
return
FALSE
;
return
FALSE
;
else
if
(
or_clause
(
clause
))
else
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
List
*
temp
;
List
*
temp
;
...
...
src/backend/parser/parser.c
View file @
d404f100
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.3
0 1997/11/26 01:11:36
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.3
1 1997/12/22 05:42:25
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -141,7 +141,7 @@ define_sets(Node *clause)
...
@@ -141,7 +141,7 @@ define_sets(Node *clause)
{
{
return
;
return
;
}
}
else
if
(
or_clause
(
clause
))
else
if
(
or_clause
(
clause
)
||
and_clause
(
clause
)
)
{
{
List
*
temp
;
List
*
temp
;
...
...
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