• unknown's avatar
    Backport: · 4eb0a553
    unknown authored
    B-g#27060: SQL Profile utility may not be reporting right duration \
          for each step
    
    Whenever the profiler is reset at the beginning of a query, there's
    a "hidden" profiling entry that represents that point in time.  It 
    has no status description, as those are set by state changes and no
    such point has yet been encountered.  That profiling entry is not
    in the list of entries generated when we change states.
    
    The profiling code had the problem that each step of printing 
    profiling data subtracted the previous "step"'s data, but gave the
    label to that data of the current step, which is wrong.  The label/
    state refers to the period beginning with that profiling data, not
    ending with it.
    
    Now, give a label to the first profiling pseudo-entry, so that we 
    have a name to assign to the period that ends with the first state 
    change.  Now also use the state name of the previous step in showing 
    the delta values that end with this step.
    
    
    sql/sql_profile.cc:
      Store a status of "initializing" whenever we construct the first
      profile entry -- the one that gets reset whenever we're starting 
      a new query, before the server sets a real status.
      
      Additionally, associate the previous status with the time period
      that ends with the current profile entry's stats.
      
      Since we need yet another piece of info from the previous profiling
      entry, take out the piecemeal ways we currently do it and make a
      general pointer to the whole thing.
    4eb0a553
sql_profile.cc 23.5 KB