1 | /* |
2 | * common.h |
3 | * Common support routines for bin/scripts/ |
4 | * |
5 | * Copyright (c) 2003-2019, PostgreSQL Global Development Group |
6 | * |
7 | * src/bin/scripts/common.h |
8 | */ |
9 | #ifndef COMMON_H |
10 | #define COMMON_H |
11 | |
12 | #include "common/username.h" |
13 | #include "libpq-fe.h" |
14 | #include "getopt_long.h" /* pgrminclude ignore */ |
15 | #include "pqexpbuffer.h" /* pgrminclude ignore */ |
16 | |
17 | enum trivalue |
18 | { |
19 | TRI_DEFAULT, |
20 | TRI_NO, |
21 | TRI_YES |
22 | }; |
23 | |
24 | extern bool CancelRequested; |
25 | |
26 | typedef void (*help_handler) (const char *progname); |
27 | |
28 | extern void handle_help_version_opts(int argc, char *argv[], |
29 | const char *fixed_progname, |
30 | help_handler hlp); |
31 | |
32 | extern PGconn *connectDatabase(const char *dbname, const char *pghost, |
33 | const char *pgport, const char *pguser, |
34 | enum trivalue prompt_password, const char *progname, |
35 | bool echo, bool fail_ok, bool allow_password_reuse); |
36 | |
37 | extern PGconn *connectMaintenanceDatabase(const char *maintenance_db, |
38 | const char *pghost, const char *pgport, |
39 | const char *pguser, enum trivalue prompt_password, |
40 | const char *progname, bool echo); |
41 | |
42 | extern PGresult *executeQuery(PGconn *conn, const char *query, |
43 | const char *progname, bool echo); |
44 | |
45 | extern void executeCommand(PGconn *conn, const char *query, |
46 | const char *progname, bool echo); |
47 | |
48 | extern bool executeMaintenanceCommand(PGconn *conn, const char *query, |
49 | bool echo); |
50 | |
51 | extern void splitTableColumnsSpec(const char *spec, int encoding, |
52 | char **table, const char **columns); |
53 | |
54 | extern void appendQualifiedRelation(PQExpBuffer buf, const char *name, |
55 | PGconn *conn, const char *progname, bool echo); |
56 | |
57 | extern bool yesno_prompt(const char *question); |
58 | |
59 | extern void setup_cancel_handler(void); |
60 | |
61 | extern void SetCancelConn(PGconn *conn); |
62 | extern void ResetCancelConn(void); |
63 | |
64 | |
65 | #endif /* COMMON_H */ |
66 | |