Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 22ef6b0

Browse files
committed
dblink: Change some StringInfo to StringInfoData
For consistency with other code and to avoid wasting some small amount of memory. From: Tsunakawa, Takayuki <tsunakawa.takay@jp.fujitsu.com>
1 parent acaf7cc commit 22ef6b0

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

contrib/dblink/dblink.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -2721,13 +2721,15 @@ get_connect_string(const char *servername)
27212721
ForeignServer *foreign_server = NULL;
27222722
UserMapping *user_mapping;
27232723
ListCell *cell;
2724-
StringInfo buf = makeStringInfo();
2724+
StringInfoData buf;
27252725
ForeignDataWrapper *fdw;
27262726
AclResult aclresult;
27272727
char *srvname;
27282728

27292729
static const PQconninfoOption *options = NULL;
27302730

2731+
initStringInfo(&buf);
2732+
27312733
/*
27322734
* Get list of valid libpq options.
27332735
*
@@ -2769,7 +2771,7 @@ get_connect_string(const char *servername)
27692771
DefElem *def = lfirst(cell);
27702772

27712773
if (is_valid_dblink_option(options, def->defname, ForeignDataWrapperRelationId))
2772-
appendStringInfo(buf, "%s='%s' ", def->defname,
2774+
appendStringInfo(&buf, "%s='%s' ", def->defname,
27732775
escape_param_str(strVal(def->arg)));
27742776
}
27752777

@@ -2778,7 +2780,7 @@ get_connect_string(const char *servername)
27782780
DefElem *def = lfirst(cell);
27792781

27802782
if (is_valid_dblink_option(options, def->defname, ForeignServerRelationId))
2781-
appendStringInfo(buf, "%s='%s' ", def->defname,
2783+
appendStringInfo(&buf, "%s='%s' ", def->defname,
27822784
escape_param_str(strVal(def->arg)));
27832785
}
27842786

@@ -2788,11 +2790,11 @@ get_connect_string(const char *servername)
27882790
DefElem *def = lfirst(cell);
27892791

27902792
if (is_valid_dblink_option(options, def->defname, UserMappingRelationId))
2791-
appendStringInfo(buf, "%s='%s' ", def->defname,
2793+
appendStringInfo(&buf, "%s='%s' ", def->defname,
27922794
escape_param_str(strVal(def->arg)));
27932795
}
27942796

2795-
return buf->data;
2797+
return buf.data;
27962798
}
27972799
else
27982800
return NULL;
@@ -2807,16 +2809,18 @@ static char *
28072809
escape_param_str(const char *str)
28082810
{
28092811
const char *cp;
2810-
StringInfo buf = makeStringInfo();
2812+
StringInfoData buf;
2813+
2814+
initStringInfo(&buf);
28112815

28122816
for (cp = str; *cp; cp++)
28132817
{
28142818
if (*cp == '\\' || *cp == '\'')
2815-
appendStringInfoChar(buf, '\\');
2816-
appendStringInfoChar(buf, *cp);
2819+
appendStringInfoChar(&buf, '\\');
2820+
appendStringInfoChar(&buf, *cp);
28172821
}
28182822

2819-
return buf->data;
2823+
return buf.data;
28202824
}
28212825

28222826
/*

0 commit comments

Comments
 (0)