* PQexitPipelineMode * End pipeline mode and return to normal command mode. * * Returns 1 in success (pipeline mode successfully ended, or not in pipeline * mode). * * Returns 0 if in pipeline mode and cannot be ended yet. Error message will * be set. */
| 2962 | * be set. |
| 2963 | */ |
| 2964 | int |
| 2965 | PQexitPipelineMode(PGconn *conn) |
| 2966 | { |
| 2967 | if (!conn) |
| 2968 | return 0; |
| 2969 | |
| 2970 | if (conn->pipelineStatus == PQ_PIPELINE_OFF) |
| 2971 | return 1; |
| 2972 | |
| 2973 | switch (conn->asyncStatus) |
| 2974 | { |
| 2975 | case PGASYNC_READY: |
| 2976 | case PGASYNC_READY_MORE: |
| 2977 | /* there are some uncollected results */ |
| 2978 | appendPQExpBufferStr(&conn->errorMessage, |
| 2979 | libpq_gettext("cannot exit pipeline mode with uncollected results\n")); |
| 2980 | return 0; |
| 2981 | |
| 2982 | case PGASYNC_BUSY: |
| 2983 | appendPQExpBufferStr(&conn->errorMessage, |
| 2984 | libpq_gettext("cannot exit pipeline mode while busy\n")); |
| 2985 | return 0; |
| 2986 | |
| 2987 | default: |
| 2988 | /* OK */ |
| 2989 | break; |
| 2990 | } |
| 2991 | |
| 2992 | /* still work to process */ |
| 2993 | if (conn->cmd_queue_head != NULL) |
| 2994 | { |
| 2995 | appendPQExpBufferStr(&conn->errorMessage, |
| 2996 | libpq_gettext("cannot exit pipeline mode with uncollected results\n")); |
| 2997 | return 0; |
| 2998 | } |
| 2999 | |
| 3000 | conn->pipelineStatus = PQ_PIPELINE_OFF; |
| 3001 | conn->asyncStatus = PGASYNC_IDLE; |
| 3002 | |
| 3003 | /* Flush any pending data in out buffer */ |
| 3004 | if (pqFlush(conn) < 0) |
| 3005 | return 0; /* error message is setup already */ |
| 3006 | return 1; |
| 3007 | } |
| 3008 | |
| 3009 | /* |
| 3010 | * pqCommandQueueAdvance |