List:Commits« Previous MessageNext Message »
From:ahristov Date:October 1 2007 3:52pm
Subject:PHP mysqlnd svn commit: r1074 - in trunk: mysqlnd php4/ext/mysql php5/ext/mysql php5/ext/mysqli php6/ext/mysql php6/ext/mysqli tests/ext/mysqli
View as plain text  
Author: ahristov
Date: 2007-10-01 17:52:21 +0200 (Mon, 01 Oct 2007)
New Revision: 1074

Modified:
   trunk/mysqlnd/mysqlnd.c
   trunk/mysqlnd/mysqlnd.h
   trunk/mysqlnd/mysqlnd_loaddata.c
   trunk/mysqlnd/mysqlnd_structs.h
   trunk/php4/ext/mysql/php_mysql.c
   trunk/php5/ext/mysql/php_mysql.c
   trunk/php5/ext/mysqli/mysqli.c
   trunk/php5/ext/mysqli/mysqli_api.c
   trunk/php5/ext/mysqli/mysqli_fe.c
   trunk/php6/ext/mysql/php_mysql.c
   trunk/php6/ext/mysqli/mysqli.c
   trunk/php6/ext/mysqli/mysqli_api.c
   trunk/php6/ext/mysqli/mysqli_fe.c
   trunk/tests/ext/mysqli/mysqli_class_mysqli_interface.phpt
   trunk/tests/ext/mysqli/mysqli_class_mysqli_reflection.phpt
   trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt
Log:
Disable INFILE handler for mysqlnd. Whoever needs that functionality might
write a stream wrapper and gain the same.


Modified: trunk/mysqlnd/mysqlnd.c
===================================================================
--- trunk/mysqlnd/mysqlnd.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/mysqlnd/mysqlnd.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -111,7 +111,7 @@
 
 	DBG_ENTER("mysqlnd_conn::free_contents");
 
-	mysqlnd_local_infile_default(conn, TRUE);
+	mysqlnd_local_infile_default(conn);
 	if (conn->current_result) {
 		conn->current_result->m.free_result_contents(conn->current_result TSRMLS_CC);
 		mnd_efree(conn->current_result);
@@ -729,6 +729,7 @@
 		conn->net.cmd_buffer.length = 128L*1024L;
 		conn->net.cmd_buffer.buffer = mnd_pemalloc(conn->net.cmd_buffer.length,
conn->persistent);
 
+        mysqlnd_local_infile_default(conn);
 		{
 			uint buf_size;
 			buf_size = MYSQLND_G(net_read_buffer_size); /* this is long, cast to uint*/

Modified: trunk/mysqlnd/mysqlnd.h
===================================================================
--- trunk/mysqlnd/mysqlnd.h	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/mysqlnd/mysqlnd.h	2007-10-01 15:52:21 UTC (rev 1074)
@@ -206,7 +206,7 @@
 PHPAPI const char * mysqlnd_field_type_name(enum mysqlnd_field_types field_type);
 
 /* LOAD DATA LOCAL */
-PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn, zend_bool free_callback);
+PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn);
 PHPAPI void mysqlnd_set_local_infile_handler(MYSQLND * const conn, const char * const
funcname);
 
 /* Simple commands */

Modified: trunk/mysqlnd/mysqlnd_loaddata.c
===================================================================
--- trunk/mysqlnd/mysqlnd_loaddata.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/mysqlnd/mysqlnd_loaddata.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -90,97 +90,16 @@
 	MYSQLND_INFILE_INFO	*info = (MYSQLND_INFILE_INFO *)ptr;
 	int			count;
 
-	DBG_ENTER("mysqlnd_local_infile_read");
-	/* default processing */
-	if (!info->callback) {
-		count = (int)php_stream_read(info->fd, buf, buf_len);
+    DBG_ENTER("mysqlnd_local_infile_read");
 
-		if (count < 0) {
-			strcpy(info->error_msg, "Error reading file");
-			info->error_no = CR_UNKNOWN_ERROR;
-		}
+	count = (int)php_stream_read(info->fd, buf, buf_len);
 
-		DBG_RETURN(count);
-	} else {
-		zval	***callback_args;
-		zval	*retval;
-		zval	*fp;
-		int		argc = 4;
-		int		i;
-		long	rc;
-
-		ALLOC_CALLBACK_ARGS(callback_args, 1, argc);
-	
-		/* set parameters: filepointer, buffer, buffer_len, errormsg */
-
-		MAKE_STD_ZVAL(fp);
-		php_stream_to_zval(info->fd, fp);
-		callback_args[0] = &fp;
-		ZVAL_STRING(*callback_args[1], "", 1);	
-		ZVAL_LONG(*callback_args[2], buf_len);	
-		ZVAL_STRING(*callback_args[3], "", 1);	
-	
-		if (call_user_function_ex(EG(function_table), 
-						NULL,
-						info->callback,
-						&retval,
-						argc,	 	
-						callback_args,
-						0,
-						NULL TSRMLS_CC) == SUCCESS) {
-
-			rc = Z_LVAL_P(retval);
-			zval_ptr_dtor(&retval);
-			convert_to_string(*callback_args[1]);
-			if (rc > 0) {
-				const char * msg = NULL;
-				if (rc >= 0 && rc != Z_STRLEN_P(*callback_args[1])) {
-					msg = "Mismatch between the return value of the callback and the content "
-						  "length of the buffer.";
-					php_error_docref(NULL TSRMLS_CC, E_WARNING, msg);
-					rc = -1;
-				} else if (Z_STRLEN_P(*callback_args[1]) > buf_len) {
-					/* check buffer overflow */
-					msg = "Too much data returned";
-					rc = -1;
-				} else {
-					memcpy(buf, Z_STRVAL_P(*callback_args[1]), MIN(rc, Z_STRLEN_P(*callback_args[1])));
-				}
-				if (rc == -1) {
-					DBG_ERR(msg);
-					php_error_docref(NULL TSRMLS_CC, E_WARNING, msg);
-					strcpy(info->error_msg, msg);
-					info->error_no = CR_UNKNOWN_ERROR;
-				}
-			} else if (rc < 0) {
-				convert_to_string(*callback_args[3]);
-				DBG_ERR(Z_STRVAL_P(*callback_args[3]));
-				strncpy(info->error_msg, Z_STRVAL_P(*callback_args[3]), MYSQLND_ERRMSG_SIZE); 
-				info->error_no = CR_UNKNOWN_ERROR;
-			}
-		} else {
-			DBG_ERR("Can't execute load data local init callback function");
-			strcpy(info->error_msg, "Can't execute load data local init callback function");
-			info->error_no = CR_UNKNOWN_ERROR;
-			rc = -1;
-		}
-		/*
-		  If the (ab)user has closed the file handle we should
-		  not try to use it anymore or even close it
-		*/
-		if (!zend_rsrc_list_get_rsrc_type(Z_LVAL_P(fp) TSRMLS_CC)) {
-			DBG_ERR("File handle closed!!");
-			strcpy(info->error_msg, "File handle closed in handler");
-			info->error_no = CR_UNKNOWN_ERROR;
-			rc = -1;
-			/* Thus the end handler won't try to free already freed memory */
-			info->fd = NULL;
-		}
-
-		mnd_efree(fp);
-		FREE_CALLBACK_ARGS(callback_args, 1, argc);
-		DBG_RETURN(rc);
+	if (count < 0) {
+		strcpy(info->error_msg, "Error reading file");
+		info->error_no = CR_UNKNOWN_ERROR;
 	}
+
+	DBG_RETURN(count);
 }
 /* }}} */
 
@@ -216,6 +135,7 @@
 		/* php_stream_close segfaults on NULL */
 		if (info->fd) {
 			php_stream_close(info->fd);
+			info->fd = NULL;
 		}
 		mnd_efree(info);
 	}
@@ -224,17 +144,12 @@
 
 
 /* {{{ mysqlnd_local_infile_default */
-PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn, zend_bool free_callback)
+PHPAPI void mysqlnd_local_infile_default(MYSQLND *conn)
 {
 	conn->infile.local_infile_init = mysqlnd_local_infile_init;
 	conn->infile.local_infile_read = mysqlnd_local_infile_read;
 	conn->infile.local_infile_error = mysqlnd_local_infile_error;
 	conn->infile.local_infile_end = mysqlnd_local_infile_end;
-	conn->infile.userdata = NULL;
-	if (free_callback == TRUE && conn->infile.callback) {
-		zval_ptr_dtor(&conn->infile.callback);
-		conn->infile.callback = NULL;	
-	}
 }
 /* }}} */
 
@@ -277,12 +192,6 @@
 		goto infile_error;
 	}
 
-	/* check if we have valid functions */
-	if (!conn->infile.local_infile_init || !conn->infile.local_infile_read ||
-		!conn->infile.local_infile_error || !conn->infile.local_infile_end) {
-		mysqlnd_local_infile_default(conn, FALSE);
-	}
-
 	infile = conn->infile;
 	/* allocate buffer for reading data */
 	buf = (char *)mnd_ecalloc(1, buflen);
@@ -302,13 +211,6 @@
 		goto infile_error;
 	}
 
-	/* pass callback handler */
-	if (infile.callback) {
-		MYSQLND_INFILE_INFO	*ptr = (MYSQLND_INFILE_INFO *)info;
-		ptr->callback = infile.callback;
-	}
-		
-
 	/* read data */
 	while ((bufsize = infile.local_infile_read (info, buf + MYSQLND_HEADER_SIZE,
 												buflen - MYSQLND_HEADER_SIZE TSRMLS_CC)) > 0) {

Modified: trunk/mysqlnd/mysqlnd_structs.h
===================================================================
--- trunk/mysqlnd/mysqlnd_structs.h	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/mysqlnd/mysqlnd_structs.h	2007-10-01 15:52:21 UTC (rev 1074)
@@ -86,7 +86,6 @@
 	int					error_no;
 	char				error_msg[MYSQLND_ERRMSG_SIZE + 1];
 	const char			*filename;
-	zval				*callback;
 } MYSQLND_INFILE_INFO;
 
 

Modified: trunk/php4/ext/mysql/php_mysql.c
===================================================================
--- trunk/php4/ext/mysql/php_mysql.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php4/ext/mysql/php_mysql.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -130,7 +130,7 @@
 
 /* {{{ mysql_functions[]
  */
-const function_entry mysql_functions[] = {
+static const function_entry mysql_functions[] = {
 	PHP_FE(mysql_connect,								NULL)
 	PHP_FE(mysql_pconnect,								NULL)
 	PHP_FE(mysql_close,									NULL)
@@ -215,7 +215,7 @@
 /* }}} */
 
 /* Dependancies */
-static zend_module_dep mysql_deps[] = {
+static const zend_module_dep mysql_deps[] = {
 #if defined(HAVE_MYSQLND)
 	ZEND_MOD_REQUIRED("mysqlnd")
 #endif
@@ -476,9 +476,12 @@
 {
 #if !defined(HAVE_MYSQLND) && MYSQL_VERSION_ID >= 40000
 #ifdef PHP_WIN32
-	unsigned long client_ver = mysql_get_client_version;
-	/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
-	if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+	unsigned long client_ver = mysql_get_client_version();
+	/*
+	  Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows.
+	  PHP bug#41350 MySQL bug#25621
+	*/
+	if ((client_ver >= 50042 && client_ver < 50100) || client_ver > 50122)
{
 		mysql_server_end();
 	}
 #else

Modified: trunk/php5/ext/mysql/php_mysql.c
===================================================================
--- trunk/php5/ext/mysql/php_mysql.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php5/ext/mysql/php_mysql.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -137,7 +137,7 @@
 
 /* {{{ mysql_functions[]
  */
-const zend_function_entry mysql_functions[] = {
+static const zend_function_entry mysql_functions[] = {
 	PHP_FE(mysql_connect,								NULL)
 	PHP_FE(mysql_pconnect,								NULL)
 	PHP_FE(mysql_close,									NULL)
@@ -222,7 +222,7 @@
 /* }}} */
 
 /* Dependancies */
-static zend_module_dep mysql_deps[] = {
+static const zend_module_dep mysql_deps[] = {
 #if defined(HAVE_MYSQLND)
 	ZEND_MOD_REQUIRED("mysqlnd")
 #endif
@@ -450,9 +450,11 @@
 	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS |
CONST_PERSISTENT); 
 
 #ifndef HAVE_MYSQLND
+#if MYSQL_VERSION >= 40000
 	if (mysql_server_init(0, NULL, NULL)) {
 		return FAILURE;
 	}
+#endif
 #else
 	mysql_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MySG(cache_size));
 	mysql_mysqlnd_qcache = mysqlnd_qcache_init_cache();
@@ -468,9 +470,12 @@
 {
 #ifndef HAVE_MYSQLND
 #ifdef PHP_WIN32
-	unsigned long client_ver = mysql_get_client_version;
-	/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
-	if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+	unsigned long client_ver = mysql_get_client_version();
+	/*
+	  Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows.
+	  PHP bug#41350 MySQL bug#25621
+	*/
+	if ((client_ver >= 50042 && client_ver < 50100) || client_ver > 50122)
{
 		mysql_server_end();
 	}
 #else
@@ -490,7 +495,7 @@
  */
 PHP_RINIT_FUNCTION(mysql)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	if (mysql_thread_init()) {
 		return FAILURE;
 	}
@@ -514,7 +519,7 @@
  */
 PHP_RSHUTDOWN_FUNCTION(mysql)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	mysql_thread_end();
 #endif
 

Modified: trunk/php5/ext/mysqli/mysqli.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php5/ext/mysqli/mysqli.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -603,9 +603,11 @@
 	
 	REGISTER_INI_ENTRIES();
 #ifndef HAVE_MYSQLND
+#if MYSQL_VERSION >= 40000
 	if (mysql_server_init(0, NULL, NULL)) {
 		return FAILURE;
 	}
+#endif
 #else
 	mysqli_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MyG(cache_size));
 	mysqli_mysqlnd_qcache = mysqlnd_qcache_init_cache();
@@ -792,8 +794,11 @@
 #ifndef HAVE_MYSQLND
 #ifdef PHP_WIN32
 	unsigned long client_ver = mysql_get_client_version();
-	/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
-	if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+	/*
+	  Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows.
+	  PHP bug#41350 MySQL bug#25621
+	*/
+	if ((client_ver >= 50042 && client_ver < 50100) || client_ver > 50122)
{
 		mysql_server_end();
 	}
 #else
@@ -820,7 +825,7 @@
  */
 PHP_RINIT_FUNCTION(mysqli)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	if (mysql_thread_init()) {
 		return FAILURE;
 	}
@@ -842,7 +847,7 @@
 	/* check persistent connections, move used to free */
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_on_rshut
TSRMLS_CC);
 
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	mysql_thread_end();
 #endif
 	if (MyG(error_msg)) {
@@ -1180,6 +1185,8 @@
 }
 /* }}} */
 
+#if !defined(HAVE_MYSQLND)
+
 #define ALLOC_CALLBACK_ARGS(a, b, c)\
 if (c) {\
 	a = (zval ***)safe_emalloc(c, sizeof(zval **), 0);\
@@ -1206,20 +1213,15 @@
 */
 void php_set_local_infile_handler_default(MY_MYSQL *mysql) {
 	/* register internal callback functions */
-#if !defined(HAVE_MYSQLND)
 	mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init,
&php_local_infile_read,
 				&php_local_infile_end, &php_local_infile_error, (void *)mysql);
 	if (mysql->li_read) {
 		zval_ptr_dtor(&mysql->li_read);
 		mysql->li_read = NULL;
 	}
-#else
-	mysqlnd_local_infile_default(mysql->mysql, TRUE);
-#endif
 }
 /* }}} */
 
-#if !defined(HAVE_MYSQLND)
 /* {{{ php_local_infile_init
  */
 int php_local_infile_init(void **ptr, const char *filename, void *userdata)

Modified: trunk/php5/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_api.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php5/ext/mysqli/mysqli_api.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -1323,6 +1323,7 @@
 
 /* {{{ proto void mysqli_set_local_infile_default(object link)
    unsets user defined handler for load local infile command */
+#if !defined(HAVE_MYSQLND)
 PHP_FUNCTION(mysqli_set_local_infile_default)
 {
 	MY_MYSQL	*mysql;
@@ -1334,15 +1335,11 @@
 
 	MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link",
MYSQLI_STATUS_VALID);
 
-#if !defined(HAVE_MYSQLND)
 	if (mysql->li_read) {
 		efree(Z_STRVAL_P(mysql->li_read));
 		zval_dtor(mysql->li_read);
 		mysql->li_read = NULL;
 	}
-#else
-	mysqlnd_local_infile_default(mysql->mysql, TRUE);
-#endif
 }
 /* }}} */
 
@@ -1371,19 +1368,16 @@
 	efree(callback_name);
 
 	/* save callback function */
-#if !defined(HAVE_MYSQLND)
 	if (!mysql->li_read) {
 		MAKE_STD_ZVAL(mysql->li_read);
 	} else {
 		zval_dtor(mysql->li_read);
 	}
 	ZVAL_STRINGL(mysql->li_read, Z_STRVAL_P(callback_func), Z_STRLEN_P(callback_func),
1);
-#else
-	mysqlnd_set_local_infile_handler(mysql->mysql, callback_func->value.str.val);
-#endif
 
 	RETURN_TRUE;
 }
+#endif
 /* }}} */
 
 /* {{{ proto bool mysqli_more_results(object link)

Modified: trunk/php5/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php5/ext/mysqli/mysqli_fe.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php5/ext/mysqli/mysqli_fe.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -117,8 +117,10 @@
 	PHP_FE(mysqli_info,									NULL)
 	PHP_FE(mysqli_insert_id,							NULL)
 	PHP_FE(mysqli_kill,									NULL)
+#if !defined(HAVE_MYSQLND)
 	PHP_FE(mysqli_set_local_infile_default,				NULL)
 	PHP_FE(mysqli_set_local_infile_handler,				NULL)
+#endif
 	PHP_FE(mysqli_more_results,							NULL)
 	PHP_FE(mysqli_multi_query, 							NULL)
 	PHP_FE(mysqli_next_result,							NULL)
@@ -225,8 +227,10 @@
 	PHP_FALIAS(get_warnings, mysqli_get_warnings, NULL)
 	PHP_FALIAS(init,mysqli_init,NULL)
 	PHP_FALIAS(kill,mysqli_kill,NULL)
+#if !defined(HAVE_MYSQLND)
 	PHP_FALIAS(set_local_infile_default,mysqli_set_local_infile_default,NULL)
 	PHP_FALIAS(set_local_infile_handler,mysqli_set_local_infile_handler,NULL)
+#endif
 	PHP_FALIAS(multi_query,mysqli_multi_query,NULL)
 	PHP_FALIAS(mysqli,mysqli_connect,NULL)
 	PHP_FALIAS(more_results,mysqli_more_results, NULL)

Modified: trunk/php6/ext/mysql/php_mysql.c
===================================================================
--- trunk/php6/ext/mysql/php_mysql.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php6/ext/mysql/php_mysql.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -132,7 +132,7 @@
 
 /* {{{ mysql_functions[]
  */
-zend_function_entry mysql_functions[] = {
+static const zend_function_entry mysql_functions[] = {
 	PHP_FE(mysql_connect,								NULL)
 	PHP_FE(mysql_pconnect,								NULL)
 	PHP_FE(mysql_close,									NULL)
@@ -219,7 +219,7 @@
 /* }}} */
 
 /* Dependancies */
-static zend_module_dep mysql_deps[] = {
+static const zend_module_dep mysql_deps[] = {
 #if defined(HAVE_MYSQLND)
 	ZEND_MOD_REQUIRED("mysqlnd")
 #endif
@@ -447,9 +447,11 @@
 	REGISTER_LONG_CONSTANT("MYSQL_CLIENT_IGNORE_SPACE", CLIENT_IGNORE_SPACE, CONST_CS |
CONST_PERSISTENT); 
 
 #ifndef HAVE_MYSQLND
+#if MYSQL_VERSION >= 40000
 	if (mysql_server_init(0, NULL, NULL)) {
 		return FAILURE;
 	}
+#endif
 #else
 	mysql_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MySG(cache_size));
 	mysql_mysqlnd_qcache = mysqlnd_qcache_init_cache();
@@ -465,9 +467,12 @@
 {
 #ifndef HAVE_MYSQLND
 #ifdef PHP_WIN32
-	unsigned long client_ver = mysql_get_client_version;
-	/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
-	if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+	unsigned long client_ver = mysql_get_client_version();
+	/*
+	  Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows.
+	  PHP bug#41350 MySQL bug#25621
+	*/
+	if ((client_ver >= 50042 && client_ver < 50100) || client_ver > 50122)
{
 		mysql_server_end();
 	}
 #else
@@ -487,7 +492,7 @@
  */
 PHP_RINIT_FUNCTION(mysql)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	if (mysql_thread_init()) {
 		return FAILURE;
 	}
@@ -511,7 +516,7 @@
  */
 PHP_RSHUTDOWN_FUNCTION(mysql)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	mysql_thread_end();
 #endif
 

Modified: trunk/php6/ext/mysqli/mysqli.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php6/ext/mysqli/mysqli.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -607,9 +607,11 @@
 	REGISTER_INI_ENTRIES();
 
 #ifndef HAVE_MYSQLND
+#if MYSQL_VERSION >= 40000
 	if (mysql_server_init(0, NULL, NULL)) {
 		return FAILURE;
 	}
+#endif
 #else
 	mysqli_mysqlnd_zval_cache = mysqlnd_palloc_init_cache(MyG(cache_size));
 	mysqli_mysqlnd_qcache = mysqlnd_qcache_init_cache();
@@ -798,8 +800,11 @@
 #ifndef HAVE_MYSQLND
 #ifdef PHP_WIN32
 	unsigned long client_ver = mysql_get_client_version();
-	/* Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows */
-	if ((client_ver > 50042 && client_ver < 50100) || client_ver > 50122) {
+	/*
+	  Can't call mysql_server_end() multiple times prior to 5.0.42 on Windows.
+	  PHP bug#41350 MySQL bug#25621
+	*/
+	if ((client_ver >= 50042 && client_ver < 50100) || client_ver > 50122)
{
 		mysql_server_end();
 	}
 #else
@@ -826,7 +831,7 @@
  */
 PHP_RINIT_FUNCTION(mysqli)
 {
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	if (mysql_thread_init()) {
 		return FAILURE;
 	}
@@ -848,7 +853,7 @@
 	/* check persistent connections, move used to free */
 	zend_hash_apply(&EG(persistent_list), (apply_func_t) php_mysqli_persistent_on_rshut
TSRMLS_CC);
 
-#if !defined(HAVE_MYSQLND) && defined(ZTS)
+#if !defined(HAVE_MYSQLND) && defined(ZTS) && MYSQL_VERSION_ID >=
40000
 	mysql_thread_end();
 #endif
 	if (MyG(error_msg)) {
@@ -1214,6 +1219,9 @@
 }
 /* }}} */
 
+#if !defined(HAVE_MYSQLND)
+
+
 #define ALLOC_CALLBACK_ARGS(a, b, c)\
 if (c) {\
 	a = (zval ***)safe_emalloc(c, sizeof(zval **), 0);\
@@ -1237,24 +1245,20 @@
 memcpy(source, dest, MIN(strlen(dest), LOCAL_INFILE_ERROR_LEN-1));\
 php_error_docref(NULL TSRMLS_CC, E_WARNING, dest);
 
+
 /* {{{ void php_set_local_infile_handler_default 
 */
 void php_set_local_infile_handler_default(MY_MYSQL *mysql) {
 	/* register internal callback functions */
-#if !defined(HAVE_MYSQLND)
 	mysql_set_local_infile_handler(mysql->mysql, &php_local_infile_init,
&php_local_infile_read,
 				&php_local_infile_end, &php_local_infile_error, (void *)mysql);
 	if (mysql->li_read) {
 		zval_ptr_dtor(&mysql->li_read);
 		mysql->li_read = NULL;
 	}
-#else
-	mysqlnd_local_infile_default(mysql->mysql, TRUE);
-#endif
 }
 /* }}} */
 
-#if !defined(HAVE_MYSQLND)
 /* {{{ php_local_infile_init
  */
 int php_local_infile_init(void **ptr, const char *filename, void *userdata)

Modified: trunk/php6/ext/mysqli/mysqli_api.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_api.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php6/ext/mysqli/mysqli_api.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -1390,6 +1390,7 @@
 
 /* {{{ proto void mysqli_set_local_infile_default(object link) U
    unsets user defined handler for load local infile command */
+#if !defined(HAVE_MYSQLND)
 PHP_FUNCTION(mysqli_set_local_infile_default)
 {
 	MY_MYSQL	*mysql;
@@ -1401,15 +1402,10 @@
 
 	MYSQLI_FETCH_RESOURCE(mysql, MY_MYSQL *, &mysql_link, "mysqli_link",
MYSQLI_STATUS_VALID);
 
-#if !defined(HAVE_MYSQLND)
 	if (mysql->li_read) {
-		efree(Z_STRVAL_P(mysql->li_read));
 		zval_dtor(mysql->li_read);
 		mysql->li_read = NULL;
 	}
-#else
-	mysqlnd_local_infile_default(mysql->mysql, TRUE);
-#endif
 }
 /* }}} */
 
@@ -1442,19 +1438,16 @@
 	zval_dtor(&callback_name);
 
 	/* save callback function */
-#if !defined(HAVE_MYSQLND)
 	if (!mysql->li_read) {
 		MAKE_STD_ZVAL(mysql->li_read);
 	} else {
 		zval_dtor(mysql->li_read);
 	}
 	ZVAL_STRINGL(mysql->li_read, Z_STRVAL_P(callback_func), Z_STRLEN_P(callback_func),
1);
-#else
-	mysqlnd_set_local_infile_handler(mysql->mysql, callback_func->value.str.val);
-#endif
 
 	RETURN_TRUE;
 }
+#endif
 /* }}} */
 
 /* {{{ proto bool mysqli_more_results(object link) U

Modified: trunk/php6/ext/mysqli/mysqli_fe.c
===================================================================
--- trunk/php6/ext/mysqli/mysqli_fe.c	2007-09-28 15:25:15 UTC (rev 1073)
+++ trunk/php6/ext/mysqli/mysqli_fe.c	2007-10-01 15:52:21 UTC (rev 1074)
@@ -119,8 +119,10 @@
 	PHP_FE(mysqli_info,									NULL)
 	PHP_FE(mysqli_insert_id,							NULL)
 	PHP_FE(mysqli_kill,									NULL)
+#if !defined(HAVE_MYSQLND)
 	PHP_FE(mysqli_set_local_infile_default,				NULL)
 	PHP_FE(mysqli_set_local_infile_handler,				NULL)
+#endif
 	PHP_FE(mysqli_more_results,							NULL)
 	PHP_FE(mysqli_multi_query, 							NULL)
 	PHP_FE(mysqli_next_result,							NULL)
@@ -227,8 +229,10 @@
 	PHP_FALIAS(get_warnings, mysqli_get_warnings, NULL)
 	PHP_FALIAS(init,mysqli_init,NULL)
 	PHP_FALIAS(kill,mysqli_kill,NULL)
+#if !defined(HAVE_MYSQLND)
 	PHP_FALIAS(set_local_infile_default,mysqli_set_local_infile_default,NULL)
 	PHP_FALIAS(set_local_infile_handler,mysqli_set_local_infile_handler,NULL)
+#endif
 	PHP_FALIAS(multi_query,mysqli_multi_query,NULL)
 	PHP_FALIAS(mysqli,mysqli_connect,NULL)
 	PHP_FALIAS(more_results,mysqli_more_results, NULL)

Modified: trunk/tests/ext/mysqli/mysqli_class_mysqli_interface.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_class_mysqli_interface.phpt	2007-09-28 15:25:15 UTC (rev
1073)
+++ trunk/tests/ext/mysqli/mysqli_class_mysqli_interface.phpt	2007-10-01 15:52:21 UTC (rev
1074)
@@ -48,8 +48,6 @@
 		'rollback'			=> true,
 		'select_db'			=> true,
 		'set_charset'			=> true,
-		'set_local_infile_default'	=> true,
-		'set_local_infile_handler'	=> true,
 		'set_opt'			=> true,
 		'stat'				=> true,
 		'stmt_init'			=> true,
@@ -93,6 +91,8 @@
 
 		if (function_exists('mysqli_ssl_set'))
 			$expected_methods['ssl_set'] = true;
+		$expected_methods['set_local_infile_default']	= true;
+		$expected_methods['set_local_infile_handler']	= true;
 	}
 
 	/* we should add ruled when to expect them */
@@ -305,4 +305,4 @@
 Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation):
 mysqli->connect_error = ''/unicode (''/unicode)
 mysqli->connect_errno = '0'/integer ('0'/integer)
-done!
\ No newline at end of file
+done!

Modified: trunk/tests/ext/mysqli/mysqli_class_mysqli_reflection.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_class_mysqli_reflection.phpt	2007-09-28 15:25:15 UTC
(rev 1073)
+++ trunk/tests/ext/mysqli/mysqli_class_mysqli_reflection.phpt	2007-10-01 15:52:21 UTC
(rev 1074)
@@ -551,38 +551,6 @@
 Number of Parameters: 0
 Number of Required Parameters: 0
 
-Inspecting method 'set_local_infile_default'
-isFinal: no
-isAbstract: no
-isPublic: yes
-isPrivate: no
-isProtected: no
-isStatic: no
-isConstructor: no
-isDestructor: no
-isInternal: yes
-isUserDefined: no
-returnsReference: no
-Modifiers: 256
-Number of Parameters: 0
-Number of Required Parameters: 0
-
-Inspecting method 'set_local_infile_handler'
-isFinal: no
-isAbstract: no
-isPublic: yes
-isPrivate: no
-isProtected: no
-isStatic: no
-isConstructor: no
-isDestructor: no
-isInternal: yes
-isUserDefined: no
-returnsReference: no
-Modifiers: 256
-Number of Parameters: 0
-Number of Required Parameters: 0
-
 Inspecting method 'set_opt'
 isFinal: no
 isAbstract: no
@@ -678,4 +646,4 @@
 Modifiers: 256
 Number of Parameters: 0
 Number of Required Parameters: 0
-done!
\ No newline at end of file
+done!

Modified: trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt	2007-09-28
15:25:15 UTC (rev 1073)
+++ trunk/tests/ext/mysqli/mysqli_set_local_infile_handler_unregister.phpt	2007-10-01
15:52:21 UTC (rev 1074)
@@ -60,5 +60,8 @@
 --EXPECTF--
 Callback set to 'callback_unregister'
 Callback: 0
-[022] LOAD DATA failed, [2000] Can't execute load data local init callback function
-done!
\ No newline at end of file
+
+Warning: mysqli_query(): File handle closed in %s on line %d
+[022] LOAD DATA failed, [2000] File handle closed
+[024/0] [0] ''
+done!

Thread
PHP mysqlnd svn commit: r1074 - in trunk: mysqlnd php4/ext/mysql php5/ext/mysql php5/ext/mysqli php6/ext/mysql php6/ext/mysqli tests/ext/mysqliahristov1 Oct