changeset 1564:da11f7b18067

Add an URWEB_PQ_CON environment variable, which overrides the PostgreSQL connection string.
author Austin Seipp <as@hacks.yi.org>
date Fri, 23 Sep 2011 23:11:59 -0500
parents a0caa991cdad
children 9c7b79214cae 0fab80567fa3
files doc/manual.tex src/postgres.sml
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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}
--- 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.\");",