do_postgres 0.10.2-x86-mswin32-60 → 0.10.3-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 0.10.3 2011-01-30
2
+ * Reworked transactions
3
+ * Fix a DST bug that could cause datetimes in the wrong timezone
4
+
1
5
  ## 0.10.2 2010-05-19
2
6
  * Make Encoding.default_internal aware
3
7
  * Rework logging for making callbacks possible
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ JRUBY = RUBY_PLATFORM =~ /java/
11
11
  IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'
12
12
  WINDOWS = Gem.win_platform? || (JRUBY && ENV_JAVA['os.name'] =~ /windows/i)
13
13
  SUDO = WINDOWS ? '' : ('sudo' unless ENV['SUDOLESS'])
14
- BINARY_VERSION = '8.3.10'
14
+ BINARY_VERSION = '8.3.13'
15
15
 
16
16
  CLEAN.include(%w[ {tmp,pkg}/ **/*.{o,so,bundle,jar,log,a,gem,dSYM,obj,pdb,exp,DS_Store,rbc,db} ext/do_postgres/Makefile ext-java/target ])
17
17
 
@@ -38,7 +38,7 @@ begin
38
38
  gem.add_dependency 'data_objects', DataObjects::Postgres::VERSION
39
39
 
40
40
  gem.add_development_dependency 'bacon', '~>1.1'
41
- gem.add_development_dependency 'rake-compiler', '~>0.7'
41
+ gem.add_development_dependency 'rake-compiler', '= 0.7.0'
42
42
 
43
43
  gem.has_rdoc = false
44
44
  gem.rubyforge_project = 'dorb'
@@ -201,10 +201,10 @@ static VALUE parse_date_time(const char *date) {
201
201
  do_int64 num, den;
202
202
 
203
203
  long int gmt_offset;
204
- int is_dst;
204
+ int dst_adjustment;
205
205
 
206
206
  time_t rawtime;
207
- struct tm * timeinfo;
207
+ struct tm timeinfo;
208
208
 
209
209
  int tokens_read, max_tokens;
210
210
 
@@ -234,22 +234,50 @@ static VALUE parse_date_time(const char *date) {
234
234
  }
235
235
  // We read the Date and Time, default to the current locale's offset
236
236
 
237
+ tzset();
238
+
237
239
  // Get localtime
238
240
  time(&rawtime);
239
- timeinfo = localtime(&rawtime);
241
+ #ifdef HAVE_LOCALTIME_R
242
+ localtime_r(&rawtime, &timeinfo);
243
+ #else
244
+ // Thread unsafe, this is used on Windows...
245
+ timeinfo = *localtime(&rawtime);
246
+ #endif
240
247
 
241
- is_dst = timeinfo->tm_isdst * 3600;
248
+ timeinfo.tm_sec = sec;
249
+ timeinfo.tm_min = min;
250
+ timeinfo.tm_hour = hour;
251
+ timeinfo.tm_mday = day;
252
+ timeinfo.tm_mon = month;
253
+ timeinfo.tm_year = year - 1900;
254
+ timeinfo.tm_isdst = -1;
255
+
256
+ // Update tm_isdst
257
+ mktime(&timeinfo);
258
+
259
+ if (timeinfo.tm_isdst) {
260
+ dst_adjustment = 3600;
261
+ } else {
262
+ dst_adjustment = 0;
263
+ }
242
264
 
265
+ #ifdef HAVE_GMTIME_R
243
266
  // Reset to GM Time
244
- timeinfo = gmtime(&rawtime);
267
+ gmtime_r(&rawtime, &timeinfo);
268
+ #else
269
+ // Same as for localtime_r above
270
+ timeinfo = *gmtime(&rawtime);
271
+ #endif
245
272
 
246
- gmt_offset = mktime(timeinfo) - rawtime;
273
+ gmt_offset = rawtime - mktime(&timeinfo);
247
274
 
248
- if ( is_dst > 0 )
249
- gmt_offset -= is_dst;
275
+ if (dst_adjustment) {
276
+ gmt_offset += dst_adjustment;
277
+ }
250
278
 
251
- hour_offset = -((int)gmt_offset / 3600);
252
- minute_offset = -((int)gmt_offset % 3600 / 60);
279
+ hour_offset = ((int)gmt_offset / 3600);
280
+ minute_offset = ((int)gmt_offset % 3600 / 60);
253
281
 
254
282
  } else {
255
283
  // Something went terribly wrong
@@ -820,7 +848,11 @@ static VALUE cCommand_execute_non_query(int argc, VALUE *argv[], VALUE self) {
820
848
  status = PQresultStatus(response);
821
849
 
822
850
  if ( status == PGRES_TUPLES_OK ) {
823
- insert_id = INT2NUM(atoi(PQgetvalue(response, 0, 0)));
851
+ if (PQgetlength(response, 0, 0) == 0) {
852
+ insert_id = Qnil;
853
+ } else {
854
+ insert_id = INT2NUM(atoi(PQgetvalue(response, 0, 0)));
855
+ }
824
856
  affected_rows = INT2NUM(atoi(PQcmdTuples(response)));
825
857
  }
826
858
  else if ( status == PGRES_COMMAND_OK ) {
@@ -984,6 +1016,7 @@ static VALUE cReader_field_count(VALUE self) {
984
1016
 
985
1017
  void Init_do_postgres() {
986
1018
  rb_require("date");
1019
+ rb_require("rational");
987
1020
  rb_require("bigdecimal");
988
1021
  rb_require("data_objects");
989
1022
 
@@ -20,13 +20,13 @@ def have_build_env
20
20
  have_header('catalog/pg_type.h')
21
21
  end
22
22
 
23
- $CFLAGS << '-UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT' if RUBY_PLATFORM =~ /mswin|mingw/
23
+ $CFLAGS << ' -UENABLE_NLS -DHAVE_GETTIMEOFDAY -DHAVE_CRYPT' if RUBY_PLATFORM =~ /mswin|mingw/
24
24
 
25
25
  dir_config('pgsql-server', config_value('includedir-server'), config_value('libdir'))
26
26
  dir_config('pgsql-client', config_value('includedir'), config_value('libdir'))
27
27
  dir_config('pgsql-win32') if RUBY_PLATFORM =~ /mswin|mingw/
28
28
 
29
- desired_functions = %w(PQsetClientEncoding pg_encoding_to_char PQfreemem)
29
+ desired_functions = %w(localtime_r gmtime_r PQsetClientEncoding pg_encoding_to_char PQfreemem)
30
30
  compat_functions = %w(PQescapeString PQexecParams)
31
31
 
32
32
  if have_build_env
@@ -1,5 +1,5 @@
1
1
  module DataObjects
2
2
  module Postgres
3
- VERSION = '0.10.2'
3
+ VERSION = '0.10.3'
4
4
  end
5
5
  end
@@ -19,16 +19,22 @@ describe DataObjects::Postgres::Connection do
19
19
  # FIXME: behaves_like 'a Connection with JDBC URL support' if JRUBY
20
20
 
21
21
  describe 'byte array quoting' do
22
+ # There are two possible byte array quotings available: hex or escape.
23
+ # The default changed from escape to hex in version 9, so these specs
24
+ # check for either.
25
+ #
26
+ # http://developer.postgresql.org/pgdocs/postgres/datatype-binary.html
27
+ # http://developer.postgresql.org/pgdocs/postgres/release-9-0.html (E.3.2.3.)
22
28
  it 'should properly escape non-printable ASCII characters' do
23
- @connection.quote_byte_array("\001").should.match(/'\\?\\001'/)
29
+ ["'\\001'", "'\\x01'"].should.include @connection.quote_byte_array("\001")
24
30
  end
25
31
 
26
32
  it 'should properly escape bytes with the high bit set' do
27
- @connection.quote_byte_array("\210").should.match(/'\\?\\210'/)
33
+ ["'\\210'", "'\\x88'"].should.include @connection.quote_byte_array("\210")
28
34
  end
29
35
 
30
36
  it 'should not escape printable ASCII characters' do
31
- @connection.quote_byte_array("a").should == "'a'"
37
+ ["'a'", "'\\x61'"].should.include @connection.quote_byte_array("a")
32
38
  end
33
39
  end
34
40
  end
@@ -0,0 +1,8 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
4
+ require 'data_objects/spec/error/sql_error_spec'
5
+
6
+ describe 'DataObjects::Postgres raising SQLError' do
7
+ behaves_like 'raising a SQLError'
8
+ end
@@ -139,6 +139,10 @@ module DataObjectsSpecHelpers
139
139
  update widgets set release_timestamp = NULL where id = 9
140
140
  EOF
141
141
 
142
+ conn.create_command(<<-EOF).execute_non_query
143
+ update widgets set release_datetime = '2008-07-14 00:31:12' where id = 10
144
+ EOF
145
+
142
146
  conn.close
143
147
 
144
148
  end
@@ -73,7 +73,7 @@ begin
73
73
  ext.classpath = '../do_jdbc/lib/do_jdbc_internal.jar'
74
74
  ext.java_compiling do |gem|
75
75
  gem.add_dependency 'jdbc-postgres', '>=8.2'
76
- gem.add_dependency 'do_jdbc', '0.10.2'
76
+ gem.add_dependency 'do_jdbc', '0.10.3'
77
77
  end
78
78
  end
79
79
  rescue LoadError
@@ -3,7 +3,7 @@ task :build_all do
3
3
  `rake clean`
4
4
  `rake build`
5
5
  `rake java gem`
6
- `rake cross native gem RUBY_CC_VERSION=1.8.6:1.9.1`
6
+ `rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.2`
7
7
  end
8
8
 
9
9
  desc 'Release all gems (native, binaries for JRuby and Windows)'
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: do_postgres
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 49
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 10
8
- - 2
9
- version: 0.10.2
9
+ - 3
10
+ version: 0.10.3
10
11
  platform: x86-mswin32-60
11
12
  authors:
12
13
  - Dirkjan Bussink
@@ -14,30 +15,34 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-19 00:00:00 +02:00
18
+ date: 2011-01-30 00:00:00 +01:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: data_objects
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
27
  - - "="
26
28
  - !ruby/object:Gem::Version
29
+ hash: 49
27
30
  segments:
28
31
  - 0
29
32
  - 10
30
- - 2
31
- version: 0.10.2
33
+ - 3
34
+ version: 0.10.3
32
35
  type: :runtime
33
36
  version_requirements: *id001
34
37
  - !ruby/object:Gem::Dependency
35
38
  name: bacon
36
39
  prerelease: false
37
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
38
42
  requirements:
39
43
  - - ~>
40
44
  - !ruby/object:Gem::Version
45
+ hash: 13
41
46
  segments:
42
47
  - 1
43
48
  - 1
@@ -48,13 +53,16 @@ dependencies:
48
53
  name: rake-compiler
49
54
  prerelease: false
50
55
  requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
51
57
  requirements:
52
- - - ~>
58
+ - - "="
53
59
  - !ruby/object:Gem::Version
60
+ hash: 3
54
61
  segments:
55
62
  - 0
56
63
  - 7
57
- version: "0.7"
64
+ - 0
65
+ version: 0.7.0
58
66
  type: :development
59
67
  version_requirements: *id003
60
68
  description: Implements the DataObjects API for PostgreSQL
@@ -75,6 +83,7 @@ files:
75
83
  - spec/command_spec.rb
76
84
  - spec/connection_spec.rb
77
85
  - spec/encoding_spec.rb
86
+ - spec/error/sql_error_spec.rb
78
87
  - spec/reader_spec.rb
79
88
  - spec/result_spec.rb
80
89
  - spec/spec_helper.rb
@@ -116,13 +125,13 @@ post_install_message: |+
116
125
  ======================================================================================================
117
126
 
118
127
  You've installed the binary version of do_postgres.
119
- It was built using PostgreSQL version 8.3.10.
128
+ It was built using PostgreSQL version 8.3.13.
120
129
  It's recommended to use the exact same version to avoid potential issues.
121
130
 
122
131
  At the time of building this gem, the necessary DLL files where available
123
132
  in the following download:
124
133
 
125
- http://wwwmaster.postgresql.org/redir/107/h/binary/v8.3.10/win32/postgresql-8.3.10-1-binaries-no-installer.zip
134
+ http://wwwmaster.postgresql.org/redir/107/h/binary/v8.3.13/win32/postgresql-8.3.13-1-binaries-no-installer.zip
126
135
 
127
136
  You can put the following files available in this package in your Ruby bin
128
137
  directory, for example C:\Ruby\bin
@@ -144,23 +153,27 @@ rdoc_options:
144
153
  require_paths:
145
154
  - lib
146
155
  required_ruby_version: !ruby/object:Gem::Requirement
156
+ none: false
147
157
  requirements:
148
158
  - - ">="
149
159
  - !ruby/object:Gem::Version
160
+ hash: 3
150
161
  segments:
151
162
  - 0
152
163
  version: "0"
153
164
  required_rubygems_version: !ruby/object:Gem::Requirement
165
+ none: false
154
166
  requirements:
155
167
  - - ">="
156
168
  - !ruby/object:Gem::Version
169
+ hash: 3
157
170
  segments:
158
171
  - 0
159
172
  version: "0"
160
173
  requirements: []
161
174
 
162
175
  rubyforge_project: dorb
163
- rubygems_version: 1.3.6
176
+ rubygems_version: 1.3.7
164
177
  signing_key:
165
178
  specification_version: 3
166
179
  summary: DataObjects PostgreSQL Driver
@@ -168,6 +181,7 @@ test_files:
168
181
  - spec/command_spec.rb
169
182
  - spec/connection_spec.rb
170
183
  - spec/encoding_spec.rb
184
+ - spec/error/sql_error_spec.rb
171
185
  - spec/reader_spec.rb
172
186
  - spec/result_spec.rb
173
187
  - spec/spec_helper.rb