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

Save compression metadata settings on access node #2662

Merged
merged 1 commit into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions sql/pre_install/tables.sql
Expand Up @@ -37,8 +37,10 @@
-- chunks.
-- The unique constraint is table_name +schema_name. The ordering is
-- important as we want index access when we filter by table_name
CREATE SEQUENCE IF NOT EXISTS _timescaledb_catalog.hypertable_id_seq MINVALUE 1;

CREATE TABLE IF NOT EXISTS _timescaledb_catalog.hypertable (
id serial PRIMARY KEY,
id INTEGER PRIMARY KEY DEFAULT nextval('_timescaledb_catalog.hypertable_id_seq'),
schema_name name NOT NULL CHECK (schema_name != '_timescaledb_catalog'),
table_name name NOT NULL,
associated_schema_name name NOT NULL,
Expand All @@ -47,19 +49,20 @@ CREATE TABLE IF NOT EXISTS _timescaledb_catalog.hypertable (
chunk_sizing_func_schema name NOT NULL,
chunk_sizing_func_name name NOT NULL,
chunk_target_size bigint NOT NULL CHECK (chunk_target_size >= 0), -- size in bytes
compressed boolean NOT NULL DEFAULT FALSE,
compression_state smallint NOT NULL DEFAULT 0,
erimatnor marked this conversation as resolved.
Show resolved Hide resolved
compressed_hypertable_id integer REFERENCES _timescaledb_catalog.hypertable (id),
replication_factor smallint NULL CHECK (replication_factor > 0),
UNIQUE (associated_schema_name, associated_table_prefix),
CONSTRAINT hypertable_table_name_schema_name_key UNIQUE (table_name, schema_name),
CONSTRAINT hypertable_dim_compress_check CHECK (num_dimensions > 0 OR compressed = TRUE),
CONSTRAINT hypertable_compress_check CHECK (compressed = FALSE OR (compressed = TRUE AND compressed_hypertable_id IS NULL))
----internal compressed hypertables have compression state = 2
CONSTRAINT hypertable_dim_compress_check CHECK (num_dimensions > 0 OR compression_state = 2),
CONSTRAINT hypertable_compress_check CHECK ( (compression_state = 0 OR compression_state = 1 ) OR (compression_state = 2 AND compressed_hypertable_id IS NULL))
);
ALTER SEQUENCE _timescaledb_catalog.hypertable_id_seq OWNED BY _timescaledb_catalog.hypertable.id;
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.hypertable_id_seq', '');

SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.hypertable', '');

SELECT pg_catalog.pg_extension_config_dump(pg_get_serial_sequence('_timescaledb_catalog.hypertable', 'id'), '');

CREATE TABLE IF NOT EXISTS _timescaledb_catalog.hypertable_data_node (
hypertable_id integer NOT NULL REFERENCES _timescaledb_catalog.hypertable (id),
node_hypertable_id integer NULL,
Expand Down
122 changes: 122 additions & 0 deletions sql/updates/latest-dev.sql
Expand Up @@ -2,3 +2,125 @@ DROP VIEW IF EXISTS timescaledb_information.continuous_aggregates;
DROP VIEW IF EXISTS timescaledb_information.job_stats;
DROP FUNCTION IF EXISTS _timescaledb_internal.get_git_commit;

-- Begin Modify hypertable table
-- we make a copy of the data, remove dependencies, drop the table
DROP VIEW IF EXISTS timescaledb_information.hypertables;
DROP VIEW IF EXISTS timescaledb_information.chunks;
DROP VIEW IF EXISTS timescaledb_information.dimensions;
DROP VIEW IF EXISTS timescaledb_information.jobs;
DROP VIEW IF EXISTS timescaledb_information.compression_settings;
DROP VIEW IF EXISTS _timescaledb_internal.compressed_chunk_stats;
DROP VIEW IF EXISTS _timescaledb_internal.hypertable_chunk_local_size;
DROP FUNCTION IF EXISTS _timescaledb_internal.hypertable_from_main_table;

CREATE TABLE _timescaledb_catalog.hypertable_tmp
AS SELECT * from _timescaledb_catalog.hypertable;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
AS SELECT * from _timescaledb_catalog.hypertable;
AS SELECT * FROM _timescaledb_catalog.hypertable;


--drop foreign keys on hypertable
ALTER TABLE _timescaledb_catalog.hypertable DROP CONSTRAINT hypertable_compressed_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.hypertable_data_node DROP CONSTRAINT hypertable_data_node_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.tablespace DROP CONSTRAINT tablespace_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.dimension DROP CONSTRAINT dimension_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.chunk DROP CONSTRAINT chunk_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.chunk_index DROP CONSTRAINT chunk_index_hypertable_id_fkey ;
ALTER TABLE _timescaledb_config.bgw_job DROP CONSTRAINT bgw_job_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.continuous_agg DROP CONSTRAINT continuous_agg_mat_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.continuous_agg DROP CONSTRAINT continuous_agg_raw_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.continuous_aggs_invalidation_threshold DROP CONSTRAINT continuous_aggs_invalidation_threshold_hypertable_id_fkey ;
ALTER TABLE _timescaledb_catalog.hypertable_compression DROP CONSTRAINT hypertable_compression_hypertable_id_fkey ;


CREATE TABLE tmp_hypertable_seq_value AS
SELECT last_value, is_called FROM _timescaledb_catalog.hypertable_id_seq;
ALTER EXTENSION timescaledb DROP TABLE _timescaledb_catalog.hypertable;
ALTER EXTENSION timescaledb DROP SEQUENCE _timescaledb_catalog.hypertable_id_seq;
DROP TABLE _timescaledb_catalog.hypertable;

CREATE SEQUENCE IF NOT EXISTS _timescaledb_catalog.hypertable_id_seq MINVALUE 1;

-- now create table without self referential foreign key
CREATE TABLE IF NOT EXISTS _timescaledb_catalog.hypertable(
id INTEGER PRIMARY KEY DEFAULT nextval('_timescaledb_catalog.hypertable_id_seq'),
schema_name name NOT NULL CHECK (schema_name != '_timescaledb_catalog'),
table_name name NOT NULL,
associated_schema_name name NOT NULL,
associated_table_prefix name NOT NULL,
num_dimensions smallint NOT NULL,
chunk_sizing_func_schema name NOT NULL,
chunk_sizing_func_name name NOT NULL,
chunk_target_size bigint NOT NULL CHECK (chunk_target_size >= 0), -- size in bytes
compression_state smallint NOT NULL DEFAULT 0,
compressed_hypertable_id integer ,
replication_factor smallint NULL CHECK (replication_factor > 0),
UNIQUE (associated_schema_name, associated_table_prefix),
CONSTRAINT hypertable_table_name_schema_name_key UNIQUE (table_name, schema_name),
----internal compressed hypertables have compression state = 2
CONSTRAINT hypertable_dim_compress_check CHECK (num_dimensions > 0 OR compression_state = 2),
CONSTRAINT hypertable_compress_check CHECK ( (compression_state = 0 OR compression_state = 1 ) OR (compression_state = 2 AND compressed_hypertable_id IS NULL))
);
ALTER SEQUENCE _timescaledb_catalog.hypertable_id_seq OWNED BY _timescaledb_catalog.hypertable.id;
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.hypertable_id_seq', '');
SELECT setval('_timescaledb_catalog.hypertable_id_seq', last_value, is_called) FROM tmp_hypertable_seq_value;

INSERT INTO _timescaledb_catalog.hypertable
( id, schema_name, table_name, associated_schema_name, associated_table_prefix,
num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name,
chunk_target_size, compression_state, compressed_hypertable_id,
replication_factor)
SELECT id, schema_name, table_name, associated_schema_name, associated_table_prefix,
num_dimensions, chunk_sizing_func_schema, chunk_sizing_func_name,
chunk_target_size,
CASE WHEN compressed is FALSE AND compressed_hypertable_id IS NOT NULL THEN 1
WHEN compressed is TRUE THEN 2
ELSE 0
END,
compressed_hypertable_id,
replication_factor
FROM _timescaledb_catalog.hypertable_tmp;

-- add self referential foreign key
ALTER TABLE _timescaledb_catalog.hypertable ADD CONSTRAINT hypertable_compressed_hypertable_id_fkey FOREIGN KEY ( compressed_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id );
SELECT pg_catalog.pg_extension_config_dump('_timescaledb_catalog.hypertable', '');
--cleanup
DROP TABLE _timescaledb_catalog.hypertable_tmp;
DROP TABLE tmp_hypertable_seq_value;

-- add all the other foreign keys
ALTER TABLE _timescaledb_catalog.hypertable_data_node
ADD CONSTRAINT hypertable_data_node_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.tablespace ADD CONSTRAINT tablespace_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.dimension ADD CONSTRAINT dimension_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.chunk ADD CONSTRAINT chunk_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id );
ALTER TABLE _timescaledb_catalog.chunk_index ADD CONSTRAINT chunk_index_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_config.bgw_job ADD CONSTRAINT bgw_job_hypertable_id_fkey
FOREIGN KEY ( hypertable_id ) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_mat_hypertable_id_fkey FOREIGN KEY ( mat_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_agg ADD CONSTRAINT
continuous_agg_raw_hypertable_id_fkey FOREIGN KEY ( raw_hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.continuous_aggs_invalidation_threshold
ADD CONSTRAINT continuous_aggs_invalidation_threshold_hypertable_id_fkey
FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;
ALTER TABLE _timescaledb_catalog.hypertable_compression ADD CONSTRAINT
hypertable_compression_hypertable_id_fkey FOREIGN KEY ( hypertable_id )
REFERENCES _timescaledb_catalog.hypertable( id )
ON DELETE CASCADE;

GRANT SELECT ON _timescaledb_catalog.hypertable_id_seq TO PUBLIC;
GRANT SELECT ON _timescaledb_catalog.hypertable TO PUBLIC;
--End Modify hypertable table
10 changes: 5 additions & 5 deletions sql/views.sql
Expand Up @@ -15,10 +15,10 @@ SELECT ht.schema_name AS hypertable_schema,
FROM _timescaledb_catalog.chunk ch
WHERE ch.hypertable_id = ht.id) AS num_chunks,
(
CASE WHEN ht.compressed_hypertable_id IS NULL THEN
FALSE
CASE WHEN compression_state = 1 THEN
TRUE
ELSE
TRUE
FALSE
END) AS compression_enabled,
(
CASE WHEN ht.replication_factor > 0 THEN
Expand All @@ -43,7 +43,7 @@ FROM _timescaledb_catalog.hypertable ht
array_agg(node_name ORDER BY node_name) AS node_list
FROM _timescaledb_catalog.hypertable_data_node
GROUP BY hypertable_id) dn ON ht.id = dn.hypertable_id
WHERE ht.compressed IS FALSE --> no internal compression tables
WHERE ht.compression_state != 2 --> no internal compression tables
AND ca.mat_hypertable_id IS NULL;

CREATE OR REPLACE VIEW timescaledb_information.job_stats AS
Expand Down Expand Up @@ -234,7 +234,7 @@ FROM (
FROM _timescaledb_catalog.chunk_data_node
GROUP BY chunk_id) chdn ON srcch.id = chdn.chunk_id
WHERE srcch.dropped IS FALSE
AND ht.compressed = FALSE) finalq
AND ht.compression_state != 2 ) finalq
WHERE chunk_dimension_num = 1;

-- hypertable's dimension information
Expand Down
4 changes: 2 additions & 2 deletions src/catalog.h
Expand Up @@ -109,7 +109,7 @@ enum Anum_hypertable
Anum_hypertable_chunk_sizing_func_schema,
Anum_hypertable_chunk_sizing_func_name,
Anum_hypertable_chunk_target_size,
Anum_hypertable_compressed,
Anum_hypertable_compression_state,
Anum_hypertable_compressed_hypertable_id,
Anum_hypertable_replication_factor,
_Anum_hypertable_max,
Expand All @@ -128,7 +128,7 @@ typedef struct FormData_hypertable
NameData chunk_sizing_func_schema;
NameData chunk_sizing_func_name;
int64 chunk_target_size;
bool compressed;
int16 compression_state;
int32 compressed_hypertable_id;
int16 replication_factor;
} FormData_hypertable;
Expand Down
2 changes: 1 addition & 1 deletion src/chunk.c
Expand Up @@ -1931,7 +1931,7 @@ get_chunks_in_time_range(Hypertable *ht, int64 older_than, int64 newer_than,
errmsg("invalid time range"),
errhint("The start of the time range must be before the end.")));

if (ht->fd.compressed)
if (TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht))
elog(ERROR, "invalid operation on compressed hypertable");

start_strategy = (newer_than == PG_INT64_MIN) ? InvalidStrategy : BTGreaterEqualStrategyNumber;
Expand Down
44 changes: 34 additions & 10 deletions src/hypertable.c
Expand Up @@ -154,7 +154,8 @@ hypertable_formdata_make_tuple(const FormData_hypertable *fd, TupleDesc desc)
values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_target_size)] =
Int64GetDatum(fd->chunk_target_size);

values[AttrNumberGetAttrOffset(Anum_hypertable_compressed)] = BoolGetDatum(fd->compressed);
values[AttrNumberGetAttrOffset(Anum_hypertable_compression_state)] =
Int16GetDatum(fd->compression_state);
if (fd->compressed_hypertable_id == INVALID_HYPERTABLE_ID)
nulls[AttrNumberGetAttrOffset(Anum_hypertable_compressed_hypertable_id)] = true;
else
Expand Down Expand Up @@ -189,7 +190,7 @@ hypertable_formdata_fill(FormData_hypertable *fd, const TupleInfo *ti)
Assert(!nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_schema)]);
Assert(!nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_sizing_func_name)]);
Assert(!nulls[AttrNumberGetAttrOffset(Anum_hypertable_chunk_target_size)]);
Assert(!nulls[AttrNumberGetAttrOffset(Anum_hypertable_compressed)]);
Assert(!nulls[AttrNumberGetAttrOffset(Anum_hypertable_compression_state)]);

fd->id = DatumGetInt32(values[AttrNumberGetAttrOffset(Anum_hypertable_id)]);
memcpy(&fd->schema_name,
Expand Down Expand Up @@ -217,7 +218,8 @@ hypertable_formdata_fill(FormData_hypertable *fd, const TupleInfo *ti)

fd->chunk_target_size =
DatumGetInt64(values[AttrNumberGetAttrOffset(Anum_hypertable_chunk_target_size)]);
fd->compressed = DatumGetBool(values[AttrNumberGetAttrOffset(Anum_hypertable_compressed)]);
fd->compression_state =
DatumGetInt16(values[AttrNumberGetAttrOffset(Anum_hypertable_compression_state)]);

if (nulls[AttrNumberGetAttrOffset(Anum_hypertable_compressed_hypertable_id)])
fd->compressed_hypertable_id = INVALID_HYPERTABLE_ID;
Expand Down Expand Up @@ -347,7 +349,8 @@ static bool
hypertable_is_compressed_or_materialization(Hypertable *ht)
{
ContinuousAggHypertableStatus status = ts_continuous_agg_hypertable_status(ht->fd.id);
return (ht->fd.compressed || status == HypertableIsMaterialization);
return (TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht) ||
status == HypertableIsMaterialization);
}

static ScanFilterResult
Expand Down Expand Up @@ -388,7 +391,8 @@ hypertable_is_user_table(Hypertable *ht)
{
ContinuousAggHypertableStatus status = ts_continuous_agg_hypertable_status(ht->fd.id);

return !ht->fd.compressed && status != HypertableIsMaterialization;
return (!TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht) &&
status != HypertableIsMaterialization);
}

static ScanTupleResult
Expand Down Expand Up @@ -416,7 +420,7 @@ hypertable_tuple_add_stat(TupleInfo *ti, void *data)
break;
default:
Assert(replication_factor >= 1);
Assert(!ht->fd.compressed);
Assert(!TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht));
stat->num_hypertables_distributed++;
if (replication_factor > 1)
stat->num_hypertables_distributed_and_replicated++;
Expand Down Expand Up @@ -1002,7 +1006,10 @@ hypertable_insert(int32 hypertable_id, Name schema_name, Name table_name,
if (fd.chunk_target_size < 0)
fd.chunk_target_size = 0;

fd.compressed = compressed;
if (compressed)
fd.compression_state = HypertableInternalCompressionTable;
else
fd.compression_state = HypertableCompressionOff;

/* when creating a hypertable, there is never an associated compressed dual */
fd.compressed_hypertable_id = INVALID_HYPERTABLE_ID;
Expand Down Expand Up @@ -2419,15 +2426,21 @@ ts_hypertable_set_integer_now_func(PG_FUNCTION_ARGS)
bool
ts_hypertable_set_compressed_id(Hypertable *ht, int32 compressed_hypertable_id)
{
Assert(!ht->fd.compressed);
ht->fd.compressed_hypertable_id = compressed_hypertable_id;
Assert(!TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht));
ht->fd.compression_state = HypertableCompressionEnabled;
/* distr. hypertables do not have a internal compression table
* on the access node
*/
if (!hypertable_is_distributed(ht))
ht->fd.compressed_hypertable_id = compressed_hypertable_id;
return ts_hypertable_update(ht) > 0;
}

bool
ts_hypertable_unset_compressed_id(Hypertable *ht)
{
Assert(!ht->fd.compressed);
Assert(!TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht));
ht->fd.compression_state = HypertableCompressionOff;
ht->fd.compressed_hypertable_id = INVALID_HYPERTABLE_ID;
return ts_hypertable_update(ht) > 0;
}
Expand Down Expand Up @@ -2734,3 +2747,14 @@ ts_hypertable_get_open_dim_max_value(const Hypertable *ht, int dimension_index,

return maxdat;
}

bool
ts_hypertable_has_compression(Hypertable *ht)
{
if (ht->fd.compressed_hypertable_id != INVALID_HYPERTABLE_ID)
{
Assert(ht->fd.compression_state == HypertableCompressionEnabled);
return true;
}
return false;
}
21 changes: 19 additions & 2 deletions src/hypertable.h
Expand Up @@ -26,9 +26,24 @@ typedef struct SubspaceStore SubspaceStore;
typedef struct Chunk Chunk;
typedef struct Hypercube Hypercube;

#define TS_HYPERTABLE_HAS_COMPRESSION(ht) \
((ht)->fd.compressed_hypertable_id != INVALID_HYPERTABLE_ID)
/* For the distributed node case, we would have compression enabled
* but don't have a corresponding internal table on the access
* node
*/
enum
{
HypertableCompressionOff = 0,
HypertableCompressionEnabled = 1,
HypertableInternalCompressionTable = 2,
};

#define TS_HYPERTABLE_HAS_COMPRESSION(ht) ts_hypertable_has_compression(ht)

#define TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht) \
((ht)->fd.compression_state == HypertableCompressionEnabled)
Comment on lines +40 to +43
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between TS_HYPERTABLE_HAS_COMPRESSION and TS_HYPERTABLE_HAS_COMPRESSION_ENABLED?

This is somewhat confusing and it is difficult to tell these two macros apart.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TS_HYPERTABLE_HAS_COMPRESSION is used in places where we need to know that the internal table exists for the user table. The action is done on the internal table.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I should have been more clear/specific. The issue here is that the macros are hard to tell apart. I understand that they are used differently, although it was initially hard for me to realize the difference. This leads me to believe that this will be the case for others too, so just explaining in the PR is not enough.

If I look at the implementation of ts_hypertable_has_compression it is asserted that ht->fd.compression_state == HypertableCompressionEnabled is true when the function returns true. This is the same condition used in TS_HYPERTABLE_HAS_COMPRESSION_ENABLED. So it is really unclear what the difference is.

I think what we actually want to do here is distinguish between distributed and non-distributed compressed hypertables:

#define TS_HYPERTABLE_IS_DISTRIBUTED_AND_COMPRESSED(ht) \
   (TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht) && \
     ht->fd.compressed_hypertable_id != INVALID_HYPERTABLE_ID)

This would make the naming more clear and also, looking at the definition, that this is a stricter condition than just having compression enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The check is for the existence of a "compressed" hypertable. I think a more appropriate rename is TS_HYPERTABLE_HAS_COMPRESSION_TABLE. If it is distributed, compressed_hypertable_id would be null.


#define TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht) \
((ht)->fd.compression_state == HypertableInternalCompressionTable)
typedef struct Hypertable
{
FormData_hypertable fd;
Expand Down Expand Up @@ -159,6 +174,8 @@ extern TSDLLEXPORT int16 ts_validate_replication_factor(int32 replication_factor
extern TSDLLEXPORT Datum ts_hypertable_get_open_dim_max_value(const Hypertable *ht,
int dimension_index, bool *isnull);

extern TSDLLEXPORT bool ts_hypertable_has_compression(Hypertable *ht);

#define hypertable_scan(schema, table, tuple_found, data, lockmode, tuplock) \
ts_hypertable_scan_with_memory_context(schema, \
table, \
Expand Down
6 changes: 3 additions & 3 deletions src/process_utility.c
Expand Up @@ -594,7 +594,7 @@ add_compressed_chunk_to_vacuum(Hypertable *ht, Oid comp_chunk_relid, void *arg)

Chunk *chunk_parent;
/* chunk is from a compressed hypertable */
Assert(ht->fd.compressed);
Assert(TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht));

/*chunks for internal compression table have a parent */
chunk_parent = ts_chunk_get_compressed_chunk_parent(compressed_chunk);
Expand Down Expand Up @@ -774,7 +774,7 @@ process_vacuum(ProcessUtilityArgs *args)
if (hypertable_is_distributed(ht))
continue;

if (ht->fd.compressed)
if (TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht))
{
ctx.ht_vacuum_rel = vacuum_rel;
foreach_chunk(ht, add_compressed_chunk_to_vacuum, &ctx);
Expand Down Expand Up @@ -1106,7 +1106,7 @@ process_drop_hypertable(ProcessUtilityArgs *args, DropStmt *stmt)
if (list_length(stmt->objects) != 1)
elog(ERROR, "cannot drop a hypertable along with other objects");

if (ht->fd.compressed)
if (TS_HYPERTABLE_IS_INTERNAL_COMPRESSION_TABLE(ht))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("dropping compressed hypertables not supported"),
Expand Down