Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions | Variables
mysqlnd_statistics.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  st_mysqlnd_string

Defines

#define MYSQLND_STATS_LOCK(stats)
#define MYSQLND_STATS_UNLOCK(stats)
#define MYSQLND_STAT_CALL_TRIGGER(s_array, statistic, val)
#define MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(stats, statistic, value)
#define MYSQLND_DEC_STATISTIC(enabler, stats, statistic)
#define MYSQLND_INC_STATISTIC(enabler, stats, statistic)
#define MYSQLND_INC_STATISTIC_W_VALUE(enabler, stats, statistic, value)
#define MYSQLND_INC_STATISTIC_W_VALUE2(enabler, stats, statistic1, value1, statistic2, value2)
#define MYSQLND_INC_STATISTIC_W_VALUE3(enabler, stats, statistic1, value1, statistic2, value2, statistic3, value3)
#define MYSQLND_INC_GLOBAL_STATISTIC(statistic)   MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
#define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic)   MYSQLND_DEC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))
#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2(statistic1, value1, statistic2, value2)   MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2))
#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic)
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE(conn_stats, statistic, value)
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2(conn_stats, statistic1, value1, statistic2, value2)
#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3(conn_stats, statistic1, value1, statistic2, value2, statistic3, value3)

Typedefs

typedef struct st_mysqlnd_string MYSQLND_STRING

Functions

PHPAPI void mysqlnd_fill_stats_hash (const MYSQLND_STATS *const stats, const MYSQLND_STRING *names, zval *return_value TSRMLS_DC ZEND_FILE_LINE_DC)
PHPAPI void mysqlnd_stats_init (MYSQLND_STATS **stats, size_t statistic_count)
PHPAPI void mysqlnd_stats_end (MYSQLND_STATS *stats)
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger (MYSQLND_STATS *const stats, enum_mysqlnd_collected_stats stat, mysqlnd_stat_trigger trigger TSRMLS_DC)
PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers (MYSQLND_STATS *const stats TSRMLS_DC)

Variables

PHPAPI MYSQLND_STATS * mysqlnd_global_stats
const MYSQLND_STRING mysqlnd_stats_values_names []

Class Documentation

struct st_mysqlnd_string

Definition at line 29 of file mysqlnd_statistics.h.

Class Members
size_t l
char * s

Define Documentation

#define MYSQLND_DEC_CONN_STATISTIC (   conn_stats,
  statistic 
)    MYSQLND_DEC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic))

Definition at line 132 of file mysqlnd_statistics.h.

#define MYSQLND_DEC_STATISTIC (   enabler,
  stats,
  statistic 
)
Value:
{ \
	enum_mysqlnd_collected_stats _s = (statistic);\
       MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
       if ((enabler) && _p_s && _s != _p_s->count) { \
              MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, -1); \
       }\
 }

Definition at line 68 of file mysqlnd_statistics.h.

#define MYSQLND_INC_CONN_STATISTIC (   conn_stats,
  statistic 
)
Value:
MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic)); \
       MYSQLND_INC_STATISTIC(MYSQLND_G(collect_statistics), (conn_stats), (statistic));

Definition at line 138 of file mysqlnd_statistics.h.

#define MYSQLND_INC_CONN_STATISTIC_W_VALUE (   conn_stats,
  statistic,
  value 
)
Value:
MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic), (value)); \
       MYSQLND_INC_STATISTIC_W_VALUE(MYSQLND_G(collect_statistics), (conn_stats), (statistic), (value));

Definition at line 142 of file mysqlnd_statistics.h.

#define MYSQLND_INC_CONN_STATISTIC_W_VALUE2 (   conn_stats,
  statistic1,
  value1,
  statistic2,
  value2 
)
Value:
MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2)); \
       MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2));

Definition at line 146 of file mysqlnd_statistics.h.

#define MYSQLND_INC_CONN_STATISTIC_W_VALUE3 (   conn_stats,
  statistic1,
  value1,
  statistic2,
  value2,
  statistic3,
  value3 
)
Value:
MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2), (statistic3), (value3)); \
       MYSQLND_INC_STATISTIC_W_VALUE3(MYSQLND_G(collect_statistics), (conn_stats), (statistic1), (value1), (statistic2), (value2), (statistic3), (value3));

Definition at line 150 of file mysqlnd_statistics.h.

Definition at line 129 of file mysqlnd_statistics.h.

#define MYSQLND_INC_GLOBAL_STATISTIC_W_VALUE2 (   statistic1,
  value1,
  statistic2,
  value2 
)    MYSQLND_INC_STATISTIC_W_VALUE2(MYSQLND_G(collect_statistics), mysqlnd_global_stats, (statistic1), (value1), (statistic2), (value2))

Definition at line 135 of file mysqlnd_statistics.h.

#define MYSQLND_INC_STATISTIC (   enabler,
  stats,
  statistic 
)
Value:
{ \
	enum_mysqlnd_collected_stats _s = (statistic);\
       MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
       if ((enabler) && _p_s && _s != _p_s->count) { \
              MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, 1); \
       }\
 }

Definition at line 77 of file mysqlnd_statistics.h.

#define MYSQLND_INC_STATISTIC_W_VALUE (   enabler,
  stats,
  statistic,
  value 
)
Value:
{ \
	enum_mysqlnd_collected_stats _s = (statistic);\
       MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
       if ((enabler) && _p_s && _s != _p_s->count) { \
		uint64_t v = (uint64_t) (value); \
              MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s, v); \
       }\
 }

Definition at line 86 of file mysqlnd_statistics.h.

#define MYSQLND_INC_STATISTIC_W_VALUE2 (   enabler,
  stats,
  statistic1,
  value1,
  statistic2,
  value2 
)
Value:
{ \
       MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
       if ((enabler) && _p_s) { \
		uint64_t v1 = (uint64_t) (value1); \
		uint64_t v2 = (uint64_t) (value2); \
		enum_mysqlnd_collected_stats _s1 = (statistic1);\
		enum_mysqlnd_collected_stats _s2 = (statistic2);\
              if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
              if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
       }\
 }

Definition at line 96 of file mysqlnd_statistics.h.

#define MYSQLND_INC_STATISTIC_W_VALUE3 (   enabler,
  stats,
  statistic1,
  value1,
  statistic2,
  value2,
  statistic3,
  value3 
)
Value:
{ \
       MYSQLND_STATS * _p_s = (MYSQLND_STATS *) (stats); \
       if ((enabler) && _p_s) { \
		uint64_t v1 = (uint64_t) (value1); \
		uint64_t v2 = (uint64_t) (value2); \
		uint64_t v3 = (uint64_t) (value3); \
		enum_mysqlnd_collected_stats _s1 = (statistic1);\
		enum_mysqlnd_collected_stats _s2 = (statistic2);\
		enum_mysqlnd_collected_stats _s3 = (statistic3);\
              if (_s1 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s1, v1); \
              if (_s2 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s2, v2); \
              if (_s3 != _p_s->count) MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER(_p_s, _s3, v3); \
       }\
 }

Definition at line 109 of file mysqlnd_statistics.h.

#define MYSQLND_STAT_CALL_TRIGGER (   s_array,
  statistic,
  val 
)
Value:
if ((s_array)->triggers[(statistic)] && (s_array)->in_trigger == FALSE) { \
                            (s_array)->in_trigger = TRUE; \
                            MYSQLND_STATS_UNLOCK((s_array)); \
                                                                                                                                                          \
                            (s_array)->triggers[(statistic)]((s_array), (statistic), (val) TSRMLS_CC); \
																						\
				MYSQLND_STATS_LOCK((s_array)); \
                            (s_array)->in_trigger = FALSE; \
                     }

Definition at line 46 of file mysqlnd_statistics.h.

#define MYSQLND_STATS_LOCK (   stats)

Definition at line 41 of file mysqlnd_statistics.h.

#define MYSQLND_STATS_UNLOCK (   stats)

Definition at line 42 of file mysqlnd_statistics.h.

#define MYSQLND_UPDATE_VALUE_AND_CALL_TRIGGER (   stats,
  statistic,
  value 
)
Value:
{ \
                     MYSQLND_STATS_LOCK(stats); \
                     (stats)->values[(statistic)] += (value); \
                     MYSQLND_STAT_CALL_TRIGGER((stats), (statistic), (value)); \
                     MYSQLND_STATS_UNLOCK(_p_s); \
       }

Definition at line 60 of file mysqlnd_statistics.h.


Typedef Documentation


Function Documentation

PHPAPI void mysqlnd_fill_stats_hash ( const MYSQLND_STATS *const  stats,
const MYSQLND_STRING names,
zval *return_value TSRMLS_DC  ZEND_FILE_LINE_DC 
)

Definition at line 202 of file mysqlnd_statistics.c.

{
       unsigned int i;

       mysqlnd_array_init(return_value, stats->count);
       for (i = 0; i < stats->count; i++) {
#if MYSQLND_UNICODE
              UChar *ustr, *tstr;
              int ulen, tlen;
#endif
              char tmp[25];

              sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
#if MYSQLND_UNICODE
              zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen, names[i].s, names[i].l + 1 TSRMLS_CC);
              zend_string_to_unicode(UG(utf8_conv), &tstr, &tlen, tmp, strlen(tmp) + 1 TSRMLS_CC);
              add_u_assoc_unicode_ex(return_value, IS_UNICODE, ZSTR(ustr), ulen, tstr, 1);
              efree(ustr);
              efree(tstr);
#else
              add_assoc_string_ex(return_value, names[i].s, names[i].l + 1, tmp, 1);
#endif
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI void mysqlnd_stats_end ( MYSQLND_STATS *  stats)

Definition at line 267 of file mysqlnd_statistics.c.

{
#ifdef ZTS
       tsrm_mutex_free(stats->LOCK_access);
#endif
       free(stats->triggers);
       free(stats->values);
       /* mnd_free will reference LOCK_access and crash...*/
       free(stats);
}

Here is the caller graph for this function:

PHPAPI void mysqlnd_stats_init ( MYSQLND_STATS **  stats,
size_t  statistic_count 
)

Definition at line 247 of file mysqlnd_statistics.c.

{
       *stats = calloc(1, sizeof(MYSQLND_STATS));
       if (*stats == NULL) {
              return;
       }
       (*stats)->values = calloc(statistic_count, sizeof(uint64_t));
       (*stats)->triggers = calloc(statistic_count, sizeof(mysqlnd_stat_trigger));
       (*stats)->in_trigger = FALSE;
       (*stats)->count = statistic_count;
#ifdef ZTS
       (*stats)->LOCK_access = tsrm_mutex_alloc();
#endif

}

Here is the caller graph for this function:

PHPAPI mysqlnd_stat_trigger mysqlnd_stats_reset_triggers ( MYSQLND_STATS *const stats  TSRMLS_DC)

Definition at line 299 of file mysqlnd_statistics.c.

{
       mysqlnd_stat_trigger ret = NULL;
       DBG_ENTER("mysqlnd_stats_reset_trigger");
       if (stats) {
              MYSQLND_STATS_LOCK(stats);
              memset(stats->triggers, 0, stats->count * sizeof(mysqlnd_stat_trigger));
              MYSQLND_STATS_UNLOCK(stats);
       }
       DBG_RETURN(ret);
}

Here is the call graph for this function:

PHPAPI mysqlnd_stat_trigger mysqlnd_stats_set_trigger ( MYSQLND_STATS *const  stats,
enum_mysqlnd_collected_stats  stat,
mysqlnd_stat_trigger trigger  TSRMLS_DC 
)

Definition at line 282 of file mysqlnd_statistics.c.

{
       mysqlnd_stat_trigger ret = NULL;
       DBG_ENTER("mysqlnd_stats_set_trigger");
       if (stats) {
              MYSQLND_STATS_LOCK(stats);
              ret = stats->triggers[statistic];
              stats->triggers[statistic] = trigger;
              MYSQLND_STATS_UNLOCK(stats);
       }
       DBG_RETURN(ret);
}

Here is the call graph for this function:


Variable Documentation

PHPAPI MYSQLND_STATS* mysqlnd_global_stats

Definition at line 66 of file mysqlnd.c.

Definition at line 34 of file mysqlnd_statistics.c.