summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/manual.tex3
-rw-r--r--src/postgres.sml6
2 files changed, 6 insertions, 3 deletions
diff --git a/doc/manual.tex b/doc/manual.tex
index 00db43fb..20c78235 100644
--- a/doc/manual.tex
+++ b/doc/manual.tex
@@ -331,6 +331,7 @@ Compiled applications consult a few environment variables to modify their behavi
\begin{itemize}
\item \cd{URWEB\_NUM\_THREADS}: alternative to the \cd{-t} command-line argument (currently used only by FastCGI)
\item \cd{URWEB\_STACK\_SIZE}: size of per-thread stacks, in bytes
+ \item \cd{URWEB\_PQ\_CON}: when using PostgreSQL, overrides the compiled-in connection string
\end{itemize}
@@ -2428,4 +2429,4 @@ The program is translated to what is more or less a subset of C. If any use of
The output of the last phase is pretty-printed as C source code and passed to the C compiler.
-\end{document} \ No newline at end of file
+\end{document}
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.\");",