Re: [HACKERS] pg_regress config

Поиск
Список
Период
Сортировка
Искать

Re: [HACKERS] pg_regress config

От:
Andrew Dunstan <andrew@dunslane.net>
Дата:


Magnus Hagander wrote:
> Andrew Dunstan wrote:
>   
>> I would like to add an argument to pg_regress that allows us to set some
>> config options for the temp install. Specifically right now I am
>> interested in setting the following:
>>
>>  log_line_prefix = '[%c] '
>>  log_statement = 'all'
>>  log_connections = 'true'
>>
>> But I think it makes more sense to provide for a general option setting
>> mechanism, such as --extra_config=/path/to/some/file
>>
>> This would dovetail neatly with the recent suggestion that we might
>> provide for buildfarm members to run several config sets.
>>
>> Thoughts?
>>     
>
> I think the file makes a lot more sense - would keep you from ending up
> with really horrible commandlines. Also, it would make it easier if you
> want to set up different configs manually (the buildfarm script can
> always manage).
>   

OK, patch attached. I called the option 'temp-config' to go with 
'temp-install'.

> What about the ability to pass options to initdb, while you're at it?
> Like changing the locale? (which will break the scripts, but it should
> only break them in predictable locations)
>
>
>   

Sufficient unto the day is the evil thereof. We can handle that another 
time.

What I will do however is add some ability to use this to the makefiles 
and the vcregress script.

cheers

andrew
Index: src/test/regress/pg_regress.c
===================================================================
RCS file: /cvsroot/pgsql/src/test/regress/pg_regress.c,v
retrieving revision 1.36
diff -c -r1.36 pg_regress.c
*** src/test/regress/pg_regress.c	18 Jul 2007 21:19:17 -0000	1.36
--- src/test/regress/pg_regress.c	5 Sep 2007 19:06:50 -0000
***************
*** 76,81 ****
--- 76,82 ----
  static _stringlist *schedulelist = NULL;
  static _stringlist *extra_tests = NULL;
  static char *temp_install = NULL;
+ static char *temp_config = NULL;
  static char *top_builddir = NULL;
  static int	temp_port = 65432;
  static bool nolocale = false;
***************
*** 1718,1728 ****
  	printf(_("                            (can be used multiple times to concatenate)\n"));
  	printf(_("  --srcdir=DIR              absolute path to source directory (for VPATH builds)\n"));
  	printf(_("  --temp-install=DIR        create a temporary installation in DIR\n"));
- 	printf(_("  --no-locale               use C locale\n"));
  	printf(_("\n"));
  	printf(_("Options for \"temp-install\" mode:\n"));
  	printf(_("  --top-builddir=DIR        (relative) path to top level build directory\n"));
  	printf(_("  --temp-port=PORT          port number to start temp postmaster on\n"));
  	printf(_("\n"));
  	printf(_("Options for using an existing installation:\n"));
  	printf(_("  --host=HOST               use postmaster running on HOST\n"));
--- 1719,1730 ----
  	printf(_("                            (can be used multiple times to concatenate)\n"));
  	printf(_("  --srcdir=DIR              absolute path to source directory (for VPATH builds)\n"));
  	printf(_("  --temp-install=DIR        create a temporary installation in DIR\n"));
  	printf(_("\n"));
  	printf(_("Options for \"temp-install\" mode:\n"));
+ 	printf(_("  --no-locale               use C locale\n"));
  	printf(_("  --top-builddir=DIR        (relative) path to top level build directory\n"));
  	printf(_("  --temp-port=PORT          port number to start temp postmaster on\n"));
+ 	printf(_("  --temp-config=PATH        append contents of PATH to temporary config\n"));
  	printf(_("\n"));
  	printf(_("Options for using an existing installation:\n"));
  	printf(_("  --host=HOST               use postmaster running on HOST\n"));
***************
*** 1766,1771 ****
--- 1768,1774 ----
  		{"psqldir", required_argument, NULL, 16},
  		{"srcdir", required_argument, NULL, 17},
  		{"create-role", required_argument, NULL, 18},
+ 		{"temp-config", required_argument, NULL, 19},
  		{NULL, 0, NULL, 0}
  	};
  
***************
*** 1874,1879 ****
--- 1877,1885 ----
  			case 18:
  				split_to_stringlist(strdup(optarg), ", ", &extraroles);
  				break;
+ 			case 19:
+ 				temp_config = strdup(optarg);
+ 				break;
  			default:
  				/* getopt_long already emitted a complaint */
  				fprintf(stderr, _("\nTry \"%s -h\" for more information.\n"),
***************
*** 1962,1967 ****
--- 1968,1999 ----
  			exit_nicely(2);
  		}
  
+ 		/* add any extra config specified to the postgresql.conf */
+ 		if (temp_config != NULL)
+ 		{
+ 			FILE * extra_conf;
+ 			FILE * pg_conf;
+ 			char line_buf[1024];
+ 
+ 			snprintf(buf, sizeof(buf),"%s/data/postgresql.conf", temp_install);
+ 			pg_conf = fopen(buf,"a");
+ 			if (pg_conf == NULL)
+ 			{
+ 				fprintf(stderr, _("\n%s: could not open %s for adding extra config:\nError was %s\n"), progname, buf, strerror(errno));
+ 				exit_nicely(2);				
+ 			}
+ 			extra_conf = fopen(temp_config,"r");
+ 			if (extra_conf == NULL)
+ 			{
+ 				fprintf(stderr, _("\n%s: could not open %s to read extra config:\nError was %s\n"), progname, buf, strerror(errno));
+ 				exit_nicely(2);				
+ 			}
+ 			while(fgets(line_buf, sizeof(line_buf),extra_conf) != NULL)
+ 				fputs(line_buf, pg_conf);
+ 			fclose(extra_conf);
+ 			fclose(pg_conf);
+ 		}
+ 
  		/*
  		 * Start the temp postmaster
  		 */

Re: [HACKERS] pg_regress config

От:
Magnus Hagander <magnus@hagander.net>
Дата:
Andrew Dunstan wrote:
> 
> 
> Magnus Hagander wrote:
>> Andrew Dunstan wrote:
>>  
>>> I would like to add an argument to pg_regress that allows us to set some
>>> config options for the temp install. Specifically right now I am
>>> interested in setting the following:
>>>
>>>  log_line_prefix = '[%c] '
>>>  log_statement = 'all'
>>>  log_connections = 'true'
>>>
>>> But I think it makes more sense to provide for a general option setting
>>> mechanism, such as --extra_config=/path/to/some/file
>>>
>>> This would dovetail neatly with the recent suggestion that we might
>>> provide for buildfarm members to run several config sets.
>>>
>>> Thoughts?
>>>     
>>
>> I think the file makes a lot more sense - would keep you from ending up
>> with really horrible commandlines. Also, it would make it easier if you
>> want to set up different configs manually (the buildfarm script can
>> always manage).
>>   
> 
> OK, patch attached. I called the option 'temp-config' to go with
> 'temp-install'.

I'd have used an include statement instead of copying the whole file,
but can't see anything actually wrong with it ;-)

//Magnus
FAQ