]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_config_pgsql: Fix removed support to previous for versions PostgreSQL 9.1
authorRodrigo Ramírez Norambuena <a@rodrigoramirez.com>
Tue, 19 Sep 2017 10:22:50 +0000 (07:22 -0300)
committerRodrigo Ramirez Norambuena <a@rodrigoramirez.com>
Thu, 21 Sep 2017 16:25:39 +0000 (11:25 -0500)
In PostgreSQL 9.1 the backslash are string literals and not the escape
of characters.

In previous issue ASTERISK_26057 was fixed the use of escape LIKE but the
support for old version of Postgresql than 9.1 was dropped. The sentence
before make was "ESCAPE '\'" but in version before than 9.1  need it to be
as follow "ESCAPE '\\'".

ASTERISK-27283

Change-Id: I96d9ee1ed7693ab17503cb36a9cd72847165f949

res/res_config_pgsql.c

index b0a24c464320a98c4eb27419b9f3aa5ec934b72b..0244001424f18a08ef852a41dee6c4d4ebca929d 100644 (file)
@@ -54,6 +54,7 @@ AST_THREADSTORAGE(semibuf_buf);
 static PGconn *pgsqlConn = NULL;
 static int version;
 #define has_schema_support     (version > 70300 ? 1 : 0)
+#define USE_BACKSLASH_AS_STRING        (version >= 90100 ? 1 : 0)
 
 #define MAX_DB_OPTION_SIZE 64
 
@@ -419,7 +420,7 @@ static struct columns *find_column(struct tables *t, const char *colname)
 }
 
 #define IS_SQL_LIKE_CLAUSE(x) ((x) && ast_ends_with(x, " LIKE"))
-static char *ESCAPE_CLAUSE = " ESCAPE '\\'";
+#define ESCAPE_CLAUSE (USE_BACKSLASH_AS_STRING ? " ESCAPE '\\'" : " ESCAPE '\\\\'")
 
 static struct ast_variable *realtime_pgsql(const char *database, const char *tablename, const struct ast_variable *fields)
 {