comparison src/cjr_print.sml @ 738:7fa4871e8272

Prepared statements with blobs
author Adam Chlipala <adamc@hcoop.net>
date Sat, 25 Apr 2009 14:04:38 -0400
parents d049d31a1966
children 4bb7e1c0550a
comparison
equal deleted inserted replaced
737:d049d31a1966 738:7fa4871e8272
1646 string ";"]) 1646 string ";"])
1647 ets, 1647 ets,
1648 newline, 1648 newline,
1649 newline, 1649 newline,
1650 1650
1651 string "const int paramFormats[] = { ",
1652 p_list_sep (box [string ",", space])
1653 (fn (_, t) => if isBlob t then string "1" else string "0") ets,
1654 string " };",
1655 newline,
1656 string "const int paramLengths[] = { ",
1657 p_list_sepi (box [string ",", space])
1658 (fn i => fn (_, Blob) => string ("arg" ^ Int.toString (i + 1) ^ ".size")
1659 | (_, Nullable Blob) => string ("arg" ^ Int.toString (i + 1)
1660 ^ "?arg" ^ Int.toString (i + 1) ^ "->size:0")
1661 | _ => string "0") ets,
1662 string " };",
1663 newline,
1651 string "const char *paramValues[] = { ", 1664 string "const char *paramValues[] = { ",
1652 p_list_sepi (box [string ",", space]) 1665 p_list_sepi (box [string ",", space])
1653 (fn i => fn (_, t) => p_ensql t (box [string "arg", 1666 (fn i => fn (_, t) => p_ensql t (box [string "arg",
1654 string (Int.toString (i + 1))])) 1667 string (Int.toString (i + 1))]))
1655 ets, 1668 ets,
1664 NONE => string "PQexecParams(conn, dml, 0, NULL, NULL, NULL, NULL, 0);" 1677 NONE => string "PQexecParams(conn, dml, 0, NULL, NULL, NULL, NULL, 0);"
1665 | SOME n => box [string "PQexecPrepared(conn, \"uw", 1678 | SOME n => box [string "PQexecPrepared(conn, \"uw",
1666 string (Int.toString n), 1679 string (Int.toString n),
1667 string "\", ", 1680 string "\", ",
1668 string (Int.toString (length (getPargs dml))), 1681 string (Int.toString (length (getPargs dml))),
1669 string ", paramValues, NULL, NULL, 0);"], 1682 string ", paramValues, paramLengths, paramFormats, 0);"],
1670 newline, 1683 newline,
1671 newline, 1684 newline,
1672 1685
1673 string "if (res == NULL) uw_error(ctx, FATAL, \"Out of memory allocating DML result.\");", 1686 string "if (res == NULL) uw_error(ctx, FATAL, \"Out of memory allocating DML result.\");",
1674 newline, 1687 newline,