Skip to content

pgsqlSetNoticeCallback #4823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed

pgsqlSetNoticeCallback #4823

wants to merge 14 commits into from

Conversation

outtersg
Copy link
Contributor

Allows a callback to be triggered on every notice sent by PostgreSQL.

Such notices can be sent with a RAISE NOTICE in PL/pgSQL; in a long running
stored procedure, they prove useful as realtime checkpoint indicators.

@cmb69 cmb69 added the Feature label Oct 17, 2019
@cmb69
Copy link
Member

cmb69 commented Oct 28, 2019

@yohgaki, could you please check this?

outtersg added a commit to outtersg/php-src that referenced this pull request Jan 8, 2020
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request Jan 8, 2020
outtersg added a commit to outtersg/php-src that referenced this pull request Jan 8, 2020
@cmb69
Copy link
Member

cmb69 commented Jan 9, 2020

Thanks for working on this @outtersg, but this can't go into PHP-7.3 because that branch is closed for any new features. Maybe it's okay for PHP-7.4 (@derickr ?), but usually new features should target the master branch.

@derickr
Copy link
Member

derickr commented Jan 9, 2020

This should not go into 7.4 either as you say @cmb69

@outtersg
Copy link
Contributor Author

outtersg commented Jan 9, 2020

@ranvis, @cmb69, @derickr: thank you for your feedback.
I'm painly discovering memory management macros (so thank you too TravisCI for the feedback!), apparently what I did last night was not sufficient.
This evening I'll try finishing on my nicely configured 7.3 (the core dump seems to occur on Z_ADDREF_P of a static function name, maybe Z_TRY_ADDREF_P will do), then I'll switch to master.

outtersg and others added 12 commits January 9, 2020 20:29
Allows a callback to be triggered on every notice sent by PostgreSQL.

Such notices can be sent with a RAISE NOTICE in PL/pgSQL; in a long running
stored procedure, they prove useful as realtime checkpoint indicators.
Add a test for a standard pgsqlSetNoticeCallback use.
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
Move callback cleanup to a separate function.
The PostgreSQL-provided message was zvaled and not freed.
Discard non-null result of callback.
Core dumped when using a string callable.
@outtersg outtersg changed the base branch from PHP-7.3 to master January 10, 2020 03:48
outtersg added a commit to outtersg/guili that referenced this pull request Jan 10, 2020
# Prise en compte de php/php-src#4823 (comment)
= On essaie de faire converger les modifs sur PHP 7 et leur report en PHP 5.

darcs-hash:e027eb266470eaf8f8ea4bb6df11295f9b2f555b
@yohgaki
Copy link
Contributor

yohgaki commented Jan 10, 2020

It seems this patch addresses known NOTICE shortcoming. I cannot be sure if it addresses all shortcomings.
I'll check this during weekend.

@outtersg
Copy link
Contributor Author

@yohgaki: to be honest, I would say that we could obtain more details using PQsetNoticeReceiver instead of PQsetNoticeProcessor. Maybe dissociate the level and the message, get the call stack *…

But I think this could be studied in a second time, without breaking what has been done here: even if reimplementing on PQsetNoticeReceiver, the message would still be passed as the first callback param (after all, it's the main thing we're interested in); and details would go into additional, optional parameters of the callback.

* Incidentally, the only locations where I found info on those hypothetical additional fields are PHP pgsql's doc (https://www.php.net/manual/pgsql.constants.php, look for pg_result_error_field()) and Symfony's code (https://github.com/symfony/var-dumper/blob/master/Caster/PgSqlCaster.php)

@outtersg
Copy link
Contributor Author

(that said, I would be honored if you could find the time to review this iteration of the enhancement, @yohgaki)

outtersg added a commit to outtersg/php-src that referenced this pull request Mar 18, 2021
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
@outtersg
Copy link
Contributor Author

Superseded by #6764 (which targets master).

@outtersg outtersg closed this Oct 25, 2021
outtersg added a commit to outtersg/php-src that referenced this pull request Oct 26, 2021
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request Apr 17, 2024
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request Apr 17, 2024
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request Apr 17, 2024
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request Apr 17, 2024
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
outtersg added a commit to outtersg/php-src that referenced this pull request May 21, 2024
php#4823 (comment)
Closure cannot be used as a callback if not persisted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants