summaryrefslogtreecommitdiff
path: root/src/interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'src/interfaces')
-rw-r--r--src/interfaces/libpq/fe-connect.c46
1 files changed, 6 insertions, 40 deletions
diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c
index e2a06b3d929..638d103f8c0 100644
--- a/src/interfaces/libpq/fe-connect.c
+++ b/src/interfaces/libpq/fe-connect.c
@@ -22,6 +22,7 @@
#include <time.h>
#include <unistd.h>
+#include "common/connstrings.h"
#include "libpq-fe.h"
#include "libpq-int.h"
#include "fe-auth.h"
@@ -339,8 +340,6 @@ static void closePGconn(PGconn *conn);
static PQconninfoOption *conninfo_init(PQExpBuffer errorMessage);
static PQconninfoOption *parse_connection_string(const char *conninfo,
PQExpBuffer errorMessage, bool use_defaults);
-static int uri_prefix_length(const char *connstr);
-static bool recognized_connection_string(const char *connstr);
static PQconninfoOption *conninfo_parse(const char *conninfo,
PQExpBuffer errorMessage, bool use_defaults);
static PQconninfoOption *conninfo_array_parse(const char *const * keywords,
@@ -971,7 +970,7 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions,
* If the dbName parameter contains what looks like a connection string,
* parse it into conn struct using connectOptions1.
*/
- if (dbName && recognized_connection_string(dbName))
+ if (dbName && libpq_connstring_is_recognized(dbName))
{
if (!connectOptions1(conn, dbName))
return conn;
@@ -4185,7 +4184,7 @@ parse_connection_string(const char *connstr, PQExpBuffer errorMessage,
bool use_defaults)
{
/* Parse as URI if connection string matches URI prefix */
- if (uri_prefix_length(connstr) != 0)
+ if (libpq_connstring_uri_prefix_length(connstr) != 0)
return conninfo_uri_parse(connstr, errorMessage, use_defaults);
/* Parse as default otherwise */
@@ -4193,39 +4192,6 @@ parse_connection_string(const char *connstr, PQExpBuffer errorMessage,
}
/*
- * Checks if connection string starts with either of the valid URI prefix
- * designators.
- *
- * Returns the URI prefix length, 0 if the string doesn't contain a URI prefix.
- */
-static int
-uri_prefix_length(const char *connstr)
-{
- if (strncmp(connstr, uri_designator,
- sizeof(uri_designator) - 1) == 0)
- return sizeof(uri_designator) - 1;
-
- if (strncmp(connstr, short_uri_designator,
- sizeof(short_uri_designator) - 1) == 0)
- return sizeof(short_uri_designator) - 1;
-
- return 0;
-}
-
-/*
- * Recognized connection string either starts with a valid URI prefix or
- * contains a "=" in it.
- *
- * Must be consistent with parse_connection_string: anything for which this
- * returns true should at least look like it's parseable by that routine.
- */
-static bool
-recognized_connection_string(const char *connstr)
-{
- return uri_prefix_length(connstr) != 0 || strchr(connstr, '=') != NULL;
-}
-
-/*
* Subroutine for parse_connection_string
*
* Deal with a string containing key=value pairs.
@@ -4400,7 +4366,7 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,
*
* If expand_dbname is non-zero, and the value passed for the first occurrence
* of "dbname" keyword is a connection string (as indicated by
- * recognized_connection_string) then parse and process it, overriding any
+ * libpq_connstring_is_recognized) then parse and process it, overriding any
* previously processed conflicting keywords. Subsequent keywords will take
* precedence, however.
*/
@@ -4431,7 +4397,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values,
* defaults here -- those get picked up later. We only want to
* override for those parameters actually passed.
*/
- if (recognized_connection_string(pvalue))
+ if (libpq_connstring_is_recognized(pvalue))
{
dbname_options = parse_connection_string(pvalue, errorMessage, false);
if (dbname_options == NULL)
@@ -4722,7 +4688,7 @@ conninfo_uri_parse_options(PQconninfoOption *options, const char *uri,
start = buf;
/* Skip the URI prefix */
- prefix_len = uri_prefix_length(uri);
+ prefix_len = libpq_connstring_uri_prefix_length(uri);
if (prefix_len == 0)
{
/* Should never happen */