amalgalite 1.6.0-x64-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CONTRIBUTING.md +49 -0
- data/HISTORY.md +346 -0
- data/LICENSE +31 -0
- data/Manifest.txt +104 -0
- data/README.md +65 -0
- data/Rakefile +26 -0
- data/TODO.md +57 -0
- data/bin/amalgalite-pack +147 -0
- data/examples/a.rb +9 -0
- data/examples/blob.rb +88 -0
- data/examples/bootstrap.rb +36 -0
- data/examples/define_aggregate.rb +75 -0
- data/examples/define_function.rb +104 -0
- data/examples/fts5.rb +152 -0
- data/examples/gem-db.rb +94 -0
- data/examples/require_me.rb +11 -0
- data/examples/requires.rb +42 -0
- data/examples/schema-info.rb +34 -0
- data/ext/amalgalite/c/amalgalite.c +355 -0
- data/ext/amalgalite/c/amalgalite.h +151 -0
- data/ext/amalgalite/c/amalgalite_blob.c +240 -0
- data/ext/amalgalite/c/amalgalite_constants.c +1226 -0
- data/ext/amalgalite/c/amalgalite_database.c +1178 -0
- data/ext/amalgalite/c/amalgalite_requires_bootstrap.c +282 -0
- data/ext/amalgalite/c/amalgalite_statement.c +649 -0
- data/ext/amalgalite/c/extconf.rb +62 -0
- data/ext/amalgalite/c/gen_constants.rb +330 -0
- data/ext/amalgalite/c/notes.txt +134 -0
- data/ext/amalgalite/c/sqlite3.c +205352 -0
- data/ext/amalgalite/c/sqlite3.h +10727 -0
- data/ext/amalgalite/c/sqlite3_options.h +4 -0
- data/ext/amalgalite/c/sqlite3ext.h +578 -0
- data/lib/amalgalite.rb +51 -0
- data/lib/amalgalite/2.0/amalgalite.so +0 -0
- data/lib/amalgalite/2.1/amalgalite.so +0 -0
- data/lib/amalgalite/2.2/amalgalite.so +0 -0
- data/lib/amalgalite/2.3/amalgalite.so +0 -0
- data/lib/amalgalite/2.4/amalgalite.so +0 -0
- data/lib/amalgalite/aggregate.rb +67 -0
- data/lib/amalgalite/blob.rb +186 -0
- data/lib/amalgalite/boolean.rb +42 -0
- data/lib/amalgalite/busy_timeout.rb +47 -0
- data/lib/amalgalite/column.rb +99 -0
- data/lib/amalgalite/core_ext/kernel/require.rb +21 -0
- data/lib/amalgalite/csv_table_importer.rb +74 -0
- data/lib/amalgalite/database.rb +984 -0
- data/lib/amalgalite/function.rb +61 -0
- data/lib/amalgalite/index.rb +43 -0
- data/lib/amalgalite/memory_database.rb +15 -0
- data/lib/amalgalite/packer.rb +231 -0
- data/lib/amalgalite/paths.rb +80 -0
- data/lib/amalgalite/profile_tap.rb +131 -0
- data/lib/amalgalite/progress_handler.rb +21 -0
- data/lib/amalgalite/requires.rb +151 -0
- data/lib/amalgalite/schema.rb +225 -0
- data/lib/amalgalite/sqlite3.rb +6 -0
- data/lib/amalgalite/sqlite3/constants.rb +95 -0
- data/lib/amalgalite/sqlite3/database/function.rb +48 -0
- data/lib/amalgalite/sqlite3/database/status.rb +68 -0
- data/lib/amalgalite/sqlite3/status.rb +60 -0
- data/lib/amalgalite/sqlite3/version.rb +55 -0
- data/lib/amalgalite/statement.rb +418 -0
- data/lib/amalgalite/table.rb +91 -0
- data/lib/amalgalite/taps.rb +2 -0
- data/lib/amalgalite/taps/console.rb +27 -0
- data/lib/amalgalite/taps/io.rb +71 -0
- data/lib/amalgalite/trace_tap.rb +35 -0
- data/lib/amalgalite/type_map.rb +63 -0
- data/lib/amalgalite/type_maps/default_map.rb +166 -0
- data/lib/amalgalite/type_maps/storage_map.rb +38 -0
- data/lib/amalgalite/type_maps/text_map.rb +21 -0
- data/lib/amalgalite/version.rb +8 -0
- data/lib/amalgalite/view.rb +26 -0
- data/spec/aggregate_spec.rb +154 -0
- data/spec/amalgalite_spec.rb +4 -0
- data/spec/blob_spec.rb +78 -0
- data/spec/boolean_spec.rb +24 -0
- data/spec/busy_handler.rb +157 -0
- data/spec/data/iso-3166-country.txt +242 -0
- data/spec/data/iso-3166-schema.sql +22 -0
- data/spec/data/iso-3166-subcountry.txt +3995 -0
- data/spec/data/make-iso-db.sh +12 -0
- data/spec/database_spec.rb +508 -0
- data/spec/default_map_spec.rb +92 -0
- data/spec/function_spec.rb +78 -0
- data/spec/integeration_spec.rb +97 -0
- data/spec/iso_3166_database.rb +58 -0
- data/spec/packer_spec.rb +60 -0
- data/spec/paths_spec.rb +28 -0
- data/spec/progress_handler_spec.rb +91 -0
- data/spec/requires_spec.rb +54 -0
- data/spec/rtree_spec.rb +66 -0
- data/spec/schema_spec.rb +131 -0
- data/spec/spec_helper.rb +48 -0
- data/spec/sqlite3/constants_spec.rb +108 -0
- data/spec/sqlite3/database_status_spec.rb +36 -0
- data/spec/sqlite3/status_spec.rb +22 -0
- data/spec/sqlite3/version_spec.rb +28 -0
- data/spec/sqlite3_spec.rb +53 -0
- data/spec/statement_spec.rb +168 -0
- data/spec/storage_map_spec.rb +38 -0
- data/spec/tap_spec.rb +57 -0
- data/spec/text_map_spec.rb +20 -0
- data/spec/type_map_spec.rb +14 -0
- data/spec/version_spec.rb +8 -0
- data/tasks/custom.rake +102 -0
- data/tasks/default.rake +240 -0
- data/tasks/extension.rake +38 -0
- data/tasks/this.rb +208 -0
- metadata +318 -0
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
# used by the ext:build_win-1.x.x tasks, really no one else but jeremy should be
|
5
|
+
# using this hack
|
6
|
+
$ruby = ARGV.shift if ARGV[0]
|
7
|
+
|
8
|
+
# make available table and column meta data api
|
9
|
+
$CFLAGS += " -DSQLITE_ENABLE_COLUMN_METADATA=1"
|
10
|
+
$CFLAGS += " -DSQLITE_ENABLE_DBSTAT_VTAB=1"
|
11
|
+
$CFLAGS += " -DSQLITE_ENABLE_DBPAGE_VTAB=1"
|
12
|
+
$CFLAGS += " -DSQLITE_ENABLE_FTS3=1"
|
13
|
+
$CFLAGS += " -DSQLITE_ENABLE_FTS3_PARENTHESIS=1"
|
14
|
+
$CFLAGS += " -DSQLITE_ENABLE_FTS4=1"
|
15
|
+
$CFLAGS += " -DSQLITE_ENABLE_FTS5=1"
|
16
|
+
$CFLAGS += " -DSQLITE_ENABLE_JSON1=1"
|
17
|
+
$CFLAGS += " -DSQLITE_ENABLE_MEMORY_MANAGEMENT=1"
|
18
|
+
$CFLAGS += " -DSQLITE_ENABLE_PREUPDATE_HOOK=1"
|
19
|
+
$CFLAGS += " -DSQLITE_ENABLE_RBU=1"
|
20
|
+
$CFLAGS += " -DSQLITE_ENABLE_RTREE=1"
|
21
|
+
$CFLAGS += " -DSQLITE_ENABLE_SESSION=1"
|
22
|
+
$CFLAGS += " -DSQLITE_ENABLE_STMTVTAB=1"
|
23
|
+
$CFLAGS += " -DSQLITE_ENABLE_STAT4=1"
|
24
|
+
$CFLAGS += " -DSQLITE_ENABLE_UNLOCK_NOTIFY=1"
|
25
|
+
|
26
|
+
# we compile sqlite the same way that the installation of ruby is compiled.
|
27
|
+
if RbConfig::MAKEFILE_CONFIG['configure_args'].include?( "--enable-pthread" ) then
|
28
|
+
$CFLAGS += " -DSQLITE_THREADSAFE=1"
|
29
|
+
else
|
30
|
+
$CFLAGS += " -DSQLITE_THREADSAFE=0"
|
31
|
+
end
|
32
|
+
|
33
|
+
# remove the -g flags if it exists
|
34
|
+
%w[ -ggdb\\d* -g\\d* ].each do |debug|
|
35
|
+
$CFLAGS = $CFLAGS.gsub(/#{debug}/,'')
|
36
|
+
RbConfig::MAKEFILE_CONFIG['debugflags'] = RbConfig::MAKEFILE_CONFIG['debugflags'].gsub(/#{debug}/,'') if RbConfig::MAKEFILE_CONFIG['debugflags']
|
37
|
+
end
|
38
|
+
|
39
|
+
ignoreable_warnings = %w[ write-strings ]
|
40
|
+
ignore_by_compiler = {
|
41
|
+
"clang" => %w[
|
42
|
+
empty-body
|
43
|
+
incompatible-pointer-types-discards-qualifiers
|
44
|
+
shorten-64-to-32
|
45
|
+
sign-compare
|
46
|
+
unused-const-variable
|
47
|
+
unused-variable
|
48
|
+
]
|
49
|
+
}
|
50
|
+
|
51
|
+
if extras = ignore_by_compiler[RbConfig::MAKEFILE_CONFIG["CC"]] then
|
52
|
+
ignoreable_warnings.concat(extras)
|
53
|
+
end
|
54
|
+
|
55
|
+
ignoreable_warnings.each do |warning|
|
56
|
+
$CFLAGS = $CFLAGS.gsub(/-W#{warning}/,'')
|
57
|
+
RbConfig::MAKEFILE_CONFIG['warnflags'] = RbConfig::MAKEFILE_CONFIG['warnflags'].gsub(/-W#{warning}/,'') if RbConfig::MAKEFILE_CONFIG['warnflags']
|
58
|
+
$CFLAGS += " -Wno-#{warning}"
|
59
|
+
end
|
60
|
+
|
61
|
+
subdir = RUBY_VERSION.sub(/\.\d$/,'')
|
62
|
+
create_makefile("amalgalite/#{subdir}/amalgalite")
|
@@ -0,0 +1,330 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
# readin in the sqlite3.h file and parse out all the #define lines
|
6
|
+
sqlite3_h_fname = File.expand_path(File.join(File.dirname(__FILE__), "sqlite3.h"))
|
7
|
+
|
8
|
+
# special handling for those that are function result codes
|
9
|
+
result_codes = %w[
|
10
|
+
SQLITE_OK
|
11
|
+
SQLITE_ERROR
|
12
|
+
SQLITE_INTERNAL
|
13
|
+
SQLITE_PERM
|
14
|
+
SQLITE_ABORT
|
15
|
+
SQLITE_BUSY
|
16
|
+
SQLITE_LOCKED
|
17
|
+
SQLITE_NOMEM
|
18
|
+
SQLITE_READONLY
|
19
|
+
SQLITE_INTERRUPT
|
20
|
+
SQLITE_IOERR
|
21
|
+
SQLITE_CORRUPT
|
22
|
+
SQLITE_NOTFOUND
|
23
|
+
SQLITE_FULL
|
24
|
+
SQLITE_CANTOPEN
|
25
|
+
SQLITE_PROTOCOL
|
26
|
+
SQLITE_EMPTY
|
27
|
+
SQLITE_SCHEMA
|
28
|
+
SQLITE_TOOBIG
|
29
|
+
SQLITE_CONSTRAINT
|
30
|
+
SQLITE_MISMATCH
|
31
|
+
SQLITE_MISUSE
|
32
|
+
SQLITE_NOLFS
|
33
|
+
SQLITE_AUTH
|
34
|
+
SQLITE_FORMAT
|
35
|
+
SQLITE_RANGE
|
36
|
+
SQLITE_NOTADB
|
37
|
+
SQLITE_NOTICE
|
38
|
+
SQLITE_WARNING
|
39
|
+
SQLITE_ROW
|
40
|
+
SQLITE_DONE
|
41
|
+
SQLITE_IOERR_READ
|
42
|
+
SQLITE_IOERR_SHORT_READ
|
43
|
+
SQLITE_IOERR_WRITE
|
44
|
+
SQLITE_IOERR_FSYNC
|
45
|
+
SQLITE_IOERR_DIR_FSYNC
|
46
|
+
SQLITE_IOERR_TRUNCATE
|
47
|
+
SQLITE_IOERR_FSTAT
|
48
|
+
SQLITE_IOERR_UNLOCK
|
49
|
+
SQLITE_IOERR_RDLOCK
|
50
|
+
SQLITE_IOERR_DELETE
|
51
|
+
SQLITE_IOERR_BLOCKED
|
52
|
+
SQLITE_IOERR_NOMEM
|
53
|
+
SQLITE_IOERR_ACCESS
|
54
|
+
SQLITE_IOERR_CHECKRESERVEDLOCK
|
55
|
+
SQLITE_IOERR_LOCK
|
56
|
+
SQLITE_IOERR_CLOSE
|
57
|
+
SQLITE_IOERR_DIR_CLOSE
|
58
|
+
SQLITE_IOERR_SHMOPEN
|
59
|
+
SQLITE_IOERR_SHMSIZE
|
60
|
+
SQLITE_IOERR_SHMLOCK
|
61
|
+
SQLITE_IOERR_SHMMAP
|
62
|
+
SQLITE_IOERR_SEEK
|
63
|
+
SQLITE_IOERR_DELETE_NOENT
|
64
|
+
SQLITE_IOERR_MMAP
|
65
|
+
SQLITE_IOERR_GETTEMPPATH
|
66
|
+
SQLITE_IOERR_CONVPATH
|
67
|
+
SQLITE_IOERR_VNODE
|
68
|
+
SQLITE_IOERR_AUTH
|
69
|
+
SQLITE_IOERR_BEGIN_ATOMIC
|
70
|
+
SQLITE_IOERR_COMMIT_ATOMIC
|
71
|
+
SQLITE_IOERR_ROLLBACK_ATOMIC
|
72
|
+
SQLITE_LOCKED_SHAREDCACHE
|
73
|
+
SQLITE_BUSY_RECOVERY
|
74
|
+
SQLITE_BUSY_SNAPSHOT
|
75
|
+
SQLITE_CANTOPEN_NOTEMPDIR
|
76
|
+
SQLITE_CANTOPEN_ISDIR
|
77
|
+
SQLITE_CANTOPEN_FULLPATH
|
78
|
+
SQLITE_CANTOPEN_CONVPATH
|
79
|
+
SQLITE_CORRUPT_VTAB
|
80
|
+
SQLITE_READONLY_RECOVERY
|
81
|
+
SQLITE_READONLY_CANTLOCK
|
82
|
+
SQLITE_READONLY_ROLLBACK
|
83
|
+
SQLITE_READONLY_DBMOVED
|
84
|
+
SQLITE_ABORT_ROLLBACK
|
85
|
+
SQLITE_CONSTRAINT_CHECK
|
86
|
+
SQLITE_CONSTRAINT_COMMITHOOK
|
87
|
+
SQLITE_CONSTRAINT_FOREIGNKEY
|
88
|
+
SQLITE_CONSTRAINT_FUNCTION
|
89
|
+
SQLITE_CONSTRAINT_NOTNULL
|
90
|
+
SQLITE_CONSTRAINT_PRIMARYKEY
|
91
|
+
SQLITE_CONSTRAINT_TRIGGER
|
92
|
+
SQLITE_CONSTRAINT_UNIQUE
|
93
|
+
SQLITE_CONSTRAINT_VTAB
|
94
|
+
SQLITE_CONSTRAINT_ROWID
|
95
|
+
SQLITE_NOTICE_RECOVER_WAL
|
96
|
+
SQLITE_NOTICE_RECOVER_ROLLBACK
|
97
|
+
SQLITE_WARNING_AUTOINDEX
|
98
|
+
SQLITE_AUTH_USER
|
99
|
+
SQLITE_OK_LOAD_PERMANENTLY
|
100
|
+
]
|
101
|
+
|
102
|
+
deprecated_codes = %w[ SQLITE_GET_LOCKPROXYFILE SQLITE_SET_LOCKPROXYFILE SQLITE_LAST_ERRNO ]
|
103
|
+
version_codes = %w[ SQLITE_VERSION SQLITE_VERSION_NUMBER SQLITE_SOURCE_ID ]
|
104
|
+
rtree_codes = %w[ NOT_WITHIN PARTLY_WITHIN FULLY_WITHIN ]
|
105
|
+
|
106
|
+
authorizer_codes = %w[
|
107
|
+
SQLITE_DENY
|
108
|
+
SQLITE_IGNORE
|
109
|
+
SQLITE_CREATE_INDEX
|
110
|
+
SQLITE_CREATE_TABLE
|
111
|
+
SQLITE_CREATE_TEMP_INDEX
|
112
|
+
SQLITE_CREATE_TEMP_TABLE
|
113
|
+
SQLITE_CREATE_TEMP_TRIGGER
|
114
|
+
SQLITE_CREATE_TEMP_VIEW
|
115
|
+
SQLITE_CREATE_TRIGGER
|
116
|
+
SQLITE_CREATE_VIEW
|
117
|
+
SQLITE_DELETE
|
118
|
+
SQLITE_DROP_INDEX
|
119
|
+
SQLITE_DROP_TABLE
|
120
|
+
SQLITE_DROP_TEMP_INDEX
|
121
|
+
SQLITE_DROP_TEMP_TABLE
|
122
|
+
SQLITE_DROP_TEMP_TRIGGER
|
123
|
+
SQLITE_DROP_TEMP_VIEW
|
124
|
+
SQLITE_DROP_TRIGGER
|
125
|
+
SQLITE_DROP_VIEW
|
126
|
+
SQLITE_INSERT
|
127
|
+
SQLITE_PRAGMA
|
128
|
+
SQLITE_READ
|
129
|
+
SQLITE_SELECT
|
130
|
+
SQLITE_TRANSACTION
|
131
|
+
SQLITE_UPDATE
|
132
|
+
SQLITE_ATTACH
|
133
|
+
SQLITE_DETACH
|
134
|
+
SQLITE_ALTER_TABLE
|
135
|
+
SQLITE_REINDEX
|
136
|
+
SQLITE_ANALYZE
|
137
|
+
SQLITE_CREATE_VTABLE
|
138
|
+
SQLITE_DROP_VTABLE
|
139
|
+
SQLITE_FUNCTION
|
140
|
+
SQLITE_SAVEPOINT
|
141
|
+
SQLITE_COPY
|
142
|
+
SQLITE_RECURSIVE
|
143
|
+
]
|
144
|
+
|
145
|
+
text_encoding_codes = %w[
|
146
|
+
SQLITE_UTF8
|
147
|
+
SQLITE_UTF16LE
|
148
|
+
SQLITE_UTF16BE
|
149
|
+
SQLITE_UTF16
|
150
|
+
SQLITE_ANY
|
151
|
+
SQLITE_UTF16_ALIGNED
|
152
|
+
SQLITE_DETERMINISTIC
|
153
|
+
]
|
154
|
+
|
155
|
+
data_type_codes = %w[
|
156
|
+
SQLITE_INTEGER
|
157
|
+
SQLITE_FLOAT
|
158
|
+
SQLITE_BLOB
|
159
|
+
SQLITE_NULL
|
160
|
+
SQLITE3_TEXT
|
161
|
+
]
|
162
|
+
|
163
|
+
fts5_codes = %w[
|
164
|
+
FTS5_TOKENIZE_QUERY
|
165
|
+
FTS5_TOKENIZE_PREFIX
|
166
|
+
FTS5_TOKENIZE_DOCUMENT
|
167
|
+
FTS5_TOKENIZE_AUX
|
168
|
+
FTS5_TOKEN_COLOCATED
|
169
|
+
]
|
170
|
+
|
171
|
+
ignore_codes = [
|
172
|
+
# vtab related
|
173
|
+
"SQLITE_ROLLBACK",
|
174
|
+
"SQLITE_FAIL",
|
175
|
+
"SQLITE_REPLACE",
|
176
|
+
"SQLITE_VTAB_CONSTRAINT_SUPPORT",
|
177
|
+
|
178
|
+
# sqlite destructor callback codes
|
179
|
+
"SQLITE_STATIC",
|
180
|
+
"SQLITE_TRANSIENT",
|
181
|
+
]
|
182
|
+
|
183
|
+
# oddball name
|
184
|
+
module_name_mapping = {
|
185
|
+
|
186
|
+
"DBCONFIG" => "DBConfig",
|
187
|
+
"DBSTATUS" => "DBStatus",
|
188
|
+
"IOCAP" => "IOCap",
|
189
|
+
"SHM" => "SHM",
|
190
|
+
"SCANSTAT" => "ScanStat",
|
191
|
+
"STMTSTATUS" => "StatementStatus",
|
192
|
+
}
|
193
|
+
|
194
|
+
defines = []
|
195
|
+
IO.readlines(sqlite3_h_fname).each do |l|
|
196
|
+
result = {
|
197
|
+
"c_define" => nil,
|
198
|
+
"c_value" => nil,
|
199
|
+
"docstring" => nil,
|
200
|
+
|
201
|
+
"is_error_code" => false,
|
202
|
+
|
203
|
+
"r_module" => nil,
|
204
|
+
"r_constant" => nil,
|
205
|
+
}
|
206
|
+
|
207
|
+
if l =~ /beginning-of-error-codes/ .. l =~ /end-of-error-codes/ then
|
208
|
+
result["is_error_code"] = true
|
209
|
+
end
|
210
|
+
|
211
|
+
l.strip!
|
212
|
+
md = l.match(/\A#define\s+(\w+)\s+([^\/]+)\s*(\/\*(.*)\*\/)?\Z/)
|
213
|
+
next unless md
|
214
|
+
|
215
|
+
# Name munging
|
216
|
+
c_define = md[1]
|
217
|
+
|
218
|
+
c_parts = c_define.gsub(/^SQLITE_/,'').split("_")
|
219
|
+
r_module = c_parts.shift
|
220
|
+
r_constant = c_parts.join("_")
|
221
|
+
|
222
|
+
|
223
|
+
# custom module naming so they are human readable
|
224
|
+
r_module = module_name_mapping.fetch(r_module) { |m| r_module.capitalize }
|
225
|
+
|
226
|
+
case c_define
|
227
|
+
when *version_codes
|
228
|
+
next
|
229
|
+
|
230
|
+
when *deprecated_codes
|
231
|
+
next
|
232
|
+
|
233
|
+
when *rtree_codes
|
234
|
+
r_module = "RTree"
|
235
|
+
r_constant = c_define
|
236
|
+
|
237
|
+
when *result_codes
|
238
|
+
r_module = "ResultCode"
|
239
|
+
r_constant = c_define.gsub(/^SQLITE_/,'')
|
240
|
+
|
241
|
+
when *authorizer_codes
|
242
|
+
r_module = "Authorizer"
|
243
|
+
r_constant = c_define.gsub(/^SQLITE_/,'')
|
244
|
+
|
245
|
+
when *text_encoding_codes
|
246
|
+
r_module = "TextEncoding"
|
247
|
+
r_constant = c_define.gsub(/^SQLITE_/,'')
|
248
|
+
|
249
|
+
when *data_type_codes
|
250
|
+
r_module = "DataType"
|
251
|
+
r_constant = c_define.gsub(/^SQLITE(3)?_/,'')
|
252
|
+
|
253
|
+
when *fts5_codes
|
254
|
+
r_module = "FTS5"
|
255
|
+
r_constant = c_define.gsub(/^FTS5_/,'')
|
256
|
+
|
257
|
+
when *ignore_codes
|
258
|
+
next
|
259
|
+
|
260
|
+
when /TESTCTRL/ # sqlite3 codes used in testing
|
261
|
+
next
|
262
|
+
|
263
|
+
when /^__/ # sqlite3 internal items
|
264
|
+
next
|
265
|
+
end
|
266
|
+
|
267
|
+
result["c_define"] = c_define
|
268
|
+
result["c_value"] = md[2].strip
|
269
|
+
if !md[4].nil? && (md[4].strip.length > 0) then
|
270
|
+
result["docstring"] = md[4].strip
|
271
|
+
end
|
272
|
+
result["r_module"] = r_module
|
273
|
+
result["r_constant"] = r_constant
|
274
|
+
|
275
|
+
defines << result
|
276
|
+
end
|
277
|
+
|
278
|
+
#
|
279
|
+
# rework defines into constants
|
280
|
+
#
|
281
|
+
CONSTANTS = defines.group_by{ |d| d["r_module"] }
|
282
|
+
|
283
|
+
fname = File.expand_path(File.join(File.dirname(__FILE__), "amalgalite_constants.c"))
|
284
|
+
|
285
|
+
|
286
|
+
File.open(fname, "w+") do |f|
|
287
|
+
f.puts "/* Generated by gen_constants.rb -- do not edit */"
|
288
|
+
f.puts
|
289
|
+
f.puts '#include "amalgalite.h"'
|
290
|
+
f.puts '/**'
|
291
|
+
f.puts ' * Document-class: Amalgalite::SQLite3::Constants'
|
292
|
+
f.puts ' *'
|
293
|
+
f.puts ' * class holding constants in the sqlite extension'
|
294
|
+
f.puts ' */'
|
295
|
+
f.puts "void Init_amalgalite_constants( )"
|
296
|
+
f.puts "{"
|
297
|
+
f.puts
|
298
|
+
f.puts ' VALUE ma = rb_define_module("Amalgalite");'
|
299
|
+
f.puts ' VALUE mas = rb_define_module_under(ma, "SQLite3");'
|
300
|
+
f.puts
|
301
|
+
f.puts " /*"
|
302
|
+
f.puts " * module encapsulating all the SQLite C extension constants "
|
303
|
+
f.puts " */"
|
304
|
+
f.puts ' VALUE mC = rb_define_module_under( mas, "Constants");'
|
305
|
+
|
306
|
+
|
307
|
+
CONSTANTS.keys.sort.each do |mod|
|
308
|
+
f.puts " /**"
|
309
|
+
f.puts " * module encapsulating the SQLite3 C extension constants for #{mod}"
|
310
|
+
f.puts " */"
|
311
|
+
f.puts " VALUE mC_#{mod} = rb_define_module_under(mC, \"#{mod}\");"
|
312
|
+
f.puts
|
313
|
+
end
|
314
|
+
|
315
|
+
CONSTANTS.keys.sort.each do |mod|
|
316
|
+
const_set = CONSTANTS[mod]
|
317
|
+
const_set.sort_by { |c| c["c_define"] }.each do |result|
|
318
|
+
sql_const = result["c_define"]
|
319
|
+
const_doc = " /* no meaningful autogenerated documentation -- constant is self explanatory ?*/"
|
320
|
+
if !result["docstring"].nil? then
|
321
|
+
const_doc = " /* #{result['c_value']} -- #{result['docstring']} */"
|
322
|
+
end
|
323
|
+
ruby_constant = result['r_constant']
|
324
|
+
f.puts const_doc
|
325
|
+
f.puts " rb_define_const(mC_#{mod}, \"#{ruby_constant}\", INT2FIX(#{sql_const}));"
|
326
|
+
f.puts
|
327
|
+
end
|
328
|
+
end
|
329
|
+
f.puts "}"
|
330
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
Top level "methods"
|
2
|
+
===================
|
3
|
+
|
4
|
+
*done* const char* sqlite3_libversion(void)
|
5
|
+
*done* int sqlite3_libversion_number(void)
|
6
|
+
*done* int sqlite3_threadsave(void)
|
7
|
+
*done* int sqlite3_complete(const char*sql);
|
8
|
+
*done* int sqlite3_complete16(const void *sql);
|
9
|
+
|
10
|
+
*done* sqlite3_int64 sqlite3_memory_used(void);
|
11
|
+
*done* sqlite3_int64 sqtlie3_memory_highwater(int resetFlag);
|
12
|
+
*done* void sqlite3_randomness(int N, void *p)
|
13
|
+
|
14
|
+
*future* int sqlite3_enabled_shared_cache(int); # TODO maybe
|
15
|
+
*future* int sqlite3_release_memory(int); // maybe, hook into gc calls ?
|
16
|
+
*future* void sqlite3_soft_heap_limit(int);
|
17
|
+
*future* char* sqlite3_temp_directory;
|
18
|
+
|
19
|
+
UTF-8 vs. UTF-16
|
20
|
+
----------------
|
21
|
+
|
22
|
+
in cases where there is a xxx16() method in the C api, the ruby methods add a
|
23
|
+
flag to the method.
|
24
|
+
|
25
|
+
Core 'Objects'
|
26
|
+
==============
|
27
|
+
|
28
|
+
sqlite3 (typdef struct sqlite3) -> main database handle
|
29
|
+
-------
|
30
|
+
*done* int sqlite3_open_v2(*filename, sqlite3**, flags, NULL)
|
31
|
+
*done* int sqlite3_open16
|
32
|
+
*done* int sqlite3_extended_result_codes(sqlite3, int onoff) # default to turning this on
|
33
|
+
*skipped* called during rb_raise
|
34
|
+
*skipped* const char *sqlite3_errmsg(sqlite3*);
|
35
|
+
*skipped* const void *sqlite3_errmsg16(sqlite3*);
|
36
|
+
*done* int sqlite3_close(sqlite3 *)
|
37
|
+
*skipped* int sqlite3_exec -> don't use, wrap in ruby exec
|
38
|
+
*done* sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*)
|
39
|
+
*done* int sqlite3_get_autocommit(sqlite3*)
|
40
|
+
*done* int sqlite3_changes(sqlite3*)
|
41
|
+
*done* int sqlite3_total_changes(sqlite3*)
|
42
|
+
*skipped* int sqlite3_errcode(sqlite3 *db)
|
43
|
+
*done* int sqlite3_prepare_v2(sqlite3* db, sql, nbyte, sqlite3_stmt**, const char **tail)
|
44
|
+
|
45
|
+
int sqlite3_prepare16_v2(sqlite3* db, sql, nbyte, sqlite3_stmt**, const char **tail)
|
46
|
+
|
47
|
+
// not yet, but implement if/when a purchase of sqlite3 encryption works
|
48
|
+
TODO: int sqlite3_key(sqlite3* db, const void *pKey, int nKey);
|
49
|
+
TODO: int sqlite3_rekey(sqlite3* db, const void *pKey, int nKey);
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
TODO: int sqlite3_busy_timeout(sqlite3*)
|
54
|
+
*done* void sqlite3_progress_hander(sqlite3*, int, int(*)(void*), void*)
|
55
|
+
|
56
|
+
*done* tracing should be an IO object, if it is true then send it to STDERR
|
57
|
+
*done* tracing should also yield a block like a transaction so that during the block the db has tracing turned on.
|
58
|
+
*done* sqlite3_trace
|
59
|
+
|
60
|
+
TODO: create Table and Column classes
|
61
|
+
TODO: int sqlite3_table_column_metadata();
|
62
|
+
|
63
|
+
for later implementation
|
64
|
+
________________________
|
65
|
+
sqlite3_enable_load_extensions
|
66
|
+
sqlite3_load_extension
|
67
|
+
sqlite3_interrupt
|
68
|
+
sqlite3_busy_handler(sqlite3*, function pointer, void *)
|
69
|
+
|
70
|
+
*skip - experimental* sqlite3_profile
|
71
|
+
*Skip - experimental* sqlite3_limit(sqlite3*, int id, int newVal) -- maybe implement
|
72
|
+
*skip - experimental* sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
|
73
|
+
*skip - experimental* sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
|
74
|
+
*skip - experimental* sqlite3_update_hook(sqlite3*, function ponter, void*);
|
75
|
+
|
76
|
+
|
77
|
+
sqlite3_stmt (typedef struct sqlite3_stmt) -> handle for statements
|
78
|
+
------------
|
79
|
+
*done* const char *sqlite3_sql(sqlite3_stmt *pStmt)
|
80
|
+
*done* int sqlite3_bind_parameter_count(sqlite3_stmt*);
|
81
|
+
|
82
|
+
*done* sqlite3_bind_double(sqlite3_stmt*, int, double);
|
83
|
+
*done* sqlite3_bind_int(sqlite3_stmt*, int, int);
|
84
|
+
*done* sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
|
85
|
+
*done* sqlite3_bind_null(sqlite3_stmt*, int);
|
86
|
+
*done* sqlite3_bind_text(sqlite3_stmt*, int, constc char*, int n, void(*)(void*));
|
87
|
+
* skipping *sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
|
88
|
+
*done* const char* sqlite3_bind_parameter_name(sqlite3_stmt*, int )
|
89
|
+
*done* sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
|
90
|
+
*done* sqlite3_clear_bindings(sqlite3_stmt*);
|
91
|
+
*done* sqlite3_column_count(sqlite3_stmt *pStmt);
|
92
|
+
*done* sqlite3_column_name(sqlite3_stmt*, int N);
|
93
|
+
*skip - used internally* sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
|
94
|
+
*done* sqlite3_column_database_name(sqlite3_stmt*, int);
|
95
|
+
*done* sqlite3_column_table_name(sqlite3_stmt*, int);
|
96
|
+
*done* sqlite3_column_origin_name(sqlite3_stmt*, int);
|
97
|
+
*done* sqlite3_step(sqlite3_stmt*);
|
98
|
+
*done - as 'close' *int sqlite3_finalize(sqlite3_stmt *pStmt);
|
99
|
+
*done* int sqlite3_reset(sqlite3_stmt *pStmt);
|
100
|
+
*done - same as sqlite3_column_count* sqlite3_data_count(sqlite3_stmt *pStmt);
|
101
|
+
*do not use* sqlite3_value* sqlite3_column_value(sqlite3_stmt*, int iCol);
|
102
|
+
|
103
|
+
sqlite3_bind_text16(sqlite3_stmt*, int, constc char*, int, void(*)(void*));
|
104
|
+
* done *sqlite3_column_database_name16(sqlite3_stmt*, int);
|
105
|
+
* done *sqlite3_column_table_name16(sqlite3_stmt*, int);
|
106
|
+
* done *sqlite3_column_origin_name16(sqlite3_stmt*, int);
|
107
|
+
sqlite3_column_name16(sqlite3_stmt*, int N);
|
108
|
+
|
109
|
+
*done* sqlite3_column_decltype(sqlite3_stmt*, int);
|
110
|
+
sqlite3_column_decltype16(sqlite3_stmt*, int);
|
111
|
+
|
112
|
+
// use this to find the type and then call the appropriate method afterwards.
|
113
|
+
*done* sqlite3_column_type(sqlite3_stmt*, int iCol);
|
114
|
+
|
115
|
+
# binding by name or index, if passed in an array to the bind() method then
|
116
|
+
# bind by index, if passed in a hash, bind by name, using hte keys of the hash
|
117
|
+
*done* sqlite3_bind_blob(sqlite3_stmt*, int, const void *, int n, void(*)(void*));
|
118
|
+
*done* sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
|
119
|
+
|
120
|
+
|
121
|
+
sqlite3_blob
|
122
|
+
------------
|
123
|
+
// BLOB
|
124
|
+
*done* sqlite3_blob_open(sqlite3*, *db, *table, *column, rowid, flags, **blob);
|
125
|
+
*done* sqlite3_blob_close(sqlite3_blob*)
|
126
|
+
*done* sqlite3_blob_bytes(sqlite3_blob*)
|
127
|
+
*done* sqlite3_blob_read(sqlite3_blob*, *to_buffer, bytes_to_read, starting_at_offset);
|
128
|
+
*done* sqlite3_blob_write(sqlite3_blob*, *from_buffer, bytes_to_write, starting_at_offset);
|
129
|
+
|
130
|
+
Result Codes
|
131
|
+
============
|
132
|
+
|
133
|
+
*done* Convert to Individual Exceptions and allow the top level module generate them
|
134
|
+
based upon integer value
|