From 2e88c67c9de5452c7e442d8e7fd35ca0172ad569 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 25 Nov 2009 20:55:19 +0000 Subject: [PATCH] improve chunked sql transaction submission git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@15672 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/switch_core_sqldb.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/src/switch_core_sqldb.c b/src/switch_core_sqldb.c index 9c31152df2..e591073083 100644 --- a/src/switch_core_sqldb.c +++ b/src/switch_core_sqldb.c @@ -366,7 +366,7 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl char *p, *s, *e; int chunk_count; switch_size_t len; - + switch_assert(chunk_size); if (err) *err = NULL; @@ -391,23 +391,25 @@ static switch_status_t switch_cache_db_execute_sql_chunked(switch_cache_db_handl p = e; } - while (p > s && *p != ';') { + while (p > s) { + if (*p == '\n' && *(p-1) == ';') { + *p = '\0'; + *(p-1) = '\0'; + break; + } + p--; } - if (p) { - *p = '\0'; - while(p < e && (*p == '\n' || *p == ' ')) { - p++; - } - } + if (p <= s) break; + status = switch_cache_db_execute_sql_real(dbh, s, err); if (status != SWITCH_STATUS_SUCCESS || (err && *err)) { break; } - s = p + 1; + s = p; } @@ -422,14 +424,9 @@ SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_hand switch (dbh->type) { - case SCDB_TYPE_CORE_DB: - { - status = switch_cache_db_execute_sql_real(dbh, sql, err); - } - break; default: { - status = switch_cache_db_execute_sql_chunked(dbh, (char *)sql, 32000, err); + status = switch_cache_db_execute_sql_chunked(dbh, (char *)sql, 32768, err); } break; }