timescaledb/test/sql/edition.sql
Matvey Arye e049238a07 Adjust permissions on internal functions
The following functions have had permission checks
added or adjusted:
ts_chunk_index_clone
ts_chunk_index_replace
ts_hypertable_insert_blocker_trigger_add
ts_current_license_key
ts_calculate_chunk_interval
ts_chunk_adaptive_set

The following functions have been removed from the regular SQL install.
They are only installed and used in tests:

dimension_calculate_default_range_open
dimension_calculate_default_range_closed
2019-06-24 10:57:38 -04:00

64 lines
1.9 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
SELECT _timescaledb_internal.current_license_key();
SELECT _timescaledb_internal.tsl_loaded();
SELECT _timescaledb_internal.enterprise_enabled();
\unset ECHO
\o /dev/null
\ir include/test_utils.sql
\o
\set ECHO queries
\set VERBOSITY default
\c :TEST_DBNAME :ROLE_SUPERUSER
\set ON_ERROR_STOP 0
SET timescaledb.license_key='ApacheOnly';
\set ON_ERROR_STOP 1
SELECT allow_downgrade_to_apache();
SET timescaledb.license_key='ApacheOnly';
select * from timescaledb_information.license;
SELECT _timescaledb_internal.current_db_set_license_key('CommunityLicense');
select * from timescaledb_information.license;
-- Default perm user shouldn't be able to change the license key.
\c :TEST_DBNAME :ROLE_DEFAULT_PERM_USER
-- Hides error messages in cases where error messages differe between Postgres versions
create or replace function get_sqlstate(in_text TEXT) RETURNS TEXT AS
$$
BEGIN
BEGIN
EXECUTE in_text;
EXCEPTION WHEN others THEN GET STACKED DIAGNOSTICS in_text = RETURNED_SQLSTATE;
END;
RETURN in_text;
END;
$$
LANGUAGE PLPGSQL;
--allowed
SELECT * FROM timescaledb_information.license;
SELECT * FROM _timescaledb_internal.enterprise_enabled();
SELECT * FROM _timescaledb_internal.tsl_loaded();
SELECT * FROM _timescaledb_internal.license_expiration_time();
SELECT * FROM _timescaledb_internal.print_license_expiration_info();
SELECT * FROM _timescaledb_internal.license_edition();
--disallowd
\set ON_ERROR_STOP 0
SELECT get_sqlstate($$SELECT _timescaledb_internal.current_db_set_license_key('ApacheOnly')$$);
SELECT get_sqlstate($$SHOW timescaledb.license_key;$$);
SELECT * FROM _timescaledb_internal.current_license_key();
\set ON_ERROR_STOP 1
drop function get_sqlstate(TEXT);