From 88ece2757b2efe0254255b60ba8cf589ad22fa60 Mon Sep 17 00:00:00 2001 From: Konstantina Skovola Date: Fri, 15 Sep 2023 17:06:10 +0300 Subject: [PATCH] Update error message --- src/nodes/chunk_dispatch/chunk_dispatch.c | 23 ++++++++++++++++++++-- tsl/test/expected/chunk_utils_internal.out | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/nodes/chunk_dispatch/chunk_dispatch.c b/src/nodes/chunk_dispatch/chunk_dispatch.c index 435554d5190..1bdc93da855 100644 --- a/src/nodes/chunk_dispatch/chunk_dispatch.c +++ b/src/nodes/chunk_dispatch/chunk_dispatch.c @@ -23,6 +23,7 @@ #include "guc.h" #include "nodes/hypertable_modify.h" #include "ts_catalog/chunk_data_node.h" +#include "hypercube.h" static Node *chunk_dispatch_state_create(CustomScan *cscan); @@ -106,13 +107,31 @@ ts_chunk_dispatch_get_chunk_insert_state(ChunkDispatch *dispatch, Point *point, elog(ERROR, "cannot INSERT into frozen chunk \"%s\"", get_rel_name(chunk->table_id)); #endif if (chunk && IS_OSM_CHUNK(chunk)) + { + const Dimension *time_dim = + hyperspace_get_open_dimension(dispatch->hypertable->space, 0); + Assert(time_dim != NULL); + + Oid outfuncid = InvalidOid; + bool isvarlena; + getTypeOutputInfo(time_dim->fd.column_type, &outfuncid, &isvarlena); + Assert(!isvarlena); + Datum start_ts = ts_internal_to_time_value(chunk->cube->slices[0]->fd.range_start, + time_dim->fd.column_type); + Datum end_ts = ts_internal_to_time_value(chunk->cube->slices[0]->fd.range_end, + time_dim->fd.column_type); ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("Cannot insert into tiered chunk range of %s.%s", + errmsg("Cannot insert into tiered chunk range of %s.%s - attempt to create " + "new chunk " + "with range [%s %s] failed", NameStr(dispatch->hypertable->fd.schema_name), - NameStr(dispatch->hypertable->fd.table_name)), + NameStr(dispatch->hypertable->fd.table_name), + DatumGetCString(OidFunctionCall1(outfuncid, start_ts)), + DatumGetCString(OidFunctionCall1(outfuncid, end_ts))), errhint( "Hypertable has tiered data with time range that overlaps the insert"))); + } if (!chunk) { diff --git a/tsl/test/expected/chunk_utils_internal.out b/tsl/test/expected/chunk_utils_internal.out index eca87510452..44a2eb9829c 100644 --- a/tsl/test/expected/chunk_utils_internal.out +++ b/tsl/test/expected/chunk_utils_internal.out @@ -1235,7 +1235,7 @@ SELECT ts_setup_osm_hook(); \set ON_ERROR_STOP 0 INSERT INTO test_chunkapp VALUES ('2020-01-03 02:00'::timestamptz, 3); -ERROR: Cannot insert into tiered chunk range of public.test_chunkapp +ERROR: Cannot insert into tiered chunk range of public.test_chunkapp - attempt to create new chunk with range [Fri Jan 03 00:00:00 2020 PST Sat Jan 04 00:00:00 2020 PST] failed \set ON_ERROR_STOP 1 SELECT ts_undo_osm_hook(); ts_undo_osm_hook