pg 0.21.0 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +5 -5
  2. checksums.yaml.gz.sig +0 -0
  3. data/.appveyor.yml +42 -0
  4. data/.gems +6 -0
  5. data/.github/workflows/binary-gems.yml +117 -0
  6. data/.github/workflows/source-gem.yml +137 -0
  7. data/.gitignore +22 -0
  8. data/.hgsigs +34 -0
  9. data/.hgtags +41 -0
  10. data/.irbrc +23 -0
  11. data/.pryrc +23 -0
  12. data/.tm_properties +21 -0
  13. data/.travis.yml +49 -0
  14. data/Gemfile +14 -0
  15. data/History.md +876 -0
  16. data/Manifest.txt +8 -4
  17. data/README-Windows.rdoc +4 -4
  18. data/README.ja.md +276 -0
  19. data/README.md +286 -0
  20. data/Rakefile +38 -139
  21. data/Rakefile.cross +70 -74
  22. data/certs/ged.pem +24 -0
  23. data/certs/larskanis-2022.pem +26 -0
  24. data/certs/larskanis-2023.pem +24 -0
  25. data/ext/errorcodes.def +88 -0
  26. data/ext/errorcodes.rb +1 -1
  27. data/ext/errorcodes.txt +24 -2
  28. data/ext/extconf.rb +111 -54
  29. data/ext/gvl_wrappers.c +8 -0
  30. data/ext/gvl_wrappers.h +40 -33
  31. data/ext/pg.c +224 -199
  32. data/ext/pg.h +93 -96
  33. data/ext/pg_binary_decoder.c +162 -16
  34. data/ext/pg_binary_encoder.c +238 -13
  35. data/ext/pg_coder.c +159 -35
  36. data/ext/pg_connection.c +1585 -1046
  37. data/ext/pg_copy_coder.c +364 -38
  38. data/ext/pg_errors.c +1 -1
  39. data/ext/pg_record_coder.c +522 -0
  40. data/ext/pg_result.c +708 -219
  41. data/ext/pg_text_decoder.c +627 -43
  42. data/ext/pg_text_encoder.c +206 -62
  43. data/ext/pg_tuple.c +572 -0
  44. data/ext/pg_type_map.c +45 -11
  45. data/ext/pg_type_map_all_strings.c +21 -7
  46. data/ext/pg_type_map_by_class.c +59 -27
  47. data/ext/pg_type_map_by_column.c +80 -37
  48. data/ext/pg_type_map_by_mri_type.c +49 -20
  49. data/ext/pg_type_map_by_oid.c +62 -29
  50. data/ext/pg_type_map_in_ruby.c +56 -22
  51. data/ext/{util.c → pg_util.c} +12 -12
  52. data/ext/{util.h → pg_util.h} +2 -2
  53. data/lib/pg/basic_type_map_based_on_result.rb +67 -0
  54. data/lib/pg/basic_type_map_for_queries.rb +198 -0
  55. data/lib/pg/basic_type_map_for_results.rb +104 -0
  56. data/lib/pg/basic_type_registry.rb +299 -0
  57. data/lib/pg/binary_decoder/date.rb +9 -0
  58. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  59. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  60. data/lib/pg/coder.rb +36 -13
  61. data/lib/pg/connection.rb +755 -71
  62. data/lib/pg/exceptions.rb +16 -2
  63. data/lib/pg/result.rb +14 -2
  64. data/lib/pg/text_decoder/date.rb +18 -0
  65. data/lib/pg/text_decoder/inet.rb +9 -0
  66. data/lib/pg/text_decoder/json.rb +14 -0
  67. data/lib/pg/text_decoder/numeric.rb +9 -0
  68. data/lib/pg/text_decoder/timestamp.rb +30 -0
  69. data/lib/pg/text_encoder/date.rb +12 -0
  70. data/lib/pg/text_encoder/inet.rb +28 -0
  71. data/lib/pg/text_encoder/json.rb +14 -0
  72. data/lib/pg/text_encoder/numeric.rb +9 -0
  73. data/lib/pg/text_encoder/timestamp.rb +24 -0
  74. data/lib/pg/tuple.rb +30 -0
  75. data/lib/pg/type_map_by_column.rb +3 -2
  76. data/lib/pg/version.rb +4 -0
  77. data/lib/pg.rb +96 -43
  78. data/misc/openssl-pg-segfault.rb +31 -0
  79. data/misc/postgres/History.txt +9 -0
  80. data/misc/postgres/Manifest.txt +5 -0
  81. data/misc/postgres/README.txt +21 -0
  82. data/misc/postgres/Rakefile +21 -0
  83. data/misc/postgres/lib/postgres.rb +16 -0
  84. data/misc/ruby-pg/History.txt +9 -0
  85. data/misc/ruby-pg/Manifest.txt +5 -0
  86. data/misc/ruby-pg/README.txt +21 -0
  87. data/misc/ruby-pg/Rakefile +21 -0
  88. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  89. data/pg.gemspec +34 -0
  90. data/rakelib/task_extension.rb +46 -0
  91. data/sample/array_insert.rb +20 -0
  92. data/sample/async_api.rb +102 -0
  93. data/sample/async_copyto.rb +39 -0
  94. data/sample/async_mixed.rb +56 -0
  95. data/sample/check_conn.rb +21 -0
  96. data/sample/copydata.rb +71 -0
  97. data/sample/copyfrom.rb +81 -0
  98. data/sample/copyto.rb +19 -0
  99. data/sample/cursor.rb +21 -0
  100. data/sample/disk_usage_report.rb +177 -0
  101. data/sample/issue-119.rb +94 -0
  102. data/sample/losample.rb +69 -0
  103. data/sample/minimal-testcase.rb +17 -0
  104. data/sample/notify_wait.rb +72 -0
  105. data/sample/pg_statistics.rb +285 -0
  106. data/sample/replication_monitor.rb +222 -0
  107. data/sample/test_binary_values.rb +33 -0
  108. data/sample/wal_shipper.rb +434 -0
  109. data/sample/warehouse_partitions.rb +311 -0
  110. data/translation/.po4a-version +7 -0
  111. data/translation/po/all.pot +910 -0
  112. data/translation/po/ja.po +1047 -0
  113. data/translation/po4a.cfg +12 -0
  114. data.tar.gz.sig +0 -0
  115. metadata +154 -217
  116. metadata.gz.sig +0 -0
  117. data/ChangeLog +0 -6595
  118. data/History.rdoc +0 -394
  119. data/README.ja.rdoc +0 -14
  120. data/README.rdoc +0 -168
  121. data/lib/pg/basic_type_mapping.rb +0 -426
  122. data/lib/pg/constants.rb +0 -11
  123. data/lib/pg/deprecated_constants.rb +0 -21
  124. data/lib/pg/text_decoder.rb +0 -51
  125. data/lib/pg/text_encoder.rb +0 -35
  126. data/spec/data/expected_trace.out +0 -26
  127. data/spec/data/random_binary_data +0 -0
  128. data/spec/helpers.rb +0 -352
  129. data/spec/pg/basic_type_mapping_spec.rb +0 -305
  130. data/spec/pg/connection_spec.rb +0 -1676
  131. data/spec/pg/result_spec.rb +0 -456
  132. data/spec/pg/type_map_by_class_spec.rb +0 -138
  133. data/spec/pg/type_map_by_column_spec.rb +0 -222
  134. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  135. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  136. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  137. data/spec/pg/type_map_spec.rb +0 -22
  138. data/spec/pg/type_spec.rb +0 -777
  139. data/spec/pg_spec.rb +0 -50
data/History.rdoc DELETED
@@ -1,394 +0,0 @@
1
- == v0.21.0 [2017-06-12] Michael Granger <ged@FaerieMUD.org>
2
-
3
- Enhancements:
4
- - Move add_dll_directory to the Runtime namespace for newest versions
5
- of RubyInstaller.
6
- - Deprecate PGconn, PGresult, and PGError top-level constants; a warning
7
- will be output the first time one of them is used. They will be
8
- removed in the upcoming 1.0 release.
9
-
10
- Documentation fixes:
11
- - Update the docs for PG::Result#cmd_tuples
12
-
13
-
14
- == v0.20.0 [2017-03-10] Michael Granger <ged@FaerieMUD.org>
15
-
16
- Enhancements:
17
- - Update error codes to PostgreSQL-9.6
18
- - Update Windows binary gems to Ruby-2.4, PostgreSQL 9.6.1 and
19
- OpenSSL 1.0.2j.
20
- - Add support for RubyInstaller2 to Windows binary gems.
21
-
22
- Bugfixes:
23
- - Use secure JSON methods for JSON (de)serialisation. #248
24
- - Fix Result#inspect on a cleared result.
25
- - Fix test case that failed on Ruby-2.4. #255
26
-
27
- Documentation fixes:
28
- - Talk about Integer instead of Fixnum.
29
- - Fix method signature of Coder#encode.
30
-
31
-
32
- == v0.19.0 [2016-09-21] Michael Granger <ged@FaerieMUD.org>
33
-
34
- - Deprecate Ruby 1.9
35
-
36
- Enhancements:
37
- - Respect and convert character encoding of all strings sent
38
- to the server. #231
39
- - Add PostgreSQL-9.5 functions PQsslInUse(), PQsslAttribute()
40
- and PQsslAttributeNames().
41
- - Various documentation fixes and improvements.
42
- - Add mechanism to build without pg_config:
43
- gem install pg -- --with-pg-config=ignore
44
- - Update Windows binary gems to Ruby-2.3, PostgreSQL 9.5.4 and
45
- OpenSSL 1.0.2f.
46
- - Add JSON coders and add them to BasicTypeMapForResults and
47
- BasicTypeMapBasedOnResult
48
- - Allow build from git per bundler.
49
-
50
- Bugfixes:
51
- - Release GVL while calling PQsetClientEncoding(). #245
52
- - Add __EXTENSIONS__ to Solaris/SmartOS for Ruby >= 2.3.x. #236
53
- - Fix wrong exception when running SQL while in Connection#copy_data
54
- block for output
55
-
56
-
57
- == v0.18.4 [2015-11-13] Michael Granger <ged@FaerieMUD.org>
58
-
59
- Enhancements:
60
- - Fixing compilation problems with Microsoft Visual Studio 2008. GH #10
61
- - Avoid name clash with xcode and jemalloc. PR#22, PR#23
62
-
63
- Bugfixes:
64
- - Avoid segfault, when quote_ident or TextEncoder::Identifier
65
- is called with Array containing non-strings. #226
66
-
67
-
68
- == v0.18.3 [2015-09-03] Michael Granger <ged@FaerieMUD.org>
69
-
70
- Enhancements:
71
- - Use rake-compiler-dock to build windows gems easily.
72
- - Add CI-tests on appveyor and fix test cases accordingly.
73
-
74
- Bugfixes:
75
- - Fix data type resulting in wrong base64 encoding.
76
- - Change instance_of checks to kind_of for subclassing. #220
77
- - TextDecoder::Date returns an actual Ruby Date instead of a Time
78
- (thanks to Thomas Ramfjord)
79
-
80
-
81
- == v0.18.2 [2015-05-14] Michael Granger <ged@FaerieMUD.org>
82
-
83
- Enhancements:
84
-
85
- - Allow URI connection string (thanks to Chris Bandy)
86
- - Allow Array type parameter to conn.quote_ident
87
-
88
- Bugfixes:
89
-
90
- - Speedups and fixes for PG::TextDecoder::Identifier and quoting behavior
91
- - Revert addition of PG::Connection#hostaddr [#202].
92
- - Fix decoding of fractional timezones and timestamps [#203]
93
- - Fixes for non-C99 compilers
94
- - Avoid possible symbol name clash when linking againt static libpq.
95
-
96
-
97
- == v0.18.1 [2015-01-05] Michael Granger <ged@FaerieMUD.org>
98
-
99
- Correct the minimum compatible Ruby version to 1.9.3. #199
100
-
101
-
102
- == v0.18.0 [2015-01-01] Michael Granger <ged@FaerieMUD.org>
103
-
104
- Bugfixes:
105
- - Fix OID to Integer mapping (it is unsigned now). #187
106
- - Fix possible segfault in conjunction with notice receiver. #185
107
-
108
- Enhancements:
109
-
110
- - Add an extensible type cast system.
111
- - A lot of performance improvements.
112
- - Return frozen String objects for result field names.
113
- - Add PG::Result#stream_each and #stream_each_row as fast helpers for
114
- the single row mode.
115
- - Add Enumerator variant to PG::Result#each and #each_row.
116
- - Add PG::Connection#conninfo and #hostaddr.
117
- - Add PG.init_openssl and PG.init_ssl methods.
118
- - Add PG::Result.inspect
119
- - Force zero termination for all text strings that are given to libpq.
120
- It raises an ArgumentError if the string contains a null byte.
121
- - Update Windows cross build to PostgreSQL 9.3.
122
-
123
-
124
-
125
- == v0.17.1 [2013-12-18] Michael Granger <ged@FaerieMUD.org>
126
-
127
- Bugfixes:
128
-
129
- - Fix compatibility with signal handlers defined in Ruby. This reverts
130
- cancelation of queries running on top of the blocking libpq API (like
131
- Connection#exec) in case of signals. As an alternative the #async_exec
132
- can be used, which is reverted to use the non-blocking API, again.
133
- - Wrap PQcancel to be called without GVL. It internally waits for
134
- the canceling connection.
135
-
136
- Documentation fixes:
137
-
138
- - Fix documentation for PG::Connection::conndefaults.
139
-
140
-
141
- == v0.17.0 [2013-09-15] Michael Granger <ged@FaerieMUD.org>
142
-
143
- Bugfixes:
144
-
145
- - Fix crash by calling PQsend* and PQisBusy without GVL (#171).
146
-
147
- Enhancements:
148
-
149
- - Add method PG::Connection#copy_data.
150
- - Add a Gemfile to allow installation of dependencies with bundler.
151
- - Add compatibility with rake-compiler-dev-box.
152
- - Return self from PG::Result#check instead of nil. This allows
153
- to stack method calls.
154
-
155
-
156
- == v0.16.0 [2013-07-22] Michael Granger <ged@FaerieMUD.org>
157
-
158
- Bugfixes:
159
-
160
- - Avoid warnings about uninitialized instance variables.
161
- - Use a more standard method of adding library and include directories.
162
- This fixes build on AIX (Github #7) and Solaris (#164).
163
- - Cancel the running query, if a thread is about to be killed (e.g. by CTRL-C).
164
- - Fix GVL issue with wait_for_notify/notifies and notice callbacks.
165
- - Set proper encoding on the string returned by quote_ident, escape_literal
166
- and escape_identifier (#163).
167
- - Use nil as PG::Error#result in case of a NULL-result from libpq (#166).
168
- - Recalculate the timeout of conn#wait_for_notify and conn#block in case
169
- of socket events that require re-runs of select().
170
-
171
- Documentation fixes:
172
-
173
- - Fix non working example for PGresult#error_field.
174
-
175
- Enhancements:
176
-
177
- - Add unique exception classes for each PostgreSQL error type (#5).
178
- - Return result of the block in conn#transaction instead of nil (#158).
179
- - Allow 'rake compile' and 'rake gem' on non mercurial repos.
180
- - Add support for PG_DIAG_*_NAME error fields of PostgreSQL-9.3 (#161).
181
-
182
-
183
- == v0.15.1 [2013-04-08] Michael Granger <ged@FaerieMUD.org>
184
-
185
- Bugfixes:
186
-
187
- - Shorten application_name to avoid warnings about truncated identifier.
188
-
189
-
190
- == v0.15.0 [2013-03-03] Michael Granger <ged@FaerieMUD.org>
191
-
192
- Bugfixes:
193
-
194
- - Fix segfault in PG::Result#field_values when called with non String value.
195
- - Fix encoding of messages delivered by notice callbacks.
196
- - Fix text encoding for Connection#wait_for_notify and Connection#notifies.
197
- - Fix 'Bad file descriptor' problems under Windows: wrong behaviour of
198
- #wait_for_notify() and timeout handling of #block on Ruby 1.9.
199
-
200
- Documentation fixes:
201
-
202
- - conn#socket() can not be used with IO.for_fd() on Windows.
203
-
204
- Enhancements:
205
-
206
- - Tested under Ruby 2.0.0p0.
207
- - Add single row mode of PostgreSQL 9.2.
208
- - Set fallback_application_name to programm name $0. Thanks to Will Leinweber
209
- for the patch.
210
- - Release Ruby's GVL while calls to blocking libpq functions to allow better
211
- concurrency in threaded applications.
212
- - Refactor different variants of waiting for the connection socket.
213
- - Make use of rb_thread_fd_select() on Ruby 1.9 and avoid deprecated
214
- rb_thread_select().
215
- - Add an example of how to insert array data using a prepared statement (#145).
216
- - Add continous integration tests on travis-ci.org.
217
- - Add PG::Result#each_row for iterative over result sets by row. Thanks to
218
- Aaron Patterson for the patch.
219
- - Add a PG::Connection#socket_io method for fetching a (non-autoclosing) IO
220
- object for the connection's socket.
221
-
222
- Specs:
223
-
224
- - Fix various specs to run on older PostgreSQL and Ruby versions.
225
- - Avoid fork() in specs to allow usage on Windows and JRuby.
226
-
227
-
228
- == v0.14.1 [2012-09-02] Michael Granger <ged@FaerieMUD.org>
229
-
230
- Important bugfix:
231
-
232
- - Fix stack overflow bug in PG::Result#values and #column_values (#135). Thanks
233
- to everyone who reported the bug, and Lars Kanis especially for figuring out
234
- the problem.
235
-
236
- PostgreSQL 9.2 beta fixes:
237
-
238
- - Recognize PGRES_SINGLE_TUPLE as OK when checking PGresult (Jeremy Evans)
239
-
240
- Documentation fixes:
241
-
242
- - Add note about the usage scope of the result object received by the
243
- #set_notice_receiver block. (Lars Kanis)
244
- - Add PGRES_COPY_BOTH to documentation of PG::Result#result_status. (Lars Kanis)
245
- - Add some documentation to PG::Result#fnumber (fix for #139)
246
-
247
-
248
- == v0.14.0 [2012-06-17] Michael Granger <ged@FaerieMUD.org>
249
-
250
- Bugfixes:
251
- #47, #104
252
-
253
-
254
- New Methods for PostgreSQL 9 and async API support:
255
- PG
256
- - ::library_version
257
-
258
- PG::Connection
259
- - ::ping
260
- - #escape_literal
261
- - #escape_identifier
262
- - #set_default_encoding
263
-
264
- PG::Result
265
- - #check
266
-
267
-
268
- New Samples:
269
-
270
- This release also comes with a collection of contributed sample scripts for
271
- doing resource-utilization reports, graphing database statistics,
272
- monitoring for replication lag, shipping WAL files for replication,
273
- automated tablespace partitioning, etc. See the samples/ directory.
274
-
275
-
276
- == v0.13.2 [2012-02-22] Michael Granger <ged@FaerieMUD.org>
277
-
278
- - Make builds against PostgreSQL earlier than 8.3 fail with a descriptive
279
- message instead of a compile failure.
280
-
281
-
282
- == v0.13.1 [2012-02-12] Michael Granger <ged@FaerieMUD.org>
283
-
284
- - Made use of a finished PG::Connection raise a PG::Error instead of
285
- a fatal error (#110).
286
- - Added missing BSDL license file (#108)
287
-
288
-
289
- == v0.13.0 [2012-02-09] Michael Granger <ged@FaerieMUD.org>
290
-
291
- Reorganization of modules/classes to be better Ruby citizens (with backward-compatible aliases):
292
- - Created toplevel namespace 'PG' to correspond with the gem name.
293
- - Renamed PGconn to PG::Connection (with ::PGconn alias)
294
- - Renamed PGresult to PG::Result (with ::PGresult alias)
295
- - Renamed PGError to PG::Error (with ::PGError alias)
296
- - Declare all constants inside PG::Constants, then include them in
297
- PG::Connection and PG::Result for backward-compatibility, and
298
- in PG for convenience.
299
- - Split the extension source up by class/module.
300
- - Removed old compatibility code for PostgreSQL versions < 8.3
301
-
302
- Documentation:
303
- - Clarified licensing, updated to Ruby 1.9's license.
304
- - Merged authors list, added some missing people to the Contributor's
305
- list.
306
- - Cleaned up the sample/ directory
307
- - Making contact info a bit clearer, link to the Google+ page and
308
- the mailing list
309
-
310
- Enhancements:
311
- - Added a convenience method: PG.connect -> PG::Connection.new
312
-
313
- Bugfixes:
314
- - Fixed LATIN5-LATIN10 Postgres<->Ruby encoding conversions
315
-
316
-
317
-
318
- == v0.12.2 [2012-01-03] Michael Granger <ged@FaerieMUD.org>
319
-
320
- - Fix for the 1.8.7 breakage introduced by the st.h fix for alternative Ruby
321
- implementations (#97 and #98). Thanks to Lars Kanis for the patch.
322
- - Encode error messages with the connection's encoding under 1.9 (#96)
323
-
324
-
325
- == v0.12.1 [2011-12-14] Michael Granger <ged@FaerieMUD.org>
326
-
327
- - Made rake-compiler a dev dependency, as Rubygems doesn't use the Rakefile
328
- for compiling the extension. Thanks to eolamey@bitbucket and Jeremy Evans
329
- for pointing this out.
330
- - Added an explicit include for ruby/st.h for implementations that need it
331
- (fixes #95).
332
-
333
-
334
- == v0.12.0 [2011-12-07] Michael Granger <ged@FaerieMUD.org>
335
-
336
- - PGconn#wait_for_notify
337
- * send nil as the payload argument if the NOTIFY didn't have one.
338
- * accept a nil argument for no timeout (Sequel support)
339
- * Fixed API docs
340
- * Taint and encode event name and payload
341
- - Handle errors while rb_thread_select()ing in PGconn#block.
342
- (Brian Weaver).
343
- - Fixes for Win32 async queries (Rafał Bigaj)
344
- - Memory leak fixed: Closing opened WSA event. (rafal)
345
- - Fixes for #66 Win32 asynchronous queries hang on connection
346
- error. (rafal)
347
- - Fixed a typo in PGconn#error_message's documentation
348
- - fixing unused variable warnings for ruby 1.9.3 (Aaron Patterson)
349
- - Build system bugfixes
350
- - Converted to Hoe
351
- - Updates for the Win32 binary gem builds (Lars Kanis)
352
-
353
-
354
- == v0.11.0 [2011-02-09] Michael Granger <ged@FaerieMUD.org>
355
-
356
- Enhancements:
357
-
358
- * Added a PGresult#values method to fetch all result rows as an Array of
359
- Arrays. Thanks to Jason Yanowitz (JYanowitz at enovafinancial dot com) for
360
- the patch.
361
-
362
-
363
- == v0.10.1 [2011-01-19] Michael Granger <ged@FaerieMUD.org>
364
-
365
- Bugfixes:
366
-
367
- * Add an include guard for pg.h
368
- * Simplify the common case require of the ext
369
- * Include the extconf header
370
- * Fix compatibility with versions of PostgreSQL without PQgetCancel. (fixes #36)
371
- * Fix require for natively-compiled extension under Windows. (fixes #55)
372
- * Change rb_yield_splat() to rb_yield_values() for compatibility with Rubinius. (fixes #54)
373
-
374
-
375
- == v0.10.0 [2010-12-01] Michael Granger <ged@FaerieMUD.org>
376
-
377
- Enhancements:
378
-
379
- * Added support for the payload of NOTIFY events (w/Mahlon E. Smith)
380
- * Updated the build system with Rubygems suggestions from RubyConf 2010
381
-
382
- Bugfixes:
383
-
384
- * Fixed issue with PGconn#wait_for_notify that caused it to miss notifications that happened after
385
- the LISTEN but before the wait_for_notify.
386
-
387
- == v0.9.0 [2010-02-28] Michael Granger <ged@FaerieMUD.org>
388
-
389
- Bugfixes.
390
-
391
- == v0.8.0 [2009-03-28] Jeff Davis <davis.jeffrey@gmail.com>
392
-
393
- Bugfixes, better Windows support.
394
-
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,168 +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
- {<img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/ged/ruby-pg">}[https://gitter.im/ged/ruby-pg?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge]
8
-
9
-
10
- == Description
11
-
12
- Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
13
-
14
- It works with {PostgreSQL 9.1 and later}[http://www.postgresql.org/support/versioning/].
15
-
16
- A small example usage:
17
-
18
- #!/usr/bin/env ruby
19
-
20
- require 'pg'
21
-
22
- # Output a table of current connections to the DB
23
- conn = PG.connect( dbname: 'sales' )
24
- conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
25
- puts " PID | User | Query"
26
- result.each do |row|
27
- puts " %7d | %-16s | %s " %
28
- row.values_at('procpid', 'usename', 'current_query')
29
- end
30
- end
31
-
32
- == Build Status
33
-
34
- {<img src="https://travis-ci.org/ged/ruby-pg.svg?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
35
- {<img src="https://ci.appveyor.com/api/projects/status/at4g4swb2cd4xji7/branch/master?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg]
36
-
37
-
38
- == Requirements
39
-
40
- * Ruby 2.2
41
- * PostgreSQL 9.1.x or later (with headers, -dev packages, etc).
42
-
43
- It usually work with earlier versions of Ruby/PostgreSQL as well, but those are
44
- not regularly tested.
45
-
46
-
47
- == How To Install
48
-
49
- Install via RubyGems:
50
-
51
- gem install pg
52
-
53
- You may need to specify the path to the 'pg_config' program installed with
54
- Postgres:
55
-
56
- gem install pg -- --with-pg-config=<path to pg_config>
57
-
58
- If you're installing via Bundler, you can provide compile hints like so:
59
-
60
- bundle config build.pg --with-pg-config=<path to pg_config>
61
-
62
- See README-OS_X.rdoc for more information about installing under MacOS X, and
63
- README-Windows.rdoc for Windows build/installation instructions.
64
-
65
- There's also {a Google+ group}[http://goo.gl/TFy1U] and a
66
- {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
67
- want to chat about something.
68
-
69
- If you want to install as a signed gem, the public certs of the gem signers
70
- can be found in {the `certs` directory}[https://bitbucket.org/ged/ruby-pg/src/tip/certs/]
71
- of the repository.
72
-
73
-
74
- == Type Casts
75
-
76
- Pg can optionally type cast result values and query parameters in Ruby or
77
- native C code. This can speed up data transfers to and from the database,
78
- because String allocations are reduced and conversions in (slower) Ruby code
79
- can be omitted.
80
-
81
- Very basic type casting can be enabled by:
82
-
83
- conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
84
- # ... this works for result value mapping:
85
- conn.exec("select 1, now(), '{2,3}'::int[]").values
86
- # => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
87
-
88
- conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
89
- # ... and this for param value mapping:
90
- conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
91
- # => [["1", "1.2300000000000000E+00", "{2,3}"]]
92
-
93
- But Pg's type casting is highly customizable. That's why it's divided into
94
- 2 layers:
95
-
96
- === Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
97
-
98
- This is the lower layer, containing encoding classes that convert Ruby
99
- objects for transmission to the DBMS and decoding classes to convert
100
- received data back to Ruby objects. The classes are namespaced according
101
- to their format and direction in PG::TextEncoder, PG::TextDecoder,
102
- PG::BinaryEncoder and PG::BinaryDecoder.
103
-
104
- It is possible to assign a type OID, format code (text or binary) and
105
- optionally a name to an encoder or decoder object. It's also possible
106
- to build composite types by assigning an element encoder/decoder.
107
- PG::Coder objects can be used to set up a PG::TypeMap or alternatively
108
- to convert single values to/from their string representation.
109
-
110
- === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
111
-
112
- A TypeMap defines which value will be converted by which encoder/decoder.
113
- There are different type map strategies, implemented by several derivations
114
- of this class. They can be chosen and configured according to the particular
115
- needs for type casting. The default type map is PG::TypeMapAllStrings.
116
-
117
- A type map can be assigned per connection or per query respectively per
118
- result set. Type maps can also be used for COPY in and out data streaming.
119
- See PG::Connection#copy_data .
120
-
121
- == Contributing
122
-
123
- To report bugs, suggest features, or check out the source with Mercurial,
124
- {check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
125
- Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
126
-
127
- After checking out the source, run:
128
-
129
- $ rake newb
130
-
131
- This task will install any missing dependencies, run the tests/specs, and
132
- generate the API documentation.
133
-
134
- The current maintainers are Michael Granger <ged@FaerieMUD.org> and
135
- Lars Kanis <lars@greiz-reinsdorf.de>.
136
-
137
-
138
- == Copying
139
-
140
- Copyright (c) 1997-2016 by the authors.
141
-
142
- * Jeff Davis <ruby-pg@j-davis.com>
143
- * Guy Decoux (ts) <decoux@moulon.inra.fr>
144
- * Michael Granger <ged@FaerieMUD.org>
145
- * Lars Kanis <lars@greiz-reinsdorf.de>
146
- * Dave Lee
147
- * Eiji Matsumoto <usagi@ruby.club.or.jp>
148
- * Yukihiro Matsumoto <matz@ruby-lang.org>
149
- * Noboru Saitou <noborus@netlab.jp>
150
-
151
- You may redistribute this software under the same terms as Ruby itself; see
152
- https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
153
- for details.
154
-
155
- Portions of the code are from the PostgreSQL project, and are distributed
156
- under the terms of the PostgreSQL license, included in the file POSTGRES.
157
-
158
- Portions copyright LAIKA, Inc.
159
-
160
-
161
- == Acknowledgments
162
-
163
- See Contributors.rdoc for the many additional fine people that have contributed
164
- to this library over the years.
165
-
166
- We are thankful to the people at the ruby-list and ruby-dev mailing lists.
167
- And to the people who developed PostgreSQL.
168
-