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

Function read_connect_arg

src/bin/psql/command.c:2823–2853  ·  view source on GitHub ↗

* Read and interpret an argument to the \connect slash command. * * Returns a malloc'd string, or NULL if no/empty argument. */

Source from the content-addressed store, hash-verified

2821 * Returns a malloc'd string, or NULL if no/empty argument.
2822 */
2823static char *
2824read_connect_arg(PsqlScanState scan_state)
2825{
2826 char *result;
2827 char quote;
2828
2829 /*
2830 * Ideally we should treat the arguments as SQL identifiers. But for
2831 * backwards compatibility with 7.2 and older pg_dump files, we have to
2832 * take unquoted arguments verbatim (don't downcase them). For now,
2833 * double-quoted arguments may be stripped of double quotes (as if SQL
2834 * identifiers). By 7.4 or so, pg_dump files can be expected to
2835 * double-quote all mixed-case \connect arguments, and then we can get rid
2836 * of OT_SQLIDHACK.
2837 */
2838 result = psql_scan_slash_option(scan_state, OT_SQLIDHACK, &quote, true);
2839
2840 if (!result)
2841 return NULL;
2842
2843 if (quote)
2844 return result;
2845
2846 if (*result == '\0' || strcmp(result, "-") == 0)
2847 {
2848 free(result);
2849 return NULL;
2850 }
2851
2852 return result;
2853}
2854
2855/*
2856 * Read a boolean expression, return it as a PQExpBuffer string.

Callers 1

exec_command_connectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected