"Massimiliano Poletto" <max.poletto@gmail.com> writes:
>> If you call it exactly once, it'll say that exactly once. If you keep
>> calling it "millions of times", it'll keep saying that.
> OK. I wonder, though, why at some point it does in fact return 0.
Probably because you ran out of memory to create new PGresult structs.
regards, tom lane