Add utility function validate_conninfo_string()

This commit is contained in:
Ian Barwick
2020-05-05 11:15:33 +09:00
parent 5ee4540640
commit be8e5b45fa
2 changed files with 27 additions and 1 deletions

View File

@@ -705,10 +705,35 @@ param_get(t_conninfo_param_list *param_list, const char *param)
}
/*
* Validate a conninfo string by attempting to parse it.
*
* "errmsg": passed to PQconninfoParse(), may be NULL
*
* NOTE: PQconninfoParse() verifies the string format and checks for
* valid options but does not sanity check values.
*/
bool
validate_conninfo_string(const char *conninfo_str, char **errmsg)
{
PQconninfoOption *connOptions = NULL;
connOptions = PQconninfoParse(conninfo_str, errmsg);
if (connOptions == NULL)
return false;
return true;
}
/*
* Parse a conninfo string into a t_conninfo_param_list
*
* See conn_to_param_list() to do the same for a PGconn
* See conn_to_param_list() to do the same for a PGconn.
*
* "errmsg": passed to PQconninfoParse(), may be NULL
*
* "ignore_local_params": ignores those parameters specific
* to a local installation, i.e. when parsing an upstream