From: zolv at t-k dot pl
Operating system: Linux Gentoo x86_64
PHP version: 5.2.3
PHP Bug Type: PDO related
Bug description: CONSTRAINTS ALL DEFERRED doesnt work in PDO with Postgres
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 bug report at http://bugs.php.net/?id=41837&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41837&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41837&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41837&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41837&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41837&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41837&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41837&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41837&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41837&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41837&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41837&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41837&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41837&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41837&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41837&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41837&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41837&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41837&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41837&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41837&r=mysqlcfg