From ddfc9cb054abed4d08cc2709c9b2197dab96f449 Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Thu, 6 Feb 2014 11:28:13 -0500
Subject: [PATCH] Assert(IsTransactionState()) in RelationIdGetRelation().

Commit 42c80c696e9c8323841180029cc62741c21bd356 added an
Assert(IsTransactionState()) in SearchCatCache(), to catch
any code that thought it could do a catcache lookup outside
transactions.  Extend the same idea to relcache lookups.
---
 src/backend/utils/cache/relcache.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 2a46cfcff71..d47d2d37fcb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -1578,6 +1578,9 @@ RelationIdGetRelation(Oid relationId)
 {
 	Relation	rd;
 
+	/* Make sure we're in an xact, even if this ends up being a cache hit */
+	Assert(IsTransactionState());
+
 	/*
 	 * first try to find reldesc in the cache
 	 */
-- 
GitLab