Re: Error in PQsetvalue

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: Error in PQsetvalue
Дата
Msg-id BANLkTikdj53urvQV1Y-UqSdf96SoRunyqw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Error in PQsetvalue  (Andrew Chernow <ac@esilo.com>)
Ответы Re: Error in PQsetvalue
Список pgsql-hackers
On Fri, Jun 3, 2011 at 3:38 PM, Andrew Chernow <ac@esilo.com> wrote:

> Eeekks.  Found an additional bug.  PQsetvalue only allocates the actual
> tuple if the provided tup_num equals the number of tuples (append) and that
> slot is NULL.  This is wrong.  The original idea behind PQsetvalue was you
> can add tuples in any order and overwrite existing ones.

That was by design -- you are only supposed to be able to add a tuple
if you pass in exactly the insertion position (which is the same as
PQntuples()).  If you pass less than that, you will overwrite the
value at that position.  If you pass greater, you should get an error.This is also how the function is documented.
That'swhy you don't 
have to zero out the tuple slots at all -- the insertion position is
always known and you just need to make sure the tuple atts are not
allocated more than one time per inserted tuple.  Meaning, PQsetvalue
needs to work more like pqAddTuple (and the insertion code should
probably be abstracted).

merlin


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

Предыдущее
От: Alexander Shulgin
Дата:
Сообщение: Postmaster holding unlinked files for pg_largeobject table
Следующее
От: "Kevin Grittner"
Дата:
Сообщение: Re: SIREAD lock versus ACCESS EXCLUSIVE lock