1/*-------------------------------------------------------------------------
2 *
3 * String-processing utility routines for frontend code
4 *
5 * Utility functions that interpret backend output or quote strings for
6 * assorted contexts.
7 *
8 *
9 * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
10 * Portions Copyright (c) 1994, Regents of the University of California
11 *
12 * src/include/fe_utils/string_utils.h
13 *
14 *-------------------------------------------------------------------------
15 */
16#ifndef STRING_UTILS_H
17#define STRING_UTILS_H
18
19#include "libpq-fe.h"
20#include "pqexpbuffer.h"
21
22/* Global variables controlling behavior of fmtId() and fmtQualifiedId() */
23extern int quote_all_identifiers;
24extern PQExpBuffer (*getLocalPQExpBuffer) (void);
25
26/* Functions */
27extern const char *fmtId(const char *identifier);
28extern const char *fmtQualifiedId(const char *schema, const char *id);
29
30extern char *formatPGVersionNumber(int version_number, bool include_minor,
31 char *buf, size_t buflen);
32
33extern void appendStringLiteral(PQExpBuffer buf, const char *str,
34 int encoding, bool std_strings);
35extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
36 PGconn *conn);
37extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
38 const char *dqprefix);
39extern void appendByteaLiteral(PQExpBuffer buf,
40 const unsigned char *str, size_t length,
41 bool std_strings);
42
43extern void appendShellString(PQExpBuffer buf, const char *str);
44extern bool appendShellStringNoError(PQExpBuffer buf, const char *str);
45extern void appendConnStrVal(PQExpBuffer buf, const char *str);
46extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
47
48extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
49
50extern bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
51 const char *prefix, int encoding, bool std_strings);
52
53extern bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf,
54 const char *pattern,
55 bool have_where, bool force_escape,
56 const char *schemavar, const char *namevar,
57 const char *altnamevar, const char *visibilityrule);
58
59#endif /* STRING_UTILS_H */
60