From a9751ccd5eb030026d7b975d22753f5964972389 Mon Sep 17 00:00:00 2001 From: Sven Klemm Date: Tue, 29 Aug 2023 10:49:47 +0200 Subject: [PATCH] Move partitioning functions to _timescaledb_functions schema To increase schema security we do not want to mix our own internal objects with user objects. Since chunks are created in the _timescaledb_internal schema our internal functions should live in a different dedicated schema. This patch make the necessary adjustments for the following functions: - get_partition_for_key(val anyelement) - get_partition_hash(val anyelement) --- sql/partitioning.sql | 4 +- sql/updates/latest-dev.sql | 4 + sql/updates/reverse-dev.sql | 5 + src/partitioning.h | 2 +- src/planner/space_constraint.c | 4 +- test/expected/broken_tables.out | 20 ++-- test/expected/chunk_adaptive.out | 6 +- test/expected/chunk_utils.out | 4 +- test/expected/create_chunks.out | 2 +- test/expected/create_hypertable.out | 26 ++--- test/expected/ddl-13.out | 4 +- test/expected/ddl-14.out | 4 +- test/expected/ddl-15.out | 4 +- test/expected/dump_meta.out | 12 +-- test/expected/hash.out | 98 +++++++++---------- test/expected/insert_single.out | 4 +- test/expected/partition.out | 36 +++---- test/expected/partitionwise.out | 30 +++--- test/expected/pg_dump.out | 4 +- test/expected/upsert.out | 2 +- test/sql/chunk_adaptive.sql | 6 +- test/sql/chunk_utils.sql | 4 +- test/sql/create_hypertable.sql | 10 +- test/sql/hash.sql | 98 +++++++++---------- test/sql/partition.sql | 12 +-- test/sql/partitionwise.sql | 2 +- test/sql/upsert.sql | 2 +- test/sql/util.sql | 6 +- tsl/test/expected/bgw_policy.out | 2 +- tsl/test/expected/dist_hypertable-13.out | 92 ++++++++--------- tsl/test/expected/dist_hypertable-14.out | 92 ++++++++--------- tsl/test/expected/dist_hypertable-15.out | 92 ++++++++--------- tsl/test/shared/expected/extension.out | 4 +- .../shared/expected/space_constraint-13.out | 16 +-- .../shared/expected/space_constraint-14.out | 6 +- .../shared/expected/space_constraint-15.out | 6 +- tsl/test/shared/sql/include/shared_setup.sql | 2 +- tsl/test/sql/dist_hypertable.sql.in | 4 +- 38 files changed, 370 insertions(+), 361 deletions(-) diff --git a/sql/partitioning.sql b/sql/partitioning.sql index ad3a6b7bc11..5637ecbd32e 100644 --- a/sql/partitioning.sql +++ b/sql/partitioning.sql @@ -3,11 +3,11 @@ -- LICENSE-APACHE for a copy of the license. -- Deprecated partition hash function -CREATE OR REPLACE FUNCTION _timescaledb_internal.get_partition_for_key(val anyelement) +CREATE OR REPLACE FUNCTION _timescaledb_functions.get_partition_for_key(val anyelement) RETURNS int AS '@MODULE_PATHNAME@', 'ts_get_partition_for_key' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; -CREATE OR REPLACE FUNCTION _timescaledb_internal.get_partition_hash(val anyelement) +CREATE OR REPLACE FUNCTION _timescaledb_functions.get_partition_hash(val anyelement) RETURNS int AS '@MODULE_PATHNAME@', 'ts_get_partition_hash' LANGUAGE C IMMUTABLE STRICT PARALLEL SAFE; diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index 53179ba4caa..f58af14e557 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -150,4 +150,8 @@ ALTER FUNCTION _timescaledb_internal.restart_background_workers() SET SCHEMA _ti ALTER FUNCTION _timescaledb_internal.process_ddl_event() SET SCHEMA _timescaledb_functions; +ALTER FUNCTION _timescaledb_internal.get_partition_for_key(val anyelement) SET SCHEMA _timescaledb_functions; +ALTER FUNCTION _timescaledb_internal.get_partition_hash(val anyelement) SET SCHEMA _timescaledb_functions; + +UPDATE _timescaledb_catalog.dimension SET partitioning_func_schema = '_timescaledb_functions' WHERE partitioning_func_schema = '_timescaledb_internal' AND partitioning_func IN ('get_partition_for_key','get_partition_hash'); diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index d9ee158e2ae..0e9e28bd72e 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -152,3 +152,8 @@ ALTER FUNCTION _timescaledb_functions.process_ddl_event() SET SCHEMA _timescaled ALTER FUNCTION _timescaledb_functions.recompress_chunk_segmentwise(regclass,boolean) SET SCHEMA _timescaledb_internal; ALTER PROCEDURE _timescaledb_functions.wait_subscription_sync(name,name,integer,numeric) SET SCHEMA _timescaledb_internal; +ALTER FUNCTION _timescaledb_functions.get_partition_for_key(val anyelement) SET SCHEMA _timescaledb_internal; +ALTER FUNCTION _timescaledb_functions.get_partition_hash(val anyelement) SET SCHEMA _timescaledb_internal; + +UPDATE _timescaledb_catalog.dimension SET partitioning_func_schema = '_timescaledb_internal' WHERE partitioning_func_schema = '_timescaledb_functions' AND partitioning_func IN ('get_partition_for_key','get_partition_hash'); + diff --git a/src/partitioning.h b/src/partitioning.h index 677831862b4..4fbdcaa6cd2 100644 --- a/src/partitioning.h +++ b/src/partitioning.h @@ -20,7 +20,7 @@ #define OPEN_START_TIME -1 #define OPEN_END_TIME PG_INT64_MAX -#define DEFAULT_PARTITIONING_FUNC_SCHEMA INTERNAL_SCHEMA_NAME +#define DEFAULT_PARTITIONING_FUNC_SCHEMA FUNCTIONS_SCHEMA_NAME #define DEFAULT_PARTITIONING_FUNC_NAME "get_partition_hash" typedef struct PartitioningFunc diff --git a/src/planner/space_constraint.c b/src/planner/space_constraint.c index 5d4b16e41e0..6b49342935e 100644 --- a/src/planner/space_constraint.c +++ b/src/planner/space_constraint.c @@ -182,7 +182,7 @@ make_partfunc_call(Oid funcid, Oid rettype, List *args, Oid inputcollid) /* * Transform a constraint like: device_id = 1 * into - * ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + * ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) */ static OpExpr * transform_space_constraint(PlannerInfo *root, List *rtable, OpExpr *op) @@ -223,7 +223,7 @@ transform_space_constraint(PlannerInfo *root, List *rtable, OpExpr *op) /* * Transforms a constraint like: s1 = ANY ('{s1_2,s1_2}'::text[]) * into - * ((s1 = ANY ('{s1_2,s1_2}'::text[])) AND (_timescaledb_internal.get_partition_hash(s1) = ANY + * ((s1 = ANY ('{s1_2,s1_2}'::text[])) AND (_timescaledb_functions.get_partition_hash(s1) = ANY * ('{1583420735,1583420735}'::integer[]))) */ static ScalarArrayOpExpr * diff --git a/test/expected/broken_tables.out b/test/expected/broken_tables.out index 91c8437c0b7..3a255826b14 100644 --- a/test/expected/broken_tables.out +++ b/test/expected/broken_tables.out @@ -57,13 +57,13 @@ FROM _timescaledb_catalog.chunk_constraint, WHERE conname = constraint_name ) AS con ORDER BY chunk_id, dimension_slice_id; - chunk_id | dimension_slice_id | constraint_name | constraint_expr -----------+--------------------+-----------------+--------------------------------------------------------------- + chunk_id | dimension_slice_id | constraint_name | constraint_expr +----------+--------------------+-----------------+---------------------------------------------------------------- 1 | 1 | constraint_1 | (("time" >= 3) AND ("time" < 6)) - 1 | 2 | constraint_2 | (_timescaledb_internal.get_partition_hash(tag) < 1073741823) + 1 | 2 | constraint_2 | (_timescaledb_functions.get_partition_hash(tag) < 1073741823) 2 | 1 | constraint_1 | (("time" >= 3) AND ("time" < 6)) - 2 | 3 | constraint_3 | (_timescaledb_internal.get_partition_hash(tag) >= 1073741823) - 3 | 3 | constraint_3 | (_timescaledb_internal.get_partition_hash(tag) >= 1073741823) + 2 | 3 | constraint_3 | (_timescaledb_functions.get_partition_hash(tag) >= 1073741823) + 3 | 3 | constraint_3 | (_timescaledb_functions.get_partition_hash(tag) >= 1073741823) 3 | 4 | constraint_4 | (("time" >= 9) AND ("time" < 12)) (6 rows) @@ -102,13 +102,13 @@ FROM _timescaledb_catalog.chunk_constraint, WHERE conname = constraint_name ) AS con ORDER BY chunk_id, dimension_slice_id; - chunk_id | dimension_slice_id | constraint_name | constraint_expr -----------+--------------------+-----------------+--------------------------------------------------------------- + chunk_id | dimension_slice_id | constraint_name | constraint_expr +----------+--------------------+-----------------+---------------------------------------------------------------- 4 | 5 | constraint_5 | (("time" >= 3) AND ("time" < 6)) - 4 | 6 | constraint_6 | (_timescaledb_internal.get_partition_hash(tag) < 1073741823) + 4 | 6 | constraint_6 | (_timescaledb_functions.get_partition_hash(tag) < 1073741823) 5 | 5 | constraint_5 | (("time" >= 3) AND ("time" < 6)) - 5 | 7 | constraint_7 | (_timescaledb_internal.get_partition_hash(tag) >= 1073741823) - 6 | 7 | constraint_7 | (_timescaledb_internal.get_partition_hash(tag) >= 1073741823) + 5 | 7 | constraint_7 | (_timescaledb_functions.get_partition_hash(tag) >= 1073741823) + 6 | 7 | constraint_7 | (_timescaledb_functions.get_partition_hash(tag) >= 1073741823) 6 | 8 | constraint_8 | (("time" >= 9) AND ("time" < 12)) (6 rows) diff --git a/test/expected/chunk_adaptive.out b/test/expected/chunk_adaptive.out index 307f16142ee..2349120cef3 100644 --- a/test/expected/chunk_adaptive.out +++ b/test/expected/chunk_adaptive.out @@ -237,7 +237,7 @@ SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; -- to get determinstic location IDs so that we always spread these -- values the same way across space partitions INSERT INTO test_adaptive -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; @@ -295,7 +295,7 @@ SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; (2 rows) INSERT INTO test_adaptive_no_index -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; @@ -498,7 +498,7 @@ SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; (4 rows) INSERT INTO test_adaptive_space -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; diff --git a/test/expected/chunk_utils.out b/test/expected/chunk_utils.out index 5530a20e161..4d2271c7802 100644 --- a/test/expected/chunk_utils.out +++ b/test/expected/chunk_utils.out @@ -81,13 +81,13 @@ ORDER BY c.id; --------+------+------+------- (0 rows) -SELECT _timescaledb_internal.get_partition_for_key('dev1'::text); +SELECT _timescaledb_functions.get_partition_for_key('dev1'::text); get_partition_for_key ----------------------- 1129986420 (1 row) -SELECT _timescaledb_internal.get_partition_for_key('dev7'::varchar(5)); +SELECT _timescaledb_functions.get_partition_for_key('dev7'::varchar(5)); get_partition_for_key ----------------------- 449729092 diff --git a/test/expected/create_chunks.out b/test/expected/create_chunks.out index d65b3806eae..1b21bd9497c 100644 --- a/test/expected/create_chunks.out +++ b/test/expected/create_chunks.out @@ -84,7 +84,7 @@ SELECT set_chunk_time_interval('chunk_test', 5::bigint); SELECT * FROM _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 2 | 1 | tag | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | tag | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 1 | 1 | time | integer | t | | | | 5 | | | (2 rows) diff --git a/test/expected/create_hypertable.out b/test/expected/create_hypertable.out index 0f4a86a3de7..f96a7cba4b4 100644 --- a/test/expected/create_hypertable.out +++ b/test/expected/create_hypertable.out @@ -95,10 +95,10 @@ select * from _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | bigint | t | | | | 2592000000000 | | | - 2 | 1 | device_id | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device_id | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 3 | 2 | time | bigint | t | | | | 2592000000000 | | | - 4 | 2 | device_id | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | - 5 | 2 | location | text | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 4 | 2 | device_id | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | + 5 | 2 | location | text | f | 4 | _timescaledb_functions | get_partition_hash | | | | (5 rows) --test that we can change the number of partitions and that 1 is allowed @@ -111,7 +111,7 @@ SELECT set_number_partitions('test_schema.test_table', 1, 'location'); select * from _timescaledb_catalog.dimension WHERE column_name = 'location'; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 5 | 2 | location | text | f | 1 | _timescaledb_internal | get_partition_hash | | | | + 5 | 2 | location | text | f | 1 | _timescaledb_functions | get_partition_hash | | | | (1 row) SELECT set_number_partitions('test_schema.test_table', 2, 'location'); @@ -123,7 +123,7 @@ SELECT set_number_partitions('test_schema.test_table', 2, 'location'); select * from _timescaledb_catalog.dimension WHERE column_name = 'location'; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 5 | 2 | location | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 5 | 2 | location | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | (1 row) \set ON_ERROR_STOP 0 @@ -158,10 +158,10 @@ select * from _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | bigint | t | | | | 2592000000000 | | | - 2 | 1 | device_id | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device_id | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 3 | 2 | time | bigint | t | | | | 2592000000000 | | | - 4 | 2 | device_id | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | - 5 | 2 | location | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 4 | 2 | device_id | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | + 5 | 2 | location | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 6 | 2 | id | integer | t | | | | 1000 | | | (6 rows) @@ -636,35 +636,35 @@ CREATE OR REPLACE FUNCTION partfunc_not_immutable(source anyelement) RETURNS INTEGER LANGUAGE PLPGSQL AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; CREATE OR REPLACE FUNCTION partfunc_bad_return_type(source anyelement) RETURNS BIGINT LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; CREATE OR REPLACE FUNCTION partfunc_bad_arg_type(source text) RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; CREATE OR REPLACE FUNCTION partfunc_bad_multi_arg(source anyelement, extra_arg integer) RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; CREATE OR REPLACE FUNCTION partfunc_valid(source anyelement) RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; create table test_schema.test_partfunc(time timestamptz, temp float, device int); diff --git a/test/expected/ddl-13.out b/test/expected/ddl-13.out index a5c61b1e120..ba33a2b5bec 100644 --- a/test/expected/ddl-13.out +++ b/test/expected/ddl-13.out @@ -424,7 +424,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | color | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | color | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time | timestamp with time zone | t | | | | 2628000000000 | | | (2 rows) @@ -478,7 +478,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-----------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | colorname | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | colorname | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time_us | timestamp without time zone | t | | | | 2628000000000 | | | (2 rows) diff --git a/test/expected/ddl-14.out b/test/expected/ddl-14.out index 0c120ed8a21..85aa8ab5297 100644 --- a/test/expected/ddl-14.out +++ b/test/expected/ddl-14.out @@ -424,7 +424,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | color | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | color | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time | timestamp with time zone | t | | | | 2628000000000 | | | (2 rows) @@ -478,7 +478,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-----------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | colorname | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | colorname | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time_us | timestamp without time zone | t | | | | 2628000000000 | | | (2 rows) diff --git a/test/expected/ddl-15.out b/test/expected/ddl-15.out index 0c120ed8a21..85aa8ab5297 100644 --- a/test/expected/ddl-15.out +++ b/test/expected/ddl-15.out @@ -424,7 +424,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | color | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | color | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time | timestamp with time zone | t | | | | 2628000000000 | | | (2 rows) @@ -478,7 +478,7 @@ SELECT * FROM test.show_columnsp('_timescaledb_internal._hyper_9_%chunk'); SELECT * FROM _timescaledb_catalog.dimension WHERE hypertable_id = 9; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-----------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ - 15 | 9 | colorname | character varying | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 15 | 9 | colorname | character varying | f | 2 | _timescaledb_functions | get_partition_hash | | | | 14 | 9 | time_us | timestamp without time zone | t | | | | 2628000000000 | | | (2 rows) diff --git a/test/expected/dump_meta.out b/test/expected/dump_meta.out index 72c1072eabe..7086798f41c 100644 --- a/test/expected/dump_meta.out +++ b/test/expected/dump_meta.out @@ -186,12 +186,12 @@ SELECT *, GROUP BY c.id, pgc.reltoastrelid, pgc.oid ORDER BY c.id ) sub1 ) sub2; - chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes -----------+--------------------------------------------+------------------------+---------------------------+-------------------------------------------------+-------------------------------------------------------------------+-------------+-------------+-------------+------------- - 1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741823,)"} | 8192 | 114688 | 8192 | 131072 - 2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741823,)"} | 8192 | 106496 | 8192 | 122880 - 3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741823,)"} | 8192 | 98304 | 8192 | 114688 - 4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_internal.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[,1073741823)"} | 8192 | 98304 | 8192 | 114688 + chunk_id | chunk_table | partitioning_columns | partitioning_column_types | partitioning_hash_functions | ranges | table_bytes | index_bytes | toast_bytes | total_bytes +----------+--------------------------------------------+------------------------+---------------------------+--------------------------------------------------+-------------------------------------------------------------------+-------------+-------------+-------------+------------- + 1 | "_timescaledb_internal"."_hyper_1_1_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_functions.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[1073741823,)"} | 8192 | 114688 | 8192 | 131072 + 2 | "_timescaledb_internal"."_hyper_1_2_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_functions.get_partition_hash} | {"['1257897600000000000','1257900192000000000')","[1073741823,)"} | 8192 | 106496 | 8192 | 122880 + 3 | "_timescaledb_internal"."_hyper_1_3_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_functions.get_partition_hash} | {"['1257985728000000000','1257988320000000000')","[1073741823,)"} | 8192 | 98304 | 8192 | 114688 + 4 | "_timescaledb_internal"."_hyper_1_4_chunk" | {timeCustom,device_id} | {bigint,text} | {NULL,_timescaledb_functions.get_partition_hash} | {"['1257892416000000000','1257895008000000000')","[,1073741823)"} | 8192 | 98304 | 8192 | 114688 (4 rows) \echo 'Hypertable index sizes' diff --git a/test/expected/hash.out b/test/expected/hash.out index cd27ec70bc3..15166878f85 100644 --- a/test/expected/hash.out +++ b/test/expected/hash.out @@ -3,63 +3,63 @@ -- LICENSE-APACHE for a copy of the license. -- Test hashing Const values. We should expect the same hash value for -- all integer types when values are compatible -SELECT _timescaledb_internal.get_partition_hash(1::int); +SELECT _timescaledb_functions.get_partition_hash(1::int); get_partition_hash -------------------- 242423622 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1::bigint); +SELECT _timescaledb_functions.get_partition_hash(1::bigint); get_partition_hash -------------------- 242423622 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1::smallint); +SELECT _timescaledb_functions.get_partition_hash(1::smallint); get_partition_hash -------------------- 242423622 (1 row) -SELECT _timescaledb_internal.get_partition_hash(true); +SELECT _timescaledb_functions.get_partition_hash(true); get_partition_hash -------------------- 242423622 (1 row) -- Floating point types should also hash the same for compatible values -SELECT _timescaledb_internal.get_partition_hash(1.0::real); +SELECT _timescaledb_functions.get_partition_hash(1.0::real); get_partition_hash -------------------- 376496956 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1.0::double precision); +SELECT _timescaledb_functions.get_partition_hash(1.0::double precision); get_partition_hash -------------------- 376496956 (1 row) -- Float aliases -SELECT _timescaledb_internal.get_partition_hash(1.0::float); +SELECT _timescaledb_functions.get_partition_hash(1.0::float); get_partition_hash -------------------- 376496956 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1.0::float4); +SELECT _timescaledb_functions.get_partition_hash(1.0::float4); get_partition_hash -------------------- 376496956 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1.0::float8); +SELECT _timescaledb_functions.get_partition_hash(1.0::float8); get_partition_hash -------------------- 376496956 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1.0::numeric); +SELECT _timescaledb_functions.get_partition_hash(1.0::numeric); get_partition_hash -------------------- 1324868424 @@ -69,13 +69,13 @@ SELECT _timescaledb_internal.get_partition_hash(1.0::numeric); -- intended for use by the general user. They are included here only -- for completeness -- https://www.postgresql.org/docs/10/static/datatype-character.html#datatype-character-special-table -SELECT _timescaledb_internal.get_partition_hash('c'::name); +SELECT _timescaledb_functions.get_partition_hash('c'::name); get_partition_hash -------------------- 1903644986 (1 row) -SELECT _timescaledb_internal.get_partition_hash('c'::"char"); +SELECT _timescaledb_functions.get_partition_hash('c'::"char"); get_partition_hash -------------------- 203891234 @@ -83,148 +83,148 @@ SELECT _timescaledb_internal.get_partition_hash('c'::"char"); -- String and character hashes should also have the same output for -- compatible values -SELECT _timescaledb_internal.get_partition_hash('c'::char); +SELECT _timescaledb_functions.get_partition_hash('c'::char); get_partition_hash -------------------- 1903644986 (1 row) -SELECT _timescaledb_internal.get_partition_hash('c'::varchar(2)); +SELECT _timescaledb_functions.get_partition_hash('c'::varchar(2)); get_partition_hash -------------------- 1903644986 (1 row) -SELECT _timescaledb_internal.get_partition_hash('c'::text); +SELECT _timescaledb_functions.get_partition_hash('c'::text); get_partition_hash -------------------- 1903644986 (1 row) -- 'c' is 0x63 in ASCII -SELECT _timescaledb_internal.get_partition_hash(E'\\x63'::bytea); +SELECT _timescaledb_functions.get_partition_hash(E'\\x63'::bytea); get_partition_hash -------------------- 1903644986 (1 row) -- Time and date types -SELECT _timescaledb_internal.get_partition_hash(interval '1 day'); +SELECT _timescaledb_functions.get_partition_hash(interval '1 day'); get_partition_hash -------------------- 93502988 (1 row) -SELECT _timescaledb_internal.get_partition_hash('2017-03-22T09:18:23'::timestamp); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22T09:18:23'::timestamp); get_partition_hash -------------------- 307315039 (1 row) -SELECT _timescaledb_internal.get_partition_hash('2017-03-22T09:18:23'::timestamptz); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22T09:18:23'::timestamptz); get_partition_hash -------------------- 1195163597 (1 row) -SELECT _timescaledb_internal.get_partition_hash('2017-03-22'::date); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22'::date); get_partition_hash -------------------- 693590295 (1 row) -SELECT _timescaledb_internal.get_partition_hash('10:00:00'::time); +SELECT _timescaledb_functions.get_partition_hash('10:00:00'::time); get_partition_hash -------------------- 1380652790 (1 row) -SELECT _timescaledb_internal.get_partition_hash('10:00:00-1'::timetz); +SELECT _timescaledb_functions.get_partition_hash('10:00:00-1'::timetz); get_partition_hash -------------------- 769387140 (1 row) -- Other types -SELECT _timescaledb_internal.get_partition_hash(ARRAY[1,2,3]); +SELECT _timescaledb_functions.get_partition_hash(ARRAY[1,2,3]); get_partition_hash -------------------- 1822090118 (1 row) -SELECT _timescaledb_internal.get_partition_hash('08002b:010203'::macaddr); +SELECT _timescaledb_functions.get_partition_hash('08002b:010203'::macaddr); get_partition_hash -------------------- 294987870 (1 row) -SELECT _timescaledb_internal.get_partition_hash('192.168.100.128/25'::cidr); +SELECT _timescaledb_functions.get_partition_hash('192.168.100.128/25'::cidr); get_partition_hash -------------------- 1612896565 (1 row) -SELECT _timescaledb_internal.get_partition_hash('192.168.100.128'::inet); +SELECT _timescaledb_functions.get_partition_hash('192.168.100.128'::inet); get_partition_hash -------------------- 1952516432 (1 row) -SELECT _timescaledb_internal.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1'::inet); +SELECT _timescaledb_functions.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1'::inet); get_partition_hash -------------------- 933321588 (1 row) -SELECT _timescaledb_internal.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'::cidr); +SELECT _timescaledb_functions.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'::cidr); get_partition_hash -------------------- 933321588 (1 row) -SELECT _timescaledb_internal.get_partition_hash('{ "foo": "bar" }'::jsonb); +SELECT _timescaledb_functions.get_partition_hash('{ "foo": "bar" }'::jsonb); get_partition_hash -------------------- 208840587 (1 row) -SELECT _timescaledb_internal.get_partition_hash('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::uuid); +SELECT _timescaledb_functions.get_partition_hash('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::uuid); get_partition_hash -------------------- 504202548 (1 row) -SELECT _timescaledb_internal.get_partition_hash(1::regclass); +SELECT _timescaledb_functions.get_partition_hash(1::regclass); get_partition_hash -------------------- 242423622 (1 row) -SELECT _timescaledb_internal.get_partition_hash(int4range(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(int4range(10, 20)); get_partition_hash -------------------- 1202375768 (1 row) -SELECT _timescaledb_internal.get_partition_hash(int8range(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(int8range(10, 20)); get_partition_hash -------------------- 1202375768 (1 row) -SELECT _timescaledb_internal.get_partition_hash(numrange(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(numrange(10, 20)); get_partition_hash -------------------- 1083987536 (1 row) -SELECT _timescaledb_internal.get_partition_hash(tsrange('2017-03-22T09:18:23', '2017-03-23T09:18:23')); +SELECT _timescaledb_functions.get_partition_hash(tsrange('2017-03-22T09:18:23', '2017-03-23T09:18:23')); get_partition_hash -------------------- 2079608838 (1 row) -SELECT _timescaledb_internal.get_partition_hash(tstzrange('2017-03-22T09:18:23+01', '2017-03-23T09:18:23+00')); +SELECT _timescaledb_functions.get_partition_hash(tstzrange('2017-03-22T09:18:23+01', '2017-03-23T09:18:23+00')); get_partition_hash -------------------- 1255083771 @@ -234,69 +234,69 @@ SELECT _timescaledb_internal.get_partition_hash(tstzrange('2017-03-22T09:18:23+0 CREATE TABLE hash_test(id int, value text); INSERT INTO hash_test VALUES (1, 'test'); -- Test Vars -SELECT _timescaledb_internal.get_partition_hash(id) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(id) FROM hash_test; get_partition_hash -------------------- 242423622 (1 row) -SELECT _timescaledb_internal.get_partition_hash(value) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(value) FROM hash_test; get_partition_hash -------------------- 1771415073 (1 row) -- Test coerced value -SELECT _timescaledb_internal.get_partition_hash(id::text) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(id::text) FROM hash_test; get_partition_hash -------------------- 1516350201 (1 row) -- Test legacy function that converts values to text first -SELECT _timescaledb_internal.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::text); +SELECT _timescaledb_functions.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::text); get_partition_for_key ----------------------- 934882099 (1 row) -SELECT _timescaledb_internal.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::varchar); +SELECT _timescaledb_functions.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::varchar); get_partition_for_key ----------------------- 934882099 (1 row) -SELECT _timescaledb_internal.get_partition_for_key(187); +SELECT _timescaledb_functions.get_partition_for_key(187); get_partition_for_key ----------------------- 1161071810 (1 row) -SELECT _timescaledb_internal.get_partition_for_key(187::bigint); +SELECT _timescaledb_functions.get_partition_for_key(187::bigint); get_partition_for_key ----------------------- 1161071810 (1 row) -SELECT _timescaledb_internal.get_partition_for_key(187::numeric); +SELECT _timescaledb_functions.get_partition_for_key(187::numeric); get_partition_for_key ----------------------- 1161071810 (1 row) -SELECT _timescaledb_internal.get_partition_for_key(187::double precision); +SELECT _timescaledb_functions.get_partition_for_key(187::double precision); get_partition_for_key ----------------------- 1161071810 (1 row) -SELECT _timescaledb_internal.get_partition_for_key(int4range(10, 20)); +SELECT _timescaledb_functions.get_partition_for_key(int4range(10, 20)); get_partition_for_key ----------------------- 505239042 (1 row) -SELECT _timescaledb_internal.get_partition_hash('08002b:010203'::macaddr); +SELECT _timescaledb_functions.get_partition_hash('08002b:010203'::macaddr); get_partition_hash -------------------- 294987870 @@ -304,10 +304,10 @@ SELECT _timescaledb_internal.get_partition_hash('08002b:010203'::macaddr); -- Test inside IMMUTABLE function (Issue #4575) CREATE FUNCTION my_get_partition_hash(INTEGER) RETURNS INTEGER -AS 'SELECT _timescaledb_internal.get_partition_hash($1);' +AS 'SELECT _timescaledb_functions.get_partition_hash($1);' LANGUAGE SQL IMMUTABLE; CREATE FUNCTION my_get_partition_for_key(INTEGER) RETURNS INTEGER -AS 'SELECT _timescaledb_internal.get_partition_for_key($1);' +AS 'SELECT _timescaledb_functions.get_partition_for_key($1);' LANGUAGE SQL IMMUTABLE; SELECT my_get_partition_hash(1); my_get_partition_hash diff --git a/test/expected/insert_single.out b/test/expected/insert_single.out index cf18d8ed827..2f5c7cabcc5 100644 --- a/test/expected/insert_single.out +++ b/test/expected/insert_single.out @@ -307,8 +307,8 @@ SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_7_16_chunk'); Constraint | Type | Columns | Index | Expr | Deferrable | Deferred | Validated ---------------+------+------------+-------+----------------------------------------------------------------------------------------------------------------------------------------------+------------+----------+----------- constraint_16 | c | {time} | - | (("time" >= 'Thu Jan 19 00:00:00 2017'::timestamp without time zone) AND ("time" < 'Thu Jan 26 00:00:00 2017'::timestamp without time zone)) | f | f | t - constraint_17 | c | {device} | - | (_timescaledb_internal.get_partition_hash(device) < 1073741823) | f | f | t - constraint_18 | c | {location} | - | (_timescaledb_internal.get_partition_hash(location) >= 1073741823) | f | f | t + constraint_17 | c | {device} | - | (_timescaledb_functions.get_partition_hash(device) < 1073741823) | f | f | t + constraint_18 | c | {location} | - | (_timescaledb_functions.get_partition_hash(location) >= 1073741823) | f | f | t (3 rows) --queries should work in three dimensions diff --git a/test/expected/partition.out b/test/expected/partition.out index f3e248eca03..d0057efd5cc 100644 --- a/test/expected/partition.out +++ b/test/expected/partition.out @@ -2,7 +2,7 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-APACHE for a copy of the license. CREATE TABLE part_legacy(time timestamptz, temp float, device int); -SELECT create_hypertable('part_legacy', 'time', 'device', 2, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT create_hypertable('part_legacy', 'time', 'device', 2, partitioning_func => '_timescaledb_functions.get_partition_for_key'); NOTICE: adding not-null constraint to column "time" create_hypertable -------------------------- @@ -14,7 +14,7 @@ SELECT * FROM _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 2 | _timescaledb_internal | get_partition_for_key | | | | + 2 | 1 | device | integer | f | 2 | _timescaledb_functions | get_partition_for_key | | | | (2 rows) INSERT INTO part_legacy VALUES ('2017-03-22T09:18:23', 23.4, 1); @@ -25,9 +25,9 @@ SELECT * FROM test.show_constraintsp('_timescaledb_internal._hyper_1_%_chunk'); Table | Constraint | Type | Columns | Index | Expr | Deferrable | Deferred | Validated ----------------------------------------+--------------+------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------+------------+----------+----------- _timescaledb_internal._hyper_1_1_chunk | constraint_1 | c | {time} | - | (("time" >= 'Wed Mar 15 17:00:00 2017 PDT'::timestamp with time zone) AND ("time" < 'Wed Mar 22 17:00:00 2017 PDT'::timestamp with time zone)) | f | f | t - _timescaledb_internal._hyper_1_1_chunk | constraint_2 | c | {device} | - | (_timescaledb_internal.get_partition_for_key(device) >= 1073741823) | f | f | t + _timescaledb_internal._hyper_1_1_chunk | constraint_2 | c | {device} | - | (_timescaledb_functions.get_partition_for_key(device) >= 1073741823) | f | f | t _timescaledb_internal._hyper_1_2_chunk | constraint_1 | c | {time} | - | (("time" >= 'Wed Mar 15 17:00:00 2017 PDT'::timestamp with time zone) AND ("time" < 'Wed Mar 22 17:00:00 2017 PDT'::timestamp with time zone)) | f | f | t - _timescaledb_internal._hyper_1_2_chunk | constraint_3 | c | {device} | - | (_timescaledb_internal.get_partition_for_key(device) < 1073741823) | f | f | t + _timescaledb_internal._hyper_1_2_chunk | constraint_3 | c | {device} | - | (_timescaledb_functions.get_partition_for_key(device) < 1073741823) | f | f | t (4 rows) -- Make sure constraint exclusion works on device column @@ -57,9 +57,9 @@ SELECT * FROM _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 2 | _timescaledb_internal | get_partition_for_key | | | | + 2 | 1 | device | integer | f | 2 | _timescaledb_functions | get_partition_for_key | | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 4 | 2 | device | integer | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 4 | 2 | device | integer | f | 2 | _timescaledb_functions | get_partition_hash | | | | (4 rows) INSERT INTO part_new VALUES ('2017-03-22T09:18:23', 23.4, 1); @@ -70,9 +70,9 @@ SELECT * FROM test.show_constraintsp('_timescaledb_internal._hyper_2_%_chunk'); Table | Constraint | Type | Columns | Index | Expr | Deferrable | Deferred | Validated ----------------------------------------+--------------+------+----------+-------+------------------------------------------------------------------------------------------------------------------------------------------------+------------+----------+----------- _timescaledb_internal._hyper_2_3_chunk | constraint_4 | c | {time} | - | (("time" >= 'Wed Mar 15 17:00:00 2017 PDT'::timestamp with time zone) AND ("time" < 'Wed Mar 22 17:00:00 2017 PDT'::timestamp with time zone)) | f | f | t - _timescaledb_internal._hyper_2_3_chunk | constraint_5 | c | {device} | - | (_timescaledb_internal.get_partition_hash(device) < 1073741823) | f | f | t + _timescaledb_internal._hyper_2_3_chunk | constraint_5 | c | {device} | - | (_timescaledb_functions.get_partition_hash(device) < 1073741823) | f | f | t _timescaledb_internal._hyper_2_4_chunk | constraint_4 | c | {time} | - | (("time" >= 'Wed Mar 15 17:00:00 2017 PDT'::timestamp with time zone) AND ("time" < 'Wed Mar 22 17:00:00 2017 PDT'::timestamp with time zone)) | f | f | t - _timescaledb_internal._hyper_2_4_chunk | constraint_6 | c | {device} | - | (_timescaledb_internal.get_partition_hash(device) >= 1073741823) | f | f | t + _timescaledb_internal._hyper_2_4_chunk | constraint_6 | c | {device} | - | (_timescaledb_functions.get_partition_hash(device) >= 1073741823) | f | f | t (4 rows) -- Make sure constraint exclusion works on device column @@ -126,7 +126,7 @@ NOTICE: adding not-null constraint to column "time" SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => 'bad_func'); ERROR: function "bad_func" does not exist at character 74 \set ON_ERROR_STOP 1 -SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => '_timescaledb_functions.get_partition_for_key'); add_dimension ------------------------------------ (9,public,part_add_dim,location,t) @@ -136,14 +136,14 @@ SELECT * FROM _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-----------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 2 | _timescaledb_internal | get_partition_for_key | | | | + 2 | 1 | device | integer | f | 2 | _timescaledb_functions | get_partition_for_key | | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 4 | 2 | device | integer | f | 2 | _timescaledb_internal | get_partition_hash | | | | - 6 | 3 | temp | double precision | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 4 | 2 | device | integer | f | 2 | _timescaledb_functions | get_partition_hash | | | | + 6 | 3 | temp | double precision | f | 2 | _timescaledb_functions | get_partition_hash | | | | 5 | 3 | time | timestamp without time zone | t | | | | 604800000000 | | | 7 | 4 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 4 | temp | double precision | f | 2 | _timescaledb_internal | get_partition_hash | | | | - 9 | 4 | location | integer | f | 2 | _timescaledb_internal | get_partition_for_key | | | | + 8 | 4 | temp | double precision | f | 2 | _timescaledb_functions | get_partition_hash | | | | + 9 | 4 | location | integer | f | 2 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) -- Test that we support custom SQL-based partitioning functions and @@ -155,7 +155,7 @@ $BODY$ DECLARE retval INTEGER; BEGIN - retval = _timescaledb_internal.get_partition_hash(substring(source::text FROM '[A-za-z0-9 ]+')); + retval = _timescaledb_functions.get_partition_hash(substring(source::text FROM '[A-za-z0-9 ]+')); RAISE NOTICE 'hash value for % is %', source, retval; RETURN retval; END @@ -168,19 +168,19 @@ NOTICE: adding not-null constraint to column "time" (5,public,part_custom_func,t) (1 row) -SELECT _timescaledb_internal.get_partition_hash(substring('dev1' FROM '[A-za-z0-9 ]+')); +SELECT _timescaledb_functions.get_partition_hash(substring('dev1' FROM '[A-za-z0-9 ]+')); get_partition_hash -------------------- 1129986420 (1 row) -SELECT _timescaledb_internal.get_partition_hash('dev1'::text); +SELECT _timescaledb_functions.get_partition_hash('dev1'::text); get_partition_hash -------------------- 1129986420 (1 row) -SELECT _timescaledb_internal.get_partition_hash('dev7'::text); +SELECT _timescaledb_functions.get_partition_hash('dev7'::text); get_partition_hash -------------------- 449729092 diff --git a/test/expected/partitionwise.out b/test/expected/partitionwise.out index 56975ba59d6..c307681a859 100644 --- a/test/expected/partitionwise.out +++ b/test/expected/partitionwise.out @@ -851,34 +851,34 @@ LIMIT 10; -- Should also work to use partitioning function on closed dimensions :PREFIX -SELECT time_func(time), _timescaledb_internal.get_partition_hash(device), avg(temp) +SELECT time_func(time), _timescaledb_functions.get_partition_hash(device), avg(temp) FROM hyper_timepart GROUP BY 1, 2 ORDER BY 1, 2 LIMIT 10; - QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------- + QUERY PLAN +----------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit - Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)), (avg(_hyper_3_7_chunk.temp)) + Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)), (avg(_hyper_3_7_chunk.temp)) -> Merge Append - Sort Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)) + Sort Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)) -> GroupAggregate - Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)), avg(_hyper_3_7_chunk.temp) - Group Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)) + Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)), avg(_hyper_3_7_chunk.temp) + Group Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)) -> Incremental Sort - Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)), _hyper_3_7_chunk.temp - Sort Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device)) + Output: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)), _hyper_3_7_chunk.temp + Sort Key: (time_func(_hyper_3_7_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device)) Presorted Key: (time_func(_hyper_3_7_chunk."time")) -> Index Scan Backward using _hyper_3_7_chunk_hyper_timepart_expr_idx on _timescaledb_internal._hyper_3_7_chunk - Output: time_func(_hyper_3_7_chunk."time"), _timescaledb_internal.get_partition_hash(_hyper_3_7_chunk.device), _hyper_3_7_chunk.temp + Output: time_func(_hyper_3_7_chunk."time"), _timescaledb_functions.get_partition_hash(_hyper_3_7_chunk.device), _hyper_3_7_chunk.temp -> GroupAggregate - Output: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_8_chunk.device)), avg(_hyper_3_8_chunk.temp) - Group Key: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_8_chunk.device)) + Output: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_8_chunk.device)), avg(_hyper_3_8_chunk.temp) + Group Key: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_8_chunk.device)) -> Incremental Sort - Output: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_8_chunk.device)), _hyper_3_8_chunk.temp - Sort Key: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_internal.get_partition_hash(_hyper_3_8_chunk.device)) + Output: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_8_chunk.device)), _hyper_3_8_chunk.temp + Sort Key: (time_func(_hyper_3_8_chunk."time")), (_timescaledb_functions.get_partition_hash(_hyper_3_8_chunk.device)) Presorted Key: (time_func(_hyper_3_8_chunk."time")) -> Index Scan Backward using _hyper_3_8_chunk_hyper_timepart_expr_idx on _timescaledb_internal._hyper_3_8_chunk - Output: time_func(_hyper_3_8_chunk."time"), _timescaledb_internal.get_partition_hash(_hyper_3_8_chunk.device), _hyper_3_8_chunk.temp + Output: time_func(_hyper_3_8_chunk."time"), _timescaledb_functions.get_partition_hash(_hyper_3_8_chunk.device), _hyper_3_8_chunk.temp (22 rows) diff --git a/test/expected/pg_dump.out b/test/expected/pg_dump.out index a7d81c5ba73..a862ab2db83 100644 --- a/test/expected/pg_dump.out +++ b/test/expected/pg_dump.out @@ -156,7 +156,7 @@ SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_1_1_chunk'); ---------------------------------------+------+---------------------------------+---------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------+----------+----------- 1_1_timecustom_device_id_series_2_key | u | {timeCustom,device_id,series_2} | _timescaledb_internal."1_1_timecustom_device_id_series_2_key" | | f | f | t constraint_1 | c | {timeCustom} | - | (("timeCustom" >= '1257892416000000000'::bigint) AND ("timeCustom" < '1257895008000000000'::bigint)) | f | f | t - constraint_2 | c | {device_id} | - | (_timescaledb_internal.get_partition_hash(device_id) >= 1073741823) | f | f | t + constraint_2 | c | {device_id} | - | (_timescaledb_functions.get_partition_hash(device_id) >= 1073741823) | f | f | t (3 rows) SELECT * FROM test.show_triggers('"test_schema"."two_Partitions"'); @@ -410,7 +410,7 @@ SELECT * FROM test.show_constraints('_timescaledb_internal._hyper_1_1_chunk'); ---------------------------------------+------+---------------------------------+---------------------------------------------------------------+------------------------------------------------------------------------------------------------------+------------+----------+----------- 1_1_timecustom_device_id_series_2_key | u | {timeCustom,device_id,series_2} | _timescaledb_internal."1_1_timecustom_device_id_series_2_key" | | f | f | t constraint_1 | c | {timeCustom} | - | (("timeCustom" >= '1257892416000000000'::bigint) AND ("timeCustom" < '1257895008000000000'::bigint)) | f | f | t - constraint_2 | c | {device_id} | - | (_timescaledb_internal.get_partition_hash(device_id) >= 1073741823) | f | f | t + constraint_2 | c | {device_id} | - | (_timescaledb_functions.get_partition_hash(device_id) >= 1073741823) | f | f | t (3 rows) SELECT * FROM test.show_triggers('"test_schema"."two_Partitions"'); diff --git a/test/expected/upsert.out b/test/expected/upsert.out index e1bc8339b68..f96e9be8ba0 100644 --- a/test/expected/upsert.out +++ b/test/expected/upsert.out @@ -144,7 +144,7 @@ CREATE TABLE upsert_test_space(time timestamp, device_id_1 char(20), to_drop int ALTER TABLE upsert_test_space DROP to_drop; ALTER TABLE upsert_test_space DROP device_id_1, ADD device_id char(20); ALTER TABLE upsert_test_space ADD CONSTRAINT time_space_constraint UNIQUE (time, device_id); -SELECT create_hypertable('upsert_test_space', 'time', 'device_id', 2, partitioning_func=>'_timescaledb_internal.get_partition_for_key'::regproc); +SELECT create_hypertable('upsert_test_space', 'time', 'device_id', 2, partitioning_func=>'_timescaledb_functions.get_partition_for_key'::regproc); WARNING: column type "timestamp without time zone" used for "time" does not follow best practices NOTICE: adding not-null constraint to column "time" create_hypertable diff --git a/test/sql/chunk_adaptive.sql b/test/sql/chunk_adaptive.sql index c57bdaa9563..3f8373857f3 100644 --- a/test/sql/chunk_adaptive.sql +++ b/test/sql/chunk_adaptive.sql @@ -127,7 +127,7 @@ SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; -- to get determinstic location IDs so that we always spread these -- values the same way across space partitions INSERT INTO test_adaptive -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; @@ -148,7 +148,7 @@ SELECT create_hypertable('test_adaptive_no_index', 'time', SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; INSERT INTO test_adaptive_no_index -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; @@ -264,7 +264,7 @@ SELECT create_hypertable('test_adaptive_space', 'time', 'location', 2, SELECT id, hypertable_id, interval_length FROM _timescaledb_catalog.dimension; INSERT INTO test_adaptive_space -SELECT time, random() * 35, _timescaledb_internal.get_partition_hash(time) FROM +SELECT time, random() * 35, _timescaledb_functions.get_partition_hash(time) FROM generate_series('2017-03-07T18:18:03+00'::timestamptz - interval '175 days', '2017-03-07T18:18:03+00'::timestamptz, '2 minutes') as time; diff --git a/test/sql/chunk_utils.sql b/test/sql/chunk_utils.sql index 8b60c49042a..19278e97710 100644 --- a/test/sql/chunk_utils.sql +++ b/test/sql/chunk_utils.sql @@ -47,8 +47,8 @@ ORDER BY c.id; \dt "_timescaledb_internal"._hyper* -SELECT _timescaledb_internal.get_partition_for_key('dev1'::text); -SELECT _timescaledb_internal.get_partition_for_key('dev7'::varchar(5)); +SELECT _timescaledb_functions.get_partition_for_key('dev1'::text); +SELECT _timescaledb_functions.get_partition_for_key('dev7'::varchar(5)); INSERT INTO PUBLIC.drop_chunk_test1 VALUES(1, 1.0, 'dev1'); INSERT INTO PUBLIC.drop_chunk_test1 VALUES(2, 2.0, 'dev1'); diff --git a/test/sql/create_hypertable.sql b/test/sql/create_hypertable.sql index 45191a378cd..520746b16a8 100644 --- a/test/sql/create_hypertable.sql +++ b/test/sql/create_hypertable.sql @@ -321,7 +321,7 @@ CREATE OR REPLACE FUNCTION partfunc_not_immutable(source anyelement) RETURNS INTEGER LANGUAGE PLPGSQL AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; @@ -330,7 +330,7 @@ CREATE OR REPLACE FUNCTION partfunc_bad_return_type(source anyelement) RETURNS BIGINT LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; @@ -339,7 +339,7 @@ CREATE OR REPLACE FUNCTION partfunc_bad_arg_type(source text) RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; @@ -348,7 +348,7 @@ CREATE OR REPLACE FUNCTION partfunc_bad_multi_arg(source anyelement, extra_arg i RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; @@ -356,7 +356,7 @@ CREATE OR REPLACE FUNCTION partfunc_valid(source anyelement) RETURNS INTEGER LANGUAGE PLPGSQL IMMUTABLE AS $BODY$ BEGIN - RETURN _timescaledb_internal.get_partition_hash(source); + RETURN _timescaledb_functions.get_partition_hash(source); END $BODY$; diff --git a/test/sql/hash.sql b/test/sql/hash.sql index 0f0d6a730a7..443dbc0bb3d 100644 --- a/test/sql/hash.sql +++ b/test/sql/hash.sql @@ -4,86 +4,86 @@ -- Test hashing Const values. We should expect the same hash value for -- all integer types when values are compatible -SELECT _timescaledb_internal.get_partition_hash(1::int); -SELECT _timescaledb_internal.get_partition_hash(1::bigint); -SELECT _timescaledb_internal.get_partition_hash(1::smallint); -SELECT _timescaledb_internal.get_partition_hash(true); +SELECT _timescaledb_functions.get_partition_hash(1::int); +SELECT _timescaledb_functions.get_partition_hash(1::bigint); +SELECT _timescaledb_functions.get_partition_hash(1::smallint); +SELECT _timescaledb_functions.get_partition_hash(true); -- Floating point types should also hash the same for compatible values -SELECT _timescaledb_internal.get_partition_hash(1.0::real); -SELECT _timescaledb_internal.get_partition_hash(1.0::double precision); +SELECT _timescaledb_functions.get_partition_hash(1.0::real); +SELECT _timescaledb_functions.get_partition_hash(1.0::double precision); -- Float aliases -SELECT _timescaledb_internal.get_partition_hash(1.0::float); -SELECT _timescaledb_internal.get_partition_hash(1.0::float4); -SELECT _timescaledb_internal.get_partition_hash(1.0::float8); -SELECT _timescaledb_internal.get_partition_hash(1.0::numeric); +SELECT _timescaledb_functions.get_partition_hash(1.0::float); +SELECT _timescaledb_functions.get_partition_hash(1.0::float4); +SELECT _timescaledb_functions.get_partition_hash(1.0::float8); +SELECT _timescaledb_functions.get_partition_hash(1.0::numeric); -- 'name' and '"char"' are internal PostgreSQL types, which are not -- intended for use by the general user. They are included here only -- for completeness -- https://www.postgresql.org/docs/10/static/datatype-character.html#datatype-character-special-table -SELECT _timescaledb_internal.get_partition_hash('c'::name); -SELECT _timescaledb_internal.get_partition_hash('c'::"char"); +SELECT _timescaledb_functions.get_partition_hash('c'::name); +SELECT _timescaledb_functions.get_partition_hash('c'::"char"); -- String and character hashes should also have the same output for -- compatible values -SELECT _timescaledb_internal.get_partition_hash('c'::char); -SELECT _timescaledb_internal.get_partition_hash('c'::varchar(2)); -SELECT _timescaledb_internal.get_partition_hash('c'::text); +SELECT _timescaledb_functions.get_partition_hash('c'::char); +SELECT _timescaledb_functions.get_partition_hash('c'::varchar(2)); +SELECT _timescaledb_functions.get_partition_hash('c'::text); -- 'c' is 0x63 in ASCII -SELECT _timescaledb_internal.get_partition_hash(E'\\x63'::bytea); +SELECT _timescaledb_functions.get_partition_hash(E'\\x63'::bytea); -- Time and date types -SELECT _timescaledb_internal.get_partition_hash(interval '1 day'); -SELECT _timescaledb_internal.get_partition_hash('2017-03-22T09:18:23'::timestamp); -SELECT _timescaledb_internal.get_partition_hash('2017-03-22T09:18:23'::timestamptz); -SELECT _timescaledb_internal.get_partition_hash('2017-03-22'::date); -SELECT _timescaledb_internal.get_partition_hash('10:00:00'::time); -SELECT _timescaledb_internal.get_partition_hash('10:00:00-1'::timetz); +SELECT _timescaledb_functions.get_partition_hash(interval '1 day'); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22T09:18:23'::timestamp); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22T09:18:23'::timestamptz); +SELECT _timescaledb_functions.get_partition_hash('2017-03-22'::date); +SELECT _timescaledb_functions.get_partition_hash('10:00:00'::time); +SELECT _timescaledb_functions.get_partition_hash('10:00:00-1'::timetz); -- Other types -SELECT _timescaledb_internal.get_partition_hash(ARRAY[1,2,3]); -SELECT _timescaledb_internal.get_partition_hash('08002b:010203'::macaddr); -SELECT _timescaledb_internal.get_partition_hash('192.168.100.128/25'::cidr); -SELECT _timescaledb_internal.get_partition_hash('192.168.100.128'::inet); -SELECT _timescaledb_internal.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1'::inet); -SELECT _timescaledb_internal.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'::cidr); -SELECT _timescaledb_internal.get_partition_hash('{ "foo": "bar" }'::jsonb); -SELECT _timescaledb_internal.get_partition_hash('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::uuid); -SELECT _timescaledb_internal.get_partition_hash(1::regclass); -SELECT _timescaledb_internal.get_partition_hash(int4range(10, 20)); -SELECT _timescaledb_internal.get_partition_hash(int8range(10, 20)); -SELECT _timescaledb_internal.get_partition_hash(numrange(10, 20)); -SELECT _timescaledb_internal.get_partition_hash(tsrange('2017-03-22T09:18:23', '2017-03-23T09:18:23')); -SELECT _timescaledb_internal.get_partition_hash(tstzrange('2017-03-22T09:18:23+01', '2017-03-23T09:18:23+00')); +SELECT _timescaledb_functions.get_partition_hash(ARRAY[1,2,3]); +SELECT _timescaledb_functions.get_partition_hash('08002b:010203'::macaddr); +SELECT _timescaledb_functions.get_partition_hash('192.168.100.128/25'::cidr); +SELECT _timescaledb_functions.get_partition_hash('192.168.100.128'::inet); +SELECT _timescaledb_functions.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1'::inet); +SELECT _timescaledb_functions.get_partition_hash('2001:4f8:3:ba:2e0:81ff:fe22:d1f1/128'::cidr); +SELECT _timescaledb_functions.get_partition_hash('{ "foo": "bar" }'::jsonb); +SELECT _timescaledb_functions.get_partition_hash('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::uuid); +SELECT _timescaledb_functions.get_partition_hash(1::regclass); +SELECT _timescaledb_functions.get_partition_hash(int4range(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(int8range(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(numrange(10, 20)); +SELECT _timescaledb_functions.get_partition_hash(tsrange('2017-03-22T09:18:23', '2017-03-23T09:18:23')); +SELECT _timescaledb_functions.get_partition_hash(tstzrange('2017-03-22T09:18:23+01', '2017-03-23T09:18:23+00')); -- Test hashing Var values CREATE TABLE hash_test(id int, value text); INSERT INTO hash_test VALUES (1, 'test'); -- Test Vars -SELECT _timescaledb_internal.get_partition_hash(id) FROM hash_test; -SELECT _timescaledb_internal.get_partition_hash(value) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(id) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(value) FROM hash_test; -- Test coerced value -SELECT _timescaledb_internal.get_partition_hash(id::text) FROM hash_test; +SELECT _timescaledb_functions.get_partition_hash(id::text) FROM hash_test; -- Test legacy function that converts values to text first -SELECT _timescaledb_internal.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::text); -SELECT _timescaledb_internal.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::varchar); -SELECT _timescaledb_internal.get_partition_for_key(187); -SELECT _timescaledb_internal.get_partition_for_key(187::bigint); -SELECT _timescaledb_internal.get_partition_for_key(187::numeric); -SELECT _timescaledb_internal.get_partition_for_key(187::double precision); -SELECT _timescaledb_internal.get_partition_for_key(int4range(10, 20)); -SELECT _timescaledb_internal.get_partition_hash('08002b:010203'::macaddr); +SELECT _timescaledb_functions.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::text); +SELECT _timescaledb_functions.get_partition_for_key('4b6a5eec-b344-11e7-abc4-cec278b6b50a'::varchar); +SELECT _timescaledb_functions.get_partition_for_key(187); +SELECT _timescaledb_functions.get_partition_for_key(187::bigint); +SELECT _timescaledb_functions.get_partition_for_key(187::numeric); +SELECT _timescaledb_functions.get_partition_for_key(187::double precision); +SELECT _timescaledb_functions.get_partition_for_key(int4range(10, 20)); +SELECT _timescaledb_functions.get_partition_hash('08002b:010203'::macaddr); -- Test inside IMMUTABLE function (Issue #4575) CREATE FUNCTION my_get_partition_hash(INTEGER) RETURNS INTEGER -AS 'SELECT _timescaledb_internal.get_partition_hash($1);' +AS 'SELECT _timescaledb_functions.get_partition_hash($1);' LANGUAGE SQL IMMUTABLE; CREATE FUNCTION my_get_partition_for_key(INTEGER) RETURNS INTEGER -AS 'SELECT _timescaledb_internal.get_partition_for_key($1);' +AS 'SELECT _timescaledb_functions.get_partition_for_key($1);' LANGUAGE SQL IMMUTABLE; SELECT my_get_partition_hash(1); diff --git a/test/sql/partition.sql b/test/sql/partition.sql index 707a51585c7..c90ba291f0b 100644 --- a/test/sql/partition.sql +++ b/test/sql/partition.sql @@ -3,7 +3,7 @@ -- LICENSE-APACHE for a copy of the license. CREATE TABLE part_legacy(time timestamptz, temp float, device int); -SELECT create_hypertable('part_legacy', 'time', 'device', 2, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT create_hypertable('part_legacy', 'time', 'device', 2, partitioning_func => '_timescaledb_functions.get_partition_for_key'); -- Show legacy partitioning function is used SELECT * FROM _timescaledb_catalog.dimension; @@ -68,7 +68,7 @@ SELECT create_hypertable('part_add_dim', 'time', 'temp', 2); SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => 'bad_func'); \set ON_ERROR_STOP 1 -SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT add_dimension('part_add_dim', 'location', 2, partitioning_func => '_timescaledb_functions.get_partition_for_key'); SELECT * FROM _timescaledb_catalog.dimension; -- Test that we support custom SQL-based partitioning functions and @@ -80,7 +80,7 @@ $BODY$ DECLARE retval INTEGER; BEGIN - retval = _timescaledb_internal.get_partition_hash(substring(source::text FROM '[A-za-z0-9 ]+')); + retval = _timescaledb_functions.get_partition_hash(substring(source::text FROM '[A-za-z0-9 ]+')); RAISE NOTICE 'hash value for % is %', source, retval; RETURN retval; END @@ -89,9 +89,9 @@ $BODY$; CREATE TABLE part_custom_func(time timestamptz, temp float8, device text); SELECT create_hypertable('part_custom_func', 'time', 'device', 2, partitioning_func => 'custom_partfunc'); -SELECT _timescaledb_internal.get_partition_hash(substring('dev1' FROM '[A-za-z0-9 ]+')); -SELECT _timescaledb_internal.get_partition_hash('dev1'::text); -SELECT _timescaledb_internal.get_partition_hash('dev7'::text); +SELECT _timescaledb_functions.get_partition_hash(substring('dev1' FROM '[A-za-z0-9 ]+')); +SELECT _timescaledb_functions.get_partition_hash('dev1'::text); +SELECT _timescaledb_functions.get_partition_hash('dev7'::text); INSERT INTO part_custom_func VALUES ('2017-03-22T09:18:23', 23.4, 'dev1'), ('2017-03-22T09:18:23', 23.4, 'dev7'); diff --git a/test/sql/partitionwise.sql b/test/sql/partitionwise.sql index c3121aa4bd0..f2f7981c439 100644 --- a/test/sql/partitionwise.sql +++ b/test/sql/partitionwise.sql @@ -265,7 +265,7 @@ LIMIT 10; -- Should also work to use partitioning function on closed dimensions :PREFIX -SELECT time_func(time), _timescaledb_internal.get_partition_hash(device), avg(temp) +SELECT time_func(time), _timescaledb_functions.get_partition_hash(device), avg(temp) FROM hyper_timepart GROUP BY 1, 2 ORDER BY 1, 2 diff --git a/test/sql/upsert.sql b/test/sql/upsert.sql index 9e6b42630f2..c65ea712853 100644 --- a/test/sql/upsert.sql +++ b/test/sql/upsert.sql @@ -65,7 +65,7 @@ CREATE TABLE upsert_test_space(time timestamp, device_id_1 char(20), to_drop int ALTER TABLE upsert_test_space DROP to_drop; ALTER TABLE upsert_test_space DROP device_id_1, ADD device_id char(20); ALTER TABLE upsert_test_space ADD CONSTRAINT time_space_constraint UNIQUE (time, device_id); -SELECT create_hypertable('upsert_test_space', 'time', 'device_id', 2, partitioning_func=>'_timescaledb_internal.get_partition_for_key'::regproc); +SELECT create_hypertable('upsert_test_space', 'time', 'device_id', 2, partitioning_func=>'_timescaledb_functions.get_partition_for_key'::regproc); INSERT INTO upsert_test_space (time, device_id, temp, color) VALUES ('2017-01-20T09:00:01', 'dev1', 25.9, 'yellow') RETURNING *; INSERT INTO upsert_test_space (time, device_id, temp, color) VALUES ('2017-01-20T09:00:01', 'dev2', 25.9, 'yellow'); INSERT INTO upsert_test_space (time, device_id, temp, color) VALUES ('2017-01-20T09:00:01', 'dev1', 23.5, 'green') ON CONFLICT (time, device_id) diff --git a/test/sql/util.sql b/test/sql/util.sql index dc379dec370..881b2289e6b 100644 --- a/test/sql/util.sql +++ b/test/sql/util.sql @@ -7,7 +7,7 @@ DO $$ BEGIN - ASSERT( _timescaledb_internal.get_partition_for_key(''::text) = 669664877 ); - ASSERT( _timescaledb_internal.get_partition_for_key('dev1'::text) = 1129986420 ); - ASSERT( _timescaledb_internal.get_partition_for_key('longlonglonglongpartitionkey'::text) = 1169179734); + ASSERT( _timescaledb_functions.get_partition_for_key(''::text) = 669664877 ); + ASSERT( _timescaledb_functions.get_partition_for_key('dev1'::text) = 1129986420 ); + ASSERT( _timescaledb_functions.get_partition_for_key('longlonglonglongpartitionkey'::text) = 1169179734); END$$; diff --git a/tsl/test/expected/bgw_policy.out b/tsl/test/expected/bgw_policy.out index 75d1dd654bf..cd84d710a16 100644 --- a/tsl/test/expected/bgw_policy.out +++ b/tsl/test/expected/bgw_policy.out @@ -591,7 +591,7 @@ select * from _timescaledb_catalog.dimension; id | hypertable_id | column_name | column_type | aligned | num_slices | partitioning_func_schema | partitioning_func | interval_length | compress_interval_length | integer_now_func_schema | integer_now_func ----+---------------+-------------+-----------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | chunk_id | integer | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | chunk_id | integer | f | 2 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time | timestamp without time zone | t | | | | 1 | | | 6 | 5 | time | double precision | t | | new_public | time_partfunc | 1 | | new_public | dummy_now 3 | 2 | time | bigint | t | | | | 1 | | new_public | nowstamp diff --git a/tsl/test/expected/dist_hypertable-13.out b/tsl/test/expected/dist_hypertable-13.out index 873bc08b760..897c14a5157 100644 --- a/tsl/test/expected/dist_hypertable-13.out +++ b/tsl/test/expected/dist_hypertable-13.out @@ -1197,21 +1197,21 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) (18 rows) @@ -1324,26 +1324,26 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) @@ -2214,9 +2214,9 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 4 | _timescaledb_functions | get_partition_hash | | | | (5 rows) SELECT * FROM test.show_triggers('"Table\\Schema"."Param_Table"'); @@ -2249,9 +2249,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2283,9 +2283,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2317,9 +2317,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2419,7 +2419,7 @@ SELECT * FROM dimented_table_slices; 11 | 5 | 9 | 10 | _timescaledb_internal | _dist_hyper_5_11_chunk | -9223372036854775808 | 9223372036854775807 (3 rows) -SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_functions.get_partition_for_key'); dimension_id | schema_name | table_name | column_name | created --------------+-------------+----------------+-------------+--------- 10 | public | dimented_table | column3 | t @@ -2445,13 +2445,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) SELECT * FROM attach_data_node(:'DATA_NODE_2', 'dimented_table'); @@ -2465,13 +2465,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) -- ensure data node has new dimensions @@ -2485,13 +2485,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 6| 4|time |timestamp with time zone|t | | | | 604800000000| | | - 7| 4|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 4|column2 |timestamp with time zone|t | | | | 604800000000| | | - 9| 4|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | + 9| 4|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2502,13 +2502,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 5|time |timestamp with time zone|t | | | | 604800000000| | | - 9| 5|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 9| 5|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 10| 5|column2 |timestamp with time zone|t | | | | 604800000000| | | -11| 5|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | +11| 5|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2519,9 +2519,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -3525,7 +3525,7 @@ id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_sc -- Test adding a space dimension. Should apply to data nodes as -- well. We're setting num_partitions lower than the number of servers -- and expect a warning. -SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_internal.get_partition_hash'); +SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_functions.get_partition_hash'); WARNING: insufficient number of partitions for dimension "device" dimension_id | schema_name | table_name | column_name | created --------------+-------------+------------+-------------+--------- @@ -3543,7 +3543,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3554,7 +3554,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3565,7 +3565,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3609,7 +3609,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3620,7 +3620,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3631,7 +3631,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) diff --git a/tsl/test/expected/dist_hypertable-14.out b/tsl/test/expected/dist_hypertable-14.out index b6a1bc01665..f4b6eea8e9f 100644 --- a/tsl/test/expected/dist_hypertable-14.out +++ b/tsl/test/expected/dist_hypertable-14.out @@ -1201,21 +1201,21 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) (18 rows) @@ -1328,26 +1328,26 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) @@ -2218,9 +2218,9 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 4 | _timescaledb_functions | get_partition_hash | | | | (5 rows) SELECT * FROM test.show_triggers('"Table\\Schema"."Param_Table"'); @@ -2253,9 +2253,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2287,9 +2287,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2321,9 +2321,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2423,7 +2423,7 @@ SELECT * FROM dimented_table_slices; 11 | 5 | 9 | 10 | _timescaledb_internal | _dist_hyper_5_11_chunk | -9223372036854775808 | 9223372036854775807 (3 rows) -SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_functions.get_partition_for_key'); dimension_id | schema_name | table_name | column_name | created --------------+-------------+----------------+-------------+--------- 10 | public | dimented_table | column3 | t @@ -2449,13 +2449,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) SELECT * FROM attach_data_node(:'DATA_NODE_2', 'dimented_table'); @@ -2469,13 +2469,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) -- ensure data node has new dimensions @@ -2489,13 +2489,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 6| 4|time |timestamp with time zone|t | | | | 604800000000| | | - 7| 4|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 4|column2 |timestamp with time zone|t | | | | 604800000000| | | - 9| 4|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | + 9| 4|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2506,13 +2506,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 5|time |timestamp with time zone|t | | | | 604800000000| | | - 9| 5|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 9| 5|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 10| 5|column2 |timestamp with time zone|t | | | | 604800000000| | | -11| 5|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | +11| 5|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2523,9 +2523,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -3532,7 +3532,7 @@ id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_sc -- Test adding a space dimension. Should apply to data nodes as -- well. We're setting num_partitions lower than the number of servers -- and expect a warning. -SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_internal.get_partition_hash'); +SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_functions.get_partition_hash'); WARNING: insufficient number of partitions for dimension "device" dimension_id | schema_name | table_name | column_name | created --------------+-------------+------------+-------------+--------- @@ -3550,7 +3550,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3561,7 +3561,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3572,7 +3572,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3616,7 +3616,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3627,7 +3627,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3638,7 +3638,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) diff --git a/tsl/test/expected/dist_hypertable-15.out b/tsl/test/expected/dist_hypertable-15.out index f6280de1ebe..f65ca9fd0a0 100644 --- a/tsl/test/expected/dist_hypertable-15.out +++ b/tsl/test/expected/dist_hypertable-15.out @@ -1207,21 +1207,21 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) (18 rows) @@ -1334,26 +1334,26 @@ FROM test.show_subtables('disttable') st; chunk_relid | show_constraints ---------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_1_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_1_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_2_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_2_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_1,c,{time},-,"((""time"" >= 'Wed Dec 28 16:00:00 2016 PST'::timestamp with time zone) AND (""time"" < 'Wed Jan 04 16:00:00 2017 PST'::timestamp with time zone))",f,f,t) - _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_3_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_3_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) < 715827882)",f,f,t) + _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_2,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) < 715827882)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_4_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_internal.get_partition_hash(device) >= 715827882) AND (_timescaledb_internal.get_partition_hash(device) < 1431655764))",f,f,t) + _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_4,c,{device},-,"((_timescaledb_functions.get_partition_hash(device) >= 715827882) AND (_timescaledb_functions.get_partition_hash(device) < 1431655764))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_5_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) - _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_internal.get_partition_hash(device) >= 1431655764)",f,f,t) + _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_3,c,{device},-,"(_timescaledb_functions.get_partition_hash(device) >= 1431655764)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (constraint_5,c,{time},-,"((""time"" >= 'Wed Jun 27 17:00:00 2018 PDT'::timestamp with time zone) AND (""time"" < 'Wed Jul 04 17:00:00 2018 PDT'::timestamp with time zone))",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_device_check,c,{device},-,"(device > 0)",f,f,t) _timescaledb_internal._dist_hyper_1_6_chunk | (disttable_temp_non_negative,c,{temp},-,"(temp > (0.0)::double precision)",f,f,t) @@ -2224,9 +2224,9 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+--------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 4 | _timescaledb_functions | get_partition_hash | | | | (5 rows) SELECT * FROM test.show_triggers('"Table\\Schema"."Param_Table"'); @@ -2259,9 +2259,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2293,9 +2293,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2327,9 +2327,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -2429,7 +2429,7 @@ SELECT * FROM dimented_table_slices; 11 | 5 | 9 | 10 | _timescaledb_internal | _dist_hyper_5_11_chunk | -9223372036854775808 | 9223372036854775807 (3 rows) -SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_functions.get_partition_for_key'); dimension_id | schema_name | table_name | column_name | created --------------+-------------+----------------+-------------+--------- 10 | public | dimented_table | column3 | t @@ -2455,13 +2455,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) SELECT * FROM attach_data_node(:'DATA_NODE_2', 'dimented_table'); @@ -2475,13 +2475,13 @@ SELECT * FROM _timescaledb_catalog.dimension; ----+---------------+------------------+--------------------------+---------+------------+--------------------------+-----------------------+-----------------+--------------------------+-------------------------+------------------ 1 | 1 | time | timestamp with time zone | t | | | | 604800000000 | | | 3 | 2 | time | timestamp with time zone | t | | | | 604800000000 | | | - 2 | 1 | device | integer | f | 3 | _timescaledb_internal | get_partition_hash | | | | + 2 | 1 | device | integer | f | 3 | _timescaledb_functions | get_partition_hash | | | | 5 | 4 | time Col %#^#@$# | timestamp with time zone | t | | | | 604800000000 | | | - 6 | 4 | __region | text | f | 2 | _timescaledb_internal | get_partition_hash | | | | + 6 | 4 | __region | text | f | 2 | _timescaledb_functions | get_partition_hash | | | | 7 | 5 | time | timestamp with time zone | t | | | | 604800000000 | | | - 8 | 5 | column1 | integer | f | 4 | _timescaledb_internal | get_partition_hash | | | | + 8 | 5 | column1 | integer | f | 4 | _timescaledb_functions | get_partition_hash | | | | 9 | 5 | column2 | timestamp with time zone | t | | | | 604800000000 | | | - 10 | 5 | column3 | integer | f | 4 | _timescaledb_internal | get_partition_for_key | | | | + 10 | 5 | column3 | integer | f | 4 | _timescaledb_functions | get_partition_for_key | | | | (9 rows) -- ensure data node has new dimensions @@ -2495,13 +2495,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 6| 4|time |timestamp with time zone|t | | | | 604800000000| | | - 7| 4|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 4|column2 |timestamp with time zone|t | | | | 604800000000| | | - 9| 4|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | + 9| 4|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2512,13 +2512,13 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+---------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash | | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash | | | | 6| 4|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 7| 4|__region |text |f | 4|_timescaledb_internal |get_partition_hash | | | | + 7| 4|__region |text |f | 4|_timescaledb_functions |get_partition_hash | | | | 8| 5|time |timestamp with time zone|t | | | | 604800000000| | | - 9| 5|column1 |integer |f | 4|_timescaledb_internal |get_partition_hash | | | | + 9| 5|column1 |integer |f | 4|_timescaledb_functions |get_partition_hash | | | | 10| 5|column2 |timestamp with time zone|t | | | | 604800000000| | | -11| 5|column3 |integer |f | 4|_timescaledb_internal |get_partition_for_key| | | | +11| 5|column3 |integer |f | 4|_timescaledb_functions |get_partition_for_key| | | | (9 rows) @@ -2529,9 +2529,9 @@ id|hypertable_id|column_name |column_type |aligned|num_slices|pa --+-------------+----------------+------------------------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- 1| 1|time |timestamp with time zone|t | | | | 604800000000| | | 3| 2|time |timestamp with time zone|t | | | | 604800000000| | | - 2| 1|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | + 2| 1|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 4| 3|time Col %#^#@$#|timestamp with time zone|t | | | | 604800000000| | | - 5| 3|__region |text |f | 4|_timescaledb_internal |get_partition_hash| | | | + 5| 3|__region |text |f | 4|_timescaledb_functions |get_partition_hash| | | | (5 rows) @@ -3538,7 +3538,7 @@ id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_sc -- Test adding a space dimension. Should apply to data nodes as -- well. We're setting num_partitions lower than the number of servers -- and expect a warning. -SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_internal.get_partition_hash'); +SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_functions.get_partition_hash'); WARNING: insufficient number of partitions for dimension "device" dimension_id | schema_name | table_name | column_name | created --------------+-------------+------------+-------------+--------- @@ -3556,7 +3556,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3567,7 +3567,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3578,7 +3578,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 1|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 1|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 1000000| | | (2 rows) @@ -3622,7 +3622,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_1]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3633,7 +3633,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_2]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -21| 11|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +21| 11|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 20| 11|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) @@ -3644,7 +3644,7 @@ WHERE h.id = d.hypertable_id AND h.table_name = 'disttable' NOTICE: [db_dist_hypertable_3]: id|hypertable_id|column_name|column_type|aligned|num_slices|partitioning_func_schema|partitioning_func |interval_length|compress_interval_length|integer_now_func_schema|integer_now_func --+-------------+-----------+-----------+-------+----------+------------------------+------------------+---------------+------------------------+-----------------------+---------------- -15| 9|device |integer |f | 3|_timescaledb_internal |get_partition_hash| | | | +15| 9|device |integer |f | 3|_timescaledb_functions |get_partition_hash| | | | 14| 9|time |bigint |t | | | | 2000000000| |public |dummy_now (2 rows) diff --git a/tsl/test/shared/expected/extension.out b/tsl/test/shared/expected/extension.out index 66b32bd2edd..3949a415a95 100644 --- a/tsl/test/shared/expected/extension.out +++ b/tsl/test/shared/expected/extension.out @@ -77,6 +77,8 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text _timescaledb_functions.get_create_command(name) _timescaledb_functions.get_git_commit() _timescaledb_functions.get_os_info() + _timescaledb_functions.get_partition_for_key(anyelement) + _timescaledb_functions.get_partition_hash(anyelement) _timescaledb_functions.health() _timescaledb_functions.hist_combinefunc(internal,internal) _timescaledb_functions.hist_deserializefunc(bytea,internal) @@ -142,8 +144,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text _timescaledb_internal.finalize_agg(text,name,name,name[],bytea,anyelement) _timescaledb_internal.finalize_agg_ffunc(internal,text,name,name,name[],bytea,anyelement) _timescaledb_internal.finalize_agg_sfunc(internal,text,name,name,name[],bytea,anyelement) - _timescaledb_internal.get_partition_for_key(anyelement) - _timescaledb_internal.get_partition_hash(anyelement) _timescaledb_internal.partialize_agg(anyelement) debug_waitpoint_enable(text) debug_waitpoint_id(text) diff --git a/tsl/test/shared/expected/space_constraint-13.out b/tsl/test/shared/expected/space_constraint-13.out index cea0c66ec4a..33e29592267 100644 --- a/tsl/test/shared/expected/space_constraint-13.out +++ b/tsl/test/shared/expected/space_constraint-13.out @@ -226,13 +226,13 @@ QUERY PLAN Delete on _hyper_X_X_chunk metrics_space_2 Delete on _hyper_X_X_chunk metrics_space_3 -> Seq Scan on metrics_space - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_1 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_2 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_3 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) (13 rows) :PREFIX DELETE FROM metrics_space WHERE device_id = 1 AND device_id = 2; @@ -245,19 +245,19 @@ QUERY PLAN -> Result One-Time Filter: (false AND false) -> Seq Scan on metrics_space - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Result One-Time Filter: (false AND false) -> Seq Scan on _hyper_X_X_chunk metrics_space_1 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Result One-Time Filter: (false AND false) -> Seq Scan on _hyper_X_X_chunk metrics_space_2 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Result One-Time Filter: (false AND false) -> Seq Scan on _hyper_X_X_chunk metrics_space_3 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) (21 rows) :PREFIX DELETE FROM metrics_space WHERE device_id = 1 OR device_id = 2; diff --git a/tsl/test/shared/expected/space_constraint-14.out b/tsl/test/shared/expected/space_constraint-14.out index 1e34e46a1c4..36adc1b08b2 100644 --- a/tsl/test/shared/expected/space_constraint-14.out +++ b/tsl/test/shared/expected/space_constraint-14.out @@ -223,11 +223,11 @@ QUERY PLAN Delete on _hyper_X_X_chunk metrics_space_3 -> Append -> Seq Scan on _hyper_X_X_chunk metrics_space_1 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_2 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_3 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) (12 rows) :PREFIX DELETE FROM metrics_space WHERE device_id = 1 AND device_id = 2; diff --git a/tsl/test/shared/expected/space_constraint-15.out b/tsl/test/shared/expected/space_constraint-15.out index 1e34e46a1c4..36adc1b08b2 100644 --- a/tsl/test/shared/expected/space_constraint-15.out +++ b/tsl/test/shared/expected/space_constraint-15.out @@ -223,11 +223,11 @@ QUERY PLAN Delete on _hyper_X_X_chunk metrics_space_3 -> Append -> Seq Scan on _hyper_X_X_chunk metrics_space_1 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_2 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) -> Seq Scan on _hyper_X_X_chunk metrics_space_3 - Filter: ((device_id = 1) AND (_timescaledb_internal.get_partition_hash(device_id) = 242423622)) + Filter: ((device_id = 1) AND (_timescaledb_functions.get_partition_hash(device_id) = 242423622)) (12 rows) :PREFIX DELETE FROM metrics_space WHERE device_id = 1 AND device_id = 2; diff --git a/tsl/test/shared/sql/include/shared_setup.sql b/tsl/test/shared/sql/include/shared_setup.sql index 65e9a09bad8..1a82e93eeb9 100644 --- a/tsl/test/shared/sql/include/shared_setup.sql +++ b/tsl/test/shared/sql/include/shared_setup.sql @@ -259,7 +259,7 @@ ALTER TABLE dist_chunk_copy SET (timescaledb.compress); SELECT setseed(0); INSERT INTO dist_chunk_copy -SELECT t, ceil(_timescaledb_internal.get_partition_hash(t)::int % 5), random() * 20 +SELECT t, ceil(_timescaledb_functions.get_partition_hash(t)::int % 5), random() * 20 FROM generate_series('2020-01-01'::timestamp, '2020-01-25'::timestamp, '1d') t; -- Compress a few chunks of this dist_chunk_copy hypertable diff --git a/tsl/test/sql/dist_hypertable.sql.in b/tsl/test/sql/dist_hypertable.sql.in index a3bda50d110..860f2681f45 100644 --- a/tsl/test/sql/dist_hypertable.sql.in +++ b/tsl/test/sql/dist_hypertable.sql.in @@ -734,7 +734,7 @@ SELECT * FROM dimented_table_slices; SELECT * FROM add_dimension('dimented_table', 'column2', chunk_time_interval => interval '1 week'); SELECT * FROM dimented_table_slices; -SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_internal.get_partition_for_key'); +SELECT * FROM add_dimension('dimented_table', 'column3', 4, partitioning_func => '_timescaledb_functions.get_partition_for_key'); SELECT * FROM dimented_table_slices; SELECT * FROM dimented_table ORDER BY time; @@ -1004,7 +1004,7 @@ $$); -- Test adding a space dimension. Should apply to data nodes as -- well. We're setting num_partitions lower than the number of servers -- and expect a warning. -SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_internal.get_partition_hash'); +SELECT * FROM add_dimension('disttable', 'device', 1, partitioning_func => '_timescaledb_functions.get_partition_hash'); CREATE INDEX disttable_device_time_idx ON disttable (device, time); SELECT * FROM test.remote_exec(ARRAY[:'DATA_NODE_1', :'DATA_NODE_2', :'DATA_NODE_3'], $$