Re: BUG #16200: returned data from ESQL/C FETCH is tramplingoutside assigned memory for CHAR column

Поиск
Список
Период
Сортировка
От Michael Meskes
Тема Re: BUG #16200: returned data from ESQL/C FETCH is tramplingoutside assigned memory for CHAR column
Дата
Msg-id f4ed822c8819851534ced9e4a6efb621e23775d1.camel@postgresql.org
обсуждение исходный текст
Ответ на Re: BUG #16200: returned data from ESQL/C FETCH is trampling outsideassigned memory for CHAR column  (Matthias Apitz <guru@unixarea.de>)
Список pgsql-bugs
> I mean with ESQL/C the general term "Embedded SQL in C". Of course I
> do
> know that for PostgreSQL the precompiler is named "ecpg".

No worries, I was just making sure we do not talk about different
things as I have never seen anyone use this abbreviation before.

> Neither do I know if there is some written standard, but char strings

There is.

> IMHO
> should be NULL terminated. Our application expects in this example no
> more than 16 bytes and that's why we provide a host variable as the
> struct member of 17 bytes so the NULL fits into.
>
> I digged into the sources of the ecpglib and this small fix solved
> our problem:
> ...

Sure, this fixes your use case, but as I said, I'm not sure it's the
right thing to do for general use.

> > Could you please verify if the indicator is set accordingly?
>
> If I read the docs here
> https://www.postgresql.org/docs/11/ecpg-variables.html#ECPG-INDICATORS
> indicator vars are meant to show null values in the table and not the
> string truncation. Am I wrong? We do not use indicators at all, but
> catch the error condition -213.

Sorry, you're right of course. What I meant was the sqlca structure
which includes:

...
char            sqlwarn[8];
        /* Element 0: set to 'W' if at least one other is 'W'   */
        /* 1: if 'W' at least one character string              */
        /* value was truncated when it was                      */
        /* stored into a host variable.             */
...

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 #16203: So difficult to set an use postgres
Следующее
От: Tomas Vondra
Дата:
Сообщение: Re: BUG #16203: So difficult to set an use postgres