瀏覽代碼

Merge pull request #1672 from sergey-safarov/psql

db_postgres: Fixed blob hex encoding (#1255)
Daniel-Constantin Mierla 7 年之前
父節點
當前提交
167ff2b29d
共有 1 個文件被更改,包括 10 次插入0 次删除
  1. 10 0
      src/modules/db_postgres/km_pg_con.c

+ 10 - 0
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;
 	int i = 0;
 	const char *keywords[10], *values[10];
 	const char *keywords[10], *values[10];
 	char to[16];
 	char to[16];
+	PGresult   *res;
 
 
 	LM_DBG("db_id = %p\n", id);
 	LM_DBG("db_id = %p\n", id);
 
 
@@ -141,6 +142,15 @@ struct pg_con *db_postgres_new_connection(struct db_id *id)
 	}
 	}
 #endif
 #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;
 	return ptr;
 
 
 err:
 err: