#22761 [Asn->Fbk]: nextId does not create the sequence within transaction

From: Date: Wed, 30 Apr 2003 11:50:56 +0000
Subject: #22761 [Asn->Fbk]: nextId does not create the sequence within transaction
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-15749@lists.php.net to get a copy of this message
ID: 22761 Updated by: lsmith@php.net Reported By: zubchenko at alarit dot com -Status: Assigned +Status: Feedback Bug Type: PEAR related Operating System: Linux PHP Version: 4.3.0 Assigned To: lsmith New Comment: i would also say that we leave things as they are an simply document this behavior accordingly. the auto creation of sequences is more a "lazy" programmers feature that really a core requirement of nextId and therefore we should not make the code even more complex for this "lazy" programmers feature. Previous Comments: ------------------------------------------------------------------------ [2003-04-28 03:57:04] arnaud@php.net changing status (alan got me again ;) ------------------------------------------------------------------------ [2003-03-18 16:23:11] blair at squiz dot net This has to do with PostgreSQL's mannerism of abortting a transaction when an error occurs and the error occurs when the SELECT NEXTVAL('[seqname]'); gets called because the sequence does not exist. Then when the DB object attempts to create the sequence you get this msg : ERROR: current transaction is aborted, queries ignored until end of transaction block The only way I have found around this is to make DB::createSequence() calls in my install script. Anything else would mean making making a specific query for checking for each PostgreSQL version and checking that the sequence existed before calling it (I haven't found an easy way to check if a table/sequence exists). This could also be a performance hit when doing large data imports. ------------------------------------------------------------------------ [2003-03-18 06:38:17] zubchenko at alarit dot com We are using PostrgreSQL 7.3 with PHP 4.2.3 in our project. We have discovered that when calling nextId with name of non-existent sequence we get NULL as result without any error. In pgAdmin all is fine. It happens only within transaction. Here is example of code: //opening connection to DB with DB class $res = $db->query('BEGIN'); if (DB::isError($res)) { die(trigger_error($res->getMessage() ." : ".$res->getUserInfo(),E_USER_ERROR)); } debug($db->nextId('some_non_existing_seq')); $res = $db->query('COMMIT'); if (DB::isError($res)) { die(trigger_error($res->getMessage() ." : ".$res->getUserInfo(),E_USER_ERROR)); } //closing connection This code results in NULL output from debug and nothing else. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22761&edit=1

« previous php.pear.dev (#15749) next »