Assessing query privileges via safe and efficient permission composition