cleanup

introduce safe_strlen(), use open_grant_tables(),
use DEFAULT_ROLE_COLUMN_IDX instead of 44 and 45.