pg 0.13.2-x86-mingw32 → 0.14.0.pre.353-x86-mingw32
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.
- data/ChangeLog +230 -1
- data/History.rdoc +28 -0
- data/Manifest.txt +8 -0
- data/Rakefile +8 -2
- data/Rakefile.cross +11 -4
- data/ext/extconf.rb +7 -0
- data/ext/pg.c +76 -2
- data/ext/pg.h +2 -2
- data/ext/pg_connection.c +196 -81
- data/ext/pg_result.c +77 -58
- data/lib/1.8/pg_ext.so +0 -0
- data/lib/1.9/pg_ext.so +0 -0
- data/lib/pg.rb +1 -1
- data/lib/pg/connection.rb +7 -0
- data/sample/async_api.rb +2 -0
- data/sample/check_conn.rb +21 -0
- data/sample/disk_usage_report.rb +186 -0
- data/sample/issue-119.rb +94 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/pg_statistics.rb +294 -0
- data/sample/replication_monitor.rb +231 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +320 -0
- data/spec/lib/helpers.rb +6 -1
- data/spec/pg/connection_spec.rb +205 -141
- data/spec/pg/result_spec.rb +18 -6
- data/spec/pg_spec.rb +9 -0
- metadata +50 -34
data/ChangeLog
CHANGED
@@ -1,8 +1,237 @@
|
|
1
|
+
2012-06-17 Lars Kanis <kanis@comcard.de>
|
2
|
+
|
3
|
+
* Rakefile.cross, ext/extconf.rb,
|
4
|
+
misc/postgresql-9.1.4.mingw-w64-support.patch:
|
5
|
+
Update windows cross compilation tasks to the latest
|
6
|
+
Openssl+Postgresql versions and the latest mingw-w64 compiler
|
7
|
+
[a45710f8db30] [tip]
|
8
|
+
|
9
|
+
* Rakefile:
|
10
|
+
Use RbConfig instead of obsolete and deprecated Config.
|
11
|
+
[d67cbb4310ac]
|
12
|
+
|
13
|
+
2012-06-17 Michael Granger <ged@FaerieMUD.org>
|
14
|
+
|
15
|
+
* History.rdoc, ext/pg_connection.c, lib/pg.rb:
|
16
|
+
Bumped minor version, updated history.
|
17
|
+
[a3a3177b921c]
|
18
|
+
|
19
|
+
* .hoerc, ext/pg.h, ext/pg_connection.c, ext/pg_result.c,
|
20
|
+
spec/pg/result_spec.rb:
|
21
|
+
New method: PG::Result#check. (fixes #123)
|
22
|
+
|
23
|
+
This method exposes a previously internal-only function for checking
|
24
|
+
the status of a PG::Result, primarily for people using the async
|
25
|
+
interface. The check is done for you if you're using the synchronous
|
26
|
+
interface, but there was no way to get the same behavior for results
|
27
|
+
fetched via PG::Connection#get_result.
|
28
|
+
|
29
|
+
This change also adds the PG::Connection associated with a result as
|
30
|
+
an instance variable (@connection) on the PG::Result object.
|
31
|
+
|
32
|
+
Thanks to @royaltm for the idea.
|
33
|
+
[237cc4f69f63]
|
34
|
+
|
35
|
+
* ext/pg_connection.c, spec/pg/connection_spec.rb:
|
36
|
+
New method: PG::Connection#set_default_encoding (fixes #124)
|
37
|
+
|
38
|
+
This pulls up the code that sets the client_encoding in synchronous
|
39
|
+
connections into a public method that can be called by people using
|
40
|
+
the asynchronous API to achieve the same thing once the connection
|
41
|
+
is established.
|
42
|
+
|
43
|
+
Thanks to @royaltm for the suggestion.
|
44
|
+
[6680b395e6f4]
|
45
|
+
|
46
|
+
* Manifest.txt, sample/check_conn.rb:
|
47
|
+
Adding a minimal "connection-test function" example
|
48
|
+
[15bfcbe2bd5e]
|
49
|
+
|
50
|
+
* .rvm.gems:
|
51
|
+
Bump the hoe-deveiate version in the rvm gemset
|
52
|
+
[bc2ef3d461cd]
|
53
|
+
|
54
|
+
2012-06-12 Mahlon E. Smith <mahlon@laika.com>
|
55
|
+
|
56
|
+
* sample/warehouse_partitions.rb:
|
57
|
+
Move indexes across tablespaces along with their parents. Remove
|
58
|
+
the 'parent table' option, as we can derive that automatically from
|
59
|
+
the pg_inherits table.
|
60
|
+
[be46f44349bf]
|
61
|
+
|
62
|
+
2012-05-07 Michael Granger <ged@FaerieMUD.org>
|
63
|
+
|
64
|
+
* Rakefile, ext/pg.c, ext/pg_connection.c, ext/pg_result.c:
|
65
|
+
Documentation fixes.
|
66
|
+
[a965926418dd]
|
67
|
+
|
68
|
+
2012-04-23 Michael Granger <ged@FaerieMUD.org>
|
69
|
+
|
70
|
+
* Manifest.txt:
|
71
|
+
Adding Mahlon's samples to the manifest.
|
72
|
+
[997c3a247f44]
|
73
|
+
|
74
|
+
* .rvm.gems, Rakefile:
|
75
|
+
Updated dev dependencies
|
76
|
+
[cc07b81eaf18]
|
77
|
+
|
78
|
+
2012-04-17 Mahlon E. Smith <mahlon@laika.com>
|
79
|
+
|
80
|
+
* sample/disk_usage_report.rb, sample/minimal-testcase.rb,
|
81
|
+
sample/pg_statistics.rb, sample/replication_monitor.rb,
|
82
|
+
sample/wal_shipper.rb, sample/warehouse_partitions.rb:
|
83
|
+
Add a pile of additional sample scripts that perform various
|
84
|
+
administrative tasks.
|
85
|
+
|
86
|
+
These have all been fairly well battle-tested and are in production
|
87
|
+
use at $DAYJOB, though they were cleaned up for addition to the
|
88
|
+
Ruby-PG repo.
|
89
|
+
|
90
|
+
See the top comments in each script for additional information, or
|
91
|
+
the
|
92
|
+
--help flag on any of them for usage.
|
93
|
+
|
94
|
+
- disk_usage_report
|
95
|
+
|
96
|
+
Quick reporting on the heaviest disk consumers for a
|
97
|
+
database. Nice for cronned/email reporting.
|
98
|
+
|
99
|
+
- pg_statistics
|
100
|
+
|
101
|
+
Continuous polled statistics for a database.
|
102
|
+
Suitable for graphing with gnuplot (example
|
103
|
+
included.)
|
104
|
+
|
105
|
+
- replication_monitor
|
106
|
+
|
107
|
+
A command-line monitor for slave replication lag.
|
108
|
+
Works for both streaming replication and WAL
|
109
|
+
shipping. You should be able to use it as a base to
|
110
|
+
plug into your preferred monitoring system.
|
111
|
+
|
112
|
+
- wal_shipper
|
113
|
+
|
114
|
+
A smart WAL file transfer script, similar to
|
115
|
+
PITRTools.
|
116
|
+
|
117
|
+
- warehouse_partitions
|
118
|
+
|
119
|
+
An automated tablespace migrator for older, date-
|
120
|
+
based partitioned tables.
|
121
|
+
[36ca5b412583]
|
122
|
+
|
123
|
+
2012-04-02 Michael Granger <ged@FaerieMUD.org>
|
124
|
+
|
125
|
+
* sample/issue-119.rb:
|
126
|
+
Add a sample from <<issue 119>>
|
127
|
+
[35d75de3f5a5]
|
128
|
+
|
129
|
+
2012-03-26 Michael Granger <ged@FaerieMUD.org>
|
130
|
+
|
131
|
+
* sample/minimal-testcase.rb:
|
132
|
+
Adding a minimal-testcase sample
|
133
|
+
[87a8dadf1fdd]
|
134
|
+
|
135
|
+
2012-03-10 Michael Granger <ged@faeriemud.org>
|
136
|
+
|
137
|
+
* ext/pg_result.c:
|
138
|
+
Merged in larskanis/ruby-pg (pull request #7)
|
139
|
+
[4050c3412bd7]
|
140
|
+
|
141
|
+
2012-03-10 Lars Kanis <kanis@comcard.de>
|
142
|
+
|
143
|
+
* spec/pg/result_spec.rb:
|
144
|
+
Add checks with binary data for other PG::Result methods
|
145
|
+
[ef981c14a854]
|
146
|
+
|
147
|
+
* ext/pg_result.c:
|
148
|
+
Don't associate encoding with non-text-type fields in
|
149
|
+
PGresult#getvalue. This fixes #104 .
|
150
|
+
[9c90c50ca41a]
|
151
|
+
|
152
|
+
2012-03-09 Michael Granger <ged@FaerieMUD.org>
|
153
|
+
|
154
|
+
* ext/pg_result.c:
|
155
|
+
Avoid use of uninitialized Arrays (fixes #47).
|
156
|
+
|
157
|
+
Instead of declaring an Array at the beginning of fetching results
|
158
|
+
and pushing values onto it to return at the end (which could result
|
159
|
+
in a segfault if the GC runs during a NEWOBJ.
|
160
|
+
[6cea3cea3b2b]
|
161
|
+
|
162
|
+
2012-03-06 Michael Granger <ged@FaerieMUD.org>
|
163
|
+
|
164
|
+
* ext/pg.c, ext/pg_result.c:
|
165
|
+
Fix the guard for PGRES_COPY_BOTH.
|
166
|
+
[4053dfd600e8]
|
167
|
+
|
168
|
+
* ext/pg.c, ext/pg_connection.c, lib/pg/connection.rb,
|
169
|
+
spec/lib/helpers.rb, spec/pg/connection_spec.rb, spec/pg_spec.rb:
|
170
|
+
Factor some library-introspection methods up into the toplevel
|
171
|
+
namespace.
|
172
|
+
|
173
|
+
- PG::Connection.library_version -> PG.library_version
|
174
|
+
- PG::Connection.isthreadsafe -> PG.is_threadsafe? (with backward-
|
175
|
+
compat aliases)
|
176
|
+
- Split up examples by PG version metadata
|
177
|
+
[e24ff9f37b12]
|
178
|
+
|
179
|
+
* Rakefile:
|
180
|
+
Depend on RSpec 2.8 for example metadata
|
181
|
+
[c0b00fdff58a]
|
182
|
+
|
183
|
+
* ext/extconf.rb, ext/pg_result.c:
|
184
|
+
ifdef'ed PGRES_COPY_BOTH
|
185
|
+
[ad4f62c38edf]
|
186
|
+
|
187
|
+
2012-03-06 Michael Granger <ged@faeriemud.org>
|
188
|
+
|
189
|
+
* Merged in krasul/ruby-pg/issue-68 (pull request #6)
|
190
|
+
[dedcce66d5e8]
|
191
|
+
|
192
|
+
2012-03-05 Kashif Rasul <kashif@nomad-labs.com>
|
193
|
+
|
194
|
+
* ext/pg_connection.c, ext/pg_result.c, sample/async_api.rb:
|
195
|
+
Added logic for missing cases.
|
196
|
+
[ae9e73972844] <issue-68>
|
197
|
+
|
198
|
+
2012-03-04 Kashif Rasul <kashif@nomad-labs.com>
|
199
|
+
|
200
|
+
* ext/extconf.rb, ext/pg.c, ext/pg_connection.c,
|
201
|
+
spec/pg/connection_spec.rb:
|
202
|
+
Added server ping() API.
|
203
|
+
[fec045ed060d] <issue-68>
|
204
|
+
|
205
|
+
2012-03-02 Kashif Rasul <kashif@nomad-labs.com>
|
206
|
+
|
207
|
+
* ext/extconf.rb, ext/pg_connection.c:
|
208
|
+
Added library_version() as a singleton method. Removed non-
|
209
|
+
singletons.
|
210
|
+
[f82d969cc755] <issue-68>
|
211
|
+
|
212
|
+
* ext/pg_connection.c:
|
213
|
+
Added missing #def to rb_define_method() calls.
|
214
|
+
[fd22651ae6c5] <issue-68>
|
215
|
+
|
216
|
+
* ext/pg_connection.c, spec/pg/connection_spec.rb,
|
217
|
+
spec/pg/result_spec.rb:
|
218
|
+
Added spec for escape_literal().
|
219
|
+
[1ce12f2fe97c] <issue-68>
|
220
|
+
|
221
|
+
* ext/pg_connection.c:
|
222
|
+
Removed unused variable.
|
223
|
+
[3b52e0e0d421] <issue-68>
|
224
|
+
|
225
|
+
* ext/extconf.rb, ext/pg_connection.c, spec/pg/connection_spec.rb:
|
226
|
+
Added PGconn#escape_literal and PGconn#escape_identifier API and a
|
227
|
+
spec to test for keepalive connection parameters.
|
228
|
+
[3bdbb90eb13b] <issue-68>
|
229
|
+
|
1
230
|
2012-02-22 Michael Granger <ged@FaerieMUD.org>
|
2
231
|
|
3
232
|
* .hgtags:
|
4
233
|
Added tag v0.13.2 for changeset c79cd308363d
|
5
|
-
[d8e73919acb6]
|
234
|
+
[d8e73919acb6]
|
6
235
|
|
7
236
|
* .hgsigs:
|
8
237
|
Added signature for changeset 41e071bdd6ed
|
data/History.rdoc
CHANGED
@@ -1,3 +1,31 @@
|
|
1
|
+
== v0.14.0 [2012-06-17] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
#47, #104
|
5
|
+
|
6
|
+
|
7
|
+
New Methods for PostgreSQL 9 and async API support:
|
8
|
+
PG
|
9
|
+
- ::library_version
|
10
|
+
|
11
|
+
PG::Connection
|
12
|
+
- ::ping
|
13
|
+
- #escape_literal
|
14
|
+
- #escape_identifier
|
15
|
+
- #set_default_encoding
|
16
|
+
|
17
|
+
PG::Result
|
18
|
+
- #check
|
19
|
+
|
20
|
+
|
21
|
+
New Samples:
|
22
|
+
|
23
|
+
This release also comes with a collection of contributed sample scripts for
|
24
|
+
doing resource-utilization reports, graphing database statistics,
|
25
|
+
monitoring for replication lag, shipping WAL files for replication,
|
26
|
+
automated tablespace partitioning, etc. See the samples/ directory.
|
27
|
+
|
28
|
+
|
1
29
|
== v0.13.2 [2012-02-22] Michael Granger <ged@FaerieMUD.org>
|
2
30
|
|
3
31
|
- Make builds against PostgreSQL earlier than 8.3 fail with a descriptive
|
data/Manifest.txt
CHANGED
@@ -28,12 +28,20 @@ lib/pg/result.rb
|
|
28
28
|
sample/async_api.rb
|
29
29
|
sample/async_copyto.rb
|
30
30
|
sample/async_mixed.rb
|
31
|
+
sample/check_conn.rb
|
31
32
|
sample/copyfrom.rb
|
32
33
|
sample/copyto.rb
|
33
34
|
sample/cursor.rb
|
35
|
+
sample/disk_usage_report.rb
|
36
|
+
sample/issue-119.rb
|
34
37
|
sample/losample.rb
|
38
|
+
sample/minimal-testcase.rb
|
35
39
|
sample/notify_wait.rb
|
40
|
+
sample/pg_statistics.rb
|
41
|
+
sample/replication_monitor.rb
|
36
42
|
sample/test_binary_values.rb
|
43
|
+
sample/wal_shipper.rb
|
44
|
+
sample/warehouse_partitions.rb
|
37
45
|
spec/data/expected_trace.out
|
38
46
|
spec/data/random_binary_data
|
39
47
|
spec/lib/helpers.rb
|
data/Rakefile
CHANGED
@@ -26,7 +26,7 @@ EXTDIR = BASEDIR + 'ext'
|
|
26
26
|
PKGDIR = BASEDIR + 'pkg'
|
27
27
|
TMPDIR = BASEDIR + 'tmp'
|
28
28
|
|
29
|
-
DLEXT =
|
29
|
+
DLEXT = RbConfig::CONFIG['DLEXT']
|
30
30
|
EXT = LIBDIR + "pg_ext.#{DLEXT}"
|
31
31
|
|
32
32
|
TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
@@ -37,6 +37,7 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
|
37
37
|
# Set up Hoe plugins
|
38
38
|
Hoe.plugin :mercurial
|
39
39
|
Hoe.plugin :signing
|
40
|
+
Hoe.plugin :deveiate
|
40
41
|
|
41
42
|
Hoe.plugins.delete :rubyforge
|
42
43
|
Hoe.plugins.delete :compiler
|
@@ -55,7 +56,7 @@ $hoespec = Hoe.spec 'pg' do
|
|
55
56
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
56
57
|
|
57
58
|
self.dependency 'rake-compiler', '~> 0.7', :developer
|
58
|
-
self.dependency '
|
59
|
+
self.dependency 'hoe-deveiate', '~> 0.1', :developer
|
59
60
|
|
60
61
|
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
61
62
|
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
|
@@ -64,6 +65,11 @@ $hoespec = Hoe.spec 'pg' do
|
|
64
65
|
|
65
66
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
66
67
|
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
68
|
+
self.spec_extras[:rdoc_options] = [
|
69
|
+
'-f', 'fivefish',
|
70
|
+
'-t', 'pg: The Ruby Interface to PostgreSQL',
|
71
|
+
'-m', 'README.rdoc',
|
72
|
+
]
|
67
73
|
|
68
74
|
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
69
75
|
end
|
data/Rakefile.cross
CHANGED
@@ -18,8 +18,8 @@ else
|
|
18
18
|
end
|
19
19
|
|
20
20
|
# Cross-compilation constants
|
21
|
-
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '1.0.
|
22
|
-
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '9.1.
|
21
|
+
OPENSSL_VERSION = ENV['OPENSSL_VERSION'] || '1.0.1c'
|
22
|
+
POSTGRESQL_VERSION = ENV['POSTGRESQL_VERSION'] || '9.1.4'
|
23
23
|
|
24
24
|
COMPILE_HOME = Pathname( "./build" ).expand_path
|
25
25
|
STATIC_SOURCESDIR = COMPILE_HOME + 'sources'
|
@@ -36,7 +36,7 @@ OPENSSL_MAKEFILE = STATIC_OPENSSL_BUILDDIR + 'Makefile'
|
|
36
36
|
LIBSSLEAY32 = STATIC_OPENSSL_BUILDDIR + 'libssleay32.a'
|
37
37
|
LIBEAY32 = STATIC_OPENSSL_BUILDDIR + 'libeay32.a'
|
38
38
|
|
39
|
-
OPENSSL_PATCHES = Rake::FileList[ MISCDIR + "openssl-#{OPENSSL_VERSION}.*.patch" ]
|
39
|
+
OPENSSL_PATCHES = Rake::FileList[ (MISCDIR + "openssl-#{OPENSSL_VERSION}.*.patch").to_s ]
|
40
40
|
|
41
41
|
# Static PostgreSQL build vars
|
42
42
|
STATIC_POSTGRESQL_BUILDDIR = STATIC_BUILDDIR + "postgresql-#{POSTGRESQL_VERSION}"
|
@@ -55,6 +55,7 @@ POSTGRESQL_GLOBAL_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.global'
|
|
55
55
|
POSTGRESQL_SHLIB_MAKEFILE = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib'
|
56
56
|
POSTGRESQL_SHLIB_MF_ORIG = STATIC_POSTGRESQL_SRCDIR + 'Makefile.shlib.orig'
|
57
57
|
POSTGRESQL_LIB = STATIC_POSTGRESQL_LIBDIR + 'libpq.a'
|
58
|
+
POSTGRESQL_PATCHES = Rake::FileList[ (MISCDIR + "postgresql-#{POSTGRESQL_VERSION}.*.patch").to_s ]
|
58
59
|
|
59
60
|
CROSS_PREFIX = begin
|
60
61
|
Rake::ExtensionCompiler.mingw_host
|
@@ -171,6 +172,12 @@ file STATIC_POSTGRESQL_BUILDDIR => POSTGRESQL_TARBALL do |t|
|
|
171
172
|
STATIC_POSTGRESQL_BUILDDIR.mkpath
|
172
173
|
run 'tar', '-xjf', POSTGRESQL_TARBALL.to_s, '-C', STATIC_POSTGRESQL_BUILDDIR.parent.to_s
|
173
174
|
mv POSTGRESQL_SHLIB_MAKEFILE, POSTGRESQL_SHLIB_MF_ORIG
|
175
|
+
|
176
|
+
POSTGRESQL_PATCHES.each do |patchfile|
|
177
|
+
puts " applying patch #{patchfile}..."
|
178
|
+
run 'patch', '-Np1', '-d', STATIC_POSTGRESQL_BUILDDIR.to_s,
|
179
|
+
'-i', File.expand_path( patchfile, BASEDIR )
|
180
|
+
end
|
174
181
|
end
|
175
182
|
|
176
183
|
# generate the makefile in a clean build location
|
@@ -200,7 +207,7 @@ end
|
|
200
207
|
# patch the Makefile.shlib -- depend on the build dir so it's only
|
201
208
|
# rewritten if the tarball is re-extracted.
|
202
209
|
file POSTGRESQL_SHLIB_MAKEFILE => POSTGRESQL_SHLIB_MF_ORIG do |t|
|
203
|
-
tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename )
|
210
|
+
tf = Tempfile.new( POSTGRESQL_SHLIB_MAKEFILE.basename.to_s )
|
204
211
|
POSTGRESQL_SHLIB_MF_ORIG.open( File::RDONLY ) do |ifh|
|
205
212
|
ifh.each_line do |line|
|
206
213
|
tf.print( line.sub(/^(\s*haslibarule\s*=\s*yes)/, "# \\1 ") )
|
data/ext/extconf.rb
CHANGED
@@ -19,6 +19,7 @@ if ENV['CROSS_COMPILING']
|
|
19
19
|
$LDFLAGS << " -L#{CONFIG['libdir']}"
|
20
20
|
|
21
21
|
# Link against all required libraries for static build, if they are available
|
22
|
+
have_library( 'crypt32', 'CertOpenStore' ) && append_library( $libs, 'crypt32' )
|
22
23
|
have_library( 'gdi32', 'CreateDC' ) && append_library( $libs, 'gdi32' )
|
23
24
|
have_library( 'secur32' ) && append_library( $libs, 'secur32' )
|
24
25
|
have_library( 'ws2_32', 'WSASocket') && append_library( $libs, 'ws2_32' )
|
@@ -55,15 +56,21 @@ have_func 'PQprepare'
|
|
55
56
|
have_func 'PQexecParams'
|
56
57
|
have_func 'PQescapeString'
|
57
58
|
have_func 'PQescapeStringConn'
|
59
|
+
have_func 'PQescapeLiteral'
|
60
|
+
have_func 'PQescapeIdentifier'
|
58
61
|
have_func 'PQgetCancel'
|
59
62
|
have_func 'lo_create'
|
60
63
|
have_func 'pg_encoding_to_char'
|
61
64
|
have_func 'pg_char_to_encoding'
|
62
65
|
have_func 'PQsetClientEncoding'
|
66
|
+
have_func 'PQlibVersion'
|
67
|
+
have_func 'PQping'
|
63
68
|
|
64
69
|
have_func 'rb_encdb_alias'
|
65
70
|
have_func 'rb_enc_alias'
|
66
71
|
|
72
|
+
have_const 'PGRES_COPY_BOTH', 'libpq-fe.h'
|
73
|
+
|
67
74
|
$defs.push( "-DHAVE_ST_NOTIFY_EXTRA" ) if
|
68
75
|
have_struct_member 'struct pgNotify', 'extra', 'libpq-fe.h'
|
69
76
|
|
data/ext/pg.c
CHANGED
@@ -53,7 +53,7 @@ VALUE rb_mPGconstants;
|
|
53
53
|
|
54
54
|
|
55
55
|
/*
|
56
|
-
* Document-class:
|
56
|
+
* Document-class: PG::Error
|
57
57
|
*
|
58
58
|
* This is the exception class raised when an error is returned from
|
59
59
|
* a libpq API call.
|
@@ -250,6 +250,52 @@ pg_get_rb_encoding_as_pg_encoding( rb_encoding *enc )
|
|
250
250
|
#endif /* M17N_SUPPORTED */
|
251
251
|
|
252
252
|
|
253
|
+
/**************************************************************************
|
254
|
+
* Module Methods
|
255
|
+
**************************************************************************/
|
256
|
+
|
257
|
+
#ifdef HAVE_PQLIBVERSION
|
258
|
+
/*
|
259
|
+
* call-seq:
|
260
|
+
* PG.library_version -> Integer
|
261
|
+
*
|
262
|
+
* Get the version of the libpq library in use. The number is formed by
|
263
|
+
* converting the major, minor, and revision numbers into two-decimal-
|
264
|
+
* digit numbers and appending them together.
|
265
|
+
* For example, version 7.4.2 will be returned as 70402, and version
|
266
|
+
* 8.1 will be returned as 80100 (leading zeroes are not shown). Zero
|
267
|
+
* is returned if the connection is bad.
|
268
|
+
*/
|
269
|
+
static VALUE
|
270
|
+
pg_s_library_version(VALUE self)
|
271
|
+
{
|
272
|
+
UNUSED( self );
|
273
|
+
return INT2NUM(PQlibVersion());
|
274
|
+
}
|
275
|
+
#endif
|
276
|
+
|
277
|
+
|
278
|
+
/*
|
279
|
+
* call-seq:
|
280
|
+
* PG.isthreadsafe -> Boolean
|
281
|
+
* PG.is_threadsafe? -> Boolean
|
282
|
+
* PG.threadsafe? -> Boolean
|
283
|
+
*
|
284
|
+
* Returns +true+ if libpq is thread-safe, +false+ otherwise.
|
285
|
+
*/
|
286
|
+
static VALUE
|
287
|
+
pg_s_threadsafe_p(VALUE self)
|
288
|
+
{
|
289
|
+
UNUSED( self );
|
290
|
+
return PQisthreadsafe() ? Qtrue : Qfalse;
|
291
|
+
}
|
292
|
+
|
293
|
+
|
294
|
+
|
295
|
+
/**************************************************************************
|
296
|
+
* Initializer
|
297
|
+
**************************************************************************/
|
298
|
+
|
253
299
|
void
|
254
300
|
Init_pg_ext()
|
255
301
|
{
|
@@ -257,6 +303,16 @@ Init_pg_ext()
|
|
257
303
|
rb_ePGerror = rb_define_class_under( rb_mPG, "Error", rb_eStandardError );
|
258
304
|
rb_mPGconstants = rb_define_module_under( rb_mPG, "Constants" );
|
259
305
|
|
306
|
+
/*************************
|
307
|
+
* PG module methods
|
308
|
+
*************************/
|
309
|
+
#ifdef HAVE_PQLIBVERSION
|
310
|
+
rb_define_singleton_method( rb_mPG, "library_version", pg_s_library_version, 0 );
|
311
|
+
#endif
|
312
|
+
rb_define_singleton_method( rb_mPG, "isthreadsafe", pg_s_threadsafe_p, 0 );
|
313
|
+
SINGLETON_ALIAS( rb_mPG, "is_threadsafe?", "isthreadsafe" );
|
314
|
+
SINGLETON_ALIAS( rb_mPG, "threadsafe?", "isthreadsafe" );
|
315
|
+
|
260
316
|
/*************************
|
261
317
|
* PG::Error
|
262
318
|
*************************/
|
@@ -285,6 +341,8 @@ Init_pg_ext()
|
|
285
341
|
rb_define_const(rb_mPGconstants, "CONNECTION_SSL_STARTUP", INT2FIX(CONNECTION_SSL_STARTUP));
|
286
342
|
/* Negotiating environment-driven parameter settings. */
|
287
343
|
rb_define_const(rb_mPGconstants, "CONNECTION_SETENV", INT2FIX(CONNECTION_SETENV));
|
344
|
+
/* Internal state: connect() needed. */
|
345
|
+
rb_define_const(rb_mPGconstants, "CONNECTION_NEEDED", INT2FIX(CONNECTION_NEEDED));
|
288
346
|
|
289
347
|
/****** PG::Connection CLASS CONSTANTS: Nonblocking connection polling status ******/
|
290
348
|
|
@@ -319,6 +377,19 @@ Init_pg_ext()
|
|
319
377
|
/* Verbose error verbosity level (#set_error_verbosity) */
|
320
378
|
rb_define_const(rb_mPGconstants, "PQERRORS_VERBOSE", INT2FIX(PQERRORS_VERBOSE));
|
321
379
|
|
380
|
+
#ifdef HAVE_PQPING
|
381
|
+
/****** PG::Connection CLASS CONSTANTS: Check Server Status ******/
|
382
|
+
|
383
|
+
/* Server is accepting connections. */
|
384
|
+
rb_define_const(rb_mPGconstants, "PQPING_OK", INT2FIX(PQPING_OK));
|
385
|
+
/* Server is alive but rejecting connections. */
|
386
|
+
rb_define_const(rb_mPGconstants, "PQPING_REJECT", INT2FIX(PQPING_REJECT));
|
387
|
+
/* Could not establish connection. */
|
388
|
+
rb_define_const(rb_mPGconstants, "PQPING_NO_RESPONSE", INT2FIX(PQPING_NO_RESPONSE));
|
389
|
+
/* Connection not attempted (bad params). */
|
390
|
+
rb_define_const(rb_mPGconstants, "PQPING_NO_ATTEMPT", INT2FIX(PQPING_NO_ATTEMPT));
|
391
|
+
#endif
|
392
|
+
|
322
393
|
/****** PG::Connection CLASS CONSTANTS: Large Objects ******/
|
323
394
|
|
324
395
|
/* Flag for #lo_creat, #lo_open -- open for writing */
|
@@ -332,7 +403,6 @@ Init_pg_ext()
|
|
332
403
|
/* Flag for #lo_lseek -- seek from object end */
|
333
404
|
rb_define_const(rb_mPGconstants, "SEEK_END", INT2FIX(SEEK_END));
|
334
405
|
|
335
|
-
|
336
406
|
/****** PG::Result CONSTANTS: result status ******/
|
337
407
|
|
338
408
|
/* #result_status constant: The string sent to the server was empty. */
|
@@ -352,6 +422,10 @@ Init_pg_ext()
|
|
352
422
|
rb_define_const(rb_mPGconstants, "PGRES_NONFATAL_ERROR",INT2FIX(PGRES_NONFATAL_ERROR));
|
353
423
|
/* #result_status constant: A fatal error occurred. */
|
354
424
|
rb_define_const(rb_mPGconstants, "PGRES_FATAL_ERROR", INT2FIX(PGRES_FATAL_ERROR));
|
425
|
+
/* #result_status constant: Copy In/Out data transfer in progress. */
|
426
|
+
#ifdef HAVE_CONST_PGRES_COPY_BOTH
|
427
|
+
rb_define_const(rb_mPGconstants, "PGRES_COPY_BOTH", INT2FIX(PGRES_COPY_BOTH));
|
428
|
+
#endif
|
355
429
|
|
356
430
|
/****** Result CONSTANTS: result error field codes ******/
|
357
431
|
|