Fixed bug and added regression tests
Merge branch 'rollups_branch' of https://github.com/davidfetter/postgresql_projects into rollups_branch