Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation

Поиск
Список
Период
Сортировка
От Peter Geoghegan
Тема Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation
Дата
Msg-id CAH2-Wzk11wvwjhrbje4DDyXydy5pGACb4wNCHCXiuij0Y10h+Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Sat, Aug 13, 2022 at 5:30 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Attached is a quick draft fix.  Some notes:
>
> * I'm not really proposing the added Asserts for commit,
> though they helped provide confidence that I was on the
> right track.

It seems very unlikely that anybody will notice the added cycles in
debug builds. And while the risk of introducing unwanted side-effects
in assert-enabled builds is greater than zero, it might be worth it.

> * We need to look around and see if the same mistake appears
> in any other sortsupport code.

I just did -- I see no problems. The only other SortSupport code that
allocates a buffer that is associated its SortSupport state is used by
numeric. That is a fixed-sized buffer (it's dynamically allocated
because we only need it when abbreviated keys are used).

> * The bug could never have existed at all if these buffer
> resizings had been done with repalloc().  I get that the
> idea is to avoid copying data we don't care about, but
> this coding is still feeling like an antipattern.  I wonder
> if it'd be worth inventing a variant of repalloc that makes
> the chunk bigger without preserving its contents.

Or we could just use repalloc(). The vast majority of text sorts won't
need a buffer larger than the initial buffer size (TEXTBUFLEN/1024
bytes), so it seems like a fairly useless optimization.

I think that repalloc might even be mandatory. These buffers are used
as caches that allow us to avoid repeat strxfrm()/strcoll() calls,
which is quite a useful optimization. But we're not accounting for
that here -- we're not invalidating the cache. We wouldn't have to
bother with that if we just used repalloc().

-- 
Peter Geoghegan



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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #17584: SQL crashes PostgreSQL when using ICU collation