[svn-commits] russell: branch 1.2 r74656 - /branches/1.2/res/res_config_odbc.c
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Wed Jul 11 13:33:23 CDT 2007
Author: russell
Date: Wed Jul 11 13:33:23 2007
New Revision: 74656
URL: http://svn.digium.com/view/asterisk?view=rev&rev=74656
Log:
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)
Modified:
branches/1.2/res/res_config_odbc.c
Modified: branches/1.2/res/res_config_odbc.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/res/res_config_odbc.c?view=diff&rev=74656&r1=74655&r2=74656
==============================================================================
--- branches/1.2/res/res_config_odbc.c (original)
+++ branches/1.2/res/res_config_odbc.c Wed Jul 11 13:33:23 2007
@@ -95,16 +95,15 @@
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)) {
@@ -242,18 +241,17 @@
if (initfield && (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)) {
More information about the svn-commits
mailing list