Merge test branch changes excluding tests directory
This commit is contained in:
@@ -74,11 +74,24 @@ BEGIN
|
||||
END $$;
|
||||
|
||||
-- ==========================================================================
|
||||
-- IMPORTANT: If the Zabbix Server connects with a non-superuser (e.g., 'zabbix'),
|
||||
-- that user MUST have access to the partitions schema for the housekeeper trigger
|
||||
-- to work. Without these GRANTs, every INSERT into housekeeper will FAIL.
|
||||
-- Uncomment and adjust the username below:
|
||||
-- IMPORTANT: To ensure the Zabbix Server can insert into the housekeeper
|
||||
-- table without permission issues, we automatically grant access to the
|
||||
-- partitions schema to the owner of the housekeeper table.
|
||||
-- ==========================================================================
|
||||
-- GRANT USAGE ON SCHEMA partitions TO zabbix;
|
||||
-- GRANT SELECT ON partitions.config TO zabbix;
|
||||
DO $$
|
||||
DECLARE
|
||||
v_owner text;
|
||||
BEGIN
|
||||
SELECT pg_get_userbyid(c.relowner) INTO v_owner
|
||||
FROM pg_class c
|
||||
JOIN pg_namespace n ON n.oid = c.relnamespace
|
||||
WHERE c.relname = 'housekeeper' AND pg_table_is_visible(c.oid);
|
||||
|
||||
IF v_owner IS NOT NULL THEN
|
||||
EXECUTE format('GRANT USAGE ON SCHEMA partitions TO %I', v_owner);
|
||||
EXECUTE format('GRANT SELECT ON partitions.config TO %I', v_owner);
|
||||
RAISE NOTICE 'Granted partitions schema permissions to housekeeper owner: %', v_owner;
|
||||
ELSE
|
||||
RAISE WARNING 'housekeeper table not found, could not grant permissions automatically!';
|
||||
END IF;
|
||||
END $$;
|
||||
|
||||
Reference in New Issue
Block a user