ID: 32537
User updated by: mauroi at digbang dot com
Reported By: mauroi at digbang dot com
-Status: Feedback
+Status: Open
Bug Type: PostgreSQL related
Operating System: Linux
PHP Version: 5.0.3
New Comment:
The following class (code) causes a segmentation fault if it has the
ROLLBACK query in the destructor.
It results in a segfault always if it's executed as a command line
script, and sometimes if it's called by a web request (lots of calls
repeteadly and with persistence).
The extension code (pgsql.c) has a "feature" which automatically close
every query result that was left opened. But I think that it's pretty
acceptable to have a script like this one.
<?
class db
{
public function __construct($string)
{
$this->handle = pg_pconnect($string);
$this->Execute('BEGIN');
}
public function Commit()
{
$this->execute('COMMIT');
$this->execute('BEGIN');
}
public function Execute($query)
{
$res = pg_query($this->handle, $query);
pg_affected_rows($res);
pg_free_result($res);
}
public function __destruct()
{
$this->execute('ROLLBACK');
pg_close($this->handle);
}
private $handle;
}
$c = new db([connection string]);
$c->execute("SELECT 1");
$c->Commit();
?>
Previous Comments:
------------------------------------------------------------------------
[2005-04-01 18:29:01] [EMAIL PROTECTED]
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php
If you can provide more information, feel free to add it
to this bug and change the status back to "Open".
Thank you for your interest in PHP.
------------------------------------------------------------------------
[2005-04-01 18:27:23] mauroi at digbang dot com
Description:
------------
Out application works perfectly using normal postgresql connections.
But when we enable persistence we're getting random errors and
segmentation faults.
We're using PHP 5 and PostgreSQL 8.0.1 .
The sequence of querys is something like
BEGIN;
SELECT;
INSERT;
.....
COMMIT;
BEGIN;
ROLLBACK;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=32537&edit=1