replace pg_exec with pg_query

pg_exec is the old form of pg_query and is not supported by some performance profilers like New Relic.