Fixes #6271: Query caching returns the same data when running the same SQL with different fetch modes