Req #78621 [PATCH]: pgsqlSetNoticeCallback

From: Date: Sun, 13 Oct 2019 23:17:06 +0000
Subject: Req #78621 [PATCH]: pgsqlSetNoticeCallback
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-223198@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78621&edit=1 ID: 78621 Patch added by: guillaume-php@outters.eu Reported by: guillaume-php at outters dot eu Summary: pgsqlSetNoticeCallback Status: Open Type: Feature/Change Request Package: PDO PgSQL Operating System: all PHP Version: 7.3.10 Block user comment: N Private report: N New Comment: The following pull request has been associated: Patch Name: pgsqlSetNoticeCallback On GitHub: https://github.com/php/php-src/pull/4823 Patch: https://github.com/php/php-src/pull/4823.patch Previous Comments: ------------------------------------------------------------------------ [2019-10-02 05:05:18] guillaume-php at outters dot eu The following patch has been added/updated: Patch Name: pgsqlSetNoticeCallback.7.diff Revision: 1569992718 URL: https://bugs.php.net/patch-display.php?bug=78621&patch=pgsqlSetNoticeCallback.7.diff&revision=1569992718 ------------------------------------------------------------------------ [2019-10-02 05:04:53] guillaume-php at outters dot eu Description: ------------ There is currently no way to receive PostgreSQL's notices PHP-side. A PQsetNoticeProcessor has been defined 15 years ago to the empty function _pdo_pgsql_notice, to prevent libpq's default behaviour (fprintfing to stderr)). Passing notices to PHP could prove useful, allowing e.g. user-defined RAISE NOTICE in PL/pgSQL long-running code to provide feedback. A user-space callback would give more control on what to do with the message (compared to the exec-then-fetch method of non-PDO pgsql driver's pg_last_notice)… not the least being the live feedback ability. Test script: --------------- function disp($message) { echo trim($message)."\n"; } $db = new PDO('pgsql:host=localhost;port=5432;dbname=…', '', ''); if(method_exists($db, 'pgsqlSetNoticeCallback')) $db->pgsqlSetNoticeCallback('disp'); $db->beginTransaction(); $db->exec("create temporary table t (a varchar(3))"); $db->exec("create function hey() returns trigger as \$\$ begin new.a := 'oh'; raise notice 'I tampered your data, did you know?'; return new; end; \$\$ language plpgsql"); $db->exec("create trigger hop before insert on t for each row execute procedure hey()"); $db->exec("insert into t values ('ah')"); print_r($db->query("select * from t")->fetchAll()); Expected result: ---------------- I would like to know that a trigger triggered ("I tampered your data, did you know?"). Actual result: -------------- Only tcpdump will display my carefully-crafted RAISE NOTICE. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=78621&edit=1

« previous php.bugs (#223198) next »