Mercurial > urweb
comparison src/cjr_print.sml @ 1936:6745eafff617
Start SQL transactions as read-only when possible, based on conservative program analysis
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Thu, 12 Dec 2013 17:42:48 -0500 |
parents | fda9d5af69e7 |
children | 94f9570671f0 |
comparison
equal
deleted
inserted
replaced
1935:fda9d5af69e7 | 1936:6745eafff617 |
---|---|
2999 | _ => raise Fail "CjrPrint: Last argument to an action isn't a record") | 2999 | _ => raise Fail "CjrPrint: Last argument to an action isn't a record") |
3000 | _ => (List.take (ts, length ts - 1), string "", string "", NONE) | 3000 | _ => (List.take (ts, length ts - 1), string "", string "", NONE) |
3001 | 3001 |
3002 fun couldWrite ek = | 3002 fun couldWrite ek = |
3003 case ek of | 3003 case ek of |
3004 Link => false | 3004 Link _ => false |
3005 | Action ef => ef = ReadCookieWrite | 3005 | Action ef => ef = ReadCookieWrite |
3006 | Rpc ef => ef = ReadCookieWrite | 3006 | Rpc ef => ef = ReadCookieWrite |
3007 | Extern _ => false | 3007 | Extern _ => false |
3008 | |
3009 fun couldWriteDb ek = | |
3010 case ek of | |
3011 Link ef => ef <> ReadOnly | |
3012 | Action ef => ef <> ReadOnly | |
3013 | Rpc ef => ef <> ReadOnly | |
3014 | Extern ef => ef <> ReadOnly | |
3008 | 3015 |
3009 val s = | 3016 val s = |
3010 case Settings.getUrlPrefix () of | 3017 case Settings.getUrlPrefix () of |
3011 "" => s | 3018 "" => s |
3012 | "/" => s | 3019 | "/" => s |
3089 in | 3096 in |
3090 string scripts | 3097 string scripts |
3091 end, | 3098 end, |
3092 string "\");", | 3099 string "\");", |
3093 newline]), | 3100 newline]), |
3101 string "uw_set_could_write_db(ctx, ", | |
3102 string (if couldWriteDb ek then "1" else "0"), | |
3103 string ");", | |
3104 newline, | |
3094 string "uw_set_needs_push(ctx, ", | 3105 string "uw_set_needs_push(ctx, ", |
3095 string (case side of | 3106 string (case side of |
3096 ServerAndPullAndPush => "1" | 3107 ServerAndPullAndPush => "1" |
3097 | _ => "0"), | 3108 | _ => "0"), |
3098 string ");", | 3109 string ");", |