dbd-pg 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,16 +3,16 @@
3
3
  #
4
4
  # Copyright (c) 2001, 2002, 2003 Jim Weirich, Michael Neumann <mneumann@ntecs.de>
5
5
  # Copyright (c) 2008 Erik Hollensbe, Christopher Maujean
6
- #
6
+ #
7
7
  # All rights reserved.
8
8
  #
9
- # Redistribution and use in source and binary forms, with or without
10
- # modification, are permitted provided that the following conditions
9
+ # Redistribution and use in source and binary forms, with or without
10
+ # modification, are permitted provided that the following conditions
11
11
  # are met:
12
- # 1. Redistributions of source code must retain the above copyright
12
+ # 1. Redistributions of source code must retain the above copyright
13
13
  # notice, this list of conditions and the following disclaimer.
14
- # 2. Redistributions in binary form must reproduce the above copyright
15
- # notice, this list of conditions and the following disclaimer in the
14
+ # 2. Redistributions in binary form must reproduce the above copyright
15
+ # notice, this list of conditions and the following disclaimer in the
16
16
  # documentation and/or other materials provided with the distribution.
17
17
  # 3. The name of the author may not be used to endorse or promote products
18
18
  # derived from this software without specific prior written permission.
@@ -49,12 +49,12 @@ module DBI
49
49
  # Only things that extend DBI's results are documented.
50
50
  #
51
51
  module Pg
52
- VERSION = "0.3.8"
52
+ VERSION = "0.3.9"
53
53
  DESCRIPTION = "PostgreSQL DBI DBD"
54
54
 
55
55
  #
56
56
  # returns 'Pg'
57
- #
57
+ #
58
58
  # See DBI::TypeUtil#convert for more information.
59
59
  #
60
60
  def self.driver_name
@@ -110,7 +110,7 @@ module DBI
110
110
  pos = ftype.index('(')
111
111
  decimal = nil
112
112
  size = nil
113
- array_of_type = nil
113
+ array_of_type = nil
114
114
 
115
115
  if pos != nil
116
116
  type = ftype[0..pos-1]
@@ -14,7 +14,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
14
14
  super(db)
15
15
  @db = db
16
16
  @sql = sql
17
- @stmt_name = PG_STMT_NAME_PREFIX + self.object_id.to_s
17
+ @stmt_name = PG_STMT_NAME_PREFIX + self.object_id.to_s + Time.now.to_f.to_s
18
18
  @result = nil
19
19
  @bindvars = []
20
20
  @prepared = false
@@ -33,17 +33,17 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
33
33
  # DBI::Binary objects are passed in.
34
34
  #
35
35
  def execute
36
- # replace DBI::Binary object by oid returned by lo_import
36
+ # replace DBI::Binary object by oid returned by lo_import
37
37
  @bindvars.collect! do |var|
38
38
  if var.is_a? DBI::Binary then
39
39
  oid = @db.__blob_create(PGconn::INV_WRITE)
40
40
  @db.__blob_write(oid, var.to_s)
41
- oid
41
+ oid
42
42
  else
43
43
  var
44
44
  end
45
45
  end
46
-
46
+
47
47
  internal_prepare
48
48
 
49
49
  if not @db['AutoCommit'] then
@@ -93,7 +93,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
93
93
 
94
94
  #
95
95
  # Attributes:
96
- #
96
+ #
97
97
  # If +pg_row_count+ is requested and the statement has already executed,
98
98
  # postgres will return what it believes is the row count.
99
99
  #
@@ -110,7 +110,7 @@ class DBI::DBD::Pg::Statement < DBI::BaseStatement
110
110
  end
111
111
  end
112
112
 
113
- private
113
+ private
114
114
 
115
115
  #
116
116
  # A native binding helper.
@@ -1,5 +1,10 @@
1
1
  require 'dbd/Pg'
2
2
 
3
+ module DBI
4
+ class ForcedError < ::DBI::Error
5
+ end
6
+ end
7
+
3
8
  ######################################################################
4
9
  # Test the PostgreSql DBD driver. This test exercises options
5
10
  # difficult to test through the standard DBI interface.
@@ -59,7 +64,7 @@ class TestDbdPostgres < DBDConfig.testbase(:postgresql)
59
64
  # XXX this is a potentially horrible way of doing it since it'll
60
65
  # create another prepared statement, but *at this time*, I don't
61
66
  # see any drawbacks and the alternative is considerably uglier.
62
-
67
+
63
68
  @sth = @dbh.prepare("select count(*) from pg_prepared_statements where name = ?")
64
69
  @sth.execute(sth_internal_name)
65
70
  assert_equal([0], @sth.fetch)
@@ -163,14 +168,30 @@ class TestDbdPostgres < DBDConfig.testbase(:postgresql)
163
168
  :type_name =>"integer",
164
169
  :unique =>nil,
165
170
  :array_of_type =>nil
166
-
171
+
167
172
  }
168
- ],
173
+ ],
169
174
  @dbh.columns('tbl')
170
175
  )
171
-
176
+
172
177
  end
173
178
 
179
+ def test_statement_name_uniqueness
180
+ 5000.times do
181
+ begin
182
+ @dbh.prepare('SELECT 1').execute()
183
+ raise DBI::ForcedError
184
+ sth.finish # never reached
185
+ rescue DBI::ProgrammingError => e
186
+ # ERROR: prepared statement "ruby-dbi:Pg:-604926268" already exists
187
+ # This should never happen
188
+ raise e
189
+ rescue DBI::ForcedError
190
+ # no-op
191
+ end
192
+ end
193
+ end
194
+
174
195
  def test_connect_errors
175
196
  dbd = nil
176
197
  ex = assert_raises(DBI::OperationalError) {
@@ -204,7 +225,7 @@ class TestDbdPostgres < DBDConfig.testbase(:postgresql)
204
225
  dbd = get_dbd
205
226
  res = dbd.do("INSERT INTO names (name, age) VALUES('Dan', 16)")
206
227
  assert_equal 1, res
207
-
228
+
208
229
  @sth = get_dbi.prepare("SELECT name FROM names WHERE age=16")
209
230
  @sth.execute
210
231
  assert @sth.fetchable?
@@ -269,7 +290,7 @@ class TestDbdPostgres < DBDConfig.testbase(:postgresql)
269
290
  # per bug #1082, views do not show up in tables listing.
270
291
  assert get_dbi.tables.include?("view_names")
271
292
  end
272
-
293
+
273
294
  def get_dbi
274
295
  config = DBDConfig.get_config
275
296
  DBI.connect("dbi:Pg:#{config['postgresql']['dbname']}", config['postgresql']['username'], config['postgresql']['password'])
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dbd-pg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 9
9
+ version: 0.3.9
5
10
  platform: ruby
6
11
  authors:
7
12
  - Erik Hollensbe
@@ -10,29 +15,35 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2009-07-11 00:00:00 -04:00
18
+ date: 2010-03-06 00:00:00 -05:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: dbi
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 4
31
+ - 0
24
32
  version: 0.4.0
25
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
26
35
  - !ruby/object:Gem::Dependency
27
36
  name: pg
28
- type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
31
39
  requirements:
32
40
  - - ">="
33
41
  - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
34
44
  version: "0"
35
- version:
45
+ type: :runtime
46
+ version_requirements: *id002
36
47
  description: PostgreSQL DBI DBD
37
48
  email: ruby-dbi-users@rubyforge.org
38
49
  executables: []
@@ -44,25 +55,25 @@ extra_rdoc_files:
44
55
  - LICENSE
45
56
  - ChangeLog
46
57
  files:
47
- - test/dbd/general/test_statement.rb
48
58
  - test/dbd/general/test_database.rb
59
+ - test/dbd/general/test_statement.rb
49
60
  - test/dbd/general/test_types.rb
50
- - test/dbd/postgresql/base.rb
51
61
  - test/dbd/postgresql/testdbipg.rb
52
- - test/dbd/postgresql/test_async.rb
53
- - test/dbd/postgresql/test_arrays.rb
54
- - test/dbd/postgresql/down.sql
62
+ - test/dbd/postgresql/test_blob.rb
63
+ - test/dbd/postgresql/test_timestamp.rb
55
64
  - test/dbd/postgresql/up.sql
65
+ - test/dbd/postgresql/base.rb
66
+ - test/dbd/postgresql/down.sql
56
67
  - test/dbd/postgresql/test_bytea.rb
57
- - test/dbd/postgresql/test_transactions.rb
68
+ - test/dbd/postgresql/test_async.rb
58
69
  - test/dbd/postgresql/test_ping.rb
59
- - test/dbd/postgresql/test_timestamp.rb
60
- - test/dbd/postgresql/test_blob.rb
70
+ - test/dbd/postgresql/test_transactions.rb
71
+ - test/dbd/postgresql/test_arrays.rb
61
72
  - lib/dbd/Pg.rb
73
+ - lib/dbd/pg/type.rb
74
+ - lib/dbd/pg/statement.rb
62
75
  - lib/dbd/pg/tuples.rb
63
76
  - lib/dbd/pg/database.rb
64
- - lib/dbd/pg/statement.rb
65
- - lib/dbd/pg/type.rb
66
77
  - lib/dbd/pg/exec.rb
67
78
  - test/DBD_TESTS
68
79
  - README
@@ -70,6 +81,8 @@ files:
70
81
  - ChangeLog
71
82
  has_rdoc: true
72
83
  homepage: http://www.rubyforge.org/projects/ruby-dbi
84
+ licenses: []
85
+
73
86
  post_install_message:
74
87
  rdoc_options: []
75
88
 
@@ -79,20 +92,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
79
92
  requirements:
80
93
  - - ">="
81
94
  - !ruby/object:Gem::Version
95
+ segments:
96
+ - 1
97
+ - 8
98
+ - 0
82
99
  version: 1.8.0
83
- version:
84
100
  required_rubygems_version: !ruby/object:Gem::Requirement
85
101
  requirements:
86
102
  - - ">="
87
103
  - !ruby/object:Gem::Version
104
+ segments:
105
+ - 0
88
106
  version: "0"
89
- version:
90
107
  requirements: []
91
108
 
92
109
  rubyforge_project: ruby-dbi
93
- rubygems_version: 1.3.1
110
+ rubygems_version: 1.3.6
94
111
  signing_key:
95
- specification_version: 2
112
+ specification_version: 3
96
113
  summary: PostgreSQL DBI DBD
97
114
  test_files:
98
115
  - test/ts_dbd.rb