diff options
author | Andrey Hristov <andrey@php.net> | 2010-06-14 18:19:13 +0000 |
---|---|---|
committer | Andrey Hristov <andrey@php.net> | 2010-06-14 18:19:13 +0000 |
commit | 4637e3641f2bfd74fe34df1e2a0a33a9da531369 (patch) | |
tree | 89fe59fa8c5ed31a8ced15abd4714a7388c49f31 /ext/mysqli/mysqli_api.c | |
parent | 65b1895759cb5eccf53845b703fb21c2919d9f6b (diff) | |
download | php-git-4637e3641f2bfd74fe34df1e2a0a33a9da531369.tar.gz |
And a fix for MySQL Server which is pre 5.1.23, which doesn't support
preserving of the charset when performing change_user. This is libmysql
only code.
Diffstat (limited to 'ext/mysqli/mysqli_api.c')
-rw-r--r-- | ext/mysqli/mysqli_api.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/mysqli/mysqli_api.c b/ext/mysqli/mysqli_api.c index fc3a72e49b..bb19f665ce 100644 --- a/ext/mysqli/mysqli_api.c +++ b/ext/mysqli/mysqli_api.c @@ -521,18 +521,35 @@ PHP_FUNCTION(mysqli_change_user) char *user, *password, *dbname; int user_len, password_len, dbname_len; ulong rc; +#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET) + const CHARSET_INFO * old_charset; +#endif if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Osss", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) { return; } MYSQLI_FETCH_RESOURCE_CONN(mysql, &mysql_link, MYSQLI_STATUS_VALID); +#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET) + old_charset = mysql->mysql->charset; +#endif + rc = mysql_change_user(mysql->mysql, user, password, dbname); MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql); if (rc) { RETURN_FALSE; } +#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET) + if (mysql_get_server_version(mysql->mysql) < 501023L) { + /* + Request the current charset, or it will be reset to the system one. + 5.0 doesn't support it. Support added in 5.1.23 by fixing the following bug : + Bug #30472 libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call + */ + rc = mysql_set_character_set(mysql->mysql, old_charset->csname); + } +#endif RETURN_TRUE; } |