pg_jruby 0.14.1.rc2-java → 0.17.1-java
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -0
- data/BSDL +22 -0
- data/ChangeLog +0 -0
- data/Contributors.rdoc +45 -0
- data/History.rdoc +270 -0
- data/LICENSE +56 -0
- data/Manifest.txt +51 -5
- data/POSTGRES +23 -0
- data/README-OS_X.rdoc +68 -0
- data/README-Windows.rdoc +67 -0
- data/README.ja.rdoc +14 -0
- data/README.rdoc +52 -94
- data/Rakefile +181 -73
- data/Rakefile.cross +273 -0
- data/ext/errorcodes.def +931 -0
- data/ext/errorcodes.rb +99 -0
- data/ext/errorcodes.txt +463 -0
- data/ext/extconf.rb +97 -0
- data/ext/gvl_wrappers.c +13 -0
- data/ext/gvl_wrappers.h +253 -0
- data/ext/pg.c +545 -0
- data/ext/pg.h +156 -0
- data/ext/pg_connection.c +3643 -0
- data/ext/pg_errors.c +89 -0
- data/ext/pg_result.c +920 -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 +12 -18
- data/lib/pg/connection.rb +117 -10
- data/lib/pg/exceptions.rb +2 -8
- data/lib/pg/result.rb +6 -1
- data/lib/pg_ext.jar +0 -0
- data/sample/array_insert.rb +20 -0
- data/sample/async_api.rb +106 -0
- data/sample/async_copyto.rb +39 -0
- data/sample/async_mixed.rb +56 -0
- data/sample/check_conn.rb +21 -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 +186 -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 +294 -0
- data/sample/replication_monitor.rb +231 -0
- data/sample/test_binary_values.rb +33 -0
- data/sample/wal_shipper.rb +434 -0
- data/sample/warehouse_partitions.rb +320 -0
- data/spec/data/expected_trace.out +26 -0
- data/spec/data/random_binary_data +0 -0
- data/spec/lib/helpers.rb +350 -0
- data/spec/pg/connection_spec.rb +1276 -0
- data/spec/pg/result_spec.rb +345 -0
- data/spec/pg_spec.rb +44 -0
- metadata +136 -90
- metadata.gz.sig +0 -0
- data/CHANGELOG.rdoc +0 -7
- data/bin/pg +0 -3
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,67 @@
|
|
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 either
|
6
|
+
use VC++ 6.0 or the compiler that comes with cygwin or mingw if you're
|
7
|
+
building on that 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
|
+
== Cross compiling for mswin32
|
33
|
+
|
34
|
+
Using rake-compiler a cross compiled pg gem can be build on a Linux or MacOS X
|
35
|
+
host for the win32 platform. The generated gem is statically linked against
|
36
|
+
libpq and libssl. OpenSSL and PostgreSQL are downloaded and compiled from the
|
37
|
+
sources. There are no runtime dependencies to any but the standard Windows
|
38
|
+
DLLs.
|
39
|
+
|
40
|
+
Install mingw32 using the instructions in rake-compiler's README.
|
41
|
+
For Debian/Ubuntu it is <tt>apt-get install gcc-mingw32</tt> .
|
42
|
+
Use ruby-1.8.7 for the following commands.
|
43
|
+
|
44
|
+
Download and cross compile ruby 1.8 and 1.9 for win32 with:
|
45
|
+
|
46
|
+
rake-compiler cross-ruby VERSION=1.8.7-p352
|
47
|
+
rake-compiler cross-ruby VERSION=1.9.2-p290
|
48
|
+
|
49
|
+
Download and cross compile pg for win32:
|
50
|
+
|
51
|
+
rake cross native gem
|
52
|
+
|
53
|
+
or with custom versions:
|
54
|
+
|
55
|
+
rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2 \
|
56
|
+
OPENSSL_VERSION=1.0.0e POSTGRESQL_VERSION=9.1.1
|
57
|
+
|
58
|
+
If everything works, there should be pg-VERSION-x86-mingw32.gem in the pkg
|
59
|
+
directory.
|
60
|
+
|
61
|
+
|
62
|
+
== Reporting Problems
|
63
|
+
|
64
|
+
If you have any problems you can submit them via
|
65
|
+
[the project's issue-tracker][bitbucket]. And submit questions, problems, or
|
66
|
+
solutions, so that it can be improved.
|
67
|
+
|
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
CHANGED
@@ -1,125 +1,83 @@
|
|
1
1
|
= pg
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
This is a native implementation of the Postsgres protocol written
|
8
|
-
entirely in Java. The project was started by @headius as a ruby-pg
|
9
|
-
replacement for JRuby that uses the JDBC driver and private API of
|
10
|
-
Postgres. Unfortunately ruby-pg (which uses libpq under the hood)
|
11
|
-
exposed a lot of features of Postgres that were impossible to
|
12
|
-
implement or were complicated given the nature of the JDBC and the
|
13
|
-
encapsulation of many features that are exposed in ruby-pg.
|
14
|
-
|
15
|
-
*WARNING* this gem is not production ready yet. There are many
|
16
|
-
bugs that needs to be fixed and more testing. So please checkout
|
17
|
-
the code and submit pull requests with some fixes. If your Java-Fu
|
18
|
-
isn't that great you can still contribute by submitting test cases
|
19
|
-
and We'll be happy to fix them.
|
20
|
-
|
21
|
-
== FEATURES:
|
22
|
-
|
23
|
-
* A ruby-pg drop in replacement for JRuby
|
24
|
-
* Async operations are supported
|
25
|
-
* Large Object API
|
26
|
-
* SSL connections
|
27
|
-
* Copy operations
|
28
|
-
* Zero dependencies on other jars and gems
|
29
|
-
* All active record test suite pass (except 5 tests see PROBLEMS).
|
3
|
+
This is a JRuby gem replacement for ruby-pg. The gem should be a
|
4
|
+
drop-in replacement for ruby-pg version 0.17.1. If you see any
|
5
|
+
inconsistency please open an issue
|
6
|
+
{here}(https://github.com/headius/jruby-pg/issues)
|
30
7
|
|
31
|
-
|
8
|
+
= Documentation
|
32
9
|
|
33
|
-
|
10
|
+
For documentation please refair to the MRI pg gem docs which you can
|
11
|
+
find {here}(http://www.rubydoc.info/gems/pg/0.17.1/PG). The original
|
12
|
+
ruby-pg project can be found {here on github}(https://github.com/ged/ruby-pg)
|
34
13
|
|
35
|
-
|
14
|
+
== Build Status
|
36
15
|
|
37
|
-
|
16
|
+
{<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
|
38
17
|
|
39
|
-
== PROBLEMS:
|
40
18
|
|
41
|
-
|
42
|
-
(https://github.com/jruby/jruby/issues/411) you'll need JRuby 1.7.1
|
43
|
-
or later.
|
44
|
-
* Due to a bug in the json gem
|
45
|
-
(https://github.com/flori/json/pull/152) and (https://github.com/flori/json/pull/155)
|
46
|
-
you'll need gem version
|
47
|
-
1.7.7 or later.
|
48
|
-
* We currently have some failing tests when we run the activerecord test suite.
|
49
|
-
The failing tests are due to the inconsistencies between JRuby and MRI (see
|
50
|
-
https://github.com/jruby/jruby/issues/540 and https://github.com/jruby/jruby/pull/539)
|
51
|
-
* The current implementation targets postgres protocol V3 (introduced in v 7.4)
|
52
|
-
only. I'll wait until someone ask for support of earlier versions.
|
53
|
-
* Run pg_search test suites on this implementation
|
54
|
-
* lo_import and lo_export are not implemented yet
|
55
|
-
* More Documentation especially in the parts that deal with the protocol.
|
56
|
-
* Profiling the library would be awesome, but will try to get it running first
|
57
|
-
then optimize.
|
58
|
-
* JRuby 1.6.x (1.8 mode) needs to be tested.
|
19
|
+
== Requirements
|
59
20
|
|
60
|
-
|
21
|
+
* JRuby 1.7.1 or later (due to https://github.com/jruby/jruby/issues/411)
|
22
|
+
* JRuby in 1.9 or 2.0 mode
|
23
|
+
* json gem 1.7.7 or later (see https://github.com/flori/json/pull/152 and
|
24
|
+
https://github.com/flori/json/pull/155)
|
25
|
+
* Postgresql 7.4 or higher
|
61
26
|
|
62
|
-
|
27
|
+
The gem has been tested with the following:
|
63
28
|
|
64
|
-
|
29
|
+
* JRuby 1.7.18
|
30
|
+
* PostgreSQL 9.3.6
|
65
31
|
|
66
|
-
|
67
|
-
|
68
|
-
which is also available in the +postgresql-contrib+ Ubuntu package (see
|
69
|
-
http://www.postgresql.org/docs/9.0/static/hstore.html
|
70
|
-
for more info) and +postgresql-server-dev+ to get the pg_config binary.
|
32
|
+
It may work with earlier versions of Ruby/PostgreSQL as well, but those are
|
33
|
+
not regularly tested.
|
71
34
|
|
72
|
-
You'll also need to create a new super user using your username and no password. You can
|
73
|
-
use the following command to do that:
|
74
35
|
|
75
|
-
|
36
|
+
== How To Install
|
37
|
+
|
38
|
+
Install via RubyGems:
|
76
39
|
|
77
|
-
|
40
|
+
gem install pg_jruby
|
78
41
|
|
79
|
-
|
42
|
+
Install via Bundler, in your gemfile add the following:
|
80
43
|
|
81
|
-
|
44
|
+
# Please note that the 1.0 is necessary to let bundler do its dependency management, as there is no .gemspec in the source.
|
45
|
+
gem 'pg_jruby', '0.17.1', :platform => :jruby, :git => 'git://github.com/headius/jruby-pg.git', :branch => :master
|
82
46
|
|
83
|
-
|
47
|
+
== Copying
|
84
48
|
|
85
|
-
|
49
|
+
Copyright (c) 1997-2013 by the authors.
|
86
50
|
|
87
|
-
|
88
|
-
more specs targetted towards the JRuby implementation details in
|
89
|
-
jruby-spec. When you run `rake` both test suites are merged under
|
90
|
-
the 'spec' directory.
|
51
|
+
=== MRI contributors
|
91
52
|
|
92
|
-
|
53
|
+
* Jeff Davis <ruby-pg@j-davis.com>
|
54
|
+
* Guy Decoux (ts) <decoux@moulon.inra.fr>
|
55
|
+
* Michael Granger <ged@FaerieMUD.org>
|
56
|
+
* Lars Kanis <lars@greiz-reinsdorf.de>
|
57
|
+
* Dave Lee
|
58
|
+
* Eiji Matsumoto <usagi@ruby.club.or.jp>
|
59
|
+
* Yukihiro Matsumoto <matz@ruby-lang.org>
|
60
|
+
* Noboru Saitou <noborus@netlab.jp>
|
93
61
|
|
94
|
-
|
62
|
+
=== JRuby contributors
|
95
63
|
|
96
|
-
|
64
|
+
* John Shahid <jvshahid@gmail.com>
|
97
65
|
|
98
|
-
|
66
|
+
You may redistribute this software under the same terms as Ruby itself; see
|
67
|
+
http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
|
68
|
+
for details.
|
99
69
|
|
100
|
-
|
70
|
+
Portions of the code are from the PostgreSQL project, and are distributed
|
71
|
+
under the terms of the PostgreSQL license, included in the file POSTGRES.
|
101
72
|
|
102
|
-
|
73
|
+
Portions copyright LAIKA, Inc.
|
103
74
|
|
104
|
-
(The MIT License)
|
105
75
|
|
106
|
-
|
76
|
+
== Acknowledgments
|
107
77
|
|
108
|
-
|
109
|
-
|
110
|
-
'Software'), to deal in the Software without restriction, including
|
111
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
112
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
113
|
-
permit persons to whom the Software is furnished to do so, subject to
|
114
|
-
the following conditions:
|
78
|
+
See Contributors.rdoc for the many additional fine people that have contributed
|
79
|
+
to this library over the years.
|
115
80
|
|
116
|
-
|
117
|
-
|
81
|
+
We are thankful to the people at the ruby-list and ruby-dev mailing lists.
|
82
|
+
And to the people who developed PostgreSQL.
|
118
83
|
|
119
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
120
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
121
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
122
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
123
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
124
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
125
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
@@ -1,96 +1,204 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
#-*- ruby -*-
|
2
3
|
|
3
|
-
require '
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require 'logger'
|
4
|
+
require 'rbconfig'
|
5
|
+
require 'pathname'
|
6
|
+
require 'tmpdir'
|
7
7
|
|
8
|
-
|
8
|
+
begin
|
9
|
+
require 'rake/extensiontask'
|
10
|
+
rescue LoadError
|
11
|
+
abort "This Rakefile requires rake-compiler (gem install rake-compiler)"
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
require 'hoe'
|
16
|
+
rescue LoadError
|
17
|
+
abort "This Rakefile requires hoe (gem install hoe)"
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'rake/clean'
|
21
|
+
|
22
|
+
# Build directory constants
|
23
|
+
BASEDIR = Pathname( __FILE__ ).dirname
|
24
|
+
SPECDIR = BASEDIR + 'spec'
|
25
|
+
LIBDIR = BASEDIR + 'lib'
|
26
|
+
EXTDIR = BASEDIR + 'ext'
|
27
|
+
PKGDIR = BASEDIR + 'pkg'
|
28
|
+
TMPDIR = BASEDIR + 'tmp'
|
29
|
+
|
30
|
+
DLEXT = RbConfig::CONFIG['DLEXT']
|
31
|
+
EXT = LIBDIR + "pg_ext.#{DLEXT}"
|
32
|
+
|
33
|
+
TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
|
34
|
+
|
35
|
+
CLOBBER.include( TEST_DIRECTORY.to_s )
|
36
|
+
CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
|
37
|
+
|
38
|
+
# Set up Hoe plugins
|
39
|
+
Hoe.plugin :mercurial
|
40
|
+
Hoe.plugin :signing
|
41
|
+
Hoe.plugin :deveiate
|
9
42
|
Hoe.plugin :bundler
|
10
|
-
Hoe.plugin :test
|
11
43
|
|
12
|
-
|
13
|
-
|
14
|
-
|
44
|
+
Hoe.plugins.delete :rubyforge
|
45
|
+
Hoe.plugins.delete :compiler
|
46
|
+
|
47
|
+
def jruby?
|
48
|
+
RUBY_PLATFORM =~ /java/
|
49
|
+
end
|
50
|
+
|
51
|
+
# Hoe specification
|
52
|
+
$hoespec = Hoe.spec 'pg_jruby' do
|
53
|
+
self.history_file = 'History.rdoc'
|
54
|
+
self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
|
55
|
+
self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
|
56
|
+
self.extra_rdoc_files.include( 'ext/*.c' )
|
57
|
+
|
58
|
+
self.developer 'John Shahid', 'jvshahid@gmail.com'
|
59
|
+
|
60
|
+
self.dependency 'rake-compiler', '~> 0.9', :developer
|
61
|
+
self.dependency 'hoe', '~> 3.5.1', :developer
|
62
|
+
self.dependency 'hoe-deveiate', '~> 0.2', :developer
|
63
|
+
self.dependency 'hoe-bundler', '~> 1.0', :developer
|
64
|
+
|
65
|
+
self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
|
66
|
+
self.spec_extras[:extensions] = [ 'ext/extconf.rb' ] unless jruby?
|
15
67
|
|
16
|
-
|
17
|
-
|
68
|
+
self.spec_extras[:files] = Proc.new do |f|
|
69
|
+
self.spec_extras[:files] = f << 'lib/pg_ext.jar'
|
70
|
+
end
|
18
71
|
|
19
|
-
|
20
|
-
["hoe-bundler", ">= 1.1"],
|
21
|
-
["hoe-gemspec", ">= 1.0"],
|
22
|
-
["rake", ">= 0.9"],
|
23
|
-
["rake-compiler", "= 0.8.0"],
|
24
|
-
["git"],
|
25
|
-
["logger"],
|
26
|
-
["rspec"]
|
27
|
-
]
|
72
|
+
self.require_ruby_version( '>= 1.8.7' )
|
28
73
|
|
29
|
-
|
30
|
-
|
74
|
+
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
|
75
|
+
self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
|
76
|
+
self.spec_extras[:rdoc_options] = [
|
77
|
+
'-f', 'fivefish',
|
78
|
+
'-t', 'pg: The Ruby Interface to PostgreSQL',
|
79
|
+
'-m', 'README.rdoc',
|
80
|
+
]
|
31
81
|
|
32
|
-
|
82
|
+
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
83
|
+
self.spec_extras[:platform] = 'java' if jruby?
|
33
84
|
end
|
34
85
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
86
|
+
if jruby?
|
87
|
+
require "rake/javaextensiontask"
|
88
|
+
|
89
|
+
Rake::JavaExtensionTask.new("pg_ext", $hoespec.spec) do |ext|
|
90
|
+
ext.ext_dir = 'ext/java'
|
91
|
+
ext.lib_dir = 'lib'
|
92
|
+
end
|
93
|
+
else
|
94
|
+
load 'Rakefile.cross'
|
95
|
+
|
96
|
+
# Rake-compiler task
|
97
|
+
Rake::ExtensionTask.new do |ext|
|
98
|
+
ext.name = 'pg_ext'
|
99
|
+
ext.gem_spec = $hoespec.spec
|
100
|
+
ext.ext_dir = 'ext'
|
101
|
+
ext.lib_dir = 'lib'
|
102
|
+
ext.source_pattern = "*.{c,h}"
|
103
|
+
ext.cross_compile = true
|
104
|
+
ext.cross_platform = CrossLibraries.map &:for_platform
|
105
|
+
|
106
|
+
ext.cross_config_options += CrossLibraries.map do |lib|
|
107
|
+
{
|
108
|
+
lib.for_platform => [
|
109
|
+
"--with-pg-include=#{lib.static_postgresql_libdir}",
|
110
|
+
"--with-opt-include=#{lib.static_postgresql_incdir}",
|
111
|
+
"--with-pg-lib=#{lib.static_postgresql_libdir}",
|
112
|
+
"--with-opt-lib=#{lib.static_openssl_builddir}",
|
113
|
+
]
|
114
|
+
}
|
115
|
+
end
|
116
|
+
end
|
42
117
|
end
|
43
118
|
|
44
|
-
|
45
|
-
|
119
|
+
ENV['VERSION'] ||= $hoespec.spec.version.to_s
|
120
|
+
|
121
|
+
# Tests should pass before checking in
|
122
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
|
123
|
+
|
124
|
+
# Support for 'rvm specs'
|
125
|
+
task :specs => :spec
|
126
|
+
|
127
|
+
# Compile before testing
|
128
|
+
task :spec => :compile
|
129
|
+
|
130
|
+
# gem-testers support
|
131
|
+
task :test do
|
132
|
+
# rake-compiler always wants to copy the compiled extension into lib/, but
|
133
|
+
# we don't want testers to have to re-compile, especially since that
|
134
|
+
# often fails because they can't (and shouldn't have to) write to tmp/ in
|
135
|
+
# the installed gem dir. So we clear the task rake-compiler set up
|
136
|
+
# to break the dependency between :spec and :compile when running under
|
137
|
+
# rubygems-test, and then run :spec.
|
138
|
+
Rake::Task[ EXT.to_s ].clear
|
139
|
+
Rake::Task[ :spec ].execute
|
46
140
|
end
|
47
141
|
|
48
|
-
desc
|
49
|
-
task
|
50
|
-
|
51
|
-
FileUtils.rm_rf '/tmp/checkout'
|
52
|
-
g = Git.clone(remote, '/tmp/checkout', :log => Logger.new(STDOUT))
|
53
|
-
g.checkout('fix_path_to_pg_binaries')
|
54
|
-
FileUtils.cp_r Dir.glob('/tmp/checkout/spec/*'), 'spec/'
|
55
|
-
end
|
142
|
+
desc "Turn on warnings and debugging in the build."
|
143
|
+
task :maint do
|
144
|
+
ENV['MAINTAINER_MODE'] = 'yes'
|
56
145
|
end
|
57
146
|
|
58
|
-
|
59
|
-
|
147
|
+
ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
|
148
|
+
|
149
|
+
# Make the ChangeLog update if the repo has changed since it was last built
|
150
|
+
file '.hg/branch' do
|
151
|
+
warn "WARNING: You need the Mercurial repo to update the ChangeLog"
|
152
|
+
end
|
153
|
+
file 'ChangeLog' do |task|
|
154
|
+
if File.exist?('.hg/branch')
|
155
|
+
$stderr.puts "Updating the changelog..."
|
156
|
+
begin
|
157
|
+
content = make_changelog()
|
158
|
+
rescue NameError
|
159
|
+
abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
|
160
|
+
end
|
161
|
+
File.open( task.name, 'w', 0644 ) do |fh|
|
162
|
+
fh.print( content )
|
163
|
+
end
|
164
|
+
else
|
165
|
+
touch 'ChangeLog'
|
166
|
+
end
|
167
|
+
end
|
60
168
|
|
61
|
-
|
62
|
-
|
63
|
-
Rake::Task[:spec].prerequisites << :java_debug
|
64
|
-
Rake::Task[:spec].prerequisites << :import_certs
|
169
|
+
# Rebuild the ChangeLog immediately before release
|
170
|
+
task :prerelease => 'ChangeLog'
|
65
171
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
172
|
+
|
173
|
+
desc "Stop any Postmaster instances that remain after testing."
|
174
|
+
task :cleanup_testing_dbs do
|
175
|
+
require 'spec/lib/helpers'
|
176
|
+
PgTestingHelpers.stop_existing_postmasters()
|
177
|
+
Rake::Task[:clean].invoke
|
71
178
|
end
|
72
179
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
puts "copying #{file_name} to #{new_name}, pwd: #{Dir.pwd}"
|
85
|
-
FileUtils.chmod 0644, new_name if File.exist?(new_name)
|
86
|
-
FileUtils.cp file_name, new_name
|
87
|
-
File.chmod 0444, new_name
|
88
|
-
end
|
89
|
-
end
|
90
|
-
Rake::Task[:'sync-files'].prerequisites << t
|
180
|
+
desc "Update list of server error codes"
|
181
|
+
task :update_error_codes do
|
182
|
+
URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
|
183
|
+
|
184
|
+
ERRORCODES_TXT = "ext/errorcodes.txt"
|
185
|
+
sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
|
186
|
+
end
|
187
|
+
|
188
|
+
def error_codes_file
|
189
|
+
if jruby?
|
190
|
+
return 'ext/java/Errors.java'
|
91
191
|
end
|
192
|
+
'ext/errorcodes.def'
|
92
193
|
end
|
93
|
-
|
94
|
-
|
194
|
+
|
195
|
+
file error_codes_file => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
|
196
|
+
ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', error_codes_file
|
197
|
+
end
|
198
|
+
|
199
|
+
file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
|
200
|
+
# trigger compilation of changed errorcodes.def
|
201
|
+
touch 'ext/pg_errors.c'
|
95
202
|
end
|
96
|
-
|
203
|
+
|
204
|
+
file 'ext/java/PgExtService.java' => error_codes_file
|