Note: There was a very similar bug
MDEV-19595. However the test case there was only failing on 10.2+, so the bug was fixed in 10.2+. The test case below reveals the same problem on 5.5 and 10.1. On 10.2+ it stopped failing after the fix for MDEV-19595, so it's apparently the same problem. I don't expect it to be fixed in 10.1 which is at the moment 3 major releases behind the latest one; but tests on 10.1 are still running, and the bug affects them, so I need it to be filed. It will quietly expire when 5.5 and 10.1 go EOL.