[PATCH] Add error handling to byteaout.

Поиск
Список
Период
Сортировка
От Andreas Seltenreich
Тема [PATCH] Add error handling to byteaout.
Дата
Msg-id 87a8wif9wz.fsf@oort.credativ.de
обсуждение исходный текст
Ответы Re: [PATCH] Add error handling to byteaout.
Список pgsql-hackers
Hi,

when dealing with bytea values that are below the 1GB limit, but too
large to be escaped, the error messages emitted are not very helpful for
users.  Especially if they appear in an unrelated context such as during
pg_dump.  I've attached a patch that adds ereport()ing that would have
prevented some confusion.

Example:

,----[ master ]
| ase=# select mkbytea(29);
| ERROR:  invalid memory alloc request size 1073741827
| ase=# set bytea_output to escape;
| ase=# select mkbytea(29);
| ERROR:  invalid memory alloc request size 18446744071562067969
`----

The scary one is due to an integer overflow the attached patch also
fixes.  I don't see any security implications though as it's only the
sign bit that is affected.

,----[ with patch applied ]
| ase=# set bytea_output to 'escape';
| ase=# select mkbytea(29);
| ERROR:  escaped bytea value would be too big
| DETAIL:  Value would require 2147483649 bytes.
| HINT:  Use a different bytea_output setting or binary methods such as COPY BINARY.
`----

regards,
Andreas

create function mkbytea(power int, part bytea default '\x00')      returns bytea as      $$select case when power>0
thenmkbytea(power-1,part||part) else part end;$$      language sql;
 


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: nested loop semijoin estimates
Следующее
От: Andres Freund
Дата:
Сообщение: Re: checkpointer continuous flushing