mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-28 09:46:44 +08:00
This commit allows `ALTER TABLE SET ACCESS METHOD` on a hypertable, which will set the access method of the hypertable to the given access method and also set the compression flag if changing to `hyperstore` access method. In order to set compression when setting the access method, it is necessary to allow several ALTER TABLE commands, which was previously not allowed. To support this, `ProcessUtility` will process each `ALTER TABLE` command in turn and remove it from the list if it is dealt with. If there are any remaining commands in the list after that, it will assume that these are not timescaledb-specific and continue running the normal command and also recurse the ALTER TABLE SET ACCESS METHOD command to the chunks.
33 lines
1.3 KiB
SQL
33 lines
1.3 KiB
SQL
-- This file and its contents are licensed under the Apache License 2.0.
|
|
-- Please see the included NOTICE for copyright information and
|
|
-- LICENSE-APACHE for a copy of the license.
|
|
|
|
CREATE TABLE reloptions_test(time integer, temp float8, color integer)
|
|
WITH (fillfactor=75, autovacuum_vacuum_threshold=100);
|
|
|
|
SELECT create_hypertable('reloptions_test', 'time', chunk_time_interval => 3);
|
|
|
|
INSERT INTO reloptions_test VALUES (4, 24.3, 1), (9, 13.3, 2);
|
|
|
|
-- Show that reloptions are inherited by chunks
|
|
SELECT relname, reloptions FROM pg_class
|
|
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
|
|
|
|
-- Alter reloptions. We support multiple options for the ALTER TABLE
|
|
ALTER TABLE reloptions_test SET (fillfactor=80, parallel_workers=8);
|
|
ALTER TABLE reloptions_test SET (fillfactor=80), SET (parallel_workers=8);
|
|
|
|
SELECT relname, reloptions FROM pg_class
|
|
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
|
|
|
|
ALTER TABLE reloptions_test RESET (fillfactor);
|
|
|
|
SELECT relname, reloptions FROM pg_class
|
|
WHERE relname ~ '^_hyper.*' AND relkind = 'r';
|
|
|
|
-- Test reloptions on a regular table
|
|
CREATE TABLE reloptions_test2(time integer, temp float8, color integer);
|
|
ALTER TABLE reloptions_test2 SET (fillfactor=80, parallel_workers=8);
|
|
ALTER TABLE reloptions_test2 SET (fillfactor=80), SET (parallel_workers=8);
|
|
DROP TABLE reloptions_test2;
|