[SQL] Add type checking debugging functions

Adds some functions that were very useful when trying to track down the bug from #2656.