src/backend/replication/logical/reorderbuffer.c
bool
ResolveCminCmaxDuringDecoding(HTAB *tuplecid_data,
							  Snapshot snapshot,
							  HeapTuple htup, Buffer buffer,
							  CommandId *cmin, CommandId *cmax)
{
	ReorderBufferTupleCidKey key;
	ReorderBufferTupleCidEnt *ent;
	ForkNumber	forkno;
	BlockNumber blockno;
	bool		updated_mapping = false;

	/* be careful about padding */
	memset(&key, 0, sizeof(key));

	Assert(!BufferIsLocal(buffer));

	/*
	 * get relfilenode from the buffer, no convenient way to access it other
	 * than that.
	 */
	BufferGetTag(buffer, &key.relnode, &forkno, &blockno);

	/* tuples can only be in the main fork */
	Assert(forkno == MAIN_FORKNUM);
	Assert(blockno == ItemPointerGetBlockNumber(&htup->t_self));

	ItemPointerCopy(&htup->t_self,
					&key.tid);

restart:
	ent = (ReorderBufferTupleCidEnt *)
		hash_search(tuplecid_data,
					(void *) &key,
					HASH_FIND,
					NULL);

	/*
	 * failed to find a mapping, check whether the table was rewritten and
	 * apply mapping if so, but only do that once - there can be no new
	 * mappings while we are in here since we have to hold a lock on the
	 * relation.
	 */
	if (ent == NULL && !updated_mapping)
	{
		UpdateLogicalMappings(tuplecid_data, htup->t_tableOid, snapshot);
		/* now check but don't update for a mapping again */
		updated_mapping = true;
		goto restart;
	}
	else if (ent == NULL)
		return false;

	if (cmin)
		*cmin = ent->cmin;
	if (cmax)
		*cmax = ent->cmax;
	return true;
}
/*
 * Lookup cmin/cmax of a tuple, during logical decoding where we can't rely on
 * combocids.
 */
Lookup cmin/cmax of a tuple, during logical decoding where we can't rely on
combocids.
Lookup cmin / cmax of a tuple during logical decoding where we can ' t rely on combocids .
bool
ResolveCminCmaxDuringDecoding(HTAB *tuplecid_data,
							  Snapshot snapshot,
							  HeapTuple htup, Buffer buffer,
							  CommandId *cmin, CommandId *cmax)
{
	ReorderBufferTupleCidKey key;
	ReorderBufferTupleCidEnt *ent;
	ForkNumber	forkno;
	BlockNumber blockno;
	bool		updated_mapping = false;
	memset(&key, 0, sizeof(key));
	Assert(!BufferIsLocal(buffer));
	BufferGetTag(buffer, &key.relnode, &forkno, &blockno);
	Assert(forkno == MAIN_FORKNUM);
	Assert(blockno == ItemPointerGetBlockNumber(&htup->t_self));
	ItemPointerCopy(&htup->t_self,
					&key.tid);
restart:
	ent = (ReorderBufferTupleCidEnt *)
		hash_search(tuplecid_data,
					(void *) &key,
					HASH_FIND,
					NULL);
	if (ent == NULL && !updated_mapping)
	{
		UpdateLogicalMappings(tuplecid_data, htup->t_tableOid, snapshot);
		updated_mapping = true;
		goto restart;
	}
	else if (ent == NULL)
		return false;
	if (cmin)
		*cmin = ent->cmin;
	if (cmax)
		*cmax = ent->cmax;
	return true;
}
bool ResolveCminCmaxDuringDecoding ( HTAB * tuplecid_data , Snapshot snapshot , HeapTuple htup , Buffer buffer , CommandId * cmin , CommandId * cmax ) { ReorderBufferTupleCidKey key ; ReorderBufferTupleCidEnt * ent ; ForkNumber forkno ; BlockNumber blockno ; bool updated_mapping = false ; memset ( & key , 0 , sizeof ( key ) ) ; Assert ( ! BufferIsLocal ( buffer ) ) ; BufferGetTag ( buffer , & key . relnode , & forkno , & blockno ) ; Assert ( forkno == MAIN_FORKNUM ) ; Assert ( blockno == ItemPointerGetBlockNumber ( & htup -> t_self ) ) ; ItemPointerCopy ( & htup -> t_self , & key . tid ) ; restart : ent = ( ReorderBufferTupleCidEnt * ) hash_search ( tuplecid_data , ( void * ) & key , HASH_FIND , NULL ) ; if ( ent == NULL && ! updated_mapping ) { UpdateLogicalMappings ( tuplecid_data , htup -> t_tableOid , snapshot ) ; updated_mapping = true ; goto restart ; } else if ( ent == NULL ) return false ; if ( cmin ) * cmin = ent -> cmin ; if ( cmax ) * cmax = ent -> cmax ; return true ; }
Lookup cmin/cmax of a tuple, during logical decoding where we can't rely on
 combocids.
Lookup cmin / cmax of a tuple during logical decoding where we can ' t rely on combocids .
/* be careful about padding */ /*
	 * get relfilenode from the buffer, no convenient way to access it other
	 * than that.
	 */ /* tuples can only be in the main fork */ /*
	 * failed to find a mapping, check whether the table was rewritten and
	 * apply mapping if so, but only do that once - there can be no new
	 * mappings while we are in here since we have to hold a lock on the
	 * relation.
	 */ /* now check but don't update for a mapping again */