comparison src/settings.sml @ 867:e7f80d78075b

Moved query code into Settings
author Adam Chlipala <adamc@hcoop.net>
date Sun, 28 Jun 2009 16:03:00 -0400
parents 03e7f111fe99
children 06497beb265b
comparison
equal deleted inserted replaced
866:03e7f111fe99 867:e7f80d78075b
272 272
273 val debug = ref false 273 val debug = ref false
274 fun setDebug b = debug := b 274 fun setDebug b = debug := b
275 fun getDebug () = !debug 275 fun getDebug () = !debug
276 276
277 datatype sql_type =
278 Int
279 | Float
280 | String
281 | Bool
282 | Time
283 | Blob
284 | Channel
285 | Client
286 | Nullable of sql_type
287
288 fun p_sql_type t =
289 let
290 open Print.PD
291 open Print
292 in
293 case t of
294 Int => string "uw_Basis_int"
295 | Float => string "uw_Basis_float"
296 | String => string "uw_Basis_string"
297 | Bool => string "uw_Basis_bool"
298 | Time => string "uw_Basis_time"
299 | Blob => string "uw_Basis_blob"
300 | Channel => string "uw_Basis_channel"
301 | Client => string "uw_Basis_client"
302 | Nullable String => string "uw_Basis_string"
303 | Nullable t => box [p_sql_type t, string "*"]
304 end
305
306 fun isBlob Blob = true
307 | isBlob (Nullable t) = isBlob t
308 | isBlob _ = false
309
277 type dbms = { 310 type dbms = {
278 name : string, 311 name : string,
279 header : string, 312 header : string,
280 link : string, 313 link : string,
281 global_init : Print.PD.pp_desc, 314 global_init : Print.PD.pp_desc,
282 init : string * (string * int) list -> Print.PD.pp_desc 315 init : string * (string * int) list -> Print.PD.pp_desc,
316 query : {loc : ErrorMsg.span, numCols : int,
317 doCols : ({wontLeakStrings : bool, col : int, typ : sql_type} -> Print.PD.pp_desc)
318 -> Print.PD.pp_desc}
319 -> Print.PD.pp_desc,
320 queryPrepared : {loc : ErrorMsg.span, id : int, query : string,
321 inputs : sql_type list, numCols : int,
322 doCols : ({wontLeakStrings : bool, col : int, typ : sql_type} -> Print.PD.pp_desc)
323 -> Print.PD.pp_desc}
324 -> Print.PD.pp_desc
283 } 325 }
284 326
285 val dbmses = ref ([] : dbms list) 327 val dbmses = ref ([] : dbms list)
286 val curDb = ref ({name = "", 328 val curDb = ref ({name = "",
287 header = "", 329 header = "",
288 link = "", 330 link = "",
289 global_init = Print.box [], 331 global_init = Print.box [],
290 init = fn _ => Print.box []} : dbms) 332 init = fn _ => Print.box [],
333 query = fn _ => Print.box [],
334 queryPrepared = fn _ => Print.box []} : dbms)
291 335
292 fun addDbms v = dbmses := v :: !dbmses 336 fun addDbms v = dbmses := v :: !dbmses
293 fun setDbms s = 337 fun setDbms s =
294 case List.find (fn db => #name db = s) (!dbmses) of 338 case List.find (fn db => #name db = s) (!dbmses) of
295 NONE => raise Fail ("Unknown DBMS " ^ s) 339 NONE => raise Fail ("Unknown DBMS " ^ s)