Rewriting the query implementation

This allows a query to raise an exception and have it pass all the way through

This now uses a forward cursor, which is different than an Iterator.