Bug #80924 [NEW]: PDO: Begin transaction plus lock table fail

From: Date: Wed, 31 Mar 2021 20:20:55 +0000
Subject: Bug #80924 [NEW]: PDO: Begin transaction plus lock table fail
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-233109@lists.php.net to get a copy of this message
From:             pau dot ferran dot grau at gmail dot com
Operating system: All
PHP version:      8.0.3
Package:          PDO MySQL
Bug Type:         Bug
Bug description:PDO: Begin transaction plus lock table fail

Description:
------------
when I begin a transaction and I try lock a table then pdo throw the
exception with the message: There is no active transaction.


I use a MySQL 5.7.20

Test script:
---------------
try {
    $dbh =  new
\PDO('mysql:host=127.0.0.1;port=3309;dbname=event_sourcing_test',
'root', null);
    $dbh->beginTransaction();

    $dbh->exec('LOCK TABLE test WRITE');
    $dbh->exec("INSERT INTO test (id) VALUES ('a')");

    $dbh->commit();

    $dbh->exec('UNLOCK TABLES');

} catch (\PDOException $e) {
    
    echo $e->getMessage() . PHP_EOL; //There is no active transaction
}


Expected result:
----------------
Pdo doesn't throw an exception

Actual result:
--------------
Pdo throws an exception

PDOException Object
(
    [message:protected] => There is no active transaction
    [string:Exception:private] =>
    [code:protected] => 0
    [file:protected] =>
/Users/pau/Projects/apps/event-sourcing/test.php
    [line:protected] => 10
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] =>
/Users/pau/Projects/apps/event-sourcing/test.php
                    [line] => 10
                    [function] => commit
                    [class] => PDO
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

        )

    [previous:Exception:private] =>
    [errorInfo] =>
)

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


Thread (6 messages)

« previous php.bugs (#233109) next »