referenced_uid_set.union({getattr(row,security_uid_field)forrowinreq("select distinct %s from catalog where %s is not NULL"%(security_uid_field,security_uid_field))})
referenced_uid_set.update([row[0]forrowinreq("select distinct %s from catalog where %s is not NULL"%(security_uid_field,security_uid_field),max_rows=0)[1]])
print(">> useless uids in roles_and_users table <<\n")
iflen(referenced_uid_set)>0:
forrowinreq("select * from roles_and_users where uid not in %s"+tuple(referenced_uid_set)):