From:             
Operating system: Linux (FC10)
PHP version:      5.3.3
Package:          PostgreSQL related
Bug Type:         Bug
Bug description:pg_get_result does not block if an error occurred

Description:
------------
Continuation of http://bugs.php.net/bug.php?id=36469 -- it won't let me
reopen the bug (too old?) but it still exists. (It seems to be worse on
modern hardware since there are multiple CPUs and the php process never has
to yield to the postgres process)



The manual says that pg_get_result() will block until results are ready,
but if there was any sort of error (syntax error or query error, eg table
does not exist) then pg_get_result() will return immediately.



This causes problems since the next command you try to run may fail because
the previous command hasn't actually finished. 

Test script:
---------------
#!/usr/local/src/php5/php-5.3.3/sapi/cli/php

<?php



if (!isset($_SERVER['argv'][1])) {

    echo "Missing sleep time\n";

    exit(1);

}

$sleepTime = $_SERVER['argv'][1];



$connStr = sprintf("host=%s dbname=%s user=%s password=%s", 'localhost',
'testlevi', 'levi', 'levi');

($dbconn = pg_connect($connStr)) or die("Could not connect");



$i = 0;



do {

    pg_send_query($dbconn, 'i am a syntax error;');

    pg_get_result($dbconn);

    usleep($sleepTime);

    $i++;

} while (!pg_connection_busy($dbconn));



echo "got a busy signal after $i commands";



?>





(There are 2 alternate scripts in the previous bug report that effectively
show the same thing)

Expected result:
----------------
Should loop forever

Actual result:
--------------
./test.php 0

got a busy signal after 1 commands



./test.php 10

got a busy signal after 3033 commands



./test.php 1000

(loops forever)





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

Reply via email to