Skip to content

Commit

Permalink
Fix OSM build failure
Browse files Browse the repository at this point in the history
The commit timescale#6513 removed some restricted chunk operations, enabling
adding constraints to OSM chunks directly. This operation is blocked
on OSM chunks. The present commit ensures that adding a constraint
directly on an OSM chunk is blocked.
  • Loading branch information
konskov committed Jan 23, 2024
1 parent 0b23bab commit f06b2a2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/process_utility.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ check_chunk_alter_table_operation_allowed(Oid relid, AlterTableStmt *stmt)

switch (cmd->subtype)
{
case AT_AddConstraint:
case AT_SetOptions:
case AT_ResetOptions:
case AT_SetRelOptions:
Expand All @@ -162,6 +161,18 @@ check_chunk_alter_table_operation_allowed(Oid relid, AlterTableStmt *stmt)
#endif
/* allowed on chunks */
break;
case AT_AddConstraint:
{
/* if this is an OSM chunk, block the operation */
Chunk *chunk = ts_chunk_get_by_relid(relid, false /* fail_if_not_found */);
if (chunk && chunk->fd.osm_chunk)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("operation not supported on OSM chunk tables")));
}
break;
}
default:
/* disable by default */
all_allowed = false;
Expand Down
4 changes: 4 additions & 0 deletions tsl/test/expected/chunk_utils_internal.out
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,10 @@ SELECT * FROM test_chunkapp ORDER BY 1;
Thu Jan 02 01:00:00 2020 PST | 2
(2 rows)

\set ON_ERROR_STOP 0
ALTER TABLE test_chunkapp_fdw_child ADD CHECK (a > 0);
ERROR: operation not supported on OSM chunk tables
\set ON_ERROR_STOP 1
-- test error is triggered when time dimension not found
CREATE TABLE test2(time timestamptz not null, a int);
SELECT create_hypertable('test2', 'time');
Expand Down
4 changes: 4 additions & 0 deletions tsl/test/sql/chunk_utils_internal.sql
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,10 @@ SELECT _timescaledb_functions.hypertable_osm_range_update('test_chunkapp', NULL:
EXPLAIN SELECT * FROM test_chunkapp ORDER BY 1;
SELECT * FROM test_chunkapp ORDER BY 1;

\set ON_ERROR_STOP 0
ALTER TABLE test_chunkapp_fdw_child ADD CHECK (a > 0);
\set ON_ERROR_STOP 1

-- test error is triggered when time dimension not found
CREATE TABLE test2(time timestamptz not null, a int);
SELECT create_hypertable('test2', 'time');
Expand Down

0 comments on commit f06b2a2

Please sign in to comment.