#40969 [Opn->Bgs]: Insert row with unique key violation, no error.
| From: | georg@php.net | Date: | Mon, 02 Apr 2007 11:35:02 +0000 |
| Subject: | #40969 [Opn->Bgs]: Insert row with unique key violation, no error. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-111004@lists.php.net to get a copy of this message | ||
ID: 40969
Updated by: georg@php.net
Reported By: andrew dot craft at wyndhamworldwide dot com
-Status: Open
+Status: Bogus
Bug Type: MySQLi related
Operating System: Windows XP SP2 32bit
PHP Version: 5.2.1
New Comment:
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
http://www.php.net/manual/en/function.mysqli-stmt-execute.php:
Return Values
Returns TRUE on success or FALSE on failure.
Previous Comments:
------------------------------------------------------------------------
[2007-03-31 19:03:50] andrew dot craft at wyndhamworldwide dot com
Description:
------------
I am using mysql 5.0.27.
There is a table that has a unique index on it. When inserting a new
row that would violate the uniqueness using a prepared statement no
errors/exceptions are raised. When looking at the query log the
statement is prepared but no executions queries. Should there not be an
exception raised for the error?
I did a google search and searched the bug database but did not find an
existing issue.
Reproduce code:
---------------
CREATE TABLE
docs_classification (
classification_id smallint(6) NOT NULL auto_increment,
name varchar(100) NOT NULL,
description varchar(255) NOT NULL,
short_name char(3) NOT NULL,
bit_value int(11) NOT NULL,
PRIMARY KEY (classification_id),
UNIQUE KEY bit_value (bit_value)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=10 ;
//////////
First Run
array('test1', 'test1test1', 'TS1', '1'),
array('test2', 'test2test2', 'TS2', '2'),
array('test3', 'test3test3', 'TS3', '4')
);
$m = new mysqli('localhost', 'dbuser', '','dbname');
$sql = 'INSERT INTO dbtable '
' (classification_id, name, description, short_name, bit_value) '.
' VALUES (NULL, ?, ?, ?, ?)';
$stmt = $m->prepare($sql);
foreach ($a as $b)
{
$stmt->bind_param('ssss', $b[0], $b[1], $b[2], $b[3]);
$stmt->execute();
}
///////
Then repeat above code and no errors are raised.
Expected result:
----------------
Expected to be notified of the duplicate entry error in the bit_value
field when re-running the code.
Actual result:
--------------
No errors or indication of any errors.
In the query log it shows the sql being prepared but no Execute
commands.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=40969&edit=1