|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41837 CONSTRAINTS ALL DEFERRED doesnt work in PDO with Postgres
Submitted: 2007-06-28 09:16 UTC Modified: 2007-06-28 11:02 UTC
From: zolv at t-k dot pl Assigned:
Status: Not a bug Package: PDO related
PHP Version: 5.2.3 OS: Linux Gentoo x86_64
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: zolv at t-k dot pl
New email:
PHP Version: OS:


 [2007-06-28 09:16 UTC] zolv at t-k dot pl
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');

$fields = 
	'id, '.
	'name, '.

$inspoints = 
	':id, '.
	':name, '.

$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();


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 :(


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-06-28 09:22 UTC]
Doesn't work? Exception? Could you please be more specific? 
Don't forget to paste all error messages you see.
 [2007-06-28 10:54 UTC] zolv at t-k dot pl
Trying to "be more specific" i found bugs in my code.

Thanks for fast reply.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Jul 21 21:01:44 2024 UTC