Update copyright for 2022
[pgsql.git] / src / interfaces / libpq / libpq-events.h
blobd93b7c4d4e72321fd776e812e89067bf8dd3132e
1 /*-------------------------------------------------------------------------
3 * libpq-events.h
4 * This file contains definitions that are useful to applications
5 * that invoke the libpq "events" API, but are not interesting to
6 * ordinary users of libpq.
8 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
9 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/interfaces/libpq/libpq-events.h
13 *-------------------------------------------------------------------------
16 #ifndef LIBPQ_EVENTS_H
17 #define LIBPQ_EVENTS_H
19 #include "libpq-fe.h"
21 #ifdef __cplusplus
22 extern "C"
24 #endif
26 /* Callback Event Ids */
27 typedef enum
29 PGEVT_REGISTER,
30 PGEVT_CONNRESET,
31 PGEVT_CONNDESTROY,
32 PGEVT_RESULTCREATE,
33 PGEVT_RESULTCOPY,
34 PGEVT_RESULTDESTROY
35 } PGEventId;
37 typedef struct
39 PGconn *conn;
40 } PGEventRegister;
42 typedef struct
44 PGconn *conn;
45 } PGEventConnReset;
47 typedef struct
49 PGconn *conn;
50 } PGEventConnDestroy;
52 typedef struct
54 PGconn *conn;
55 PGresult *result;
56 } PGEventResultCreate;
58 typedef struct
60 const PGresult *src;
61 PGresult *dest;
62 } PGEventResultCopy;
64 typedef struct
66 PGresult *result;
67 } PGEventResultDestroy;
69 typedef int (*PGEventProc) (PGEventId evtId, void *evtInfo, void *passThrough);
71 /* Registers an event proc with the given PGconn. */
72 extern int PQregisterEventProc(PGconn *conn, PGEventProc proc,
73 const char *name, void *passThrough);
75 /* Sets the PGconn instance data for the provided proc to data. */
76 extern int PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data);
78 /* Gets the PGconn instance data for the provided proc. */
79 extern void *PQinstanceData(const PGconn *conn, PGEventProc proc);
81 /* Sets the PGresult instance data for the provided proc to data. */
82 extern int PQresultSetInstanceData(PGresult *result, PGEventProc proc, void *data);
84 /* Gets the PGresult instance data for the provided proc. */
85 extern void *PQresultInstanceData(const PGresult *result, PGEventProc proc);
87 /* Fires RESULTCREATE events for an application-created PGresult. */
88 extern int PQfireResultCreateEvents(PGconn *conn, PGresult *res);
90 #ifdef __cplusplus
92 #endif
94 #endif /* LIBPQ_EVENTS_H */