diff --git a/tsl/src/hypercore/hypercore_handler.c b/tsl/src/hypercore/hypercore_handler.c index 14a29432cea..7a5bdf02638 100644 --- a/tsl/src/hypercore/hypercore_handler.c +++ b/tsl/src/hypercore/hypercore_handler.c @@ -279,14 +279,19 @@ lazy_build_hypercore_info_cache(Relation rel, bool create_chunk_constraints, HypercoreInfo * RelationGetHypercoreInfo(Relation rel) { - if (NULL == rel->rd_amcache) - rel->rd_amcache = lazy_build_hypercore_info_cache(rel, - true /* create constraints */, - NULL /* compressed rel created */); + HypercoreInfo *hinfo = (HypercoreInfo *) rel->rd_amcache; - Assert(rel->rd_amcache && OidIsValid(((HypercoreInfo *) rel->rd_amcache)->compressed_relid)); + if (NULL == hinfo) + { + hinfo = lazy_build_hypercore_info_cache(rel, + true /* create constraints */, + NULL /* compressed rel created */); + rel->rd_amcache = hinfo; + } + + Assert(hinfo && OidIsValid(hinfo->compressed_relid)); - return rel->rd_amcache; + return hinfo; } static void