fixed bug in postgres support when there were no rows in the table

Change-Id: I2b8225282a6a7990d4fd1c9cbd54de9a1b1dd31b