PostgreSQL Source Code  git master
common.h
Go to the documentation of this file.
1 /*
2  * common.h
3  * Common support routines for bin/scripts/
4  *
5  * Copyright (c) 2003-2018, 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 
18 {
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 appendQualifiedRelation(PQExpBuffer buf, const char *name,
52  PGconn *conn, const char *progname, bool echo);
53 
54 extern bool yesno_prompt(const char *question);
55 
56 extern void setup_cancel_handler(void);
57 
58 extern void SetCancelConn(PGconn *conn);
59 extern void ResetCancelConn(void);
60 
61 
62 #endif /* COMMON_H */
void setup_cancel_handler(void)
Definition: common.c:332
Definition: common.h:20
bool yesno_prompt(const char *question)
Definition: common.c:382
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
Definition: common.c:37
void executeCommand(PGconn *conn, const char *query, const char *progname, bool echo)
Definition: common.c:212
const char * progname
Definition: pg_standby.c:37
void SetCancelConn(void)
Definition: common.c:446
PGconn * connectDatabase(const char *dbname, const char *pghost, const char *pgport, const char *pguser, enum trivalue prompt_password, const char *progname, bool echo, bool fail_ok, bool allow_password_reuse)
Definition: common.c:68
bool executeMaintenanceCommand(PGconn *conn, const char *query, bool echo)
Definition: common.c:242
PGconn * conn
Definition: streamutil.c:55
static char * buf
Definition: pg_test_fsync.c:67
PGconn * connectMaintenanceDatabase(const char *maintenance_db, const char *pghost, const char *pgport, const char *pguser, enum trivalue prompt_password, const char *progname, bool echo)
Definition: common.c:159
Definition: common.h:21
bool CancelRequested
Definition: common.c:26
void appendQualifiedRelation(PQExpBuffer buf, const char *name, PGconn *conn, const char *progname, bool echo)
Definition: common.c:305
char * pghost
Definition: pgbench.c:193
trivalue
Definition: vacuumlo.c:32
void(* help_handler)(const char *progname)
Definition: common.h:26
char * dbname
Definition: streamutil.c:51
const char * name
Definition: encode.c:521
void ResetCancelConn(void)
Definition: common.c:476
PGresult * executeQuery(PGconn *conn, const char *query, const char *progname, bool echo)
Definition: common.c:185
char * pgport
Definition: pgbench.c:194