summaryrefslogtreecommitdiff
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
commit5dbc51a838dcf8951b0bce270eb5855dda0d076e (patch)
tree2cb34ab27658250c39c87e0adeafd5860b006e83 /src/postgres.sml
parent8d4e456a56e3cf84589df3f8dd7181550200587f (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.\");",