mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-17 11:03:36 +08:00
Add tests that constraint adding is blocked
Adding constraints to tables that have compression enabled should be blocked for now.
This commit is contained in:
parent
b8a98c1f18
commit
7380efa0fe
@ -71,7 +71,7 @@ ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10;
|
||||
-- TABLESPACES
|
||||
-- For tablepaces with compressed chunks the semantics are the following:
|
||||
-- - compressed chunks get put into the same tablespace as the
|
||||
-- uncommpressed chunk on compression.
|
||||
-- uncompressed chunk on compression.
|
||||
-- - set tablespace on uncompressed hypertable cascades to compressed hypertable+chunks
|
||||
-- - set tablespace on all chunks is blocked (same as w/o compression)
|
||||
-- - move chunks on a uncompressed chunk errors
|
||||
|
@ -68,6 +68,7 @@ ALTER TABLE reserved_column_prefix set (timescaledb.compress);
|
||||
ERROR: cannot compress tables with reserved column prefix '_ts_meta_'
|
||||
--basic test with count
|
||||
create table foo (a integer, b integer, c integer, t text, p point);
|
||||
ALTER TABLE foo ADD CONSTRAINT chk_existing CHECK(b > 0);
|
||||
select table_name from create_hypertable('foo', 'a', chunk_time_interval=> 10);
|
||||
NOTICE: adding not-null constraint to column "a"
|
||||
table_name
|
||||
@ -148,6 +149,12 @@ ALTER TABLE foo ALTER COLUMN t SET NOT NULL;
|
||||
ERROR: operation not supported on hypertables that have compression enabled
|
||||
ALTER TABLE foo RESET (timescaledb.compress);
|
||||
ERROR: compression options cannot be reset
|
||||
ALTER TABLE foo ADD CONSTRAINT chk CHECK(b > 0);
|
||||
ERROR: operation not supported on hypertables that have compression enabled
|
||||
ALTER TABLE foo ADD CONSTRAINT chk UNIQUE(b);
|
||||
ERROR: operation not supported on hypertables that have compression enabled
|
||||
ALTER TABLE foo DROP CONSTRAINT chk_existing;
|
||||
ERROR: operation not supported on hypertables that have compression enabled
|
||||
--note that the time column "a" should not be added to the end of the order by list again (should appear first)
|
||||
select hc.* from _timescaledb_catalog.hypertable_compression hc inner join _timescaledb_catalog.hypertable h on (h.id = hc.hypertable_id) where h.table_name = 'foo' order by attname;
|
||||
hypertable_id | attname | compression_algorithm_id | segmentby_column_index | orderby_column_index | orderby_asc | orderby_nullsfirst
|
||||
@ -245,6 +252,9 @@ ALTER TABLE table_constr set (timescaledb.compress, timescaledb.compress_orderby
|
||||
NOTICE: adding index _compressed_hypertable_13_device_id__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_13 USING BTREE(device_id, _ts_meta_sequence_num)
|
||||
NOTICE: adding index _compressed_hypertable_13_location__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_13 USING BTREE(location, _ts_meta_sequence_num)
|
||||
NOTICE: adding index _compressed_hypertable_13_d__ts_meta_sequence_num_idx ON _timescaledb_internal._compressed_hypertable_13 USING BTREE(d, _ts_meta_sequence_num)
|
||||
--can't add fks after compression enabled
|
||||
alter table table_constr add constraint table_constr_fk_add_after FOREIGN KEY(d) REFERENCES fortable(col) on delete cascade;
|
||||
ERROR: operation not supported on hypertables that have compression enabled
|
||||
-- TEST fk cascade delete behavior on compressed chunk --
|
||||
insert into fortable values(1);
|
||||
insert into fortable values(10);
|
||||
|
@ -48,7 +48,7 @@ ALTER TABLE test1 ALTER COLUMN b SET STATISTICS 10;
|
||||
-- TABLESPACES
|
||||
-- For tablepaces with compressed chunks the semantics are the following:
|
||||
-- - compressed chunks get put into the same tablespace as the
|
||||
-- uncommpressed chunk on compression.
|
||||
-- uncompressed chunk on compression.
|
||||
-- - set tablespace on uncompressed hypertable cascades to compressed hypertable+chunks
|
||||
-- - set tablespace on all chunks is blocked (same as w/o compression)
|
||||
-- - move chunks on a uncompressed chunk errors
|
||||
|
@ -37,6 +37,7 @@ ALTER TABLE reserved_column_prefix set (timescaledb.compress);
|
||||
|
||||
--basic test with count
|
||||
create table foo (a integer, b integer, c integer, t text, p point);
|
||||
ALTER TABLE foo ADD CONSTRAINT chk_existing CHECK(b > 0);
|
||||
select table_name from create_hypertable('foo', 'a', chunk_time_interval=> 10);
|
||||
|
||||
insert into foo values( 3 , 16 , 20);
|
||||
@ -84,6 +85,9 @@ ALTER TABLE foo DROP COLUMN a;
|
||||
ALTER TABLE foo DROP COLUMN t;
|
||||
ALTER TABLE foo ALTER COLUMN t SET NOT NULL;
|
||||
ALTER TABLE foo RESET (timescaledb.compress);
|
||||
ALTER TABLE foo ADD CONSTRAINT chk CHECK(b > 0);
|
||||
ALTER TABLE foo ADD CONSTRAINT chk UNIQUE(b);
|
||||
ALTER TABLE foo DROP CONSTRAINT chk_existing;
|
||||
|
||||
--note that the time column "a" should not be added to the end of the order by list again (should appear first)
|
||||
select hc.* from _timescaledb_catalog.hypertable_compression hc inner join _timescaledb_catalog.hypertable h on (h.id = hc.hypertable_id) where h.table_name = 'foo' order by attname;
|
||||
@ -147,6 +151,8 @@ ALTER TABLE table_constr set (timescaledb.compress, timescaledb.compress_orderby
|
||||
alter table table_constr drop constraint table_constr_exclu ;
|
||||
--now it works
|
||||
ALTER TABLE table_constr set (timescaledb.compress, timescaledb.compress_orderby = 'timec', timescaledb.compress_segmentby = 'device_id, location, d');
|
||||
--can't add fks after compression enabled
|
||||
alter table table_constr add constraint table_constr_fk_add_after FOREIGN KEY(d) REFERENCES fortable(col) on delete cascade;
|
||||
|
||||
-- TEST fk cascade delete behavior on compressed chunk --
|
||||
insert into fortable values(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user