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

Look for pg_stat_statements in heroku_ext too #192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iriberri
Copy link

@iriberri iriberri commented Sep 5, 2022

Following: https://devcenter.heroku.com/changelog-items/2446.

pg_stat_statements can exist in any of the public and heroku_ext schemas, and this plugin needs to account for that.

This is the equivalent of heroku/cli#2038 for pg-extras, given the command duplication between this plugin and the core CLI.

cc @verajohne @subakva

@@ -7,7 +7,7 @@ function * ensurePGStatStatement (db) {
const query = `
SELECT exists(
SELECT 1 FROM pg_extension e LEFT JOIN pg_namespace n ON n.oid = e.extnamespace
WHERE e.extname='pg_stat_statements' AND n.nspname = 'public'
WHERE e.extname='pg_stat_statements' AND n.nspname IN ('public', 'heroku_ext')

Choose a reason for hiding this comment

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

@iriberri does this check even need to be present? if the extension is in a different schema, what happens? will it fail to execute? can the user recover?

Copy link
Author

Choose a reason for hiding this comment

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

Oh, good point! We don't really care about what's the schema where the extension is installed here, as far as that schema is part of the search_path. All the calls that I can see in the code don't use any fully-qualified view names.

We also made some changes in the core CLI that I missed here: https://github.com/heroku/cli/blob/7a78c0ec61c3006fbd10c402e8d8bce07fc09268/packages/pg-v5/commands/outliers.js#L14-L18.

Looks like we want a check to see if the extension exists already, anywhere, and a second check to see if it's installed in a schema that's part of the search_path (to point the customer to specific troubleshooting steps). How does that sound @halorgium?

@chaadow
Copy link

chaadow commented Mar 14, 2023

Can this be merged? @mimen

@marns93
Copy link

marns93 commented Mar 15, 2023

Can this be merged? @mimen

I'm also interested in this to be merged. :)

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.

4 participants