Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1304f29

Browse files
committed
Remove PGINTERVALSTYLE from the set of special environment variables for
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.
1 parent 4d1ba04 commit 1304f29

File tree

3 files changed

+20
-18
lines changed

3 files changed

+20
-18
lines changed

doc/src/sgml/libpq.sgml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.270 2008/11/14 22:58:51 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.271 2008/11/25 19:30:42 tgl Exp $ -->
22

33
<chapter id="libpq">
44
<title><application>libpq</application> - C Library</title>
@@ -5820,17 +5820,6 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
58205820
</para>
58215821
</listitem>
58225822

5823-
<listitem>
5824-
<para>
5825-
<indexterm>
5826-
<primary><envar>PGINTERVALSTYLE</envar></primary>
5827-
</indexterm>
5828-
<envar>PGINTERVALSTYLE</envar> sets the default style of interval
5829-
representation. (Equivalent to <literal>SET intervalstyle TO
5830-
...</literal>.)
5831-
</para>
5832-
</listitem>
5833-
58345823
<listitem>
58355824
<para>
58365825
<indexterm>

src/interfaces/libpq/fe-connect.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.368 2008/11/13 09:45:24 mha Exp $
11+
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-connect.c,v 1.369 2008/11/25 19:30:42 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -213,9 +213,6 @@ static const PQEnvironmentOption EnvironmentOptions[] =
213213
{
214214
"PGDATESTYLE", "datestyle"
215215
},
216-
{
217-
"PGINTERVALSTYLE", "intervalstyle"
218-
},
219216
{
220217
"PGTZ", "timezone"
221218
},

src/test/regress/pg_regress.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.51 2008/11/25 11:49:35 petere Exp $
14+
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.52 2008/11/25 19:30:42 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -716,7 +716,23 @@ initialize_environment(void)
716716
*/
717717
putenv("PGTZ=PST8PDT");
718718
putenv("PGDATESTYLE=Postgres, MDY");
719-
putenv("PGINTERVALSTYLE=postgres_verbose");
719+
720+
/*
721+
* Likewise set intervalstyle to ensure consistent results. This is a
722+
* bit more painful because we must use PGOPTIONS, and we want to preserve
723+
* the user's ability to set other variables through that.
724+
*/
725+
{
726+
const char *my_pgoptions = "--intervalstyle=postgres_verbose";
727+
const char *old_pgoptions = getenv("PGOPTIONS");
728+
char *new_pgoptions;
729+
730+
if (!old_pgoptions)
731+
old_pgoptions = "";
732+
new_pgoptions = malloc(strlen(old_pgoptions) + strlen(my_pgoptions) + 12);
733+
sprintf(new_pgoptions, "PGOPTIONS=%s %s", old_pgoptions, my_pgoptions);
734+
putenv(new_pgoptions);
735+
}
720736

721737
if (temp_install)
722738
{

0 commit comments

Comments
 (0)