Req #78621 [NEW]: pgsqlSetNoticeCallback
| From: | guillaume-php at outters dot eu | Date: | Wed, 02 Oct 2019 05:04:53 +0000 |
| Subject: | Req #78621 [NEW]: pgsqlSetNoticeCallback | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-222981@lists.php.net to get a copy of this message | ||
From: guillaume-php at outters dot eu
Operating system: all
PHP version: 7.3.10
Package: PDO PgSQL
Bug Type: Feature/Change Request
Bug description:pgsqlSetNoticeCallback
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 bug report at https://bugs.php.net/bug.php?id=78621&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=78621&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78621&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78621&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78621&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78621&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78621&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78621&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78621&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78621&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78621&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=78621&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=78621&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78621&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78621&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78621&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78621&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78621&r=mysqlcfg