[MLton-commit] r5225
Wesley Terpstra
wesley at mlton.org
Fri Feb 16 11:38:43 PST 2007
support meta-data when its support is compiled in
----------------------------------------------------------------------
U mltonlib/trunk/ca/terpstra/sqlite3/prim.sig
U mltonlib/trunk/ca/terpstra/sqlite3/prim.sml
U mltonlib/trunk/ca/terpstra/sqlite3/sql.sig
U mltonlib/trunk/ca/terpstra/sqlite3/sql.sml
----------------------------------------------------------------------
Modified: mltonlib/trunk/ca/terpstra/sqlite3/prim.sig
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/prim.sig 2007-02-16 19:16:44 UTC (rev 5224)
+++ mltonlib/trunk/ca/terpstra/sqlite3/prim.sig 2007-02-16 19:38:43 UTC (rev 5225)
@@ -53,14 +53,14 @@
* Depending on compile options of sqlite3, you might have more meta-data.
* We comment out the sections that must be enabled at sqlite3 compile-time.
*)
- type column = { name: string }
- (*
+ type column = { name: string,
origin: { table: string,
db: string,
decl: string,
schema: string }
- option } *)
+ option }
val meta: query -> column vector
+ val columns: query -> string vector
(* User defined methods *)
val valueB: value -> Word8Vector.vector
Modified: mltonlib/trunk/ca/terpstra/sqlite3/prim.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/prim.sml 2007-02-16 19:16:44 UTC (rev 5224)
+++ mltonlib/trunk/ca/terpstra/sqlite3/prim.sml 2007-02-16 19:38:43 UTC (rev 5225)
@@ -204,20 +204,18 @@
| 5 => NULL
| _ => raise Error "SQLite handed SML an invalid storage type"
- type column = { name: string }
-(* origin: { table: string,
+ type column = { name: string,
+ origin: { table: string,
db: string,
decl: string,
schema: string }
option }
-*)
+ fun fetchName (q, i) = CStr.toString (Pcolumn_name (q, i))
fun fetchMeta (q, i) =
let
fun get f = CStr.toString (f (q, i))
val name = get Pcolumn_name
in
- { name = name }
-(* usually not compiled into sqlite3:
case CStr.toStringOpt (Pcolumn_decltype (q, i)) of
NONE => { name = name, origin = NONE }
| SOME decl =>
@@ -226,8 +224,8 @@
db = get Pcolumn_database_name,
decl = decl,
schema = get Pcolumn_origin_name } }
-*)
end
+ fun columns q = Vector.tabulate (cols q, fn i => fetchName (q, i))
fun meta q = Vector.tabulate (cols q, fn i => fetchMeta (q, i))
fun valueB v = Blob.toVector (Pvalue_blob v, Pvalue_bytes v)
Modified: mltonlib/trunk/ca/terpstra/sqlite3/sql.sig
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/sql.sig 2007-02-16 19:16:44 UTC (rev 5224)
+++ mltonlib/trunk/ca/terpstra/sqlite3/sql.sig 2007-02-16 19:38:43 UTC (rev 5225)
@@ -1,7 +1,12 @@
signature SQL =
sig
type db
- type column = { name: string }
+ type column = { name: string,
+ origin: { table: string,
+ db: string,
+ decl: string,
+ schema: string }
+ option }
exception Retry of string
exception Abort of string
@@ -83,8 +88,10 @@
val iX: (storage, 'i, 'o, 'p, 'q, 'a, 'b, 'x, 'y, 'z) input
end
- (* Meta-data about the columns in the output *)
- val columns: ('i, 'o) Query.t -> column vector
+ (* Names of the output columns *)
+ val columns: ('i, 'o) Query.t -> string vector
+ (* Column meta-data requires SQLITE_ENABLE_COLUMN_METADATA compiled *)
+ val columnsMeta: ('i, 'o) Query.t -> column vector
(* Run a function on each output row from a query *)
val map: ('o -> 'v) -> ('i, 'o) Query.t -> 'i -> 'v vector
Modified: mltonlib/trunk/ca/terpstra/sqlite3/sql.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/sql.sml 2007-02-16 19:16:44 UTC (rev 5224)
+++ mltonlib/trunk/ca/terpstra/sqlite3/sql.sml 2007-02-16 19:38:43 UTC (rev 5225)
@@ -13,7 +13,8 @@
val version = Prim.version
- fun columns q = Prim.meta (Query.peek q)
+ fun columns q = Prim.columns (Query.peek q)
+ fun columnsMeta q = Prim.meta (Query.peek q)
val openDB = Prim.openDB
val closeDB = Prim.closeDB
More information about the MLton-commit
mailing list