php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76386 Prepared Statement formatter truncates fractional seconds from date/time column
Submitted: 2018-05-29 07:29 UTC Modified: 2018-06-15 05:31 UTC
From: info at strongholdmedia dot eu Assigned: ab (profile)
Status: Closed Package: mysql (PECL)
PHP Version: Irrelevant OS: ANY
Private report: No CVE-ID: None
 [2018-05-29 07:29 UTC] info at strongholdmedia dot eu
Description:
------------
The prepared statement codec throws away the "second_part" member of the datetime/timestamp structures using a fixed format string that does not include it.

The attached patch (kindly provided by Joey Smith (github.com/tml)) fixes it in a backwards-compatible manner that doesn't break current behaviour.

HOWEVER it supports only timestamp(6)/datetime(6). So that I attach it only as a reference.

If nothing happens for a while :) I try to figure out how actual metadata is passed to the adapter from the engine, to be able to derive the needed precision.

This is also a duplicate for #67122 but it definitely belongs here.

Test script:
---------------
https://gist.github.com/sndsgd/11234272

Expected result:
----------------
PDO::ATTR_EMULATE_PREPARES = true:
2014-04-23 08:45:36.022588
PDO::ATTR_EMULATE_PREPARES = false:
2014-04-23 08:45:36.022588


Actual result:
--------------
PDO::ATTR_EMULATE_PREPARES = true:
2014-04-23 08:45:36.022588
PDO::ATTR_EMULATE_PREPARES = false:
2014-04-23 08:45:36



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-05-29 15:32 UTC] cmb@php.net
-Package: mysql +Package: PDO MySQL
 [2018-05-29 21:26 UTC] info at strongholdmedia dot eu
-Package: PDO MySQL +Package: mysql
 [2018-05-29 21:26 UTC] info at strongholdmedia dot eu
Please do not switch it back to PDO. It in fact has nothing to do with PDO, except that prepared statements are more commonly used with that.

The trouble is in the "ps_fetch_time" method of "mysqlnd_ps_codec.c" file.

(If you have a more proper place for the mysqlnd extension, please re-assign accordingly.)
 [2018-05-30 10:14 UTC] info at strongholdmedia dot eu
I did manage to find time for it last night. :P
Put together a proper fix and sent a pull request as well.

See https://github.com/php/php-src/pull/3257

Please understand that I have scarce ideas how to mock anything in C, let alone a mysql wire protocol response, it will take some time for me to make a test for it.
 [2018-05-30 10:47 UTC] info at strongholdmedia dot eu
Can't seem to be able to attach the pull request here.
I keep receiving "Failed to retrieve pull request from GitHub".
Any ideas how to solve this?
 [2018-05-30 13:58 UTC] cmb@php.net
> Can't seem to be able to attach the pull request here.

Known issue, see bug #76079.
 [2018-06-02 21:34 UTC] info at strongholdmedia dot eu
Aha. Thanks, good to know.

--

Added test case to the GitHub PR.
Let's hope it will be merged sometime.
 [2018-06-15 05:31 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2018-06-15 05:31 UTC] ab@php.net
The PR was merged.

Thanks!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 02:01:29 2024 UTC