Browse files

Nikhil Sontakke kindly provided this to fix gtm_ctl dependency

on PATH environment, the bug 3602944.

	modified:   src/bin/gtm_ctl/gtm_ctl.c
	modified:   src/gtm/main/main.c
	modified:   src/gtm/proxy/proxy_main.c
  • Loading branch information...
1 parent 7b36cbe commit 7d7bc1351125cf43568990b19d1b41e57949e87f Koichi Suzuki committed Feb 1, 2013
Showing with 57 additions and 0 deletions.
  1. +45 −0 src/bin/gtm_ctl/gtm_ctl.c
  2. +6 −0 src/gtm/main/main.c
  3. +6 −0 src/gtm/proxy/proxy_main.c
View
45 src/bin/gtm_ctl/gtm_ctl.c
@@ -480,6 +480,45 @@ do_start(void)
read_gtm_opts();
+ /* The binary for both gtm and gtm_standby is the same */
+ if (strcmp(gtm_app, "gtm_standby") == 0)
+ gtm_app = "gtm";
+
+ if (gtm_path == NULL)
+ {
+ int ret;
+ char *found_path;
+ char version_str[MAXPGPATH];
+
+ found_path = pg_malloc(MAXPGPATH);
+ sprintf(version_str, "%s (Postgres-XC) %s\n", gtm_app, PGXC_VERSION);
+
+ if ((ret = find_other_exec(argv0, gtm_app, version_str, found_path)) < 0)
+ {
+ char full_path[MAXPGPATH];
+
+ if (find_my_exec(argv0, full_path) < 0)
+ strlcpy(full_path, progname, sizeof(full_path));
+
+ if (ret == -1)
+ write_stderr(_("The program \"%s\" is needed by gtm_ctl "
+ "but was not found in the\n"
+ "same directory as \"%s\".\n"
+ "Check your installation.\n"),
+ gtm_app, full_path);
+ else
+ write_stderr(_("The program \"%s\" was found by \"%s\"\n"
+ "but was not the same version as gtm_ctl.\n"
+ "Check your installation.\n"),
+ gtm_app, full_path);
+ exit(1);
+ }
+
+ *last_dir_separator(found_path) = '\0';
+
+ gtm_path = found_path;
+ }
+
exitcode = start_gtm();
if (exitcode != 0)
{
@@ -923,6 +962,7 @@ do_help(void)
printf(_(" -t SECS seconds to wait when using -w option\n"));
printf(_(" -w wait until operation completes\n"));
printf(_(" -W do not wait until operation completes\n"));
+ printf(_(" -V, --version output version information, then exit\n"));
printf(_(" --help show this help, then exit\n"));
printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n"));
@@ -997,6 +1037,11 @@ main(int argc, char **argv)
do_help();
exit(0);
}
+ if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+ {
+ puts("gtm_ctl (Postgres-XC) " PGXC_VERSION);
+ exit(0);
+ }
}
/*
View
6 src/gtm/main/main.c
@@ -264,6 +264,7 @@ help(const char *progname)
printf(_(" -D directory GTM working directory\n"));
printf(_(" -l filename GTM server log file name \n"));
printf(_(" -c show server status, then exit\n"));
+ printf(_(" -V, --version output version information, then exit\n"));
printf(_(" --help show this help, then exit\n"));
printf(_("\n"));
printf(_("Options for Standby mode:\n"));
@@ -338,6 +339,11 @@ main(int argc, char *argv[])
help(argv[0]);
exit(0);
}
+ if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+ {
+ puts("gtm (Postgres-XC) " PGXC_VERSION);
+ exit(0);
+ }
}
ListenAddresses = strdup(GTM_DEFAULT_HOSTNAME);
View
6 src/gtm/proxy/proxy_main.c
@@ -549,6 +549,7 @@ help(const char *progname)
printf(_(" -n count Number of worker threads\n"));
printf(_(" -D directory GTM proxy working directory\n"));
printf(_(" -l filename GTM proxy log file name \n"));
+ printf(_(" -V, --version output version information, then exit\n"));
printf(_(" --help show this help, then exit\n"));
}
@@ -589,6 +590,11 @@ main(int argc, char *argv[])
help(argv[0]);
exit(0);
}
+ if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
+ {
+ puts("gtm_proxy (Postgres-XC) " PGXC_VERSION);
+ exit(0);
+ }
}
ListenAddresses = strdup(GTM_PROXY_DEFAULT_HOSTNAME);

0 comments on commit 7d7bc13

Please sign in to comment.