Fix failures with older psycopg2 versions