/* check that WAL is used with EXPLAIN ANALYZE */ if (es->wal && !es->analyze)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("EXPLAIN option %s requires ANALYZE", "WAL")));
/* if the timing was not set explicitly, set default value */
es->timing = (timing_set) ? es->timing : es->analyze;
/* if the buffers was not set explicitly, set default value */
es->buffers = (buffers_set) ? es->buffers : es->analyze;
/* check that timing is used with EXPLAIN ANALYZE */ if (es->timing && !es->analyze)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("EXPLAIN option %s requires ANALYZE", "TIMING")));
/* check that serialize is used with EXPLAIN ANALYZE */ if (es->serialize != EXPLAIN_SERIALIZE_NONE && !es->analyze)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("EXPLAIN option %s requires ANALYZE", "SERIALIZE")));
/* check that GENERIC_PLAN is not used with EXPLAIN ANALYZE */ if (es->generic && es->analyze)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("%s options %s and %s cannot be used together", "EXPLAIN", "ANALYZE", "GENERIC_PLAN")));
/* if the summary was not set explicitly, set default value */
es->summary = (summary_set) ? es->summary : es->analyze;
/* plugin specific option validation */ if (explain_validate_options_hook)
(*explain_validate_options_hook) (es, options, pstate);
}
/* *MapthenameofanEXPLAINextensiontoanintegerID. * *Withinthelifetimeofaparticularbackend,thesamenamewillbemapped *tothesameIDeverytime.IDsarenotstableacrossbackends.UsetheID *thatyougetfromthisfunctiontocallGetExplainExtensionStateand *SetExplainExtensionState. * *extension_nameisassumedtobeaconstantstringorallocatedinstorage *thatwillneverbefreed.
*/ int
GetExplainExtensionId(constchar *extension_name)
{ /* Search for an existing extension by this name; if found, return ID. */ for (int i = 0; i < ExplainExtensionNamesAssigned; ++i) if (strcmp(ExplainExtensionNameArray[i], extension_name) == 0) return i;
/* If there is no array yet, create one. */ if (ExplainExtensionNameArray == NULL)
{
ExplainExtensionNamesAllocated = 16;
ExplainExtensionNameArray = (constchar **)
MemoryContextAlloc(TopMemoryContext,
ExplainExtensionNamesAllocated
* sizeof(char *));
}
/* If there's an array but it's currently full, expand it. */ if (ExplainExtensionNamesAssigned >= ExplainExtensionNamesAllocated)
{ int i = pg_nextpower2_32(ExplainExtensionNamesAssigned + 1);
/* Search for an existing option by this name; if found, update handler. */ for (int i = 0; i < ExplainExtensionOptionsAssigned; ++i)
{ if (strcmp(ExplainExtensionOptionArray[i].option_name,
option_name) == 0)
{
ExplainExtensionOptionArray[i].option_handler = handler; return;
}
}
/* If there is no array yet, create one. */ if (ExplainExtensionOptionArray == NULL)
{
ExplainExtensionOptionsAllocated = 16;
ExplainExtensionOptionArray = (ExplainExtensionOption *)
MemoryContextAlloc(TopMemoryContext,
ExplainExtensionOptionsAllocated
* sizeof(ExplainExtensionOption));
}
/* If there's an array but it's currently full, expand it. */ if (ExplainExtensionOptionsAssigned >= ExplainExtensionOptionsAllocated)
{ int i = pg_nextpower2_32(ExplainExtensionOptionsAssigned + 1);