PDO PgSQL: _pdo_pgsql_notice
am 05.10.2009 20:58:05 von Samuel ROZE
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.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: PDO PgSQL: _pdo_pgsql_notice
am 05.10.2009 23:55:37 von 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 lundi 05 octobre 2009 à 20:58 +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.
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: PDO PgSQL: _pdo_pgsql_notice
am 06.10.2009 00:14:16 von dmagick
Samuel ROZE wrote:
> 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:
You'll need to take this suggestion to the php-internals mailing list.
They write and discuss the C code behind php so they'll be able to help you.
--
Postgresql & php tutorials
http://www.designmagick.com/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php