Edit report at http://bugs.php.net/bug.php?id=52682&edit=1
ID: 52682 Updated by: il...@php.net Reported by: benoitg at coeus dot ca Summary: pg_query does not return on error -Status: Open +Status: Feedback Type: Bug Package: PostgreSQL related Operating System: Ubuntu Lucid or Maverick PHP Version: 5.3.3 Block user comment: N New Comment: Seems to work fine in latest snapshot. Previous Comments: ------------------------------------------------------------------------ [2010-08-25 23:17:52] benoitg at coeus dot ca Additional notes: When the bug occurs, lines like the following are written to the postgresql log: 2010-08-25 17:03:03 EDT LOG: unexpected EOF on client connection No errors are reported by apache. ------------------------------------------------------------------------ [2010-08-24 00:52:50] benoitg at coeus dot ca Description: ------------ pg_query() should return when an SQL error happens (there are then various function to get the error description. However in php 5.3.2 (ubuntu lucid) and 5.3.3 (ubuntu maverick), the function doesn't return at all (the php script ends). Included is a short test script. As will run on ubuntu as written if you run php cli as the postgres system user, for example: sudo -u postgres php test_pg_query_not_returning.php Test script: --------------- <?php define ('CONF_DATABASE_NAME', "postgres"); define ('CONF_DATABASE_USER', "postgres"); define ('CONF_DATABASE_PASSWORD', ""); $conn_string = "dbname=".CONF_DATABASE_NAME." user=".CONF_DATABASE_USER." password=".CONF_DATABASE_PASSWORD."\n"; $conn = pg_connect($conn_string) or die("Unable to connect to database, fix this first"); echo "About to execute actual test: \n"; $sql = "SOME INVALID SQL"; $return = pg_query($conn, $sql); if($return === FALSE) { echo "You should see this, but this code is never executed!\n"; } echo "Even this code is never executed!\n"; ?> Expected result: ---------------- sudo -u postgres php test_pg_query_not_returning.php About to execute actual test: PHP Warning: pg_query(): Query failed: ERROR: syntax error at or near "SOME" LINE 1: SOME INVALID SQL ^ in /var/www/eureka/html/tests/test_pg_query_not_returning.php on line 11 You should see this, but this code is never executed! Even this code is never executed! Actual result: -------------- sudo -u postgres php test_pg_query_not_returning.php About to execute actual test: PHP Warning: pg_query(): Query failed: ERROR: syntax error at or near "SOME" LINE 1: SOME INVALID SQL ^ in /var/www/eureka/html/tests/test_pg_query_not_returning.php on line 11 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52682&edit=1