cipherstash-pg 1.0.0.beta.1-arm64-darwin-22 → 1.0.0.beta.4-arm64-darwin-22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.appveyor.yml +42 -0
- data/.gems +6 -0
- data/.gemtest +0 -0
- data/.github/workflows/binary-gems.yml +117 -0
- data/.github/workflows/source-gem.yml +137 -0
- data/.gitignore +19 -0
- data/.hgsigs +34 -0
- data/.hgtags +41 -0
- data/.irbrc +23 -0
- data/.pryrc +23 -0
- data/.tm_properties +21 -0
- data/.travis.yml +49 -0
- data/Gemfile +3 -3
- data/Gemfile.lock +45 -0
- data/{History.rdoc → History.md} +168 -153
- data/README.ja.md +266 -0
- data/README.md +272 -0
- data/Rakefile +65 -104
- data/Rakefile.cross +298 -0
- data/certs/larskanis-2023.pem +24 -0
- data/cipherstash-pg.gemspec +0 -0
- data/lib/2.7/pg_ext.bundle +0 -0
- data/lib/3.0/pg_ext.bundle +0 -0
- data/lib/3.1/pg_ext.bundle +0 -0
- data/lib/3.2/pg_ext.bundle +0 -0
- data/lib/cipherstash-pg/basic_type_map_based_on_result.rb +11 -0
- data/lib/cipherstash-pg/basic_type_map_for_queries.rb +113 -0
- data/lib/cipherstash-pg/basic_type_map_for_results.rb +30 -0
- data/lib/cipherstash-pg/basic_type_registry.rb +206 -0
- data/lib/cipherstash-pg/binary_decoder.rb +21 -0
- data/lib/cipherstash-pg/coder.rb +82 -0
- data/lib/cipherstash-pg/connection.rb +467 -0
- data/lib/cipherstash-pg/constants.rb +3 -0
- data/lib/cipherstash-pg/exceptions.rb +19 -0
- data/lib/cipherstash-pg/result.rb +22 -0
- data/lib/cipherstash-pg/text_decoder.rb +43 -0
- data/lib/cipherstash-pg/text_encoder.rb +67 -0
- data/lib/cipherstash-pg/tuple.rb +24 -0
- data/lib/cipherstash-pg/type_map_by_column.rb +11 -0
- data/lib/cipherstash-pg/version.rb +3 -0
- data/lib/cipherstash-pg.rb +56 -11
- data/lib/libpq.5.dylib +0 -0
- data/misc/openssl-pg-segfault.rb +15 -25
- data/misc/postgres/Rakefile +13 -20
- data/misc/postgres/lib/postgres.rb +10 -14
- data/misc/ruby-pg/Rakefile +13 -20
- data/misc/ruby-pg/lib/ruby/pg.rb +10 -14
- data/rakelib/task_extension.rb +17 -31
- data/sample/array_insert.rb +7 -20
- data/sample/async_api.rb +54 -96
- data/sample/async_copyto.rb +20 -35
- data/sample/async_mixed.rb +22 -50
- data/sample/check_conn.rb +8 -20
- data/sample/copydata.rb +18 -68
- data/sample/copyfrom.rb +26 -78
- data/sample/copyto.rb +10 -16
- data/sample/cursor.rb +9 -19
- data/sample/disk_usage_report.rb +89 -174
- data/sample/issue-119.rb +45 -93
- data/sample/losample.rb +48 -66
- data/sample/minimal-testcase.rb +6 -17
- data/sample/notify_wait.rb +21 -67
- data/sample/pg_statistics.rb +100 -281
- data/sample/replication_monitor.rb +119 -218
- data/sample/test_binary_values.rb +14 -30
- data/sample/wal_shipper.rb +199 -431
- data/sample/warehouse_partitions.rb +157 -307
- data/translation/.po4a-version +7 -0
- data/translation/po/all.pot +875 -0
- data/translation/po/ja.po +868 -0
- data/translation/po4a.cfg +9 -0
- metadata +50 -28
- data/README.ja.rdoc +0 -13
- data/README.rdoc +0 -233
- data/lib/pg/basic_type_map_based_on_result.rb +0 -47
- data/lib/pg/basic_type_map_for_queries.rb +0 -193
- data/lib/pg/basic_type_map_for_results.rb +0 -81
- data/lib/pg/basic_type_registry.rb +0 -301
- data/lib/pg/binary_decoder.rb +0 -23
- data/lib/pg/coder.rb +0 -104
- data/lib/pg/connection.rb +0 -878
- data/lib/pg/constants.rb +0 -12
- data/lib/pg/exceptions.rb +0 -18
- data/lib/pg/result.rb +0 -43
- data/lib/pg/text_decoder.rb +0 -46
- data/lib/pg/text_encoder.rb +0 -59
- data/lib/pg/tuple.rb +0 -30
- data/lib/pg/type_map_by_column.rb +0 -16
- data/lib/pg/version.rb +0 -4
- data/lib/pg.rb +0 -55
data/sample/pg_statistics.rb
CHANGED
@@ -1,285 +1,104 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
# Mahlon E. Smith <mahlon@martini.nu>
|
6
|
-
#
|
7
|
-
# Based on queries by Kenny Gorman.
|
8
|
-
# http://www.kennygorman.com/wordpress/?page_id=491
|
9
|
-
#
|
10
|
-
# An example gnuplot input script is included in the __END__ block
|
11
|
-
# of this script. Using it, you can feed the output this script
|
12
|
-
# generates to gnuplot (after removing header lines) to generate
|
13
|
-
# some nice performance charts.
|
14
|
-
#
|
15
|
-
|
16
|
-
require 'ostruct'
|
17
|
-
require 'optparse'
|
18
|
-
require 'etc'
|
19
|
-
require 'pg'
|
20
|
-
|
21
|
-
|
22
|
-
### PostgreSQL Stats. Fetch information from pg_stat_* tables.
|
23
|
-
### Optionally run in a continuous loop, displaying deltas.
|
24
|
-
###
|
1
|
+
require("ostruct")
|
2
|
+
require("optparse")
|
3
|
+
require("etc")
|
4
|
+
require("cipherstash-pg")
|
25
5
|
class Stats
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
# calculate deltas
|
71
|
-
#
|
72
|
-
delta = current_stat.inject({}) do |h, pair|
|
73
|
-
stat, val = *pair
|
74
|
-
|
75
|
-
if %w[ activeq locks bkends ].include?( stat )
|
76
|
-
h[stat] = current_stat[stat].to_i
|
77
|
-
else
|
78
|
-
h[stat] = current_stat[stat].to_i - @last[stat].to_i
|
79
|
-
end
|
80
|
-
|
81
|
-
h
|
82
|
-
end
|
83
|
-
delta[ 'time' ] = Time.now.strftime('%F %T')
|
84
|
-
|
85
|
-
# new values
|
86
|
-
#
|
87
|
-
puts "%-20s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s" % [
|
88
|
-
delta['time'], delta['commits'], delta['rollbks'], delta['blksrd'],
|
89
|
-
delta['blkshit'], delta['bkends'], delta['seqscan'],
|
90
|
-
delta['seqtprd'], delta['idxscn'], delta['idxtrd'],
|
91
|
-
delta['ins'], delta['upd'], delta['del'], delta['locks'], delta['activeq']
|
92
|
-
]
|
93
|
-
|
94
|
-
@last = current_stat
|
95
|
-
run_count += 1
|
96
|
-
sleep @opts.interval
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
|
101
|
-
### Query the database for performance measurements. Returns a hash.
|
102
|
-
###
|
103
|
-
def get_stats
|
104
|
-
res = @db.exec %Q{
|
105
|
-
SELECT
|
106
|
-
MAX(stat_db.xact_commit) AS commits,
|
107
|
-
MAX(stat_db.xact_rollback) AS rollbks,
|
108
|
-
MAX(stat_db.blks_read) AS blksrd,
|
109
|
-
MAX(stat_db.blks_hit) AS blkshit,
|
110
|
-
MAX(stat_db.numbackends) AS bkends,
|
111
|
-
SUM(stat_tables.seq_scan) AS seqscan,
|
112
|
-
SUM(stat_tables.seq_tup_read) AS seqtprd,
|
113
|
-
SUM(stat_tables.idx_scan) AS idxscn,
|
114
|
-
SUM(stat_tables.idx_tup_fetch) AS idxtrd,
|
115
|
-
SUM(stat_tables.n_tup_ins) AS ins,
|
116
|
-
SUM(stat_tables.n_tup_upd) AS upd,
|
117
|
-
SUM(stat_tables.n_tup_del) AS del,
|
118
|
-
MAX(stat_locks.locks) AS locks,
|
119
|
-
MAX(activity.sess) AS activeq
|
120
|
-
FROM
|
121
|
-
pg_stat_database AS stat_db,
|
122
|
-
pg_stat_user_tables AS stat_tables,
|
123
|
-
(SELECT COUNT(*) AS locks FROM pg_locks ) AS stat_locks,
|
124
|
-
(SELECT COUNT(*) AS sess FROM pg_stat_activity WHERE current_query <> '<IDLE>') AS activity
|
125
|
-
WHERE
|
126
|
-
stat_db.datname = '%s';
|
127
|
-
} % [ @opts.database ]
|
128
|
-
|
129
|
-
return res[0]
|
130
|
-
end
|
6
|
+
VERSION = "Id"
|
7
|
+
|
8
|
+
def initialize(opts)
|
9
|
+
@opts = opts
|
10
|
+
@db = CipherStashPG.connect(:dbname => opts.database, :host => opts.host, :port => opts.port, :user => opts.user, :password => opts.pass, :sslmode => "prefer")
|
11
|
+
@last = nil
|
12
|
+
end
|
13
|
+
|
14
|
+
public
|
15
|
+
|
16
|
+
def run
|
17
|
+
run_count = 0
|
18
|
+
loop do
|
19
|
+
current_stat = self.get_stats
|
20
|
+
if @last.nil? then
|
21
|
+
@last = current_stat
|
22
|
+
sleep(@opts.interval)
|
23
|
+
next
|
24
|
+
end
|
25
|
+
if ((run_count == 0) or ((run_count % 50) == 0)) then
|
26
|
+
puts(("%-20s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s" % ["time", "commits", "rollbks", "blksrd", "blkshit", "bkends", "seqscan", "seqtprd", "idxscn", "idxtrd", "ins", "upd", "del", "locks", "activeq"]))
|
27
|
+
end
|
28
|
+
delta = current_stat.inject({}) do |h, pair|
|
29
|
+
stat, val = *pair
|
30
|
+
if ["activeq", "locks", "bkends"].include?(stat) then
|
31
|
+
h[stat] = current_stat[stat].to_i
|
32
|
+
else
|
33
|
+
h[stat] = (current_stat[stat].to_i - @last[stat].to_i)
|
34
|
+
end
|
35
|
+
h
|
36
|
+
end
|
37
|
+
delta["time"] = Time.now.strftime("%F %T")
|
38
|
+
puts(("%-20s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s%12s" % [delta["time"], delta["commits"], delta["rollbks"], delta["blksrd"], delta["blkshit"], delta["bkends"], delta["seqscan"], delta["seqtprd"], delta["idxscn"], delta["idxtrd"], delta["ins"], delta["upd"], delta["del"], delta["locks"], delta["activeq"]]))
|
39
|
+
@last = current_stat
|
40
|
+
run_count = (run_count + 1)
|
41
|
+
sleep(@opts.interval)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_stats
|
46
|
+
res = @db.exec(("\n\t\t\tSELECT\n\t\t\t\tMAX(stat_db.xact_commit) AS commits,\n\t\t\t\tMAX(stat_db.xact_rollback) AS rollbks,\n\t\t\t\tMAX(stat_db.blks_read) AS blksrd,\n\t\t\t\tMAX(stat_db.blks_hit) AS blkshit,\n\t\t\t\tMAX(stat_db.numbackends) AS bkends,\n\t\t\t\tSUM(stat_tables.seq_scan) AS seqscan,\n\t\t\t\tSUM(stat_tables.seq_tup_read) AS seqtprd,\n\t\t\t\tSUM(stat_tables.idx_scan) AS idxscn,\n\t\t\t\tSUM(stat_tables.idx_tup_fetch) AS idxtrd,\n\t\t\t\tSUM(stat_tables.n_tup_ins) AS ins,\n\t\t\t\tSUM(stat_tables.n_tup_upd) AS upd,\n\t\t\t\tSUM(stat_tables.n_tup_del) AS del,\n\t\t\t\tMAX(stat_locks.locks) AS locks,\n\t\t\t\tMAX(activity.sess) AS activeq\n\t\t\tFROM\n\t\t\t\tpg_stat_database AS stat_db,\n\t\t\t\tpg_stat_user_tables AS stat_tables,\n\t\t\t\t(SELECT COUNT(*) AS locks FROM pg_locks ) AS stat_locks,\n\t\t\t\t(SELECT COUNT(*) AS sess FROM pg_stat_activity WHERE current_query <> '<IDLE>') AS activity\n\t\t\tWHERE\n\t\t\t\tstat_db.datname = '%s';\n\t\t" % [@opts.database]))
|
47
|
+
return res[0]
|
48
|
+
end
|
131
49
|
end
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
opts.separator 'Other options:'
|
183
|
-
|
184
|
-
opts.on( '-i', '--interval SECONDS', Integer,
|
185
|
-
"refresh interval in seconds (default: \"#{options.interval}\")") do |seconds|
|
186
|
-
options.interval = seconds
|
187
|
-
end
|
188
|
-
|
189
|
-
opts.on_tail( '--help', 'show this help, then exit' ) do
|
190
|
-
$stderr.puts opts
|
191
|
-
exit
|
192
|
-
end
|
193
|
-
|
194
|
-
opts.on_tail( '--version', 'output version information, then exit' ) do
|
195
|
-
puts Stats::VERSION
|
196
|
-
exit
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
opts.parse!( args )
|
201
|
-
return options
|
50
|
+
def parse_args(args)
|
51
|
+
options = OpenStruct.new
|
52
|
+
options.database = Etc.getpwuid(Process.uid).name
|
53
|
+
options.host = "127.0.0.1"
|
54
|
+
options.port = 5432
|
55
|
+
options.user = Etc.getpwuid(Process.uid).name
|
56
|
+
options.sslmode = "disable"
|
57
|
+
options.interval = 5
|
58
|
+
opts = OptionParser.new do |opts|
|
59
|
+
opts.banner = "Usage: #{$0} [options]"
|
60
|
+
opts.separator("")
|
61
|
+
opts.separator("Connection options:")
|
62
|
+
opts.on("-d", "--database DBNAME", "specify the database to connect to (default: \"#{options.database}\")") do |db|
|
63
|
+
options.database = db
|
64
|
+
end
|
65
|
+
opts.on("-h", "--host HOSTNAME", "database server host") do |host|
|
66
|
+
options.host = host
|
67
|
+
end
|
68
|
+
opts.on("-p", "--port PORT", Integer, "database server port (default: \"#{options.port}\")") do |port|
|
69
|
+
options.port = port
|
70
|
+
end
|
71
|
+
opts.on("-U", "--user NAME", "database user name (default: \"#{options.user}\")") do |user|
|
72
|
+
options.user = user
|
73
|
+
end
|
74
|
+
opts.on("-W", "force password prompt") do |pw|
|
75
|
+
print("Password: ")
|
76
|
+
begin
|
77
|
+
(system("stty -echo")
|
78
|
+
options.pass = gets.chomp)
|
79
|
+
ensure
|
80
|
+
(system("stty echo")
|
81
|
+
puts)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
opts.separator("")
|
85
|
+
opts.separator("Other options:")
|
86
|
+
opts.on("-i", "--interval SECONDS", Integer, "refresh interval in seconds (default: \"#{options.interval}\")") do |seconds|
|
87
|
+
options.interval = seconds
|
88
|
+
end
|
89
|
+
opts.on_tail("--help", "show this help, then exit") do
|
90
|
+
$stderr.puts(opts)
|
91
|
+
exit
|
92
|
+
end
|
93
|
+
opts.on_tail("--version", "output version information, then exit") do
|
94
|
+
puts(Stats::VERSION)
|
95
|
+
exit
|
96
|
+
end
|
97
|
+
end
|
98
|
+
opts.parse!(args)
|
99
|
+
return options
|
202
100
|
end
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
###
|
207
|
-
if __FILE__ == $0
|
208
|
-
$stdout.sync = true
|
209
|
-
Stats.new( parse_args( ARGV ) ).run
|
101
|
+
if ("(string)" == $0) then
|
102
|
+
$stdout.sync = true
|
103
|
+
Stats.new(parse_args(ARGV)).run
|
210
104
|
end
|
211
|
-
|
212
|
-
|
213
|
-
__END__
|
214
|
-
######################################################################
|
215
|
-
### T E R M I N A L O P T I O N S
|
216
|
-
######################################################################
|
217
|
-
|
218
|
-
#set terminal png nocrop enhanced font arial 8 size '800x600' x000000 xffffff x444444
|
219
|
-
#set output 'graph.png'
|
220
|
-
|
221
|
-
set terminal pdf linewidth 4 size 11,8
|
222
|
-
set output 'graph.pdf'
|
223
|
-
|
224
|
-
#set terminal aqua
|
225
|
-
|
226
|
-
|
227
|
-
######################################################################
|
228
|
-
### O P T I O N S F O R A L L G R A P H S
|
229
|
-
######################################################################
|
230
|
-
|
231
|
-
set multiplot layout 2,1 title "PostgreSQL Statistics\n5 second sample rate (smoothed)"
|
232
|
-
|
233
|
-
set grid x y
|
234
|
-
set key right vertical outside
|
235
|
-
set key nobox
|
236
|
-
set xdata time
|
237
|
-
set timefmt "%Y-%m-%d.%H:%M:%S"
|
238
|
-
set format x "%l%p"
|
239
|
-
set xtic rotate by -45
|
240
|
-
input_file = "database_stats.txt"
|
241
|
-
|
242
|
-
# edit to taste!
|
243
|
-
set xrange ["2012-04-16.00:00:00":"2012-04-17.00:00:00"]
|
244
|
-
|
245
|
-
|
246
|
-
######################################################################
|
247
|
-
### G R A P H 1
|
248
|
-
######################################################################
|
249
|
-
|
250
|
-
set title "Database Operations and Connection Totals"
|
251
|
-
set yrange [0:200]
|
252
|
-
|
253
|
-
plot \
|
254
|
-
input_file using 1:2 title "Commits" with lines smooth bezier, \
|
255
|
-
input_file using 1:3 title "Rollbacks" with lines smooth bezier, \
|
256
|
-
input_file using 1:11 title "Inserts" with lines smooth bezier, \
|
257
|
-
input_file using 1:12 title "Updates" with lines smooth bezier, \
|
258
|
-
input_file using 1:13 title "Deletes" with lines smooth bezier, \
|
259
|
-
input_file using 1:6 title "Backends (total)" with lines, \
|
260
|
-
input_file using 1:15 title "Active queries (total)" with lines smooth bezier
|
261
|
-
|
262
|
-
|
263
|
-
######################################################################
|
264
|
-
### G R A P H 2
|
265
|
-
######################################################################
|
266
|
-
|
267
|
-
set title "Backend Performance"
|
268
|
-
set yrange [0:10000]
|
269
|
-
|
270
|
-
plot \
|
271
|
-
input_file using 1:4 title "Block (cache) reads" with lines smooth bezier, \
|
272
|
-
input_file using 1:5 title "Block (cache) hits" with lines smooth bezier, \
|
273
|
-
input_file using 1:7 title "Sequence scans" with lines smooth bezier, \
|
274
|
-
input_file using 1:8 title "Sequence tuple reads" with lines smooth bezier, \
|
275
|
-
input_file using 1:9 title "Index scans" with lines smooth bezier, \
|
276
|
-
input_file using 1:10 title "Index tuple reads" with lines smooth bezier
|
277
|
-
|
278
|
-
|
279
|
-
######################################################################
|
280
|
-
### C L E A N U P
|
281
|
-
######################################################################
|
282
|
-
|
283
|
-
unset multiplot
|
284
|
-
reset
|
285
|
-
|