-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathsqlite3-wasm.c
More file actions
1966 lines (1849 loc) · 64.8 KB
/
sqlite3-wasm.c
File metadata and controls
1966 lines (1849 loc) · 64.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** This file requires access to sqlite3.c static state in order to
** implement certain WASM-specific features, and thus directly
** includes that file. Unlike the rest of sqlite3.c, this file
** requires compiling with -std=c99 (or equivalent, or a later C
** version) because it makes use of features not available in C89.
**
** At its simplest, to build sqlite3.wasm either place this file
** in the same directory as sqlite3.c/h before compilation or use the
** -I/path flag to tell the compiler where to find both of those
** files, then compile this file. For example:
**
** emcc -o sqlite3.wasm ... -I/path/to/sqlite3-c-and-h sqlite3-wasm.c
*/
#define SQLITE_WASM
#ifdef SQLITE_WASM_ENABLE_C_TESTS
# undef SQLITE_WASM_ENABLE_C_TESTS
# define SQLITE_WASM_ENABLE_C_TESTS 1
/*
** Code blocked off by SQLITE_WASM_ENABLE_C_TESTS is intended solely
** for use in unit/regression testing. They may be safely omitted from
** client-side builds. The main unit test script, tester1.js, will
** skip related tests if it doesn't find the corresponding functions
** in the WASM exports.
*/
#else
# define SQLITE_WASM_ENABLE_C_TESTS 0
#endif
/*
** Threading and file locking: JS is single-threaded. Each Worker
** thread is a separate instance of the JS engine so can never access
** the same db handle as another thread, thus multi-threading support
** is unnecessary in the library. Because the filesystems are virtual
** and local to a given wasm runtime instance, two Workers can never
** access the same db file at once, with the exception of OPFS.
**
** Summary: except for the case of OPFS, which supports locking using
** its own API, threading and file locking support are unnecessary in
** the wasm build.
*/
/*
** Undefine any SQLITE_... config flags which we specifically do not
** want defined. Please keep these alphabetized.
*/
#undef SQLITE_OMIT_DESERIALIZE
#undef SQLITE_OMIT_MEMORYDB
/*
** Define any SQLITE_... config defaults we want if they aren't
** overridden by the builder. Please keep these alphabetized.
*/
/**********************************************************************/
/* SQLITE_D... */
#ifndef SQLITE_DEFAULT_CACHE_SIZE
/*
** The OPFS impls benefit tremendously from an increased cache size
** when working on large workloads, e.g. speedtest1 --size 50 or
** higher. On smaller workloads, e.g. speedtest1 --size 25, they
** clearly benefit from having 4mb of cache, but not as much as a
** larger cache benefits the larger workloads. Speed differences
** between 2x and nearly 3x have been measured with ample page cache.
*/
# define SQLITE_DEFAULT_CACHE_SIZE -16384
#endif
#if !defined(SQLITE_DEFAULT_PAGE_SIZE)
/*
** OPFS performance is improved by approx. 12% with a page size of 8kb
** instead of 4kb. Performance with 16kb is equivalent to 8kb.
**
** Performance difference of kvvfs with a page size of 8kb compared to
** 4kb, as measured by speedtest1 --size 4, is indeterminate:
** measurements are all over the place either way and not
** significantly different.
*/
# define SQLITE_DEFAULT_PAGE_SIZE 8192
#endif
#ifndef SQLITE_DEFAULT_UNIX_VFS
# define SQLITE_DEFAULT_UNIX_VFS "unix-none"
#endif
#undef SQLITE_DQS
#define SQLITE_DQS 0
/**********************************************************************/
/* SQLITE_ENABLE_... */
/*
** Unconditionally enable API_ARMOR in the WASM build. It ensures that
** public APIs behave predictable in the face of passing illegal NULLs
** or ranges which might otherwise invoke undefined behavior.
*/
#undef SQLITE_ENABLE_API_ARMOR
#define SQLITE_ENABLE_API_ARMOR 1
/**********************************************************************/
/* SQLITE_EXPERIMENTAL_PRAGMA_20251114 */
/*
** See:
** https://sqlite.org/src/info/e2b3f1a9480a9be3
** https://github.com/rhashimoto/wa-sqlite/discussions/301
**
** It is enabled here for the sake of VFS experimentors.
*/
#undef SQLITE_EXPERIMENTAL_PRAGMA_20251114
#define SQLITE_EXPERIMENTAL_PRAGMA_20251114
/**********************************************************************/
/* SQLITE_O... */
#undef SQLITE_OMIT_DEPRECATED
#define SQLITE_OMIT_DEPRECATED 1
#undef SQLITE_OMIT_LOAD_EXTENSION
#define SQLITE_OMIT_LOAD_EXTENSION 1
#undef SQLITE_OMIT_SHARED_CACHE
#define SQLITE_OMIT_SHARED_CACHE 1
#undef SQLITE_OMIT_UTF16
#define SQLITE_OMIT_UTF16 1
#undef SQLITE_OS_KV_OPTIONAL
#define SQLITE_OS_KV_OPTIONAL 1
/**********************************************************************/
/* SQLITE_S... */
#ifndef SQLITE_STRICT_SUBTYPE
# define SQLITE_STRICT_SUBTYPE 1
#endif
/**********************************************************************/
/* SQLITE_T... */
#ifndef SQLITE_TEMP_STORE
# define SQLITE_TEMP_STORE 2
#endif
#ifndef SQLITE_THREADSAFE
# define SQLITE_THREADSAFE 0
#endif
/**********************************************************************/
/* SQLITE_USE_... */
#ifndef SQLITE_USE_URI
# define SQLITE_USE_URI 1
#endif
#ifdef SQLITE_WASM_EXTRA_INIT
/* SQLITE_EXTRA_INIT vs SQLITE_EXTRA_INIT_MUTEXED:
** see https://sqlite.org/forum/forumpost/14183b98fc0b1dea */
# define SQLITE_EXTRA_INIT_MUTEXED sqlite3_wasm_extra_init
#endif
/*
** If SQLITE_WASM_BARE_BONES is defined, undefine most of the ENABLE
** macros. This will, when using the canonical makefile, also elide
** any C functions from the WASM exports: see
** ./EXPORTED_FUNCTIONS.c-pp.
*/
#ifdef SQLITE_WASM_BARE_BONES
# undef SQLITE_ENABLE_COLUMN_METADATA
# undef SQLITE_ENABLE_DBPAGE_VTAB
# undef SQLITE_ENABLE_DBSTAT_VTAB
# undef SQLITE_ENABLE_EXPLAIN_COMMENTS
# undef SQLITE_ENABLE_FTS5
# undef SQLITE_ENABLE_OFFSET_SQL_FUNC
# undef SQLITE_ENABLE_PERCENTILE
# undef SQLITE_ENABLE_PREUPDATE_HOOK
# undef SQLITE_ENABLE_RTREE
# undef SQLITE_ENABLE_SESSION
# undef SQLITE_ENABLE_STMTVTAB
# undef SQLITE_OMIT_AUTHORIZATION
# define SQLITE_OMIT_AUTHORIZATION
# undef SQLITE_OMIT_GET_TABLE
# define SQLITE_OMIT_GET_TABLE
# undef SQLITE_OMIT_INCRBLOB
# define SQLITE_OMIT_INCRBLOB
# undef SQLITE_OMIT_INTROSPECTION_PRAGMAS
# define SQLITE_OMIT_INTROSPECTION_PRAGMAS
# undef SQLITE_OMIT_JSON
# define SQLITE_OMIT_JSON
# undef SQLITE_OMIT_PROGRESS_CALLBACK
# define SQLITE_OMIT_PROGRESS_CALLBACK
# undef SQLITE_OMIT_WAL
# define SQLITE_OMIT_WAL
/*
The following OMITs do not work with the standard amalgamation, so
require a custom build:
fossil clean -x
./configure
OPTS='...' make -e sqlite3
where ... has a -D... for each of the following OMIT flags:
# undef SQLITE_OMIT_EXPLAIN
# define SQLITE_OMIT_EXPLAIN
# undef SQLITE_OMIT_TRIGGER
# define SQLITE_OMIT_TRIGGER
# undef SQLITE_OMIT_VIRTUALTABLE
# define SQLITE_OMIT_VIRTUALTABLE
# undef SQLITE_OMIT_WINDOWFUNC
# define SQLITE_OMIT_WINDOWFUNC
As of this writing (2024-07-25), such a build fails in various ways
for as-yet-unknown reasons.
*/
#endif
#if !defined(SQLITE_OMIT_VIRTUALTABLE) && !defined(SQLITE_WASM_BARE_BONES)
# define SQLITE_WASM_HAS_VTAB 1
#else
# define SQLITE_WASM_HAS_VTAB 0
#endif
#include <assert.h>
/*
** SQLITE_WASM_EXPORT is functionally identical to EMSCRIPTEN_KEEPALIVE
** but is not Emscripten-specific. It explicitly marks functions for
** export into the target wasm file without requiring explicit listing
** of those functions in Emscripten's -sEXPORTED_FUNCTIONS=... list
** (or equivalent in other build platforms). Any function with neither
** this attribute nor which is listed as an explicit export will not
** be exported from the wasm file (but may still be used internally
** within the wasm file).
**
** The functions in this file (sqlite3-wasm.c) which require exporting
** are marked with this flag. They may also be added to any explicit
** build-time export list but need not be. All of these APIs are
** intended for use only within the project's own JS/WASM code, and
** not by client code, so an argument can be made for reducing their
** visibility by not including them in any build-time export lists.
**
** 2025-12-01: for use in non-Emscripten builds, we need a more
** invasive macro which explicitly names the export:
** SQLITE_WASM_EXPORT2.
*/
#define SQLITE_WASM_EXPORT __attribute__((used,visibility("default")))
#define SQLITE_WASM_EXPORT_NAMED(X) __attribute__((export_name(#X),used,visibility("default")))
#define SQLITE_WASM_EXPORT2(RETTYPE,NAME,SIG) SQLITE_WASM_EXPORT_NAMED(NAME) RETTYPE NAME SIG
#if 1
/** Increase the kvvfs key size limit from 32. */
#define KVRECORD_KEY_SZ 128
#endif
/*
** Which sqlite3.c we're using needs to be configurable to enable
** building against a custom copy, e.g. the SEE variant. We #include
** the .c file, rather than the header, so that the WASM extensions
** have access to private API internals (namely for kvvfs and
** SQLTester pieces).
**
** The caveat here is that custom variants need to account for
** exporting any necessary symbols (e.g. sqlite3_activate_see()). We
** cannot export them from here using SQLITE_WASM_EXPORT because that
** attribute (apparently) has to be part of the function definition.
*/
#ifndef SQLITE_C
# define SQLITE_C sqlite3.c /* yes, .c instead of .h. */
#endif
#define INC__STRINGIFY_(f) #f
#define INC__STRINGIFY(f) INC__STRINGIFY_(f)
#include INC__STRINGIFY(SQLITE_C)
#undef INC__STRINGIFY_
#undef INC__STRINGIFY
#undef SQLITE_C
/*
** State for the "pseudo-stack" allocator implemented in
** sqlite3__wasm_pstack_xyz(). In order to avoid colliding with
** Emscripten-controlled stack space, it carves out a bit of stack
** memory to use for that purpose. This memory ends up in the
** WASM-managed memory, such that routines which manipulate the wasm
** heap can also be used to manipulate this memory.
**
** This particular allocator is intended for small allocations such as
** storage for output pointers. We cannot reasonably size it large
** enough for general-purpose string conversions because some of our
** tests use input files (strings) of 16MB+.
*/
static unsigned char PStack_mem[
1024 * 4 /* API docs guaranty at least 2kb and it's been set at 4kb
since it was introduced. */
] = {0};
static struct {
unsigned const char * const pBegin;/* Start (inclusive) of memory */
unsigned const char * const pEnd; /* One-after-the-end of memory */
unsigned char * pPos; /* Current stack pointer */
} PStack = {
&PStack_mem[0],
&PStack_mem[0] + sizeof(PStack_mem),
&PStack_mem[0] + sizeof(PStack_mem)
};
/*
** Returns the current pstack position.
*/
SQLITE_WASM_EXPORT void * sqlite3__wasm_pstack_ptr(void){
return PStack.pPos;
}
/*
** Sets the pstack position pointer to p. Results are undefined if the
** given value did not come from sqlite3__wasm_pstack_ptr().
*/
SQLITE_WASM_EXPORT void sqlite3__wasm_pstack_restore(unsigned char * p){
assert(p>=PStack.pBegin && p<=PStack.pEnd && p>=PStack.pPos);
assert(0==((unsigned long long)p & 0x7) /* 8-byte aligned */);
if(p>=PStack.pBegin && p<=PStack.pEnd /*&& p>=PStack.pPos*/){
PStack.pPos = p;
}
}
/*
** Allocate and zero out n bytes from the pstack. Returns a pointer to
** the memory on success, 0 on error (including a negative n value). n
** is always adjusted to be a multiple of 8 and returned memory is
** always zeroed out before returning (because this keeps the client
** JS code from having to do so, and most uses of the pstack call for
** doing so).
*/
SQLITE_WASM_EXPORT2(void *,sqlite3__wasm_pstack_alloc,(int n)){
if( n<=0 ) return 0;
n = (n + 7) & ~7 /* align to 8-byte boundary */;
if( PStack.pBegin + n > PStack.pPos /*not enough space left*/
|| PStack.pBegin + n <= PStack.pBegin /*overflow*/ ) return 0;
memset((PStack.pPos = PStack.pPos - n), 0, (unsigned int)n);
return PStack.pPos;
}
/*
** Return the number of bytes left which can be
** sqlite3__wasm_pstack_alloc()'d.
*/
SQLITE_WASM_EXPORT2(int,sqlite3__wasm_pstack_remaining,(void)){
assert(PStack.pPos >= PStack.pBegin);
assert(PStack.pPos <= PStack.pEnd);
return (int)(PStack.pPos - PStack.pBegin);
}
/*
** Return the total number of bytes available in the pstack, including
** any space which is currently allocated. This value is a
** compile-time constant.
*/
SQLITE_WASM_EXPORT2(int,sqlite3__wasm_pstack_quota,(void)){
return (int)(PStack.pEnd - PStack.pBegin);
}
#if SQLITE_WASM_ENABLE_C_TESTS
struct WasmTestStruct {
int v4;
void * ppV;
const char * cstr;
int64_t v8;
void (*xFunc)(void*);
};
typedef struct WasmTestStruct WasmTestStruct;
SQLITE_WASM_EXPORT2(void,sqlite3__wasm_test_struct,(WasmTestStruct * s)){
if(s){
if( 0 ){
/* Do not be alarmed by the small (and odd) pointer values.
Function pointers in WASM are their index into the
indirect function table, not their address. */
fprintf(stderr,"%s:%s()@%p s=@%p xFunc=@%p\n",
__FILE__, __func__,
(void*)sqlite3__wasm_test_struct,
s, (void*)s->xFunc);
}
s->v4 *= 2;
s->v8 = s->v4 * 2;
s->ppV = s;
s->cstr = __FILE__;
if(s->xFunc) s->xFunc(s);
}
}
#endif /* SQLITE_WASM_ENABLE_C_TESTS */
/*
** This function is NOT part of the sqlite3 public API. It is strictly
** for use by the sqlite project's own JS/WASM bindings. Unlike the
** rest of the sqlite3 API, this part requires C99 for snprintf() and
** variadic macros.
**
** Returns a string containing a JSON-format "enum" of C-level
** constants and struct-related metadata intended to be imported into
** the JS environment. The JSON is initialized the first time this
** function is called and that result is reused for all future calls.
**
** If this function returns NULL then it means that the internal
** buffer is not large enough for the generated JSON and needs to be
** increased. In debug builds that will trigger an assert().
**
** 2025-09-19: for reasons entirely not understood, building with emcc
** -sMEMORY64=2 causes this function to fail (return 0). -sMEMORY64=1
** fails to compile with "tables may not be 64-bit" but does not tell
** us where it's happening.
*/
SQLITE_WASM_EXPORT2(const char *,sqlite3__wasm_enum_json,(void)){
static char aBuffer[1024 * 20] =
{0} /* where the JSON goes. 2025-09-19: output size=19295, but
that can vary slightly from build to build, so a little
leeway is needed here. */;
int n = 0, nChildren = 0, nStruct = 0
/* output counters for figuring out where commas go */;
char * zPos = &aBuffer[1] /* skip first byte for now to help protect
** against a small race condition */;
char const * const zEnd = &aBuffer[0] + sizeof(aBuffer) /* one-past-the-end */;
if(aBuffer[0]) return aBuffer;
/* Leave aBuffer[0] at 0 until the end to help guard against a tiny
** race condition. If this is called twice concurrently, they might
** end up both writing to aBuffer, but they'll both write the same
** thing, so that's okay. If we set byte 0 up front then the 2nd
** instance might return and use the string before the 1st instance
** is done filling it. */
/* Core output macros... */
#define lenCheck assert(zPos < zEnd - 128 \
&& "sqlite3__wasm_enum_json() buffer is too small."); \
if( zPos >= zEnd - 128 ) return 0
#define outf(format,...) \
zPos += snprintf(zPos, ((size_t)(zEnd - zPos)), format, __VA_ARGS__); \
lenCheck
#define out(TXT) outf("%s",TXT)
#define CloseBrace(LEVEL) \
assert(LEVEL<5); memset(zPos, '}', LEVEL); zPos+=LEVEL; lenCheck
/* Macros for emitting maps of integer- and string-type macros to
** their values. */
#define DefGroup(KEY) n = 0; \
outf("%s\"" #KEY "\": {",(nChildren++ ? "," : ""));
#define DefInt(KEY) \
outf("%s\"%s\": %d", (n++ ? ", " : ""), #KEY, (int)KEY)
#define DefStr(KEY) \
outf("%s\"%s\": \"%s\"", (n++ ? ", " : ""), #KEY, KEY)
#define _DefGroup CloseBrace(1)
/* The following groups are sorted alphabetic by group name. */
DefGroup(access){
DefInt(SQLITE_ACCESS_EXISTS);
DefInt(SQLITE_ACCESS_READWRITE);
DefInt(SQLITE_ACCESS_READ)/*docs say this is unused*/;
} _DefGroup;
DefGroup(authorizer){
DefInt(SQLITE_DENY);
DefInt(SQLITE_IGNORE);
DefInt(SQLITE_CREATE_INDEX);
DefInt(SQLITE_CREATE_TABLE);
DefInt(SQLITE_CREATE_TEMP_INDEX);
DefInt(SQLITE_CREATE_TEMP_TABLE);
DefInt(SQLITE_CREATE_TEMP_TRIGGER);
DefInt(SQLITE_CREATE_TEMP_VIEW);
DefInt(SQLITE_CREATE_TRIGGER);
DefInt(SQLITE_CREATE_VIEW);
DefInt(SQLITE_DELETE);
DefInt(SQLITE_DROP_INDEX);
DefInt(SQLITE_DROP_TABLE);
DefInt(SQLITE_DROP_TEMP_INDEX);
DefInt(SQLITE_DROP_TEMP_TABLE);
DefInt(SQLITE_DROP_TEMP_TRIGGER);
DefInt(SQLITE_DROP_TEMP_VIEW);
DefInt(SQLITE_DROP_TRIGGER);
DefInt(SQLITE_DROP_VIEW);
DefInt(SQLITE_INSERT);
DefInt(SQLITE_PRAGMA);
DefInt(SQLITE_READ);
DefInt(SQLITE_SELECT);
DefInt(SQLITE_TRANSACTION);
DefInt(SQLITE_UPDATE);
DefInt(SQLITE_ATTACH);
DefInt(SQLITE_DETACH);
DefInt(SQLITE_ALTER_TABLE);
DefInt(SQLITE_REINDEX);
DefInt(SQLITE_ANALYZE);
DefInt(SQLITE_CREATE_VTABLE);
DefInt(SQLITE_DROP_VTABLE);
DefInt(SQLITE_FUNCTION);
DefInt(SQLITE_SAVEPOINT);
//DefInt(SQLITE_COPY) /* No longer used */;
DefInt(SQLITE_RECURSIVE);
} _DefGroup;
DefGroup(blobFinalizers) {
/* SQLITE_STATIC/TRANSIENT need to be handled explicitly as
** integers to avoid casting-related warnings. */
out("\"SQLITE_STATIC\":0, \"SQLITE_TRANSIENT\":-1");
outf(",\"SQLITE_WASM_DEALLOC\": %lld",
(sqlite3_int64)(sqlite3_free));
} _DefGroup;
DefGroup(changeset){
#ifdef SQLITE_CHANGESETSTART_INVERT
DefInt(SQLITE_CHANGESETSTART_INVERT);
DefInt(SQLITE_CHANGESETAPPLY_NOSAVEPOINT);
DefInt(SQLITE_CHANGESETAPPLY_INVERT);
DefInt(SQLITE_CHANGESETAPPLY_IGNORENOOP);
DefInt(SQLITE_CHANGESET_DATA);
DefInt(SQLITE_CHANGESET_NOTFOUND);
DefInt(SQLITE_CHANGESET_CONFLICT);
DefInt(SQLITE_CHANGESET_CONSTRAINT);
DefInt(SQLITE_CHANGESET_FOREIGN_KEY);
DefInt(SQLITE_CHANGESET_OMIT);
DefInt(SQLITE_CHANGESET_REPLACE);
DefInt(SQLITE_CHANGESET_ABORT);
#endif
} _DefGroup;
DefGroup(config){
DefInt(SQLITE_CONFIG_SINGLETHREAD);
DefInt(SQLITE_CONFIG_MULTITHREAD);
DefInt(SQLITE_CONFIG_SERIALIZED);
DefInt(SQLITE_CONFIG_MALLOC);
DefInt(SQLITE_CONFIG_GETMALLOC);
DefInt(SQLITE_CONFIG_SCRATCH);
DefInt(SQLITE_CONFIG_PAGECACHE);
DefInt(SQLITE_CONFIG_HEAP);
DefInt(SQLITE_CONFIG_MEMSTATUS);
DefInt(SQLITE_CONFIG_MUTEX);
DefInt(SQLITE_CONFIG_GETMUTEX);
/* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
DefInt(SQLITE_CONFIG_LOOKASIDE);
DefInt(SQLITE_CONFIG_PCACHE);
DefInt(SQLITE_CONFIG_GETPCACHE);
DefInt(SQLITE_CONFIG_LOG);
DefInt(SQLITE_CONFIG_URI);
DefInt(SQLITE_CONFIG_PCACHE2);
DefInt(SQLITE_CONFIG_GETPCACHE2);
DefInt(SQLITE_CONFIG_COVERING_INDEX_SCAN);
DefInt(SQLITE_CONFIG_SQLLOG);
DefInt(SQLITE_CONFIG_MMAP_SIZE);
DefInt(SQLITE_CONFIG_WIN32_HEAPSIZE);
DefInt(SQLITE_CONFIG_PCACHE_HDRSZ);
DefInt(SQLITE_CONFIG_PMASZ);
DefInt(SQLITE_CONFIG_STMTJRNL_SPILL);
DefInt(SQLITE_CONFIG_SMALL_MALLOC);
DefInt(SQLITE_CONFIG_SORTERREF_SIZE);
DefInt(SQLITE_CONFIG_MEMDB_MAXSIZE);
/* maintenance note: we specifically do not include
SQLITE_CONFIG_ROWID_IN_VIEW here, on the grounds that
it's only for legacy support and no apps written with
this API require that. */
} _DefGroup;
DefGroup(dataTypes) {
DefInt(SQLITE_INTEGER);
DefInt(SQLITE_FLOAT);
DefInt(SQLITE_TEXT);
DefInt(SQLITE_BLOB);
DefInt(SQLITE_NULL);
} _DefGroup;
DefGroup(dbConfig){
DefInt(SQLITE_DBCONFIG_MAINDBNAME);
DefInt(SQLITE_DBCONFIG_LOOKASIDE);
DefInt(SQLITE_DBCONFIG_ENABLE_FKEY);
DefInt(SQLITE_DBCONFIG_ENABLE_TRIGGER);
DefInt(SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION);
DefInt(SQLITE_DBCONFIG_NO_CKPT_ON_CLOSE);
DefInt(SQLITE_DBCONFIG_ENABLE_QPSG);
DefInt(SQLITE_DBCONFIG_TRIGGER_EQP);
DefInt(SQLITE_DBCONFIG_RESET_DATABASE);
DefInt(SQLITE_DBCONFIG_DEFENSIVE);
DefInt(SQLITE_DBCONFIG_WRITABLE_SCHEMA);
DefInt(SQLITE_DBCONFIG_LEGACY_ALTER_TABLE);
DefInt(SQLITE_DBCONFIG_DQS_DML);
DefInt(SQLITE_DBCONFIG_DQS_DDL);
DefInt(SQLITE_DBCONFIG_ENABLE_VIEW);
DefInt(SQLITE_DBCONFIG_LEGACY_FILE_FORMAT);
DefInt(SQLITE_DBCONFIG_TRUSTED_SCHEMA);
DefInt(SQLITE_DBCONFIG_STMT_SCANSTATUS);
DefInt(SQLITE_DBCONFIG_REVERSE_SCANORDER);
DefInt(SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE);
DefInt(SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE);
DefInt(SQLITE_DBCONFIG_ENABLE_COMMENTS);
DefInt(SQLITE_DBCONFIG_MAX);
DefInt(SQLITE_DBCONFIG_FP_DIGITS);
} _DefGroup;
DefGroup(dbStatus){
DefInt(SQLITE_DBSTATUS_LOOKASIDE_USED);
DefInt(SQLITE_DBSTATUS_CACHE_USED);
DefInt(SQLITE_DBSTATUS_SCHEMA_USED);
DefInt(SQLITE_DBSTATUS_STMT_USED);
DefInt(SQLITE_DBSTATUS_LOOKASIDE_HIT);
DefInt(SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE);
DefInt(SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL);
DefInt(SQLITE_DBSTATUS_CACHE_HIT);
DefInt(SQLITE_DBSTATUS_CACHE_MISS);
DefInt(SQLITE_DBSTATUS_CACHE_WRITE);
DefInt(SQLITE_DBSTATUS_DEFERRED_FKS);
DefInt(SQLITE_DBSTATUS_CACHE_USED_SHARED);
DefInt(SQLITE_DBSTATUS_CACHE_SPILL);
DefInt(SQLITE_DBSTATUS_TEMPBUF_SPILL);
DefInt(SQLITE_DBSTATUS_MAX);
} _DefGroup;
DefGroup(encodings) {
/* Noting that the wasm binding only aims to support UTF-8. */
DefInt(SQLITE_UTF8);
DefInt(SQLITE_UTF8_ZT);
DefInt(SQLITE_UTF16LE);
DefInt(SQLITE_UTF16BE);
DefInt(SQLITE_UTF16);
/*deprecated DefInt(SQLITE_ANY); */
DefInt(SQLITE_UTF16_ALIGNED);
} _DefGroup;
DefGroup(fcntl) {
DefInt(SQLITE_FCNTL_LOCKSTATE);
DefInt(SQLITE_FCNTL_GET_LOCKPROXYFILE);
DefInt(SQLITE_FCNTL_SET_LOCKPROXYFILE);
DefInt(SQLITE_FCNTL_LAST_ERRNO);
DefInt(SQLITE_FCNTL_SIZE_HINT);
DefInt(SQLITE_FCNTL_CHUNK_SIZE);
DefInt(SQLITE_FCNTL_FILE_POINTER);
DefInt(SQLITE_FCNTL_SYNC_OMITTED);
DefInt(SQLITE_FCNTL_WIN32_AV_RETRY);
DefInt(SQLITE_FCNTL_PERSIST_WAL);
DefInt(SQLITE_FCNTL_OVERWRITE);
DefInt(SQLITE_FCNTL_VFSNAME);
DefInt(SQLITE_FCNTL_POWERSAFE_OVERWRITE);
DefInt(SQLITE_FCNTL_PRAGMA);
DefInt(SQLITE_FCNTL_BUSYHANDLER);
DefInt(SQLITE_FCNTL_TEMPFILENAME);
DefInt(SQLITE_FCNTL_MMAP_SIZE);
DefInt(SQLITE_FCNTL_TRACE);
DefInt(SQLITE_FCNTL_HAS_MOVED);
DefInt(SQLITE_FCNTL_SYNC);
DefInt(SQLITE_FCNTL_COMMIT_PHASETWO);
DefInt(SQLITE_FCNTL_WIN32_SET_HANDLE);
DefInt(SQLITE_FCNTL_WAL_BLOCK);
DefInt(SQLITE_FCNTL_ZIPVFS);
DefInt(SQLITE_FCNTL_RBU);
DefInt(SQLITE_FCNTL_VFS_POINTER);
DefInt(SQLITE_FCNTL_JOURNAL_POINTER);
DefInt(SQLITE_FCNTL_WIN32_GET_HANDLE);
DefInt(SQLITE_FCNTL_PDB);
DefInt(SQLITE_FCNTL_BEGIN_ATOMIC_WRITE);
DefInt(SQLITE_FCNTL_COMMIT_ATOMIC_WRITE);
DefInt(SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE);
DefInt(SQLITE_FCNTL_LOCK_TIMEOUT);
DefInt(SQLITE_FCNTL_DATA_VERSION);
DefInt(SQLITE_FCNTL_SIZE_LIMIT);
DefInt(SQLITE_FCNTL_CKPT_DONE);
DefInt(SQLITE_FCNTL_RESERVE_BYTES);
DefInt(SQLITE_FCNTL_CKPT_START);
DefInt(SQLITE_FCNTL_EXTERNAL_READER);
DefInt(SQLITE_FCNTL_CKSM_FILE);
DefInt(SQLITE_FCNTL_RESET_CACHE);
} _DefGroup;
DefGroup(flock) {
DefInt(SQLITE_LOCK_NONE);
DefInt(SQLITE_LOCK_SHARED);
DefInt(SQLITE_LOCK_RESERVED);
DefInt(SQLITE_LOCK_PENDING);
DefInt(SQLITE_LOCK_EXCLUSIVE);
} _DefGroup;
DefGroup(ioCap) {
DefInt(SQLITE_IOCAP_ATOMIC);
DefInt(SQLITE_IOCAP_ATOMIC512);
DefInt(SQLITE_IOCAP_ATOMIC1K);
DefInt(SQLITE_IOCAP_ATOMIC2K);
DefInt(SQLITE_IOCAP_ATOMIC4K);
DefInt(SQLITE_IOCAP_ATOMIC8K);
DefInt(SQLITE_IOCAP_ATOMIC16K);
DefInt(SQLITE_IOCAP_ATOMIC32K);
DefInt(SQLITE_IOCAP_ATOMIC64K);
DefInt(SQLITE_IOCAP_SAFE_APPEND);
DefInt(SQLITE_IOCAP_SEQUENTIAL);
DefInt(SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN);
DefInt(SQLITE_IOCAP_POWERSAFE_OVERWRITE);
DefInt(SQLITE_IOCAP_IMMUTABLE);
DefInt(SQLITE_IOCAP_BATCH_ATOMIC);
} _DefGroup;
DefGroup(limits) {
DefInt(SQLITE_MAX_ALLOCATION_SIZE);
DefInt(SQLITE_LIMIT_LENGTH);
DefInt(SQLITE_MAX_LENGTH);
DefInt(SQLITE_LIMIT_SQL_LENGTH);
DefInt(SQLITE_MAX_SQL_LENGTH);
DefInt(SQLITE_LIMIT_COLUMN);
DefInt(SQLITE_MAX_COLUMN);
DefInt(SQLITE_LIMIT_EXPR_DEPTH);
DefInt(SQLITE_MAX_EXPR_DEPTH);
DefInt(SQLITE_LIMIT_COMPOUND_SELECT);
DefInt(SQLITE_MAX_COMPOUND_SELECT);
DefInt(SQLITE_LIMIT_VDBE_OP);
DefInt(SQLITE_MAX_VDBE_OP);
DefInt(SQLITE_LIMIT_FUNCTION_ARG);
DefInt(SQLITE_MAX_FUNCTION_ARG);
DefInt(SQLITE_LIMIT_ATTACHED);
DefInt(SQLITE_MAX_ATTACHED);
DefInt(SQLITE_LIMIT_LIKE_PATTERN_LENGTH);
DefInt(SQLITE_MAX_LIKE_PATTERN_LENGTH);
DefInt(SQLITE_LIMIT_VARIABLE_NUMBER);
DefInt(SQLITE_MAX_VARIABLE_NUMBER);
DefInt(SQLITE_LIMIT_TRIGGER_DEPTH);
DefInt(SQLITE_MAX_TRIGGER_DEPTH);
DefInt(SQLITE_LIMIT_WORKER_THREADS);
DefInt(SQLITE_MAX_WORKER_THREADS);
DefInt(SQLITE_LIMIT_PARSER_DEPTH);
DefInt(SQLITE_MAX_PARSER_DEPTH);
} _DefGroup;
DefGroup(openFlags) {
/* Noting that not all of these will have any effect in
** WASM-space. */
DefInt(SQLITE_OPEN_READONLY);
DefInt(SQLITE_OPEN_READWRITE);
DefInt(SQLITE_OPEN_CREATE);
DefInt(SQLITE_OPEN_URI);
DefInt(SQLITE_OPEN_MEMORY);
DefInt(SQLITE_OPEN_NOMUTEX);
DefInt(SQLITE_OPEN_FULLMUTEX);
DefInt(SQLITE_OPEN_SHAREDCACHE);
DefInt(SQLITE_OPEN_PRIVATECACHE);
DefInt(SQLITE_OPEN_EXRESCODE);
DefInt(SQLITE_OPEN_NOFOLLOW);
/* OPEN flags for use with VFSes... */
DefInt(SQLITE_OPEN_MAIN_DB);
DefInt(SQLITE_OPEN_MAIN_JOURNAL);
DefInt(SQLITE_OPEN_TEMP_DB);
DefInt(SQLITE_OPEN_TEMP_JOURNAL);
DefInt(SQLITE_OPEN_TRANSIENT_DB);
DefInt(SQLITE_OPEN_SUBJOURNAL);
DefInt(SQLITE_OPEN_SUPER_JOURNAL);
DefInt(SQLITE_OPEN_WAL);
DefInt(SQLITE_OPEN_DELETEONCLOSE);
DefInt(SQLITE_OPEN_EXCLUSIVE);
} _DefGroup;
DefGroup(prepareFlags) {
DefInt(SQLITE_PREPARE_PERSISTENT);
DefInt(SQLITE_PREPARE_NORMALIZE);
DefInt(SQLITE_PREPARE_NO_VTAB);
DefInt(SQLITE_PREPARE_FROM_DDL);
} _DefGroup;
DefGroup(resultCodes) {
DefInt(SQLITE_OK);
DefInt(SQLITE_ERROR);
DefInt(SQLITE_INTERNAL);
DefInt(SQLITE_PERM);
DefInt(SQLITE_ABORT);
DefInt(SQLITE_BUSY);
DefInt(SQLITE_LOCKED);
DefInt(SQLITE_NOMEM);
DefInt(SQLITE_READONLY);
DefInt(SQLITE_INTERRUPT);
DefInt(SQLITE_IOERR);
DefInt(SQLITE_CORRUPT);
DefInt(SQLITE_NOTFOUND);
DefInt(SQLITE_FULL);
DefInt(SQLITE_CANTOPEN);
DefInt(SQLITE_PROTOCOL);
DefInt(SQLITE_EMPTY);
DefInt(SQLITE_SCHEMA);
DefInt(SQLITE_TOOBIG);
DefInt(SQLITE_CONSTRAINT);
DefInt(SQLITE_MISMATCH);
DefInt(SQLITE_MISUSE);
DefInt(SQLITE_NOLFS);
DefInt(SQLITE_AUTH);
DefInt(SQLITE_FORMAT);
DefInt(SQLITE_RANGE);
DefInt(SQLITE_NOTADB);
DefInt(SQLITE_NOTICE);
DefInt(SQLITE_WARNING);
DefInt(SQLITE_ROW);
DefInt(SQLITE_DONE);
// Extended Result Codes
DefInt(SQLITE_ERROR_MISSING_COLLSEQ);
DefInt(SQLITE_ERROR_RETRY);
DefInt(SQLITE_ERROR_SNAPSHOT);
DefInt(SQLITE_IOERR_READ);
DefInt(SQLITE_IOERR_SHORT_READ);
DefInt(SQLITE_IOERR_WRITE);
DefInt(SQLITE_IOERR_FSYNC);
DefInt(SQLITE_IOERR_DIR_FSYNC);
DefInt(SQLITE_IOERR_TRUNCATE);
DefInt(SQLITE_IOERR_FSTAT);
DefInt(SQLITE_IOERR_UNLOCK);
DefInt(SQLITE_IOERR_RDLOCK);
DefInt(SQLITE_IOERR_DELETE);
DefInt(SQLITE_IOERR_BLOCKED);
DefInt(SQLITE_IOERR_NOMEM);
DefInt(SQLITE_IOERR_ACCESS);
DefInt(SQLITE_IOERR_CHECKRESERVEDLOCK);
DefInt(SQLITE_IOERR_LOCK);
DefInt(SQLITE_IOERR_CLOSE);
DefInt(SQLITE_IOERR_DIR_CLOSE);
DefInt(SQLITE_IOERR_SHMOPEN);
DefInt(SQLITE_IOERR_SHMSIZE);
DefInt(SQLITE_IOERR_SHMLOCK);
DefInt(SQLITE_IOERR_SHMMAP);
DefInt(SQLITE_IOERR_SEEK);
DefInt(SQLITE_IOERR_DELETE_NOENT);
DefInt(SQLITE_IOERR_MMAP);
DefInt(SQLITE_IOERR_GETTEMPPATH);
DefInt(SQLITE_IOERR_CONVPATH);
DefInt(SQLITE_IOERR_VNODE);
DefInt(SQLITE_IOERR_AUTH);
DefInt(SQLITE_IOERR_BEGIN_ATOMIC);
DefInt(SQLITE_IOERR_COMMIT_ATOMIC);
DefInt(SQLITE_IOERR_ROLLBACK_ATOMIC);
DefInt(SQLITE_IOERR_DATA);
DefInt(SQLITE_IOERR_CORRUPTFS);
DefInt(SQLITE_LOCKED_SHAREDCACHE);
DefInt(SQLITE_LOCKED_VTAB);
DefInt(SQLITE_BUSY_RECOVERY);
DefInt(SQLITE_BUSY_SNAPSHOT);
DefInt(SQLITE_BUSY_TIMEOUT);
DefInt(SQLITE_CANTOPEN_NOTEMPDIR);
DefInt(SQLITE_CANTOPEN_ISDIR);
DefInt(SQLITE_CANTOPEN_FULLPATH);
DefInt(SQLITE_CANTOPEN_CONVPATH);
//DefInt(SQLITE_CANTOPEN_DIRTYWAL)/*docs say not used*/;
DefInt(SQLITE_CANTOPEN_SYMLINK);
DefInt(SQLITE_CORRUPT_VTAB);
DefInt(SQLITE_CORRUPT_SEQUENCE);
DefInt(SQLITE_CORRUPT_INDEX);
DefInt(SQLITE_READONLY_RECOVERY);
DefInt(SQLITE_READONLY_CANTLOCK);
DefInt(SQLITE_READONLY_ROLLBACK);
DefInt(SQLITE_READONLY_DBMOVED);
DefInt(SQLITE_READONLY_CANTINIT);
DefInt(SQLITE_READONLY_DIRECTORY);
DefInt(SQLITE_ABORT_ROLLBACK);
DefInt(SQLITE_CONSTRAINT_CHECK);
DefInt(SQLITE_CONSTRAINT_COMMITHOOK);
DefInt(SQLITE_CONSTRAINT_FOREIGNKEY);
DefInt(SQLITE_CONSTRAINT_FUNCTION);
DefInt(SQLITE_CONSTRAINT_NOTNULL);
DefInt(SQLITE_CONSTRAINT_PRIMARYKEY);
DefInt(SQLITE_CONSTRAINT_TRIGGER);
DefInt(SQLITE_CONSTRAINT_UNIQUE);
DefInt(SQLITE_CONSTRAINT_VTAB);
DefInt(SQLITE_CONSTRAINT_ROWID);
DefInt(SQLITE_CONSTRAINT_PINNED);
DefInt(SQLITE_CONSTRAINT_DATATYPE);
DefInt(SQLITE_NOTICE_RECOVER_WAL);
DefInt(SQLITE_NOTICE_RECOVER_ROLLBACK);
DefInt(SQLITE_WARNING_AUTOINDEX);
DefInt(SQLITE_AUTH_USER);
DefInt(SQLITE_OK_LOAD_PERMANENTLY);
//DefInt(SQLITE_OK_SYMLINK) /* internal use only */;
} _DefGroup;
DefGroup(serialize){
DefInt(SQLITE_SERIALIZE_NOCOPY);
DefInt(SQLITE_DESERIALIZE_FREEONCLOSE);
DefInt(SQLITE_DESERIALIZE_READONLY);
DefInt(SQLITE_DESERIALIZE_RESIZEABLE);
} _DefGroup;
DefGroup(session){
#ifdef SQLITE_SESSION_CONFIG_STRMSIZE
DefInt(SQLITE_SESSION_CONFIG_STRMSIZE);
DefInt(SQLITE_SESSION_OBJCONFIG_SIZE);
#endif
} _DefGroup;
DefGroup(sqlite3Status){
DefInt(SQLITE_STATUS_MEMORY_USED);
DefInt(SQLITE_STATUS_PAGECACHE_USED);
DefInt(SQLITE_STATUS_PAGECACHE_OVERFLOW);
//DefInt(SQLITE_STATUS_SCRATCH_USED) /* NOT USED */;
//DefInt(SQLITE_STATUS_SCRATCH_OVERFLOW) /* NOT USED */;
DefInt(SQLITE_STATUS_MALLOC_SIZE);
DefInt(SQLITE_STATUS_PARSER_STACK);
DefInt(SQLITE_STATUS_PAGECACHE_SIZE);
//DefInt(SQLITE_STATUS_SCRATCH_SIZE) /* NOT USED */;
DefInt(SQLITE_STATUS_MALLOC_COUNT);
} _DefGroup;
DefGroup(stmtStatus){
DefInt(SQLITE_STMTSTATUS_FULLSCAN_STEP);
DefInt(SQLITE_STMTSTATUS_SORT);
DefInt(SQLITE_STMTSTATUS_AUTOINDEX);
DefInt(SQLITE_STMTSTATUS_VM_STEP);
DefInt(SQLITE_STMTSTATUS_REPREPARE);
DefInt(SQLITE_STMTSTATUS_RUN);
DefInt(SQLITE_STMTSTATUS_FILTER_MISS);
DefInt(SQLITE_STMTSTATUS_FILTER_HIT);
DefInt(SQLITE_STMTSTATUS_MEMUSED);
} _DefGroup;
DefGroup(syncFlags) {
DefInt(SQLITE_SYNC_NORMAL);
DefInt(SQLITE_SYNC_FULL);
DefInt(SQLITE_SYNC_DATAONLY);
} _DefGroup;
DefGroup(trace) {
DefInt(SQLITE_TRACE_STMT);
DefInt(SQLITE_TRACE_PROFILE);
DefInt(SQLITE_TRACE_ROW);
DefInt(SQLITE_TRACE_CLOSE);
} _DefGroup;
DefGroup(txnState){
DefInt(SQLITE_TXN_NONE);
DefInt(SQLITE_TXN_READ);
DefInt(SQLITE_TXN_WRITE);
} _DefGroup;
DefGroup(udfFlags) {
DefInt(SQLITE_DETERMINISTIC);
DefInt(SQLITE_DIRECTONLY);
DefInt(SQLITE_INNOCUOUS);
DefInt(SQLITE_SUBTYPE);
DefInt(SQLITE_RESULT_SUBTYPE);
DefInt(SQLITE_SELFORDER1);
} _DefGroup;
DefGroup(version) {
DefInt(SQLITE_VERSION_NUMBER);
DefStr(SQLITE_VERSION);
DefStr(SQLITE_SOURCE_ID);
} _DefGroup;
DefGroup(vtab) {
#if SQLITE_WASM_HAS_VTAB
DefInt(SQLITE_INDEX_SCAN_UNIQUE);
DefInt(SQLITE_INDEX_CONSTRAINT_EQ);
DefInt(SQLITE_INDEX_CONSTRAINT_GT);
DefInt(SQLITE_INDEX_CONSTRAINT_LE);
DefInt(SQLITE_INDEX_CONSTRAINT_LT);
DefInt(SQLITE_INDEX_CONSTRAINT_GE);
DefInt(SQLITE_INDEX_CONSTRAINT_MATCH);
DefInt(SQLITE_INDEX_CONSTRAINT_LIKE);
DefInt(SQLITE_INDEX_CONSTRAINT_GLOB);
DefInt(SQLITE_INDEX_CONSTRAINT_REGEXP);
DefInt(SQLITE_INDEX_CONSTRAINT_NE);
DefInt(SQLITE_INDEX_CONSTRAINT_ISNOT);
DefInt(SQLITE_INDEX_CONSTRAINT_ISNOTNULL);
DefInt(SQLITE_INDEX_CONSTRAINT_ISNULL);
DefInt(SQLITE_INDEX_CONSTRAINT_IS);
DefInt(SQLITE_INDEX_CONSTRAINT_LIMIT);
DefInt(SQLITE_INDEX_CONSTRAINT_OFFSET);
DefInt(SQLITE_INDEX_CONSTRAINT_FUNCTION);
DefInt(SQLITE_VTAB_CONSTRAINT_SUPPORT);
DefInt(SQLITE_VTAB_INNOCUOUS);
DefInt(SQLITE_VTAB_DIRECTONLY);
DefInt(SQLITE_VTAB_USES_ALL_SCHEMAS);
DefInt(SQLITE_ROLLBACK);
//DefInt(SQLITE_IGNORE); // Also used by sqlite3_authorizer() callback
DefInt(SQLITE_FAIL);
//DefInt(SQLITE_ABORT); // Also an error code
DefInt(SQLITE_REPLACE);
#endif /*SQLITE_WASM_HAS_VTAB*/
} _DefGroup;
#undef DefGroup
#undef DefStr
#undef DefInt
#undef _DefGroup
/*
** Emit an array of "StructBinder" struct descriptions, which look
** like:
**
** {
** "name": "MyStruct",
** "sizeof": 16,
** "members": {
** "member1": {"offset": 0,"sizeof": 4,"signature": "i"},
** "member2": {"offset": 4,"sizeof": 4,"signature": "p"},
** "member3": {"offset": 8,"sizeof": 8,"signature": "j"}
** }
** }
**
** Detailed documentation for those bits are in the Jaccwabyt
** JS-side component.
*/
/** Macros for emitting StructBinder description. */
#define StructBinder__(TYPE) \
n = 0; \
outf("%s{", (nStruct++ ? ", " : "")); \
out("\"name\": \"" # TYPE "\","); \
outf("\"sizeof\": %d", (int)sizeof(TYPE)); \
out(",\"members\": {");
#define StructBinder_(T) StructBinder__(T)
/** ^^^ indirection needed to expand CurrentStruct */
#define StructBinder StructBinder_(CurrentStruct)
#define _StructBinder CloseBrace(2)
#define M3(MEMBER,SIG,READONLY) \
outf("%s\"%s\": " \
"{\"offset\":%d,\"sizeof\":%d,\"signature\":\"%s\"%s}", \
(n++ ? ", " : ""), #MEMBER, \
(int)offsetof(CurrentStruct,MEMBER), \
(int)sizeof(((CurrentStruct*)0)->MEMBER), \
SIG, (READONLY ? ",\"readOnly\":true" : ""))
#define M(MEMBER,SIG) M3(MEMBER,SIG,0)
#define MRO(MEMBER,SIG) M3(MEMBER,SIG,1)
nStruct = 0;
out(", \"structs\": ["); {