diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-04-06 22:22:13 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-04-06 22:22:13 -0400 |
commit | c7654f6a37792ab9525ff98b710c23b27c7868a5 (patch) | |
tree | 38b482ac8386739b6dd2893564d1ab9443036bf0 /src/backend/commands/explain.c | |
parent | 4c04be9b05ad2ec5acd27c3417bf075c13cab134 (diff) | |
download | postgresql-c7654f6a37792ab9525ff98b710c23b27c7868a5.tar.gz postgresql-c7654f6a37792ab9525ff98b710c23b27c7868a5.zip |
Fix representation of SORT_TYPE_STILL_IN_PROGRESS.
It turns out that the code did indeed rely on a zeroed
TuplesortInstrumentation.sortMethod field to indicate
"this worker never did anything", although it seems the
issue only comes up during certain race-condition-y cases.
Hence, rearrange the TuplesortMethod enum to restore
SORT_TYPE_STILL_IN_PROGRESS to having the value zero,
and add some comments reinforcing that that isn't optional.
Also future-proof a loop over the possible values of the enum.
sizeof(bits32) happened to be the correct limit value,
but only by purest coincidence.
Per buildfarm and local investigation.
Discussion: https://postgr.es/m/12222.1586223974@sss.pgh.pa.us
Diffstat (limited to 'src/backend/commands/explain.c')
-rw-r--r-- | src/backend/commands/explain.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index cad10662bb0..baaa5817af7 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -2762,14 +2762,14 @@ show_incremental_sort_group_info(IncrementalSortGroupInfo *groupInfo, List *methodNames = NIL; /* Generate a list of sort methods used across all groups. */ - for (int bit = 0; bit < sizeof(bits32); ++bit) + for (int bit = 0; bit < NUM_TUPLESORTMETHODS; bit++) { - if (groupInfo->sortMethods & (1 << bit)) + TuplesortMethod sortMethod = (1 << bit); + + if (groupInfo->sortMethods & sortMethod) { - TuplesortMethod sortMethod = (1 << bit); - const char *methodName; + const char *methodName = tuplesort_method_name(sortMethod); - methodName = tuplesort_method_name(sortMethod); methodNames = lappend(methodNames, unconstify(char *, methodName)); } } |