Skip to content

Commit 147471b

Browse files
author
Jonathan Curran
committed
Update notification to include "extra" parameter
1 parent 0c66e90 commit 147471b

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

examples/prompt.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ let rec dump_res conn =
4949

5050
let rec dump_notification conn =
5151
match conn#notifies with
52-
| Some (msg, pid) ->
53-
printf "Notication from backend %i: [%s]\n" pid msg;
52+
| Some (msg, pid, extra) ->
53+
printf "Notication from backend %i: [%s] [%s]\n" pid msg extra;
5454
flush stdout;
5555
dump_notification conn
5656
| None -> ()

examples/prompt_gtk.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,8 @@ let main () =
147147

148148
let rec dump_notification () =
149149
match conn#notifies with
150-
| Some (msg, pid) ->
151-
let _ = clist#append [string_of_int pid; msg] in
150+
| Some (msg, pid, extra) ->
151+
let _ = clist#append [string_of_int pid; msg; extra] in
152152
window#show ();
153153
dump_notification ()
154154
| None -> () in

lib/postgresql.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ module Stub = struct
452452

453453
(* Asynchronous Notification *)
454454

455-
external notifies : connection -> (string * int) option = "PQnotifies_stub"
455+
external notifies : connection -> (string * int * string) option = "PQnotifies_stub"
456456

457457

458458
(* Functions Associated with the COPY Command *)

lib/postgresql.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ object
468468

469469
(** Asynchronous Notification *)
470470

471-
method notifies : (string * int) option
471+
method notifies : (string * int * string) option
472472
(** [#notifies] @return [Some (name, pid)] if available ([None]
473473
otherwise), where [name] is the name the of relation containing
474474
data, [pid] the process id of the backend.

lib/postgresql_stubs.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,14 +1006,17 @@ CAMLprim value PQnotifies_stub(value v_conn)
10061006
{
10071007
CAMLparam1(v_conn);
10081008
CAMLlocal1(v_str);
1009+
CAMLlocal1(v_extra);
10091010
PGnotify *noti = PQnotifies(get_conn(v_conn));
10101011

10111012
if (noti) {
10121013
value v_pair;
10131014
v_str = make_string(noti->relname);
1014-
v_pair = caml_alloc_small(2, 0);
1015+
v_pair = caml_alloc_small(3, 0);
1016+
v_extra = make_string(noti->extra);
10151017
Field(v_pair, 0) = v_str;
10161018
Field(v_pair, 1) = Val_int(noti->be_pid);
1019+
Field(v_pair, 2) = v_extra;
10171020
PQfreemem(noti);
10181021
CAMLreturn(make_some(v_pair));
10191022
}

0 commit comments

Comments
 (0)