MCPcopy Create free account
hub / github.com/apache/cloudberry / conninfo_parse

Function conninfo_parse

src/interfaces/libpq/fe-connect.c:5694–5851  ·  view source on GitHub ↗

* Subroutine for parse_connection_string * * Deal with a string containing key=value pairs. */

Source from the content-addressed store, hash-verified

5692 * Deal with a string containing key=value pairs.
5693 */
5694static PQconninfoOption *
5695conninfo_parse(const char *conninfo, PQExpBuffer errorMessage,
5696 bool use_defaults)
5697{
5698 char *pname;
5699 char *pval;
5700 char *buf;
5701 char *cp;
5702 char *cp2;
5703 PQconninfoOption *options;
5704
5705 /* Make a working copy of PQconninfoOptions */
5706 options = conninfo_init(errorMessage);
5707 if (options == NULL)
5708 return NULL;
5709
5710 /* Need a modifiable copy of the input string */
5711 if ((buf = strdup(conninfo)) == NULL)
5712 {
5713 appendPQExpBufferStr(errorMessage,
5714 libpq_gettext("out of memory\n"));
5715 PQconninfoFree(options);
5716 return NULL;
5717 }
5718 cp = buf;
5719
5720 while (*cp)
5721 {
5722 /* Skip blanks before the parameter name */
5723 if (isspace((unsigned char) *cp))
5724 {
5725 cp++;
5726 continue;
5727 }
5728
5729 /* Get the parameter name */
5730 pname = cp;
5731 while (*cp)
5732 {
5733 if (*cp == '=')
5734 break;
5735 if (isspace((unsigned char) *cp))
5736 {
5737 *cp++ = '\0';
5738 while (*cp)
5739 {
5740 if (!isspace((unsigned char) *cp))
5741 break;
5742 cp++;
5743 }
5744 break;
5745 }
5746 cp++;
5747 }
5748
5749 /* Check that there is a following '=' */
5750 if (*cp != '=')
5751 {

Callers 1

parse_connection_stringFunction · 0.85

Calls 7

conninfo_initFunction · 0.85
appendPQExpBufferStrFunction · 0.85
libpq_gettextFunction · 0.85
PQconninfoFreeFunction · 0.85
appendPQExpBufferFunction · 0.85
conninfo_storevalFunction · 0.85
conninfo_add_defaultsFunction · 0.85

Tested by

no test coverage detected