Fix for CI tests with old PostgreSQL

json type wasnt't available until PostgreSQL 9.2
Fix for num_rows on PostgreSQL 8.4

PostgreSQL 8.4 doesn't include number of selected rows in tag