[bugfix] Expression state not properly reset throughout function calls

This may result in issues if a query is reused from the pool.
I did not introduce the flag, but I understand it's there to prevent stack overflow issues in recursive calls. If body contains another call to the same function, it should return from resetState immediately. I thus think the flag has to be set right at the start, before body.resetState is called.