In the Snowball dictionary, don't try to stem excessively-long words.
authorTom Lane <[email protected]>
Wed, 31 Aug 2022 14:42:05 +0000 (10:42 -0400)
committerTom Lane <[email protected]>
Wed, 31 Aug 2022 14:42:05 +0000 (10:42 -0400)
commit61f6e5c2360382be99846be904af33e3406c938a
treeb1fbe53c5382914345fc6519afca32bccfc87ff6
parentfe9d009e3e945945e1e3bb0f65514217fc8566e5
In the Snowball dictionary, don't try to stem excessively-long words.

If the input word exceeds 1000 bytes, don't pass it to the stemmer;
just return it as-is after case folding.  Such an input is surely
not a word in any human language, so whatever the stemmer might
do to it would be pretty dubious in the first place.  Adding this
restriction protects us against a known recursion-to-stack-overflow
problem in the Turkish stemmer, and it seems like good insurance
against any other safety or performance issues that may exist in
the Snowball stemmers.  (I note, for example, that they contain no
CHECK_FOR_INTERRUPTS calls, so we really don't want them running
for a long time.)  The threshold of 1000 bytes is arbitrary.

An alternative definition could have been to treat such words as
stopwords, but that seems like a bigger break from the old behavior.

Per report from Egor Chindyaskin and Alexander Lakhin.
Thanks to Olly Betts for the recommendation to fix it this way.

Discussion: https://postgr.es/m/1661334672.728714027@f473.i.mail.ru
src/backend/snowball/dict_snowball.c