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
2d32d909
Commit
2d32d909
authored
Aug 10, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup optimizer function names and clarify code.
parent
addddea3
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
130 additions
and
112 deletions
+130
-112
src/backend/optimizer/README
src/backend/optimizer/README
+24
-1
src/backend/optimizer/geqo/geqo_eval.c
src/backend/optimizer/geqo/geqo_eval.c
+11
-11
src/backend/optimizer/geqo/geqo_main.c
src/backend/optimizer/geqo/geqo_main.c
+2
-2
src/backend/optimizer/geqo/minspantree.c
src/backend/optimizer/geqo/minspantree.c
+2
-2
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/allpaths.c
+7
-8
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/indxpath.c
+4
-4
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/joinrels.c
+2
-2
src/backend/optimizer/path/xfunc.c
src/backend/optimizer/path/xfunc.c
+2
-2
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/initsplan.c
+35
-37
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planmain.c
+20
-20
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/clauses.c
+4
-4
src/backend/optimizer/util/joininfo.c
src/backend/optimizer/util/joininfo.c
+2
-2
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/relnode.c
+4
-6
src/backend/parser/gram.c
src/backend/parser/gram.c
+1
-1
src/include/nodes/parsenodes.h
src/include/nodes/parsenodes.h
+3
-3
src/include/optimizer/clauses.h
src/include/optimizer/clauses.h
+2
-2
src/include/optimizer/planmain.h
src/include/optimizer/planmain.h
+5
-5
No files found.
src/backend/optimizer/README
View file @
2d32d909
...
@@ -9,13 +9,36 @@ planner()
...
@@ -9,13 +9,36 @@ planner()
preprocess target list
preprocess target list
preprocess qualifications(WHERE)
preprocess qualifications(WHERE)
--query_planner()
--query_planner()
cnfify qualification, so qual are expressions (were AND's) and OR clauses
cnfify()
Summary:
Simple cases with all AND's are handled by removing the AND's:
convert: a = 1 AND b = 2 AND c = 3
to: a = 1, b = 2, c = 3
Qualifications with OR's are handled differently. OR's inside AND
clauses are not modified drastically:
convert: a = 1 AND b = 2 AND (c = 3 OR d = 4)
to: a = 1, b = 2, c = 3 OR d = 4
OR's in the upper level are more complex to handle:
convert: (a = 1 AND b = 2) OR c = 3
to: (a = 1 OR c = 3) AND (b = 2 OR c = 3)
finally: (a = 1 OR c = 3), (b = 2 OR c = 3)
These clauses all have to be true for a result to be returned,
so the optimizer can choose the most restrictive clauses.
pull out constants from target list
pull out constants from target list
get a target list that only contains column names, no expressions
get a target list that only contains column names, no expressions
if none, then return
if none, then return
---subplanner()
---subplanner()
make list of relations in target
make list of relations in target
make list of relations in where clause
make list of relations in where clause
split up the qual into restrictions (a=1) and joins (b=c)
find which relations can do merge sort and hash joins
find which relations can do merge sort and hash joins
----find_paths()
----find_paths()
find scan and all index paths for each relation not yet joined
find scan and all index paths for each relation not yet joined
...
...
src/backend/optimizer/geqo/geqo_eval.c
View file @
2d32d909
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
*
*
* Copyright (c) 1994, Regents of the University of California
* Copyright (c) 1994, Regents of the University of California
*
*
* $Id: geqo_eval.c,v 1.2
1 1998/08/04 16:44:02
momjian Exp $
* $Id: geqo_eval.c,v 1.2
2 1998/08/10 02:26:16
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -71,9 +71,9 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
...
@@ -71,9 +71,9 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
List
*
temp
;
List
*
temp
;
/* remember root->join_rel
ation_list_
... */
/* remember root->join_rel
_list
... */
/* because root->join_rel
ation_list_
will be changed during the following */
/* because root->join_rel
_list
will be changed during the following */
temp
=
listCopy
(
root
->
join_rel
ation_list_
);
temp
=
listCopy
(
root
->
join_rel
_list
);
/* joinrel is readily processed query tree -- left-sided ! */
/* joinrel is readily processed query tree -- left-sided ! */
joinrel
=
gimme_tree
(
root
,
tour
,
0
,
num_gene
,
NULL
);
joinrel
=
gimme_tree
(
root
,
tour
,
0
,
num_gene
,
NULL
);
...
@@ -81,7 +81,7 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
...
@@ -81,7 +81,7 @@ geqo_eval(Query *root, Gene *tour, int num_gene)
/* compute fitness */
/* compute fitness */
fitness
=
(
Cost
)
joinrel
->
cheapestpath
->
path_cost
;
fitness
=
(
Cost
)
joinrel
->
cheapestpath
->
path_cost
;
root
->
join_rel
ation_list_
=
listCopy
(
temp
);
root
->
join_rel
_list
=
listCopy
(
temp
);
pfree
(
joinrel
);
pfree
(
joinrel
);
freeList
(
temp
);
freeList
(
temp
);
...
@@ -113,7 +113,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
...
@@ -113,7 +113,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
/* tour[0] = 3; tour[1] = 1; tour[2] = 2 */
base_rel_index
=
(
int
)
tour
[
rel_count
];
base_rel_index
=
(
int
)
tour
[
rel_count
];
inner_rel
=
(
RelOptInfo
*
)
geqo_nth
(
base_rel_index
,
root
->
base_rel
ation_list_
);
inner_rel
=
(
RelOptInfo
*
)
geqo_nth
(
base_rel_index
,
root
->
base_rel
_list
);
if
(
rel_count
==
0
)
if
(
rel_count
==
0
)
{
/* processing first join with
{
/* processing first join with
...
@@ -169,7 +169,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
...
@@ -169,7 +169,7 @@ gimme_tree(Query *root, Gene *tour, int rel_count, int num_gene, RelOptInfo *out
new_rel
->
size
=
compute_rel_size
(
new_rel
);
new_rel
->
size
=
compute_rel_size
(
new_rel
);
new_rel
->
width
=
compute_rel_width
(
new_rel
);
new_rel
->
width
=
compute_rel_width
(
new_rel
);
root
->
join_rel
ation_list_
=
lcons
(
new_rel
,
NIL
);
root
->
join_rel
_list
=
lcons
(
new_rel
,
NIL
);
return
gimme_tree
(
root
,
tour
,
rel_count
,
num_gene
,
new_rel
);
return
gimme_tree
(
root
,
tour
,
rel_count
,
num_gene
,
new_rel
);
}
}
...
@@ -482,7 +482,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
...
@@ -482,7 +482,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
*/
*/
/*
/*
* if ( (root->join_rel
ation_list_
) != NIL ) { rel =
* if ( (root->join_rel
_list
) != NIL ) { rel =
* get_join_rel(root, xrelid); } else { rel =
* get_join_rel(root, xrelid); } else { rel =
* get_base_rel(root, lfirsti(xrelid)); }
* get_base_rel(root, lfirsti(xrelid)); }
*/
*/
...
@@ -495,7 +495,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
...
@@ -495,7 +495,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
*/
*/
relids
=
lconsi
(
lfirsti
(
xrelid
),
NIL
);
relids
=
lconsi
(
lfirsti
(
xrelid
),
NIL
);
rel
=
rel_member
(
relids
,
root
->
base_rel
ation_list_
);
rel
=
rel_member
(
relids
,
root
->
base_rel
_list
);
add_superrels
(
rel
,
joinrel
);
add_superrels
(
rel
,
joinrel
);
}
}
...
@@ -521,7 +521,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
...
@@ -521,7 +521,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
*/
*/
/*
/*
* if ( (root->join_rel
ation_list_
) != NIL ) { rel =
* if ( (root->join_rel
_list
) != NIL ) { rel =
* get_join_rel(root, xrelid); } else { rel =
* get_join_rel(root, xrelid); } else { rel =
* get_base_rel(root, lfirsti(xrelid)); }
* get_base_rel(root, lfirsti(xrelid)); }
*/
*/
...
@@ -534,7 +534,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
...
@@ -534,7 +534,7 @@ geqo_add_new_joininfos(Query *root, List *joinrels, List *outerrels)
*/
*/
relids
=
lconsi
(
lfirsti
(
xrelid
),
NIL
);
relids
=
lconsi
(
lfirsti
(
xrelid
),
NIL
);
rel
=
rel_member
(
relids
,
root
->
base_rel
ation_list_
);
rel
=
rel_member
(
relids
,
root
->
base_rel
_list
);
super_rels
=
rel
->
superrels
;
super_rels
=
rel
->
superrels
;
new_joininfo
=
makeNode
(
JInfo
);
new_joininfo
=
makeNode
(
JInfo
);
...
...
src/backend/optimizer/geqo/geqo_main.c
View file @
2d32d909
...
@@ -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: geqo_main.c,v 1.
8 1998/07/18 04:22:2
7 momjian Exp $
* $Id: geqo_main.c,v 1.
9 1998/08/10 02:26:1
7 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -104,7 +104,7 @@ geqo(Query *root)
...
@@ -104,7 +104,7 @@ geqo(Query *root)
/* set tour size */
/* set tour size */
number_of_rels
=
length
(
root
->
base_rel
ation_list_
);
number_of_rels
=
length
(
root
->
base_rel
_list
);
/* set GA parameters */
/* set GA parameters */
geqo_params
(
number_of_rels
);
/* out of "$PGDATA/pg_geqo" file */
geqo_params
(
number_of_rels
);
/* out of "$PGDATA/pg_geqo" file */
...
...
src/backend/optimizer/geqo/minspantree.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.
6 1998/07/18 04:22:2
9 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.
7 1998/08/10 02:26:1
9 momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
void
void
minspantree
(
Query
*
root
,
List
*
join_rels
,
RelOptInfo
*
garel
)
minspantree
(
Query
*
root
,
List
*
join_rels
,
RelOptInfo
*
garel
)
{
{
int
number_of_rels
=
length
(
root
->
base_rel
ation_list_
);
int
number_of_rels
=
length
(
root
->
base_rel
_list
);
int
number_of_joins
=
length
(
join_rels
);
int
number_of_joins
=
length
(
join_rels
);
int
*
connectto
;
int
*
connectto
;
...
...
src/backend/optimizer/path/allpaths.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.
19 1998/08/07 05:02:15
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.
20 1998/08/10 02:26:20
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,7 +45,9 @@ int32 _use_geqo_rels_ = GEQO_RELS;
...
@@ -45,7 +45,9 @@ int32 _use_geqo_rels_ = GEQO_RELS;
static
void
find_rel_paths
(
Query
*
root
,
List
*
rels
);
static
void
find_rel_paths
(
Query
*
root
,
List
*
rels
);
static
List
*
find_join_paths
(
Query
*
root
,
List
*
outer_rels
,
int
levels_needed
);
static
List
*
find_join_paths
(
Query
*
root
,
List
*
outer_rels
,
int
levels_needed
);
#ifdef OPTIMIZER_DEBUG
static
void
debug_print_rel
(
Query
*
root
,
RelOptInfo
*
rel
);
static
void
debug_print_rel
(
Query
*
root
,
RelOptInfo
*
rel
);
#endif
/*
/*
* find-paths--
* find-paths--
...
@@ -74,7 +76,6 @@ find_paths(Query *root, List *rels)
...
@@ -74,7 +76,6 @@ find_paths(Query *root, List *rels)
if
(
levels_needed
<=
1
)
if
(
levels_needed
<=
1
)
{
{
/*
/*
* Unsorted single relation, no more processing is required.
* Unsorted single relation, no more processing is required.
*/
*/
...
@@ -82,7 +83,6 @@ find_paths(Query *root, List *rels)
...
@@ -82,7 +83,6 @@ find_paths(Query *root, List *rels)
}
}
else
else
{
{
/*
/*
* this means that joins or sorts are required. set selectivities
* this means that joins or sorts are required. set selectivities
* of clauses that have not been set by an index.
* of clauses that have not been set by an index.
...
@@ -115,8 +115,7 @@ find_rel_paths(Query *root, List *rels)
...
@@ -115,8 +115,7 @@ find_rel_paths(Query *root, List *rels)
List
*
or_index_scan_list
;
List
*
or_index_scan_list
;
RelOptInfo
*
rel
=
(
RelOptInfo
*
)
lfirst
(
temp
);
RelOptInfo
*
rel
=
(
RelOptInfo
*
)
lfirst
(
temp
);
sequential_scan_list
=
lcons
(
create_seqscan_path
(
rel
),
sequential_scan_list
=
lcons
(
create_seqscan_path
(
rel
),
NIL
);
NIL
);
rel_index_scan_list
=
rel_index_scan_list
=
find_index_paths
(
root
,
find_index_paths
(
root
,
...
@@ -181,7 +180,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
...
@@ -181,7 +180,7 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
* <utesch@aut.tu-freiberg.de> *
* <utesch@aut.tu-freiberg.de> *
*******************************************/
*******************************************/
if
((
_use_geqo_
)
&&
length
(
root
->
base_rel
ation_list_
)
>=
_use_geqo_rels_
)
if
((
_use_geqo_
)
&&
length
(
root
->
base_rel
_list
)
>=
_use_geqo_rels_
)
return
lcons
(
geqo
(
root
),
NIL
);
/* returns *one* RelOptInfo, so lcons it */
return
lcons
(
geqo
(
root
),
NIL
);
/* returns *one* RelOptInfo, so lcons it */
/*******************************************
/*******************************************
...
@@ -255,10 +254,10 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
...
@@ -255,10 +254,10 @@ find_join_paths(Query *root, List *outer_rels, int levels_needed)
* merge join rels if then contain the same list of base rels
* merge join rels if then contain the same list of base rels
*/
*/
outer_rels
=
merge_joinrels
(
new_rels
,
outer_rels
);
outer_rels
=
merge_joinrels
(
new_rels
,
outer_rels
);
root
->
join_rel
ation_list_
=
outer_rels
;
root
->
join_rel
_list
=
outer_rels
;
}
}
else
else
root
->
join_rel
ation_list_
=
new_rels
;
root
->
join_rel
_list
=
new_rels
;
if
(
!
BushyPlanFlag
)
if
(
!
BushyPlanFlag
)
outer_rels
=
new_rels
;
outer_rels
=
new_rels
;
}
}
...
...
src/backend/optimizer/path/indxpath.c
View file @
2d32d909
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.2
5 1998/08/04 16:44:06
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.2
6 1998/08/10 02:26:22
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -662,7 +662,7 @@ match_clause_to_indexkey(RelOptInfo *rel,
...
@@ -662,7 +662,7 @@ match_clause_to_indexkey(RelOptInfo *rel,
join_op
=
((
Oper
*
)
((
Expr
*
)
clause
)
->
oper
)
->
opno
;
join_op
=
((
Oper
*
)
((
Expr
*
)
clause
)
->
oper
)
->
opno
;
if
(
join_op
&&
op_class
(
join_op
,
xclass
,
index
->
relam
)
&&
if
(
join_op
&&
op_class
(
join_op
,
xclass
,
index
->
relam
)
&&
join_clause_p
((
Node
*
)
clause
))
is_joinable
((
Node
*
)
clause
))
{
{
isIndexable
=
true
;
isIndexable
=
true
;
...
@@ -1153,7 +1153,7 @@ extract_restrict_clauses(List *clausegroup)
...
@@ -1153,7 +1153,7 @@ extract_restrict_clauses(List *clausegroup)
{
{
CInfo
*
cinfo
=
lfirst
(
l
);
CInfo
*
cinfo
=
lfirst
(
l
);
if
(
!
join_clause_p
((
Node
*
)
cinfo
->
clause
))
if
(
!
is_joinable
((
Node
*
)
cinfo
->
clause
))
restrict_cls
=
lappend
(
restrict_cls
,
cinfo
);
restrict_cls
=
lappend
(
restrict_cls
,
cinfo
);
}
}
return
restrict_cls
;
return
restrict_cls
;
...
@@ -1282,7 +1282,7 @@ create_index_paths(Query *root,
...
@@ -1282,7 +1282,7 @@ create_index_paths(Query *root,
foreach
(
j
,
clausegroup
)
foreach
(
j
,
clausegroup
)
{
{
clauseinfo
=
(
CInfo
*
)
lfirst
(
j
);
clauseinfo
=
(
CInfo
*
)
lfirst
(
j
);
if
(
!
(
join_clause_p
((
Node
*
)
clauseinfo
->
clause
)
&&
if
(
!
(
is_joinable
((
Node
*
)
clauseinfo
->
clause
)
&&
equal_path_merge_ordering
(
index
->
ordering
,
equal_path_merge_ordering
(
index
->
ordering
,
clauseinfo
->
mergejoinorder
)))
clauseinfo
->
mergejoinorder
)))
temp
=
false
;
temp
=
false
;
...
...
src/backend/optimizer/path/joinrels.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.1
2 1998/08/04 16:44:08
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.1
3 1998/08/10 02:26:24
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -74,7 +74,7 @@ find_join_rels(Query *root, List *outer_rels)
...
@@ -74,7 +74,7 @@ find_join_rels(Query *root, List *outer_rels)
if
(
BushyPlanFlag
)
if
(
BushyPlanFlag
)
joins
=
find_clauseless_joins
(
outer_rel
,
outer_rels
);
joins
=
find_clauseless_joins
(
outer_rel
,
outer_rels
);
else
else
joins
=
find_clauseless_joins
(
outer_rel
,
root
->
base_rel
ation_list_
);
joins
=
find_clauseless_joins
(
outer_rel
,
root
->
base_rel
_list
);
}
}
join_list
=
nconc
(
join_list
,
joins
);
join_list
=
nconc
(
join_list
,
joins
);
...
...
src/backend/optimizer/path/xfunc.c
View file @
2d32d909
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.1
7 1998/08/04 16:44:11
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.1
8 1998/08/10 02:26:25
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -734,7 +734,7 @@ xfunc_card_unreferenced(Query *queryInfo,
...
@@ -734,7 +734,7 @@ xfunc_card_unreferenced(Query *queryInfo,
LispValue
temp
;
LispValue
temp
;
/* find all relids of base relations referenced in query */
/* find all relids of base relations referenced in query */
foreach
(
temp
,
queryInfo
->
base_rel
ation_list_
)
foreach
(
temp
,
queryInfo
->
base_rel
_list
)
{
{
Assert
(
lnext
(
get_relids
((
RelOptInfo
)
lfirst
(
temp
)))
==
LispNil
);
Assert
(
lnext
(
get_relids
((
RelOptInfo
)
lfirst
(
temp
)))
==
LispNil
);
allrelids
=
lappend
(
allrelids
,
allrelids
=
lappend
(
allrelids
,
...
...
src/backend/optimizer/plan/initsplan.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.1
7 1998/08/09 04:59:03
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.1
8 1998/08/10 02:26:26
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -21,6 +21,10 @@
...
@@ -21,6 +21,10 @@
#include "nodes/relation.h"
#include "nodes/relation.h"
#include "nodes/makefuncs.h"
#include "nodes/makefuncs.h"
#include "access/htup.h"
#include "catalog/pg_type.h"
#include "utils/lsyscache.h"
#include "utils/lsyscache.h"
#include "utils/palloc.h"
#include "utils/palloc.h"
...
@@ -36,9 +40,9 @@
...
@@ -36,9 +40,9 @@
extern
int
Quiet
;
extern
int
Quiet
;
static
void
add_clause_to_rels
(
Query
*
root
,
List
*
clause
);
static
void
add_clause_to_rels
(
Query
*
root
,
List
*
clause
);
static
void
add_join_
clause_
info_to_rels
(
Query
*
root
,
CInfo
*
clauseinfo
,
static
void
add_join_info_to_rels
(
Query
*
root
,
CInfo
*
clauseinfo
,
List
*
join_relids
);
List
*
join_relids
);
static
void
add_vars_to_
rels
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
);
static
void
add_vars_to_
targetlist
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
);
static
MergeOrder
*
mergejoinop
(
Expr
*
clause
);
static
MergeOrder
*
mergejoinop
(
Expr
*
clause
);
static
Oid
hashjoinop
(
Expr
*
clause
);
static
Oid
hashjoinop
(
Expr
*
clause
);
...
@@ -51,7 +55,7 @@ static Oid hashjoinop(Expr *clause);
...
@@ -51,7 +55,7 @@ static Oid hashjoinop(Expr *clause);
*****************************************************************************/
*****************************************************************************/
/*
/*
* init
ialize_rel_nodes
--
* init
-base-rel-tlist
--
* Creates rel nodes for every relation mentioned in the target list
* Creates rel nodes for every relation mentioned in the target list
* 'tlist' (if a node hasn't already been created) and adds them to
* 'tlist' (if a node hasn't already been created) and adds them to
* *query-relation-list*. Creates targetlist entries for each member of
* *query-relation-list*. Creates targetlist entries for each member of
...
@@ -60,7 +64,7 @@ static Oid hashjoinop(Expr *clause);
...
@@ -60,7 +64,7 @@ static Oid hashjoinop(Expr *clause);
* Returns nothing.
* Returns nothing.
*/
*/
void
void
init
ialize_base_rels_
list
(
Query
*
root
,
List
*
tlist
)
init
_base_rels_t
list
(
Query
*
root
,
List
*
tlist
)
{
{
List
*
tlist_vars
=
NIL
;
List
*
tlist_vars
=
NIL
;
List
*
l
=
NIL
;
List
*
l
=
NIL
;
...
@@ -78,7 +82,7 @@ initialize_base_rels_list(Query *root, List *tlist)
...
@@ -78,7 +82,7 @@ initialize_base_rels_list(Query *root, List *tlist)
{
{
Var
*
var
;
Var
*
var
;
Index
varno
;
Index
varno
;
RelOptInfo
*
result
;
RelOptInfo
*
result
;
var
=
(
Var
*
)
lfirst
(
tvar
);
var
=
(
Var
*
)
lfirst
(
tvar
);
varno
=
var
->
varno
;
varno
=
var
->
varno
;
...
@@ -89,7 +93,7 @@ initialize_base_rels_list(Query *root, List *tlist)
...
@@ -89,7 +93,7 @@ initialize_base_rels_list(Query *root, List *tlist)
}
}
/*
/*
* add_missing
_variables_to_base_rels
-
* add_missing
-vars-to-tlist-
-
* If we have range variable(s) in the FROM clause that does not appear
* If we have range variable(s) in the FROM clause that does not appear
* in the target list nor qualifications, we add it to the base relation
* in the target list nor qualifications, we add it to the base relation
* list. For instance, "select f.x from foo f, foo f2" is a join of f and
* list. For instance, "select f.x from foo f, foo f2" is a join of f and
...
@@ -97,7 +101,7 @@ initialize_base_rels_list(Query *root, List *tlist)
...
@@ -97,7 +101,7 @@ initialize_base_rels_list(Query *root, List *tlist)
* into a join.
* into a join.
*/
*/
void
void
add_missing_vars_to_
base_rels
(
Query
*
root
,
List
*
tlist
)
add_missing_vars_to_
tlist
(
Query
*
root
,
List
*
tlist
)
{
{
List
*
l
;
List
*
l
;
int
varno
;
int
varno
;
...
@@ -107,16 +111,15 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
...
@@ -107,16 +111,15 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
{
{
RangeTblEntry
*
rte
=
(
RangeTblEntry
*
)
lfirst
(
l
);
RangeTblEntry
*
rte
=
(
RangeTblEntry
*
)
lfirst
(
l
);
List
*
relids
;
List
*
relids
;
RelOptInfo
*
result
;
RelOptInfo
*
result
;
Var
*
var
;
Var
*
var
;
relids
=
lconsi
(
varno
,
NIL
);
relids
=
lconsi
(
varno
,
NIL
);
if
(
rte
->
inFromCl
&&
if
(
rte
->
inFromCl
&&
!
rel_member
(
relids
,
root
->
base_rel_list
))
!
rel_member
(
relids
,
root
->
base_relation_list_
))
{
{
var
=
makeVar
(
varno
,
ObjectIdAttributeNumber
,
var
=
makeVar
(
varno
,
-
2
,
26
,
-
1
,
0
,
varno
,
-
2
);
OIDOID
,
-
1
,
0
,
varno
,
ObjectIdAttributeNumber
);
/* add it to base_rel
ation_list_
*/
/* add it to base_rel
_list
*/
result
=
get_base_rel
(
root
,
varno
);
result
=
get_base_rel
(
root
,
varno
);
add_tl_element
(
result
,
var
);
add_tl_element
(
result
,
var
);
}
}
...
@@ -136,7 +139,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
...
@@ -136,7 +139,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
/*
/*
* init
ialize-qualification
--
* init
-base-rels-qual
--
* Initializes ClauseInfo and JoinInfo fields of relation entries for all
* Initializes ClauseInfo and JoinInfo fields of relation entries for all
* relations appearing within clauses. Creates new relation entries if
* relations appearing within clauses. Creates new relation entries if
* necessary, adding them to *query-relation-list*.
* necessary, adding them to *query-relation-list*.
...
@@ -144,7 +147,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
...
@@ -144,7 +147,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
* Returns nothing of interest.
* Returns nothing of interest.
*/
*/
void
void
init
ialize_base_rels_jinfo
(
Query
*
root
,
List
*
clauses
)
init
_base_rels_qual
(
Query
*
root
,
List
*
clauses
)
{
{
List
*
clause
;
List
*
clause
;
...
@@ -174,7 +177,6 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -174,7 +177,6 @@ add_clause_to_rels(Query *root, List *clause)
*/
*/
clause_get_relids_vars
((
Node
*
)
clause
,
&
relids
,
&
vars
);
clause_get_relids_vars
((
Node
*
)
clause
,
&
relids
,
&
vars
);
clauseinfo
->
clause
=
(
Expr
*
)
clause
;
clauseinfo
->
clause
=
(
Expr
*
)
clause
;
clauseinfo
->
notclause
=
contains_not
((
Node
*
)
clause
);
clauseinfo
->
notclause
=
contains_not
((
Node
*
)
clause
);
clauseinfo
->
selectivity
=
0
;
clauseinfo
->
selectivity
=
0
;
...
@@ -184,7 +186,7 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -184,7 +186,7 @@ add_clause_to_rels(Query *root, List *clause)
if
(
length
(
relids
)
==
1
)
if
(
length
(
relids
)
==
1
)
{
{
RelOptInfo
*
rel
=
get_base_rel
(
root
,
lfirsti
(
relids
));
RelOptInfo
*
rel
=
get_base_rel
(
root
,
lfirsti
(
relids
));
/*
/*
* There is only one relation participating in 'clause', so
* There is only one relation participating in 'clause', so
...
@@ -197,7 +199,6 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -197,7 +199,6 @@ add_clause_to_rels(Query *root, List *clause)
*/
*/
if
(
is_funcclause
((
Node
*
)
clause
))
if
(
is_funcclause
((
Node
*
)
clause
))
{
{
/*
/*
* XXX If we have a func clause set selectivity to 1/3, really
* XXX If we have a func clause set selectivity to 1/3, really
* need a true selectivity function.
* need a true selectivity function.
...
@@ -209,8 +210,7 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -209,8 +210,7 @@ add_clause_to_rels(Query *root, List *clause)
clauseinfo
->
selectivity
=
clauseinfo
->
selectivity
=
compute_clause_selec
(
root
,
(
Node
*
)
clause
,
NIL
);
compute_clause_selec
(
root
,
(
Node
*
)
clause
,
NIL
);
}
}
rel
->
clauseinfo
=
lcons
(
clauseinfo
,
rel
->
clauseinfo
=
lcons
(
clauseinfo
,
rel
->
clauseinfo
);
rel
->
clauseinfo
);
}
}
else
else
{
{
...
@@ -222,7 +222,6 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -222,7 +222,6 @@ add_clause_to_rels(Query *root, List *clause)
if
(
is_funcclause
((
Node
*
)
clause
))
if
(
is_funcclause
((
Node
*
)
clause
))
{
{
/*
/*
* XXX If we have a func clause set selectivity to 1/3, really
* XXX If we have a func clause set selectivity to 1/3, really
* need a true selectivity function.
* need a true selectivity function.
...
@@ -232,16 +231,16 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -232,16 +231,16 @@ add_clause_to_rels(Query *root, List *clause)
else
else
{
{
clauseinfo
->
selectivity
=
clauseinfo
->
selectivity
=
compute_clause_selec
(
root
,
(
Node
*
)
clause
,
compute_clause_selec
(
root
,
(
Node
*
)
clause
,
NIL
);
NIL
);
}
}
add_join_clause_info_to_rels
(
root
,
clauseinfo
,
relids
);
add_join_info_to_rels
(
root
,
clauseinfo
,
relids
);
add_vars_to_rels
(
root
,
vars
,
relids
);
/* we are going to be doing a join, so add var to targetlist */
add_vars_to_targetlist
(
root
,
vars
,
relids
);
}
}
}
}
/*
/*
* add-join-
clause-
info-to-rels--
* add-join-info-to-rels--
* For every relation participating in a join clause, add 'clauseinfo' to
* For every relation participating in a join clause, add 'clauseinfo' to
* the appropriate joininfo node(creating a new one and adding it to the
* the appropriate joininfo node(creating a new one and adding it to the
* appropriate rel node if necessary).
* appropriate rel node if necessary).
...
@@ -253,7 +252,7 @@ add_clause_to_rels(Query *root, List *clause)
...
@@ -253,7 +252,7 @@ add_clause_to_rels(Query *root, List *clause)
*
*
*/
*/
static
void
static
void
add_join_
clause_
info_to_rels
(
Query
*
root
,
CInfo
*
clauseinfo
,
List
*
join_relids
)
add_join_info_to_rels
(
Query
*
root
,
CInfo
*
clauseinfo
,
List
*
join_relids
)
{
{
List
*
join_relid
;
List
*
join_relid
;
...
@@ -269,8 +268,7 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
...
@@ -269,8 +268,7 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
other_rels
=
lappendi
(
other_rels
,
lfirsti
(
rel
));
other_rels
=
lappendi
(
other_rels
,
lfirsti
(
rel
));
}
}
joininfo
=
joininfo
=
find_joininfo_node
(
get_base_rel
(
root
,
lfirsti
(
join_relid
)),
find_joininfo_node
(
get_base_rel
(
root
,
lfirsti
(
join_relid
)),
other_rels
);
other_rels
);
joininfo
->
jinfoclauseinfo
=
joininfo
->
jinfoclauseinfo
=
lcons
(
copyObject
((
void
*
)
clauseinfo
),
joininfo
->
jinfoclauseinfo
);
lcons
(
copyObject
((
void
*
)
clauseinfo
),
joininfo
->
jinfoclauseinfo
);
...
@@ -279,7 +277,7 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
...
@@ -279,7 +277,7 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
}
}
/*
/*
* add-vars-to-
rels
--
* add-vars-to-
targetlist
--
* For each variable appearing in a clause,
* For each variable appearing in a clause,
* (1) If a targetlist entry for the variable is not already present in
* (1) If a targetlist entry for the variable is not already present in
* the appropriate relation's target list, add one.
* the appropriate relation's target list, add one.
...
@@ -294,11 +292,11 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
...
@@ -294,11 +292,11 @@ add_join_clause_info_to_rels(Query *root, CInfo *clauseinfo, List *join_relids)
* Returns nothing.
* Returns nothing.
*/
*/
static
void
static
void
add_vars_to_
rels
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
)
add_vars_to_
targetlist
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
)
{
{
Var
*
var
;
Var
*
var
;
List
*
temp
=
NIL
;
List
*
temp
=
NIL
;
RelOptInfo
*
rel
=
(
RelOptInfo
*
)
NULL
;
RelOptInfo
*
rel
=
(
RelOptInfo
*
)
NULL
;
TargetEntry
*
tlistentry
;
TargetEntry
*
tlistentry
;
foreach
(
temp
,
vars
)
foreach
(
temp
,
vars
)
...
@@ -319,7 +317,7 @@ add_vars_to_rels(Query *root, List *vars, List *join_relids)
...
@@ -319,7 +317,7 @@ add_vars_to_rels(Query *root, List *vars, List *join_relids)
*****************************************************************************/
*****************************************************************************/
/*
/*
* init
ialize-join-clause
-info--
* init
-join
-info--
* Set the MergeJoinable or HashJoinable field for every joininfo node
* Set the MergeJoinable or HashJoinable field for every joininfo node
* (within a rel node) and the MergeJoinOrder or HashJoinOp field for
* (within a rel node) and the MergeJoinOrder or HashJoinOp field for
* each clauseinfo node(within a joininfo node) for all relations in a
* each clauseinfo node(within a joininfo node) for all relations in a
...
@@ -328,12 +326,12 @@ add_vars_to_rels(Query *root, List *vars, List *join_relids)
...
@@ -328,12 +326,12 @@ add_vars_to_rels(Query *root, List *vars, List *join_relids)
* Returns nothing.
* Returns nothing.
*/
*/
void
void
init
ialize_join_clause
_info
(
List
*
rel_list
)
init
_join
_info
(
List
*
rel_list
)
{
{
List
*
x
,
List
*
x
,
*
y
,
*
y
,
*
z
;
*
z
;
RelOptInfo
*
rel
;
RelOptInfo
*
rel
;
JInfo
*
joininfo
;
JInfo
*
joininfo
;
CInfo
*
clauseinfo
;
CInfo
*
clauseinfo
;
Expr
*
clause
;
Expr
*
clause
;
...
@@ -348,7 +346,7 @@ initialize_join_clause_info(List *rel_list)
...
@@ -348,7 +346,7 @@ initialize_join_clause_info(List *rel_list)
{
{
clauseinfo
=
(
CInfo
*
)
lfirst
(
z
);
clauseinfo
=
(
CInfo
*
)
lfirst
(
z
);
clause
=
clauseinfo
->
clause
;
clause
=
clauseinfo
->
clause
;
if
(
join_clause_p
((
Node
*
)
clause
))
if
(
is_joinable
((
Node
*
)
clause
))
{
{
MergeOrder
*
sortop
=
(
MergeOrder
*
)
NULL
;
MergeOrder
*
sortop
=
(
MergeOrder
*
)
NULL
;
Oid
hashop
=
(
Oid
)
NULL
;
Oid
hashop
=
(
Oid
)
NULL
;
...
...
src/backend/optimizer/plan/planmain.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.2
4 1998/08/07 05:02:19
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.2
5 1998/08/10 02:26:28
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -255,33 +255,33 @@ subplanner(Query *root,
...
@@ -255,33 +255,33 @@ subplanner(Query *root,
List
*
flat_tlist
,
List
*
flat_tlist
,
List
*
qual
)
List
*
qual
)
{
{
RelOptInfo
*
final_rel
ation
;
RelOptInfo
*
final_rel
;
List
*
final_rel
ation
_list
;
List
*
final_rel_list
;
/*
/*
* Initialize the targetlist and qualification, adding entries to
* Initialize the targetlist and qualification, adding entries to
*
*query-relation-list*
as relation references are found (e.g., in
*
base_rel_list
as relation references are found (e.g., in
* the qualification, the targetlist, etc.)
* the qualification, the targetlist, etc.)
*/
*/
root
->
base_relation_list_
=
NIL
;
root
->
base_rel_list
=
NIL
;
root
->
join_relation_list_
=
NIL
;
root
->
join_rel_list
=
NIL
;
initialize_base_rels_list
(
root
,
flat_tlist
);
initialize_base_rels_jinfo
(
root
,
qual
);
init_base_rels_tlist
(
root
,
flat_tlist
);
add_missing_vars_to_base_rels
(
root
,
flat_tlist
);
init_base_rels_qual
(
root
,
qual
);
add_missing_vars_to_tlist
(
root
,
flat_tlist
);
/*
/*
* Find all possible scan and join paths. Mark all the clauses and
* Find all possible scan and join paths. Mark all the clauses and
* relations that can be processed using special join methods, then do
* relations that can be processed using special join methods, then do
* the exhaustive path search.
* the exhaustive path search.
*/
*/
initialize_join_clause_info
(
root
->
base_relation_list_
);
init_join_info
(
root
->
base_rel_list
);
final_relation_list
=
find_paths
(
root
,
final_rel_list
=
find_paths
(
root
,
root
->
base_rel_list
);
root
->
base_relation_list_
);
if
(
final_rel
ation
_list
)
if
(
final_rel_list
)
final_rel
ation
=
(
RelOptInfo
*
)
lfirst
(
final_relation
_list
);
final_rel
=
(
RelOptInfo
*
)
lfirst
(
final_rel
_list
);
else
else
final_rel
ation
=
(
RelOptInfo
*
)
NIL
;
final_rel
=
(
RelOptInfo
*
)
NIL
;
#if 0 /* fix xfunc */
#if 0 /* fix xfunc */
...
@@ -294,14 +294,14 @@ subplanner(Query *root,
...
@@ -294,14 +294,14 @@ subplanner(Query *root,
* expensive functions left to pull up. -- JMH, 11/22/92
* expensive functions left to pull up. -- JMH, 11/22/92
*/
*/
if (XfuncMode != XFUNC_OFF && XfuncMode != XFUNC_NOPM &&
if (XfuncMode != XFUNC_OFF && XfuncMode != XFUNC_NOPM &&
XfuncMode != XFUNC_NOPULL && !final_rel
ation
->pruneable)
XfuncMode != XFUNC_NOPULL && !final_rel->pruneable)
{
{
List *pathnode;
List *pathnode;
foreach(pathnode, final_rel
ation
->pathlist)
foreach(pathnode, final_rel->pathlist)
{
{
if (xfunc_do_predmig((Path *) lfirst(pathnode)))
if (xfunc_do_predmig((Path *) lfirst(pathnode)))
set_cheapest(final_rel
ation, final_relation
->pathlist);
set_cheapest(final_rel
, final_rel
->pathlist);
}
}
}
}
#endif
#endif
...
@@ -310,8 +310,8 @@ subplanner(Query *root,
...
@@ -310,8 +310,8 @@ subplanner(Query *root,
* Determine the cheapest path and create a subplan corresponding to
* Determine the cheapest path and create a subplan corresponding to
* it.
* it.
*/
*/
if
(
final_rel
ation
)
if
(
final_rel
)
return
(
create_plan
((
Path
*
)
final_rel
ation
->
cheapestpath
));
return
(
create_plan
((
Path
*
)
final_rel
->
cheapestpath
));
else
else
{
{
elog
(
NOTICE
,
"final relation is nil"
);
elog
(
NOTICE
,
"final relation is nil"
);
...
...
src/backend/optimizer/util/clauses.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.
19 1998/08/09 04:59:06
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.
20 1998/08/10 02:26:29
momjian Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -439,13 +439,13 @@ contains_not(Node *clause)
...
@@ -439,13 +439,13 @@ contains_not(Node *clause)
}
}
/*
/*
*
join-clause-p
--
*
is_joinable
--
*
*
* Returns t iff 'clause' is a valid join clause.
* Returns t iff 'clause' is a valid join clause.
*
*
*/
*/
bool
bool
join_clause_p
(
Node
*
clause
)
is_joinable
(
Node
*
clause
)
{
{
Node
*
leftop
,
Node
*
leftop
,
*
rightop
;
*
rightop
;
...
@@ -460,7 +460,7 @@ join_clause_p(Node *clause)
...
@@ -460,7 +460,7 @@ join_clause_p(Node *clause)
* One side of the clause (i.e. left or right operands) must either be
* One side of the clause (i.e. left or right operands) must either be
* a var node ...
* a var node ...
*/
*/
if
(
IsA
(
leftop
,
Var
)
||
IsA
(
rightop
,
Var
))
if
(
IsA
(
leftop
,
Var
)
||
IsA
(
rightop
,
Var
))
return
true
;
return
true
;
/*
/*
...
...
src/backend/optimizer/util/joininfo.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.
9 1998/08/04 16:44:17
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.
10 1998/08/10 02:26:30
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -97,7 +97,7 @@ other_join_clause_var(Var *var, Expr *clause)
...
@@ -97,7 +97,7 @@ other_join_clause_var(Var *var, Expr *clause)
retval
=
(
Var
*
)
NULL
;
retval
=
(
Var
*
)
NULL
;
if
(
var
!=
NULL
&&
join_clause_p
((
Node
*
)
clause
))
if
(
var
!=
NULL
&&
is_joinable
((
Node
*
)
clause
))
{
{
l
=
(
Var
*
)
get_leftop
(
clause
);
l
=
(
Var
*
)
get_leftop
(
clause
);
r
=
(
Var
*
)
get_rightop
(
clause
);
r
=
(
Var
*
)
get_rightop
(
clause
);
...
...
src/backend/optimizer/util/relnode.c
View file @
2d32d909
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.
6 1998/07/18 04:22:41
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.
7 1998/08/10 02:26:32
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -34,7 +34,7 @@ get_base_rel(Query *root, int relid)
...
@@ -34,7 +34,7 @@ get_base_rel(Query *root, int relid)
RelOptInfo
*
rel
;
RelOptInfo
*
rel
;
relids
=
lconsi
(
relid
,
NIL
);
relids
=
lconsi
(
relid
,
NIL
);
rel
=
rel_member
(
relids
,
root
->
base_rel
ation_list_
);
rel
=
rel_member
(
relids
,
root
->
base_rel
_list
);
if
(
rel
==
NULL
)
if
(
rel
==
NULL
)
{
{
rel
=
makeNode
(
RelOptInfo
);
rel
=
makeNode
(
RelOptInfo
);
...
@@ -56,8 +56,7 @@ get_base_rel(Query *root, int relid)
...
@@ -56,8 +56,7 @@ get_base_rel(Query *root, int relid)
rel
->
innerjoin
=
NIL
;
rel
->
innerjoin
=
NIL
;
rel
->
superrels
=
NIL
;
rel
->
superrels
=
NIL
;
root
->
base_relation_list_
=
lcons
(
rel
,
root
->
base_rel_list
=
lcons
(
rel
,
root
->
base_rel_list
);
root
->
base_relation_list_
);
/*
/*
* ??? the old lispy C code (get_rel) do a listp(relid) here but
* ??? the old lispy C code (get_rel) do a listp(relid) here but
...
@@ -66,7 +65,6 @@ get_base_rel(Query *root, int relid)
...
@@ -66,7 +65,6 @@ get_base_rel(Query *root, int relid)
*/
*/
if
(
relid
<
0
)
if
(
relid
<
0
)
{
{
/*
/*
* If the relation is a materialized relation, assume
* If the relation is a materialized relation, assume
* constants for sizes.
* constants for sizes.
...
@@ -103,7 +101,7 @@ get_base_rel(Query *root, int relid)
...
@@ -103,7 +101,7 @@ get_base_rel(Query *root, int relid)
RelOptInfo
*
RelOptInfo
*
get_join_rel
(
Query
*
root
,
List
*
relid
)
get_join_rel
(
Query
*
root
,
List
*
relid
)
{
{
return
rel_member
(
relid
,
root
->
join_rel
ation_list_
);
return
rel_member
(
relid
,
root
->
join_rel
_list
);
}
}
/*
/*
...
...
src/backend/parser/gram.c
View file @
2d32d909
...
@@ -219,7 +219,7 @@
...
@@ -219,7 +219,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.2
4 1998/08/06 05:12:37
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.2
5 1998/08/10 02:26:33
momjian Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
...
src/include/nodes/parsenodes.h
View file @
2d32d909
...
@@ -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: parsenodes.h,v 1.5
3 1998/08/05 04:49:13 scrappy
Exp $
* $Id: parsenodes.h,v 1.5
4 1998/08/10 02:26:37 momjian
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -62,8 +62,8 @@ typedef struct Query
...
@@ -62,8 +62,8 @@ typedef struct Query
* query */
* query */
/* internal to planner */
/* internal to planner */
List
*
base_rel
ation_list_
;
/* base relation list */
List
*
base_rel
_list
;
/* base relation list */
List
*
join_rel
ation_list_
;
/* list of relatio
ns */
List
*
join_rel
_list
;
/* list of relation involved in joi
ns */
}
Query
;
}
Query
;
...
...
src/include/optimizer/clauses.h
View file @
2d32d909
...
@@ -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: clauses.h,v 1.1
1 1998/08/09 04:59:08
momjian Exp $
* $Id: clauses.h,v 1.1
2 1998/08/10 02:26:39
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -38,7 +38,7 @@ extern List *pull_constant_clauses(List *quals, List **constantQual);
...
@@ -38,7 +38,7 @@ extern List *pull_constant_clauses(List *quals, List **constantQual);
extern
void
clause_get_relids_vars
(
Node
*
clause
,
List
**
relids
,
List
**
vars
);
extern
void
clause_get_relids_vars
(
Node
*
clause
,
List
**
relids
,
List
**
vars
);
extern
int
NumRelids
(
Node
*
clause
);
extern
int
NumRelids
(
Node
*
clause
);
extern
bool
contains_not
(
Node
*
clause
);
extern
bool
contains_not
(
Node
*
clause
);
extern
bool
join_clause_p
(
Node
*
clause
);
extern
bool
is_joinable
(
Node
*
clause
);
extern
bool
qual_clause_p
(
Node
*
clause
);
extern
bool
qual_clause_p
(
Node
*
clause
);
extern
void
fix_opid
(
Node
*
clause
);
extern
void
fix_opid
(
Node
*
clause
);
extern
List
*
fix_opids
(
List
*
clauses
);
extern
List
*
fix_opids
(
List
*
clauses
);
...
...
src/include/optimizer/planmain.h
View file @
2d32d909
...
@@ -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
3 1998/07/19 05:49:25
momjian Exp $
* $Id: planmain.h,v 1.1
4 1998/08/10 02:26:40
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,10 +45,10 @@ extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
...
@@ -45,10 +45,10 @@ extern Unique *make_unique(List *tlist, Plan *lefttree, char *uniqueAttr);
/*
/*
* prototypes for plan/initsplan.c
* prototypes for plan/initsplan.c
*/
*/
extern
void
init
ialize_base_rels_
list
(
Query
*
root
,
List
*
tlist
);
extern
void
init
_base_rels_t
list
(
Query
*
root
,
List
*
tlist
);
extern
void
init
ialize_base_rels_jinfo
(
Query
*
root
,
List
*
clauses
);
extern
void
init
_base_rels_qual
(
Query
*
root
,
List
*
clauses
);
extern
void
init
ialize_join_clause
_info
(
List
*
rel_list
);
extern
void
init
_join
_info
(
List
*
rel_list
);
extern
void
add_missing_vars_to_
base_rels
(
Query
*
root
,
List
*
tlist
);
extern
void
add_missing_vars_to_
tlist
(
Query
*
root
,
List
*
tlist
);
/*
/*
* prototypes for plan/setrefs.c
* prototypes for plan/setrefs.c
...
...
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