Error messages for Postgres dbtool
authorAdam Chlipala <adamc@hcoop.net>
Thu, 22 Nov 2007 21:45:34 +0000 (21:45 +0000)
committerAdam Chlipala <adamc@hcoop.net>
Thu, 22 Nov 2007 21:45:34 +0000 (21:45 +0000)
src/plugins/postgres.sml

index 09e3a07..f80fcea 100644 (file)
 structure Postgres :> POSTGRES = struct
 
 fun adduser {user, passwd} =
-    if Slave.shell [Config.Postgres.adduser, user] then
-       NONE
-    else
-       SOME "Error executing CREATE USER script"
+    Option.map (fn s => "Error executing CREATE USER script:\n" ^ s)
+              (Slave.shellOutput [Config.Postgres.adduser, user])
 
 fun passwd _ = SOME "We don't use PostgreSQL passwords."
 
 fun createdb {user, dbname} =
-    if Slave.shell [Config.Postgres.createdb, user, " ", dbname] then
-       NONE
-    else
-       SOME "Error executing CREATE DATABASE script"
+    Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s)
+              (Slave.shellOutput [Config.Postgres.createdb, user, " ", dbname])
 
 fun dropdb {user, dbname} =
-    if Slave.shell [Config.Postgres.dropdb, user, " ", dbname] then
-       NONE
-    else
-       SOME "Error executing DROP DATABASE script"
+    Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s)
+              (Slave.shellOutput [Config.Postgres.dropdb, user, " ", dbname])
 
 val _ = Dbms.register ("postgres", {getpass = NONE,
                                    adduser = adduser,