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

Function ExplainQuery

src/backend/commands/explain.c:205–356  ·  view source on GitHub ↗

* ExplainQuery - * execute an EXPLAIN command */

Source from the content-addressed store, hash-verified

203 * execute an EXPLAIN command
204 */
205void
206ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
207 ParamListInfo params, DestReceiver *dest)
208{
209 ExplainState *es = NewExplainState();
210 TupOutputState *tstate;
211 JumbleState *jstate = NULL;
212 Query *query;
213 List *rewritten;
214 ListCell *lc;
215 bool timing_set = false;
216 bool summary_set = false;
217
218 /* Parse options list. */
219 foreach(lc, stmt->options)
220 {
221 DefElem *opt = (DefElem *) lfirst(lc);
222
223 if (strcmp(opt->defname, "analyze") == 0)
224 es->analyze = defGetBoolean(opt);
225 else if (strcmp(opt->defname, "verbose") == 0)
226 es->verbose = defGetBoolean(opt);
227 else if (strcmp(opt->defname, "locus") == 0)
228 es->locus = defGetBoolean(opt);
229 else if (strcmp(opt->defname, "costs") == 0)
230 es->costs = defGetBoolean(opt);
231 else if (strcmp(opt->defname, "buffers") == 0)
232 es->buffers = defGetBoolean(opt);
233 else if (strcmp(opt->defname, "wal") == 0)
234 es->wal = defGetBoolean(opt);
235 else if (strcmp(opt->defname, "settings") == 0)
236 es->settings = defGetBoolean(opt);
237 else if (strcmp(opt->defname, "timing") == 0)
238 {
239 timing_set = true;
240 es->timing = defGetBoolean(opt);
241 }
242 else if (strcmp(opt->defname, "summary") == 0)
243 {
244 summary_set = true;
245 es->summary = defGetBoolean(opt);
246 }
247 else if (strcmp(opt->defname, "format") == 0)
248 {
249 char *p = defGetString(opt);
250
251 if (strcmp(p, "text") == 0)
252 es->format = EXPLAIN_FORMAT_TEXT;
253 else if (strcmp(p, "xml") == 0)
254 es->format = EXPLAIN_FORMAT_XML;
255 else if (strcmp(p, "json") == 0)
256 es->format = EXPLAIN_FORMAT_JSON;
257 else if (strcmp(p, "yaml") == 0)
258 es->format = EXPLAIN_FORMAT_YAML;
259 else
260 ereport(ERROR,
261 (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
262 errmsg("unrecognized value for EXPLAIN option \"%s\": \"%s\"",

Callers 1

standard_ProcessUtilityFunction · 0.85

Calls 15

NewExplainStateFunction · 0.85
defGetBooleanFunction · 0.85
defGetStringFunction · 0.85
parser_errpositionFunction · 0.85
IsQueryIdEnabledFunction · 0.85
JumbleQueryFunction · 0.85
QueryRewriteFunction · 0.85
ExplainBeginOutputFunction · 0.85
appendStringInfoStringFunction · 0.85
ExplainOneQueryFunction · 0.85
lnextFunction · 0.85
ExplainSeparatePlansFunction · 0.85

Tested by

no test coverage detected