-mQIConn.cmi: mQIMap.cmi
+mQIMySql.cmi: mQITypes.cmo
+mQIPostgres.cmi: mQITypes.cmo
+mQIConn.cmi: mQIMap.cmi mQITypes.cmo
mQILib.cmi: mQIConn.cmi
mQIProperty.cmi: mQIConn.cmi
mQueryIO.cmi: mQILib.cmi
mQueryInterpreter.cmi: mQIConn.cmi
+mQIMySql.cmo: mQIMySql.cmi
+mQIMySql.cmx: mQIMySql.cmi
mQIPostgres.cmo: mQIPostgres.cmi
mQIPostgres.cmx: mQIPostgres.cmi
mQIMap.cmo: mQIMap.cmi
mQIMap.cmx: mQIMap.cmi
-mQIConn.cmo: mQIMap.cmi mQIPostgres.cmi mQIConn.cmi
-mQIConn.cmx: mQIMap.cmx mQIPostgres.cmx mQIConn.cmi
+mQIConn.cmo: mQIMap.cmi mQIMySql.cmi mQIPostgres.cmi mQIConn.cmi
+mQIConn.cmx: mQIMap.cmx mQIMySql.cmx mQIPostgres.cmx mQIConn.cmi
mQILib.cmo: mQIConn.cmi mQILib.cmi
mQILib.cmx: mQIConn.cmx mQILib.cmi
-mQIProperty.cmo: mQIConn.cmi mQIMap.cmi mQIPostgres.cmi mQIProperty.cmi
-mQIProperty.cmx: mQIConn.cmx mQIMap.cmx mQIPostgres.cmx mQIProperty.cmi
+mQIProperty.cmo: mQIConn.cmi mQIMap.cmi mQIProperty.cmi
+mQIProperty.cmx: mQIConn.cmx mQIMap.cmx mQIProperty.cmi
mQueryTParser.cmo: mQILib.cmi mQueryTParser.cmi
mQueryTParser.cmx: mQILib.cmx mQueryTParser.cmi
mQueryTLexer.cmo: mQueryTParser.cmi
PACKAGE = mathql_interpreter
-REQUIRES = postgres helm-registry helm-mathql
+REQUIRES = postgres mysql helm-registry helm-mathql
#natile-galax
PREDICATES =
-PRE_IFILES = mQIPostgres.mli mQIMap.mli mQIConn.mli \
+PRE_IFILES = mQIMySql.mli mQIPostgres.mli mQIMap.mli mQIConn.mli \
mQILib.mli mQIProperty.mli
POST_IFILES = mQueryIO.mli mQueryInterpreter.mli mQueryStandard.mli
INTERFACE_FILES = $(PRE_IFILES) $(POST_IFILES)
-IMPLEMENTATION_FILES = $(PRE_IFILES:%.mli=%.ml) \
+IMPLEMENTATION_FILES = mQITypes.ml \
+ $(PRE_IFILES:%.mli=%.ml) \
mQueryTParser.ml mQueryTLexer.ml \
$(POST_IFILES:%.mli=%.ml)
-EXTRA_OBJECTS_TO_INSTALL = mQITypes.cmi mQueryTLexer.cmi \
+EXTRA_OBJECTS_TO_INSTALL = mQITypes.ml mQITypes.cmi \
+ mQITypes.cmi mQueryTLexer.cmi \
mQITypes.ml mQueryTLexer.mll mQueryTParser.mly
EXTRA_OBJECTS_TO_CLEAN = mQueryTParser.ml mQueryTParser.mli \
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
+module I = MathQL.I
+
let init () =
try Mysql.quick_connect
~host:"mowgli.cs.unibo.it" ~database:"mowgli" ~user:"helm" ()
| [head] -> f head
| head :: tail -> f head ^ sep ^ iter f sep tail
in
+ let avs_iter f sep v =
+ let aux a s = function
+ | true -> a ^ (f s) ^ sep
+ | false -> a ^ (f s)
+ in
+ I.iter aux "" v
+ in
let pg_cols = iter (fun x -> x) ", " cols in
- let pg_msval v = iter quote ", " v in
+ let pg_msval v = avs_iter quote ", " v in
let pg_con (pat, col, v) =
if col <> "" then
- let f s = col ^ " regexp " ^ quote ("^" ^ s ^ "$") in
- if pat then "(" ^ iter f " or " v ^ ")"
- else match v with
- | [s] -> "binary " ^ col ^ " = " ^ (quote s)
- | v -> "binary " ^ col ^ " in (" ^ pg_msval v ^ ")"
+ let f s = col ^ " regexp " ^ quote ("^" ^ s ^ "$") in
+ if pat then "(" ^ avs_iter f " or " v ^ ")"
+ else match I.single v with
+ | Some s -> "binary " ^ col ^ " = " ^ (quote s)
+ | None -> "binary " ^ col ^ " in (" ^ pg_msval v ^ ")"
else "1"
in
let pg_cons l = iter pg_con " and " l in
| _ -> [], q
else
exec c ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^
- " order by " ^ List.hd cols ^ " asc")
+ " order by " ^ List.hd cols ^ " asc") (* desc *)
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
+module I = MathQL.I
+
let init () =
let connection_string =
Helm_registry.get "mathql_interpreter.postgresql_connection_string"
| [head] -> f head
| head :: tail -> f head ^ sep ^ iter f sep tail
in
+ let avs_iter f sep v =
+ let aux a s = function
+ | true -> a ^ (f s) ^ sep
+ | false -> a ^ (f s)
+ in
+ I.iter aux "" v
+ in
let pg_cols = iter (fun x -> x) ", " cols in
- let pg_msval v = iter quote ", " v in
+ let pg_msval v = avs_iter quote ", " v in
let pg_con (pat, col, v) =
if col <> "" then
let f s = col ^ " ~ " ^ quote ("^" ^ s ^ "$") in
- if pat then "(" ^ iter f " or " v ^ ")"
- else match v with
- | [s] -> col ^ " = " ^ (quote s)
- | v -> col ^ " in (" ^ pg_msval v ^ ")"
+ if pat then "(" ^ avs_iter f " or " v ^ ")"
+ else match I.single v with
+ | Some s -> col ^ " = " ^ (quote s)
+ | None -> col ^ " in (" ^ pg_msval v ^ ")"
else "true"
in
let pg_cons l = iter pg_con " and " l in
| _ -> [], q
else
exec c ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^
- " order by " ^ List.hd cols ^ " asc")
+ " order by " ^ List.hd cols ^ " asc") (* desc *)
(* funzioni vecchie ********************************************************)
(*
module M = MathQL
module I = M.I
module U = AvsUtil
-module P = MQIPostgres
module C = MQIConn
module A = MQIMap
in
List.iter c_print l
-(* PostgreSQL backend ******************************************************)
-
-let pg_query h table cols ct cfl =
- let exec q =
- if C.set h C.Queries then C.log h (q ^ "\n");
- P.exec (C.pgc h) q
- in
- let rec iter f sep = function
- | [] -> ""
- | [head] -> f head
- | head :: tail -> f head ^ sep ^ iter f sep tail
- in
- let avs_iter f sep v =
- let aux a s = function
- | true -> a ^ (f s) ^ sep
- | false -> a ^ (f s)
- in
- I.iter aux "" v
- in
- let pg_cols = iter (fun x -> x) ", " cols in
- let pg_msval v = avs_iter P.quote ", " v in
- let pg_con (pat, col, v) =
- if col <> "" then
- let f s = col ^ " ~ " ^ P.quote ("^" ^ s ^ "$") in
- if pat then "(" ^ avs_iter f " or " v ^ ")"
- else match I.single v with
- | Some s -> col ^ " = " ^ (P.quote s)
- | None -> col ^ " in (" ^ pg_msval v ^ ")"
- else "true"
- in
- let pg_cons l = iter pg_con " and " l in
- let pg_cons_not l = "not (" ^ pg_cons l ^ ")" in
- let pg_cons_not_l ll = iter pg_cons_not " and " ll in
- let pg_where = match ct, cfl with
- | [], [] -> ""
- | lt, [] -> " where " ^ pg_cons lt
- | [], llf -> " where " ^ pg_cons_not_l llf
- | lt, llf -> " where " ^ pg_cons lt ^ " and " ^ pg_cons_not_l llf
- in
- if cols = [] then
- let r = exec ("select count (source) from " ^ table ^ pg_where) in
- match r with
- | [[s]] when int_of_string s > 0 -> [[]]
- | _ -> []
- else
- exec ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^
- " order by " ^ List.hd cols ^ " asc") (* desc *)
-
-(* Galax backend ***********************************************************)
-
-let gx_query h table cols ct cfl = not_supported "Galax"
-
(* Common functions ********************************************************)
let pg_result subj el res =
let cons_false = List.map mk_con cfl in
let other_cols = List.map (fun (p, _) -> conv p) el in
let cols = if first = "" then other_cols else first :: other_cols in
- let low_level = if C.set h C.Galax then gx_query else pg_query in
- let result = low_level h (C.resolve h table) cols cons_true cons_false in
+ let result, q = C.exec h (C.resolve h table) cols cons_true cons_false in
+ if C.set h C.Queries then C.log h (q ^ "\n");
pg_result first el result
let deadline = 100
| _ ->
exec_single h mc ct cfl el table
in exec_aux ct
-
-(* funzioni vecchie ********************************************************)
-
-let pg_name h s =
- let q = "select id from registry where uri = " ^ P.quote s in
- match P.exec h q with
- | [[id]] -> "t" ^ id
- | _ -> ""
-
-let get_id b = if b then ["B"] else ["F"]
-
(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
*)
-type 'a con = MathQL.pattern * 'a * MathQL.value
+type 'a con = MathQL.pattern * 'a * MathQL.result
type 'a con_true = 'a con list