pgdexter 0.6.2 → 0.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8c6d5363b46c95785cf87964a0d1226161b43433e10d7700c71342ebcf3c10bc
4
- data.tar.gz: 89edef30213d5ec288c9c7ab8bcb8b371649f569408a34abb4fe9038050729dc
3
+ metadata.gz: 9e926f9a4b3e7f95a7e1d95813901d689795efa42edf9690872f3caf04477020
4
+ data.tar.gz: 1039ccc8c6184a5f09899dd8243f3852aae738a8ecc317c8302ea10db66b1d5d
5
5
  SHA512:
6
- metadata.gz: d65547dc4e985162671f3a5d32b66534ad9ceb7e17dbe1bbf516e16b0b820abadbf32aa045a0a431b36e92ea5ab1347539db220bc08d67c50095b501c6b56b62
7
- data.tar.gz: c86be55126a037ddeba3170076ac94b3d10cbe0f29e530aa5a2e077b62719998427668420c3802f2ae612cea4127f4536db16683466c8f9184678ec2284481f5
6
+ metadata.gz: 9cb24cb4005250306fee1e6c20003e3a922d72b21bd91bb1d5ea0a00a3fefee46baf51e2d48d58085783993c0a5ce405c589af0140865d87c0e54de353d2baea
7
+ data.tar.gz: adcce320a6c5713ead81f0d18d6d8332f4392854ed9eac086e58e50f3f4af18e4f411a922ce3cbc6d8c2ae3595662e6ed1c7d32d064c25672f55a5b75d2b1a69
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.6.3 (2025-10-15)
2
+
3
+ - Added `--non-concurrently` option
4
+ - Added support for multiple `--statement` options
5
+
1
6
  ## 0.6.2 (2025-07-27)
2
7
 
3
8
  - Fixed error with utility statements
data/README.md CHANGED
@@ -253,7 +253,7 @@ And run it with:
253
253
  docker run -ti ankane/dexter <connection-options>
254
254
  ```
255
255
 
256
- For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires Docker 20.04+ and `--add-host=host.docker.internal:host-gateway`).
256
+ For databases on the host machine, use `host.docker.internal` as the hostname (on Linux, this requires `--add-host=host.docker.internal:host-gateway`).
257
257
 
258
258
  ### Homebrew
259
259
 
data/lib/dexter/client.rb CHANGED
@@ -23,7 +23,7 @@ module Dexter
23
23
  connection.setup(options[:enable_hypopg])
24
24
 
25
25
  source =
26
- if options[:statement]
26
+ if options[:statement].any?
27
27
  # TODO raise error for --interval, --min-calls, --min-time
28
28
  StatementSource.new(options[:statement])
29
29
  elsif options[:pg_stat_statements]
@@ -63,7 +63,7 @@ module Dexter
63
63
  o.boolean "--pg-stat-activity", "use pg_stat_activity", default: false
64
64
  o.boolean "--pg-stat-statements", "use pg_stat_statements", default: false, help: false
65
65
  o.boolean "--stdin", "use stdin", default: false
66
- o.string "-s", "--statement", "process a single statement"
66
+ o.array "-s", "--statement", "process a single statement", delimiter: nil
67
67
  o.separator ""
68
68
 
69
69
  o.separator "Connection options:"
@@ -88,6 +88,7 @@ module Dexter
88
88
  o.integer "--min-cost", default: 100, help: false
89
89
  o.integer "--min-cost-savings-pct", default: 50, help: false
90
90
  o.string "--tablespace", "tablespace to create indexes"
91
+ o.boolean "--non-concurrently", "use non-concurrent index creation", default: false
91
92
  o.separator ""
92
93
 
93
94
  o.separator "Logging options:"
@@ -2,11 +2,12 @@ module Dexter
2
2
  class IndexCreator
3
3
  include Logging
4
4
 
5
- def initialize(connection, indexer, new_indexes, tablespace)
5
+ def initialize(connection, indexer, new_indexes, tablespace, concurrently)
6
6
  @connection = connection
7
7
  @indexer = indexer
8
8
  @new_indexes = new_indexes
9
9
  @tablespace = tablespace
10
+ @concurrently = concurrently
10
11
  end
11
12
 
12
13
  # 1. create lock
@@ -17,7 +18,9 @@ module Dexter
17
18
  with_advisory_lock do
18
19
  @new_indexes.each do |index|
19
20
  unless index_exists?(index)
20
- statement = String.new("CREATE INDEX CONCURRENTLY ON #{@connection.quote_ident(index[:table])} (#{index[:columns].map { |c| @connection.quote_ident(c) }.join(", ")})")
21
+ statement = String.new("CREATE INDEX")
22
+ statement << " CONCURRENTLY" if @concurrently
23
+ statement << " ON #{@connection.quote_ident(index[:table])} (#{index[:columns].map { |c| @connection.quote_ident(c) }.join(", ")})"
21
24
  statement << " TABLESPACE #{@connection.quote_ident(@tablespace)}" if @tablespace
22
25
  log "Creating index: #{statement}"
23
26
  started_at = monotonic_time
@@ -26,6 +29,8 @@ module Dexter
26
29
  log "Index created: #{((monotonic_time - started_at) * 1000).to_i} ms"
27
30
  rescue PG::LockNotAvailable
28
31
  log "Could not acquire lock: #{index[:table]}"
32
+ rescue PG::FeatureNotSupported => e
33
+ raise Error, e.message
29
34
  end
30
35
  end
31
36
  end
@@ -61,7 +61,7 @@ module Dexter
61
61
  show_debug_info(new_indexes, queries) if @log_level.start_with?("debug")
62
62
 
63
63
  # create new indexes
64
- IndexCreator.new(@connection, self, new_indexes, @tablespace).perform if @create && new_indexes.any?
64
+ IndexCreator.new(@connection, self, new_indexes, @tablespace, !@options[:non_concurrently]).perform if @create && new_indexes.any?
65
65
  end
66
66
 
67
67
  private
@@ -1,11 +1,13 @@
1
1
  module Dexter
2
2
  class StatementSource
3
- def initialize(statement)
4
- @statement = statement
3
+ def initialize(statements)
4
+ @statements = statements
5
5
  end
6
6
 
7
7
  def perform(collector)
8
- collector.add(@statement, 0, 0, true)
8
+ @statements.each do |statement|
9
+ collector.add(statement, 0, 0, true)
10
+ end
9
11
  end
10
12
  end
11
13
  end
@@ -1,3 +1,3 @@
1
1
  module Dexter
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pgdexter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane