diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/fe_utils/psqlscan.h | 15 | ||||
-rw-r--r-- | src/include/fe_utils/psqlscan_int.h | 2 | ||||
-rw-r--r-- | src/include/fe_utils/string_utils.h | 1 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/include/fe_utils/psqlscan.h b/src/include/fe_utils/psqlscan.h index 0cc632b821b..e9c81439254 100644 --- a/src/include/fe_utils/psqlscan.h +++ b/src/include/fe_utils/psqlscan.h @@ -48,13 +48,22 @@ typedef enum _promptStatus PROMPT_COPY } promptStatus_t; +/* Quoting request types for get_variable() callback */ +typedef enum +{ + PQUOTE_PLAIN, /* just return the actual value */ + PQUOTE_SQL_LITERAL, /* add quotes to make a valid SQL literal */ + PQUOTE_SQL_IDENT, /* quote if needed to make a SQL identifier */ + PQUOTE_SHELL_ARG /* quote if needed to be safe in a shell cmd */ +} PsqlScanQuoteType; + /* Callback functions to be used by the lexer */ typedef struct PsqlScanCallbacks { - /* Fetch value of a variable, as a pfree'able string; NULL if unknown */ + /* Fetch value of a variable, as a free'able string; NULL if unknown */ /* This pointer can be NULL if no variable substitution is wanted */ - char *(*get_variable) (const char *varname, bool escape, - bool as_ident, void *passthrough); + char *(*get_variable) (const char *varname, PsqlScanQuoteType quote, + void *passthrough); /* Print an error message someplace appropriate */ /* (very old gcc versions don't support attributes on function pointers) */ #if defined(__GNUC__) && __GNUC__ < 4 diff --git a/src/include/fe_utils/psqlscan_int.h b/src/include/fe_utils/psqlscan_int.h index b4044e806a8..af62f5ebdfc 100644 --- a/src/include/fe_utils/psqlscan_int.h +++ b/src/include/fe_utils/psqlscan_int.h @@ -141,6 +141,6 @@ extern char *psqlscan_extract_substring(PsqlScanState state, const char *txt, int len); extern void psqlscan_escape_variable(PsqlScanState state, const char *txt, int len, - bool as_ident); + PsqlScanQuoteType quote); #endif /* PSQLSCAN_INT_H */ diff --git a/src/include/fe_utils/string_utils.h b/src/include/fe_utils/string_utils.h index 6fb7f5e30ec..c68234335e2 100644 --- a/src/include/fe_utils/string_utils.h +++ b/src/include/fe_utils/string_utils.h @@ -42,6 +42,7 @@ extern void appendByteaLiteral(PQExpBuffer buf, bool std_strings); extern void appendShellString(PQExpBuffer buf, const char *str); +extern bool appendShellStringNoError(PQExpBuffer buf, const char *str); extern void appendConnStrVal(PQExpBuffer buf, const char *str); extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname); |