Debian Codegraph @

src/bin/pg_dump/dumputils.h

raw
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-2025, 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 char *sanitize_line(const char *str, bool want_hyphen);
40 extern bool buildACLCommands(const char *name, const char *subname, const char *nspname,
41 const char *type, const char *acls, const char *baseacls,
42 const char *owner, const char *prefix, int remoteVersion,
43 PQExpBuffer sql);
44 extern bool buildDefaultACLCommands(const char *type, const char *nspname,
45 const char *acls, const char *acldefault,
46 const char *owner,
47 int remoteVersion,
48 PQExpBuffer sql);
49
50 extern void quoteAclUserName(PQExpBuffer output, const char *input);
51
52 extern void buildShSecLabelQuery(const char *catalog_name,
53 Oid objectId, PQExpBuffer sql);
54 extern void emitShSecLabels(PGconn *conn, PGresult *res,
55 PQExpBuffer buffer, const char *objtype, const char *objname);
56
57 extern bool variable_is_guc_list_quote(const char *name);
58
59 extern void makeAlterConfigCommand(PGconn *conn, const char *configitem,
60 const char *type, const char *name,
61 const char *type2, const char *name2,
62 PQExpBuffer buf);
63 extern void create_or_open_dir(const char *dirname);
64
65 extern char *generate_restrict_key(void);
66 extern bool valid_restrict_key(const char *restrict_key);
67
68 #endif /* DUMPUTILS_H */