summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2009-06-12 13:24:57 +0000
committerAndrey Hristov <andrey@php.net>2009-06-12 13:24:57 +0000
commit22c87864934257e8212d7ec4f39378017c8102f9 (patch)
treeb320684def86fdede80891fd8d07e38658c060da
parent5f8ca6da9515db5c23a1f0b44a0993b345743dd9 (diff)
downloadphp-git-22c87864934257e8212d7ec4f39378017c8102f9.tar.gz
MFH:
Fix crash when tracing is enabled. Position after buffer was used also direct usage of MYSQLND_STRING pointer instead of the "s" property of the structure.
-rw-r--r--ext/mysqlnd/mysqlnd_enum_n_def.h9
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.c2
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.h103
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c1
4 files changed, 70 insertions, 45 deletions
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index a1a1ae0eba..8b7c416262 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -142,7 +142,6 @@ typedef enum mysqlnd_option
MYSQLND_OPT_NET_READ_BUFFER_SIZE = 203,
} enum_mysqlnd_option;
-
typedef enum mysqlnd_field_types
{
MYSQL_TYPE_DECIMAL,
@@ -177,7 +176,6 @@ typedef enum mysqlnd_field_types
/* Please update this if there is a new type after MYSQL_TYPE_GEOMETRY */
#define MYSQL_TYPE_LAST MYSQL_TYPE_GEOMETRY
-
typedef enum mysqlnd_server_option
{
MYSQL_OPTION_MULTI_STATEMENTS_ON,
@@ -241,7 +239,6 @@ typedef enum mysqlnd_server_option
/* see mysqlnd_charset.c for more information */
#define MYSQLND_BINARY_CHARSET_NR 63
-
/*
/-----> CONN_CLOSE <---------------\
| ^ \
@@ -261,7 +258,6 @@ typedef enum mysqlnd_connection_state
CONN_QUIT_SENT, /* object is "destroyed" at this stage */
} enum_mysqlnd_connection_state;
-
typedef enum mysqlnd_stmt_state
{
MYSQLND_STMT_INITTED = 0,
@@ -272,13 +268,11 @@ typedef enum mysqlnd_stmt_state
MYSQLND_STMT_USER_FETCHING, /* fetch_row_buff or fetch_row_unbuf */
} enum_mysqlnd_stmt_state;
-
typedef enum param_bind_flags
{
MYSQLND_PARAM_BIND_BLOB_USED = 1
} enum_param_bind_flags;
-
/* PS */
enum mysqlnd_stmt_attr
{
@@ -286,7 +280,6 @@ enum mysqlnd_stmt_attr
STMT_ATTR_CURSOR_TYPE,
STMT_ATTR_PREFETCH_ROWS
};
-
enum myslqnd_cursor_type
{
CURSOR_TYPE_NO_CURSOR= 0,
@@ -294,7 +287,6 @@ enum myslqnd_cursor_type
CURSOR_TYPE_FOR_UPDATE= 2,
CURSOR_TYPE_SCROLLABLE= 4
};
-
typedef enum mysqlnd_connection_close_type
{
MYSQLND_CLOSE_EXPLICIT = 0,
@@ -303,7 +295,6 @@ typedef enum mysqlnd_connection_close_type
MYSQLND_CLOSE_LAST /* for checking, should always be last */
} enum_connection_close_type;
-
typedef enum mysqlnd_collected_stats
{
STAT_BYTES_SENT,
diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c
index 4e6089b915..7e6ea55060 100644
--- a/ext/mysqlnd/mysqlnd_statistics.c
+++ b/ext/mysqlnd/mysqlnd_statistics.c
@@ -168,7 +168,7 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, zval *return_value TS
UChar *ustr, *tstr;
int ulen, tlen;
#endif
- char tmp[22];
+ char tmp[25];
sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
#if PHP_MAJOR_VERSION >= 6
diff --git a/ext/mysqlnd/mysqlnd_statistics.h b/ext/mysqlnd/mysqlnd_statistics.h
index dc36aa777c..eb9bdb3190 100644
--- a/ext/mysqlnd/mysqlnd_statistics.h
+++ b/ext/mysqlnd/mysqlnd_statistics.h
@@ -39,7 +39,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
+ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
mysqlnd_global_stats->values[(statistic)]++; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
@@ -49,7 +50,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global&conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)].s); \
+ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
mysqlnd_global_stats->values[(statistic)]--; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
@@ -64,11 +66,15 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
if (MYSQLND_G(collect_statistics)) { \
uint64_t v1 = (uint64_t) (value1); \
uint64_t v2 = (uint64_t) (value2); \
- DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[(statistic1)], mysqlnd_stats_values_names[(statistic2)]); \
+ enum_mysqlnd_collected_stats _s1 = (statistic1);\
+ enum_mysqlnd_collected_stats _s2 = (statistic2);\
+ \
+ if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
\
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
}\
}
@@ -76,7 +82,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
+ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
mysqlnd_global_stats->values[(statistic)]++; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
@@ -90,7 +97,8 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
uint64_t v = (uint64_t) (value); \
- DBG_INF_FMT("Global&Conn stat increase w value [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&Conn stat increase w value [%s]", mysqlnd_stats_values_names[(statistic)].s); \
+ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
mysqlnd_global_stats->values[(statistic)] += v; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
@@ -105,14 +113,19 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
if (MYSQLND_G(collect_statistics)) { \
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 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
+ \
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
if ((conn_stats)) { \
- if (statistic1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
} \
} \
}
@@ -124,16 +137,23 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
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 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
+ if (_s3 != STAT_LAST) DBG_INF_FMT("Global stat increase3 [%s]", mysqlnd_stats_values_names[_s3].s); \
\
tsrm_mutex_lock(mysqlnd_global_stats->LOCK_access); \
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
- if (statistic3 != STAT_LAST) mysqlnd_global_stats->values[(statistic3)]+= v3; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
+ if (_s3 != STAT_LAST) mysqlnd_global_stats->values[_s3]+= v3; \
tsrm_mutex_unlock(mysqlnd_global_stats->LOCK_access); \
if ((conn_stats)) { \
- if (statistic1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+= v2; \
- if (statistic3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic3)]+= v3; \
+ if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
+ if (_s3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s3]+= v3; \
} \
} \
}
@@ -144,7 +164,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_INC_GLOBAL_STATISTIC(statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
mysqlnd_global_stats->values[(statistic)]++; \
} \
}
@@ -153,7 +173,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
#define MYSQLND_DEC_CONN_STATISTIC(conn_stats, statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global&Conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&Conn stat decrease [%s]", mysqlnd_stats_values_names[(statistic)].s); \
mysqlnd_global_stats->values[(statistic)]--; \
if ((conn_stats)) { \
((MYSQLND_STATS *) conn_stats)->values[(statistic)]--; \
@@ -166,17 +186,21 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
if (MYSQLND_G(collect_statistics)) { \
uint64_t v1 = (uint64_t) (value1); \
uint64_t v2 = (uint64_t) (value2); \
- DBG_INF_FMT("Global stat increase [%s] [%s]", mysqlnd_stats_values_names[(statistic1)], mysqlnd_stats_values_names[(statistic2)]); \
+ enum_mysqlnd_collected_stats _s1 = (statistic1);\
+ enum_mysqlnd_collected_stats _s2 = (statistic2);\
+ \
+ if (_s1 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
\
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
}\
}
#define MYSQLND_INC_CONN_STATISTIC(conn_stats, statistic) \
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
- DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&Conn stat increase [%s]", mysqlnd_stats_values_names[(statistic)].s); \
mysqlnd_global_stats->values[(statistic)]++; \
if ((conn_stats)) { \
((MYSQLND_STATS *) conn_stats)->values[(statistic)]++; \
@@ -188,7 +212,7 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
{ \
if (MYSQLND_G(collect_statistics) && (statistic) != STAT_LAST) { \
uint64_t v = (uint64_t) (value); \
- DBG_INF_FMT("Global&Conn stats increase w value [%s]", mysqlnd_stats_values_names[(statistic)]); \
+ DBG_INF_FMT("Global&Conn stats increase w value [%s]", mysqlnd_stats_values_names[(statistic)].s); \
mysqlnd_global_stats->values[(statistic)] += v; \
if ((conn_stats)) { \
((MYSQLND_STATS *) conn_stats)->values[(statistic)] += v; \
@@ -201,12 +225,16 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
if (MYSQLND_G(collect_statistics)) { \
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 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
\
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
if ((conn_stats)) { \
- if (statistic1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+= v2; \
+ if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
} \
} \
}
@@ -217,14 +245,21 @@ extern const MYSQLND_STRING mysqlnd_stats_values_names[];
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 != STAT_LAST) DBG_INF_FMT("Global stat increase1 [%s]", mysqlnd_stats_values_names[_s1].s); \
+ if (_s2 != STAT_LAST) DBG_INF_FMT("Global stat increase2 [%s]", mysqlnd_stats_values_names[_s2].s); \
+ if (_s3 != STAT_LAST) DBG_INF_FMT("Global stat increase3 [%s]", mysqlnd_stats_values_names[_s3].s); \
\
- if (statistic1 != STAT_LAST) mysqlnd_global_stats->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) mysqlnd_global_stats->values[(statistic2)]+= v2; \
- if (statistic3 != STAT_LAST) mysqlnd_global_stats->values[(statistic3)]+= v3; \
+ if (_s1 != STAT_LAST) mysqlnd_global_stats->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) mysqlnd_global_stats->values[_s2]+= v2; \
+ if (_s3 != STAT_LAST) mysqlnd_global_stats->values[_s3]+= v3; \
if ((conn_stats)) { \
- if (statistic1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic1)]+= v1; \
- if (statistic2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic2)]+= v2; \
- if (statistic3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[(statistic3)]+= v3; \
+ if (_s1 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s1]+= v1; \
+ if (_s2 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s2]+= v2; \
+ if (_s3 != STAT_LAST) ((MYSQLND_STATS *) conn_stats)->values[_s3]+= v3; \
} \
} \
}
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index 8619eae2e7..9ff74f078c 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -69,7 +69,6 @@
1); \
}
-
extern mysqlnd_packet_methods packet_methods[];
static const char *unknown_sqlstate= "HY000";