--- /dev/null
+--TEST--
+mysqli_float_handling - ensure 4 byte float is handled correctly
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('skipifconnectfailure.inc');
+ if (@$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ if ($link->server_version < 50709) {
+ die("skip MySQL 5.7.9+ needed. Found [".
+ intval(substr($link->server_version."", -5, 1)).
+ ".".
+ intval(substr($link->server_version."", -4, 2)).
+ ".".
+ intval(substr($link->server_version."", -2, 2)).
+ "]");
+ }
+ }
+?>
+--FILE--
+<?php
+ require('connect.inc');
+ if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ die();
+ }
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ if (!mysqli_query($link, "CREATE TABLE test(jsfield JSON) ENGINE = InnoDB")) {
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+ $jsfield_data = '{"aaa": 123}';
+ // Insert via string to make sure the real floating number gets to the DB
+ if (!mysqli_query($link, "INSERT INTO test VALUES ('".$jsfield_data."')")) {
+ printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+
+ if (!($res = mysqli_query($link, "SELECT * FROM test"))) {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ die();
+ }
+ $rows = $res->fetch_all();
+ if (json_encode($rows[0][0]) != json_encode($jsfield_data)) {
+ printf("[006] Data differs");
+ var_dump(json_encode($rows[0][0]) != json_encode($jsfield_data));
+ die();
+ }
+ mysqli_close($link);
+ echo "OK";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+OK
\ No newline at end of file
mysqli_close($link);
?>
--EXPECTF--
-array(160) {
+array(161) {
[%u|b%"bytes_sent"]=>
%unicode|string%(1) "0"
[%u|b%"bytes_received"]=>
%unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_string"]=>
%unicode|string%(1) "0"
+ [%u|b%"proto_binary_fetched_json"]=>
+ %unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_blob"]=>
%unicode|string%(1) "0"
[%u|b%"proto_binary_fetched_enum"]=>
PHPAPI const char *mysqlnd_field_type_name(enum mysqlnd_field_types field_type)
{
switch(field_type) {
+ case FIELD_TYPE_JSON:
+ return "json";
case FIELD_TYPE_STRING:
case FIELD_TYPE_VAR_STRING:
return "string";
MYSQL_TYPE_NEWDATE = 14,
MYSQL_TYPE_VARCHAR = 15,
MYSQL_TYPE_BIT = 16,
+ MYSQL_TYPE_JSON=245,
MYSQL_TYPE_NEWDECIMAL=246,
MYSQL_TYPE_ENUM=247,
MYSQL_TYPE_SET=248,
#define FIELD_TYPE_NEWDATE MYSQL_TYPE_NEWDATE
#define FIELD_TYPE_ENUM MYSQL_TYPE_ENUM
#define FIELD_TYPE_SET MYSQL_TYPE_SET
+#define FIELD_TYPE_JSON MYSQL_TYPE_JSON
#define FIELD_TYPE_TINY_BLOB MYSQL_TYPE_TINY_BLOB
#define FIELD_TYPE_MEDIUM_BLOB MYSQL_TYPE_MEDIUM_BLOB
#define FIELD_TYPE_LONG_BLOB MYSQL_TYPE_LONG_BLOB
STAT_TEXT_TYPE_FETCHED_DATETIME,
STAT_TEXT_TYPE_FETCHED_TIMESTAMP,
STAT_TEXT_TYPE_FETCHED_STRING,
+ STAT_TEXT_TYPE_FETCHED_JSON,
STAT_TEXT_TYPE_FETCHED_BLOB,
STAT_TEXT_TYPE_FETCHED_ENUM,
STAT_TEXT_TYPE_FETCHED_SET,
mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIMESTAMP].php_type= IS_STRING;
mysqlnd_ps_fetch_functions[MYSQL_TYPE_TIMESTAMP].can_ret_as_str_in_uni = TRUE;
+ mysqlnd_ps_fetch_functions[MYSQL_TYPE_JSON].func = ps_fetch_string;
+ mysqlnd_ps_fetch_functions[MYSQL_TYPE_JSON].pack_len= MYSQLND_PS_SKIP_RESULT_STR;
+ mysqlnd_ps_fetch_functions[MYSQL_TYPE_JSON].php_type = IS_STRING;
+ mysqlnd_ps_fetch_functions[MYSQL_TYPE_JSON].is_possibly_blob = TRUE;
+ mysqlnd_ps_fetch_functions[MYSQL_TYPE_JSON].can_ret_as_str_in_uni = TRUE;
+
mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].func = ps_fetch_string;
mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].pack_len= MYSQLND_PS_SKIP_RESULT_STR;
mysqlnd_ps_fetch_functions[MYSQL_TYPE_TINY_BLOB].php_type = IS_STRING;
{ MYSQLND_STR_W_LEN("proto_binary_fetched_datetime") },
{ MYSQLND_STR_W_LEN("proto_binary_fetched_timestamp") },
{ MYSQLND_STR_W_LEN("proto_binary_fetched_string") },
+ { MYSQLND_STR_W_LEN("proto_binary_fetched_json") },
{ MYSQLND_STR_W_LEN("proto_binary_fetched_blob") },
{ MYSQLND_STR_W_LEN("proto_binary_fetched_enum") },
{ MYSQLND_STR_W_LEN("proto_binary_fetched_set") },
case MYSQL_TYPE_NEWDECIMAL: statistic = STAT_TEXT_TYPE_FETCHED_DECIMAL; break;
case MYSQL_TYPE_ENUM: statistic = STAT_TEXT_TYPE_FETCHED_ENUM; break;
case MYSQL_TYPE_SET: statistic = STAT_TEXT_TYPE_FETCHED_SET; break;
+ case MYSQL_TYPE_JSON: statistic = STAT_TEXT_TYPE_FETCHED_JSON; break;
case MYSQL_TYPE_TINY_BLOB: statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_MEDIUM_BLOB:statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;
case MYSQL_TYPE_LONG_BLOB: statistic = STAT_TEXT_TYPE_FETCHED_BLOB; break;