Re: TupleTableSlot abstraction

Поиск
Список
Период
Сортировка
От Amit Khandekar
Тема Re: TupleTableSlot abstraction
Дата
Msg-id CAJ3gD9fLTn0U5N5iNPkSKFCWLDKfFO7AKq7L8ozxZ2QcuJEuiw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: TupleTableSlot abstraction  (Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>)
Ответы Re: TupleTableSlot abstraction  (Andres Freund <andres@anarazel.de>)
Re: TupleTableSlot abstraction  (Andres Freund <andres@anarazel.de>)
Re: TupleTableSlot abstraction  (Andres Freund <andres@anarazel.de>)
Список pgsql-hackers
On 28 August 2018 at 22:43, Ashutosh Bapat
<ashutosh.bapat@enterprisedb.com> wrote:
> On Fri, Aug 24, 2018 at 6:46 AM, Andres Freund <andres@anarazel.de> wrote:
>
>>
>>> @@ -2883,7 +2885,7 @@ CopyFrom(CopyState cstate)
>>>                       if (slot == NULL)       /* "do nothing" */
>>>                               skip_tuple = true;
>>>                       else                            /* trigger might have changed tuple */
>>> -                             tuple = ExecMaterializeSlot(slot);
>>> +                             tuple = ExecFetchSlotTuple(slot, true);
>>>               }
>>
>> Could we do the Materialize vs Fetch vs Copy change separately?
>>
>
> Ok. I will do that.

Ashutosh offlist has shared with me
0006-Rethink-ExecMaterializeSlot-ExecFetchSlotTuple-in-th.patch which
contains the separated changes. The attached tar includes this
additional patch.


>>
>>> @@ -1590,7 +1590,8 @@ ExecHashTableInsert(HashJoinTable hashtable,
>>>                                       TupleTableSlot *slot,
>>>                                       uint32 hashvalue)
>>>  {
>>> -     MinimalTuple tuple = ExecFetchSlotMinimalTuple(slot);
>>> +     bool            shouldFree;
>>> +     MinimalTuple tuple = ExecFetchSlotMinimalTuple(slot, &shouldFree);
>>>       int                     bucketno;
>>>       int                     batchno;
>>>
>>> @@ -1664,6 +1665,9 @@ ExecHashTableInsert(HashJoinTable hashtable,
>>>                                                         hashvalue,
>>>                                                         &hashtable->innerBatchFile[batchno]);
>>>       }
>>> +
>>> +     if (shouldFree)
>>> +             heap_free_minimal_tuple(tuple);
>>>  }
>>
>> Hm, how about splitting these out?
>
> Split into a separate patch? It doesn't make sense to add this patch
> before 0006 since the slots in those patches can "own" a minimal
> tuple. Let's add a patch after 0006 i.e. tuple table abstraction
> patch. Will do.

Ashutosh offlist has shared with me
0009-Rethink-ExecFetchSlotMinimalTuple.patch which contains the above
separated changes. The attached tar includes this additional patch.


On 31 August 2018 at 20:50, Andres Freund <andres@anarazel.de> wrote:
>> On 31 August 2018 at 10:05, Amit Khandekar <amitdkhan.pg@gmail.com> wrote:
> Hi,
>
> On 2018-08-31 10:05:05 +0530, Amit Khandekar wrote:
>> On 28 August 2018 at 22:43, Ashutosh Bapat
>> >> I think I was wrong at saying that we should remove this. I think you
>> >> were right that it should become a callback...
>>
>> > We have replaced all slot_getsysattrs() with heap_getsysattr(). Do you
>> > want to reinstantiate those as well? If so, slot_getsysattr() becomes
>> > a wrapper around getsysattr() callback.
>
> Right.
>
>> One option is that the getsysattr() callback function returns false if
>> system attributes are not supported for that slot type. Other option
>> is that in the not-supported case, the function errors out, meaning
>> that the caller should be aware that the slot type is the one that
>> supports system attributes.
>
>> I had prepared changes for the first option, but Ashutosh Bapat
>> offlist made me realize that it's worth considering the 2nd option(
>> i.e. erroring out).
>
> I think we should error out.

I did these changes in the existing 0007-Restructure-TupleTableSlot...
patch. This patch now contains changes for the new getsysattr()
callback. I used the 2nd option : erroring out.

On 31 August 2018 at 10:05, Amit Khandekar <amitdkhan.pg@gmail.com> wrote:
> The only use case where slot_getsysattr() is called right now is
> execCurrentOf(), and it currently checks the bool return value of
> slot_getsysattr() and prints a user-friendly message if false is
> returned. Looking at the code (commit 8f5ac440430ab), it seems that we
> want to continue to have a user-friendly message for some unhandled
> cases like custom scans. So perhaps for now it's ok to go with the
> first option where getsysattr callback returns false for slot types
> that don't have system attributes.

I noticed that the issue for which commit 8f5ac440430ab was done was
that the tid was attempted to be fetched from a tuple that doesn't
support system attribute (virtual tuple), although the report
complained about a non-user-friendly message being given. So similarly
for custom scan, since it is not handled similarly, for now we can
continue to give an "unfriendly" message. The getsysattr() callbacks
will return something like "virtual tuple table slot does not have
system atttributes" if the slot does not support system attributes.


The attached v11 tar has the above set of changes.

Thanks
-Amit Khandekar

Вложения

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: [HACKERS] proposal: schema variables
Следующее
От: Pavan Deolasee
Дата:
Сообщение: Re: MERGE SQL statement for PG12