aboutsummaryrefslogtreecommitdiff
path: root/src/include/fe_utils/string_utils.h
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2016-03-24 15:55:44 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2016-03-24 15:55:57 -0400
commit588d963b00e5e4385b6425418e3faa726f63f72e (patch)
treeea104b491189a036fd36898359b960bb914f6a08 /src/include/fe_utils/string_utils.h
parenta596db332b8c7f593a82af86f69353ba08f6214c (diff)
downloadpostgresql-588d963b00e5e4385b6425418e3faa726f63f72e.tar.gz
postgresql-588d963b00e5e4385b6425418e3faa726f63f72e.zip
Create src/fe_utils/, and move stuff into there from pg_dump's dumputils.
Per discussion, we want to create a static library and put the stuff into it that until now has been shared across src/bin/ directories by ad-hoc methods like symlinking a source file. This commit creates the library and populates it with a couple of files that contain the widely-useful portions of pg_dump's dumputils.c file. dumputils.c survives, because it has some stuff that didn't seem appropriate for fe_utils, but it's significantly smaller and is no longer referenced from any other directory. Follow-on patches will move more stuff into fe_utils. The Mkvcbuild.pm hacking here is just a best guess; we'll see how the buildfarm likes it.
Diffstat (limited to 'src/include/fe_utils/string_utils.h')
-rw-r--r--src/include/fe_utils/string_utils.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/include/fe_utils/string_utils.h b/src/include/fe_utils/string_utils.h
new file mode 100644
index 00000000000..5d3fcc24271
--- /dev/null
+++ b/src/include/fe_utils/string_utils.h
@@ -0,0 +1,51 @@
+/*-------------------------------------------------------------------------
+ *
+ * String-processing utility routines for frontend code
+ *
+ * Assorted utility functions that are useful in constructing SQL queries
+ * and interpreting backend output.
+ *
+ *
+ * Portions Copyright (c) 1996-2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1994, Regents of the University of California
+ *
+ * src/include/fe_utils/string_utils.h
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef STRING_UTILS_H
+#define STRING_UTILS_H
+
+#include "libpq-fe.h"
+#include "pqexpbuffer.h"
+
+#define atooid(x) ((Oid) strtoul((x), NULL, 10))
+
+/* Global variables controlling behavior of fmtId() and fmtQualifiedId() */
+extern int quote_all_identifiers;
+extern PQExpBuffer (*getLocalPQExpBuffer) (void);
+
+/* Functions */
+extern const char *fmtId(const char *identifier);
+extern const char *fmtQualifiedId(int remoteVersion,
+ const char *schema, const char *id);
+
+extern void appendStringLiteral(PQExpBuffer buf, const char *str,
+ int encoding, bool std_strings);
+extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
+ PGconn *conn);
+extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
+ const char *dqprefix);
+extern void appendByteaLiteral(PQExpBuffer buf,
+ const unsigned char *str, size_t length,
+ bool std_strings);
+
+extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
+
+extern 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);
+
+#endif /* STRING_UTILS_H */