Refacture type casting of query params, to avoid doublicated code.

This also bundles memory allocation for query functions.
Merge branch 'column_type_mapping' of github.com:larskanis/ruby-pg into column_type_mapping

Conflicts:
	ext/pg_type_map_by_oid.c