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

Function ExplainOpenWorker

src/backend/commands/explain.c:5239–5296  ·  view source on GitHub ↗

* Begin or resume output into the set-aside group for worker N. */

Source from the content-addressed store, hash-verified

5237 * Begin or resume output into the set-aside group for worker N.
5238 */
5239static void
5240ExplainOpenWorker(int n, ExplainState *es)
5241{
5242 ExplainWorkersState *wstate = es->workers_state;
5243
5244 Assert(wstate);
5245 Assert(n >= 0 && n < wstate->num_workers);
5246
5247 /* Save prior output buffer pointer */
5248 wstate->prev_str = es->str;
5249
5250 if (!wstate->worker_inited[n])
5251 {
5252 /* First time through, so create the buffer for this worker */
5253 initStringInfo(&wstate->worker_str[n]);
5254 es->str = &wstate->worker_str[n];
5255
5256 /*
5257 * Push suitable initial formatting state for this worker's field
5258 * group. We allow one extra logical nesting level, since this group
5259 * will eventually be wrapped in an outer "Workers" group.
5260 */
5261 ExplainOpenSetAsideGroup("Worker", NULL, true, 2, es);
5262
5263 /*
5264 * In non-TEXT formats we always emit a "Worker Number" field, even if
5265 * there's no other data for this worker.
5266 */
5267 if (es->format != EXPLAIN_FORMAT_TEXT)
5268 ExplainPropertyInteger("Worker Number", NULL, n, es);
5269
5270 wstate->worker_inited[n] = true;
5271 }
5272 else
5273 {
5274 /* Resuming output for a worker we've already emitted some data for */
5275 es->str = &wstate->worker_str[n];
5276
5277 /* Restore formatting state saved by last ExplainCloseWorker() */
5278 ExplainRestoreGroup(es, 2, &wstate->worker_state_save[n]);
5279 }
5280
5281 /*
5282 * In TEXT format, prefix the first output line for this worker with
5283 * "Worker N:". Then, any additional lines should be indented one more
5284 * stop than the "Worker N" line is.
5285 */
5286 if (es->format == EXPLAIN_FORMAT_TEXT)
5287 {
5288 if (es->str->len == 0)
5289 {
5290 ExplainIndentText(es);
5291 appendStringInfo(es->str, "Worker %d: ", n);
5292 }
5293
5294 es->indent++;
5295 }
5296}

Callers 5

ExplainNodeFunction · 0.85
show_sort_infoFunction · 0.85
show_memoize_infoFunction · 0.85
show_hashagg_infoFunction · 0.85

Calls 6

initStringInfoFunction · 0.85
ExplainOpenSetAsideGroupFunction · 0.85
ExplainPropertyIntegerFunction · 0.85
ExplainRestoreGroupFunction · 0.85
ExplainIndentTextFunction · 0.85
appendStringInfoFunction · 0.85

Tested by

no test coverage detected