Retry loop helper

For both stale statements (e.g. DDL invalidating a prepared statement) and rollback errors in general.

Mostly for DumpClient, which uses lots of prepared statements but had no handling of re-preparing them. Includes slight refactor of pulling out the inline strings and formatting consistently.