So having studied the fe-exec.c sources, I came to this conclusion:
we may just ignore deleted tuple and it will be destroyed by
PQclear automatically, becuase PQclear deals with memory blocks.
int PQdeleteTuple(PGresult *src, int tup_num)
/* Invalid tup_num, must be < ntups */
if (tup_num < 0 || tup_num >= src->ntups)
for (i = tup_num; i < src->ntups - 1; i++)
src->tuples[i] = src->tuples[i + 1];
I also checked pqAddTuple, PQcopyResult and PQSetValue, they are OK with this
Am I correct with this?
PG> I'm some kind of PQdeleteTuple function will be very usefull in libpq.
PG> Because right now after deleting some record I need refetch result
PG> set, or mark tuple as deleted and this is headache for me.
PG> So I checked fe-exec.c sources and wrote this:
PG> int PQdeleteTuple(PGresult *src, int tup_num)
PG> if (!src)
PG> return NULL;
PG> int i,
PG> /* Invalid tup_num, must be < ntups */
PG> if (tup_num < 0 || tup_num >= src->ntups)
PG> return FALSE;
PG> for (i = tup_num; i < src->ntups - 1; i++)
PG> src->tuples[i] = src->tuples[i + 1];
PG> return TRUE;
PG> But I'm pretty sure, that "free(src->tuples[tup_num])" is bullshit!
PG> Because memory is allocated by pqResultAlloc, which in turn plays with
PG> memory blocks and so on...
PG> Can anyone help me in this?
PG> PS I'm not a C guru, so don't please kick me hard. :)
With best wishes,
In response to
pgsql-hackers by date
|Next:||From: Teodor Sigaev||Date: 2011-06-02 08:45:41|
|Subject: Re: Cube Index Size|
|Previous:||From: Pavel Stehule||Date: 2011-06-02 08:39:05|
|Subject: patch: enhanced get diagnostics statement 2|
pgsql-interfaces by date
|Next:||From: Miguel García||Date: 2011-06-02 13:07:46|
|Previous:||From: Pavel Golub||Date: 2011-06-02 08:28:26|
|Subject: Re: [HACKERS] PQdeleteTuple function in libpq|