pg 0.18.4 → 1.5.3

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