Skip to content

Commit

Permalink
Check CREATE INDEX with transaction per chunk using dist hypertable
Browse files Browse the repository at this point in the history
Issue: #836
  • Loading branch information
pmwkaa committed Aug 21, 2020
1 parent c281dcd commit 33d5d11
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -1991,6 +1991,12 @@ process_index_start(ProcessUtilityArgs *args)
errmsg(
"cannot use timescaledb.transaction_per_chunk with UNIQUE or PRIMARY KEY")));

if (info.extended_options.multitransaction && hypertable_is_distributed(ht))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg(
"cannot use timescaledb.transaction_per_chunk with distributed hypetable")));

ts_indexing_verify_index(ht->space, stmt);

if (info.extended_options.multitransaction)
Expand Down
25 changes: 25 additions & 0 deletions tsl/test/expected/dist_hypertable-11.out
Original file line number Diff line number Diff line change
Expand Up @@ -4565,3 +4565,28 @@ SELECT * FROM create_distributed_hypertable('dist_hypertable_1', 'time', 'device
migrate_data => TRUE);
ERROR: cannot migrate data for distributed hypertable
\set ON_ERROR_STOP 1
-- Test creating index with transaction per chunk on a distributed hypertable
--
DROP TABLE disttable;
CREATE TABLE disttable(
time timestamptz NOT NULL,
device int,
value float
);
SELECT * FROM create_distributed_hypertable('disttable', 'time', 'device', 3);
hypertable_id | schema_name | table_name | created
---------------+-------------+------------+---------
25 | public | disttable | t
(1 row)

INSERT INTO disttable VALUES
('2017-01-01 06:01', 1, 1.2),
('2017-01-01 09:11', 3, 4.3),
('2017-01-01 08:01', 1, 7.3),
('2017-01-02 08:01', 2, 0.23),
('2018-07-02 08:01', 87, 0.0),
('2018-07-01 06:01', 13, 3.1),
('2018-07-01 09:11', 90, 10303.12),
('2018-07-01 08:01', 29, 64);
CREATE INDEX disttable_time_device_idx ON disttable (time, device) WITH (timescaledb.transaction_per_chunk);
ERROR: cannot use timescaledb.transaction_per_chunk with distributed hypetable
25 changes: 25 additions & 0 deletions tsl/test/expected/dist_hypertable-12.out
Original file line number Diff line number Diff line change
Expand Up @@ -4545,3 +4545,28 @@ SELECT * FROM create_distributed_hypertable('dist_hypertable_1', 'time', 'device
migrate_data => TRUE);
ERROR: cannot migrate data for distributed hypertable
\set ON_ERROR_STOP 1
-- Test creating index with transaction per chunk on a distributed hypertable
--
DROP TABLE disttable;
CREATE TABLE disttable(
time timestamptz NOT NULL,
device int,
value float
);
SELECT * FROM create_distributed_hypertable('disttable', 'time', 'device', 3);
hypertable_id | schema_name | table_name | created
---------------+-------------+------------+---------
25 | public | disttable | t
(1 row)

INSERT INTO disttable VALUES
('2017-01-01 06:01', 1, 1.2),
('2017-01-01 09:11', 3, 4.3),
('2017-01-01 08:01', 1, 7.3),
('2017-01-02 08:01', 2, 0.23),
('2018-07-02 08:01', 87, 0.0),
('2018-07-01 06:01', 13, 3.1),
('2018-07-01 09:11', 90, 10303.12),
('2018-07-01 08:01', 29, 64);
CREATE INDEX disttable_time_device_idx ON disttable (time, device) WITH (timescaledb.transaction_per_chunk);
ERROR: cannot use timescaledb.transaction_per_chunk with distributed hypetable
21 changes: 21 additions & 0 deletions tsl/test/sql/dist_hypertable.sql.in
Original file line number Diff line number Diff line change
Expand Up @@ -1470,3 +1470,24 @@ SELECT * FROM create_distributed_hypertable('dist_hypertable_1', 'time', 'device
SELECT * FROM create_distributed_hypertable('dist_hypertable_1', 'time', 'device', 3,
migrate_data => TRUE);
\set ON_ERROR_STOP 1

-- Test creating index with transaction per chunk on a distributed hypertable
--
DROP TABLE disttable;

CREATE TABLE disttable(
time timestamptz NOT NULL,
device int,
value float
);
SELECT * FROM create_distributed_hypertable('disttable', 'time', 'device', 3);
INSERT INTO disttable VALUES
('2017-01-01 06:01', 1, 1.2),
('2017-01-01 09:11', 3, 4.3),
('2017-01-01 08:01', 1, 7.3),
('2017-01-02 08:01', 2, 0.23),
('2018-07-02 08:01', 87, 0.0),
('2018-07-01 06:01', 13, 3.1),
('2018-07-01 09:11', 90, 10303.12),
('2018-07-01 08:01', 29, 64);
CREATE INDEX disttable_time_device_idx ON disttable (time, device) WITH (timescaledb.transaction_per_chunk);

0 comments on commit 33d5d11

Please sign in to comment.