timescaledb/test/sql/debug_utils.sql
Erik Nordström 616080ef10 Grant USAGE on debug schema
Make it possible for regular users to execute functions in the schema
`_timescaledb_debug`.

As a consequence, the `extension_state()` function in this schema can
now be executed by "public". This is the only function in this schema
and there is no security risk in making it accessible.
2024-09-19 17:31:19 +02:00

27 lines
742 B
SQL

-- 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
SET ROLE :ROLE_DEFAULT_PERM_USER;
SELECT _timescaledb_debug.extension_state();
RESET ROLE;
DO $$
DECLARE
module text;
BEGIN
SELECT probin INTO module FROM pg_proc WHERE proname = 'extension_state' AND pronamespace = '_timescaledb_debug'::regnamespace;
EXECUTE format('CREATE FUNCTION extension_state() RETURNS TEXT AS ''%s'', ''ts_extension_get_state'' LANGUAGE C', module);
END
$$;
DROP EXTENSION timescaledb;
SELECT * FROM extension_state();
\c
CREATE EXTENSION timescaledb;
SELECT * FROM extension_state();