diff --git a/cmake/ScriptFiles.cmake b/cmake/ScriptFiles.cmake index e0cff8d8f93..b5c19b023af 100644 --- a/cmake/ScriptFiles.cmake +++ b/cmake/ScriptFiles.cmake @@ -16,18 +16,20 @@ set(PRE_INSTALL_SOURCE_FILES pre_install/types.post.sql # Must be before tables.sql pre_install/tables.sql pre_install/cache.sql + pre_install/tam.functions.sql + pre_install/tam.sql pre_install/insert_data.sql) # Source files that define functions and need to be rerun in update set(PRE_INSTALL_FUNCTION_FILES pre_install/types.functions.sql + pre_install/tam.functions.sql ) # The rest of the source files defining mostly functions set(SOURCE_FILES hypertable.sql chunk.sql - hypercore.sql ddl_internal.sql util_time.sql util_internal_table_ddl.sql diff --git a/scripts/check_updates_ast.py b/scripts/check_updates_ast.py index 2ea4a05edf9..b6b7a73ac69 100644 --- a/scripts/check_updates_ast.py +++ b/scripts/check_updates_ast.py @@ -161,6 +161,8 @@ def visit_CreateFunctionStmt( lang and lang[0].arg.sval == "c" and code[-1].sval != "ts_update_placeholder" + and node.returnType.names[0].sval + not in ["table_am_handler", "index_am_handler"] ): self.errors += 1 functype = "procedure" if node.is_procedure else "function" diff --git a/sql/pre_install/tam.functions.sql b/sql/pre_install/tam.functions.sql new file mode 100644 index 00000000000..bbbb6d6b79f --- /dev/null +++ b/sql/pre_install/tam.functions.sql @@ -0,0 +1,10 @@ +-- This file and its contents are licensed under the Apache License 2.0. +-- Please see the included NOTICE for copyright information and +-- LICENSE-APACHE for a copy of the license. + +CREATE OR REPLACE FUNCTION @extschema@.ts_hypercore_handler(internal) RETURNS table_am_handler +AS '@MODULE_PATHNAME@', 'ts_hypercore_handler' LANGUAGE C; + +CREATE OR REPLACE FUNCTION @extschema@.ts_hypercore_proxy_handler(internal) RETURNS index_am_handler +AS '@MODULE_PATHNAME@', 'ts_hypercore_proxy_handler' LANGUAGE C; + diff --git a/sql/hypercore.sql b/sql/pre_install/tam.sql similarity index 66% rename from sql/hypercore.sql rename to sql/pre_install/tam.sql index 5fe85bfd785..9241e29bbd0 100644 --- a/sql/hypercore.sql +++ b/sql/pre_install/tam.sql @@ -2,16 +2,10 @@ -- Please see the included NOTICE for copyright information and -- LICENSE-APACHE for a copy of the license. -CREATE FUNCTION ts_hypercore_handler(internal) RETURNS table_am_handler -AS '@MODULE_PATHNAME@', 'ts_hypercore_handler' LANGUAGE C; - -CREATE ACCESS METHOD hypercore TYPE TABLE HANDLER ts_hypercore_handler; +CREATE ACCESS METHOD hypercore TYPE TABLE HANDLER @extschema@.ts_hypercore_handler; COMMENT ON ACCESS METHOD hypercore IS 'Storage engine using hybrid row/columnar compression'; -CREATE FUNCTION ts_hypercore_proxy_handler(internal) RETURNS index_am_handler -AS '@MODULE_PATHNAME@', 'ts_hypercore_proxy_handler' LANGUAGE C; - -CREATE ACCESS METHOD hypercore_proxy TYPE INDEX HANDLER ts_hypercore_proxy_handler; +CREATE ACCESS METHOD hypercore_proxy TYPE INDEX HANDLER @extschema@.ts_hypercore_proxy_handler; COMMENT ON ACCESS METHOD hypercore_proxy IS 'Hypercore proxy index access method'; -- An index AM needs at least one operator class for the column type diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql index 5863834971c..49788b504e8 100644 --- a/sql/updates/latest-dev.sql +++ b/sql/updates/latest-dev.sql @@ -153,3 +153,20 @@ CREATE PROCEDURE @extschema@.merge_chunks( CREATE PROCEDURE @extschema@.merge_chunks( chunks REGCLASS[] ) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder'; + +CREATE FUNCTION @extschema@.ts_hypercore_handler(internal) RETURNS table_am_handler +AS '@MODULE_PATHNAME@', 'ts_hypercore_handler' LANGUAGE C; + +CREATE FUNCTION @extschema@.ts_hypercore_proxy_handler(internal) RETURNS index_am_handler +AS '@MODULE_PATHNAME@', 'ts_hypercore_proxy_handler' LANGUAGE C; + +CREATE ACCESS METHOD hypercore TYPE TABLE HANDLER @extschema@.ts_hypercore_handler; +COMMENT ON ACCESS METHOD hypercore IS 'Storage engine using hybrid row/columnar compression'; + +CREATE ACCESS METHOD hypercore_proxy TYPE INDEX HANDLER @extschema@.ts_hypercore_proxy_handler; +COMMENT ON ACCESS METHOD hypercore_proxy IS 'Hypercore proxy index access method'; + +CREATE OPERATOR CLASS int4_ops +DEFAULT FOR TYPE int4 USING hypercore_proxy AS + OPERATOR 1 = (int4, int4), + FUNCTION 1 hashint4(int4); diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql index 89c7935ebbf..bc918202f24 100644 --- a/sql/updates/reverse-dev.sql +++ b/sql/updates/reverse-dev.sql @@ -1,8 +1,8 @@ -- Hypercore AM DROP ACCESS METHOD IF EXISTS hypercore_proxy; -DROP FUNCTION IF EXISTS ts_hypercore_proxy_handler; +DROP FUNCTION IF EXISTS @extschema@.ts_hypercore_proxy_handler; DROP ACCESS METHOD IF EXISTS hypercore; -DROP FUNCTION IF EXISTS ts_hypercore_handler; +DROP FUNCTION IF EXISTS @extschema@.ts_hypercore_handler; DROP FUNCTION IF EXISTS _timescaledb_debug.is_compressed_tid; DROP FUNCTION IF EXISTS @extschema@.compress_chunk(uncompressed_chunk REGCLASS, if_not_compressed BOOLEAN, recompress BOOLEAN, hypercore_use_access_method BOOL); diff --git a/tsl/test/shared/expected/extension.out b/tsl/test/shared/expected/extension.out index 310d4ba836c..f3fd30c1c84 100644 --- a/tsl/test/shared/expected/extension.out +++ b/tsl/test/shared/expected/extension.out @@ -208,8 +208,6 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text debug_waitpoint_enable(text) debug_waitpoint_id(text) debug_waitpoint_release(text) - ts_hypercore_handler(internal) - ts_hypercore_proxy_handler(internal) ts_now_mock() add_columnstore_policy(regclass,"any",boolean,interval,timestamp with time zone,text,interval,boolean) add_compression_policy(regclass,"any",boolean,interval,timestamp with time zone,text,interval,boolean) @@ -300,6 +298,8 @@ ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text time_bucket_gapfill(smallint,smallint,smallint,smallint) timescaledb_post_restore() timescaledb_pre_restore() + ts_hypercore_handler(internal) + ts_hypercore_proxy_handler(internal) timescaledb_experimental.add_policies(regclass,boolean,"any","any","any","any",boolean) timescaledb_experimental.alter_policies(regclass,boolean,"any","any","any","any") timescaledb_experimental.remove_all_policies(regclass,boolean)