I haven't read the complete patch. But, I have noticed that many places you changed the variable declaration from c to c++ style (i.e moved the declaration in the for loop). IMHO, generally in PG, we don't follow this convention. Is there any specific reason to do this?
+1.
The patch does not apply on master, needs rebase.
Also, I got some whitespace errors.
I think you can also refactor the function tryExecuteStatement(), and
call your newly added function executeStatementExpect() by passing