summaryrefslogtreecommitdiff
path: root/res/res_config_odbc.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2007-11-25 17:50:07 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2007-11-25 17:50:07 +0000
commitf1de129e5f0e5cbf92b9d4e06a4d7eec19ebbcdc (patch)
tree143073ebaa786fc4f8e870a08f16f88f3f000ded /res/res_config_odbc.c
parentc8edf66bb453b75f541a3ff4caea1ba3b804a9fe (diff)
Merged revisions 89559 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r89559 | tilghman | 2007-11-25 11:17:10 -0600 (Sun, 25 Nov 2007) | 14 lines We previously attempted to use the ESCAPE clause to set the escape delimiter to a backslash. Unfortunately, this does not universally work on all databases, since on databases which natively use the backslash as a delimiter, the backslash itself needs to be delimited, but on other databases that have no delimiter, backslashing the backslash causes an error. So the only solution that I can come up with is to create an option in res_odbc that explicitly specifies whether or not backslash is a native delimiter. If it is, we use it natively; if not, we use the ESCAPE clause to make it one. Reported by: elguero Patch by: tilghman (Closes issue #11364) ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@89561 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_config_odbc.c')
-rw-r--r--res/res_config_odbc.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/res/res_config_odbc.c b/res/res_config_odbc.c
index 2af47209a..57b1ba528 100644
--- a/res/res_config_odbc.c
+++ b/res/res_config_odbc.c
@@ -142,11 +142,12 @@ static struct ast_variable *realtime_odbc(const char *database, const char *tabl
return NULL;
newval = va_arg(aq, const char *);
op = !strchr(newparam, ' ') ? " =" : "";
- snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?", table, newparam, op);
+ snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?%s", table, newparam, op,
+ strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
while((newparam = va_arg(aq, const char *))) {
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
- strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : "");
+ strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
}
va_end(aq);
@@ -290,11 +291,11 @@ static struct ast_config *realtime_multi_odbc(const char *database, const char *
newval = va_arg(aq, const char *);
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql, sizeof(sql), "SELECT * FROM %s WHERE %s%s ?%s", table, newparam, op,
- strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : "");
+ strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
while((newparam = va_arg(aq, const char *))) {
op = !strchr(newparam, ' ') ? " =" : "";
snprintf(sql + strlen(sql), sizeof(sql) - strlen(sql), " AND %s%s ?%s", newparam, op,
- strcasestr(newparam, "LIKE") ? " ESCAPE '\\'" : "");
+ strcasestr(newparam, "LIKE") && !ast_odbc_backslash_is_escape(obj) ? " ESCAPE '\\'" : "");
newval = va_arg(aq, const char *);
}
if (initfield)