[DB-SIG] .rowcount issues with large affected row counts.

James Henstridge james at jamesh.id.au
Tue Jul 4 07:16:29 EDT 2017


On 3 July 2017 at 21:08, Daniele Varrazzo <daniele.varrazzo at gmail.com> wrote:
> Please open a bug to the psycopg bug tracker:
>
> https://github.com/psycopg/psycopg2/issues
>
> specifying your platform (win/linux/other, 32/64 bit). Please also add
> an idea of the number you are expecting to see (I think we should be
> able to parse 2*10^9 no problem, if not it's a bug). If possible
> compile psycopg in debug mode (see
> http://initd.org/psycopg/docs/install.html#creating-a-debug-build) and
> report the debug line is printed for a failing case (it should say
> "_read_rowcount: PQcmdTuples..." looking at the link James has kindly
> provided).
>
> Regardless of the report I'll look into parsing that value without
> using 'atol()' for next bugfix release.

At a minimum, using strtol() should let you detect cases where the
number can not be converted completely.  It might also be worth
switching to a "long long int" and strtoll(): this will be a bit
slower on 32-bit systems, but (a) they are getting less important as
time goes on, and (b) correct behaviour is more important.

James.


More information about the DB-SIG mailing list