Skip to content
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

WIP: Replace errorhandler mechanism. #903

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

WIP: Replace errorhandler mechanism. #903

wants to merge 7 commits into from

Conversation

jtv
Copy link
Owner

@jtv jtv commented Nov 16, 2024

Deprecating errorhandler. The whole mechanism is outdated and clunky
and also horribly broken when a handler survives its connection.
Turns out PGresult keeps a pointer to the same handler that the
PGconn had, so it can still send notices even after you've closed the
connection.

Trying to fix this with the existing mechanism would still break the
ABI. (At least without infernal and probably non-portable trickery.)
So this is more than a "patch-level" version bump.

Instead of modernising the whole mechanism, I'm also simplifying it.
I doubt many people will need chains of handlers, with the option
for handlers to request bypassing of the following handlers. And for
those rare cases where that's useful, it's probably easier for the
application to implement the call chain itself!

Deprecating `errorhandler`.  The whole mechanism is outdated and clunky
and also horribly _broken_ when a handler survives its `connection`.
Turns out `PGresult` keeps a pointer to the same handler that the
`PGconn` had, so it can still send notices even after you've closed the
connection.

Trying to fix this with the existing mechanism would still break the
ABI.  (At least without infernal and probably non-portable trickery.)

Instead of modernising the whole mechanism, I'm also simplifying it.
I doubt many people will need _chains_ of handlers, with the option
for handlers to request bypassing of the following handlers.  And for
those rare cases where that's useful, it's probably easier for the
application to implement the call chain itself!
test/unit/test_notice_handler.cxx Fixed Show fixed Hide fixed
test/unit/test_notice_handler.cxx Dismissed Show dismissed Hide dismissed
Had to make it a `shared_ptr`.  But now I guess I'll need to register a
deleter on it to get the cleanup right.
@jtv jtv changed the title Replace errorhandler mechanism. WIP: Replace errorhandler mechanism. Nov 16, 2024

namespace
{
void test_notice_handler_receives_notice()

Check notice

Code scanning / CodeQL

Unused static function Note test

Static function test_notice_handler_receives_notice is unreachable (
tst_test_notice_handler_receives_notice
must be removed at the same time)
}


void test_process_notice_calls_notice_handler()

Check notice

Code scanning / CodeQL

Unused static function Note test

Static function test_process_notice_calls_notice_handler is unreachable (
tst_test_process_notice_calls_notice_handler
must be removed at the same time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant