ID: 36681
Updated by: [EMAIL PROTECTED]
-Summary: deferred constraints not raise error on commit
Reported By: ce at netage dot bg
-Status: Open
+Status: Verified
Bug Type: PDO related
-Operating System: linux
+Operating System: Linux & Windows
PHP Version: 5.1.2
New Comment:
I'm reproducing the bug on Windows XP with PHP 5.1.2.
Previous Comments:
------------------------------------------------------------------------
[2006-03-10 14:32:03] ce at netage dot bg
Description:
------------
When using deferred constraints in postgresql, the commit statement
doesn't raise exception on constraint violation
Reproduce code:
---------------
create table parent (id integer not null primary key);
create table child (parent integer not null references parent(id)
deferrable);
$dbh = new PDO('pgsql:dbname=test;host=localhost');
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$dbh->beginTransaction();
$dbh->exec('SET CONSTRAINTS ALL DEFERRED');
$dbh->exec('insert into child VALUES (1)');
$dbh->commit();
Expected result:
----------------
PHP Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[23503]: Foreign key violation: 7 ERROR: insert or update on
table "child" violates foreign key constraint "child_parent_fkey"
Actual result:
--------------
nothing
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36681&edit=1