annotate caching-tests/test.ur @ 2203:39faa4a037f4

ML half of initial prototype. (Doesn't compile because there's no C yet.)
author Ziv Scully <ziv@mit.edu>
date Tue, 25 Mar 2014 02:04:06 -0400
parents
children 01c8aceac480
rev   line source
ziv@2203 1 table foo01 : {Id : int, Bar : string} PRIMARY KEY Id
ziv@2203 2 table foo10 : {Id : int, Bar : string} PRIMARY KEY Id
ziv@2203 3
ziv@2203 4 (* val query = (SELECT * FROM foo WHERE foo.Bar = "baz") *)
ziv@2203 5 (* val insert = (INSERT INTO foo (Id, Bar) VALUES (42, "baz")) *)
ziv@2203 6
ziv@2203 7 fun flush01 () : transaction page=
ziv@2203 8 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
ziv@2203 9 return
ziv@2203 10 <xml>
ziv@2203 11 <body>
ziv@2203 12 Flushed 1!
ziv@2203 13 </body>
ziv@2203 14 </xml>
ziv@2203 15
ziv@2203 16 fun flush10 () : transaction page=
ziv@2203 17 dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
ziv@2203 18 return
ziv@2203 19 <xml>
ziv@2203 20 <body>
ziv@2203 21 Flushed 2!
ziv@2203 22 </body>
ziv@2203 23 </xml>
ziv@2203 24
ziv@2203 25 fun flush11 () : transaction page=
ziv@2203 26 dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz"));
ziv@2203 27 dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz"));
ziv@2203 28 return
ziv@2203 29 <xml>
ziv@2203 30 <body>
ziv@2203 31 Flushed 1 and 2!
ziv@2203 32 </body>
ziv@2203 33 </xml>
ziv@2203 34
ziv@2203 35 fun cache01 () : transaction page =
ziv@2203 36 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
ziv@2203 37 FROM foo01
ziv@2203 38 WHERE foo01.Bar = "baz");
ziv@2203 39 return
ziv@2203 40 <xml>
ziv@2203 41 <body>
ziv@2203 42 Reading 1.
ziv@2203 43 {case res of
ziv@2203 44 None => <xml></xml>
ziv@2203 45 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
ziv@2203 46 </body>
ziv@2203 47 </xml>
ziv@2203 48
ziv@2203 49 fun cache10 () : transaction page =
ziv@2203 50 res <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
ziv@2203 51 FROM foo10
ziv@2203 52 WHERE foo10.Bar = "baz");
ziv@2203 53 return
ziv@2203 54 <xml>
ziv@2203 55 <body>
ziv@2203 56 Reading 2.
ziv@2203 57 {case res of
ziv@2203 58 None => <xml></xml>
ziv@2203 59 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
ziv@2203 60 </body>
ziv@2203 61 </xml>
ziv@2203 62
ziv@2203 63 fun cache11 () : transaction page =
ziv@2203 64 res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar
ziv@2203 65 FROM foo01
ziv@2203 66 WHERE foo01.Bar = "baz");
ziv@2203 67 bla <- oneOrNoRows (SELECT foo10.Id, foo10.Bar
ziv@2203 68 FROM foo10
ziv@2203 69 WHERE foo10.Bar = "baz");
ziv@2203 70 return
ziv@2203 71 <xml>
ziv@2203 72 <body>
ziv@2203 73 Reading 1 and 2.
ziv@2203 74 {case res of
ziv@2203 75 None => <xml></xml>
ziv@2203 76 | Some row => <xml>{[row.Foo01.Bar]}</xml>}
ziv@2203 77 {case bla of
ziv@2203 78 None => <xml></xml>
ziv@2203 79 | Some row => <xml>{[row.Foo10.Bar]}</xml>}
ziv@2203 80 </body>
ziv@2203 81 </xml>