Convert func_odbc to use SQLExecDirect for speed
authorTilghman Lesher <tilghman@meg.abyt.es>
Fri, 18 Jan 2008 06:58:35 +0000 (06:58 +0000)
committerTilghman Lesher <tilghman@meg.abyt.es>
Fri, 18 Jan 2008 06:58:35 +0000 (06:58 +0000)
(closes issue #10723)
 Reported by: mnicholson
 Patches:
       func-odbc-direct-execute1.diff uploaded by mnicholson (license 96)
 Tested by: Corydon76, mnicholson, falves11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@99018 65c4cc65-6c06-0410-ace0-fbb531ad65f3

funcs/func_odbc.c

index f472e25..af4bab0 100644 (file)
@@ -98,7 +98,7 @@ static void odbc_datastore_free(void *data)
        ast_free(result);
 }
 
-static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
+static SQLHSTMT generic_execute(struct odbc_obj *obj, void *data)
 {
        int res;
        char *sql = data;
@@ -110,9 +110,9 @@ static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
                return NULL;
        }
 
-       res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
+       res = SQLExecDirect(stmt, (unsigned char *)sql, SQL_NTS);
        if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-               ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
+               ast_log(LOG_WARNING, "SQL Exec Direct failed![%s]\n", sql);
                SQLCloseCursor(stmt);
                SQLFreeHandle (SQL_HANDLE_STMT, stmt);
                return NULL;
@@ -209,7 +209,7 @@ static int acf_odbc_write(struct ast_channel *chan, const char *cmd, char *s, co
                if (!ast_strlen_zero(query->writehandle[dsn])) {
                        obj = ast_odbc_request_obj(query->writehandle[dsn], 0);
                        if (obj)
-                               stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, buf);
+                               stmt = ast_odbc_direct_execute(obj, generic_execute, buf);
                }
                if (stmt)
                        break;
@@ -310,7 +310,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha
                if (!ast_strlen_zero(query->writehandle[dsn])) {
                        obj = ast_odbc_request_obj(query->writehandle[dsn], 0);
                        if (obj)
-                               stmt = ast_odbc_prepare_and_execute(obj, generic_prepare, sql);
+                               stmt = ast_odbc_direct_execute(obj, generic_execute, sql);
                }
                if (stmt)
                        break;