@blackrainbowlabs/cli-win32-x64 0.1.3 → 0.1.6

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.
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Jason McAffee
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Jason McAffee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
Binary file
Binary file
Binary file
Binary file
@@ -1,380 +1,385 @@
1
- /*
2
- * inillucent_driver.h - the C ABI over the inillucent relational engine.
3
- *
4
- * This header is the whole contract. A binding author needs this file and
5
- * drivers/README.md, and nothing else: everything below the line is an opaque
6
- * pointer, and no struct layout crosses the boundary.
7
- *
8
- *
9
- * WHAT TO READ FIRST
10
- *
11
- * The engine this drives is deliberately incomplete in places, and it REFUSES
12
- * what it has not implemented rather than answering it wrongly. So there is a
13
- * status of its own for that - INILLUCENT_UNSUPPORTED - and it is not the same
14
- * status a mistyped statement gets. A binding that folds the two together has
15
- * thrown away the point of this driver: an application needs to be able to say
16
- * "this engine cannot do that yet" rather than "check your spelling".
17
- *
18
- * inillucent_capability() enumerates what the engine does, so an application
19
- * can ask before it composes a statement rather than after. Every row of that
20
- * table is checked against the running engine by a test, in both directions -
21
- * a claim of support that fails, and a claim of absence that now works, both
22
- * fail it. That is the difference between this and every JDBC driver's
23
- * hand-written supportsXxx().
24
- *
25
- *
26
- * THREE OWNERSHIP RULES, AND THERE ARE NO OTHERS
27
- *
28
- * 1. A handle named by a _free (or _close) function is yours to free, exactly
29
- * once. Freeing NULL is a no-op, so a finaliser need not check.
30
- *
31
- * 2. Every pointer this library RETURNS points inside the handle you asked,
32
- * is valid until that handle is freed, and is never freed by you. It does
33
- * not move: a result is materialised, so a pointer into row 0 stays valid
34
- * while row 900000 is read.
35
- *
36
- * 3. Every pointer you PASS IN is copied before the call returns. You may free
37
- * your buffer on the next line.
38
- *
39
- *
40
- * DESTRUCTION ORDER: THERE IS ONLY ONE RULE, AND IT IS ABOUT inillucent_close
41
- *
42
- * A statement and a transaction share the connection they were made on. You
43
- * may free the four handles in ANY order:
44
- *
45
- * inillucent_conn_free(conn); -- legal with a live stmt or txn
46
- * inillucent_stmt_execute(stmt, ...); -- still works
47
- * inillucent_stmt_free(stmt); -- the connection's state goes here
48
- *
49
- * The connection's state lives until the last of its handles is freed, so
50
- * freeing it early releases the handle and nothing else. Nothing dangles and
51
- * nothing needs a defined error, because there is no wrong order to report.
52
- *
53
- * inillucent_close is the exception, and it REFUSES rather than dangling.
54
- * It returns INILLUCENT_INVALID_STATE, with a message, while any connection
55
- * on the database is still alive - and a connection counts as alive while any
56
- * statement or transaction made on it is alive, even if you already freed the
57
- * inillucent_conn. The database is left open and usable; free the children and
58
- * close again.
59
- *
60
- * A statement or transaction outliving its connection keeps the session that
61
- * connection opened, so temp tables, ATTACHed databases and connection
62
- * pragmas are all still there.
63
- *
64
- * inillucent_rows owns its data outright. It depends on nothing and can be
65
- * freed at any time, before or after everything else.
66
- *
67
- * Text is NOT guaranteed NUL-terminated - a text value may contain a NUL byte,
68
- * and pretending otherwise would truncate it silently. Byte pointers therefore
69
- * come with a length out-parameter. The few strings that ARE C strings say so
70
- * on the function.
71
- *
72
- *
73
- * THREADS
74
- *
75
- * One file is one buffer pool and the engine is single threaded. A
76
- * inillucent_db and everything under it must be confined to one thread, or
77
- * every call on it serialised by a lock you own. There is no lock inside.
78
- * Two databases on two files are independent.
79
- */
80
-
81
- #ifndef INILLUCENT_DRIVER_H
82
- #define INILLUCENT_DRIVER_H
83
-
84
- #include <stddef.h>
85
- #include <stdint.h>
86
-
87
- #ifdef __cplusplus
88
- extern "C" {
89
- #endif
90
-
91
- /* ------------------------------------------------------------------ */
92
- /* Handles. Every one is opaque; none has a layout you may rely on. */
93
- /* ------------------------------------------------------------------ */
94
-
95
- typedef struct inillucent_db inillucent_db; /* an open database file */
96
- typedef struct inillucent_conn inillucent_conn; /* a connection to one */
97
- typedef struct inillucent_stmt inillucent_stmt; /* a statement + bindings */
98
- typedef struct inillucent_rows inillucent_rows; /* what a statement said */
99
- typedef struct inillucent_txn inillucent_txn; /* an open transaction */
100
- typedef struct inillucent_error inillucent_error; /* one failure */
101
-
102
- /* ------------------------------------------------------------------ */
103
- /* Status codes. Frozen at 1.0; a new one takes the next number. */
104
- /* ------------------------------------------------------------------ */
105
-
106
- #define INILLUCENT_OK 0
107
- #define INILLUCENT_UNSUPPORTED 1 /* this engine cannot do that yet */
108
- #define INILLUCENT_SYNTAX 2 /* the statement is not valid SQL */
109
- #define INILLUCENT_NOT_FOUND 3 /* no such table, column or index */
110
- #define INILLUCENT_CONSTRAINT 4 /* a constraint refused the write */
111
- #define INILLUCENT_READONLY 5
112
- #define INILLUCENT_BUSY 6
113
- #define INILLUCENT_INTERRUPTED 7
114
- #define INILLUCENT_CORRUPT 8
115
- #define INILLUCENT_IO 9
116
- #define INILLUCENT_FULL 10
117
- #define INILLUCENT_TOO_BIG 11
118
- #define INILLUCENT_INVALID_STATE 12 /* you broke this API's own contract */
119
- #define INILLUCENT_INTERNAL 13 /* a defect - please report it */
120
-
121
- /* Value kinds, as inillucent_value_type reports them. Also frozen. */
122
- #define INILLUCENT_NULL 0
123
- #define INILLUCENT_INTEGER 1
124
- #define INILLUCENT_REAL 2
125
- #define INILLUCENT_TEXT 3
126
- #define INILLUCENT_BLOB 4
127
-
128
- /* Capability states, as inillucent_capability and inillucent_supports
129
- * report them. PARTIAL means "yes, with the limit the note names", and a
130
- * binding that treats it as YES without reading the note will be surprised. */
131
- #define INILLUCENT_SUPPORT_NO 0
132
- #define INILLUCENT_SUPPORT_YES 1
133
- #define INILLUCENT_SUPPORT_PARTIAL (-1)
134
- #define INILLUCENT_SUPPORT_UNKNOWN (-2) /* no such capability in this build */
135
-
136
- /* Flags for inillucent_open. */
137
- #define INILLUCENT_OPEN_CREATE 0x0001 /* make the file if absent */
138
- #define INILLUCENT_OPEN_READONLY 0x0002 /* refuse anything but a query */
139
- #define INILLUCENT_OPEN_DIAGNOSTICS 0x0004 /* see inillucent_error_detail */
140
-
141
- /* ------------------------------------------------------------------ */
142
- /* The library itself. */
143
- /* ------------------------------------------------------------------ */
144
-
145
- /* major*1000000 + minor*1000 + patch. Check the MAJOR at load and refuse a
146
- * mismatch by name; that is the whole reason this exists. */
147
- uint32_t inillucent_abi_version(void);
148
-
149
- /* What the driver calls itself. A C string, valid forever. */
150
- const char *inillucent_version(void);
151
-
152
- /* How many capabilities this build knows about. */
153
- size_t inillucent_capability_count(void);
154
-
155
- /* Reads one capability. `name` and `note` are C strings valid forever;
156
- * `state` is one of the INILLUCENT_SUPPORT_* values. Any out-parameter may be
157
- * NULL if you do not want it. Returns INILLUCENT_INVALID_STATE if `nth` is
158
- * past the end. */
159
- int32_t inillucent_capability(size_t nth, const char **name, int32_t *state,
160
- const char **note);
161
-
162
- /* Looks one up by name. Returns an INILLUCENT_SUPPORT_* value, and
163
- * INILLUCENT_SUPPORT_UNKNOWN for a name this build has never heard of - which
164
- * you should treat as "no", never as "yes": a capability that was never
165
- * declared was certainly never checked. */
166
- int32_t inillucent_supports(const char *name);
167
-
168
- /* ------------------------------------------------------------------ */
169
- /* A database. */
170
- /* ------------------------------------------------------------------ */
171
-
172
- /* Opens (and by default creates) a database. `path` is UTF-8.
173
- * On failure *out is left alone and *error, if you passed one, is set. */
174
- int32_t inillucent_open(const char *path, uint32_t flags, inillucent_db **out,
175
- inillucent_error **error);
176
-
177
- /* Checkpoints and closes. Refuses with INILLUCENT_INVALID_STATE while any
178
- * connection on it is still open, rather than leaving them dangling. */
179
- int32_t inillucent_close(inillucent_db *db, inillucent_error **error);
180
-
181
- /* Makes everything written so far durable in the file. */
182
- int32_t inillucent_checkpoint(inillucent_db *db, inillucent_error **error);
183
-
184
- /* Walks every tree and reports the first thing that is wrong. */
185
- int32_t inillucent_integrity_check(inillucent_db *db, inillucent_error **error);
186
-
187
- /* Copies the database to a path, and opens and checks the copy before
188
- * returning - because a backup nobody checked is a file that is assumed to be
189
- * a database. */
190
- int32_t inillucent_backup_to(inillucent_db *db, const char *path,
191
- inillucent_error **error);
192
-
193
- /* The file this database is in, as a C string valid until it is closed. */
194
- const char *inillucent_path(const inillucent_db *db);
195
-
196
- /* ------------------------------------------------------------------ */
197
- /* A connection. */
198
- /* ------------------------------------------------------------------ */
199
-
200
- int32_t inillucent_connect(inillucent_db *db, inillucent_conn **out,
201
- inillucent_error **error);
202
-
203
- /* Frees the connection handle. Legal while a statement or transaction made on
204
- * it is still alive: they share the connection's state, which lives until the
205
- * last of them is freed. The database still refuses to close until then. */
206
- void inillucent_conn_free(inillucent_conn *conn);
207
-
208
- /* Runs one statement with nothing bound and collects every row it produced.
209
- * `limit` caps the rows HANDED BACK, not the rows produced - see
210
- * inillucent_rows_total and inillucent_rows_more. */
211
- int32_t inillucent_execute(inillucent_conn *conn, const char *sql,
212
- uint64_t limit, inillucent_rows **out,
213
- inillucent_error **error);
214
-
215
- /* Runs several statements separated by semicolons, for their effect. */
216
- int32_t inillucent_execute_batch(inillucent_conn *conn, const char *sql,
217
- inillucent_error **error);
218
-
219
- int64_t inillucent_last_insert_rowid(inillucent_conn *conn);
220
- int64_t inillucent_total_changes(inillucent_conn *conn);
221
-
222
- /* 1 while a transaction is open, 0 otherwise. */
223
- int32_t inillucent_in_transaction(inillucent_conn *conn);
224
-
225
- /* The schema's generation, which changes when the schema does. Compare it to
226
- * know whether a cached table description is stale. */
227
- uint64_t inillucent_schema_cookie(inillucent_conn *conn);
228
-
229
- /* Asks a running statement to stop. Safe to call from another thread while a
230
- * statement is running - it is the one call here that is - because it sets a
231
- * flag rather than touching the statement. The statement then fails with
232
- * INILLUCENT_INTERRUPTED and the connection stays usable.
233
- *
234
- * inillucent_supports("cancel") reports PARTIAL, and the limit it is reporting
235
- * is WHEN rather than whether: the flag is read at every leaf of a scan and
236
- * every batch a result collects, so a long scan, a large result and a slow join
237
- * all stop, while a single operator part-way through one indivisible piece of
238
- * work finishes it first. Draw a Stop button; do not promise it is instant.
239
- *
240
- * A cancel with nothing running cancels nothing: the next statement clears the
241
- * flag as it starts. */
242
- int32_t inillucent_cancel(inillucent_conn *conn, inillucent_error **error);
243
-
244
- /* ------------------------------------------------------------------ */
245
- /* A statement, for binding values and running more than once. */
246
- /* ------------------------------------------------------------------ */
247
-
248
- int32_t inillucent_prepare(inillucent_conn *conn, const char *sql,
249
- inillucent_stmt **out, inillucent_error **error);
250
-
251
- /* Frees the statement. Legal before or after its connection is freed. */
252
- void inillucent_stmt_free(inillucent_stmt *stmt);
253
-
254
- /* Parameters are one-based, matching ?1, ?2 in the SQL. Binding an index past
255
- * the end grows the binding list with NULLs, which is what makes binding out
256
- * of order work. Every one of these copies what it is given. */
257
- int32_t inillucent_bind_null(inillucent_stmt *stmt, uint32_t index);
258
- int32_t inillucent_bind_int(inillucent_stmt *stmt, uint32_t index, int64_t value);
259
- int32_t inillucent_bind_real(inillucent_stmt *stmt, uint32_t index, double value);
260
- int32_t inillucent_bind_text(inillucent_stmt *stmt, uint32_t index,
261
- const char *value, size_t len);
262
- int32_t inillucent_bind_blob(inillucent_stmt *stmt, uint32_t index,
263
- const uint8_t *value, size_t len);
264
-
265
- /* Unbinds everything. */
266
- void inillucent_clear_bindings(inillucent_stmt *stmt);
267
-
268
- /* Runs it with what is bound. May be called repeatedly with new bindings. */
269
- int32_t inillucent_stmt_execute(inillucent_stmt *stmt, uint64_t limit,
270
- inillucent_rows **out, inillucent_error **error);
271
-
272
- /* ------------------------------------------------------------------ */
273
- /* A result. Materialised, so every pointer below is stable until free. */
274
- /* ------------------------------------------------------------------ */
275
-
276
- void inillucent_rows_free(inillucent_rows *rows);
277
-
278
- size_t inillucent_rows_column_count(const inillucent_rows *rows);
279
-
280
- /* A C string valid until the result is freed; NULL if `nth` is past the end. */
281
- const char *inillucent_rows_column_name(const inillucent_rows *rows, size_t nth);
282
-
283
- /* The type the schema declared, or "" for an expression, which has none. */
284
- const char *inillucent_rows_column_type(const inillucent_rows *rows, size_t nth);
285
-
286
- /* How many rows you were handed. */
287
- size_t inillucent_rows_count(const inillucent_rows *rows);
288
-
289
- /* How many the statement produced, EXACTLY - not an estimate. The engine
290
- * materialises, so this was counted rather than guessed, which is what lets a
291
- * grid say "1-200 of 4,317" honestly. */
292
- size_t inillucent_rows_total(const inillucent_rows *rows);
293
-
294
- /* 1 when the limit cut something off. */
295
- int32_t inillucent_rows_more(const inillucent_rows *rows);
296
-
297
- /* Rows changed, or -1 for a statement that changed nothing (a query). */
298
- int64_t inillucent_rows_affected(const inillucent_rows *rows);
299
-
300
- uint64_t inillucent_rows_elapsed_us(const inillucent_rows *rows);
301
-
302
- /* A one-line summary for a status bar - "SELECT 27". A C string. */
303
- const char *inillucent_rows_tag(const inillucent_rows *rows);
304
-
305
- /* One of the INILLUCENT_NULL..INILLUCENT_BLOB values, or INILLUCENT_NULL for
306
- * a cell that is not there - so check the counts rather than probing. */
307
- int32_t inillucent_value_type(const inillucent_rows *rows, size_t row, size_t column);
308
-
309
- int64_t inillucent_value_int(const inillucent_rows *rows, size_t row, size_t column);
310
- double inillucent_value_real(const inillucent_rows *rows, size_t row, size_t column);
311
-
312
- /* Text or blob bytes, with the length written to *len. NOT NUL-terminated: a
313
- * text value may contain a NUL byte and truncating there would lose data
314
- * silently. Returns NULL and sets *len to 0 for NULL, a number, or a cell that
315
- * is not there. */
316
- const uint8_t *inillucent_value_bytes(const inillucent_rows *rows, size_t row,
317
- size_t column, size_t *len);
318
-
319
- /* ------------------------------------------------------------------ */
320
- /* A transaction. */
321
- /* ------------------------------------------------------------------ */
322
-
323
- /*
324
- * WHY THIS IS A HANDLE AND NOT A PAIR OF FUNCTIONS
325
- *
326
- * The rule this exists to serve is that a check on what a write DID must
327
- * happen before the COMMIT, not after: a postcondition tested after the commit
328
- * is a report about something that has already happened rather than a guard
329
- * against it. So a transaction is a handle you hold while you read
330
- * inillucent_txn_affected for each statement, decide, and only then commit.
331
- *
332
- * A handle freed without commit or rollback rolls back.
333
- */
334
- int32_t inillucent_txn_begin(inillucent_conn *conn, inillucent_txn **out,
335
- inillucent_error **error);
336
-
337
- /* Runs one statement inside it, writing how many rows it changed to
338
- * *affected. On failure the transaction is rolled back and the handle is
339
- * spent: free it. */
340
- int32_t inillucent_txn_execute(inillucent_txn *txn, const char *sql,
341
- uint64_t *affected, inillucent_error **error);
342
-
343
- /* Commits. The handle is spent either way; free it. */
344
- int32_t inillucent_txn_commit(inillucent_txn *txn, inillucent_error **error);
345
-
346
- /* Rolls back and frees. Never fails in a way you can act on, so it returns
347
- * nothing. */
348
- void inillucent_txn_rollback(inillucent_txn *txn);
349
-
350
- /* ------------------------------------------------------------------ */
351
- /* A failure. */
352
- /* ------------------------------------------------------------------ */
353
-
354
- int32_t inillucent_error_status(const inillucent_error *error);
355
-
356
- /* What happened, in the engine's own words. A C string, safe to show a person:
357
- * it never holds a file-system path, a bound value, or page bytes. */
358
- const char *inillucent_error_message(const inillucent_error *error);
359
-
360
- /* The construct the engine has not implemented - "an outer join", "VACUUM".
361
- * NULL unless the status is INILLUCENT_UNSUPPORTED. Finer-grained than the
362
- * capability table on purpose, so an application can name what it hit without
363
- * owning a list of every phrase. */
364
- const char *inillucent_error_feature(const inillucent_error *error);
365
-
366
- /* Internal diagnostic text. NULL unless the database was opened with
367
- * INILLUCENT_OPEN_DIAGNOSTICS. It MAY hold a path or a bound value, so do not
368
- * show it to a person and do not send it to a shared log. */
369
- const char *inillucent_error_detail(const inillucent_error *error);
370
-
371
- /* The byte offset into the statement, or -1 when there is none. */
372
- int32_t inillucent_error_offset(const inillucent_error *error);
373
-
374
- void inillucent_error_free(inillucent_error *error);
375
-
376
- #ifdef __cplusplus
377
- } /* extern "C" */
378
- #endif
379
-
380
- #endif /* INILLUCENT_DRIVER_H */
1
+ /*
2
+ * inillucent_driver.h - the C ABI over the inillucent relational engine.
3
+ *
4
+ * This header is the whole contract. A binding author needs this file and
5
+ * drivers/README.md, and nothing else: everything below the line is an opaque
6
+ * pointer, and no struct layout crosses the boundary.
7
+ *
8
+ *
9
+ * WHAT TO READ FIRST
10
+ *
11
+ * The engine this drives is deliberately incomplete in places, and it REFUSES
12
+ * what it has not implemented rather than answering it wrongly. So there is a
13
+ * status of its own for that - INILLUCENT_UNSUPPORTED - and it is not the same
14
+ * status a mistyped statement gets. A binding that folds the two together has
15
+ * thrown away the point of this driver: an application needs to be able to say
16
+ * "this engine cannot do that yet" rather than "check your spelling".
17
+ *
18
+ * inillucent_capability() enumerates what the engine does, so an application
19
+ * can ask before it composes a statement rather than after. Every row of that
20
+ * table is checked against the running engine by a test, in both directions -
21
+ * a claim of support that fails, and a claim of absence that now works, both
22
+ * fail it. That is the difference between this and every JDBC driver's
23
+ * hand-written supportsXxx().
24
+ *
25
+ *
26
+ * THREE OWNERSHIP RULES, AND THERE ARE NO OTHERS
27
+ *
28
+ * 1. A handle named by a _free (or _close) function is yours to free, exactly
29
+ * once. Freeing NULL is a no-op, so a finaliser need not check.
30
+ *
31
+ * 2. Every pointer this library RETURNS points inside the handle you asked,
32
+ * is valid until that handle is freed, and is never freed by you. It does
33
+ * not move: a result is materialised, so a pointer into row 0 stays valid
34
+ * while row 900000 is read.
35
+ *
36
+ * 3. Every pointer you PASS IN is copied before the call returns. You may free
37
+ * your buffer on the next line.
38
+ *
39
+ *
40
+ * DESTRUCTION ORDER: THERE IS ONLY ONE RULE, AND IT IS ABOUT inillucent_close
41
+ *
42
+ * A statement and a transaction share the connection they were made on. You
43
+ * may free the four handles in ANY order:
44
+ *
45
+ * inillucent_conn_free(conn); -- legal with a live stmt or txn
46
+ * inillucent_stmt_execute(stmt, ...); -- still works
47
+ * inillucent_stmt_free(stmt); -- the connection's state goes here
48
+ *
49
+ * The connection's state lives until the last of its handles is freed, so
50
+ * freeing it early releases the handle and nothing else. Nothing dangles and
51
+ * nothing needs a defined error, because there is no wrong order to report.
52
+ *
53
+ * inillucent_close is the exception, and it REFUSES rather than dangling.
54
+ * It returns INILLUCENT_INVALID_STATE, with a message, while any connection
55
+ * on the database is still alive - and a connection counts as alive while any
56
+ * statement or transaction made on it is alive, even if you already freed the
57
+ * inillucent_conn. The database is left open and usable; free the children and
58
+ * close again.
59
+ *
60
+ * A statement or transaction outliving its connection keeps the session that
61
+ * connection opened, so temp tables, ATTACHed databases and connection
62
+ * pragmas are all still there.
63
+ *
64
+ * inillucent_rows owns its data outright. It depends on nothing and can be
65
+ * freed at any time, before or after everything else.
66
+ *
67
+ * Text is NOT guaranteed NUL-terminated - a text value may contain a NUL byte,
68
+ * and pretending otherwise would truncate it silently. Byte pointers therefore
69
+ * come with a length out-parameter. The few strings that ARE C strings say so
70
+ * on the function.
71
+ *
72
+ *
73
+ * THREADS
74
+ *
75
+ * One file is one buffer pool and the engine is single threaded. A
76
+ * inillucent_db and everything under it must be confined to one thread, or
77
+ * every call on it serialised by a lock you own. There is no lock inside.
78
+ * Two databases on two files are independent.
79
+ */
80
+
81
+ #ifndef INILLUCENT_DRIVER_H
82
+ #define INILLUCENT_DRIVER_H
83
+
84
+ #include <stddef.h>
85
+ #include <stdint.h>
86
+
87
+ #ifdef __cplusplus
88
+ extern "C" {
89
+ #endif
90
+
91
+ /* ------------------------------------------------------------------ */
92
+ /* Handles. Every one is opaque; none has a layout you may rely on. */
93
+ /* ------------------------------------------------------------------ */
94
+
95
+ typedef struct inillucent_db inillucent_db; /* an open database file */
96
+ typedef struct inillucent_conn inillucent_conn; /* a connection to one */
97
+ typedef struct inillucent_stmt inillucent_stmt; /* a statement + bindings */
98
+ typedef struct inillucent_rows inillucent_rows; /* what a statement said */
99
+ typedef struct inillucent_txn inillucent_txn; /* an open transaction */
100
+ typedef struct inillucent_error inillucent_error; /* one failure */
101
+
102
+ /* ------------------------------------------------------------------ */
103
+ /* Status codes. Frozen at 1.0; a new one takes the next number. */
104
+ /* ------------------------------------------------------------------ */
105
+
106
+ #define INILLUCENT_OK 0
107
+ #define INILLUCENT_UNSUPPORTED 1 /* this engine cannot do that yet */
108
+ #define INILLUCENT_SYNTAX 2 /* the statement is not valid SQL */
109
+ #define INILLUCENT_NOT_FOUND 3 /* no such table, column or index */
110
+ #define INILLUCENT_CONSTRAINT 4 /* a constraint refused the write */
111
+ #define INILLUCENT_READONLY 5
112
+ #define INILLUCENT_BUSY 6
113
+ #define INILLUCENT_INTERRUPTED 7
114
+ #define INILLUCENT_CORRUPT 8
115
+ #define INILLUCENT_IO 9
116
+ #define INILLUCENT_FULL 10
117
+ #define INILLUCENT_TOO_BIG 11
118
+ #define INILLUCENT_INVALID_STATE 12 /* you broke this API's own contract */
119
+ /* The same code, under the name the handle rules use for it: a freed handle, a
120
+ * double free, or a bind index past the statement's parameter count. Every one
121
+ * of those was undefined behaviour before task-1980 - a heap corruption, a
122
+ * silently wrong value, or an allocation of tens of gigabytes. */
123
+ #define INILLUCENT_MISUSE INILLUCENT_INVALID_STATE
124
+ #define INILLUCENT_INTERNAL 13 /* a defect - please report it */
125
+
126
+ /* Value kinds, as inillucent_value_type reports them. Also frozen. */
127
+ #define INILLUCENT_NULL 0
128
+ #define INILLUCENT_INTEGER 1
129
+ #define INILLUCENT_REAL 2
130
+ #define INILLUCENT_TEXT 3
131
+ #define INILLUCENT_BLOB 4
132
+
133
+ /* Capability states, as inillucent_capability and inillucent_supports
134
+ * report them. PARTIAL means "yes, with the limit the note names", and a
135
+ * binding that treats it as YES without reading the note will be surprised. */
136
+ #define INILLUCENT_SUPPORT_NO 0
137
+ #define INILLUCENT_SUPPORT_YES 1
138
+ #define INILLUCENT_SUPPORT_PARTIAL (-1)
139
+ #define INILLUCENT_SUPPORT_UNKNOWN (-2) /* no such capability in this build */
140
+
141
+ /* Flags for inillucent_open. */
142
+ #define INILLUCENT_OPEN_CREATE 0x0001 /* make the file if absent */
143
+ #define INILLUCENT_OPEN_READONLY 0x0002 /* refuse anything but a query */
144
+ #define INILLUCENT_OPEN_DIAGNOSTICS 0x0004 /* see inillucent_error_detail */
145
+
146
+ /* ------------------------------------------------------------------ */
147
+ /* The library itself. */
148
+ /* ------------------------------------------------------------------ */
149
+
150
+ /* major*1000000 + minor*1000 + patch. Check the MAJOR at load and refuse a
151
+ * mismatch by name; that is the whole reason this exists. */
152
+ uint32_t inillucent_abi_version(void);
153
+
154
+ /* What the driver calls itself. A C string, valid forever. */
155
+ const char *inillucent_version(void);
156
+
157
+ /* How many capabilities this build knows about. */
158
+ size_t inillucent_capability_count(void);
159
+
160
+ /* Reads one capability. `name` and `note` are C strings valid forever;
161
+ * `state` is one of the INILLUCENT_SUPPORT_* values. Any out-parameter may be
162
+ * NULL if you do not want it. Returns INILLUCENT_INVALID_STATE if `nth` is
163
+ * past the end. */
164
+ int32_t inillucent_capability(size_t nth, const char **name, int32_t *state,
165
+ const char **note);
166
+
167
+ /* Looks one up by name. Returns an INILLUCENT_SUPPORT_* value, and
168
+ * INILLUCENT_SUPPORT_UNKNOWN for a name this build has never heard of - which
169
+ * you should treat as "no", never as "yes": a capability that was never
170
+ * declared was certainly never checked. */
171
+ int32_t inillucent_supports(const char *name);
172
+
173
+ /* ------------------------------------------------------------------ */
174
+ /* A database. */
175
+ /* ------------------------------------------------------------------ */
176
+
177
+ /* Opens (and by default creates) a database. `path` is UTF-8.
178
+ * On failure *out is left alone and *error, if you passed one, is set. */
179
+ int32_t inillucent_open(const char *path, uint32_t flags, inillucent_db **out,
180
+ inillucent_error **error);
181
+
182
+ /* Checkpoints and closes. Refuses with INILLUCENT_INVALID_STATE while any
183
+ * connection on it is still open, rather than leaving them dangling. */
184
+ int32_t inillucent_close(inillucent_db *db, inillucent_error **error);
185
+
186
+ /* Makes everything written so far durable in the file. */
187
+ int32_t inillucent_checkpoint(inillucent_db *db, inillucent_error **error);
188
+
189
+ /* Walks every tree and reports the first thing that is wrong. */
190
+ int32_t inillucent_integrity_check(inillucent_db *db, inillucent_error **error);
191
+
192
+ /* Copies the database to a path, and opens and checks the copy before
193
+ * returning - because a backup nobody checked is a file that is assumed to be
194
+ * a database. */
195
+ int32_t inillucent_backup_to(inillucent_db *db, const char *path,
196
+ inillucent_error **error);
197
+
198
+ /* The file this database is in, as a C string valid until it is closed. */
199
+ const char *inillucent_path(const inillucent_db *db);
200
+
201
+ /* ------------------------------------------------------------------ */
202
+ /* A connection. */
203
+ /* ------------------------------------------------------------------ */
204
+
205
+ int32_t inillucent_connect(inillucent_db *db, inillucent_conn **out,
206
+ inillucent_error **error);
207
+
208
+ /* Frees the connection handle. Legal while a statement or transaction made on
209
+ * it is still alive: they share the connection's state, which lives until the
210
+ * last of them is freed. The database still refuses to close until then. */
211
+ void inillucent_conn_free(inillucent_conn *conn);
212
+
213
+ /* Runs one statement with nothing bound and collects every row it produced.
214
+ * `limit` caps the rows HANDED BACK, not the rows produced - see
215
+ * inillucent_rows_total and inillucent_rows_more. */
216
+ int32_t inillucent_execute(inillucent_conn *conn, const char *sql,
217
+ uint64_t limit, inillucent_rows **out,
218
+ inillucent_error **error);
219
+
220
+ /* Runs several statements separated by semicolons, for their effect. */
221
+ int32_t inillucent_execute_batch(inillucent_conn *conn, const char *sql,
222
+ inillucent_error **error);
223
+
224
+ int64_t inillucent_last_insert_rowid(inillucent_conn *conn);
225
+ int64_t inillucent_total_changes(inillucent_conn *conn);
226
+
227
+ /* 1 while a transaction is open, 0 otherwise. */
228
+ int32_t inillucent_in_transaction(inillucent_conn *conn);
229
+
230
+ /* The schema's generation, which changes when the schema does. Compare it to
231
+ * know whether a cached table description is stale. */
232
+ uint64_t inillucent_schema_cookie(inillucent_conn *conn);
233
+
234
+ /* Asks a running statement to stop. Safe to call from another thread while a
235
+ * statement is running - it is the one call here that is - because it sets a
236
+ * flag rather than touching the statement. The statement then fails with
237
+ * INILLUCENT_INTERRUPTED and the connection stays usable.
238
+ *
239
+ * inillucent_supports("cancel") reports PARTIAL, and the limit it is reporting
240
+ * is WHEN rather than whether: the flag is read at every leaf of a scan and
241
+ * every batch a result collects, so a long scan, a large result and a slow join
242
+ * all stop, while a single operator part-way through one indivisible piece of
243
+ * work finishes it first. Draw a Stop button; do not promise it is instant.
244
+ *
245
+ * A cancel with nothing running cancels nothing: the next statement clears the
246
+ * flag as it starts. */
247
+ int32_t inillucent_cancel(inillucent_conn *conn, inillucent_error **error);
248
+
249
+ /* ------------------------------------------------------------------ */
250
+ /* A statement, for binding values and running more than once. */
251
+ /* ------------------------------------------------------------------ */
252
+
253
+ int32_t inillucent_prepare(inillucent_conn *conn, const char *sql,
254
+ inillucent_stmt **out, inillucent_error **error);
255
+
256
+ /* Frees the statement. Legal before or after its connection is freed. */
257
+ void inillucent_stmt_free(inillucent_stmt *stmt);
258
+
259
+ /* Parameters are one-based, matching ?1, ?2 in the SQL. Binding an index past
260
+ * the end grows the binding list with NULLs, which is what makes binding out
261
+ * of order work. Every one of these copies what it is given. */
262
+ int32_t inillucent_bind_null(inillucent_stmt *stmt, uint32_t index);
263
+ int32_t inillucent_bind_int(inillucent_stmt *stmt, uint32_t index, int64_t value);
264
+ int32_t inillucent_bind_real(inillucent_stmt *stmt, uint32_t index, double value);
265
+ int32_t inillucent_bind_text(inillucent_stmt *stmt, uint32_t index,
266
+ const char *value, size_t len);
267
+ int32_t inillucent_bind_blob(inillucent_stmt *stmt, uint32_t index,
268
+ const uint8_t *value, size_t len);
269
+
270
+ /* Unbinds everything. */
271
+ void inillucent_clear_bindings(inillucent_stmt *stmt);
272
+
273
+ /* Runs it with what is bound. May be called repeatedly with new bindings. */
274
+ int32_t inillucent_stmt_execute(inillucent_stmt *stmt, uint64_t limit,
275
+ inillucent_rows **out, inillucent_error **error);
276
+
277
+ /* ------------------------------------------------------------------ */
278
+ /* A result. Materialised, so every pointer below is stable until free. */
279
+ /* ------------------------------------------------------------------ */
280
+
281
+ void inillucent_rows_free(inillucent_rows *rows);
282
+
283
+ size_t inillucent_rows_column_count(const inillucent_rows *rows);
284
+
285
+ /* A C string valid until the result is freed; NULL if `nth` is past the end. */
286
+ const char *inillucent_rows_column_name(const inillucent_rows *rows, size_t nth);
287
+
288
+ /* The type the schema declared, or "" for an expression, which has none. */
289
+ const char *inillucent_rows_column_type(const inillucent_rows *rows, size_t nth);
290
+
291
+ /* How many rows you were handed. */
292
+ size_t inillucent_rows_count(const inillucent_rows *rows);
293
+
294
+ /* How many the statement produced, EXACTLY - not an estimate. The engine
295
+ * materialises, so this was counted rather than guessed, which is what lets a
296
+ * grid say "1-200 of 4,317" honestly. */
297
+ size_t inillucent_rows_total(const inillucent_rows *rows);
298
+
299
+ /* 1 when the limit cut something off. */
300
+ int32_t inillucent_rows_more(const inillucent_rows *rows);
301
+
302
+ /* Rows changed, or -1 for a statement that changed nothing (a query). */
303
+ int64_t inillucent_rows_affected(const inillucent_rows *rows);
304
+
305
+ uint64_t inillucent_rows_elapsed_us(const inillucent_rows *rows);
306
+
307
+ /* A one-line summary for a status bar - "SELECT 27". A C string. */
308
+ const char *inillucent_rows_tag(const inillucent_rows *rows);
309
+
310
+ /* One of the INILLUCENT_NULL..INILLUCENT_BLOB values, or INILLUCENT_NULL for
311
+ * a cell that is not there - so check the counts rather than probing. */
312
+ int32_t inillucent_value_type(const inillucent_rows *rows, size_t row, size_t column);
313
+
314
+ int64_t inillucent_value_int(const inillucent_rows *rows, size_t row, size_t column);
315
+ double inillucent_value_real(const inillucent_rows *rows, size_t row, size_t column);
316
+
317
+ /* Text or blob bytes, with the length written to *len. NOT NUL-terminated: a
318
+ * text value may contain a NUL byte and truncating there would lose data
319
+ * silently. Returns NULL and sets *len to 0 for NULL, a number, or a cell that
320
+ * is not there. */
321
+ const uint8_t *inillucent_value_bytes(const inillucent_rows *rows, size_t row,
322
+ size_t column, size_t *len);
323
+
324
+ /* ------------------------------------------------------------------ */
325
+ /* A transaction. */
326
+ /* ------------------------------------------------------------------ */
327
+
328
+ /*
329
+ * WHY THIS IS A HANDLE AND NOT A PAIR OF FUNCTIONS
330
+ *
331
+ * The rule this exists to serve is that a check on what a write DID must
332
+ * happen before the COMMIT, not after: a postcondition tested after the commit
333
+ * is a report about something that has already happened rather than a guard
334
+ * against it. So a transaction is a handle you hold while you read
335
+ * inillucent_txn_affected for each statement, decide, and only then commit.
336
+ *
337
+ * A handle freed without commit or rollback rolls back.
338
+ */
339
+ int32_t inillucent_txn_begin(inillucent_conn *conn, inillucent_txn **out,
340
+ inillucent_error **error);
341
+
342
+ /* Runs one statement inside it, writing how many rows it changed to
343
+ * *affected. On failure the transaction is rolled back and the handle is
344
+ * spent: free it. */
345
+ int32_t inillucent_txn_execute(inillucent_txn *txn, const char *sql,
346
+ uint64_t *affected, inillucent_error **error);
347
+
348
+ /* Commits. The handle is spent either way; free it. */
349
+ int32_t inillucent_txn_commit(inillucent_txn *txn, inillucent_error **error);
350
+
351
+ /* Rolls back and frees. Never fails in a way you can act on, so it returns
352
+ * nothing. */
353
+ void inillucent_txn_rollback(inillucent_txn *txn);
354
+
355
+ /* ------------------------------------------------------------------ */
356
+ /* A failure. */
357
+ /* ------------------------------------------------------------------ */
358
+
359
+ int32_t inillucent_error_status(const inillucent_error *error);
360
+
361
+ /* What happened, in the engine's own words. A C string, safe to show a person:
362
+ * it never holds a file-system path, a bound value, or page bytes. */
363
+ const char *inillucent_error_message(const inillucent_error *error);
364
+
365
+ /* The construct the engine has not implemented - "an outer join", "VACUUM".
366
+ * NULL unless the status is INILLUCENT_UNSUPPORTED. Finer-grained than the
367
+ * capability table on purpose, so an application can name what it hit without
368
+ * owning a list of every phrase. */
369
+ const char *inillucent_error_feature(const inillucent_error *error);
370
+
371
+ /* Internal diagnostic text. NULL unless the database was opened with
372
+ * INILLUCENT_OPEN_DIAGNOSTICS. It MAY hold a path or a bound value, so do not
373
+ * show it to a person and do not send it to a shared log. */
374
+ const char *inillucent_error_detail(const inillucent_error *error);
375
+
376
+ /* The byte offset into the statement, or -1 when there is none. */
377
+ int32_t inillucent_error_offset(const inillucent_error *error);
378
+
379
+ void inillucent_error_free(inillucent_error *error);
380
+
381
+ #ifdef __cplusplus
382
+ } /* extern "C" */
383
+ #endif
384
+
385
+ #endif /* INILLUCENT_DRIVER_H */
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blackrainbowlabs/cli-win32-x64",
3
- "version": "0.1.3",
3
+ "version": "0.1.6",
4
4
  "description": "The inillucent binaries for win32-x64. Installed automatically by the 'inillucent' package; there is no reason to depend on this directly.",
5
5
  "homepage": "https://github.com/Black-Rainbow-Labs/Inillucent#readme",
6
6
  "repository": {