PHP 4.0 Bug #8689 Updated: pg_Connect() seems to do some type of caching that doesn't quite work

From: Date: Sat, 13 Jan 2001 19:19:57 +0000
Subject: PHP 4.0 Bug #8689 Updated: pg_Connect() seems to do some type of caching that doesn't quite work
Groups: php.dev 
Request: Send a blank email to php-dev+get-43991@lists.php.net to get a copy of this message
ID: 8689 User Update by: matt@webcraft.ch Status: Open Bug Type: PostgreSQL related Description: pg_Connect() seems to do some type of caching that doesn't quite work Previous Comments: --------------------------------------------------------------------------- [2001-01-13 14:08:06] matt@webcraft.ch <? 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 --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=8689

« previous php.dev (#43991) next »