@ -140,6 +140,7 @@
# include <sys/stat.h>
# include <sys/stat.h>
# include <unistd.h>
# include <unistd.h>
# include "access/genam.h"
# include "access/table.h"
# include "access/table.h"
# include "access/tableam.h"
# include "access/tableam.h"
# include "access/twophase.h"
# include "access/twophase.h"
@ -410,7 +411,7 @@ static void apply_handle_delete_internal(ApplyExecutionData *edata,
ResultRelInfo * relinfo ,
ResultRelInfo * relinfo ,
TupleTableSlot * remoteslot ,
TupleTableSlot * remoteslot ,
Oid localindexoid ) ;
Oid localindexoid ) ;
static bool FindReplTupleInLocalRel ( EState * estate , Relation localrel ,
static bool FindReplTupleInLocalRel ( ApplyExecutionData * edata , Relation localrel ,
LogicalRepRelation * remoterel ,
LogicalRepRelation * remoterel ,
Oid localidxoid ,
Oid localidxoid ,
TupleTableSlot * remoteslot ,
TupleTableSlot * remoteslot ,
@ -2663,7 +2664,7 @@ apply_handle_update_internal(ApplyExecutionData *edata,
EvalPlanQualInit ( & epqstate , estate , NULL , NIL , - 1 , NIL ) ;
EvalPlanQualInit ( & epqstate , estate , NULL , NIL , - 1 , NIL ) ;
ExecOpenIndices ( relinfo , false ) ;
ExecOpenIndices ( relinfo , false ) ;
found = FindReplTupleInLocalRel ( estate , localrel ,
found = FindReplTupleInLocalRel ( edata , localrel ,
& relmapentry - > remoterel ,
& relmapentry - > remoterel ,
localindexoid ,
localindexoid ,
remoteslot , & localslot ) ;
remoteslot , & localslot ) ;
@ -2816,7 +2817,7 @@ apply_handle_delete_internal(ApplyExecutionData *edata,
EvalPlanQualInit ( & epqstate , estate , NULL , NIL , - 1 , NIL ) ;
EvalPlanQualInit ( & epqstate , estate , NULL , NIL , - 1 , NIL ) ;
ExecOpenIndices ( relinfo , false ) ;
ExecOpenIndices ( relinfo , false ) ;
found = FindReplTupleInLocalRel ( estate , localrel , remoterel , localindexoid ,
found = FindReplTupleInLocalRel ( edata , localrel , remoterel , localindexoid ,
remoteslot , & localslot ) ;
remoteslot , & localslot ) ;
/* If found delete it. */
/* If found delete it. */
@ -2855,12 +2856,13 @@ apply_handle_delete_internal(ApplyExecutionData *edata,
* Local tuple , if found , is returned in ' * localslot ' .
* Local tuple , if found , is returned in ' * localslot ' .
*/
*/
static bool
static bool
FindReplTupleInLocalRel ( EState * estate , Relation localrel ,
FindReplTupleInLocalRel ( ApplyExecutionData * edata , Relation localrel ,
LogicalRepRelation * remoterel ,
LogicalRepRelation * remoterel ,
Oid localidxoid ,
Oid localidxoid ,
TupleTableSlot * remoteslot ,
TupleTableSlot * remoteslot ,
TupleTableSlot * * localslot )
TupleTableSlot * * localslot )
{
{
EState * estate = edata - > estate ;
bool found ;
bool found ;
/*
/*
@ -2875,9 +2877,21 @@ FindReplTupleInLocalRel(EState *estate, Relation localrel,
( remoterel - > replident = = REPLICA_IDENTITY_FULL ) ) ;
( remoterel - > replident = = REPLICA_IDENTITY_FULL ) ) ;
if ( OidIsValid ( localidxoid ) )
if ( OidIsValid ( localidxoid ) )
{
# ifdef USE_ASSERT_CHECKING
Relation idxrel = index_open ( localidxoid , AccessShareLock ) ;
/* Index must be PK, RI, or usable for REPLICA IDENTITY FULL tables */
Assert ( GetRelationIdentityOrPK ( idxrel ) = = localidxoid | |
IsIndexUsableForReplicaIdentityFull ( BuildIndexInfo ( idxrel ) ,
edata - > targetRel - > attrmap ) ) ;
index_close ( idxrel , AccessShareLock ) ;
# endif
found = RelationFindReplTupleByIndex ( localrel , localidxoid ,
found = RelationFindReplTupleByIndex ( localrel , localidxoid ,
LockTupleExclusive ,
LockTupleExclusive ,
remoteslot , * localslot ) ;
remoteslot , * localslot ) ;
}
else
else
found = RelationFindReplTupleSeq ( localrel , LockTupleExclusive ,
found = RelationFindReplTupleSeq ( localrel , LockTupleExclusive ,
remoteslot , * localslot ) ;
remoteslot , * localslot ) ;
@ -2995,7 +3009,7 @@ apply_handle_tuple_routing(ApplyExecutionData *edata,
bool found ;
bool found ;
/* Get the matching local tuple from the partition. */
/* Get the matching local tuple from the partition. */
found = FindReplTupleInLocalRel ( estate , partrel ,
found = FindReplTupleInLocalRel ( edata , partrel ,
& part_entry - > remoterel ,
& part_entry - > remoterel ,
part_entry - > localindexoid ,
part_entry - > localindexoid ,
remoteslot_part , & localslot ) ;
remoteslot_part , & localslot ) ;