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
edc43458
Commit
edc43458
authored
Jan 06, 2014
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more use of psprintf()
parent
10a82cda
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
52 additions
and
119 deletions
+52
-119
contrib/dblink/dblink.c
contrib/dblink/dblink.c
+1
-4
contrib/hstore/hstore_io.c
contrib/hstore/hstore_io.c
+1
-5
contrib/pageinspect/btreefuncs.c
contrib/pageinspect/btreefuncs.c
+24
-49
contrib/pgstattuple/pgstatindex.c
contrib/pgstattuple/pgstatindex.c
+12
-22
doc/src/sgml/xtypes.sgml
doc/src/sgml/xtypes.sgml
+1
-2
src/backend/access/transam/multixact.c
src/backend/access/transam/multixact.c
+1
-2
src/backend/commands/define.c
src/backend/commands/define.c
+1
-6
src/backend/optimizer/plan/subselect.c
src/backend/optimizer/plan/subselect.c
+2
-6
src/backend/parser/parse_type.c
src/backend/parser/parse_type.c
+1
-2
src/backend/storage/smgr/md.c
src/backend/storage/smgr/md.c
+1
-3
src/backend/utils/adt/date.c
src/backend/utils/adt/date.c
+2
-4
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+2
-5
src/backend/utils/fmgr/funcapi.c
src/backend/utils/fmgr/funcapi.c
+1
-2
src/test/regress/regress.c
src/test/regress/regress.c
+1
-5
src/tutorial/complex.c
src/tutorial/complex.c
+1
-2
No files found.
contrib/dblink/dblink.c
View file @
edc43458
...
...
@@ -1563,10 +1563,7 @@ dblink_get_pkey(PG_FUNCTION_ARGS)
Datum
result
;
values
=
(
char
**
)
palloc
(
2
*
sizeof
(
char
*
));
values
[
0
]
=
(
char
*
)
palloc
(
12
);
/* sign, 10 digits, '\0' */
sprintf
(
values
[
0
],
"%d"
,
call_cntr
+
1
);
values
[
0
]
=
psprintf
(
"%d"
,
call_cntr
+
1
);
values
[
1
]
=
results
[
call_cntr
];
/* build the tuple */
...
...
contrib/hstore/hstore_io.c
View file @
edc43458
...
...
@@ -1114,11 +1114,7 @@ hstore_out(PG_FUNCTION_ARGS)
HEntry
*
entries
=
ARRPTR
(
in
);
if
(
count
==
0
)
{
out
=
palloc
(
1
);
*
out
=
'\0'
;
PG_RETURN_CSTRING
(
out
);
}
PG_RETURN_CSTRING
(
pstrdup
(
""
));
buflen
=
0
;
...
...
contrib/pageinspect/btreefuncs.c
View file @
edc43458
...
...
@@ -220,31 +220,17 @@ bt_page_stats(PG_FUNCTION_ARGS)
elog
(
ERROR
,
"return type must be a row type"
);
j
=
0
;
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
blkno
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%c"
,
stat
.
type
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
live_items
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
dead_items
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
avg_item_size
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
page_size
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
free_size
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
btpo_prev
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
btpo_next
);
values
[
j
]
=
palloc
(
32
);
if
(
stat
.
type
==
'd'
)
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
btpo
.
xact
);
else
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
btpo
.
level
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
stat
.
btpo_flags
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
blkno
);
values
[
j
++
]
=
psprintf
(
"%c"
,
stat
.
type
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
live_items
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
dead_items
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
avg_item_size
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
page_size
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
free_size
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
btpo_prev
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
btpo_next
);
values
[
j
++
]
=
psprintf
(
"%d"
,
(
stat
.
type
==
'd'
)
?
stat
.
btpo
.
xact
:
stat
.
btpo
.
level
);
values
[
j
++
]
=
psprintf
(
"%d"
,
stat
.
btpo_flags
);
tuple
=
BuildTupleFromCStrings
(
TupleDescGetAttInMetadata
(
tupleDesc
),
values
);
...
...
@@ -380,18 +366,13 @@ bt_page_items(PG_FUNCTION_ARGS)
itup
=
(
IndexTuple
)
PageGetItem
(
uargs
->
page
,
id
);
j
=
0
;
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
uargs
->
offset
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"(%u,%u)"
,
values
[
j
++
]
=
psprintf
(
"%d"
,
uargs
->
offset
);
values
[
j
++
]
=
psprintf
(
"(%u,%u)"
,
BlockIdGetBlockNumber
(
&
(
itup
->
t_tid
.
ip_blkid
)),
itup
->
t_tid
.
ip_posid
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
(
int
)
IndexTupleSize
(
itup
));
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%c"
,
IndexTupleHasNulls
(
itup
)
?
't'
:
'f'
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%c"
,
IndexTupleHasVarwidths
(
itup
)
?
't'
:
'f'
);
values
[
j
++
]
=
psprintf
(
"%d"
,
(
int
)
IndexTupleSize
(
itup
));
values
[
j
++
]
=
psprintf
(
"%c"
,
IndexTupleHasNulls
(
itup
)
?
't'
:
'f'
);
values
[
j
++
]
=
psprintf
(
"%c"
,
IndexTupleHasVarwidths
(
itup
)
?
't'
:
'f'
);
ptr
=
(
char
*
)
itup
+
IndexInfoFindDataOffset
(
itup
->
t_info
);
dlen
=
IndexTupleSize
(
itup
)
-
IndexInfoFindDataOffset
(
itup
->
t_info
);
...
...
@@ -477,18 +458,12 @@ bt_metap(PG_FUNCTION_ARGS)
elog
(
ERROR
,
"return type must be a row type"
);
j
=
0
;
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_magic
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_version
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_root
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_level
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_fastroot
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
metad
->
btm_fastlevel
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_magic
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_version
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_root
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_level
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_fastroot
);
values
[
j
++
]
=
psprintf
(
"%d"
,
metad
->
btm_fastlevel
);
tuple
=
BuildTupleFromCStrings
(
TupleDescGetAttInMetadata
(
tupleDesc
),
values
);
...
...
contrib/pgstattuple/pgstatindex.c
View file @
edc43458
...
...
@@ -271,39 +271,29 @@ pgstatindex_impl(Relation rel, FunctionCallInfo fcinfo)
elog
(
ERROR
,
"return type must be a row type"
);
j
=
0
;
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
indexStat
.
version
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%d"
,
indexStat
.
level
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
INT64_FORMAT
,
values
[
j
++
]
=
psprintf
(
"%d"
,
indexStat
.
version
);
values
[
j
++
]
=
psprintf
(
"%d"
,
indexStat
.
level
);
values
[
j
++
]
=
psprintf
(
INT64_FORMAT
,
(
indexStat
.
root_pages
+
indexStat
.
leaf_pages
+
indexStat
.
internal_pages
+
indexStat
.
deleted_pages
+
indexStat
.
empty_pages
)
*
BLCKSZ
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
"%u"
,
indexStat
.
root_blkno
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
INT64_FORMAT
,
indexStat
.
internal_pages
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
INT64_FORMAT
,
indexStat
.
leaf_pages
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
INT64_FORMAT
,
indexStat
.
empty_pages
);
values
[
j
]
=
palloc
(
32
);
snprintf
(
values
[
j
++
],
32
,
INT64_FORMAT
,
indexStat
.
deleted_pages
);
values
[
j
]
=
palloc
(
32
);
values
[
j
++
]
=
psprintf
(
"%u"
,
indexStat
.
root_blkno
);
values
[
j
++
]
=
psprintf
(
INT64_FORMAT
,
indexStat
.
internal_pages
);
values
[
j
++
]
=
psprintf
(
INT64_FORMAT
,
indexStat
.
leaf_pages
);
values
[
j
++
]
=
psprintf
(
INT64_FORMAT
,
indexStat
.
empty_pages
);
values
[
j
++
]
=
psprintf
(
INT64_FORMAT
,
indexStat
.
deleted_pages
);
if
(
indexStat
.
max_avail
>
0
)
snprintf
(
values
[
j
++
],
32
,
"%.2f"
,
values
[
j
++
]
=
psprintf
(
"%.2f"
,
100
.
0
-
(
double
)
indexStat
.
free_space
/
(
double
)
indexStat
.
max_avail
*
100
.
0
);
else
snprintf
(
values
[
j
++
],
32
,
"NaN"
);
values
[
j
]
=
palloc
(
32
);
values
[
j
++
]
=
pstrdup
(
"NaN"
);
if
(
indexStat
.
leaf_pages
>
0
)
snprintf
(
values
[
j
++
],
32
,
"%.2f"
,
values
[
j
++
]
=
psprintf
(
"%.2f"
,
(
double
)
indexStat
.
fragments
/
(
double
)
indexStat
.
leaf_pages
*
100
.
0
);
else
snprintf
(
values
[
j
++
],
32
,
"NaN"
);
values
[
j
++
]
=
pstrdup
(
"NaN"
);
tuple
=
BuildTupleFromCStrings
(
TupleDescGetAttInMetadata
(
tupleDesc
),
values
);
...
...
doc/src/sgml/xtypes.sgml
View file @
edc43458
...
...
@@ -108,8 +108,7 @@ complex_out(PG_FUNCTION_ARGS)
Complex *complex = (Complex *) PG_GETARG_POINTER(0);
char *result;
result = (char *) palloc(100);
snprintf(result, 100, "(%g,%g)", complex->x, complex->y);
result = psprintf("(%g,%g)", complex->x, complex->y);
PG_RETURN_CSTRING(result);
}
]]>
...
...
src/backend/access/transam/multixact.c
View file @
edc43458
...
...
@@ -2757,8 +2757,7 @@ pg_get_multixact_members(PG_FUNCTION_ARGS)
HeapTuple
tuple
;
char
*
values
[
2
];
values
[
0
]
=
palloc
(
32
);
sprintf
(
values
[
0
],
"%u"
,
multi
->
members
[
multi
->
iter
].
xid
);
values
[
0
]
=
psprintf
(
"%u"
,
multi
->
members
[
multi
->
iter
].
xid
);
values
[
1
]
=
mxstatus_to_string
(
multi
->
members
[
multi
->
iter
].
status
);
tuple
=
BuildTupleFromCStrings
(
funccxt
->
attinmeta
,
values
);
...
...
src/backend/commands/define.c
View file @
edc43458
...
...
@@ -56,12 +56,7 @@ defGetString(DefElem *def)
switch
(
nodeTag
(
def
->
arg
))
{
case
T_Integer
:
{
char
*
str
=
palloc
(
32
);
snprintf
(
str
,
32
,
"%ld"
,
(
long
)
intVal
(
def
->
arg
));
return
str
;
}
return
psprintf
(
"%ld"
,
(
long
)
intVal
(
def
->
arg
));
case
T_Float
:
/*
...
...
src/backend/optimizer/plan/subselect.c
View file @
edc43458
...
...
@@ -778,10 +778,7 @@ build_subplan(PlannerInfo *root, Plan *plan, PlannerInfo *subroot,
sprintf
(
splan
->
plan_name
+
offset
,
")"
);
}
else
{
splan
->
plan_name
=
palloc
(
32
);
sprintf
(
splan
->
plan_name
,
"SubPlan %d"
,
splan
->
plan_id
);
}
splan
->
plan_name
=
psprintf
(
"SubPlan %d"
,
splan
->
plan_id
);
/* Lastly, fill in the cost estimates for use later */
cost_subplan
(
root
,
splan
,
plan
);
...
...
@@ -2600,8 +2597,7 @@ SS_make_initplan_from_plan(PlannerInfo *root, Plan *plan,
node
->
setParam
=
list_make1_int
(
prm
->
paramid
);
/* Label the subplan for EXPLAIN purposes */
node
->
plan_name
=
palloc
(
64
);
sprintf
(
node
->
plan_name
,
"InitPlan %d (returns $%d)"
,
node
->
plan_name
=
psprintf
(
"InitPlan %d (returns $%d)"
,
node
->
plan_id
,
prm
->
paramid
);
return
prm
;
...
...
src/backend/parser/parse_type.c
View file @
edc43458
...
...
@@ -313,8 +313,7 @@ typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
if
(
IsA
(
&
ac
->
val
,
Integer
))
{
cstr
=
(
char
*
)
palloc
(
32
);
snprintf
(
cstr
,
32
,
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
cstr
=
psprintf
(
"%ld"
,
(
long
)
ac
->
val
.
val
.
ival
);
}
else
if
(
IsA
(
&
ac
->
val
,
Float
)
||
IsA
(
&
ac
->
val
,
String
))
...
...
src/backend/storage/smgr/md.c
View file @
edc43458
...
...
@@ -1649,9 +1649,7 @@ _mdfd_segpath(SMgrRelation reln, ForkNumber forknum, BlockNumber segno)
if
(
segno
>
0
)
{
/* be sure we have enough space for the '.segno' */
fullpath
=
(
char
*
)
palloc
(
strlen
(
path
)
+
12
);
sprintf
(
fullpath
,
"%s.%u"
,
path
,
segno
);
fullpath
=
psprintf
(
"%s.%u"
,
path
,
segno
);
pfree
(
path
);
}
else
...
...
src/backend/utils/adt/date.c
View file @
edc43458
...
...
@@ -91,14 +91,12 @@ anytime_typmodin(bool istz, ArrayType *ta)
static
char
*
anytime_typmodout
(
bool
istz
,
int32
typmod
)
{
char
*
res
=
(
char
*
)
palloc
(
64
);
const
char
*
tz
=
istz
?
" with time zone"
:
" without time zone"
;
if
(
typmod
>=
0
)
snprintf
(
res
,
64
,
"(%d)%s"
,
(
int
)
typmod
,
tz
);
return
psprintf
(
"(%d)%s"
,
(
int
)
typmod
,
tz
);
else
snprintf
(
res
,
64
,
"%s"
,
tz
);
return
res
;
return
psprintf
(
"%s"
,
tz
);
}
...
...
src/backend/utils/adt/timestamp.c
View file @
edc43458
...
...
@@ -116,15 +116,12 @@ anytimestamp_typmodin(bool istz, ArrayType *ta)
static
char
*
anytimestamp_typmodout
(
bool
istz
,
int32
typmod
)
{
char
*
res
=
(
char
*
)
palloc
(
64
);
const
char
*
tz
=
istz
?
" with time zone"
:
" without time zone"
;
if
(
typmod
>=
0
)
snprintf
(
res
,
64
,
"(%d)%s"
,
(
int
)
typmod
,
tz
);
return
psprintf
(
"(%d)%s"
,
(
int
)
typmod
,
tz
);
else
snprintf
(
res
,
64
,
"%s"
,
tz
);
return
res
;
return
psprintf
(
"%s"
,
tz
);
}
...
...
src/backend/utils/fmgr/funcapi.c
View file @
edc43458
...
...
@@ -1205,8 +1205,7 @@ build_function_result_tupdesc_d(Datum proallargtypes,
if
(
pname
==
NULL
||
pname
[
0
]
==
'\0'
)
{
/* Parameter is not named, so gin up a column name */
pname
=
(
char
*
)
palloc
(
32
);
snprintf
(
pname
,
32
,
"column%d"
,
numoutargs
+
1
);
pname
=
psprintf
(
"column%d"
,
numoutargs
+
1
);
}
outargnames
[
numoutargs
]
=
pname
;
numoutargs
++
;
...
...
src/test/regress/regress.c
View file @
edc43458
...
...
@@ -269,15 +269,11 @@ widget_in(char *str)
char
*
widget_out
(
WIDGET
*
widget
)
{
char
*
result
;
if
(
widget
==
NULL
)
return
NULL
;
result
=
(
char
*
)
palloc
(
60
);
sprintf
(
result
,
"(%g,%g,%g)"
,
return
psprintf
(
"(%g,%g,%g)"
,
widget
->
center
.
x
,
widget
->
center
.
y
,
widget
->
radius
);
return
result
;
}
PG_FUNCTION_INFO_V1
(
pt_in_widget
);
...
...
src/tutorial/complex.c
View file @
edc43458
...
...
@@ -73,8 +73,7 @@ complex_out(PG_FUNCTION_ARGS)
Complex
*
complex
=
(
Complex
*
)
PG_GETARG_POINTER
(
0
);
char
*
result
;
result
=
(
char
*
)
palloc
(
100
);
snprintf
(
result
,
100
,
"(%g,%g)"
,
complex
->
x
,
complex
->
y
);
result
=
psprintf
(
"(%g,%g)"
,
complex
->
x
,
complex
->
y
);
PG_RETURN_CSTRING
(
result
);
}
...
...
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