pl/pgSQL, get diagnostics and big data - Mailing list pgsql-hackers

From Andreas 'ads' Scherbaum
Subject pl/pgSQL, get diagnostics and big data
Date
Msg-id 56AFBEF5.102@wars-nicht.de
Whole thread Raw
Responses Re: pl/pgSQL, get diagnostics and big data
Re: pl/pgSQL, get diagnostics and big data
List pgsql-hackers
Hello,

one of our customers approached us and complained, that GET DIAGNOSTICS
row_count returns invalid results if the number of rows is > 2^31. It's
a bit complicated to test for this case, so I set up a separate instance
with this patch, and inserted 2^32+x rows into a table. Internally,
row_count it's a signed integer, the resulting number is negative:

diagnostics=# select testfunc_pg((2^31 + 50000)::bigint);
  testfunc_pg
-------------
  -2147433648
(1 row)


Going over 2^32 wraps around:

diagnostics=# select testfunc_pg((2^32 + 50000)::bigint);
  testfunc_pg
-------------
        50000
(1 row)



Attached patch expands the row_count to 64 bit.

diagnostics=# select testfunc_pg((2^32 + 50000)::bigint);
  testfunc_pg
-------------
   4295017296
(1 row)


I hope, I covered all the places which count the result set.


Regards,

--
                Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors
Volunteer Regional Contact, Germany - PostgreSQL Project

Attachment

pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: PostgreSQL Audit Extension
Next
From: Fabien COELHO
Date:
Subject: Re: extend pgbench expressions with functions