comparison src/postgres.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 da11f7b18067
children 1bfd793e7eb8
comparison
equal deleted inserted replaced
1599:252e05bf199d 1600:8128fcb2d4a4
68 ^ sl ^ "'" 68 ^ sl ^ "'"
69 69
70 val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", 70 val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '",
71 sl, 71 sl,
72 "' AND (", 72 "' AND (",
73 String.concatWith " OR " 73 case String.concatWith " OR "
74 (map (fn (x, t) => 74 (map (fn (x, t) =>
75 String.concat ["(column_name = 'uw_", 75 String.concat ["(column_name = 'uw_",
76 CharVector.map 76 CharVector.map
77 Char.toLower (ident x), 77 Char.toLower (ident x),
78 (case p_sql_type_base t of 78 (case p_sql_type_base t of
79 "bigint" => 79 "bigint" =>
80 "' AND data_type IN ('bigint', 'numeric')" 80 "' AND data_type IN ('bigint', 'numeric')"
81 | t => 81 | t =>
82 String.concat ["' AND data_type = '", 82 String.concat ["' AND data_type = '",
83 t, 83 t,
84 "'"]), 84 "'"]),
85 if checkNullable then 85 if checkNullable then
86 (" AND is_nullable = '" 86 (" AND is_nullable = '"
87 ^ (if isNotNull t then 87 ^ (if isNotNull t then
88 "NO" 88 "NO"
89 else 89 else
90 "YES") 90 "YES")
91 ^ "'") 91 ^ "'")
92 else 92 else
93 "", 93 "",
94 ")"]) xts), 94 ")"]) xts) of
95 "" => "FALSE"
96 | s => s,
95 ")"] 97 ")"]
96 98
97 val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", 99 val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '",
98 sl, 100 sl,
99 "' AND column_name LIKE 'uw_%'"] 101 "' AND column_name LIKE 'uw_%'"]