timescale/promscale_extension

SQL API drop_metric does not check if views exist before attempting to drop them

Opened this issue · 1 comments

The function set_metric_retention_period creates tables prom_data_series.<metric_name> and prom_data.<metric_name> but not views prom_series.<metric_name> or prom_metric.<metric_name>.

The function drop_metric attempts to drop views prom_series.<metric_name> and prom_metric.<metric_name> without first checking if they exist and ultimately fails.

Steps to reproduce:

select set_metric_retention_period('my_test_metric', 365 * INTERVAL '1 day');
select drop_metric('my_test_metric');

Error returned:

NOTICE:  deleting "my_test_metric" metric with metric_id as "21243" and table_name as "my_test_metric"
ERROR:  view "my_test_metric" does not exist
CONTEXT:  SQL statement "DROP VIEW prom_series.my_test_metric;"
PL/pgSQL function prom_api.drop_metric(text) line 15 at EXECUTE

Versions affected:
0.11.0

This is related to #74