[php-src] Issue #11100: mysqlnd: No exception thrown when executing INSERT RETURNING with a constraint violation (binary protocol)
| From: | 9EOR9 | Date: | Tue, 18 Apr 2023 14:58:43 +0000 |
| Subject: | [php-src] Issue #11100: mysqlnd: No exception thrown when executing INSERT RETURNING with a constraint violation (binary protocol) | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-244228@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/11100
Author: 9EOR9
### Description
The following code:
```php
<?php
$conn = mysqli_connect("localhost", "georg","", "test", 0,
"/tmp/mysql.sock");
mysqli_query($conn, "CREATE OR REPLACE TABLE t1 (a int not NULL)");
try {
mysqli_query($conn, "INSERT INTO t1 VALUES(NULL) RETURNING a");
}
catch (Exception $e)
{
echo "Expected error (text protocol): " . $e->getMessage() . "\n";
}
$stmt= mysqli_prepare($conn, "INSERT INTO t1 VALUES(NULL) RETURNING a");
try {
$stmt->execute();
echo "No exception thrown in binary protocol\n";
}
catch (Exception $e)
{
echo "Expected error (binary protocol): " . $e->getMessage() . "\n";
}
?>
```
Resulted in this output:
```
Expected error (text protocol): Column 'a' cannot be null
No exception thrown in binary protocol
```
But I expected this output instead:
```
Expected error (text protocol): Column 'a' cannot be null
Expected error (binary protocol): Column 'a' cannot be null
```
MariaDB Server version:
```
10.11.3
```
### PHP Version
PHP 8.2.5
### Operating System
_No response_