]> granicus.if.org Git - postgresql/commitdiff
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 d7b4d2393a168368207824b4b5b14360b241d42c..e1a1d5a1c58af7a03ae1e2d62f3cc64f1f12ea94 100644 (file)
@@ -1,4 +1,4 @@
-<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.270 2008/11/14 22:58:51 tgl Exp $ -->
+<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.271 2008/11/25 19:30:42 tgl Exp $ -->
 
 <chapter id="libpq">
  <title><application>libpq</application> - C Library</title>
@@ -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 e1376dc01738dffb9e1afb4ed97ea09f8f680d04..2cfe36e3a22052988903302617fcec1ec965312a 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.368 2008/11/13 09:45:24 mha Exp $
+ *       $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.369 2008/11/25 19:30:42 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -213,9 +213,6 @@ static const PQEnvironmentOption EnvironmentOptions[] =
        {
                "PGDATESTYLE", "datestyle"
        },
-       {
-               "PGINTERVALSTYLE", "intervalstyle"
-       },
        {
                "PGTZ", "timezone"
        },
index d063602c7e6ddc0166c05ba5e84ca0558c84a75c..f64e00b643fb0ce564372d3327778cc5b5414cc6 100644 (file)
@@ -11,7 +11,7 @@
  * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.51 2008/11/25 11:49:35 petere Exp $
+ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.52 2008/11/25 19:30:42 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -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)
        {