|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-04-01 18:27 UTC] 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; PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 00:00:01 2025 UTC |
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(); ?>Same problem under php 5.0.4 and postgres 8.0.2. Sample code,who causes segfault: class db { function connect(){ $this->db = pg_connect($this->conn); if (!$this->db) { $this->ErrorMsg('cannot connect to db'); } } function ErrorMsg($ErrDescription) { $this->sql("ROLLBACK"); /* if this line commented,all going OK */ $this->disconnect(); die("Error<br>$ErrDescription"); } }