MCPcopy Create free account
hub / github.com/apache/cloudberry / PQpipelineSync

Function PQpipelineSync

src/interfaces/libpq/fe-exec.c:3115–3175  ·  view source on GitHub ↗

* PQpipelineSync * Send a Sync message as part of a pipeline, and flush to server * * It's legal to start submitting more commands in the pipeline immediately, * without waiting for the results of the current pipeline. There's no need to * end pipeline mode and start it again. * * If a command in a pipeline fails, every subsequent command up to and including * the result to the Sync messa

Source from the content-addressed store, hash-verified

3113 * are processed by the client.
3114 */
3115int
3116PQpipelineSync(PGconn *conn)
3117{
3118 PGcmdQueueEntry *entry;
3119
3120 if (!conn)
3121 return 0;
3122
3123 if (conn->pipelineStatus == PQ_PIPELINE_OFF)
3124 {
3125 appendPQExpBufferStr(&conn->errorMessage,
3126 libpq_gettext("cannot send pipeline when not in pipeline mode\n"));
3127 return 0;
3128 }
3129
3130 switch (conn->asyncStatus)
3131 {
3132 case PGASYNC_COPY_IN:
3133 case PGASYNC_COPY_OUT:
3134 case PGASYNC_COPY_BOTH:
3135 /* should be unreachable */
3136 appendPQExpBufferStr(&conn->errorMessage,
3137 "internal error: cannot send pipeline while in COPY\n");
3138 return 0;
3139 case PGASYNC_READY:
3140 case PGASYNC_READY_MORE:
3141 case PGASYNC_BUSY:
3142 case PGASYNC_IDLE:
3143 /* OK to send sync */
3144 break;
3145 }
3146
3147 entry = pqAllocCmdQueueEntry(conn);
3148 if (entry == NULL)
3149 return 0; /* error msg already set */
3150
3151 entry->queryclass = PGQUERY_SYNC;
3152 entry->query = NULL;
3153
3154 /* construct the Sync message */
3155 if (pqPutMsgStart('S', conn) < 0 ||
3156 pqPutMsgEnd(conn) < 0)
3157 goto sendFailed;
3158
3159 /*
3160 * Give the data a push. In nonblock mode, don't complain if we're unable
3161 * to send it all; PQgetResult() will do any additional flushing needed.
3162 */
3163 if (PQflush(conn) < 0)
3164 goto sendFailed;
3165
3166 /* OK, it's launched! */
3167 pqAppendCmdQueueEntry(conn, entry);
3168
3169 return 1;
3170
3171sendFailed:
3172 pqRecycleCmdQueueEntry(conn, entry);

Callers 8

test_multi_pipelinesFunction · 0.85
test_pipeline_abortFunction · 0.85
test_pipelined_insertFunction · 0.85
test_preparedFunction · 0.85
test_simple_pipelineFunction · 0.85
test_singlerowmodeFunction · 0.85
test_transactionFunction · 0.85
executeMetaCommandFunction · 0.85

Calls 8

appendPQExpBufferStrFunction · 0.85
libpq_gettextFunction · 0.85
pqAllocCmdQueueEntryFunction · 0.85
pqPutMsgStartFunction · 0.85
pqPutMsgEndFunction · 0.85
PQflushFunction · 0.85
pqAppendCmdQueueEntryFunction · 0.85
pqRecycleCmdQueueEntryFunction · 0.85

Tested by 7

test_multi_pipelinesFunction · 0.68
test_pipeline_abortFunction · 0.68
test_pipelined_insertFunction · 0.68
test_preparedFunction · 0.68
test_simple_pipelineFunction · 0.68
test_singlerowmodeFunction · 0.68
test_transactionFunction · 0.68