Hi Alex,
I believe there is a problem with your implementation of getTableDef(). In the previous code, this function has the side effect of modifying several global variables, for example $sql_drop_foreign_keys.
In the new implementation, if I'm not mistaken, you are getting these global variables but never setting their modified values in the global space for use by the calling script.
I'm not advocating that you should continue using globals in this case, but we need a way to pass back these modified values, for example by passing back an array of results.
Please coordinate with Thilina who is refactoring db_operations.php.