From e2576b4a0635ab0499ff83205f8c13540076e11e Mon Sep 17 00:00:00 2001 From: tilghman Date: Sun, 25 Nov 2007 17:17:10 +0000 Subject: 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: http://svn.digium.com/svn/asterisk/branches/1.4@89559 f38db490-d61c-443f-a65b-d21fe96a405b --- res/res_odbc.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'res/res_odbc.c') diff --git a/res/res_odbc.c b/res/res_odbc.c index 53df46164..0faffe61d 100644 --- a/res/res_odbc.c +++ b/res/res_odbc.c @@ -66,6 +66,7 @@ struct odbc_class unsigned int limit:10; /* Gives a limit of 1023 maximum */ unsigned int count:10; /* Running count of pooled connections */ unsigned int delme:1; /* Purge the class */ + unsigned int backslash_is_escape:1; /* On this database, the backslash is a native escape sequence */ AST_LIST_HEAD(, odbc_obj) odbc_obj; }; @@ -212,7 +213,7 @@ static int load_odbc_config(void) struct ast_config *config; struct ast_variable *v; char *cat, *dsn, *username, *password; - int enabled, pooling, limit; + int enabled, pooling, limit, bse; int connect = 0, res = 0; struct odbc_class *new; @@ -235,6 +236,7 @@ static int load_odbc_config(void) connect = 0; pooling = 0; limit = 0; + bse = 1; for (v = ast_variable_browse(config, cat); v; v = v->next) { if (!strcasecmp(v->name, "pooling")) { if (ast_true(v->value)) @@ -259,6 +261,8 @@ static int load_odbc_config(void) username = v->value; } else if (!strcasecmp(v->name, "password")) { password = v->value; + } else if (!strcasecmp(v->name, "backslash_is_escape")) { + bse = ast_true(v->value); } } @@ -298,6 +302,8 @@ static int load_odbc_config(void) } } + new->backslash_is_escape = bse ? 1 : 0; + odbc_register_class(new, connect); ast_log(LOG_NOTICE, "Registered ODBC class '%s' dsn->[%s]\n", cat, dsn); } @@ -379,6 +385,11 @@ void ast_odbc_release_obj(struct odbc_obj *obj) obj->used = 0; } +int ast_odbc_backslash_is_escape(struct odbc_obj *obj) +{ + return obj->parent->backslash_is_escape; +} + struct odbc_obj *ast_odbc_request_obj(const char *name, int check) { struct odbc_obj *obj = NULL; @@ -533,7 +544,7 @@ static int reload(void) struct ast_config *config; struct ast_variable *v; char *cat, *dsn, *username, *password; - int enabled, pooling, limit; + int enabled, pooling, limit, bse; int connect = 0, res = 0; struct odbc_class *new, *class; @@ -560,6 +571,7 @@ static int reload(void) connect = 0; pooling = 0; limit = 0; + bse = 1; for (v = ast_variable_browse(config, cat); v; v = v->next) { if (!strcasecmp(v->name, "pooling")) { pooling = 1; @@ -583,6 +595,8 @@ static int reload(void) username = v->value; } else if (!strcasecmp(v->name, "password")) { password = v->value; + } else if (!strcasecmp(v->name, "backslash_is_escape")) { + bse = ast_true(v->value); } } @@ -637,6 +651,8 @@ static int reload(void) } } + new->backslash_is_escape = bse; + if (class) { ast_log(LOG_NOTICE, "Refreshing ODBC class '%s' dsn->[%s]\n", cat, dsn); } else { -- cgit v1.2.3