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:51:23 +0000 (13:51 +0900)
commitf4b88f226babd1dfbeff9f1c152766d493833b04
tree77e986198c134176efe13712cfedff022c03c2fa
parent1e5085ff29b657291de6fd1da155e09237e226f3
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