diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c
index caae3f0..ee3b80b 100644
*** a/src/test/regress/pg_regress.c
--- b/src/test/regress/pg_regress.c
*************** regression_main(int argc, char *argv[], 
*** 2668,2673 ****
--- 2668,2686 ----
  		stop_postmaster();
  	}
  
+ 	/*
+ 	 * If there were no errors, remove the temp installation immediately to
+ 	 * conserve disk space.  (If there were errors, we leave the installation
+ 	 * in place for possible manual investigation.)
+ 	 */
+ 	if (temp_install && fail_count == 0 && fail_ignore_count == 0)
+ 	{
+ 		header(_("removing temporary installation"));
+ 		if (!rmtree(temp_install, true))
+ 			fprintf(stderr, _("\n%s: could not remove temp installation \"%s\": %s\n"),
+ 					progname, temp_install, strerror(errno));
+ 	}
+ 
  	fclose(logfile);
  
  	/*
