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

[DB-13678] Assess Migration command guardrails check for pgss extension properly loaded or not in source db #2018

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

sanyamsinghal
Copy link
Collaborator

  • doing SELECT query on pg_stat_statements view and comparing the error message

// so instead of getting current_settings(), executing SELECT query on pg_stat_statements view
// 3. check if its properly installed/loaded without any extra permissions
_, err = pg.db.Exec(queryCheckPgssLoaded)
if err != nil && strings.Contains(err.Error(), "pg_stat_statements must be loaded via shared_preload_libraries") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: error msg constant SHARED_PRELOAD_LIBRARY_ERROR

@@ -1166,7 +1166,7 @@ const (
JOIN pg_namespace n ON e.extnamespace = n.oid
WHERE e.extname = 'pg_stat_statements'`

querySharedPreloadLibraries = `SELECT current_setting('shared_preload_libraries')`
queryCheckPgssLoaded = `SELECT query from pg_stat_statements LIMIT 1`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

schema of pgss table in case it's in non_public.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch.

…on properly loaded or not in source db

- doing SELECT query on pg_stat_statements view and comparing the error message
Copy link
Contributor

@priyanshi-yb priyanshi-yb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sanyamsinghal sanyamsinghal merged commit ed4561e into main Dec 2, 2024
29 checks passed
@sanyamsinghal sanyamsinghal deleted the sanyam/pgss-preload branch December 2, 2024 06:38
@sanyamsinghal sanyamsinghal restored the sanyam/pgss-preload branch December 5, 2024 22:34
@sanyamsinghal sanyamsinghal deleted the sanyam/pgss-preload branch January 22, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants