aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_config_odbc.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-11 18:35:36 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-11 18:35:36 +0000
commit23063a7d4d1f9a4e7b70c4c246e36ac674ebeafc (patch)
treef24672d7bef0368529731889771daa63a9abd6ac /res/res_config_odbc.c
parent5ca366c96fd9b17ec449a040881417985e5efc85 (diff)
Merged revisions 74657 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ................ r74657 | russell | 2007-07-11 13:34:51 -0500 (Wed, 11 Jul 2007) | 12 lines Merged revisions 74656 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.2 ........ r74656 | russell | 2007-07-11 13:33:23 -0500 (Wed, 11 Jul 2007) | 4 lines Make sure that the ESCAPE immediately follows the condition that uses LIKE. This fixes realtime extensions with ODBC. (closes issue #10175, reported by stuarth, patch by me) ........ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@74658 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_config_odbc.c')
-rw-r--r--res/res_config_odbc.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 8b28c2ee4..158b40f67 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -101,16 +101,15 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
return NULL;
}
newval = va_arg(aq, const char *);
- if (!strchr(newparam, ' ')) op = " ="; else op = "";
+ op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?", table, newparam, op);
while((newparam = va_arg(aq, const char *))) {
- if (!strchr(newparam, ' ')) op = " ="; else op = "";
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?", newparam, op);
+ op = !strchr(newparam, ' ') ? " =" : "";
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
+ strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
}
va_end(aq);
- if (strcasestr(sql, "LIKE"))
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ESCAPE '\\'");
res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
@@ -257,18 +256,17 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
if ((op = strchr(initfield, ' ')))
*op = '\0';
newval = va_arg(aq, const char *);
- if (!strchr(newparam, ' ')) op = " ="; else op = "";
+ op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?", table, newparam, op);
while((newparam = va_arg(aq, const char *))) {
- if (!strchr(newparam, ' ')) op = " ="; else op = "";
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?", newparam, op);
+ op = !strchr(newparam, ' ') ? " =" : "";
+ snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
+ strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
}
if (initfield)
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ORDER BY %s", initfield);
va_end(aq);
- if (strcasestr(sql, "LIKE"))
- snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " ESCAPE '\\'");
res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {