summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pgsql/pgsql.c14
-rw-r--r--ext/pgsql/tests/09notice.phpt7
2 files changed, 13 insertions, 8 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index a77c80da16..99f5a74f21 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -264,15 +264,21 @@ static void _close_pgsql_plink(zend_rsrc_list_entry *rsrc TSRMLS_DC)
static void _php_pgsql_notice_handler(void *resource_id, const char *message)
{
php_pgsql_notice *notice;
+ int i;
TSRMLS_FETCH();
if (! PGG(ignore_notices)) {
+ notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice));
+ i = strlen(message)-1;
+ while (i && (message[i] == '\r' || message[i] == '\n')) {
+ i--;
+ }
+ i++;
+ notice->message = estrndup(message, i);
+ notice->len = i;
if (PGG(log_notices)) {
- php_log_err((char *) message TSRMLS_CC);
+ php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%s", notice->message);
}
- notice = (php_pgsql_notice *)emalloc(sizeof(php_pgsql_notice));
- notice->len = strlen(message);
- notice->message = estrndup(message, notice->len);
zend_hash_index_update(&PGG(notices), *(int *)resource_id, (void **)&notice, sizeof(php_pgsql_notice *), NULL);
}
}
diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt
index 55bbd28ed1..a2955b5c52 100644
--- a/ext/pgsql/tests/09notice.phpt
+++ b/ext/pgsql/tests/09notice.phpt
@@ -18,12 +18,11 @@ if ($msg === FALSE) {
echo "Cannot find notice message in hash\n";
var_dump($msg);
}
-echo $msg;
+echo $msg."\n";
echo "pg_last_notice() is Ok\n";
?>
---EXPECT--
-NOTICE: BEGIN: already a transaction in progress
-
+--EXPECTF--
+Notice: pg_query(): NOTICE: BEGIN: already a transaction in progress in %s on line %d
NOTICE: BEGIN: already a transaction in progress
pg_last_notice() is Ok