Re: Bug in pg_autovacuum ? - Mailing list pgsql-bugs

From Tom Lane
Subject Re: Bug in pg_autovacuum ?
Date
Msg-id 1542.1074395916@sss.pgh.pa.us
Whole thread Raw
In response to Bug in pg_autovacuum ?  (Cott Lang <cott@internetstaff.com>)
List pgsql-bugs
Cott Lang <cott@internetstaff.com> writes:
> If the number of tuples is sufficiently high, pg reports 'reltuples'
> back in TABLE_STATS_QUERY in scientific notation instead of an integer.

Right, because that column is actually a float4.

> Changing from atoi() to atof() solves the problem completely.

> new_tbl->reltuples =
>   atof(PQgetvalue(res, row, PQfnumber(res, "reltuples")));

> new_tbl->relpages =
>   atof(PQgetvalue(res, row, PQfnumber(res, "relpages")));

I should think this would break in different ways once reltuples exceeds
INT_MAX.  A full fix would require changing new_tbl->reltuples to be
float or double, and coping with any downstream changes that implies.

Also, relpages *is* an integer, though it's best interpreted as an
unsigned one.  (Ditto for relid.)  Looks like this code is 0-for-3 on
getting the datatypes right :-(

            regards, tom lane

pgsql-bugs by date:

Previous
From: Cott Lang
Date:
Subject: Bug in pg_autovacuum ?
Next
From: "PostgreSQL Bugs List"
Date:
Subject: BUG #1054: inefficient compression of doco html files