Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:45669 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 71389 invoked from network); 6 Oct 2009 05:42:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 Oct 2009 05:42:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=samuel.roze@aliceadsl.fr; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=samuel.roze@aliceadsl.fr; sender-id=unknown Received-SPF: error (pb1.pair.com: domain aliceadsl.fr from 212.27.42.1 cause and error) X-PHP-List-Original-Sender: samuel.roze@aliceadsl.fr X-Host-Fingerprint: 212.27.42.1 smtp1-g21.free.fr Linux 2.6 Received: from [212.27.42.1] ([212.27.42.1:51446] helo=smtp1-g21.free.fr) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id CD/AC-31065-CC8DACA4 for ; Tue, 06 Oct 2009 01:42:38 -0400 Received: from smtp1-g21.free.fr (localhost [127.0.0.1]) by smtp1-g21.free.fr (Postfix) with ESMTP id 0E761940111 for ; Tue, 6 Oct 2009 07:42:31 +0200 (CEST) Received: from [192.168.0.10] (lns-bzn-38-82-253-115-156.adsl.proxad.net [82.253.115.156]) by smtp1-g21.free.fr (Postfix) with ESMTP id AC6769400F4 for ; Tue, 6 Oct 2009 07:42:28 +0200 (CEST) To: internals@lists.php.net In-Reply-To: <1254806557.19561.3.camel@samuel-laptop> References: <1254806557.19561.3.camel@samuel-laptop> Content-Type: text/plain; charset="UTF-8" Date: Tue, 06 Oct 2009 07:42:15 +0200 Message-ID: <1254807735.19561.5.camel@samuel-laptop> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] PDO PgSQL: _pdo_pgsql_notice From: samuel.roze@aliceadsl.fr (Samuel ROZE) To use PostgreSQL's Notices with PDO, i'm modifying the source for trying to store into "errmsg" (which I can get with PDO::errorInfo) the notice. The "_pdo_pgsql_notice" function is called everytime that there's an notice. The notice message is in the "message" var. This what i had tried: --------------------------------------- static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* {{{ */ { pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; pdo_pgsql_error_info *einfo = &H->einfo; einfo->errcode = 1; if (einfo->errmsg) { pefree(einfo->errmsg, dbh->is_persistent); einfo->errmsg = NULL; } einfo->errmsg = _pdo_pgsql_trim_message(message, dbh->is_persistent); } --------------------------------------- And in "pdo_pgsql_fetch_error_func", i've added an else condition to view if errmsg is null are not... --------------------------------------- if (einfo->errcode) { add_next_index_long(info, einfo->errcode); add_next_index_string(info, einfo->errmsg, 1); } else { zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "einfo->errcode is false : %s , %s", einfo->errcode, einfo->errmsg); } --------------------------------------- And, I've a function which send some notices (when I throw exception from "_pdo_pgsql_notice" with the "message" var, I see the notice ! :-) But, einfo->errcode is null ! -> Fatal error: Uncaught exception 'PDOException' with message 'einfo->errcode is false : (null) , (null)' in /etc/php-5.2.10/test/pgsql_notice.php:22 Stack trace: #0 /etc/php-5.2.10/test/pgsql_notice.php(22): PDO->errorInfo() #1 {main} thrown in /etc/php-5.2.10/test/pgsql_notice.php on line 22 Is anyone can help me ? Thanks a lot ! Samuel. (French) Le mardi 06 octobre 2009 à 07:22 +0200, Samuel ROZE a écrit : > Hi ! > > I'm reading the source of PDO PostgreSQL driver and i see that there's > an empty function, _pdo_pgsql_notice, which is very interesting ! I > think that it is used when PostgreSQL throw Notices. > But, nothing is done... > > I want to know if somebody know why the content of the function is > commented: > > static void _pdo_pgsql_notice(pdo_dbh_t *dbh, const char *message) /* > {{{ */ > { > /* pdo_pgsql_db_handle *H = (pdo_pgsql_db_handle *)dbh->driver_data; */ > } > > (line 98 of /etc/pdo_pgsql/pgsql_driver.c - PHP 5.2 - r272374) > > How can I store the content of "message" into a field of the > PDOStatement ? I view that there's only a "pdo_dbh_t" param, I may just > store this message into a field of the PDO class ? > > Thanks in advance. > Samuel. > >