fix in clearing of output buffer
This commit is contained in:
parent
17c287e5c0
commit
725228882d
@ -234,7 +234,7 @@ int pg_worker_work(void *handle, void *work_handle, char *input, htbuffer_t *out
|
||||
|
||||
res = process(pwh, input, output);
|
||||
|
||||
return SMM_OK;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@ -251,7 +251,7 @@ static int break_input(pg_worker_handle_t *pwh, char *input) {
|
||||
*param = '\0';
|
||||
if (cnt >= pwh->pch->param_cnt) {
|
||||
syslog(LOG_ERR, "pgworker (%p) break_input: too much parameters", pwh);
|
||||
return -1;
|
||||
return SMM_ILLEGAL_INPUT;
|
||||
}
|
||||
pwh->param_array[cnt] = nextptr;
|
||||
cnt++;
|
||||
@ -263,7 +263,7 @@ static int break_input(pg_worker_handle_t *pwh, char *input) {
|
||||
/* last */
|
||||
if (cnt >= pwh->pch->param_cnt) {
|
||||
syslog(LOG_ERR, "pgworker (%p) break_input: too much parameters", pwh);
|
||||
return -1;
|
||||
return SMM_ILLEGAL_INPUT;
|
||||
}
|
||||
pwh->param_array[cnt] = nextptr;
|
||||
cnt++;
|
||||
@ -272,7 +272,7 @@ static int break_input(pg_worker_handle_t *pwh, char *input) {
|
||||
|
||||
if (cnt < pwh->pch->param_cnt) {
|
||||
syslog(LOG_ERR, "pgworker (%p) break_input: too few parameters", pwh);
|
||||
return -1;
|
||||
return SMM_ILLEGAL_INPUT;
|
||||
}
|
||||
|
||||
syslog(LOG_DEBUG, "pgworker (%p) break_input: end", pwh);
|
||||
@ -291,12 +291,16 @@ static int populate_output_format(pg_worker_handle_t *pwh, PGresult *pgr,
|
||||
char *s;
|
||||
int i, x, cnt=0, done, res=0;
|
||||
|
||||
htbuffer_strcpy(output, "");
|
||||
syslog(LOG_DEBUG, "pgworker (%p) populate_output_format OUTPUT: %s",
|
||||
pwh, output->buf);
|
||||
|
||||
|
||||
while ((formatPtr = strchr(formatPtr, '$')) && (res == 0)) {
|
||||
syslog(LOG_DEBUG, "pgworker (%p) populate_output_format tmpPtr: %s, formatPtr: %s, d: %i",
|
||||
pwh, tmpPtr, formatPtr, formatPtr - tmpPtr);
|
||||
htbuffer_strncat(output, tmpPtr, formatPtr - tmpPtr);
|
||||
syslog(LOG_DEBUG, "pgworker (%p) populate_output_format OUTPUT: %s",
|
||||
pwh, output);
|
||||
pwh, output->buf);
|
||||
formatPtr++;
|
||||
for (i = 0, done = 0; (i <= MAX_RESULT_DIGIT_NUM) && !done; i++) {
|
||||
if (isdigit(*formatPtr)) {
|
||||
@ -322,7 +326,7 @@ static int populate_output_format(pg_worker_handle_t *pwh, PGresult *pgr,
|
||||
syslog(LOG_ERR, "pgworker (%p) populate_outputformat, not done, failure",
|
||||
pwh);
|
||||
htbuffer_strcpy(output, "");
|
||||
res = -1;
|
||||
res = SMM_ILLEGAL_INPUT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -367,16 +371,18 @@ static int process(pg_worker_handle_t *pwh, char *input, htbuffer_t *output) {
|
||||
"pgworker (%p) process: more than one result fields (%d) but no format string",
|
||||
pwh, f);
|
||||
htbuffer_strcpy(output, PQgetvalue(pgr, 0, 0));
|
||||
res = 0;
|
||||
res = SMM_OK;
|
||||
} else {
|
||||
if (0 == (res = populate_output_format(pwh, pgr, output, 0))) {
|
||||
syslog(LOG_DEBUG, "pgworker (%p) process: output %s", pwh, output->buf);
|
||||
res = SMM_OK;
|
||||
} else {
|
||||
syslog(LOG_ERR, "pgworker (%p) process failure in population of output", pwh);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
syslog(LOG_DEBUG, "pgworker (%p) process: no output", pwh);
|
||||
res = SMM_NOT_FOUND_NOK;
|
||||
}
|
||||
|
||||
PQclear(pgr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user