pg 0.12.0 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +2 -0
  3. data/BSDL +22 -0
  4. data/ChangeLog +1504 -11
  5. data/Contributors.rdoc +7 -0
  6. data/History.rdoc +181 -3
  7. data/LICENSE +12 -14
  8. data/Manifest.txt +29 -15
  9. data/{BSD → POSTGRES} +0 -0
  10. data/{README.OS_X.rdoc → README-OS_X.rdoc} +0 -0
  11. data/{README.windows.rdoc → README-Windows.rdoc} +0 -0
  12. data/README.ja.rdoc +10 -3
  13. data/README.rdoc +54 -28
  14. data/Rakefile +53 -26
  15. data/Rakefile.cross +235 -196
  16. data/ext/errorcodes.def +931 -0
  17. data/ext/errorcodes.rb +45 -0
  18. data/ext/errorcodes.txt +463 -0
  19. data/ext/extconf.rb +37 -7
  20. data/ext/gvl_wrappers.c +19 -0
  21. data/ext/gvl_wrappers.h +211 -0
  22. data/ext/pg.c +317 -4277
  23. data/ext/pg.h +124 -21
  24. data/ext/pg_connection.c +3642 -0
  25. data/ext/pg_errors.c +89 -0
  26. data/ext/pg_result.c +920 -0
  27. data/lib/pg/connection.rb +86 -0
  28. data/lib/pg/constants.rb +11 -0
  29. data/lib/pg/exceptions.rb +11 -0
  30. data/lib/pg/result.rb +16 -0
  31. data/lib/pg.rb +26 -43
  32. data/sample/array_insert.rb +20 -0
  33. data/sample/async_api.rb +21 -24
  34. data/sample/async_copyto.rb +2 -2
  35. data/sample/async_mixed.rb +56 -0
  36. data/sample/check_conn.rb +21 -0
  37. data/sample/copyfrom.rb +1 -1
  38. data/sample/copyto.rb +1 -1
  39. data/sample/cursor.rb +2 -2
  40. data/sample/disk_usage_report.rb +186 -0
  41. data/sample/issue-119.rb +94 -0
  42. data/sample/losample.rb +6 -6
  43. data/sample/minimal-testcase.rb +17 -0
  44. data/sample/notify_wait.rb +51 -22
  45. data/sample/pg_statistics.rb +294 -0
  46. data/sample/replication_monitor.rb +231 -0
  47. data/sample/test_binary_values.rb +4 -6
  48. data/sample/wal_shipper.rb +434 -0
  49. data/sample/warehouse_partitions.rb +320 -0
  50. data/spec/lib/helpers.rb +70 -23
  51. data/spec/pg/connection_spec.rb +1128 -0
  52. data/spec/{pgresult_spec.rb → pg/result_spec.rb} +142 -47
  53. data/spec/pg_spec.rb +44 -0
  54. data.tar.gz.sig +0 -0
  55. metadata +145 -100
  56. metadata.gz.sig +0 -0
  57. data/GPL +0 -340
  58. data/ext/compat.c +0 -541
  59. data/ext/compat.h +0 -184
  60. data/misc/openssl-pg-segfault.rb +0 -31
  61. data/sample/psql.rb +0 -1181
  62. data/sample/psqlHelp.rb +0 -158
  63. data/sample/test1.rb +0 -60
  64. data/sample/test2.rb +0 -44
  65. data/sample/test4.rb +0 -71
  66. data/spec/m17n_spec.rb +0 -151
  67. data/spec/pgconn_spec.rb +0 -643
data/Contributors.rdoc CHANGED
@@ -36,4 +36,11 @@ list.
36
36
  * Mahlon E. Smith <mahlon@martini.nu>
37
37
  * Lars Kanis <kanis@comcard.de>
38
38
  * Jason Yanowitz <me-bitbucket@jasonyanowitz.com>
39
+ * Charlie Savage <cfis@rubyforge.org>
40
+ * Rafał Bigaj <rafal.bigaj@gmail.com>
41
+ * Jason Yanowitz <me-bitbucket@jasonyanowitz.com>
42
+ * Greg Hazel <ghazel@gmail.com>
43
+ * Chris White <cwprogram@live.com>
44
+ * Aaron Patterson <aaron.patterson@gmail.com>
45
+ * Tim Felgentreff <timfelgentreff@gmail.com>
39
46
 
data/History.rdoc CHANGED
@@ -1,3 +1,181 @@
1
+ == v0.16.0 [2013-07-22] Michael Granger <ged@FaerieMUD.org>
2
+
3
+ Bugfixes:
4
+
5
+ - Avoid warnings about uninitialized instance variables.
6
+ - Use a more standard method of adding library and include directories.
7
+ This fixes build on AIX (Github #7) and Solaris (#164).
8
+ - Cancel the running query, if a thread is about to be killed (e.g. by CTRL-C).
9
+ - Fix GVL issue with wait_for_notify/notifies and notice callbacks.
10
+ - Set proper encoding on the string returned by quote_ident, escape_literal
11
+ and escape_identifier (#163).
12
+ - Use nil as PG::Error#result in case of a NULL-result from libpq (#166).
13
+ - Recalculate the timeout of conn#wait_for_notify and conn#block in case
14
+ of socket events that require re-runs of select().
15
+
16
+ Documentation fixes:
17
+
18
+ - Fix non working example for PGresult#error_field.
19
+
20
+ Enhancements:
21
+
22
+ - Add unique exception classes for each PostgreSQL error type (#5).
23
+ - Return result of the block in conn#transaction instead of nil (#158).
24
+ - Allow 'rake compile' and 'rake gem' on non mercurial repos.
25
+ - Add support for PG_DIAG_*_NAME error fields of PostgreSQL-9.3 (#161).
26
+
27
+
28
+ == v0.15.1 [2013-04-08] Michael Granger <ged@FaerieMUD.org>
29
+
30
+ Bugfixes:
31
+
32
+ - Shorten application_name to avoid warnings about truncated identifier.
33
+
34
+
35
+ == v0.15.0 [2013-03-03] Michael Granger <ged@FaerieMUD.org>
36
+
37
+ Bugfixes:
38
+
39
+ - Fix segfault in PG::Result#field_values when called with non String value.
40
+ - Fix encoding of messages delivered by notice callbacks.
41
+ - Fix text encoding for Connection#wait_for_notify and Connection#notifies.
42
+ - Fix 'Bad file descriptor' problems under Windows: wrong behaviour of
43
+ #wait_for_notify() and timeout handling of #block on Ruby 1.9.
44
+
45
+ Documentation fixes:
46
+
47
+ - conn#socket() can not be used with IO.for_fd() on Windows.
48
+
49
+ Enhancements:
50
+
51
+ - Tested under Ruby 2.0.0p0.
52
+ - Add single row mode of PostgreSQL 9.2.
53
+ - Set fallback_application_name to programm name $0. Thanks to Will Leinweber
54
+ for the patch.
55
+ - Release Ruby's GVL while calls to blocking libpq functions to allow better
56
+ concurrency in threaded applications.
57
+ - Refactor different variants of waiting for the connection socket.
58
+ - Make use of rb_thread_fd_select() on Ruby 1.9 and avoid deprecated
59
+ rb_thread_select().
60
+ - Add an example of how to insert array data using a prepared statement (#145).
61
+ - Add continous integration tests on travis-ci.org.
62
+ - Add PG::Result#each_row for iterative over result sets by row. Thanks to
63
+ Aaron Patterson for the patch.
64
+ - Add a PG::Connection#socket_io method for fetching a (non-autoclosing) IO
65
+ object for the connection's socket.
66
+
67
+ Specs:
68
+
69
+ - Fix various specs to run on older PostgreSQL and Ruby versions.
70
+ - Avoid fork() in specs to allow usage on Windows and JRuby.
71
+
72
+
73
+ == v0.14.1 [2012-09-02] Michael Granger <ged@FaerieMUD.org>
74
+
75
+ Important bugfix:
76
+
77
+ - Fix stack overflow bug in PG::Result#values and #column_values (#135). Thanks
78
+ to everyone who reported the bug, and Lars Kanis especially for figuring out
79
+ the problem.
80
+
81
+ PostgreSQL 9.2 beta fixes:
82
+
83
+ - Recognize PGRES_SINGLE_TUPLE as OK when checking PGresult (Jeremy Evans)
84
+
85
+ Documentation fixes:
86
+
87
+ - Add note about the usage scope of the result object received by the
88
+ #set_notice_receiver block. (Lars Kanis)
89
+ - Add PGRES_COPY_BOTH to documentation of PG::Result#result_status. (Lars Kanis)
90
+ - Add some documentation to PG::Result#fnumber (fix for #139)
91
+
92
+
93
+ == v0.14.0 [2012-06-17] Michael Granger <ged@FaerieMUD.org>
94
+
95
+ Bugfixes:
96
+ #47, #104
97
+
98
+
99
+ New Methods for PostgreSQL 9 and async API support:
100
+ PG
101
+ - ::library_version
102
+
103
+ PG::Connection
104
+ - ::ping
105
+ - #escape_literal
106
+ - #escape_identifier
107
+ - #set_default_encoding
108
+
109
+ PG::Result
110
+ - #check
111
+
112
+
113
+ New Samples:
114
+
115
+ This release also comes with a collection of contributed sample scripts for
116
+ doing resource-utilization reports, graphing database statistics,
117
+ monitoring for replication lag, shipping WAL files for replication,
118
+ automated tablespace partitioning, etc. See the samples/ directory.
119
+
120
+
121
+ == v0.13.2 [2012-02-22] Michael Granger <ged@FaerieMUD.org>
122
+
123
+ - Make builds against PostgreSQL earlier than 8.3 fail with a descriptive
124
+ message instead of a compile failure.
125
+
126
+
127
+ == v0.13.1 [2012-02-12] Michael Granger <ged@FaerieMUD.org>
128
+
129
+ - Made use of a finished PG::Connection raise a PG::Error instead of
130
+ a fatal error (#110).
131
+ - Added missing BSDL license file (#108)
132
+
133
+
134
+ == v0.13.0 [2012-02-09] Michael Granger <ged@FaerieMUD.org>
135
+
136
+ Reorganization of modules/classes to be better Ruby citizens (with backward-compatible aliases):
137
+ - Created toplevel namespace 'PG' to correspond with the gem name.
138
+ - Renamed PGconn to PG::Connection (with ::PGconn alias)
139
+ - Renamed PGresult to PG::Result (with ::PGresult alias)
140
+ - Renamed PGError to PG::Error (with ::PGError alias)
141
+ - Declare all constants inside PG::Constants, then include them in
142
+ PG::Connection and PG::Result for backward-compatibility, and
143
+ in PG for convenience.
144
+ - Split the extension source up by class/module.
145
+ - Removed old compatibility code for PostgreSQL versions < 8.3
146
+
147
+ Documentation:
148
+ - Clarified licensing, updated to Ruby 1.9's license.
149
+ - Merged authors list, added some missing people to the Contributor's
150
+ list.
151
+ - Cleaned up the sample/ directory
152
+ - Making contact info a bit clearer, link to the Google+ page and
153
+ the mailing list
154
+
155
+ Enhancements:
156
+ - Added a convenience method: PG.connect -> PG::Connection.new
157
+
158
+ Bugfixes:
159
+ - Fixed LATIN5-LATIN10 Postgres<->Ruby encoding conversions
160
+
161
+
162
+
163
+ == v0.12.2 [2012-01-03] Michael Granger <ged@FaerieMUD.org>
164
+
165
+ - Fix for the 1.8.7 breakage introduced by the st.h fix for alternative Ruby
166
+ implementations (#97 and #98). Thanks to Lars Kanis for the patch.
167
+ - Encode error messages with the connection's encoding under 1.9 (#96)
168
+
169
+
170
+ == v0.12.1 [2011-12-14] Michael Granger <ged@FaerieMUD.org>
171
+
172
+ - Made rake-compiler a dev dependency, as Rubygems doesn't use the Rakefile
173
+ for compiling the extension. Thanks to eolamey@bitbucket and Jeremy Evans
174
+ for pointing this out.
175
+ - Added an explicit include for ruby/st.h for implementations that need it
176
+ (fixes #95).
177
+
178
+
1
179
  == v0.12.0 [2011-12-07] Michael Granger <ged@FaerieMUD.org>
2
180
 
3
181
  - PGconn#wait_for_notify
@@ -5,11 +183,11 @@
5
183
  * accept a nil argument for no timeout (Sequel support)
6
184
  * Fixed API docs
7
185
  * Taint and encode event name and payload
8
- - Handle errors while rb_thread_select()ing in PGconn#block.
186
+ - Handle errors while rb_thread_select()ing in PGconn#block.
9
187
  (Brian Weaver).
10
188
  - Fixes for Win32 async queries (Rafał Bigaj)
11
189
  - Memory leak fixed: Closing opened WSA event. (rafal)
12
- - Fixes for #66 Win32 asynchronous queries hang on connection
190
+ - Fixes for #66 Win32 asynchronous queries hang on connection
13
191
  error. (rafal)
14
192
  - Fixed a typo in PGconn#error_message's documentation
15
193
  - fixing unused variable warnings for ruby 1.9.3 (Aaron Patterson)
@@ -22,7 +200,7 @@
22
200
 
23
201
  Enhancements:
24
202
 
25
- * Added a PGresult#values method to fetch all result rows as an Array of
203
+ * Added a PGresult#values method to fetch all result rows as an Array of
26
204
  Arrays. Thanks to Jason Yanowitz (JYanowitz at enovafinancial dot com) for
27
205
  the patch.
28
206
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
2
- You can redistribute it and/or modify it under either the terms of the GPL
3
- (see COPYING.txt file), or the conditions below:
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
4
 
5
5
  1. You may make and give away verbatim copies of the source form of the
6
6
  software without restriction, provided that you duplicate all of the
@@ -17,33 +17,32 @@ You can redistribute it and/or modify it under either the terms of the GPL
17
17
  b) use the modified software only within your corporation or
18
18
  organization.
19
19
 
20
- c) rename any non-standard executables so the names do not conflict
21
- with standard executables, which must also be provided.
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
22
 
23
23
  d) make other distribution arrangements with the author.
24
24
 
25
- 3. You may distribute the software in object code or executable
26
- form, provided that you do at least ONE of the following:
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
27
 
28
- a) distribute the executables and library files of the software,
28
+ a) distribute the binaries and library files of the software,
29
29
  together with instructions (in the manual page or equivalent)
30
30
  on where to get the original distribution.
31
31
 
32
32
  b) accompany the distribution with the machine-readable source of
33
33
  the software.
34
34
 
35
- c) give non-standard executables non-standard names, with
35
+ c) give non-standard binaries non-standard names, with
36
36
  instructions on where to get the original software distribution.
37
37
 
38
38
  d) make other distribution arrangements with the author.
39
39
 
40
40
  4. You may modify and include the part of the software into any other
41
41
  software (possibly commercial). But some files in the distribution
42
- are not written by the author, so that they are not under this terms.
42
+ are not written by the author, so that they are not under these terms.
43
43
 
44
- They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
45
- files under the ./missing directory. See each file for the copying
46
- condition.
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
47
46
 
48
47
  5. The scripts and library files supplied as input to or produced as
49
48
  output from the software do not automatically fall under the
@@ -55,4 +54,3 @@ You can redistribute it and/or modify it under either the terms of the GPL
55
54
  IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
56
55
  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57
56
  PURPOSE.
58
-
data/Manifest.txt CHANGED
@@ -1,43 +1,57 @@
1
1
  .gemtest
2
- BSD
2
+ BSDL
3
3
  ChangeLog
4
4
  Contributors.rdoc
5
- GPL
6
5
  History.rdoc
7
6
  LICENSE
8
7
  Manifest.txt
9
- README.OS_X.rdoc
8
+ POSTGRES
9
+ README-OS_X.rdoc
10
+ README-Windows.rdoc
10
11
  README.ja.rdoc
11
12
  README.rdoc
12
- README.windows.rdoc
13
13
  Rakefile
14
14
  Rakefile.cross
15
- ext/compat.c
16
- ext/compat.h
15
+ ext/errorcodes.def
16
+ ext/errorcodes.rb
17
+ ext/errorcodes.txt
17
18
  ext/extconf.rb
19
+ ext/gvl_wrappers.c
20
+ ext/gvl_wrappers.h
18
21
  ext/pg.c
19
22
  ext/pg.h
23
+ ext/pg_connection.c
24
+ ext/pg_errors.c
25
+ ext/pg_result.c
20
26
  ext/vc/pg.sln
21
27
  ext/vc/pg_18/pg.vcproj
22
28
  ext/vc/pg_19/pg_19.vcproj
23
29
  lib/pg.rb
24
- misc/openssl-pg-segfault.rb
30
+ lib/pg/connection.rb
31
+ lib/pg/constants.rb
32
+ lib/pg/exceptions.rb
33
+ lib/pg/result.rb
34
+ sample/array_insert.rb
25
35
  sample/async_api.rb
26
36
  sample/async_copyto.rb
37
+ sample/async_mixed.rb
38
+ sample/check_conn.rb
27
39
  sample/copyfrom.rb
28
40
  sample/copyto.rb
29
41
  sample/cursor.rb
42
+ sample/disk_usage_report.rb
43
+ sample/issue-119.rb
30
44
  sample/losample.rb
45
+ sample/minimal-testcase.rb
31
46
  sample/notify_wait.rb
32
- sample/psql.rb
33
- sample/psqlHelp.rb
34
- sample/test1.rb
35
- sample/test2.rb
36
- sample/test4.rb
47
+ sample/pg_statistics.rb
48
+ sample/replication_monitor.rb
37
49
  sample/test_binary_values.rb
50
+ sample/wal_shipper.rb
51
+ sample/warehouse_partitions.rb
38
52
  spec/data/expected_trace.out
39
53
  spec/data/random_binary_data
40
54
  spec/lib/helpers.rb
41
- spec/m17n_spec.rb
42
- spec/pgconn_spec.rb
43
- spec/pgresult_spec.rb
55
+ spec/pg/connection_spec.rb
56
+ spec/pg/result_spec.rb
57
+ spec/pg_spec.rb
data/{BSD → POSTGRES} RENAMED
File without changes
File without changes
File without changes
data/README.ja.rdoc CHANGED
@@ -1,7 +1,14 @@
1
1
  = pg
2
2
 
3
- * https://bitbucket.org/ged/ruby-pg
3
+ home :: https://bitbucket.org/ged/ruby-pg
4
+ mirror :: https://github.com/ged/ruby-pg
5
+ docs :: http://deveiate.org/code/pg
4
6
 
5
- This file needs translation. Anyone who is willing to volunteer, please
6
- mail <ged@FaerieMUD.org>.
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.
7
14
 
data/README.rdoc CHANGED
@@ -1,25 +1,44 @@
1
1
  = pg
2
2
 
3
- * https://bitbucket.org/ged/ruby-pg
3
+ home :: https://bitbucket.org/ged/ruby-pg
4
+ mirror :: https://github.com/ged/ruby-pg
5
+ docs :: http://deveiate.org/code/pg
6
+
4
7
 
5
8
  == Description
6
9
 
7
10
  Pg is the Ruby interface to the {PostgreSQL RDBMS}[http://www.postgresql.org/].
8
11
 
9
- It works with PostgreSQL 8.2 and later.
12
+ It works with {PostgreSQL 8.4 and later}[http://www.postgresql.org/support/versioning/].
13
+
14
+ A small example usage:
15
+
16
+ #!/usr/bin/env ruby
17
+
18
+ require 'pg'
10
19
 
11
- This will be the last minor version to support 8.2 -- 0.13 will support 8.3
12
- and later, following the
13
- {PostgreSQL Release Support Policy}[http://bit.ly/6AfPhm].
20
+ # Output a table of current connections to the DB
21
+ conn = PG.connect( dbname: 'sales' )
22
+ conn.exec( "SELECT * FROM pg_stat_activity" ) do |result|
23
+ puts " PID | User | Query"
24
+ result.each do |row|
25
+ puts " %7d | %-16s | %s " %
26
+ row.values_at('procpid', 'usename', 'current_query')
27
+ end
28
+ end
14
29
 
30
+ == Build Status
31
+
32
+ {<img src="https://travis-ci.org/ged/ruby-pg.png?branch=master" alt="Build Status" />}[https://travis-ci.org/ged/ruby-pg]
15
33
 
16
34
 
17
35
  == Requirements
18
36
 
19
- * Ruby 1.8.7-p249 or later.
20
- * PostgreSQL 8.2.x or later installed.
37
+ * Ruby 1.9.3-p392, or 2.0.0-p0.
38
+ * PostgreSQL 8.4.x or later (with headers, -dev packages, etc).
21
39
 
22
- It may work with earlier versions as well, but those are not regularly tested.
40
+ It may work with earlier versions of Ruby/PostgreSQL as well, but those are
41
+ not regularly tested.
23
42
 
24
43
 
25
44
  == How To Install
@@ -33,8 +52,16 @@ Postgres:
33
52
 
34
53
  gem install pg -- --with-pg-config=<path to pg_config>
35
54
 
36
- See README.OS_X.rdoc for more information about installing under MacOS X, and
37
- README.windows.rdoc for Windows build/installation instructions.
55
+ If you're installing via Bundler, you can provide compile hints like so:
56
+
57
+ bundle config build.pg --with-pg-config=<path to pg_config>
58
+
59
+ See README-OS_X.rdoc for more information about installing under MacOS X, and
60
+ README-Windows.rdoc for Windows build/installation instructions.
61
+
62
+ There's also {a Google+ group}[http://goo.gl/TFy1U] and a
63
+ {mailing list}[http://groups.google.com/group/ruby-pg] if you get stuck, or just
64
+ want to chat about something.
38
65
 
39
66
 
40
67
  == Contributing
@@ -50,39 +77,38 @@ After checking out the source, run:
50
77
  This task will install any missing dependencies, run the tests/specs, and
51
78
  generate the API documentation.
52
79
 
80
+ The current maintainers are Michael Granger <ged@FaerieMUD.org> and
81
+ Lars Kanis <lars@greiz-reinsdorf.de>.
53
82
 
54
- == Copying
55
83
 
56
- This library is copyrighted by the authors.
84
+ == Copying
57
85
 
58
- Authors:
86
+ Copyright (c) 1997-2013 by the authors.
59
87
 
60
- * Yukihiro Matsumoto <matz@ruby-lang.org> - Author of Ruby.
61
- * Eiji Matsumoto <usagi@ruby.club.or.jp> - One of users who loves Ruby.
62
88
  * Jeff Davis <ruby-pg@j-davis.com>
63
-
64
- Thanks to:
65
-
66
- * Noboru Saitou <noborus@netlab.jp> - Past maintainer.
67
- * Dave Lee - Past maintainer.
68
- * Guy Decoux (ts) <decoux@moulon.inra.fr>
69
-
70
- Maintainers:
71
-
89
+ * Guy Decoux (ts) <decoux@moulon.inra.fr>
72
90
  * Michael Granger <ged@FaerieMUD.org>
91
+ * Lars Kanis <lars@greiz-reinsdorf.de>
92
+ * Dave Lee
93
+ * Eiji Matsumoto <usagi@ruby.club.or.jp>
94
+ * Yukihiro Matsumoto <matz@ruby-lang.org>
95
+ * Noboru Saitou <noborus@netlab.jp>
73
96
 
74
- You may redistribute this software under the terms of the Ruby license,
75
- included in the file "LICENSE". The Ruby license also allows distribution
76
- under the terms of the GPL, included in the file "GPL".
97
+ You may redistribute this software under the same terms as Ruby itself; see
98
+ http://www.ruby-lang.org/en/LICENSE.txt or the LICENSE file in the source
99
+ for details.
77
100
 
78
101
  Portions of the code are from the PostgreSQL project, and are distributed
79
- under the terms of the BSD license, included in the file "BSD".
102
+ under the terms of the PostgreSQL license, included in the file POSTGRES.
80
103
 
81
104
  Portions copyright LAIKA, Inc.
82
105
 
83
106
 
84
107
  == Acknowledgments
85
108
 
109
+ See Contributors.rdoc for the many additional fine people that have contributed
110
+ to this library over the years.
111
+
86
112
  We are thankful to the people at the ruby-list and ruby-dev mailing lists.
87
113
  And to the people who developed PostgreSQL.
88
114
 
data/Rakefile CHANGED
@@ -26,7 +26,7 @@ EXTDIR = BASEDIR + 'ext'
26
26
  PKGDIR = BASEDIR + 'pkg'
27
27
  TMPDIR = BASEDIR + 'tmp'
28
28
 
29
- DLEXT = Config::CONFIG['DLEXT']
29
+ DLEXT = RbConfig::CONFIG['DLEXT']
30
30
  EXT = LIBDIR + "pg_ext.#{DLEXT}"
31
31
 
32
32
  TEST_DIRECTORY = BASEDIR + "tmp_test_specs"
@@ -37,6 +37,7 @@ CLEAN.include( PKGDIR.to_s, TMPDIR.to_s )
37
37
  # Set up Hoe plugins
38
38
  Hoe.plugin :mercurial
39
39
  Hoe.plugin :signing
40
+ Hoe.plugin :deveiate
40
41
 
41
42
  Hoe.plugins.delete :rubyforge
42
43
  Hoe.plugins.delete :compiler
@@ -49,14 +50,13 @@ $hoespec = Hoe.spec 'pg' do
49
50
  self.readme_file = 'README.rdoc'
50
51
  self.history_file = 'History.rdoc'
51
52
  self.extra_rdoc_files = Rake::FileList[ '*.rdoc' ]
52
- self.extra_rdoc_files.include( 'BSD', 'GPL', 'LICENSE' )
53
+ self.extra_rdoc_files.include( 'POSTGRES', 'LICENSE' )
53
54
  self.extra_rdoc_files.include( 'ext/*.c' )
54
55
 
55
- self.developer 'Jeff Davis', 'ruby-pg@j-davis.com'
56
56
  self.developer 'Michael Granger', 'ged@FaerieMUD.org'
57
57
 
58
- self.dependency 'rake-compiler', '~> 0.7'
59
- self.dependency 'rspec', '~> 2.6', :developer
58
+ self.dependency 'rake-compiler', '~> 0.8', :developer
59
+ self.dependency 'hoe-deveiate', '~> 0.2', :developer
60
60
 
61
61
  self.spec_extras[:licenses] = ['BSD', 'Ruby', 'GPL']
62
62
  self.spec_extras[:extensions] = [ 'ext/extconf.rb' ]
@@ -65,6 +65,11 @@ $hoespec = Hoe.spec 'pg' do
65
65
 
66
66
  self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags= )
67
67
  self.check_history_on_release = true if self.respond_to?( :check_history_on_release= )
68
+ self.spec_extras[:rdoc_options] = [
69
+ '-f', 'fivefish',
70
+ '-t', 'pg: The Ruby Interface to PostgreSQL',
71
+ '-m', 'README.rdoc',
72
+ ]
68
73
 
69
74
  self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
70
75
  end
@@ -97,7 +102,7 @@ task :maint do
97
102
  ENV['MAINTAINER_MODE'] = 'yes'
98
103
  end
99
104
 
100
- ENV['RUBY_CC_VERSION'] = '1.8.7:1.9.2'
105
+ ENV['RUBY_CC_VERSION'] ||= '1.8.7:1.9.2:2.0.0'
101
106
 
102
107
  # Rake-compiler task
103
108
  Rake::ExtensionTask.new do |ext|
@@ -107,32 +112,38 @@ Rake::ExtensionTask.new do |ext|
107
112
  ext.lib_dir = 'lib'
108
113
  ext.source_pattern = "*.{c,h}"
109
114
  ext.cross_compile = true
110
- ext.cross_platform = %w[i386-mingw32]
111
-
112
- # configure options only for cross compile
113
- ext.cross_config_options += [
114
- "--with-pg-include=#{STATIC_POSTGRESQL_LIBDIR}",
115
- "--with-opt-include=#{STATIC_POSTGRESQL_INCDIR}",
116
- "--with-pg-lib=#{STATIC_POSTGRESQL_LIBDIR}",
117
- "--with-opt-lib=#{STATIC_OPENSSL_BUILDDIR}",
118
- "--enable-static-build",
119
- ]
115
+ ext.cross_platform = CrossLibraries.map &:for_platform
116
+
117
+ ext.cross_config_options += CrossLibraries.map do |lib|
118
+ {
119
+ lib.for_platform => [
120
+ "--with-pg-include=#{lib.static_postgresql_libdir}",
121
+ "--with-opt-include=#{lib.static_postgresql_incdir}",
122
+ "--with-pg-lib=#{lib.static_postgresql_libdir}",
123
+ "--with-opt-lib=#{lib.static_openssl_builddir}",
124
+ ]
125
+ }
126
+ end
120
127
  end
121
128
 
122
129
 
123
130
  # Make the ChangeLog update if the repo has changed since it was last built
124
131
  file '.hg/branch' do
125
- abort "You need the Mercurial repo to make packages"
132
+ warn "WARNING: You need the Mercurial repo to update the ChangeLog"
126
133
  end
127
- file 'ChangeLog' => '.hg/branch' do |task|
128
- $stderr.puts "Updating the changelog..."
129
- begin
130
- content = make_changelog()
131
- rescue NameError
132
- abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
133
- end
134
- File.open( task.name, 'w', 0644 ) do |fh|
135
- fh.print( content )
134
+ file 'ChangeLog' do |task|
135
+ if File.exist?('.hg/branch')
136
+ $stderr.puts "Updating the changelog..."
137
+ begin
138
+ content = make_changelog()
139
+ rescue NameError
140
+ abort "Packaging tasks require the hoe-mercurial plugin (gem install hoe-mercurial)"
141
+ end
142
+ File.open( task.name, 'w', 0644 ) do |fh|
143
+ fh.print( content )
144
+ end
145
+ else
146
+ touch 'ChangeLog'
136
147
  end
137
148
  end
138
149
 
@@ -147,3 +158,19 @@ task :cleanup_testing_dbs do
147
158
  Rake::Task[:clean].invoke
148
159
  end
149
160
 
161
+ desc "Update list of server error codes"
162
+ task :update_error_codes do
163
+ URL_ERRORCODES_TXT = "http://git.postgresql.org/gitweb/?p=postgresql.git;a=blob_plain;f=src/backend/utils/errcodes.txt;hb=HEAD"
164
+
165
+ ERRORCODES_TXT = "ext/errorcodes.txt"
166
+ sh "wget #{URL_ERRORCODES_TXT.inspect} -O #{ERRORCODES_TXT.inspect} || curl #{URL_ERRORCODES_TXT.inspect} -o #{ERRORCODES_TXT.inspect}"
167
+ end
168
+
169
+ file 'ext/errorcodes.def' => ['ext/errorcodes.rb', 'ext/errorcodes.txt'] do
170
+ ruby 'ext/errorcodes.rb', 'ext/errorcodes.txt', 'ext/errorcodes.def'
171
+ end
172
+
173
+ file 'ext/pg_errors.c' => ['ext/errorcodes.def'] do
174
+ # trigger compilation of changed errorcodes.def
175
+ touch 'ext/pg_errors.c'
176
+ end