@@ -76,6 +76,27 @@ private mixin template ConnectionCtors()
76
76
}
77
77
}
78
78
79
+ // TODO: move to DerelictPQ
80
+ public {
81
+
82
+ private extern (C) int PQenterPipelineMode(PGconn * conn);
83
+ private extern (C) int PQexitPipelineMode(PGconn * conn);
84
+ private extern (C) int PQpipelineSync(PGconn * conn);
85
+ private extern (C) int PQsendFlushRequest(PGconn * conn);
86
+ private extern (C) PGpipelineStatus PQpipelineStatus(const PGconn * conn);
87
+
88
+ enum PGRES_PIPELINE_SYNC = 10 ;
89
+ enum PGRES_PIPELINE_ABORTED = 11 ;
90
+
91
+ enum PGpipelineStatus
92
+ {
93
+ PQ_PIPELINE_OFF ,
94
+ PQ_PIPELINE_ON ,
95
+ PQ_PIPELINE_ABORTED
96
+ }
97
+
98
+ }
99
+
79
100
// / dumb flag for Connection ctor parametrization
80
101
struct ConnectionStart {};
81
102
@@ -186,7 +207,12 @@ class Connection
186
207
if ( r != 1 ) throw new ConnectionException(this , __FILE__ , __LINE__ );
187
208
}
188
209
189
- package bool flush()
210
+ // / Attempts to flush any queued output data to the server.
211
+ // /
212
+ // / Returns: true if successful (or if the send queue is empty), or 1
213
+ // / if it was unable to send all the data in the send queue yet (this
214
+ // / case can only occur if the connection is nonblocking).
215
+ bool flush ()
190
216
{
191
217
assert (conn);
192
218
@@ -273,6 +299,40 @@ class Connection
273
299
return PQsetSingleRowMode (conn) == 1 ;
274
300
}
275
301
302
+ // / Causes a connection to enter pipeline mode if it is currently idle or already in pipeline mode.
303
+ void enterPipelineMode ()
304
+ {
305
+ if (PQenterPipelineMode(conn) == 0 )
306
+ throw new ConnectionException(this );
307
+ }
308
+
309
+ // / Causes a connection to exit pipeline mode if it is currently in pipeline mode with an empty queue and no pending results.
310
+ void exitPipelineMode ()
311
+ {
312
+ if (PQexitPipelineMode(conn) == 0 )
313
+ throw new ConnectionException(this );
314
+ }
315
+
316
+ // / Sends a request for the server to flush its output buffer.
317
+ void sendFlushRequest ()
318
+ {
319
+ if (PQsendFlushRequest(conn) == 0 )
320
+ throw new ConnectionException(this );
321
+ }
322
+
323
+ // / Marks a synchronization point in a pipeline by sending a sync message and flushing the send buffer.
324
+ void pipelineSync ()
325
+ {
326
+ if (PQpipelineSync(conn) != 1 )
327
+ throw new ConnectionException(this );
328
+ }
329
+
330
+ // /
331
+ PGpipelineStatus pipelineStatus ()
332
+ {
333
+ return PQpipelineStatus (conn);
334
+ }
335
+
276
336
/**
277
337
Try to cancel query
278
338
0 commit comments