Author: ahristov
Date: 2007-03-13 11:00:28 +0100 (Tue, 13 Mar 2007)
New Revision: 113
Modified:
trunk/ext/mysqli/mysqlnd/mysqlnd.c
trunk/ext/mysqli/mysqlnd/mysqlnd.h
trunk/ext/mysqli/mysqlnd/mysqlnd_palloc.c
trunk/ext/mysqli/mysqlnd/mysqlnd_priv.h
trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c
trunk/ext/mysqli/mysqlnd/mysqlnd_wireprotocol.c
Log:
Changed the way we compile some stuff for PHP5 and PHP6.
Needed TSRMLS_CC in lot of places and this plagued the diff.
Now mysqlnd should be more or less Unicode ready *finger_cross*, and
still compile with PHP5
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd.c 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd.c 2007-03-13 10:00:28 UTC (rev 113)
@@ -111,7 +111,7 @@
/* {{{ mysqlnd_unbuffered_free_last_data */
-void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result)
+void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC)
{
if (result->last_row_data) {
int i;
@@ -123,7 +123,7 @@
} else {
mysqlnd_palloc_zval_ptr_dtor(&(result->last_row_data[i]),
result->zval_cache, FALSE,
- ©_ctor_called);
+ ©_ctor_called TSRMLS_CC);
if (copy_ctor_called) {
MYSQLND_INC_CONN_STATISTIC(&result->conn->stats,
STAT_COPY_ON_WRITE_PERFORMED);
@@ -148,7 +148,7 @@
/* {{{ mysqlnd_internal_free_result_buffers */
-void mysqlnd_internal_free_result_buffers(MYSQLND_RES *result)
+void mysqlnd_internal_free_result_buffers(MYSQLND_RES *result TSRMLS_DC)
{
int i;
/* The user has used the old API - mysqlnd_fetch_row() */
@@ -158,7 +158,7 @@
}
if (!result->data) {
- mysqlnd_unbuffered_free_last_data(result);
+ mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
} else {
zval **current_row;
zend_uchar *current_buffer;
@@ -176,7 +176,7 @@
zend_bool copy_ctor_called;
/* Free only if we haven't referenced it */
mysqlnd_palloc_zval_ptr_dtor(&(current_row[j]), result->zval_cache,
- FALSE, ©_ctor_called);
+ FALSE, ©_ctor_called TSRMLS_CC);
MYSQLND_INC_CONN_STATISTIC(NULL, copy_ctor_called? STAT_COPY_ON_WRITE_PERFORMED:
STAT_COPY_ON_WRITE_SAVED);
}
@@ -209,12 +209,12 @@
/* {{{ mysqlnd_internal_free_result_contents */
-void mysqlnd_internal_free_result_contents(MYSQLND_RES *result)
+void mysqlnd_internal_free_result_contents(MYSQLND_RES *result TSRMLS_DC)
{
int i;
MYSQLND_FIELD *meta = result->fields;
- result->m.free_result_buffers(result);
+ result->m.free_result_buffers(result TSRMLS_CC);
if (result->row_packet) {
if (result->type == MYSQLND_RES_NORMAL) {
@@ -261,7 +261,7 @@
result->conn = NULL;
}
- mysqlnd_internal_free_result_contents(result);
+ mysqlnd_internal_free_result_contents(result TSRMLS_CC);
efree(result);
}
/* }}} */
@@ -273,7 +273,7 @@
{
mysqlnd_local_infile_default(conn);
if (conn->current_result) {
- mysqlnd_internal_free_result_contents(conn->current_result);
+ mysqlnd_internal_free_result_contents(conn->current_result TSRMLS_CC);
efree(conn->current_result);
conn->current_result = NULL;
}
@@ -835,7 +835,7 @@
return PASS;
error:
- mysqlnd_internal_free_result_contents(result);
+ mysqlnd_internal_free_result_contents(result TSRMLS_CC);
return FAIL;
}
/* }}} */
@@ -960,7 +960,7 @@
/* Check for SERVER_STATUS_MORE_RESULTS if needed */
PACKET_INIT_ALLOCA(fields_eof, PROT_EOF_PACKET);
if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, conn))) {
- mysqlnd_internal_free_result_contents(result);
+ mysqlnd_internal_free_result_contents(result TSRMLS_CC);
efree(result);
if (!stmt) {
conn->current_result = NULL;
@@ -1134,7 +1134,7 @@
mysqlnd_unbuffered_free_last_data() before it. The function returns always true.
*/
if (PASS == (ret = PACKET_READ(row_packet, result->conn)) &&
!row_packet->eof) {
- mysqlnd_unbuffered_free_last_data(result);
+ mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
result->last_row_data = row_packet->fields;
result->last_row_buffer = row_packet->row_buffer;
@@ -1193,7 +1193,7 @@
} else {
result->conn->state = CONN_READY;
}
- mysqlnd_unbuffered_free_last_data(result);
+ mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
*fetched_anything = FALSE;
}
@@ -1400,7 +1400,7 @@
/* libmysql's documentation says it should be so for SELECT statements */
conn->upsert_status.affected_rows = result->row_count;
} else {
- mysqlnd_internal_free_result_contents(result);
+ mysqlnd_internal_free_result_contents(result TSRMLS_CC);
efree(result);
result = NULL;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pretty serious error");
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd.h
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd.h 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd.h 2007-03-13 10:00:28 UTC (rev 113)
@@ -564,7 +564,7 @@
MYSQLND_ROW (*fetch_row_old_way)(MYSQLND_RES * result TSRMLS_DC ZEND_FILE_LINE_DC);
unsigned long * (*fetch_lengths)(MYSQLND_RES * const result);
- void (*free_result_buffers)(MYSQLND_RES * result); /* private */
+ void (*free_result_buffers)(MYSQLND_RES * result TSRMLS_DC); /* private */
enum_func_status (*free_result)(MYSQLND_RES * result, zend_bool implicit TSRMLS_DC);
};
@@ -988,7 +988,7 @@
/* There two should not be used from outside */
void * mysqlnd_palloc_get_zval(MYSQLND_ZVAL_PCACHE * const cache, zend_bool
*allocated);
void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_ZVAL_PCACHE * const cache,
zend_bool ps,
- zend_bool *copy_ctor_called);
+ zend_bool *copy_ctor_called TSRMLS_DC);
#endif /* MYSQLND_H */
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_palloc.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_palloc.c 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_palloc.c 2007-03-13 10:00:28 UTC (rev 113)
@@ -270,7 +270,7 @@
/* {{{ mysqlnd_palloc_zval_ptr_dtor */
void mysqlnd_palloc_zval_ptr_dtor(zval **zv, MYSQLND_ZVAL_PCACHE * const cache, zend_bool
ps,
- zend_bool *copy_ctor_called)
+ zend_bool *copy_ctor_called TSRMLS_DC)
{
#ifndef MYSQLND_SILENT
php_printf("[mysqlnd_palloc_zval_ptr_dtor %p] *zv=%p ps=%d refc=%d\n", cache, *zv, ps,
ZVAL_REFCOUNT(*zv));
@@ -294,8 +294,12 @@
I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set
to check if we need to call copy_ctor().
*/
-#if !defined(WE_USE_UNICODE)
+#if PHP_MAJOR_VERSION < 6
zval_copy_ctor(*zv);
+#else
+ if (!UG(unicode)) {
+ zval_copy_ctor(*zv);
+ }
#endif
*copy_ctor_called = TRUE;
} else {
@@ -327,8 +331,12 @@
I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set
to check if we need to call copy_ctor().
*/
-#if !defined(WE_USE_UNICODE)
+#if PHP_MAJOR_VERSION < 6
zval_copy_ctor(*zv);
+#else
+ if (!UG(unicode)) {
+ zval_copy_ctor(*zv);
+ }
#endif
((mysqlnd_zval *)*zv)->ze_alloced = TRUE;
*copy_ctor_called = TRUE;
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_priv.h
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_priv.h 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_priv.h 2007-03-13 10:00:28 UTC (rev 113)
@@ -27,16 +27,24 @@
#include "TSRM.h"
#endif
+#if PHP_MAJOR_VERSION < 6
#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); \
+ 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);\
Z_TYPE_P(arg) = IS_ARRAY;\
}
+#endif
-
#define SERVER_STATUS_IN_TRANS 1 /* Transaction has started */
#define SERVER_STATUS_AUTOCOMMIT 2 /* Server in auto_commit mode */
#define SERVER_MORE_RESULTS_EXISTS 8 /* Multi query - next query exists */
@@ -134,9 +142,9 @@
enum_func_status mysqlnd_read_result_metadata(MYSQLND *conn, MYSQLND_RES *result
TSRMLS_DC);
MYSQLND_RES *mysqlnd_result_init(unsigned int field_count, MYSQLND_ZVAL_PCACHE
*cache);
-void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result);
-void mysqlnd_internal_free_result_contents(MYSQLND_RES *result);
-void mysqlnd_internal_free_result_buffers(MYSQLND_RES *result);
+void mysqlnd_unbuffered_free_last_data(MYSQLND_RES *result TSRMLS_DC);
+void mysqlnd_internal_free_result_contents(MYSQLND_RES *result TSRMLS_DC);
+void mysqlnd_internal_free_result_buffers(MYSQLND_RES *result TSRMLS_DC);
void mysqlnd_internal_free_result(MYSQLND_RES *result TSRMLS_DC);
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c 2007-03-13 10:00:28 UTC (rev 113)
@@ -168,7 +168,7 @@
stmt->conn->upsert_status.affected_rows =
stmt->result->row_count;
} else {
- mysqlnd_internal_free_result_contents(stmt->result);
+ mysqlnd_internal_free_result_contents(stmt->result TSRMLS_CC);
efree(stmt->result);
stmt->result = NULL;
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Pretty serious error");
@@ -241,7 +241,7 @@
PACKET_INIT_ALLOCA(fields_eof, PROT_EOF_PACKET);
if (FAIL == (ret = PACKET_READ_ALLOCA(fields_eof, stmt->conn))) {
if (stmt->result) {
- mysqlnd_internal_free_result_contents(stmt->result);
+ mysqlnd_internal_free_result_contents(stmt->result TSRMLS_CC);
efree(stmt->result);
memset(stmt, 0, sizeof(MYSQLND_STMT));
stmt->state = MYSQLND_STMT_INITTED;
@@ -384,7 +384,7 @@
This will clean also the metadata, but after the EXECUTE call we will
have it again.
*/
- stmt->result->m.free_result_buffers(stmt->result);
+ stmt->result->m.free_result_buffers(stmt->result TSRMLS_CC);
} else if (stmt->state < MYSQLND_STMT_PREPARED) {
/* Only initted - error */
SET_CLIENT_ERROR(conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE,
@@ -562,7 +562,7 @@
*fetched_anything = TRUE;
if (!row_packet->skip_extraction) {
- mysqlnd_unbuffered_free_last_data(result);
+ mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
result->last_row_data = row_packet->fields;
result->last_row_buffer = row_packet->row_buffer;
@@ -705,7 +705,7 @@
if (PASS == (ret = PACKET_READ(row_packet, result->conn)) &&
!row_packet->eof) {
unsigned int i, field_count = result->field_count;
- mysqlnd_unbuffered_free_last_data(result);
+ mysqlnd_unbuffered_free_last_data(result TSRMLS_CC);
result->last_row_data = row_packet->fields;
result->last_row_buffer = row_packet->row_buffer;
@@ -1281,7 +1281,7 @@
mysqlnd_stmt_separate_result_bind(stmt);
/* Now we can destroy the result set */
- stmt->result->m.free_result_buffers(stmt->result);
+ stmt->result->m.free_result_buffers(stmt->result TSRMLS_CC);
}
/* As the buffers have been freed, we should go back to PREPARED */
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c 2007-03-13 10:00:28 UTC (rev 113)
@@ -120,13 +120,15 @@
} while (--j > 0);
tmp[10]= '\0';
/* unsigned int > INT_MAX is 10 digits - ALWAYS */
-#ifdef WE_USE_UNICODE
- ZVAL_UTF8_STRINGL(zv, tmp, 10, 0);
+#if PHP_MAJOR_VERSION < 6
+ ZVAL_STRING(zv, tmp, 0);
+#else
if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(zv, tmp, 10, 0);
efree(tmp);
+ } else {
+ ZVAL_STRING(zv, tmp, 0);
}
-#else
- ZVAL_STRING(zv, tmp, 0);
#endif
} else {
ZVAL_LONG(zv, uval);
@@ -159,10 +161,14 @@
* use MYSQLND_LL_SPEC.
*/
sprintf((char *)&tmp, uns == TRUE? MYSQLND_LLU_SPEC : MYSQLND_LL_SPEC, llval);
-#ifdef WE_USE_UNICODE
- ZVAL_UTF8_STRING(zv, tmp, ZSTR_DUPLICATE);
+#if PHP_MAJOR_VERSION < 6
+ ZVAL_STRING(zv, tmp, 1);
#else
- ZVAL_STRING(zv, tmp, 1);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRING(zv, tmp, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRING(zv, tmp, 1);
+ }
#endif
} else {
ZVAL_LONG(zv, llval);
@@ -232,11 +238,17 @@
*/
length = spprintf(&to, 0, "%s%02u:%02u:%02u",
(t.neg ? "-" : ""), t.hour, t.minute, t.second);
-#ifdef WE_USE_UNICODE
+
+#if PHP_MAJOR_VERSION < 6
ZVAL_STRINGL(zv, to, length, 1);
#else
- ZVAL_STRINGL(zv, to, length, 1);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRINGL(zv, to, length, 1);
+ }
#endif
+
efree(to);
}
@@ -272,11 +284,17 @@
Unicode equivalent of spprintf?
*/
length = spprintf(&to, 0, "%04u-%02u-%02u", t.year, t.month, t.day);
-#ifdef WE_USE_UNICODE
+
+#if PHP_MAJOR_VERSION < 6
ZVAL_STRINGL(zv, to, length, 1);
#else
- ZVAL_STRINGL(zv, to, length, 1);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRINGL(zv, to, length, 1);
+ }
#endif
+
efree(to);
}
@@ -320,11 +338,17 @@
*/
length = spprintf(&to, 0, "%04u-%02u-%02u %02u:%02u:%02u",
t.year, t.month, t.day, t.hour, t.minute, t.second);
-#ifdef WE_USE_UNICODE
+
+#if PHP_MAJOR_VERSION < 6
ZVAL_STRINGL(zv, to, length, 1);
#else
- ZVAL_STRINGL(zv, to, length, 1);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(zv, to, length, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRINGL(zv, to, length, 1);
+ }
#endif
+
efree(to);
}
@@ -338,11 +362,17 @@
to write \0 to the row buffer
*/
unsigned long length= php_mysqlnd_net_field_length(row);
-#ifdef WE_USE_UNICODE
+
+#if PHP_MAJOR_VERSION < 6
ZVAL_STRINGL(zv, (char *)*row, length, 1);
#else
- ZVAL_STRINGL(zv, (char *)*row, length, 1);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(zv, (char*)*row, length, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRINGL(zv, (char *)*row, length, 1);
+ }
#endif
+
(*row) += length;
}
Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_wireprotocol.c 2007-03-13 09:03:58 UTC (rev 112)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_wireprotocol.c 2007-03-13 10:00:28 UTC (rev 113)
@@ -1219,7 +1219,9 @@
ZVAL_NULL(*current_field);
last_field_was_string = FALSE;
} else {
-#ifdef WE_USE_UNICODE
+#if PHP_MAJOR_VERSION < 6
+ ZVAL_STRINGL(*current_field, (char *)p, len, 0);
+#else
/*
Here we have to convert to UTF16, which means not reusing the buffer.
Which in turn means that we can free the buffers once we have
@@ -1228,9 +1230,11 @@
I suppose we can use UG(unicode) in mysqlnd.c when freeing a result set
to check if we need to call copy_ctor().
*/
- ZVAL_STRINGL(*current_field, (char *)p, len, 0);
-#else
- ZVAL_STRINGL(*current_field, (char *)p, len, 0);
+ if (UG(unicode)) {
+ ZVAL_UTF8_STRINGL(*current_field, (char *)p, len, ZSTR_DUPLICATE);
+ } else {
+ ZVAL_STRINGL(*current_field, (char *)p, len, 0);
+ }
#endif
p += len;
last_field_was_string = TRUE;
| Thread |
|---|
| • PHP mysqlnd svn commit: r113 - trunk/ext/mysqli/mysqlnd | ahristov | 13 Mar |