X-Git-Url: http://matita.cs.unibo.it/gitweb/?p=helm.git;a=blobdiff_plain;f=helm%2Focaml%2Fmathql_interpreter%2FmQIConn.ml;h=11dbd1674a058ada15206614b505aee47dd8198f;hp=a51242bef323373ca38be15b6efdda5c4d0d338b;hb=1c7fb836e2af4f2f3d18afd0396701f2094265ff;hpb=2122459392680c4b53e32a2cf1d4792405f118ce diff --git a/helm/ocaml/mathql_interpreter/mQIConn.ml b/helm/ocaml/mathql_interpreter/mQIConn.ml index a51242bef..11dbd1674 100644 --- a/helm/ocaml/mathql_interpreter/mQIConn.ml +++ b/helm/ocaml/mathql_interpreter/mQIConn.ml @@ -28,10 +28,19 @@ type flag = Postgres | Galax | Stat | Quiet | Warn | Log -type handle = {log : string -> unit; (* logging function *) - set : flag list; (* options *) - pgc : Postgres.connection option (* Postgres connection *) - } +type handle = { + log : string -> unit; (* logging function *) + set : flag list; (* options *) + pgc : Postgres.connection option; (* PG connection *) + pgm : MQIMap.pg_map; (* PG conversion function *) + pga : MQIMap.pg_alias (* PG table aliases *) +} + +let tables handle p = MQIMap.get_tables handle.pgm p + +let field handle p t = MQIMap.get_field handle.pgm p t + +let resolve handle a = MQIMap.resolve handle.pga a let log handle = handle.log @@ -70,9 +79,15 @@ let flags_of_string s = string_fold_left (fun l c -> l @ flag_of_char c) [] s let init myflags mylog = + let s, m, a = + let g = + if List.mem Galax myflags + then MQIMap.empty_map else MQIMap.read_map + in g () + in {log = mylog; set = myflags; - pgc = if List.mem Galax myflags - then None else MQIPostgres.init () + pgc = if List.mem Galax myflags then None else MQIPostgres.init s; + pgm = m; pga = a } let close handle =