php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #7007 The pg_close function doesn't close the connection.
Submitted: 2000-10-04 03:05 UTC Modified: 2001-06-08 10:58 UTC
From: alex at zend dot com Assigned:
Status: Closed Package: PostgreSQL related
PHP Version: 4.0.2 OS: linux-glibc21
Private report: No CVE-ID: None
 [2000-10-04 03:05 UTC] alex at zend dot com
The script below doesn't remove the database because the second
link is not closed and the postgres will not drop a database if there is a connection using it.

<?php 
        $id1 = pg_connect("host=cheese port=7655 user=zendtest password=******** dbname=template1");
        pg_exec($id1, "CREATE DATABASE zendtest");
        pg_close($id1);

        $id2 = pg_connect("host=cheese port=7655 user=zendtest password=dnez dbname=zendtest");
        pg_close($id2);

        $id3 = pg_connect("host=cheese port=7655 user=zendtest password=******** dbname=template1");
        pg_exec($id3, "DROP DATABASE zendtest");
        pg_close($id3);
?>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-02-13 12:43 UTC] thies@php.net
it seems that postgres does not shut down connections synchronous which means that after pg_close() the connection is still alive for a very short moment (and so are the locks). inserting a sleep(1) after pg_close() fixed the problem 100% for me. i'm in contact with some postgres guy to confirm. i can assure you that it's not a php-problem.

 [2001-06-08 10:58 UTC] sniper@php.net
Not PHP problem.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 09:01:28 2024 UTC