Fix show_incremental_sort_info with force_parallel_mode
authorTomas Vondra <[email protected]>
Mon, 6 Apr 2020 21:19:13 +0000 (23:19 +0200)
committerTomas Vondra <[email protected]>
Mon, 6 Apr 2020 21:19:13 +0000 (23:19 +0200)
When executed with force_parallel_mode=regress, the function was exiting
too early and thus failed to print the worker stats. Fixed by making it
more like show_sort_info.

Discussion: https://postgr.es/m/CAPpHfds1waRZ=NOmueYq0sx1ZSCnt+5QJvizT8ndT2=etZEeAQ@mail.gmail.com

src/backend/commands/explain.c

index 62c86ecdc59316023193558936460db8fac6f7e7..c31f3e0987f0ff2cfd29f2f0d565681d74577fc7 100644 (file)
@@ -2880,19 +2880,22 @@ show_incremental_sort_info(IncrementalSortState *incrsortstate,
 
    fullsortGroupInfo = &incrsortstate->incsort_info.fullsortGroupInfo;
 
-   if (!(es->analyze && fullsortGroupInfo->groupCount > 0))
+   if (!es->analyze)
        return;
 
-   show_incremental_sort_group_info(fullsortGroupInfo, "Full-sort", true, es);
-   prefixsortGroupInfo = &incrsortstate->incsort_info.prefixsortGroupInfo;
-   if (prefixsortGroupInfo->groupCount > 0)
+   if (fullsortGroupInfo->groupCount > 0)
    {
+       show_incremental_sort_group_info(fullsortGroupInfo, "Full-sort", true, es);
+       prefixsortGroupInfo = &incrsortstate->incsort_info.prefixsortGroupInfo;
+       if (prefixsortGroupInfo->groupCount > 0)
+       {
+           if (es->format == EXPLAIN_FORMAT_TEXT)
+               appendStringInfo(es->str, " ");
+           show_incremental_sort_group_info(prefixsortGroupInfo, "Presorted", false, es);
+       }
        if (es->format == EXPLAIN_FORMAT_TEXT)
-           appendStringInfo(es->str, " ");
-       show_incremental_sort_group_info(prefixsortGroupInfo, "Presorted", false, es);
+           appendStringInfo(es->str, "\n");
    }
-   if (es->format == EXPLAIN_FORMAT_TEXT)
-       appendStringInfo(es->str, "\n");
 
    if (incrsortstate->shared_info != NULL)
    {