Skip to content

Commit

Permalink
Relax compressed chunk schema change restrictions
Browse files Browse the repository at this point in the history
Instead of disallowing certain operations when a hypertable has
compression enabled only block when there are also compressed chunks
present.
  • Loading branch information
svenklemm committed Oct 24, 2024
1 parent c243f1a commit 28d0380
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,33 @@ 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)
{
ListCell *lc;
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)
{
Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 28d0380

Please sign in to comment.