mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-18 11:45:11 +08:00
Don't show osm chunk via show_chunks
Fix show_chunks to not to show the OSM chunk. In passing, also fix a compilation error on macOS.
This commit is contained in:
parent
ebb2556ab3
commit
50cc8e3f3b
27
src/chunk.c
27
src/chunk.c
@ -129,7 +129,7 @@ static void chunk_scan_ctx_destroy(ChunkScanCtx *ctx);
|
|||||||
static void chunk_collision_scan(ChunkScanCtx *scanctx, const Hypercube *cube);
|
static void chunk_collision_scan(ChunkScanCtx *scanctx, const Hypercube *cube);
|
||||||
static int chunk_scan_ctx_foreach_chunk_stub(ChunkScanCtx *ctx, on_chunk_stub_func on_chunk,
|
static int chunk_scan_ctx_foreach_chunk_stub(ChunkScanCtx *ctx, on_chunk_stub_func on_chunk,
|
||||||
uint16 limit);
|
uint16 limit);
|
||||||
static Datum chunks_return_srf(FunctionCallInfo fcinfo);
|
static Datum show_chunks_return_srf(FunctionCallInfo fcinfo);
|
||||||
static int chunk_cmp(const void *ch1, const void *ch2);
|
static int chunk_cmp(const void *ch1, const void *ch2);
|
||||||
static int chunk_point_find_chunk_id(const Hypertable *ht, const Point *p);
|
static int chunk_point_find_chunk_id(const Hypertable *ht, const Point *p);
|
||||||
static void init_scan_by_qualified_table_name(ScanIterator *iterator, const char *schema_name,
|
static void init_scan_by_qualified_table_name(ScanIterator *iterator, const char *schema_name,
|
||||||
@ -2034,7 +2034,7 @@ Datum
|
|||||||
ts_chunk_show_chunks(PG_FUNCTION_ARGS)
|
ts_chunk_show_chunks(PG_FUNCTION_ARGS)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* chunks_return_srf is called even when it is not the first call but only
|
* show_chunks_return_srf is called even when it is not the first call but only
|
||||||
* after doing some computation first
|
* after doing some computation first
|
||||||
*/
|
*/
|
||||||
if (SRF_IS_FIRSTCALL())
|
if (SRF_IS_FIRSTCALL())
|
||||||
@ -2173,7 +2173,7 @@ ts_chunk_show_chunks(PG_FUNCTION_ARGS)
|
|||||||
ts_cache_release(hcache);
|
ts_cache_release(hcache);
|
||||||
}
|
}
|
||||||
|
|
||||||
return chunks_return_srf(fcinfo);
|
return show_chunks_return_srf(fcinfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Chunk *
|
static Chunk *
|
||||||
@ -3720,12 +3720,13 @@ chunk_cmp(const void *ch1, const void *ch2)
|
|||||||
* to work.
|
* to work.
|
||||||
*/
|
*/
|
||||||
static Datum
|
static Datum
|
||||||
chunks_return_srf(FunctionCallInfo fcinfo)
|
show_chunks_return_srf(FunctionCallInfo fcinfo)
|
||||||
{
|
{
|
||||||
FuncCallContext *funcctx;
|
FuncCallContext *funcctx;
|
||||||
uint64 call_cntr;
|
uint64 call_cntr;
|
||||||
TupleDesc tupdesc;
|
TupleDesc tupdesc;
|
||||||
Chunk *result_set;
|
Chunk *result_set;
|
||||||
|
Chunk *curr_chunk;
|
||||||
|
|
||||||
/* stuff done only on the first call of the function */
|
/* stuff done only on the first call of the function */
|
||||||
if (SRF_IS_FIRSTCALL())
|
if (SRF_IS_FIRSTCALL())
|
||||||
@ -3745,6 +3746,24 @@ chunks_return_srf(FunctionCallInfo fcinfo)
|
|||||||
call_cntr = funcctx->call_cntr;
|
call_cntr = funcctx->call_cntr;
|
||||||
result_set = (Chunk *) funcctx->user_fctx;
|
result_set = (Chunk *) funcctx->user_fctx;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* skip if it's an OSM chunk. Ideally this check could be done deep down in
|
||||||
|
* functions like "chunk_scan_context_add_chunk", "chunk_tuple_dropped_filter"
|
||||||
|
* etc. but they are used by other APIs like drop_chunks, chunk_scan_find, etc
|
||||||
|
* which need access to the OSM chunk. Trying to unify scan functions across
|
||||||
|
* all such usages seems to be too much of an overhaul as compared to this.
|
||||||
|
*
|
||||||
|
* Check the index appropriately first.
|
||||||
|
*/
|
||||||
|
if (call_cntr < funcctx->max_calls)
|
||||||
|
{
|
||||||
|
curr_chunk = &result_set[call_cntr];
|
||||||
|
if (IS_OSM_CHUNK(curr_chunk))
|
||||||
|
{
|
||||||
|
call_cntr = ++funcctx->call_cntr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* do when there is more left to send */
|
/* do when there is more left to send */
|
||||||
if (call_cntr < funcctx->max_calls)
|
if (call_cntr < funcctx->max_calls)
|
||||||
SRF_RETURN_NEXT(funcctx, result_set[call_cntr].table_id);
|
SRF_RETURN_NEXT(funcctx, result_set[call_cntr].table_id);
|
||||||
|
@ -23,7 +23,7 @@ static Datum
|
|||||||
create_cagg_validate_query_datum(TupleDesc tupdesc, const bool is_valid_query,
|
create_cagg_validate_query_datum(TupleDesc tupdesc, const bool is_valid_query,
|
||||||
const ErrorData *edata)
|
const ErrorData *edata)
|
||||||
{
|
{
|
||||||
NullableDatum datums[Natts_cagg_validate_query] = { 0 };
|
NullableDatum datums[Natts_cagg_validate_query] = { { 0 } };
|
||||||
HeapTuple tuple;
|
HeapTuple tuple;
|
||||||
|
|
||||||
tupdesc = BlessTupleDesc(tupdesc);
|
tupdesc = BlessTupleDesc(tupdesc);
|
||||||
|
@ -946,6 +946,13 @@ ORDER BY id;
|
|||||||
16 | child_hyper_constr
|
16 | child_hyper_constr
|
||||||
(2 rows)
|
(2 rows)
|
||||||
|
|
||||||
|
-- show_chunks will not show the OSM chunk which is visible via the above query
|
||||||
|
SELECT show_chunks('hyper_constr');
|
||||||
|
show_chunks
|
||||||
|
-----------------------------------------
|
||||||
|
_timescaledb_internal._hyper_7_15_chunk
|
||||||
|
(1 row)
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
CALL run_job(:deljob_id);
|
CALL run_job(:deljob_id);
|
||||||
NOTICE: hypertable_drop_chunks_hook
|
NOTICE: hypertable_drop_chunks_hook
|
||||||
|
@ -878,6 +878,16 @@ WARNING: there was some uncertainty picking the default segment by for the hype
|
|||||||
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
||||||
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
||||||
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
SELECT format('%I.%I',chunk_schema,chunk_name) AS "CHUNK_NAME"
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'osm_table'
|
||||||
|
ORDER BY chunk_name LIMIT 1 \gset
|
||||||
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
SELECT compress_chunk(show_chunks('osm_table'));
|
-- show_chunks should not show any OSM chunks
|
||||||
|
SELECT show_chunks('osm_table');
|
||||||
|
show_chunks
|
||||||
|
-------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
SELECT compress_chunk(:'CHUNK_NAME');
|
||||||
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -878,6 +878,16 @@ WARNING: there was some uncertainty picking the default segment by for the hype
|
|||||||
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
||||||
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
||||||
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
SELECT format('%I.%I',chunk_schema,chunk_name) AS "CHUNK_NAME"
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'osm_table'
|
||||||
|
ORDER BY chunk_name LIMIT 1 \gset
|
||||||
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
SELECT compress_chunk(show_chunks('osm_table'));
|
-- show_chunks should not show any OSM chunks
|
||||||
|
SELECT show_chunks('osm_table');
|
||||||
|
show_chunks
|
||||||
|
-------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
SELECT compress_chunk(:'CHUNK_NAME');
|
||||||
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -878,6 +878,16 @@ WARNING: there was some uncertainty picking the default segment by for the hype
|
|||||||
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
||||||
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
||||||
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
SELECT format('%I.%I',chunk_schema,chunk_name) AS "CHUNK_NAME"
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'osm_table'
|
||||||
|
ORDER BY chunk_name LIMIT 1 \gset
|
||||||
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
SELECT compress_chunk(show_chunks('osm_table'));
|
-- show_chunks should not show any OSM chunks
|
||||||
|
SELECT show_chunks('osm_table');
|
||||||
|
show_chunks
|
||||||
|
-------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
SELECT compress_chunk(:'CHUNK_NAME');
|
||||||
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -878,6 +878,16 @@ WARNING: there was some uncertainty picking the default segment by for the hype
|
|||||||
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
NOTICE: default segment by for hypertable "osm_table" is set to ""
|
||||||
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
NOTICE: default order by for hypertable "osm_table" is set to ""time" DESC"
|
||||||
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
SELECT format('%I.%I',chunk_schema,chunk_name) AS "CHUNK_NAME"
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'osm_table'
|
||||||
|
ORDER BY chunk_name LIMIT 1 \gset
|
||||||
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
SELECT compress_chunk(show_chunks('osm_table'));
|
-- show_chunks should not show any OSM chunks
|
||||||
|
SELECT show_chunks('osm_table');
|
||||||
|
show_chunks
|
||||||
|
-------------
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
|
SELECT compress_chunk(:'CHUNK_NAME');
|
||||||
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
ERROR: compress_chunk not permitted on tiered chunk "_hyper_43_31_chunk"
|
||||||
|
@ -515,6 +515,8 @@ SELECT drop_chunks('hyper_constr', 10::int);
|
|||||||
SELECT id, table_name FROM _timescaledb_catalog.chunk
|
SELECT id, table_name FROM _timescaledb_catalog.chunk
|
||||||
where hypertable_id = (Select id from _timescaledb_catalog.hypertable where table_name = 'hyper_constr')
|
where hypertable_id = (Select id from _timescaledb_catalog.hypertable where table_name = 'hyper_constr')
|
||||||
ORDER BY id;
|
ORDER BY id;
|
||||||
|
-- show_chunks will not show the OSM chunk which is visible via the above query
|
||||||
|
SELECT show_chunks('hyper_constr');
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
CALL run_job(:deljob_id);
|
CALL run_job(:deljob_id);
|
||||||
CALL run_job(:deljob_id);
|
CALL run_job(:deljob_id);
|
||||||
|
@ -511,7 +511,14 @@ ALTER TABLE osm_table SET (timescaledb.compress);
|
|||||||
|
|
||||||
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
INSERT INTO osm_table VALUES ('2022-11-11 11:11:11', 'foo', 1.0);
|
||||||
|
|
||||||
|
SELECT format('%I.%I',chunk_schema,chunk_name) AS "CHUNK_NAME"
|
||||||
|
FROM timescaledb_information.chunks
|
||||||
|
WHERE hypertable_name = 'osm_table'
|
||||||
|
ORDER BY chunk_name LIMIT 1 \gset
|
||||||
|
|
||||||
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
UPDATE _timescaledb_catalog.chunk ch SET osm_chunk = true FROM _timescaledb_catalog.hypertable ht WHERE ch.hypertable_id = ht.id AND ht.table_name='osm_table';
|
||||||
|
|
||||||
SELECT compress_chunk(show_chunks('osm_table'));
|
-- show_chunks should not show any OSM chunks
|
||||||
|
SELECT show_chunks('osm_table');
|
||||||
|
SELECT compress_chunk(:'CHUNK_NAME');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user