ID: 36681
User updated by: ce at netage dot bg
Reported By: ce at netage dot bg
Status: Verified
Bug Type: PDO related
Operating System: Linux & Windows
PHP Version: 5.1.2
New Comment:
I tested it against 5.1.2. It looks to me as if it works! :-)
Previous Comments:
------------------------------------------------------------------------
[2006-04-09 08:24:42] [EMAIL PROTECTED]
My guess is that this patch will fix this issue, but I haven't tried
it:
Index: pgsql_driver.c
===================================================================
RCS file: /repository/php-src/ext/pdo_pgsql/pgsql_driver.c,v
retrieving revision 1.53.2.14
diff -u -p -r1.53.2.14 pgsql_driver.c
--- pgsql_driver.c 9 Apr 2006 08:17:50 -0000 1.53.2.14
+++ pgsql_driver.c 9 Apr 2006 08:23:52 -0000
@@ -470,6 +470,7 @@ static int pdo_pgsql_transaction_cmd(con
if (PQresultStatus(res) != PGRES_COMMAND_OK) {
ret = 0;
+ pdo_pgsql_error(dbh, PQresultStatus(res),
pdo_pgsql_sqlstate(res));
}
PQclear(res);
------------------------------------------------------------------------
[2006-03-10 17:52:04] [EMAIL PROTECTED]
I'm reproducing the bug on Windows XP with PHP 5.1.2.
------------------------------------------------------------------------
[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