Bug #72416 [Fbk->Asn]: mysqli_stmt::__construct(): Unknown type 18 sent by the server.

From: Date: Tue, 21 Jun 2016 15:44:13 +0000
Subject: Bug #72416 [Fbk->Asn]: mysqli_stmt::__construct(): Unknown type 18 sent by the server.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-201773@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72416&edit=1

 ID:                 72416
 User updated by:    webart dot video at gmail dot com
 Reported by:        webart dot video at gmail dot com
 Summary:            mysqli_stmt::__construct(): Unknown type 18 sent by
                     the server.
-Status:             Feedback
+Status:             Assigned
 Type:               Bug
 Package:            MySQLi related
 Operating System:   Ubuntu 14.04 LTS
 PHP Version:        7.0.7
 Assigned To:        mysql
 Block user comment: N
 Private report:     N

 New Comment:

Hey Andrey, 

Check my gist:  

https://gist.github.com/NoMan2000/0ee7fbf41f69a7ae4cdc555241e2e5f6

Has create table and select statement syntax and repro steps, and also a non-repro case.  

Tested on Amazon RDS MySQL Databases, one is 5.1, one is 5.7.  Haven't tested with 5.5 and 5.6.


Previous Comments:
------------------------------------------------------------------------
[2016-06-21 14:26:30] andrey@php.net

Here is what the MySQL documenation reads :
"The MYSQL_TYPE_TIME2, MYSQL_TYPE_DATETIME2, and MYSQL_TYPE_TIMESTAMP2) type codes are used
only on the server side. Clients see the MYSQL_TYPE_TIME, MYSQL_TYPE_DATETIME, and
MYSQL_TYPE_TIMESTAMP codes."


TIME2, DATETIME2 and TIMESTAMP2 are 17,18,19 . So it is interesting that you see on the client, as
they should not cross the wire.

------------------------------------------------------------------------
[2016-06-20 17:30:53] andrey@php.net

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!

Andrey

------------------------------------------------------------------------
[2016-06-19 07:00:55] laruence@php.net

5.6 is also affected

------------------------------------------------------------------------
[2016-06-15 15:06:59] 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.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=72416&edit=1


Thread (15 messages)

« previous php.bugs (#201773) next »