Merge pull request #221 from nikbyte/master

Fix some PgSQL schema issues
(cherry picked from commit 671a5bb7af35833fbf1e634e8bd321417ef5aa6a)
Postgres schema regenerated.
Fixed bogus test on memory allocation.

(cherry picked from commit d9fe58e721a0e4c53841e91ba766df7bbce2cae5)