From:             volkan dot yazici at gmail dot com
Operating system: Linux 2.6.11
PHP version:      5.0.3
PHP Bug Type:     PostgreSQL related
Bug description:  stdin handling confusion in COPY

Description:
------------
There seems to be a confusion in handling stdin between PostgreSQL and
PHP.

Reproduce code:
---------------
<?php
$conn = pg_connect("user=knt dbname=template1")
        or die("Connection failed!\n");

print "Starting query...\n";
$res = pg_query("COPY example_table FROM stdin");

/*
 * If I'd not use a pg_end_copy() call just after "COPY FROM
 * stdin" query, script flow will never pass through this
 * line and stuck here with a 100% CPU usage.
 */

if ( pg_result_status($res) != PGSQL_COPY_IN )
    die("Unexpected result status!\n");

print "At last!\n";
pg_close();
?>

/*
 * The same of this script
 * [http://yazicivo.fateback.com/example-copy.txt] written
 * in C (with same libpq calls) works fine.
 */

Expected result:
----------------
shell$ php example-copy.php
Starting query...
At last!
shell$ _

Actual result:
--------------
shell$ php example-copy.php
Starting query...

# It enters to an endless loop with a 100% CPU usage.

-- 
Edit bug report at http://bugs.php.net/?id=32774&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32774&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32774&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32774&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32774&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32774&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32774&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32774&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32774&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32774&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32774&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32774&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32774&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32774&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32774&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32774&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32774&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32774&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32774&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32774&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32774&r=mysqlcfg

Reply via email to