List:Commits« Previous MessageNext Message »
From:ahristov Date:July 5 2007 4:57pm
Subject:PHP mysqlnd svn commit: r656 - in trunk: php5/ext/mysqli php6/ext/mysqli
View as plain text  
Author: ahristov
Date: 2007-07-05 18:57:46 +0200 (Thu, 05 Jul 2007)
New Revision: 656

Modified:
   trunk/php5/ext/mysqli/mysqli_api.c
   trunk/php6/ext/mysqli/mysqli.c
   trunk/php6/ext/mysqli/mysqli_api.c
Log:
Fix three failures because binary type data wasn't
returned as string but unicode with libmysql.


Modified: trunk/php5/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_api.c	2007-07-05 16:11:49 UTC (rev 655)
+++ trunk/php5/ext/mysqli/mysqli_api.c	2007-07-05 16:57:46 UTC (rev 656)
@@ -834,12 +834,14 @@
 #if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002
 							if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) !=
0) {
 								/* result was truncated */
-								ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
stmt->stmt->bind[i].buffer_length, 1);
+								ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
+											 stmt->stmt->bind[i].buffer_length, 1);
 							} else {
 #else
 							{
 #endif
-								ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
stmt->result.buf[i].buflen, 1);
+								ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
+											 stmt->result.buf[i].buflen, 1);
 							}
 						}
 						break;

Modified: trunk/php6/ext/mysqli/mysqli.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli.c	2007-07-05 16:11:49 UTC (rev 655)
+++ trunk/php6/ext/mysqli/mysqli.c	2007-07-05 16:57:46 UTC (rev 656)
@@ -1045,7 +1045,6 @@
 			zval *res;
 
 			MAKE_STD_ZVAL(res);
-
 			if (UG(unicode) && !IS_BINARY_DATA(fields[i])) {
 				UChar *ustr;
 				int ulen;

Modified: trunk/php6/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_api.c	2007-07-05 16:11:49 UTC (rev 655)
+++ trunk/php6/ext/mysqli/mysqli_api.c	2007-07-05 16:57:46 UTC (rev 656)
@@ -753,7 +753,16 @@
 /* }}} */
 
 
+
 #if !defined(HAVE_MYSQLND)
+#define MYSQL_BINARY_CHARSET_NR 63
+
+#define IS_BINARY_DATA(f) (((f).type == MYSQL_TYPE_TINY_BLOB || (f).type ==
MYSQL_TYPE_BLOB || \
+	(f).type == MYSQL_TYPE_MEDIUM_BLOB || (f).type == MYSQL_TYPE_LONG_BLOB || \
+	(f).type == MYSQL_TYPE_BIT || (f).type == MYSQL_TYPE_VAR_STRING || (f).type ==
MYSQL_TYPE_VARCHAR ||\
+	(f).type == MYSQL_TYPE_STRING) && (f).charsetnr == MYSQL_BINARY_CHARSET_NR)
+
+
 /* {{{ void mysqli_stmt_fetch_libmysql
    Fetch results from a prepared statement into the bound variables */
 void mysqli_stmt_fetch_libmysql(INTERNAL_FUNCTION_PARAMETERS)
@@ -764,6 +773,8 @@
 	ulong 			ret;
 	unsigned int	uval;
 	my_ulonglong	llval;
+	MYSQL_RES		*result_metadata = NULL;
+	MYSQL_FIELD		*fields;
 	
 
 	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O",
&mysql_stmt, mysqli_stmt_class_entry) == FAILURE) {
@@ -777,6 +788,8 @@
 			memset(stmt->result.buf[i].val, 0, stmt->result.buf[i].buflen);
 		}
 	}
+	result_metadata = mysql_stmt_result_metadata(stmt->stmt);
+	fields = mysql_fetch_fields(result_metadata);
 	ret = mysql_stmt_fetch(stmt->stmt);
 #ifdef MYSQL_DATA_TRUNCATED
 	if (!ret || ret == MYSQL_DATA_TRUNCATED) {
@@ -863,16 +876,23 @@
 						}
 #endif
 						else {
+							size_t copy_len;
 #if defined(MYSQL_DATA_TRUNCATED) && MYSQL_VERSION_ID > 50002
 							if (ret == MYSQL_DATA_TRUNCATED && *(stmt->stmt->bind[i].error) !=
0) {
 								/* result was truncated */
-								ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
stmt->stmt->bind[i].buffer_length, ZSTR_DUPLICATE);
-							} else {
-#else
+								copy_len = stmt->stmt->bind[i].buffer_length;
+							} else
+#endif
 							{
-#endif
-								ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
stmt->result.buf[i].buflen, ZSTR_DUPLICATE);
+								copy_len = stmt->result.buf[i].buflen;
 							}
+							if (!IS_BINARY_DATA(fields[i])) {
+								ZVAL_UTF8_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
+												  copy_len, ZSTR_DUPLICATE);
+							} else {
+								ZVAL_STRINGL(stmt->result.vars[i], stmt->result.buf[i].val,
+											 copy_len, 1);								
+							}
 						}
 						break;
 					default:
@@ -885,6 +905,10 @@
 	} else {
 		MYSQLI_REPORT_STMT_ERROR(stmt->stmt);
 	}
+	if (result_metadata) {
+		mysql_free_result(result_metadata);
+		result_metadata = NULL;
+	}
 
 	switch (ret) {
 		case 0:

Thread
PHP mysqlnd svn commit: r656 - in trunk: php5/ext/mysqli php6/ext/mysqliahristov5 Jul