X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5D1D2533B3 for ; Mon, 18 Apr 2005 16:47:11 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58727-02 for ; Mon, 18 Apr 2005 19:47:02 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 8A735533A1 for ; Mon, 18 Apr 2005 16:47:02 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1571110wri for ; Mon, 18 Apr 2005 12:47:04 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=YVmRnTc4snroRTok/pF2g4oLyWpk7jGAeKtvUOx3MnIIUvQK8eB77JHFK8y9HOLNWkPaUP2GCPcXejldpIgz0foqAQVaeAZwX2o0YpvUs5b6Q/W/d0RIcPBNuHBChdakpXwF2zE5dc0n1aelTdLtpFcLV5PZ0C55CRKZHqocc3Y= Received: by 10.54.31.32 with SMTP id e32mr3635194wre; Mon, 18 Apr 2005 12:47:04 -0700 (PDT) Received: by 10.54.30.31 with HTTP; Mon, 18 Apr 2005 12:47:04 -0700 (PDT) Message-ID: <7104a737050418124778333f3b@mail.gmail.com> Date: Mon, 18 Apr 2005 22:47:04 +0300 From: Volkan YAZICI Reply-To: Volkan YAZICI To: pgsql-php@postgresql.org Subject: PHP and COPY query Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.295 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200504/15 X-Sequence-Number: 3099 Hi all, Could anybody help me to figure out the reason of the endless loop after pg_query() line: /tmp$ cat example-copy.php /tmp$ php example-copy.php # Waiting and waiting `n waiting... # (CPU Usage: 99%-100%) The same program written using libpq works without any problem: /tmp$ cat example-copy.c #include #include #include int main(void) { PGconn *conn; PGresult *res; conn =3D PQconnectdb("dbname=3Dtemplate1"); if ( PQstatus(conn) !=3D CONNECTION_OK ) { fprintf(stderr, "Connection failed!\n"); fprintf(stderr, "Related error message: %s", PQerrorMessage(conn)); PQfinish(conn); exit(1); } =20 res =3D PQexec(conn, "COPY ornektablo FROM stdin"); if ( PQresultStatus(res) !=3D PGRES_COPY_IN ) { fprintf(stderr, "An unexpected result occured!\n"); PQclear(res); PQfinish(conn); exit(1); } PQfinish(conn); return 0; } /tmp$ gcc -Wall -lpq example-copy.c && ./a.out /tmp$ _ # Program ends normally. It seems like a PHP bug related with the handling of stdin between PostgreSQL and PHP. (I executed above PHP script from the command line, but the result is same when you'd use a web server too.) When I look at the source code of pg_query() function, it just makes a simple call to PQexec() after controlling taken input. Also, that encouraged me to think about stdin handling once more. Any comments are welcome. Regards.