Re: [BUG][PATCH] ecpg crash with bytea type and cursors

Поиск
Список
Период
Сортировка
От Michael Meskes
Тема Re: [BUG][PATCH] ecpg crash with bytea type and cursors
Дата
Msg-id 1451a00a0706d2f25fbcb580f6aef1e29c5b80a9.camel@postgresql.org
обсуждение исходный текст
Ответ на [BUG][PATCH] ecpg crash with bytea type and cursors  (Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
Ответы Re: [BUG][PATCH] ecpg crash with bytea type and cursors  (Jehan-Guillaume de Rorthais <jgdr@dalibo.com>)
Re: [BUG][PATCH] ecpg crash with bytea type and cursors  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
Hi,

On Tue, 2020-06-30 at 15:30 +0200, Jehan-Guillaume de Rorthais wrote:
> ...
> According to documentation and source, the bytea type is supposed to
> be handled
> as the varchar type. However, the original patch 050710b3696 miss to
> add to
> adjust_outofscope_cursor_vars() how to handle bytea type as variable.
> Because of
> this, bytea type was considered as an array of value, leading to the
> crash
> because type->u.element was all NULL. The patch adjust existing code
> to
> considers bytea in the same way varchar is handled. See in attachment
> patch
> v1-0002-Fix-ecpg-crash-with-bytea-and-cursor-variables.patch

Thanks for finding and fixing this. Patch committed.

> But there's something else the patch does not address and that might
> need to be
> adjusted. Existing tests were OK because they don't use cursors AND
> bytea vars
> are declared using a macro to hold their size. Eg.:
> 
>   bytea send_buf[2][DATA_SIZE]; # ok
>   bytea send_buf[2][512]; # crash !
> 
> This is because of this test in adjust_outofscope_cursor_vars()
> (before the
> proposed patch):
> 
>     else if ((ptr->variable->type->type != ECPGt_varchar
>               && ptr->variable->type->type != ECPGt_char
>               && ptr->variable->type->type != ECPGt_unsigned_char
>               && ptr->variable->type->type != ECPGt_string)
>              && atoi(ptr->variable->type->size) > 1)
> 
> This test match and related code crash when the size is given as
> number because
> atoi(size) > 1. When using a macro to hold the size, this test
> doesn't
> match and the fallback else{} code doesn't crash, but it doesn't
> build the same
> variable neither (see indirection before ECPGget_var). I'm not sure
> how
> important it is for bytea/varchar type though. I don't know how to
> build a test
> case producing ECPGget_var for them.

I try to find some time to look into this.

Thanks again,

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! SF 49ers! Use Debian GNU/Linux, PostgreSQL




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

Предыдущее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16519: SET SESSION ROLE in plpgsql requires string literal.
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: BUG #16519: SET SESSION ROLE in plpgsql requires string literal.