diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index 1b2d72c6def3..a7c1b42e23ae 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -2875,15 +2875,12 @@ get_connect_string(const char *servername) ForeignServer *foreign_server = NULL; UserMapping *user_mapping; ListCell *cell; - StringInfoData buf; ForeignDataWrapper *fdw; AclResult aclresult; char *srvname; static const PQconninfoOption *options = NULL; - initStringInfo(&buf); - /* * Get list of valid libpq options. * @@ -2908,6 +2905,7 @@ get_connect_string(const char *servername) if (foreign_server) { + StringInfoData buf; Oid serverid = foreign_server->serverid; Oid fdwid = foreign_server->fdwid; Oid userid = GetUserId(); @@ -2920,6 +2918,8 @@ get_connect_string(const char *servername) if (aclresult != ACLCHECK_OK) aclcheck_error(aclresult, OBJECT_FOREIGN_SERVER, foreign_server->servername); + initStringInfo(&buf); + /* * First append hardcoded options needed for SCRAM pass-through, so if * the user overwrites these options we can ereport on