2
0

string_utils.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "libpq-fe.h"
  19. #include "pqexpbuffer.h"
  20. /* Global variables controlling behavior of fmtId() and fmtQualifiedId() */
  21. extern PGDLLIMPORT int quote_all_identifiers;
  22. extern PQExpBuffer (*getLocalPQExpBuffer) (void);
  23. /* Functions */
  24. extern const char *fmtId(const char *identifier);
  25. extern const char *fmtQualifiedId(const char *schema, const char *id);
  26. extern char *formatPGVersionNumber(int version_number, bool include_minor,
  27. char *buf, size_t buflen);
  28. extern void appendStringLiteral(PQExpBuffer buf, const char *str,
  29. int encoding, bool std_strings);
  30. extern void appendStringLiteralConn(PQExpBuffer buf, const char *str,
  31. PGconn *conn);
  32. extern void appendStringLiteralDQ(PQExpBuffer buf, const char *str,
  33. const char *dqprefix);
  34. extern void appendByteaLiteral(PQExpBuffer buf,
  35. const unsigned char *str, size_t length,
  36. bool std_strings);
  37. extern void appendShellString(PQExpBuffer buf, const char *str);
  38. extern bool appendShellStringNoError(PQExpBuffer buf, const char *str);
  39. extern void appendConnStrVal(PQExpBuffer buf, const char *str);
  40. extern void appendPsqlMetaConnect(PQExpBuffer buf, const char *dbname);
  41. extern bool parsePGArray(const char *atext, char ***itemarray, int *nitems);
  42. extern void appendPGArray(PQExpBuffer buffer, const char *value);
  43. extern bool appendReloptionsArray(PQExpBuffer buffer, const char *reloptions,
  44. const char *prefix, int encoding, bool std_strings);
  45. extern bool processSQLNamePattern(PGconn *conn, PQExpBuffer buf,
  46. const char *pattern,
  47. bool have_where, bool force_escape,
  48. const char *schemavar, const char *namevar,
  49. const char *altnamevar, const char *visibilityrule,
  50. PQExpBuffer dbnamebuf, int *dotcnt);
  51. extern void patternToSQLRegex(int encoding, PQExpBuffer dbnamebuf,
  52. PQExpBuffer schemabuf, PQExpBuffer namebuf,
  53. const char *pattern, bool force_escape,
  54. bool want_literal_dbname, int *dotcnt);
  55. #endif /* STRING_UTILS_H */