comparison src/mysql.sml @ 1600:8128fcb2d4a4

Fix catalog querying about empty tables
author Adam Chlipala <adam@chlipala.net>
date Fri, 18 Nov 2011 17:44:12 -0500
parents 969b90b1f2f9
children 3e7c7e200713
comparison
equal deleted inserted replaced
1599:252e05bf199d 1600:8128fcb2d4a4
81 val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE " ^ both 81 val q = "SELECT COUNT(*) FROM information_schema." ^ table ^ " WHERE " ^ both
82 82
83 val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", 83 val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",
84 both, 84 both,
85 " AND (", 85 " AND (",
86 String.concatWith " OR " 86 case String.concatWith " OR "
87 (map (fn (x, t) => 87 (map (fn (x, t) =>
88 String.concat ["(column_name IN ('uw_", 88 String.concat ["(column_name IN ('uw_",
89 CharVector.map 89 CharVector.map
90 Char.toLower (ident x), 90 Char.toLower (ident x),
91 "', 'uw_", 91 "', 'uw_",
92 ident x, 92 ident x,
93 "') AND data_type = '", 93 "') AND data_type = '",
94 p_sql_type_base t, 94 p_sql_type_base t,
95 "'", 95 "'",
96 if checkNullable then 96 if checkNullable then
97 (" AND is_nullable = '" 97 (" AND is_nullable = '"
98 ^ (if isNotNull t then 98 ^ (if isNotNull t then
99 "NO" 99 "NO"
100 else 100 else
101 "YES") 101 "YES")
102 ^ "'") 102 ^ "'")
103 else 103 else
104 "", 104 "",
105 ")"]) xts), 105 ")"]) xts) of
106 "" => "FALSE"
107 | s => s,
106 ")"] 108 ")"]
107 109
108 val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", 110 val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ",
109 both, 111 both,
110 " AND column_name LIKE 'uw_%'"] 112 " AND column_name LIKE 'uw_%'"]