aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/postgres.sml
diff options
context:
space:
mode:
authorGravatar Austin Seipp <as@hacks.yi.org>2011-09-23 23:11:59 -0500
committerGravatar Austin Seipp <as@hacks.yi.org>2011-09-23 23:11:59 -0500
commitf926b6418df3e6b835f8bc5b7c44906c9742a085 (patch)
tree2cb34ab27658250c39c87e0adeafd5860b006e83 /src/postgres.sml
parent2004c7a6dc76cb10bc0ef8c2ca679b9f1ef1b909 (diff)
Add an URWEB_PQ_CON environment variable, which overrides the PostgreSQL connection string.
Diffstat (limited to 'src/postgres.sml')
-rw-r--r--src/postgres.sml6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/postgres.sml b/src/postgres.sml
index 9707096f..a66c85d9 100644
--- a/src/postgres.sml
+++ b/src/postgres.sml
@@ -476,9 +476,11 @@ fun init {dbstring, prepared = ss, tables, views, sequences} =
string "static void uw_db_init(uw_context ctx) {",
newline,
- string "PGconn *conn = PQconnectdb(\"",
+ string "char *env_db_str = getenv(\"URWEB_PQ_CON\");",
+ newline,
+ string "PGconn *conn = PQconnectdb(env_db_str == NULL ? \"",
string (String.toCString dbstring),
- string "\");",
+ string "\" : env_db_str);",
newline,
string "if (conn == NULL) uw_error(ctx, FATAL, ",
string "\"libpq can't allocate a connection.\");",