@@ -889,6 +889,20 @@ bool PFS_status_variable_cache::do_initialize_session(void)
889
889
return ret;
890
890
}
891
891
892
+ /* *
893
+ For the current THD, use initial_status_vars taken from before the query start.
894
+ */
895
+ STATUS_VAR *PFS_status_variable_cache::set_status_vars (void )
896
+ {
897
+ STATUS_VAR *status_vars;
898
+ if (m_safe_thd == m_current_thd && m_current_thd->initial_status_var != NULL )
899
+ status_vars= m_current_thd->initial_status_var ;
900
+ else
901
+ status_vars= &m_safe_thd->status_var ;
902
+
903
+ return status_vars;
904
+ }
905
+
892
906
/* *
893
907
Build cache for GLOBAL status variables using values totaled from all threads.
894
908
*/
@@ -967,8 +981,9 @@ int PFS_status_variable_cache::do_materialize_all(THD* unsafe_thd)
967
981
/*
968
982
Build the status variable cache using the SHOW_VAR array as a reference.
969
983
Use the status values from the THD protected by the thread manager lock.
970
- */
971
- manifest (m_safe_thd, m_show_var_array.begin (), &m_safe_thd->status_var , " " , false , false );
984
+ */
985
+ STATUS_VAR *status_vars= set_status_vars ();
986
+ manifest (m_safe_thd, m_show_var_array.begin (), status_vars, " " , false , false );
972
987
973
988
/* Release lock taken in get_THD(). */
974
989
mysql_mutex_unlock (&m_safe_thd->LOCK_thd_data );
@@ -1012,8 +1027,9 @@ int PFS_status_variable_cache::do_materialize_session(THD* unsafe_thd)
1012
1027
/*
1013
1028
Build the status variable cache using the SHOW_VAR array as a reference.
1014
1029
Use the status values from the THD protected by the thread manager lock.
1015
- */
1016
- manifest (m_safe_thd, m_show_var_array.begin (), &m_safe_thd->status_var , " " , false , true );
1030
+ */
1031
+ STATUS_VAR *status_vars= set_status_vars ();
1032
+ manifest (m_safe_thd, m_show_var_array.begin (), status_vars, " " , false , true );
1017
1033
1018
1034
/* Release lock taken in get_THD(). */
1019
1035
mysql_mutex_unlock (&m_safe_thd->LOCK_thd_data );
@@ -1054,7 +1070,8 @@ int PFS_status_variable_cache::do_materialize_session(PFS_thread *pfs_thread)
1054
1070
Build the status variable cache using the SHOW_VAR array as a reference.
1055
1071
Use the status values from the THD protected by the thread manager lock.
1056
1072
*/
1057
- manifest (m_safe_thd, m_show_var_array.begin (), &m_safe_thd->status_var , " " , false , true );
1073
+ STATUS_VAR *status_vars= set_status_vars ();
1074
+ manifest (m_safe_thd, m_show_var_array.begin (), status_vars, " " , false , true );
1058
1075
1059
1076
/* Release lock taken in get_THD(). */
1060
1077
mysql_mutex_unlock (&m_safe_thd->LOCK_thd_data );
0 commit comments