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
7f31669b
Commit
7f31669b
authored
Jan 20, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Var.varlevelup to code. More parser cleanup.
parent
412a5e65
Changes
25
Show whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
158 additions
and
104 deletions
+158
-104
src/backend/commands/recipe.c
src/backend/commands/recipe.c
+3
-1
src/backend/nodes/copyfuncs.c
src/backend/nodes/copyfuncs.c
+2
-1
src/backend/nodes/equalfuncs.c
src/backend/nodes/equalfuncs.c
+3
-1
src/backend/nodes/makefuncs.c
src/backend/nodes/makefuncs.c
+3
-1
src/backend/nodes/outfuncs.c
src/backend/nodes/outfuncs.c
+3
-1
src/backend/nodes/readfuncs.c
src/backend/nodes/readfuncs.c
+5
-1
src/backend/optimizer/plan/createplan.c
src/backend/optimizer/plan/createplan.c
+2
-1
src/backend/optimizer/plan/initsplan.c
src/backend/optimizer/plan/initsplan.c
+2
-2
src/backend/optimizer/plan/planmain.c
src/backend/optimizer/plan/planmain.c
+2
-2
src/backend/optimizer/plan/setrefs.c
src/backend/optimizer/plan/setrefs.c
+4
-1
src/backend/optimizer/prep/preptlist.c
src/backend/optimizer/prep/preptlist.c
+3
-3
src/backend/optimizer/util/clauses.c
src/backend/optimizer/util/clauses.c
+3
-2
src/backend/optimizer/util/tlist.c
src/backend/optimizer/util/tlist.c
+4
-2
src/backend/optimizer/util/var.c
src/backend/optimizer/util/var.c
+2
-1
src/backend/parser/README
src/backend/parser/README
+1
-1
src/backend/parser/analyze.c
src/backend/parser/analyze.c
+4
-4
src/backend/parser/parse_clause.c
src/backend/parser/parse_clause.c
+6
-8
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+3
-2
src/backend/parser/parse_func.c
src/backend/parser/parse_func.c
+8
-9
src/backend/parser/parse_node.c
src/backend/parser/parse_node.c
+9
-12
src/backend/parser/parse_relation.c
src/backend/parser/parse_relation.c
+74
-41
src/include/nodes/makefuncs.h
src/include/nodes/makefuncs.h
+2
-1
src/include/nodes/primnodes.h
src/include/nodes/primnodes.h
+3
-1
src/include/parser/parse_node.h
src/include/parser/parse_node.h
+3
-2
src/include/parser/parse_relation.h
src/include/parser/parse_relation.h
+4
-3
No files found.
src/backend/commands/recipe.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.1
7 1998/01/05 16:38:57
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.1
8 1998/01/20 22:10:53
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -494,6 +494,7 @@ tg_replaceNumberedParam(Node *expression,
...
@@ -494,6 +494,7 @@ tg_replaceNumberedParam(Node *expression,
newVar
=
makeVar
(
rt_ind
,
newVar
=
makeVar
(
rt_ind
,
0
,
/* the whole tuple */
0
,
/* the whole tuple */
TypeGet
(
teeRelName
,
&
defined
),
TypeGet
(
teeRelName
,
&
defined
),
0
,
rt_ind
,
rt_ind
,
0
);
0
);
return
(
Node
*
)
newVar
;
return
(
Node
*
)
newVar
;
...
@@ -503,6 +504,7 @@ tg_replaceNumberedParam(Node *expression,
...
@@ -503,6 +504,7 @@ tg_replaceNumberedParam(Node *expression,
1
,
/* just the first field,
1
,
/* just the first field,
* which is 'result' */
* which is 'result' */
TypeGet
(
teeRelName
,
&
defined
),
TypeGet
(
teeRelName
,
&
defined
),
0
,
rt_ind
,
rt_ind
,
0
);
0
);
return
(
Node
*
)
newVar
;
return
(
Node
*
)
newVar
;
...
...
src/backend/nodes/copyfuncs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.3
4 1998/01/20 05:03:40
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.3
5 1998/01/20 22:10:58
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -671,6 +671,7 @@ _copyVar(Var *from)
...
@@ -671,6 +671,7 @@ _copyVar(Var *from)
newnode
->
varno
=
from
->
varno
;
newnode
->
varno
=
from
->
varno
;
newnode
->
varattno
=
from
->
varattno
;
newnode
->
varattno
=
from
->
varattno
;
newnode
->
vartype
=
from
->
vartype
;
newnode
->
vartype
=
from
->
vartype
;
newnode
->
varlevelsup
=
from
->
varlevelsup
;
newnode
->
varnoold
=
from
->
varnoold
;
newnode
->
varnoold
=
from
->
varnoold
;
newnode
->
varoattno
=
from
->
varoattno
;
newnode
->
varoattno
=
from
->
varoattno
;
...
...
src/backend/nodes/equalfuncs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.1
2 1998/01/07 21:03:26
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.1
3 1998/01/20 22:11:02
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -129,6 +129,8 @@ _equalVar(Var *a, Var *b)
...
@@ -129,6 +129,8 @@ _equalVar(Var *a, Var *b)
return
(
false
);
return
(
false
);
if
(
a
->
vartype
!=
b
->
vartype
)
if
(
a
->
vartype
!=
b
->
vartype
)
return
(
false
);
return
(
false
);
if
(
a
->
varlevelsup
!=
b
->
varlevelsup
)
return
(
false
);
if
(
a
->
varnoold
!=
b
->
varnoold
)
if
(
a
->
varnoold
!=
b
->
varnoold
)
return
(
false
);
return
(
false
);
if
(
a
->
varoattno
!=
b
->
varoattno
)
if
(
a
->
varoattno
!=
b
->
varoattno
)
...
...
src/backend/nodes/makefuncs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.
4 1997/09/08 02:23:39
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.
5 1998/01/20 22:11:05
momjian Exp $
*
*
* NOTES
* NOTES
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
* Creator functions in POSTGRES 4.2 are generated automatically. Most of
...
@@ -53,6 +53,7 @@ Var *
...
@@ -53,6 +53,7 @@ Var *
makeVar
(
Index
varno
,
makeVar
(
Index
varno
,
AttrNumber
varattno
,
AttrNumber
varattno
,
Oid
vartype
,
Oid
vartype
,
Index
varlevelsup
,
Index
varnoold
,
Index
varnoold
,
AttrNumber
varoattno
)
AttrNumber
varoattno
)
{
{
...
@@ -61,6 +62,7 @@ makeVar(Index varno,
...
@@ -61,6 +62,7 @@ makeVar(Index varno,
var
->
varno
=
varno
;
var
->
varno
=
varno
;
var
->
varattno
=
varattno
;
var
->
varattno
=
varattno
;
var
->
vartype
=
vartype
;
var
->
vartype
=
vartype
;
var
->
varlevelsup
=
varlevelsup
;
var
->
varnoold
=
varnoold
;
var
->
varnoold
=
varnoold
;
var
->
varoattno
=
varoattno
;
var
->
varoattno
=
varoattno
;
...
...
src/backend/nodes/outfuncs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.2
5 1998/01/20 05:03:49
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.2
6 1998/01/20 22:11:12
momjian Exp $
*
*
* NOTES
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
* Every (plan) node in POSTGRES has an associated "out" routine which
...
@@ -698,6 +698,8 @@ _outVar(StringInfo str, Var *node)
...
@@ -698,6 +698,8 @@ _outVar(StringInfo str, Var *node)
appendStringInfo
(
str
,
buf
);
appendStringInfo
(
str
,
buf
);
sprintf
(
buf
,
" :vartype %u "
,
node
->
vartype
);
sprintf
(
buf
,
" :vartype %u "
,
node
->
vartype
);
appendStringInfo
(
str
,
buf
);
appendStringInfo
(
str
,
buf
);
sprintf
(
buf
,
" :varlevelsup %u "
,
node
->
varlevelsup
);
appendStringInfo
(
str
,
buf
);
sprintf
(
buf
,
" :varnoold %d "
,
node
->
varnoold
);
sprintf
(
buf
,
" :varnoold %d "
,
node
->
varnoold
);
appendStringInfo
(
str
,
buf
);
appendStringInfo
(
str
,
buf
);
sprintf
(
buf
,
" :varoattno %d "
,
node
->
varoattno
);
sprintf
(
buf
,
" :varoattno %d "
,
node
->
varoattno
);
...
...
src/backend/nodes/readfuncs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.2
1 1998/01/20 05:03:57
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.2
2 1998/01/20 22:11:15
momjian Exp $
*
*
* NOTES
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
* Most of the read functions for plan nodes are tested. (In fact, they
...
@@ -814,6 +814,10 @@ _readVar()
...
@@ -814,6 +814,10 @@ _readVar()
token
=
lsptok
(
NULL
,
&
length
);
/* get vartype */
token
=
lsptok
(
NULL
,
&
length
);
/* get vartype */
local_node
->
vartype
=
(
Oid
)
atol
(
token
);
local_node
->
vartype
=
(
Oid
)
atol
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :varlevelsup */
token
=
lsptok
(
NULL
,
&
length
);
/* get varlevelsup */
local_node
->
varlevelsup
=
(
Oid
)
atol
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :varnoold */
token
=
lsptok
(
NULL
,
&
length
);
/* eat :varnoold */
token
=
lsptok
(
NULL
,
&
length
);
/* get varnoold */
token
=
lsptok
(
NULL
,
&
length
);
/* get varnoold */
local_node
->
varnoold
=
(
Oid
)
atol
(
token
);
local_node
->
varnoold
=
(
Oid
)
atol
(
token
);
...
...
src/backend/optimizer/plan/createplan.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.2
3 1998/01/15 18:59:37
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.2
4 1998/01/20 22:11:25
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -701,6 +701,7 @@ fix_indxqual_references(Node *clause, Path *index_path)
...
@@ -701,6 +701,7 @@ fix_indxqual_references(Node *clause, Path *index_path)
makeVar
((
Index
)
lfirsti
(
index_path
->
parent
->
relids
),
makeVar
((
Index
)
lfirsti
(
index_path
->
parent
->
relids
),
1
,
/* func indices have one key */
1
,
/* func indices have one key */
((
Func
*
)
((
Expr
*
)
clause
)
->
oper
)
->
functype
,
((
Func
*
)
((
Expr
*
)
clause
)
->
oper
)
->
functype
,
0
,
(
Index
)
lfirsti
(
index_path
->
parent
->
relids
),
(
Index
)
lfirsti
(
index_path
->
parent
->
relids
),
0
);
0
);
...
...
src/backend/optimizer/plan/initsplan.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.
8 1997/09/08 21:45:19
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.
9 1998/01/20 22:11:27
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -116,7 +116,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
...
@@ -116,7 +116,7 @@ add_missing_vars_to_base_rels(Query *root, List *tlist)
!
rel_member
(
relids
,
root
->
base_relation_list_
))
!
rel_member
(
relids
,
root
->
base_relation_list_
))
{
{
var
=
makeVar
(
varno
,
-
2
,
26
,
varno
,
-
2
);
var
=
makeVar
(
varno
,
-
2
,
26
,
0
,
varno
,
-
2
);
/* add it to base_relation_list_ */
/* add it to base_relation_list_ */
result
=
get_base_rel
(
root
,
varno
);
result
=
get_base_rel
(
root
,
varno
);
add_tl_element
(
result
,
var
);
add_tl_element
(
result
,
var
);
...
...
src/backend/optimizer/plan/planmain.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.1
6 1998/01/15 18:59:44
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.1
7 1998/01/20 22:11:29
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -464,7 +464,7 @@ make_groupPlan(List **tlist,
...
@@ -464,7 +464,7 @@ make_groupPlan(List **tlist,
else
else
te
->
expr
=
(
Node
*
)
makeVar
(
1
,
resdom
->
resno
,
te
->
expr
=
(
Node
*
)
makeVar
(
1
,
resdom
->
resno
,
resdom
->
restype
,
resdom
->
restype
,
-
1
,
resdom
->
resno
);
0
,
-
1
,
resdom
->
resno
);
}
}
sortplan
=
make_sort
(
sort_tlist
,
sortplan
=
make_sort
(
sort_tlist
,
...
...
src/backend/optimizer/plan/setrefs.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.1
5 1998/01/15 18:59:50
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.1
6 1998/01/20 22:11:32
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -440,6 +440,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
...
@@ -440,6 +440,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
return
(
makeVar
(
OUTER
,
return
(
makeVar
(
OUTER
,
outer_resdom
->
resno
,
outer_resdom
->
resno
,
var
->
vartype
,
var
->
vartype
,
0
,
var
->
varnoold
,
var
->
varnoold
,
var
->
varoattno
));
var
->
varoattno
));
}
}
...
@@ -453,6 +454,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
...
@@ -453,6 +454,7 @@ replace_joinvar_refs(Var *var, List *outer_tlist, List *inner_tlist)
return
(
makeVar
(
INNER
,
return
(
makeVar
(
INNER
,
inner_resdom
->
resno
,
inner_resdom
->
resno
,
var
->
vartype
,
var
->
vartype
,
0
,
var
->
varnoold
,
var
->
varnoold
,
var
->
varoattno
));
var
->
varoattno
));
}
}
...
@@ -497,6 +499,7 @@ tlist_temp_references(Oid tempid,
...
@@ -497,6 +499,7 @@ tlist_temp_references(Oid tempid,
(
Node
*
)
makeVar
(
tempid
,
(
Node
*
)
makeVar
(
tempid
,
xtl
->
resdom
->
resno
,
xtl
->
resdom
->
resno
,
xtl
->
resdom
->
restype
,
xtl
->
resdom
->
restype
,
0
,
tempid
,
tempid
,
oattno
));
oattno
));
...
...
src/backend/optimizer/prep/preptlist.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.
7 1998/01/16 23:20:09
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.
8 1998/01/20 22:11:34
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -114,7 +114,7 @@ preprocess_targetlist(List *tlist,
...
@@ -114,7 +114,7 @@ preprocess_targetlist(List *tlist,
0
,
0
,
1
);
1
);
var
=
makeVar
(
result_relation
,
-
1
,
27
,
result_relation
,
-
1
);
var
=
makeVar
(
result_relation
,
-
1
,
27
,
0
,
result_relation
,
-
1
);
ctid
=
makeNode
(
TargetEntry
);
ctid
=
makeNode
(
TargetEntry
);
ctid
->
resdom
=
resdom
;
ctid
->
resdom
=
resdom
;
...
@@ -322,7 +322,7 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
...
@@ -322,7 +322,7 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type)
TargetEntry
*
temp_list
=
NULL
;
TargetEntry
*
temp_list
=
NULL
;
temp_var
=
temp_var
=
makeVar
(
rt_index
,
attno
,
atttype
,
rt_index
,
attno
);
makeVar
(
rt_index
,
attno
,
atttype
,
0
,
rt_index
,
attno
);
temp_list
=
MakeTLE
(
makeResdom
(
attno
,
temp_list
=
MakeTLE
(
makeResdom
(
attno
,
atttype
,
atttype
,
...
...
src/backend/optimizer/util/clauses.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.1
3 1997/12/22 05:42:14
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.1
4 1998/01/20 22:11:39
momjian Exp $
*
*
* HISTORY
* HISTORY
* AUTHOR DATE MAJOR EVENT
* AUTHOR DATE MAJOR EVENT
...
@@ -377,7 +377,8 @@ clause_relids_vars(Node *clause, List **relids, List **vars)
...
@@ -377,7 +377,8 @@ clause_relids_vars(Node *clause, List **relids, List **vars)
Var
*
in_list
=
(
Var
*
)
lfirst
(
vi
);
Var
*
in_list
=
(
Var
*
)
lfirst
(
vi
);
if
(
in_list
->
varno
==
var
->
varno
&&
if
(
in_list
->
varno
==
var
->
varno
&&
in_list
->
varattno
==
var
->
varattno
)
in_list
->
varattno
==
var
->
varattno
&&
in_list
->
varlevelsup
==
var
->
varlevelsup
)
break
;
break
;
}
}
if
(
vi
==
NIL
)
if
(
vi
==
NIL
)
...
...
src/backend/optimizer/util/tlist.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.
8 1997/11/25 22:00:16
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.
9 1998/01/20 22:11:41
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -108,6 +108,7 @@ add_tl_element(Rel *rel, Var *var)
...
@@ -108,6 +108,7 @@ add_tl_element(Rel *rel, Var *var)
Var
*
newvar
=
makeVar
(
var
->
varno
,
Var
*
newvar
=
makeVar
(
var
->
varno
,
var
->
varattno
,
var
->
varattno
,
var
->
vartype
,
var
->
vartype
,
var
->
varlevelsup
,
var
->
varno
,
var
->
varno
,
var
->
varoattno
);
var
->
varoattno
);
...
@@ -287,7 +288,8 @@ match_varid(Var *test_var, List *tlist)
...
@@ -287,7 +288,8 @@ match_varid(Var *test_var, List *tlist)
* changed to INNER/OUTER.
* changed to INNER/OUTER.
*/
*/
if
(
tlvar
->
varnoold
==
test_var
->
varnoold
&&
if
(
tlvar
->
varnoold
==
test_var
->
varnoold
&&
tlvar
->
varoattno
==
test_var
->
varoattno
)
tlvar
->
varoattno
==
test_var
->
varoattno
&&
tlvar
->
varlevelsup
==
test_var
->
varlevelsup
)
{
{
if
(
tlvar
->
vartype
==
type_var
)
if
(
tlvar
->
vartype
==
type_var
)
...
...
src/backend/optimizer/util/var.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.
7 1997/12/22 05:42:16
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.
8 1998/01/20 22:11:43
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -209,6 +209,7 @@ var_equal(Var *var1, Var *var2)
...
@@ -209,6 +209,7 @@ var_equal(Var *var1, Var *var2)
if
(
IsA
(
var1
,
Var
)
&&
IsA
(
var2
,
Var
)
&&
if
(
IsA
(
var1
,
Var
)
&&
IsA
(
var2
,
Var
)
&&
(((
Var
*
)
var1
)
->
varno
==
((
Var
*
)
var2
)
->
varno
)
&&
(((
Var
*
)
var1
)
->
varno
==
((
Var
*
)
var2
)
->
varno
)
&&
(((
Var
*
)
var1
)
->
vartype
==
((
Var
*
)
var2
)
->
vartype
)
&&
(((
Var
*
)
var1
)
->
vartype
==
((
Var
*
)
var2
)
->
vartype
)
&&
(((
Var
*
)
var1
)
->
varlevelsup
==
((
Var
*
)
var2
)
->
varlevelsup
)
&&
(((
Var
*
)
var1
)
->
varattno
==
((
Var
*
)
var2
)
->
varattno
))
(((
Var
*
)
var1
)
->
varattno
==
((
Var
*
)
var2
)
->
varattno
))
{
{
...
...
src/backend/parser/README
View file @
7f31669b
...
@@ -12,7 +12,7 @@ parse_clause.c handle clauses like WHERE, ORDER BY, GROUP BY, ...
...
@@ -12,7 +12,7 @@ parse_clause.c handle clauses like WHERE, ORDER BY, GROUP BY, ...
parse_expr.c handle expressions like col, col + 3, x = 3 or x = 4
parse_expr.c handle expressions like col, col + 3, x = 3 or x = 4
parse_oper.c handle operations in expressions
parse_oper.c handle operations in expressions
parse_agg.c handle aggregates, like SUM(col1), AVG(col2), ...
parse_agg.c handle aggregates, like SUM(col1), AVG(col2), ...
parse_func.c handle functions
like date_part(col3), trim(col4), ...
parse_func.c handle functions
, table.column and column identifiers
parse_node.c create nodes for various structures
parse_node.c create nodes for various structures
parse_target.c handle the result list of the query
parse_target.c handle the result list of the query
...
...
src/backend/parser/analyze.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.6
7 1998/01/20 05:04:05
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.6
8 1998/01/20 22:11:51
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -219,7 +219,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
...
@@ -219,7 +219,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt)
qry
->
qual
=
transformWhereClause
(
pstate
,
stmt
->
whereClause
);
qry
->
qual
=
transformWhereClause
(
pstate
,
stmt
->
whereClause
);
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
stmt
->
relname
);
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
,
stmt
->
relname
,
NULL
);
qry
->
hasAggs
=
pstate
->
p_hasAggs
;
qry
->
hasAggs
=
pstate
->
p_hasAggs
;
if
(
pstate
->
p_hasAggs
)
if
(
pstate
->
p_hasAggs
)
...
@@ -320,7 +320,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
...
@@ -320,7 +320,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt)
/* now the range table will not change */
/* now the range table will not change */
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
stmt
->
relname
);
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
,
stmt
->
relname
,
NULL
);
qry
->
groupClause
=
transformGroupClause
(
pstate
,
qry
->
groupClause
=
transformGroupClause
(
pstate
,
stmt
->
groupClause
,
stmt
->
groupClause
,
...
@@ -816,7 +816,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
...
@@ -816,7 +816,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt)
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
rtable
=
pstate
->
p_rtable
;
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
stmt
->
relname
);
qry
->
resultRelation
=
refnameRangeTablePosn
(
pstate
,
stmt
->
relname
,
NULL
);
qry
->
hasAggs
=
pstate
->
p_hasAggs
;
qry
->
hasAggs
=
pstate
->
p_hasAggs
;
if
(
pstate
->
p_hasAggs
)
if
(
pstate
->
p_hasAggs
)
...
...
src/backend/parser/parse_clause.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.1
0 1998/01/20 05:04:12
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.1
1 1998/01/20 22:11:53
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,10 +45,9 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList)
...
@@ -45,10 +45,9 @@ makeRangeTable(ParseState *pstate, char *relname, List *frmList)
if
(
relname
==
NULL
)
if
(
relname
==
NULL
)
return
;
return
;
if
(
refnameRangeTablePosn
(
pstate
->
p_rtable
,
relname
)
<
1
)
Assert
(
pstate
->
p_rtable
==
NULL
);
rte
=
addRangeTableEntry
(
pstate
,
relname
,
relname
,
FALSE
,
FALSE
);
rte
=
addRangeTableEntry
(
pstate
,
relname
,
relname
,
FALSE
,
FALSE
);
else
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
relname
);
pstate
->
p_target_rangetblentry
=
rte
;
pstate
->
p_target_rangetblentry
=
rte
;
Assert
(
pstate
->
p_target_relation
==
NULL
);
Assert
(
pstate
->
p_target_relation
==
NULL
);
...
@@ -137,8 +136,7 @@ find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
...
@@ -137,8 +136,7 @@ find_targetlist_entry(ParseState *pstate, SortGroupBy *sortgroupby, List *tlist)
TargetEntry
*
target_result
=
NULL
;
TargetEntry
*
target_result
=
NULL
;
if
(
sortgroupby
->
range
)
if
(
sortgroupby
->
range
)
real_rtable_pos
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
real_rtable_pos
=
refnameRangeTablePosn
(
pstate
,
sortgroupby
->
range
,
NULL
);
sortgroupby
->
range
);
foreach
(
i
,
tlist
)
foreach
(
i
,
tlist
)
{
{
...
...
src/backend/parser/parse_expr.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.1
1 1998/01/20 05:04:14
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.1
2 1998/01/20 22:11:55
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -304,6 +304,7 @@ transformIdent(ParseState *pstate, Node *expr, int precedence)
...
@@ -304,6 +304,7 @@ transformIdent(ParseState *pstate, Node *expr, int precedence)
{
{
Attr
*
att
=
makeNode
(
Attr
);
Attr
*
att
=
makeNode
(
Attr
);
/* we add the relation name for them */
att
->
relname
=
rte
->
refname
;
att
->
relname
=
rte
->
refname
;
att
->
attrs
=
lcons
(
makeString
(
ident
->
name
),
NIL
);
att
->
attrs
=
lcons
(
makeString
(
ident
->
name
),
NIL
);
column_result
=
column_result
=
...
@@ -312,7 +313,7 @@ transformIdent(ParseState *pstate, Node *expr, int precedence)
...
@@ -312,7 +313,7 @@ transformIdent(ParseState *pstate, Node *expr, int precedence)
}
}
/* try to find the ident as a relation */
/* try to find the ident as a relation */
if
(
refnameRangeTableEntry
(
pstate
->
p_rtable
,
ident
->
name
)
!=
NULL
)
if
(
refnameRangeTableEntry
(
pstate
,
ident
->
name
)
!=
NULL
)
{
{
ident
->
isRel
=
TRUE
;
ident
->
isRel
=
TRUE
;
relation_result
=
(
Node
*
)
ident
;
relation_result
=
(
Node
*
)
ident
;
...
...
src/backend/parser/parse_func.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.
7 1998/01/20 05:04:16
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.
8 1998/01/20 22:11:55
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -174,13 +174,12 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
...
@@ -174,13 +174,12 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
{
{
RangeTblEntry
*
rte
;
RangeTblEntry
*
rte
;
Ident
*
ident
=
(
Ident
*
)
first_arg
;
Ident
*
ident
=
(
Ident
*
)
first_arg
;
/*
/*
* first arg is a relation. This could be a projection.
* first arg is a relation. This could be a projection.
*/
*/
refname
=
ident
->
name
;
refname
=
ident
->
name
;
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
);
rte
=
refnameRangeTableEntry
(
pstate
,
refname
);
if
(
rte
==
NULL
)
if
(
rte
==
NULL
)
rte
=
addRangeTableEntry
(
pstate
,
refname
,
refname
,
FALSE
,
FALSE
);
rte
=
addRangeTableEntry
(
pstate
,
refname
,
refname
,
FALSE
,
FALSE
);
...
@@ -196,6 +195,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
...
@@ -196,6 +195,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
Oid
dummyTypeId
;
Oid
dummyTypeId
;
return
((
Node
*
)
make_var
(
pstate
,
return
((
Node
*
)
make_var
(
pstate
,
relid
,
refname
,
refname
,
funcname
,
funcname
,
&
dummyTypeId
));
&
dummyTypeId
));
...
@@ -288,19 +288,18 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
...
@@ -288,19 +288,18 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
if
(
nodeTag
(
pair
)
==
T_Ident
&&
((
Ident
*
)
pair
)
->
isRel
)
if
(
nodeTag
(
pair
)
==
T_Ident
&&
((
Ident
*
)
pair
)
->
isRel
)
{
{
/*
/*
* a relation
* a relation
*/
*/
refname
=
((
Ident
*
)
pair
)
->
name
;
refname
=
((
Ident
*
)
pair
)
->
name
;
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
);
rte
=
refnameRangeTableEntry
(
pstate
,
refname
);
if
(
rte
==
NULL
)
if
(
rte
==
NULL
)
rte
=
addRangeTableEntry
(
pstate
,
refname
,
refname
,
rte
=
addRangeTableEntry
(
pstate
,
refname
,
refname
,
FALSE
,
FALSE
);
FALSE
,
FALSE
);
relname
=
rte
->
relname
;
relname
=
rte
->
relname
;
vnum
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
rte
->
refname
);
vnum
=
refnameRangeTablePosn
(
pstate
,
rte
->
refname
,
NULL
);
/*
/*
* for func(relname), the param to the function is the tuple
* for func(relname), the param to the function is the tuple
...
@@ -312,7 +311,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
...
@@ -312,7 +311,7 @@ ParseFuncOrColumn(ParseState *pstate, char *funcname, List *fargs,
toid
=
typeTypeId
(
typenameType
(
relname
));
toid
=
typeTypeId
(
typenameType
(
relname
));
/* replace it in the arg list */
/* replace it in the arg list */
lfirst
(
fargs
)
=
lfirst
(
fargs
)
=
makeVar
(
vnum
,
0
,
toid
,
vnum
,
0
);
makeVar
(
vnum
,
0
,
toid
,
0
,
vnum
,
0
);
}
}
else
if
(
!
attisset
)
else
if
(
!
attisset
)
{
/* set functions don't have parameters */
{
/* set functions don't have parameters */
...
@@ -1074,7 +1073,7 @@ setup_tlist(char *attname, Oid relid)
...
@@ -1074,7 +1073,7 @@ setup_tlist(char *attname, Oid relid)
0
,
0
,
(
Oid
)
0
,
(
Oid
)
0
,
0
);
0
);
varnode
=
makeVar
(
-
1
,
attno
,
typeid
,
-
1
,
attno
);
varnode
=
makeVar
(
-
1
,
attno
,
typeid
,
0
,
-
1
,
attno
);
tle
=
makeNode
(
TargetEntry
);
tle
=
makeNode
(
TargetEntry
);
tle
->
resdom
=
resnode
;
tle
->
resdom
=
resnode
;
...
@@ -1101,7 +1100,7 @@ setup_base_tlist(Oid typeid)
...
@@ -1101,7 +1100,7 @@ setup_base_tlist(Oid typeid)
0
,
0
,
(
Oid
)
0
,
(
Oid
)
0
,
0
);
0
);
varnode
=
makeVar
(
-
1
,
1
,
typeid
,
-
1
,
1
);
varnode
=
makeVar
(
-
1
,
1
,
typeid
,
0
,
-
1
,
1
);
tle
=
makeNode
(
TargetEntry
);
tle
=
makeNode
(
TargetEntry
);
tle
->
resdom
=
resnode
;
tle
->
resdom
=
resnode
;
tle
->
expr
=
(
Node
*
)
varnode
;
tle
->
expr
=
(
Node
*
)
varnode
;
...
...
src/backend/parser/parse_node.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.
9 1998/01/20 05:04:21
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.
10 1998/01/20 22:11:57
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -239,27 +239,24 @@ make_op(char *opname, Node *ltree, Node *rtree)
...
@@ -239,27 +239,24 @@ make_op(char *opname, Node *ltree, Node *rtree)
}
}
Var
*
Var
*
make_var
(
ParseState
*
pstate
,
char
*
refname
,
char
*
attrname
,
Oid
*
type_id
)
make_var
(
ParseState
*
pstate
,
Oid
relid
,
char
*
refname
,
char
*
attrname
,
Oid
*
type_id
)
{
{
Var
*
varnode
;
Var
*
varnode
;
int
vnum
,
int
vnum
,
attid
;
attid
;
Oid
vartypeid
;
Oid
vartypeid
;
RangeTblEntry
*
rte
;
int
sublevels_up
;
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
);
vnum
=
refnameRangeTablePosn
(
pstate
,
refname
,
&
sublevels_up
);
if
(
rte
==
NULL
)
rte
=
addRangeTableEntry
(
pstate
,
refname
,
refname
,
FALSE
,
FALSE
);
vnum
=
refnameRangeTablePosn
(
pstate
->
p_rtable
,
refname
);
attid
=
get_attnum
(
relid
,
attrname
);
attid
=
get_attnum
(
rte
->
relid
,
attrname
);
if
(
attid
==
InvalidAttrNumber
)
if
(
attid
==
InvalidAttrNumber
)
elog
(
ERROR
,
"Relation %s does not have attribute %s"
,
elog
(
ERROR
,
"Relation %s does not have attribute %s"
,
r
te
->
rel
name
,
attrname
);
r
ef
name
,
attrname
);
vartypeid
=
get_atttype
(
r
te
->
r
elid
,
attid
);
vartypeid
=
get_atttype
(
relid
,
attid
);
varnode
=
makeVar
(
vnum
,
attid
,
vartypeid
,
vnum
,
attid
);
varnode
=
makeVar
(
vnum
,
attid
,
vartypeid
,
sublevels_up
,
vnum
,
attid
);
*
type_id
=
vartypeid
;
*
type_id
=
vartypeid
;
return
varnode
;
return
varnode
;
...
...
src/backend/parser/parse_relation.c
View file @
7f31669b
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.
7 1998/01/20 05:04:24
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.
8 1998/01/20 22:12:01
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -67,29 +67,42 @@ static char *attnum_type[SPECIALS] = {
...
@@ -67,29 +67,42 @@ static char *attnum_type[SPECIALS] = {
/* given refname, return a pointer to the range table entry */
/* given refname, return a pointer to the range table entry */
RangeTblEntry
*
RangeTblEntry
*
refnameRangeTableEntry
(
List
*
rtabl
e
,
char
*
refname
)
refnameRangeTableEntry
(
ParseState
*
pstat
e
,
char
*
refname
)
{
{
List
*
temp
;
List
*
temp
;
foreach
(
temp
,
rtable
)
while
(
pstate
!=
NULL
)
{
foreach
(
temp
,
pstate
->
p_rtable
)
{
{
RangeTblEntry
*
rte
=
lfirst
(
temp
);
RangeTblEntry
*
rte
=
lfirst
(
temp
);
if
(
!
strcmp
(
rte
->
refname
,
refname
))
if
(
!
strcmp
(
rte
->
refname
,
refname
))
return
rte
;
return
rte
;
}
}
/* only allow correlated columns in WHERE clause */
if
(
pstate
->
p_in_where_clause
)
pstate
=
pstate
->
parentParseState
;
else
break
;
}
return
NULL
;
return
NULL
;
}
}
/* given refname, return id of variable; position starts with 1 */
/* given refname, return id of variable; position starts with 1 */
int
int
refnameRangeTablePosn
(
List
*
rtable
,
char
*
refname
)
refnameRangeTablePosn
(
ParseState
*
pstate
,
char
*
refname
,
int
*
sublevels_up
)
{
{
int
index
;
int
index
;
List
*
temp
;
List
*
temp
;
if
(
sublevels_up
)
*
sublevels_up
=
0
;
while
(
pstate
!=
NULL
)
{
index
=
1
;
index
=
1
;
foreach
(
temp
,
rtable
)
foreach
(
temp
,
pstate
->
p_
rtable
)
{
{
RangeTblEntry
*
rte
=
lfirst
(
temp
);
RangeTblEntry
*
rte
=
lfirst
(
temp
);
...
@@ -97,6 +110,15 @@ refnameRangeTablePosn(List *rtable, char *refname)
...
@@ -97,6 +110,15 @@ refnameRangeTablePosn(List *rtable, char *refname)
return
index
;
return
index
;
index
++
;
index
++
;
}
}
/* only allow correlated columns in WHERE clause */
if
(
pstate
->
p_in_where_clause
)
{
pstate
=
pstate
->
parentParseState
;
if
(
sublevels_up
)
(
*
sublevels_up
)
++
;
}
else
break
;
}
return
0
;
return
0
;
}
}
...
@@ -110,12 +132,14 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
...
@@ -110,12 +132,14 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
List
*
rtable
;
List
*
rtable
;
RangeTblEntry
*
rte_result
;
RangeTblEntry
*
rte_result
;
rte_result
=
NULL
;
while
(
pstate
!=
NULL
)
{
if
(
pstate
->
p_is_rule
)
if
(
pstate
->
p_is_rule
)
rtable
=
lnext
(
lnext
(
pstate
->
p_rtable
));
rtable
=
lnext
(
lnext
(
pstate
->
p_rtable
));
else
else
rtable
=
pstate
->
p_rtable
;
rtable
=
pstate
->
p_rtable
;
rte_result
=
NULL
;
foreach
(
et
,
rtable
)
foreach
(
et
,
rtable
)
{
{
RangeTblEntry
*
rte
=
lfirst
(
et
);
RangeTblEntry
*
rte
=
lfirst
(
et
);
...
@@ -136,6 +160,11 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
...
@@ -136,6 +160,11 @@ colnameRangeTableEntry(ParseState *pstate, char *colname)
rte_result
=
rte
;
rte_result
=
rte
;
}
}
}
}
/* only allow correlated columns in WHERE clause */
if
(
pstate
->
p_in_where_clause
&&
rte_result
==
NULL
)
pstate
=
pstate
->
parentParseState
;
else
break
;
}
return
rte_result
;
return
rte_result
;
}
}
...
@@ -152,10 +181,14 @@ addRangeTableEntry(ParseState *pstate,
...
@@ -152,10 +181,14 @@ addRangeTableEntry(ParseState *pstate,
{
{
Relation
relation
;
Relation
relation
;
RangeTblEntry
*
rte
=
makeNode
(
RangeTblEntry
);
RangeTblEntry
*
rte
=
makeNode
(
RangeTblEntry
);
int
sublevels_up
;
if
(
pstate
!=
NULL
&&
if
(
pstate
!=
NULL
)
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
)
!=
NULL
)
{
if
(
refnameRangeTablePosn
(
pstate
,
refname
,
&
sublevels_up
)
!=
0
&&
(
!
inFromCl
||
sublevels_up
==
0
))
elog
(
ERROR
,
"Table name %s specified more than once"
,
refname
);
elog
(
ERROR
,
"Table name %s specified more than once"
,
refname
);
}
rte
->
relname
=
pstrdup
(
relname
);
rte
->
relname
=
pstrdup
(
relname
);
rte
->
refname
=
pstrdup
(
refname
);
rte
->
refname
=
pstrdup
(
refname
);
...
@@ -191,7 +224,6 @@ addRangeTableEntry(ParseState *pstate,
...
@@ -191,7 +224,6 @@ addRangeTableEntry(ParseState *pstate,
/*
/*
* expandAll -
* expandAll -
* makes a list of attributes
* makes a list of attributes
* assumes reldesc caching works
*/
*/
List
*
List
*
expandAll
(
ParseState
*
pstate
,
char
*
relname
,
char
*
refname
,
int
*
this_resno
)
expandAll
(
ParseState
*
pstate
,
char
*
relname
,
char
*
refname
,
int
*
this_resno
)
...
@@ -206,7 +238,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
...
@@ -206,7 +238,7 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
int
type_len
;
int
type_len
;
RangeTblEntry
*
rte
;
RangeTblEntry
*
rte
;
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
);
rte
=
refnameRangeTableEntry
(
pstate
,
refname
);
if
(
rte
==
NULL
)
if
(
rte
==
NULL
)
rte
=
addRangeTableEntry
(
pstate
,
relname
,
refname
,
FALSE
,
FALSE
);
rte
=
addRangeTableEntry
(
pstate
,
relname
,
refname
,
FALSE
,
FALSE
);
...
@@ -225,7 +257,8 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
...
@@ -225,7 +257,8 @@ expandAll(ParseState *pstate, char *relname, char *refname, int *this_resno)
TargetEntry
*
te
=
makeNode
(
TargetEntry
);
TargetEntry
*
te
=
makeNode
(
TargetEntry
);
attrname
=
pstrdup
((
rdesc
->
rd_att
->
attrs
[
varattno
]
->
attname
).
data
);
attrname
=
pstrdup
((
rdesc
->
rd_att
->
attrs
[
varattno
]
->
attname
).
data
);
varnode
=
(
Var
*
)
make_var
(
pstate
,
refname
,
attrname
,
&
type_id
);
varnode
=
(
Var
*
)
make_var
(
pstate
,
rte
->
relid
,
refname
,
attrname
,
&
type_id
);
type_len
=
(
int
)
typeLen
(
typeidType
(
type_id
));
type_len
=
(
int
)
typeLen
(
typeidType
(
type_id
));
handleTargetColname
(
pstate
,
&
resname
,
refname
,
attrname
);
handleTargetColname
(
pstate
,
&
resname
,
refname
,
attrname
);
...
@@ -381,7 +414,7 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
...
@@ -381,7 +414,7 @@ checkTargetTypes(ParseState *pstate, char *target_colname,
return
;
return
;
if
(
refname
!=
NULL
)
if
(
refname
!=
NULL
)
rte
=
refnameRangeTableEntry
(
pstate
->
p_rtable
,
refname
);
rte
=
refnameRangeTableEntry
(
pstate
,
refname
);
else
else
{
{
rte
=
colnameRangeTableEntry
(
pstate
,
colname
);
rte
=
colnameRangeTableEntry
(
pstate
,
colname
);
...
...
src/include/nodes/makefuncs.h
View file @
7f31669b
...
@@ -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: makefuncs.h,v 1.
5 1997/09/08 02:37:15
momjian Exp $
* $Id: makefuncs.h,v 1.
6 1998/01/20 22:12:13
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -27,6 +27,7 @@ extern Var *
...
@@ -27,6 +27,7 @@ extern Var *
makeVar
(
Index
varno
,
makeVar
(
Index
varno
,
AttrNumber
varattno
,
AttrNumber
varattno
,
Oid
vartype
,
Oid
vartype
,
Index
varlevelsup
,
Index
varnoold
,
Index
varnoold
,
AttrNumber
varoattno
);
AttrNumber
varoattno
);
...
...
src/include/nodes/primnodes.h
View file @
7f31669b
...
@@ -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: primnodes.h,v 1.1
5 1998/01/19 18:11:10
momjian Exp $
* $Id: primnodes.h,v 1.1
6 1998/01/20 22:12:14
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -104,6 +104,7 @@ typedef struct Expr
...
@@ -104,6 +104,7 @@ typedef struct Expr
* (could be INNER or OUTER)
* (could be INNER or OUTER)
* varattno - attribute number of this var, or zero for all
* varattno - attribute number of this var, or zero for all
* vartype - pg_type tuple oid for the type of this var
* vartype - pg_type tuple oid for the type of this var
* varlevelsup - for subquery variables referencing outer relations
* varnoold - keep varno around in case it got changed to INNER/
* varnoold - keep varno around in case it got changed to INNER/
* OUTER (see match_varid)
* OUTER (see match_varid)
* varoattno - attribute number of this var
* varoattno - attribute number of this var
...
@@ -122,6 +123,7 @@ typedef struct Var
...
@@ -122,6 +123,7 @@ typedef struct Var
Index
varno
;
Index
varno
;
AttrNumber
varattno
;
AttrNumber
varattno
;
Oid
vartype
;
Oid
vartype
;
Index
varlevelsup
;
/* erased by upper optimizer */
Index
varnoold
;
/* only used by optimizer */
Index
varnoold
;
/* only used by optimizer */
AttrNumber
varoattno
;
/* only used by optimizer */
AttrNumber
varoattno
;
/* only used by optimizer */
}
Var
;
}
Var
;
...
...
src/include/parser/parse_node.h
View file @
7f31669b
...
@@ -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: parse_node.h,v 1.
6 1998/01/19 05:06:41
momjian Exp $
* $Id: parse_node.h,v 1.
7 1998/01/20 22:12:16
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -45,7 +45,8 @@ typedef struct ParseState
...
@@ -45,7 +45,8 @@ typedef struct ParseState
extern
ParseState
*
make_parsestate
(
ParseState
*
parentParseState
);
extern
ParseState
*
make_parsestate
(
ParseState
*
parentParseState
);
extern
Expr
*
make_op
(
char
*
opname
,
Node
*
ltree
,
Node
*
rtree
);
extern
Expr
*
make_op
(
char
*
opname
,
Node
*
ltree
,
Node
*
rtree
);
extern
Var
*
make_var
(
ParseState
*
pstate
,
char
*
refname
,
char
*
attrname
,
Oid
*
type_id
);
extern
Var
*
make_var
(
ParseState
*
pstate
,
Oid
relid
,
char
*
refname
,
char
*
attrname
,
Oid
*
type_id
);
extern
ArrayRef
*
make_array_ref
(
Node
*
expr
,
extern
ArrayRef
*
make_array_ref
(
Node
*
expr
,
List
*
indirection
);
List
*
indirection
);
extern
ArrayRef
*
make_array_set
(
Expr
*
target_expr
,
extern
ArrayRef
*
make_array_set
(
Expr
*
target_expr
,
...
...
src/include/parser/parse_relation.h
View file @
7f31669b
...
@@ -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: parse_relation.h,v 1.
5 1998/01/20 05:04:56
momjian Exp $
* $Id: parse_relation.h,v 1.
6 1998/01/20 22:12:17
momjian Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -20,8 +20,9 @@
...
@@ -20,8 +20,9 @@
#include <parser/parse_node.h>
#include <parser/parse_node.h>
#include <utils/rel.h>
#include <utils/rel.h>
extern
RangeTblEntry
*
refnameRangeTableEntry
(
List
*
rtable
,
char
*
refname
);
extern
RangeTblEntry
*
refnameRangeTableEntry
(
ParseState
*
pstate
,
char
*
refname
);
extern
int
refnameRangeTablePosn
(
List
*
rtable
,
char
*
refname
);
extern
int
refnameRangeTablePosn
(
ParseState
*
pstate
,
char
*
refname
,
int
*
sublevels_up
);
extern
RangeTblEntry
*
colnameRangeTableEntry
(
ParseState
*
pstate
,
char
*
colname
);
extern
RangeTblEntry
*
colnameRangeTableEntry
(
ParseState
*
pstate
,
char
*
colname
);
extern
RangeTblEntry
*
addRangeTableEntry
(
ParseState
*
pstate
,
extern
RangeTblEntry
*
addRangeTableEntry
(
ParseState
*
pstate
,
char
*
relname
,
char
*
relname
,
...
...
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