pg 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +3 -0
- data.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/BSDL +22 -0
- data/ChangeLog +6595 -0
- data/Contributors.rdoc +46 -0
- data/History.rdoc +492 -0
- data/LICENSE +56 -0
- data/Manifest.txt +72 -0
- data/POSTGRES +23 -0
- data/README-OS_X.rdoc +68 -0
- data/README-Windows.rdoc +56 -0
- data/README.ja.rdoc +14 -0
- data/README.rdoc +178 -0
- data/Rakefile +215 -0
- data/Rakefile.cross +298 -0
- data/ext/errorcodes.def +968 -0
- data/ext/errorcodes.rb +45 -0
- data/ext/errorcodes.txt +478 -0
- data/ext/extconf.rb +94 -0
- data/ext/gvl_wrappers.c +17 -0
- data/ext/gvl_wrappers.h +241 -0
- data/ext/pg.c +640 -0
- data/ext/pg.h +365 -0
- data/ext/pg_binary_decoder.c +229 -0
- data/ext/pg_binary_encoder.c +162 -0
- data/ext/pg_coder.c +549 -0
- data/ext/pg_connection.c +4252 -0
- data/ext/pg_copy_coder.c +596 -0
- data/ext/pg_errors.c +95 -0
- data/ext/pg_result.c +1501 -0
- data/ext/pg_text_decoder.c +981 -0
- data/ext/pg_text_encoder.c +682 -0
- data/ext/pg_tuple.c +541 -0
- data/ext/pg_type_map.c +166 -0
- data/ext/pg_type_map_all_strings.c +116 -0
- data/ext/pg_type_map_by_class.c +239 -0
- data/ext/pg_type_map_by_column.c +312 -0
- data/ext/pg_type_map_by_mri_type.c +284 -0
- data/ext/pg_type_map_by_oid.c +355 -0
- data/ext/pg_type_map_in_ruby.c +299 -0
- data/ext/util.c +149 -0
- data/ext/util.h +65 -0
- data/ext/vc/pg.sln +26 -0
- data/ext/vc/pg_18/pg.vcproj +216 -0
- data/ext/vc/pg_19/pg_19.vcproj +209 -0
- data/lib/pg.rb +74 -0
- data/lib/pg/basic_type_mapping.rb +459 -0
- data/lib/pg/binary_decoder.rb +22 -0
- data/lib/pg/coder.rb +83 -0
- data/lib/pg/connection.rb +291 -0
- data/lib/pg/constants.rb +11 -0
- data/lib/pg/exceptions.rb +11 -0
- data/lib/pg/result.rb +31 -0
- data/lib/pg/text_decoder.rb +47 -0
- data/lib/pg/text_encoder.rb +69 -0
- data/lib/pg/tuple.rb +30 -0
- data/lib/pg/type_map_by_column.rb +15 -0
- data/spec/data/expected_trace.out +26 -0
- data/spec/data/random_binary_data +0 -0
- data/spec/helpers.rb +380 -0
- data/spec/pg/basic_type_mapping_spec.rb +508 -0
- data/spec/pg/connection_spec.rb +1872 -0
- data/spec/pg/connection_sync_spec.rb +41 -0
- data/spec/pg/result_spec.rb +491 -0
- data/spec/pg/tuple_spec.rb +280 -0
- data/spec/pg/type_map_by_class_spec.rb +138 -0
- data/spec/pg/type_map_by_column_spec.rb +222 -0
- data/spec/pg/type_map_by_mri_type_spec.rb +136 -0
- data/spec/pg/type_map_by_oid_spec.rb +149 -0
- data/spec/pg/type_map_in_ruby_spec.rb +164 -0
- data/spec/pg/type_map_spec.rb +22 -0
- data/spec/pg/type_spec.rb +949 -0
- data/spec/pg_spec.rb +50 -0
- metadata +322 -0
- metadata.gz.sig +0 -0
data/LICENSE
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
.gemtest
|
2
|
+
BSDL
|
3
|
+
ChangeLog
|
4
|
+
Contributors.rdoc
|
5
|
+
History.rdoc
|
6
|
+
LICENSE
|
7
|
+
Manifest.txt
|
8
|
+
POSTGRES
|
9
|
+
README-OS_X.rdoc
|
10
|
+
README-Windows.rdoc
|
11
|
+
README.ja.rdoc
|
12
|
+
README.rdoc
|
13
|
+
Rakefile
|
14
|
+
Rakefile.cross
|
15
|
+
ext/errorcodes.def
|
16
|
+
ext/errorcodes.rb
|
17
|
+
ext/errorcodes.txt
|
18
|
+
ext/extconf.rb
|
19
|
+
ext/gvl_wrappers.c
|
20
|
+
ext/gvl_wrappers.h
|
21
|
+
ext/pg.c
|
22
|
+
ext/pg.h
|
23
|
+
ext/pg_binary_decoder.c
|
24
|
+
ext/pg_binary_encoder.c
|
25
|
+
ext/pg_coder.c
|
26
|
+
ext/pg_connection.c
|
27
|
+
ext/pg_copy_coder.c
|
28
|
+
ext/pg_errors.c
|
29
|
+
ext/pg_result.c
|
30
|
+
ext/pg_text_decoder.c
|
31
|
+
ext/pg_text_encoder.c
|
32
|
+
ext/pg_tuple.c
|
33
|
+
ext/pg_type_map.c
|
34
|
+
ext/pg_type_map_all_strings.c
|
35
|
+
ext/pg_type_map_by_class.c
|
36
|
+
ext/pg_type_map_by_column.c
|
37
|
+
ext/pg_type_map_by_mri_type.c
|
38
|
+
ext/pg_type_map_by_oid.c
|
39
|
+
ext/pg_type_map_in_ruby.c
|
40
|
+
ext/util.c
|
41
|
+
ext/util.h
|
42
|
+
ext/vc/pg.sln
|
43
|
+
ext/vc/pg_18/pg.vcproj
|
44
|
+
ext/vc/pg_19/pg_19.vcproj
|
45
|
+
lib/pg.rb
|
46
|
+
lib/pg/basic_type_mapping.rb
|
47
|
+
lib/pg/binary_decoder.rb
|
48
|
+
lib/pg/coder.rb
|
49
|
+
lib/pg/connection.rb
|
50
|
+
lib/pg/constants.rb
|
51
|
+
lib/pg/exceptions.rb
|
52
|
+
lib/pg/result.rb
|
53
|
+
lib/pg/text_decoder.rb
|
54
|
+
lib/pg/text_encoder.rb
|
55
|
+
lib/pg/tuple.rb
|
56
|
+
lib/pg/type_map_by_column.rb
|
57
|
+
spec/data/expected_trace.out
|
58
|
+
spec/data/random_binary_data
|
59
|
+
spec/helpers.rb
|
60
|
+
spec/pg/basic_type_mapping_spec.rb
|
61
|
+
spec/pg/connection_spec.rb
|
62
|
+
spec/pg/connection_sync_spec.rb
|
63
|
+
spec/pg/result_spec.rb
|
64
|
+
spec/pg/tuple_spec.rb
|
65
|
+
spec/pg/type_map_by_class_spec.rb
|
66
|
+
spec/pg/type_map_by_column_spec.rb
|
67
|
+
spec/pg/type_map_by_mri_type_spec.rb
|
68
|
+
spec/pg/type_map_by_oid_spec.rb
|
69
|
+
spec/pg/type_map_in_ruby_spec.rb
|
70
|
+
spec/pg/type_map_spec.rb
|
71
|
+
spec/pg/type_spec.rb
|
72
|
+
spec/pg_spec.rb
|
data/POSTGRES
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
PostgreSQL Database Management System
|
2
|
+
(formerly known as Postgres, then as Postgres95)
|
3
|
+
|
4
|
+
Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
5
|
+
|
6
|
+
Portions Copyright (c) 1994, The Regents of the University of California
|
7
|
+
|
8
|
+
Permission to use, copy, modify, and distribute this software and its
|
9
|
+
documentation for any purpose, without fee, and without a written agreement
|
10
|
+
is hereby granted, provided that the above copyright notice and this
|
11
|
+
paragraph and the following two paragraphs appear in all copies.
|
12
|
+
|
13
|
+
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
|
14
|
+
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
|
15
|
+
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
|
16
|
+
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
|
17
|
+
POSSIBILITY OF SUCH DAMAGE.
|
18
|
+
|
19
|
+
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
|
20
|
+
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
21
|
+
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
|
22
|
+
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
|
23
|
+
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
|
data/README-OS_X.rdoc
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
= Compiling on MacOS X
|
2
|
+
|
3
|
+
The EnterpriseDB packages are the recommended PostgreSQL installations to use
|
4
|
+
with MacOS X. They eliminate most or all of the issues with getting 'pg'
|
5
|
+
installed, linked correctly, and running.
|
6
|
+
|
7
|
+
== Segfaults and SSL Support
|
8
|
+
|
9
|
+
If you need a custom installation of PostgreSQL, you should ensure that you
|
10
|
+
either compile it against the same version of OpenSSL as the OpenSSL extension
|
11
|
+
of the Ruby you'll be using, or compile it without SSL support. If you fail to
|
12
|
+
do this, you will likely see segfaults when you use 'pg' and the 'openssl'
|
13
|
+
extension at the same time. You can see what library it's linked against using
|
14
|
+
'otool -L'; for example, on my 10.7 machine I use for 'pg' development:
|
15
|
+
|
16
|
+
$ otool -L /System/Library/Frameworks/Ruby.framework/Versions\
|
17
|
+
/1.8/usr/lib/ruby/1.8/universal-darwin11.0/openssl.bundle
|
18
|
+
|
19
|
+
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/\
|
20
|
+
lib/ruby/1.8/universal-darwin11.0/openssl.bundle:
|
21
|
+
/System/Library/Frameworks/Ruby.framework/Versions/1.8/\
|
22
|
+
usr/lib/libruby.1.dylib (compatibility version 1.8.0, \
|
23
|
+
current version 1.8.7)
|
24
|
+
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, \
|
25
|
+
current version 0.9.8)
|
26
|
+
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, \
|
27
|
+
current version 0.9.8)
|
28
|
+
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, \
|
29
|
+
current version 159.0.0)
|
30
|
+
|
31
|
+
|
32
|
+
== Dealing with Installation Problems
|
33
|
+
|
34
|
+
If you are building/installing pg on MacOS X, and the installation doesn't
|
35
|
+
work at first, here are a few things you can try.
|
36
|
+
|
37
|
+
=== pg_config
|
38
|
+
|
39
|
+
The first thing you should do is ensure that the 'pg_config' tool that comes
|
40
|
+
with Postgres is in your path. If it isn't, or the one that's first in your
|
41
|
+
path isn't the one that was installed with the Postgres you want to build
|
42
|
+
against, you can specify the path to it with the --with-pg-config option.
|
43
|
+
|
44
|
+
For example, if you're using the Ruby binary that comes with OSX, and
|
45
|
+
PostgreSQL 9.0.x installed from MacPorts, do:
|
46
|
+
|
47
|
+
gem install -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
|
48
|
+
|
49
|
+
=== ARCHFLAGS and Universal Binaries
|
50
|
+
|
51
|
+
OS X supports both architecture-specific binaries (e.g. i386), as well as
|
52
|
+
universal binaries (i.e. i386 & ppc). If Ruby is built as a universal binary
|
53
|
+
and PostgreSQL is not, you need to specify the path to the appropriate
|
54
|
+
pg_config binary or set the environment variable ARCHFLAGS appropriately.
|
55
|
+
|
56
|
+
Alternatively, if the build system can't figure out which architectures it
|
57
|
+
should include, you may need to set the 'ARCHFLAGS' environment variable
|
58
|
+
explicitly:
|
59
|
+
|
60
|
+
sudo env ARCHFLAGS='-arch x86_64' gem install pg
|
61
|
+
|
62
|
+
or, if you're building from source:
|
63
|
+
|
64
|
+
rake compile ARCHFLAGS="-arch x86_64"
|
65
|
+
|
66
|
+
Note that the recommended EnterpriseDB packages are correctly compiled as
|
67
|
+
universal binaries, and don't need any of these workarounds.
|
68
|
+
|
data/README-Windows.rdoc
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
= Compiling 'pg' on MS Windows
|
2
|
+
|
3
|
+
In order to build this extension on MS Windows you will need a couple things.
|
4
|
+
|
5
|
+
First, a compiler. For the one click installer this means you should use
|
6
|
+
the DevKit or the compiler that comes with cygwin if you're building on that
|
7
|
+
platform.
|
8
|
+
|
9
|
+
If you've built Ruby yourself, you should use the same compiler to build
|
10
|
+
this library that you used to build Ruby.
|
11
|
+
|
12
|
+
Second, PostgreSQL. Be sure you installed it with the development header
|
13
|
+
files if you installed it using the standard PostgreSQL installer for
|
14
|
+
Windows. If you didn't, you can run the installer again, select "modify",
|
15
|
+
and then select the 'development headers' option to install them.
|
16
|
+
|
17
|
+
I recommend making sure that 'pg_config.exe' is in your PATH. The PostgreSQL
|
18
|
+
installer for Windows does not necessarily update your PATH when it installs
|
19
|
+
itself, so you may need to do this manually. This isn't strictly necessary,
|
20
|
+
however.
|
21
|
+
|
22
|
+
In order to build ruby-pg, just run 'rake'. If the pg_config.exe executable
|
23
|
+
is not in your PATH, you'll need to explicitly point ruby-pg to where your
|
24
|
+
PostgreSQL headers and libraries are with something like this:
|
25
|
+
|
26
|
+
rake --with-pg-dir=c:/progra~1/postgr~1/8.3
|
27
|
+
|
28
|
+
Adjust your path accordingly. BE SURE TO USE THE SHORT PATH NAMES! If you
|
29
|
+
try to use a path with spaces in it, the nmake.exe program will choke.
|
30
|
+
|
31
|
+
|
32
|
+
== Building binary 'pg' gems for MS Windows
|
33
|
+
|
34
|
+
Binary gems for windows can be built on Linux, OS-X and even on Windows
|
35
|
+
with the help of docker. This is how regular windows gems are built for
|
36
|
+
rubygems.org .
|
37
|
+
|
38
|
+
To do this, install boot2docker [on Windows](https://github.com/boot2docker/windows-installer/releases)
|
39
|
+
or [on OS X](https://github.com/boot2docker/osx-installer/releases) and make
|
40
|
+
sure it is started. A native Docker installation is best on Linux.
|
41
|
+
|
42
|
+
Then run:
|
43
|
+
|
44
|
+
rake gem:windows
|
45
|
+
|
46
|
+
This will download a docker image suited for building windows gems, and it
|
47
|
+
will download and build OpenSSL and PostgreSQL. Finally the gem is built
|
48
|
+
containing binaries for all supported ruby versions.
|
49
|
+
|
50
|
+
|
51
|
+
== Reporting Problems
|
52
|
+
|
53
|
+
If you have any problems you can submit them via
|
54
|
+
[the project's issue-tracker][bitbucket]. And submit questions, problems, or
|
55
|
+
solutions, so that it can be improved.
|
56
|
+
|
data/README.ja.rdoc
ADDED
@@ -0,0 +1,14 @@
|
|
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
ADDED
@@ -0,0 +1,178 @@
|
|
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.2 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 or newer
|
41
|
+
* PostgreSQL 9.2.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
|
+
== Versioning
|
48
|
+
|
49
|
+
We tag and release gems according to the {Semantic Versioning}[http://semver.org/] principle.
|
50
|
+
|
51
|
+
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.
|
52
|
+
|
53
|
+
For example:
|
54
|
+
|
55
|
+
spec.add_dependency 'pg', '~> 1.0'
|
56
|
+
|
57
|
+
|
58
|
+
== How To Install
|
59
|
+
|
60
|
+
Install via RubyGems:
|
61
|
+
|
62
|
+
gem install pg
|
63
|
+
|
64
|
+
You may need to specify the path to the 'pg_config' program installed with
|
65
|
+
Postgres:
|
66
|
+
|
67
|
+
gem install pg -- --with-pg-config=<path to pg_config>
|
68
|
+
|
69
|
+
If you're installing via Bundler, you can provide compile hints like so:
|
70
|
+
|
71
|
+
bundle config build.pg --with-pg-config=<path to pg_config>
|
72
|
+
|
73
|
+
See README-OS_X.rdoc for more information about installing under MacOS X, and
|
74
|
+
README-Windows.rdoc for Windows build/installation instructions.
|
75
|
+
|
76
|
+
There's also {a Google+ group}[http://goo.gl/TFy1U] and a
|
77
|
+
{mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
|
78
|
+
want to chat about something.
|
79
|
+
|
80
|
+
If you want to install as a signed gem, the public certs of the gem signers
|
81
|
+
can be found in {the `certs` directory}[https://bitbucket.org/ged/ruby-pg/src/tip/certs/]
|
82
|
+
of the repository.
|
83
|
+
|
84
|
+
|
85
|
+
== Type Casts
|
86
|
+
|
87
|
+
Pg can optionally type cast result values and query parameters in Ruby or
|
88
|
+
native C code. This can speed up data transfers to and from the database,
|
89
|
+
because String allocations are reduced and conversions in (slower) Ruby code
|
90
|
+
can be omitted.
|
91
|
+
|
92
|
+
Very basic type casting can be enabled by:
|
93
|
+
|
94
|
+
conn.type_map_for_results = PG::BasicTypeMapForResults.new conn
|
95
|
+
# ... this works for result value mapping:
|
96
|
+
conn.exec("select 1, now(), '{2,3}'::int[]").values
|
97
|
+
# => [[1, 2014-09-21 20:51:56 +0200, [2, 3]]]
|
98
|
+
|
99
|
+
conn.type_map_for_queries = PG::BasicTypeMapForQueries.new conn
|
100
|
+
# ... and this for param value mapping:
|
101
|
+
conn.exec_params("SELECT $1::text, $2::text, $3::text", [1, 1.23, [2,3]]).values
|
102
|
+
# => [["1", "1.2300000000000000E+00", "{2,3}"]]
|
103
|
+
|
104
|
+
But Pg's type casting is highly customizable. That's why it's divided into
|
105
|
+
2 layers:
|
106
|
+
|
107
|
+
=== Encoders / Decoders (ext/pg_*coder.c, lib/pg/*coder.rb)
|
108
|
+
|
109
|
+
This is the lower layer, containing encoding classes that convert Ruby
|
110
|
+
objects for transmission to the DBMS and decoding classes to convert
|
111
|
+
received data back to Ruby objects. The classes are namespaced according
|
112
|
+
to their format and direction in PG::TextEncoder, PG::TextDecoder,
|
113
|
+
PG::BinaryEncoder and PG::BinaryDecoder.
|
114
|
+
|
115
|
+
It is possible to assign a type OID, format code (text or binary) and
|
116
|
+
optionally a name to an encoder or decoder object. It's also possible
|
117
|
+
to build composite types by assigning an element encoder/decoder.
|
118
|
+
PG::Coder objects can be used to set up a PG::TypeMap or alternatively
|
119
|
+
to convert single values to/from their string representation.
|
120
|
+
|
121
|
+
=== PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
|
122
|
+
|
123
|
+
A TypeMap defines which value will be converted by which encoder/decoder.
|
124
|
+
There are different type map strategies, implemented by several derivations
|
125
|
+
of this class. They can be chosen and configured according to the particular
|
126
|
+
needs for type casting. The default type map is PG::TypeMapAllStrings.
|
127
|
+
|
128
|
+
A type map can be assigned per connection or per query respectively per
|
129
|
+
result set. Type maps can also be used for COPY in and out data streaming.
|
130
|
+
See PG::Connection#copy_data .
|
131
|
+
|
132
|
+
== Contributing
|
133
|
+
|
134
|
+
To report bugs, suggest features, or check out the source with Mercurial,
|
135
|
+
{check out the project page}[http://bitbucket.org/ged/ruby-pg]. If you prefer
|
136
|
+
Git, there's also a {Github mirror}[https://github.com/ged/ruby-pg].
|
137
|
+
|
138
|
+
After checking out the source, run:
|
139
|
+
|
140
|
+
$ rake newb
|
141
|
+
|
142
|
+
This task will install any missing dependencies, run the tests/specs, and
|
143
|
+
generate the API documentation.
|
144
|
+
|
145
|
+
The current maintainers are Michael Granger <ged@FaerieMUD.org> and
|
146
|
+
Lars Kanis <lars@greiz-reinsdorf.de>.
|
147
|
+
|
148
|
+
|
149
|
+
== Copying
|
150
|
+
|
151
|
+
Copyright (c) 1997-2016 by the authors.
|
152
|
+
|
153
|
+
* Jeff Davis <ruby-pg@j-davis.com>
|
154
|
+
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
155
|
+
* Michael Granger <ged@FaerieMUD.org>
|
156
|
+
* Lars Kanis <lars@greiz-reinsdorf.de>
|
157
|
+
* Dave Lee
|
158
|
+
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
159
|
+
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
160
|
+
* Noboru Saitou <noborus@netlab.jp>
|
161
|
+
|
162
|
+
You may redistribute this software under the same terms as Ruby itself; see
|
163
|
+
https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
|
164
|
+
for details.
|
165
|
+
|
166
|
+
Portions of the code are from the PostgreSQL project, and are distributed
|
167
|
+
under the terms of the PostgreSQL license, included in the file POSTGRES.
|
168
|
+
|
169
|
+
Portions copyright LAIKA, Inc.
|
170
|
+
|
171
|
+
|
172
|
+
== Acknowledgments
|
173
|
+
|
174
|
+
See Contributors.rdoc for the many additional fine people that have contributed
|
175
|
+
to this library over the years.
|
176
|
+
|
177
|
+
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
178
|
+
And to the people who developed PostgreSQL.
|