pg 0.18.1 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/.appveyor.yml +42 -0
- data/.gems +6 -0
- data/.github/workflows/binary-gems.yml +117 -0
- data/.github/workflows/source-gem.yml +141 -0
- data/.gitignore +22 -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/BSDL +2 -2
- data/Gemfile +17 -0
- data/History.md +901 -0
- data/Manifest.txt +8 -21
- data/README-Windows.rdoc +17 -28
- data/README.ja.md +300 -0
- data/README.md +286 -0
- data/Rakefile +43 -131
- data/Rakefile.cross +89 -70
- data/certs/ged.pem +24 -0
- data/certs/kanis@comcard.de.pem +20 -0
- data/certs/larskanis-2022.pem +26 -0
- data/certs/larskanis-2023.pem +24 -0
- data/certs/larskanis-2024.pem +24 -0
- data/ext/errorcodes.def +113 -0
- data/ext/errorcodes.rb +1 -1
- data/ext/errorcodes.txt +36 -2
- data/ext/extconf.rb +128 -55
- data/ext/gvl_wrappers.c +8 -0
- data/ext/gvl_wrappers.h +44 -33
- data/ext/pg.c +228 -202
- data/ext/pg.h +108 -99
- data/ext/pg_binary_decoder.c +164 -16
- data/ext/pg_binary_encoder.c +249 -22
- data/ext/pg_coder.c +189 -44
- data/ext/pg_connection.c +1889 -1195
- data/ext/pg_copy_coder.c +398 -42
- data/ext/pg_errors.c +1 -1
- data/ext/pg_record_coder.c +522 -0
- data/ext/pg_result.c +729 -234
- data/ext/pg_text_decoder.c +635 -52
- data/ext/pg_text_encoder.c +294 -130
- data/ext/pg_tuple.c +572 -0
- data/ext/pg_type_map.c +64 -23
- data/ext/pg_type_map_all_strings.c +21 -7
- data/ext/pg_type_map_by_class.c +59 -27
- data/ext/pg_type_map_by_column.c +86 -43
- data/ext/pg_type_map_by_mri_type.c +50 -21
- data/ext/pg_type_map_by_oid.c +62 -29
- data/ext/pg_type_map_in_ruby.c +59 -28
- data/ext/{util.c → pg_util.c} +13 -13
- data/ext/{util.h → pg_util.h} +3 -3
- data/lib/pg/basic_type_map_based_on_result.rb +67 -0
- data/lib/pg/basic_type_map_for_queries.rb +202 -0
- data/lib/pg/basic_type_map_for_results.rb +104 -0
- data/lib/pg/basic_type_registry.rb +303 -0
- data/lib/pg/binary_decoder/date.rb +9 -0
- data/lib/pg/binary_decoder/timestamp.rb +26 -0
- data/lib/pg/binary_encoder/timestamp.rb +20 -0
- data/lib/pg/coder.rb +36 -13
- data/lib/pg/connection.rb +813 -74
- data/lib/pg/exceptions.rb +16 -2
- data/lib/pg/result.rb +24 -7
- data/lib/pg/text_decoder/date.rb +18 -0
- data/lib/pg/text_decoder/inet.rb +9 -0
- data/lib/pg/text_decoder/json.rb +14 -0
- data/lib/pg/text_decoder/numeric.rb +9 -0
- data/lib/pg/text_decoder/timestamp.rb +30 -0
- data/lib/pg/text_encoder/date.rb +12 -0
- data/lib/pg/text_encoder/inet.rb +28 -0
- data/lib/pg/text_encoder/json.rb +14 -0
- data/lib/pg/text_encoder/numeric.rb +9 -0
- data/lib/pg/text_encoder/timestamp.rb +24 -0
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +3 -2
- data/lib/pg/version.rb +4 -0
- data/lib/pg.rb +106 -41
- data/misc/openssl-pg-segfault.rb +31 -0
- data/misc/postgres/History.txt +9 -0
- data/misc/postgres/Manifest.txt +5 -0
- data/misc/postgres/README.txt +21 -0
- data/misc/postgres/Rakefile +21 -0
- data/misc/postgres/lib/postgres.rb +16 -0
- data/misc/ruby-pg/History.txt +9 -0
- data/misc/ruby-pg/Manifest.txt +5 -0
- data/misc/ruby-pg/README.txt +21 -0
- data/misc/ruby-pg/Rakefile +21 -0
- data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
- data/pg.gemspec +34 -0
- data/rakelib/task_extension.rb +46 -0
- data/sample/array_insert.rb +1 -1
- data/sample/async_api.rb +4 -8
- data/sample/async_copyto.rb +1 -1
- data/sample/async_mixed.rb +1 -1
- data/sample/check_conn.rb +1 -1
- data/sample/copydata.rb +71 -0
- data/sample/copyfrom.rb +1 -1
- data/sample/copyto.rb +1 -1
- data/sample/cursor.rb +1 -1
- data/sample/disk_usage_report.rb +6 -15
- data/sample/issue-119.rb +2 -2
- data/sample/losample.rb +1 -1
- data/sample/minimal-testcase.rb +2 -2
- data/sample/notify_wait.rb +1 -1
- data/sample/pg_statistics.rb +6 -15
- data/sample/replication_monitor.rb +9 -18
- data/sample/test_binary_values.rb +1 -1
- data/sample/wal_shipper.rb +2 -2
- data/sample/warehouse_partitions.rb +8 -17
- data.tar.gz.sig +0 -0
- metadata +135 -207
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -5378
- data/History.rdoc +0 -297
- data/README.ja.rdoc +0 -14
- data/README.rdoc +0 -161
- data/lib/pg/basic_type_mapping.rb +0 -399
- data/lib/pg/constants.rb +0 -11
- data/lib/pg/text_decoder.rb +0 -42
- data/lib/pg/text_encoder.rb +0 -27
- data/spec/data/expected_trace.out +0 -26
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +0 -355
- data/spec/pg/basic_type_mapping_spec.rb +0 -251
- data/spec/pg/connection_spec.rb +0 -1459
- data/spec/pg/result_spec.rb +0 -449
- data/spec/pg/type_map_by_class_spec.rb +0 -138
- data/spec/pg/type_map_by_column_spec.rb +0 -222
- data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
- data/spec/pg/type_map_by_oid_spec.rb +0 -149
- data/spec/pg/type_map_in_ruby_spec.rb +0 -164
- data/spec/pg/type_map_spec.rb +0 -22
- data/spec/pg/type_spec.rb +0 -665
- data/spec/pg_spec.rb +0 -50
data/pg.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
|
4
|
+
require_relative 'lib/pg/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pg"
|
8
|
+
spec.version = PG::VERSION
|
9
|
+
spec.authors = ["Michael Granger", "Lars Kanis"]
|
10
|
+
spec.email = ["ged@FaerieMUD.org", "lars@greiz-reinsdorf.de"]
|
11
|
+
|
12
|
+
spec.summary = "Pg is the Ruby interface to the PostgreSQL RDBMS"
|
13
|
+
spec.description = "Pg is the Ruby interface to the PostgreSQL RDBMS. It works with PostgreSQL 9.3 and later."
|
14
|
+
spec.homepage = "https://github.com/ged/ruby-pg"
|
15
|
+
spec.license = "BSD-2-Clause"
|
16
|
+
spec.required_ruby_version = ">= 2.5"
|
17
|
+
|
18
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
19
|
+
spec.metadata["source_code_uri"] = "https://github.com/ged/ruby-pg"
|
20
|
+
spec.metadata["changelog_uri"] = "https://github.com/ged/ruby-pg/blob/master/History.md"
|
21
|
+
spec.metadata["documentation_uri"] = "http://deveiate.org/code/pg"
|
22
|
+
|
23
|
+
# Specify which files should be added to the gem when it is released.
|
24
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
25
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
26
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features|translation)/}) }
|
27
|
+
end
|
28
|
+
spec.extensions = ["ext/extconf.rb"]
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
spec.cert_chain = ["certs/ged.pem"]
|
31
|
+
spec.rdoc_options = ["--main", "README.md",
|
32
|
+
"--title", "PG: The Ruby PostgreSQL Driver"]
|
33
|
+
spec.extra_rdoc_files = `git ls-files -z *.rdoc *.md lib/*.rb lib/*/*.rb lib/*/*/*.rb ext/*.c ext/*.h`.split("\x0")
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# This source code is borrowed from:
|
2
|
+
# https://github.com/oneclick/rubyinstaller2/blob/b3dcbf69f131e44c78ea3a1c5e0041c223f266ce/lib/ruby_installer/build/utils.rb#L104-L144
|
3
|
+
|
4
|
+
module TaskExtension
|
5
|
+
# Extend rake's file task to be defined only once and to check the expected file is indeed generated
|
6
|
+
#
|
7
|
+
# The same as #task, but for #file.
|
8
|
+
# In addition this file task raises an error, if the file that is expected to be generated is not present after the block was executed.
|
9
|
+
def file(name, *args, &block)
|
10
|
+
task_once(name, block) do
|
11
|
+
super(name, *args) do |ta|
|
12
|
+
block&.call(ta).tap do
|
13
|
+
raise "file #{ta.name} is missing after task executed" unless File.exist?(ta.name)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Extend rake's task definition to be defined only once, even if called several times
|
20
|
+
#
|
21
|
+
# This allows to define common tasks next to specific tasks.
|
22
|
+
# It is expected that any variation of the task's block is reflected in the task name or namespace.
|
23
|
+
# If the task name is identical, the task block is executed only once, even if the file task definition is executed twice.
|
24
|
+
def task(name, *args, &block)
|
25
|
+
task_once(name, block) do
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private def task_once(name, block)
|
31
|
+
name = name.keys.first if name.is_a?(Hash)
|
32
|
+
if block &&
|
33
|
+
Rake::Task.task_defined?(name) &&
|
34
|
+
Rake::Task[name].instance_variable_get('@task_block_location') == block.source_location
|
35
|
+
# task is already defined for this target and the same block
|
36
|
+
# So skip double definition of the same action
|
37
|
+
Rake::Task[name]
|
38
|
+
elsif block
|
39
|
+
yield.tap do
|
40
|
+
Rake::Task[name].instance_variable_set('@task_block_location', block.source_location)
|
41
|
+
end
|
42
|
+
else
|
43
|
+
yield
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/sample/array_insert.rb
CHANGED
data/sample/async_api.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'pg'
|
4
4
|
|
@@ -27,10 +27,6 @@ conn = PG::Connection.connect_start( :dbname => 'test' ) or
|
|
27
27
|
abort "Connection failed: %s" % [ conn.error_message ] if
|
28
28
|
conn.status == PG::CONNECTION_BAD
|
29
29
|
|
30
|
-
# Now grab a reference to the underlying socket so we know when the
|
31
|
-
# connection is established
|
32
|
-
socket = conn.socket_io
|
33
|
-
|
34
30
|
# Track the progress of the connection, waiting for the socket to become readable/writable
|
35
31
|
# before polling it
|
36
32
|
poll_status = PG::PGRES_POLLING_WRITING
|
@@ -41,13 +37,13 @@ until poll_status == PG::PGRES_POLLING_OK ||
|
|
41
37
|
case poll_status
|
42
38
|
when PG::PGRES_POLLING_READING
|
43
39
|
output_progress " waiting for socket to become readable"
|
44
|
-
select( [
|
40
|
+
select( [conn.socket_io], nil, nil, TIMEOUT ) or
|
45
41
|
raise "Asynchronous connection timed out!"
|
46
42
|
|
47
43
|
# ...and the same for when the socket needs to write
|
48
44
|
when PG::PGRES_POLLING_WRITING
|
49
45
|
output_progress " waiting for socket to become writable"
|
50
|
-
select( nil, [
|
46
|
+
select( nil, [conn.socket_io], nil, TIMEOUT ) or
|
51
47
|
raise "Asynchronous connection timed out!"
|
52
48
|
end
|
53
49
|
|
@@ -85,7 +81,7 @@ loop do
|
|
85
81
|
# Buffer any incoming data on the socket until a full result is ready.
|
86
82
|
conn.consume_input
|
87
83
|
while conn.is_busy
|
88
|
-
select( [
|
84
|
+
select( [conn.socket_io], nil, nil, TIMEOUT ) or
|
89
85
|
raise "Timeout waiting for query response."
|
90
86
|
conn.consume_input
|
91
87
|
end
|
data/sample/async_copyto.rb
CHANGED
data/sample/async_mixed.rb
CHANGED
data/sample/check_conn.rb
CHANGED
data/sample/copydata.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'pg'
|
4
|
+
require 'stringio'
|
5
|
+
|
6
|
+
$stderr.puts "Opening database connection ..."
|
7
|
+
conn = PG.connect( dbname: 'test' )
|
8
|
+
|
9
|
+
conn.exec( <<END_SQL )
|
10
|
+
DROP TABLE IF EXISTS logs;
|
11
|
+
CREATE TABLE logs (
|
12
|
+
client_ip inet,
|
13
|
+
username text,
|
14
|
+
ts timestamp,
|
15
|
+
request text,
|
16
|
+
status smallint,
|
17
|
+
bytes int
|
18
|
+
);
|
19
|
+
END_SQL
|
20
|
+
|
21
|
+
csv_io = StringIO.new( <<"END_DATA" )
|
22
|
+
"127.0.0.1","","30/Aug/2010:08:21:24 -0700","GET /manual/ HTTP/1.1",404,205
|
23
|
+
"127.0.0.1","","30/Aug/2010:08:21:24 -0700","GET /favicon.ico HTTP/1.1",404,209
|
24
|
+
"127.0.0.1","","30/Aug/2010:08:21:24 -0700","GET /favicon.ico HTTP/1.1",404,209
|
25
|
+
"127.0.0.1","","30/Aug/2010:08:22:29 -0700","GET /manual/ HTTP/1.1",200,11094
|
26
|
+
"127.0.0.1","","30/Aug/2010:08:22:38 -0700","GET /manual/index.html HTTP/1.1",200,725
|
27
|
+
"127.0.0.1","","30/Aug/2010:08:27:56 -0700","GET /manual/ HTTP/1.1",200,11094
|
28
|
+
"127.0.0.1","","30/Aug/2010:08:27:57 -0700","GET /manual/ HTTP/1.1",200,11094
|
29
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/index.html HTTP/1.1",200,7709
|
30
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/images/feather.gif HTTP/1.1",200,6471
|
31
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/images/left.gif HTTP/1.1",200,60
|
32
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/style/css/manual.css HTTP/1.1",200,18674
|
33
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/style/css/manual-print.css HTTP/1.1",200,13200
|
34
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/images/favicon.ico HTTP/1.1",200,1078
|
35
|
+
"127.0.0.1","","30/Aug/2010:08:28:06 -0700","GET /manual/style/css/manual-loose-100pc.css HTTP/1.1",200,3065
|
36
|
+
"127.0.0.1","","30/Aug/2010:08:28:14 -0700","OPTIONS * HTTP/1.0",200,0
|
37
|
+
"127.0.0.1","","30/Aug/2010:08:28:15 -0700","OPTIONS * HTTP/1.0",200,0
|
38
|
+
"127.0.0.1","","30/Aug/2010:08:28:47 -0700","GET /manual/mod/directives.html HTTP/1.1",200,33561
|
39
|
+
"127.0.0.1","","30/Aug/2010:08:28:53 -0700","GET /manual/mod/mpm_common.html HTTP/1.1",200,67683
|
40
|
+
"127.0.0.1","","30/Aug/2010:08:28:53 -0700","GET /manual/images/down.gif HTTP/1.1",200,56
|
41
|
+
"127.0.0.1","","30/Aug/2010:08:28:53 -0700","GET /manual/images/up.gif HTTP/1.1",200,57
|
42
|
+
"127.0.0.1","","30/Aug/2010:09:19:58 -0700","GET /manual/mod/mod_log_config.html HTTP/1.1",200,28307
|
43
|
+
"127.0.0.1","","30/Aug/2010:09:20:19 -0700","GET /manual/mod/core.html HTTP/1.1",200,194144
|
44
|
+
"127.0.0.1","","30/Aug/2010:16:02:56 -0700","GET /manual/ HTTP/1.1",200,11094
|
45
|
+
"127.0.0.1","","30/Aug/2010:16:03:00 -0700","GET /manual/ HTTP/1.1",200,11094
|
46
|
+
"127.0.0.1","","30/Aug/2010:16:06:16 -0700","GET /manual/mod/mod_dir.html HTTP/1.1",200,10583
|
47
|
+
"127.0.0.1","","30/Aug/2010:16:06:44 -0700","GET /manual/ HTTP/1.1",200,7709
|
48
|
+
END_DATA
|
49
|
+
|
50
|
+
### You can test the error case from the database side easily by
|
51
|
+
### changing one of the numbers at the end of one of the above rows to
|
52
|
+
### something non-numeric like "-".
|
53
|
+
|
54
|
+
$stderr.puts "Running COPY command with data ..."
|
55
|
+
buf = ''
|
56
|
+
conn.transaction do
|
57
|
+
res = conn.copy_data( "COPY logs FROM STDIN WITH csv" ) do
|
58
|
+
$stderr.print "Sending lines... "
|
59
|
+
csv_io.each_line.with_index do |buf, i|
|
60
|
+
$stderr.print "#{i + 1} "
|
61
|
+
conn.put_copy_data( buf )
|
62
|
+
end
|
63
|
+
$stderr.puts "done."
|
64
|
+
end
|
65
|
+
$stderr.puts "Result of COPY is: %s" % [ res.res_status(res.result_status) ]
|
66
|
+
$stderr.puts " tuples copied: %p" % [ res.cmd_tuples ]
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
conn.finish
|
71
|
+
|
data/sample/copyfrom.rb
CHANGED
data/sample/copyto.rb
CHANGED
data/sample/cursor.rb
CHANGED
data/sample/disk_usage_report.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
#
|
4
4
|
# Quickly dump size information for a given database.
|
@@ -10,21 +10,12 @@
|
|
10
10
|
#
|
11
11
|
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
require 'pg'
|
13
|
+
require 'ostruct'
|
14
|
+
require 'optparse'
|
15
|
+
require 'etc'
|
16
|
+
require 'pg'
|
18
17
|
|
19
|
-
|
20
|
-
unless Object.const_defined?( :Gem )
|
21
|
-
require 'rubygems'
|
22
|
-
retry
|
23
|
-
end
|
24
|
-
raise
|
25
|
-
end
|
26
|
-
|
27
|
-
SCRIPT_VERSION = %q$Id: disk_usage_report.rb,v 76ebae01c937 2013/03/26 17:50:02 ged $
|
18
|
+
SCRIPT_VERSION = %q$Id$
|
28
19
|
|
29
20
|
|
30
21
|
### Gather data and output it to $stdout.
|
data/sample/issue-119.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'pg'
|
4
4
|
|
@@ -66,7 +66,7 @@ END_DATA
|
|
66
66
|
end
|
67
67
|
rescue Errno => err
|
68
68
|
errmsg = "%s while reading copy data: %s" % [err.class.name, err.message]
|
69
|
-
puts "an error
|
69
|
+
puts "an error occurred"
|
70
70
|
end
|
71
71
|
|
72
72
|
if errmsg
|
data/sample/losample.rb
CHANGED
data/sample/minimal-testcase.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
|
3
3
|
require 'pg'
|
4
4
|
|
@@ -7,7 +7,7 @@ $stderr.puts '---',
|
|
7
7
|
RUBY_DESCRIPTION,
|
8
8
|
PG.version_string( true ),
|
9
9
|
"Server version: #{conn.server_version}",
|
10
|
-
"Client version: #{PG.
|
10
|
+
"Client version: #{PG.library_version}",
|
11
11
|
'---'
|
12
12
|
|
13
13
|
result = conn.exec( "SELECT * from pg_stat_activity" )
|
data/sample/notify_wait.rb
CHANGED
data/sample/pg_statistics.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
#
|
4
4
|
# PostgreSQL statistic gatherer.
|
@@ -13,26 +13,17 @@
|
|
13
13
|
# some nice performance charts.
|
14
14
|
#
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
require 'pg'
|
21
|
-
|
22
|
-
rescue LoadError # 1.8 support
|
23
|
-
unless Object.const_defined?( :Gem )
|
24
|
-
require 'rubygems'
|
25
|
-
retry
|
26
|
-
end
|
27
|
-
raise
|
28
|
-
end
|
16
|
+
require 'ostruct'
|
17
|
+
require 'optparse'
|
18
|
+
require 'etc'
|
19
|
+
require 'pg'
|
29
20
|
|
30
21
|
|
31
22
|
### PostgreSQL Stats. Fetch information from pg_stat_* tables.
|
32
23
|
### Optionally run in a continuous loop, displaying deltas.
|
33
24
|
###
|
34
25
|
class Stats
|
35
|
-
VERSION = %q$Id
|
26
|
+
VERSION = %q$Id$
|
36
27
|
|
37
28
|
def initialize( opts )
|
38
29
|
@opts = opts
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
#
|
4
4
|
# Get the current WAL segment and offset from a master postgresql
|
@@ -15,28 +15,19 @@
|
|
15
15
|
# db_replication.monitor db-master.example.com ...
|
16
16
|
#
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
require 'pp'
|
25
|
-
|
26
|
-
rescue LoadError # 1.8 support
|
27
|
-
unless Object.const_defined?( :Gem )
|
28
|
-
require 'rubygems'
|
29
|
-
retry
|
30
|
-
end
|
31
|
-
raise
|
32
|
-
end
|
18
|
+
require 'ostruct'
|
19
|
+
require 'optparse'
|
20
|
+
require 'pathname'
|
21
|
+
require 'etc'
|
22
|
+
require 'pg'
|
23
|
+
require 'pp'
|
33
24
|
|
34
25
|
|
35
26
|
### A class to encapsulate the PG handles.
|
36
27
|
###
|
37
28
|
class PGMonitor
|
38
29
|
|
39
|
-
VERSION = %q$Id
|
30
|
+
VERSION = %q$Id$
|
40
31
|
|
41
32
|
# When to consider a slave as 'behind', measured in WAL segments.
|
42
33
|
# The default WAL segment size is 16, so we'll alert after
|
@@ -96,7 +87,7 @@ class PGMonitor
|
|
96
87
|
#########
|
97
88
|
|
98
89
|
### Ask the master for the current xlog information, to compare
|
99
|
-
### to slaves. Returns true on
|
90
|
+
### to slaves. Returns true on success. On failure, populates
|
100
91
|
### the failures array and returns false.
|
101
92
|
###
|
102
93
|
def get_current_wal
|
data/sample/wal_shipper.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
#
|
3
3
|
# A script to wrap ssh and rsync for PostgreSQL WAL files shipping.
|
4
4
|
# Mahlon E. Smith <mahlon@martini.nu>
|
@@ -350,7 +350,7 @@ module WalShipper
|
|
350
350
|
###
|
351
351
|
def dispatch_dest( dest )
|
352
352
|
if ! dest.enabled.nil? && ! dest.enabled
|
353
|
-
self.log "Skipping
|
353
|
+
self.log "Skipping explicitly disabled destination %p, WAL is queued." % [ dest.label ]
|
354
354
|
return
|
355
355
|
end
|
356
356
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# -*- ruby -*-
|
2
2
|
# vim: set nosta noet ts=4 sw=4:
|
3
3
|
#
|
4
4
|
# Script to automatically move partitioned tables and their indexes
|
@@ -36,21 +36,12 @@
|
|
36
36
|
#
|
37
37
|
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
require 'pg'
|
46
|
-
|
47
|
-
rescue LoadError # 1.8 support
|
48
|
-
unless Object.const_defined?( :Gem )
|
49
|
-
require 'rubygems'
|
50
|
-
retry
|
51
|
-
end
|
52
|
-
raise
|
53
|
-
end
|
39
|
+
require 'date'
|
40
|
+
require 'ostruct'
|
41
|
+
require 'optparse'
|
42
|
+
require 'pathname'
|
43
|
+
require 'etc'
|
44
|
+
require 'pg'
|
54
45
|
|
55
46
|
|
56
47
|
### A tablespace migration class.
|
@@ -159,7 +150,7 @@ class PGWarehouse
|
|
159
150
|
end
|
160
151
|
end
|
161
152
|
|
162
|
-
# Add table
|
153
|
+
# Add table inheritance information.
|
163
154
|
#
|
164
155
|
db.exec 'SELECT inhrelid AS oid, inhparent AS parent FROM pg_inherits' do |res|
|
165
156
|
res.each do |row|
|
data.tar.gz.sig
CHANGED
Binary file
|