From 4fc08e39b46f5b321f005c8e73b70252c17487f2 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Wed, 19 May 2021 07:17:14 +0200
Subject: [PATCH] db/proxy: require MPD 0.20 or later

Allows using ranges, always.  This is required to fix
https://github.com/MusicPlayerDaemon/MPD/issues/1130 without adding
more runtime conditionals.
---
 NEWS                                   | 2 ++
 src/db/plugins/ProxyDatabasePlugin.cxx | 5 ++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index d02f6f3a0..cff70595b 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,8 @@ ver 0.23 (not yet released)
 * protocol
   - new command "getvol"
   - show the audio format in "playlistinfo"
+* database
+  - proxy: require MPD 0.20 or later
 * output
   - pipewire: new plugin
   - snapcast: new plugin
diff --git a/src/db/plugins/ProxyDatabasePlugin.cxx b/src/db/plugins/ProxyDatabasePlugin.cxx
index a352e3344..2ac00b299 100644
--- a/src/db/plugins/ProxyDatabasePlugin.cxx
+++ b/src/db/plugins/ProxyDatabasePlugin.cxx
@@ -414,7 +414,6 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
 
 #if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
 	if (selection.window != RangeArg::All() &&
-	    mpd_connection_cmp_server_version(connection, 0, 20, 0) >= 0 &&
 	    !mpd_search_add_window(connection, selection.window.start,
 				   selection.window.end))
 		return false;
@@ -507,11 +506,11 @@ ProxyDatabase::Connect()
 	try {
 		CheckError(connection);
 
-		if (mpd_connection_cmp_server_version(connection, 0, 19, 0) < 0) {
+		if (mpd_connection_cmp_server_version(connection, 0, 20, 0) < 0) {
 			const unsigned *version =
 				mpd_connection_get_server_version(connection);
 			throw FormatRuntimeError("Connect to MPD %u.%u.%u, but this "
-						 "plugin requires at least version 0.19",
+						 "plugin requires at least version 0.20",
 						 version[0], version[1], version[2]);
 		}