fixed getTablePermissions SQL