# HG changeset patch # User Austin Seipp # Date 1316837519 18000 # Node ID da11f7b180676b94641e9c31671a48a63055f7fa # Parent a0caa991cdad7789336cf3b31c50e474ba8416db Add an URWEB_PQ_CON environment variable, which overrides the PostgreSQL connection string. diff -r a0caa991cdad -r da11f7b18067 doc/manual.tex --- a/doc/manual.tex Thu Sep 22 09:51:06 2011 -0400 +++ b/doc/manual.tex Fri Sep 23 23:11:59 2011 -0500 @@ -331,6 +331,7 @@ \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 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 -r a0caa991cdad -r da11f7b18067 src/postgres.sml --- a/src/postgres.sml Thu Sep 22 09:51:06 2011 -0400 +++ b/src/postgres.sml Fri Sep 23 23:11:59 2011 -0500 @@ -476,9 +476,11 @@ 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.\");",