|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-06-15 15:06 UTC] webart dot video at gmail dot com
Description:
------------
PHP Information:
PHP 7.0.7-4+deb.sury.org~trusty+1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
with blackfire v1.10.6, https://blackfire.io, by Blackfireio Inc.
Pretty simple, using $mysqli->prepare($query) crashes the server with the message
"mysqli_stmt::__construct(): Unknown type 18 sent by the server. Please send a report to the developers"
Test script:
---------------
https://gist.github.com/NoMan2000/0ee7fbf41f69a7ae4cdc555241e2e5f6
Refer bug: https://bugs.php.net/bug.php?id=72041&edit=1
The difference is that user is using PDO, I'm using mysqli, but the underlying cause seems to be the same.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 19 16:00:01 2025 UTC |
Hi, can you tell us what MySQL version you are using and could you produce a bit minimal script that generates the error and the crash. I tried myself with 7.0 and 7.1 but no crash. Here is my table: mysql> create table dt(a datetime(6)); Query OK, 0 rows affected (0,01 sec) mysql> insert into dt values ('2014-09-08 17:51:04.123456'); Query OK, 1 row affected (0,01 sec) mysql> select * from dt; +----------------------------+ | a | +----------------------------+ | 2014-09-08 17:51:04.123456 | +----------------------------+ 1 row in set (0,00 sec) Then on the command line: andrey@poohie:/work/dev/php/php-7.0$ ./php -r '$c=mysqli_connect("127.0.0.1","root","","test"); $s=$c->prepare("select * from dt"); $s->execute();var_dump($s->get_result()->fetch_all());' array(1) { [0]=> array(1) { [0]=> string(19) "2014-09-08 17:51:04" } } And in wireshark I see that FIELD_DATETIME (12) is sent over the wire. Type 18 is DATETIME2, which is DATETIME with microseconds. However, mysqlnd here doesn't see the microseconds as DATETIME is sent. I am curious what triggered the server to send the microseconds and the new type. This is why I would like to see a shorter example of your code that is self contained (or is one small PHP and one small SQL dump file). Thank you very much in advance! AndreyHi, I am able to reproduce with the following: <?php /* CREATE TABLE `type18` ( `tripDay` datetime NOT NULL, KEY `entity_index` (`tripDay`), KEY `day_index` (`tripDay`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `type18` VALUES ('2014-04-03 00:00:00'); */ $foo = mysqli_connect('127.0.0.1', 'root', '', 'test'); $query = "(SELECT DATE_FORMAT(DATE_ADD(MAKEDATE(YEAR(tripDay), 1), INTERVAL MONTH(tripDay) - 1 MONTH),'%c/%e/%y'), tripDay FROM type18 ORDER BY YEAR(tripDay)) ORDER BY YEAR(tripDay)"; $foo->query("set sql_mode=''"); $x = $foo->prepare($query); var_dump($foo->error); ?>Even shorter one: <?php /* CREATE TABLE `type18` ( `tripDay` datetime NOT NULL ) ENGINE=InnoDB; INSERT INTO `type18` VALUES ('2014-04-03 00:00:00'); */ $conn = mysqli_connect('127.0.0.1', 'root', '', 'test'); $conn->query("set sql_mode=''"); $sql = "(SELECT tripDay FROM type18 ORDER BY YEAR(tripDay)) ORDER BY YEAR(tripDay)"; $stmt = $conn->prepare($sql); var_dump($stmt, $conn->error); ?>