Bug #79872 [NEW]: Semantic Language inconsistency when using commit and 2 statements.

From: Date: Sat, 18 Jul 2020 13:46:49 +0000
Subject: Bug #79872 [NEW]: Semantic Language inconsistency when using commit and 2 statements.
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228108@lists.php.net to get a copy of this message
From:             drakain at statagroup dot com
Operating system: Linux
PHP version:      master-Git-2020-07-18 (Git)
Package:          PDO MySQL
Bug Type:         Bug
Bug description:Semantic Language inconsistency when using commit and 2 statements.

Description:
------------
Hypothetically there is no difference between what these two examples do
(except for the introduction of a variable).

ex1. 

    $statement = $connection->prepare($sql);
    $statement->execute();

ex2. 

    $connection->prepare($sql)->execute();

In practice, the first example fails under specific and reproducible
conditions.

Test script:
---------------
I've created a full demonstration of the issue on github using PHP
docker images.

https://github.com/Incognito/php-pdo_mysql-defect-evidence





$connection = new PDO('mysql:host=db;port=3306;dbname=mysql', 'root',
'example', []);

$connection->prepare('DROP TABLE IF EXISTS pdo_bug_test;')->execute();
$connection->prepare('CREATE TABLE pdo_bug_test (value1 VARCHAR(10),
value2 INT);')->execute();

$connection->beginTransaction();
$sql = 'INSERT INTO pdo_bug_test (value1, value2) VALUES (1, 2);';
$sql .= 'INSERT INTO pdo_bug_test (value1, value2) VALUES (3, 4);';
$statement = $connection->prepare($sql); $statement->execute();
$result = $connection->commit();

Expected result:
----------------
I expect the two examples to work exactly the same. In practice this
difference is introduced on versions of PHP which contain commit
51cdd3dc50af88461d83aec0fac1dca83400b58f .

This means 5.6 works the same for both examples. However, 7.0.23, 7.1.9,
and 7.2.0 are the releases that introduce this change in the git tree.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=79872&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79872&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79872&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79872&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79872&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79872&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79872&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79872&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79872&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79872&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79872&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79872&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79872&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79872&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79872&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79872&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79872&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79872&r=mysqlcfg


Thread (6 messages)

« previous php.bugs (#228108) next »