Improved error message if type def cannot be found for given table id. Added regression test. Part of #2439.