From 28d0380c50b65712a500d9771a3ec7a74dbb28e0 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Thu, 24 Oct 2024 14:34:42 +0200 Subject: [PATCH] Relax compressed chunk schema change restrictions Instead of disallowing certain operations when a hypertable has compression enabled only block when there are also compressed chunks present. --- src/process_utility.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/process_utility.c b/src/process_utility.c index 925a7e2274e..281d0c177ea 100644 --- a/src/process_utility.c +++ b/src/process_utility.c @@ -239,6 +239,23 @@ check_continuous_agg_alter_table_allowed(Hypertable *ht, AlterTableStmt *stmt) } } +static bool +hypertable_has_compressed_chunks(Hypertable *ht) +{ + List *chunks = ts_chunk_get_by_hypertable_id(ht->fd.id); + ListCell *lc; + + foreach (lc, chunks) + { + Chunk *chunk = lfirst(lc); + + if (ts_chunk_is_compressed(chunk)) + return true; + } + + return false; +} + static void check_alter_table_allowed_on_ht_with_compression(Hypertable *ht, AlterTableStmt *stmt) { @@ -246,6 +263,9 @@ check_alter_table_allowed_on_ht_with_compression(Hypertable *ht, AlterTableStmt if (!TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht)) return; + if (!hypertable_has_compressed_chunks(ht)) + return; + /* only allow if all commands are allowed */ foreach (lc, stmt->cmds) { @@ -295,8 +315,8 @@ check_alter_table_allowed_on_ht_with_compression(Hypertable *ht, AlterTableStmt default: ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("operation not supported on hypertables that have compression " - "enabled"))); + errmsg("operation not supported on hypertables that have compressed " + "chunks"))); break; } }