Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-09-01 20:05:30 +0200
committerErich Eckner <git@eckner.net>2018-09-01 20:05:30 +0200
commitc2fb97d586e8a2f4383823a36361207285d94d4d (patch)
treeec6d3c4f5a88b8a441ae32e2c9c16efab3fb75d3
parent5e08f8967397fb981734eaaf0f179676b9e139a9 (diff)
lib/mysql-functions: exit early from mysql_sort_versions() if all versions are ordered already
-rwxr-xr-xlib/mysql-functions18
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/mysql-functions b/lib/mysql-functions
index 9fe0984..c0f7790 100755
--- a/lib/mysql-functions
+++ b/lib/mysql-functions
@@ -1179,14 +1179,28 @@ mysql_update_versions_ordering() {
)
}
-# mysql_sort_versions
-# sort the table of versions
+# mysql_sort_versions [-f]
+# sort the table of versions, iff versions without order exist or -f was
+# given
+
mysql_sort_versions() {
( # new shell is intentional
tmp_file=$(
mktemp "tmp.mysql_sort_versions.XXXXXXXXXX" --tmpdir
)
trap 'rm "${tmp_file}"' EXIT
+ if [ "x$1" != 'x-f' ] && \
+ {
+ printf 'SELECT'
+ printf ' COUNT(1)'
+ printf ' FROM `versions`'
+ printf ' WHERE `versions`.`order` IS NULL'
+ } | \
+ mysql_run_query | \
+ grep -qxF '0'; then
+ # nothing to do
+ return 0
+ fi
{
printf 'SELECT '
printf '`versions`.`%s`,' \