comparison src/cjr_print.sml @ 878:a8952047e1d3

Sequence code compiles in MySQL
author Adam Chlipala <adamc@hcoop.net>
date Thu, 16 Jul 2009 16:29:13 -0400
parents dae141d911d9
children b2a175a0f2ef
comparison
equal deleted inserted replaced
877:dae141d911d9 878:a8952047e1d3
1735 string "uw_unit_v;", 1735 string "uw_unit_v;",
1736 newline, 1736 newline,
1737 string "}))"] 1737 string "}))"]
1738 1738
1739 | ENextval {seq, prepared} => 1739 | ENextval {seq, prepared} =>
1740 let 1740 box [string "({",
1741 val query = case seq of 1741 newline,
1742 (EPrim (Prim.String s), loc) => 1742 string "uw_Basis_int n;",
1743 (EPrim (Prim.String ("SELECT NEXTVAL('" ^ s ^ "')")), loc) 1743 newline,
1744 | _ => 1744
1745 let 1745 case prepared of
1746 val query = (EFfiApp ("Basis", "strcat", [seq, (EPrim (Prim.String "')"), loc)]), loc) 1746 NONE => #nextval (Settings.currentDbms ()) {loc = loc,
1747 in 1747 seqE = p_exp env seq,
1748 (EFfiApp ("Basis", "strcat", [(EPrim (Prim.String "SELECT NEXTVAL('"), loc), query]), loc) 1748 seqName = case #1 seq of
1749 end 1749 EPrim (Prim.String s) => SOME s
1750 in 1750 | _ => NONE}
1751 box [string "(uw_begin_region(ctx), ", 1751 | SOME (id, query) => #nextvalPrepared (Settings.currentDbms ()) {loc = loc,
1752 string "({", 1752 id = id,
1753 newline, 1753 query = query},
1754 string "uw_Basis_int n;", 1754 newline,
1755 newline, 1755 newline,
1756 1756
1757 case prepared of 1757 string "n;",
1758 NONE => box [string "char *query = ", 1758 newline,
1759 p_exp env query, 1759 string "})"]
1760 string ";",
1761 newline,
1762 newline,
1763
1764 #nextval (Settings.currentDbms ()) loc]
1765 | SOME (id, query) => #nextvalPrepared (Settings.currentDbms ()) {loc = loc,
1766 id = id,
1767 query = query},
1768 newline,
1769 newline,
1770
1771 string "n;",
1772 newline,
1773 string "}))"]
1774 end
1775 1760
1776 | EUnurlify (e, t) => 1761 | EUnurlify (e, t) =>
1777 let 1762 let
1778 fun getIt () = 1763 fun getIt () =
1779 if isUnboxable t then 1764 if isUnboxable t then