sqlite3 1.5.0.rc1-x86_64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/API_CHANGES.md +49 -0
  4. data/CHANGELOG.md +419 -0
  5. data/CONTRIBUTING.md +24 -0
  6. data/ChangeLog.cvs +88 -0
  7. data/Gemfile +3 -0
  8. data/LICENSE +27 -0
  9. data/LICENSE-DEPENDENCIES +20 -0
  10. data/README.md +233 -0
  11. data/ext/sqlite3/aggregator.c +273 -0
  12. data/ext/sqlite3/aggregator.h +12 -0
  13. data/ext/sqlite3/backup.c +168 -0
  14. data/ext/sqlite3/backup.h +15 -0
  15. data/ext/sqlite3/database.c +853 -0
  16. data/ext/sqlite3/database.h +17 -0
  17. data/ext/sqlite3/exception.c +98 -0
  18. data/ext/sqlite3/exception.h +8 -0
  19. data/ext/sqlite3/extconf.rb +159 -0
  20. data/ext/sqlite3/sqlite3.c +163 -0
  21. data/ext/sqlite3/sqlite3_ruby.h +45 -0
  22. data/ext/sqlite3/statement.c +442 -0
  23. data/ext/sqlite3/statement.h +16 -0
  24. data/faq/faq.md +431 -0
  25. data/faq/faq.rb +145 -0
  26. data/faq/faq.yml +426 -0
  27. data/lib/sqlite3/2.6/sqlite3_native.bundle +0 -0
  28. data/lib/sqlite3/2.7/sqlite3_native.bundle +0 -0
  29. data/lib/sqlite3/3.0/sqlite3_native.bundle +0 -0
  30. data/lib/sqlite3/3.1/sqlite3_native.bundle +0 -0
  31. data/lib/sqlite3/constants.rb +50 -0
  32. data/lib/sqlite3/database.rb +741 -0
  33. data/lib/sqlite3/errors.rb +35 -0
  34. data/lib/sqlite3/pragmas.rb +595 -0
  35. data/lib/sqlite3/resultset.rb +187 -0
  36. data/lib/sqlite3/statement.rb +145 -0
  37. data/lib/sqlite3/translator.rb +118 -0
  38. data/lib/sqlite3/value.rb +57 -0
  39. data/lib/sqlite3/version.rb +25 -0
  40. data/lib/sqlite3.rb +15 -0
  41. data/test/helper.rb +27 -0
  42. data/test/test_backup.rb +33 -0
  43. data/test/test_collation.rb +82 -0
  44. data/test/test_database.rb +538 -0
  45. data/test/test_database_flags.rb +95 -0
  46. data/test/test_database_readonly.rb +36 -0
  47. data/test/test_database_readwrite.rb +41 -0
  48. data/test/test_deprecated.rb +44 -0
  49. data/test/test_encoding.rb +155 -0
  50. data/test/test_integration.rb +507 -0
  51. data/test/test_integration_aggregate.rb +336 -0
  52. data/test/test_integration_open_close.rb +30 -0
  53. data/test/test_integration_pending.rb +115 -0
  54. data/test/test_integration_resultset.rb +142 -0
  55. data/test/test_integration_statement.rb +194 -0
  56. data/test/test_result_set.rb +37 -0
  57. data/test/test_sqlite3.rb +25 -0
  58. data/test/test_statement.rb +263 -0
  59. data/test/test_statement_execute.rb +35 -0
  60. metadata +190 -0
@@ -0,0 +1,17 @@
1
+ #ifndef SQLITE3_DATABASE_RUBY
2
+ #define SQLITE3_DATABASE_RUBY
3
+
4
+ #include <sqlite3_ruby.h>
5
+
6
+ struct _sqlite3Ruby {
7
+ sqlite3 *db;
8
+ };
9
+
10
+ typedef struct _sqlite3Ruby sqlite3Ruby;
11
+ typedef sqlite3Ruby * sqlite3RubyPtr;
12
+
13
+ void init_sqlite3_database();
14
+ void set_sqlite3_func_result(sqlite3_context * ctx, VALUE result);
15
+ VALUE sqlite3val2rb(sqlite3_value * val);
16
+
17
+ #endif
@@ -0,0 +1,98 @@
1
+ #include <sqlite3_ruby.h>
2
+
3
+ void rb_sqlite3_raise(sqlite3 * db, int status)
4
+ {
5
+ VALUE klass = Qnil;
6
+
7
+ /* Consider only lower 8 bits, to work correctly when
8
+ extended result codes are enabled. */
9
+ switch(status & 0xff) {
10
+ case SQLITE_OK:
11
+ return;
12
+ break;
13
+ case SQLITE_ERROR:
14
+ klass = rb_path2class("SQLite3::SQLException");
15
+ break;
16
+ case SQLITE_INTERNAL:
17
+ klass = rb_path2class("SQLite3::InternalException");
18
+ break;
19
+ case SQLITE_PERM:
20
+ klass = rb_path2class("SQLite3::PermissionException");
21
+ break;
22
+ case SQLITE_ABORT:
23
+ klass = rb_path2class("SQLite3::AbortException");
24
+ break;
25
+ case SQLITE_BUSY:
26
+ klass = rb_path2class("SQLite3::BusyException");
27
+ break;
28
+ case SQLITE_LOCKED:
29
+ klass = rb_path2class("SQLite3::LockedException");
30
+ break;
31
+ case SQLITE_NOMEM:
32
+ klass = rb_path2class("SQLite3::MemoryException");
33
+ break;
34
+ case SQLITE_READONLY:
35
+ klass = rb_path2class("SQLite3::ReadOnlyException");
36
+ break;
37
+ case SQLITE_INTERRUPT:
38
+ klass = rb_path2class("SQLite3::InterruptException");
39
+ break;
40
+ case SQLITE_IOERR:
41
+ klass = rb_path2class("SQLite3::IOException");
42
+ break;
43
+ case SQLITE_CORRUPT:
44
+ klass = rb_path2class("SQLite3::CorruptException");
45
+ break;
46
+ case SQLITE_NOTFOUND:
47
+ klass = rb_path2class("SQLite3::NotFoundException");
48
+ break;
49
+ case SQLITE_FULL:
50
+ klass = rb_path2class("SQLite3::FullException");
51
+ break;
52
+ case SQLITE_CANTOPEN:
53
+ klass = rb_path2class("SQLite3::CantOpenException");
54
+ break;
55
+ case SQLITE_PROTOCOL:
56
+ klass = rb_path2class("SQLite3::ProtocolException");
57
+ break;
58
+ case SQLITE_EMPTY:
59
+ klass = rb_path2class("SQLite3::EmptyException");
60
+ break;
61
+ case SQLITE_SCHEMA:
62
+ klass = rb_path2class("SQLite3::SchemaChangedException");
63
+ break;
64
+ case SQLITE_TOOBIG:
65
+ klass = rb_path2class("SQLite3::TooBigException");
66
+ break;
67
+ case SQLITE_CONSTRAINT:
68
+ klass = rb_path2class("SQLite3::ConstraintException");
69
+ break;
70
+ case SQLITE_MISMATCH:
71
+ klass = rb_path2class("SQLite3::MismatchException");
72
+ break;
73
+ case SQLITE_MISUSE:
74
+ klass = rb_path2class("SQLite3::MisuseException");
75
+ break;
76
+ case SQLITE_NOLFS:
77
+ klass = rb_path2class("SQLite3::UnsupportedException");
78
+ break;
79
+ case SQLITE_AUTH:
80
+ klass = rb_path2class("SQLite3::AuthorizationException");
81
+ break;
82
+ case SQLITE_FORMAT:
83
+ klass = rb_path2class("SQLite3::FormatException");
84
+ break;
85
+ case SQLITE_RANGE:
86
+ klass = rb_path2class("SQLite3::RangeException");
87
+ break;
88
+ case SQLITE_NOTADB:
89
+ klass = rb_path2class("SQLite3::NotADatabaseException");
90
+ break;
91
+ default:
92
+ klass = rb_eRuntimeError;
93
+ }
94
+
95
+ klass = rb_exc_new2(klass, sqlite3_errmsg(db));
96
+ rb_iv_set(klass, "@code", INT2FIX(status));
97
+ rb_exc_raise(klass);
98
+ }
@@ -0,0 +1,8 @@
1
+ #ifndef SQLITE3_EXCEPTION_RUBY
2
+ #define SQLITE3_EXCEPTION_RUBY
3
+
4
+ #define CHECK(_db, _status) rb_sqlite3_raise(_db, _status);
5
+
6
+ void rb_sqlite3_raise(sqlite3 * db, int status);
7
+
8
+ #endif
@@ -0,0 +1,159 @@
1
+ require "mkmf"
2
+ require "mini_portile2"
3
+
4
+ module Sqlite3
5
+ module ExtConf
6
+ ENV_ALLOWLIST = ["CC", "CFLAGS", "LDFLAGS", "LIBS", "CPPFLAGS", "LT_SYS_LIBRARY_PATH", "CPP"]
7
+
8
+ class << self
9
+ def configure
10
+ configure_cross_compiler
11
+
12
+ if system_libraries?
13
+ message "Building sqlite3-ruby using system #{libname}.\n"
14
+ configure_system_libraries
15
+ else
16
+ message "Building sqlite3-ruby using packaged sqlite3.\n"
17
+ configure_packaged_libraries
18
+ end
19
+
20
+ configure_extension
21
+
22
+ create_makefile('sqlite3/sqlite3_native')
23
+ end
24
+
25
+ def configure_cross_compiler
26
+ RbConfig::CONFIG["CC"] = RbConfig::MAKEFILE_CONFIG["CC"] = ENV["CC"] if ENV["CC"]
27
+ ENV["CC"] = RbConfig::CONFIG["CC"]
28
+ end
29
+
30
+ def system_libraries?
31
+ sqlcipher? || enable_config("system-libraries")
32
+ end
33
+
34
+ def libname
35
+ sqlcipher? ? "sqlcipher" : "sqlite3"
36
+ end
37
+
38
+ def sqlcipher?
39
+ with_config("sqlcipher")
40
+ end
41
+
42
+ def configure_system_libraries
43
+ pkg_config(libname)
44
+ append_cflags("-DUSING_SQLCIPHER") if sqlcipher?
45
+ end
46
+
47
+ def configure_packaged_libraries
48
+ minimal_recipe.tap do |recipe|
49
+ recipe.configure_options += ["--enable-shared=no", "--enable-static=yes"]
50
+ ENV.to_h.tap do |env|
51
+ env["CFLAGS"] = [env["CFLAGS"], "-fPIC"].join(" ") # needed for linking the static library into a shared library
52
+ recipe.configure_options += env.select { |k,v| ENV_ALLOWLIST.include?(k) }
53
+ .map { |key, value| "#{key}=#{value.strip}" }
54
+ end
55
+
56
+ unless File.exist?(File.join(recipe.target, recipe.host, recipe.name, recipe.version))
57
+ recipe.cook
58
+ end
59
+ recipe.activate
60
+
61
+ ENV["PKG_CONFIG_ALLOW_SYSTEM_CFLAGS"] = "t" # on macos, pkg-config will not return --cflags without this
62
+ pcfile = File.join(recipe.path, "lib", "pkgconfig", "sqlite3.pc")
63
+ if pkg_config(pcfile)
64
+ # see https://bugs.ruby-lang.org/issues/18490
65
+ libs = xpopen(["pkg-config", "--libs", "--static", pcfile], err: [:child, :out], &:read)
66
+ libs.split.each { |lib| append_ldflags(lib) } if $?.success?
67
+ else
68
+ abort("\nCould not configure the build properly. Please install either the `pkg-config` utility or the `pkg-config` rubygem.\n\n")
69
+ end
70
+ end
71
+ end
72
+
73
+ def configure_extension
74
+ if Gem::Requirement.new("< 2.7").satisfied_by?(Gem::Version.new(RUBY_VERSION))
75
+ append_cflags("-DTAINTING_SUPPORT")
76
+ end
77
+
78
+ abort_could_not_find("sqlite3.h") unless find_header("sqlite3.h")
79
+ abort_could_not_find(libname) unless find_library(libname, "sqlite3_libversion_number", "sqlite3.h")
80
+
81
+ # Functions defined in 1.9 but not 1.8
82
+ have_func('rb_proc_arity')
83
+
84
+ # Functions defined in 2.1 but not 2.0
85
+ have_func('rb_integer_pack')
86
+
87
+ # These functions may not be defined
88
+ have_func('sqlite3_initialize')
89
+ have_func('sqlite3_backup_init')
90
+ have_func('sqlite3_column_database_name')
91
+ have_func('sqlite3_enable_load_extension')
92
+ have_func('sqlite3_load_extension')
93
+
94
+ unless have_func('sqlite3_open_v2') # https://www.sqlite.org/releaselog/3_5_0.html
95
+ abort("\nPlease use a version of SQLite3 >= 3.5.0\n\n")
96
+ end
97
+
98
+ have_func('sqlite3_prepare_v2')
99
+ have_type('sqlite3_int64', 'sqlite3.h')
100
+ have_type('sqlite3_uint64', 'sqlite3.h')
101
+ end
102
+
103
+ def minimal_recipe
104
+ MiniPortile.new(libname, sqlite3_config[:version]).tap do |recipe|
105
+ recipe.files = sqlite3_config[:files]
106
+ recipe.target = File.join(package_root_dir, "ports")
107
+ recipe.patch_files = Dir[File.join(package_root_dir, "patches", "*.patch")].sort
108
+ end
109
+ end
110
+
111
+ def package_root_dir
112
+ File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
113
+ end
114
+
115
+ def sqlite3_config
116
+ mini_portile_config[:sqlite3]
117
+ end
118
+
119
+ def mini_portile_config
120
+ {
121
+ sqlite3: {
122
+ # checksum verified by first checking the published sha3(256) checksum:
123
+ #
124
+ # $ sha3sum -a 256 sqlite-autoconf-3390000.tar.gz
125
+ # b8e5b3265992350d40c4ad31efc2e6dec6256813f1d5acc8f0ea805e9f33ca2a sqlite-autoconf-3390000.tar.gz
126
+ #
127
+ # $ sha256sum sqlite-autoconf-3390000.tar.gz
128
+ # e90bcaef6dd5813fcdee4e867f6b65f3c9bfd0aec0f1017f9f3bbce1e4ed09e2 sqlite-autoconf-3390000.tar.gz
129
+ #
130
+ version: "3.39.0",
131
+ files: [{
132
+ url: "https://www.sqlite.org/2022/sqlite-autoconf-3390000.tar.gz",
133
+ sha256: "e90bcaef6dd5813fcdee4e867f6b65f3c9bfd0aec0f1017f9f3bbce1e4ed09e2",
134
+ }],
135
+ }
136
+ }
137
+ end
138
+
139
+ def abort_could_not_find(missing)
140
+ abort("\nCould not find #{missing}.\nPlease visit https://github.com/sparklemotion/sqlite3-ruby for installation instructions.\n\n")
141
+ end
142
+
143
+ def cross_build?
144
+ enable_config("cross-build")
145
+ end
146
+
147
+ def download
148
+ minimal_recipe.download
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ if arg_config("--download-dependencies")
155
+ Sqlite3::ExtConf.download
156
+ exit!(0)
157
+ end
158
+
159
+ Sqlite3::ExtConf.configure
@@ -0,0 +1,163 @@
1
+ #include <sqlite3_ruby.h>
2
+
3
+ VALUE mSqlite3;
4
+ VALUE cSqlite3Blob;
5
+
6
+ int bignum_to_int64(VALUE value, sqlite3_int64 *result)
7
+ {
8
+ #ifdef HAVE_RB_INTEGER_PACK
9
+ const int nails = 0;
10
+ int t = rb_integer_pack(value, result, 1, sizeof(*result), nails,
11
+ INTEGER_PACK_NATIVE_BYTE_ORDER|
12
+ INTEGER_PACK_2COMP);
13
+ switch (t) {
14
+ case -2: case +2:
15
+ return 0;
16
+ case +1:
17
+ if (!nails) {
18
+ if (*result < 0) return 0;
19
+ }
20
+ break;
21
+ case -1:
22
+ if (!nails) {
23
+ if (*result >= 0) return 0;
24
+ }
25
+ else {
26
+ *result += INT64_MIN;
27
+ }
28
+ break;
29
+ }
30
+ return 1;
31
+ #else
32
+ # ifndef RBIGNUM_LEN
33
+ # define RBIGNUM_LEN(x) RBIGNUM(x)->len
34
+ # endif
35
+ const long len = RBIGNUM_LEN(value);
36
+ if (len == 0) {
37
+ *result = 0;
38
+ return 1;
39
+ }
40
+ if (len > 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) return 0;
41
+ if (len == 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) {
42
+ const BDIGIT *digits = RBIGNUM_DIGITS(value);
43
+ BDIGIT blast = digits[len-1];
44
+ BDIGIT bmax = (BDIGIT)1UL << (63 % (CHAR_BIT * SIZEOF_BDIGITS));
45
+ if (blast > bmax) return 0;
46
+ if (blast == bmax) {
47
+ if (RBIGNUM_POSITIVE_P(value)) {
48
+ return 0;
49
+ }
50
+ else {
51
+ long i = len-1;
52
+ while (i) {
53
+ if (digits[--i]) return 0;
54
+ }
55
+ }
56
+ }
57
+ }
58
+ *result = (sqlite3_int64)NUM2LL(value);
59
+ return 1;
60
+ #endif
61
+ }
62
+
63
+ static VALUE libversion(VALUE UNUSED(klass))
64
+ {
65
+ return INT2NUM(sqlite3_libversion_number());
66
+ }
67
+
68
+ static VALUE using_sqlcipher(VALUE UNUSED(klass))
69
+ {
70
+ #ifdef USING_SQLCIPHER
71
+ return Qtrue;
72
+ #else
73
+ return Qfalse;
74
+ #endif
75
+ }
76
+
77
+ /* Returns the compile time setting of the SQLITE_THREADSAFE flag.
78
+ * See: https://www.sqlite.org/c3ref/threadsafe.html
79
+ */
80
+ static VALUE threadsafe_p(VALUE UNUSED(klass))
81
+ {
82
+ return INT2NUM(sqlite3_threadsafe());
83
+ }
84
+
85
+ void init_sqlite3_constants()
86
+ {
87
+ VALUE mSqlite3Constants;
88
+ VALUE mSqlite3Open;
89
+
90
+ mSqlite3Constants = rb_define_module_under(mSqlite3, "Constants");
91
+
92
+ /* sqlite3_open_v2 flags for Database::new */
93
+ mSqlite3Open = rb_define_module_under(mSqlite3Constants, "Open");
94
+
95
+ /* symbols = IO.readlines('sqlite3.h').map { |n| /\A#define\s+(SQLITE_OPEN_\w+)\s/ =~ n && $1 }.compact
96
+ * pad = symbols.map(&:length).max - 9
97
+ * symbols.each { |s| printf %Q{ rb_define_const(mSqlite3Open, %-#{pad}s INT2FIX(#{s}));\n}, '"' + s[12..-1] + '",' }
98
+ */
99
+ rb_define_const(mSqlite3Open, "READONLY", INT2FIX(SQLITE_OPEN_READONLY));
100
+ rb_define_const(mSqlite3Open, "READWRITE", INT2FIX(SQLITE_OPEN_READWRITE));
101
+ rb_define_const(mSqlite3Open, "CREATE", INT2FIX(SQLITE_OPEN_CREATE));
102
+ rb_define_const(mSqlite3Open, "DELETEONCLOSE", INT2FIX(SQLITE_OPEN_DELETEONCLOSE));
103
+ rb_define_const(mSqlite3Open, "EXCLUSIVE", INT2FIX(SQLITE_OPEN_EXCLUSIVE));
104
+ rb_define_const(mSqlite3Open, "MAIN_DB", INT2FIX(SQLITE_OPEN_MAIN_DB));
105
+ rb_define_const(mSqlite3Open, "TEMP_DB", INT2FIX(SQLITE_OPEN_TEMP_DB));
106
+ rb_define_const(mSqlite3Open, "TRANSIENT_DB", INT2FIX(SQLITE_OPEN_TRANSIENT_DB));
107
+ rb_define_const(mSqlite3Open, "MAIN_JOURNAL", INT2FIX(SQLITE_OPEN_MAIN_JOURNAL));
108
+ rb_define_const(mSqlite3Open, "TEMP_JOURNAL", INT2FIX(SQLITE_OPEN_TEMP_JOURNAL));
109
+ rb_define_const(mSqlite3Open, "SUBJOURNAL", INT2FIX(SQLITE_OPEN_SUBJOURNAL));
110
+ rb_define_const(mSqlite3Open, "MASTER_JOURNAL", INT2FIX(SQLITE_OPEN_MASTER_JOURNAL));
111
+ rb_define_const(mSqlite3Open, "NOMUTEX", INT2FIX(SQLITE_OPEN_NOMUTEX));
112
+ rb_define_const(mSqlite3Open, "FULLMUTEX", INT2FIX(SQLITE_OPEN_FULLMUTEX));
113
+ #ifdef SQLITE_OPEN_AUTOPROXY
114
+ /* SQLITE_VERSION_NUMBER>=3007002 */
115
+ rb_define_const(mSqlite3Open, "AUTOPROXY", INT2FIX(SQLITE_OPEN_AUTOPROXY));
116
+ rb_define_const(mSqlite3Open, "SHAREDCACHE", INT2FIX(SQLITE_OPEN_SHAREDCACHE));
117
+ rb_define_const(mSqlite3Open, "PRIVATECACHE", INT2FIX(SQLITE_OPEN_PRIVATECACHE));
118
+ rb_define_const(mSqlite3Open, "WAL", INT2FIX(SQLITE_OPEN_WAL));
119
+ #endif
120
+ #ifdef SQLITE_OPEN_URI
121
+ /* SQLITE_VERSION_NUMBER>=3007007 */
122
+ rb_define_const(mSqlite3Open, "URI", INT2FIX(SQLITE_OPEN_URI));
123
+ #endif
124
+ #ifdef SQLITE_OPEN_MEMORY
125
+ /* SQLITE_VERSION_NUMBER>=3007013 */
126
+ rb_define_const(mSqlite3Open, "MEMORY", INT2FIX(SQLITE_OPEN_MEMORY));
127
+ #endif
128
+ }
129
+
130
+ void Init_sqlite3_native()
131
+ {
132
+ /*
133
+ * SQLite3 is a wrapper around the popular database
134
+ * sqlite[http://sqlite.org].
135
+ *
136
+ * For an example of usage, see SQLite3::Database.
137
+ */
138
+ mSqlite3 = rb_define_module("SQLite3");
139
+
140
+ /* A class for differentiating between strings and blobs, when binding them
141
+ * into statements.
142
+ */
143
+ cSqlite3Blob = rb_define_class_under(mSqlite3, "Blob", rb_cString);
144
+
145
+ /* Initialize the sqlite3 library */
146
+ #ifdef HAVE_SQLITE3_INITIALIZE
147
+ sqlite3_initialize();
148
+ #endif
149
+
150
+ init_sqlite3_constants();
151
+ init_sqlite3_database();
152
+ init_sqlite3_statement();
153
+ #ifdef HAVE_SQLITE3_BACKUP_INIT
154
+ init_sqlite3_backup();
155
+ #endif
156
+ rb_define_singleton_method(mSqlite3, "sqlcipher?", using_sqlcipher, 0);
157
+ rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
158
+ rb_define_singleton_method(mSqlite3, "threadsafe", threadsafe_p, 0);
159
+ rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
160
+ rb_define_const(mSqlite3, "SQLITE_VERSION_NUMBER", INT2FIX(SQLITE_VERSION_NUMBER));
161
+ rb_define_const(mSqlite3, "SQLITE_LOADED_VERSION", rb_str_new2(sqlite3_libversion()));
162
+
163
+ }
@@ -0,0 +1,45 @@
1
+ #ifndef SQLITE3_RUBY
2
+ #define SQLITE3_RUBY
3
+
4
+ #include <ruby.h>
5
+
6
+ #ifdef UNUSED
7
+ #elif defined(__GNUC__)
8
+ # define UNUSED(x) UNUSED_ ## x __attribute__((unused))
9
+ #elif defined(__LCLINT__)
10
+ # define UNUSED(x) /*@unused@*/ x
11
+ #else
12
+ # define UNUSED(x) x
13
+ #endif
14
+
15
+ #include <ruby/encoding.h>
16
+
17
+ #define USASCII_P(_obj) (rb_enc_get_index(_obj) == rb_usascii_encindex())
18
+ #define UTF8_P(_obj) (rb_enc_get_index(_obj) == rb_utf8_encindex())
19
+ #define UTF16_LE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16LE"))
20
+ #define UTF16_BE_P(_obj) (rb_enc_get_index(_obj) == rb_enc_find_index("UTF-16BE"))
21
+ #define SQLITE3_UTF8_STR_NEW2(_obj) \
22
+ (rb_enc_associate_index(rb_str_new2(_obj), rb_utf8_encindex()))
23
+
24
+
25
+ #include <sqlite3.h>
26
+
27
+ #ifndef HAVE_TYPE_SQLITE3_INT64
28
+ typedef sqlite_int64 sqlite3_int64;
29
+ #endif
30
+
31
+ #ifndef HAVE_TYPE_SQLITE3_UINT64
32
+ typedef sqlite_uint64 sqlite3_uint64;
33
+ #endif
34
+
35
+ extern VALUE mSqlite3;
36
+ extern VALUE cSqlite3Blob;
37
+
38
+ #include <database.h>
39
+ #include <statement.h>
40
+ #include <exception.h>
41
+ #include <backup.h>
42
+
43
+ int bignum_to_int64(VALUE big, sqlite3_int64 *result);
44
+
45
+ #endif