PostgreSQL Source Code: src/include/libpq/libpq-be-fe-helpers.h Source File (original) (raw)
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#ifndef LIBPQ_BE_FE_HELPERS_H
31#define LIBPQ_BE_FE_HELPERS_H
32
33
34
35
36
37
38
39#ifdef BUILDING_DLL
40#error "libpq may not be used code directly built into the backend"
41#endif
42
49
50
55
56
57
58
59
60
61
62
63
64
67{
69
71
73
75
77}
78
79
80
81
82
85 const char *const *values,
86 int expand_dbname,
87 uint32 wait_event_info)
88{
90
92
94
96
98}
99
100
101
102
103
104
105
106static inline void
108{
109
110
111
112
113
114
115
116 if (conn == NULL)
117 return;
118
121}
122
123
124
125
126
127
128
129
130static inline void
132{
133
134
135
136
137
139 {
140#ifndef WIN32
142 (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
143 errmsg("could not establish connection"),
144 errdetail("There are too many open files on the local server."),
145 errhint("Raise the server's \"max_files_per_process\" and/or \"ulimit -n\" limits.")));
146#else
148 (errcode(ERRCODE_SQLCLIENT_UNABLE_TO_ESTABLISH_SQLCONNECTION),
149 errmsg("could not establish connection"),
150 errdetail("There are too many open files on the local server."),
151 errhint("Raise the server's \"max_files_per_process\" setting.")));
152#endif
153 }
154}
155
156
157
158
159static inline void
161{
162
163
164
165
166 if (conn == NULL)
167 {
169 return;
170 }
171
172
173
174
175
177 return;
178
179
180
181
182
184 {
186
187
188
189
190
191
194 {
195 int io_flag;
196 int rc;
197
200#ifdef WIN32
201
202
203
204
205
208#endif
209 else
211
215 0,
216 wait_event_info);
217
218
220 {
223 }
224
225
226 if (rc & io_flag)
228 }
229 }
231 {
232
233
234
235
236
239
241 }
243}
244
245
246
247
248
249
250
251
252
253
254
257{
259 return NULL;
261}
262
263
264
265
266
267
270 const char *command,
271 int nParams,
272 const Oid *paramTypes,
273 const char *const *paramValues,
274 const int *paramLengths,
275 const int *paramFormats,
276 int resultFormat,
277 uint32 wait_event_info)
278{
280 paramLengths, paramFormats, resultFormat))
281 return NULL;
283}
284
285
286
287
288
291{
292 PGresult *volatile lastResult = NULL;
293
294
296 {
297 for (;;)
298 {
299
301
303 if (result == NULL)
304 break;
305
306
307
308
309
311 lastResult = result;
312
317 break;
318 }
319 }
321 {
324 }
326
327 return lastResult;
328}
329
330
331
332
335{
336
337
338
339
341 {
342 int rc;
343
348 0,
349 wait_event_info);
350
351
353 {
356 }
357
358
360 {
361
362 break;
363 }
364 }
365
366
368}
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385static inline const char *
387{
389 const char *error = NULL;
390
392 if (cancel_conn == NULL)
393 return "out of memory";
394
395
396
398 {
400 {
402 goto exit;
403 }
404
405 for (;;)
406 {
409 long cur_timeout;
411
414 break;
415
416
419 if (cur_timeout <= 0)
420 {
421 error = "cancel request timed out";
422 break;
423 }
424
425 switch (pollres)
426 {
429 break;
432 break;
433 default:
435 goto exit;
436 }
437
438
441
443
445 }
446exit: ;
447 }
449 {
451 }
453
455}
456
457#endif
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
TimestampTz GetCurrentTimestamp(void)
Datum now(PG_FUNCTION_ARGS)
static Datum values[MAXATTR]
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
void ReleaseExternalFD(void)
bool AcquireExternalFD(void)
PGcancelConn * PQcancelCreate(PGconn *conn)
PostgresPollingStatusType PQcancelPoll(PGcancelConn *cancelConn)
void PQcancelFinish(PGcancelConn *cancelConn)
int PQcancelSocket(const PGcancelConn *cancelConn)
char * PQcancelErrorMessage(const PGcancelConn *cancelConn)
int PQcancelStart(PGcancelConn *cancelConn)
PostgresPollingStatusType PQconnectPoll(PGconn *conn)
ConnStatusType PQstatus(const PGconn *conn)
PGconn * PQconnectStart(const char *conninfo)
PGconn * PQconnectStartParams(const char *const *keywords, const char *const *values, int expand_dbname)
void PQfinish(PGconn *conn)
int PQsocket(const PGconn *conn)
int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
PGresult * PQgetResult(PGconn *conn)
ExecStatusType PQresultStatus(const PGresult *res)
void PQclear(PGresult *res)
int PQconsumeInput(PGconn *conn)
int PQsendQuery(PGconn *conn, const char *query)
int PQisBusy(PGconn *conn)
static const JsonPathKeyword keywords[]
int WaitLatchOrSocket(Latch *latch, int wakeEvents, pgsocket sock, long timeout, uint32 wait_event_info)
void ResetLatch(Latch *latch)
static const char * libpqsrv_cancel(PGconn *conn, TimestampTz endtime)
static PGresult * libpqsrv_exec(PGconn *conn, const char *query, uint32 wait_event_info)
static PGconn * libpqsrv_connect_params(const char *const *keywords, const char *const *values, int expand_dbname, uint32 wait_event_info)
static PGconn * libpqsrv_connect(const char *conninfo, uint32 wait_event_info)
static void libpqsrv_connect_prepare(void)
static PGresult * libpqsrv_get_result(PGconn *conn, uint32 wait_event_info)
static void libpqsrv_connect_internal(PGconn *conn, uint32 wait_event_info)
static void libpqsrv_disconnect(PGconn *conn)
static PGresult * libpqsrv_exec_params(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat, uint32 wait_event_info)
static PGresult * libpqsrv_get_result_last(PGconn *conn, uint32 wait_event_info)
PostgresPollingStatusType
char * pchomp(const char *in)
#define CHECK_FOR_INTERRUPTS()
#define WL_SOCKET_READABLE
#define WL_EXIT_ON_PM_DEATH
#define WL_SOCKET_CONNECTED
#define WL_SOCKET_WRITEABLE