User timeouts for scheduling functions
От | Steve Senior |
---|---|
Тема | User timeouts for scheduling functions |
Дата | |
Msg-id | B0344A8C-9D4A-4838-B362-52BCB1CFE928@googlemail.com обсуждение исходный текст |
Список | pgsql-hackers |
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.
I have a working implementation that at a high level does the following
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.
В списке pgsql-hackers по дате отправления: