[Asterisk-code-review] res config pgsql: Fix removed support to previous for versio... (asterisk[15.0])

Joshua Colp asteriskteam at digium.com
Mon Sep 25 08:11:25 CDT 2017


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/6563 )

Change subject: res_config_pgsql: Fix removed support to previous for versions PostgreSQL 9.1
......................................................................

res_config_pgsql: Fix removed support to previous for versions PostgreSQL 9.1

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
(cherry picked from commit 365003a444b1b8c710b991d5dfec6fb6f49dc7c5)
---
M res/res_config_pgsql.c
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/res/res_config_pgsql.c b/res/res_config_pgsql.c
index 7a2c9db..abd00ca 100644
--- a/res/res_config_pgsql.c
+++ b/res/res_config_pgsql.c
@@ -52,6 +52,7 @@
 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
 
@@ -384,7 +385,7 @@
 }
 
 #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)
 {

-- 
To view, visit https://gerrit.asterisk.org/6563
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15.0
Gerrit-MessageType: merged
Gerrit-Change-Id: I96d9ee1ed7693ab17503cb36a9cd72847165f949
Gerrit-Change-Number: 6563
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Rodrigo Ramirez Norambuena <a at rodrigoramirez.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170925/20ef9f8c/attachment.html>


More information about the asterisk-code-review mailing list