OSDN Git Service

Use more proper formula to calculate the number of bigram entries.
authorMasaoFujii <masao.fujii@gmail.com>
Fri, 3 Apr 2015 04:51:23 +0000 (13:51 +0900)
committerMasaoFujii <masao.fujii@gmail.com>
Fri, 3 Apr 2015 04:52:03 +0000 (13:52 +0900)
commite17dd9edda61dbff84551ad0eb6d5d7d08fc9076
tree77e986198c134176efe13712cfedff022c03c2fa
parent34fe5b6a66a48382ba4882531e941d8b9c9f6f80
Use more proper formula to calculate the number of bigram entries.

Previously we used the formula that we just borrowed from pg_trgm code,
to calculate the number of bigram entries. Based on the result of that
calculation we allocated the memory to store the bigram entries.
That borrowed formula was not incorrect, but not precise. It caused us to
allocate too much memory than necessary, and which limited the maximum
allowed size of column indexed by pg_bigm to smaller number.

This commit makes the formula more proper, and increases the column
limitation size to about 102MB. Also this installs some checks that the input
string length is not so large as to cause overflow in the calculations of
palloc request sizes. The addition of these checks was inspired by
the pg_trgm related commit c3ccc9e.

This change is simple and useful to alleviate the column size limitation.
So back-patch to all supported versions.

Beena Emerson, reviewed by me.
bigm_op.c
html/pg_bigm-1-1.html
html/pg_bigm_en-1-1.html