Make pkgdb iterators more universal.

Pkgdb iterators may now be either cycled, which cycle over some sql
statement forever (may be used in combination with it->finished to
make several cycles), or they can be iterated only once (old behaviour
but now it is guaranteed that iterator will go through sqlite statement
only once). PKGDB_IT_FLAG_AUTO may be used to destroy iterator
automatically after the first iteration, this flag *cannot* be combined
with another flags, since caller must ensure that he never call
pkgdb_it_next one more time with destroyed iterator.