uw                                       Tue, 22 Sep 2009 15:31:35 +0000

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

Log:
mysqlnd supports INIT_COMMAND and so we can add it to PDO_MYSQL @ mysqlnd

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c
    U   php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h
    U   
php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
    U   php/php-src/trunk/ext/pdo_mysql/mysql_driver.c
    U   php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c
    U   php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h
    U   php/php-src/trunk/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt

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	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/mysql_driver.c	2009-09-22 15:31:35 UTC (rev 288583)
@@ -620,8 +620,9 @@
 	if (driver_options) {
 		long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
 		long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
+		char *init_cmd = NULL;
 #ifndef PDO_USE_MYSQLND
-		char *init_cmd = NULL, *default_file = NULL, *default_group = NULL;
+		char *default_file = NULL, *default_group = NULL;
 		long compress = 0;
 #endif
 		H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@@ -670,7 +671,6 @@
 			mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
 		}
 #endif
-#ifndef PDO_USE_MYSQLND
 		init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC);
 		if (init_cmd) {
 			if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
@@ -680,7 +680,7 @@
 			}
 			efree(init_cmd);
 		}
-
+#ifndef PDO_USE_MYSQLND
 		default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC);
 		if (default_file) {
 			if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/pdo_mysql.c	2009-09-22 15:31:35 UTC (rev 288583)
@@ -75,9 +75,9 @@

 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);
+	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
 #ifndef PDO_USE_MYSQLND
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
-	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/php_pdo_mysql_int.h	2009-09-22 15:31:35 UTC (rev 288583)
@@ -153,8 +153,8 @@
 enum {
 	PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
 	PDO_MYSQL_ATTR_LOCAL_INFILE,
+	PDO_MYSQL_ATTR_INIT_COMMAND,
 #ifndef PDO_USE_MYSQLND
-	PDO_MYSQL_ATTR_INIT_COMMAND,
 	PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
 	PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
 	PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,

Modified: php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/branches/PHP_5_3/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt	2009-09-22 15:31:35 UTC (rev 288583)
@@ -6,8 +6,6 @@
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
 MySQLPDOTest::skip();
 $db = MySQLPDOTest::factory();
-if (MySQLPDOTest::isPDOMySQLnd())
-	die("skip PDO::MYSQL_ATTR_MAX_INIT_COMMAND not supported with mysqlnd");
 ?>
 --INI--
 error_reporting=E_ALL
@@ -27,7 +25,8 @@
 	var_dump($create);
 	$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));

-	var_dump($db->errorInfo());
+	$info = $db->errorInfo();
+	var_dump($info[0]);

 	$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
 	$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
@@ -35,22 +34,14 @@

 	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
 	print "done!\n";
-?>
 --EXPECTF--
-string(58) "CREATE TABLE test_%s(id INT)"
-array(3) {
-  [0]=>
-  string(5) "00000"
-  [1]=>
-  NULL
-  [2]=>
-  NULL
-}
+%unicode|string%(58) "CREATE TABLE test_%s(id INT)"
+%unicode|string%(5) "00000"
 array(1) {
   [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
 }
 done!

Modified: php/php-src/trunk/ext/pdo_mysql/mysql_driver.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/mysql_driver.c	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/trunk/ext/pdo_mysql/mysql_driver.c	2009-09-22 15:31:35 UTC (rev 288583)
@@ -621,8 +621,9 @@
 	if (driver_options) {
 		long connect_timeout = pdo_attr_lval(driver_options, PDO_ATTR_TIMEOUT, 30 TSRMLS_CC);
 		long local_infile = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_LOCAL_INFILE, 0 TSRMLS_CC);
+		char *init_cmd = NULL;
 #ifndef PDO_USE_MYSQLND
-		char *init_cmd = NULL, *default_file = NULL, *default_group = NULL;
+		char *default_file = NULL, *default_group = NULL;
 		long compress = 0;
 #endif
 		H->buffered = pdo_attr_lval(driver_options, PDO_MYSQL_ATTR_USE_BUFFERED_QUERY, 1 TSRMLS_CC);
@@ -671,7 +672,6 @@
 			mysql_options(H->server, MYSQL_OPT_RECONNECT, (const char*)&reconnect);
 		}
 #endif
-#ifndef PDO_USE_MYSQLND
 		init_cmd = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_INIT_COMMAND, NULL TSRMLS_CC);
 		if (init_cmd) {
 			if (mysql_options(H->server, MYSQL_INIT_COMMAND, (const char *)init_cmd)) {
@@ -681,7 +681,7 @@
 			}
 			efree(init_cmd);
 		}
-
+#ifndef PDO_USE_MYSQLND
 		default_file = pdo_attr_strval(driver_options, PDO_MYSQL_ATTR_READ_DEFAULT_FILE, NULL TSRMLS_CC);
 		if (default_file) {
 			if (mysql_options(H->server, MYSQL_READ_DEFAULT_FILE, (const char *)default_file)) {

Modified: php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/trunk/ext/pdo_mysql/pdo_mysql.c	2009-09-22 15:31:35 UTC (rev 288583)
@@ -75,9 +75,9 @@

 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);
+	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
 #ifndef PDO_USE_MYSQLND
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_MAX_BUFFER_SIZE", (long)PDO_MYSQL_ATTR_MAX_BUFFER_SIZE);
-	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_FILE", (long)PDO_MYSQL_ATTR_READ_DEFAULT_FILE);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_READ_DEFAULT_GROUP", (long)PDO_MYSQL_ATTR_READ_DEFAULT_GROUP);
 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_COMPRESS", (long)PDO_MYSQL_ATTR_COMPRESS);

Modified: php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/trunk/ext/pdo_mysql/php_pdo_mysql_int.h	2009-09-22 15:31:35 UTC (rev 288583)
@@ -153,8 +153,8 @@
 enum {
 	PDO_MYSQL_ATTR_USE_BUFFERED_QUERY = PDO_ATTR_DRIVER_SPECIFIC,
 	PDO_MYSQL_ATTR_LOCAL_INFILE,
+	PDO_MYSQL_ATTR_INIT_COMMAND,
 #ifndef PDO_USE_MYSQLND
-	PDO_MYSQL_ATTR_INIT_COMMAND,
 	PDO_MYSQL_ATTR_READ_DEFAULT_FILE,
 	PDO_MYSQL_ATTR_READ_DEFAULT_GROUP,
 	PDO_MYSQL_ATTR_MAX_BUFFER_SIZE,

Modified: php/php-src/trunk/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt
===================================================================
--- php/php-src/trunk/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt	2009-09-22 15:16:42 UTC (rev 288582)
+++ php/php-src/trunk/ext/pdo_mysql/tests/pdo_mysql_attr_init_command.phpt	2009-09-22 15:31:35 UTC (rev 288583)
@@ -6,8 +6,6 @@
 require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
 MySQLPDOTest::skip();
 $db = MySQLPDOTest::factory();
-if (MySQLPDOTest::isPDOMySQLnd())
-	die("skip PDO::MYSQL_ATTR_MAX_INIT_COMMAND not supported with mysqlnd");
 ?>
 --INI--
 error_reporting=E_ALL
@@ -27,7 +25,8 @@
 	var_dump($create);
 	$db = new PDO($dsn, $user, $pass, array(PDO::MYSQL_ATTR_INIT_COMMAND => $create));

-	var_dump($db->errorInfo());
+	$info = $db->errorInfo();
+	var_dump($info[0]);

 	$db->exec(sprintf('INSERT INTO %s(id) VALUES (1)', $table));
 	$stmt = $db->query(sprintf('SELECT id FROM %s', $table));
@@ -36,16 +35,13 @@
 	$db->exec(sprintf('DROP TABLE IF EXISTS %s', $table));
 	print "done!\n";
 --EXPECTF--
-string(58) "CREATE TABLE test_%s(id INT)"
+%unicode|string%(58) "CREATE TABLE test_%s(id INT)"
+%unicode|string%(5) "00000"
 array(1) {
   [0]=>
-  string(5) "00000"
-}
-array(1) {
-  [0]=>
   array(1) {
-    ["id"]=>
-    string(1) "1"
+    [%u|b%"id"]=>
+    %unicode|string%(1) "1"
   }
 }
-done!
\ No newline at end of file
+done!
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to