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

Function constructConnStr

src/bin/pg_dump/pg_dumpall.c:2689–2715  ·  view source on GitHub ↗

---------- * Construct a connection string from the given keyword/value pairs. It is * used to pass the connection options to the pg_dump subprocess. * * The following parameters are excluded: * dbname - varies in each pg_dump invocation * password - it's not secure to pass a password on the command line * fallback_application_name - we'll let pg_dump set it * ---------- */

Source from the content-addressed store, hash-verified

2687 * ----------
2688 */
2689static char *
2690constructConnStr(const char **keywords, const char **values)
2691{
2692 PQExpBuffer buf = createPQExpBuffer();
2693 char *connstr;
2694 int i;
2695 bool firstkeyword = true;
2696
2697 /* Construct a new connection string in key='value' format. */
2698 for (i = 0; keywords[i] != NULL; i++)
2699 {
2700 if (strcmp(keywords[i], "dbname") == 0 ||
2701 strcmp(keywords[i], "password") == 0 ||
2702 strcmp(keywords[i], "fallback_application_name") == 0)
2703 continue;
2704
2705 if (!firstkeyword)
2706 appendPQExpBufferChar(buf, ' ');
2707 firstkeyword = false;
2708 appendPQExpBuffer(buf, "%s=", keywords[i]);
2709 appendConnStrVal(buf, values[i]);
2710 }
2711
2712 connstr = pg_strdup(buf->data);
2713 destroyPQExpBuffer(buf);
2714 return connstr;
2715}
2716
2717/*
2718 * Run a query, return the results, exit program on failure.

Callers 1

connectDatabaseFunction · 0.85

Calls 6

createPQExpBufferFunction · 0.85
appendPQExpBufferCharFunction · 0.85
appendPQExpBufferFunction · 0.85
pg_strdupFunction · 0.85
destroyPQExpBufferFunction · 0.85
appendConnStrValFunction · 0.50

Tested by

no test coverage detected