-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pg_dump error on powa_module_config
powa_modules are used for cluster-wide pg_stat datasources and do not support custom datasources. powa_modules and powa_module_functions got it right and don't have the usual "added_manually" column used to distinguish custom rows, but powa_module_functions had a wrong reference to this column. Also, powa_module_config was incorrectly created with an added_manually column, and dump was configure using it but the extension install script was incorrectly marking some of the init-time data to be custom. To fix, get rid of any mention of that column in either the table structure of the dump config. Thanks to github user guruguruguru for the report.
- Loading branch information
Showing
2 changed files
with
60 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,54 @@ | ||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "ALTER EXTENSION powa" to load this file. \quit | ||
|
||
ALTER TABLE @[email protected]_module_config DROP COLUMN added_manually; | ||
|
||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_config',''); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_functions',''); | ||
|
||
CREATE FUNCTION @[email protected]_activate_module(_srvid int, _module text) RETURNS boolean | ||
AS $_$ | ||
DECLARE | ||
v_res bool; | ||
BEGIN | ||
IF (_srvid IS NULL) THEN | ||
RAISE EXCEPTION 'powa_activate_module: no server id provided'; | ||
END IF; | ||
|
||
IF (_module IS NULL) THEN | ||
RAISE EXCEPTION 'powa_activate_module: no module provided'; | ||
END IF; | ||
|
||
-- Check that the module is known. | ||
SELECT COUNT(*) = 1 INTO v_res | ||
FROM @[email protected]_modules | ||
WHERE module = _module; | ||
|
||
IF (NOT v_res) THEN | ||
RAISE EXCEPTION 'Module "%" is not known', _module; | ||
END IF; | ||
|
||
-- The record may already be present, but the enabled flag could be off. | ||
-- If so simply enable it. Otherwise, add the needed record. | ||
SELECT COUNT(*) > 0 INTO v_res | ||
FROM @[email protected]_module_config | ||
WHERE module = _module | ||
AND srvid = _srvid; | ||
|
||
IF (v_res) THEN | ||
UPDATE @[email protected]_module_config | ||
SET enabled = true | ||
WHERE enabled = false | ||
AND srvid = _srvid | ||
AND module = _module; | ||
ELSE | ||
INSERT INTO @[email protected]_module_config | ||
(srvid, module) | ||
VALUES | ||
(_srvid, _module); | ||
END IF; | ||
|
||
RETURN true; | ||
END; | ||
$_$ LANGUAGE plpgsql | ||
SET search_path = pg_catalog; /* end of powa_activate_module */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -225,17 +225,16 @@ CREATE TABLE @[email protected]_module_config ( | |
srvid integer NOT NULL, | ||
module text NOT NULL, | ||
enabled bool NOT NULL default true, | ||
added_manually boolean NOT NULL default true, | ||
PRIMARY KEY (srvid, module), | ||
FOREIGN KEY (srvid) REFERENCES @[email protected]_servers(id) | ||
MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE, | ||
FOREIGN KEY (module) REFERENCES @[email protected]_modules(module) | ||
MATCH FULL ON UPDATE CASCADE ON DELETE CASCADE | ||
); | ||
|
||
INSERT INTO @[email protected]_module_config (srvid, module, added_manually) VALUES | ||
(0, 'pg_database', false), | ||
(0, 'pg_role', false); | ||
INSERT INTO @[email protected]_module_config (srvid, module) VALUES | ||
(0, 'pg_database'), | ||
(0, 'pg_role'); | ||
|
||
CREATE TABLE @[email protected]_module_functions ( | ||
module text NOT NULL, | ||
|
@@ -1255,7 +1254,7 @@ BEGIN | |
|
||
-- declare the module and its configuration | ||
INSERT INTO @[email protected]_modules VALUES (_pg_module, _min_version); | ||
INSERT INTO @[email protected]_module_config VALUES (0, _pg_module, false); | ||
INSERT INTO @[email protected]_module_config VALUES (0, _pg_module); | ||
INSERT INTO @[email protected]_module_functions VALUES | ||
(_pg_module, 'snapshot', v_module || '_snapshot', v_module || '_src'), | ||
(_pg_module, 'aggregate', v_module || '_aggregate', NULL), | ||
|
@@ -2296,9 +2295,9 @@ BEGIN | |
AND module = _module; | ||
ELSE | ||
INSERT INTO @[email protected]_module_config | ||
(srvid, module, added_manually) | ||
(srvid, module) | ||
VALUES | ||
(_srvid, _module, (_srvid != 0)); | ||
(_srvid, _module); | ||
END IF; | ||
|
||
RETURN true; | ||
|
@@ -3166,8 +3165,8 @@ SELECT pg_catalog.pg_extension_config_dump('@[email protected]_all_tables_history_ | |
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_extensions','WHERE added_manually'); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_extension_functions','WHERE added_manually'); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_extension_config','WHERE added_manually'); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_functions','WHERE added_manually'); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_config','WHERE added_manually'); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_functions',''); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_module_config',''); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_catalog_databases',''); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_catalog_roles',''); | ||
SELECT pg_catalog.pg_extension_config_dump('@[email protected]_catalog_class',''); | ||
|