PostgreSQL Source Code git master
dumputils.h
Go to the documentation of this file.
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. One could now possibly get around that by using %z, but %z
29 * was previously not portable to pre-C99 systems, and also previously %z
30 * didn't actually act differently from %Z on Windows. But of these problems
31 * might be obsolete now.
32 */
33#ifndef WIN32
34#define PGDUMP_STRFTIME_FMT "%Y-%m-%d %H:%M:%S %Z"
35#else
36#define PGDUMP_STRFTIME_FMT "%Y-%m-%d %H:%M:%S"
37#endif
38
39
40extern char *sanitize_line(const char *str, bool want_hyphen);
41extern bool buildACLCommands(const char *name, const char *subname, const char *nspname,
42 const char *type, const char *acls, const char *baseacls,
43 const char *owner, const char *prefix, int remoteVersion,
44 PQExpBuffer sql);
45extern bool buildDefaultACLCommands(const char *type, const char *nspname,
46 const char *acls, const char *acldefault,
47 const char *owner,
48 int remoteVersion,
49 PQExpBuffer sql);
50
51extern void quoteAclUserName(PQExpBuffer output, const char *input);
52
53extern void buildShSecLabelQuery(const char *catalog_name,
54 Oid objectId, PQExpBuffer sql);
55extern void emitShSecLabels(PGconn *conn, PGresult *res,
56 PQExpBuffer buffer, const char *objtype, const char *objname);
57
58extern bool variable_is_guc_list_quote(const char *name);
59
60extern bool SplitGUCList(char *rawstring, char separator,
61 char ***namelist);
62
63extern void makeAlterConfigCommand(PGconn *conn, const char *configitem,
64 const char *type, const char *name,
65 const char *type2, const char *name2,
67extern void create_or_open_dir(const char *dirname);
68
69extern char *generate_restrict_key(void);
70extern bool valid_restrict_key(const char *restrict_key);
71
72#endif /* DUMPUTILS_H */
Acl * acldefault(ObjectType objtype, Oid ownerId)
Definition: acl.c:803
char * generate_restrict_key(void)
Definition: dumputils.c:972
bool buildACLCommands(const char *name, const char *subname, const char *nspname, const char *type, const char *acls, const char *baseacls, const char *owner, const char *prefix, int remoteVersion, PQExpBuffer sql)
Definition: dumputils.c:104
bool valid_restrict_key(const char *restrict_key)
Definition: dumputils.c:996
void buildShSecLabelQuery(const char *catalog_name, Oid objectId, PQExpBuffer sql)
Definition: dumputils.c:678
void makeAlterConfigCommand(PGconn *conn, const char *configitem, const char *type, const char *name, const char *type2, const char *name2, PQExpBuffer buf)
Definition: dumputils.c:864
bool buildDefaultACLCommands(const char *type, const char *nspname, const char *acls, const char *acldefault, const char *owner, int remoteVersion, PQExpBuffer sql)
Definition: dumputils.c:366
char * sanitize_line(const char *str, bool want_hyphen)
Definition: dumputils.c:52
void create_or_open_dir(const char *dirname)
Definition: dumputils.c:939
bool variable_is_guc_list_quote(const char *name)
Definition: dumputils.c:730
void quoteAclUserName(PQExpBuffer output, const char *input)
Definition: dumputils.c:585
void emitShSecLabels(PGconn *conn, PGresult *res, PQExpBuffer buffer, const char *objtype, const char *objname)
Definition: dumputils.c:696
bool SplitGUCList(char *rawstring, char separator, char ***namelist)
Definition: dumputils.c:764
const char * str
FILE * input
FILE * output
static char * restrict_key
Definition: pg_dumpall.c:125
NameData subname
static char * buf
Definition: pg_test_fsync.c:72
unsigned int Oid
Definition: postgres_ext.h:32
PGconn * conn
Definition: streamutil.c:52
const char * type
const char * name