|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-02-13 12:12 UTC] thies@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 16:00:01 2025 UTC |
<? function dummy($x) { $database = pg_Connect("dbname=template1 port=5432"); $querystring = "set datestyle to 'ISO'"; $result = pg_exec ($database, $querystring); echo "database = $database <br>"; // note 1: by commenting out the following line the bug disappears $x = pg_NumRows($result); // note 2: by commenting out the following line the bug disappears $y = pg_NumRows($result); // note 3: by un-commenting following line the bug disappears // pg_close($database); return 0; } // note 4: if the return-value is ignored by commenting out the following // line (only the first line: $x =) $x = dummy("12345"); echo "database = $database <br>"; // note 5: a change in the connect-string, like an additional space // at the end of the connect-string, makes the bug disappear $database = pg_Connect("dbname=template1 port=5432"); $querystring = "set datestyle to 'ISO'"; $result = pg_exec ($database, $querystring); echo "database = $database <br>"; ?> Comment: You can easily reproduce the bug by copy/paste-ing the above code in a file and check it out in a browser. By following the instruction in any one (try one at a time!) of the notes 1 to 5 in the above source you can get the bug to dissappear, which doesn't make a lot of sense in most cases (except from note 3). It seems to me, that pg_Connect() decides it has that connection already made (based on a cmpstr() of the two connect-strings), but the database-ressource has actually gone out of scope (but only under obscure circumstances, see notes...). Therefore you will get an error like this: Warning: 1 is not a valid PostgreSQL link resource in /www/auszweiterhand/docs/connect_test.php on line 33 Even though it should be valid at this point. Thanks for looking into it! regards Matt