Applied patch from MDEV-5957