mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Ignore more environment variables in pg_regress.c
This is similar to the work done in 8279f68 for TestLib.pm, where
environment variables set may cause unwanted failures if using a
temporary installation with pg_regress.  The list of variables reset is
adjusted in each stable branch depending on what is supported.
Comments are added to remember that the lists in TestLib.pm and
pg_regress.c had better be kept in sync.
Reviewed-by: Álvaro Herrera
Discussion: https://postgr.es/m/YMNR9GYDn+fHlMta@paquier.xyz
Backpatch-through: 9.6
			
			
This commit is contained in:
		@@ -63,6 +63,7 @@ BEGIN
 | 
				
			|||||||
	delete $ENV{LC_ALL};
 | 
						delete $ENV{LC_ALL};
 | 
				
			||||||
	$ENV{LC_MESSAGES} = 'C';
 | 
						$ENV{LC_MESSAGES} = 'C';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# This list should be kept in sync with pg_regress.c.
 | 
				
			||||||
	my @envkeys = qw (
 | 
						my @envkeys = qw (
 | 
				
			||||||
	  PGCLIENTENCODING
 | 
						  PGCLIENTENCODING
 | 
				
			||||||
	  PGCONNECT_TIMEOUT
 | 
						  PGCONNECT_TIMEOUT
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -802,14 +802,33 @@ initialize_environment(void)
 | 
				
			|||||||
		 * we also use psql's -X switch consistently, so that ~/.psqlrc files
 | 
							 * we also use psql's -X switch consistently, so that ~/.psqlrc files
 | 
				
			||||||
		 * won't mess things up.)  Also, set PGPORT to the temp port, and set
 | 
							 * won't mess things up.)  Also, set PGPORT to the temp port, and set
 | 
				
			||||||
		 * PGHOST depending on whether we are using TCP or Unix sockets.
 | 
							 * PGHOST depending on whether we are using TCP or Unix sockets.
 | 
				
			||||||
 | 
							 *
 | 
				
			||||||
 | 
							 * This list should be kept in sync with TestLib.pm.
 | 
				
			||||||
		 */
 | 
							 */
 | 
				
			||||||
		unsetenv("PGDATABASE");
 | 
							/* PGCLIENTENCODING, see above */
 | 
				
			||||||
		unsetenv("PGUSER");
 | 
					 | 
				
			||||||
		unsetenv("PGSERVICE");
 | 
					 | 
				
			||||||
		unsetenv("PGSSLMODE");
 | 
					 | 
				
			||||||
		unsetenv("PGREQUIRESSL");
 | 
					 | 
				
			||||||
		unsetenv("PGCONNECT_TIMEOUT");
 | 
							unsetenv("PGCONNECT_TIMEOUT");
 | 
				
			||||||
		unsetenv("PGDATA");
 | 
							unsetenv("PGDATA");
 | 
				
			||||||
 | 
							unsetenv("PGDATABASE");
 | 
				
			||||||
 | 
							unsetenv("PGGSSENCMODE");
 | 
				
			||||||
 | 
							unsetenv("PGGSSLIB");
 | 
				
			||||||
 | 
							/* PGHOSTADDR, see below */
 | 
				
			||||||
 | 
							unsetenv("PGKRBSRVNAME");
 | 
				
			||||||
 | 
							unsetenv("PGPASSFILE");
 | 
				
			||||||
 | 
							unsetenv("PGPASSWORD");
 | 
				
			||||||
 | 
							unsetenv("PGREQUIREPEER");
 | 
				
			||||||
 | 
							unsetenv("PGREQUIRESSL");
 | 
				
			||||||
 | 
							unsetenv("PGSERVICE");
 | 
				
			||||||
 | 
							unsetenv("PGSERVICEFILE");
 | 
				
			||||||
 | 
							unsetenv("PGSSLCERT");
 | 
				
			||||||
 | 
							unsetenv("PGSSLCRL");
 | 
				
			||||||
 | 
							unsetenv("PGSSLKEY");
 | 
				
			||||||
 | 
							unsetenv("PGSSLMODE");
 | 
				
			||||||
 | 
							unsetenv("PGSSLROOTCERT");
 | 
				
			||||||
 | 
							unsetenv("PGTARGETSESSIONATTRS");
 | 
				
			||||||
 | 
							unsetenv("PGUSER");
 | 
				
			||||||
 | 
							/* PGPORT, see below */
 | 
				
			||||||
 | 
							/* PGHOST, see below */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_UNIX_SOCKETS
 | 
					#ifdef HAVE_UNIX_SOCKETS
 | 
				
			||||||
		if (hostname != NULL)
 | 
							if (hostname != NULL)
 | 
				
			||||||
			doputenv("PGHOST", hostname);
 | 
								doputenv("PGHOST", hostname);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user