-- Test for CDC library path adjustment functionality
-- This test verifies that the AdjustDynamicLibraryPathForCdcDecoders function with non-superuser privileges
-- correctly modifies the dynamic_library_path when CDC is enabled
-- Test 1: Non-superuser with read_all_settings can see dynamic_library_path changes
CREATE USER cdc_test_user;
GRANT pg_read_all_settings TO cdc_test_user;
SET ROLE cdc_test_user;
-- Non-superuser should be able to see the current dynamic_library_path
SELECT current_setting('dynamic_library_path') AS user_visible_path;
 user_visible_path
---------------------------------------------------------------------
 $libdir
(1 row)

SET citus.enable_change_data_capture = true;
SHOW citus.enable_change_data_capture;
 citus.enable_change_data_capture
---------------------------------------------------------------------
 on
(1 row)

SHOW dynamic_library_path;
      dynamic_library_path
---------------------------------------------------------------------
 $libdir/citus_decoders:$libdir
(1 row)

-- Reset to superuser and cleanup
RESET ROLE;
DROP USER cdc_test_user;
-- Final cleanup
RESET citus.enable_change_data_capture;
RESET dynamic_library_path;
SHOW citus.enable_change_data_capture;
 citus.enable_change_data_capture
---------------------------------------------------------------------
 off
(1 row)

SHOW dynamic_library_path;
      dynamic_library_path
---------------------------------------------------------------------
 $libdir/citus_decoders:$libdir
(1 row)

