statement handler to rewrite the sql