server mode. (Gustavo)
- PDO MySQL driver:
+ . Implemented FR #47802 (Support for setting character sets in DSN strings).
+ (Kalle)
. Fixed bug #53551 (PDOStatement execute segfaults for pdo_mysql driver).
(Johannes)
#endif
}
+#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;
+ }
+#endif
+
dbname = vars[1].optval;
host = vars[2].optval;
if(vars[3].optval) {
# define PDO_MYSQL_PARAM_BIND MYSQL_BIND
#endif
+#if (MYSQL_VERSION_ID >= 40113 && MYSQL_VERSION_ID < 50000) || MYSQL_VERSION_ID >= 50007 || defined(MYSQL_USE_MYSQLND)
+# define PDO_MYSQL_HAS_CHARSET
+#endif
+
#if defined(PDO_USE_MYSQLND) && PHP_DEBUG && !defined(PHP_WIN32)
#define PDO_DBG_ENABLED 1
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');
--- /dev/null
+--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