MDEV-406: ANALYZE $stmt: more testcases, fix memory leak