From 93d6de491838eb3607a12686bfdc250366aa60e4 Mon Sep 17 00:00:00 2001 From: Ziv Scully Date: Tue, 25 Mar 2014 02:04:06 -0400 Subject: ML half of initial prototype. (Doesn't compile because there's no C yet.) --- caching-tests/test.ur | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ caching-tests/test.urp | 6 ++++ caching-tests/test.urs | 6 ++++ 3 files changed, 93 insertions(+) create mode 100644 caching-tests/test.ur create mode 100644 caching-tests/test.urp create mode 100644 caching-tests/test.urs (limited to 'caching-tests') diff --git a/caching-tests/test.ur b/caching-tests/test.ur new file mode 100644 index 00000000..4703e229 --- /dev/null +++ b/caching-tests/test.ur @@ -0,0 +1,81 @@ +table foo01 : {Id : int, Bar : string} PRIMARY KEY Id +table foo10 : {Id : int, Bar : string} PRIMARY KEY Id + +(* val query = (SELECT * FROM foo WHERE foo.Bar = "baz") *) +(* val insert = (INSERT INTO foo (Id, Bar) VALUES (42, "baz")) *) + +fun flush01 () : transaction page= + dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz")); + return + + + Flushed 1! + + + +fun flush10 () : transaction page= + dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz")); + return + + + Flushed 2! + + + +fun flush11 () : transaction page= + dml (INSERT INTO foo01 (Id, Bar) VALUES (42, "baz")); + dml (INSERT INTO foo10 (Id, Bar) VALUES (42, "baz")); + return + + + Flushed 1 and 2! + + + +fun cache01 () : transaction page = + res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar + FROM foo01 + WHERE foo01.Bar = "baz"); + return + + + Reading 1. + {case res of + None => + | Some row => {[row.Foo01.Bar]}} + + + +fun cache10 () : transaction page = + res <- oneOrNoRows (SELECT foo10.Id, foo10.Bar + FROM foo10 + WHERE foo10.Bar = "baz"); + return + + + Reading 2. + {case res of + None => + | Some row => {[row.Foo10.Bar]}} + + + +fun cache11 () : transaction page = + res <- oneOrNoRows (SELECT foo01.Id, foo01.Bar + FROM foo01 + WHERE foo01.Bar = "baz"); + bla <- oneOrNoRows (SELECT foo10.Id, foo10.Bar + FROM foo10 + WHERE foo10.Bar = "baz"); + return + + + Reading 1 and 2. + {case res of + None => + | Some row => {[row.Foo01.Bar]}} + {case bla of + None => + | Some row => {[row.Foo10.Bar]}} + + diff --git a/caching-tests/test.urp b/caching-tests/test.urp new file mode 100644 index 00000000..e5111220 --- /dev/null +++ b/caching-tests/test.urp @@ -0,0 +1,6 @@ +database dbname=test +safeGet Test/flush01 +safeGet Test/flush10 +safeGet Test/flush11 + +test diff --git a/caching-tests/test.urs b/caching-tests/test.urs new file mode 100644 index 00000000..ce7d0350 --- /dev/null +++ b/caching-tests/test.urs @@ -0,0 +1,6 @@ +val cache01 : unit -> transaction page +val cache10 : unit -> transaction page +val cache11 : unit -> transaction page +val flush01 : unit -> transaction page +val flush10 : unit -> transaction page +val flush11 : unit -> transaction page -- cgit v1.2.3