# HG changeset patch # User Adam Chlipala # Date 1321656252 18000 # Node ID 8128fcb2d4a45d67bce1096726b51b6d26c1ad6b # Parent 252e05bf199d0f5dabfd3eaf0b88e61927b7c525 Fix catalog querying about empty tables diff -r 252e05bf199d -r 8128fcb2d4a4 src/mysql.sml --- a/src/mysql.sml Fri Nov 18 17:17:22 2011 -0500 +++ b/src/mysql.sml Fri Nov 18 17:44:12 2011 -0500 @@ -83,26 +83,28 @@ val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", both, " AND (", - String.concatWith " OR " - (map (fn (x, t) => - String.concat ["(column_name IN ('uw_", - CharVector.map - Char.toLower (ident x), - "', 'uw_", - ident x, - "') AND data_type = '", - p_sql_type_base t, - "'", - if checkNullable then - (" AND is_nullable = '" - ^ (if isNotNull t then - "NO" - else - "YES") - ^ "'") - else - "", - ")"]) xts), + case String.concatWith " OR " + (map (fn (x, t) => + String.concat ["(column_name IN ('uw_", + CharVector.map + Char.toLower (ident x), + "', 'uw_", + ident x, + "') AND data_type = '", + p_sql_type_base t, + "'", + if checkNullable then + (" AND is_nullable = '" + ^ (if isNotNull t then + "NO" + else + "YES") + ^ "'") + else + "", + ")"]) xts) of + "" => "FALSE" + | s => s, ")"] val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE ", diff -r 252e05bf199d -r 8128fcb2d4a4 src/postgres.sml --- a/src/postgres.sml Fri Nov 18 17:17:22 2011 -0500 +++ b/src/postgres.sml Fri Nov 18 17:44:12 2011 -0500 @@ -70,28 +70,30 @@ val q' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", sl, "' AND (", - String.concatWith " OR " - (map (fn (x, t) => - String.concat ["(column_name = 'uw_", - CharVector.map - Char.toLower (ident x), - (case p_sql_type_base t of - "bigint" => - "' AND data_type IN ('bigint', 'numeric')" - | t => - String.concat ["' AND data_type = '", - t, - "'"]), - if checkNullable then - (" AND is_nullable = '" - ^ (if isNotNull t then - "NO" - else - "YES") - ^ "'") - else - "", - ")"]) xts), + case String.concatWith " OR " + (map (fn (x, t) => + String.concat ["(column_name = 'uw_", + CharVector.map + Char.toLower (ident x), + (case p_sql_type_base t of + "bigint" => + "' AND data_type IN ('bigint', 'numeric')" + | t => + String.concat ["' AND data_type = '", + t, + "'"]), + if checkNullable then + (" AND is_nullable = '" + ^ (if isNotNull t then + "NO" + else + "YES") + ^ "'") + else + "", + ")"]) xts) of + "" => "FALSE" + | s => s, ")"] val q'' = String.concat ["SELECT COUNT(*) FROM information_schema.columns WHERE table_name = '", diff -r 252e05bf199d -r 8128fcb2d4a4 tests/emptyTable.ur --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/emptyTable.ur Fri Nov 18 17:44:12 2011 -0500 @@ -0,0 +1,1 @@ +table tricky : {} diff -r 252e05bf199d -r 8128fcb2d4a4 tests/emptyTable.urp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/emptyTable.urp Fri Nov 18 17:44:12 2011 -0500 @@ -0,0 +1,4 @@ +database dbname=test +sql emptyTable.sql + +emptyTable