-
Notifications
You must be signed in to change notification settings - Fork 7.9k
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
Closed
Fix PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect #8628
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8283f9d
Fix PDOStatement->execute() failed, then execute successfully, errorI…
Yurunsoft e1ba1b2
Fix other driver test
Yurunsoft 4a00255
Fix test
Yurunsoft c402f11
Fix test
Yurunsoft 46d4402
Fix I386 test
Yurunsoft b00dabf
Support pgsql, sqlite driver test
Yurunsoft d0be22e
Fix
Yurunsoft 1810d47
remove skip
Yurunsoft 0b7427d
Fix odbc test
Yurunsoft File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
GH-8626: PDOStatement->execute() failed, then execute successfully, errorInfo() information is incorrect | ||
--SKIPIF-- | ||
<?php | ||
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'); | ||
require_once $dir . 'pdo_test.inc'; | ||
PDOTest::skip(); | ||
?> | ||
--FILE-- | ||
<?php | ||
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/'); | ||
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; | ||
|
||
$db = PDOTest::factory(); | ||
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); | ||
|
||
$db->exec("SET SESSION sql_mode=CONCAT((select @@sql_mode),',STRICT_TRANS_TABLES')"); | ||
@$db->exec('DROP TABLE test'); | ||
$db->exec('CREATE TABLE test (x int)'); | ||
|
||
$stmt = $db->prepare('INSERT INTO test VALUES(?)'); | ||
|
||
// fail | ||
var_dump($stmt->execute([PHP_INT_MIN]), $stmt->errorCode(), $stmt->errorInfo()); | ||
|
||
// success | ||
var_dump($stmt->execute([1]), $stmt->errorCode(), $stmt->errorInfo()); | ||
?> | ||
===DONE=== | ||
--EXPECTF-- | ||
bool(false) | ||
string(%d) "%s" | ||
array(3) { | ||
[0]=> | ||
string(%d) "%s" | ||
[1]=> | ||
int(%d) | ||
[2]=> | ||
string(%d) "%s" | ||
} | ||
bool(true) | ||
string(5) "00000" | ||
array(3) { | ||
[0]=> | ||
string(5) "00000" | ||
[1]=> | ||
NULL | ||
[2]=> | ||
NULL | ||
} | ||
===DONE=== |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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?
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'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.
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 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.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've added mysql, pgsql, sqlite tests.
Other databases I am really not familiar with and cannot test.