1996-07-09 08:22:35 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* libpq-fe.h
|
1997-09-07 07:04:48 +02:00
|
|
|
* This file contains definitions for structures and
|
|
|
|
* externs for functions used by frontend postgres applications.
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2003-08-04 04:40:20 +02:00
|
|
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
2004-03-15 11:41:26 +01:00
|
|
|
* $PostgreSQL: pgsql/src/interfaces/libpq/libpq-fe.h,v 1.103 2004/03/15 10:41:26 ishii Exp $
|
1996-07-09 08:22:35 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef LIBPQ_FE_H
|
|
|
|
#define LIBPQ_FE_H
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
1997-09-08 04:41:22 +02:00
|
|
|
extern "C"
|
1997-09-07 07:04:48 +02:00
|
|
|
{
|
1996-07-09 08:22:35 +02:00
|
|
|
#endif
|
|
|
|
|
1996-11-22 05:39:53 +01:00
|
|
|
#include <stdio.h>
|
2001-08-21 22:39:54 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/*
|
|
|
|
* postgres_ext.h defines the backend's externally visible types,
|
1998-09-03 04:10:56 +02:00
|
|
|
* such as Oid.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2000-04-14 02:24:52 +02:00
|
|
|
#include "postgres_ext.h"
|
2001-08-21 22:39:54 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* SSL type is needed here only to declare PQgetssl() */
|
2000-08-30 16:54:24 +02:00
|
|
|
#ifdef USE_SSL
|
|
|
|
#include <openssl/ssl.h>
|
|
|
|
#endif
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-05-07 01:51:16 +02:00
|
|
|
/* Application-visible enum types */
|
|
|
|
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
/*
|
2003-06-08 19:43:00 +02:00
|
|
|
* Although it is okay to add to this list, values which become unused
|
2003-08-04 02:43:34 +02:00
|
|
|
* should never be removed, nor should constants be redefined - that
|
|
|
|
* would break compatibility with existing code.
|
2001-11-08 21:37:52 +01:00
|
|
|
*/
|
|
|
|
CONNECTION_OK,
|
|
|
|
CONNECTION_BAD,
|
|
|
|
/* Non-blocking mode only below here */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The existence of these should never be relied upon - they should
|
|
|
|
* only be used for user feedback or similar purposes.
|
|
|
|
*/
|
|
|
|
CONNECTION_STARTED, /* Waiting for connection to be made. */
|
|
|
|
CONNECTION_MADE, /* Connection OK; waiting to send. */
|
|
|
|
CONNECTION_AWAITING_RESPONSE, /* Waiting for a response from the
|
2001-11-05 18:46:40 +01:00
|
|
|
* postmaster. */
|
2001-11-08 21:37:52 +01:00
|
|
|
CONNECTION_AUTH_OK, /* Received authentication; waiting for
|
2001-11-05 18:46:40 +01:00
|
|
|
* backend startup. */
|
2003-06-08 19:43:00 +02:00
|
|
|
CONNECTION_SETENV, /* Negotiating environment. */
|
|
|
|
CONNECTION_SSL_STARTUP, /* Negotiating SSL. */
|
|
|
|
CONNECTION_NEEDED /* Internal state: connect() needed */
|
2001-11-08 21:37:52 +01:00
|
|
|
} ConnStatusType;
|
2001-11-05 18:46:40 +01:00
|
|
|
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PGRES_POLLING_FAILED = 0,
|
|
|
|
PGRES_POLLING_READING, /* These two indicate that one may */
|
|
|
|
PGRES_POLLING_WRITING, /* use select before polling again. */
|
|
|
|
PGRES_POLLING_OK,
|
2003-08-04 02:43:34 +02:00
|
|
|
PGRES_POLLING_ACTIVE /* unused; keep for awhile for backwards
|
|
|
|
* compatibility */
|
2001-11-08 21:37:52 +01:00
|
|
|
} PostgresPollingStatusType;
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
2003-06-08 19:43:00 +02:00
|
|
|
PGRES_EMPTY_QUERY = 0, /* empty query string was executed */
|
2001-11-08 21:37:52 +01:00
|
|
|
PGRES_COMMAND_OK, /* a query command that doesn't return
|
2001-11-05 18:46:40 +01:00
|
|
|
* anything was executed properly by the
|
|
|
|
* backend */
|
2001-11-08 21:37:52 +01:00
|
|
|
PGRES_TUPLES_OK, /* a query command that returns tuples was
|
2001-11-05 18:46:40 +01:00
|
|
|
* executed properly by the backend,
|
|
|
|
* PGresult contains the result tuples */
|
2001-11-08 21:37:52 +01:00
|
|
|
PGRES_COPY_OUT, /* Copy Out data transfer in progress */
|
|
|
|
PGRES_COPY_IN, /* Copy In data transfer in progress */
|
|
|
|
PGRES_BAD_RESPONSE, /* an unexpected response was recv'd from
|
2001-11-05 18:46:40 +01:00
|
|
|
* the backend */
|
2003-06-08 19:43:00 +02:00
|
|
|
PGRES_NONFATAL_ERROR, /* notice or warning message */
|
|
|
|
PGRES_FATAL_ERROR /* query failed */
|
2001-11-08 21:37:52 +01:00
|
|
|
} ExecStatusType;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PQTRANS_IDLE, /* connection idle */
|
|
|
|
PQTRANS_ACTIVE, /* command in progress */
|
|
|
|
PQTRANS_INTRANS, /* idle, within transaction block */
|
|
|
|
PQTRANS_INERROR, /* idle, within failed transaction */
|
|
|
|
PQTRANS_UNKNOWN /* cannot determine status */
|
2003-08-08 23:42:59 +02:00
|
|
|
} PGTransactionStatusType;
|
2003-06-21 23:51:35 +02:00
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PQERRORS_TERSE, /* single-line error messages */
|
|
|
|
PQERRORS_DEFAULT, /* recommended style */
|
|
|
|
PQERRORS_VERBOSE /* all the facts, ma'am */
|
2003-08-08 23:42:59 +02:00
|
|
|
} PGVerbosity;
|
2003-06-21 23:51:35 +02:00
|
|
|
|
1998-09-03 04:10:56 +02:00
|
|
|
/* PGconn encapsulates a connection to the backend.
|
|
|
|
* The contents of this struct are not supposed to be known to applications.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct pg_conn PGconn;
|
1996-07-09 08:22:35 +02:00
|
|
|
|
1998-09-03 04:10:56 +02:00
|
|
|
/* PGresult encapsulates the result of a query (or more precisely, of a single
|
|
|
|
* SQL command --- a query string given to PQsendQuery can contain multiple
|
|
|
|
* commands and thus return multiple PGresult objects).
|
|
|
|
* The contents of this struct are not supposed to be known to applications.
|
1996-07-09 08:22:35 +02:00
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct pg_result PGresult;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-03 04:10:56 +02:00
|
|
|
/* PGnotify represents the occurrence of a NOTIFY message.
|
|
|
|
* Ideally this would be an opaque typedef, but it's so simple that it's
|
|
|
|
* unlikely to change.
|
1998-10-01 03:40:26 +02:00
|
|
|
* NOTE: in Postgres 6.4 and later, the be_pid is the notifying backend's,
|
|
|
|
* whereas in earlier versions it was always your own backend's PID.
|
1998-08-17 05:50:43 +02:00
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct pgNotify
|
|
|
|
{
|
2003-06-21 23:51:35 +02:00
|
|
|
char *relname; /* notification condition name */
|
|
|
|
int be_pid; /* process ID of server process */
|
|
|
|
char *extra; /* notification parameter */
|
2001-11-08 21:37:52 +01:00
|
|
|
} PGnotify;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* Function types for notice-handling callbacks */
|
|
|
|
typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef void (*PQnoticeProcessor) (void *arg, const char *message);
|
1998-08-17 05:50:43 +02:00
|
|
|
|
1998-05-07 01:51:16 +02:00
|
|
|
/* Print options for PQprint() */
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef char pqbool;
|
1999-05-25 18:15:34 +02:00
|
|
|
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct _PQprintOpt
|
|
|
|
{
|
|
|
|
pqbool header; /* print output field headings and row
|
2001-11-05 18:46:40 +01:00
|
|
|
* count */
|
2001-11-08 21:37:52 +01:00
|
|
|
pqbool align; /* fill align the fields */
|
|
|
|
pqbool standard; /* old brain dead format */
|
|
|
|
pqbool html3; /* output html tables */
|
|
|
|
pqbool expanded; /* expand tables */
|
|
|
|
pqbool pager; /* use pager for output if needed */
|
|
|
|
char *fieldSep; /* field separator */
|
|
|
|
char *tableOpt; /* insert to HTML <table ...> */
|
|
|
|
char *caption; /* HTML <caption> */
|
|
|
|
char **fieldName; /* null terminated array of repalcement
|
2001-11-05 18:46:40 +01:00
|
|
|
* field names */
|
2001-11-08 21:37:52 +01:00
|
|
|
} PQprintOpt;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1996-11-09 11:39:54 +01:00
|
|
|
/* ----------------
|
1998-08-17 05:50:43 +02:00
|
|
|
* Structure for the conninfo parameter definitions returned by PQconndefaults
|
2000-03-11 04:08:37 +01:00
|
|
|
*
|
|
|
|
* All fields except "val" point at static strings which must not be altered.
|
|
|
|
* "val" is either NULL or a malloc'd current-value string. PQconninfoFree()
|
|
|
|
* will release both the val strings and the PQconninfoOption array itself.
|
1996-11-09 11:39:54 +01:00
|
|
|
* ----------------
|
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct _PQconninfoOption
|
|
|
|
{
|
|
|
|
char *keyword; /* The keyword of the option */
|
|
|
|
char *envvar; /* Fallback environment variable name */
|
|
|
|
char *compiled; /* Fallback compiled in default value */
|
|
|
|
char *val; /* Option's current value, or NULL */
|
|
|
|
char *label; /* Label for field in connect dialog */
|
|
|
|
char *dispchar; /* Character to display for this field in
|
2001-11-05 18:46:40 +01:00
|
|
|
* a connect dialog. Values are: ""
|
|
|
|
* Display entered value as is "*"
|
|
|
|
* Password field - hide value "D" Debug
|
|
|
|
* option - don't show by default */
|
2001-11-08 21:37:52 +01:00
|
|
|
int dispsize; /* Field size in characters for dialog */
|
|
|
|
} PQconninfoOption;
|
1997-09-07 07:04:48 +02:00
|
|
|
|
1998-09-03 04:10:56 +02:00
|
|
|
/* ----------------
|
|
|
|
* PQArgBlock -- structure for PQfn() arguments
|
|
|
|
* ----------------
|
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
int len;
|
|
|
|
int isint;
|
|
|
|
union
|
1998-09-03 04:10:56 +02:00
|
|
|
{
|
2001-11-08 21:37:52 +01:00
|
|
|
int *ptr; /* can't use void (dec compiler barfs) */
|
|
|
|
int integer;
|
|
|
|
} u;
|
|
|
|
} PQArgBlock;
|
1998-09-03 04:10:56 +02:00
|
|
|
|
1998-08-17 05:50:43 +02:00
|
|
|
/* ----------------
|
|
|
|
* Exported functions of libpq
|
|
|
|
* ----------------
|
|
|
|
*/
|
|
|
|
|
1997-09-07 07:04:48 +02:00
|
|
|
/* === in fe-connect.c === */
|
1998-08-17 05:50:43 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* make a new client connection to the backend */
|
|
|
|
/* Asynchronous (non-blocking) */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGconn *PQconnectStart(const char *conninfo);
|
|
|
|
extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Synchronous (blocking) */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGconn *PQconnectdb(const char *conninfo);
|
|
|
|
extern PGconn *PQsetdbLogin(const char *pghost, const char *pgport,
|
|
|
|
const char *pgoptions, const char *pgtty,
|
|
|
|
const char *dbName,
|
|
|
|
const char *login, const char *pwd);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
1998-08-17 05:50:43 +02:00
|
|
|
#define PQsetdb(M_PGHOST,M_PGPORT,M_PGOPT,M_PGTTY,M_DBNAME) \
|
|
|
|
PQsetdbLogin(M_PGHOST, M_PGPORT, M_PGOPT, M_PGTTY, M_DBNAME, NULL, NULL)
|
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* close the current connection and free the PGconn data structure */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern void PQfinish(PGconn *conn);
|
2000-03-11 04:08:37 +01:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* get info about connection options known to PQconnectdb */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PQconninfoOption *PQconndefaults(void);
|
1998-08-17 05:50:43 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* free the data structure returned by PQconndefaults() */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern void PQconninfoFree(PQconninfoOption *connOptions);
|
1998-09-01 06:40:42 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/*
|
|
|
|
* close the current connection and restablish a new one with the same
|
|
|
|
* parameters
|
|
|
|
*/
|
|
|
|
/* Asynchronous (non-blocking) */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQresetStart(PGconn *conn);
|
|
|
|
extern PostgresPollingStatusType PQresetPoll(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Synchronous (blocking) */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern void PQreset(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* issue a cancel request */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQrequestCancel(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Accessor functions for PGconn objects */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern char *PQdb(const PGconn *conn);
|
|
|
|
extern char *PQuser(const PGconn *conn);
|
|
|
|
extern char *PQpass(const PGconn *conn);
|
|
|
|
extern char *PQhost(const PGconn *conn);
|
|
|
|
extern char *PQport(const PGconn *conn);
|
|
|
|
extern char *PQtty(const PGconn *conn);
|
|
|
|
extern char *PQoptions(const PGconn *conn);
|
|
|
|
extern ConnStatusType PQstatus(const PGconn *conn);
|
2003-06-21 23:51:35 +02:00
|
|
|
extern PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
|
|
|
|
extern const char *PQparameterStatus(const PGconn *conn,
|
2003-08-04 02:43:34 +02:00
|
|
|
const char *paramName);
|
2003-06-21 23:51:35 +02:00
|
|
|
extern int PQprotocolVersion(const PGconn *conn);
|
2001-11-08 21:37:52 +01:00
|
|
|
extern char *PQerrorMessage(const PGconn *conn);
|
|
|
|
extern int PQsocket(const PGconn *conn);
|
|
|
|
extern int PQbackendPID(const PGconn *conn);
|
|
|
|
extern int PQclientEncoding(const PGconn *conn);
|
|
|
|
extern int PQsetClientEncoding(PGconn *conn, const char *encoding);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2000-08-30 16:54:24 +02:00
|
|
|
#ifdef USE_SSL
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Get the SSL structure associated with a connection */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern SSL *PQgetssl(PGconn *conn);
|
2000-08-30 16:54:24 +02:00
|
|
|
#endif
|
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* Set verbosity for PQerrorMessage and PQresultErrorMessage */
|
|
|
|
extern PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
|
1998-05-07 01:51:16 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Enable/disable tracing */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern void PQtrace(PGconn *conn, FILE *debug_port);
|
|
|
|
extern void PQuntrace(PGconn *conn);
|
1996-07-09 08:22:35 +02:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* Override default notice handling routines */
|
|
|
|
extern PQnoticeReceiver PQsetNoticeReceiver(PGconn *conn,
|
2003-08-04 02:43:34 +02:00
|
|
|
PQnoticeReceiver proc,
|
|
|
|
void *arg);
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PQnoticeProcessor PQsetNoticeProcessor(PGconn *conn,
|
|
|
|
PQnoticeProcessor proc,
|
|
|
|
void *arg);
|
1998-08-09 04:59:33 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* === in fe-exec.c === */
|
1998-08-17 05:50:43 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Simple synchronous query */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGresult *PQexec(PGconn *conn, const char *query);
|
2003-06-21 23:51:35 +02:00
|
|
|
extern PGresult *PQexecParams(PGconn *conn,
|
2003-08-04 02:43:34 +02:00
|
|
|
const char *command,
|
|
|
|
int nParams,
|
|
|
|
const Oid *paramTypes,
|
|
|
|
const char *const * paramValues,
|
|
|
|
const int *paramLengths,
|
|
|
|
const int *paramFormats,
|
|
|
|
int resultFormat);
|
2003-08-13 18:29:03 +02:00
|
|
|
extern PGresult *PQexecPrepared(PGconn *conn,
|
|
|
|
const char *stmtName,
|
|
|
|
int nParams,
|
|
|
|
const char *const * paramValues,
|
|
|
|
const int *paramLengths,
|
|
|
|
const int *paramFormats,
|
|
|
|
int resultFormat);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Interface for multiple-result or asynchronous queries */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQsendQuery(PGconn *conn, const char *query);
|
2003-08-04 02:43:34 +02:00
|
|
|
extern int PQsendQueryParams(PGconn *conn,
|
|
|
|
const char *command,
|
|
|
|
int nParams,
|
|
|
|
const Oid *paramTypes,
|
|
|
|
const char *const * paramValues,
|
|
|
|
const int *paramLengths,
|
|
|
|
const int *paramFormats,
|
2003-08-13 18:29:03 +02:00
|
|
|
int resultFormat);
|
|
|
|
extern int PQsendQueryPrepared(PGconn *conn,
|
|
|
|
const char *stmtName,
|
|
|
|
int nParams,
|
|
|
|
const char *const * paramValues,
|
|
|
|
const int *paramLengths,
|
|
|
|
const int *paramFormats,
|
2003-08-04 02:43:34 +02:00
|
|
|
int resultFormat);
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGresult *PQgetResult(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
2003-03-10 23:28:22 +01:00
|
|
|
/* Routines for managing an asynchronous query */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQisBusy(PGconn *conn);
|
|
|
|
extern int PQconsumeInput(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* LISTEN/NOTIFY support */
|
|
|
|
extern PGnotify *PQnotifies(PGconn *conn);
|
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Routines for copy in/out */
|
2003-06-21 23:51:35 +02:00
|
|
|
extern int PQputCopyData(PGconn *conn, const char *buffer, int nbytes);
|
|
|
|
extern int PQputCopyEnd(PGconn *conn, const char *errormsg);
|
|
|
|
extern int PQgetCopyData(PGconn *conn, char **buffer, int async);
|
2003-08-04 02:43:34 +02:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* Deprecated routines for copy in/out */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQgetline(PGconn *conn, char *string, int length);
|
|
|
|
extern int PQputline(PGconn *conn, const char *string);
|
|
|
|
extern int PQgetlineAsync(PGconn *conn, char *buffer, int bufsize);
|
|
|
|
extern int PQputnbytes(PGconn *conn, const char *buffer, int nbytes);
|
|
|
|
extern int PQendcopy(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Set blocking/nonblocking connection to the backend */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQsetnonblocking(PGconn *conn, int arg);
|
|
|
|
extern int PQisnonblocking(const PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Force the write buffer to be written (or at least try) */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQflush(PGconn *conn);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* "Fast path" interface --- not really recommended for application
|
|
|
|
* use
|
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGresult *PQfn(PGconn *conn,
|
|
|
|
int fnid,
|
|
|
|
int *result_buf,
|
|
|
|
int *result_len,
|
|
|
|
int result_is_int,
|
|
|
|
const PQArgBlock *args,
|
|
|
|
int nargs);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Accessor functions for PGresult objects */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern ExecStatusType PQresultStatus(const PGresult *res);
|
|
|
|
extern char *PQresStatus(ExecStatusType status);
|
|
|
|
extern char *PQresultErrorMessage(const PGresult *res);
|
2003-06-21 23:51:35 +02:00
|
|
|
extern char *PQresultErrorField(const PGresult *res, int fieldcode);
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQntuples(const PGresult *res);
|
|
|
|
extern int PQnfields(const PGresult *res);
|
|
|
|
extern int PQbinaryTuples(const PGresult *res);
|
|
|
|
extern char *PQfname(const PGresult *res, int field_num);
|
|
|
|
extern int PQfnumber(const PGresult *res, const char *field_name);
|
2003-06-21 23:51:35 +02:00
|
|
|
extern Oid PQftable(const PGresult *res, int field_num);
|
|
|
|
extern int PQftablecol(const PGresult *res, int field_num);
|
|
|
|
extern int PQfformat(const PGresult *res, int field_num);
|
2001-11-08 21:37:52 +01:00
|
|
|
extern Oid PQftype(const PGresult *res, int field_num);
|
|
|
|
extern int PQfsize(const PGresult *res, int field_num);
|
|
|
|
extern int PQfmod(const PGresult *res, int field_num);
|
|
|
|
extern char *PQcmdStatus(PGresult *res);
|
|
|
|
extern char *PQoidStatus(const PGresult *res); /* old and ugly */
|
|
|
|
extern Oid PQoidValue(const PGresult *res); /* new and improved */
|
|
|
|
extern char *PQcmdTuples(PGresult *res);
|
|
|
|
extern char *PQgetvalue(const PGresult *res, int tup_num, int field_num);
|
|
|
|
extern int PQgetlength(const PGresult *res, int tup_num, int field_num);
|
|
|
|
extern int PQgetisnull(const PGresult *res, int tup_num, int field_num);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
|
|
|
/* Delete a PGresult */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern void PQclear(PGresult *res);
|
2001-11-02 21:51:27 +01:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
/* For freeing other alloc'd results, such as PGnotify structs */
|
|
|
|
extern void PQfreemem(void *ptr);
|
|
|
|
|
|
|
|
/* Exists for backward compatibility. bjm 2003-03-24 */
|
|
|
|
#define PQfreeNotify(ptr) PQfreemem(ptr)
|
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/*
|
|
|
|
* Make an empty PGresult with given status (some apps find this
|
|
|
|
* useful). If conn is not NULL and status indicates an error, the
|
|
|
|
* conn's errorMessage is copied.
|
|
|
|
*/
|
2001-11-08 21:37:52 +01:00
|
|
|
extern PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
|
1998-09-03 04:10:56 +02:00
|
|
|
|
2003-06-21 23:51:35 +02:00
|
|
|
|
|
|
|
/* Quoting strings before inclusion in queries. */
|
|
|
|
extern size_t PQescapeString(char *to, const char *from, size_t length);
|
|
|
|
extern unsigned char *PQescapeBytea(const unsigned char *bintext, size_t binlen,
|
|
|
|
size_t *bytealen);
|
|
|
|
extern unsigned char *PQunescapeBytea(const unsigned char *strtext,
|
|
|
|
size_t *retbuflen);
|
|
|
|
|
|
|
|
|
|
|
|
|
1998-05-07 01:51:16 +02:00
|
|
|
/* === in fe-print.c === */
|
1998-08-17 05:50:43 +02:00
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern void
|
|
|
|
PQprint(FILE *fout, /* output stream */
|
|
|
|
const PGresult *res,
|
|
|
|
const PQprintOpt *ps); /* option structure */
|
2000-04-12 19:17:23 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/*
|
|
|
|
* really old printing routines
|
|
|
|
*/
|
2003-08-04 02:43:34 +02:00
|
|
|
extern void
|
|
|
|
PQdisplayTuples(const PGresult *res,
|
2001-11-08 21:37:52 +01:00
|
|
|
FILE *fp, /* where to send the output */
|
|
|
|
int fillAlign, /* pad the fields with spaces */
|
|
|
|
const char *fieldSep, /* field separator */
|
|
|
|
int printHeader, /* display headers? */
|
|
|
|
int quiet);
|
|
|
|
|
2003-08-04 02:43:34 +02:00
|
|
|
extern void
|
|
|
|
PQprintTuples(const PGresult *res,
|
2001-11-08 21:37:52 +01:00
|
|
|
FILE *fout, /* output stream */
|
|
|
|
int printAttName, /* print attribute names */
|
|
|
|
int terseOutput, /* delimiter bars */
|
|
|
|
int width); /* width of column, if 0, use variable
|
|
|
|
* width */
|
2000-02-08 00:10:11 +01:00
|
|
|
|
1998-06-16 09:29:54 +02:00
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
/* === in fe-lobj.c === */
|
1998-08-17 05:50:43 +02:00
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Large-object access routines */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int lo_open(PGconn *conn, Oid lobjId, int mode);
|
|
|
|
extern int lo_close(PGconn *conn, int fd);
|
|
|
|
extern int lo_read(PGconn *conn, int fd, char *buf, size_t len);
|
|
|
|
extern int lo_write(PGconn *conn, int fd, char *buf, size_t len);
|
|
|
|
extern int lo_lseek(PGconn *conn, int fd, int offset, int whence);
|
|
|
|
extern Oid lo_creat(PGconn *conn, int mode);
|
|
|
|
extern int lo_tell(PGconn *conn, int fd);
|
|
|
|
extern int lo_unlink(PGconn *conn, Oid lobjId);
|
|
|
|
extern Oid lo_import(PGconn *conn, const char *filename);
|
|
|
|
extern int lo_export(PGconn *conn, Oid lobjId, const char *filename);
|
1998-05-07 01:51:16 +02:00
|
|
|
|
2000-01-29 17:58:54 +01:00
|
|
|
/* === in fe-misc.c === */
|
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Determine length of multibyte encoded char at *s */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQmblen(const unsigned char *s, int encoding);
|
2000-01-29 17:58:54 +01:00
|
|
|
|
2004-03-15 11:41:26 +01:00
|
|
|
/* Determine display length of multibyte encoded char at *s */
|
|
|
|
extern int PQdsplen(const unsigned char *s, int encoding);
|
|
|
|
|
2001-11-02 21:51:27 +01:00
|
|
|
/* Get encoding id from environment variable PGCLIENTENCODING */
|
2001-11-08 21:37:52 +01:00
|
|
|
extern int PQenv2encoding(void);
|
2000-01-29 17:58:54 +01:00
|
|
|
|
2004-01-09 03:02:43 +01:00
|
|
|
/* === in fe-secure.c === */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Indicates whether the libpq thread is in send().
|
|
|
|
* Used to ignore SIGPIPE if thread is in send().
|
|
|
|
*/
|
|
|
|
pqbool PQinSend(void);
|
|
|
|
|
1996-07-09 08:22:35 +02:00
|
|
|
#ifdef __cplusplus
|
2000-03-30 04:59:14 +02:00
|
|
|
}
|
1997-09-07 07:04:48 +02:00
|
|
|
#endif
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2001-11-05 18:46:40 +01:00
|
|
|
#endif /* LIBPQ_FE_H */
|