Server: escape variables in SQL query (fixes #123)
Server: slight optimization on row fetch

No need to fetch all matching rows in memory if we keep only the first
one (hence the former `current`). This patch just fetches the first row
and discard all others.