Re: Why do we have MakeSingleTupleTableSlot instead of not using MakeTupleTableSlot?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: Zhihong Yu <zyu(at)yugabyte(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Why do we have MakeSingleTupleTableSlot instead of not using MakeTupleTableSlot?
Date: 2021-02-13 04:24:08
Message-ID: CALj2ACX2pwpn=G5OXsZ1JzVOb0CwcmxvjPP3-36vaD3nzOj0ow@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Feb 12, 2021 at 9:37 PM Zhihong Yu <zyu(at)yugabyte(dot)com> wrote:
> On Fri, Feb 12, 2021 at 5:44 AM Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com> wrote:
>>
>> Hi,
>>
>> I wonder, is there a specific reason that MakeTupleTableSlot is
>> wrapped up in MakeSingleTupleTableSlot without doing anything than
>> just returning the slot created by MakeTupleTableSlot? Do we really
>> need MakeSingleTupleTableSlot? Can't we just use MakeTupleTableSlot
>> directly? Am I missing something?
>>
>> I think we can avoid some unnecessary function call costs, for
>> instance when called 1000 times inside table_slot_create from
>> copyfrom.c or in some other places where MakeSingleTupleTableSlot is
>> called in a loop.
>>
>> If it's okay to remove MakeSingleTupleTableSlot and use
>> MakeTupleTableSlot instead, we might have to change in a lot of
>> places. If we don't want to change in those many files, we could
>> rename MakeTupleTableSlot to MakeSingleTupleTableSlot and change it in
>> only a few places.
>>
>> Thoughts?
>
> MakeSingleTupleTableSlot can be defined as a macro, calling MakeTupleTableSlot().

Right, we could as well have an inline function. My point was that why
do we need to wrap MakeTupleTableSlot inside MakeSingleTupleTableSlot
which just does nothing. As I said upthread, how about renaming
MakeTupleTableSlot to
MakeSingleTupleTableSlot which requires minimal changes? Patch
attached. Both make check and make check-world passes on it. Please
have a look.

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

Attachment Content-Type Size
v1-0001-Remove-unnecessary-wrapping-of-MakeTupleTableSlot.patch application/octet-stream 5.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2021-02-13 04:38:18 Re: 64-bit XIDs in deleted nbtree pages
Previous Message Zhihong Yu 2021-02-13 04:09:17 Re: Possible dereference null return (src/backend/replication/logical/reorderbuffer.c)