]> granicus.if.org Git - php/commitdiff
Added test case for #47802 and fixed macro name after the move to mysql_options()
authorKalle Sommer Nielsen <kalle@php.net>
Fri, 7 Jan 2011 17:18:30 +0000 (17:18 +0000)
committerKalle Sommer Nielsen <kalle@php.net>
Fri, 7 Jan 2011 17:18:30 +0000 (17:18 +0000)
ext/pdo_mysql/mysql_driver.c
ext/pdo_mysql/tests/mysql_pdo_test.inc
ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt [new file with mode: 0644]

index bbf0a2ce0ccedfe29df6a4755fd11d7dc40b4c37..d9718c6f83c601b62c04646a9c560d2842748e77 100755 (executable)
@@ -683,7 +683,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_
 #endif
        }
 
-#ifdef PDO_MYSQL_HAS_CHARSET_X
+#ifdef PDO_MYSQL_HAS_CHARSET
        if (vars[0].optval && mysql_options(H->server, MYSQL_SET_CHARSET_NAME, vars[0].optval)) {
                pdo_mysql_error(dbh);
                goto cleanup;
index 01c4cb9aafb02cc7796a9e969e8725871388a529..a3ffd5b9ccb3879e71c6361c6a07a8b138e47f92 100644 (file)
@@ -4,9 +4,9 @@ require_once(dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc');
 
 class MySQLPDOTest extends PDOTest {
 
-       static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null) {
+       static function factory($classname = 'PDO', $drop_test_tables = false, $myattr = null, $mydsn = null) {
 
-               $dsn    = self::getDSN();
+               $dsn    = self::getDSN($mydsn);
                $user   = PDO_MYSQL_TEST_USER;
                $pass   = PDO_MYSQL_TEST_PASS;
                $attr   = getenv('PDOTEST_ATTR');
diff --git a/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt b/ext/pdo_mysql/tests/pdo_mysql_connect_charset.phpt
new file mode 100644 (file)
index 0000000..b7e6ab4
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--\r
+PDO_MYSQL: Defining a connection charset in the DSN\r
+--SKIPIF--\r
+<?php\r
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');\r
+require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');\r
+MySQLPDOTest::skip();\r
+?>\r
+--FILE--\r
+<?php\r
+       /* TODO: remove this test after fix and enable the BIT test in pdo_mysql_types.phpt again */\r
+       require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');\r
+\r
+       /* Connect to mysql to determine the current charset so we can diffinate it */\r
+       $link           = MySQLPDOTest::factory();\r
+       $charset        = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value;\r
+\r
+       /* Make sure that we don't attempt to set the current character set to make this case useful */\r
+       $new_charset    = ($charset == 'latin1' ? 'ascii' : 'latin1');\r
+\r
+       /* Done with the original connection, create a second link to test the character set being defined */\r
+       unset($link);\r
+\r
+       $link           = MySQLPDOTest::factory('PDO', false, null, Array('charset' => $new_charset));\r
+       $conn_charset   = $link->query("SHOW VARIABLES LIKE 'character_set_connection'")->fetchObject()->value;\r
+\r
+       if ($charset !== $conn_charset) {\r
+               echo "done!\n";\r
+       } else {\r
+               echo "failed!\n";\r
+       }\r
+?>\r
+--EXPECTF--\r
+done!
\ No newline at end of file