break;
case DISTRIB_NONE:
default:
+ command_str = ""; /* keep compiler quiet */
Assert(0); /* Should not happen */
}
pgxc_node_str(PG_FUNCTION_ARGS)
{
Name result;
- int len;
- len = strlen(PGXCNodeName);
/* We use palloc0 here to ensure result is zero-padded */
result = (Name) palloc0(NAMEDATALEN);
memcpy(NameStr(*result), PGXCNodeName, NAMEDATALEN - 1);
/* Create tuplestore if does not exist */
if (*tuplestore == NULL)
{
- int ptrno;
+ int ptrno PG_USED_FOR_ASSERTS_ONLY;
char storename[64];
#ifdef SQUEUE_STAT
ClusterMonitorGetGlobalXmin(bool invalid_ok)
{
GlobalTransactionId xmin = InvalidGlobalTransactionId;
- int retries = 0;
SpinLockAcquire(&ClusterMonitorCtl->mutex);
xmin = ClusterMonitorCtl->gtm_recent_global_xmin;
*/
if (portal->holdStore == NULL && portal->status != PORTAL_FAILED)
{
- int idx;
+ int idx PG_USED_FOR_ASSERTS_ONLY;
char storename[64];
PortalCreateProducerStore(portal);
char cmd[1024];
FILE *pgxc_ctl_bash = fopen(path, "w");
int i;
+ int rc;
elog(NOTICE, "Installing pgxc_ctl_bash script as %s.\n", path);
if (!pgxc_ctl_bash)
fprintf(pgxc_ctl_bash, "%s\n", pgxc_ctl_bash_script[i]);
fclose(pgxc_ctl_bash);
sprintf(cmd, "chmod +x %s", path);
- system(cmd);
+ rc = system(cmd);
+ if (WEXITSTATUS(rc) != 0)
+ elog(ERROR, "failed to execute system command \"%s\"", cmd);
}
/*
continue;
}
} while(GetToken());
+
if (cmdList)
{
- int rc;
- rc = doCmdList(cmdList);
+ if (doCmdList(cmdList) != 0)
+ elog(ERROR, "failed to execute command list");
cleanCmdList(cmdList);
- elog(INFO, "Done.\n");
}
- return;
}
}
{
int pid;
pid = waitpid(cmds->cmds[ii]->pid, &status, 0);
+ (void ) pid; /* keep compiler quiet */
rc = WEXITSTATUS(status);
}
}
void appendCmdEl(cmd_t *src, cmd_t *new)
{
- cmd_t *curr;
+ /* go to the end of the list */
+ for(; src->next; src = src->next);
- for(curr = src; src->next; src = src->next);
src->next = new;
}
void do_monitor_command(char *line)
{
char *token;
- int rc = 0;
if (!GetToken())
{
if (isVarYes(VAR_gtmSlave))
monitor_gtm_slave();
else
- elog(ERROR, "ERROR: gtm slave is not configured.\n"), rc=-1;
+ elog(ERROR, "ERROR: gtm slave is not configured.\n");
}
else
- elog(ERROR, "Invalid monitor gtm command option.\n"), rc=-1;
+ elog(ERROR, "Invalid monitor gtm command option.\n");
return;
}
else if (TestToken("gtm_proxy"))
else if (TestToken("slave"))
{
if (!isVarYes(VAR_coordSlave))
- elog(ERROR, "ERROR: coordinator slave is not configured.\n"), rc = -1;
+ elog(ERROR, "ERROR: coordinator slave is not configured.\n");
else
if (!GetToken() || TestToken("all"))
monitor_coordinator_slave(aval(VAR_coordNames));
else if (TestToken("slave"))
{
if (!isVarYes(VAR_coordSlave))
- elog(ERROR, "ERROR: datanode slave is not configured.\n"), rc = -1;
+ elog(ERROR, "ERROR: datanode slave is not configured.\n");
else
if (!GetToken() || TestToken("all"))
monitor_datanode_slave(aval(VAR_coordNames));
{
struct stat buf;
char cmd[MAXLINE+1];
+ int rc;
if (stat(pgxc_ctl_home, &buf) ==0)
{
}
}
snprintf(cmd, MAXLINE, "mkdir -p %s", pgxc_ctl_home);
- system(cmd);
+
+ rc = system(cmd);
+ if (WEXITSTATUS(rc) != 0)
+ {
+ fprintf(stderr, "failed to execute system command \"%s\"", cmd);
+ exit(1);
+ }
+
if (stat(pgxc_ctl_home, &buf) ==0)
{
if (S_ISDIR(buf.st_mode))
static void pgxcCtlMkdir(char *path)
{
- char cmd[MAXPATH+1];
+ char cmd[MAXPATH+1];
+ int rc;
snprintf(cmd, MAXPATH, "mkdir -p %s", path);
- system(cmd);
+ rc = system(cmd);
+ if (WEXITSTATUS(rc) != 0)
+ {
+ fprintf(stderr, "failed to execute system command \"%s\"", cmd);
+ exit(1);
+ }
}
static void startLog(char *path, char *logFileNam)
elog(ERROR, "ERROR: could not open the command, \"%s\", %s\n", command, strerror(errno));
return NULL;
}
+
ipAddr = Malloc(MAXTOKEN+1);
- fgets(ipAddr, MAXTOKEN, f);
+ if (fgets(ipAddr, MAXTOKEN, f) == NULL)
+ {
+ elog(ERROR, "could not get IP address from the command \"%s\"",
+ command);
+ return NULL;
+ }
+
pclose(f);
trimNl(ipAddr);
return ipAddr;