diff --git a/.unreleased/fix_6509 b/.unreleased/fix_6509
new file mode 100644
index 000000000..25784c2c8
--- /dev/null
+++ b/.unreleased/fix_6509
@@ -0,0 +1 @@
+Fixes: #6509 Make extension state available through function
diff --git a/cmake/ScriptFiles.cmake b/cmake/ScriptFiles.cmake
index c388f7834..589ab9822 100644
--- a/cmake/ScriptFiles.cmake
+++ b/cmake/ScriptFiles.cmake
@@ -58,6 +58,10 @@ set(SOURCE_FILES
     osm_api.sql)
 
 if(ENABLE_DEBUG_UTILS AND CMAKE_BUILD_TYPE MATCHES Debug)
+  list(APPEND SOURCE_FILES debug_build_utils.sql)
+endif()
+
+if(ENABLE_DEBUG_UTILS)
   list(APPEND SOURCE_FILES debug_utils.sql)
 endif()
 
diff --git a/sql/debug_build_utils.sql b/sql/debug_build_utils.sql
new file mode 100644
index 000000000..30f3f3019
--- /dev/null
+++ b/sql/debug_build_utils.sql
@@ -0,0 +1,15 @@
+-- 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.
+
+-- This file contains utility functions that are only used in debug
+-- builds for debugging and testing.
+
+CREATE OR REPLACE FUNCTION debug_waitpoint_enable(TEXT) RETURNS VOID LANGUAGE C VOLATILE STRICT
+AS '@MODULE_PATHNAME@', 'ts_debug_point_enable';
+
+CREATE OR REPLACE FUNCTION debug_waitpoint_release(TEXT) RETURNS VOID LANGUAGE C VOLATILE STRICT
+AS '@MODULE_PATHNAME@', 'ts_debug_point_release';
+
+CREATE OR REPLACE FUNCTION debug_waitpoint_id(TEXT) RETURNS BIGINT LANGUAGE C VOLATILE STRICT
+AS '@MODULE_PATHNAME@', 'ts_debug_point_id';
diff --git a/sql/debug_utils.sql b/sql/debug_utils.sql
index 30f3f3019..d644517a1 100644
--- a/sql/debug_utils.sql
+++ b/sql/debug_utils.sql
@@ -2,14 +2,9 @@
 -- Please see the included NOTICE for copyright information and
 -- LICENSE-APACHE for a copy of the license.
 
--- This file contains utility functions that are only used in debug
--- builds for debugging and testing.
+-- This file contains utility functions and views that are used for
+-- debugging in release builds. These are all placed in the schema
+-- _timescaledb_debug.
 
-CREATE OR REPLACE FUNCTION debug_waitpoint_enable(TEXT) RETURNS VOID LANGUAGE C VOLATILE STRICT
-AS '@MODULE_PATHNAME@', 'ts_debug_point_enable';
-
-CREATE OR REPLACE FUNCTION debug_waitpoint_release(TEXT) RETURNS VOID LANGUAGE C VOLATILE STRICT
-AS '@MODULE_PATHNAME@', 'ts_debug_point_release';
-
-CREATE OR REPLACE FUNCTION debug_waitpoint_id(TEXT) RETURNS BIGINT LANGUAGE C VOLATILE STRICT
-AS '@MODULE_PATHNAME@', 'ts_debug_point_id';
+CREATE OR REPLACE FUNCTION _timescaledb_debug.extension_state() RETURNS TEXT
+AS '@MODULE_PATHNAME@', 'ts_extension_get_state' LANGUAGE C;
diff --git a/sql/pre_install/schemas.sql b/sql/pre_install/schemas.sql
index 4f55c8f09..7bbda92cf 100644
--- a/sql/pre_install/schemas.sql
+++ b/sql/pre_install/schemas.sql
@@ -11,6 +11,15 @@ CREATE SCHEMA _timescaledb_cache;
 CREATE SCHEMA _timescaledb_config;
 CREATE SCHEMA timescaledb_experimental;
 CREATE SCHEMA timescaledb_information;
+CREATE SCHEMA _timescaledb_debug;
 
-GRANT USAGE ON SCHEMA _timescaledb_cache, _timescaledb_catalog, _timescaledb_functions, _timescaledb_internal, _timescaledb_config, timescaledb_information, timescaledb_experimental TO PUBLIC;
+GRANT USAGE ON SCHEMA
+      _timescaledb_cache,
+      _timescaledb_catalog,
+      _timescaledb_functions,
+      _timescaledb_internal,
+      _timescaledb_config,
+      timescaledb_information,
+      timescaledb_experimental
+TO PUBLIC;
 
diff --git a/sql/updates/latest-dev.sql b/sql/updates/latest-dev.sql
index 113c7418b..70b29b432 100644
--- a/sql/updates/latest-dev.sql
+++ b/sql/updates/latest-dev.sql
@@ -316,3 +316,5 @@ ALTER TABLE _timescaledb_catalog.dimension
     ADD CONSTRAINT dimension_hypertable_id_fkey FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable(id) ON DELETE CASCADE;
 ALTER TABLE _timescaledb_catalog.tablespace
     ADD CONSTRAINT tablespace_hypertable_id_fkey FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable(id) ON DELETE CASCADE;
+
+CREATE SCHEMA _timescaledb_debug;
diff --git a/sql/updates/reverse-dev.sql b/sql/updates/reverse-dev.sql
index e8ede2f98..1e4eae2f3 100644
--- a/sql/updates/reverse-dev.sql
+++ b/sql/updates/reverse-dev.sql
@@ -623,3 +623,5 @@ ALTER TABLE _timescaledb_catalog.hypertable_data_node
 ALTER TABLE _timescaledb_catalog.tablespace
     ADD CONSTRAINT tablespace_hypertable_id_fkey FOREIGN KEY (hypertable_id) REFERENCES _timescaledb_catalog.hypertable(id) ON DELETE CASCADE;
 
+DROP FUNCTION IF EXISTS _timescaledb_debug.extension_state;
+DROP SCHEMA IF EXISTS _timescaledb_debug;
diff --git a/src/extension.c b/src/extension.c
index 06a73a880..9d7db309a 100644
--- a/src/extension.c
+++ b/src/extension.c
@@ -349,7 +349,6 @@ ts_extension_is_proxy_table_relid(Oid relid)
 	return relid == extension_proxy_oid;
 }
 
-#ifdef TS_DEBUG
 TS_FUNCTION_INFO_V1(ts_extension_get_state);
 
 Datum
@@ -357,4 +356,3 @@ ts_extension_get_state(PG_FUNCTION_ARGS)
 {
 	PG_RETURN_TEXT_P(cstring_to_text(extstate_str[extstate]));
 }
-#endif
diff --git a/test/expected/debug_utils.out b/test/expected/debug_utils.out
new file mode 100644
index 000000000..ead6b8a3b
--- /dev/null
+++ b/test/expected/debug_utils.out
@@ -0,0 +1,15 @@
+-- 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_debug.extension_state();
+ extension_state 
+-----------------
+ created
+(1 row)
+
+SET ROLE :ROLE_DEFAULT_PERM_USER;
+\set ON_ERROR_STOP 0
+SELECT _timescaledb_debug.extension_state();
+ERROR:  permission denied for schema _timescaledb_debug at character 8
+\set ON_ERROR_STOP 1
diff --git a/test/sql/CMakeLists.txt b/test/sql/CMakeLists.txt
index ff855c990..46ebac8df 100644
--- a/test/sql/CMakeLists.txt
+++ b/test/sql/CMakeLists.txt
@@ -16,6 +16,7 @@ set(TEST_FILES
     copy.sql
     copy_where.sql
     ddl_errors.sql
+    debug_utils.sql
     drop_extension.sql
     drop_hypertable.sql
     drop_owned.sql
diff --git a/test/sql/debug_utils.sql b/test/sql/debug_utils.sql
new file mode 100644
index 000000000..4333bad97
--- /dev/null
+++ b/test/sql/debug_utils.sql
@@ -0,0 +1,12 @@
+-- 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_debug.extension_state();
+
+SET ROLE :ROLE_DEFAULT_PERM_USER;
+
+\set ON_ERROR_STOP 0
+SELECT _timescaledb_debug.extension_state();
+\set ON_ERROR_STOP 1
diff --git a/tsl/test/shared/expected/extension.out b/tsl/test/shared/expected/extension.out
index 30829be87..63bbebb93 100644
--- a/tsl/test/shared/expected/extension.out
+++ b/tsl/test/shared/expected/extension.out
@@ -19,6 +19,7 @@ FROM pg_proc p
     e.oid = d.refobjid
 WHERE proname <> 'get_telemetry_report'
 ORDER BY pronamespace::regnamespace::text COLLATE "C", p.oid::regprocedure::text COLLATE "C";
+ _timescaledb_debug.extension_state()
  _timescaledb_functions.alter_job_set_hypertable_id(integer,regclass)
  _timescaledb_functions.attach_osm_table_chunk(regclass,regclass)
  _timescaledb_functions.bookend_deserializefunc(bytea,internal)