Re: allocation limit for encoding conversion

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: allocation limit for encoding conversion
Дата
Msg-id 27990.1565991109@sss.pgh.pa.us
обсуждение исходный текст
Ответ на allocation limit for encoding conversion  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Ответы Re: allocation limit for encoding conversion  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> Somebody ran into issues when generating large XML output (upwards of
> 256 MB) and then sending via a connection with a different
> client_encoding.  This occurs because we pessimistically allocate 4x as
> much memory as the string needs, and we run into the 1GB palloc
> limitation.  ISTM we can do better now by using huge allocations, as per
> the preliminary attached patch (which probably needs an updated overflow
> check rather than have it removed altogether); but at least it is able
> to process this query, which it wasn't without the patch:

> select query_to_xml(
>     'select a, cash_words(a::text::money) from generate_series(0, 2000000) a',
>     true, false, '');

I fear that allowing pg_do_encoding_conversion to return strings longer
than 1GB is just going to create failure cases somewhere else.

However, it's certainly true that 4x growth is a pretty unlikely worst
case.  Maybe we could do something like

1. If string is short (say up to a few megabytes), continue to do it
like now.  This avoids adding overhead for typical cases.

2. Otherwise, run some lobotomized form of encoding conversion that
just computes the space required (as an int64, I guess) without saving
the result anywhere.

3. If space required > 1GB, fail.

4. Otherwise, allocate just the space required, and convert.

            regards, tom lane



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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: pgsql: doc: Add some images
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [Proposal] Table-level Transparent Data Encryption (TDE) and KeyManagement Service (KMS)