andrey Thu, 12 Aug 2010 12:02:02 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=302142
Log:
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.
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
U php/php-src/branches/PHP_5_3/ext/mysqlnd/php_mysqlnd.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h
U php/php-src/trunk/ext/mysqlnd/mysqlnd_priv.h
U php/php-src/trunk/ext/mysqlnd/mysqlnd_ps.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_statistics.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h
U php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
U php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -481,7 +481,7 @@
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_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 @@
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;
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_debug.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -1249,7 +1249,7 @@
/* 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); \
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -152,7 +152,7 @@
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
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_priv.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -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
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -869,7 +869,7 @@
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 @@
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
)
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -117,7 +117,7 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
break;
case MYSQL_TYPE_VAR_STRING:
data_size += 8; /* max 8 bytes for size */
-#if 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)
-#elif PHP_MAJOR_VERSION >= 6
- if (Z_TYPE_P(the_var) != IS_STRING || Z_TYPE_P(the_var) == IS_UNICODE)
#endif
{
if (!copies || !copies[i]) {
@@ -717,7 +717,7 @@
}
}
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);
}
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -814,7 +814,7 @@
*/
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 @@
*/
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,
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_result_meta.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -92,7 +92,7 @@
/* }}} */
-#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 @@
{
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 @@
}
-#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 @@
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 @@
/* 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);
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_statistics.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -203,14 +203,14 @@
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);
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_structs.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -788,7 +788,7 @@
{
zend_bool is_numeric;
unsigned long key;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zstr ustr;
unsigned int ulen;
#endif
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -1332,7 +1332,7 @@
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 @@
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 @@
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 @@
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);
}
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/php_mysqlnd.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/php_mysqlnd.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/php_mysqlnd.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -37,7 +37,7 @@
/* {{{ mysqlnd_minfo_print_hash */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
PHPAPI void mysqlnd_minfo_print_hash(zval *values)
{
zval **values_entry;
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -481,7 +481,7 @@
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_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 @@
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;
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_debug.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -1249,7 +1249,7 @@
/* 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); \
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_enum_n_def.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -152,7 +152,7 @@
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
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_priv.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_priv.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_priv.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -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
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_ps.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_ps.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_ps.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -869,7 +869,7 @@
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 @@
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
)
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -117,7 +117,7 @@
}
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
break;
case MYSQL_TYPE_VAR_STRING:
data_size += 8; /* max 8 bytes for size */
-#if 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)
-#elif PHP_MAJOR_VERSION >= 6
- if (Z_TYPE_P(the_var) != IS_STRING || Z_TYPE_P(the_var) == IS_UNICODE)
#endif
{
if (!copies || !copies[i]) {
@@ -717,7 +717,7 @@
}
}
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);
}
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -814,7 +814,7 @@
*/
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 @@
*/
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,
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_result_meta.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -92,7 +92,7 @@
/* }}} */
-#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 @@
{
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 @@
}
-#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 @@
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 @@
/* 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);
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_statistics.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_statistics.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_statistics.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -203,14 +203,14 @@
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);
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_structs.h 2010-08-12 12:02:02 UTC (rev 302142)
@@ -788,7 +788,7 @@
{
zend_bool is_numeric;
unsigned long key;
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
zstr ustr;
unsigned int ulen;
#endif
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -1332,7 +1332,7 @@
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 @@
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 @@
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 @@
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);
}
Modified: php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c 2010-08-12 11:38:08 UTC (rev 302141)
+++ php/php-src/trunk/ext/mysqlnd/php_mysqlnd.c 2010-08-12 12:02:02 UTC (rev 302142)
@@ -37,7 +37,7 @@
/* {{{ mysqlnd_minfo_print_hash */
-#if PHP_MAJOR_VERSION >= 6
+#if MYSQLND_UNICODE
PHPAPI void mysqlnd_minfo_print_hash(zval *values)
{
zval **values_entry;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php