pg 1.2.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/Gemfile +14 -0
- data/History.md +884 -0
- data/Manifest.txt +0 -1
- data/README.ja.md +300 -0
- data/README.md +286 -0
- data/Rakefile +33 -135
- data/Rakefile.cross +12 -13
- data/certs/ged.pem +24 -0
- data/certs/larskanis-2022.pem +26 -0
- data/certs/larskanis-2023.pem +24 -0
- data/ext/errorcodes.def +12 -0
- data/ext/errorcodes.rb +0 -0
- data/ext/errorcodes.txt +4 -1
- data/ext/extconf.rb +104 -25
- data/ext/gvl_wrappers.c +4 -0
- data/ext/gvl_wrappers.h +23 -0
- data/ext/pg.c +73 -58
- data/ext/pg.h +28 -5
- data/ext/pg_binary_decoder.c +80 -1
- data/ext/pg_binary_encoder.c +225 -1
- data/ext/pg_coder.c +96 -33
- data/ext/pg_connection.c +1010 -704
- data/ext/pg_copy_coder.c +351 -33
- data/ext/pg_errors.c +1 -1
- data/ext/pg_record_coder.c +50 -19
- data/ext/pg_result.c +177 -64
- data/ext/pg_text_decoder.c +29 -11
- data/ext/pg_text_encoder.c +29 -16
- data/ext/pg_tuple.c +83 -60
- data/ext/pg_type_map.c +44 -10
- data/ext/pg_type_map_all_strings.c +17 -3
- data/ext/pg_type_map_by_class.c +54 -27
- data/ext/pg_type_map_by_column.c +73 -31
- data/ext/pg_type_map_by_mri_type.c +48 -19
- data/ext/pg_type_map_by_oid.c +59 -27
- data/ext/pg_type_map_in_ruby.c +55 -21
- data/ext/pg_util.c +2 -2
- data/lib/pg/basic_type_map_based_on_result.rb +67 -0
- data/lib/pg/basic_type_map_for_queries.rb +198 -0
- data/lib/pg/basic_type_map_for_results.rb +104 -0
- data/lib/pg/basic_type_registry.rb +299 -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 +15 -13
- data/lib/pg/connection.rb +743 -83
- data/lib/pg/exceptions.rb +14 -1
- 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/version.rb +4 -0
- data/lib/pg.rb +94 -39
- 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 +20 -0
- data/sample/async_api.rb +102 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -0
- data/sample/copydata.rb +71 -0
- data/sample/copyfrom.rb +81 -0
- data/sample/copyto.rb +19 -0
- data/sample/cursor.rb +21 -0
- data/sample/disk_usage_report.rb +177 -0
- data/sample/issue-119.rb +94 -0
- data/sample/losample.rb +69 -0
- data/sample/minimal-testcase.rb +17 -0
- data/sample/notify_wait.rb +72 -0
- data/sample/pg_statistics.rb +285 -0
- data/sample/replication_monitor.rb +222 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +311 -0
- data/translation/.po4a-version +7 -0
- data/translation/po/all.pot +936 -0
- data/translation/po/ja.po +1036 -0
- data/translation/po4a.cfg +12 -0
- data.tar.gz.sig +0 -0
- metadata +135 -207
- metadata.gz.sig +0 -0
- data/ChangeLog +0 -0
- data/History.rdoc +0 -578
- data/README.ja.rdoc +0 -13
- data/README.rdoc +0 -213
- data/lib/pg/basic_type_mapping.rb +0 -522
- data/lib/pg/binary_decoder.rb +0 -23
- data/lib/pg/constants.rb +0 -12
- data/lib/pg/text_decoder.rb +0 -46
- data/lib/pg/text_encoder.rb +0 -59
- data/spec/data/expected_trace.out +0 -26
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +0 -380
- data/spec/pg/basic_type_mapping_spec.rb +0 -630
- data/spec/pg/connection_spec.rb +0 -1949
- data/spec/pg/connection_sync_spec.rb +0 -41
- data/spec/pg/result_spec.rb +0 -681
- data/spec/pg/tuple_spec.rb +0 -333
- data/spec/pg/type_map_by_class_spec.rb +0 -138
- data/spec/pg/type_map_by_column_spec.rb +0 -226
- 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 -1123
- 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.
|