Bug #80949 [NEW]: The transaction is closed when dropping a table but it should not
| From: | lyrixx at lyrixx dot info | Date: | Mon, 12 Apr 2021 10:19:41 +0000 |
| Subject: | Bug #80949 [NEW]: The transaction is closed when dropping a table but it should not | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-233359@lists.php.net to get a copy of this message | ||
From: lyrixx at lyrixx dot info
Operating system: linux
PHP version: 8.0.3
Package: PDO MySQL
Bug Type: Bug
Bug description:The transaction is closed when dropping a table but it should not
Description:
------------
With PDO, when dropping a table, the driver emits a
ROLLBACK, and so
close the transaction. It should not.
I tested it with a raw CLI connection, and it works well.
MySQL Logs
```
210412 10:17:07 77 Connect root@172.21.0.2 as anonymous on rio
77 Query START TRANSACTION
77 Query CREATE TEMPORARY TABLE greg
(
source_input LONGTEXT DEFAULT NULL COLLATE utf8mb4_bin,
INDEX source_input_index (source_input (12) )
)
77 Query DELETE FROM greg
77 Query DROP TABLE greg
77 Query ROLLBACK
77 Quit
```
Note: The following code work well on PHP 7.4
Note2: To enable MySQL Logs at runtime:
```
SET GLOBAL general_log = 'ON';
SET GLOBAL general_log_file = '/var/log/mysql/mysql.log';
```
Test script:
---------------
$conn = new PDO('mysql:dbname=rio;host=database', 'root', 'rio');
$conn->beginTransaction();
$conn->exec(<<<'EOSQL'
CREATE TEMPORARY TABLE greg
(
source_input LONGTEXT DEFAULT NULL COLLATE utf8mb4_bin,
INDEX source_input_index (source_input (12) )
)
EOSQL);
var_dump($conn->inTransaction()); // true
$conn->exec('DELETE FROM greg');
var_dump($conn->inTransaction()); // true
$conn->exec('DROP TABLE greg');
var_dump($conn->inTransaction()); // false, but it should not
$conn->commit(); // Throw an exception because there is not transaction
Expected result:
----------------
bool(true)
bool(true)
bool(true)
Actual result:
--------------
bool(true)
bool(true)
bool(false)
PDOException {#844
#message: "There is no active transaction"
#code: 0
#file: "./test.php"
#line: 44
+errorInfo: null
trace: {
./test.php:44 {
⺠var_dump($conn->inTransaction());
⺠$conn->commit();
âº
}
}
}
--
Edit bug report at https://bugs.php.net/bug.php?id=80949&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80949&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80949&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80949&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80949&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80949&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80949&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80949&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80949&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80949&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80949&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80949&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80949&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80949&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80949&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80949&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80949&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80949&r=mysqlcfg