diff -rpcd a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
*** a/doc/src/sgml/ref/pg_ctl-ref.sgml 2014-06-21 09:17:03.000000000 +0900
--- b/doc/src/sgml/ref/pg_ctl-ref.sgml 2014-07-15 22:35:12.880000000 +0900
*************** PostgreSQL documentation
*** 115,120 ****
--- 115,121 ----
+ event-source
seconds
*************** PostgreSQL documentation
*** 420,425 ****
--- 421,441 ----
+
+
+
+ Name of the event source for pg_ctl
+ to use for event log when it is running as a Windows service.
+ The default is PostgreSQL. The server process
+ postgres uses the event source
+ specified by in
+ postgresql.conf, not the one specified
+ by this command-line option.
+
+
+
+
+
diff -rpcd a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
*** a/src/backend/utils/error/elog.c 2014-06-21 09:17:03.000000000 +0900
--- b/src/backend/utils/error/elog.c 2014-07-15 21:59:17.006000000 +0900
*************** write_eventlog(int level, const char *li
*** 1989,1995 ****
if (evtHandle == INVALID_HANDLE_VALUE)
{
! evtHandle = RegisterEventSource(NULL, event_source ? event_source : "PostgreSQL");
if (evtHandle == NULL)
{
evtHandle = INVALID_HANDLE_VALUE;
--- 1989,1996 ----
if (evtHandle == INVALID_HANDLE_VALUE)
{
! evtHandle = RegisterEventSource(NULL,
! event_source ? event_source : DEFAULT_EVENT_SOURCE);
if (evtHandle == NULL)
{
evtHandle = INVALID_HANDLE_VALUE;
diff -rpcd a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
*** a/src/backend/utils/misc/guc.c 2014-06-21 09:17:03.000000000 +0900
--- b/src/backend/utils/misc/guc.c 2014-07-15 21:59:17.020000000 +0900
*************** static struct config_string ConfigureNam
*** 3017,3023 ****
NULL
},
&event_source,
! "PostgreSQL",
NULL, NULL, NULL
},
--- 3017,3023 ----
NULL
},
&event_source,
! DEFAULT_EVENT_SOURCE,
NULL, NULL, NULL
},
diff -rpcd a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c
*** a/src/bin/pg_ctl/pg_ctl.c 2014-06-21 09:17:03.000000000 +0900
--- b/src/bin/pg_ctl/pg_ctl.c 2014-07-15 21:59:17.033000000 +0900
*************** static char *post_opts = NULL;
*** 89,94 ****
--- 89,95 ----
static const char *progname;
static char *log_file = NULL;
static char *exec_path = NULL;
+ static char *event_source = NULL;
static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
static char *register_username = NULL;
static char *register_password = NULL;
*************** write_eventlog(int level, const char *li
*** 178,184 ****
if (evtHandle == INVALID_HANDLE_VALUE)
{
! evtHandle = RegisterEventSource(NULL, "PostgreSQL");
if (evtHandle == NULL)
{
evtHandle = INVALID_HANDLE_VALUE;
--- 179,186 ----
if (evtHandle == INVALID_HANDLE_VALUE)
{
! evtHandle = RegisterEventSource(NULL,
! event_source ? event_source : DEFAULT_EVENT_SOURCE);
if (evtHandle == NULL)
{
evtHandle = INVALID_HANDLE_VALUE;
*************** pgwin32_CommandLine(bool registration)
*** 1406,1411 ****
--- 1408,1416 ----
free(dataDir);
}
+ if (registration && event_source != NULL)
+ appendPQExpBuffer(cmdLine, " -e \"%s\"", event_source);
+
if (registration && do_wait)
appendPQExpBuffer(cmdLine, " -w");
*************** do_help(void)
*** 1871,1877 ****
printf(_(" %s kill SIGNALNAME PID\n"), progname);
#if defined(WIN32) || defined(__CYGWIN__)
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
! " [-S START-TYPE] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s unregister [-N SERVICENAME]\n"), progname);
#endif
--- 1876,1882 ----
printf(_(" %s kill SIGNALNAME PID\n"), progname);
#if defined(WIN32) || defined(__CYGWIN__)
printf(_(" %s register [-N SERVICENAME] [-U USERNAME] [-P PASSWORD] [-D DATADIR]\n"
! " [-S START-TYPE] [-e event-source] [-w] [-t SECS] [-o \"OPTIONS\"]\n"), progname);
printf(_(" %s unregister [-N SERVICENAME]\n"), progname);
#endif
*************** do_help(void)
*** 1910,1915 ****
--- 1915,1921 ----
#if defined(WIN32) || defined(__CYGWIN__)
printf(_("\nOptions for register and unregister:\n"));
printf(_(" -N SERVICENAME service name with which to register PostgreSQL server\n"));
+ printf(_(" -e event-source event source for pg_ctl to use for event log\n"));
printf(_(" -P PASSWORD password of account to register PostgreSQL server\n"));
printf(_(" -U USERNAME user name of account to register PostgreSQL server\n"));
printf(_(" -S START-TYPE service start type to register PostgreSQL server\n"));
*************** main(int argc, char **argv)
*** 2140,2146 ****
/* process command-line options */
while (optind < argc)
{
! while ((c = getopt_long(argc, argv, "cD:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
{
switch (c)
{
--- 2146,2152 ----
/* process command-line options */
while (optind < argc)
{
! while ((c = getopt_long(argc, argv, "cD:e:l:m:N:o:p:P:sS:t:U:wW", long_options, &option_index)) != -1)
{
switch (c)
{
*************** main(int argc, char **argv)
*** 2168,2173 ****
--- 2174,2182 ----
case 'm':
set_mode(optarg);
break;
+ case 'e':
+ event_source = pg_strdup(optarg);
+ break;
case 'N':
register_servicename = pg_strdup(optarg);
break;
diff -rpcd a/src/bin/pgevent/pgevent.c b/src/bin/pgevent/pgevent.c
*** a/src/bin/pgevent/pgevent.c 2014-06-21 09:17:03.000000000 +0900
--- b/src/bin/pgevent/pgevent.c 2014-07-16 20:32:03.534000000 +0900
*************** HANDLE g_module = NULL; /* hModule of D
*** 26,32 ****
* The maximum length of a registry key is 255 characters.
* http://msdn.microsoft.com/en-us/library/ms724872(v=vs.85).aspx
*/
! char event_source[256] = "PostgreSQL";
/* Prototypes */
HRESULT DllInstall(BOOL bInstall, LPCWSTR pszCmdLine);
--- 26,32 ----
* The maximum length of a registry key is 255 characters.
* http://msdn.microsoft.com/en-us/library/ms724872(v=vs.85).aspx
*/
! char event_source[256] = DEFAULT_EVENT_SOURCE;
/* Prototypes */
HRESULT DllInstall(BOOL bInstall, LPCWSTR pszCmdLine);
diff -rpcd a/src/include/pg_config_manual.h b/src/include/pg_config_manual.h
*** a/src/include/pg_config_manual.h 2014-06-21 09:17:03.000000000 +0900
--- b/src/include/pg_config_manual.h 2014-07-15 21:59:17.051000000 +0900
***************
*** 155,160 ****
--- 155,165 ----
#define DEFAULT_PGSOCKET_DIR "/tmp"
/*
+ * This is the default event source for Windows event log.
+ */
+ #define DEFAULT_EVENT_SOURCE "PostgreSQL"
+
+ /*
* The random() function is expected to yield values between 0 and
* MAX_RANDOM_VALUE. Currently, all known implementations yield
* 0..2^31-1, so we just hardwire this constant. We could do a