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
4557c846
Commit
4557c846
authored
Jan 06, 1998
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup of sort nodes and use of strtoul .
parent
f439eb35
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
114 additions
and
76 deletions
+114
-76
src/backend/nodes/outfuncs.c
src/backend/nodes/outfuncs.c
+61
-25
src/backend/nodes/readfuncs.c
src/backend/nodes/readfuncs.c
+53
-51
No files found.
src/backend/nodes/outfuncs.c
View file @
4557c846
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.1
5 1998/01/06 18:52:15
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.1
6 1998/01/06 23:19:47
momjian Exp $
*
* NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which
...
...
@@ -80,7 +80,7 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
_outNode
(
str
,
node
->
inhRelnames
);
appendStringInfo
(
str
,
" :constraints"
);
_outNode
(
str
,
node
->
constraints
);
}
/* _outCreateStmt() */
}
static
void
_outIndexStmt
(
StringInfo
str
,
IndexStmt
*
node
)
...
...
@@ -102,10 +102,10 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
appendStringInfo
(
str
,
" :rangetable "
);
_outNode
(
str
,
node
->
rangetable
);
appendStringInfo
(
str
,
" :lossy "
);
appendStringInfo
(
str
,
(
*
node
->
lossy
?
"
y"
:
"n
"
));
appendStringInfo
(
str
,
(
*
node
->
lossy
?
"
true"
:
"false
"
));
appendStringInfo
(
str
,
" :unique "
);
appendStringInfo
(
str
,
(
node
->
unique
?
"
y"
:
"n
"
));
}
/* _outIndexStmt() */
appendStringInfo
(
str
,
(
node
->
unique
?
"
true"
:
"false
"
));
}
static
void
_outColumnDef
(
StringInfo
str
,
ColumnDef
*
node
)
...
...
@@ -117,12 +117,32 @@ _outColumnDef(StringInfo str, ColumnDef *node)
appendStringInfo
(
str
,
" :typename "
);
_outNode
(
str
,
node
->
typename
);
appendStringInfo
(
str
,
" :is_not_null "
);
appendStringInfo
(
str
,
(
node
->
is_not_null
?
"
y"
:
"n
"
));
appendStringInfo
(
str
,
(
node
->
is_not_null
?
"
true"
:
"false
"
));
appendStringInfo
(
str
,
" :defval "
);
appendStringInfo
(
str
,
node
->
defval
);
appendStringInfo
(
str
,
" :constraints"
);
_outNode
(
str
,
node
->
constraints
);
}
/* _outColumnDef() */
}
static
void
_outTypeName
(
StringInfo
str
,
TypeName
*
node
)
{
char
buf
[
500
];
appendStringInfo
(
str
,
"TYPENAME"
);
appendStringInfo
(
str
,
" :name "
);
appendStringInfo
(
str
,
node
->
name
);
appendStringInfo
(
str
,
" :timezone "
);
appendStringInfo
(
str
,
(
node
->
timezone
?
"true"
:
"false"
));
appendStringInfo
(
str
,
" :setof "
);
appendStringInfo
(
str
,
(
node
->
setof
?
"true"
:
"false"
));
appendStringInfo
(
str
,
" :arrayBounds "
);
_outNode
(
str
,
node
->
arrayBounds
);
appendStringInfo
(
str
,
" :typlen "
);
sprintf
(
buf
,
" %d "
,
node
->
typlen
);
appendStringInfo
(
str
,
buf
);
}
static
void
_outIndexElem
(
StringInfo
str
,
IndexElem
*
node
)
...
...
@@ -137,7 +157,7 @@ _outIndexElem(StringInfo str, IndexElem *node)
appendStringInfo
(
str
,
node
->
class
);
appendStringInfo
(
str
,
" :tname"
);
_outNode
(
str
,
node
->
tname
);
}
/* _outIndexElem() */
}
static
void
_outQuery
(
StringInfo
str
,
Query
*
node
)
...
...
@@ -190,11 +210,11 @@ _outQuery(StringInfo str, Query *node)
appendStringInfo
(
str
,
" :into "
);
appendStringInfo
(
str
,
node
->
into
);
appendStringInfo
(
str
,
" :isPortal "
);
appendStringInfo
(
str
,
(
node
->
isPortal
?
"
y"
:
"n
"
));
appendStringInfo
(
str
,
(
node
->
isPortal
?
"
true"
:
"false
"
));
appendStringInfo
(
str
,
" :isBinary "
);
appendStringInfo
(
str
,
(
node
->
isBinary
?
"
y"
:
"n
"
));
appendStringInfo
(
str
,
(
node
->
isBinary
?
"
true"
:
"false
"
));
appendStringInfo
(
str
,
" :unionall "
);
appendStringInfo
(
str
,
(
node
->
unionall
?
"
y"
:
"n
"
));
appendStringInfo
(
str
,
(
node
->
unionall
?
"
true"
:
"false
"
));
appendStringInfo
(
str
,
" :unique "
);
appendStringInfo
(
str
,
node
->
uniqueFlag
);
appendStringInfo
(
str
,
" :sortClause "
);
...
...
@@ -220,21 +240,31 @@ _outQuery(StringInfo str, Query *node)
}
static
void
_outSort
GroupBy
(
StringInfo
str
,
SortGroupBy
*
node
)
_outSort
Clause
(
StringInfo
str
,
SortClause
*
node
)
{
char
buf
[
500
];
int
i
;
appendStringInfo
(
str
,
"SORT
GROUPBY
"
);
appendStringInfo
(
str
,
"SORT
CLAUSE
"
);
appendStringInfo
(
str
,
" :resno "
);
sprintf
(
buf
,
" %d "
,
node
->
resno
);
appendStringInfo
(
str
,
" :range "
);
appendStringInfo
(
str
,
node
->
range
);
appendStringInfo
(
str
,
" :name "
);
appendStringInfo
(
str
,
node
->
name
);
appendStringInfo
(
str
,
" :useOp "
);
appendStringInfo
(
str
,
node
->
useOp
);
appendStringInfo
(
str
,
" :resdom "
);
_outNode
(
str
,
node
->
resdom
);
appendStringInfo
(
str
,
" :opoid "
);
sprintf
(
buf
,
" %u "
,
node
->
opoid
);
appendStringInfo
(
str
,
buf
);
}
static
void
_outGroupClause
(
StringInfo
str
,
GroupClause
*
node
)
{
char
buf
[
500
];
appendStringInfo
(
str
,
"GROUPCLAUSE"
);
appendStringInfo
(
str
,
" :entry "
);
_outNode
(
str
,
node
->
entry
);
appendStringInfo
(
str
,
" :grpOpoid "
);
sprintf
(
buf
,
" %u "
,
node
->
grpOpoid
);
appendStringInfo
(
str
,
buf
);
}
/*
...
...
@@ -252,7 +282,7 @@ _outPlanInfo(StringInfo str, Plan *node)
sprintf
(
buf
,
" :width %d"
,
node
->
plan_width
);
appendStringInfo
(
str
,
buf
);
appendStringInfo
(
str
,
" :state "
);
appendStringInfo
(
str
,
(
node
->
state
==
(
EState
*
)
NULL
?
"nil"
:
"non-NIL"
)
);
appendStringInfo
(
str
,
node
->
state
?
"not-NULL"
:
"
\"\"
"
);
appendStringInfo
(
str
,
" :qptargetlist "
);
_outNode
(
str
,
node
->
targetlist
);
appendStringInfo
(
str
,
" :qpqual "
);
...
...
@@ -1544,6 +1574,9 @@ _outNode(StringInfo str, void *obj)
case
T_ColumnDef
:
_outColumnDef
(
str
,
obj
);
break
;
case
T_TypeName
:
_outTypeName
(
str
,
obj
);
break
;
case
T_IndexElem
:
_outIndexElem
(
str
,
obj
);
break
;
...
...
@@ -1551,8 +1584,11 @@ _outNode(StringInfo str, void *obj)
case
T_Query
:
_outQuery
(
str
,
obj
);
break
;
case
T_SortGroupBy
:
_outSortGroupBy
(
str
,
obj
);
case
T_SortClause
:
_outSortClause
(
str
,
obj
);
break
;
case
T_GroupClause
:
_outGroupClause
(
str
,
obj
);
break
;
case
T_Plan
:
_outPlan
(
str
,
obj
);
...
...
src/backend/nodes/readfuncs.c
View file @
4557c846
...
...
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.1
4 1998/01/06 18:52:22
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.1
5 1998/01/06 23:19:49
momjian Exp $
*
* NOTES
* Most of the read functions for plan nodes are tested. (In fact, they
...
...
@@ -174,51 +174,49 @@ _readQuery()
}
/* ----------------
* _readSort
GroupBy
* _readSort
Clause
* ----------------
*/
static
Sort
GroupBy
*
_readSort
GroupBy
()
static
Sort
Clause
*
_readSort
Clause
()
{
Sort
GroupBy
*
local_node
;
Sort
Clause
*
local_node
;
char
*
token
;
int
length
;
local_node
=
makeNode
(
Sort
GroupBy
);
local_node
=
makeNode
(
Sort
Clause
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip the :res
no
*/
token
=
lsptok
(
NULL
,
&
length
);
/* get res
no
*/
local_node
->
res
no
=
atoi
(
token
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip the :res
dom
*/
token
=
lsptok
(
NULL
,
&
length
);
/* get res
dom
*/
local_node
->
res
dom
=
nodeRead
(
true
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip :range */
token
=
lsptok
(
NULL
,
&
length
);
/* get range */
if
(
length
==
0
)
local_node
->
range
=
NULL
;
else
{
local_node
->
range
=
palloc
(
length
+
1
);
StrNCpy
(
local_node
->
range
,
token
,
length
+
1
);
}
token
=
lsptok
(
NULL
,
&
length
);
/* skip :opoid */
token
=
lsptok
(
NULL
,
&
length
);
/* get opoid */
local_node
->
opoid
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip :name */
token
=
lsptok
(
NULL
,
&
length
);
/* get name */
if
(
length
==
0
)
local_node
->
name
=
NULL
;
else
{
local_node
->
name
=
palloc
(
length
+
1
);
StrNCpy
(
local_node
->
name
,
token
,
length
+
1
);
}
return
(
local_node
);
}
token
=
lsptok
(
NULL
,
&
length
);
/* skip :useOp */
token
=
lsptok
(
NULL
,
&
length
);
/* get useOp */
if
(
length
==
0
)
local_node
->
useOp
=
NULL
;
else
{
local_node
->
useOp
=
palloc
(
length
+
1
);
StrNCpy
(
local_node
->
useOp
,
token
,
length
+
1
);
}
/* ----------------
* _readGroupClause
* ----------------
*/
static
GroupClause
*
_readGroupClause
()
{
GroupClause
*
local_node
;
char
*
token
;
int
length
;
local_node
=
makeNode
(
GroupClause
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip the :entry */
token
=
lsptok
(
NULL
,
&
length
);
/* get entry */
local_node
->
entry
=
nodeRead
(
true
);
token
=
lsptok
(
NULL
,
&
length
);
/* skip :grpOpoid */
token
=
lsptok
(
NULL
,
&
length
);
/* get grpOpoid */
local_node
->
grpOpoid
=
strtoul
(
token
,
NULL
,
10
);
return
(
local_node
);
}
...
...
@@ -248,7 +246,7 @@ _getPlan(Plan *node)
token
=
lsptok
(
NULL
,
&
length
);
/* eat the :state stuff */
token
=
lsptok
(
NULL
,
&
length
);
/* now get the state */
if
(
!
strncmp
(
token
,
"nil"
,
3
)
)
if
(
length
==
0
)
{
node
->
state
=
(
EState
*
)
NULL
;
}
...
...
@@ -343,7 +341,7 @@ _readAppend()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :unionrelid */
token
=
lsptok
(
NULL
,
&
length
);
/* get unionrelid */
local_node
->
unionrelid
=
atoi
(
token
);
local_node
->
unionrelid
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :unionrtentries */
local_node
->
unionrtentries
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -449,7 +447,7 @@ _readHashJoin()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :hashjoinop */
token
=
lsptok
(
NULL
,
&
length
);
/* get hashjoinop */
local_node
->
hashjoinop
=
atoi
(
token
);
local_node
->
hashjoinop
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :hashjointable */
token
=
lsptok
(
NULL
,
&
length
);
/* eat hashjointable */
...
...
@@ -490,7 +488,7 @@ _getScan(Scan *node)
token
=
lsptok
(
NULL
,
&
length
);
/* eat :scanrelid */
token
=
lsptok
(
NULL
,
&
length
);
/* get scanrelid */
node
->
scanrelid
=
atoi
(
token
);
node
->
scanrelid
=
strtoul
(
token
,
NULL
,
10
);
}
/* ----------------
...
...
@@ -735,7 +733,7 @@ _readResdom()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :reskey */
token
=
lsptok
(
NULL
,
&
length
);
/* get reskey */
local_node
->
reskey
=
atoi
(
token
);
local_node
->
reskey
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :reskeyop */
token
=
lsptok
(
NULL
,
&
length
);
/* get reskeyop */
...
...
@@ -816,7 +814,7 @@ _readVar()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :varno */
token
=
lsptok
(
NULL
,
&
length
);
/* get varno */
local_node
->
varno
=
atoi
(
token
);
local_node
->
varno
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :varattno */
token
=
lsptok
(
NULL
,
&
length
);
/* get varattno */
...
...
@@ -854,7 +852,7 @@ _readArray()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :arrayelemtype */
token
=
lsptok
(
NULL
,
&
length
);
/* get arrayelemtype */
local_node
->
arrayelemtype
=
(
Oid
)
atoi
(
token
);
local_node
->
arrayelemtype
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :arrayelemlength */
token
=
lsptok
(
NULL
,
&
length
);
/* get arrayelemlength */
...
...
@@ -896,7 +894,7 @@ _readArrayRef()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :refelemtype */
token
=
lsptok
(
NULL
,
&
length
);
/* get refelemtype */
local_node
->
refelemtype
=
(
Oid
)
atoi
(
token
);
local_node
->
refelemtype
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* eat :refattrlength */
token
=
lsptok
(
NULL
,
&
length
);
/* get refattrlength */
...
...
@@ -947,7 +945,7 @@ _readConst()
token
=
lsptok
(
NULL
,
&
length
);
/* get :constlen */
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
constlen
=
atoi
(
token
);
local_node
->
constlen
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :constisnull */
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
...
...
@@ -1337,7 +1335,7 @@ _readRangeTblEntry()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :inh */
token
=
lsptok
(
NULL
,
&
length
);
/* get :inh */
local_node
->
inh
=
atoi
(
token
)
;
local_node
->
inh
=
(
token
[
0
]
==
't'
)
?
true
:
false
;
token
=
lsptok
(
NULL
,
&
length
);
/* eat :refname */
token
=
lsptok
(
NULL
,
&
length
);
/* get :refname */
...
...
@@ -1351,7 +1349,7 @@ _readRangeTblEntry()
token
=
lsptok
(
NULL
,
&
length
);
/* eat :relid */
token
=
lsptok
(
NULL
,
&
length
);
/* get :relid */
local_node
->
relid
=
atoi
(
token
);
local_node
->
relid
=
strtoul
(
token
,
NULL
,
10
);
return
(
local_node
);
}
...
...
@@ -1676,7 +1674,7 @@ _readOrderKey()
token
=
lsptok
(
NULL
,
&
length
);
/* get :array_index */
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
array_index
=
atoi
(
token
);
local_node
->
array_index
=
strtoul
(
token
,
NULL
,
10
);
return
(
local_node
);
}
...
...
@@ -1838,7 +1836,7 @@ _readHInfo()
token
=
lsptok
(
NULL
,
&
length
);
/* get :hashop */
token
=
lsptok
(
NULL
,
&
length
);
/* now read it */
local_node
->
hashop
=
atoi
(
token
);
local_node
->
hashop
=
strtoul
(
token
,
NULL
,
10
);
token
=
lsptok
(
NULL
,
&
length
);
/* get :jmkeys */
local_node
->
jmethod
.
jmkeys
=
nodeRead
(
true
);
/* now read it */
...
...
@@ -2108,9 +2106,13 @@ parsePlanString(void)
{
return_value
=
_readQuery
();
}
else
if
(
!
strncmp
(
token
,
"SORTGROUPBY"
,
11
))
else
if
(
!
strncmp
(
token
,
"SORTCLAUSE"
,
10
))
{
return_value
=
_readSortClause
();
}
else
if
(
!
strncmp
(
token
,
"GROUPCLAUSE"
,
10
))
{
return_value
=
_read
SortGroupBy
();
return_value
=
_read
GroupClause
();
}
else
{
...
...
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