2
0

connect_utils.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*-------------------------------------------------------------------------
  2. *
  3. * Facilities for frontend code to connect to and disconnect from databases.
  4. *
  5. * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
  6. * Portions Copyright (c) 1994, Regents of the University of California
  7. *
  8. * src/include/fe_utils/connect_utils.h
  9. *
  10. *-------------------------------------------------------------------------
  11. */
  12. #ifndef CONNECT_UTILS_H
  13. #define CONNECT_UTILS_H
  14. #include "libpq-fe.h"
  15. enum trivalue
  16. {
  17. TRI_DEFAULT,
  18. TRI_NO,
  19. TRI_YES
  20. };
  21. /* Parameters needed by connectDatabase/connectMaintenanceDatabase */
  22. typedef struct _connParams
  23. {
  24. /* These fields record the actual command line parameters */
  25. const char *dbname; /* this may be a connstring! */
  26. const char *pghost;
  27. const char *pgport;
  28. const char *pguser;
  29. enum trivalue prompt_password;
  30. /* If not NULL, this overrides the dbname obtained from command line */
  31. /* (but *only* the DB name, not anything else in the connstring) */
  32. const char *override_dbname;
  33. } ConnParams;
  34. extern PGconn *connectDatabase(const ConnParams *cparams,
  35. const char *progname,
  36. bool echo, bool fail_ok,
  37. bool allow_password_reuse);
  38. extern PGconn *connectMaintenanceDatabase(ConnParams *cparams,
  39. const char *progname, bool echo);
  40. extern void disconnectDatabase(PGconn *conn);
  41. #endif /* CONNECT_UTILS_H */