[bug fix??] Fishy code in tts_cirtual_copyslot() - Mailing list pgsql-hackers

From Tsunakawa, Takayuki
Subject [bug fix??] Fishy code in tts_cirtual_copyslot()
Date
Msg-id 0A3221C70F24FB45833433255569204D1FD34C0E@G01JPEXMBYT05
Whole thread Raw
Responses Re: [bug fix??] Fishy code in tts_cirtual_copyslot()
List pgsql-hackers
Hello,

In the following code in execTuples.c, shouldn' srcdesc point to the source slot's tuple descriptor?  The attached fix
passesmake check.  What kind of failure could this cause?
 

BTW, I thought that in PostgreSQL coding convention, local variables should be defined at the top of blocks, but this
functionwrites "for (int natts;".  I didn't modify it because many other source files also write in that way.
 


--------------------------------------------------
static void
tts_virtual_copyslot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
{
    TupleDesc   srcdesc = dstslot->tts_tupleDescriptor;

    Assert(srcdesc->natts <= dstslot->tts_tupleDescriptor->natts);

    tts_virtual_clear(dstslot);

    slot_getallattrs(srcslot);

    for (int natt = 0; natt < srcdesc->natts; natt++)
    {
        dstslot->tts_values[natt] = srcslot->tts_values[natt];
        dstslot->tts_isnull[natt] = srcslot->tts_isnull[natt];
    }
--------------------------------------------------


Regards
Takayuki Tsunakawa


Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Leakproofness of texteq()/textne()
Next
From: Peter Geoghegan
Date:
Subject: Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.