Revert "Simplify queryPathInfo query"

refs stores the ids of the relevant paths, not the full path.

This reverts commit 585280f08636c5195b291fcc75f478920f76e229.
Fix queryReferrers query

refs stores the ids of the relevant paths, not the full path