Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:21075 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32343 invoked by uid 1010); 7 Dec 2005 13:17:58 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 32327 invoked from network); 7 Dec 2005 13:17:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 Dec 2005 13:17:58 -0000 X-Host-Fingerprint: 217.20.119.125 adviser.com NetCache 5.3-5.5 Received: from ([217.20.119.125:52757] helo=smtp.adviser.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id EE/EC-14828-501E6934 for ; Wed, 07 Dec 2005 08:17:57 -0500 Received: from e176181244.adsl.alicedsl.de ([85.176.181.244] helo=[192.168.255.11]) by smtp.adviser.com with esmtpsa (TLSv1:RC4-SHA:128) (Exim 4.54 (FreeBSD)) id 1EjzBA-0003Qn-7u; Wed, 07 Dec 2005 14:17:52 +0100 Mime-Version: 1.0 (Apple Message framework v746.2) To: internals@lists.php.net, Wez Furlong Message-ID: <343A7333-A147-4C4E-B570-FBA927895583@thieso.net> Content-Type: multipart/mixed; boundary=Apple-Mail-2-1035377586 Cc: Thies Arntzen Date: Wed, 7 Dec 2005 14:16:40 +0100 X-Mailer: Apple Mail (2.746.2) Subject: PDO:PGSQL problem with double prepared statements. (solution included) From: thies@thieso.net ("Thies C. Arntzen") --Apple-Mail-2-1035377586 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed hi, i had a slight problem with Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE [42P05]: Duplicate prepared statement: 7 ERROR: prepared statement "pdo_pgsql_stmt_086eebf4" already exists' in /home/thies/public_html/ portal-HEAD/include/pw.db/table.php:670 some investigation showed that my prepared statement failed executing but not "preparing" (some expected unique constraint problem) - so my code would assign a diffferent value to the bound variables and try again (this time i would get the noted message). the code as it is now in pgsql_statement.c says (line 129 -) if (!stmt->executed) { /* we deferred the prepare until now, because we didn't * know anything about the parameter types; now we do */ S->result = PQprepare(H->server, S->stmt_name, S->query, stmt->bound_params ? zend_hash_num_elements (stmt->bound_params) : 0, S->param_types); but stmt->executed only seems to get set to when the execution was successful. my workaround is to add a new var to pdo_pgsql_stmt called is_prepared and use that as my protection against multiple prepares. re, thies --Apple-Mail-2-1035377586 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-2-1035377586--