summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Adam Chlipala <adamc@hcoop.net>2009-04-25 14:04:38 -0400
committerGravatar Adam Chlipala <adamc@hcoop.net>2009-04-25 14:04:38 -0400
commit2dd6e83e23759ef4f5a27e399e43636881449345 (patch)
tree73ca1c4b83a6f9cc857b4a92438a576e3f7b40fc
parente6ee37d85ac1e6fa7e2d20fc4320b89129b58ac1 (diff)
Prepared statements with blobs
-rw-r--r--src/cjr_print.sml15
-rw-r--r--src/prepare.sml2
2 files changed, 16 insertions, 1 deletions
diff --git a/src/cjr_print.sml b/src/cjr_print.sml
index 8450c467..d24cbfa4 100644
--- a/src/cjr_print.sml
+++ b/src/cjr_print.sml
@@ -1648,6 +1648,19 @@ fun p_exp' par env (e, loc) =
newline,
newline,
+ string "const int paramFormats[] = { ",
+ p_list_sep (box [string ",", space])
+ (fn (_, t) => if isBlob t then string "1" else string "0") ets,
+ string " };",
+ newline,
+ string "const int paramLengths[] = { ",
+ p_list_sepi (box [string ",", space])
+ (fn i => fn (_, Blob) => string ("arg" ^ Int.toString (i + 1) ^ ".size")
+ | (_, Nullable Blob) => string ("arg" ^ Int.toString (i + 1)
+ ^ "?arg" ^ Int.toString (i + 1) ^ "->size:0")
+ | _ => string "0") ets,
+ string " };",
+ newline,
string "const char *paramValues[] = { ",
p_list_sepi (box [string ",", space])
(fn i => fn (_, t) => p_ensql t (box [string "arg",
@@ -1666,7 +1679,7 @@ fun p_exp' par env (e, loc) =
string (Int.toString n),
string "\", ",
string (Int.toString (length (getPargs dml))),
- string ", paramValues, NULL, NULL, 0);"],
+ string ", paramValues, paramLengths, paramFormats, 0);"],
newline,
newline,
diff --git a/src/prepare.sml b/src/prepare.sml
index e1777b11..52308540 100644
--- a/src/prepare.sml
+++ b/src/prepare.sml
@@ -47,6 +47,8 @@ fun prepString (e, ss, n) =
SOME ("$" ^ Int.toString (n + 1) ^ "::bool" :: ss, n + 1)
| EFfiApp ("Basis", "sqlifyTime", [e]) =>
SOME ("$" ^ Int.toString (n + 1) ^ "::timestamp" :: ss, n + 1)
+ | EFfiApp ("Basis", "sqlifyBlob", [e]) =>
+ SOME ("$" ^ Int.toString (n + 1) ^ "::bytea" :: ss, n + 1)
| EFfiApp ("Basis", "sqlifyChannel", [e]) =>
SOME ("$" ^ Int.toString (n + 1) ^ "::int8" :: ss, n + 1)
| EFfiApp ("Basis", "sqlifyClient", [e]) =>