Handle the case where extra_env=None (e.g. with MariaDB).
Check for expected BEGIN statements and don't filter them by DB.