codekingpro/portable-devtools
115k
1/*-------------------------------------------------------------------------2 *3 * Facilities for frontend code to connect to and disconnect from databases.4 *5 * Portions Copyright (c) 1996-2023, PostgreSQL Global Development Group6 * Portions Copyright (c) 1994, Regents of the University of California7 *8 * src/include/fe_utils/connect_utils.h9 *10 *-------------------------------------------------------------------------11 */12#ifndef CONNECT_UTILS_H13#define CONNECT_UTILS_H14 15#include "libpq-fe.h"16 17enum trivalue18{19 TRI_DEFAULT,20 TRI_NO,21 TRI_YES22};23 24/* Parameters needed by connectDatabase/connectMaintenanceDatabase */25typedef struct _connParams26{27 /* These fields record the actual command line parameters */28 const char *dbname; /* this may be a connstring! */29 const char *pghost;30 const char *pgport;31 const char *pguser;32 enum trivalue prompt_password;33 /* If not NULL, this overrides the dbname obtained from command line */34 /* (but *only* the DB name, not anything else in the connstring) */35 const char *override_dbname;36} ConnParams;37 38extern PGconn *connectDatabase(const ConnParams *cparams,39 const char *progname,40 bool echo, bool fail_ok,41 bool allow_password_reuse);42 43extern PGconn *connectMaintenanceDatabase(ConnParams *cparams,44 const char *progname, bool echo);45 46extern void disconnectDatabase(PGconn *conn);47 48#endif /* CONNECT_UTILS_H */49 