PQdeleteTuple function in libpq - Mailing list pgsql-interfaces

From Pavel Golub
Subject PQdeleteTuple function in libpq
Date
Msg-id 147534417.20110601184310@gf.microolap.com
Whole thread Raw
Responses Re: PQdeleteTuple function in libpq  (Pavel Golub <pavel@microolap.com>)
List pgsql-interfaces
Hello.

I'm some kind of PQdeleteTuple function will be very usefull in libpq.
Because right now after deleting some record I need refetch result
set, or mark tuple as deleted and this is headache for me.

So I checked fe-exec.c sources and wrote this:

int PQdeleteTuple(PGresult *src, int tup_num)
{       if (!src)               return NULL;
       int                     i,                               field;                                      /* Invalid
tup_num,must be < ntups */                         if (tup_num < 0 || tup_num >= src->ntups)               return
FALSE;
       free(src->tuples[tup_num]);              for (i = tup_num; i < src->ntups - 1; i++)       {
src->tuples[i]= src->tuples[i + 1];       }       src->ntups--;       return TRUE;
 
}

But I'm pretty sure, that "free(src->tuples[tup_num])" is bullshit!
Because memory is allocated by pqResultAlloc, which in turn plays with
memory blocks and so on...

Can anyone help me in this?

PS I'm not a C guru, so don't please kick me hard. :)

Thanks.


-- 
With best wishes,Pavel                          mailto:pavel@gf.microolap.com



pgsql-interfaces by date:

Previous
From: hatem gamal elzanaty
Date:
Subject: how to write cgi script that is hosted under apache and accessing postgresql
Next
From: Pavel Golub
Date:
Subject: Re: [HACKERS] PQdeleteTuple function in libpq