aboutsummaryrefslogtreecommitdiff
path: root/contrib/pg_stat_statements
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-12-09 14:38:19 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-12-09 14:38:19 -0500
commit3eea7a0c97e94f9570af87317ce3f6a41eb62768 (patch)
treefe426b4ddb973faf23194ce07c4d853c55accbd5 /contrib/pg_stat_statements
parent4d8275046c36792afb3604677c0a53c8530388ae (diff)
downloadpostgresql-3eea7a0c97e94f9570af87317ce3f6a41eb62768.tar.gz
postgresql-3eea7a0c97e94f9570af87317ce3f6a41eb62768.zip
Simplify executor's determination of whether to use parallelism.
Our parallel-mode code only works when we are executing a query in full, so ExecutePlan must disable parallel mode when it is asked to do partial execution. The previous logic for this involved passing down a flag (variously named execute_once or run_once) from callers of ExecutorRun or PortalRun. This is overcomplicated, and unsurprisingly some of the callers didn't get it right, since it requires keeping state that not all of them have handy; not to mention that the requirements for it were undocumented. That led to assertion failures in some corner cases. The only state we really need for this is the existing QueryDesc.already_executed flag, so let's just put all the responsibility in ExecutePlan. (It could have been done in ExecutorRun too, leading to a slightly shorter patch -- but if there's ever more than one caller of ExecutePlan, it seems better to have this logic in the subroutine than the callers.) This makes those ExecutorRun/PortalRun parameters unnecessary. In master it seems okay to just remove them, returning the API for those functions to what it was before parallelism. Such an API break is clearly not okay in stable branches, but for them we can just leave the parameters in place after documenting that they do nothing. Per report from Yugo Nagata, who also reviewed and tested this patch. Back-patch to all supported branches. Discussion: https://postgr.es/m/20241206062549.710dc01cf91224809dd6c0e1@sraoss.co.jp
Diffstat (limited to 'contrib/pg_stat_statements')
-rw-r--r--contrib/pg_stat_statements/pg_stat_statements.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/contrib/pg_stat_statements/pg_stat_statements.c b/contrib/pg_stat_statements/pg_stat_statements.c
index 49c657b3e07..602cae54ffd 100644
--- a/contrib/pg_stat_statements/pg_stat_statements.c
+++ b/contrib/pg_stat_statements/pg_stat_statements.c
@@ -335,7 +335,7 @@ static PlannedStmt *pgss_planner(Query *parse,
static void pgss_ExecutorStart(QueryDesc *queryDesc, int eflags);
static void pgss_ExecutorRun(QueryDesc *queryDesc,
ScanDirection direction,
- uint64 count, bool execute_once);
+ uint64 count);
static void pgss_ExecutorFinish(QueryDesc *queryDesc);
static void pgss_ExecutorEnd(QueryDesc *queryDesc);
static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString,
@@ -1021,16 +1021,15 @@ pgss_ExecutorStart(QueryDesc *queryDesc, int eflags)
* ExecutorRun hook: all we need do is track nesting depth
*/
static void
-pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
- bool execute_once)
+pgss_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count)
{
nesting_level++;
PG_TRY();
{
if (prev_ExecutorRun)
- prev_ExecutorRun(queryDesc, direction, count, execute_once);
+ prev_ExecutorRun(queryDesc, direction, count);
else
- standard_ExecutorRun(queryDesc, direction, count, execute_once);
+ standard_ExecutorRun(queryDesc, direction, count);
}
PG_FINALLY();
{