From 6bfa2992166f17e9c649edd6d037ad23334bbdd4 Mon Sep 17 00:00:00 2001 From: Seven Du Date: Tue, 2 Jun 2015 18:46:29 +0800 Subject: [PATCH] set affected_rows also for non-SELECT queries --- src/switch_pgsql.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/switch_pgsql.c b/src/switch_pgsql.c index 4d955f1f45..d51312e866 100644 --- a/src/switch_pgsql.c +++ b/src/switch_pgsql.c @@ -25,6 +25,7 @@ * * Anthony Minessale II * Eliot Gable + * Seven Du * * switch_pgsql.c -- PGSQL Driver * @@ -465,7 +466,17 @@ SWITCH_DECLARE(switch_pgsql_status_t) switch_pgsql_finish_results_real(const cha switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_ERROR, "Error executing query:\n%s\n", res->err); final_status = SWITCH_PGSQL_FAIL; } - if (!res) done = 1; + + if (!res) { + done = 1; + } else if (res->result) { + char *affected_rows = PQcmdTuples(res->result); + + if (!zstr(affected_rows)) { + handle->affected_rows = atoi(affected_rows); + } + } + switch_pgsql_free_result(&res); } while (!done); return final_status;