-
Notifications
You must be signed in to change notification settings - Fork 49
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
Support for LISTEN/NOTIFY #242
Comments
You can access this using the C API in LibPQ.libpq_c, the function is listed here: https://www.postgresql.org/docs/14/libpq-notify.html However, receiving notifications is unfortunately tied to consuming input or executing queries. If you're fine waiting for queries, you can call |
thanks for the pointers - I'll have a look and will post a mwe here before closing the issue. At the moment, I'm not interested in async or multi-threaded operation. |
hi @iamed2 - I managed to identify whenever a notification is sent but I am struggling to get the payload. My code is the following: using LibPQ
using ConfigEnv
dotenv()
lpqc = LibPQ.libpq_c
function onenotify()
conn = lpqc.PQconnectdb(ENV["EXPCONNSTR"])
res = lpqc.PQexec(conn, "LISTEN virtual")
lpqc.PQclear(res)
while true
notify = lpqc.PQnotifies(conn)
if notify != C_NULL
@show notify
lpqc.PQfreeNotify(notify)
break
end
lpqc.PQfreeNotify(notify)
lpqc.PQconsumeInput(conn)
sleep(1)
end
lpqc.PQfinish(conn)
end Calling this function results in: julia> onenotify()
notify = Ptr{Nothing} @0x0000000004cbed50
julia> any hints on how to convert this to Thank you for your time and apologies for my poor C... |
Ah, I noticed that there is a Even without changing the return type of the ccall in tmp = unsafe_load(Ptr{lpqc.pqNotify}(onenotify())) |
Thank you - I raised #245 with the fix you suggested. |
Is there support for LISTEN/NOTIFY as per this? I didn't see any examples in the docs and not sure how to go about it.
The text was updated successfully, but these errors were encountered: