duel-postgresql 0.1.3 → 0.1.5

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: 3066e4e14b701089420022b7e89ca2e7946fe0161d0e2ad0cf34af2bdc734e21
4
- data.tar.gz: f9e2131173d358d33f6b7609fc9e10f417a6334af81c0800b66d2c36c4a424d7
3
+ metadata.gz: bc55e93ddfcce9ccda67d1a02341d8afdb27b599ea031fd1a1ea9db38b4f0a30
4
+ data.tar.gz: edcf2b4280ec35fd2a0b3cb0e6402dc1643d32f5cf44d8c119e7c093164cc139
5
5
  SHA512:
6
- metadata.gz: 0f41bb792ae9bca5b138a01d36f8d21648d17839de123615618ee45bf945f1819fa17785990151695664ccd67ee3268a7a68a61a2b2143e9c9c30a216a32a0a1
7
- data.tar.gz: '08fa516b1621defd7e8173fad00cc4bd2a7c0e4631078619a034ad79f179a0d620137810359737fdaf2d84bd96592b958a152296d7f5e8136c9c222d16d4e40b'
6
+ metadata.gz: 31bee9421e4a333b89f6f80590c1ccebe94aea684ead7051eb9d1d3b12c58d6ee4cd0f5761aae35c857ac702e74a6ad8aa7bf4dadf4a3b096f8e2b2cd80f4443
7
+ data.tar.gz: c1a5214d4ef7903eb06503513052ee51f56fe002c7b32d9d690862343f7f878767f4c82846e843db656d7fadbe86ad170e5d892d6515393880420c43ff2e5a92
data/CHANGELOG.md CHANGED
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.1.5] - 2026-11-08
11
+
12
+ No changes of its own: released in step with the other Duel gems.
13
+
14
+ ## [0.1.4] - 2026-11-06
15
+
16
+ ### Fixed
17
+
18
+ - In pg's own repository, every worker measured the bundle's release
19
+ of pg, not its version's own, as the plugin required pg as it
20
+ loaded, in `.duel.rb`, before the worker loaded the version. It now
21
+ requires pg once it's used: in the runner, to start the server, and
22
+ in a worker, once the version has loaded.
23
+
10
24
  ## [0.1.3] - 2026-11-04
11
25
 
12
26
  No changes of its own: released in step with the other Duel gems.
@@ -85,7 +99,9 @@ later, with `pg_stat_statements`.
85
99
  CI.
86
100
  - RBS signatures in sig/, checked with Steep.
87
101
 
88
- [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.3...HEAD
102
+ [Unreleased]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.5...HEAD
103
+ [0.1.5]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.4...duel-postgresql-v0.1.5
104
+ [0.1.4]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.3...duel-postgresql-v0.1.4
89
105
  [0.1.3]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.2...duel-postgresql-v0.1.3
90
106
  [0.1.2]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.1...duel-postgresql-v0.1.2
91
107
  [0.1.1]: https://github.com/sferik/duel-ruby/compare/duel-postgresql-v0.1.0...duel-postgresql-v0.1.1
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Duel
4
4
  module PostgreSQL
5
- VERSION = "0.1.3"
5
+ VERSION = "0.1.5"
6
6
  end
7
7
  end
@@ -3,7 +3,6 @@
3
3
  require "duel"
4
4
  require "digest"
5
5
  require "fileutils"
6
- require "pg"
7
6
  require_relative "postgresql/version"
8
7
 
9
8
  module Duel
@@ -69,6 +68,7 @@ module Duel
69
68
  # Config#in_worker, and in tests, Duel::Testing.in_worker).
70
69
  def self.configure(config, bin: ENV.fetch("DUEL_POSTGRESQL_BIN", nil), settings: {}, setup: nil, env: %w[DATABASE_URL])
71
70
  config.prepare(:worker) do |w|
71
+ require_pg
72
72
  programs = File.expand_path(bin || Cluster.find_bin ||
73
73
  w.failed("no postgres on the PATH (give its directory as bin:, or DUEL_POSTGRESQL_BIN)"))
74
74
  data = w.path("data")
@@ -88,12 +88,25 @@ module Duel
88
88
  .merge(env.to_h { |name| [name, url] })
89
89
  end
90
90
  # (In the worker, libpq's environment is its server's.)
91
- connection = config.in_worker { |w| PG.connect.tap { |pg| w.at_stop { pg.close } } }
91
+ connection = config.in_worker do |w|
92
+ require_pg
93
+ PG.connect.tap { |pg| w.at_stop { pg.close } }
94
+ end
92
95
  statements = Statements.new(connection)
93
96
  config.metric(METRICS) { statements.read }.costly.details { |stretches, sample| statements.details(stretches, sample.n) }
94
97
  connection
95
98
  end
96
99
 
100
+ # Loads pg, once Duel has loaded the worker's version: not as the
101
+ # plugin loads, in .duel.rb, before it. In pg's own repository, pg is
102
+ # what's measured, and the worker would load whichever pg the load
103
+ # path led to first (the bundle's release, say), and keep it. (In the
104
+ # runner, which loads no version, the bundle's.)
105
+ # mutant:disable -- the tests' process has pg loaded from the start, so
106
+ # a require changes nothing there: test_loads_pg_only_when_used checks
107
+ # it, in a process of its own
108
+ def self.require_pg = require("pg")
109
+
97
110
  # Runs SQL on a connection of its own to +url+; returns the last
98
111
  # statement's result. (async_exec is exec, by its other name: one a
99
112
  # mutation can't make Kernel#exec.)
@@ -132,9 +145,14 @@ module Duel
132
145
 
133
146
  # STATEMENTS' columns, as pg decodes them: the query id as text, the
134
147
  # counts as Integers and the time (ms) as a Float, with no String
135
- # made for a number only to be parsed.
136
- COLUMNS = PG::TypeMapByColumn.new([nil, PG::TextDecoder::Integer.new, PG::TextDecoder::Integer.new,
137
- PG::TextDecoder::Integer.new, PG::TextDecoder::Float.new])
148
+ # made for a number only to be parsed. (Made once pg is loaded: see
149
+ # .require_pg.)
150
+ # mutant:disable -- kept from one reading to the next only so as not to
151
+ # make it again: a reading is the same without
152
+ def self.column_types
153
+ @column_types ||= PG::TypeMapByColumn.new([nil, PG::TextDecoder::Integer.new, PG::TextDecoder::Integer.new,
154
+ PG::TextDecoder::Integer.new, PG::TextDecoder::Float.new])
155
+ end
138
156
 
139
157
  # Statements' texts, by query id (a PostgreSQL array of them).
140
158
  TEXTS = "SELECT DISTINCT ON (queryid) queryid, coalesce(query, '') FROM pg_stat_statements WHERE queryid = ANY($1::bigint[])"
@@ -145,7 +163,7 @@ module Duel
145
163
  def self.columns(connection)
146
164
  settle
147
165
  # (None is NULL: every statement has a query id.)
148
- result = connection.async_exec(STATEMENTS).map_types!(COLUMNS)
166
+ result = connection.async_exec(STATEMENTS).map_types!(column_types)
149
167
  [result.column_values(0), result.column_values(1), result.column_values(2), result.column_values(3), result.column_values(4)]
150
168
  end
151
169
 
@@ -21,8 +21,13 @@ module Duel
21
21
  # these readings.
22
22
  STATEMENTS: String
23
23
 
24
- # STATEMENTS' columns, as pg decodes them.
25
- COLUMNS: ::PG::TypeMapByColumn
24
+ # STATEMENTS' columns, as pg decodes them (made once pg is loaded).
25
+ self.@column_types: ::PG::TypeMapByColumn?
26
+
27
+ def self.column_types: () -> ::PG::TypeMapByColumn
28
+
29
+ # Loads pg, once Duel has loaded the worker's version.
30
+ def self.require_pg: () -> bool
26
31
 
27
32
  # Statements' texts, by query id.
28
33
  TEXTS: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duel-postgresql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Berlin
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 4.0.23
77
+ rubygems_version: 4.0.24
78
78
  specification_version: 4
79
79
  summary: A PostgreSQL server for each Duel worker, and what it did for each benchmark
80
80
  test_files: []