--- streamutil.c.orig	2018-02-26 19:13:40.000000000 -0300
+++ streamutil.c	2018-04-17 02:32:38.503288788 -0300
@@ -209,8 +209,13 @@
 	if (conn_opts)
 		PQconninfoFree(conn_opts);
 
-	/* Set always-secure search path, so malicious users can't get control. */
-	if (dbname != NULL)
+	/*  
+	 * Set always-secure search path, so malicious users can't get control.
+	 * The capacity to run normal SQL queries was added in PostgreSQL
+	 * 10, so the search path cannot be changed (by us or attackers) on
+	 * earlier versions.
+	 */
+	if (dbname != NULL && PQserverVersion(conn) >= 100000)
 	{
 		PGresult   *res;
 
