sqlite3 1.3.4-x86-mswin32-60 → 1.3.5-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +18 -0
- data/README.rdoc +2 -2
- data/ext/sqlite3/database.c +22 -0
- data/ext/sqlite3/extconf.rb +1 -1
- data/ext/sqlite3/statement.c +21 -3
- data/lib/sqlite3/1.8/sqlite3_native.so +0 -0
- data/lib/sqlite3/1.9/sqlite3_native.so +0 -0
- data/lib/sqlite3/database.rb +0 -8
- data/lib/sqlite3/version.rb +1 -1
- data/tasks/native.rake +2 -2
- data/tasks/vendor_sqlite3.rake +7 -0
- data/test/test_database.rb +18 -1
- data/test/test_encoding.rb +4 -2
- data/test/test_integration.rb +11 -0
- data/test/test_statement.rb +25 -0
- metadata +24 -11
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,21 @@
|
|
1
|
+
=== 1.3.5 / 2011-12-03 - ZOMG Holidays are here Edition!
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Windows: build against SQLite 3.7.9
|
5
|
+
* Static: enable SQLITE_ENABLE_COLUMN_METADATA
|
6
|
+
* Added Statement#clear_bindings! to set bindings back to nil
|
7
|
+
|
8
|
+
* Bugfixes
|
9
|
+
* Fixed a segv on Database.new. Fixes #34 (thanks nobu!)
|
10
|
+
* Database error is not reset, so don't check it in Statement#reset!
|
11
|
+
* Remove conditional around Bignum statement bindings.
|
12
|
+
Fixes #52. Fixes #56. Thank you Evgeny Myasishchev.
|
13
|
+
|
14
|
+
* Internal
|
15
|
+
* Use proper endianness when testing database connection with UTF-16.
|
16
|
+
Fixes #40. Fixes #51
|
17
|
+
* Use -fPIC for static compilation when host is x86_64.
|
18
|
+
|
1
19
|
=== 1.3.4 / 2011-07-25
|
2
20
|
|
3
21
|
* Enhancements:
|
data/README.rdoc
CHANGED
@@ -9,7 +9,7 @@ This module allows Ruby programs to interface with the SQLite3
|
|
9
9
|
database engine (http://www.sqlite.org). You must have the
|
10
10
|
SQLite engine installed in order to build this module.
|
11
11
|
|
12
|
-
Note that this module is
|
12
|
+
Note that this module is only compatible with SQLite 3.6.16 or newer.
|
13
13
|
|
14
14
|
== SYNOPSIS
|
15
15
|
|
@@ -42,7 +42,7 @@ Note that this module is NOT compatible with SQLite 2.x.
|
|
42
42
|
|
43
43
|
== Compilation and Installation
|
44
44
|
|
45
|
-
Install SQLite3, enabling option SQLITE_ENABLE_COLUMN_METADATA (see
|
45
|
+
Install SQLite3, enabling the option SQLITE_ENABLE_COLUMN_METADATA (see
|
46
46
|
www.sqlite.org/compile.html for details).
|
47
47
|
|
48
48
|
Then do the following:
|
data/ext/sqlite3/database.c
CHANGED
@@ -50,7 +50,14 @@ static VALUE initialize(int argc, VALUE *argv, VALUE self)
|
|
50
50
|
Data_Get_Struct(self, sqlite3Ruby, ctx);
|
51
51
|
|
52
52
|
rb_scan_args(argc, argv, "12", &file, &opts, &zvfs);
|
53
|
+
#if defined StringValueCStr
|
54
|
+
StringValuePtr(file);
|
55
|
+
rb_check_safe_obj(file);
|
56
|
+
#else
|
57
|
+
Check_SafeStr(file);
|
58
|
+
#endif
|
53
59
|
if(NIL_P(opts)) opts = rb_hash_new();
|
60
|
+
else Check_Type(opts, T_HASH);
|
54
61
|
|
55
62
|
#ifdef HAVE_RUBY_ENCODING_H
|
56
63
|
if(UTF16_LE_P(file)) {
|
@@ -716,6 +723,20 @@ static VALUE db_encoding(VALUE self)
|
|
716
723
|
return rb_iv_get(self, "@encoding");
|
717
724
|
}
|
718
725
|
|
726
|
+
/* call-seq: db.transaction_active?
|
727
|
+
*
|
728
|
+
* Returns +true+ if there is a transaction active, and +false+ otherwise.
|
729
|
+
*
|
730
|
+
*/
|
731
|
+
static VALUE transaction_active_p(VALUE self)
|
732
|
+
{
|
733
|
+
sqlite3RubyPtr ctx;
|
734
|
+
Data_Get_Struct(self, sqlite3Ruby, ctx);
|
735
|
+
REQUIRE_OPEN_DB(ctx);
|
736
|
+
|
737
|
+
return sqlite3_get_autocommit(ctx->db) ? Qfalse : Qtrue;
|
738
|
+
}
|
739
|
+
|
719
740
|
void init_sqlite3_database()
|
720
741
|
{
|
721
742
|
ID id_utf16, id_results_as_hash, id_type_translation;
|
@@ -742,6 +763,7 @@ void init_sqlite3_database()
|
|
742
763
|
rb_define_method(cSqlite3Database, "authorizer=", set_authorizer, 1);
|
743
764
|
rb_define_method(cSqlite3Database, "busy_handler", busy_handler, -1);
|
744
765
|
rb_define_method(cSqlite3Database, "busy_timeout=", set_busy_timeout, 1);
|
766
|
+
rb_define_method(cSqlite3Database, "transaction_active?", transaction_active_p, 0);
|
745
767
|
|
746
768
|
#ifdef HAVE_SQLITE3_LOAD_EXTENSION
|
747
769
|
rb_define_method(cSqlite3Database, "load_extension", load_extension, 1);
|
data/ext/sqlite3/extconf.rb
CHANGED
@@ -25,7 +25,7 @@ def asplode missing
|
|
25
25
|
else
|
26
26
|
abort <<-error
|
27
27
|
#{missing} is missing. Try 'port install sqlite3 +universal'
|
28
|
-
or 'yum install
|
28
|
+
or 'yum install sqlite-devel' and check your shared library search path (the
|
29
29
|
location where your sqlite3 shared library is located).
|
30
30
|
error
|
31
31
|
end
|
data/ext/sqlite3/statement.c
CHANGED
@@ -255,12 +255,10 @@ static VALUE bind_param(VALUE self, VALUE key, VALUE value)
|
|
255
255
|
}
|
256
256
|
break;
|
257
257
|
case T_BIGNUM:
|
258
|
-
#if SIZEOF_LONG < 8
|
259
258
|
if (RBIGNUM_LEN(value) * SIZEOF_BDIGITS <= 8) {
|
260
259
|
status = sqlite3_bind_int64(ctx->st, index, (sqlite3_int64)NUM2LL(value));
|
261
260
|
break;
|
262
261
|
}
|
263
|
-
#endif
|
264
262
|
case T_FLOAT:
|
265
263
|
status = sqlite3_bind_double(ctx->st, index, NUM2DBL(value));
|
266
264
|
break;
|
@@ -295,7 +293,26 @@ static VALUE reset_bang(VALUE self)
|
|
295
293
|
REQUIRE_OPEN_STMT(ctx);
|
296
294
|
|
297
295
|
status = sqlite3_reset(ctx->st);
|
298
|
-
|
296
|
+
|
297
|
+
ctx->done_p = 0;
|
298
|
+
|
299
|
+
return self;
|
300
|
+
}
|
301
|
+
|
302
|
+
/* call-seq: stmt.clear_bindings!
|
303
|
+
*
|
304
|
+
* Resets the statement. This is typically done internally, though it might
|
305
|
+
* occassionally be necessary to manually reset the statement.
|
306
|
+
*/
|
307
|
+
static VALUE clear_bindings(VALUE self)
|
308
|
+
{
|
309
|
+
sqlite3StmtRubyPtr ctx;
|
310
|
+
int status;
|
311
|
+
|
312
|
+
Data_Get_Struct(self, sqlite3StmtRuby, ctx);
|
313
|
+
REQUIRE_OPEN_STMT(ctx);
|
314
|
+
|
315
|
+
status = sqlite3_clear_bindings(ctx->st);
|
299
316
|
|
300
317
|
ctx->done_p = 0;
|
301
318
|
|
@@ -405,6 +422,7 @@ void init_sqlite3_statement()
|
|
405
422
|
rb_define_method(cSqlite3Statement, "closed?", closed_p, 0);
|
406
423
|
rb_define_method(cSqlite3Statement, "bind_param", bind_param, 2);
|
407
424
|
rb_define_method(cSqlite3Statement, "reset!", reset_bang, 0);
|
425
|
+
rb_define_method(cSqlite3Statement, "clear_bindings!", clear_bindings, 0);
|
408
426
|
rb_define_method(cSqlite3Statement, "step", step, 0);
|
409
427
|
rb_define_method(cSqlite3Statement, "done?", done_p, 0);
|
410
428
|
rb_define_method(cSqlite3Statement, "column_count", column_count, 0);
|
Binary file
|
Binary file
|
data/lib/sqlite3/database.rb
CHANGED
@@ -482,7 +482,6 @@ Support for this will be removed in version 2.0.0.
|
|
482
482
|
# #rollback.
|
483
483
|
def transaction( mode = :deferred )
|
484
484
|
execute "begin #{mode.to_s} transaction"
|
485
|
-
@transaction_active = true
|
486
485
|
|
487
486
|
if block_given?
|
488
487
|
abort = false
|
@@ -505,7 +504,6 @@ Support for this will be removed in version 2.0.0.
|
|
505
504
|
# <tt>abort? and rollback or commit</tt>.
|
506
505
|
def commit
|
507
506
|
execute "commit transaction"
|
508
|
-
@transaction_active = false
|
509
507
|
true
|
510
508
|
end
|
511
509
|
|
@@ -515,15 +513,9 @@ Support for this will be removed in version 2.0.0.
|
|
515
513
|
# <tt>abort? and rollback or commit</tt>.
|
516
514
|
def rollback
|
517
515
|
execute "rollback transaction"
|
518
|
-
@transaction_active = false
|
519
516
|
true
|
520
517
|
end
|
521
518
|
|
522
|
-
# Returns +true+ if there is a transaction active, and +false+ otherwise.
|
523
|
-
def transaction_active?
|
524
|
-
@transaction_active
|
525
|
-
end
|
526
|
-
|
527
519
|
# Returns +true+ if the database has been open in readonly mode
|
528
520
|
# A helper to check before performing any operation
|
529
521
|
def readonly?
|
data/lib/sqlite3/version.rb
CHANGED
data/tasks/native.rake
CHANGED
@@ -4,8 +4,8 @@ require 'rake/extensiontask'
|
|
4
4
|
# NOTE: version used by cross compilation of Windows native extension
|
5
5
|
# It do not affect compilation under other operating systems
|
6
6
|
# The version indicated is the minimum DLL suggested for correct functionality
|
7
|
-
BINARY_VERSION =
|
8
|
-
URL_VERSION
|
7
|
+
BINARY_VERSION = "3.7.9"
|
8
|
+
URL_VERSION = "3070900"
|
9
9
|
|
10
10
|
# build sqlite3_native C extension
|
11
11
|
Rake::ExtensionTask.new('sqlite3_native', HOE.spec) do |ext|
|
data/tasks/vendor_sqlite3.rake
CHANGED
@@ -16,6 +16,9 @@ namespace :ports do
|
|
16
16
|
checkpoint = "ports/.#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
17
17
|
|
18
18
|
unless File.exist?(checkpoint)
|
19
|
+
cflags = "-O2 -DSQLITE_ENABLE_COLUMN_METADATA"
|
20
|
+
cflags << " -fPIC" if recipe.host.include?("x86_64")
|
21
|
+
recipe.configure_options << "CFLAGS='#{cflags}'"
|
19
22
|
recipe.cook
|
20
23
|
touch checkpoint
|
21
24
|
end
|
@@ -28,6 +31,10 @@ if RUBY_PLATFORM =~ /mingw/
|
|
28
31
|
Rake::Task['compile'].prerequisites.unshift "ports:sqlite3"
|
29
32
|
end
|
30
33
|
|
34
|
+
if ENV["USE_MINI_PORTILE"] == "true"
|
35
|
+
Rake::Task["compile"].prerequisites.unshift "ports:sqlite3"
|
36
|
+
end
|
37
|
+
|
31
38
|
task :cross do
|
32
39
|
host = ENV.fetch("HOST", Rake::ExtensionCompiler.mingw_host)
|
33
40
|
$recipes.each do |_, recipe|
|
data/test/test_database.rb
CHANGED
@@ -2,10 +2,24 @@ require 'helper'
|
|
2
2
|
|
3
3
|
module SQLite3
|
4
4
|
class TestDatabase < Test::Unit::TestCase
|
5
|
+
attr_reader :db
|
6
|
+
|
5
7
|
def setup
|
6
8
|
@db = SQLite3::Database.new(':memory:')
|
7
9
|
end
|
8
10
|
|
11
|
+
def test_segv
|
12
|
+
assert_raises(TypeError) { SQLite3::Database.new 1 }
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_bignum
|
16
|
+
num = 4907021672125087844
|
17
|
+
db.execute 'CREATE TABLE "employees" ("token" integer(8), "name" varchar(20) NOT NULL)'
|
18
|
+
db.execute "INSERT INTO employees(name, token) VALUES('employee-1', ?)", [num]
|
19
|
+
rows = db.execute 'select token from employees'
|
20
|
+
assert_equal num, rows.first.first
|
21
|
+
end
|
22
|
+
|
9
23
|
def test_blob
|
10
24
|
@db.execute("CREATE TABLE blobs ( id INTEGER, hash BLOB(10) )")
|
11
25
|
str = "\0foo"
|
@@ -60,7 +74,10 @@ module SQLite3
|
|
60
74
|
end
|
61
75
|
|
62
76
|
def test_new_with_options
|
63
|
-
|
77
|
+
# determine if Ruby is running on Big Endian platform
|
78
|
+
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
79
|
+
|
80
|
+
db = SQLite3::Database.new(Iconv.conv(utf16, 'UTF-8', ':memory:'),
|
64
81
|
:utf16 => true)
|
65
82
|
assert db
|
66
83
|
end
|
data/test/test_encoding.rb
CHANGED
@@ -75,8 +75,10 @@ module SQLite3
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_db_with_utf16
|
78
|
-
|
79
|
-
|
78
|
+
utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
|
79
|
+
|
80
|
+
db = SQLite3::Database.new(':memory:'.encode(utf16))
|
81
|
+
assert_equal(Encoding.find(utf16), db.encoding)
|
80
82
|
end
|
81
83
|
|
82
84
|
def test_statement_eucjp
|
data/test/test_integration.rb
CHANGED
@@ -454,6 +454,17 @@ class TC_Database_Integration < Test::Unit::TestCase
|
|
454
454
|
assert !@db.transaction_active?
|
455
455
|
end
|
456
456
|
|
457
|
+
def test_transaction_implicit_rollback
|
458
|
+
assert !@db.transaction_active?
|
459
|
+
@db.transaction
|
460
|
+
@db.execute('create table bar (x CHECK(1 = 0))')
|
461
|
+
assert @db.transaction_active?
|
462
|
+
assert_raises( SQLite3::ConstraintException ) do
|
463
|
+
@db.execute("insert or rollback into bar (x) VALUES ('x')")
|
464
|
+
end
|
465
|
+
assert !@db.transaction_active?
|
466
|
+
end
|
467
|
+
|
457
468
|
def test_interrupt
|
458
469
|
@db.create_function( "abort", 1 ) do |func,x|
|
459
470
|
@db.interrupt
|
data/test/test_statement.rb
CHANGED
@@ -209,5 +209,30 @@ module SQLite3
|
|
209
209
|
stmt = @db.prepare('select :n, :h')
|
210
210
|
assert_equal [[10, nil]], stmt.execute('n' => 10, 'h' => nil).to_a
|
211
211
|
end
|
212
|
+
|
213
|
+
def test_with_error
|
214
|
+
@db.execute('CREATE TABLE "employees" ("name" varchar(20) NOT NULL CONSTRAINT "index_employees_on_name" UNIQUE)')
|
215
|
+
stmt = @db.prepare("INSERT INTO Employees(name) VALUES(?)")
|
216
|
+
stmt.execute('employee-1')
|
217
|
+
stmt.execute('employee-1') rescue SQLite3::ConstraintException
|
218
|
+
stmt.reset!
|
219
|
+
assert_nothing_raised(SQLite3::ConstraintException) {
|
220
|
+
stmt.execute('employee-2')
|
221
|
+
}
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_clear_bindings
|
225
|
+
stmt = @db.prepare('select ?, ?')
|
226
|
+
stmt.bind_param 1, "foo"
|
227
|
+
stmt.bind_param 2, "bar"
|
228
|
+
|
229
|
+
# We can't fetch bound parameters back out of sqlite3, so just call
|
230
|
+
# the clear_bindings! method and assert that nil is returned
|
231
|
+
stmt.clear_bindings!
|
232
|
+
|
233
|
+
while x = stmt.step
|
234
|
+
assert_equal [nil, nil], x
|
235
|
+
end
|
236
|
+
end
|
212
237
|
end
|
213
238
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sqlite3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 1.3.
|
9
|
+
- 5
|
10
|
+
version: 1.3.5
|
11
11
|
platform: x86-mswin32-60
|
12
12
|
authors:
|
13
13
|
- Jamis Buck
|
@@ -17,8 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
21
|
-
default_executable:
|
20
|
+
date: 2011-12-03 00:00:00 Z
|
22
21
|
dependencies:
|
23
22
|
- !ruby/object:Gem::Dependency
|
24
23
|
name: rake-compiler
|
@@ -60,19 +59,34 @@ dependencies:
|
|
60
59
|
requirements:
|
61
60
|
- - ~>
|
62
61
|
- !ruby/object:Gem::Version
|
63
|
-
hash:
|
62
|
+
hash: 27
|
64
63
|
segments:
|
65
64
|
- 2
|
66
|
-
-
|
67
|
-
version: "2.
|
65
|
+
- 12
|
66
|
+
version: "2.12"
|
68
67
|
type: :development
|
69
68
|
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 19
|
78
|
+
segments:
|
79
|
+
- 3
|
80
|
+
- 10
|
81
|
+
version: "3.10"
|
82
|
+
type: :development
|
83
|
+
version_requirements: *id004
|
70
84
|
description: |-
|
71
85
|
This module allows Ruby programs to interface with the SQLite3
|
72
86
|
database engine (http://www.sqlite.org). You must have the
|
73
87
|
SQLite engine installed in order to build this module.
|
74
88
|
|
75
|
-
Note that this module is
|
89
|
+
Note that this module is only compatible with SQLite 3.6.16 or newer.
|
76
90
|
email:
|
77
91
|
- jamis@37signals.com
|
78
92
|
- luislavena@gmail.com
|
@@ -145,7 +159,6 @@ files:
|
|
145
159
|
- .gemtest
|
146
160
|
- lib/sqlite3/1.8/sqlite3_native.so
|
147
161
|
- lib/sqlite3/1.9/sqlite3_native.so
|
148
|
-
has_rdoc: true
|
149
162
|
homepage: http://github.com/luislavena/sqlite3-ruby
|
150
163
|
licenses: []
|
151
164
|
|
@@ -180,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
193
|
requirements: []
|
181
194
|
|
182
195
|
rubyforge_project: sqlite3
|
183
|
-
rubygems_version: 1.
|
196
|
+
rubygems_version: 1.8.12
|
184
197
|
signing_key:
|
185
198
|
specification_version: 3
|
186
199
|
summary: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org)
|