summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2014-11-10 11:04:17 +0000
committerPavan Deolasee2015-04-15 05:46:38 +0000
commit260f268187607615323a4c31da28d3c35ad01744 (patch)
treecbdd44f4488199d4e99d73e55a30d8003079d1ab
parent58a80dbf7182f6edff44d66efdd191238ded46af (diff)
Do not read prototype config file when dealing with user specified conf file
pgxc_ctl utility was picking up parameters from the default configuration when such parameters are not defined in the conf file. This creates all sorts of unintentional side effects. Fix that by skipping default conf while dealing with a specified conf file
-rw-r--r--contrib/pgxc_ctl/bash_handler.c9
-rw-r--r--contrib/pgxc_ctl/bash_handler.h2
-rw-r--r--contrib/pgxc_ctl/pgxc_ctl.c4
3 files changed, 9 insertions, 6 deletions
diff --git a/contrib/pgxc_ctl/bash_handler.c b/contrib/pgxc_ctl/bash_handler.c
index 1cae6b46b3..c4aa1e27f1 100644
--- a/contrib/pgxc_ctl/bash_handler.c
+++ b/contrib/pgxc_ctl/bash_handler.c
@@ -24,7 +24,7 @@ extern char *pgxc_ctl_conf_prototype[];
/*
* Install bash script.
*/
-void install_pgxc_ctl_bash(char *path)
+void install_pgxc_ctl_bash(char *path, int read_prototype)
{
char cmd[1024];
FILE *pgxc_ctl_bash = fopen(path, "w");
@@ -35,8 +35,11 @@ void install_pgxc_ctl_bash(char *path)
{
elog(ERROR, "ERROR: Could not open pgxc_ctl bash script, %s, %s\n", path, strerror(errno));
}
- for (i=0; pgxc_ctl_conf_prototype[i]; i++)
- fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_conf_prototype[i]);
+ if (read_prototype)
+ {
+ for (i=0; pgxc_ctl_conf_prototype[i]; i++)
+ fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_conf_prototype[i]);
+ }
for (i=0; pgxc_ctl_bash_script[i]; i++)
fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_bash_script[i]);
fclose(pgxc_ctl_bash);
diff --git a/contrib/pgxc_ctl/bash_handler.h b/contrib/pgxc_ctl/bash_handler.h
index c16638b7a3..c0494137bd 100644
--- a/contrib/pgxc_ctl/bash_handler.h
+++ b/contrib/pgxc_ctl/bash_handler.h
@@ -11,7 +11,7 @@
#ifndef BASH_HANDLER_H
#define BASH_HANDLER_H
-void install_pgxc_ctl_bash(char *path);
+void install_pgxc_ctl_bash(char *path, int read_prototype);
void read_config_file(char *path, char *conf);
void uninstall_pgxc_ctl_bash(char *path);
diff --git a/contrib/pgxc_ctl/pgxc_ctl.c b/contrib/pgxc_ctl/pgxc_ctl.c
index 4f47c656b0..1bb567bcfa 100644
--- a/contrib/pgxc_ctl/pgxc_ctl.c
+++ b/contrib/pgxc_ctl/pgxc_ctl.c
@@ -241,7 +241,7 @@ static void read_configuration(void)
FILE *conf;
char cmd[MAXPATH+1];
- install_pgxc_ctl_bash(pgxc_ctl_bash_path);
+ install_pgxc_ctl_bash(pgxc_ctl_bash_path, false);
if (pgxc_ctl_config_path[0])
snprintf(cmd, MAXPATH, "%s --home %s --configuration %s",
pgxc_ctl_bash_path, pgxc_ctl_home, pgxc_ctl_config_path);
@@ -267,7 +267,7 @@ static void prepare_pgxc_ctl_bash(char *path)
rc = stat(path, &buf);
if (rc)
- install_pgxc_ctl_bash(path);
+ install_pgxc_ctl_bash(path, true);
else
if (S_ISREG(buf.st_mode))
return;