Re: BUG #8821: pg_trgm segfault with Turkish locale database

From: Ufuk Kayserilioglu <ufuk(at)paralaus(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #8821: pg_trgm segfault with Turkish locale database
Date: 2014-01-13 16:17:13
Message-ID: etPan.52d41189.74de0ee3.c82f@Ufuk-MBA-2.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Tom,

Thanks for the quick response. Just a quick followup note though; running:

SELECT show_trgm(maker) FROM car_makers;

behaves properly, but trying to make a similarity comparison triggers the segfault (at least in my case). That's why I suspect there may be 2 related bugs, one related trigram generation and, maybe, one related to trigram comparison. Hope this info will help you as well.

Regards,

--
Ufuk Kayserilioglu

From: Tom Lane Tom Lane
Reply: Tom Lane tgl(at)sss(dot)pgh(dot)pa(dot)us
Date: 13 January 2014 at 18:09:46
To: ufuk(at)paralaus(dot)com ufuk(at)paralaus(dot)com
Subject:  Re: [BUGS] BUG #8821: pg_trgm segfault with Turkish locale database
ufuk(at)paralaus(dot)com writes:
> Given a database with encoding UTF-8, locale tr_TR.UTF-8, 'pg_trgm'
> extension enabled, and the following setup:

> CREATE TABLE car_makers (maker TEXT);
> INSERT INTO car_makers VALUES ('AUDI'), ('MINI');

> Run any one of the following commands:

> - SELECT maker <-> 'MAZDA' FROM car_makers;
> - SELECT similarity(maker, 'MAZDA') FROM car_makers;
> - SELECT show_trgm('III');

> As a result, it seems there is a problem with trigrams generation and/or
> comparison when the Turkish locale is being used.

It looks like generate_trgm() is not considering the possibility that
case-folding will make the string physically longer, so you get a buffer
overrun when any of these I-containing strings are converted to trigrams.
Will fix, thanks for the report!

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Maciek Sakrejda 2014-01-13 18:12:07 BUG #8728: Toast table much larger on replica
Previous Message Tom Lane 2014-01-13 16:09:45 Re: BUG #8821: pg_trgm segfault with Turkish locale database