#41837 [Csd->Bgs]: CONSTRAINTS ALL DEFERRED doesnt work in PDO with Postgres

From: Date: Thu, 28 Jun 2007 11:02:19 +0000
Subject: #41837 [Csd->Bgs]: CONSTRAINTS ALL DEFERRED doesnt work in PDO with Postgres
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-114407@lists.php.net to get a copy of this message
ID: 41837 Updated by: scottmac@php.net Reported By: zolv at t-k dot pl -Status: Closed +Status: Bogus Bug Type: PDO related Operating System: Linux Gentoo x86_64 PHP Version: 5.2.3 Previous Comments: ------------------------------------------------------------------------ [2007-06-28 10:54:01] zolv at t-k dot pl Trying to "be more specific" i found bugs in my code. Thanks for fast reply. ------------------------------------------------------------------------ [2007-06-28 09:22:57] tony2001@php.net Doesn't work? Exception? Could you please be more specific? Don't forget to paste all error messages you see. ------------------------------------------------------------------------ [2007-06-28 09:16:32] zolv at t-k dot pl Description: ------------ when i use PDO with Postgresql and use transactions with 'SET CONSTRAINTS ALL DEFERRED' PDO throws exception on inserts that works perfectly when i dont use PDO, but pg_connect and pg_query Reproduce code: --------------- example sql: create table obiekt_c4 ( id serial NOT NULL, name varchar(255), PRIMARY KEY (id) ); create table obiekt_a4 ( id serial NOT NULL, name varchar(255), obiekt_c4_id integer REFERENCES obiekt_c4( id ) DEFERRABLE, PRIMARY KEY (id) ); ---------------------- bellow code showing what i try do do: $DB = new PDO('pgsql:host=localhost;dbname=atoncd_test', 'atoncd', 'atoncd'); $DB->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $DB->beginTransaction(); $DB->exec( 'SET CONSTRAINTS ALL DEFERRED' ); $fields = 'id, '. 'name, '. 'obiekt_c4_id'; $inspoints = ':id, '. ':name, '. ':obiekt_c4_id'; $q = sprintf( 'INSERT INTO "%s" ( %s ) VALUES ( %s )', self::TABLE_NAME_OBIEKT_A4, $fields, $inspoints ); $stmt = $DB->prepare($q); $stmt -> bindValue( ':id', 1, PDO::PARAM_INT ); $stmt -> bindValue( ':name', 'my id is 1', PDO::PARAM_STR ); $stmt -> bindValue( ':obiekt_c4_id', 999, PDO::PARAM_INT ); $stmt -> execute(); $DB->commit(); Expected result: ---------------- Exception should be thrown on '$DB->commit()' Actual result: -------------- Exception is thrown on '$stmt -> execute()', so '$DB->exec( 'SET CONSTRAINTS ALL DEFERRED' );' doesnt work :( ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41837&edit=1

« previous php.bugs (#114407) next »