php / php/php-src

No exception on `mysqli::rollback` when transaction is no longer active

Open
#12,576 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: mysqli Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

Description

Repro steps:

  1. have an open mysqli connection
  2. start transaction using mysqli::begin_transaction
  3. run some query like analyze table xx, this is "administrative statement" [1] which implicit autocommit
  4. rollback transaction using mysqli::rollback and notice no exception is thrown

Since PHP 8.0, PDO checks if a transaction is active and throws an exception: PDOException: There is no active transaction

mysqli must throw the same exception as well.

Related MariaDB tickets:

[1] docs https://dev.mysql.com/doc/refman/8.0/en/implicit-commit.html and repro: https://dbfiddle.uk/coUjimLq

PHP Version

7.4 - master

Operating System

any

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the mysqli::rollback entry point and reproduce the begin_transaction, administrative-statement, and rollback sequence described in the issue. Compare the transaction-state behavior with PHP 8's PDO exception behavior, then add coverage showing that rollback reports an exception when the transaction is no longer active.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, php
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.