From 6ecd0b659126d4b9dad48d4712c20b5f521bd857 Mon Sep 17 00:00:00 2001
From: Onder Kalaci <onderkalaci@gmail.com>
Date: Fri, 10 Mar 2023 12:03:05 +0300
Subject: [PATCH v43 1/2] Skip dropped columns for tuples_equal

It looks like tuples_equal() behaves wrong when there are some dropped
columns. The dropped columns comes as NULL on the source tuple, but not
on the target tuple that resides in the subscriber.

With this commit, we skip dropped columns so that tuples_equal works
as expected.
---
 src/backend/executor/execReplication.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c
index c484f5c301..d8ea567f0d 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -242,6 +242,11 @@ tuples_equal(TupleTableSlot *slot1, TupleTableSlot *slot2,
 	{
 		Form_pg_attribute att;
 		TypeCacheEntry *typentry;
+		Form_pg_attribute attr = TupleDescAttr(slot1->tts_tupleDescriptor, attrnum);
+
+		/* dropped column is not visible, so ignore */
+		if (attr->attisdropped)
+			continue;
 
 		/*
 		 * If one value is NULL and other is not, then they are certainly not
-- 
2.34.1

