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
31cce21f
Commit
31cce21f
authored
Feb 18, 1999
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bushy plans. Cleanup.
parent
c82ca4c1
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
180 additions
and
363 deletions
+180
-363
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+2
-4
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+2
-2
src/backend/nodes/freefuncs.c
src/backend/nodes/freefuncs.c
+2
-3
src/backend/nodes/outfuncs.c
src/backend/nodes/outfuncs.c
+4
-4
src/backend/nodes/readfuncs.c
src/backend/nodes/readfuncs.c
+3
-3
src/backend/optimizer/path/_deadcode/xfunc.c
src/backend/optimizer/path/_deadcode/xfunc.c
+9
-10
src/backend/optimizer/path/allpaths.c
src/backend/optimizer/path/allpaths.c
+3
-26
src/backend/optimizer/path/indxpath.c
src/backend/optimizer/path/indxpath.c
+2
-2
src/backend/optimizer/path/joinpath.c
src/backend/optimizer/path/joinpath.c
+4
-4
src/backend/optimizer/path/joinrels.c
src/backend/optimizer/path/joinrels.c
+86
-190
src/backend/optimizer/path/prune.c
src/backend/optimizer/path/prune.c
+5
-51
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/initsplan.c
+14
-14
src/backend/optimizer/prep/prepunion.c
src/backend/optimizer/prep/prepunion.c
+5
-5
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/clauses.c
+2
-2
src/backend/optimizer/util/joininfo.c
src/backend/optimizer/util/joininfo.c
+9
-10
src/backend/optimizer/util/pathnode.c
src/backend/optimizer/util/pathnode.c
+2
-2
src/backend/optimizer/util/relnode.c
src/backend/optimizer/util/relnode.c
+7
-10
src/include/nodes/relation.h
src/include/nodes/relation.h
+8
-10
src/include/optimizer/clauses.h
src/include/optimizer/clauses.h
+3
-2
src/include/optimizer/pathnode.h
src/include/optimizer/pathnode.h
+3
-3
src/include/optimizer/paths.h
src/include/optimizer/paths.h
+2
-3
src/include/optimizer/xfunc.h
src/include/optimizer/xfunc.h
+3
-3
No files found.
src/backend/nodes/copyfuncs.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.7
2 1999/02/15 05:21:01
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.7
3 1999/02/18 00:49:12
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1066,7 +1066,6 @@ _copyRelOptInfo(RelOptInfo * from)
Node_Copy
(
from
,
newnode
,
restrictinfo
);
Node_Copy
(
from
,
newnode
,
joininfo
);
Node_Copy
(
from
,
newnode
,
innerjoin
);
Node_Copy
(
from
,
newnode
,
superrels
);
return
newnode
;
}
...
...
@@ -1428,12 +1427,11 @@ _copyJoinInfo(JoinInfo *from)
* copy remainder of node
* ----------------
*/
newnode
->
unjoined_rel
s
=
listCopy
(
from
->
unjoined_rel
s
);
newnode
->
unjoined_rel
ids
=
listCopy
(
from
->
unjoined_relid
s
);
Node_Copy
(
from
,
newnode
,
jinfo_restrictinfo
);
newnode
->
mergejoinable
=
from
->
mergejoinable
;
newnode
->
hashjoinable
=
from
->
hashjoinable
;
newnode
->
bushy_inactive
=
from
->
bushy_inactive
;
return
newnode
;
}
...
...
src/backend/nodes/equalfuncs.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.3
4 1999/02/15 05:21:02
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.3
5 1999/02/18 00:49:14
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -526,7 +526,7 @@ _equalJoinInfo(JoinInfo *a, JoinInfo *b)
{
Assert
(
IsA
(
a
,
JoinInfo
));
Assert
(
IsA
(
b
,
JoinInfo
));
if
(
!
equal
(
a
->
unjoined_rel
s
,
b
->
unjoined_rel
s
))
if
(
!
equal
(
a
->
unjoined_rel
ids
,
b
->
unjoined_relid
s
))
return
false
;
if
(
!
equal
(
a
->
jinfo_restrictinfo
,
b
->
jinfo_restrictinfo
))
return
false
;
...
...
src/backend/nodes/freefuncs.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.1
2 1999/02/15 05:21:02
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.1
3 1999/02/18 00:49:14
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -740,7 +740,6 @@ _freeRelOptInfo(RelOptInfo *node)
freeObject
(
node
->
restrictinfo
);
freeObject
(
node
->
joininfo
);
freeObject
(
node
->
innerjoin
);
freeObject
(
node
->
superrels
);
pfree
(
node
);
}
...
...
@@ -1024,7 +1023,7 @@ _freeJoinInfo(JoinInfo *node)
* free remainder of node
* ----------------
*/
freeList
(
node
->
unjoined_rels
);
freeList
(
node
->
unjoined_rel
id
s
);
freeObject
(
node
->
jinfo_restrictinfo
);
pfree
(
node
);
...
...
src/backend/nodes/outfuncs.c
View file @
31cce21f
...
...
@@ -5,7 +5,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: outfuncs.c,v 1.7
4 1999/02/15 05:21:02
momjian Exp $
* $Id: outfuncs.c,v 1.7
5 1999/02/18 00:49:14
momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
...
...
@@ -61,7 +61,7 @@ _outIntList(StringInfo str, List *list)
appendStringInfo
(
str
,
"("
);
foreach
(
l
,
list
)
{
appendStringInfo
(
str
,
" %d "
,
(
int
)
lfirst
(
l
));
appendStringInfo
(
str
,
" %d "
,
lfirsti
(
l
));
}
appendStringInfo
(
str
,
")"
);
}
...
...
@@ -1198,8 +1198,8 @@ _outHashInfo(StringInfo str, HashInfo *node)
static
void
_outJoinInfo
(
StringInfo
str
,
JoinInfo
*
node
)
{
appendStringInfo
(
str
,
" JINFO :unjoined_rels "
);
_outIntList
(
str
,
node
->
unjoined_rels
);
appendStringInfo
(
str
,
" JINFO :unjoined_rel
id
s "
);
_outIntList
(
str
,
node
->
unjoined_rel
id
s
);
appendStringInfo
(
str
,
" :jinfo_restrictinfo "
);
_outNode
(
str
,
node
->
jinfo_restrictinfo
);
...
...
src/backend/nodes/readfuncs.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.5
8 1999/02/15 05:21:03
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.5
9 1999/02/18 00:49:15
momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
...
...
@@ -1982,8 +1982,8 @@ _readJoinInfo()
local_node
=
makeNode
(
JoinInfo
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :unjoined_rels */
local_node
->
unjoined_rels
=
toIntList
(
nodeRead
(
true
));
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :unjoined_rel
id
s */
local_node
->
unjoined_rel
id
s
=
toIntList
(
nodeRead
(
true
));
/* now read it */
token
=
lsptok
(
NULL
,
&
length
);
/* get :jinfo_restrictinfo */
local_node
->
jinfo_restrictinfo
=
nodeRead
(
true
);
/* now read it */
...
...
src/backend/optimizer/path/xfunc.c
→
src/backend/optimizer/path/
_deadcode/
xfunc.c
View file @
31cce21f
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/
Attic/xfunc.c,v 1.28 1999/02/13 23:16
:24 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/
_deadcode/Attic/xfunc.c,v 1.1 1999/02/18 00:49
:24 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -44,7 +44,7 @@
/* local funcs */
static
int
xfunc_card_unreferenced
(
Query
*
queryInfo
,
Expr
*
clause
,
Relid
referenced
);
Expr
*
clause
,
Relid
s
referenced
);
*/
...
...
@@ -631,10 +631,10 @@ xfunc_width(LispValue clause)
}
else
if
(
IsA
(
clause
,
Param
))
{
if
(
typeidTypeRelid
(
get_paramtype
((
Param
)
clause
)))
if
(
typeidTypeRelid
s
(
get_paramtype
((
Param
)
clause
)))
{
/* Param node returns a tuple. Find its width */
rd
=
heap_open
(
typeidTypeRelid
(
get_paramtype
((
Param
)
clause
)));
rd
=
heap_open
(
typeidTypeRelid
s
(
get_paramtype
((
Param
)
clause
)));
retval
=
xfunc_tuple_width
(
rd
);
heap_close
(
rd
);
}
...
...
@@ -724,9 +724,9 @@ exit:
*/
static
Count
xfunc_card_unreferenced
(
Query
*
queryInfo
,
LispValue
clause
,
Relid
referenced
)
LispValue
clause
,
Relid
s
referenced
)
{
Relid
unreferenced
,
Relid
s
unreferenced
,
allrelids
=
LispNil
;
LispValue
temp
;
...
...
@@ -751,7 +751,7 @@ xfunc_card_unreferenced(Query *queryInfo,
** multiple together cardinalities of a list relations.
*/
Count
xfunc_card_product
(
Query
*
queryInfo
,
Relid
relids
)
xfunc_card_product
(
Query
*
queryInfo
,
Relid
s
relids
)
{
LispValue
cinfonode
;
LispValue
temp
;
...
...
@@ -1310,9 +1310,9 @@ xfunc_func_width(RegProcedure funcid, LispValue args)
proc
=
(
Form_pg_proc
)
GETSTRUCT
(
tupl
);
/* if function returns a tuple, get the width of that */
if
(
typeidTypeRelid
(
proc
->
prorettype
))
if
(
typeidTypeRelid
s
(
proc
->
prorettype
))
{
rd
=
heap_open
(
typeidTypeRelid
(
proc
->
prorettype
));
rd
=
heap_open
(
typeidTypeRelid
s
(
proc
->
prorettype
));
retval
=
xfunc_tuple_width
(
rd
);
heap_close
(
rd
);
goto
exit
;
...
...
@@ -1478,7 +1478,6 @@ xfunc_copyrel(RelOptInfo from, RelOptInfo *to)
Node_Copy
(
from
,
newnode
,
alloc
,
restrictinfo
);
Node_Copy
(
from
,
newnode
,
alloc
,
joininfo
);
Node_Copy
(
from
,
newnode
,
alloc
,
innerjoin
);
Node_Copy
(
from
,
newnode
,
alloc
,
superrels
);
(
*
to
)
=
newnode
;
return
true
;
...
...
src/backend/optimizer/path/allpaths.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.4
0 1999/02/16 00:40:59
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.4
1 1999/02/18 00:49:17
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -191,6 +191,8 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
merge_rels_with_same_relids
(
joined_rels
);
root
->
join_rel_list
=
rels
=
joined_rels
;
#if 0
/*
* * for each expensive predicate in each path in each distinct
...
...
@@ -203,17 +205,6 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
rels_set_cheapest
(
joined_rels
);
if
(
BushyPlanFlag
)
{
/*
* In case of bushy trees if there is still a join between a
* join relation and another relation, add a new joininfo that
* involves the join relation to the joininfo list of the
* other relation
*/
add_rel_to_rel_joininfos
(
root
,
joined_rels
,
rels
);
}
foreach
(
x
,
joined_rels
)
{
rel
=
(
RelOptInfo
*
)
lfirst
(
x
);
...
...
@@ -228,20 +219,6 @@ make_one_rel_by_joins(Query *root, List *rels, int levels_needed)
#endif
}
if
(
BushyPlanFlag
)
{
/*
* prune rels that have been completely incorporated into new
* join rels
*/
joined_rels
=
del_rels_all_bushy_inactive
(
rels
);
/*
* merge join rels if then contain the same list of base rels
*/
merge_rels_with_same_relids
(
joined_rels
);
}
root
->
join_rel_list
=
rels
=
joined_rels
;
}
Assert
(
BushyPlanFlag
||
length
(
rels
)
==
1
);
...
...
src/backend/optimizer/path/indxpath.c
View file @
31cce21f
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.5
0 1999/02/15 05:50:00
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.5
1 1999/02/18 00:49:18
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -1208,7 +1208,7 @@ indexable_joinclauses(RelOptInfo *rel, RelOptInfo *index,
{
List
*
clauses
=
lfirst
(
clausegroups
);
((
RestrictInfo
*
)
lfirst
(
clauses
))
->
restrictinfojoinid
=
joininfo
->
unjoined_rels
;
((
RestrictInfo
*
)
lfirst
(
clauses
))
->
restrictinfojoinid
=
joininfo
->
unjoined_rel
id
s
;
}
cg_list
=
nconc
(
cg_list
,
clausegroups
);
}
...
...
src/backend/optimizer/path/joinpath.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.2
7 1999/02/15 03:22:05
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.2
8 1999/02/18 00:49:19
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -71,8 +71,8 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
foreach
(
j
,
joinrels
)
{
RelOptInfo
*
joinrel
=
(
RelOptInfo
*
)
lfirst
(
j
);
List
*
innerrelids
;
List
*
outerrelids
;
Relids
innerrelids
;
Relids
outerrelids
;
RelOptInfo
*
innerrel
;
RelOptInfo
*
outerrel
;
Path
*
bestinnerjoin
;
...
...
@@ -163,7 +163,7 @@ update_rels_pathlist_for_joins(Query *root, List *joinrels)
* Returns the pathnode of the selected path.
*/
static
Path
*
best_innerjoin
(
List
*
join_paths
,
List
*
outer_relids
)
best_innerjoin
(
List
*
join_paths
,
Relids
outer_relids
)
{
Path
*
cheapest
=
(
Path
*
)
NULL
;
List
*
join_path
;
...
...
src/backend/optimizer/path/joinrels.c
View file @
31cce21f
This diff is collapsed.
Click to expand it.
src/backend/optimizer/path/prune.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.3
6 1999/02/16 00:41:00
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.3
7 1999/02/18 00:49:21
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -24,7 +24,7 @@
#include "utils/elog.h"
static
List
*
merge_rel_with_same_relids
(
RelOptInfo
*
rel
,
List
*
unjoined_rel
s
);
static
List
*
merge_rel_with_same_relids
(
RelOptInfo
*
rel
,
Relids
unjoined_relid
s
);
/*
* merge_rels_with_same_relids
...
...
@@ -49,7 +49,7 @@ merge_rels_with_same_relids(List *rel_list)
/*
* merge_rel_with_same_relids
* Prunes those relations from 'unjoined_rels' that are redundant with
* Prunes those relations from 'unjoined_rel
id
s' that are redundant with
* 'rel'. A relation is redundant if it is built up of the same
* relations as 'rel'. Paths for the redundant relation are merged into
* the pathlist of 'rel'.
...
...
@@ -59,12 +59,12 @@ merge_rels_with_same_relids(List *rel_list)
*
*/
static
List
*
merge_rel_with_same_relids
(
RelOptInfo
*
rel
,
List
*
unjoined_rel
s
)
merge_rel_with_same_relids
(
RelOptInfo
*
rel
,
Relids
unjoined_relid
s
)
{
List
*
i
=
NIL
;
List
*
result
=
NIL
;
foreach
(
i
,
unjoined_rels
)
foreach
(
i
,
unjoined_rel
id
s
)
{
RelOptInfo
*
unjoined_rel
=
(
RelOptInfo
*
)
lfirst
(
i
);
...
...
@@ -105,49 +105,3 @@ rels_set_cheapest(List *rel_list)
elog
(
ERROR
,
"non JoinPath called"
);
}
}
/*
* del_rels_all_bushy_inactive
* If all the joininfo's in a rel node are bushy_inactive,
* that means that this node has been joined into
* other nodes in all possible ways, therefore
* this node can be discarded. If not, it will cause
* extra complexity of the optimizer.
*
* old_rels is a list of rel nodes
*
* Returns a new list of rel nodes
*/
List
*
del_rels_all_bushy_inactive
(
List
*
old_rels
)
{
RelOptInfo
*
rel
;
List
*
joininfo_list
,
*
xjoininfo
,
*
i
,
*
temp_list
=
NIL
;
foreach
(
i
,
old_rels
)
{
rel
=
(
RelOptInfo
*
)
lfirst
(
i
);
joininfo_list
=
rel
->
joininfo
;
if
(
joininfo_list
==
NIL
)
temp_list
=
lcons
(
rel
,
temp_list
);
else
{
foreach
(
xjoininfo
,
joininfo_list
)
{
JoinInfo
*
joininfo
=
(
JoinInfo
*
)
lfirst
(
xjoininfo
);
if
(
!
joininfo
->
bushy_inactive
)
{
temp_list
=
lcons
(
rel
,
temp_list
);
break
;
}
}
}
}
return
temp_list
;
}
src/backend/optimizer/plan/initsplan.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.2
7 1999/02/15 05:21:0
6 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.2
8 1999/02/18 00:49:2
6 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -41,8 +41,8 @@ extern int Quiet;
static
void
add_restrict_and_join_to_rel
(
Query
*
root
,
List
*
clause
);
static
void
add_join_info_to_rels
(
Query
*
root
,
RestrictInfo
*
restrictinfo
,
List
*
join_relids
);
static
void
add_vars_to_targetlist
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
);
Relids
join_relids
);
static
void
add_vars_to_targetlist
(
Query
*
root
,
List
*
vars
,
Relids
join_relids
);
static
MergeOrder
*
mergejoinop
(
Expr
*
clause
);
static
Oid
hashjoinop
(
Expr
*
clause
);
...
...
@@ -107,7 +107,7 @@ add_missing_vars_to_tlist(Query *root, List *tlist)
foreach
(
l
,
root
->
rtable
)
{
RangeTblEntry
*
rte
=
(
RangeTblEntry
*
)
lfirst
(
l
);
List
*
relids
;
Relids
relids
;
RelOptInfo
*
result
;
Var
*
var
;
...
...
@@ -165,7 +165,7 @@ add_restrict_and_join_to_rels(Query *root, List *clauses)
static
void
add_restrict_and_join_to_rel
(
Query
*
root
,
List
*
clause
)
{
List
*
relids
;
Relids
relids
;
List
*
vars
;
RestrictInfo
*
restrictinfo
=
makeNode
(
RestrictInfo
);
...
...
@@ -235,31 +235,31 @@ add_restrict_and_join_to_rel(Query *root, List *clause)
* 'restrictinfo' describes the join clause
* 'join_relids' is the list of relations participating in the join clause
*
* Returns nothing.
*
*/
static
void
add_join_info_to_rels
(
Query
*
root
,
RestrictInfo
*
restrictinfo
,
List
*
join_relids
)
add_join_info_to_rels
(
Query
*
root
,
RestrictInfo
*
restrictinfo
,
Relids
join_relids
)
{
List
*
join_relid
;
/* For every relid, find the rel, and add the proper join entries */
foreach
(
join_relid
,
join_relids
)
{
JoinInfo
*
joininfo
;
List
*
unjoined_rel
s
=
NIL
;
List
*
rel
;
Relids
unjoined_relid
s
=
NIL
;
List
*
rel
;
/* Get the relids not equal to the current relid */
foreach
(
rel
,
join_relids
)
{
if
(
lfirsti
(
rel
)
!=
lfirsti
(
join_relid
))
unjoined_rel
s
=
lappendi
(
unjoined_rel
s
,
lfirsti
(
rel
));
unjoined_rel
ids
=
lappendi
(
unjoined_relid
s
,
lfirsti
(
rel
));
}
joininfo
=
find_joininfo_node
(
get_base_rel
(
root
,
lfirsti
(
join_relid
)),
unjoined_rels
);
unjoined_rel
id
s
);
joininfo
->
jinfo_restrictinfo
=
lcons
(
copyObject
((
void
*
)
restrictinfo
),
joininfo
->
jinfo_restrictinfo
);
}
}
...
...
@@ -279,7 +279,7 @@ add_join_info_to_rels(Query *root, RestrictInfo *restrictinfo, List *join_relids
* Returns nothing.
*/
static
void
add_vars_to_targetlist
(
Query
*
root
,
List
*
vars
,
List
*
join_relids
)
add_vars_to_targetlist
(
Query
*
root
,
List
*
vars
,
Relids
join_relids
)
{
Var
*
var
;
List
*
temp
=
NIL
;
...
...
src/backend/optimizer/prep/prepunion.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.
29 1999/02/13 23:16:40
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.
30 1999/02/18 00:49:32
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -34,7 +34,7 @@
#include "optimizer/planner.h"
#include "optimizer/planmain.h"
static
List
*
plan_inherit_query
(
List
*
relids
,
Index
rt_index
,
static
List
*
plan_inherit_query
(
Relids
relids
,
Index
rt_index
,
RangeTblEntry
*
rt_entry
,
Query
*
parse
,
List
**
union_rtentriesPtr
);
static
RangeTblEntry
*
new_rangetable_entry
(
Oid
new_relid
,
...
...
@@ -248,7 +248,7 @@ plan_inherit_queries(Query *parse, Index rt_index)
* in union_rtentries.
*/
static
List
*
plan_inherit_query
(
List
*
relids
,
plan_inherit_query
(
Relids
relids
,
Index
rt_index
,
RangeTblEntry
*
rt_entry
,
Query
*
root
,
...
...
@@ -301,8 +301,8 @@ plan_inherit_query(List *relids,
* lists.
*/
List
*
find_all_inheritors
(
List
*
unexamined_relids
,
List
*
examined_relids
)
find_all_inheritors
(
Relids
unexamined_relids
,
Relids
examined_relids
)
{
List
*
new_inheritors
=
NIL
;
List
*
new_examined_relids
=
NIL
;
...
...
src/backend/optimizer/util/clauses.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.3
0 1999/02/14 22:24:25 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.3
1 1999/02/18 00:49:37 momjian
Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
...
...
@@ -369,7 +369,7 @@ pull_constant_clauses(List *quals, List **constantQual)
*
*/
void
clause_get_relids_vars
(
Node
*
clause
,
List
*
*
relids
,
List
**
vars
)
clause_get_relids_vars
(
Node
*
clause
,
Relids
*
relids
,
List
**
vars
)
{
List
*
clvars
=
pull_var_clause
(
clause
);
List
*
var_list
=
NIL
;
...
...
src/backend/optimizer/util/joininfo.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.1
7 1999/02/15 05:21:11
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.1
8 1999/02/18 00:49:37
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -38,16 +38,16 @@
JoinInfo
*
joininfo_member
(
List
*
join_relids
,
List
*
joininfo_list
)
{
List
*
i
=
NIL
;
List
*
other_rels
=
NIL
;
List
*
i
;
foreach
(
i
,
joininfo_list
)
{
other_rels
=
lfirst
(
i
);
if
(
same
(
join_relids
,
((
JoinInfo
*
)
other_rels
)
->
unjoined_rels
))
return
(
JoinInfo
*
)
other_rels
;
JoinInfo
*
joininfo
=
(
JoinInfo
*
)
lfirst
(
i
);
if
(
same
(
join_relids
,
joininfo
->
unjoined_relids
))
return
joininfo
;
}
return
(
JoinInfo
*
)
NULL
;
return
NULL
;
}
...
...
@@ -62,7 +62,7 @@ joininfo_member(List *join_relids, List *joininfo_list)
*
*/
JoinInfo
*
find_joininfo_node
(
RelOptInfo
*
this_rel
,
List
*
join_relids
)
find_joininfo_node
(
RelOptInfo
*
this_rel
,
Relids
join_relids
)
{
JoinInfo
*
joininfo
=
joininfo_member
(
join_relids
,
this_rel
->
joininfo
);
...
...
@@ -70,11 +70,10 @@ find_joininfo_node(RelOptInfo *this_rel, List *join_relids)
if
(
joininfo
==
NULL
)
{
joininfo
=
makeNode
(
JoinInfo
);
joininfo
->
unjoined_rels
=
join_relids
;
joininfo
->
unjoined_rel
id
s
=
join_relids
;
joininfo
->
jinfo_restrictinfo
=
NIL
;
joininfo
->
mergejoinable
=
false
;
joininfo
->
hashjoinable
=
false
;
joininfo
->
bushy_inactive
=
false
;
this_rel
->
joininfo
=
lcons
(
joininfo
,
this_rel
->
joininfo
);
}
return
joininfo
;
...
...
src/backend/optimizer/util/pathnode.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.3
6 1999/02/15 03:22:16
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.3
7 1999/02/18 00:49:38
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -633,7 +633,7 @@ create_hashjoin_path(RelOptInfo *joinrel,
pathnode
->
jpath
.
path
.
pathorder
->
ordtype
=
SORTOP_ORDER
;
pathnode
->
jpath
.
path
.
pathorder
->
ord
.
sortop
=
NULL
;
pathnode
->
jpath
.
path
.
outerjoincost
=
(
Cost
)
0
.
0
;
pathnode
->
jpath
.
path
.
joinid
=
(
Relid
)
NULL
;
pathnode
->
jpath
.
path
.
joinid
=
(
Relid
s
)
NULL
;
/* pathnode->hashjoinoperator = operator; */
pathnode
->
path_hashclauses
=
hashclauses
;
pathnode
->
outerhashkeys
=
outerkeys
;
...
...
src/backend/optimizer/util/relnode.c
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.1
4 1999/02/15 03:22:17
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.1
5 1999/02/18 00:49:38
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -30,7 +30,7 @@
RelOptInfo
*
get_base_rel
(
Query
*
root
,
int
relid
)
{
List
*
relids
;
Relids
relids
;
RelOptInfo
*
rel
;
relids
=
lconsi
(
relid
,
NIL
);
...
...
@@ -53,7 +53,6 @@ get_base_rel(Query *root, int relid)
rel
->
restrictinfo
=
NIL
;
rel
->
joininfo
=
NIL
;
rel
->
innerjoin
=
NIL
;
rel
->
superrels
=
NIL
;
root
->
base_rel_list
=
lcons
(
rel
,
root
->
base_rel_list
);
...
...
@@ -76,7 +75,6 @@ get_base_rel(Query *root, int relid)
bool
hasindex
;
int
pages
,
tuples
;
/*
* Otherwise, retrieve relation characteristics from the
* system catalogs.
...
...
@@ -93,11 +91,10 @@ get_base_rel(Query *root, int relid)
/*
* get_join_rel
* Returns relation entry corresponding to 'relid' (a list of relids),
* creating a new one if necessary. This is for join relations.
*
* or NULL.
*/
RelOptInfo
*
get_join_rel
(
Query
*
root
,
List
*
relid
)
get_join_rel
(
Query
*
root
,
Relids
relid
)
{
return
rel_member
(
relid
,
root
->
join_rel_list
);
}
...
...
@@ -111,17 +108,17 @@ get_join_rel(Query *root, List *relid)
*
*/
RelOptInfo
*
rel_member
(
List
*
relid
,
List
*
rels
)
rel_member
(
Relids
relids
,
List
*
rels
)
{
List
*
temp
=
NIL
;
List
*
temprelid
=
NIL
;
if
(
relid
!=
NIL
&&
rels
!=
NIL
)
if
(
relid
s
!=
NIL
&&
rels
!=
NIL
)
{
foreach
(
temp
,
rels
)
{
temprelid
=
((
RelOptInfo
*
)
lfirst
(
temp
))
->
relids
;
if
(
same
(
temprelid
,
relid
))
if
(
same
(
temprelid
,
relid
s
))
return
(
RelOptInfo
*
)
(
lfirst
(
temp
));
}
}
...
...
src/include/nodes/relation.h
View file @
31cce21f
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: relation.h,v 1.2
5 1999/02/15 05:21:12
momjian Exp $
* $Id: relation.h,v 1.2
6 1999/02/18 00:49:38
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -17,11 +17,11 @@
#include <nodes/primnodes.h>
/*
* Relid
* Relid
s
* List of relation identifiers (indexes into the rangetable).
*/
typedef
List
*
Relid
;
typedef
List
*
Relid
s
;
/*
* RelOptInfo
...
...
@@ -72,7 +72,7 @@ typedef struct RelOptInfo
NodeTag
type
;
/* all relations: */
Relid
relids
;
Relid
s
relids
;
/* integer list of base relids involved */
/* catalog statistics information */
bool
indexed
;
...
...
@@ -84,7 +84,7 @@ typedef struct RelOptInfo
/* materialization information */
List
*
targetlist
;
List
*
pathlist
;
/* Path structures */
struct
Path
*
cheapestpath
;
struct
Path
*
cheapestpath
;
bool
pruneable
;
/* used solely by indices: */
...
...
@@ -100,7 +100,6 @@ typedef struct RelOptInfo
List
*
restrictinfo
;
/* RestrictInfo structures */
List
*
joininfo
;
/* JoinInfo structures */
List
*
innerjoin
;
List
*
superrels
;
}
RelOptInfo
;
extern
Var
*
get_expr
(
TargetEntry
*
foo
);
...
...
@@ -148,7 +147,7 @@ typedef struct Path
* indexes.
*/
Cost
outerjoincost
;
Relid
joinid
;
Relid
s
joinid
;
List
*
loc_restrictinfo
;
}
Path
;
...
...
@@ -221,7 +220,7 @@ typedef struct RestrictInfo
/* hashjoin only */
Oid
hashjoinoperator
;
Relid
restrictinfojoinid
;
Relid
s
restrictinfojoinid
;
}
RestrictInfo
;
typedef
struct
JoinMethod
...
...
@@ -246,11 +245,10 @@ typedef struct MergeInfo
typedef
struct
JoinInfo
{
NodeTag
type
;
List
*
unjoined_rel
s
;
Relids
unjoined_relid
s
;
List
*
jinfo_restrictinfo
;
bool
mergejoinable
;
bool
hashjoinable
;
bool
bushy_inactive
;
}
JoinInfo
;
typedef
struct
Iter
...
...
src/include/optimizer/clauses.h
View file @
31cce21f
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: clauses.h,v 1.1
5 1999/02/13 23:21:42
momjian Exp $
* $Id: clauses.h,v 1.1
6 1999/02/18 00:49:46
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -14,6 +14,7 @@
#define CLAUSES_H
#include <nodes/primnodes.h>
#include <nodes/relation.h>
extern
Expr
*
make_clause
(
int
type
,
Node
*
oper
,
List
*
args
);
extern
bool
is_opclause
(
Node
*
clause
);
...
...
@@ -37,7 +38,7 @@ extern Expr *make_andclause(List *andclauses);
extern
bool
case_clause
(
Node
*
clause
);
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
,
Relids
*
relids
,
List
**
vars
);
extern
int
NumRelids
(
Node
*
clause
);
extern
bool
contains_not
(
Node
*
clause
);
extern
bool
is_joinable
(
Node
*
clause
);
...
...
src/include/optimizer/pathnode.h
View file @
31cce21f
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pathnode.h,v 1.1
4 1999/02/13 23:21:49
momjian Exp $
* $Id: pathnode.h,v 1.1
5 1999/02/18 00:49:46
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -42,9 +42,9 @@ extern HashPath *create_hashjoin_path(RelOptInfo *joinrel, int outersize,
/*
* prototypes for rel.c
*/
extern
RelOptInfo
*
rel_member
(
List
*
relid
,
List
*
rels
);
extern
RelOptInfo
*
rel_member
(
Relids
relid
,
List
*
rels
);
extern
RelOptInfo
*
get_base_rel
(
Query
*
root
,
int
relid
);
extern
RelOptInfo
*
get_join_rel
(
Query
*
root
,
List
*
relid
);
extern
RelOptInfo
*
get_join_rel
(
Query
*
root
,
Relids
relid
);
/*
* prototypes for indexnode.h
...
...
src/include/optimizer/paths.h
View file @
31cce21f
...
...
@@ -7,7 +7,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: paths.h,v 1.2
0 1999/02/16 00:41:03
momjian Exp $
* $Id: paths.h,v 1.2
1 1999/02/18 00:49:47
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -78,9 +78,8 @@ extern MergeInfo *match_order_mergeinfo(PathOrder *ordering,
* routines to determine which relations to join
*/
extern
List
*
make_rels_by_joins
(
Query
*
root
,
List
*
outer_rels
);
extern
void
add_rel_to_rel_joininfos
(
Query
*
root
,
List
*
joinrels
,
List
*
outerrels
);
extern
List
*
make_rels_by_clause_joins
(
Query
*
root
,
RelOptInfo
*
outer_rel
,
List
*
joininfo_list
,
List
*
only_relids
);
List
*
joininfo_list
,
Relids
only_relids
);
extern
List
*
make_rels_by_clauseless_joins
(
RelOptInfo
*
outer_rel
,
List
*
inner_rels
);
extern
RelOptInfo
*
make_join_rel
(
RelOptInfo
*
outer_rel
,
RelOptInfo
*
inner_rel
,
JoinInfo
*
joininfo
);
...
...
src/include/optimizer/xfunc.h
View file @
31cce21f
...
...
@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: xfunc.h,v 1.1
5 1999/02/13 23:21:54
momjian Exp $
* $Id: xfunc.h,v 1.1
6 1999/02/18 00:49:48
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -62,8 +62,8 @@ extern Cost xfunc_func_expense(Expr *node, List *args);
extern
int
xfunc_width
(
Expr
*
clause
);
/* static, moved to xfunc.c */
/* extern int xfunc_card_unreferenced(Expr *clause, Relid referenced); */
extern
int
xfunc_card_product
(
Relid
relids
);
/* extern int xfunc_card_unreferenced(Expr *clause, Relid
s
referenced); */
extern
int
xfunc_card_product
(
Relid
s
relids
);
extern
List
*
xfunc_find_references
(
List
*
clause
);
extern
List
*
xfunc_primary_join
(
JoinPath
*
pathnode
);
extern
Cost
xfunc_get_path_cost
(
Path
*
pathnode
);
...
...
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