# HG changeset patch # User Adam Chlipala # Date 1255385802 14400 # Node ID ad434669f29929ed6949afdd2da153e99dddc12d # Parent 588b31fe6cc9f1ce94d2d47830edd71e06754cce Fix some MySQL hijinks diff -r 588b31fe6cc9 -r ad434669f299 src/mono_opt.sml --- a/src/mono_opt.sml Fri Oct 09 09:50:26 2009 -0400 +++ b/src/mono_opt.sml Mon Oct 12 18:16:42 2009 -0400 @@ -100,7 +100,7 @@ let fun doChars (cs, acc) = case cs of - #"T" :: #"." :: cs => doChars (cs, acc) + #"T" :: #"_" :: #"T" :: #"." :: cs => doChars (cs, acc) | #"'" :: cs => doString (cs, acc) | ch :: cs => doChars (cs, ch :: acc) | [] => String.implode (rev acc) diff -r 588b31fe6cc9 -r ad434669f299 src/mysql.sml --- a/src/mysql.sml Fri Oct 09 09:50:26 2009 -0400 +++ b/src/mysql.sml Mon Oct 12 18:16:42 2009 -0400 @@ -73,19 +73,21 @@ fun checkRel (table, checkNullable) (s, xts) = let val sl = CharVector.map Char.toLower s + val both = "table_name IN ('" ^ sl ^ "', '" ^ s ^ "')" - val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE table_name = '" - ^ sl ^ "'" + val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE " ^ both - val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", - sl, - "' AND (", + val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", + both, + " AND (", String.concatWith " OR " (map (fn (x, t) => - String.concat ["(column_name = 'uw_", + String.concat ["(column_name IN ('uw_", CharVector.map Char.toLower (ident x), - "' AND data_type = '", + "', 'uw_", + ident x, + "') AND data_type = '", p_sql_type_base t, "'", if checkNullable then @@ -100,9 +102,9 @@ ")"]) xts), ")"] - val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", - sl, - "' AND column_name LIKE 'uw_%'"] + val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", + both, + " AND column_name LIKE 'uw_%'"] in box [string "if (mysql_query(conn->conn, \"", string q,