From 385150b196c418d3056e02bf9a0f22a2f383bff7 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 3 Sep 2018 14:18:01 +0200 Subject: lib/mysql-functions: mysql_load_min_and_max_versions() new --- lib/mysql-functions | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'lib/mysql-functions') diff --git a/lib/mysql-functions b/lib/mysql-functions index 8cdafad..6c8154c 100755 --- a/lib/mysql-functions +++ b/lib/mysql-functions @@ -1257,3 +1257,32 @@ mysql_sort_versions() { mysql_run_query ) } + +# mysql_load_min_and_max_versions +# load the minimal and maximal versions into min_version and max_version + +mysql_load_min_and_max_versions() { + if [ -z "${min_version}" ]; then + min_version=$( + { + printf 'SELECT CONCAT(`versions`.`epoch`,":",`versions`.`version`)' + printf ' FROM `versions`' + printf ' ORDER BY `versions`.`order`' + printf ' LIMIT 1' + } | \ + mysql_run_query + ) + fi + + if [ -z "${max_version}" ]; then + max_version=$( + { + printf 'SELECT CONCAT(`versions`.`epoch`,":",`versions`.`version`)' + printf ' FROM `versions`' + printf ' ORDER BY `versions`.`order` DESC' + printf ' LIMIT 1' + } | \ + mysql_run_query + ) + fi +} -- cgit v1.2.3-70-g09d2