Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax compressed hypertable schema change restrictions #7389

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't there already a function for this: ts_chunk_exists_with_compression? Or is it doing something else. Seems a bit unnecessary to build all chunks just to check for the occurrence of one.

{
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
Loading