This is an automated email from the ASF dual-hosted git repository.

ztao1987 pushed a commit to branch ztao
in repository https://gitbox.apache.org/repos/asf/hawq.git

commit ee9cdc9e2bfb91146a48c85ad6bfb21de332a41e
Author: ztao1987 <zhenglin.ta...@gmail.com>
AuthorDate: Tue Feb 15 11:51:55 2022 +0800

    HAWQ-1830. decorate the output of gp_enable_explain_allstat
---
 src/backend/cdb/cdbexplain.c | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/backend/cdb/cdbexplain.c b/src/backend/cdb/cdbexplain.c
index addae08..1ed3395 100644
--- a/src/backend/cdb/cdbexplain.c
+++ b/src/backend/cdb/cdbexplain.c
@@ -1242,12 +1242,30 @@ cdbexplain_depositStatsToNode(PlanState *planstate, 
CdbExplain_RecvStatCtx *ctx)
           );
         }
 
+        if (gp_enable_explain_allstat) {
+          StringInfoData *extratextbuf = ctx->extratextbuf;
+          if (rsi->bnotes < rsi->enotes)
+          {
+            /* Locate extra message text in dispatch result buffer. */
+            int         notelen = rsi->enotes - rsi->bnotes;
+            const char *notes = (const char *)rsh + rsh->bnotes + rsi->bnotes;
+
+            Insist(rsh->bnotes + rsi->enotes < rsh->enotes &&
+                   notes[notelen] == '\0');
+
+            /* Append to extratextbuf. */
+            nsi->bnotes = extratextbuf->len;
+            appendBinaryStringInfo(extratextbuf, notes, notelen);
+            nsi->enotes = extratextbuf->len;
+          }
+        }
+
         /*
          * Drop qExec's extra text.  We rescue it below if qExec is a winner.
          * For local qDisp slice, ctx->extratextbuf is NULL, which tells us to
          * leave the extra text undisturbed in its existing buffer.
          */
-        if (ctx->extratextbuf)
+        if (ctx->extratextbuf && !gp_enable_explain_allstat)
             nsi->bnotes = nsi->enotes = 0;
 
         if (nsi->running)
@@ -2095,7 +2113,7 @@ cdbexplain_showExecStats(struct PlanState              
*planstate,
                appendStringInfoString(str,
                                "allstat: "
         /*      
"seg_starttime_firststart_counter_firsttuple_startup_total_ntuples_nloops" */
-                                                      
"seg_firststart_total_ntuples");
+                                                      "seg n_tuples 
start_offset timing_to_first_row timing_to_last_row n_loops\n");
 
         for (i = 0; i < ns->ninst; i++)
                {
@@ -2110,16 +2128,19 @@ cdbexplain_showExecStats(struct PlanState              
*planstate,
                        INSTR_TIME_SET_ZERO(timediff);
                INSTR_TIME_ACCUM_DIFF(timediff, nsi->firststart, 
ctx->querystarttime);
                cdbexplain_formatSeconds(startbuf, sizeof(startbuf), 
INSTR_TIME_GET_DOUBLE(timediff));
+                       cdbexplain_formatSeconds(firstbuf, sizeof(firstbuf), 
nsi->firsttuple);
                        cdbexplain_formatSeconds(totalbuf, sizeof(totalbuf), 
nsi->total);
 
+                       appendStringInfoFill(str, 2*indent + 
sizeof("allstat:"), ' ');
                        appendStringInfo(str,
-                             "/seg%d_%s_%s_%.0f",
+                             "seg%d rows_out %.0f, start_offset_by %s, %s 
to_first, %s to_end, in %.0f loop\n",
                              ns->segindex0 + i,
+                                                        nsi->ntuples,
                                                         startbuf,
+                                                        firstbuf,
                                                         totalbuf,
-                             nsi->ntuples);
+                                                        nsi->nloops);
                }
-               appendStringInfoString(str, "//end\n");
        }
 }                               /* cdbexplain_showExecStats */
 

Reply via email to