提交 f66fbe2e authored 作者: Eliot Gable's avatar Eliot Gable

Fix callback method to pass column count instead of the integer representation…

Fix callback method to pass column count instead of the integer representation of the row we are on.
上级 ec20bc0b
......@@ -623,6 +623,7 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed
}
while (result != NULL) {
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Processing result with %d rows and %d columns.\n", result->rows, result->cols);*/
for (row = 0; row < result->rows; ++row) {
char **names;
char **vals;
......@@ -648,13 +649,16 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed
vals[col][len] = '\0';
tmp = PQgetvalue(result->result, row, col);
strncpy(vals[col], tmp, len);
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Processing result row %d, col %d: %s => %s\n", row, col, names[col], vals[col]);*/
} else {
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Processing result row %d, col %d.\n", row, col);*/
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "ERR: Column number %d out of range\n", col);
}
}
if (callback(pdata, row, vals, names)) {
break;
/*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Executing callback for row %d...\n", row);*/
if (callback(pdata, result->cols, vals, names)) {
goto done;
}
for (col = 0; col < result->cols; ++col) {
......@@ -682,6 +686,12 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_handle_callback_exec_detailed
goto error;
}
done:
if (result) {
switch_pgsql_free_result(&result);
}
switch_pgsql_finish_results(handle);
return SWITCH_PGSQL_SUCCESS;
error:
#endif
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论