Limit rewrite recursion depth

Loops in the rewriter would end up pegging the CPU until memory was
exhausted. Max recursion is now configurable and limited to 100
iterations.

Fixes: COUCHDB-1441
1 file changed