Block unique idx creation on compressed hypertable

This block was removed by accident, in order to support this we
need to ensure the uniqueness in the compressed data which is
something we should do in the future thus removing this block.
This commit is contained in:
Ante Kresic 2023-04-20 12:54:28 +02:00 committed by Ante Kresic
parent 12f3131f9e
commit 23b3f8d7a6
3 changed files with 25 additions and 0 deletions

View File

@ -2711,6 +2711,18 @@ process_index_start(ProcessUtilityArgs *args)
/* Make the RangeVar for the underlying materialization hypertable */
stmt->relation = makeRangeVar(NameStr(ht->fd.schema_name), NameStr(ht->fd.table_name), -1);
}
else if (TS_HYPERTABLE_HAS_COMPRESSION_ENABLED(ht))
{
/* unique indexes are not allowed on compressed hypertables*/
if (stmt->unique || stmt->primary || stmt->isconstraint)
{
ts_cache_release(hcache);
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("operation not supported on hypertables that have compression "
"enabled")));
}
}
ts_hypertable_permissions_check_by_id(ht->fd.id);
add_hypertable_to_process_args(args, ht);

View File

@ -62,6 +62,13 @@ DROP INDEX new_index;
ALTER TABLE test1 SET (fillfactor=100);
ALTER TABLE test1 RESET (fillfactor);
ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10;
-- make sure we cannot create constraints or unique indexes on compressed hypertables
\set ON_ERROR_STOP 0
ALTER TABLE test1 ADD CONSTRAINT c1 UNIQUE(time,i);
ERROR: operation not supported on hypertables that have compression enabled
CREATE UNIQUE INDEX unique_index ON test1(time,i);
ERROR: operation not supported on hypertables that have compression enabled
\set ON_ERROR_STOP 1
--test adding boolean columns with default and not null
CREATE TABLE records (time timestamp NOT NULL);
SELECT create_hypertable('records', 'time');

View File

@ -42,6 +42,12 @@ ALTER TABLE test1 SET (fillfactor=100);
ALTER TABLE test1 RESET (fillfactor);
ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10;
-- make sure we cannot create constraints or unique indexes on compressed hypertables
\set ON_ERROR_STOP 0
ALTER TABLE test1 ADD CONSTRAINT c1 UNIQUE(time,i);
CREATE UNIQUE INDEX unique_index ON test1(time,i);
\set ON_ERROR_STOP 1
--test adding boolean columns with default and not null
CREATE TABLE records (time timestamp NOT NULL);
SELECT create_hypertable('records', 'time');