sqlite3 1.7.3 → 2.5.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +292 -0
- data/CONTRIBUTING.md +33 -7
- data/FAQ.md +43 -77
- data/INSTALLATION.md +14 -6
- data/LICENSE +18 -22
- data/README.md +97 -9
- data/dependencies.yml +10 -11
- data/ext/sqlite3/aggregator.c +142 -145
- data/ext/sqlite3/aggregator.h +2 -4
- data/ext/sqlite3/backup.c +74 -65
- data/ext/sqlite3/backup.h +2 -2
- data/ext/sqlite3/database.c +621 -493
- data/ext/sqlite3/database.h +13 -4
- data/ext/sqlite3/exception.c +116 -92
- data/ext/sqlite3/exception.h +5 -1
- data/ext/sqlite3/extconf.rb +33 -24
- data/ext/sqlite3/sqlite3.c +176 -115
- data/ext/sqlite3/sqlite3_ruby.h +2 -2
- data/ext/sqlite3/statement.c +553 -300
- data/ext/sqlite3/statement.h +4 -3
- data/ext/sqlite3/timespec.h +20 -0
- data/lib/sqlite3/constants.rb +195 -47
- data/lib/sqlite3/database.rb +223 -187
- data/lib/sqlite3/errors.rb +54 -1
- data/lib/sqlite3/fork_safety.rb +66 -0
- data/lib/sqlite3/pragmas.rb +140 -136
- data/lib/sqlite3/resultset.rb +14 -97
- data/lib/sqlite3/statement.rb +58 -13
- data/lib/sqlite3/value.rb +17 -20
- data/lib/sqlite3/version.rb +2 -21
- data/lib/sqlite3/version_info.rb +17 -0
- data/lib/sqlite3.rb +8 -4
- data/ports/archives/sqlite-autoconf-3470200.tar.gz +0 -0
- metadata +9 -37
- data/API_CHANGES.md +0 -49
- data/ChangeLog.cvs +0 -88
- data/Gemfile +0 -10
- data/LICENSE-DEPENDENCIES +0 -20
- data/lib/sqlite3/translator.rb +0 -117
- data/ports/archives/sqlite-autoconf-3450200.tar.gz +0 -0
- data/test/helper.rb +0 -27
- data/test/test_backup.rb +0 -33
- data/test/test_collation.rb +0 -82
- data/test/test_database.rb +0 -668
- data/test/test_database_flags.rb +0 -95
- data/test/test_database_readonly.rb +0 -36
- data/test/test_database_readwrite.rb +0 -41
- data/test/test_deprecated.rb +0 -49
- data/test/test_encoding.rb +0 -165
- data/test/test_integration.rb +0 -507
- data/test/test_integration_aggregate.rb +0 -336
- data/test/test_integration_open_close.rb +0 -30
- data/test/test_integration_pending.rb +0 -115
- data/test/test_integration_resultset.rb +0 -142
- data/test/test_integration_statement.rb +0 -194
- data/test/test_pragmas.rb +0 -22
- data/test/test_result_set.rb +0 -47
- data/test/test_sqlite3.rb +0 -30
- data/test/test_statement.rb +0 -290
- data/test/test_statement_execute.rb +0 -39
data/lib/sqlite3/errors.rb
CHANGED
@@ -1,35 +1,88 @@
|
|
1
|
-
require
|
1
|
+
require "sqlite3/constants"
|
2
2
|
|
3
3
|
module SQLite3
|
4
4
|
class Exception < ::StandardError
|
5
5
|
# A convenience for accessing the error code for this exception.
|
6
6
|
attr_reader :code
|
7
|
+
|
8
|
+
# If the error is associated with a SQL query, this is the query
|
9
|
+
attr_reader :sql
|
10
|
+
|
11
|
+
# If the error is associated with a particular offset in a SQL query, this is the non-negative
|
12
|
+
# offset. If the offset is not available, this will be -1.
|
13
|
+
attr_reader :sql_offset
|
14
|
+
|
15
|
+
def message
|
16
|
+
[super, sql_error].compact.join(":\n")
|
17
|
+
end
|
18
|
+
|
19
|
+
private def sql_error
|
20
|
+
return nil unless @sql
|
21
|
+
return @sql.chomp unless @sql_offset >= 0
|
22
|
+
|
23
|
+
offset = @sql_offset
|
24
|
+
sql.lines.flat_map do |line|
|
25
|
+
if offset >= 0 && line.length > offset
|
26
|
+
blanks = " " * offset
|
27
|
+
offset = -1
|
28
|
+
[line.chomp, blanks + "^"]
|
29
|
+
else
|
30
|
+
offset -= line.length if offset
|
31
|
+
line.chomp
|
32
|
+
end
|
33
|
+
end.join("\n")
|
34
|
+
end
|
7
35
|
end
|
8
36
|
|
9
37
|
class SQLException < Exception; end
|
38
|
+
|
10
39
|
class InternalException < Exception; end
|
40
|
+
|
11
41
|
class PermissionException < Exception; end
|
42
|
+
|
12
43
|
class AbortException < Exception; end
|
44
|
+
|
13
45
|
class BusyException < Exception; end
|
46
|
+
|
14
47
|
class LockedException < Exception; end
|
48
|
+
|
15
49
|
class MemoryException < Exception; end
|
50
|
+
|
16
51
|
class ReadOnlyException < Exception; end
|
52
|
+
|
17
53
|
class InterruptException < Exception; end
|
54
|
+
|
18
55
|
class IOException < Exception; end
|
56
|
+
|
19
57
|
class CorruptException < Exception; end
|
58
|
+
|
20
59
|
class NotFoundException < Exception; end
|
60
|
+
|
21
61
|
class FullException < Exception; end
|
62
|
+
|
22
63
|
class CantOpenException < Exception; end
|
64
|
+
|
23
65
|
class ProtocolException < Exception; end
|
66
|
+
|
24
67
|
class EmptyException < Exception; end
|
68
|
+
|
25
69
|
class SchemaChangedException < Exception; end
|
70
|
+
|
26
71
|
class TooBigException < Exception; end
|
72
|
+
|
27
73
|
class ConstraintException < Exception; end
|
74
|
+
|
28
75
|
class MismatchException < Exception; end
|
76
|
+
|
29
77
|
class MisuseException < Exception; end
|
78
|
+
|
30
79
|
class UnsupportedException < Exception; end
|
80
|
+
|
31
81
|
class AuthorizationException < Exception; end
|
82
|
+
|
32
83
|
class FormatException < Exception; end
|
84
|
+
|
33
85
|
class RangeException < Exception; end
|
86
|
+
|
34
87
|
class NotADatabaseException < Exception; end
|
35
88
|
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "weakref"
|
4
|
+
|
5
|
+
module SQLite3
|
6
|
+
# based on Rails's active_support/fork_tracker.rb
|
7
|
+
module ForkSafety
|
8
|
+
module CoreExt # :nodoc:
|
9
|
+
def _fork
|
10
|
+
pid = super
|
11
|
+
if pid == 0
|
12
|
+
ForkSafety.discard
|
13
|
+
end
|
14
|
+
pid
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
@databases = []
|
19
|
+
@mutex = Mutex.new
|
20
|
+
@suppress = false
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def hook! # :nodoc:
|
24
|
+
::Process.singleton_class.prepend(CoreExt)
|
25
|
+
end
|
26
|
+
|
27
|
+
def track(database) # :nodoc:
|
28
|
+
@mutex.synchronize do
|
29
|
+
@databases << WeakRef.new(database)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def discard # :nodoc:
|
34
|
+
warned = @suppress
|
35
|
+
@databases.each do |db|
|
36
|
+
next unless db.weakref_alive?
|
37
|
+
|
38
|
+
begin
|
39
|
+
unless db.closed? || db.readonly?
|
40
|
+
unless warned
|
41
|
+
# If you are here, you may want to read
|
42
|
+
# https://github.com/sparklemotion/sqlite3-ruby/pull/558
|
43
|
+
warn("Writable sqlite database connection(s) were inherited from a forked process. " \
|
44
|
+
"This is unsafe and the connections are being closed to prevent possible data " \
|
45
|
+
"corruption. Please close writable sqlite database connections before forking.",
|
46
|
+
uplevel: 0)
|
47
|
+
warned = true
|
48
|
+
end
|
49
|
+
db.close
|
50
|
+
end
|
51
|
+
rescue WeakRef::RefError
|
52
|
+
# GC may run while this method is executing, and that's OK
|
53
|
+
end
|
54
|
+
end
|
55
|
+
@databases.clear
|
56
|
+
end
|
57
|
+
|
58
|
+
# Call to suppress the fork-related warnings.
|
59
|
+
def suppress_warnings!
|
60
|
+
@suppress = true
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
SQLite3::ForkSafety.hook!
|