aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--caching-tests/test.ur7
-rw-r--r--src/sql.sml6
-rw-r--r--src/sqlcache.sml14
3 files changed, 15 insertions, 12 deletions
diff --git a/caching-tests/test.ur b/caching-tests/test.ur
index 510a5524..f6568db4 100644
--- a/caching-tests/test.ur
+++ b/caching-tests/test.ur
@@ -11,11 +11,10 @@ fun cache id =
| Some row => <xml>{[row.Tab.Val]}</xml>}
</body></xml>
-
fun flush id =
- dml (UPDATE tab
- SET Id = 29, Val = 42
- WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]});
+ dml (UPDATE tab
+ SET Val = Val * (Id + 2) / Val - 3
+ WHERE Id = {[id]} OR Id = {[id - 1]} OR Id = {[id + 1]});
return <xml><body>
Changed {[id]}!
</body></xml>
diff --git a/src/sql.sml b/src/sql.sml
index 959575e9..27894e3f 100644
--- a/src/sql.sml
+++ b/src/sql.sml
@@ -325,6 +325,11 @@ val funcName = altL [constK "COUNT",
constK "SUM",
constK "AVG"]
+fun arithmetic pExp = follow (const "(")
+ (follow pExp
+ (follow (altL (map const [" + ", " - ", " * ", " / "]))
+ (follow pExp (const ")"))))
+
val unmodeled = altL [const "COUNT(*)",
const "CURRENT_TIMESTAMP"]
@@ -340,6 +345,7 @@ fun sqexp chs =
wrap uw_ident Computed,
wrap known SqKnown,
wrap func SqFunc,
+ wrap (arithmetic sqexp) (fn _ => Unmodeled),
wrap unmodeled (fn () => Unmodeled),
wrap (if !sqlcacheMode then sqlifySqlcache else sqlify) Inj,
wrap (follow (const "COALESCE(") (follow sqexp (follow (const ",")
diff --git a/src/sqlcache.sml b/src/sqlcache.sml
index d5f6c1c0..5f737ac5 100644
--- a/src/sqlcache.sml
+++ b/src/sqlcache.sml
@@ -410,15 +410,13 @@ structure ConflictMaps = struct
List.foldr (fn (SOME eqs, SOME acc) => SOME (IM.unionWith #1 (eqs, acc)) | _ => NONE)
(SOME IM.empty)
+ val simplify =
+ map TS.listItems
+ o removeRedundant (fn (x, y) => TS.isSubset (y, x))
+ o map (fn xs => TS.addList (TS.empty, xs))
+
fun dnf (fQuery, fDml) =
- let
- val simplify =
- map TS.listItems
- o removeRedundant (fn (x, y) => TS.isSubset (y, x))
- o map (fn xs => TS.addList (TS.empty, xs))
- in
- normalize simplify negateCmp Disj (Combo (Conj, [markQuery fQuery, markDml fDml]))
- end
+ normalize simplify negateCmp Disj (Combo (Conj, [markQuery fQuery, markDml fDml]))
val conflictMaps = List.mapPartial (mergeEqs o map eqsOfClass o equivClasses) o dnf