MYSQLI_FETCH_RESOURCE_CONN(mysql, mysql_link, MYSQLI_STATUS_VALID);
if (mysql_set_character_set(mysql->mysql, cs_name)) {
+ MYSQLI_REPORT_MYSQL_ERROR(mysql->mysql);
RETURN_FALSE;
}
RETURN_TRUE;
}
mysqli_free_result($res);
+ // Make sure that set_charset throws an exception in exception mode
+ mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
+ try {
+ $link->set_charset('invalid');
+ } catch (\mysqli_sql_exception $exception) {
+ echo "Exception: " . $exception->getMessage() . "\n";
+ }
+
+ try {
+ $link->set_charset('ucs2');
+ } catch (\mysqli_sql_exception $exception) {
+ echo "Exception: " . $exception->getMessage() . "\n";
+ }
+
mysqli_close($link);
try {
<?php
require_once("clean_table.inc");
?>
---EXPECT--
+--EXPECTF--
+Exception: %s
+Exception: Variable 'character_set_client' can't be set to the value of 'ucs2'
mysqli object is already closed
done!
DBG_INF_FMT("conn=%llu cs=%s", conn->thread_id, csname);
if (!charset) {
- SET_CLIENT_ERROR(conn->error_info, CR_CANT_FIND_CHARSET, UNKNOWN_SQLSTATE,
- "Invalid characterset or character set not supported");
+ SET_CLIENT_ERROR(conn->error_info, CR_CANT_FIND_CHARSET, UNKNOWN_SQLSTATE, "Invalid character set was provided");
DBG_RETURN(ret);
}
char * query;
size_t query_len = mnd_sprintf(&query, 0, "SET NAMES %s", csname);
- if (FAIL == (ret = conn->m->query(conn, query, query_len))) {
- php_error_docref(NULL, E_WARNING, "Error executing query");
- } else if (conn->error_info->error_no) {
+ if (FAIL == (ret = conn->m->query(conn, query, query_len)) || conn->error_info->error_no) {
ret = FAIL;
} else {
conn->charset = charset;