Skip to content

Commit

Permalink
Draft PR
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziomello committed Oct 6, 2023
1 parent b514d05 commit 7d34107
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
12 changes: 2 additions & 10 deletions sql/compat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,8 @@ BEGIN
END$$
SET search_path TO pg_catalog,pg_temp;


CREATE OR REPLACE FUNCTION _timescaledb_internal.continuous_agg_invalidation_trigger() RETURNS trigger LANGUAGE PLPGSQL AS $$
BEGIN
IF current_setting('timescaledb.enable_deprecation_warnings', true)::bool THEN
RAISE WARNING 'function _timescaledb_internal.continuous_agg_invalidation_trigger() is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.';
END IF;
RETURN _timescaledb_functions.continuous_agg_invalidation_trigger();
END$$
SET search_path TO pg_catalog,pg_temp;

CREATE OR REPLACE FUNCTION _timescaledb_internal.continuous_agg_invalidation_trigger() RETURNS TRIGGER
AS '@MODULE_PATHNAME@', 'ts_continuous_agg_invalidation_trigger' LANGUAGE C;

-- we have to prefix slices, schema_name and table_name parameter with _ here to not clash with output names otherwise plpgsql will complain
CREATE OR REPLACE FUNCTION _timescaledb_internal.create_chunk(hypertable regclass,_slices jsonb,_schema_name name=NULL,_table_name name=NULL,chunk_table regclass=NULL) RETURNS TABLE(chunk_id INTEGER, hypertable_id INTEGER, schema_name NAME, table_name NAME, relkind "char", slices JSONB, created BOOLEAN) LANGUAGE PLPGSQL AS $$
Expand Down
2 changes: 1 addition & 1 deletion src/guc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern bool ts_telemetry_on(void);
extern bool ts_function_telemetry_on(void);
#endif

extern bool ts_guc_enable_deprecation_warnings;
extern TSDLLEXPORT bool ts_guc_enable_deprecation_warnings;
extern bool ts_guc_enable_optimizations;
extern bool ts_guc_enable_constraint_aware_append;
extern bool ts_guc_enable_ordered_append;
Expand Down
10 changes: 10 additions & 0 deletions tsl/src/continuous_aggs/insert.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

#include "chunk.h"
#include "dimension.h"
#include "guc.h"
#include "hypertable.h"
#include "hypertable_cache.h"
#include "invalidation.h"
Expand Down Expand Up @@ -222,6 +223,15 @@ continuous_agg_trigfn(PG_FUNCTION_ARGS)
if (trigdata == NULL || trigdata->tg_trigger == NULL || trigdata->tg_trigger->tgnargs < 0)
elog(ERROR, "must supply hypertable id");

if (ts_guc_enable_deprecation_warnings && OidIsValid(trigdata->tg_trigger->tgfoid) &&
strncmp(get_namespace_name(get_func_namespace(trigdata->tg_trigger->tgfoid)),
INTERNAL_SCHEMA_NAME,
strlen(INTERNAL_SCHEMA_NAME)) == 0)
elog(WARNING,
"function _timescaledb_internal.continuous_agg_invalidation_trigger() is deprecated "
"and has been moved to _timescaledb_functions schema. this compatibility function "
"will be removed in a future version.");

hypertable_id_str = trigdata->tg_trigger->tgargs[0];
hypertable_id = atol(hypertable_id_str);

Expand Down
2 changes: 2 additions & 0 deletions tsl/test/shared/expected/compat.out
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ ERROR: hypertable cannot be NULL
SELECT _timescaledb_internal.create_compressed_chunk(0,0,0,0,0,0,0,0,0,0);
WARNING: function _timescaledb_internal.create_compressed_chunk(regclass,regclass,bigint,bigint,bigint,bigint,bigint,bigint,bigint,bigint) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
ERROR: invalid Oid
SELECT _timescaledb_internal.continuous_agg_invalidation_trigger();
ERROR: must supply hypertable id
SELECT _timescaledb_internal.data_node_chunk_info(NULL,NULL,NULL);
WARNING: function _timescaledb_internal.data_node_chunk_info(name,name,name) is deprecated and has been moved to _timescaledb_functions schema. this compatibility function will be removed in a future version.
data_node_chunk_info
Expand Down
1 change: 1 addition & 0 deletions tsl/test/shared/sql/compat.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SELECT _timescaledb_internal.create_chunk(0,NULL,NULL,NULL,0);
SELECT _timescaledb_internal.create_chunk_replica_table(0,NULL);
SELECT _timescaledb_internal.create_chunk_table(0,NULL,NULL,NULL);
SELECT _timescaledb_internal.create_compressed_chunk(0,0,0,0,0,0,0,0,0,0);
SELECT _timescaledb_internal.continuous_agg_invalidation_trigger();
SELECT _timescaledb_internal.data_node_chunk_info(NULL,NULL,NULL);
SELECT _timescaledb_internal.data_node_compressed_chunk_stats(NULL,NULL,NULL);
SELECT _timescaledb_internal.data_node_hypertable_info(NULL,NULL,NULL);
Expand Down

0 comments on commit 7d34107

Please sign in to comment.