pg 1.2.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/Gemfile +14 -0
- data/History.md +884 -0
- data/Manifest.txt +0 -1
- data/README.ja.md +300 -0
- data/README.md +286 -0
- data/Rakefile +33 -135
- data/Rakefile.cross +12 -13
- data/certs/ged.pem +24 -0
- data/certs/larskanis-2022.pem +26 -0
- data/certs/larskanis-2023.pem +24 -0
- data/ext/errorcodes.def +12 -0
- data/ext/errorcodes.rb +0 -0
- data/ext/errorcodes.txt +4 -1
- data/ext/extconf.rb +104 -25
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +23 -0
- data/ext/pg.c +73 -58
- data/ext/pg.h +28 -5
- data/ext/pg_binary_decoder.c +80 -1
- data/ext/pg_binary_encoder.c +225 -1
- data/ext/pg_coder.c +96 -33
- data/ext/pg_connection.c +1010 -704
- data/ext/pg_copy_coder.c +351 -33
- data/ext/pg_errors.c +1 -1
- data/ext/pg_record_coder.c +50 -19
- data/ext/pg_result.c +177 -64
- data/ext/pg_text_decoder.c +29 -11
- data/ext/pg_text_encoder.c +29 -16
- data/ext/pg_tuple.c +83 -60
- data/ext/pg_type_map.c +44 -10
- data/ext/pg_type_map_all_strings.c +17 -3
- data/ext/pg_type_map_by_class.c +54 -27
- data/ext/pg_type_map_by_column.c +73 -31
- data/ext/pg_type_map_by_mri_type.c +48 -19
- data/ext/pg_type_map_by_oid.c +59 -27
- data/ext/pg_type_map_in_ruby.c +55 -21
- data/ext/pg_util.c +2 -2
- data/lib/pg/basic_type_map_based_on_result.rb +67 -0
- data/lib/pg/basic_type_map_for_queries.rb +198 -0
- data/lib/pg/basic_type_map_for_results.rb +104 -0
- data/lib/pg/basic_type_registry.rb +299 -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 +15 -13
- data/lib/pg/connection.rb +743 -83
- data/lib/pg/exceptions.rb +14 -1
- 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/version.rb +4 -0
- data/lib/pg.rb +94 -39
- 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 +20 -0
- data/sample/async_api.rb +102 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copydata.rb +71 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +19 -0
- data/sample/cursor.rb +21 -0
- data/sample/disk_usage_report.rb +177 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +69 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +72 -0
- data/sample/pg_statistics.rb +285 -0
- data/sample/replication_monitor.rb +222 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +311 -0
- data/translation/.po4a-version +7 -0
- data/translation/po/all.pot +936 -0
- data/translation/po/ja.po +1036 -0
- data/translation/po4a.cfg +12 -0
- data.tar.gz.sig +0 -0
- metadata +135 -207
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -0
- data/History.rdoc +0 -578
- data/README.ja.rdoc +0 -13
- data/README.rdoc +0 -213
- data/lib/pg/basic_type_mapping.rb +0 -522
- data/lib/pg/binary_decoder.rb +0 -23
- data/lib/pg/constants.rb +0 -12
- data/lib/pg/text_decoder.rb +0 -46
- data/lib/pg/text_encoder.rb +0 -59
- data/spec/data/expected_trace.out +0 -26
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +0 -380
- data/spec/pg/basic_type_mapping_spec.rb +0 -630
- data/spec/pg/connection_spec.rb +0 -1949
- data/spec/pg/connection_sync_spec.rb +0 -41
- data/spec/pg/result_spec.rb +0 -681
- data/spec/pg/tuple_spec.rb +0 -333
- data/spec/pg/type_map_by_class_spec.rb +0 -138
- data/spec/pg/type_map_by_column_spec.rb +0 -226
- 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 -1123
- data/spec/pg_spec.rb +0 -50
data/lib/pg/exceptions.rb
CHANGED
@@ -6,7 +6,20 @@ require 'pg' unless defined?( PG )
|
|
6
6
|
|
7
7
|
module PG
|
8
8
|
|
9
|
-
class Error < StandardError
|
9
|
+
class Error < StandardError
|
10
|
+
def initialize(msg=nil, connection: nil, result: nil)
|
11
|
+
@connection = connection
|
12
|
+
@result = result
|
13
|
+
super(msg)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
class NotAllCopyDataRetrieved < PG::Error
|
18
|
+
end
|
19
|
+
class LostCopyState < PG::Error
|
20
|
+
end
|
21
|
+
class NotInBlockingMode < PG::Error
|
22
|
+
end
|
10
23
|
|
11
24
|
end # module PG
|
12
25
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
module PG
|
7
|
+
module TextDecoder
|
8
|
+
class Date < SimpleDecoder
|
9
|
+
def decode(string, tuple=nil, field=nil)
|
10
|
+
if string =~ /\A(\d{4})-(\d\d)-(\d\d)\z/
|
11
|
+
::Date.new $1.to_i, $2.to_i, $3.to_i
|
12
|
+
else
|
13
|
+
string
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end # module PG
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
module PG
|
7
|
+
module TextDecoder
|
8
|
+
class JSON < SimpleDecoder
|
9
|
+
def decode(string, tuple=nil, field=nil)
|
10
|
+
::JSON.parse(string, quirks_mode: true)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end # module PG
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module PG
|
5
|
+
module TextDecoder
|
6
|
+
# Convenience classes for timezone options
|
7
|
+
class TimestampUtc < Timestamp
|
8
|
+
def initialize(hash={}, **kwargs)
|
9
|
+
warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
|
10
|
+
super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_UTC)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
class TimestampUtcToLocal < Timestamp
|
14
|
+
def initialize(hash={}, **kwargs)
|
15
|
+
warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
|
16
|
+
super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_UTC | PG::Coder::TIMESTAMP_APP_LOCAL)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
class TimestampLocal < Timestamp
|
20
|
+
def initialize(hash={}, **kwargs)
|
21
|
+
warn("PG::Coder.new(hash) is deprecated. Please use keyword arguments instead! Called from #{caller.first}", category: :deprecated) unless hash.empty?
|
22
|
+
super(**hash, **kwargs, flags: PG::Coder::TIMESTAMP_DB_LOCAL | PG::Coder::TIMESTAMP_APP_LOCAL)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# For backward compatibility:
|
27
|
+
TimestampWithoutTimeZone = TimestampLocal
|
28
|
+
TimestampWithTimeZone = Timestamp
|
29
|
+
end
|
30
|
+
end # module PG
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'ipaddr'
|
5
|
+
|
6
|
+
module PG
|
7
|
+
module TextEncoder
|
8
|
+
class Inet < SimpleEncoder
|
9
|
+
def encode(value)
|
10
|
+
case value
|
11
|
+
when IPAddr
|
12
|
+
default_prefix = (value.family == Socket::AF_INET ? 32 : 128)
|
13
|
+
s = value.to_s
|
14
|
+
if value.respond_to?(:prefix)
|
15
|
+
prefix = value.prefix
|
16
|
+
else
|
17
|
+
range = value.to_range
|
18
|
+
prefix = default_prefix - Math.log(((range.end.to_i - range.begin.to_i) + 1), 2).to_i
|
19
|
+
end
|
20
|
+
s << "/" << prefix.to_s if prefix != default_prefix
|
21
|
+
s
|
22
|
+
else
|
23
|
+
value
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end # module PG
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module PG
|
5
|
+
module TextEncoder
|
6
|
+
class TimestampWithoutTimeZone < SimpleEncoder
|
7
|
+
def encode(value)
|
8
|
+
value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N") : value
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class TimestampUtc < SimpleEncoder
|
13
|
+
def encode(value)
|
14
|
+
value.respond_to?(:utc) ? value.utc.strftime("%Y-%m-%d %H:%M:%S.%N") : value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class TimestampWithTimeZone < SimpleEncoder
|
19
|
+
def encode(value)
|
20
|
+
value.respond_to?(:strftime) ? value.strftime("%Y-%m-%d %H:%M:%S.%N %:z") : value
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end # module PG
|
data/lib/pg/version.rb
ADDED
data/lib/pg.rb
CHANGED
@@ -1,15 +1,28 @@
|
|
1
|
+
|
1
2
|
# -*- ruby -*-
|
2
3
|
# frozen_string_literal: true
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
rescue LoadError
|
7
|
-
# If it's a Windows binary gem, try the <major>.<minor> subdirectory
|
8
|
-
if RUBY_PLATFORM =~/(mswin|mingw)/i
|
9
|
-
major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
|
10
|
-
raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
|
5
|
+
# The top-level PG namespace.
|
6
|
+
module PG
|
11
7
|
|
12
|
-
|
8
|
+
# Is this file part of a fat binary gem with bundled libpq?
|
9
|
+
bundled_libpq_path = File.join(__dir__, RUBY_PLATFORM.gsub(/^i386-/, "x86-"))
|
10
|
+
if File.exist?(bundled_libpq_path)
|
11
|
+
POSTGRESQL_LIB_PATH = bundled_libpq_path
|
12
|
+
else
|
13
|
+
bundled_libpq_path = nil
|
14
|
+
# Try to load libpq path as found by extconf.rb
|
15
|
+
begin
|
16
|
+
require "pg/postgresql_lib_path"
|
17
|
+
rescue LoadError
|
18
|
+
# rake-compiler doesn't use regular "make install", but uses it's own install tasks.
|
19
|
+
# It therefore doesn't copy pg/postgresql_lib_path.rb in case of "rake compile".
|
20
|
+
POSTGRESQL_LIB_PATH = false
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
add_dll_path = proc do |path, &block|
|
25
|
+
if RUBY_PLATFORM =~/(mswin|mingw)/i && path && File.exist?(path)
|
13
26
|
begin
|
14
27
|
require 'ruby_installer/runtime'
|
15
28
|
RubyInstaller::Runtime.add_dll_directory(path, &block)
|
@@ -19,56 +32,98 @@ rescue LoadError
|
|
19
32
|
block.call
|
20
33
|
ENV['PATH'] = old_path
|
21
34
|
end
|
35
|
+
else
|
36
|
+
# No need to set a load path manually - it's set as library rpath.
|
37
|
+
block.call
|
22
38
|
end
|
39
|
+
end
|
23
40
|
|
24
|
-
|
25
|
-
|
26
|
-
|
41
|
+
# Add a load path to the one retrieved from pg_config
|
42
|
+
add_dll_path.call(POSTGRESQL_LIB_PATH) do
|
43
|
+
if bundled_libpq_path
|
44
|
+
# It's a Windows binary gem, try the <major>.<minor> subdirectory
|
45
|
+
major_minor = RUBY_VERSION[ /^(\d+\.\d+)/ ] or
|
46
|
+
raise "Oops, can't extract the major/minor version from #{RUBY_VERSION.dump}"
|
27
47
|
require "#{major_minor}/pg_ext"
|
48
|
+
else
|
49
|
+
require 'pg_ext'
|
28
50
|
end
|
29
|
-
else
|
30
|
-
raise
|
31
51
|
end
|
32
52
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# Library version
|
40
|
-
VERSION = '1.2.3'
|
53
|
+
# Get the PG library version.
|
54
|
+
#
|
55
|
+
# +include_buildnum+ is no longer used and any value passed will be ignored.
|
56
|
+
def self.version_string( include_buildnum=nil )
|
57
|
+
"%s %s" % [ self.name, VERSION ]
|
58
|
+
end
|
41
59
|
|
42
|
-
# VCS revision
|
43
|
-
REVISION = %q$Revision: 6f611e78845a $
|
44
60
|
|
45
|
-
|
61
|
+
### Convenience alias for PG::Connection.new.
|
62
|
+
def self.connect( *args, &block )
|
63
|
+
Connection.new( *args, &block )
|
46
64
|
end
|
47
65
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
66
|
+
if defined?(Ractor.make_shareable)
|
67
|
+
def self.make_shareable(obj)
|
68
|
+
Ractor.make_shareable(obj)
|
69
|
+
end
|
70
|
+
else
|
71
|
+
def self.make_shareable(obj)
|
72
|
+
obj.freeze
|
73
|
+
end
|
53
74
|
end
|
54
75
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
76
|
+
module BinaryDecoder
|
77
|
+
%i[ TimestampUtc TimestampUtcToLocal TimestampLocal ].each do |klass|
|
78
|
+
autoload klass, 'pg/binary_decoder/timestamp'
|
79
|
+
end
|
80
|
+
autoload :Date, 'pg/binary_decoder/date'
|
81
|
+
end
|
82
|
+
module BinaryEncoder
|
83
|
+
%i[ TimestampUtc TimestampLocal ].each do |klass|
|
84
|
+
autoload klass, 'pg/binary_encoder/timestamp'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
module TextDecoder
|
88
|
+
%i[ TimestampUtc TimestampUtcToLocal TimestampLocal TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
|
89
|
+
autoload klass, 'pg/text_decoder/timestamp'
|
90
|
+
end
|
91
|
+
autoload :Date, 'pg/text_decoder/date'
|
92
|
+
autoload :Inet, 'pg/text_decoder/inet'
|
93
|
+
autoload :JSON, 'pg/text_decoder/json'
|
94
|
+
autoload :Numeric, 'pg/text_decoder/numeric'
|
95
|
+
end
|
96
|
+
module TextEncoder
|
97
|
+
%i[ TimestampUtc TimestampWithoutTimeZone TimestampWithTimeZone ].each do |klass|
|
98
|
+
autoload klass, 'pg/text_encoder/timestamp'
|
99
|
+
end
|
100
|
+
autoload :Date, 'pg/text_encoder/date'
|
101
|
+
autoload :Inet, 'pg/text_encoder/inet'
|
102
|
+
autoload :JSON, 'pg/text_encoder/json'
|
103
|
+
autoload :Numeric, 'pg/text_encoder/numeric'
|
59
104
|
end
|
60
105
|
|
61
|
-
|
106
|
+
autoload :BasicTypeMapBasedOnResult, 'pg/basic_type_map_based_on_result'
|
107
|
+
autoload :BasicTypeMapForQueries, 'pg/basic_type_map_for_queries'
|
108
|
+
autoload :BasicTypeMapForResults, 'pg/basic_type_map_for_results'
|
109
|
+
autoload :BasicTypeRegistry, 'pg/basic_type_registry'
|
62
110
|
require 'pg/exceptions'
|
63
|
-
require 'pg/constants'
|
64
111
|
require 'pg/coder'
|
65
|
-
require 'pg/binary_decoder'
|
66
|
-
require 'pg/text_encoder'
|
67
|
-
require 'pg/text_decoder'
|
68
|
-
require 'pg/basic_type_mapping'
|
69
112
|
require 'pg/type_map_by_column'
|
70
113
|
require 'pg/connection'
|
71
114
|
require 'pg/result'
|
72
115
|
require 'pg/tuple'
|
116
|
+
autoload :VERSION, 'pg/version'
|
117
|
+
|
118
|
+
|
119
|
+
# Avoid "uninitialized constant Truffle::WarningOperations" on Truffleruby up to 22.3.1
|
120
|
+
if RUBY_ENGINE=="truffleruby" && !defined?(Truffle::WarningOperations)
|
121
|
+
module TruffleFixWarn
|
122
|
+
def warn(str, category=nil)
|
123
|
+
super(str)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
Warning.extend(TruffleFixWarn)
|
127
|
+
end
|
73
128
|
|
74
129
|
end # module PG
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
PGHOST = 'localhost'
|
4
|
+
PGDB = 'test'
|
5
|
+
#SOCKHOST = 'github.com'
|
6
|
+
SOCKHOST = 'it-trac.laika.com'
|
7
|
+
|
8
|
+
# Load pg first, so the libssl.so that libpq is linked against is loaded.
|
9
|
+
require 'pg'
|
10
|
+
$stderr.puts "connecting to postgres://#{PGHOST}/#{PGDB}"
|
11
|
+
conn = PG.connect( PGHOST, :dbname => PGDB )
|
12
|
+
|
13
|
+
# Now load OpenSSL, which might be linked against a different libssl.
|
14
|
+
require 'socket'
|
15
|
+
require 'openssl'
|
16
|
+
$stderr.puts "Connecting to #{SOCKHOST}"
|
17
|
+
sock = TCPSocket.open( SOCKHOST, 443 )
|
18
|
+
ctx = OpenSSL::SSL::SSLContext.new
|
19
|
+
sock = OpenSSL::SSL::SSLSocket.new( sock, ctx )
|
20
|
+
sock.sync_close = true
|
21
|
+
|
22
|
+
# The moment of truth...
|
23
|
+
$stderr.puts "Attempting to connect..."
|
24
|
+
begin
|
25
|
+
sock.connect
|
26
|
+
rescue Errno
|
27
|
+
$stderr.puts "Got an error connecting, but no segfault."
|
28
|
+
else
|
29
|
+
$stderr.puts "Nope, no segfault!"
|
30
|
+
end
|
31
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
= postgres
|
2
|
+
|
3
|
+
* https://github.com/ged/ruby-pg
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
This is an old, deprecated version of the Ruby PostgreSQL driver that hasn't
|
8
|
+
been maintained or supported since early 2008.
|
9
|
+
|
10
|
+
You should install/require 'pg' instead.
|
11
|
+
|
12
|
+
If you need the 'postgres' gem for legacy code that can't be converted, you can
|
13
|
+
still install it using an explicit version, like so:
|
14
|
+
|
15
|
+
gem install postgres -v '0.7.9.2008.01.28'
|
16
|
+
gem uninstall postgres -v '>0.7.9.2008.01.28'
|
17
|
+
|
18
|
+
If you have any questions, the nice folks in the Google group can help:
|
19
|
+
|
20
|
+
http://goo.gl/OjOPP / ruby-pg@googlegroups.com
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'hoe'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
Hoe.spec 'postgres' do
|
9
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
10
|
+
self.dependency 'pg', '~> 0'
|
11
|
+
self.spec_extras[:date] = Date.parse( '2008/01/30' )
|
12
|
+
|
13
|
+
line = '-' * 75
|
14
|
+
msg = paragraphs_of( 'README.txt', 3..-1 )
|
15
|
+
msg.unshift( line )
|
16
|
+
msg.push( line )
|
17
|
+
|
18
|
+
self.spec_extras[:post_install_message] = msg.join( "\n\n" ) + "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
# vim: syntax=ruby
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module Postgres
|
6
|
+
|
7
|
+
VERSION = '0.8.1'
|
8
|
+
|
9
|
+
gemdir = Pathname( __FILE__ ).dirname.parent
|
10
|
+
readme = gemdir + 'README.txt'
|
11
|
+
|
12
|
+
header, message = readme.read.split( /^== Description/m )
|
13
|
+
abort( message.strip )
|
14
|
+
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
= ruby-pg
|
2
|
+
|
3
|
+
* https://github.com/ged/ruby-pg
|
4
|
+
|
5
|
+
== Description
|
6
|
+
|
7
|
+
This is an old, deprecated version of the 'pg' gem that hasn't been
|
8
|
+
maintained or supported since early 2008.
|
9
|
+
|
10
|
+
You should install/require 'pg' instead.
|
11
|
+
|
12
|
+
If you need ruby-pg for legacy code that can't be converted, you can still
|
13
|
+
install it using an explicit version, like so:
|
14
|
+
|
15
|
+
gem install ruby-pg -v '0.7.9.2008.01.28'
|
16
|
+
gem uninstall ruby-pg -v '>0.7.9.2008.01.28'
|
17
|
+
|
18
|
+
If you have any questions, the nice folks in the Google group can help:
|
19
|
+
|
20
|
+
http://goo.gl/OjOPP / ruby-pg@googlegroups.com
|
21
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
require 'rubygems'
|
5
|
+
require 'hoe'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
Hoe.spec 'ruby-pg' do
|
9
|
+
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
10
|
+
self.dependency 'pg', '~> 0'
|
11
|
+
self.spec_extras[:date] = Date.parse( '2008/01/30' )
|
12
|
+
|
13
|
+
line = '-' * 75
|
14
|
+
msg = paragraphs_of( 'README.txt', 3..-1 )
|
15
|
+
msg.unshift( line )
|
16
|
+
msg.push( line )
|
17
|
+
|
18
|
+
self.spec_extras[:post_install_message] = msg.join( "\n\n" ) + "\n"
|
19
|
+
end
|
20
|
+
|
21
|
+
# vim: syntax=ruby
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
module Pg
|
6
|
+
|
7
|
+
VERSION = '0.8.0'
|
8
|
+
|
9
|
+
gemdir = Pathname( __FILE__ ).dirname.parent.parent
|
10
|
+
readme = gemdir + 'README.txt'
|
11
|
+
|
12
|
+
header, message = readme.read.split( /^== Description/m )
|
13
|
+
abort( message.strip )
|
14
|
+
|
15
|
+
end
|
16
|
+
|
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)/}) }
|
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
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'pg'
|
4
|
+
|
5
|
+
c = PG.connect( dbname: 'test' )
|
6
|
+
|
7
|
+
# this one works:
|
8
|
+
c.exec( "DROP TABLE IF EXISTS foo" )
|
9
|
+
c.exec( "CREATE TABLE foo (strings character varying[]);" )
|
10
|
+
|
11
|
+
# But using a prepared statement works:
|
12
|
+
c.set_error_verbosity( PG::PQERRORS_VERBOSE )
|
13
|
+
c.prepare( 'stmt', "INSERT INTO foo VALUES ($1);" )
|
14
|
+
|
15
|
+
# This won't work
|
16
|
+
#c.exec_prepared( 'stmt', ["ARRAY['this','that']"] )
|
17
|
+
|
18
|
+
# but this will:
|
19
|
+
c.exec_prepared( 'stmt', ["{'this','that'}"] )
|
20
|
+
|