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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?

) AS available`
const output = yield pg.psql.exec(db, query)

Expand Down