1 (* HCoop
Domtool (http
://hcoop
.sourceforge
.net
/)
2 * Copyright (c
) 2006, Adam Chlipala
3 * Copyright (c
) 2012 Clinton Ebadi
<clinton@unknownlamer
.org
>
5 * This program is free software
; you can redistribute it
and/or
6 * modify it under the terms
of the GNU General Public License
7 * as published by the Free Software Foundation
; either version
2
8 * of the License
, or (at your option
) any later version
.
10 * This program is distributed
in the hope that it will be useful
,
11 * but WITHOUT ANY WARRANTY
; without even the implied warranty
of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE
. See the
13 * GNU General Public License for more details
.
15 * You should have received a copy
of the GNU General Public License
16 * along
with this program
; if not
, write to the Free Software
17 * Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA
.
20 (* PostgreSQL user
/table management
*)
22 structure Postgres
:> POSTGRES
= struct
24 fun adduser port
{user
, passwd
} =
25 Option
.map (fn s
=> "Error executing CREATE USER script:\n" ^ s
)
26 (Slave
.shellOutput
[Config
.Postgres
.adduser
, " ", port
, " ", user
])
28 fun passwd _
= SOME
"We don't use PostgreSQL passwords."
30 fun createdb port
{user
, dbname
, encoding
} =
31 Option
.map (fn s
=> "Error executing CREATE DATABASE script:\n" ^ s
)
32 (Slave
.shellOutput
[Config
.Postgres
.createdb
,
33 " ", port
, " ", user
, " ", dbname
,
34 case encoding
of NONE
=> "" | SOME e
=> " " ^ e
])
36 fun dropdb port
{user
, dbname
} =
37 Option
.map (fn s
=> "Error executing DROP DATABASE script:\n" ^ s
)
38 (Slave
.shellOutput
[Config
.Postgres
.dropdb
, " ", port
, " ", user
, " ", dbname
])
40 val _
= Dbms
.register ("postgres-9", {getpass
= NONE
,
41 adduser
= adduser Config
.Postgres
.postgres9port
,
43 createdb
= createdb Config
.Postgres
.postgres9port
,
44 dropdb
= dropdb Config
.Postgres
.postgres9port
,
45 grant
= fn _
=> SOME
"You don't need to use GRANT for Postgres."})