Module: kamailio Branch: master Commit: 861205b8aeed19fe8693e21fe5f1856f1dcb08c5 URL: https://github.com/kamailio/kamailio/commit/861205b8aeed19fe8693e21fe5f1856f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2018-10-12T02:09:21+02:00
db_postgres: new parameter bytea_output_escape
- control escaping output for bytea fields - default 1 (do the escape)
---
Modified: src/modules/db_postgres/km_pg_con.c Modified: src/modules/db_postgres/pg_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/861205b8aeed19fe8693e21fe5f1856f... Patch: https://github.com/kamailio/kamailio/commit/861205b8aeed19fe8693e21fe5f1856f...
---
diff --git a/src/modules/db_postgres/km_pg_con.c b/src/modules/db_postgres/km_pg_con.c index b66a94a0fb..f6a2b8c8e0 100644 --- a/src/modules/db_postgres/km_pg_con.c +++ b/src/modules/db_postgres/km_pg_con.c @@ -37,6 +37,8 @@ #include <netinet/tcp.h>
+extern int pg_bytea_output_escape; + /*! * \brief Create a new connection * @@ -52,7 +54,7 @@ struct pg_con *db_postgres_new_connection(struct db_id *id) int i = 0; const char *keywords[10], *values[10]; char to[16]; - PGresult *res; + PGresult *res = NULL;
LM_DBG("db_id = %p\n", id);
@@ -142,15 +144,16 @@ struct pg_con *db_postgres_new_connection(struct db_id *id) } #endif
- res = PQexec(ptr->con, "SET bytea_output=escape"); - if (PQresultStatus(res) != PGRES_COMMAND_OK) - { - LM_ERR("cannot set blob output escaping format\n"); + if(pg_bytea_output_escape!=0) { + res = PQexec(ptr->con, "SET bytea_output=escape"); + if (PQresultStatus(res) != PGRES_COMMAND_OK) + { + LM_ERR("cannot set blob output escaping format\n"); + PQclear(res); + goto err; + } PQclear(res); - goto err; } - PQclear(res); - return ptr;
err: diff --git a/src/modules/db_postgres/pg_mod.c b/src/modules/db_postgres/pg_mod.c index 070fc66a49..7ebee934c4 100644 --- a/src/modules/db_postgres/pg_mod.c +++ b/src/modules/db_postgres/pg_mod.c @@ -58,6 +58,7 @@ int pg_retries = int pg_lockset = 4; int pg_timeout = 0; /* default = no timeout */ int pg_keepalive = 0; +int pg_bytea_output_escape = 1;
/* * Postgres module interface @@ -91,6 +92,7 @@ static param_export_t params[] = { {"lockset", PARAM_INT, &pg_lockset}, {"timeout", PARAM_INT, &pg_timeout}, {"tcp_keepalive", PARAM_INT, &pg_keepalive}, + {"bytea_output_escape", PARAM_INT, &pg_bytea_output_escape}, {0, 0, 0} };