PostgreSQL Source Code  git master
string_utils.h
Go to the documentation of this file.
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-2022, 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() */
24 extern PQExpBuffer (*getLocalPQExpBuffer) (void);
25 
26 /* Functions */
27 extern const char *fmtId(const char *identifier);
28 extern const char *fmtQualifiedId(const char *schema, const char *id);
29 
30 extern char *formatPGVersionNumber(int version_number, bool include_minor,
31  char *buf, size_t buflen);
32 
33 extern void appendStringLiteral(PQExpBuffer buf, const char *str,
34  int encoding, bool std_strings);
35 extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
36  PGconn *conn);
37 extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
38  const char *dqprefix);
40  const unsigned char *str, size_t length,
41  bool std_strings);
42 
43 extern void appendShellString(PQExpBuffer buf, const char *str);
44 extern bool appendShellStringNoError(PQExpBuffer buf, const char *str);
45 extern void appendConnStrVal(PQExpBuffer buf, const char *str);
46 extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
47 
48 extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
49 extern void appendPGArray(PQExpBuffer buffer, const char *value);
50 
51 extern bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
52  const char *prefix, int encoding, bool std_strings);
53 
55  const char *pattern,
56  bool have_where, bool force_escape,
57  const char *schemavar, const char *namevar,
58  const char *altnamevar, const char *visibilityrule,
59  PQExpBuffer dbnamebuf, int *dotcnt);
60 
61 extern void patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf,
62  PQExpBuffer schemabuf, PQExpBuffer namebuf,
63  const char *pattern, bool force_escape,
64  bool want_literal_dbname, int *dotcnt);
65 
66 #endif /* STRING_UTILS_H */
#define PGDLLIMPORT
Definition: c.h:1331
static struct @151 value
int32 encoding
Definition: pg_database.h:41
static char * buf
Definition: pg_test_fsync.c:67
PQExpBufferData * PQExpBuffer
Definition: pqexpbuffer.h:51
char * dbname
Definition: streamutil.c:51
PGconn * conn
Definition: streamutil.c:54
bool appendShellStringNoError(PQExpBuffer buf, const char *str)
Definition: string_utils.c:441
void appendShellString(PQExpBuffer buf, const char *str)
Definition: string_utils.c:429
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
Definition: string_utils.c:293
void appendPGArray(PQExpBuffer buffer, const char *value)
Definition: string_utils.c:740
bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf, const char *pattern, bool have_where, bool force_escape, const char *schemavar, const char *namevar, const char *altnamevar, const char *visibilityrule, PQExpBuffer dbnamebuf, int *dotcnt)
Definition: string_utils.c:893
void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname)
Definition: string_utils.c:590
void appendByteaLiteral(PQExpBuffer buf, const unsigned char *str, size_t length, bool std_strings)
Definition: string_utils.c:374
bool parsePGArray(const char *atext, char ***itemarray, int *nitems)
Definition: string_utils.c:657
void appendStringLiteral(PQExpBuffer buf, const char *str, int encoding, bool std_strings)
Definition: string_utils.c:215
void patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf, PQExpBuffer schemabuf, PQExpBuffer namebuf, const char *pattern, bool force_escape, bool want_literal_dbname, int *dotcnt)
bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions, const char *prefix, int encoding, bool std_strings)
Definition: string_utils.c:804
const char * fmtId(const char *identifier)
Definition: string_utils.c:64
const char * fmtQualifiedId(const char *schema, const char *id)
Definition: string_utils.c:145
PGDLLIMPORT int quote_all_identifiers
Definition: ruleutils.c:323
PQExpBuffer(* getLocalPQExpBuffer)(void)
Definition: string_utils.c:27
void appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
Definition: string_utils.c:331
void appendConnStrVal(PQExpBuffer buf, const char *str)
Definition: string_utils.c:545
char * formatPGVersionNumber(int version_number, bool include_minor, char *buf, size_t buflen)
Definition: string_utils.c:177