-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPg.h
174 lines (146 loc) · 7.98 KB
/
Pg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
$Id: Pg.h 12599 2009-03-10 23:28:35Z turnstep $
Copyright (c) 2000-2009 Greg Sabino Mullane and others: see the Changes file
Copyright (c) 1997-2000 Edmund Mergl
Portions Copyright (c) 1994-1997 Tim Bunce
You may distribute under the terms of either the GNU General Public
License or the Artistic License, as specified in the Perl README file.
*/
#include <math.h>
#include <wchar.h>
#ifdef WIN32
static int errno;
#include <string.h>
#define strcasecmp(s1,s2) stricmp((s1), (s2))
#ifndef snprintf
#define snprintf _snprintf
#endif
#else
#include <strings.h>
#endif
#define DBDPG_TRUE (bool)1
#define DBDPG_FALSE (bool)0
#define PG_ASYNC 1
#define PG_OLDQUERY_CANCEL 2
#define PG_OLDQUERY_WAIT 4
/* Force preprocessors to use this variable. Default to something valid yet noticeable */
#ifndef PGLIBVERSION
#define PGLIBVERSION 80009
#endif
#include "libpq-fe.h"
#ifndef INV_READ
#define INV_READ 0x00040000
#endif
#ifndef INV_WRITE
#define INV_WRITE 0x00020000
#endif
#ifdef BUFSIZ
#undef BUFSIZ
#endif
/* this should improve I/O performance for large objects */
#define BUFSIZ 32768
#define NEED_DBIXS_VERSION 93
#define PERL_NO_GET_CONTEXT
#include <DBIXS.h> /* installed by the DBI module */
#include <dbivport.h> /* DBI portability macros */
#include <dbd_xsh.h> /* installed by the DBI module */
DBISTATE_DECLARE;
#include "types.h"
#include "dbdimp.h"
#include "quote.h"
#define TLEVEL (DBIS->debug & DBIc_TRACE_LEVEL_MASK)
#define TFLAGS (DBIS->debug & DBIc_TRACE_FLAGS_MASK)
#define TSQL (TFLAGS & 256) /* Defined in DBI */
#define FLAGS_LIBPQ 0x01000000
#define FLAGS_START 0x02000000
#define FLAGS_END 0x04000000
#define FLAGS_PREFIX 0x08000000
#define FLAGS_LOGIN 0x10000000
#define FLAGS_CORO 0x20000000
#define TFLIBPQ (TFLAGS & FLAGS_LIBPQ)
#define TFSTART (TFLAGS & FLAGS_START)
#define TFEND (TFLAGS & FLAGS_END)
#define TFPREFIX (TFLAGS & FLAGS_PREFIX)
#define TFLOGIN (TFLAGS & FLAGS_LOGIN)
#define TFCORO (TFLAGS & FLAGS_CORO)
#define TRACE1 (TLEVEL >= 1) /* Avoid using directly: DBI only */
#define TRACE2 (TLEVEL >= 2) /* Avoid using directly: DBI only */
#define TRACE3 (TLEVEL >= 3) /* Basic debugging */
#define TRACE4 (TLEVEL >= 4) /* More detailed debugging */
#define TRACE5 (TLEVEL >= 5) /* Very detailed debugging */
#define TRACE6 (TLEVEL >= 6)
#define TRACE7 (TLEVEL >= 7)
#define TRACE8 (TLEVEL >= 8)
#define TLIBPQ (TRACE5 || TFLIBPQ)
#define TSTART (TRACE4 || TFSTART) /* Start of a major function */
#define TEND (TRACE4 || TFEND) /* End of a major function */
#define TLOGIN (TRACE5 || TFLOGIN) /* Connect and disconnect */
#define TCORO (TRACE5 || TFCORO) /* coro and I/O functions */
#define TRACEWARN (TRACE1) /* Non-fatal but serious problems */
/* Do we show a "dbdpg: " header? */
#define THEADER (TFPREFIX) ? "dbdpg: " : ""
#define TRC (void)PerlIO_printf
/* Fancy stuff for tracing of commonly used libpq functions */
#define TRACE_XX if (TLIBPQ) TRC(DBILOGFP,
#define TRACE_PQBACKENDPID TRACE_XX "%sPQbackendPID\n", THEADER)
#define TRACE_PQCANCEL TRACE_XX "%sPQcancel\n", THEADER)
#define TRACE_PQCLEAR TRACE_XX "%sPQclear\n", THEADER)
#define TRACE_PQCMDSTATUS TRACE_XX "%sPQcmdStatus\n", THEADER)
#define TRACE_PQCMDTUPLES TRACE_XX "%sPQcmdTuples\n", THEADER)
#define TRACE_PQCONNECTDB TRACE_XX "%sPQconnectdb\n", THEADER)
#define TRACE_PQCONNECTSTART TRACE_XX "%sPQconnectStart\n", THEADER)
#define TRACE_PQCONNECTPOLL TRACE_XX "%sPQconnectPoll\n", THEADER)
#define TRACE_PQCONSUMEINPUT TRACE_XX "%sPQconsumeInput\n", THEADER)
#define TRACE_PQDB TRACE_XX "%sPQdb\n", THEADER)
#define TRACE_PQENDCOPY TRACE_XX "%sPQendcopy\n", THEADER)
#define TRACE_PQERRORMESSAGE TRACE_XX "%sPQerrorMessage\n", THEADER)
#define TRACE_PQEXEC TRACE_XX "%sPQexec\n", THEADER)
#define TRACE_PQEXECPARAMS TRACE_XX "%sPQexecParams\n", THEADER)
#define TRACE_PQEXECPREPARED TRACE_XX "%sPQexecPrepared\n", THEADER)
#define TRACE_PQFINISH TRACE_XX "%sPQfinish\n", THEADER)
#define TRACE_PQFLUSH TRACE_XX "%sPQflush\n", THEADER)
#define TRACE_PQFMOD TRACE_XX "%sPQfmod\n", THEADER)
#define TRACE_PQFNAME TRACE_XX "%sPQfname\n", THEADER)
#define TRACE_PQFREECANCEL TRACE_XX "%sPQfreeCancel\n", THEADER)
#define TRACE_PQFREEMEM TRACE_XX "%sPQfreemem\n", THEADER)
#define TRACE_PQFREEMEM TRACE_XX "%sPQfreemem\n", THEADER)
#define TRACE_PQFSIZE TRACE_XX "%sPQfsize\n", THEADER)
#define TRACE_PQFTABLECOL TRACE_XX "%sPQftableCol\n", THEADER)
#define TRACE_PQFTABLE TRACE_XX "%sPQftable\n", THEADER)
#define TRACE_PQFTYPE TRACE_XX "%sPQftype\n", THEADER)
#define TRACE_PQGETCANCEL TRACE_XX "%sPQgetCancel\n", THEADER)
#define TRACE_PQGETCOPYDATA TRACE_XX "%sPQgetCopyData\n", THEADER)
#define TRACE_PQGETISNULL TRACE_XX "%sPQgetisnull\n", THEADER)
#define TRACE_PQGETRESULT TRACE_XX "%sPQgetResult\n", THEADER)
#define TRACE_PQGETVALUE TRACE_XX "%sPQgetvalue\n", THEADER)
#define TRACE_PQHOST TRACE_XX "%sPQhost\n", THEADER)
#define TRACE_PQISBUSY TRACE_XX "%sPQisBusy\n", THEADER)
#define TRACE_PQNFIELDS TRACE_XX "%sPQnfields\n", THEADER)
#define TRACE_PQNOTIFIES TRACE_XX "%sPQnotifies\n", THEADER)
#define TRACE_PQNTUPLES TRACE_XX "%sPQntuples\n", THEADER)
#define TRACE_PQOIDVALUE TRACE_XX "%sPQoidValue\n", THEADER)
#define TRACE_PQOPTIONS TRACE_XX "%sPQoptions\n", THEADER)
#define TRACE_PQPARAMETERSTATUS TRACE_XX "%sPQparameterStatus\n", THEADER)
#define TRACE_PQPASS TRACE_XX "%sPQpass\n", THEADER)
#define TRACE_PQPORT TRACE_XX "%sPQport\n", THEADER)
#define TRACE_PQPREPARE TRACE_XX "%sPQprepare\n", THEADER)
#define TRACE_PQPROTOCOLVERSION TRACE_XX "%sPQprotocolVersion\n", THEADER)
#define TRACE_PQPUTCOPYDATA TRACE_XX "%sPQputCopyData\n", THEADER)
#define TRACE_PQPUTCOPYEND TRACE_XX "%sPQputCopyEnd\n", THEADER)
#define TRACE_PQRESULTERRORFIELD TRACE_XX "%sPQresultErrorField\n", THEADER)
#define TRACE_PQRESULTSTATUS TRACE_XX "%sPQresultStatus\n", THEADER)
#define TRACE_PQSENDPREPARE TRACE_XX "%sPQsendPrepare\n", THEADER)
#define TRACE_PQSENDQUERY TRACE_XX "%sPQsendQuery\n", THEADER)
#define TRACE_PQSENDQUERYPARAMS TRACE_XX "%sPQsendQueryParams\n", THEADER)
#define TRACE_PQSENDQUERYPREPARED TRACE_XX "%sPQsendQueryPrepared\n", THEADER)
#define TRACE_PQSERVERVERSION TRACE_XX "%sPQserverVersion\n", THEADER)
#define TRACE_PQSETERRORVERBOSITY TRACE_XX "%sPQsetErrorVerbosity\n", THEADER)
#define TRACE_PQSETNOTICEPROCESSOR TRACE_XX "%sPQsetNoticeProcessor\n", THEADER)
#define TRACE_PQSETNONBLOCKING TRACE_XX "%sPQsetnonblocking\n", THEADER)
#define TRACE_PQSOCKET TRACE_XX "%sPQsocket\n", THEADER)
#define TRACE_PQSTATUS TRACE_XX "%sPQstatus\n", THEADER)
#define TRACE_PQTRACE TRACE_XX "%sPQtrace\n", THEADER)
#define TRACE_PQTRANSACTIONSTATUS TRACE_XX "%sPQtransactionStatus\n", THEADER)
#define TRACE_PQUNTRACE TRACE_XX "%sPQuntrace\n", THEADER)
#define TRACE_PQUSER TRACE_XX "%sPQuser\n", THEADER)
/* end of Pg.h */