PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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-2017, 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 #define atooid(x) ((Oid) strtoul((x), NULL, 10))
23 
24 /* Global variables controlling behavior of fmtId() and fmtQualifiedId() */
25 extern int quote_all_identifiers;
26 extern PQExpBuffer (*getLocalPQExpBuffer) (void);
27 
28 /* Functions */
29 extern const char *fmtId(const char *identifier);
30 extern const char *fmtQualifiedId(int remoteVersion,
31  const char *schema, const char *id);
32 
33 extern char *formatPGVersionNumber(int version_number, bool include_minor,
34  char *buf, size_t buflen);
35 
36 extern void appendStringLiteral(PQExpBuffer buf, const char *str,
37  int encoding, bool std_strings);
38 extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
39  PGconn *conn);
40 extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
41  const char *dqprefix);
43  const unsigned char *str, size_t length,
44  bool std_strings);
45 
46 extern void appendShellString(PQExpBuffer buf, const char *str);
47 extern void appendConnStrVal(PQExpBuffer buf, const char *str);
48 extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
49 
50 extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
51 
52 extern bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
53  const char *prefix, int encoding, bool std_strings);
54 
56  const char *pattern,
57  bool have_where, bool force_escape,
58  const char *schemavar, const char *namevar,
59  const char *altnamevar, const char *visibilityrule);
60 
61 #endif /* STRING_UTILS_H */
int length(const List *list)
Definition: list.c:1271
PQExpBufferData * PQExpBuffer
Definition: pqexpbuffer.h:51
void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname)
Definition: string_utils.c:581
int quote_all_identifiers
Definition: ruleutils.c:296
void appendByteaLiteral(PQExpBuffer buf, const unsigned char *str, size_t length, bool std_strings)
Definition: string_utils.c:379
void appendShellString(PQExpBuffer buf, const char *str)
Definition: string_utils.c:430
void appendStringLiteralDQ(PQExpBuffer buf, const char *str, const char *dqprefix)
Definition: string_utils.c:336
PGconn * conn
Definition: streamutil.c:45
static char * buf
Definition: pg_test_fsync.c:65
bool parsePGArray(const char *atext, char ***itemarray, int *nitems)
Definition: string_utils.c:647
PQExpBuffer(* getLocalPQExpBuffer)(void)
Definition: string_utils.c:29
bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions, const char *prefix, int encoding, bool std_strings)
Definition: string_utils.c:731
char * formatPGVersionNumber(int version_number, bool include_minor, char *buf, size_t buflen)
Definition: string_utils.c:182
static char * encoding
Definition: initdb.c:121
void appendStringLiteralConn(PQExpBuffer buf, const char *str, PGconn *conn)
Definition: string_utils.c:298
const char * fmtId(const char *identifier)
Definition: string_utils.c:66
void appendConnStrVal(PQExpBuffer buf, const char *str)
Definition: string_utils.c:536
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)
Definition: string_utils.c:817
char * dbname
Definition: streamutil.c:41
const char * fmtQualifiedId(int remoteVersion, const char *schema, const char *id)
Definition: string_utils.c:150
void appendStringLiteral(PQExpBuffer buf, const char *str, int encoding, bool std_strings)
Definition: string_utils.c:220