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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: alex at zend dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Sat Jul 05 13:01:33 2025 UTC