]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix autovacuum's database sorting.
authorNathan Bossart <nathan@postgresql.org>
Fri, 31 Jul 2026 15:34:40 +0000 (10:34 -0500)
committerNathan Bossart <nathan@postgresql.org>
Fri, 31 Jul 2026 15:34:40 +0000 (10:34 -0500)
When db_comparator() was updated to use pg_cmp_s32(), the arguments
were listed in the wrong order.  This caused autovacuum to sort the
databases by their scores in ascending order instead of descending
order.  To fix, swap the arguments to pg_cmp_s32().

Oversight in commit 3b42bdb471.

Reported-by: Хамидуллин Рустам <r.khamidullin@postgrespro.ru>
Author: Хамидуллин Рустам <r.khamidullin@postgrespro.ru>
Discussion: https://postgr.es/m/5c5a7984-b149-b505-7ad9-2a7766c65b55%40postgrespro.ru
Backpatch-through: 17

src/backend/postmaster/autovacuum.c

index 45abf48768afdaeffe0a6ec9805fdb2c0419d24e..ee202a4b47eaa89846aac4cb3365607f24399bac 100644 (file)
@@ -1113,8 +1113,8 @@ rebuild_database_list(Oid newdb)
 static int
 db_comparator(const void *a, const void *b)
 {
-       return pg_cmp_s32(((const avl_dbase *) a)->adl_score,
-                                         ((const avl_dbase *) b)->adl_score);
+       return pg_cmp_s32(((const avl_dbase *) b)->adl_score,
+                                         ((const avl_dbase *) a)->adl_score);
 }
 
 /*