| 1 | /*------------------------------------------------------------------------- |
| 2 | * |
| 3 | * Utility routines for SQL dumping |
| 4 | * |
| 5 | * Basically this is stuff that is useful in both pg_dump and pg_dumpall. |
| 6 | * |
| 7 | * |
| 8 | * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
| 9 | * Portions Copyright (c) 1994, Regents of the University of California |
| 10 | * |
| 11 | * src/bin/pg_dump/dumputils.h |
| 12 | * |
| 13 | *------------------------------------------------------------------------- |
| 14 | */ |
| 15 | #ifndef DUMPUTILS_H |
| 16 | #define DUMPUTILS_H |
| 17 | |
| 18 | #include "libpq-fe.h" |
| 19 | #include "pqexpbuffer.h" |
| 20 | |
| 21 | /* |
| 22 | * Preferred strftime(3) format specifier for printing timestamps in pg_dump |
| 23 | * and friends. |
| 24 | * |
| 25 | * We don't print the timezone on Windows, because the names are long and |
| 26 | * localized, which means they may contain characters in various random |
| 27 | * encodings; this has been seen to cause encoding errors when reading the |
| 28 | * dump script. Think not to get around that by using %z, because |
| 29 | * (1) %z is not portable to pre-C99 systems, and |
| 30 | * (2) %z doesn't actually act differently from %Z on Windows anyway. |
| 31 | */ |
| 32 | #ifndef WIN32 |
| 33 | #define PGDUMP_STRFTIME_FMT "%Y-%m-%d %H:%M:%S %Z" |
| 34 | #else |
| 35 | #define PGDUMP_STRFTIME_FMT "%Y-%m-%d %H:%M:%S" |
| 36 | #endif |
| 37 | |
| 38 | |
| 39 | extern bool buildACLCommands(const char *name, const char *subname, const char *nspname, |
| 40 | const char *type, const char *acls, const char *racls, |
| 41 | const char *owner, const char *prefix, int remoteVersion, |
| 42 | PQExpBuffer sql); |
| 43 | extern bool buildDefaultACLCommands(const char *type, const char *nspname, |
| 44 | const char *acls, const char *racls, |
| 45 | const char *initacls, const char *initracls, |
| 46 | const char *owner, |
| 47 | int remoteVersion, |
| 48 | PQExpBuffer sql); |
| 49 | extern void buildShSecLabelQuery(PGconn *conn, const char *catalog_name, |
| 50 | Oid objectId, PQExpBuffer sql); |
| 51 | extern void emitShSecLabels(PGconn *conn, PGresult *res, |
| 52 | PQExpBuffer buffer, const char *objtype, const char *objname); |
| 53 | |
| 54 | extern void buildACLQueries(PQExpBuffer acl_subquery, PQExpBuffer racl_subquery, |
| 55 | PQExpBuffer init_acl_subquery, PQExpBuffer init_racl_subquery, |
| 56 | const char *acl_column, const char *acl_owner, |
| 57 | const char *obj_kind, bool binary_upgrade); |
| 58 | |
| 59 | extern bool variable_is_guc_list_quote(const char *name); |
| 60 | |
| 61 | extern bool SplitGUCList(char *rawstring, char separator, |
| 62 | char ***namelist); |
| 63 | |
| 64 | extern void makeAlterConfigCommand(PGconn *conn, const char *configitem, |
| 65 | const char *type, const char *name, |
| 66 | const char *type2, const char *name2, |
| 67 | PQExpBuffer buf); |
| 68 | |
| 69 | #endif /* DUMPUTILS_H */ |
| 70 | |