[bugfix] Expression state not properly reset throughout function calls

This may result in issues if a query is reused from the pool.