* pqAppendCmdQueueEntry * Append a caller-allocated entry to the command queue, and update * conn->asyncStatus to account for it. * * The query itself must already have been put in the output buffer by the * caller. */
| 1278 | * caller. |
| 1279 | */ |
| 1280 | void |
| 1281 | pqAppendCmdQueueEntry(PGconn *conn, PGcmdQueueEntry *entry) |
| 1282 | { |
| 1283 | Assert(entry->next == NULL); |
| 1284 | |
| 1285 | if (conn->cmd_queue_head == NULL) |
| 1286 | conn->cmd_queue_head = entry; |
| 1287 | else |
| 1288 | conn->cmd_queue_tail->next = entry; |
| 1289 | |
| 1290 | conn->cmd_queue_tail = entry; |
| 1291 | |
| 1292 | switch (conn->pipelineStatus) |
| 1293 | { |
| 1294 | case PQ_PIPELINE_OFF: |
| 1295 | case PQ_PIPELINE_ON: |
| 1296 | |
| 1297 | /* |
| 1298 | * When not in pipeline aborted state, if there's a result ready |
| 1299 | * to be consumed, let it be so (that is, don't change away from |
| 1300 | * READY or READY_MORE); otherwise set us busy to wait for |
| 1301 | * something to arrive from the server. |
| 1302 | */ |
| 1303 | if (conn->asyncStatus == PGASYNC_IDLE) |
| 1304 | conn->asyncStatus = PGASYNC_BUSY; |
| 1305 | break; |
| 1306 | |
| 1307 | case PQ_PIPELINE_ABORTED: |
| 1308 | |
| 1309 | /* |
| 1310 | * In aborted pipeline state, we don't expect anything from the |
| 1311 | * server (since we don't send any queries that are queued). |
| 1312 | * Therefore, if IDLE then do what PQgetResult would do to let |
| 1313 | * itself consume commands from the queue; if we're in any other |
| 1314 | * state, we don't have to do anything. |
| 1315 | */ |
| 1316 | if (conn->asyncStatus == PGASYNC_IDLE) |
| 1317 | { |
| 1318 | resetPQExpBuffer(&conn->errorMessage); |
| 1319 | pqPipelineProcessQueue(conn); |
| 1320 | } |
| 1321 | break; |
| 1322 | } |
| 1323 | } |
| 1324 | |
| 1325 | /* |
| 1326 | * pqRecycleCmdQueueEntry |
no test coverage detected