pg 1.2.3 → 1.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  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 +0 -1
  17. data/README.ja.md +276 -0
  18. data/README.md +286 -0
  19. data/Rakefile +33 -135
  20. data/Rakefile.cross +12 -13
  21. data/certs/ged.pem +24 -0
  22. data/certs/larskanis-2022.pem +26 -0
  23. data/certs/larskanis-2023.pem +24 -0
  24. data/ext/errorcodes.def +12 -0
  25. data/ext/errorcodes.rb +0 -0
  26. data/ext/errorcodes.txt +4 -1
  27. data/ext/extconf.rb +100 -25
  28. data/ext/gvl_wrappers.c +4 -0
  29. data/ext/gvl_wrappers.h +23 -0
  30. data/ext/pg.c +72 -57
  31. data/ext/pg.h +28 -4
  32. data/ext/pg_binary_decoder.c +80 -1
  33. data/ext/pg_binary_encoder.c +225 -1
  34. data/ext/pg_coder.c +96 -33
  35. data/ext/pg_connection.c +996 -697
  36. data/ext/pg_copy_coder.c +351 -33
  37. data/ext/pg_errors.c +1 -1
  38. data/ext/pg_record_coder.c +50 -19
  39. data/ext/pg_result.c +177 -64
  40. data/ext/pg_text_decoder.c +29 -11
  41. data/ext/pg_text_encoder.c +29 -16
  42. data/ext/pg_tuple.c +83 -60
  43. data/ext/pg_type_map.c +44 -10
  44. data/ext/pg_type_map_all_strings.c +17 -3
  45. data/ext/pg_type_map_by_class.c +54 -27
  46. data/ext/pg_type_map_by_column.c +73 -31
  47. data/ext/pg_type_map_by_mri_type.c +48 -19
  48. data/ext/pg_type_map_by_oid.c +59 -27
  49. data/ext/pg_type_map_in_ruby.c +55 -21
  50. data/ext/pg_util.c +2 -2
  51. data/lib/pg/basic_type_map_based_on_result.rb +67 -0
  52. data/lib/pg/basic_type_map_for_queries.rb +198 -0
  53. data/lib/pg/basic_type_map_for_results.rb +104 -0
  54. data/lib/pg/basic_type_registry.rb +299 -0
  55. data/lib/pg/binary_decoder/date.rb +9 -0
  56. data/lib/pg/binary_decoder/timestamp.rb +26 -0
  57. data/lib/pg/binary_encoder/timestamp.rb +20 -0
  58. data/lib/pg/coder.rb +15 -13
  59. data/lib/pg/connection.rb +743 -83
  60. data/lib/pg/exceptions.rb +14 -1
  61. data/lib/pg/text_decoder/date.rb +18 -0
  62. data/lib/pg/text_decoder/inet.rb +9 -0
  63. data/lib/pg/text_decoder/json.rb +14 -0
  64. data/lib/pg/text_decoder/numeric.rb +9 -0
  65. data/lib/pg/text_decoder/timestamp.rb +30 -0
  66. data/lib/pg/text_encoder/date.rb +12 -0
  67. data/lib/pg/text_encoder/inet.rb +28 -0
  68. data/lib/pg/text_encoder/json.rb +14 -0
  69. data/lib/pg/text_encoder/numeric.rb +9 -0
  70. data/lib/pg/text_encoder/timestamp.rb +24 -0
  71. data/lib/pg/version.rb +4 -0
  72. data/lib/pg.rb +94 -39
  73. data/misc/openssl-pg-segfault.rb +31 -0
  74. data/misc/postgres/History.txt +9 -0
  75. data/misc/postgres/Manifest.txt +5 -0
  76. data/misc/postgres/README.txt +21 -0
  77. data/misc/postgres/Rakefile +21 -0
  78. data/misc/postgres/lib/postgres.rb +16 -0
  79. data/misc/ruby-pg/History.txt +9 -0
  80. data/misc/ruby-pg/Manifest.txt +5 -0
  81. data/misc/ruby-pg/README.txt +21 -0
  82. data/misc/ruby-pg/Rakefile +21 -0
  83. data/misc/ruby-pg/lib/ruby/pg.rb +16 -0
  84. data/pg.gemspec +34 -0
  85. data/rakelib/task_extension.rb +46 -0
  86. data/sample/array_insert.rb +20 -0
  87. data/sample/async_api.rb +102 -0
  88. data/sample/async_copyto.rb +39 -0
  89. data/sample/async_mixed.rb +56 -0
  90. data/sample/check_conn.rb +21 -0
  91. data/sample/copydata.rb +71 -0
  92. data/sample/copyfrom.rb +81 -0
  93. data/sample/copyto.rb +19 -0
  94. data/sample/cursor.rb +21 -0
  95. data/sample/disk_usage_report.rb +177 -0
  96. data/sample/issue-119.rb +94 -0
  97. data/sample/losample.rb +69 -0
  98. data/sample/minimal-testcase.rb +17 -0
  99. data/sample/notify_wait.rb +72 -0
  100. data/sample/pg_statistics.rb +285 -0
  101. data/sample/replication_monitor.rb +222 -0
  102. data/sample/test_binary_values.rb +33 -0
  103. data/sample/wal_shipper.rb +434 -0
  104. data/sample/warehouse_partitions.rb +311 -0
  105. data/translation/.po4a-version +7 -0
  106. data/translation/po/all.pot +910 -0
  107. data/translation/po/ja.po +1047 -0
  108. data/translation/po4a.cfg +12 -0
  109. data.tar.gz.sig +0 -0
  110. metadata +142 -210
  111. metadata.gz.sig +0 -0
  112. data/ChangeLog +0 -0
  113. data/History.rdoc +0 -578
  114. data/README.ja.rdoc +0 -13
  115. data/README.rdoc +0 -213
  116. data/lib/pg/basic_type_mapping.rb +0 -522
  117. data/lib/pg/binary_decoder.rb +0 -23
  118. data/lib/pg/constants.rb +0 -12
  119. data/lib/pg/text_decoder.rb +0 -46
  120. data/lib/pg/text_encoder.rb +0 -59
  121. data/spec/data/expected_trace.out +0 -26
  122. data/spec/data/random_binary_data +0 -0
  123. data/spec/helpers.rb +0 -380
  124. data/spec/pg/basic_type_mapping_spec.rb +0 -630
  125. data/spec/pg/connection_spec.rb +0 -1949
  126. data/spec/pg/connection_sync_spec.rb +0 -41
  127. data/spec/pg/result_spec.rb +0 -681
  128. data/spec/pg/tuple_spec.rb +0 -333
  129. data/spec/pg/type_map_by_class_spec.rb +0 -138
  130. data/spec/pg/type_map_by_column_spec.rb +0 -226
  131. data/spec/pg/type_map_by_mri_type_spec.rb +0 -136
  132. data/spec/pg/type_map_by_oid_spec.rb +0 -149
  133. data/spec/pg/type_map_in_ruby_spec.rb +0 -164
  134. data/spec/pg/type_map_spec.rb +0 -22
  135. data/spec/pg/type_spec.rb +0 -1123
  136. data/spec/pg_spec.rb +0 -50
data/README.rdoc DELETED
@@ -1,213 +0,0 @@
1
- = pg
2
-
3
- home :: https://github.com/ged/ruby-pg
4
- docs :: http://deveiate.org/code/pg
5
-
6
- {<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]
7
-
8
-
9
- == Description
10
-
11
- Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
12
-
13
- It works with {PostgreSQL 9.2 and later}[http://www.postgresql.org/support/versioning/].
14
-
15
- A small example usage:
16
-
17
- #!/usr/bin/env ruby
18
-
19
- require 'pg'
20
-
21
- # Output a table of current connections to the DB
22
- conn = PG.connect( dbname: 'sales' )
23
- conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
24
- puts " PID | User | Query"
25
- result.each do |row|
26
- puts " %7d | %-16s | %s " %
27
- row.values_at('procpid', 'usename', 'current_query')
28
- end
29
- end
30
-
31
- == Build Status
32
-
33
- {<img src="https://travis-ci.org/ged/ruby-pg.svg?branch=master" alt="Build Status Travis-CI" />}[https://travis-ci.org/ged/ruby-pg]
34
- {<img src="https://ci.appveyor.com/api/projects/status/gjx5axouf3b1wicp?svg=true" alt="Build Status Appveyor" />}[https://ci.appveyor.com/project/ged/ruby-pg-9j8l3]
35
-
36
-
37
- == Requirements
38
-
39
- * Ruby 2.2 or newer
40
- * PostgreSQL 9.2.x or later (with headers, -dev packages, etc).
41
-
42
- It usually works with earlier versions of Ruby/PostgreSQL as well, but those are
43
- not regularly tested.
44
-
45
-
46
- == Versioning
47
-
48
- We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
49
-
50
- As a result of this policy, you can (and should) specify a dependency on this gem using the {Pessimistic Version Constraint}[http://guides.rubygems.org/patterns/#pessimistic-version-constraint] with two digits of precision.
51
-
52
- For example:
53
-
54
- spec.add_dependency 'pg', '~> 1.0'
55
-
56
-
57
- == How To Install
58
-
59
- Install via RubyGems:
60
-
61
- gem install pg
62
-
63
- You may need to specify the path to the 'pg_config' program installed with
64
- Postgres:
65
-
66
- gem install pg -- --with-pg-config=<path to pg_config>
67
-
68
- If you're installing via Bundler, you can provide compile hints like so:
69
-
70
- bundle config build.pg --with-pg-config=<path to pg_config>
71
-
72
- See README-OS_X.rdoc for more information about installing under MacOS X, and
73
- README-Windows.rdoc for Windows build/installation instructions.
74
-
75
- There's also {a Google+ group}[http://goo.gl/TFy1U] and a
76
- {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
77
- want to chat about something.
78
-
79
- If you want to install as a signed gem, the public certs of the gem signers
80
- can be found in {the `certs` directory}[https://github.com/ged/ruby-pg/tree/master/certs]
81
- of the repository.
82
-
83
-
84
- == Type Casts
85
-
86
- Pg can optionally type cast result values and query parameters in Ruby or
87
- native C code. This can speed up data transfers to and from the database,
88
- because String allocations are reduced and conversions in (slower) Ruby code
89
- can be omitted.
90
-
91
- Very basic type casting can be enabled by:
92
-
93
- conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
94
- # ... this works for result value mapping:
95
- conn.exec("select 1, now(), '{2,3}'::int[]").values
96
- # => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
97
-
98
- conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
99
- # ... and this for param value mapping:
100
- conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
101
- # => [["1", "1.2300000000000000E+00", "{2,3}"]]
102
-
103
- But Pg's type casting is highly customizable. That's why it's divided into
104
- 2 layers:
105
-
106
- === Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
107
-
108
- This is the lower layer, containing encoding classes that convert Ruby
109
- objects for transmission to the DBMS and decoding classes to convert
110
- received data back to Ruby objects. The classes are namespaced according
111
- to their format and direction in PG::TextEncoder, PG::TextDecoder,
112
- PG::BinaryEncoder and PG::BinaryDecoder.
113
-
114
- It is possible to assign a type OID, format code (text or binary) and
115
- optionally a name to an encoder or decoder object. It's also possible
116
- to build composite types by assigning an element encoder/decoder.
117
- PG::Coder objects can be used to set up a PG::TypeMap or alternatively
118
- to convert single values to/from their string representation.
119
-
120
- The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
121
- * Integer: {TE}[rdoc-ref:PG::TextEncoder::Integer], {TD}[rdoc-ref:PG::TextDecoder::Integer], {BD}[rdoc-ref:PG::BinaryDecoder::Integer] 💡 No links? Switch to {here}[https://deveiate.org/code/pg/README_rdoc.html#label-Type+Casts] 💡
122
- * BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
123
- * Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
124
- * Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
125
- * Boolean: {TE}[rdoc-ref:PG::TextEncoder::Boolean], {TD}[rdoc-ref:PG::TextDecoder::Boolean], {BE}[rdoc-ref:PG::BinaryEncoder::Boolean], {BD}[rdoc-ref:PG::BinaryDecoder::Boolean]
126
- * String: {TE}[rdoc-ref:PG::TextEncoder::String], {TD}[rdoc-ref:PG::TextDecoder::String], {BE}[rdoc-ref:PG::BinaryEncoder::String], {BD}[rdoc-ref:PG::BinaryDecoder::String]
127
- * Bytea: {TE}[rdoc-ref:PG::TextEncoder::Bytea], {TD}[rdoc-ref:PG::TextDecoder::Bytea], {BE}[rdoc-ref:PG::BinaryEncoder::Bytea], {BD}[rdoc-ref:PG::BinaryDecoder::Bytea]
128
- * Base64: {TE}[rdoc-ref:PG::TextEncoder::ToBase64], {TD}[rdoc-ref:PG::TextDecoder::FromBase64], {BE}[rdoc-ref:PG::BinaryEncoder::FromBase64], {BD}[rdoc-ref:PG::BinaryDecoder::ToBase64]
129
- * Timestamp:
130
- * TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
131
- * TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
132
- * BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
133
- * Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
134
- * JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
135
- * Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
136
- * Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
137
- * Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
138
-
139
- The following text formats can also be encoded although they are not used as column type:
140
- * COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
141
- * Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
142
- * SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
143
-
144
- === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
145
-
146
- A TypeMap defines which value will be converted by which encoder/decoder.
147
- There are different type map strategies, implemented by several derivations
148
- of this class. They can be chosen and configured according to the particular
149
- needs for type casting. The default type map is PG::TypeMapAllStrings.
150
-
151
- A type map can be assigned per connection or per query respectively per
152
- result set. Type maps can also be used for COPY in and out data streaming.
153
- See PG::Connection#copy_data .
154
-
155
- The following base type maps are available:
156
- * PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
157
- * PG::TypeMapByClass - selects encoder based on the class of the value to be sent
158
- * PG::TypeMapByColumn - selects encoder and decoder by column order
159
- * PG::TypeMapByOid - selects decoder by PostgreSQL type OID
160
- * PG::TypeMapInRuby - define a custom type map in ruby
161
-
162
- The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
163
- * PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
164
- * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
165
- * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
166
-
167
-
168
- == Contributing
169
-
170
- To report bugs, suggest features, or check out the source with Git,
171
- {check out the project page}[https://github.com/ged/ruby-pg].
172
-
173
- After checking out the source, run:
174
-
175
- $ rake newb
176
-
177
- This task will install any missing dependencies, run the tests/specs, and
178
- generate the API documentation.
179
-
180
- The current maintainers are Michael Granger <ged@FaerieMUD.org> and
181
- Lars Kanis <lars@greiz-reinsdorf.de>.
182
-
183
-
184
- == Copying
185
-
186
- Copyright (c) 1997-2019 by the authors.
187
-
188
- * Jeff Davis <ruby-pg@j-davis.com>
189
- * Guy Decoux (ts) <decoux@moulon.inra.fr>
190
- * Michael Granger <ged@FaerieMUD.org>
191
- * Lars Kanis <lars@greiz-reinsdorf.de>
192
- * Dave Lee
193
- * Eiji Matsumoto <usagi@ruby.club.or.jp>
194
- * Yukihiro Matsumoto <matz@ruby-lang.org>
195
- * Noboru Saitou <noborus@netlab.jp>
196
-
197
- You may redistribute this software under the same terms as Ruby itself; see
198
- https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
199
- for details.
200
-
201
- Portions of the code are from the PostgreSQL project, and are distributed
202
- under the terms of the PostgreSQL license, included in the file POSTGRES.
203
-
204
- Portions copyright LAIKA, Inc.
205
-
206
-
207
- == Acknowledgments
208
-
209
- See Contributors.rdoc for the many additional fine people that have contributed
210
- to this library over the years.
211
-
212
- We are thankful to the people at the ruby-list and ruby-dev mailing lists.
213
- And to the people who developed PostgreSQL.