ID: 8689 User Update by: [EMAIL PROTECTED] 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] [EMAIL PROTECTED] <? 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 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]