From 5a1d570ac327702fea19ed18198efeb02632a2f3 Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horiguchi.kyotaro@lab.ntt.co.jp>
Date: Tue, 26 Jul 2016 11:02:48 +0900
Subject: [PATCH] Split equalTupleDescs into two functions.

equalTupleDescs intends to the two given tuple descriptors are
compatible on generating a tuple. Comaprison on constraints are
required to invalidate cache but it is a separate matter. So split it
into two new functions equalTupleDescs and equalTupleConstraints.
---
 src/backend/access/common/tupdesc.c | 14 ++++++++++++++
 src/include/access/tupdesc.h        |  1 +
 2 files changed, 15 insertions(+)

diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index b56d0e3..1e42c87 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -411,6 +411,19 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 		/* attacl, attoptions and attfdwoptions are not even present... */
 	}
 
+	return true;
+}
+
+/*
+ * Compare constraints between two TupleDesc structures
+ */
+bool
+equalTupleConstraints(TupleDesc tupdesc1, TupleDesc tupdesc2)
+{
+	int			i,
+				j,
+				n;
+
 	if (tupdesc1->constr != NULL)
 	{
 		TupleConstr *constr1 = tupdesc1->constr;
@@ -470,6 +483,7 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
 	}
 	else if (tupdesc2->constr != NULL)
 		return false;
+
 	return true;
 }
 
diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h
index de18f74..58fa466 100644
--- a/src/include/access/tupdesc.h
+++ b/src/include/access/tupdesc.h
@@ -111,6 +111,7 @@ extern void DecrTupleDescRefCount(TupleDesc tupdesc);
 	} while (0)
 
 extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
+extern bool equalTupleConstraints(TupleDesc tupdesc1, TupleDesc tupdesc2);
 
 extern void TupleDescInitEntry(TupleDesc desc,
 				   AttrNumber attributeNumber,
-- 
1.8.3.1

