andrey                                   Fri, 02 Sep 2011 13:53:41 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=316039

Log:
Fix for Bug #54158 MYSQLND + PDO MySQL requires #define MYSQL_OPT_LOCAL_INFILE
and a bunch of other small preprocessor fixes

Bug: https://bugs.php.net/54158 (Analyzed) MYSQLND + PDO MySQL requires #define 
MYSQL_OPT_LOCAL_INFILE
      
Changed paths:
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/branches/PHP_5_4/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/trunk/ext/pdo_mysql/mysql_driver.c

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS	2011-09-02 13:35:17 UTC (rev 316038)
+++ php/php-src/branches/PHP_5_3/NEWS	2011-09-02 13:53:41 UTC (rev 316039)
@@ -19,6 +19,10 @@
   . Fixed bug #55067 (MySQL doesn't support compression - wrong config option).
     (Andrey)

+- PDO MySQL driver:
+  . Fixed bug #54158 (MYSQLND+PDO MySQL requires #define MYSQL_OPT_LOCAL_INFILE)
+  (Andrey)
+
 - Phar:
   . Fixed bug#52013 (Unable to decompress files in a compressed phar). (Hannes)
   . Fixed bug#53872 (internal corruption of phar). (Hannes)

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:35:17 UTC (rev 316038)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:53:41 UTC (rev 316039)
@@ -42,7 +42,7 @@
 #	define pdo_mysql_init(persistent) mysql_init(NULL)
 #endif

-#if !HAVE_MYSQL_SQLSTATE && !PDO_USE_MYSQLND
+#if !defined(HAVE_MYSQL_SQLSTATE) && !defined(PDO_USE_MYSQLND)
 static const char *pdo_mysql_get_sqlstate(unsigned int my_errno) { /* {{{ */
 	switch (my_errno) {
 		/* import auto-generated case: code */
@@ -72,7 +72,7 @@
 		einfo   = &H->einfo;
 	}

-#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
+#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)
 	if (S && S->stmt) {
 		einfo->errcode = mysql_stmt_errno(S->stmt);
 	}
@@ -112,8 +112,8 @@
 		PDO_DBG_RETURN(0);
 	}

-#if HAVE_MYSQL_SQLSTATE || PDO_USE_MYSQLND
-# if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
+#if defined(HAVE_MYSQL_SQLSTATE) || defined(PDO_USE_MYSQLND)
+# if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)
 	if (S && S->stmt) {
 		strcpy(*pdo_err, mysql_stmt_sqlstate(S->stmt));
 	} else
@@ -187,7 +187,7 @@
 {
 	pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
 	pdo_mysql_stmt *S = ecalloc(1, sizeof(pdo_mysql_stmt));
-#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
+#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)
 	char *nsql = NULL;
 	int nsql_len = 0;
 	int ret;
@@ -206,7 +206,7 @@
 		goto end;
 	}

-#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSQLND
+#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSQLND)
 	server_version = mysql_get_server_version(H->server);
 	if (server_version < 40100) {
 		goto fallback;
@@ -255,7 +255,7 @@

 	if (S->num_params) {
 		S->params_given = 0;
-#if PDO_USE_MYSQLND
+#ifdef PDO_USE_MYSQLND
 		S->params = NULL;
 #else
 		S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
@@ -296,7 +296,7 @@
 			PDO_DBG_RETURN(H->einfo.errcode ? -1 : 0);
 		} else {

-#if HAVE_MYSQL_NEXT_RESULT || PDO_USE_MYSQLND
+#if defined(HAVE_MYSQL_NEXT_RESULT) || defined(PDO_USE_MYSQLND)
 			/* MULTI_QUERY support - eat up all unfetched result sets */
 			MYSQL_RES* result;
 			while (mysql_more_results(H->server)) {
@@ -461,7 +461,7 @@
 			break;
 		case PDO_ATTR_SERVER_INFO: {
 			char *tmp;
-#if PDO_USE_MYSQLND
+#ifdef PDO_USE_MYSQLND
 			unsigned int tmp_len;

 			if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
@@ -583,7 +583,7 @@
 #endif
 		;

-#if PDO_USE_MYSQLND
+#ifdef PDO_USE_MYSQLND
 	int dbname_len = 0;
 	int password_len = 0;
 #endif
@@ -625,7 +625,7 @@
 		char *default_file = NULL, *default_group = NULL;
 		long compress = 0;
 #endif
-#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSLQND
+#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSLQND)
 		char *ssl_key = NULL, *ssl_cert = NULL, *ssl_ca = NULL, *ssl_capath = NULL, *ssl_cipher = NULL;
 #endif
 		H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@@ -660,7 +660,7 @@
 		{
 			local_infile = 0;
 		}
-#ifdef MYSQL_OPT_LOCAL_INFILE
+#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
 		if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
 			pdo_mysql_error(dbh);
 			goto cleanup;
@@ -668,7 +668,9 @@
 #endif
 #ifdef MYSQL_OPT_RECONNECT
 		/* since 5.0.3, the default for this option is 0 if not specified.
-		 * we want the old behaviour */
+		 * we want the old behaviour
+		 * mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
+		*/
 		{
 			long reconnect = 1;
 			mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
@@ -712,7 +714,7 @@
 			}
 		}
 #endif
-#if HAVE_MYSQL_STMT_PREPARE || PDO_USE_MYSLQND
+#if defined(HAVE_MYSQL_STMT_PREPARE) || defined(PDO_USE_MYSLQND)
 		ssl_key = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_KEY, NULL TSRMLS_CC);
 		ssl_cert = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CERT, NULL TSRMLS_CC);
 		ssl_ca = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_SSL_CA, NULL TSRMLS_CC);

Modified: php/php-src/branches/PHP_5_4/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/branches/PHP_5_4/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:35:17 UTC (rev 316038)
+++ php/php-src/branches/PHP_5_4/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:53:41 UTC (rev 316039)
@@ -36,7 +36,7 @@
 #endif
 #include "zend_exceptions.h"

-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 #	define pdo_mysql_init(persistent) mysqlnd_init(persistent)
 #else
 #	define pdo_mysql_init(persistent) mysql_init(NULL)
@@ -230,7 +230,7 @@

 	if (S->num_params) {
 		S->params_given = 0;
-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 		S->params = NULL;
 #else
 		S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
@@ -433,7 +433,7 @@
 			break;
 		case PDO_ATTR_SERVER_INFO: {
 			char *tmp;
-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 			unsigned int tmp_len;

 			if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
@@ -555,7 +555,7 @@
 #endif
 		;

-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 	int dbname_len = 0;
 	int password_len = 0;
 #endif
@@ -630,7 +630,7 @@
 		{
 			local_infile = 0;
 		}
-#ifdef MYSQL_OPT_LOCAL_INFILE
+#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
 		if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
 			pdo_mysql_error(dbh);
 			goto cleanup;
@@ -638,7 +638,9 @@
 #endif
 #ifdef MYSQL_OPT_RECONNECT
 		/* since 5.0.3, the default for this option is 0 if not specified.
-		 * we want the old behaviour */
+		 * we want the old behaviour
+		 * mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
+		*/
 		{
 			long reconnect = 1;
 			mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);

Modified: php/php-src/trunk/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:35:17 UTC (rev 316038)
+++ php/php-src/trunk/ext/pdo_mysql/mysql_driver.c	2011-09-02 13:53:41 UTC (rev 316039)
@@ -36,7 +36,7 @@
 #endif
 #include "zend_exceptions.h"

-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 #	define pdo_mysql_init(persistent) mysqlnd_init(persistent)
 #else
 #	define pdo_mysql_init(persistent) mysql_init(NULL)
@@ -230,7 +230,7 @@

 	if (S->num_params) {
 		S->params_given = 0;
-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 		S->params = NULL;
 #else
 		S->params = ecalloc(S->num_params, sizeof(MYSQL_BIND));
@@ -433,7 +433,7 @@
 			break;
 		case PDO_ATTR_SERVER_INFO: {
 			char *tmp;
-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 			unsigned int tmp_len;

 			if (mysqlnd_stat(H->server, &tmp, &tmp_len) == PASS) {
@@ -555,7 +555,7 @@
 #endif
 		;

-#if PDO_USE_MYSQLND
+#if defined(PDO_USE_MYSQLND)
 	int dbname_len = 0;
 	int password_len = 0;
 #endif
@@ -630,7 +630,7 @@
 		{
 			local_infile = 0;
 		}
-#ifdef MYSQL_OPT_LOCAL_INFILE
+#if defined(MYSQL_OPT_LOCAL_INFILE) || defined(PDO_USE_MYSQLND)
 		if (mysql_options(H->server, MYSQL_OPT_LOCAL_INFILE, (const char *)&local_infile)) {
 			pdo_mysql_error(dbh);
 			goto cleanup;
@@ -638,7 +638,9 @@
 #endif
 #ifdef MYSQL_OPT_RECONNECT
 		/* since 5.0.3, the default for this option is 0 if not specified.
-		 * we want the old behaviour */
+		 * we want the old behaviour
+		 * mysqlnd doesn't support reconnect, thus we don't have "|| defined(PDO_USE_MYSQLND)"
+		*/
 		{
 			long reconnect = 1;
 			mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to