libpq-fe.h

来自「PostgreSQL7.4.6 for Linux」· C头文件 代码 · 共 458 行 · 第 1/2 页

H
458
字号
/*------------------------------------------------------------------------- * * libpq-fe.h *	  This file contains definitions for structures and *	  externs for functions used by frontend postgres applications. * * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * * $Id: libpq-fe.h,v 1.100 2003/08/27 00:33:34 petere Exp $ * *------------------------------------------------------------------------- */#ifndef LIBPQ_FE_H#define LIBPQ_FE_H#ifdef __cplusplusextern		"C"{#endif#include <stdio.h>/* * postgres_ext.h defines the backend's externally visible types, * such as Oid. */#include "postgres_ext.h"/* SSL type is needed here only to declare PQgetssl() */#ifdef USE_SSL#include <openssl/ssl.h>#endif/* Application-visible enum types */typedef enum{	/*	 * Although it is okay to add to this list, values which become unused	 * should never be removed, nor should constants be redefined - that	 * would break compatibility with existing code.	 */	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										 * 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 */} ConnStatusType;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,	PGRES_POLLING_ACTIVE		/* unused; keep for awhile for backwards								 * compatibility */} PostgresPollingStatusType;typedef enum{	PGRES_EMPTY_QUERY = 0,		/* empty query string was executed */	PGRES_COMMAND_OK,			/* a query command that doesn't return								 * anything was executed properly by the								 * backend */	PGRES_TUPLES_OK,			/* a query command that returns tuples was								 * executed properly by the backend,								 * PGresult contains the result tuples */	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								 * the backend */	PGRES_NONFATAL_ERROR,		/* notice or warning message */	PGRES_FATAL_ERROR			/* query failed */} ExecStatusType;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 */} PGTransactionStatusType;typedef enum{	PQERRORS_TERSE,				/* single-line error messages */	PQERRORS_DEFAULT,			/* recommended style */	PQERRORS_VERBOSE			/* all the facts, ma'am */} PGVerbosity;/* PGconn encapsulates a connection to the backend. * The contents of this struct are not supposed to be known to applications. */typedef struct pg_conn PGconn;/* 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. */typedef struct pg_result PGresult;/* 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. * 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. */typedef struct pgNotify{	char	   *relname;		/* notification condition name */	int			be_pid;			/* process ID of server process */	char	   *extra;			/* notification parameter */} PGnotify;/* Function types for notice-handling callbacks */typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);typedef void (*PQnoticeProcessor) (void *arg, const char *message);/* Print options for PQprint() */typedef char pqbool;typedef struct _PQprintOpt{	pqbool		header;			/* print output field headings and row								 * count */	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								 * field names */} PQprintOpt;/* ---------------- * Structure for the conninfo parameter definitions returned by PQconndefaults * * 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. * ---------------- */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								 * a connect dialog. Values are: ""								 * Display entered value as is "*"								 * Password field - hide value "D"	Debug								 * option - don't show by default */	int			dispsize;		/* Field size in characters for dialog	*/} PQconninfoOption;/* ---------------- * PQArgBlock -- structure for PQfn() arguments * ---------------- */typedef struct{	int			len;	int			isint;	union	{		int		   *ptr;		/* can't use void (dec compiler barfs)	 */		int			integer;	}			u;} PQArgBlock;/* ---------------- * Exported functions of libpq * ---------------- *//* ===	in fe-connect.c === *//* make a new client connection to the backend *//* Asynchronous (non-blocking) */extern PGconn *PQconnectStart(const char *conninfo);extern PostgresPollingStatusType PQconnectPoll(PGconn *conn);/* Synchronous (blocking) */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);#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)/* close the current connection and free the PGconn data structure */extern void PQfinish(PGconn *conn);/* get info about connection options known to PQconnectdb */extern PQconninfoOption *PQconndefaults(void);/* free the data structure returned by PQconndefaults() */extern void PQconninfoFree(PQconninfoOption *connOptions);/* * close the current connection and restablish a new one with the same * parameters *//* Asynchronous (non-blocking) */extern int	PQresetStart(PGconn *conn);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?