Remove PGINTERVALSTYLE from the set of special environment variables for
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 25 Nov 2008 19:30:42 +0000 (19:30 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 25 Nov 2008 19:30:42 +0000 (19:30 +0000)
libpq.  As noted by Peter, adding this variable created a risk of unexpected
connection failures when talking to older server versions, and since it
doesn't do anything you can't do with PGOPTIONS, it doesn't seem really
necessary.  Removing it does occasion a few extra lines in pg_regress.c,
but saving a getenv() call per libpq connection attempt is perhaps worth
that anyway.

doc/src/sgml/libpq.sgml
src/interfaces/libpq/fe-connect.c
src/test/regress/pg_regress.c

index 554471f5270a3f9779a8c1b4f3201c5651e29afc..cebeb0467244762f303abfd52b2f944aca1e200a 100644 (file)
@@ -5820,17 +5820,6 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
      </para>
     </listitem>
 
-    <listitem>
-     <para>
-      <indexterm>
-       <primary><envar>PGINTERVALSTYLE</envar></primary>
-      </indexterm>
-      <envar>PGINTERVALSTYLE</envar> sets the default style of interval
-      representation.  (Equivalent to <literal>SET intervalstyle TO
-      ...</literal>.)
-     </para>
-    </listitem>
-
     <listitem>
      <para>
       <indexterm>
index 05fd094b1ce830eb8e3e2973cc7f922200855268..5b8e84744f2c71c625d5a0983ff6ac8f3a89c60d 100644 (file)
@@ -213,9 +213,6 @@ static const PQEnvironmentOption EnvironmentOptions[] =
        {
                "PGDATESTYLE", "datestyle"
        },
-       {
-               "PGINTERVALSTYLE", "intervalstyle"
-       },
        {
                "PGTZ", "timezone"
        },
index bb17fa278c6d8362f829f8107a68e6087cad2949..d7c4847c925e8cbc5a7807ad1a50d106b5a14d0f 100644 (file)
@@ -716,7 +716,23 @@ initialize_environment(void)
         */
        putenv("PGTZ=PST8PDT");
        putenv("PGDATESTYLE=Postgres, MDY");
-       putenv("PGINTERVALSTYLE=postgres_verbose");
+
+       /*
+        * Likewise set intervalstyle to ensure consistent results.  This is a
+        * bit more painful because we must use PGOPTIONS, and we want to preserve
+        * the user's ability to set other variables through that.
+        */
+       {
+               const char *my_pgoptions = "--intervalstyle=postgres_verbose";
+               const char *old_pgoptions = getenv("PGOPTIONS");
+               char   *new_pgoptions;
+
+               if (!old_pgoptions)
+                       old_pgoptions = "";
+               new_pgoptions = malloc(strlen(old_pgoptions) + strlen(my_pgoptions) + 12);
+               sprintf(new_pgoptions, "PGOPTIONS=%s %s", old_pgoptions, my_pgoptions);
+               putenv(new_pgoptions);
+       }
 
        if (temp_install)
        {