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

Set NONCONTIGUOUS status flag upon OSM chunk creation #6094

Merged
merged 1 commit into from
Sep 19, 2023
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
13 changes: 10 additions & 3 deletions src/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4614,10 +4614,17 @@ add_foreign_table_as_chunk(Oid relid, Hypertable *parent_ht)
chunk_add_inheritance(chunk, parent_ht);
/*
* Update hypertable entry with tiering status information.
* Noncontiguous flag is not set since the chunk is empty upon creation,
* with an invalid range assigned, so ordered append should be allowed.
* XXX: For compatibility reasons, we set the noncontiguous flag, but
* this should be reverted as soon as the newer version of the OSM extension
* is rolled out.
* Noncontiguous flag should not be set since the chunk should be empty upon
* creation, with an invalid range assigned, so ordered append should be allowed.
* Once the data is moved into the OSM chunk, then our catalog should be
* udpated with proper API calls from the OSM extension.
*/
parent_ht->fd.status = ts_set_flags_32(parent_ht->fd.status, HYPERTABLE_STATUS_OSM);
parent_ht->fd.status =
ts_set_flags_32(parent_ht->fd.status,
HYPERTABLE_STATUS_OSM | HYPERTABLE_STATUS_OSM_CHUNK_NONCONTIGUOUS);
ts_hypertable_update(parent_ht);
}

Expand Down
11 changes: 8 additions & 3 deletions tsl/test/expected/chunk_utils_internal.out
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,14 @@ SELECT _timescaledb_functions.attach_osm_table_chunk('ht_try', 'child_fdw_table'
t
(1 row)

-- must also update the range since the created chunk is assumed to be empty,
-- and its range actually updated when data is moved to OSM. But in this mock
-- test case, the attached OSM chunk contains data
-- check hypertable status
SELECT status FROM _timescaledb_catalog.hypertable WHERE table_name = 'ht_try';
status
--------
3
(1 row)

-- must also update the range since the created chunk contains data
SELECT _timescaledb_functions.hypertable_osm_range_update('ht_try', '2020-01-01'::timestamptz, '2020-01-02');
hypertable_osm_range_update
-----------------------------
Expand Down
6 changes: 3 additions & 3 deletions tsl/test/sql/chunk_utils_internal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ SELECT _timescaledb_functions.hypertable_osm_range_update('ht_try','2020-01-01 0
\set ON_ERROR_STOP 1

SELECT _timescaledb_functions.attach_osm_table_chunk('ht_try', 'child_fdw_table');
-- must also update the range since the created chunk is assumed to be empty,
-- and its range actually updated when data is moved to OSM. But in this mock
-- test case, the attached OSM chunk contains data
-- check hypertable status
SELECT status FROM _timescaledb_catalog.hypertable WHERE table_name = 'ht_try';
-- must also update the range since the created chunk contains data
SELECT _timescaledb_functions.hypertable_osm_range_update('ht_try', '2020-01-01'::timestamptz, '2020-01-02');

-- OSM chunk is not visible in chunks view
Expand Down