]> granicus.if.org Git - postgresql/blobdiff - src/interfaces/libpq/libpq-fe.h
Add a "SQLSTATE-only" error verbosity option to libpq and psql.
[postgresql] / src / interfaces / libpq / libpq-fe.h
index 80591728a0fe85d6ec3ba055c6890ce5e0acf271..f44030b4b0d0dcf09e611f2aef42947ca53a4e84 100644 (file)
@@ -4,7 +4,7 @@
  *       This file contains definitions for structures and
  *       externs for functions used by frontend postgres applications.
  *
- * Portions Copyright (c) 1996-2014, PostgreSQL Global Development Group
+ * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
  * src/interfaces/libpq/libpq-fe.h
@@ -16,7 +16,7 @@
 #define LIBPQ_FE_H
 
 #ifdef __cplusplus
-extern         "C"
+extern "C"
 {
 #endif
 
@@ -56,13 +56,18 @@ typedef enum
         */
        CONNECTION_STARTED,                     /* Waiting for connection to be made.  */
        CONNECTION_MADE,                        /* Connection OK; waiting to send.     */
-       CONNECTION_AWAITING_RESPONSE,           /* Waiting for a response from the
-                                                                                * postmaster.        */
+       CONNECTION_AWAITING_RESPONSE,   /* Waiting for a response from the
+                                                                        * postmaster.        */
        CONNECTION_AUTH_OK,                     /* Received authentication; waiting for
                                                                 * backend startup. */
        CONNECTION_SETENV,                      /* Negotiating environment. */
        CONNECTION_SSL_STARTUP,         /* Negotiating SSL. */
-       CONNECTION_NEEDED                       /* Internal state: connect() needed */
+       CONNECTION_NEEDED,                      /* Internal state: connect() needed */
+       CONNECTION_CHECK_WRITABLE,      /* Check if we could make a writable
+                                                                * connection. */
+       CONNECTION_CONSUME,                     /* Wait for any pending message and consume
+                                                                * them. */
+       CONNECTION_GSS_STARTUP          /* Negotiating GSSAPI. */
 } ConnStatusType;
 
 typedef enum
@@ -107,9 +112,17 @@ typedef enum
 {
        PQERRORS_TERSE,                         /* single-line error messages */
        PQERRORS_DEFAULT,                       /* recommended style */
-       PQERRORS_VERBOSE                        /* all the facts, ma'am */
+       PQERRORS_VERBOSE,                       /* all the facts, ma'am */
+       PQERRORS_SQLSTATE                       /* only error severity and SQLSTATE code */
 } PGVerbosity;
 
+typedef enum
+{
+       PQSHOW_CONTEXT_NEVER,           /* never show CONTEXT field */
+       PQSHOW_CONTEXT_ERRORS,          /* show CONTEXT for errors only (default) */
+       PQSHOW_CONTEXT_ALWAYS           /* always show CONTEXT field */
+} PGContextVisibility;
+
 /*
  * PGPing - The ordering of this enum should not be altered because the
  * values are exposed externally via pg_isready.
@@ -242,14 +255,14 @@ typedef struct pgresAttDesc
 /* make a new client connection to the backend */
 /* Asynchronous (non-blocking) */
 extern PGconn *PQconnectStart(const char *conninfo);
-extern PGconn *PQconnectStartParams(const char *const * keywords,
-                                        const char *const * values, int expand_dbname);
+extern PGconn *PQconnectStartParams(const char *const *keywords,
+                                        const char *const *values, int expand_dbname);
 extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
 
 /* Synchronous (blocking) */
 extern PGconn *PQconnectdb(const char *conninfo);
-extern PGconn *PQconnectdbParams(const char *const * keywords,
-                                 const char *const * values, int expand_dbname);
+extern PGconn *PQconnectdbParams(const char *const *keywords,
+                                 const char *const *values, int expand_dbname);
 extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
                         const char *pgoptions, const char *pgtty,
                         const char *dbName,
@@ -319,6 +332,12 @@ extern int PQconnectionUsedPassword(const PGconn *conn);
 extern int     PQclientEncoding(const PGconn *conn);
 extern int     PQsetClientEncoding(PGconn *conn, const char *encoding);
 
+/* SSL information functions */
+extern int     PQsslInUse(PGconn *conn);
+extern void *PQsslStruct(PGconn *conn, const char *struct_name);
+extern const char *PQsslAttribute(PGconn *conn, const char *attribute_name);
+extern const char *const *PQsslAttributeNames(PGconn *conn);
+
 /* Get the OpenSSL structure associated with a connection. Returns NULL for
  * unencrypted connections or if any other TLS library is in use. */
 extern void *PQgetssl(PGconn *conn);
@@ -329,9 +348,19 @@ extern void PQinitSSL(int do_init);
 /* More detailed way to tell libpq whether it needs to initialize OpenSSL */
 extern void PQinitOpenSSL(int do_ssl, int do_crypto);
 
+/* Return true if GSSAPI encryption is in use */
+extern int PQgssEncInUse(PGconn *conn);
+
+/* Returns GSSAPI context if GSSAPI is in use */
+extern void *PQgetgssctx(PGconn *conn);
+
 /* Set verbosity for PQerrorMessage and PQresultErrorMessage */
 extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
 
+/* Set CONTEXT visibility for PQerrorMessage and PQresultErrorMessage */
+extern PGContextVisibility PQsetErrorContextVisibility(PGconn *conn,
+                                                       PGContextVisibility show_context);
+
 /* Enable/disable tracing */
 extern void PQtrace(PGconn *conn, FILE *debug_port);
 extern void PQuntrace(PGconn *conn);
@@ -363,7 +392,7 @@ extern PGresult *PQexecParams(PGconn *conn,
                         const char *command,
                         int nParams,
                         const Oid *paramTypes,
-                        const char *const * paramValues,
+                        const char *const *paramValues,
                         const int *paramLengths,
                         const int *paramFormats,
                         int resultFormat);
@@ -373,7 +402,7 @@ extern PGresult *PQprepare(PGconn *conn, const char *stmtName,
 extern PGresult *PQexecPrepared(PGconn *conn,
                           const char *stmtName,
                           int nParams,
-                          const char *const * paramValues,
+                          const char *const *paramValues,
                           const int *paramLengths,
                           const int *paramFormats,
                           int resultFormat);
@@ -384,7 +413,7 @@ extern int PQsendQueryParams(PGconn *conn,
                                  const char *command,
                                  int nParams,
                                  const Oid *paramTypes,
-                                 const char *const * paramValues,
+                                 const char *const *paramValues,
                                  const int *paramLengths,
                                  const int *paramFormats,
                                  int resultFormat);
@@ -394,7 +423,7 @@ extern int PQsendPrepare(PGconn *conn, const char *stmtName,
 extern int PQsendQueryPrepared(PGconn *conn,
                                        const char *stmtName,
                                        int nParams,
-                                       const char *const * paramValues,
+                                       const char *const *paramValues,
                                        const int *paramLengths,
                                        const int *paramFormats,
                                        int resultFormat);
@@ -425,8 +454,8 @@ extern int  PQsetnonblocking(PGconn *conn, int arg);
 extern int     PQisnonblocking(const PGconn *conn);
 extern int     PQisthreadsafe(void);
 extern PGPing PQping(const char *conninfo);
-extern PGPing PQpingParams(const char *const * keywords,
-                        const char *const * values, int expand_dbname);
+extern PGPing PQpingParams(const char *const *keywords,
+                        const char *const *values, int expand_dbname);
 
 /* Force the write buffer to be written (or at least try) */
 extern int     PQflush(PGconn *conn);
@@ -447,6 +476,9 @@ extern PGresult *PQfn(PGconn *conn,
 extern ExecStatusType PQresultStatus(const PGresult *res);
 extern char *PQresStatus(ExecStatusType status);
 extern char *PQresultErrorMessage(const PGresult *res);
+extern char *PQresultVerboseErrorMessage(const PGresult *res,
+                                                       PGVerbosity verbosity,
+                                                       PGContextVisibility show_context);
 extern char *PQresultErrorField(const PGresult *res, int fieldcode);
 extern int     PQntuples(const PGresult *res);
 extern int     PQnfields(const PGresult *res);
@@ -493,6 +525,7 @@ extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
 extern PGresult *PQcopyResult(const PGresult *src, int flags);
 extern int     PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
 extern void *PQresultAlloc(PGresult *res, size_t nBytes);
+extern size_t PQresultMemorySize(const PGresult *res);
 extern int     PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
 
 /* Quoting strings before inclusion in queries. */
@@ -574,6 +607,7 @@ extern int  PQenv2encoding(void);
 /* === in fe-auth.c === */
 
 extern char *PQencryptPassword(const char *passwd, const char *user);
+extern char *PQencryptPasswordConn(PGconn *conn, const char *passwd, const char *user, const char *algorithm);
 
 /* === in encnames.c === */
 
@@ -585,4 +619,4 @@ extern int  pg_valid_server_encoding_id(int encoding);
 }
 #endif
 
-#endif   /* LIBPQ_FE_H */
+#endif                                                 /* LIBPQ_FE_H */