Bug #66621 [Fbk]: PDO::commit() bug

From: Date: Wed, 30 Apr 2014 11:47:59 +0000
Subject: Bug #66621 [Fbk]: PDO::commit() bug
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-185517@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=66621&edit=1

 ID:                 66621
 Updated by:         ab@php.net
 Reported by:        enrico_kaelert at kabelmail dot de
 Summary:            PDO::commit() bug
 Status:             Feedback
 Type:               Bug
 Package:            PDO MySQL
 Operating System:   Windows 7 64bit
 PHP Version:        Irrelevant
 Assigned To:        ab
 Block user comment: N
 Private report:     N

 New Comment:

Johannes, thanks for looking in. As far as I could debug by now, the behaviour is reproduceable.
But, only if mysqld runs on windows. When I point the snippet from April 24th to a DB running under
Linux, the error disappears. Strange enough, but seems to have to do with mysqld+platform itself or
its configs.

Additionally, as far I could debug, the error is caused by something in mysqlnd, namely
mysqlnd.c:320 in simple_command method. There, when asked for the connection status, it appears to
be CONN_NEXT_RESULT_PENDING, so produces an error and no COMMIT. In the backtrace, simple_method is
called from the pdo commit method doing COMMIT query internally. That's all I have at the
moment, so digging deeper into it. Interestingly, when adding CONN_NEXT_RESULT_PENDING to CONN_READY
case, it seems to pass. But I'm entirely not sure it should be so.

Enrico, could you please test whether it works if you use mysqld not on windows? Thanks.


Previous Comments:
------------------------------------------------------------------------
[2014-04-29 15:07:30] enrico_kaelert at kabelmail dot de

edit:
try this:

change the query in the test script to: 
# 3. multi insert via beginTransaction() and commit() / rollBack()
(...)
$sql = "
    -- this is my pretty commented query ...
    -- above comments works
    INSERT INTO
        testdb.tbl
    SET
        name = 'a' -- middle comment works
        -- name = 'a' middle new line comments works
    ; -- but this comment finally f* it up
    -- so simple nothing is allowed after the ;
    -- except if we destroy the stmt
";

------------------------------------------------------------------------
[2014-04-29 14:51:50] enrico_kaelert at kabelmail dot de

@johannes
Which $type you used?
And did you looked into the db to make sure the entries really exists?

@all
btw: something new:
I found out that:
- if you use only 1 INSERT INTO in the query
- and if you add comments to the query 
then the same effect happen: no INSERT made.

So change the query in the test script to: 
# 3. multi insert via beginTransaction() and commit() / rollBack()
(...)
$sql = "
    INSERT INTO testdb.tbl SET name = 'a'; -- this
is my comment
    -- this is a new line comment
";
(...)

Delete the test table if exists and use the $type "regular".
This is only 1 INSERT INTO and should work.
But it doesnt because of the comments(?).

BUT it will work if we destroy the $stmt (by using the $type "alternative").

------------------------------------------------------------------------
[2014-04-29 09:38:32] johannes@php.net

With the ode from 2014-04-24 12:25 UTC I get this result:

Array
(
    [0] => Array
        (
            [id] => 1
            [name] => a
        )

    [1] => Array
        (
            [id] => 2
            [name] => b
        )

    [2] => Array
        (
            [id] => 3
            [name] => c
        )

)

This seems right to me. I tried a handful combinations of MySQL servers & PHP versions. Not on
windows, though (while I can't imagine something Windows specific to be the case)

------------------------------------------------------------------------
[2014-04-24 14:05:31] ab@php.net

Enrico,

don't get me wrong, but brevity is wit. The script is still too excessive, but the explanation
in your latest pastebin is much better, even for such a dull person like me. Lets see.

Thanks

------------------------------------------------------------------------
[2014-04-24 12:25:49] enrico_kaelert at kabelmail dot de

Sorry, but i cant reduce that test script to 20 lines.
I dont wanna wast your or my time.
But i wrote it again as simple as possible: explanation and script at once.

http://pastebin.com/wt2DiNNB
If you dont understand what im doing there .. well, then sorry, i wont do more.
What you do if somebody wants to report a huge security bug? In 20 lines? 
Well, ... . Please dont get me wrong, but you need to spend a bit time to bug reports.

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=66621


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


Thread (15 messages)

« previous php.bugs (#185517) next »