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/History.rdoc
DELETED
@@ -1,297 +0,0 @@
|
|
1
|
-
== v0.18.1 [2015-01-05] Michael Granger <ged@FaerieMUD.org>
|
2
|
-
|
3
|
-
Correct the minimum compatible Ruby version to 1.9.3. #199
|
4
|
-
|
5
|
-
|
6
|
-
== v0.18.0 [2015-01-01] Michael Granger <ged@FaerieMUD.org>
|
7
|
-
|
8
|
-
Bugfixes:
|
9
|
-
- Fix OID to Integer mapping (it is unsigned now). #187
|
10
|
-
- Fix possible segfault in conjunction with notice receiver. #185
|
11
|
-
|
12
|
-
Enhancements:
|
13
|
-
|
14
|
-
- Add an extensible type cast system.
|
15
|
-
- A lot of performance improvements.
|
16
|
-
- Return frozen String objects for result field names.
|
17
|
-
- Add PG::Result#stream_each and #stream_each_row as fast helpers for
|
18
|
-
the single row mode.
|
19
|
-
- Add Enumerator variant to PG::Result#each and #each_row.
|
20
|
-
- Add PG::Connection#conninfo and #hostaddr.
|
21
|
-
- Add PG.init_openssl and PG.init_ssl methods.
|
22
|
-
- Force zero termination for all text strings that are given to libpq.
|
23
|
-
It raises an ArgumentError if the string contains a null byte.
|
24
|
-
- Update Windows cross build to PostgreSQL 9.3.
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
== v0.17.1 [2013-12-18] Michael Granger <ged@FaerieMUD.org>
|
29
|
-
|
30
|
-
Bugfixes:
|
31
|
-
|
32
|
-
- Fix compatibility with signal handlers defined in Ruby. This reverts
|
33
|
-
cancelation of queries running on top of the blocking libpq API (like
|
34
|
-
Connection#exec) in case of signals. As an alternative the #async_exec
|
35
|
-
can be used, which is reverted to use the non-blocking API, again.
|
36
|
-
- Wrap PQcancel to be called without GVL. It internally waits for
|
37
|
-
the canceling connection.
|
38
|
-
|
39
|
-
Documentation fixes:
|
40
|
-
|
41
|
-
- Fix documentation for PG::Connection::conndefaults.
|
42
|
-
|
43
|
-
|
44
|
-
== v0.17.0 [2013-09-15] Michael Granger <ged@FaerieMUD.org>
|
45
|
-
|
46
|
-
Bugfixes:
|
47
|
-
|
48
|
-
- Fix crash by calling PQsend* and PQisBusy without GVL (#171).
|
49
|
-
|
50
|
-
Enhancements:
|
51
|
-
|
52
|
-
- Add method PG::Connection#copy_data.
|
53
|
-
- Add a Gemfile to allow installation of dependencies with bundler.
|
54
|
-
- Add compatibility with rake-compiler-dev-box.
|
55
|
-
- Return self from PG::Result#check instead of nil. This allows
|
56
|
-
to stack method calls.
|
57
|
-
|
58
|
-
|
59
|
-
== v0.16.0 [2013-07-22] Michael Granger <ged@FaerieMUD.org>
|
60
|
-
|
61
|
-
Bugfixes:
|
62
|
-
|
63
|
-
- Avoid warnings about uninitialized instance variables.
|
64
|
-
- Use a more standard method of adding library and include directories.
|
65
|
-
This fixes build on AIX (Github #7) and Solaris (#164).
|
66
|
-
- Cancel the running query, if a thread is about to be killed (e.g. by CTRL-C).
|
67
|
-
- Fix GVL issue with wait_for_notify/notifies and notice callbacks.
|
68
|
-
- Set proper encoding on the string returned by quote_ident, escape_literal
|
69
|
-
and escape_identifier (#163).
|
70
|
-
- Use nil as PG::Error#result in case of a NULL-result from libpq (#166).
|
71
|
-
- Recalculate the timeout of conn#wait_for_notify and conn#block in case
|
72
|
-
of socket events that require re-runs of select().
|
73
|
-
|
74
|
-
Documentation fixes:
|
75
|
-
|
76
|
-
- Fix non working example for PGresult#error_field.
|
77
|
-
|
78
|
-
Enhancements:
|
79
|
-
|
80
|
-
- Add unique exception classes for each PostgreSQL error type (#5).
|
81
|
-
- Return result of the block in conn#transaction instead of nil (#158).
|
82
|
-
- Allow 'rake compile' and 'rake gem' on non mercurial repos.
|
83
|
-
- Add support for PG_DIAG_*_NAME error fields of PostgreSQL-9.3 (#161).
|
84
|
-
|
85
|
-
|
86
|
-
== v0.15.1 [2013-04-08] Michael Granger <ged@FaerieMUD.org>
|
87
|
-
|
88
|
-
Bugfixes:
|
89
|
-
|
90
|
-
- Shorten application_name to avoid warnings about truncated identifier.
|
91
|
-
|
92
|
-
|
93
|
-
== v0.15.0 [2013-03-03] Michael Granger <ged@FaerieMUD.org>
|
94
|
-
|
95
|
-
Bugfixes:
|
96
|
-
|
97
|
-
- Fix segfault in PG::Result#field_values when called with non String value.
|
98
|
-
- Fix encoding of messages delivered by notice callbacks.
|
99
|
-
- Fix text encoding for Connection#wait_for_notify and Connection#notifies.
|
100
|
-
- Fix 'Bad file descriptor' problems under Windows: wrong behaviour of
|
101
|
-
#wait_for_notify() and timeout handling of #block on Ruby 1.9.
|
102
|
-
|
103
|
-
Documentation fixes:
|
104
|
-
|
105
|
-
- conn#socket() can not be used with IO.for_fd() on Windows.
|
106
|
-
|
107
|
-
Enhancements:
|
108
|
-
|
109
|
-
- Tested under Ruby 2.0.0p0.
|
110
|
-
- Add single row mode of PostgreSQL 9.2.
|
111
|
-
- Set fallback_application_name to programm name $0. Thanks to Will Leinweber
|
112
|
-
for the patch.
|
113
|
-
- Release Ruby's GVL while calls to blocking libpq functions to allow better
|
114
|
-
concurrency in threaded applications.
|
115
|
-
- Refactor different variants of waiting for the connection socket.
|
116
|
-
- Make use of rb_thread_fd_select() on Ruby 1.9 and avoid deprecated
|
117
|
-
rb_thread_select().
|
118
|
-
- Add an example of how to insert array data using a prepared statement (#145).
|
119
|
-
- Add continous integration tests on travis-ci.org.
|
120
|
-
- Add PG::Result#each_row for iterative over result sets by row. Thanks to
|
121
|
-
Aaron Patterson for the patch.
|
122
|
-
- Add a PG::Connection#socket_io method for fetching a (non-autoclosing) IO
|
123
|
-
object for the connection's socket.
|
124
|
-
|
125
|
-
Specs:
|
126
|
-
|
127
|
-
- Fix various specs to run on older PostgreSQL and Ruby versions.
|
128
|
-
- Avoid fork() in specs to allow usage on Windows and JRuby.
|
129
|
-
|
130
|
-
|
131
|
-
== v0.14.1 [2012-09-02] Michael Granger <ged@FaerieMUD.org>
|
132
|
-
|
133
|
-
Important bugfix:
|
134
|
-
|
135
|
-
- Fix stack overflow bug in PG::Result#values and #column_values (#135). Thanks
|
136
|
-
to everyone who reported the bug, and Lars Kanis especially for figuring out
|
137
|
-
the problem.
|
138
|
-
|
139
|
-
PostgreSQL 9.2 beta fixes:
|
140
|
-
|
141
|
-
- Recognize PGRES_SINGLE_TUPLE as OK when checking PGresult (Jeremy Evans)
|
142
|
-
|
143
|
-
Documentation fixes:
|
144
|
-
|
145
|
-
- Add note about the usage scope of the result object received by the
|
146
|
-
#set_notice_receiver block. (Lars Kanis)
|
147
|
-
- Add PGRES_COPY_BOTH to documentation of PG::Result#result_status. (Lars Kanis)
|
148
|
-
- Add some documentation to PG::Result#fnumber (fix for #139)
|
149
|
-
|
150
|
-
|
151
|
-
== v0.14.0 [2012-06-17] Michael Granger <ged@FaerieMUD.org>
|
152
|
-
|
153
|
-
Bugfixes:
|
154
|
-
#47, #104
|
155
|
-
|
156
|
-
|
157
|
-
New Methods for PostgreSQL 9 and async API support:
|
158
|
-
PG
|
159
|
-
- ::library_version
|
160
|
-
|
161
|
-
PG::Connection
|
162
|
-
- ::ping
|
163
|
-
- #escape_literal
|
164
|
-
- #escape_identifier
|
165
|
-
- #set_default_encoding
|
166
|
-
|
167
|
-
PG::Result
|
168
|
-
- #check
|
169
|
-
|
170
|
-
|
171
|
-
New Samples:
|
172
|
-
|
173
|
-
This release also comes with a collection of contributed sample scripts for
|
174
|
-
doing resource-utilization reports, graphing database statistics,
|
175
|
-
monitoring for replication lag, shipping WAL files for replication,
|
176
|
-
automated tablespace partitioning, etc. See the samples/ directory.
|
177
|
-
|
178
|
-
|
179
|
-
== v0.13.2 [2012-02-22] Michael Granger <ged@FaerieMUD.org>
|
180
|
-
|
181
|
-
- Make builds against PostgreSQL earlier than 8.3 fail with a descriptive
|
182
|
-
message instead of a compile failure.
|
183
|
-
|
184
|
-
|
185
|
-
== v0.13.1 [2012-02-12] Michael Granger <ged@FaerieMUD.org>
|
186
|
-
|
187
|
-
- Made use of a finished PG::Connection raise a PG::Error instead of
|
188
|
-
a fatal error (#110).
|
189
|
-
- Added missing BSDL license file (#108)
|
190
|
-
|
191
|
-
|
192
|
-
== v0.13.0 [2012-02-09] Michael Granger <ged@FaerieMUD.org>
|
193
|
-
|
194
|
-
Reorganization of modules/classes to be better Ruby citizens (with backward-compatible aliases):
|
195
|
-
- Created toplevel namespace 'PG' to correspond with the gem name.
|
196
|
-
- Renamed PGconn to PG::Connection (with ::PGconn alias)
|
197
|
-
- Renamed PGresult to PG::Result (with ::PGresult alias)
|
198
|
-
- Renamed PGError to PG::Error (with ::PGError alias)
|
199
|
-
- Declare all constants inside PG::Constants, then include them in
|
200
|
-
PG::Connection and PG::Result for backward-compatibility, and
|
201
|
-
in PG for convenience.
|
202
|
-
- Split the extension source up by class/module.
|
203
|
-
- Removed old compatibility code for PostgreSQL versions < 8.3
|
204
|
-
|
205
|
-
Documentation:
|
206
|
-
- Clarified licensing, updated to Ruby 1.9's license.
|
207
|
-
- Merged authors list, added some missing people to the Contributor's
|
208
|
-
list.
|
209
|
-
- Cleaned up the sample/ directory
|
210
|
-
- Making contact info a bit clearer, link to the Google+ page and
|
211
|
-
the mailing list
|
212
|
-
|
213
|
-
Enhancements:
|
214
|
-
- Added a convenience method: PG.connect -> PG::Connection.new
|
215
|
-
|
216
|
-
Bugfixes:
|
217
|
-
- Fixed LATIN5-LATIN10 Postgres<->Ruby encoding conversions
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
== v0.12.2 [2012-01-03] Michael Granger <ged@FaerieMUD.org>
|
222
|
-
|
223
|
-
- Fix for the 1.8.7 breakage introduced by the st.h fix for alternative Ruby
|
224
|
-
implementations (#97 and #98). Thanks to Lars Kanis for the patch.
|
225
|
-
- Encode error messages with the connection's encoding under 1.9 (#96)
|
226
|
-
|
227
|
-
|
228
|
-
== v0.12.1 [2011-12-14] Michael Granger <ged@FaerieMUD.org>
|
229
|
-
|
230
|
-
- Made rake-compiler a dev dependency, as Rubygems doesn't use the Rakefile
|
231
|
-
for compiling the extension. Thanks to eolamey@bitbucket and Jeremy Evans
|
232
|
-
for pointing this out.
|
233
|
-
- Added an explicit include for ruby/st.h for implementations that need it
|
234
|
-
(fixes #95).
|
235
|
-
|
236
|
-
|
237
|
-
== v0.12.0 [2011-12-07] Michael Granger <ged@FaerieMUD.org>
|
238
|
-
|
239
|
-
- PGconn#wait_for_notify
|
240
|
-
* send nil as the payload argument if the NOTIFY didn't have one.
|
241
|
-
* accept a nil argument for no timeout (Sequel support)
|
242
|
-
* Fixed API docs
|
243
|
-
* Taint and encode event name and payload
|
244
|
-
- Handle errors while rb_thread_select()ing in PGconn#block.
|
245
|
-
(Brian Weaver).
|
246
|
-
- Fixes for Win32 async queries (Rafał Bigaj)
|
247
|
-
- Memory leak fixed: Closing opened WSA event. (rafal)
|
248
|
-
- Fixes for #66 Win32 asynchronous queries hang on connection
|
249
|
-
error. (rafal)
|
250
|
-
- Fixed a typo in PGconn#error_message's documentation
|
251
|
-
- fixing unused variable warnings for ruby 1.9.3 (Aaron Patterson)
|
252
|
-
- Build system bugfixes
|
253
|
-
- Converted to Hoe
|
254
|
-
- Updates for the Win32 binary gem builds (Lars Kanis)
|
255
|
-
|
256
|
-
|
257
|
-
== v0.11.0 [2011-02-09] Michael Granger <ged@FaerieMUD.org>
|
258
|
-
|
259
|
-
Enhancements:
|
260
|
-
|
261
|
-
* Added a PGresult#values method to fetch all result rows as an Array of
|
262
|
-
Arrays. Thanks to Jason Yanowitz (JYanowitz at enovafinancial dot com) for
|
263
|
-
the patch.
|
264
|
-
|
265
|
-
|
266
|
-
== v0.10.1 [2011-01-19] Michael Granger <ged@FaerieMUD.org>
|
267
|
-
|
268
|
-
Bugfixes:
|
269
|
-
|
270
|
-
* Add an include guard for pg.h
|
271
|
-
* Simplify the common case require of the ext
|
272
|
-
* Include the extconf header
|
273
|
-
* Fix compatibility with versions of PostgreSQL without PQgetCancel. (fixes #36)
|
274
|
-
* Fix require for natively-compiled extension under Windows. (fixes #55)
|
275
|
-
* Change rb_yield_splat() to rb_yield_values() for compatibility with Rubinius. (fixes #54)
|
276
|
-
|
277
|
-
|
278
|
-
== v0.10.0 [2010-12-01] Michael Granger <ged@FaerieMUD.org>
|
279
|
-
|
280
|
-
Enhancements:
|
281
|
-
|
282
|
-
* Added support for the payload of NOTIFY events (w/Mahlon E. Smith)
|
283
|
-
* Updated the build system with Rubygems suggestions from RubyConf 2010
|
284
|
-
|
285
|
-
Bugfixes:
|
286
|
-
|
287
|
-
* Fixed issue with PGconn#wait_for_notify that caused it to miss notifications that happened after
|
288
|
-
the LISTEN but before the wait_for_notify.
|
289
|
-
|
290
|
-
== v0.9.0 [2010-02-28] Michael Granger <ged@FaerieMUD.org>
|
291
|
-
|
292
|
-
Bugfixes.
|
293
|
-
|
294
|
-
== v0.8.0 [2009-03-28] Jeff Davis <davis.jeffrey@gmail.com>
|
295
|
-
|
296
|
-
Bugfixes, better Windows support.
|
297
|
-
|
data/README.ja.rdoc
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
= pg
|
2
|
-
|
3
|
-
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
-
mirror :: https://github.com/ged/ruby-pg
|
5
|
-
docs :: http://deveiate.org/code/pg
|
6
|
-
|
7
|
-
|
8
|
-
== Description
|
9
|
-
|
10
|
-
This file needs a translation of the English README. Pull requests, patches, or
|
11
|
-
volunteers gladly accepted.
|
12
|
-
|
13
|
-
Until such time, please accept my sincere apologies for not knowing Japanese.
|
14
|
-
|
data/README.rdoc
DELETED
@@ -1,161 +0,0 @@
|
|
1
|
-
= pg
|
2
|
-
|
3
|
-
home :: https://bitbucket.org/ged/ruby-pg
|
4
|
-
mirror :: https://github.com/ged/ruby-pg
|
5
|
-
docs :: http://deveiate.org/code/pg
|
6
|
-
|
7
|
-
|
8
|
-
== Description
|
9
|
-
|
10
|
-
Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
|
11
|
-
|
12
|
-
It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
|
13
|
-
|
14
|
-
A small example usage:
|
15
|
-
|
16
|
-
#!/usr/bin/env ruby
|
17
|
-
|
18
|
-
require 'pg'
|
19
|
-
|
20
|
-
# Output a table of current connections to the DB
|
21
|
-
conn = PG.connect( dbname: 'sales' )
|
22
|
-
conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
|
23
|
-
puts " PID | User | Query"
|
24
|
-
result.each do |row|
|
25
|
-
puts " %7d | %-16s | %s " %
|
26
|
-
row.values_at('procpid', 'usename', 'current_query')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
== Build Status
|
31
|
-
|
32
|
-
{<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
|
33
|
-
|
34
|
-
|
35
|
-
== Requirements
|
36
|
-
|
37
|
-
* Ruby 1.9.3-p392, or 2.0.0-p0.
|
38
|
-
* PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
|
39
|
-
|
40
|
-
It may work with earlier versions of Ruby/PostgreSQL as well, but those are
|
41
|
-
not regularly tested.
|
42
|
-
|
43
|
-
|
44
|
-
== How To Install
|
45
|
-
|
46
|
-
Install via RubyGems:
|
47
|
-
|
48
|
-
gem install pg
|
49
|
-
|
50
|
-
You may need to specify the path to the 'pg_config' program installed with
|
51
|
-
Postgres:
|
52
|
-
|
53
|
-
gem install pg -- --with-pg-config=<path to pg_config>
|
54
|
-
|
55
|
-
If you're installing via Bundler, you can provide compile hints like so:
|
56
|
-
|
57
|
-
bundle config build.pg --with-pg-config=<path to pg_config>
|
58
|
-
|
59
|
-
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
60
|
-
README-Windows.rdoc for Windows build/installation instructions.
|
61
|
-
|
62
|
-
There's also {a Google+ group}[http://goo.gl/TFy1U] and a
|
63
|
-
{mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
|
64
|
-
want to chat about something.
|
65
|
-
|
66
|
-
|
67
|
-
== Type Casts
|
68
|
-
|
69
|
-
Pg can optionally type cast result values and query parameters in Ruby or
|
70
|
-
native C code. This can speed up data transfers to and from the database,
|
71
|
-
because String allocations are reduced and conversions in (slower) Ruby code
|
72
|
-
can be omitted.
|
73
|
-
|
74
|
-
Very basic type casting can be enabled by:
|
75
|
-
|
76
|
-
conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
|
77
|
-
# ... this works for result value mapping:
|
78
|
-
conn.exec("select 1, now(), '{2,3}'::int[]").values
|
79
|
-
# => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
|
80
|
-
|
81
|
-
conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
|
82
|
-
# ... and this for param value mapping:
|
83
|
-
conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
|
84
|
-
# => [["1", "1.2300000000000000E+00", "{2,3}"]]
|
85
|
-
|
86
|
-
But Pg's type casting is highly customizable. That's why it's divided into
|
87
|
-
2 layers:
|
88
|
-
|
89
|
-
=== Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
|
90
|
-
|
91
|
-
This is the lower layer, containing encoding classes that convert Ruby
|
92
|
-
objects for transmission to the DBMS and decoding classes to convert
|
93
|
-
received data back to Ruby objects. The classes are namespaced according
|
94
|
-
to their format and direction in PG::TextEncoder, PG::TextDecoder,
|
95
|
-
PG::BinaryEncoder and PG::BinaryDecoder.
|
96
|
-
|
97
|
-
It is possible to assign a type OID, format code (text or binary) and
|
98
|
-
optionally a name to an encoder or decoder object. It's also possible
|
99
|
-
to build composite types by assigning an element encoder/decoder.
|
100
|
-
PG::Coder objects can be used to set up a PG::TypeMap or alternatively
|
101
|
-
to convert single values to/from their string representation.
|
102
|
-
|
103
|
-
=== PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
|
104
|
-
|
105
|
-
A TypeMap defines which value will be converted by which encoder/decoder.
|
106
|
-
There are different type map strategies, implemented by several derivations
|
107
|
-
of this class. They can be chosen and configured according to the particular
|
108
|
-
needs for type casting. The default type map is PG::TypeMapAllStrings.
|
109
|
-
|
110
|
-
A type map can be assigned per connection or per query respectively per
|
111
|
-
result set. Type maps can also be used for COPY in and out data streaming.
|
112
|
-
|
113
|
-
|
114
|
-
== Contributing
|
115
|
-
|
116
|
-
To report bugs, suggest features, or check out the source with Mercurial,
|
117
|
-
{check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
|
118
|
-
Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
|
119
|
-
|
120
|
-
After checking out the source, run:
|
121
|
-
|
122
|
-
$ rake newb
|
123
|
-
|
124
|
-
This task will install any missing dependencies, run the tests/specs, and
|
125
|
-
generate the API documentation.
|
126
|
-
|
127
|
-
The current maintainers are Michael Granger <ged@FaerieMUD.org> and
|
128
|
-
Lars Kanis <lars@greiz-reinsdorf.de>.
|
129
|
-
|
130
|
-
|
131
|
-
== Copying
|
132
|
-
|
133
|
-
Copyright (c) 1997-2013 by the authors.
|
134
|
-
|
135
|
-
* Jeff Davis <ruby-pg@j-davis.com>
|
136
|
-
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
137
|
-
* Michael Granger <ged@FaerieMUD.org>
|
138
|
-
* Lars Kanis <lars@greiz-reinsdorf.de>
|
139
|
-
* Dave Lee
|
140
|
-
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
141
|
-
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
142
|
-
* Noboru Saitou <noborus@netlab.jp>
|
143
|
-
|
144
|
-
You may redistribute this software under the same terms as Ruby itself; see
|
145
|
-
http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
|
146
|
-
for details.
|
147
|
-
|
148
|
-
Portions of the code are from the PostgreSQL project, and are distributed
|
149
|
-
under the terms of the PostgreSQL license, included in the file POSTGRES.
|
150
|
-
|
151
|
-
Portions copyright LAIKA, Inc.
|
152
|
-
|
153
|
-
|
154
|
-
== Acknowledgments
|
155
|
-
|
156
|
-
See Contributors.rdoc for the many additional fine people that have contributed
|
157
|
-
to this library over the years.
|
158
|
-
|
159
|
-
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
160
|
-
And to the people who developed PostgreSQL.
|
161
|
-
|