Rewrite of postgresql module to allow invocation by defined types

It now also support defining custom queries.

As a bonus, this rewrite is backward compatible (!)
Merge pull request #168 from txaj/postgresql-module-rewrite

Rewrite of postgresql module to allow invocation by defined types