Skip to content

Commit

Permalink
Set license specific extension comment in install script
Browse files Browse the repository at this point in the history
Remove the license information from the control file as we package
that with the generic loader and will be used for both Apache licensed
and TSL licensed versions of the extension. This patch adjusts
the extension comment in the install and update script and adds the
appropriate license information.

The effective change from this PR will be that pg_available_extensions
will show the generic message but `\dx` whill show the correct info
depending on what you installed. This setup is mainly due to packaging
constraints as we have 3 extension packages. The loader package,
apache 2 package and community package. The loader package is shared
between apache 2 and community and has the control file with the
extension commment so we dont know which timescaledb version we are
used with in that package.
  • Loading branch information
svenklemm committed Oct 8, 2024
1 parent b409c25 commit 2959bd4
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 118 deletions.
1 change: 1 addition & 0 deletions .unreleased/pr_7320
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #7320 Set license specific extension comment in install script
12 changes: 0 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,18 +397,6 @@ if(PG_SOURCE_DIR)
endif(PG_SOURCE_DIR)

set(EXT_CONTROL_FILE ${PROJECT_NAME}.control)

# When building apt or rpm packages we build a separate loader package that will
# be used by both the apache and community editions. Having the edition in the
# description would be misleading so we remove it for these cases.
set(GENERIC_LOADER_METHOD apt rpm)
if(PROJECT_INSTALL_METHOD IN_LIST GENERIC_LOADER_METHOD)
set(COMMENT_SUFFIX "")
elseif(APACHE_ONLY)
set(COMMENT_SUFFIX " (Apache 2 Edition)")
else()
set(COMMENT_SUFFIX " (Community Edition)")
endif()
configure_file(${EXT_CONTROL_FILE}.in ${EXT_CONTROL_FILE})

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXT_CONTROL_FILE}
Expand Down
6 changes: 6 additions & 0 deletions cmake/ScriptFiles.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ list(APPEND SOURCE_FILES
list(APPEND SOURCE_FILES
bgw_startup.sql)

if(APACHE_ONLY)
list(APPEND SOURCE_FILES comment_apache.sql)
else()
list(APPEND SOURCE_FILES comment_tsl.sql)
endif()

# These files should be prepended to update scripts so that they are executed
# before anything else during updates
set(PRE_UPDATE_FILES updates/pre-version-change.sql updates/pre-update.sql)
Expand Down
5 changes: 5 additions & 0 deletions sql/comment_apache.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- 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.

COMMENT ON EXTENSION timescaledb IS 'Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)';
5 changes: 5 additions & 0 deletions sql/comment_tsl.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- 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.

COMMENT ON EXTENSION timescaledb IS 'Enables scalable inserts and complex queries for time-series data (Community Edition)';
111 changes: 58 additions & 53 deletions test/expected/loader-oss.out
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ WARNING: mock post_analyze_hook "mock-1"

\dx
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-1';
Expand Down Expand Up @@ -78,11 +78,11 @@ WARNING: mock post_analyze_hook "mock-1"

\dx
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--start new backend;
Expand Down Expand Up @@ -113,11 +113,11 @@ WARNING: mock function call "mock-1"

\dx
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
Expand Down Expand Up @@ -219,11 +219,11 @@ CREATE EXTENSION timescaledb VERSION 'mock-1';
WARNING: mock init "mock-1"
\dx
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--start a new backend to update
Expand All @@ -239,11 +239,11 @@ WARNING: mock post_analyze_hook "mock-2"

\dx
WARNING: mock post_analyze_hook "mock-2"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--drop extension
Expand Down Expand Up @@ -274,11 +274,11 @@ WARNING: mock post_analyze_hook "mock-2"

\dx
WARNING: mock post_analyze_hook "mock-2"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

-- test db 1 still has old version
Expand All @@ -293,23 +293,23 @@ WARNING: mock post_analyze_hook "mock-1"

\dx
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--try a broken upgrade
\c :TEST_DBNAME_2 :ROLE_SUPERUSER
\dx
WARNING: mock init "mock-2"
WARNING: mock post_analyze_hook "mock-2"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

\set ON_ERROR_STOP 0
Expand All @@ -326,11 +326,11 @@ WARNING: mock post_analyze_hook "mock-2"

\dx
WARNING: mock post_analyze_hook "mock-2"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--drop extension
Expand Down Expand Up @@ -362,11 +362,11 @@ WARNING: mock post_analyze_hook "mock-3"

\dx
WARNING: mock post_analyze_hook "mock-3"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-3 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-3 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

DROP EXTENSION timescaledb;
Expand Down Expand Up @@ -476,11 +476,11 @@ server closed the connection unexpectedly
connection to server was lost
\dx
WARNING: mock post_analyze_hook "mock-6"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-6 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-6 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--TEST: create extension when old .so already loaded
Expand All @@ -489,11 +489,11 @@ WARNING: mock post_analyze_hook "mock-6"
\dx
WARNING: mock init "mock-1"
WARNING: mock post_analyze_hook "mock-1"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

DROP EXTENSION timescaledb;
Expand Down Expand Up @@ -522,11 +522,11 @@ CREATE EXTENSION timescaledb VERSION 'mock-2';
WARNING: mock init "mock-2"
\dx
WARNING: mock post_analyze_hook "mock-2"
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+--------------------------------------------------------------------------------------
List of installed extensions
Name | Version | Schema | Description
-------------+---------+------------+-------------------------------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition)
timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data
(2 rows)

--make sure parallel workers started after a 'DISCARD ALL' work
Expand All @@ -536,8 +536,13 @@ INSERT INTO test SELECT x, x+0.1 FROM generate_series(1,100) AS x;
WARNING: mock post_analyze_hook "mock-2"
DISCARD ALL;
WARNING: mock post_analyze_hook "mock-2"
SET force_parallel_mode = 'on';
SELECT set_config(CASE WHEN current_setting('server_version_num')::int < 160000 THEN 'force_parallel_mode' ELSE 'debug_parallel_query' END,'on', false);
WARNING: mock post_analyze_hook "mock-2"
set_config
------------
on
(1 row)

SET max_parallel_workers_per_gather = 1;
WARNING: mock post_analyze_hook "mock-2"
SELECT count(*) FROM test;
Expand Down
Loading

0 comments on commit 2959bd4

Please sign in to comment.