Refactor pqc_fetch to use a PrepareFun fun

This makes the pqc functions agnostic to details of the driver (so
could be ported to mysql if we choose to keep mysql support). It also
allows the query cache functionality to be tested without mocks.