I'm prototyping an extension in which I need to execute a C function repeatedly on a timer as part of a sql execution hook, and end it when I choose.
I've spent the time reading these lists, the documentation etc and the only solution I saw that wouldn't require a patch was user-definable timeouts https://github.com/postgres/postgres/blob/master/src/include/utils/timeout.h#L40 <https://github.com/postgres/postgres/blob/master/src/include/utils/timeout.h#L40>. I have a working implementation that at a high level does the following /* register and enable the timeout to call my_handler_proc every second */ tId = RegisterTimeout(USER_TIMEOUT, my_handler_proc); enable_timeout_after((int)tId, 1000); ... /* stop the timeout */ disable_timeout((int)tId, 0); Note: I'm also working on the code to ensure I don't try to allocate beyond MAX_TIMEOUTS but I haven't shown that here for brevity. My question really is: should I be doing this? Is it safe? I can't find this documented nor any other examples of code that uses this which is a red flag for me. Thanks in advance, Steve.