pg 0.20.0-x86-mingw32 → 0.21.0-x86-mingw32
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.tar.gz.sig +0 -0
- data/ChangeLog +145 -44
- data/History.rdoc +13 -0
- data/Manifest.txt +1 -18
- data/README.rdoc +1 -1
- data/Rakefile +5 -5
- data/ext/pg.c +1 -1
- data/ext/pg_binary_decoder.c +1 -1
- data/ext/pg_binary_encoder.c +1 -1
- data/ext/pg_connection.c +1 -1
- data/ext/pg_result.c +12 -6
- data/ext/pg_text_decoder.c +1 -1
- data/ext/pg_text_encoder.c +1 -1
- data/ext/pg_type_map.c +1 -1
- data/ext/pg_type_map_all_strings.c +1 -1
- data/ext/pg_type_map_by_class.c +1 -1
- data/ext/pg_type_map_by_column.c +1 -1
- data/ext/pg_type_map_by_mri_type.c +1 -1
- data/ext/pg_type_map_by_oid.c +1 -1
- data/ext/pg_type_map_in_ruby.c +1 -1
- data/ext/util.c +1 -1
- data/lib/2.0/pg_ext.so +0 -0
- data/lib/2.1/pg_ext.so +0 -0
- data/lib/2.2/pg_ext.so +0 -0
- data/lib/2.3/pg_ext.so +0 -0
- data/lib/2.4/pg_ext.so +0 -0
- data/lib/libpq.dll +0 -0
- data/lib/pg.rb +8 -6
- data/lib/pg/connection.rb +0 -4
- data/lib/pg/deprecated_constants.rb +21 -0
- data/lib/pg/result.rb +0 -3
- data/spec/pg/result_spec.rb +4 -4
- metadata +40 -63
- metadata.gz.sig +0 -0
- data/sample/array_insert.rb +0 -20
- data/sample/async_api.rb +0 -106
- data/sample/async_copyto.rb +0 -39
- data/sample/async_mixed.rb +0 -56
- data/sample/check_conn.rb +0 -21
- data/sample/copyfrom.rb +0 -81
- data/sample/copyto.rb +0 -19
- data/sample/cursor.rb +0 -21
- data/sample/disk_usage_report.rb +0 -186
- data/sample/issue-119.rb +0 -94
- data/sample/losample.rb +0 -69
- data/sample/minimal-testcase.rb +0 -17
- data/sample/notify_wait.rb +0 -72
- data/sample/pg_statistics.rb +0 -294
- data/sample/replication_monitor.rb +0 -231
- data/sample/test_binary_values.rb +0 -33
- data/sample/wal_shipper.rb +0 -434
- data/sample/warehouse_partitions.rb +0 -320
data/ext/pg_type_map_by_column.c
CHANGED
data/ext/pg_type_map_by_oid.c
CHANGED
data/ext/pg_type_map_in_ruby.c
CHANGED
data/ext/util.c
CHANGED
data/lib/2.0/pg_ext.so
CHANGED
Binary file
|
data/lib/2.1/pg_ext.so
CHANGED
Binary file
|
data/lib/2.2/pg_ext.so
CHANGED
Binary file
|
data/lib/2.3/pg_ext.so
CHANGED
Binary file
|
data/lib/2.4/pg_ext.so
CHANGED
Binary file
|
data/lib/libpq.dll
CHANGED
Binary file
|
data/lib/pg.rb
CHANGED
@@ -10,8 +10,8 @@ rescue LoadError
|
|
10
10
|
|
11
11
|
add_dll_path = proc do |path, &block|
|
12
12
|
begin
|
13
|
-
require 'ruby_installer'
|
14
|
-
RubyInstaller.add_dll_directory(path, &block)
|
13
|
+
require 'ruby_installer/runtime'
|
14
|
+
RubyInstaller::Runtime.add_dll_directory(path, &block)
|
15
15
|
rescue LoadError
|
16
16
|
old_path = ENV['PATH']
|
17
17
|
ENV['PATH'] = "#{path};#{old_path}"
|
@@ -35,10 +35,10 @@ end
|
|
35
35
|
module PG
|
36
36
|
|
37
37
|
# Library version
|
38
|
-
VERSION = '0.
|
38
|
+
VERSION = '0.21.0'
|
39
39
|
|
40
40
|
# VCS revision
|
41
|
-
REVISION = %q$Revision
|
41
|
+
REVISION = %q$Revision$
|
42
42
|
|
43
43
|
class NotAllCopyDataRetrieved < PG::Error
|
44
44
|
end
|
@@ -70,5 +70,7 @@ module PG
|
|
70
70
|
end # module PG
|
71
71
|
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
autoload :PGError, 'pg/deprecated_constants'
|
74
|
+
autoload :PGconn, 'pg/deprecated_constants'
|
75
|
+
autoload :PGresult, 'pg/deprecated_constants'
|
76
|
+
|
data/lib/pg/connection.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
#encoding: utf-8
|
3
|
+
|
4
|
+
# Warn about use of deprecated constants when this is autoloaded
|
5
|
+
callsite = caller(3).first
|
6
|
+
|
7
|
+
warn <<END_OF_WARNING
|
8
|
+
The PGconn, PGresult, and PGError constants are deprecated, and will be
|
9
|
+
removed as of version 1.0.
|
10
|
+
|
11
|
+
You should use PG::Connection, PG::Result, and PG::Error instead, respectively.
|
12
|
+
|
13
|
+
Called from #{callsite}
|
14
|
+
END_OF_WARNING
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
PGconn = PG::Connection
|
19
|
+
PGresult = PG::Result
|
20
|
+
PGError = PG::Error
|
21
|
+
|
data/lib/pg/result.rb
CHANGED
data/spec/pg/result_spec.rb
CHANGED
@@ -100,11 +100,11 @@ describe PG::Result do
|
|
100
100
|
expect( res[0]['n'] ).to be_nil()
|
101
101
|
end
|
102
102
|
|
103
|
-
it "encapsulates errors in a
|
103
|
+
it "encapsulates errors in a PG::Error object" do
|
104
104
|
exception = nil
|
105
105
|
begin
|
106
106
|
@conn.exec( "SELECT * FROM nonexistant_table" )
|
107
|
-
rescue
|
107
|
+
rescue PG::Error => err
|
108
108
|
exception = err
|
109
109
|
end
|
110
110
|
|
@@ -136,7 +136,7 @@ describe PG::Result do
|
|
136
136
|
exception = nil
|
137
137
|
begin
|
138
138
|
@conn.exec( "INSERT INTO integrity VALUES (NULL)" )
|
139
|
-
rescue
|
139
|
+
rescue PG::Error => err
|
140
140
|
exception = err
|
141
141
|
end
|
142
142
|
result = exception.result
|
@@ -152,7 +152,7 @@ describe PG::Result do
|
|
152
152
|
sqlstate = nil
|
153
153
|
begin
|
154
154
|
res = @conn.exec("SELECT 1/0")
|
155
|
-
rescue
|
155
|
+
rescue PG::Error => e
|
156
156
|
sqlstate = e.result.result_error_field( PG::PG_DIAG_SQLSTATE ).to_i
|
157
157
|
end
|
158
158
|
expect( sqlstate ).to eq( 22012 )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.21.0
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Michael Granger
|
@@ -11,32 +11,26 @@ bindir: bin
|
|
11
11
|
cert_chain:
|
12
12
|
- |
|
13
13
|
-----BEGIN CERTIFICATE-----
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
/
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
inYLQagqAF6goWTXgAJCdPd6SNeeSNqA6vlY7CV1Jh5kfNJJ6xu/CVij1GzCLu/5
|
33
|
-
DMOr26DBv+qLJRRC/2h34uX71q5QgeOyxvMg+7V3u/Q06DXyQ2VgeeqiwDFFpEH0
|
34
|
-
PFkdPO6ZqbTRcLfNH7mFgCBJjsfSjJrn0sPBlYyOXgCoByfZnZyrIMH/UY+lgQqS
|
35
|
-
6Von1VDsfQm0eJh5zYZD64ZF86phSR7mUX3mXItwH04HrZwkWpvgd871DZVR3i1n
|
36
|
-
w8aNA5re5+Rt/Vvjxj5AcEnZnZiz5x959NaddQocX32Z1unHw44pzRNUur1GInfW
|
37
|
-
p4vpx2kUSFSAGjtCbDGTNV2AH8w9OU4xEmNz8c5lyoA=
|
14
|
+
MIIDPDCCAiSgAwIBAgIBAzANBgkqhkiG9w0BAQUFADBEMQ0wCwYDVQQDDARsYXJz
|
15
|
+
MR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZImiZPyLGQB
|
16
|
+
GRYCZGUwHhcNMTcwNDA0MTgyNDE1WhcNMTgwNDA0MTgyNDE1WjBEMQ0wCwYDVQQD
|
17
|
+
DARsYXJzMR8wHQYKCZImiZPyLGQBGRYPZ3JlaXotcmVpbnNkb3JmMRIwEAYKCZIm
|
18
|
+
iZPyLGQBGRYCZGUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDZb4Uv
|
19
|
+
RFJfRu/VEWiy3psh2jinETjiuBrL0NeRFGf8H7iU9+gx/DI/FFhfHGLrDeIskrJx
|
20
|
+
YIWDMmEjVO10UUdj7wu4ZhmU++0Cd7Kq9/TyP/shIP3IjqHjVLCnJ3P6f1cl5rxZ
|
21
|
+
gqo+d3BAoDrmPk0rtaf6QopwUw9RBiF8V4HqvpiY+ruJotP5UQDP4/lVOKvA8PI9
|
22
|
+
P0GmVbFBrbc7Zt5h78N3UyOK0u+nvOC23BvyHXzCtcFsXCoEkt+Wwh0RFqVZdnjM
|
23
|
+
LMO2vULHKKHDdX54K/sbVCj9pN9h1aotNzrEyo55zxn0G9PHg/G3P8nMvAXPkUTe
|
24
|
+
brhXrfCwWRvOXA4TAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0G
|
25
|
+
A1UdDgQWBBRAHK81igrXodaDj8a8/BIKsaZrETANBgkqhkiG9w0BAQUFAAOCAQEA
|
26
|
+
Wbp+grpaqUH+RiXNXmi/5xBfvSYLbxWj+DZpCSnQW+DMfx46RVVko3b7BtKDs2zs
|
27
|
+
EtKM6r6s7VbllPgcYUzaP92uzPqCw8FncvqG0+B+Nd4C2jKzPxAQyzYXv/3bQhv1
|
28
|
+
sXAzEqLQqKx5V63eBDh1TPvPTEMfJwmjcdcbvMwFSt5EcUkT63W13ZJXX23JYp1K
|
29
|
+
KRW+N1WIYz8RSBNaQIP2v5Inb9vUA+jPUOcdyLHoi205lyZ28hE4lcnh9Zs02aHs
|
30
|
+
Ao8FZozVJz8xVEuYNJsL2k70w0FiwXwoWyvKyekgPBvYNUj4JGDMtBBayJTOpDs7
|
31
|
+
3EVmCm5IRuqZ1UcDFouQ9w==
|
38
32
|
-----END CERTIFICATE-----
|
39
|
-
date: 2017-
|
33
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
40
34
|
dependencies:
|
41
35
|
- !ruby/object:Gem::Dependency
|
42
36
|
name: hoe-mercurial
|
@@ -58,14 +52,14 @@ dependencies:
|
|
58
52
|
requirements:
|
59
53
|
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0.
|
55
|
+
version: '0.9'
|
62
56
|
type: :development
|
63
57
|
prerelease: false
|
64
58
|
version_requirements: !ruby/object:Gem::Requirement
|
65
59
|
requirements:
|
66
60
|
- - "~>"
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0.
|
62
|
+
version: '0.9'
|
69
63
|
- !ruby/object:Gem::Dependency
|
70
64
|
name: hoe-highline
|
71
65
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,84 +80,84 @@ dependencies:
|
|
86
80
|
requirements:
|
87
81
|
- - "~>"
|
88
82
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.0
|
83
|
+
version: '1.0'
|
90
84
|
type: :development
|
91
85
|
prerelease: false
|
92
86
|
version_requirements: !ruby/object:Gem::Requirement
|
93
87
|
requirements:
|
94
88
|
- - "~>"
|
95
89
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.0
|
90
|
+
version: '1.0'
|
97
91
|
- !ruby/object:Gem::Dependency
|
98
92
|
name: rake-compiler-dock
|
99
93
|
requirement: !ruby/object:Gem::Requirement
|
100
94
|
requirements:
|
101
95
|
- - "~>"
|
102
96
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.6
|
97
|
+
version: '0.6'
|
104
98
|
type: :development
|
105
99
|
prerelease: false
|
106
100
|
version_requirements: !ruby/object:Gem::Requirement
|
107
101
|
requirements:
|
108
102
|
- - "~>"
|
109
103
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.6
|
104
|
+
version: '0.6'
|
111
105
|
- !ruby/object:Gem::Dependency
|
112
|
-
name: hoe
|
106
|
+
name: hoe-bundler
|
113
107
|
requirement: !ruby/object:Gem::Requirement
|
114
108
|
requirements:
|
115
109
|
- - "~>"
|
116
110
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
111
|
+
version: '1.0'
|
118
112
|
type: :development
|
119
113
|
prerelease: false
|
120
114
|
version_requirements: !ruby/object:Gem::Requirement
|
121
115
|
requirements:
|
122
116
|
- - "~>"
|
123
117
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
118
|
+
version: '1.0'
|
125
119
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
120
|
+
name: rspec
|
127
121
|
requirement: !ruby/object:Gem::Requirement
|
128
122
|
requirements:
|
129
123
|
- - "~>"
|
130
124
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
125
|
+
version: '3.5'
|
132
126
|
type: :development
|
133
127
|
prerelease: false
|
134
128
|
version_requirements: !ruby/object:Gem::Requirement
|
135
129
|
requirements:
|
136
130
|
- - "~>"
|
137
131
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
132
|
+
version: '3.5'
|
139
133
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
134
|
+
name: rdoc
|
141
135
|
requirement: !ruby/object:Gem::Requirement
|
142
136
|
requirements:
|
143
137
|
- - "~>"
|
144
138
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
139
|
+
version: '5.1'
|
146
140
|
type: :development
|
147
141
|
prerelease: false
|
148
142
|
version_requirements: !ruby/object:Gem::Requirement
|
149
143
|
requirements:
|
150
144
|
- - "~>"
|
151
145
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
146
|
+
version: '5.1'
|
153
147
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
148
|
+
name: hoe
|
155
149
|
requirement: !ruby/object:Gem::Requirement
|
156
150
|
requirements:
|
157
151
|
- - "~>"
|
158
152
|
- !ruby/object:Gem::Version
|
159
|
-
version: '
|
153
|
+
version: '3.16'
|
160
154
|
type: :development
|
161
155
|
prerelease: false
|
162
156
|
version_requirements: !ruby/object:Gem::Requirement
|
163
157
|
requirements:
|
164
158
|
- - "~>"
|
165
159
|
- !ruby/object:Gem::Version
|
166
|
-
version: '
|
160
|
+
version: '3.16'
|
167
161
|
description: |-
|
168
162
|
Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
|
169
163
|
|
@@ -274,29 +268,12 @@ files:
|
|
274
268
|
- lib/pg/coder.rb
|
275
269
|
- lib/pg/connection.rb
|
276
270
|
- lib/pg/constants.rb
|
271
|
+
- lib/pg/deprecated_constants.rb
|
277
272
|
- lib/pg/exceptions.rb
|
278
273
|
- lib/pg/result.rb
|
279
274
|
- lib/pg/text_decoder.rb
|
280
275
|
- lib/pg/text_encoder.rb
|
281
276
|
- lib/pg/type_map_by_column.rb
|
282
|
-
- sample/array_insert.rb
|
283
|
-
- sample/async_api.rb
|
284
|
-
- sample/async_copyto.rb
|
285
|
-
- sample/async_mixed.rb
|
286
|
-
- sample/check_conn.rb
|
287
|
-
- sample/copyfrom.rb
|
288
|
-
- sample/copyto.rb
|
289
|
-
- sample/cursor.rb
|
290
|
-
- sample/disk_usage_report.rb
|
291
|
-
- sample/issue-119.rb
|
292
|
-
- sample/losample.rb
|
293
|
-
- sample/minimal-testcase.rb
|
294
|
-
- sample/notify_wait.rb
|
295
|
-
- sample/pg_statistics.rb
|
296
|
-
- sample/replication_monitor.rb
|
297
|
-
- sample/test_binary_values.rb
|
298
|
-
- sample/wal_shipper.rb
|
299
|
-
- sample/warehouse_partitions.rb
|
300
277
|
- spec/data/expected_trace.out
|
301
278
|
- spec/data/random_binary_data
|
302
279
|
- spec/helpers.rb
|
@@ -336,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
336
313
|
version: '0'
|
337
314
|
requirements: []
|
338
315
|
rubyforge_project:
|
339
|
-
rubygems_version: 2.6.
|
316
|
+
rubygems_version: 2.6.12
|
340
317
|
signing_key:
|
341
318
|
specification_version: 4
|
342
319
|
summary: Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/]
|
metadata.gz.sig
CHANGED
Binary file
|
data/sample/array_insert.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/usr/bin/env 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
|
-
|
data/sample/async_api.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pg'
|
4
|
-
|
5
|
-
# This is a example of how to use the asynchronous API to query the
|
6
|
-
# server without blocking other threads. It's intentionally low-level;
|
7
|
-
# if you hooked up the PG::Connection#socket to some kind of reactor, you
|
8
|
-
# could make this much nicer.
|
9
|
-
|
10
|
-
TIMEOUT = 5.0 # seconds to wait for an async operation to complete
|
11
|
-
|
12
|
-
# Print 'x' continuously to demonstrate that other threads aren't
|
13
|
-
# blocked while waiting for the connection, for the query to be sent,
|
14
|
-
# for results, etc. You might want to sleep inside the loop or
|
15
|
-
# comment this out entirely for cleaner output.
|
16
|
-
progress_thread = Thread.new { loop { print 'x' } }
|
17
|
-
|
18
|
-
# Output progress messages
|
19
|
-
def output_progress( msg )
|
20
|
-
puts "\n>>> #{msg}\n"
|
21
|
-
end
|
22
|
-
|
23
|
-
# Start the connection
|
24
|
-
output_progress "Starting connection..."
|
25
|
-
conn = PG::Connection.connect_start( :dbname => 'test' ) or
|
26
|
-
abort "Unable to create a new connection!"
|
27
|
-
abort "Connection failed: %s" % [ conn.error_message ] if
|
28
|
-
conn.status == PG::CONNECTION_BAD
|
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
|
-
# Track the progress of the connection, waiting for the socket to become readable/writable
|
35
|
-
# before polling it
|
36
|
-
poll_status = PG::PGRES_POLLING_WRITING
|
37
|
-
until poll_status == PG::PGRES_POLLING_OK ||
|
38
|
-
poll_status == PG::PGRES_POLLING_FAILED
|
39
|
-
|
40
|
-
# If the socket needs to read, wait 'til it becomes readable to poll again
|
41
|
-
case poll_status
|
42
|
-
when PG::PGRES_POLLING_READING
|
43
|
-
output_progress " waiting for socket to become readable"
|
44
|
-
select( [socket], nil, nil, TIMEOUT ) or
|
45
|
-
raise "Asynchronous connection timed out!"
|
46
|
-
|
47
|
-
# ...and the same for when the socket needs to write
|
48
|
-
when PG::PGRES_POLLING_WRITING
|
49
|
-
output_progress " waiting for socket to become writable"
|
50
|
-
select( nil, [socket], nil, TIMEOUT ) or
|
51
|
-
raise "Asynchronous connection timed out!"
|
52
|
-
end
|
53
|
-
|
54
|
-
# Output a status message about the progress
|
55
|
-
case conn.status
|
56
|
-
when PG::CONNECTION_STARTED
|
57
|
-
output_progress " waiting for connection to be made."
|
58
|
-
when PG::CONNECTION_MADE
|
59
|
-
output_progress " connection OK; waiting to send."
|
60
|
-
when PG::CONNECTION_AWAITING_RESPONSE
|
61
|
-
output_progress " waiting for a response from the server."
|
62
|
-
when PG::CONNECTION_AUTH_OK
|
63
|
-
output_progress " received authentication; waiting for backend start-up to finish."
|
64
|
-
when PG::CONNECTION_SSL_STARTUP
|
65
|
-
output_progress " negotiating SSL encryption."
|
66
|
-
when PG::CONNECTION_SETENV
|
67
|
-
output_progress " negotiating environment-driven parameter settings."
|
68
|
-
when PG::CONNECTION_NEEDED
|
69
|
-
output_progress " internal state: connect() needed."
|
70
|
-
end
|
71
|
-
|
72
|
-
# Check to see if it's finished or failed yet
|
73
|
-
poll_status = conn.connect_poll
|
74
|
-
end
|
75
|
-
|
76
|
-
abort "Connect failed: %s" % [ conn.error_message ] unless conn.status == PG::CONNECTION_OK
|
77
|
-
|
78
|
-
output_progress "Sending query"
|
79
|
-
conn.send_query( "SELECT * FROM pg_stat_activity" )
|
80
|
-
|
81
|
-
# Fetch results until there aren't any more
|
82
|
-
loop do
|
83
|
-
output_progress " waiting for a response"
|
84
|
-
|
85
|
-
# Buffer any incoming data on the socket until a full result is ready.
|
86
|
-
conn.consume_input
|
87
|
-
while conn.is_busy
|
88
|
-
select( [socket], nil, nil, TIMEOUT ) or
|
89
|
-
raise "Timeout waiting for query response."
|
90
|
-
conn.consume_input
|
91
|
-
end
|
92
|
-
|
93
|
-
# Fetch the next result. If there isn't one, the query is finished
|
94
|
-
result = conn.get_result or break
|
95
|
-
|
96
|
-
puts "\n\nQuery result:\n%p\n" % [ result.values ]
|
97
|
-
end
|
98
|
-
|
99
|
-
output_progress "Done."
|
100
|
-
conn.finish
|
101
|
-
|
102
|
-
if defined?( progress_thread )
|
103
|
-
progress_thread.kill
|
104
|
-
progress_thread.join
|
105
|
-
end
|
106
|
-
|