Skip to content

Commit d23d1a4

Browse files
committed
Merge tag 'v1.2.5'
2 parents 52ed83e + e47ecda commit d23d1a4

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

src/dpq2/connection.d

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,27 @@ private mixin template ConnectionCtors()
7676
}
7777
}
7878

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+
79100
/// dumb flag for Connection ctor parametrization
80101
struct ConnectionStart {};
81102

@@ -186,7 +207,12 @@ class Connection
186207
if( r != 1 ) throw new ConnectionException(this, __FILE__, __LINE__);
187208
}
188209

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()
190216
{
191217
assert(conn);
192218

@@ -273,6 +299,40 @@ class Connection
273299
return PQsetSingleRowMode(conn) == 1;
274300
}
275301

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+
276336
/**
277337
Try to cancel query
278338

0 commit comments

Comments
 (0)