---------- * 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 * ---------- */
| 2687 | * ---------- |
| 2688 | */ |
| 2689 | static char * |
| 2690 | constructConnStr(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. |
no test coverage detected