sqlite3 1.6.3 → 2.10.2

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +615 -1
  3. data/CONTRIBUTING.md +103 -6
  4. data/{faq/faq.md → FAQ.md} +66 -79
  5. data/INSTALLATION.md +267 -0
  6. data/LICENSE +18 -22
  7. data/README.md +87 -124
  8. data/dependencies.yml +10 -11
  9. data/ext/sqlite3/aggregator.c +178 -178
  10. data/ext/sqlite3/aggregator.h +7 -4
  11. data/ext/sqlite3/backup.c +92 -65
  12. data/ext/sqlite3/backup.h +2 -2
  13. data/ext/sqlite3/database.c +964 -477
  14. data/ext/sqlite3/database.h +26 -4
  15. data/ext/sqlite3/exception.c +213 -94
  16. data/ext/sqlite3/exception.h +26 -1
  17. data/ext/sqlite3/extconf.rb +59 -29
  18. data/ext/sqlite3/sqlite3.c +190 -115
  19. data/ext/sqlite3/sqlite3_ruby.h +5 -2
  20. data/ext/sqlite3/statement.c +672 -297
  21. data/ext/sqlite3/statement.h +4 -3
  22. data/ext/sqlite3/timespec.h +29 -0
  23. data/lib/sqlite3/constants.rb +195 -47
  24. data/lib/sqlite3/database.rb +272 -225
  25. data/lib/sqlite3/errors.rb +54 -1
  26. data/lib/sqlite3/fork_safety.rb +66 -0
  27. data/lib/sqlite3/pragmas.rb +194 -141
  28. data/lib/sqlite3/resultset.rb +30 -111
  29. data/lib/sqlite3/statement.rb +105 -25
  30. data/lib/sqlite3/value.rb +17 -20
  31. data/lib/sqlite3/version.rb +2 -21
  32. data/lib/sqlite3/version_info.rb +17 -0
  33. data/lib/sqlite3.rb +8 -4
  34. data/ports/archives/sqlite-autoconf-3540100.tar.gz +0 -0
  35. metadata +16 -48
  36. data/API_CHANGES.md +0 -49
  37. data/ChangeLog.cvs +0 -88
  38. data/Gemfile +0 -11
  39. data/LICENSE-DEPENDENCIES +0 -20
  40. data/faq/faq.rb +0 -145
  41. data/faq/faq.yml +0 -426
  42. data/lib/sqlite3/translator.rb +0 -118
  43. data/ports/archives/sqlite-autoconf-3420000.tar.gz +0 -0
  44. data/test/helper.rb +0 -27
  45. data/test/test_backup.rb +0 -33
  46. data/test/test_collation.rb +0 -82
  47. data/test/test_database.rb +0 -569
  48. data/test/test_database_flags.rb +0 -95
  49. data/test/test_database_readonly.rb +0 -36
  50. data/test/test_database_readwrite.rb +0 -41
  51. data/test/test_deprecated.rb +0 -49
  52. data/test/test_encoding.rb +0 -165
  53. data/test/test_integration.rb +0 -507
  54. data/test/test_integration_aggregate.rb +0 -336
  55. data/test/test_integration_open_close.rb +0 -30
  56. data/test/test_integration_pending.rb +0 -115
  57. data/test/test_integration_resultset.rb +0 -142
  58. data/test/test_integration_statement.rb +0 -194
  59. data/test/test_pragmas.rb +0 -22
  60. data/test/test_result_set.rb +0 -47
  61. data/test/test_sqlite3.rb +0 -30
  62. data/test/test_statement.rb +0 -288
  63. data/test/test_statement_execute.rb +0 -39
@@ -1,41 +0,0 @@
1
- require 'helper'
2
-
3
- module SQLite3
4
- class TestDatabaseReadwrite < SQLite3::TestCase
5
- def setup
6
- File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
7
- @db = SQLite3::Database.new('test-readwrite.db')
8
- @db.execute("CREATE TABLE foos (id integer)")
9
- @db.close
10
- end
11
-
12
- def teardown
13
- @db.close unless @db.closed?
14
- File.unlink 'test-readwrite.db' if File.exist?('test-readwrite.db')
15
- end
16
-
17
- def test_open_readwrite_database
18
- @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
19
- assert !@db.readonly?
20
- end
21
-
22
- def test_open_readwrite_readonly_database
23
- assert_raise(RuntimeError) do
24
- @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true, :readonly => true)
25
- end
26
- end
27
-
28
- def test_open_readwrite_not_exists_database
29
- File.unlink 'test-readwrite.db'
30
- assert_raise(SQLite3::CantOpenException) do
31
- @db = SQLite3::Database.new('test-readwrite.db', :readonly => true)
32
- end
33
- end
34
-
35
- def test_insert_readwrite_database
36
- @db = SQLite3::Database.new('test-readwrite.db', :readwrite => true)
37
- @db.execute("INSERT INTO foos (id) VALUES (12)")
38
- assert @db.changes == 1
39
- end
40
- end
41
- end
@@ -1,49 +0,0 @@
1
- require 'helper'
2
-
3
- module SQLite3
4
- class TestDeprecated < SQLite3::TestCase
5
- def setup
6
- super
7
- @warn_before = $-w
8
- $-w = false
9
- @db = SQLite3::Database.new(':memory:')
10
- @db.execute 'CREATE TABLE test_table (name text, age int)'
11
- end
12
-
13
- def teardown
14
- super
15
- $-w = @warn_before
16
- @db.close
17
- end
18
-
19
- def test_query_with_many_bind_params_not_nil
20
- rs = @db.query('select ?, ?', 1, 2)
21
- assert_equal [[1, 2]], rs.to_a
22
- rs.close
23
- end
24
-
25
- def test_execute_with_many_bind_params_not_nil
26
- assert_equal [[1, 2]], @db.execute("select ?, ?", 1, 2).to_a
27
- end
28
-
29
- def test_query_with_many_bind_params
30
- rs = @db.query("select ?, ?", nil, 1)
31
- assert_equal [[nil, 1]], rs.to_a
32
- rs.close
33
- end
34
-
35
- def test_query_with_nil_bind_params
36
- rs = @db.query("select 'foo'", nil)
37
- assert_equal [['foo']], rs.to_a
38
- rs.close
39
- end
40
-
41
- def test_execute_with_many_bind_params
42
- assert_equal [[nil, 1]], @db.execute("select ?, ?", nil, 1)
43
- end
44
-
45
- def test_execute_with_nil_bind_params
46
- assert_equal [['foo']], @db.execute("select 'foo'", nil)
47
- end
48
- end
49
- end
@@ -1,165 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- require 'helper'
4
-
5
- module SQLite3
6
- class TestEncoding < SQLite3::TestCase
7
- def setup
8
- @db = SQLite3::Database.new(':memory:')
9
- @create = "create table ex(id int, data string)"
10
- @insert = "insert into ex(id, data) values (?, ?)"
11
- @db.execute(@create);
12
- end
13
-
14
- def teardown
15
- @db.close
16
- end
17
-
18
- def test_select_encoding_on_utf_16
19
- str = "foo"
20
- utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
21
- db = SQLite3::Database.new(':memory:'.encode(utf16))
22
- db.execute @create
23
- db.execute "insert into ex (id, data) values (1, \"#{str}\")"
24
-
25
- stmt = db.prepare 'select * from ex where data = ?'
26
- ['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each do |enc|
27
- stmt.bind_param 1, str.encode(enc)
28
- assert_equal 1, stmt.to_a.length
29
- stmt.reset!
30
- end
31
- stmt.close
32
- end
33
-
34
- def test_insert_encoding
35
- str = "foo"
36
- utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
37
- db = SQLite3::Database.new(':memory:'.encode(utf16))
38
- db.execute @create
39
- stmt = db.prepare @insert
40
-
41
- ['US-ASCII', utf16, 'EUC-JP', 'UTF-8'].each_with_index do |enc,i|
42
- stmt.bind_param 1, i
43
- stmt.bind_param 2, str.encode(enc)
44
- stmt.to_a
45
- stmt.reset!
46
- end
47
- stmt.close
48
-
49
- db.execute('select data from ex').flatten.each do |s|
50
- assert_equal str, s
51
- end
52
- end
53
-
54
- def test_default_internal_is_honored
55
- warn_before = $-w
56
- $-w = false
57
-
58
- before_enc = Encoding.default_internal
59
-
60
- str = "壁に耳あり、障子に目あり"
61
- stmt = @db.prepare('insert into ex(data) values (?)')
62
- stmt.bind_param 1, str
63
- stmt.step
64
- stmt.close
65
-
66
- Encoding.default_internal = 'EUC-JP'
67
- string = @db.execute('select data from ex').first.first
68
-
69
- assert_equal Encoding.default_internal, string.encoding
70
- assert_equal str.encode('EUC-JP'), string
71
- assert_equal str, string.encode(str.encoding)
72
- ensure
73
- Encoding.default_internal = before_enc
74
- $-w = warn_before
75
- end
76
-
77
- def test_blob_is_binary
78
- str = "猫舌"
79
- @db.execute('create table foo(data text)')
80
- stmt = @db.prepare('insert into foo(data) values (?)')
81
- stmt.bind_param(1, SQLite3::Blob.new(str))
82
- stmt.step
83
- stmt.close
84
-
85
- string = @db.execute('select data from foo').first.first
86
- assert_equal Encoding.find('ASCII-8BIT'), string.encoding
87
- assert_equal str, string.force_encoding('UTF-8')
88
- end
89
-
90
- def test_blob_is_ascii8bit
91
- str = "猫舌"
92
- @db.execute('create table foo(data text)')
93
- stmt = @db.prepare('insert into foo(data) values (?)')
94
- stmt.bind_param(1, str.dup.force_encoding("ASCII-8BIT"))
95
- stmt.step
96
- stmt.close
97
-
98
- string = @db.execute('select data from foo').first.first
99
- assert_equal Encoding.find('ASCII-8BIT'), string.encoding
100
- assert_equal str, string.force_encoding('UTF-8')
101
- end
102
-
103
- def test_blob_with_eucjp
104
- str = "猫舌".encode("EUC-JP")
105
- @db.execute('create table foo(data text)')
106
- stmt = @db.prepare('insert into foo(data) values (?)')
107
- stmt.bind_param(1, SQLite3::Blob.new(str))
108
- stmt.step
109
- stmt.close
110
-
111
- string = @db.execute('select data from foo').first.first
112
- assert_equal Encoding.find('ASCII-8BIT'), string.encoding
113
- assert_equal str, string.force_encoding('EUC-JP')
114
- end
115
-
116
- def test_db_with_eucjp
117
- db = SQLite3::Database.new(':memory:'.encode('EUC-JP'))
118
- assert_equal(Encoding.find('UTF-8'), db.encoding)
119
- end
120
-
121
- def test_db_with_utf16
122
- utf16 = ([1].pack("I") == [1].pack("N")) ? "UTF-16BE" : "UTF-16LE"
123
-
124
- db = SQLite3::Database.new(':memory:'.encode(utf16))
125
- assert_equal(Encoding.find(utf16), db.encoding)
126
- end
127
-
128
- def test_statement_eucjp
129
- str = "猫舌"
130
- @db.execute("insert into ex(data) values ('#{str}')".encode('EUC-JP'))
131
- row = @db.execute("select data from ex")
132
- assert_equal @db.encoding, row.first.first.encoding
133
- assert_equal str, row.first.first
134
- end
135
-
136
- def test_statement_utf8
137
- str = "猫舌"
138
- @db.execute("insert into ex(data) values ('#{str}')")
139
- row = @db.execute("select data from ex")
140
- assert_equal @db.encoding, row.first.first.encoding
141
- assert_equal str, row.first.first
142
- end
143
-
144
- def test_encoding
145
- assert_equal Encoding.find("UTF-8"), @db.encoding
146
- end
147
-
148
- def test_utf_8
149
- str = "猫舌"
150
- @db.execute(@insert, [10, str])
151
- row = @db.execute("select data from ex")
152
- assert_equal @db.encoding, row.first.first.encoding
153
- assert_equal str, row.first.first
154
- end
155
-
156
- def test_euc_jp
157
- str = "猫舌".encode('EUC-JP')
158
- @db.execute(@insert, [10, str])
159
- row = @db.execute("select data from ex")
160
- assert_equal @db.encoding, row.first.first.encoding
161
- assert_equal str.encode('UTF-8'), row.first.first
162
- end
163
-
164
- end if RUBY_VERSION >= '1.9.1'
165
- end