diff --git a/.unreleased/pr_6113 b/.unreleased/pr_6113 new file mode 100644 index 00000000000..80ba723f5f5 --- /dev/null +++ b/.unreleased/pr_6113 @@ -0,0 +1,3 @@ +Fixes: #6113 Fix planner distributed table count + +Thanks: @symbx for reporting a crash when selecting from empty hypertables diff --git a/src/planner/planner.c b/src/planner/planner.c index 69d918515d0..fe0c1a26c8a 100644 --- a/src/planner/planner.c +++ b/src/planner/planner.c @@ -388,19 +388,18 @@ preprocess_query(Node *node, PreprocessQueryContext *context) query->rowMarks == NIL && rte->inh) rte_mark_for_expansion(rte); + if (hypertable_is_distributed(ht)) + { + context->num_distributed_tables++; + } + if (TS_HYPERTABLE_HAS_COMPRESSION_TABLE(ht)) { int compr_htid = ht->fd.compressed_hypertable_id; /* Also warm the cache with the compressed * companion hypertable */ - ht = ts_hypertable_cache_get_entry_by_id(hcache, compr_htid); - Assert(ht != NULL); - } - - if (hypertable_is_distributed(ht)) - { - context->num_distributed_tables++; + ts_hypertable_cache_get_entry_by_id(hcache, compr_htid); } } else