php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #10153 Resource lost on the way..
Submitted: 2001-04-04 05:09 UTC Modified: 2001-06-27 01:57 UTC
From: romolo at bicnet dot it Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0 Latest CVS (04/04/2001) OS: linux
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: romolo at bicnet dot it
New email:
PHP Version: OS:

 

 [2001-04-04 05:09 UTC] romolo at bicnet dot it
Executing this script generate the error:
Warning: 1 is not a valid PostgreSQL link resource in test.php on line 24
The main problem is that adding a little bit of code to php source to printout the refcount of the resource just after the pg_connect get executed and zend_list_addref get called 
and just before the pg_exec get really executed i obtain the output at the end of the script, please not how refcount magically decrease between the pg_connect and the pg_exec.

The script...
<?php
// 
// Test script to show the bug
//
$db1=pg_connect("dbname=test");
$res1=pg_exec($db1,"SELECT * from tbltest");
echo "1 ".$db1."<br>";

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "2 ".$db."<br>";
pg_close($db);

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "3 ".$db."<br>";
pg_close($db);

$db=pg_connect("dbname=test");
$res1=pg_exec($db,"SELECT * from tbltest");
echo "4 ".$db."<br>";
pg_close($db);

pg_close($db1);

?>

The output:

Warning: Refcount 2 in /usr/local/httpd/htdocs/test.php on line 6
1 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 9
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 10
2 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 14
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 15
3 Resource id #1
Warning: Refcount 3 in /usr/local/httpd/htdocs/test.php on line 19
Warning: Refcount 2 in /usr/local/httpd/htdocs/test.php on line 20
4 Resource id #1
Warning: 1 is not a valid PostgreSQL link resource in
   /usr/local/httpd/htdocs/test.php on line 24

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-06-20 18:27 UTC] sniper@php.net
I get this output (with php 4.0.6RC4):

1 Resource id #1
2 Resource id #1
3 Resource id #1
4 Resource id #1

Warning: 1 is not a valid PostgreSQL link resource in /www/apache/htdocs/pgsql.php on line 18

which is correct. The pg_connect() behaves the same way
as mysql_connect() ie, if connection to same database is
made with same arguments, no new connection is established
but the old one returned instead. 

Reclassified as documentation problem.

--Jani

 [2001-06-27 01:57 UTC] danbeck@php.net
Corrected in latest cvs documentation.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 11:01:30 2025 UTC