-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature GH-12576: [mysqli] Added transaction check process #12579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
5a48c1d
to
11a2d34
Compare
8445b31
to
42868db
Compare
Some tests are failing, so I'll fix them later. |
c41ce6b
to
35fb0af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tests need to be updated
fix macro fix report flags fix tests fix tests
35fb0af
to
832c30f
Compare
The scope of influence on the test was larger than I expected. I think it's probably okay because I passed it on local, but I'll wait for CI to pass. |
@Girgias |
@@ -53,6 +53,14 @@ if (!have_innodb($link)) | |||
echo $exception->getMessage() . "\n"; | |||
} | |||
|
|||
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket); | |||
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysqli_report(MYSQLI_REPORT_ERROR|MYSQLI_REPORT_STRICT); |
should be not needed because of https://wiki.php.net/rfc/mysqli_default_errmode
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I thought at first, but it seems like this is a global setting. If I didn't set it like this here, I ended up in warning mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Warning mode is set at the beginning of this test case, and if I do not change the mode with this line, the warning mode will be inherited even if I create a new mysqli instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see - https://github.com/php/php-src/blob/832c30f38df/ext/mysqli/tests/connect.inc#L10 - new mysqli_driver
is an instance of the monostate pattern - https://www.php.net/manual/en/class.mysqli-driver.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right.
|
||
mysqli_rollback($link); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mysqli_rollback($link); | |
mysqli_commit($link); |
to test if the first mysqli_begin_transaction
can still be commit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is the same no matter which one you use. This is because the only errors that occur are due to the checks added this time.
Personally, I'm fine with either.
Do you know why it doesn't work for me? I tried with this code:
and I always get the error. |
What happens if I start a transaction before committing? It seems like correct behavior that a transaction cannot be committed before it has started. |
Starting the transaction using I am also concerned that if MySQL has autocommit disabled then PHP will always throw an error. Is that right? If that's the case then we cannot introduce this change. |
Ah I see. In fact, MySQL's CLI tools behave that way. But it seems that the behavior is a little different when using the API, as the transaction is started after executing sql (like an insert statement), etc.
That's not my intention, but there may be some hidden use cases that I haven't envisioned. |
I tried implementing it for the time being, but mysqli is different from PDO, and I personally don't think it's necessary to forcefully add this feature. |
Ahh, that explains it. But I wonder if this could problems for anyone though. I will have to think about it more. |
Closes #12576
Added checks similar to PDO. Personally, this is not a bug but a feature addition, so I set the target branch to master.
cc: @kamil-tekiela