diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/interfaces/libpq/exports.txt | 3 | ||||
-rw-r--r-- | src/interfaces/libpq/fe-exec.c | 36 | ||||
-rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 1 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/interfaces/libpq/exports.txt b/src/interfaces/libpq/exports.txt index 824a03ffbdc..e8bcc883709 100644 --- a/src/interfaces/libpq/exports.txt +++ b/src/interfaces/libpq/exports.txt @@ -184,4 +184,5 @@ PQexitPipelineMode 181 PQpipelineSync 182 PQpipelineStatus 183 PQsetTraceFlags 184 -PQmblenBounded 185 +PQmblenBounded 185 +PQsendFlushRequest 186 diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 7bd5b3a7b9d..c1b12696725 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -3099,6 +3099,42 @@ sendFailed: return 0; } +/* + * PQsendFlushRequest + * Send request for server to flush its buffer. Useful in pipeline + * mode when a sync point is not desired. + */ +int +PQsendFlushRequest(PGconn *conn) +{ + if (!conn) + return 0; + + /* Don't try to send if we know there's no live connection. */ + if (conn->status != CONNECTION_OK) + { + appendPQExpBufferStr(&conn->errorMessage, + libpq_gettext("no connection to the server\n")); + return 0; + } + + /* Can't send while already busy, either, unless enqueuing for later */ + if (conn->asyncStatus != PGASYNC_IDLE && + conn->pipelineStatus == PQ_PIPELINE_OFF) + { + appendPQExpBufferStr(&conn->errorMessage, + libpq_gettext("another command is already in progress\n")); + return false; + } + + if (pqPutMsgStart('H', conn) < 0 || + pqPutMsgEnd(conn) < 0) + { + return 0; + } + + return 1; +} /* ====== accessor funcs for PGresult ======== */ diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index cc6032b15bd..a6fd69acebc 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -470,6 +470,7 @@ extern int PQconsumeInput(PGconn *conn); extern int PQenterPipelineMode(PGconn *conn); extern int PQexitPipelineMode(PGconn *conn); extern int PQpipelineSync(PGconn *conn); +extern int PQsendFlushRequest(PGconn *conn); /* LISTEN/NOTIFY support */ extern PGnotify *PQnotifies(PGconn *conn); |