summaryrefslogtreecommitdiff
path: root/ext/mysqlnd
diff options
context:
space:
mode:
authorAndrey Hristov <andrey@php.net>2010-08-12 12:02:02 +0000
committerAndrey Hristov <andrey@php.net>2010-08-12 12:02:02 +0000
commit92ef63a07b04bb85d6587b2905d068ce8a781061 (patch)
tree4ce90d8821ccc1673b4d42539285049f93c46bc3 /ext/mysqlnd
parent8bf7114691540f29e6a07a34231fdf536652c1b8 (diff)
downloadphp-git-92ef63a07b04bb85d6587b2905d068ce8a781061.tar.gz
Switch from using PHP_MAJOR_VERSION to separate define for
unicode. Unicode is no more, but these are "bookmarks" where to change mysqlnd, if Unicode becomes trendy again.
Diffstat (limited to 'ext/mysqlnd')
-rw-r--r--ext/mysqlnd/mysqlnd.c6
-rw-r--r--ext/mysqlnd/mysqlnd_debug.c2
-rw-r--r--ext/mysqlnd/mysqlnd_enum_n_def.h2
-rw-r--r--ext/mysqlnd/mysqlnd_priv.h12
-rw-r--r--ext/mysqlnd/mysqlnd_ps.c4
-rw-r--r--ext/mysqlnd/mysqlnd_ps_codec.c30
-rw-r--r--ext/mysqlnd/mysqlnd_result.c4
-rw-r--r--ext/mysqlnd/mysqlnd_result_meta.c10
-rw-r--r--ext/mysqlnd/mysqlnd_statistics.c4
-rw-r--r--ext/mysqlnd/mysqlnd_structs.h2
-rw-r--r--ext/mysqlnd/mysqlnd_wireprotocol.c8
-rw-r--r--ext/mysqlnd/php_mysqlnd.c2
12 files changed, 46 insertions, 40 deletions
diff --git a/ext/mysqlnd/mysqlnd.c b/ext/mysqlnd/mysqlnd.c
index a84b485910..faac95ea86 100644
--- a/ext/mysqlnd/mysqlnd.c
+++ b/ext/mysqlnd/mysqlnd.c
@@ -481,7 +481,7 @@ mysqlnd_connect_run_authentication(
if (options->charset_name && (charset = mysqlnd_find_charset_name(options->charset_name))) {
auth_packet->charset_no = charset->nr;
} else {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
auth_packet->charset_no = 200;/* utf8 - swedish collation, check mysqlnd_charset.c */
#else
auth_packet->charset_no = greet_packet->charset_no;
@@ -799,7 +799,7 @@ MYSQLND_METHOD(mysqlnd_conn, connect)(MYSQLND * conn,
mysqlnd_local_infile_default(conn);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
{
unsigned int as_unicode = 1;
conn->m->set_client_option(conn, MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE, (char *)&as_unicode TSRMLS_CC);
@@ -2052,7 +2052,7 @@ MYSQLND_METHOD(mysqlnd_conn, set_client_option)(MYSQLND * const conn,
case MYSQLND_OPT_NET_READ_BUFFER_SIZE:
ret = conn->net->m.set_client_option(conn->net, option, value TSRMLS_CC);
break;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
case MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE:
conn->options.numeric_and_datetime_as_unicode = *(unsigned int*) value;
break;
diff --git a/ext/mysqlnd/mysqlnd_debug.c b/ext/mysqlnd/mysqlnd_debug.c
index 5022e03edc..587ff14e2c 100644
--- a/ext/mysqlnd/mysqlnd_debug.c
+++ b/ext/mysqlnd/mysqlnd_debug.c
@@ -1249,7 +1249,7 @@ PHPAPI struct st_mysqlnd_allocator_methods mysqlnd_allocator =
/* Follows code borrowed from zend_builtin_functions.c because the functions there are static */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
/* {{{ gettraceasstring() macros */
#define TRACE_APPEND_CHR(chr) \
*str = (char*)erealloc(*str, *len + 1 + 1); \
diff --git a/ext/mysqlnd/mysqlnd_enum_n_def.h b/ext/mysqlnd/mysqlnd_enum_n_def.h
index c3a094ca2a..5c6a6f25f3 100644
--- a/ext/mysqlnd/mysqlnd_enum_n_def.h
+++ b/ext/mysqlnd/mysqlnd_enum_n_def.h
@@ -152,7 +152,7 @@ typedef enum mysqlnd_option
MYSQL_REPORT_DATA_TRUNCATION,
MYSQL_OPT_RECONNECT,
MYSQL_OPT_SSL_VERIFY_SERVER_CERT,
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
MYSQLND_OPT_NUMERIC_AND_DATETIME_AS_UNICODE = 200,
#endif
#ifdef MYSQLND_STRING_TO_INT_CONVERSION
diff --git a/ext/mysqlnd/mysqlnd_priv.h b/ext/mysqlnd/mysqlnd_priv.h
index 3f0bc7fed3..2f91d0732a 100644
--- a/ext/mysqlnd/mysqlnd_priv.h
+++ b/ext/mysqlnd/mysqlnd_priv.h
@@ -33,6 +33,12 @@
#define Z_DELREF_PP(ppz) Z_DELREF_P(*(ppz))
#endif
+#if PHP_MAJOR_VERSION >= 6
+#define MYSQLND_UNICODE 1
+#else
+#define MYSQLND_UNICODE 0
+#endif
+
#ifdef ZTS
#include "TSRM.h"
#endif
@@ -45,18 +51,18 @@
#define MYSQLND_CLASS_METHODS_START(class) struct st_##class##_methods MYSQLND_CLASS_METHOD_TABLE_NAME(class) = {
#define MYSQLND_CLASS_METHODS_END }
-#if PHP_MAJOR_VERSION < 6
+#if MYSQLND_UNICODE
#define mysqlnd_array_init(arg, field_count) \
{ \
ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
- zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
+ zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
Z_TYPE_P(arg) = IS_ARRAY;\
}
#else
#define mysqlnd_array_init(arg, field_count) \
{ \
ALLOC_HASHTABLE_REL(Z_ARRVAL_P(arg));\
- zend_u_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0, 0);\
+ zend_hash_init(Z_ARRVAL_P(arg), (field_count), NULL, ZVAL_PTR_DTOR, 0); \
Z_TYPE_P(arg) = IS_ARRAY;\
}
#endif
diff --git a/ext/mysqlnd/mysqlnd_ps.c b/ext/mysqlnd/mysqlnd_ps.c
index a6f2b33c7a..bf42e2a67d 100644
--- a/ext/mysqlnd/mysqlnd_ps.c
+++ b/ext/mysqlnd/mysqlnd_ps.c
@@ -869,7 +869,7 @@ mysqlnd_stmt_fetch_row_unbuffered(MYSQLND_RES *result, void *param, unsigned int
if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data)) ) {
if (
(Z_TYPE_P(data) == IS_STRING
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
|| Z_TYPE_P(data) == IS_UNICODE
#endif
)
@@ -1059,7 +1059,7 @@ mysqlnd_fetch_stmt_row_cursor(MYSQLND_RES *result, void *param, unsigned int fla
Z_TYPE_P(data), Z_REFCOUNT_P(stmt->result_bind[i].zv));
if (IS_NULL != (Z_TYPE_P(stmt->result_bind[i].zv) = Z_TYPE_P(data))) {
if ((Z_TYPE_P(data) == IS_STRING
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
|| Z_TYPE_P(data) == IS_UNICODE
#endif
)
diff --git a/ext/mysqlnd/mysqlnd_ps_codec.c b/ext/mysqlnd/mysqlnd_ps_codec.c
index 673cfacb5a..a0e6c0050e 100644
--- a/ext/mysqlnd/mysqlnd_ps_codec.c
+++ b/ext/mysqlnd/mysqlnd_ps_codec.c
@@ -117,7 +117,7 @@ void ps_fetch_from_1_to_8_bytes(zval *zv, const MYSQLND_FIELD * const field,
}
if (tmp_len) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (as_unicode) {
DBG_INF("stringify");
ZVAL_UTF8_STRINGL(zv, tmp, tmp_len, ZSTR_DUPLICATE);
@@ -265,12 +265,12 @@ void ps_fetch_time(zval *zv, const MYSQLND_FIELD * const field,
length = spprintf(&to, 0, "%s%02u:%02u:%02u", (t.neg ? "-" : ""), t.hour, t.minute, t.second);
DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (!as_unicode) {
#endif
ZVAL_STRINGL(zv, to, length, 1);
efree(to); /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
} else {
ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
}
@@ -316,12 +316,12 @@ void ps_fetch_date(zval *zv, const MYSQLND_FIELD * const field,
length = spprintf(&to, 0, "%04u-%02u-%02u", t.year, t.month, t.day);
DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (!as_unicode) {
#endif
ZVAL_STRINGL(zv, to, length, 1);
efree(to); /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
} else {
ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
}
@@ -375,12 +375,12 @@ void ps_fetch_datetime(zval *zv, const MYSQLND_FIELD * const field,
t.year, t.month, t.day, t.hour, t.minute, t.second);
DBG_INF_FMT("%s", to);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (!as_unicode) {
#endif
ZVAL_STRINGL(zv, to, length, 1);
efree(to); /* allocated by spprintf */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
} else {
ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_AUTOFREE);
}
@@ -403,10 +403,7 @@ void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field,
unsigned long length = php_mysqlnd_net_field_length(row);
DBG_ENTER("ps_fetch_string");
DBG_INF_FMT("len = %lu", length);
-#if PHP_MAJOR_VERSION < 6
- DBG_INF("copying from the row buffer");
- ZVAL_STRINGL(zv, (char *)*row, length, 1);
-#else
+#if MYSQLND_UNICODE
if (field->charsetnr == MYSQLND_BINARY_CHARSET_NR) {
DBG_INF("Binary charset");
ZVAL_STRINGL(zv, (char *)*row, length, 1);
@@ -414,6 +411,9 @@ void ps_fetch_string(zval *zv, const MYSQLND_FIELD * const field,
DBG_INF_FMT("copying from the row buffer");
ZVAL_UTF8_STRINGL(zv, (char*)*row, length, ZSTR_DUPLICATE);
}
+#else
+ DBG_INF("copying from the row buffer");
+ ZVAL_STRINGL(zv, (char *)*row, length, 1);
#endif
(*row) += length;
@@ -704,10 +704,10 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
break;
case MYSQL_TYPE_VAR_STRING:
data_size += 8; /* max 8 bytes for size */
-#if PHP_MAJOR_VERSION < 6
- if (Z_TYPE_P(the_var) != IS_STRING)
-#elif PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (Z_TYPE_P(the_var) != IS_STRING || Z_TYPE_P(the_var) == IS_UNICODE)
+#else
+ if (Z_TYPE_P(the_var) != IS_STRING)
#endif
{
if (!copies || !copies[i]) {
@@ -717,7 +717,7 @@ mysqlnd_stmt_execute_store_params(MYSQLND_STMT * s, zend_uchar **buf, zend_uchar
}
}
the_var = copies[i];
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (Z_TYPE_P(the_var) == IS_UNICODE) {
zval_unicode_to_string_ex(the_var, UG(utf8_conv) TSRMLS_CC);
}
diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index a160d93a03..4d4fbd296a 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -814,7 +814,7 @@ mysqlnd_fetch_row_unbuffered(MYSQLND_RES * result, void *param, unsigned int fla
*/
Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
zend_hash_key->ustr,
zend_hash_key->ulen + 1,
@@ -1069,7 +1069,7 @@ mysqlnd_fetch_row_buffered(MYSQLND_RES * result, void *param, unsigned int flags
*/
Z_ADDREF_P(data);
if (zend_hash_key->is_numeric == FALSE) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zend_u_hash_quick_update(Z_ARRVAL_P(row), IS_UNICODE,
zend_hash_key->ustr,
zend_hash_key->ulen + 1,
diff --git a/ext/mysqlnd/mysqlnd_result_meta.c b/ext/mysqlnd/mysqlnd_result_meta.c
index 73c0d9c7fd..8828c0bba6 100644
--- a/ext/mysqlnd/mysqlnd_result_meta.c
+++ b/ext/mysqlnd/mysqlnd_result_meta.c
@@ -92,7 +92,7 @@ mysqlnd_is_key_numeric(char *key, size_t length, long *idx)
/* }}} */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
/* {{{ mysqlnd_unicode_is_key_numeric */
static zend_bool
mysqlnd_unicode_is_key_numeric(UChar *key, size_t length, long *idx)
@@ -142,7 +142,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
{
unsigned int i = 0;
MYSQLND_PACKET_RES_FIELD * field_packet;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
UChar *ustr;
int ulen;
#endif
@@ -227,7 +227,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, read_metadata)(MYSQLND_RES_METADATA * const met
}
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zend_string_to_unicode(UG(utf8_conv), &ustr, &ulen,
meta->fields[i].name,
meta->fields[i].name_length TSRMLS_CC);
@@ -284,7 +284,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, free)(MYSQLND_RES_METADATA * meta TSRMLS_DC)
if (meta->zend_hash_keys) {
DBG_INF("Freeing zend_hash_keys");
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (UG(unicode)) {
for (i = 0; i < meta->field_count; i++) {
if (meta->zend_hash_keys[i].ustr.v) {
@@ -380,7 +380,7 @@ MYSQLND_METHOD(mysqlnd_res_meta, clone_metadata)(const MYSQLND_RES_METADATA * co
/* copy the trailing \0 too */
memcpy(new_fields[i].def, orig_fields[i].def, orig_fields[i].def_length + 1);
}
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (new_meta->zend_hash_keys[i].ustr.u) {
new_meta->zend_hash_keys[i].ustr.u =
eustrndup(new_meta->zend_hash_keys[i].ustr.u, new_meta->zend_hash_keys[i].ulen);
diff --git a/ext/mysqlnd/mysqlnd_statistics.c b/ext/mysqlnd/mysqlnd_statistics.c
index 98d05aa01d..f0c82cc19d 100644
--- a/ext/mysqlnd/mysqlnd_statistics.c
+++ b/ext/mysqlnd/mysqlnd_statistics.c
@@ -203,14 +203,14 @@ mysqlnd_fill_stats_hash(const MYSQLND_STATS * const stats, const MYSQLND_STRING
mysqlnd_array_init(return_value, stats->count);
for (i = 0; i < stats->count; i++) {
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
UChar *ustr, *tstr;
int ulen, tlen;
#endif
char tmp[25];
sprintf((char *)&tmp, MYSQLND_LLU_SPEC, stats->values[i]);
-#if PHP_MAJOR_VERSION >= 6
+#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);
diff --git a/ext/mysqlnd/mysqlnd_structs.h b/ext/mysqlnd/mysqlnd_structs.h
index 4c3ffdb892..426a2067ed 100644
--- a/ext/mysqlnd/mysqlnd_structs.h
+++ b/ext/mysqlnd/mysqlnd_structs.h
@@ -788,7 +788,7 @@ struct mysqlnd_field_hash_key
{
zend_bool is_numeric;
unsigned long key;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zstr ustr;
unsigned int ulen;
#endif
diff --git a/ext/mysqlnd/mysqlnd_wireprotocol.c b/ext/mysqlnd/mysqlnd_wireprotocol.c
index ba31984d80..eb2ce4b459 100644
--- a/ext/mysqlnd/mysqlnd_wireprotocol.c
+++ b/ext/mysqlnd/mysqlnd_wireprotocol.c
@@ -1332,7 +1332,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
ZVAL_NULL(*current_field);
last_field_was_string = FALSE;
} else {
-#if PHP_MAJOR_VERSION >= 6 || defined(MYSQLND_STRING_TO_INT_CONVERSION)
+#if MYSQLND_UNICODE || defined(MYSQLND_STRING_TO_INT_CONVERSION)
struct st_mysqlnd_perm_bind perm_bind =
mysqlnd_ps_fetch_functions[fields_metadata[i].type];
#endif
@@ -1437,7 +1437,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
p -= len;
if (Z_TYPE_PP(current_field) == IS_LONG) {
bit_area += 1 + sprintf((char *)start, "%ld", Z_LVAL_PP(current_field));
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (as_unicode) {
ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
} else
@@ -1450,7 +1450,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
bit_area += Z_STRLEN_PP(current_field);
*bit_area++ = '\0';
zval_dtor(*current_field);
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
if (as_unicode) {
ZVAL_UTF8_STRINGL(*current_field, start, bit_area - start - 1, 0);
} else
@@ -1464,7 +1464,7 @@ php_mysqlnd_rowp_read_text_protocol(MYSQLND_MEMORY_POOL_CHUNK * row_buffer, zval
the buffers are not referenced - everything is copied.
*/
} else
-#if PHP_MAJOR_VERSION < 6
+#if MYSQLND_UNICODE == 0
{
ZVAL_STRINGL(*current_field, (char *)p, len, 0);
}
diff --git a/ext/mysqlnd/php_mysqlnd.c b/ext/mysqlnd/php_mysqlnd.c
index b16b7fc092..d4618c1394 100644
--- a/ext/mysqlnd/php_mysqlnd.c
+++ b/ext/mysqlnd/php_mysqlnd.c
@@ -37,7 +37,7 @@ static zend_function_entry mysqlnd_functions[] = {
/* {{{ mysqlnd_minfo_print_hash */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
PHPAPI void mysqlnd_minfo_print_hash(zval *values)
{
zval **values_entry;