pg 1.3.0.rc2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +3 -0
  3. data/.appveyor.yml +36 -0
  4. data/.gems +6 -0
  5. data/.gemtest +0 -0
  6. data/.github/workflows/binary-gems.yml +85 -0
  7. data/.github/workflows/source-gem.yml +130 -0
  8. data/.gitignore +13 -0
  9. data/.hgsigs +34 -0
  10. data/.hgtags +41 -0
  11. data/.irbrc +23 -0
  12. data/.pryrc +23 -0
  13. data/.tm_properties +21 -0
  14. data/.travis.yml +49 -0
  15. data/BSDL +22 -0
  16. data/Contributors.rdoc +46 -0
  17. data/Gemfile +14 -0
  18. data/History.rdoc +648 -0
  19. data/LICENSE +56 -0
  20. data/Manifest.txt +72 -0
  21. data/POSTGRES +23 -0
  22. data/README-OS_X.rdoc +68 -0
  23. data/README-Windows.rdoc +56 -0
  24. data/README.ja.rdoc +13 -0
  25. data/README.rdoc +214 -0
  26. data/Rakefile +106 -0
  27. data/Rakefile.cross +300 -0
  28. data/certs/ged.pem +24 -0
  29. data/ext/errorcodes.def +1040 -0
  30. data/ext/errorcodes.rb +45 -0
  31. data/ext/errorcodes.txt +496 -0
  32. data/ext/extconf.rb +165 -0
  33. data/ext/gvl_wrappers.c +21 -0
  34. data/ext/gvl_wrappers.h +264 -0
  35. data/ext/pg.c +732 -0
  36. data/ext/pg.h +385 -0
  37. data/ext/pg_binary_decoder.c +229 -0
  38. data/ext/pg_binary_encoder.c +163 -0
  39. data/ext/pg_coder.c +615 -0
  40. data/ext/pg_connection.c +4415 -0
  41. data/ext/pg_copy_coder.c +628 -0
  42. data/ext/pg_errors.c +95 -0
  43. data/ext/pg_record_coder.c +519 -0
  44. data/ext/pg_result.c +1683 -0
  45. data/ext/pg_text_decoder.c +987 -0
  46. data/ext/pg_text_encoder.c +814 -0
  47. data/ext/pg_tuple.c +575 -0
  48. data/ext/pg_type_map.c +199 -0
  49. data/ext/pg_type_map_all_strings.c +129 -0
  50. data/ext/pg_type_map_by_class.c +269 -0
  51. data/ext/pg_type_map_by_column.c +349 -0
  52. data/ext/pg_type_map_by_mri_type.c +313 -0
  53. data/ext/pg_type_map_by_oid.c +385 -0
  54. data/ext/pg_type_map_in_ruby.c +330 -0
  55. data/ext/pg_util.c +149 -0
  56. data/ext/pg_util.h +65 -0
  57. data/ext/vc/pg.sln +26 -0
  58. data/ext/vc/pg_18/pg.vcproj +216 -0
  59. data/ext/vc/pg_19/pg_19.vcproj +209 -0
  60. data/lib/3.1/pg_ext.so +0 -0
  61. data/lib/pg/basic_type_map_based_on_result.rb +47 -0
  62. data/lib/pg/basic_type_map_for_queries.rb +193 -0
  63. data/lib/pg/basic_type_map_for_results.rb +81 -0
  64. data/lib/pg/basic_type_registry.rb +296 -0
  65. data/lib/pg/binary_decoder.rb +23 -0
  66. data/lib/pg/coder.rb +104 -0
  67. data/lib/pg/connection.rb +813 -0
  68. data/lib/pg/constants.rb +12 -0
  69. data/lib/pg/exceptions.rb +12 -0
  70. data/lib/pg/result.rb +43 -0
  71. data/lib/pg/text_decoder.rb +46 -0
  72. data/lib/pg/text_encoder.rb +59 -0
  73. data/lib/pg/tuple.rb +30 -0
  74. data/lib/pg/type_map_by_column.rb +16 -0
  75. data/lib/pg/version.rb +4 -0
  76. data/lib/pg.rb +87 -0
  77. data/lib/x64-mingw-ucrt/libpq.dll +0 -0
  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 +32 -0
  90. data/sample/array_insert.rb +20 -0
  91. data/sample/async_api.rb +106 -0
  92. data/sample/async_copyto.rb +39 -0
  93. data/sample/async_mixed.rb +56 -0
  94. data/sample/check_conn.rb +21 -0
  95. data/sample/copydata.rb +71 -0
  96. data/sample/copyfrom.rb +81 -0
  97. data/sample/copyto.rb +19 -0
  98. data/sample/cursor.rb +21 -0
  99. data/sample/disk_usage_report.rb +177 -0
  100. data/sample/issue-119.rb +94 -0
  101. data/sample/losample.rb +69 -0
  102. data/sample/minimal-testcase.rb +17 -0
  103. data/sample/notify_wait.rb +72 -0
  104. data/sample/pg_statistics.rb +285 -0
  105. data/sample/replication_monitor.rb +222 -0
  106. data/sample/test_binary_values.rb +33 -0
  107. data/sample/wal_shipper.rb +434 -0
  108. data/sample/warehouse_partitions.rb +311 -0
  109. data.tar.gz.sig +0 -0
  110. metadata +188 -0
  111. metadata.gz.sig +0 -0
data/Manifest.txt ADDED
@@ -0,0 +1,72 @@
1
+ .gemtest
2
+ BSDL
3
+ Contributors.rdoc
4
+ History.rdoc
5
+ LICENSE
6
+ Manifest.txt
7
+ POSTGRES
8
+ README-OS_X.rdoc
9
+ README-Windows.rdoc
10
+ README.ja.rdoc
11
+ README.rdoc
12
+ Rakefile
13
+ Rakefile.cross
14
+ ext/errorcodes.def
15
+ ext/errorcodes.rb
16
+ ext/errorcodes.txt
17
+ ext/extconf.rb
18
+ ext/gvl_wrappers.c
19
+ ext/gvl_wrappers.h
20
+ ext/pg.c
21
+ ext/pg.h
22
+ ext/pg_binary_decoder.c
23
+ ext/pg_binary_encoder.c
24
+ ext/pg_coder.c
25
+ ext/pg_connection.c
26
+ ext/pg_copy_coder.c
27
+ ext/pg_errors.c
28
+ ext/pg_record_coder.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/pg_util.c
41
+ ext/pg_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
+
@@ -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 {the project's
54
+ issue-tracker}[https://github.com/ged/ruby-pg/issues]. And submit questions, problems, or
55
+ solutions, so that it can be improved.
56
+
data/README.ja.rdoc ADDED
@@ -0,0 +1,13 @@
1
+ = pg
2
+
3
+ home :: https://github.com/ged/ruby-pg
4
+ docs :: http://deveiate.org/code/pg
5
+
6
+
7
+ == Description
8
+
9
+ This file needs a translation of the English README. Pull requests, patches, or
10
+ volunteers gladly accepted.
11
+
12
+ Until such time, please accept my sincere apologies for not knowing Japanese.
13
+
data/README.rdoc ADDED
@@ -0,0 +1,214 @@
1
+ = pg
2
+
3
+ home :: https://github.com/ged/ruby-pg
4
+ docs :: http://deveiate.org/code/pg
5
+ clog :: link:/History.rdoc
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.3 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('pid', 'usename', 'query')
29
+ end
30
+ end
31
+
32
+ == Build Status
33
+
34
+ {<img src="https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml/badge.svg?branch=master" alt="Build Status Github Actions" />}[https://github.com/ged/ruby-pg/actions/workflows/source-gem.yml]
35
+ {<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]
36
+ {<img src="https://app.travis-ci.com/larskanis/ruby-pg.svg?branch=master" alt="Build Status" />}[https://app.travis-ci.com/larskanis/ruby-pg]
37
+
38
+ == Requirements
39
+
40
+ * Ruby 2.4 or newer
41
+ * PostgreSQL 9.3.x or later (with headers, -dev packages, etc).
42
+
43
+ It usually works 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://github.com/ged/ruby-pg/tree/master/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
+ The following PostgreSQL column types are supported by ruby-pg (TE = Text Encoder, TD = Text Decoder, BE = Binary Encoder, BD = Binary Decoder):
122
+ * 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] 💡
123
+ * BE: {Int2}[rdoc-ref:PG::BinaryEncoder::Int2], {Int4}[rdoc-ref:PG::BinaryEncoder::Int4], {Int8}[rdoc-ref:PG::BinaryEncoder::Int8]
124
+ * Float: {TE}[rdoc-ref:PG::TextEncoder::Float], {TD}[rdoc-ref:PG::TextDecoder::Float], {BD}[rdoc-ref:PG::BinaryDecoder::Float]
125
+ * Numeric: {TE}[rdoc-ref:PG::TextEncoder::Numeric], {TD}[rdoc-ref:PG::TextDecoder::Numeric]
126
+ * 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]
127
+ * 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]
128
+ * 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]
129
+ * 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]
130
+ * Timestamp:
131
+ * TE: {local}[rdoc-ref:PG::TextEncoder::TimestampWithoutTimeZone], {UTC}[rdoc-ref:PG::TextEncoder::TimestampUtc], {with-TZ}[rdoc-ref:PG::TextEncoder::TimestampWithTimeZone]
132
+ * TD: {local}[rdoc-ref:PG::TextDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::TextDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::TextDecoder::TimestampUtcToLocal]
133
+ * BD: {local}[rdoc-ref:PG::BinaryDecoder::TimestampLocal], {UTC}[rdoc-ref:PG::BinaryDecoder::TimestampUtc], {UTC-to-local}[rdoc-ref:PG::BinaryDecoder::TimestampUtcToLocal]
134
+ * Date: {TE}[rdoc-ref:PG::TextEncoder::Date], {TD}[rdoc-ref:PG::TextDecoder::Date]
135
+ * JSON and JSONB: {TE}[rdoc-ref:PG::TextEncoder::JSON], {TD}[rdoc-ref:PG::TextDecoder::JSON]
136
+ * Inet: {TE}[rdoc-ref:PG::TextEncoder::Inet], {TD}[rdoc-ref:PG::TextDecoder::Inet]
137
+ * Array: {TE}[rdoc-ref:PG::TextEncoder::Array], {TD}[rdoc-ref:PG::TextDecoder::Array]
138
+ * Composite Type (also called "Row" or "Record"): {TE}[rdoc-ref:PG::TextEncoder::Record], {TD}[rdoc-ref:PG::TextDecoder::Record]
139
+
140
+ The following text formats can also be encoded although they are not used as column type:
141
+ * COPY input and output data: {TE}[rdoc-ref:PG::TextEncoder::CopyRow], {TD}[rdoc-ref:PG::TextDecoder::CopyRow]
142
+ * Literal for insertion into SQL string: {TE}[rdoc-ref:PG::TextEncoder::QuotedLiteral]
143
+ * SQL-Identifier: {TE}[rdoc-ref:PG::TextEncoder::Identifier], {TD}[rdoc-ref:PG::TextDecoder::Identifier]
144
+
145
+ === PG::TypeMap and derivations (ext/pg_type_map*.c, lib/pg/type_map*.rb)
146
+
147
+ A TypeMap defines which value will be converted by which encoder/decoder.
148
+ There are different type map strategies, implemented by several derivations
149
+ of this class. They can be chosen and configured according to the particular
150
+ needs for type casting. The default type map is PG::TypeMapAllStrings.
151
+
152
+ A type map can be assigned per connection or per query respectively per
153
+ result set. Type maps can also be used for COPY in and out data streaming.
154
+ See PG::Connection#copy_data .
155
+
156
+ The following base type maps are available:
157
+ * PG::TypeMapAllStrings - encodes and decodes all values to and from strings (default)
158
+ * PG::TypeMapByClass - selects encoder based on the class of the value to be sent
159
+ * PG::TypeMapByColumn - selects encoder and decoder by column order
160
+ * PG::TypeMapByOid - selects decoder by PostgreSQL type OID
161
+ * PG::TypeMapInRuby - define a custom type map in ruby
162
+
163
+ The following type maps are prefilled with type mappings from the PG::BasicTypeRegistry :
164
+ * PG::BasicTypeMapForResults - a PG::TypeMapByOid prefilled with decoders for common PostgreSQL column types
165
+ * PG::BasicTypeMapBasedOnResult - a PG::TypeMapByOid prefilled with encoders for common PostgreSQL column types
166
+ * PG::BasicTypeMapForQueries - a PG::TypeMapByClass prefilled with encoders for common Ruby value classes
167
+
168
+
169
+ == Contributing
170
+
171
+ To report bugs, suggest features, or check out the source with Git,
172
+ {check out the project page}[https://github.com/ged/ruby-pg].
173
+
174
+ After checking out the source, run:
175
+
176
+ $ rake newb
177
+
178
+ This task will install any missing dependencies, run the tests/specs, and
179
+ generate the API documentation.
180
+
181
+ The current maintainers are Michael Granger <ged@FaerieMUD.org> and
182
+ Lars Kanis <lars@greiz-reinsdorf.de>.
183
+
184
+
185
+ == Copying
186
+
187
+ Copyright (c) 1997-2019 by the authors.
188
+
189
+ * Jeff Davis <ruby-pg@j-davis.com>
190
+ * Guy Decoux (ts) <decoux@moulon.inra.fr>
191
+ * Michael Granger <ged@FaerieMUD.org>
192
+ * Lars Kanis <lars@greiz-reinsdorf.de>
193
+ * Dave Lee
194
+ * Eiji Matsumoto <usagi@ruby.club.or.jp>
195
+ * Yukihiro Matsumoto <matz@ruby-lang.org>
196
+ * Noboru Saitou <noborus@netlab.jp>
197
+
198
+ You may redistribute this software under the same terms as Ruby itself; see
199
+ https://www.ruby-lang.org/en/about/license.txt or the BSDL file in the source
200
+ for details.
201
+
202
+ Portions of the code are from the PostgreSQL project, and are distributed
203
+ under the terms of the PostgreSQL license, included in the file POSTGRES.
204
+
205
+ Portions copyright LAIKA, Inc.
206
+
207
+
208
+ == Acknowledgments
209
+
210
+ See Contributors.rdoc for the many additional fine people that have contributed
211
+ to this library over the years.
212
+
213
+ We are thankful to the people at the ruby-list and ruby-dev mailing lists.
214
+ And to the people who developed PostgreSQL.
data/Rakefile ADDED
@@ -0,0 +1,106 @@
1
+ # -*- rake -*-
2
+
3
+ require 'rbconfig'
4
+ require 'pathname'
5
+ require 'tmpdir'
6
+ require 'rake/extensiontask'
7
+ require 'rake/clean'
8
+ require 'rspec/core/rake_task'
9
+ require 'bundler'
10
+ require 'bundler/gem_helper'
11
+
12
+ # Build directory constants
13
+ BASEDIR = Pathname( __FILE__ ).dirname
14
+ SPECDIR = BASEDIR + 'spec'
15
+ LIBDIR = BASEDIR + 'lib'
16
+ EXTDIR = BASEDIR + 'ext'
17
+ PKGDIR = BASEDIR + 'pkg'
18
+ TMPDIR = BASEDIR + 'tmp'
19
+ TESTDIR = BASEDIR + "tmp_test_specs"
20
+
21
+ DLEXT = RbConfig::CONFIG['DLEXT']
22
+ EXT = LIBDIR + "pg_ext.#{DLEXT}"
23
+
24
+ GEMSPEC = 'pg.gemspec'
25
+
26
+ CLOBBER.include( TESTDIR.to_s )
27
+ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
28
+ CLEAN.include "lib/*/libpq.dll"
29
+ CLEAN.include "lib/pg_ext.*"
30
+ CLEAN.include "lib/pg/postgresql_lib_path.rb"
31
+
32
+ load 'Rakefile.cross'
33
+
34
+ Bundler::GemHelper.install_tasks
35
+ $gem_spec = Bundler.load_gemspec(GEMSPEC)
36
+
37
+ desc "Turn on warnings and debugging in the build."
38
+ task :maint do
39
+ ENV['MAINTAINER_MODE'] = 'yes'
40
+ end
41
+
42
+ # Rake-compiler task
43
+ Rake::ExtensionTask.new do |ext|
44
+ ext.name = 'pg_ext'
45
+ ext.gem_spec = $gem_spec
46
+ ext.ext_dir = 'ext'
47
+ ext.lib_dir = 'lib'
48
+ ext.source_pattern = "*.{c,h}"
49
+ ext.cross_compile = true
50
+ ext.cross_platform = CrossLibraries.map(&:for_platform)
51
+
52
+ ext.cross_config_options += CrossLibraries.map do |lib|
53
+ {
54
+ lib.for_platform => [
55
+ "--enable-windows-cross",
56
+ "--with-pg-include=#{lib.static_postgresql_incdir}",
57
+ "--with-pg-lib=#{lib.static_postgresql_libdir}",
58
+ # libpq-fe.h resides in src/interfaces/libpq/ before make install
59
+ "--with-opt-include=#{lib.static_postgresql_libdir}",
60
+ ]
61
+ }
62
+ end
63
+
64
+ # Add libpq.dll to windows binary gemspec
65
+ ext.cross_compiling do |spec|
66
+ spec.files << "lib/#{spec.platform}/libpq.dll"
67
+ end
68
+ end
69
+
70
+ RSpec::Core::RakeTask.new(:spec).rspec_opts = "--profile -cfdoc"
71
+ task :test => :spec
72
+
73
+ # Use the fivefish formatter for docs generated from development checkout
74
+ require 'rdoc/task'
75
+
76
+ RDoc::Task.new( 'docs' ) do |rdoc|
77
+ rdoc.main = "README.rdoc"
78
+ rdoc.rdoc_files.include( "*.rdoc", "lib/**/*.rb", 'ext/**/*.{c,h}' )
79
+ rdoc.generator = :fivefish
80
+ rdoc.title = "PG: The Ruby PostgreSQL Driver"
81
+ rdoc.rdoc_dir = 'doc'
82
+ end
83
+
84
+ desc "Build the source gem #{$gem_spec.full_name}.gem into the pkg directory"
85
+ task :gem => :build
86
+
87
+ task :clobber do
88
+ puts "Stop any Postmaster instances that remain after testing."
89
+ require_relative 'spec/helpers'
90
+ PG::TestingHelpers.stop_existing_postmasters()
91
+ end
92
+
93
+ desc "Update list of server error codes"
94
+ task :update_error_codes do
95
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=refs/tags/REL_14_0"
96
+
97
+ ERRORCODES_TXT = "ext/errorcodes.txt"
98
+ sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
99
+
100
+ ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
101
+ end
102
+
103
+ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
104
+ # trigger compilation of changed errorcodes.def
105
+ touch 'ext/pg_errors.c'
106
+ end