summaryrefslogtreecommitdiff
path: root/lib/ur/top.ur
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-03-29 13:30:01 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-03-29 13:30:01 -0400
commit5430dbfa3f1c7c0adaabc230e86ffd90e6f923da (patch)
tree3bd72d9c87173e9ba21a556e5b90841f36e24651 /lib/ur/top.ur
parent6217967a353bc9d97ae45c2af495b653a47e2481 (diff)
Expunging non-nullable rows
Diffstat (limited to 'lib/ur/top.ur')
-rw-r--r--lib/ur/top.ur20
1 files changed, 5 insertions, 15 deletions
diff --git a/lib/ur/top.ur b/lib/ur/top.ur
index 5465da3d..154e88e9 100644
--- a/lib/ur/top.ur
+++ b/lib/ur/top.ur
@@ -200,7 +200,7 @@ fun eqNullable' (tables ::: {{Type}}) (agg ::: {{Type}}) (exps ::: {Type})
functor Broadcast(M : sig type t end) = struct
sequence s
- table t : {Id : int, Client : option client, Channel : option (channel M.t)}
+ table t : {Id : int, Client : client, Channel : channel M.t}
type topic = int
@@ -208,27 +208,17 @@ functor Broadcast(M : sig type t end) = struct
val create = nextval s
- val cleanup =
- dml (DELETE FROM t WHERE Client IS NULL)
-
fun subscribe id =
cli <- self;
- cleanup;
- ro <- oneOrNoRows (SELECT t.Channel FROM t WHERE t.Id = {[id]} AND t.Client = {[Some cli]});
+ ro <- oneOrNoRows (SELECT t.Channel FROM t WHERE t.Id = {[id]} AND t.Client = {[cli]});
case ro of
None =>
ch <- channel;
- dml (INSERT INTO t (Id, Client, Channel) VALUES ({[id]}, {[Some cli]}, {[Some ch]}));
+ dml (INSERT INTO t (Id, Client, Channel) VALUES ({[id]}, {[cli]}, {[ch]}));
return ch
- | Some r =>
- case r.T.Channel of
- None => error <xml>Broadcast.subscribe: Got null result</xml>
- | Some ch => return ch
+ | Some r => return r.T.Channel
fun send id msg =
- cleanup;
queryI (SELECT t.Channel FROM t WHERE t.Id = {[id]})
- (fn r => case r.T.Channel of
- None => error <xml>Broadcast.send: Got null result</xml>
- | Some ch => Basis.send ch msg)
+ (fn r => Basis.send r.T.Channel msg)
end