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-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 "getopt_long.h" /* pgrminclude ignore */
14 #include "libpq-fe.h"
15 #include "pqexpbuffer.h" /* pgrminclude ignore */
16 
18 {
22 };
23 
24 typedef void (*help_handler) (const char *progname);
25 
26 extern void handle_help_version_opts(int argc, char *argv[],
27  const char *fixed_progname,
28  help_handler hlp);
29 
30 extern PGconn *connectDatabase(const char *dbname, const char *pghost,
31  const char *pgport, const char *pguser,
32  enum trivalue prompt_password, const char *progname,
33  bool echo, bool fail_ok, bool allow_password_reuse);
34 
35 extern PGconn *connectMaintenanceDatabase(const char *maintenance_db,
36  const char *pghost, const char *pgport,
37  const char *pguser, enum trivalue prompt_password,
38  const char *progname, bool echo);
39 
40 extern void disconnectDatabase(PGconn *conn);
41 
42 extern PGresult *executeQuery(PGconn *conn, const char *query, bool echo);
43 
44 extern void executeCommand(PGconn *conn, const char *query, bool echo);
45 
46 extern bool executeMaintenanceCommand(PGconn *conn, const char *query,
47  bool echo);
48 
49 extern bool consumeQueryResult(PGconn *conn);
50 
51 extern bool processQueryResult(PGconn *conn, PGresult *result);
52 
53 extern void splitTableColumnsSpec(const char *spec, int encoding,
54  char **table, const char **columns);
55 
56 extern void appendQualifiedRelation(PQExpBuffer buf, const char *name,
57  PGconn *conn, bool echo);
58 
59 extern bool yesno_prompt(const char *question);
60 
61 #endif /* COMMON_H */
void splitTableColumnsSpec(const char *spec, int encoding, char **table, const char **columns)
Definition: common.c:333
Definition: common.h:20
bool yesno_prompt(const char *question)
Definition: common.c:435
void handle_help_version_opts(int argc, char *argv[], const char *fixed_progname, help_handler hlp)
Definition: common.c:33
const char * progname
Definition: pg_standby.c:36
bool consumeQueryResult(PGconn *conn)
Definition: common.c:281
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:64
bool processQueryResult(PGconn *conn, PGresult *result)
Definition: common.c:302
bool executeMaintenanceCommand(PGconn *conn, const char *query, bool echo)
Definition: common.c:255
PGconn * conn
Definition: streamutil.c:54
PGresult * executeQuery(PGconn *conn, const char *query, bool echo)
Definition: common.c:203
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:153
Definition: common.h:21
char * pghost
Definition: pgbench.c:243
trivalue
Definition: vacuumlo.c:33
void(* help_handler)(const char *progname)
Definition: common.h:24
char * dbname
Definition: streamutil.c:50
void disconnectDatabase(PGconn *conn)
Definition: common.c:179
int32 encoding
Definition: pg_database.h:41
const char * name
Definition: encode.c:521
void appendQualifiedRelation(PQExpBuffer buf, const char *name, PGconn *conn, bool echo)
Definition: common.c:368
void executeCommand(PGconn *conn, const char *query, bool echo)
Definition: common.c:228
char * pgport
Definition: pgbench.c:244