mysqli: use native api

Tested with:
* mysql-5.6.49-linux-glibc2.12-x86_64
* mysql-5.7.31-linux-glibc2.12-x86_64
* mysql-8.0.21-linux-glibc2.17-x86_64
* mariadb-10.5.6

configure --with-mysqli=/usr/local/$version/bin/mysql_config   --with-pdo-mysql=/usr/local/$version

MySQL-8.0 removed my_bool
Some options where deprecated in mysql-8.0

MY_CHARSET_INFO used with exposed api mysql_get_character_set_info
rather than internal structures.
This commit is contained in:
Daniel Black 2020-08-29 17:18:57 +10:00 committed by Nikita Popov
parent efc52f1754
commit 202a0697f3
3 changed files with 10 additions and 17 deletions

View File

@ -614,7 +614,7 @@ PHP_FUNCTION(mysqli_change_user)
size_t user_len, password_len, dbname_len;
zend_ulong rc;
#if !defined(MYSQLI_USE_MYSQLND) && defined(HAVE_MYSQLI_SET_CHARSET)
const CHARSET_INFO * old_charset;
MY_CHARSET_INFO old_charset;
#endif
if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Osss!", &mysql_link, mysqli_link_class_entry, &user, &user_len, &password, &password_len, &dbname, &dbname_len) == FAILURE) {
@ -623,7 +623,7 @@ PHP_FUNCTION(mysqli_change_user)
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;
mysql_get_character_set_info(mysql->mysql, &old_charset);
#endif
#if defined(MYSQLI_USE_MYSQLND)
@ -643,7 +643,7 @@ PHP_FUNCTION(mysqli_change_user)
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);
rc = mysql_set_character_set(mysql->mysql, old_charset.csname);
}
#endif
@ -1716,10 +1716,12 @@ static int mysqli_options_get_option_zval_type(int option)
#endif /* MySQL 4.1.0 */
case MYSQL_OPT_READ_TIMEOUT:
case MYSQL_OPT_WRITE_TIMEOUT:
#ifdef MYSQL_OPT_GUESS_CONNECTION /* removed in MySQL-8.0 */
case MYSQL_OPT_GUESS_CONNECTION:
case MYSQL_OPT_USE_EMBEDDED_CONNECTION:
case MYSQL_OPT_USE_REMOTE_CONNECTION:
case MYSQL_SECURE_AUTH:
#endif
#ifdef MYSQL_OPT_RECONNECT
case MYSQL_OPT_RECONNECT:
#endif /* MySQL 5.0.13 */

View File

@ -303,7 +303,8 @@ void mysqli_common_connect(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_real_conne
php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql));
#if !defined(MYSQLI_USE_MYSQLND)
mysql->mysql->reconnect = MyG(reconnect);
char reconnect = MyG(reconnect);
mysql_options(mysql->mysql, MYSQL_OPT_RECONNECT, (char *)&reconnect);
#endif
unsigned int allow_local_infile = MyG(allow_local_infile);
mysql_options(mysql->mysql, MYSQL_OPT_LOCAL_INFILE, (char *)&allow_local_infile);

View File

@ -58,8 +58,6 @@
#define HAVE_ULONG
#endif
#include <my_global.h>
#if !defined(HAVE_MBRLEN) && defined(WE_HAD_MBRLEN)
#define HAVE_MBRLEN 1
#endif
@ -68,20 +66,12 @@
#define HAVE_MBSTATE_T 1
#endif
/*
We need more than mysql.h because we need CHARSET_INFO in one place.
This order has been borrowed from the ODBC driver. Nothing can be removed
from the list of headers :(
*/
#include <my_sys.h>
#include <mysql.h>
#ifndef my_bool
typedef char my_bool;
#endif
#include <errmsg.h>
#include <my_list.h>
#include <m_string.h>
#include <mysqld_error.h>
#include <my_list.h>
#include <m_ctype.h>
#include "mysqli_libmysql.h"
#endif /* MYSQLI_USE_MYSQLND */