aim-sqlite3 2.9.6.1-aarch64-linux-gnu

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 (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gemtest +0 -0
  3. data/CHANGELOG.md +1062 -0
  4. data/CONTRIBUTING.md +130 -0
  5. data/FAQ.md +399 -0
  6. data/INSTALLATION.md +267 -0
  7. data/LICENSE +23 -0
  8. data/README.md +222 -0
  9. data/dependencies.yml +13 -0
  10. data/ext/sqlite3/aggregator.c +314 -0
  11. data/ext/sqlite3/aggregator.h +14 -0
  12. data/ext/sqlite3/backup.c +190 -0
  13. data/ext/sqlite3/backup.h +15 -0
  14. data/ext/sqlite3/database.c +1274 -0
  15. data/ext/sqlite3/database.h +36 -0
  16. data/ext/sqlite3/exception.c +122 -0
  17. data/ext/sqlite3/exception.h +12 -0
  18. data/ext/sqlite3/extconf.rb +299 -0
  19. data/ext/sqlite3/gvl.c +154 -0
  20. data/ext/sqlite3/gvl.h +16 -0
  21. data/ext/sqlite3/sqlite3.c +225 -0
  22. data/ext/sqlite3/sqlite3_ruby.h +49 -0
  23. data/ext/sqlite3/statement.c +755 -0
  24. data/ext/sqlite3/statement.h +17 -0
  25. data/ext/sqlite3/timespec.h +20 -0
  26. data/lib/sqlite3/3.2/sqlite3_native.so +0 -0
  27. data/lib/sqlite3/3.3/sqlite3_native.so +0 -0
  28. data/lib/sqlite3/3.4/sqlite3_native.so +0 -0
  29. data/lib/sqlite3/4.0/sqlite3_native.so +0 -0
  30. data/lib/sqlite3/aim_version.rb +5 -0
  31. data/lib/sqlite3/cli.rb +8 -0
  32. data/lib/sqlite3/constants.rb +198 -0
  33. data/lib/sqlite3/database.rb +798 -0
  34. data/lib/sqlite3/errors.rb +88 -0
  35. data/lib/sqlite3/fork_safety.rb +66 -0
  36. data/lib/sqlite3/pragmas.rb +648 -0
  37. data/lib/sqlite3/resultset.rb +96 -0
  38. data/lib/sqlite3/statement.rb +208 -0
  39. data/lib/sqlite3/value.rb +54 -0
  40. data/lib/sqlite3/version.rb +4 -0
  41. data/lib/sqlite3/version_info.rb +17 -0
  42. data/lib/sqlite3.rb +21 -0
  43. data/ports/aarch64-linux-gnu/sqlite3/3.53.2/bin/sqlite3 +0 -0
  44. metadata +106 -0
@@ -0,0 +1,225 @@
1
+ #include <sqlite3_ruby.h>
2
+
3
+ VALUE mSqlite3;
4
+ VALUE cSqlite3Blob;
5
+
6
+ int
7
+ bignum_to_int64(VALUE value, sqlite3_int64 *result)
8
+ {
9
+ #ifdef HAVE_RB_INTEGER_PACK
10
+ const int nails = 0;
11
+ int t = rb_integer_pack(value, result, 1, sizeof(*result), nails,
12
+ INTEGER_PACK_NATIVE_BYTE_ORDER |
13
+ INTEGER_PACK_2COMP);
14
+ switch (t) {
15
+ case -2:
16
+ case +2:
17
+ return 0;
18
+ case +1:
19
+ if (!nails) {
20
+ if (*result < 0) { return 0; }
21
+ }
22
+ break;
23
+ case -1:
24
+ if (!nails) {
25
+ if (*result >= 0) { return 0; }
26
+ } else {
27
+ *result += INT64_MIN;
28
+ }
29
+ break;
30
+ }
31
+ return 1;
32
+ #else
33
+ # ifndef RBIGNUM_LEN
34
+ # define RBIGNUM_LEN(x) RBIGNUM(x)->len
35
+ # endif
36
+ const long len = RBIGNUM_LEN(value);
37
+ if (len == 0) {
38
+ *result = 0;
39
+ return 1;
40
+ }
41
+ if (len > 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) { return 0; }
42
+ if (len == 63 / (SIZEOF_BDIGITS * CHAR_BIT) + 1) {
43
+ const BDIGIT *digits = RBIGNUM_DIGITS(value);
44
+ BDIGIT blast = digits[len - 1];
45
+ BDIGIT bmax = (BDIGIT)1UL << (63 % (CHAR_BIT * SIZEOF_BDIGITS));
46
+ if (blast > bmax) { return 0; }
47
+ if (blast == bmax) {
48
+ if (RBIGNUM_POSITIVE_P(value)) {
49
+ return 0;
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
64
+ libversion(VALUE UNUSED(klass))
65
+ {
66
+ return INT2NUM(sqlite3_libversion_number());
67
+ }
68
+
69
+ static VALUE
70
+ using_sqlcipher(VALUE UNUSED(klass))
71
+ {
72
+ #ifdef USING_SQLCIPHER
73
+ return Qtrue;
74
+ #else
75
+ return Qfalse;
76
+ #endif
77
+ }
78
+
79
+ /* Returns the compile time setting of the SQLITE_THREADSAFE flag.
80
+ * See: https://www.sqlite.org/c3ref/threadsafe.html
81
+ */
82
+ static VALUE
83
+ threadsafe_p(VALUE UNUSED(klass))
84
+ {
85
+ return INT2NUM(sqlite3_threadsafe());
86
+ }
87
+
88
+ /*
89
+ * call-seq:
90
+ * status(parameter) → Hash
91
+ * status(parameter, reset_flag = false) → Hash
92
+ *
93
+ * Queries the SQLite3 library for run-time status information. Passing a truthy +reset_flag+ will
94
+ * reset the highwater mark to the current value.
95
+ *
96
+ * [Parameters]
97
+ * - +parameter+ (Integer, SQLite3::Constants::Status): The status parameter to query.
98
+ * - +reset_flag+ (Boolean): Whether to reset the highwater mark. (default is +false+)
99
+ *
100
+ * [Returns]
101
+ * A Hash containing +:current+ and +:highwater+ keys for integer values.
102
+ */
103
+ static VALUE
104
+ rb_sqlite3_status(int argc, VALUE *argv, VALUE klass)
105
+ {
106
+ VALUE opArg, resetFlagArg;
107
+
108
+ rb_scan_args(argc, argv, "11", &opArg, &resetFlagArg);
109
+
110
+ int op = NUM2INT(opArg);
111
+ bool resetFlag = RTEST(resetFlagArg);
112
+
113
+ int pCurrent = 0;
114
+ int pHighwater = 0;
115
+ sqlite3_status(op, &pCurrent, &pHighwater, resetFlag);
116
+
117
+ VALUE hash = rb_hash_new();
118
+ rb_hash_aset(hash, ID2SYM(rb_intern("current")), INT2FIX(pCurrent));
119
+ rb_hash_aset(hash, ID2SYM(rb_intern("highwater")), INT2FIX(pHighwater));
120
+
121
+ return hash;
122
+ }
123
+
124
+ void
125
+ init_sqlite3_constants(void)
126
+ {
127
+ VALUE mSqlite3Constants;
128
+ VALUE mSqlite3Open;
129
+
130
+ mSqlite3Constants = rb_define_module_under(mSqlite3, "Constants");
131
+
132
+ /* sqlite3_open_v2 flags for Database::new */
133
+ mSqlite3Open = rb_define_module_under(mSqlite3Constants, "Open");
134
+
135
+ /* symbols = IO.readlines('sqlite3.h').map { |n| /\A#define\s+(SQLITE_OPEN_\w+)\s/ =~ n && $1 }.compact
136
+ * pad = symbols.map(&:length).max - 9
137
+ * symbols.each { |s| printf %Q{ rb_define_const(mSqlite3Open, %-#{pad}s INT2FIX(#{s}));\n}, '"' + s[12..-1] + '",' }
138
+ */
139
+ rb_define_const(mSqlite3Open, "READONLY", INT2FIX(SQLITE_OPEN_READONLY));
140
+ rb_define_const(mSqlite3Open, "READWRITE", INT2FIX(SQLITE_OPEN_READWRITE));
141
+ rb_define_const(mSqlite3Open, "CREATE", INT2FIX(SQLITE_OPEN_CREATE));
142
+ rb_define_const(mSqlite3Open, "DELETEONCLOSE", INT2FIX(SQLITE_OPEN_DELETEONCLOSE));
143
+ rb_define_const(mSqlite3Open, "EXCLUSIVE", INT2FIX(SQLITE_OPEN_EXCLUSIVE));
144
+ rb_define_const(mSqlite3Open, "MAIN_DB", INT2FIX(SQLITE_OPEN_MAIN_DB));
145
+ rb_define_const(mSqlite3Open, "TEMP_DB", INT2FIX(SQLITE_OPEN_TEMP_DB));
146
+ rb_define_const(mSqlite3Open, "TRANSIENT_DB", INT2FIX(SQLITE_OPEN_TRANSIENT_DB));
147
+ rb_define_const(mSqlite3Open, "MAIN_JOURNAL", INT2FIX(SQLITE_OPEN_MAIN_JOURNAL));
148
+ rb_define_const(mSqlite3Open, "TEMP_JOURNAL", INT2FIX(SQLITE_OPEN_TEMP_JOURNAL));
149
+ rb_define_const(mSqlite3Open, "SUBJOURNAL", INT2FIX(SQLITE_OPEN_SUBJOURNAL));
150
+ rb_define_const(mSqlite3Open, "MASTER_JOURNAL",
151
+ INT2FIX(SQLITE_OPEN_MASTER_JOURNAL)); /* pre-3.33.0 */
152
+ rb_define_const(mSqlite3Open, "SUPER_JOURNAL", INT2FIX(SQLITE_OPEN_MASTER_JOURNAL));
153
+ rb_define_const(mSqlite3Open, "NOMUTEX", INT2FIX(SQLITE_OPEN_NOMUTEX));
154
+ rb_define_const(mSqlite3Open, "FULLMUTEX", INT2FIX(SQLITE_OPEN_FULLMUTEX));
155
+ #ifdef SQLITE_OPEN_AUTOPROXY
156
+ /* SQLITE_VERSION_NUMBER>=3007002 */
157
+ rb_define_const(mSqlite3Open, "AUTOPROXY", INT2FIX(SQLITE_OPEN_AUTOPROXY));
158
+ rb_define_const(mSqlite3Open, "SHAREDCACHE", INT2FIX(SQLITE_OPEN_SHAREDCACHE));
159
+ rb_define_const(mSqlite3Open, "PRIVATECACHE", INT2FIX(SQLITE_OPEN_PRIVATECACHE));
160
+ rb_define_const(mSqlite3Open, "WAL", INT2FIX(SQLITE_OPEN_WAL));
161
+ #endif
162
+ #ifdef SQLITE_OPEN_URI
163
+ /* SQLITE_VERSION_NUMBER>=3007007 */
164
+ rb_define_const(mSqlite3Open, "URI", INT2FIX(SQLITE_OPEN_URI));
165
+ #endif
166
+ #ifdef SQLITE_OPEN_MEMORY
167
+ /* SQLITE_VERSION_NUMBER>=3007013 */
168
+ rb_define_const(mSqlite3Open, "MEMORY", INT2FIX(SQLITE_OPEN_MEMORY));
169
+ #endif
170
+ }
171
+
172
+ RUBY_FUNC_EXPORTED
173
+ void
174
+ Init_sqlite3_native(void)
175
+ {
176
+ /*
177
+ * SQLite3 is a wrapper around the popular database
178
+ * sqlite[http://sqlite.org].
179
+ *
180
+ * For an example of usage, see SQLite3::Database.
181
+ */
182
+ mSqlite3 = rb_define_module("SQLite3");
183
+
184
+ /* A class for differentiating between strings and blobs, when binding them
185
+ * into statements.
186
+ */
187
+ cSqlite3Blob = rb_define_class_under(mSqlite3, "Blob", rb_cString);
188
+
189
+ /* Initialize the sqlite3 library */
190
+ #ifdef HAVE_SQLITE3_INITIALIZE
191
+ sqlite3_initialize();
192
+ #endif
193
+
194
+ init_sqlite3_constants();
195
+ init_sqlite3_database();
196
+ init_sqlite3_statement();
197
+ #ifdef HAVE_SQLITE3_BACKUP_INIT
198
+ init_sqlite3_backup();
199
+ #endif
200
+ rb_define_singleton_method(mSqlite3, "sqlcipher?", using_sqlcipher, 0);
201
+ rb_define_singleton_method(mSqlite3, "libversion", libversion, 0);
202
+ rb_define_singleton_method(mSqlite3, "threadsafe", threadsafe_p, 0);
203
+ rb_define_singleton_method(mSqlite3, "status", rb_sqlite3_status, -1);
204
+
205
+ /* (String) The version of the sqlite3 library compiled with (e.g., "3.46.1") */
206
+ rb_define_const(mSqlite3, "SQLITE_VERSION", rb_str_new2(SQLITE_VERSION));
207
+
208
+ /* (Integer) The version of the sqlite3 library compiled with (e.g., 346001) */
209
+ rb_define_const(mSqlite3, "SQLITE_VERSION_NUMBER", INT2FIX(SQLITE_VERSION_NUMBER));
210
+
211
+ /* (String) The version of the sqlite3 library loaded at runtime (e.g., "3.46.1") */
212
+ rb_define_const(mSqlite3, "SQLITE_LOADED_VERSION", rb_str_new2(sqlite3_libversion()));
213
+
214
+ #ifdef USING_PACKAGED_LIBRARIES
215
+ rb_define_const(mSqlite3, "SQLITE_PACKAGED_LIBRARIES", Qtrue);
216
+ #else
217
+ rb_define_const(mSqlite3, "SQLITE_PACKAGED_LIBRARIES", Qfalse);
218
+ #endif
219
+
220
+ #ifdef USING_PRECOMPILED_LIBRARIES
221
+ rb_define_const(mSqlite3, "SQLITE_PRECOMPILED_LIBRARIES", Qtrue);
222
+ #else
223
+ rb_define_const(mSqlite3, "SQLITE_PRECOMPILED_LIBRARIES", Qfalse);
224
+ #endif
225
+ }
@@ -0,0 +1,49 @@
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) (rb_utf8_str_new_cstr(_obj))
22
+
23
+ #ifdef USING_SQLCIPHER_INC_SUBDIR
24
+ # include <sqlcipher/sqlite3.h>
25
+ #else
26
+ # include <sqlite3.h>
27
+ #endif
28
+
29
+ #ifndef HAVE_TYPE_SQLITE3_INT64
30
+ typedef sqlite_int64 sqlite3_int64;
31
+ #endif
32
+
33
+ #ifndef HAVE_TYPE_SQLITE3_UINT64
34
+ typedef sqlite_uint64 sqlite3_uint64;
35
+ #endif
36
+
37
+ extern VALUE mSqlite3;
38
+ extern VALUE cSqlite3Blob;
39
+
40
+ #include <database.h>
41
+ #include <statement.h>
42
+ #include <exception.h>
43
+ #include <backup.h>
44
+ #include <timespec.h>
45
+ #include <gvl.h>
46
+
47
+ int bignum_to_int64(VALUE big, sqlite3_int64 *result);
48
+
49
+ #endif