-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsqlite3.e
More file actions
5504 lines (4745 loc) · 236 KB
/
sqlite3.e
File metadata and controls
5504 lines (4745 loc) · 236 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
--
-- C-language Interface Specification for SQLite
-- https://www.sqlite.org/capi3ref.html
--
namespace sqlite3
include std/dll.e
include std/error.e
include std/machine.e
include std/map.e
include std/serialize.e
include std/types.e
constant
C_CALLBACK = C_POINTER,
C_SQLITE3 = C_POINTER,
C_SQLITE3_BACKUP = C_POINTER,
C_SQLITE3_BLOB = C_POINTER,
C_SQLITE3_CONTEXT = C_POINTER,
C_SQLITE3_MODULE = C_POINTER,
C_SQLITE3_STMT = C_POINTER,
C_SQLITE3_VALUE = C_POINTER,
C_SQLITE3_VFS = C_POINTER,
C_STRING = C_POINTER,
C_WSTRING = C_POINTER,
C_ULONGLONG = C_LONGLONG -- FIXME
constant INVALID_RID = -1
-- safely return NULL if rid is invalid
function call_back( integer rid )
if rid = INVALID_RID then
return NULL
end if
return dll:call_back( rid )
end function
-- store a sequence of bytes in memory, or allocate and clear memory
function allocate_data( object data, integer cleanup = FALSE )
atom ptr
if sequence( data ) then
ptr = machine:allocate_data( length(data), cleanup )
poke( ptr, data )
else
ptr = machine:allocate_data( data, cleanup )
mem_set( ptr, data, NULL )
end if
return ptr
end function
-- safely return NULL if string is empty
function allocate_string( sequence str, integer cleanup = FALSE )
if length( str ) = 0 then
return NULL
end if
return machine:allocate_string( str, cleanup )
end function
-- safely return NULL if string is empty
function allocate_wstring( sequence str, integer cleanup = FALSE )
if length( str ) = 0 then
return NULL
end if
return machine:allocate_wstring( str, cleanup )
end function
-- safely return an empty string if ptr is NULL
function peek_string( atom ptr )
if ptr then
return eu:peek_string( ptr )
end if
return ""
end function
-- safely return an empty string if ptr is NULL
function peek_wstring( atom ptr )
if ptr then
return machine:peek_wstring( ptr )
end if
return ""
end function
ifdef WINDOWS then
export atom sqlite3 = open_dll( "sqlite3.dll" )
elsifdef LINUX then
export atom sqlite3 = open_dll({ "libsqlite3.so.0", "libsqlite3.so" })
elsedef
error:crash( "Platform not supported" )
end ifdef
if sqlite3 = NULL then
error:crash( "sqlite3 not found!" )
end if
constant
_sqlite3_version = define_c_var( sqlite3, "sqlite3_version" ),
_sqlite3_libversion = define_c_func( sqlite3, "sqlite3_libversion", {}, C_STRING ),
_sqlite3_libversion_number = define_c_func( sqlite3, "sqlite3_libversion_number", {}, C_INT ),
_sqlite3_sourceid = define_c_func( sqlite3, "sqlite3_sourceid", {}, C_STRING ),
_sqlite3_compileoption_used = define_c_func( sqlite3, "sqlite3_compileoption_used", {C_STRING}, C_INT ),
_sqlite3_compileoption_get = define_c_func( sqlite3, "sqlite3_compileoption_get", {C_INT}, C_STRING ),
_sqlite3_threadsafe = define_c_func( sqlite3, "sqlite3_threadsafe", {}, C_INT ),
_sqlite3_close = define_c_func( sqlite3, "sqlite3_close", {C_SQLITE3}, C_INT ),
_sqlite3_close_v2 = define_c_func( sqlite3, "sqlite3_close_v2", {C_SQLITE3}, C_INT ),
_sqlite3_exec = define_c_func( sqlite3, "sqlite3_exec", {C_SQLITE3,C_STRING,C_CALLBACK,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_initialize = define_c_func( sqlite3, "sqlite3_initialize", {}, C_INT ),
_sqlite3_shutdown = define_c_func( sqlite3, "sqlite3_shutdown", {}, C_INT ),
_sqlite3_extended_result_codes = define_c_func( sqlite3, "sqlite3_extended_result_codes", {C_SQLITE3,C_INT}, C_INT ),
_sqlite3_last_insert_rowid = define_c_func( sqlite3, "sqlite3_last_insert_rowid", {C_SQLITE3}, C_LONGLONG ),
_sqlite3_set_last_insert_rowid = define_c_proc( sqlite3, "sqlite3_set_last_insert_rowid", {C_SQLITE3,C_LONGLONG} ),
_sqlite3_changes = define_c_func( sqlite3, "sqlite3_changes", {C_SQLITE3}, C_INT ),
_sqlite3_total_changes = define_c_func( sqlite3, "sqlite3_total_changes", {C_SQLITE3}, C_INT ),
_sqlite3_interrupt = define_c_proc( sqlite3, "sqlite3_interrupt", {C_SQLITE3} ),
_sqlite3_complete = define_c_func( sqlite3, "sqlite3_complete", {C_STRING}, C_INT ),
_sqlite3_complete16 = define_c_func( sqlite3, "sqlite3_complete16", {C_WSTRING}, C_INT ),
_sqlite3_busy_handler = define_c_func( sqlite3, "sqlite3_busy_handler", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_INT ),
_sqlite3_busy_timeout = define_c_func( sqlite3, "sqlite3_busy_timeout", {C_SQLITE3,C_INT}, C_INT ),
_sqlite3_get_table = define_c_func( sqlite3, "sqlite3_get_table", {C_SQLITE3,C_STRING,C_POINTER,C_POINTER,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_free_table = define_c_proc( sqlite3, "sqlite3_free_table", {C_POINTER} ),
_sqlite3_malloc = define_c_func( sqlite3, "sqlite3_malloc", {C_INT}, C_POINTER ),
_sqlite3_malloc64 = define_c_func( sqlite3, "sqlite3_malloc64", {C_ULONGLONG}, C_POINTER ),
_sqlite3_realloc = define_c_func( sqlite3, "sqlite3_realloc", {C_POINTER,C_INT}, C_POINTER ),
_sqlite3_realloc64 = define_c_func( sqlite3, "sqlite3_realloc64", {C_POINTER,C_ULONGLONG}, C_POINTER ),
_sqlite3_free = define_c_proc( sqlite3, "sqlite3_free", {C_POINTER} ),
_sqlite3_msize = define_c_func( sqlite3, "sqlite3_msize", {C_POINTER}, C_ULONGLONG ),
_sqlite3_memory_used = define_c_func( sqlite3, "sqlite3_memory_used", {}, C_LONGLONG ),
_sqlite3_memory_highwater = define_c_func( sqlite3, "sqlite3_memory_highwater", {C_INT}, C_LONGLONG ),
_sqlite3_randomness = define_c_proc( sqlite3, "sqlite3_randomness", {C_INT,C_POINTER} ),
_sqlite3_set_authorizer = define_c_func( sqlite3, "sqlite3_set_authorizer", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_INT ),
_sqlite3_trace = define_c_func( sqlite3, "sqlite3_trace", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_POINTER ),
_sqlite3_profile = define_c_func( sqlite3, "sqlite3_profile", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_POINTER ),
_sqlite3_trace_v2 = define_c_func( sqlite3, "sqlite3_trace_v2", {C_SQLITE3,C_UINT,C_CALLBACK,C_POINTER}, C_INT ),
_sqlite3_progress_handler = define_c_proc( sqlite3, "sqlite3_progress_handler", {C_SQLITE3,C_INT,C_CALLBACK,C_POINTER} ),
_sqlite3_open = define_c_func( sqlite3, "sqlite3_open", {C_STRING,C_POINTER}, C_INT ),
_sqlite3_open16 = define_c_func( sqlite3, "sqlite3_open16", {C_WSTRING,C_POINTER}, C_INT ),
_sqlite3_open_v2 = define_c_func( sqlite3, "sqlite3_open_v2", {C_STRING,C_POINTER,C_INT,C_STRING}, C_INT ),
_sqlite3_uri_parameter = define_c_func( sqlite3, "sqlite3_uri_parameter", {C_STRING,C_STRING}, C_STRING ),
_sqlite3_uri_boolean = define_c_func( sqlite3, "sqlite3_uri_boolean", {C_STRING,C_STRING,C_INT}, C_INT ),
_sqlite3_uri_int64 = define_c_func( sqlite3, "sqlite3_uri_int64", {C_STRING,C_STRING,C_LONGLONG}, C_LONGLONG ),
_sqlite3_uri_key = define_c_func( sqlite3, "sqlite3_uri_key", {C_STRING,C_INT}, C_STRING ),
_sqlite3_filename_database = define_c_func( sqlite3, "sqlite3_filename_database", {C_STRING}, C_STRING ),
_sqlite3_filename_journal = define_c_func( sqlite3, "sqlite3_filename_journal", {C_STRING}, C_STRING ),
_sqlite3_filename_wal = define_c_func( sqlite3, "sqlite3_filename_wal", {C_STRING}, C_STRING ),
_sqlite3_errcode = define_c_func( sqlite3, "sqlite3_errcode", {C_SQLITE3}, C_INT ),
_sqlite3_extended_errcode = define_c_func( sqlite3, "sqlite3_extended_errcode", {C_SQLITE3}, C_INT ),
_sqlite3_errmsg = define_c_func( sqlite3, "sqlite3_errmsg", {C_SQLITE3}, C_STRING ),
_sqlite3_errmsg16 = define_c_func( sqlite3, "sqlite3_errmsg16", {C_SQLITE3}, C_WSTRING ),
_sqlite3_errstr = define_c_func( sqlite3, "sqlite3_errstr", {C_INT}, C_STRING ),
_sqlite3_limit = define_c_func( sqlite3, "sqlite3_limit", {C_SQLITE3,C_INT,C_INT}, C_INT ),
_sqlite3_prepare = define_c_func( sqlite3, "sqlite3_prepare", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_prepare_v2 = define_c_func( sqlite3, "sqlite3_prepare_v2", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_prepare_v3 = define_c_func( sqlite3, "sqlite3_prepare_v3", {C_SQLITE3,C_STRING,C_INT,C_UINT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_prepare16 = define_c_func( sqlite3, "sqlite3_prepare16", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_prepare16_v2 = define_c_func( sqlite3, "sqlite3_prepare16_v2", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_prepare16_v3 = define_c_func( sqlite3, "sqlite3_prepare16_v3", {C_SQLITE3,C_STRING,C_INT,C_UINT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_sql = define_c_func( sqlite3, "sqlite3_sql", {C_POINTER}, C_STRING ),
_sqlite3_expanded_sql = define_c_func( sqlite3, "sqlite3_expanded_sql", {C_POINTER}, C_STRING ),
_sqlite3_stmt_readonly = define_c_func( sqlite3, "sqlite3_stmt_readonly", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_stmt_isexplain = define_c_func( sqlite3, "sqlite3_stmt_isexplain", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_stmt_busy = define_c_func( sqlite3, "sqlite3_stmt_busy", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_bind_blob = define_c_func( sqlite3, "sqlite3_bind_blob", {C_SQLITE3_STMT,C_INT,C_POINTER,C_INT,C_CALLBACK}, C_INT ),
_sqlite3_bind_blob64 = define_c_func( sqlite3, "sqlite3_bind_blob64", {C_SQLITE3_STMT,C_INT,C_POINTER,C_ULONGLONG,C_CALLBACK}, C_INT ),
_sqlite3_bind_double = define_c_func( sqlite3, "sqlite3_bind_double", {C_SQLITE3_STMT,C_INT,C_DOUBLE}, C_INT ),
_sqlite3_bind_int = define_c_func( sqlite3, "sqlite3_bind_int", {C_SQLITE3_STMT,C_INT,C_INT}, C_INT ),
_sqlite3_bind_int64 = define_c_func( sqlite3, "sqlite3_bind_int64", {C_SQLITE3_STMT,C_INT,C_LONGLONG}, C_INT ),
_sqlite3_bind_null = define_c_func( sqlite3, "sqlite3_bind_null", {C_SQLITE3_STMT,C_INT}, C_INT ),
_sqlite3_bind_text = define_c_func( sqlite3, "sqlite3_bind_text", {C_SQLITE3_STMT,C_INT,C_STRING,C_INT,C_CALLBACK}, C_INT ),
_sqlite3_bind_text16 = define_c_func( sqlite3, "sqlite3_bind_text16", {C_SQLITE3_STMT,C_INT,C_POINTER,C_INT,C_CALLBACK}, C_INT ),
_sqlite3_bind_text64 = define_c_func( sqlite3, "sqlite3_bind_text64", {C_SQLITE3_STMT,C_INT,C_STRING,C_ULONGLONG,C_CALLBACK,C_UCHAR}, C_INT ),
_sqlite3_bind_value = define_c_func( sqlite3, "sqlite3_bind_value", {C_SQLITE3_STMT,C_INT,C_POINTER}, C_INT ),
_sqlite3_bind_pointer = define_c_func( sqlite3, "sqlite3_bind_pointer", {C_SQLITE3_STMT,C_INT,C_POINTER,C_STRING,C_CALLBACK}, C_INT ),
_sqlite3_bind_zeroblob = define_c_func( sqlite3, "sqlite3_bind_zeroblob", {C_SQLITE3_STMT,C_INT,C_INT}, C_INT ),
_sqlite3_bind_zeroblob64 = define_c_func( sqlite3, "sqlite3_bind_zeroblob64", {C_SQLITE3_STMT,C_INT,C_ULONGLONG}, C_INT ),
_sqlite3_bind_parameter_count = define_c_func( sqlite3, "sqlite3_bind_parameter_count", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_bind_parameter_name = define_c_func( sqlite3, "sqlite3_bind_parameter_name", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_bind_parameter_index = define_c_func( sqlite3, "sqlite3_bind_parameter_index", {C_SQLITE3_STMT,C_STRING}, C_INT ),
_sqlite3_clear_bindings = define_c_func( sqlite3, "sqlite3_clear_bindings", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_column_count = define_c_func( sqlite3, "sqlite3_column_count", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_column_name = define_c_func( sqlite3, "sqlite3_column_name", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_name16 = define_c_func( sqlite3, "sqlite3_column_name16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_column_database_name = define_c_func( sqlite3, "sqlite3_column_database_name", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_database_name16 = define_c_func( sqlite3, "sqlite3_column_database_name16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_column_table_name = define_c_func( sqlite3, "sqlite3_column_table_name", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_table_name16 = define_c_func( sqlite3, "sqlite3_column_table_name16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_column_origin_name = define_c_func( sqlite3, "sqlite3_column_origin_name", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_origin_name16 = define_c_func( sqlite3, "sqlite3_column_origin_name16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_column_decltype = define_c_func( sqlite3, "sqlite3_column_decltype", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_decltype16 = define_c_func( sqlite3, "sqlite3_column_decltype16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_step = define_c_func( sqlite3, "sqlite3_step", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_data_count = define_c_func( sqlite3, "sqlite3_data_count", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_column_blob = define_c_func( sqlite3, "sqlite3_column_blob", {C_SQLITE3_STMT,C_INT}, C_POINTER ),
_sqlite3_column_double = define_c_func( sqlite3, "sqlite3_column_double", {C_SQLITE3_STMT,C_INT}, C_DOUBLE ),
_sqlite3_column_int = define_c_func( sqlite3, "sqlite3_column_int", {C_SQLITE3_STMT,C_INT}, C_INT ),
_sqlite3_column_int64 = define_c_func( sqlite3, "sqlite3_column_int64", {C_SQLITE3_STMT,C_INT}, C_LONGLONG ),
_sqlite3_column_text = define_c_func( sqlite3, "sqlite3_column_text", {C_SQLITE3_STMT,C_INT}, C_STRING ),
_sqlite3_column_text16 = define_c_func( sqlite3, "sqlite3_column_text16", {C_SQLITE3_STMT,C_INT}, C_WSTRING ),
_sqlite3_column_value = define_c_func( sqlite3, "sqlite3_column_value", {C_SQLITE3_STMT,C_INT}, C_POINTER ),
_sqlite3_column_bytes = define_c_func( sqlite3, "sqlite3_column_bytes", {C_SQLITE3_STMT,C_INT}, C_INT ),
_sqlite3_column_bytes16 = define_c_func( sqlite3, "sqlite3_column_bytes16", {C_SQLITE3_STMT,C_INT}, C_INT ),
_sqlite3_column_type = define_c_func( sqlite3, "sqlite3_column_type", {C_SQLITE3_STMT,C_INT}, C_INT ),
_sqlite3_finalize = define_c_func( sqlite3, "sqlite3_finalize", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_reset = define_c_func( sqlite3, "sqlite3_reset", {C_SQLITE3_STMT}, C_INT ),
_sqlite3_create_function = define_c_func( sqlite3, "sqlite3_create_function", {C_SQLITE3,C_STRING,C_INT,C_INT,C_POINTER,C_CALLBACK,C_CALLBACK,C_CALLBACK}, C_INT ),
_sqlite3_create_function16 = define_c_func( sqlite3, "sqlite3_create_function16", {C_SQLITE3,C_WSTRING,C_INT,C_INT,C_POINTER,C_CALLBACK,C_CALLBACK,C_CALLBACK}, C_INT ),
_sqlite3_create_function_v2 = define_c_func( sqlite3, "sqlite3_create_function_v2", {C_SQLITE3,C_STRING,C_INT,C_INT,C_POINTER,C_CALLBACK,C_CALLBACK,C_CALLBACK,C_CALLBACK}, C_INT ),
_sqlite3_create_window_function = define_c_func( sqlite3, "sqlite3_create_window_function", {C_SQLITE3,C_STRING,C_INT,C_INT,C_POINTER,C_CALLBACK,C_CALLBACK,C_CALLBACK,C_CALLBACK,C_CALLBACK}, C_INT ),
_sqlite3_value_blob = define_c_func( sqlite3, "sqlite3_value_blob", {C_SQLITE3_VALUE}, C_POINTER ),
_sqlite3_value_double = define_c_func( sqlite3, "sqlite3_value_double", {C_SQLITE3_VALUE}, C_DOUBLE ),
_sqlite3_value_int = define_c_func( sqlite3, "sqlite3_value_int", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_int64 = define_c_func( sqlite3, "sqlite3_value_int64", {C_SQLITE3_VALUE}, C_LONGLONG ),
_sqlite3_value_pointer = define_c_func( sqlite3, "sqlite3_value_pointer", {C_SQLITE3_VALUE,C_STRING}, C_POINTER ),
_sqlite3_value_text = define_c_func( sqlite3, "sqlite3_value_text", {C_SQLITE3_VALUE}, C_STRING ),
_sqlite3_value_text16 = define_c_func( sqlite3, "sqlite3_value_text16", {C_SQLITE3_VALUE}, C_WSTRING ),
_sqlite3_value_text16le = define_c_func( sqlite3, "sqlite3_value_text16le", {C_SQLITE3_VALUE}, C_WSTRING ),
_sqlite3_value_text16be = define_c_func( sqlite3, "sqlite3_value_text16be", {C_SQLITE3_VALUE}, C_WSTRING ),
_sqlite3_value_bytes = define_c_func( sqlite3, "sqlite3_value_bytes", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_bytes16 = define_c_func( sqlite3, "sqlite3_value_bytes16", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_type = define_c_func( sqlite3, "sqlite3_value_type", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_numeric_type = define_c_func( sqlite3, "sqlite3_value_numeric_type", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_nochange = define_c_func( sqlite3, "sqlite3_value_nochange", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_frombind = define_c_func( sqlite3, "sqlite3_value_frombind", {C_SQLITE3_VALUE}, C_INT ),
_sqlite3_value_subtype = define_c_func( sqlite3, "sqlite3_value_subtype", {C_SQLITE3_VALUE}, C_UINT ),
_sqlite3_value_dup = define_c_func( sqlite3, "sqlite3_value_dup", {C_SQLITE3_VALUE}, C_SQLITE3_VALUE ),
_sqlite3_value_free = define_c_proc( sqlite3, "sqlite3_value_free", {C_SQLITE3_VALUE} ),
_sqlite3_aggregate_context = define_c_func( sqlite3, "sqlite3_aggregate_context", {C_SQLITE3_CONTEXT,C_INT}, C_POINTER ),
_sqlite3_user_data = define_c_func( sqlite3, "sqlite3_user_data", {C_SQLITE3_CONTEXT}, C_POINTER ),
_sqlite3_context_db_handle = define_c_func( sqlite3, "sqlite3_context_db_handle", {C_SQLITE3_CONTEXT}, C_SQLITE3 ),
_sqlite3_get_auxdata = define_c_func( sqlite3, "sqlite3_get_auxdata", {C_POINTER,C_INT}, C_POINTER ),
_sqlite3_set_auxdata = define_c_proc( sqlite3, "sqlite3_set_auxdata", {C_POINTER,C_INT,C_POINTER,C_CALLBACK} ),
_sqlite3_result_blob = define_c_proc( sqlite3, "sqlite3_result_blob", {C_SQLITE3_CONTEXT,C_POINTER,C_INT,C_CALLBACK} ),
_sqlite3_result_blob64 = define_c_proc( sqlite3, "sqlite3_result_blob64", {C_SQLITE3_CONTEXT,C_POINTER,C_ULONGLONG,C_CALLBACK} ),
_sqlite3_result_double = define_c_proc( sqlite3, "sqlite3_result_double", {C_SQLITE3_CONTEXT,C_DOUBLE} ),
_sqlite3_result_error = define_c_proc( sqlite3, "sqlite3_result_error", {C_SQLITE3_CONTEXT,C_STRING,C_INT} ),
_sqlite3_result_error16 = define_c_proc( sqlite3, "sqlite3_result_error16", {C_SQLITE3_CONTEXT,C_WSTRING,C_INT} ),
_sqlite3_result_error_toobig = define_c_proc( sqlite3, "sqlite3_result_error_toobig", {C_SQLITE3_CONTEXT} ),
_sqlite3_result_error_nomem = define_c_proc( sqlite3, "sqlite3_result_error_nomem", {C_SQLITE3_CONTEXT} ),
_sqlite3_result_error_code = define_c_proc( sqlite3, "sqlite3_result_error_code", {C_SQLITE3_CONTEXT,C_INT} ),
_sqlite3_result_int = define_c_proc( sqlite3, "sqlite3_result_int", {C_SQLITE3_CONTEXT,C_INT} ),
_sqlite3_result_int64 = define_c_proc( sqlite3, "sqlite3_result_int64", {C_SQLITE3_CONTEXT,C_LONGLONG} ),
_sqlite3_result_null = define_c_proc( sqlite3, "sqlite3_result_null", {C_SQLITE3_CONTEXT} ),
_sqlite3_result_text = define_c_proc( sqlite3, "sqlite3_result_text", {C_SQLITE3_CONTEXT,C_STRING,C_INT,C_CALLBACK} ),
_sqlite3_result_text64 = define_c_proc( sqlite3, "sqlite3_result_text64", {C_SQLITE3_CONTEXT,C_STRING,C_LONGLONG,C_CALLBACK,C_INT} ),
_sqlite3_result_text16 = define_c_proc( sqlite3, "sqlite3_result_text16", {C_SQLITE3_CONTEXT,C_POINTER,C_INT,C_CALLBACK} ),
_sqlite3_result_text16le = define_c_proc( sqlite3, "sqlite3_result_text16le", {C_SQLITE3_CONTEXT,C_POINTER,C_INT,C_CALLBACK} ),
_sqlite3_result_text16be = define_c_proc( sqlite3, "sqlite3_result_text16be", {C_SQLITE3_CONTEXT,C_POINTER,C_INT,C_CALLBACK} ),
_sqlite3_result_value = define_c_proc( sqlite3, "sqlite3_result_value", {C_SQLITE3_CONTEXT,C_SQLITE3_VALUE} ),
_sqlite3_result_pointer = define_c_proc( sqlite3, "sqlite3_result_pointer", {C_SQLITE3_CONTEXT,C_POINTER,C_STRING,C_CALLBACK} ),
_sqlite3_result_zeroblob = define_c_proc( sqlite3, "sqlite3_result_zeroblob", {C_SQLITE3_CONTEXT,C_INT} ),
_sqlite3_result_zeroblob64 = define_c_func( sqlite3, "sqlite3_result_zeroblob64", {C_SQLITE3_CONTEXT,C_LONGLONG}, C_INT ),
_sqlite3_result_subtype = define_c_proc( sqlite3, "sqlite3_result_subtype", {C_SQLITE3_CONTEXT,C_UINT} ),
_sqlite3_create_collation = define_c_func( sqlite3, "sqlite3_create_collation", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_CALLBACK}, C_INT ),
_sqlite3_create_collation_v2 = define_c_func( sqlite3, "sqlite3_create_collation_v2", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_CALLBACK,C_CALLBACK}, C_INT ),
_sqlite3_create_collation16 = define_c_func( sqlite3, "sqlite3_create_collation16", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_CALLBACK}, C_INT ),
_sqlite3_collation_needed = define_c_func( sqlite3, "sqlite3_collation_needed", {C_SQLITE3,C_POINTER,C_CALLBACK}, C_INT ),
_sqlite3_collation_needed16 = define_c_func( sqlite3, "sqlite3_collation_needed16", {C_SQLITE3,C_POINTER,C_CALLBACK}, C_INT ),
_sqlite3_sleep = define_c_func( sqlite3, "sqlite3_sleep", {C_INT}, C_INT ),
_sqlite3_temp_directory = define_c_var( sqlite3, "sqlite3_temp_directory" ),
_sqlite3_data_directory = define_c_var( sqlite3, "sqlite3_data_directory" ),
_sqlite3_win32_set_directory = define_c_func( sqlite3, "sqlite3_win32_set_directory", {C_ULONG,C_STRING}, C_INT ),
_sqlite3_win32_set_directory8 = define_c_func( sqlite3, "sqlite3_win32_set_directory8", {C_ULONG,C_STRING}, C_INT ),
_sqlite3_win32_set_directory16 = define_c_func( sqlite3, "sqlite3_win32_set_directory16", {C_ULONG,C_WSTRING}, C_INT ),
_sqlite3_get_autocommit = define_c_func( sqlite3, "sqlite3_get_autocommit", {C_SQLITE3}, C_INT ),
_sqlite3_db_handle = define_c_func( sqlite3, "sqlite3_db_handle", {C_SQLITE3_STMT}, C_SQLITE3 ),
_sqlite3_db_filename = define_c_func( sqlite3, "sqlite3_db_filename", {C_SQLITE3,C_STRING}, C_STRING ),
_sqlite3_db_readonly = define_c_func( sqlite3, "sqlite3_db_readonly", {C_SQLITE3,C_STRING}, C_INT ),
_sqlite3_next_stmt = define_c_func( sqlite3, "sqlite3_next_stmt", {C_SQLITE3,C_SQLITE3_STMT}, C_SQLITE3_STMT ),
_sqlite3_commit_hook = define_c_func( sqlite3, "sqlite3_commit_hook", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_POINTER ),
_sqlite3_rollback_hook = define_c_func( sqlite3, "sqlite3_rollback_hook", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_POINTER ),
_sqlite3_enable_shared_cache = define_c_func( sqlite3, "sqlite3_enable_shared_cache", {C_INT}, C_INT ),
_sqlite3_release_memory = define_c_func( sqlite3, "sqlite3_release_memory", {C_INT}, C_INT ),
_sqlite3_db_release_memory = define_c_func( sqlite3, "sqlite3_db_release_memory", {C_SQLITE3}, C_INT ),
_sqlite3_soft_heap_limit = define_c_proc( sqlite3, "sqlite3_soft_heap_limit", {C_INT} ),
_sqlite3_soft_heap_limit64 = define_c_func( sqlite3, "sqlite3_soft_heap_limit64", {C_LONGLONG}, C_LONGLONG ),
_sqlite3_table_column_metadata = define_c_func( sqlite3, "sqlite3_table_column_metadata", {C_SQLITE3,C_STRING,C_STRING,C_STRING,C_POINTER,C_POINTER,C_POINTER,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_load_extension = define_c_func( sqlite3, "sqlite3_load_extension", {C_SQLITE3,C_STRING,C_STRING,C_POINTER}, C_INT ),
_sqlite3_enable_load_extension = define_c_func( sqlite3, "sqlite3_enable_load_extension", {C_SQLITE3,C_INT}, C_INT ),
_sqlite3_auto_extension = define_c_func( sqlite3, "sqlite3_auto_extension", {C_CALLBACK}, C_INT ),
_sqlite3_cancel_auto_extension = define_c_func( sqlite3, "sqlite3_cancel_auto_extension", {C_CALLBACK}, C_INT ),
_sqlite3_reset_auto_extension = define_c_proc( sqlite3, "sqlite3_reset_auto_extension", {} ),
_sqlite3_create_module = define_c_func( sqlite3, "sqlite3_create_module", {C_SQLITE3,C_STRING,C_SQLITE3_MODULE,C_POINTER}, C_INT ),
_sqlite3_create_module_v2 = define_c_func( sqlite3, "sqlite3_create_module_v2", {C_SQLITE3,C_STRING,C_SQLITE3_MODULE,C_POINTER,C_CALLBACK}, C_INT ),
_sqlite3_declare_vtab = define_c_func( sqlite3, "sqlite3_declare_vtab", {C_SQLITE3,C_STRING}, C_INT ),
_sqlite3_overload_function = define_c_func( sqlite3, "sqlite3_overload_function", {C_SQLITE3,C_STRING,C_INT}, C_INT ),
_sqlite3_blob_open = define_c_func( sqlite3, "sqlite3_blob_open", {C_SQLITE3,C_STRING,C_STRING,C_STRING,C_LONGLONG,C_INT,C_POINTER}, C_INT ),
_sqlite3_blob_reopen = define_c_func( sqlite3, "sqlite3_blob_reopen", {C_SQLITE3_BLOB,C_LONGLONG}, C_INT ),
_sqlite3_blob_close = define_c_func( sqlite3, "sqlite3_blob_close", {C_SQLITE3_BLOB}, C_INT ),
_sqlite3_blob_bytes = define_c_func( sqlite3, "sqlite3_blob_bytes", {C_SQLITE3_BLOB}, C_INT ),
_sqlite3_blob_read = define_c_func( sqlite3, "sqlite3_blob_read", {C_SQLITE3_BLOB,C_POINTER,C_INT,C_INT}, C_INT ),
_sqlite3_blob_write = define_c_func( sqlite3, "sqlite3_blob_write", {C_SQLITE3_BLOB,C_POINTER,C_INT,C_INT}, C_INT ),
_sqlite3_vfs_find = define_c_func( sqlite3, "sqlite3_vfs_find", {C_STRING}, C_SQLITE3_VFS ),
_sqlite3_vfs_register = define_c_func( sqlite3, "sqlite3_vfs_register", {C_SQLITE3_VFS,C_INT}, C_INT ),
_sqlite3_vfs_unregister = define_c_func( sqlite3, "sqlite3_vfs_unregister", {C_SQLITE3_VFS}, C_INT ),
_sqlite3_file_control = define_c_func( sqlite3, "sqlite3_file_control", {C_SQLITE3,C_STRING,C_INT,C_POINTER}, C_INT ),
_sqlite3_keyword_count = define_c_func( sqlite3, "sqlite3_keyword_count", {}, C_INT ),
_sqlite3_keyword_name = define_c_func( sqlite3, "sqlite3_keyword_name", {C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_keyword_check = define_c_func( sqlite3, "sqlite3_keyword_check", {C_STRING,C_INT}, C_INT ),
_sqlite3_status = define_c_func( sqlite3, "sqlite3_status", {C_INT,C_POINTER,C_POINTER,C_INT}, C_INT ),
_sqlite3_status64 = define_c_func( sqlite3, "sqlite3_status64", {C_INT,C_POINTER,C_POINTER,C_INT}, C_INT ),
_sqlite3_db_status = define_c_func( sqlite3, "sqlite3_db_status", {C_SQLITE3,C_INT,C_POINTER,C_POINTER,C_INT}, C_INT ),
_sqlite3_stmt_status = define_c_func( sqlite3, "sqlite3_stmt_status", {C_SQLITE3_STMT,C_INT,C_INT}, C_INT ),
_sqlite3_backup_init = define_c_func( sqlite3, "sqlite3_backup_init", {C_SQLITE3,C_STRING,C_SQLITE3,C_STRING}, C_SQLITE3_BACKUP ),
_sqlite3_backup_step = define_c_func( sqlite3, "sqlite3_backup_step", {C_SQLITE3_BACKUP,C_INT}, C_INT ),
_sqlite3_backup_finish = define_c_func( sqlite3, "sqlite3_backup_finish", {C_SQLITE3_BACKUP}, C_INT ),
_sqlite3_backup_remaining = define_c_func( sqlite3, "sqlite3_backup_remaining", {C_SQLITE3_BACKUP}, C_INT ),
_sqlite3_backup_pagecount = define_c_func( sqlite3, "sqlite3_backup_pagecount", {C_SQLITE3_BACKUP}, C_INT ),
_sqlite3_wal_hook = define_c_func( sqlite3, "sqlite3_wal_hook", {C_SQLITE3,C_CALLBACK,C_POINTER}, C_POINTER ),
_sqlite3_wal_autocheckpoint = define_c_func( sqlite3, "sqlite3_wal_autocheckpoint", {C_SQLITE3,C_INT}, C_INT ),
_sqlite3_wal_checkpoint = define_c_func( sqlite3, "sqlite3_wal_checkpoint", {C_SQLITE3,C_STRING}, C_INT ),
_sqlite3_wal_checkpoint_v2 = define_c_func( sqlite3, "sqlite3_wal_checkpoint_v2", {C_SQLITE3,C_STRING,C_INT,C_POINTER,C_POINTER}, C_INT ),
_sqlite3_db_cacheflush = define_c_func( sqlite3, "sqlite3_db_cacheflush", {C_SQLITE3}, C_INT ),
_sqlite3_system_errno = define_c_func( sqlite3, "sqlite3_system_errno", {C_SQLITE3}, C_INT ),
_sqlite3_serialize = define_c_func( sqlite3, "sqlite3_serialize", {C_SQLITE3,C_STRING,C_POINTER,C_UINT}, C_STRING ),
_sqlite3_deserialize = define_c_func( sqlite3, "sqlite3_deserialize", {C_SQLITE3,C_STRING,C_POINTER,C_LONGLONG,C_LONGLONG,C_UINT}, C_INT ),
$
map _sqlite3_config = map:new()
map _sqlite3_db_config = map:new()
/*
** CAPI3REF: Compile-Time Library Version Numbers
**
** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
** evaluates to a string literal that is the SQLite version in the
** format "X.Y.Z" where X is the major version number (always 3 for
** SQLite3) and Y is the minor version number and Z is the release number.)^
** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
** numbers used in [SQLITE_VERSION].)^
** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
** be larger than the release from which it is derived. Either Y will
** be held constant and Z will be incremented or else Y will be incremented
** and Z will be reset to zero.
**
** Since [version 3.6.18] ([dateof:3.6.18]),
** SQLite source code has been stored in the
** <a href="http://www.fossil-scm.org/">Fossil configuration management
** system</a>. ^The SQLITE_SOURCE_ID macro evaluates to
** a string which identifies a particular check-in of SQLite
** within its configuration management system. ^The SQLITE_SOURCE_ID
** string contains the date and time of the check-in (UTC) and a SHA1
** or SHA3-256 hash of the entire source tree. If the source code has
** been edited in any way since it was last checked in, then the last
** four hexadecimal digits of the hash may be modified.
**
** See also: [sqlite3_libversion()],
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
** [sqlite_version()] and [sqlite_source_id()].
*/
public constant SQLITE_VERSION = "3.33.0"
public constant SQLITE_VERSION_NUMBER = 3033000
public constant SQLITE_SOURCE_ID = "2020-08-14 13:23:32 fca8dc8b578f215a969cd899336378966156154710873e68b3d9ac5881b0ff3f"
/*
** CAPI3REF: Run-Time Library Version Numbers
** KEYWORDS: sqlite3_version sqlite3_sourceid
**
** These interfaces provide the same information as the [SQLITE_VERSION],
** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
** but are associated with the library instead of the header file. ^(Cautious
** programmers might include assert() statements in their application to
** verify that values returned by these interfaces match the macros in
** the header, and thus ensure that the application is
** compiled with matching library and header files.
**
** <blockquote><pre>
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 );
** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
** </pre></blockquote>)^
**
** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
** macro. ^The sqlite3_libversion() function returns a pointer to the
** to the sqlite3_version[] string constant. The sqlite3_libversion()
** function is provided for use in DLLs since DLL users usually do not have
** direct access to string constants within the DLL. ^The
** sqlite3_libversion_number() function returns an integer equal to
** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns
** a pointer to a string constant whose value is the same as the
** [SQLITE_SOURCE_ID] C preprocessor macro. Except if SQLite is built
** using an edited copy of [the amalgamation], then the last four characters
** of the hash might be different from [SQLITE_SOURCE_ID].)^
**
** See also: [sqlite_version()] and [sqlite_source_id()].
*/
public constant sqlite3_version = peek_string( _sqlite3_version )
public function sqlite3_libversion()
return peek_string( c_func( _sqlite3_libversion, {} ) )
end function
public function sqlite3_sourceid()
return peek_string( c_func( _sqlite3_sourceid, {} ) )
end function
public function sqlite3_libversion_number()
return c_func( _sqlite3_libversion_number, {} )
end function
public constant
SQLITE_INVALID_VERSION = -1,
SQLITE_INVALID_VERSION_NUMBER = -2,
SQLITE_INVALID_SOURCE_ID = -3,
$
public function sqlite3_check_version()
if not equal( sqlite3_libversion(), SQLITE_VERSION ) then
return SQLITE_INVALID_VERSION
end if
if not equal( sqlite3_libversion_number(), SQLITE_VERSION_NUMBER ) then
return SQLITE_INVALID_VERSION_NUMBER
end if
if not equal( sqlite3_sourceid(), SQLITE_SOURCE_ID ) then
return SQLITE_INVALID_SOURCE_ID
end if
return SQLITE_OK
end function
/*
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
**
** ^The sqlite3_compileoption_used() function returns 0 or 1
** indicating whether the specified option was defined at
** compile time. ^The SQLITE_ prefix may be omitted from the
** option name passed to sqlite3_compileoption_used().
**
** ^The sqlite3_compileoption_get() function allows iterating
** over the list of options that were defined at compile time by
** returning the N-th compile time option string. ^If N is out of range,
** sqlite3_compileoption_get() returns a NULL pointer. ^The SQLITE_
** prefix is omitted from any strings returned by
** sqlite3_compileoption_get().
**
** ^Support for the diagnostic functions sqlite3_compileoption_used()
** and sqlite3_compileoption_get() may be omitted by specifying the
** [SQLITE_OMIT_COMPILEOPTION_DIAGS] option at compile time.
**
** See also: SQL functions [sqlite_compileoption_used()] and
** [sqlite_compileoption_get()] and the [compile_options pragma].
*/
public function sqlite3_compileoption_used( sequence optname )
return c_func( _sqlite3_compileoption_used, {allocate_string(optname,TRUE)} )
end function
public function sqlite3_compileoption_get( integer opt )
return peek_string( c_func( _sqlite3_compileoption_get, {opt} ) )
end function
/*
** CAPI3REF: Test To See If The Library Is Threadsafe
**
** ^The sqlite3_threadsafe() function returns zero if and only if
** SQLite was compiled with mutexing code omitted due to the
** [SQLITE_THREADSAFE] compile-time option being set to 0.
**
** SQLite can be compiled with or without mutexes. When
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
** are enabled and SQLite is threadsafe. When the
** [SQLITE_THREADSAFE] macro is 0,
** the mutexes are omitted. Without the mutexes, it is not safe
** to use SQLite concurrently from more than one thread.
**
** Enabling mutexes incurs a measurable performance penalty.
** So if speed is of utmost importance, it makes sense to disable
** the mutexes. But for maximum safety, mutexes should be enabled.
** ^The default behavior is for mutexes to be enabled.
**
** This interface can be used by an application to make sure that the
** version of SQLite that it is linking against was compiled with
** the desired setting of the [SQLITE_THREADSAFE] macro.
**
** This interface only reports on the compile-time mutex setting
** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
** can be fully or partially disabled using a call to [sqlite3_config()]
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
** or [SQLITE_CONFIG_SERIALIZED]. ^(The return value of the
** sqlite3_threadsafe() function shows only the compile-time setting of
** thread safety, not any run-time changes to that setting made by
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
** is unchanged by calls to sqlite3_config().)^
**
** See the [threading mode] documentation for additional information.
*/
public function sqlite3_threadsafe()
return c_func( _sqlite3_threadsafe, {} )
end function
/*
** CAPI3REF: Closing A Database Connection
** DESTRUCTOR: sqlite3
**
** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
** for the [sqlite3] object.
** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
** the [sqlite3] object is successfully destroyed and all associated
** resources are deallocated.
**
** Ideally, applications should [sqlite3_finalize | finalize] all
** [prepared statements], [sqlite3_blob_close | close] all [BLOB handles], and
** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
** with the [sqlite3] object prior to attempting to close the object.
** ^If the database connection is associated with unfinalized prepared
** statements, BLOB handlers, and/or unfinished sqlite3_backup objects then
** sqlite3_close() will leave the database connection open and return
** [SQLITE_BUSY]. ^If sqlite3_close_v2() is called with unfinalized prepared
** statements, unclosed BLOB handlers, and/or unfinished sqlite3_backups,
** it returns [SQLITE_OK] regardless, but instead of deallocating the database
** connection immediately, it marks the database connection as an unusable
** "zombie" and makes arrangements to automatically deallocate the database
** connection after all prepared statements are finalized, all BLOB handles
** are closed, and all backups have finished. The sqlite3_close_v2() interface
** is intended for use with host languages that are garbage collected, and
** where the order in which destructors are called is arbitrary.
**
** ^If an [sqlite3] object is destroyed while a transaction is open,
** the transaction is automatically rolled back.
**
** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]
** must be either a NULL
** pointer or an [sqlite3] object pointer obtained
** from [sqlite3_open()], [sqlite3_open16()], or
** [sqlite3_open_v2()], and not previously closed.
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
** argument is a harmless no-op.
*/
public function sqlite3_close( atom db )
return c_func( _sqlite3_close, {db} )
end function
public function sqlite3_close_v2( atom db )
return c_func( _sqlite3_close_v2, {db} )
end function
/*
** CAPI3REF: One-Step Query Execution Interface
** METHOD: sqlite3
**
** The sqlite3_exec() interface is a convenience wrapper around
** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
** that allows an application to run multiple statements of SQL
** without having to use a lot of C code.
**
** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
** semicolon-separate SQL statements passed into its 2nd argument,
** in the context of the [database connection] passed in as its 1st
** argument. ^If the callback function of the 3rd argument to
** sqlite3_exec() is not NULL, then it is invoked for each result row
** coming out of the evaluated SQL statements. ^The 4th argument to
** sqlite3_exec() is relayed through to the 1st argument of each
** callback invocation. ^If the callback pointer to sqlite3_exec()
** is NULL, then no callback is ever invoked and result rows are
** ignored.
**
** ^If an error occurs while evaluating the SQL statements passed into
** sqlite3_exec(), then execution of the current statement stops and
** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
** is not NULL then any error message is written into memory obtained
** from [sqlite3_malloc()] and passed back through the 5th parameter.
** To avoid memory leaks, the application should invoke [sqlite3_free()]
** on error message strings returned through the 5th parameter of
** sqlite3_exec() after the error message string is no longer needed.
** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
** NULL before returning.
**
** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
** routine returns SQLITE_ABORT without invoking the callback again and
** without running any subsequent SQL statements.
**
** ^The 2nd argument to the sqlite3_exec() callback function is the
** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
** callback is an array of pointers to strings obtained as if from
** [sqlite3_column_text()], one for each column. ^If an element of a
** result row is NULL then the corresponding string pointer for the
** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
** sqlite3_exec() callback is an array of pointers to strings where each
** entry represents the name of corresponding result column as obtained
** from [sqlite3_column_name()].
**
** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
** to an empty string, or a pointer that contains only whitespace and/or
** SQL comments, then no SQL statements are evaluated and the database
** is not changed.
**
** Restrictions:
**
** <ul>
** <li> The application must ensure that the 1st parameter to sqlite3_exec()
** is a valid and open [database connection].
** <li> The application must not close the [database connection] specified by
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
** <li> The application must not modify the SQL statement text passed into
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
** </ul>
*/
public function sqlite3_exec( atom db, sequence sql, sequence func="", atom data=NULL, integer func_id=routine_id(func) )
return c_func( _sqlite3_exec, {db,allocate_string(sql,TRUE),call_back(func_id),data,NULL} )
end function
public function sqlite3_exec_stmt( atom db, sequence sql, object params = {} )
atom result, stmt
{result,stmt} = sqlite3_prepare16_v2( db, sql )
if result != SQLITE_OK then
return {result,NULL}
end if
if atom( params ) then
params = {params}
end if
for i = 1 to length( params ) do
if atom( params[i] ) or length( params[i] ) != 2 then
params[i] = {params[i]}
end if
object param_value = params[i][1]
integer param_type = SQLITE_NULL
if length( params[i] ) = 2 then param_type = params[i][2]
elsif integer( param_value ) then param_type = SQLITE_INTEGER
elsif atom( param_value ) then param_type = SQLITE_FLOAT
elsif string( param_value ) then param_type = SQLITE_TEXT
else param_type = SQLITE_BLOB
end if
switch param_type do
case SQLITE_INTEGER then sqlite3_bind_int( stmt, i, param_value )
case SQLITE_FLOAT then sqlite3_bind_double( stmt, i, param_value )
case SQLITE_TEXT then sqlite3_bind_text( stmt, i, param_value )
case SQLITE_BLOB then sqlite3_bind_blob( stmt, i, param_value )
end switch
end for
result = sqlite3_step( stmt )
sqlite3_finalize( stmt )
return result
end function
public function sqlite3_exec_scalar( atom db, sequence sql, object params = {} )
atom result, stmt
{result,stmt} = sqlite3_prepare16_v2( db, sql )
if result != SQLITE_OK then
return {result,NULL}
end if
if atom( params ) then
params = {params}
end if
for i = 1 to length( params ) do
if atom( params[i] ) or length( params[i] ) != 2 then
params[i] = {params[i]}
end if
object param_value = params[i][1]
integer param_type = SQLITE_NULL
if length( params[i] ) = 2 then param_type = params[i][2]
elsif integer( param_value ) then param_type = SQLITE_INTEGER
elsif atom( param_value ) then param_type = SQLITE_FLOAT
elsif string( param_value ) then param_type = SQLITE_TEXT
else param_type = SQLITE_BLOB
end if
switch param_type do
case SQLITE_INTEGER then sqlite3_bind_int( stmt, i, param_value )
case SQLITE_FLOAT then sqlite3_bind_double( stmt, i, param_value )
case SQLITE_TEXT then sqlite3_bind_text( stmt, i, param_value )
case SQLITE_BLOB then sqlite3_bind_blob( stmt, i, param_value )
end switch
end for
result = sqlite3_step( stmt )
if result != SQLITE_ROW then
sqlite3_finalize( stmt )
return {result,NULL}
end if
integer columns = sqlite3_column_count( stmt )
if columns != 1 then
sqlite3_finalize( stmt )
return {SQLITE_MISUSE,NULL}
end if
sequence row = sqlite3_fetch_row( stmt )
sqlite3_finalize( stmt )
return {SQLITE_DONE,row[1]}
end function
/*
** CAPI3REF: Result Codes
** KEYWORDS: {result code definitions}
**
** Many SQLite functions return an integer result code from the set shown
** here in order to indicate success or failure.
**
** New error codes may be added in future versions of SQLite.
**
** See also: [extended result code definitions]
*/
public constant
SQLITE_OK = 0, /* Successful result */
/* beginning-of-error-codes */
SQLITE_ERROR = 1, /* Generic error */
SQLITE_INTERNAL = 2, /* Internal logic error in SQLite */
SQLITE_PERM = 3, /* Access permission denied */
SQLITE_ABORT = 4, /* Callback routine requested an abort */
SQLITE_BUSY = 5, /* The database file is locked */
SQLITE_LOCKED = 6, /* A table in the database is locked */
SQLITE_NOMEM = 7, /* A malloc() failed */
SQLITE_READONLY = 8, /* Attempt to write a readonly database */
SQLITE_INTERRUPT = 9, /* Operation terminated by sqlite3_interrupt()*/
SQLITE_IOERR = 10, /* Some kind of disk I/O error occurred */
SQLITE_CORRUPT = 11, /* The database disk image is malformed */
SQLITE_NOTFOUND = 12, /* Unknown opcode in sqlite3_file_control() */
SQLITE_FULL = 13, /* Insertion failed because database is full */
SQLITE_CANTOPEN = 14, /* Unable to open the database file */
SQLITE_PROTOCOL = 15, /* Database lock protocol error */
SQLITE_EMPTY = 16, /* Internal use only */
SQLITE_SCHEMA = 17, /* The database schema changed */
SQLITE_TOOBIG = 18, /* String or BLOB exceeds size limit */
SQLITE_CONSTRAINT = 19, /* Abort due to constraint violation */
SQLITE_MISMATCH = 20, /* Data type mismatch */
SQLITE_MISUSE = 21, /* Library used incorrectly */
SQLITE_NOLFS = 22, /* Uses OS features not supported on host */
SQLITE_AUTH = 23, /* Authorization denied */
SQLITE_FORMAT = 24, /* Not used */
SQLITE_RANGE = 25, /* 2nd parameter to sqlite3_bind out of range */
SQLITE_NOTADB = 26, /* File opened that is not a database file */
SQLITE_NOTICE = 27, /* Notifications from sqlite3_log() */
SQLITE_WARNING = 28, /* Warnings from sqlite3_log() */
SQLITE_ROW = 100, /* sqlite3_step() has another row ready */
SQLITE_DONE = 101, /* sqlite3_step() has finished executing */
/* end-of-error-codes */
$
/*
** CAPI3REF: Extended Result Codes
** KEYWORDS: {extended result code definitions}
**
** In its default configuration, SQLite API routines return one of 30 integer
** [result codes]. However, experience has shown that many of
** these result codes are too coarse-grained. They do not provide as
** much information about problems as programmers might like. In an effort to
** address this, newer versions of SQLite (version 3.3.8 [dateof:3.3.8]
** and later) include
** support for additional result codes that provide more detailed information
** about errors. These [extended result codes] are enabled or disabled
** on a per database connection basis using the
** [sqlite3_extended_result_codes()] API. Or, the extended code for
** the most recent error can be obtained using
** [sqlite3_extended_errcode()].
*/
public constant
SQLITE_ERROR_MISSING_COLLSEQ = 257, -- (SQLITE_ERROR | ( 1<<8))
SQLITE_ERROR_RETRY = 513, -- (SQLITE_ERROR | ( 2<<8))
SQLITE_ERROR_SNAPSHOT = 769, -- (SQLITE_ERROR | ( 3<<8))
SQLITE_IOERR_READ = 266, -- (SQLITE_IOERR | ( 1<<8))
SQLITE_IOERR_SHORT_READ = 522, -- (SQLITE_IOERR | ( 2<<8))
SQLITE_IOERR_WRITE = 778, -- (SQLITE_IOERR | ( 3<<8))
SQLITE_IOERR_FSYNC = 1034, -- (SQLITE_IOERR | ( 4<<8))
SQLITE_IOERR_DIR_FSYNC = 1290, -- (SQLITE_IOERR | ( 5<<8))
SQLITE_IOERR_TRUNCATE = 1546, -- (SQLITE_IOERR | ( 6<<8))
SQLITE_IOERR_FSTAT = 1802, -- (SQLITE_IOERR | ( 7<<8))
SQLITE_IOERR_UNLOCK = 2058, -- (SQLITE_IOERR | ( 8<<8))
SQLITE_IOERR_RDLOCK = 2314, -- (SQLITE_IOERR | ( 9<<8))
SQLITE_IOERR_DELETE = 2570, -- (SQLITE_IOERR | (10<<8))
SQLITE_IOERR_BLOCKED = 2826, -- (SQLITE_IOERR | (11<<8))
SQLITE_IOERR_NOMEM = 3082, -- (SQLITE_IOERR | (12<<8))
SQLITE_IOERR_ACCESS = 3338, -- (SQLITE_IOERR | (13<<8))
SQLITE_IOERR_CHECKRESERVEDLOCK = 3594, -- (SQLITE_IOERR | (14<<8))
SQLITE_IOERR_LOCK = 3850, -- (SQLITE_IOERR | (15<<8))
SQLITE_IOERR_CLOSE = 4106, -- (SQLITE_IOERR | (16<<8))
SQLITE_IOERR_DIR_CLOSE = 4362, -- (SQLITE_IOERR | (17<<8))
SQLITE_IOERR_SHMOPEN = 4618, -- (SQLITE_IOERR | (18<<8))
SQLITE_IOERR_SHMSIZE = 4874, -- (SQLITE_IOERR | (19<<8))
SQLITE_IOERR_SHMLOCK = 5130, -- (SQLITE_IOERR | (20<<8))
SQLITE_IOERR_SHMMAP = 5386, -- (SQLITE_IOERR | (21<<8))
SQLITE_IOERR_SEEK = 5642, -- (SQLITE_IOERR | (22<<8))
SQLITE_IOERR_DELETE_NOENT = 5898, -- (SQLITE_IOERR | (23<<8))
SQLITE_IOERR_MMAP = 6154, -- (SQLITE_IOERR | (24<<8))
SQLITE_IOERR_GETTEMPPATH = 6410, -- (SQLITE_IOERR | (25<<8))
SQLITE_IOERR_CONVPATH = 6666, -- (SQLITE_IOERR | (26<<8))
SQLITE_IOERR_VNODE = 6922, -- (SQLITE_IOERR | (27<<8))
SQLITE_IOERR_AUTH = 7178, -- (SQLITE_IOERR | (28<<8))
SQLITE_IOERR_BEGIN_ATOMIC = 7434, -- (SQLITE_IOERR | (29<<8))
SQLITE_IOERR_COMMIT_ATOMIC = 7690, -- (SQLITE_IOERR | (30<<8))
SQLITE_IOERR_ROLLBACK_ATOMIC = 7946, -- (SQLITE_IOERR | (31<<8))
SQLITE_LOCKED_SHAREDCACHE = 262, -- (SQLITE_LOCKED | (1<<8))
SQLITE_LOCKED_VTAB = 518, -- (SQLITE_LOCKED | (2<<8))
SQLITE_BUSY_RECOVERY = 261, -- (SQLITE_BUSY | (1<<8))
SQLITE_BUSY_SNAPSHOT = 517, -- (SQLITE_BUSY | (2<<8))
SQLITE_CANTOPEN_NOTEMPDIR = 270, -- (SQLITE_CANTOPEN | (1<<8))
SQLITE_CANTOPEN_ISDIR = 526, -- (SQLITE_CANTOPEN | (2<<8))
SQLITE_CANTOPEN_FULLPATH = 782, -- (SQLITE_CANTOPEN | (3<<8))
SQLITE_CANTOPEN_CONVPATH = 1038, -- (SQLITE_CANTOPEN | (4<<8))
SQLITE_CANTOPEN_DIRTYWAL = 1294, -- (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
SQLITE_CORRUPT_VTAB = 267, -- (SQLITE_CORRUPT | (1<<8))
SQLITE_CORRUPT_SEQUENCE = 523, -- (SQLITE_CORRUPT | (2<<8))
SQLITE_READONLY_RECOVERY = 264, -- (SQLITE_READONLY | (1<<8))
SQLITE_READONLY_CANTLOCK = 520, -- (SQLITE_READONLY | (2<<8))
SQLITE_READONLY_ROLLBACK = 776, -- (SQLITE_READONLY | (3<<8))
SQLITE_READONLY_DBMOVED = 1032, -- (SQLITE_READONLY | (4<<8))
SQLITE_READONLY_CANTINIT = 1288, -- (SQLITE_READONLY | (5<<8))
SQLITE_READONLY_DIRECTORY = 1544, -- (SQLITE_READONLY | (6<<8))
SQLITE_ABORT_ROLLBACK = 516, -- (SQLITE_ABORT | (2<<8))
SQLITE_CONSTRAINT_CHECK = 275, -- (SQLITE_CONSTRAINT | (1<<8))
SQLITE_CONSTRAINT_COMMITHOOK = 531, -- (SQLITE_CONSTRAINT | (2<<8))
SQLITE_CONSTRAINT_FOREIGNKEY = 787, -- (SQLITE_CONSTRAINT | (3<<8))
SQLITE_CONSTRAINT_FUNCTION = 1043, -- (SQLITE_CONSTRAINT | (4<<8))
SQLITE_CONSTRAINT_NOTNULL = 1299, -- (SQLITE_CONSTRAINT | (5<<8))
SQLITE_CONSTRAINT_PRIMARYKEY = 1555, -- (SQLITE_CONSTRAINT | (6<<8))
SQLITE_CONSTRAINT_TRIGGER = 1811, -- (SQLITE_CONSTRAINT | (7<<8))
SQLITE_CONSTRAINT_UNIQUE = 2067, -- (SQLITE_CONSTRAINT | (8<<8))
SQLITE_CONSTRAINT_VTAB = 2323, -- (SQLITE_CONSTRAINT | (9<<8))
SQLITE_CONSTRAINT_ROWID = 2579, -- (SQLITE_CONSTRAINT | (10<<8))
SQLITE_NOTICE_RECOVER_WAL = 283, -- (SQLITE_NOTICE | (1<<8))
SQLITE_NOTICE_RECOVER_ROLLBACK = 539, -- (SQLITE_NOTICE | (2<<8))
SQLITE_WARNING_AUTOINDEX = 284, -- (SQLITE_WARNING | (1<<8))
SQLITE_AUTH_USER = 279, -- (SQLITE_AUTH | (1<<8))
SQLITE_OK_LOAD_PERMANENTLY = 256, -- (SQLITE_OK | (1<<8))
$
/*
** CAPI3REF: Flags For File Open Operations
**
** These bit values are intended for use in the
** 3rd parameter to the [sqlite3_open_v2()] interface and
** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
*/
public constant
SQLITE_OPEN_READONLY = 0x00000001, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_READWRITE = 0x00000002, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_CREATE = 0x00000004, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_DELETEONCLOSE = 0x00000008, /* VFS only */
SQLITE_OPEN_EXCLUSIVE = 0x00000010, /* VFS only */
SQLITE_OPEN_AUTOPROXY = 0x00000020, /* VFS only */
SQLITE_OPEN_URI = 0x00000040, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_MEMORY = 0x00000080, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_MAIN_DB = 0x00000100, /* VFS only */
SQLITE_OPEN_TEMP_DB = 0x00000200, /* VFS only */
SQLITE_OPEN_TRANSIENT_DB = 0x00000400, /* VFS only */
SQLITE_OPEN_MAIN_JOURNAL = 0x00000800, /* VFS only */
SQLITE_OPEN_TEMP_JOURNAL = 0x00001000, /* VFS only */
SQLITE_OPEN_SUBJOURNAL = 0x00002000, /* VFS only */
SQLITE_OPEN_NOMUTEX = 0x00008000, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_FULLMUTEX = 0x00010000, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_SHAREDCACHE = 0x00020000, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_PRIVATECACHE = 0x00040000, /* Ok for sqlite3_open_v2() */
SQLITE_OPEN_WAL = 0x00080000, /* VFS only */
/* Reserved: 0x00F00000, */
/* Legacy compatibility: */
SQLITE_OPEN_MASTER_JOURNAL = 0x00004000, /* VFS only */
$
/*
** CAPI3REF: Device Characteristics
**
** The xDeviceCharacteristics method of the [sqlite3_io_methods]
** object returns an integer which is a vector of these
** bit values expressing I/O characteristics of the mass storage
** device that holds the file that the [sqlite3_io_methods]
** refers to.
**
** The SQLITE_IOCAP_ATOMIC property means that all writes of
** any size are atomic. The SQLITE_IOCAP_ATOMICnnn values
** mean that writes of blocks that are nnn bytes in size and
** are aligned to an address which is an integer multiple of
** nnn are atomic. The SQLITE_IOCAP_SAFE_APPEND value means
** that when data is appended to a file, the data is appended
** first then the size of the file is extended, never the other
** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
** information is written to disk in the same order as calls
** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
** after reboot following a crash or power loss, the only bytes in a
** file that were written at the application level might have changed
** and that adjacent bytes, even bytes within the same sector are
** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
** flag indicates that a file cannot be deleted when open. The
** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
** read-only media and cannot be changed even by processes with
** elevated privileges.
**
** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying
** filesystem supports doing multiple write operations atomically when those
** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and
** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE].
*/
public constant
SQLITE_IOCAP_ATOMIC = 0x00000001,
SQLITE_IOCAP_ATOMIC512 = 0x00000002,
SQLITE_IOCAP_ATOMIC1K = 0x00000004,
SQLITE_IOCAP_ATOMIC2K = 0x00000008,
SQLITE_IOCAP_ATOMIC4K = 0x00000010,
SQLITE_IOCAP_ATOMIC8K = 0x00000020,
SQLITE_IOCAP_ATOMIC16K = 0x00000040,
SQLITE_IOCAP_ATOMIC32K = 0x00000080,
SQLITE_IOCAP_ATOMIC64K = 0x00000100,
SQLITE_IOCAP_SAFE_APPEND = 0x00000200,
SQLITE_IOCAP_SEQUENTIAL = 0x00000400,
SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN = 0x00000800,
SQLITE_IOCAP_POWERSAFE_OVERWRITE = 0x00001000,
SQLITE_IOCAP_IMMUTABLE = 0x00002000,
SQLITE_IOCAP_BATCH_ATOMIC = 0x00004000,
$
/*
** CAPI3REF: File Locking Levels
**
** SQLite uses one of these integer values as the second
** argument to calls it makes to the xLock() and xUnlock() methods
** of an [sqlite3_io_methods] object.
*/
public constant
SQLITE_LOCK_NONE = 0,
SQLITE_LOCK_SHARED = 1,
SQLITE_LOCK_RESERVED = 2,
SQLITE_LOCK_PENDING = 3,
SQLITE_LOCK_EXCLUSIVE = 4,
$
/*
** CAPI3REF: Synchronization Type Flags
**
** When SQLite invokes the xSync() method of an
** [sqlite3_io_methods] object it uses a combination of
** these integer values as the second argument.
**
** When the SQLITE_SYNC_DATAONLY flag is used, it means that the
** sync operation only needs to flush data to mass storage. Inode
** information need not be flushed. If the lower four bits of the flag
** equal SQLITE_SYNC_NORMAL, that means to use normal fsync() semantics.
** If the lower four bits equal SQLITE_SYNC_FULL, that means
** to use Mac OS X style fullsync instead of fsync().
**
** Do not confuse the SQLITE_SYNC_NORMAL and SQLITE_SYNC_FULL flags
** with the [PRAGMA synchronous]=NORMAL and [PRAGMA synchronous]=FULL
** settings. The [synchronous pragma] determines when calls to the