Make callback to pool.query optional

closes #585