pgsql: Reduce number of bytes examined by convert_one_string_to_scalar(

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Reduce number of bytes examined by convert_one_string_to_scalar(
Дата
Msg-id E1ZTakC-0007Hg-P7@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Reduce number of bytes examined by convert_one_string_to_scalar().

Previously, convert_one_string_to_scalar() would examine up to 20 bytes of
the input string, producing a scalar conversion with theoretical precision
far greater than is of any possible use considering the other limitations
on the accuracy of the resulting selectivity estimate.  (I think this
choice might pre-date the caller-level logic that strips any common prefix
of the strings; before that, there could have been value in scanning the
strings far enough to use all the precision available in a double.)

Aside from wasting cycles to little purpose, this choice meant that the
"denom" variable could grow to as much as 256^21 = 3.74e50, which could
overflow in some non-IEEE float arithmetics.  While we don't really support
any machines with non-IEEE arithmetic anymore, this still seems like quite
an unnecessary platform dependency.  Limit the scan to 12 bytes instead,
thus limiting "denom" to 256^13 = 2.03e31, a value more likely to be
computable everywhere.

Per testing by Greg Stark, which showed overflow failures in our standard
regression tests on VAX.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/aad663a0b4af785d0b245bbded27537f23932839

Modified Files
--------------
src/backend/utils/adt/selfuncs.c |   12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Andres Freund
Дата:
Сообщение: Re: pgsql: Avoid use of float arithmetic in bipartite_match.c.
Следующее
От: Tom Lane
Дата:
Сообщение: pgsql: Tweak wording of syntax error messages about bad CONTINUE/EXIT s