Skip to content

Fix GH-8267: MySQLi uses unsupported format specifier on Windows #8268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions ext/mysqli/php_mysqli_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ typedef struct {

#ifdef PHP_WIN32
#define PHP_MYSQLI_API __declspec(dllexport)
#define MYSQLI_LLU_SPEC "%I64u"
#define MYSQLI_LL_SPEC "%I64d"
#ifndef L64
#define L64(x) x##i64
#endif
Expand All @@ -146,16 +144,17 @@ typedef __int64 my_longlong;
# else
# define PHP_MYSQLI_API
# endif
/* we need this for PRIu64 and PRId64 */
#include <inttypes.h>
#define MYSQLI_LLU_SPEC "%" PRIu64
#define MYSQLI_LL_SPEC "%" PRId64
#ifndef L64
#define L64(x) x##LL
#endif
typedef int64_t my_longlong;
#endif

/* we need this for PRIu64 and PRId64 */
#include <inttypes.h>
#define MYSQLI_LLU_SPEC "%" PRIu64
#define MYSQLI_LL_SPEC "%" PRId64

#ifdef ZTS
#include "TSRM.h"
#endif
Expand Down
22 changes: 22 additions & 0 deletions ext/mysqli/tests/gh8267.phpt
Original file line number Diff line number Diff line change
@@ -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"