Skip to content

Commit

Permalink
Fix TAM handling in update script
Browse files Browse the repository at this point in the history
The TAM SQL code was not written with update and downgrade scripts
in mind prevents further releases past 2.18.0 due to not splitting
up the parts that need to be part of every update script and those
that can only run once during initial installation.
  • Loading branch information
svenklemm committed Jan 23, 2025
1 parent bbf183c commit 96ab6b7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 8 deletions.
7 changes: 5 additions & 2 deletions cmake/ScriptFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ set(PRE_INSTALL_SOURCE_FILES
pre_install/types.functions.sql
pre_install/types.post.sql # Must be before tables.sql
pre_install/tables.sql
pre_install/tam_functions.sql
pre_install/tam.sql
pre_install/cache.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
Expand Down Expand Up @@ -56,7 +58,8 @@ set(SOURCE_FILES
cagg_migrate.sql
job_stat_history_log_retention.sql
osm_api.sql
compression_defaults.sql)
compression_defaults.sql
)

if(ENABLE_DEBUG_UTILS AND CMAKE_BUILD_TYPE MATCHES Debug)
list(APPEND SOURCE_FILES debug_build_utils.sql)
Expand Down
6 changes: 0 additions & 6 deletions sql/hypercore.sql → sql/pre_install/tam.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@
-- 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;
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;
COMMENT ON ACCESS METHOD hypercore_proxy IS 'Hypercore proxy index access method';

Expand Down
10 changes: 10 additions & 0 deletions sql/pre_install/tam_functions.sql
Original file line number Diff line number Diff line change
@@ -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 ts_hypercore_handler(internal) RETURNS table_am_handler
AS '@MODULE_PATHNAME@', 'ts_hypercore_handler' LANGUAGE C;

CREATE OR REPLACE FUNCTION ts_hypercore_proxy_handler(internal) RETURNS index_am_handler
AS '@MODULE_PATHNAME@', 'ts_hypercore_proxy_handler' LANGUAGE C;

18 changes: 18 additions & 0 deletions sql/updates/latest-dev.sql
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,21 @@ CREATE PROCEDURE @[email protected]_chunks(
CREATE PROCEDURE @[email protected]_chunks(
chunks REGCLASS[]
) LANGUAGE C AS '@MODULE_PATHNAME@', 'ts_update_placeholder';

CREATE FUNCTION ts_hypercore_handler(internal) RETURNS table_am_handler
AS '@MODULE_PATHNAME@', 'ts_update_placeholder' LANGUAGE C;

CREATE FUNCTION ts_hypercore_proxy_handler(internal) RETURNS index_am_handler
AS '@MODULE_PATHNAME@', 'ts_update_placeholder' LANGUAGE C;

CREATE ACCESS METHOD hypercore TYPE TABLE HANDLER ts_hypercore_handler;
COMMENT ON ACCESS METHOD hypercore IS 'Storage engine using hybrid row/columnar compression';

CREATE ACCESS METHOD hypercore_proxy TYPE INDEX HANDLER 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);

0 comments on commit 96ab6b7

Please sign in to comment.