From 42d84be2adb17e0cab07d36b64d6fa89b6608e3b Mon Sep 17 00:00:00 2001 From: Konstantina Skovola Date: Tue, 14 Mar 2023 14:23:09 +0200 Subject: [PATCH] Add license information to extension description Fixes #5436 --- CMakeLists.txt | 9 +- test/expected/{loader.out => loader-oss.out} | 108 ++-- test/expected/loader-tsl.out | 555 +++++++++++++++++++ test/sql/CMakeLists.txt | 13 +- test/sql/{loader.sql => loader.sql.in} | 6 +- test/test-defs.cmake | 5 + timescaledb.control.in | 2 +- 7 files changed, 635 insertions(+), 63 deletions(-) rename test/expected/{loader.out => loader-oss.out} (82%) create mode 100644 test/expected/loader-tsl.out rename test/sql/{loader.sql => loader.sql.in} (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 09840e823a1..bac5d8b9f8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include(GitCommands) include(GenerateScripts) include(CMakeDependentOption) +option(APACHE_ONLY "only compile apache code" off) # This requires all tests to run. This defaults to OFF but can be enabled to # ensure that no tests are skipped because of missing tools. option(REQUIRE_ALL_TESTS "Require all tests to run." OFF) @@ -386,6 +387,12 @@ set(EXT_CONTROL_FILE ${PROJECT_NAME}.control) if(${PG_VERSION_MAJOR} GREATER "12") set(TRUSTED trusted=true) endif() + +if(APACHE_ONLY) + set(LICENSE_EDITION "Apache 2 Edition") +else() + set(LICENSE_EDITION "Community Edition") +endif() configure_file(${EXT_CONTROL_FILE}.in ${EXT_CONTROL_FILE}) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${EXT_CONTROL_FILE} @@ -618,8 +625,6 @@ add_subdirectory(sql) add_subdirectory(test) add_subdirectory(src) -option(APACHE_ONLY "only compile apache code" off) - if(NOT APACHE_ONLY) add_subdirectory(tsl) endif() diff --git a/test/expected/loader.out b/test/expected/loader-oss.out similarity index 82% rename from test/expected/loader.out rename to test/expected/loader-oss.out index 6ee710cd6c1..f89be841048 100644 --- a/test/expected/loader.out +++ b/test/expected/loader-oss.out @@ -3,7 +3,7 @@ -- LICENSE-APACHE for a copy of the license. \set TEST_DBNAME_2 :TEST_DBNAME _2 \c :TEST_DBNAME :ROLE_SUPERUSER -CREATE DATABASE :TEST_DBNAME_2; +CREATE DATABASE :"TEST_DBNAME_2"; DROP EXTENSION timescaledb; --no extension \dx @@ -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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-1'; @@ -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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --start new backend; @@ -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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) \c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER @@ -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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --start a new backend to update @@ -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 + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --drop extension @@ -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 + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) -- test db 1 still has old version @@ -293,11 +293,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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --try a broken upgrade @@ -305,11 +305,11 @@ WARNING: mock post_analyze_hook "mock-1" \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 + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) \set ON_ERROR_STOP 0 @@ -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 + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --drop extension @@ -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 + timescaledb | mock-3 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) DROP EXTENSION timescaledb; @@ -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 + timescaledb | mock-6 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --TEST: create extension when old .so already loaded @@ -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 + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) DROP EXTENSION timescaledb; @@ -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 + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Apache 2 Edition) (2 rows) --make sure parallel workers started after a 'DISCARD ALL' work @@ -550,6 +550,6 @@ WARNING: mock init "mock-2" -- clean up additional database \c :TEST_DBNAME :ROLE_SUPERUSER -DROP DATABASE :TEST_DBNAME_2; +DROP DATABASE :"TEST_DBNAME_2"; WARNING: mock init "mock-2" WARNING: mock post_analyze_hook "mock-2" diff --git a/test/expected/loader-tsl.out b/test/expected/loader-tsl.out new file mode 100644 index 00000000000..5d1bca9e155 --- /dev/null +++ b/test/expected/loader-tsl.out @@ -0,0 +1,555 @@ +-- 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. +\set TEST_DBNAME_2 :TEST_DBNAME _2 +\c :TEST_DBNAME :ROLE_SUPERUSER +CREATE DATABASE :"TEST_DBNAME_2"; +DROP EXTENSION timescaledb; +--no extension +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +\c :TEST_DBNAME :ROLE_SUPERUSER +CREATE EXTENSION timescaledb VERSION 'mock-1'; +WARNING: mock init "mock-1" +SELECT 1; +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-1" + 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 (Community Edition) +(2 rows) + +CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-1'; +WARNING: mock post_analyze_hook "mock-1" +NOTICE: extension "timescaledb" already exists, skipping +CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-2'; +WARNING: mock post_analyze_hook "mock-1" +NOTICE: extension "timescaledb" already exists, skipping +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-1" +\set ON_ERROR_STOP 0 +--test that we cannot accidentally load another library version +CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-2'; +ERROR: extension "timescaledb" has already been loaded with another version +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME :ROLE_SUPERUSER +--no extension +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +CREATE EXTENSION timescaledb VERSION 'mock-1'; +WARNING: mock init "mock-1" +--same backend as create extension; +SELECT 1; +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-1" + 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 (Community Edition) +(2 rows) + +--start new backend; +\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER +SELECT 1; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +SELECT 1; +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +--test fn call after load +SELECT mock_function(); +WARNING: mock post_analyze_hook "mock-1" +WARNING: mock function call "mock-1" + mock_function +--------------- + +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-1" + 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 (Community Edition) +(2 rows) + +\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER +--test fn call as first command +SELECT mock_function(); +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" +WARNING: mock function call "mock-1" + mock_function +--------------- + +(1 row) + +--use guc to prevent loading +\c :TEST_DBNAME :ROLE_SUPERUSER +SET timescaledb.disable_load = 'on'; +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SELECT 1; + ?column? +---------- + 1 +(1 row) + +SET timescaledb.disable_load = 'off'; +SELECT 1; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\set ON_ERROR_STOP 0 +SET timescaledb.disable_load = 'not bool'; +WARNING: mock post_analyze_hook "mock-1" +ERROR: parameter "timescaledb.disable_load" requires a Boolean value +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME :ROLE_SUPERUSER +RESET ALL; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" +SELECT 1; +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\c :TEST_DBNAME :ROLE_SUPERUSER +SET timescaledb.disable_load TO DEFAULT; +SELECT 1; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\c :TEST_DBNAME :ROLE_SUPERUSER +RESET timescaledb.disable_load; +SELECT 1; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\c :TEST_DBNAME :ROLE_SUPERUSER +SET timescaledb.other = 'on'; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" +SELECT 1; +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\set ON_ERROR_STOP 0 +--cannot update extension after .so of previous version already loaded +ALTER EXTENSION timescaledb UPDATE TO 'mock-2'; +ERROR: extension "timescaledb" cannot be updated after the old version has already been loaded +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +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 +-------------+---------+------------+--------------------------------------------------------------------------------------- + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language + timescaledb | mock-1 | public | Enables scalable inserts and complex queries for time-series data (Community Edition) +(2 rows) + +--start a new backend to update +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +ALTER EXTENSION timescaledb UPDATE TO 'mock-2'; +WARNING: mock init "mock-2" +SELECT 1; +WARNING: mock post_analyze_hook "mock-2" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-2" + 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 (Community Edition) +(2 rows) + +--drop extension +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-2" +SELECT 1; + ?column? +---------- + 1 +(1 row) + +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +CREATE EXTENSION timescaledb VERSION 'mock-2'; +WARNING: mock init "mock-2" +SELECT 1; +WARNING: mock post_analyze_hook "mock-2" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-2" + 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 (Community Edition) +(2 rows) + +-- test db 1 still has old version +\c :TEST_DBNAME :ROLE_SUPERUSER +SELECT 1; +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-1" + 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 (Community Edition) +(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 +-------------+---------+------------+--------------------------------------------------------------------------------------- + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Community Edition) +(2 rows) + +\set ON_ERROR_STOP 0 +ALTER EXTENSION timescaledb UPDATE TO 'mock-3'; +ERROR: extension "timescaledb" cannot be updated after the old version has already been loaded +\set ON_ERROR_STOP 1 +--should still be on mock-2 +SELECT 1; +WARNING: mock post_analyze_hook "mock-2" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-2" + 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 (Community Edition) +(2 rows) + +--drop extension +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-2" +SELECT 1; + ?column? +---------- + 1 +(1 row) + +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +--create extension anew, only upgrade was broken +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +CREATE EXTENSION timescaledb VERSION 'mock-3'; +WARNING: mock init "mock-3" +SELECT 1; +WARNING: mock post_analyze_hook "mock-3" + ?column? +---------- + 1 +(1 row) + +\dx +WARNING: mock post_analyze_hook "mock-3" + 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 (Community Edition) +(2 rows) + +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-3" +SELECT 1; + ?column? +---------- + 1 +(1 row) + +--mismatched version errors +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +--mock-4 has mismatched versions, so the .so load should be fatal +SELECT format($$\! utils/test_fatal_command.sh %1$s "CREATE EXTENSION timescaledb VERSION 'mock-4'"$$, :'TEST_DBNAME_2') as command_to_run \gset +:command_to_run +FATAL: extension "timescaledb" version mismatch: shared library version mock-4-mismatch; SQL version mock-4 +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. +connection to server was lost +--mock-4 not installed. +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +--broken version and drop +CREATE EXTENSION timescaledb VERSION 'mock-broken'; +WARNING: mock init "mock-broken" +\set ON_ERROR_STOP 0 +--intentional broken version +\dx +WARNING: mock post_analyze_hook "mock-broken" +ERROR: mock broken "mock-broken" +SELECT 1; +WARNING: mock post_analyze_hook "mock-broken" +ERROR: mock broken "mock-broken" +SELECT 1; +WARNING: mock post_analyze_hook "mock-broken" +ERROR: mock broken "mock-broken" +--cannot drop extension; already loaded broken version +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-broken" +ERROR: mock broken "mock-broken" +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +--can drop extension now. Since drop first command. +DROP EXTENSION timescaledb; +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +--broken version and update to fixed +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +CREATE EXTENSION timescaledb VERSION 'mock-broken'; +WARNING: mock init "mock-broken" +\set ON_ERROR_STOP 0 +--intentional broken version +SELECT 1; +WARNING: mock post_analyze_hook "mock-broken" +ERROR: mock broken "mock-broken" +--cannot update extension; already loaded bad version +ALTER EXTENSION timescaledb UPDATE TO 'mock-5'; +ERROR: extension "timescaledb" cannot be updated after the old version has already been loaded +\set ON_ERROR_STOP 1 +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +--can update extension now. +ALTER EXTENSION timescaledb UPDATE TO 'mock-5'; +WARNING: mock init "mock-5" +SELECT 1; +WARNING: mock post_analyze_hook "mock-5" + ?column? +---------- + 1 +(1 row) + +SELECT mock_function(); +WARNING: mock post_analyze_hook "mock-5" +WARNING: mock function call "mock-5" + mock_function +--------------- + +(1 row) + +\c :TEST_DBNAME_2 :ROLE_SUPERUSER +ALTER EXTENSION timescaledb UPDATE TO 'mock-6'; +WARNING: mock init "mock-6" +--The mock-5->mock_6 upgrade is intentionally broken. +--The mock_function was never changed to point to mock-6 in the update script. +--Thus mock_function is defined incorrectly to point to the mock-5.so +--This will now be a FATAL error. +SELECT format($$\! utils/test_fatal_command.sh %1$s "SELECT mock_function()"$$, :'TEST_DBNAME_2') as command_to_run \gset +WARNING: mock post_analyze_hook "mock-6" +:command_to_run +WARNING: mock init "mock-6" +WARNING: mock post_analyze_hook "mock-6" +FATAL: extension "timescaledb" version mismatch: shared library version mock-5; SQL version mock-6 +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. +connection to server was lost +\dx +WARNING: mock post_analyze_hook "mock-6" + 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 (Community Edition) +(2 rows) + +--TEST: create extension when old .so already loaded +\c :TEST_DBNAME :ROLE_SUPERUSER +--force load of extension with (\dx) +\dx +WARNING: mock init "mock-1" +WARNING: mock post_analyze_hook "mock-1" + 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 (Community Edition) +(2 rows) + +DROP EXTENSION timescaledb; +WARNING: mock post_analyze_hook "mock-1" +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +\set ON_ERROR_STOP 0 +CREATE EXTENSION timescaledb VERSION 'mock-2'; +ERROR: extension "timescaledb" has already been loaded with another version +\set ON_ERROR_STOP 1 +\dx + List of installed extensions + Name | Version | Schema | Description +---------+---------+------------+------------------------------ + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language +(1 row) + +--can create in a new session. +\c :TEST_DBNAME :ROLE_SUPERUSER +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 +-------------+---------+------------+--------------------------------------------------------------------------------------- + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language + timescaledb | mock-2 | public | Enables scalable inserts and complex queries for time-series data (Community Edition) +(2 rows) + +--make sure parallel workers started after a 'DISCARD ALL' work +CREATE TABLE test (i int, j double precision); +WARNING: mock post_analyze_hook "mock-2" +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'; +WARNING: mock post_analyze_hook "mock-2" +SET max_parallel_workers_per_gather = 1; +WARNING: mock post_analyze_hook "mock-2" +SELECT count(*) FROM test; +WARNING: mock post_analyze_hook "mock-2" +WARNING: mock init "mock-2" + count +------- + 100 +(1 row) + +-- clean up additional database +\c :TEST_DBNAME :ROLE_SUPERUSER +DROP DATABASE :"TEST_DBNAME_2"; +WARNING: mock init "mock-2" +WARNING: mock post_analyze_hook "mock-2" diff --git a/test/sql/CMakeLists.txt b/test/sql/CMakeLists.txt index 6d22208c901..7ac4e206b23 100644 --- a/test/sql/CMakeLists.txt +++ b/test/sql/CMakeLists.txt @@ -72,6 +72,12 @@ set(TEST_TEMPLATES parallel.sql.in query.sql.in) +# Loader test must distinguish between Apache and TSL builds so we parametrize +# this here +set(LOADER_TEST_FILE loader-${TEST_LICENSE_SUFFIX}) +configure_file(loader.sql.in + ${CMAKE_CURRENT_SOURCE_DIR}/${LOADER_TEST_FILE}.sql) + # tests that fail or are unreliable when run in parallel bgw tests need to run # first otherwise they are flaky set(SOLO_TESTS @@ -80,12 +86,13 @@ set(SOLO_TESTS bgw_launcher chunk_utils index - loader net pg_dump_unprivileged tablespace telemetry) +list(APPEND SOLO_TESTS ${LOADER_TEST_FILE}) + if(CMAKE_BUILD_TYPE MATCHES Debug) list( APPEND @@ -94,13 +101,13 @@ if(CMAKE_BUILD_TYPE MATCHES Debug) c_unit_tests.sql copy_memory_usage.sql guc_options.sql - loader.sql metadata.sql multi_transaction_index.sql net.sql pg_dump.sql symbol_conflict.sql - test_utils.sql) + test_utils.sql + ${LOADER_TEST_FILE}.sql) if(USE_TELEMETRY) list(APPEND TEST_FILES telemetry.sql) endif() diff --git a/test/sql/loader.sql b/test/sql/loader.sql.in similarity index 98% rename from test/sql/loader.sql rename to test/sql/loader.sql.in index 9ec16a3e968..2105d440067 100644 --- a/test/sql/loader.sql +++ b/test/sql/loader.sql.in @@ -5,7 +5,8 @@ \set TEST_DBNAME_2 :TEST_DBNAME _2 \c :TEST_DBNAME :ROLE_SUPERUSER -CREATE DATABASE :TEST_DBNAME_2; + +CREATE DATABASE :"TEST_DBNAME_2"; DROP EXTENSION timescaledb; --no extension @@ -209,5 +210,4 @@ SELECT count(*) FROM test; -- clean up additional database \c :TEST_DBNAME :ROLE_SUPERUSER -DROP DATABASE :TEST_DBNAME_2; - +DROP DATABASE :"TEST_DBNAME_2"; diff --git a/test/test-defs.cmake b/test/test-defs.cmake index e9e53605b24..cff52d559fb 100644 --- a/test/test-defs.cmake +++ b/test/test-defs.cmake @@ -152,3 +152,8 @@ if(PG_ISOLATION_REGRESS) endif() set(TEST_VERSION_SUFFIX ${PG_VERSION_MAJOR}) +if(APACHE_ONLY) + set(TEST_LICENSE_SUFFIX "oss") +else() + set(TEST_LICENSE_SUFFIX "tsl") +endif() diff --git a/timescaledb.control.in b/timescaledb.control.in index eee43db4cdc..3b87d387d71 100644 --- a/timescaledb.control.in +++ b/timescaledb.control.in @@ -1,5 +1,5 @@ # timescaledb extension -comment = 'Enables scalable inserts and complex queries for time-series data' +comment = 'Enables scalable inserts and complex queries for time-series data (@LICENSE_EDITION@)' default_version = '@PROJECT_VERSION_MOD@' module_pathname = '$libdir/timescaledb-@PROJECT_VERSION_MOD@' #extension cannot be relocatable once installed because it uses multiple schemas and that is forbidden by PG.