From:             
Operating system: Ubuntu Lucid or Maverick
PHP version:      5.3.3
Package:          PostgreSQL related
Bug Type:         Bug
Bug description:pg_query does not return on error

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 bug report at http://bugs.php.net/bug.php?id=52682&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=52682&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=52682&r=trysnapshot53
Try a snapshot (trunk):              
http://bugs.php.net/fix.php?id=52682&r=trysnapshottrunk
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=52682&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=52682&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=52682&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=52682&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=52682&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=52682&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=52682&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=52682&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=52682&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=52682&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=52682&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=52682&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=52682&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=52682&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=52682&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=52682&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=52682&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=52682&r=mysqlcfg

Reply via email to