Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure to generate backend data from pg_catalog.pg_settings #3

Closed
rustprooflabs opened this issue Mar 2, 2021 · 2 comments
Closed
Labels
enhancement New feature or request
Milestone

Comments

@rustprooflabs
Copy link
Owner

rustprooflabs commented Mar 2, 2021

Details

The current method to add a new version directly uses postgresql.conf to determine defaults. This was a bit awkward from the beginning and has a number drawbacks with maintainability and accuracy. This change should set the stage for a number of subsequent improvements.

Planned approach

Use a query against pg_catalog.pg_settings similar to this example. Create a Python script to dump to csv/json/something to parse back in. This calculates the postgresconf_line for matching current expectations, not sure that will make it to the final version. Also calculating a few bool indicators that may be helpful.

SELECT name, setting, context, source, reset_val, boot_val,
		unit, category,
		name || ' = ' ||  setting AS postgresconf_line,
		short_desc,
		CASE WHEN name LIKE 'lc%'
				THEN True
			WHEN name IN ('application_name', 'TimeZone')
				THEN True
			ELSE False
			END AS frequent_override,
		CASE WHEN boot_val = reset_val THEN True 
			ELSE False 
			END AS system_default,
		CASE WHEN reset_val = setting THEN False 
			ELSE True
			END AS session_override
	FROM pg_catalog.pg_settings
;

Possible future improvements

  • Handle case when a GUC type is different Handle case when a GUC type is different #7
  • Display differences between server config (postgresql.conf) & user config (SET TimeZone = 'America/Denver';)
  • Allow for extension specific config, e.g. pg_stat_statements, Timescale. <-- Should be category='Customized Options'
  • Allow for config specific to Pg variants, e.g AWS RDS, MS Azure, etc.
@rustprooflabs rustprooflabs added the enhancement New feature or request label Mar 2, 2021
@rustprooflabs rustprooflabs added this to the 0.0.6 milestone Mar 2, 2021
@rustprooflabs rustprooflabs self-assigned this Mar 2, 2021
@rustprooflabs
Copy link
Owner Author

CREATE SCHEMA pgconfig;

DROP VIEW IF EXISTS pgconfig.settings;
CREATE VIEW pgconfig.settings AS
SELECT name, setting, context, source, reset_val, boot_val,
        unit, category,
        name || ' = ' ||  setting AS postgresconf_line,
        name || ' = ' || boot_val AS default_config_line,
        short_desc,
        CASE WHEN name LIKE 'lc%'
                THEN True
            WHEN name IN ('application_name', 'TimeZone')
                THEN True
            ELSE False
            END AS frequent_override,
        CASE WHEN boot_val = reset_val THEN True 
            ELSE False 
            END AS system_default,
        CASE WHEN reset_val = setting THEN False 
            ELSE True
            END AS session_override, 
        pending_restart
    FROM pg_catalog.pg_settings
;


SELECT postgresconf_line, *
    FROM pgconfig.settings
    WHERE default_config_line IS NOT NULL
        AND NOT frequent_override
;

rustprooflabs added a commit that referenced this issue Jul 1, 2021
…Manually updated most of Pg13 for minor differences in format. #3
@rustprooflabs rustprooflabs removed their assignment Apr 6, 2023
@rustprooflabs rustprooflabs removed this from the 0.0.6 milestone Sep 22, 2023
rustprooflabs added a commit that referenced this issue Jan 6, 2024
…Manually updated most of Pg13 for minor differences in format. #3
@rustprooflabs rustprooflabs added this to the 0.1.0 milestone Jan 6, 2024
@rustprooflabs
Copy link
Owner Author

Done via #17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant