Skip to content

Fix PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect #8628

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

Closed
wants to merge 9 commits into from

Conversation

Yurunsoft
Copy link
Contributor

Fix #8626

This problem exists for both PHP 7.4, 8.0, 8.1

Reference:

if(!strncmp(dbh->query_stmt->error_code, PDO_ERR_NONE, sizeof(PDO_ERR_NONE))) goto fill_array;

@Yurunsoft Yurunsoft force-pushed the fix-pdo-stmt-errorInfo-8.0 branch from 3118ad0 to e1ba1b2 Compare May 25, 2022 08:52
if (!extension_loaded('pdo') || !extension_loaded('pdo_mysql')) die('skip');
$dir = getenv('REDIR_TEST_DIR');
if (false == $dir) die('skip no driver');
if (!str_starts_with(getenv('PDOTEST_DSN'), 'mysql')) die('skip non-mysql drivers');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the test is only meant for PDO_MySQL, there is no point in putting it into ext/pdo/tests and making it a redirect test. Instead, the test should be put into ext/pdo_mysql/tests. However, since there is a behavioral change for all PDO drivers, shouldn't we test it for all drivers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not very familiar with other databases, so I had to use MySQL to test it.
And, I'm not quite sure why the I386 test failed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem the usage of PHP_INT_MIN to trigger a failure. PHP_INT_MIN is -2147483648 on 32bit architectures, and that wouldn't be problem for the database. Can't we use something else to trigger a failure? I'm thinking about trying to insert a non numeric string into an INTEGER column, or such. That should work for other drivers as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added mysql, pgsql, sqlite tests.
Other databases I am really not familiar with and cannot test.

Copy link
Member

@kamil-tekiela kamil-tekiela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devnexen
Copy link
Member

devnexen commented Jun 2, 2022

Merged with df52903ee. Thank you.

@devnexen devnexen closed this Jun 2, 2022
@kamil-tekiela
Copy link
Member

Something is still not right with the tests here https://github.com/php/php-src/runs/6712417535?check_suite_focus=true I suppose DBLIB needs the same exception as ODBC.

devnexen pushed a commit that referenced this pull request Jun 3, 2022
@Yurunsoft Yurunsoft deleted the fix-pdo-stmt-errorInfo-8.0 branch June 17, 2022 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect
5 participants