Header And Logo

PostgreSQL
| The world's most advanced open source database.

libpq-events.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * libpq-events.h
00004  *    This file contains definitions that are useful to applications
00005  *    that invoke the libpq "events" API, but are not interesting to
00006  *    ordinary users of libpq.
00007  *
00008  * Portions Copyright (c) 1996-2013, PostgreSQL Global Development Group
00009  * Portions Copyright (c) 1994, Regents of the University of California
00010  *
00011  * src/interfaces/libpq/libpq-events.h
00012  *
00013  *-------------------------------------------------------------------------
00014  */
00015 
00016 #ifndef LIBPQ_EVENTS_H
00017 #define LIBPQ_EVENTS_H
00018 
00019 #include "libpq-fe.h"
00020 
00021 #ifdef __cplusplus
00022 extern      "C"
00023 {
00024 #endif
00025 
00026 /* Callback Event Ids */
00027             typedef enum
00028 {
00029     PGEVT_REGISTER,
00030     PGEVT_CONNRESET,
00031     PGEVT_CONNDESTROY,
00032     PGEVT_RESULTCREATE,
00033     PGEVT_RESULTCOPY,
00034     PGEVT_RESULTDESTROY
00035 } PGEventId;
00036 
00037 typedef struct
00038 {
00039     PGconn     *conn;
00040 } PGEventRegister;
00041 
00042 typedef struct
00043 {
00044     PGconn     *conn;
00045 } PGEventConnReset;
00046 
00047 typedef struct
00048 {
00049     PGconn     *conn;
00050 } PGEventConnDestroy;
00051 
00052 typedef struct
00053 {
00054     PGconn     *conn;
00055     PGresult   *result;
00056 } PGEventResultCreate;
00057 
00058 typedef struct
00059 {
00060     const PGresult *src;
00061     PGresult   *dest;
00062 } PGEventResultCopy;
00063 
00064 typedef struct
00065 {
00066     PGresult   *result;
00067 } PGEventResultDestroy;
00068 
00069 typedef int (*PGEventProc) (PGEventId evtId, void *evtInfo, void *passThrough);
00070 
00071 /* Registers an event proc with the given PGconn. */
00072 extern int PQregisterEventProc(PGconn *conn, PGEventProc proc,
00073                     const char *name, void *passThrough);
00074 
00075 /* Sets the PGconn instance data for the provided proc to data. */
00076 extern int  PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data);
00077 
00078 /* Gets the PGconn instance data for the provided proc. */
00079 extern void *PQinstanceData(const PGconn *conn, PGEventProc proc);
00080 
00081 /* Sets the PGresult instance data for the provided proc to data. */
00082 extern int  PQresultSetInstanceData(PGresult *result, PGEventProc proc, void *data);
00083 
00084 /* Gets the PGresult instance data for the provided proc. */
00085 extern void *PQresultInstanceData(const PGresult *result, PGEventProc proc);
00086 
00087 /* Fires RESULTCREATE events for an application-created PGresult. */
00088 extern int  PQfireResultCreateEvents(PGconn *conn, PGresult *res);
00089 
00090 #ifdef __cplusplus
00091 }
00092 #endif
00093 
00094 #endif   /* LIBPQ_EVENTS_H */