This is not privilege separation/sandboxing. Separate virtual machine for an agent with limited credentials is reasonably safe approach
WHERE (name LIKE :name OR :name IS NULL)
AND (city = :city OR :city IS NULL)
AND ...
By no means it is perfect, but can save you from writing many different queries for different filters while being easy to optimize by db (:name and :city are known before query execution).