From 9691aa72e2a7fb146ac759e1f8a8b04962128cc0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 5 May 2019 13:10:07 -0400 Subject: Fix style violations in syscache lookups. Project style is to check the success of SearchSysCacheN and friends by applying HeapTupleIsValid to the result. A tiny minority of calls creatively did it differently. Bring them into line with the rest. This is just cosmetic, since HeapTupleIsValid is indeed just a null check at the moment ... but that may not be true forever, and in any case it puts a mental burden on readers who may wonder why these call sites are not like the rest. Back-patch to v11 just to keep the branches in sync. (The bulk of these errors seem to have originated in v11 or v12, though a few are old.) Per searching to see if anyplace else had made the same error repaired in 62148c352. --- src/backend/catalog/partition.c | 2 +- src/backend/catalog/pg_publication.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/backend/catalog') diff --git a/src/backend/catalog/partition.c b/src/backend/catalog/partition.c index 8ea7a62418..da98c54391 100644 --- a/src/backend/catalog/partition.c +++ b/src/backend/catalog/partition.c @@ -164,7 +164,7 @@ index_get_partition(Relation partition, Oid indexId) bool ispartition; tup = SearchSysCache1(RELOID, ObjectIdGetDatum(partIdx)); - if (!tup) + if (!HeapTupleIsValid(tup)) elog(ERROR, "cache lookup failed for relation %u", partIdx); classForm = (Form_pg_class) GETSTRUCT(tup); ispartition = classForm->relispartition; diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c index bbf2173936..bda7a3e92b 100644 --- a/src/backend/catalog/pg_publication.c +++ b/src/backend/catalog/pg_publication.c @@ -130,7 +130,7 @@ pg_relation_is_publishable(PG_FUNCTION_ARGS) bool result; tuple = SearchSysCache1(RELOID, ObjectIdGetDatum(relid)); - if (!tuple) + if (!HeapTupleIsValid(tuple)) PG_RETURN_NULL(); result = is_publishable_class(relid, (Form_pg_class) GETSTRUCT(tuple)); ReleaseSysCache(tuple); -- cgit v1.2.1