[sr-dev] git:master:5557a441: db_postgres: Fixed blob hex encoding (#1255)

Sergey Safarov s.safarov at gmail.com
Fri Oct 12 02:02:28 CEST 2018


Module: kamailio
Branch: master
Commit: 5557a441a4969994c2a82a89d53dec710164a034
URL: https://github.com/kamailio/kamailio/commit/5557a441a4969994c2a82a89d53dec710164a034

Author: Sergey Safarov <s.safarov at gmail.com>
Committer: Sergey Safarov <s.safarov at gmail.com>
Date: 2018-10-10T06:13:17Z

db_postgres: Fixed blob hex encoding (#1255)

---

Modified: src/modules/db_postgres/km_pg_con.c

---

Diff:  https://github.com/kamailio/kamailio/commit/5557a441a4969994c2a82a89d53dec710164a034.diff
Patch: https://github.com/kamailio/kamailio/commit/5557a441a4969994c2a82a89d53dec710164a034.patch

---

diff --git a/src/modules/db_postgres/km_pg_con.c b/src/modules/db_postgres/km_pg_con.c
index 5a7225cefa..b66a94a0fb 100644
--- a/src/modules/db_postgres/km_pg_con.c
+++ b/src/modules/db_postgres/km_pg_con.c
@@ -52,6 +52,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;
 
 	LM_DBG("db_id = %p\n", id);
 
@@ -141,6 +142,15 @@ 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");
+		PQclear(res);
+		goto err;
+	}
+	PQclear(res);
+
 	return ptr;
 
 err:




More information about the sr-dev mailing list