aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_config_odbc.c
diff options
context:
space:
mode:
Diffstat (limited to 'res/res_config_odbc.c')
-rw-r--r--res/res_config_odbc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 8154ecc..86cc25c 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -30,6 +30,7 @@
/*** MODULEINFO
<depend>res_odbc</depend>
+ <support_level>core</support_level>
***/
#include "asterisk.h"
@@ -481,7 +482,7 @@ static int update_odbc(const char *database, const char *table, const char *keyf
va_list aq;
struct custom_prepare_struct cps = { .sql = sql, .extra = lookup };
struct odbc_cache_tables *tableptr;
- struct odbc_cache_columns *column;
+ struct odbc_cache_columns *column = NULL;
struct ast_flags connected_flag = { RES_ODBC_CONNECTED };
if (!table) {
@@ -519,7 +520,16 @@ static int update_odbc(const char *database, const char *table, const char *keyf
while((newparam = va_arg(aq, const char *))) {
va_arg(aq, const char *);
if ((tableptr && (column = ast_odbc_find_column(tableptr, newparam))) || count > 63) {
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=?", newparam);
+ /* NULL test for integer-based columns */
+ if (ast_strlen_zero(newparam) && tableptr && column && column->nullable && count < 64 &&
+ (column->type == SQL_INTEGER || column->type == SQL_BIGINT ||
+ column->type == SQL_SMALLINT || column->type == SQL_TINYINT ||
+ column->type == SQL_NUMERIC || column->type == SQL_DECIMAL)) {
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=NULL", newparam);
+ cps.skip |= (1LL << count);
+ } else {
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), ", %s=?", newparam);
+ }
} else { /* the column does not exist in the table */
cps.skip |= (1LL << count);
}