On Thur, Jan 20, 2022 7:25 PM Amit Kapila <amit.kapil...@gmail.com> wrote: > > On Thu, Jan 20, 2022 at 6:42 AM houzj.f...@fujitsu.com > <houzj.f...@fujitsu.com> wrote: > > > > Attach the V68 patch set which addressed the above comments and changes. > > > > Few comments and suggestions: > ========================== > 1. > /* > + * For updates, if both the new tuple and old tuple are not null, then both > + * of them need to be checked against the row filter. > + */ > + tmp_new_slot = new_slot; > + slot_getallattrs(new_slot); > + slot_getallattrs(old_slot); > + > > Isn't it better to add assert like > Assert(map_changetype_pubaction[*action] == PUBACTION_UPDATE); before > the above code? I have tried to change this part of the code in the > attached top-up patch. > > 2. > + /* > + * For updates, if both the new tuple and old tuple are not null, then both > + * of them need to be checked against the row filter. > + */ > + tmp_new_slot = new_slot; > + slot_getallattrs(new_slot); > + slot_getallattrs(old_slot); > + > + /* > + * The new tuple might not have all the replica identity columns, in which > + * case it needs to be copied over from the old tuple. > + */ > + for (i = 0; i < desc->natts; i++) > + { > + Form_pg_attribute att = TupleDescAttr(desc, i); > + > + /* > + * if the column in the new tuple or old tuple is null, nothing to do > + */ > + if (tmp_new_slot->tts_isnull[i] || old_slot->tts_isnull[i]) > + continue; > + > + /* > + * Unchanged toasted replica identity columns are only detoasted in the > + * old tuple, copy this over to the new tuple. > + */ > + if (att->attlen == -1 && > + VARATT_IS_EXTERNAL_ONDISK(tmp_new_slot->tts_values[i]) && > + !VARATT_IS_EXTERNAL_ONDISK(old_slot->tts_values[i])) > + { > + if (tmp_new_slot == new_slot) > + { > + tmp_new_slot = MakeSingleTupleTableSlot(desc, &TTSOpsVirtual); > + ExecClearTuple(tmp_new_slot); > + ExecCopySlot(tmp_new_slot, new_slot); > + } > + > + tmp_new_slot->tts_values[i] = old_slot->tts_values[i]; > + tmp_new_slot->tts_isnull[i] = old_slot->tts_isnull[i]; > + } > + } > > > What is the need to assign new_slot to tmp_new_slot at the beginning > of this part of the code? Can't we do this when we found some > attribute that needs to be copied from the old tuple?
Thanks for the comments, Changed. > The other part which is not clear to me by looking at this code and > comments is how do we ensure that we cover all cases where the new > tuple doesn't have values? I will do some research about this and respond soon. Best regards, Hou zj