timescaledb/test/sql/extension_scripts.sql
Mats Kindahl 15d33f0624 Add option to compile without telemetry
Add option `USE_TELEMETRY` that can be used to exclude telemetry from
the compile.

Telemetry-specific SQL is moved, which is only included when extension
is compiled with telemetry and the notice is changed so that the
message about telemetry is not printed when Telemetry is not compiled
in.

The following code is not compiled in when telemetry is not used:
- Cross-module functions for telemetry.
- Checks for telemetry job in job execution.
- GUC variables `telemetry_level` and `telemetry_cloud`.

Telemetry subsystem is not included when compiling without telemetry,
which requires some functions to be moved out of the telemetry
subsystem:
- Metadata handling is moved out of the telemetry module since it is
  used not only with telemetry.
- UUID functions are moved into a separate module instead of being
  part of the telemetry subsystem.
- Telemetry functions are either added or removed when updating from a
  previous version.

Tests are updated to:
- Not use telemetry functions to get UUID or Metadata and instead use
  the moved UUID and metadata functions.
- Not include telemetry information in tests that do not require it.
- Configuration files do not set telemetry variables when telemetry is
  not compiled in.
- Replaced usage of telemetry functions in non-telemetry tests with
  other sources of same information.

Fixes #3931
2022-03-03 12:21:07 +01:00

55 lines
1.8 KiB
PL/PgSQL

-- 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.
\c :TEST_DBNAME :ROLE_SUPERUSER
DROP EXTENSION timescaledb;
-- test that installation script errors when any of our internal schemas already exists
\set ON_ERROR_STOP 0
CREATE SCHEMA _timescaledb_catalog;
CREATE EXTENSION timescaledb;
DROP SCHEMA _timescaledb_catalog;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE SCHEMA _timescaledb_internal;
CREATE EXTENSION timescaledb;
DROP SCHEMA _timescaledb_internal;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE SCHEMA _timescaledb_cache;
CREATE EXTENSION timescaledb;
DROP SCHEMA _timescaledb_cache;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE SCHEMA _timescaledb_config;
CREATE EXTENSION timescaledb;
DROP SCHEMA _timescaledb_config;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE SCHEMA timescaledb_experimental;
CREATE EXTENSION timescaledb;
DROP SCHEMA timescaledb_experimental;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE SCHEMA timescaledb_information;
CREATE EXTENSION timescaledb;
DROP SCHEMA timescaledb_information;
-- test that installation script errors when any of the function in public schema already exists
-- we don't test every public function but just a few common ones
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE FUNCTION time_bucket(int,int) RETURNS int LANGUAGE SQL AS $$ SELECT 1::int; $$;
CREATE EXTENSION timescaledb;
DROP FUNCTION time_bucket;
\c :TEST_DBNAME :ROLE_SUPERUSER
CREATE OR REPLACE FUNCTION show_chunks(relation regclass, older_than "any" DEFAULT NULL, newer_than "any" DEFAULT NULL) RETURNS SETOF regclass language internal as 'pg_partition_ancestors';
CREATE EXTENSION timescaledb;
DROP FUNCTION show_chunks;
\c :TEST_DBNAME :ROLE_SUPERUSER
SET client_min_messages TO ERROR;
CREATE EXTENSION timescaledb;