List:Commits« Previous MessageNext Message »
From:ahristov Date:March 2 2007 6:28pm
Subject:PHP mysqlnd svn commit: r80 - trunk/ext/mysqli/mysqlnd
View as plain text  
Author: ahristov
Date: 2007-03-02 19:28:43 +0100 (Fri, 02 Mar 2007)
New Revision: 80

Modified:
   trunk/ext/mysqli/mysqlnd/mysqlnd.c
   trunk/ext/mysqli/mysqlnd/mysqlnd.h
   trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
   trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c
Log:
Added mysqlnd_stmt_reset()


Modified: trunk/ext/mysqli/mysqlnd/mysqlnd.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd.c	2007-02-28 14:42:48 UTC (rev 79)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd.c	2007-03-02 18:28:43 UTC (rev 80)
@@ -1406,15 +1406,16 @@
 {
 	zend_bool fetched_anything;
 
-	if (result->data) {
-		result->data_cursor = NULL;
-		return PASS;
-	}
-	/* Unbuffered sets */
-	if (result->conn && !result->eof_reached) {
+	/*
+	  Unbuffered sets
+	  A PS could be prepared - there is metadata and thus a stmt->result but the
+	  fetch_row function isn't actually set (NULL), thus we have to skip these.
+	*/
+	if (!result->data && result->conn && !result->eof_reached
&& result->m.fetch_row) {
 		/* We have to fetch all data to clean the line */
 		while ((PASS == result->m.fetch_row(result, NULL, 0, &fetched_anything
TSRMLS_CC)) &&
 			   fetched_anything == TRUE) {
+			/* do nothing */;
 		}
 	}
 	return PASS;

Modified: trunk/ext/mysqli/mysqlnd/mysqlnd.h
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd.h	2007-02-28 14:42:48 UTC (rev 79)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd.h	2007-03-02 18:28:43 UTC (rev 80)
@@ -525,6 +525,7 @@
 	MYSQLND_RES *		(*store_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	enum_func_status	(*free_result)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	enum_func_status	(*seek_data)(const MYSQLND_STMT * const stmt, mynd_ulonglong row);
+	enum_func_status	(*reset)(MYSQLND_STMT * const stmt TSRMLS_DC);
 	enum_func_status	(*close)(MYSQLND_STMT * const stmt TSRMLS_DC); /* private */
 	enum_func_status	(*dtor)(MYSQLND_STMT * const stmt TSRMLS_DC); /* use this for
mysqlnd_stmt_close */
 
@@ -897,6 +898,7 @@
 #define mysqlnd_stmt_execute(stmt) 			(stmt)->m->execute((stmt) TSRMLS_CC)
 #define	mysqlnd_stmt_free_result(stmt)		(stmt)->m->free_result((stmt) TSRMLS_CC)
 #define	mysqlnd_stmt_close(stmt)			(stmt)->m->dtor((stmt) TSRMLS_CC)
+#define	mysqlnd_stmt_reset(stmt)			(stmt)->m->reset((stmt) TSRMLS_CC)
 
 
 #define mysqlnd_stmt_attr_get(stmt, attr, value)	(stmt)->m->get_attribute((stmt),
(attr), (value))

Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c	2007-02-28 14:42:48 UTC (rev 79)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_ps.c	2007-03-02 18:28:43 UTC (rev 80)
@@ -733,6 +733,38 @@
 /* }}} */
 
 
+/* {{{ _mysqlnd_stmt_reset */
+static enum_func_status
+_mysqlnd_stmt_reset(MYSQLND_STMT * const stmt TSRMLS_DC)
+{
+	enum_func_status ret = PASS;
+	MYSQLND * conn = stmt->conn;
+	zend_uchar cmd_buf[STMT_ID_LENGTH /* statement id */];
+
+	if (stmt->stmt_id) {
+		/* XXX: If we have long data implemented, we have to reset it here !! */
+
+		if (stmt->result) {
+			stmt->result->m.skip_result(stmt->result TSRMLS_CC);
+		}
+		/* Now the line should be free, if it wasn't */
+
+		int4store(cmd_buf, stmt->stmt_id);
+		if (conn->state == CONN_READY &&
+			FAIL == (ret = mysqlnd_simple_command(conn, COM_STMT_RESET, (char *)cmd_buf,
+												  sizeof(cmd_buf), PROT_OK_PACKET,
+												  FALSE TSRMLS_CC))) {
+			stmt->error_info = conn->error_info;
+		}
+		stmt->upsert_status = conn->upsert_status;
+
+		stmt->state = MYSQLND_STMT_PREPARED;
+	}
+	return ret;
+}
+/* }}} */
+
+
 /* {{{ _mysqlnd_stmt_close */
 static enum_func_status
 _mysqlnd_stmt_close(MYSQLND_STMT * const stmt TSRMLS_DC)
@@ -745,7 +777,7 @@
 		int4store(cmd_buf, stmt->stmt_id);
 		if (conn->state == CONN_READY &&
 			FAIL == mysqlnd_simple_command(conn, COM_STMT_CLOSE, (char *)cmd_buf, sizeof(cmd_buf),
-										   PROT_LAST /* we will handle the response packet*/,
+										   PROT_LAST /*COM_STMT_CLOSE doesn't send OK packet*/,
 										   FALSE TSRMLS_CC)) {
 			stmt->error_info = conn->error_info;
 			return FAIL;
@@ -934,9 +966,9 @@
 /* }}} */
 
 
-/* {{{ _mysqlnd_stmt_sqlstate */
-static
-enum_func_status _mysqlnd_stmt_data_seek(const MYSQLND_STMT * const stmt, mynd_ulonglong
row)
+/* {{{ _mysqlnd_stmt_data_seek */
+static enum_func_status
+_mysqlnd_stmt_data_seek(const MYSQLND_STMT * const stmt, mynd_ulonglong row)
 {
 	return stmt->result? stmt->result->m.seek_data(stmt->result, row) : FAIL;
 }
@@ -1150,6 +1182,7 @@
 	_mysqlnd_stmt_store_result,
 	_mysqlnd_stmt_free_result,
 	_mysqlnd_stmt_data_seek,
+	_mysqlnd_stmt_reset,
 	_mysqlnd_stmt_close,
 	_mysqlnd_stmt_dtor,
 

Modified: trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c	2007-02-28 14:42:48 UTC (rev 79)
+++ trunk/ext/mysqli/mysqlnd/mysqlnd_ps_codec.c	2007-03-02 18:28:43 UTC (rev 80)
@@ -66,18 +66,7 @@
 
 
 
-
 static
-void ps_store_string(char *value, unsigned int len, zend_uchar **row)
-{
-	char *to= (char *) php_mysqlnd_net_store_length(*row, len);
-	memcpy(to, value, len);
-	*row = (zend_uchar*) to + len;
-}
-
-
-
-static
 void ps_fetch_null(zval *zv, const MYSQLND_FIELD * const field,
 				   uint pack_len, zend_uchar **row TSRMLS_DC)
 {
@@ -564,7 +553,6 @@
 						(*p) += len;
 					}
 
-					ps_store_string(Z_STRVAL_P(data), Z_STRLEN_P(data), buf);
 					break;
 				default:
 					/* Won't happen, but set to NULL */

Thread
PHP mysqlnd svn commit: r80 - trunk/ext/mysqli/mysqlndahristov2 Mar