Skip to content

Commit

Permalink
Added --enable-hypopg option
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Apr 18, 2023
1 parent 309a3f4 commit d28b5ef
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 0.5.0 (unreleased)

- Added support for normalized queries
- Added `--enable-hypopg` option
- Improved output when HypoPG not installed
- Changed `--pg-stat-activity` to run for one second
- Detect input format based on file extension
Expand Down
1 change: 1 addition & 0 deletions lib/dexter/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def parse_args(args)
o.separator "Indexing options:"
o.boolean "--analyze", "analyze tables that haven't been analyzed in the past hour", default: false
o.boolean "--create", "create indexes", default: false
o.boolean "--enable-hypopg", "enable the HypoPG extension", default: false
o.array "--exclude", "prevent specific tables from being indexed"
o.string "--include", "only include specific tables"
o.integer "--min-cost-savings-pct", default: 50, help: false
Expand Down
14 changes: 5 additions & 9 deletions lib/dexter/indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,12 @@ def check_extension
end

if extension["installed_version"].nil?
create_extension
end
end

def create_extension
suppress_messages do
execute("CREATE EXTENSION hypopg")
if @options[:enable_hypopg]
execute("CREATE EXTENSION hypopg")
else
raise Dexter::Abort, "Run `CREATE EXTENSION hypopg` or pass --enable-hypopg"
end
end
rescue PG::InsufficientPrivilege
raise Dexter::Abort, "Use a superuser to run: CREATE EXTENSION hypopg"
end

def reset_hypothetical_indexes
Expand Down
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$conn.exec <<-SQL
SET client_min_messages = warning;
CREATE EXTENSION IF NOT EXISTS hstore;
CREATE EXTENSION IF NOT EXISTS hypopg;
DROP TABLE IF EXISTS posts CASCADE;
CREATE TABLE posts (
id int,
Expand Down

0 comments on commit d28b5ef

Please sign in to comment.