The approach currently in this script is to process dumps line by line switching between cases when a new SQL statement is matched. For instance, we handle a CREATE TABLE statement until we see an INSERT statement. We make no attempt to determine the end of statements.
The issue here is things like functions have BEGIN/END blocks where INSERTS or CREATES can be defined.
We need to make an attempt to determine the end of statements so we get a better state machine.