mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix GH-8267: MySQLi uses unsupported format specifier on Windows
Instead of using the unsupported `%I64u` and `%I64d` format specifiers on Windows, we use the portable `PRIu64` and `PRId64` specifiers. The `L64()` macro and the `my_longlong` typedef should be adapted as well, as the `i64` literal suffix is still supported by MSVC, but using `LL` or `ll` is recommended[1], and the standard `int64_t` is available there anyway. This is not urgent, though. [1] <https://docs.microsoft.com/en-us/cpp/cpp/numeric-boolean-and-pointer-literals-cpp?view=msvc-170#integer-literals> Closes GH-8268.
This commit is contained in:
parent
7aefee1613
commit
7c702b72f2
3 changed files with 31 additions and 7 deletions
5
NEWS
5
NEWS
|
@ -3,10 +3,13 @@ PHP NEWS
|
||||||
?? ??? 2022, PHP 8.0.19
|
?? ??? 2022, PHP 8.0.19
|
||||||
|
|
||||||
- Core:
|
- Core:
|
||||||
|
|
||||||
. Fixed bug GH-8289 (Exceptions thrown within a yielded from iterator are
|
. Fixed bug GH-8289 (Exceptions thrown within a yielded from iterator are
|
||||||
not rethrown into the generator). (Bob)
|
not rethrown into the generator). (Bob)
|
||||||
|
|
||||||
|
- MySQLi:
|
||||||
|
. Fixed bug GH-8267 (MySQLi uses unsupported format specifier on Windows).
|
||||||
|
(cmb)
|
||||||
|
|
||||||
14 Apr 2022, PHP 8.0.18
|
14 Apr 2022, PHP 8.0.18
|
||||||
|
|
||||||
- Core:
|
- Core:
|
||||||
|
|
|
@ -134,8 +134,6 @@ typedef struct {
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
#define PHP_MYSQLI_API __declspec(dllexport)
|
#define PHP_MYSQLI_API __declspec(dllexport)
|
||||||
#define MYSQLI_LLU_SPEC "%I64u"
|
|
||||||
#define MYSQLI_LL_SPEC "%I64d"
|
|
||||||
#ifndef L64
|
#ifndef L64
|
||||||
#define L64(x) x##i64
|
#define L64(x) x##i64
|
||||||
#endif
|
#endif
|
||||||
|
@ -146,16 +144,17 @@ typedef __int64 my_longlong;
|
||||||
# else
|
# else
|
||||||
# define PHP_MYSQLI_API
|
# define PHP_MYSQLI_API
|
||||||
# endif
|
# endif
|
||||||
/* we need this for PRIu64 and PRId64 */
|
|
||||||
#include <inttypes.h>
|
|
||||||
#define MYSQLI_LLU_SPEC "%" PRIu64
|
|
||||||
#define MYSQLI_LL_SPEC "%" PRId64
|
|
||||||
#ifndef L64
|
#ifndef L64
|
||||||
#define L64(x) x##LL
|
#define L64(x) x##LL
|
||||||
#endif
|
#endif
|
||||||
typedef int64_t my_longlong;
|
typedef int64_t my_longlong;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* we need this for PRIu64 and PRId64 */
|
||||||
|
#include <inttypes.h>
|
||||||
|
#define MYSQLI_LLU_SPEC "%" PRIu64
|
||||||
|
#define MYSQLI_LL_SPEC "%" PRId64
|
||||||
|
|
||||||
#ifdef ZTS
|
#ifdef ZTS
|
||||||
#include "TSRM.h"
|
#include "TSRM.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
22
ext/mysqli/tests/gh8267.phpt
Normal file
22
ext/mysqli/tests/gh8267.phpt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
--TEST--
|
||||||
|
Bug GH-8267 (MySQLi uses unsupported format specifier on Windows)
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
require_once("skipif.inc");
|
||||||
|
require_once("skipifconnectfailure.inc");
|
||||||
|
?>
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require_once("connect.inc");
|
||||||
|
|
||||||
|
$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
|
||||||
|
$mysqli->query("DROP TABLE IF EXISTS foo");
|
||||||
|
$mysqli->query("CREATE TABLE foo (id BIGINT UNSIGNED AUTO_INCREMENT, PRIMARY KEY (id))");
|
||||||
|
$mysqli->query("INSERT INTO foo VALUES (9223372036854775807)");
|
||||||
|
var_dump($mysqli->insert_id);
|
||||||
|
$mysqli->query("INSERT INTO foo VALUES (0)");
|
||||||
|
var_dump($mysqli->insert_id);
|
||||||
|
?>
|
||||||
|
--EXPECT--
|
||||||
|
string(19) "9223372036854775807"
|
||||||
|
string(19) "9223372036854775808"
|
Loading…
Add table
Add a link
Reference in a new issue