Re: Error in PQsetvalue

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Error in PQsetvalue
Дата
Msg-id BANLkTikL8a0qoXZM-5UkqgOe=HoOvif1KQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Error in PQsetvalue  (Andrew Chernow <ac@esilo.com>)
Ответы Re: Error in PQsetvalue  (Andrew Chernow <ac@esilo.com>)
Список pgsql-hackers
On Fri, Jun 3, 2011 at 3:06 PM, Andrew Chernow <ac@esilo.com> wrote:
> On 6/3/2011 3:03 PM, Pavel Golub wrote:
>>
>> Hello.
>>
>> Reproduced under Windows XP SP3 using Visual C++ 2008 and Delphi. If
>> PQsetvalue is called with second parameter equals to PQntuples then
>> memory corruption appears. But it should grow internal tuples array
>> and populate the last item with provided data. Please see the code:
>>
>>
>
> At first glance (have not tested this theory), looks like pqAddTuple()
> doesn't zero the newly allocated tuples slots like PQsetvalue() does.
> PQsetvalue is depending on the unassigned tuple table slots to be NULL to
> detect when a tuple must be allocated.  Around line 446 on fe-exec.c.  I
> never tested this case since libpqtypes never tried to call PQsetvalue on a
> PGresult created by the standard libpq library.
>
> The solution I see would be to zero the new table slots within pqAddTuple.
>  Any other ideas?

It might not be necessary to do that.  AIUI the tuple table slot guard
is there essentially to let setval know if it needs to allocate tuple
attributes, which always has to be done after a new tuple is created
after a set.  It should be enough to keep track of the 'allocation
tuple' as an int (which is incremented after attributes are allocated
for the new tuple).  so if tup# is same is allocation tuple, allocate
the atts and increment the number, otherwise just do a straight 'set'.Basically we are taking advantage of the fact
onlyone tuple can be 
allocated at a time, and it always has to be the next one after the
current set.

merlin


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Getting a bug tracker for the Postgres project
Следующее
От: Andrew Chernow
Дата:
Сообщение: Re: Error in PQsetvalue