X-Git-Url: https://git.hcoop.net/hcoop/domtool2.git/blobdiff_plain/86aa5de7d9f2754d50489432ffaa43cba3fa170f..HEAD:/src/plugins/postgres.sml diff --git a/src/plugins/postgres.sml b/src/plugins/postgres.sml index 1689840..fda5801 100644 --- a/src/plugins/postgres.sml +++ b/src/plugins/postgres.sml @@ -1,5 +1,6 @@ (* HCoop Domtool (http://hcoop.sourceforge.net/) * Copyright (c) 2006, Adam Chlipala + * Copyright (c) 2012 Clinton Ebadi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,23 +21,27 @@ structure Postgres :> POSTGRES = struct -fun adduser {user, passwd} = - if Slave.shell [Config.Postgres.adduser, user] then - NONE - else - SOME "Error executing CREATE USER script" +fun adduser port {user, passwd} = + Option.map (fn s => "Error executing CREATE USER script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.adduser, " ", port, " ", 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" +fun createdb port {user, dbname, encoding} = + Option.map (fn s => "Error executing CREATE DATABASE script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.createdb, + " ", port, " ", user, " ", dbname, + case encoding of NONE => "" | SOME e => " " ^ e]) -val _ = Dbms.register ("postgres", {getpass = NONE, - adduser = adduser, - passwd = passwd, - createdb = createdb}) +fun dropdb port {user, dbname} = + Option.map (fn s => "Error executing DROP DATABASE script:\n" ^ s) + (Slave.shellOutput [Config.Postgres.dropdb, " ", port, " ", user, " ", dbname]) + +val _ = Dbms.register ("postgres-9", {getpass = NONE, + adduser = adduser Config.Postgres.postgres9port, + passwd = passwd, + createdb = createdb Config.Postgres.postgres9port, + dropdb = dropdb Config.Postgres.postgres9port, + grant = fn _ => SOME "You don't need to use GRANT for Postgres."}) end