-
-
Notifications
You must be signed in to change notification settings - Fork 136
/
Copy pathmormot.db.raw.sqlite3.pas
9236 lines (8651 loc) · 439 KB
/
mormot.db.raw.sqlite3.pas
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
/// Database Framework Low-Level SQLite3 Engine
// - this unit is a part of the Open Source Synopse mORMot framework 2,
// licensed under a MPL/GPL/LGPL three license - see LICENSE.md
unit mormot.db.raw.sqlite3;
{
*****************************************************************************
Direct Access to the SQLite3 Database Engine
- Raw SQLite3 API Constants and Functions
- High-Level Classes for SQlite3 Queries
*****************************************************************************
}
interface
{$I ..\mormot.defines.inc}
uses
sysutils,
classes,
mormot.core.base,
mormot.core.os,
mormot.core.data,
mormot.core.unicode,
mormot.core.text,
mormot.core.datetime,
mormot.core.json,
mormot.core.rtti,
mormot.core.perf,
mormot.core.buffers,
mormot.core.variants,
mormot.core.search, // for soundex functions
mormot.core.log,
mormot.db.core,
mormot.lib.static;
{ ************ Raw SQLite3 API Constants and Functions }
{$ifdef FPC}
{$packrecords C}
{$packenum 4}
{$endif FPC}
type
/// internally store the SQLite3 database handle
TSqlite3DB = type PtrUInt;
/// internally store the SQLite3 statement handle
// - This object is variously known as a "prepared statement" or a "compiled
// SQL statement" or simply as a "statement".
// - Create the object using sqlite3.prepare_v2() or a related function.
// - Bind values to host parameters using the sqlite3.bind_*() interfaces.
// - Run the SQL by calling sqlite3.step() one or more times.
// - Reset the statement using sqlite3.reset() then go back to "Bind" step.
// Do this zero or more times.
// - Destroy the object using sqlite3.finalize().
TSqlite3Statement = type PtrUInt;
/// internally store the SQLite3 blob handle
TSqlite3Blob = type PtrUInt;
/// internally store a SQLite3 Dynamically Typed Value Object
// - SQLite uses the sqlite3.value object to represent all values that
// can be stored in a database table, which are mapped to this TSqlite3Value type
// - SQLite uses dynamic typing for the values it stores
// - Values stored in sqlite3.value objects can be integers, floating point
// values, strings, BLOBs, or NULL
TSqlite3Value = type PtrUInt;
/// internal store a SQLite3 Function Context Object
// - The context in which an SQL function executes is stored in an sqlite3.context
// object, which is mapped to this TSqlite3FunctionContext type
// - A pointer to an sqlite3.context object is always first parameter to
// application-defined SQL functions, i.e. a TSqlFunctionFunc prototype
TSqlite3FunctionContext = type PtrUInt;
/// internally store a SQLite3 Backup process handle
TSqlite3Backup = type PtrUInt;
/// internally store of SQLite3 values, as used by TSqlFunctionFunc
TSqlite3ValueArray = array[0..63] of TSqlite3Value;
/// A pointer to the opaque TSqlite3APIRoutines structure is passed as the third
// parameter to entry points of loadable extensions.
TSqlite3APIRoutines = type PtrUInt;
const
{$ifdef OSWINDOWS}
{$ifdef CPU64}
// see https://synopse.info/files/SQLite3-64.7z or static/delphi folder
SQLITE_LIBRARY_DEFAULT_NAME = 'sqlite3-64.dll';
{$else}
SQLITE_LIBRARY_DEFAULT_NAME = 'sqlite3.dll';
{$endif CPU64}
{$else}
{$ifdef OSPOSIX}
{$ifdef OSANDROID}
SQLITE_LIBRARY_DEFAULT_NAME = 'libsqlite.so';
{$else}
{$ifdef OSDARWIN}
SQLITE_LIBRARY_DEFAULT_NAME = 'libsqlite3.dylib';
{$else}
SQLITE_LIBRARY_DEFAULT_NAME = 'libsqlite3.so.0';
{$endif OSDARWIN}
{$endif OSANDROID}
{$endif OSPOSIX}
{$endif OSWINDOWS}
/// internal SQLite3 type as integer
SQLITE_INTEGER = 1;
/// internal SQLite3 type as Floating point value
SQLITE_FLOAT = 2;
/// internal SQLite3 type as Text
SQLITE_TEXT = 3;
/// internal SQLite3 type as Blob
SQLITE_BLOB = 4;
/// internal SQLite3 type as NULL
SQLITE_NULL = 5;
/// text is UTF-8 encoded
SQLITE_UTF8 = 1;
/// text is UTF-16 LE encoded
SQLITE_UTF16LE = 2;
/// text is UTF-16 BE encoded
SQLITE_UTF16BE = 3;
/// text is UTF-16 encoded, using the system native byte order
SQLITE_UTF16 = 4;
/// sqlite3.create_function don't care about text encoding
SQLITE_ANY = 5;
/// used by sqlite3.create_collation() only
SQLITE_UTF16_ALIGNED = 8;
/// Successful result. No error occurred
SQLITE_OK = 0;
/// SQL error or missing database - legacy generic code
// - Use Extended Result Codes for more detailed information about errors
// - sqlite3.extended_result_codes() enables or disables the extended result codes
// - Or, the extended code for the most recent error can be obtained using
// sqlite3.extended_errcode()
SQLITE_ERROR = 1;
/// An internal logic error in SQLite
SQLITE_INTERNAL = 2;
/// Access permission denied
SQLITE_PERM = 3;
/// Callback routine requested an abort
SQLITE_ABORT = 4;
/// The database file is locked
SQLITE_BUSY = 5;
/// A table in the database is locked
SQLITE_LOCKED = 6;
/// A malloc() failed
SQLITE_NOMEM = 7;
/// Attempt to write a readonly database
SQLITE_READONLY = 8;
/// Operation terminated by sqlite3.interrupt()
SQLITE_INTERRUPT = 9;
/// Some kind of disk I/O error occurred
SQLITE_IOERR = 10;
/// The database disk image is malformed
SQLITE_CORRUPT = 11;
/// (Internal Only) Table or record not found
SQLITE_NOTFOUND = 12;
/// Insertion failed because database is full
SQLITE_FULL = 13;
/// Unable to open the database file
SQLITE_CANTOPEN = 14;
/// (Internal Only) Database lock protocol error
SQLITE_PROTOCOL = 15;
/// Database is empty
SQLITE_EMPTY = 16;
/// The database schema changed, and unable to be recompiled
SQLITE_SCHEMA = 17;
/// Too much data for one row of a table
SQLITE_TOOBIG = 18;
/// Abort due to contraint violation
SQLITE_CONSTRAINT = 19;
/// Data type mismatch
SQLITE_MISMATCH = 20;
/// Library used incorrectly
SQLITE_MISUSE = 21;
/// Uses OS features not supported on host
SQLITE_NOLFS = 22;
/// Authorization denied
SQLITE_AUTH = 23;
/// Auxiliary database format error
SQLITE_FORMAT = 24;
/// 2nd parameter to sqlite3.bind out of range
SQLITE_RANGE = 25;
/// File opened that is not a database file
SQLITE_NOTADB = 26;
// note: SQLITE_NOTICE=27 and SQLITE_WARNING=28 are never returned by the API
/// sqlite3.step() return code: another result row is ready
SQLITE_ROW = 100;
/// sqlite3.step() return code: has finished executing
SQLITE_DONE = 101;
/// possible error codes for sqlite_exec() and sqlite3.step()
// - as verified by sqlite3_check()
SQLITE_ERRORS = [SQLITE_ERROR .. SQLITE_ROW-1];
/// The sqlite3.load_extension() interface loads an extension into a single database connection.
// - The default behavior is for that extension to be automatically unloaded when the database
// connection closes.
// - However, if the extension entry point returns SQLITE_OK_LOAD_PERMANENTLY instead of
// SQLITE_OK, then the extension remains loaded into the process address space after the
// database connection closes.
// - In other words, the xDlClose methods of the sqlite3_vfs object is not called for the
// extension when the database connection closes.
// - The SQLITE_OK_LOAD_PERMANENTLY return code is useful to loadable extensions that
// register new VFSes, for example.
SQLITE_OK_LOAD_PERMANENTLY = 256;
/// The SQLITE_ERROR_MISSING_COLLSEQ result code means that an SQL statement could not be
// prepared because a collating sequence named in that SQL statement could not be located.
// - Sometimes when this error code is encountered, the sqlite3.prepare_v2() routine will
// convert the error into SQLITE_ERROR_RETRY and try again to prepare the SQL statement
// using a different query plan that does not require the use of the unknown collating sequence.
SQLITE_ERROR_MISSING_COLLSEQ = 257;
/// The SQLITE_BUSY_RECOVERY error code is an extended error code for SQLITE_BUSY that
// indicates that an operation could not continue because another process is busy recovering
// a WAL mode database file following a crash.
// - The SQLITE_BUSY_RECOVERY error code only occurs on WAL mode databases.
SQLITE_BUSY_RECOVERY = 261;
/// The SQLITE_LOCKED_SHAREDCACHE result code indicates that access to an SQLite data
// record is blocked by another database connection that is using the same record in
// shared cache mode.
// - When two or more database connections share the same cache and one of the connections
// is in the middle of modifying a record in that cache, then other connections are blocked
// from accessing that data while the modifications are on-going in order to prevent the
// readers from seeing a corrupt or partially completed change.
SQLITE_LOCKED_SHAREDCACHE = 262;
/// The SQLITE_READONLY_RECOVERY error code is an extended error code for SQLITE_READONLY.
// - The SQLITE_READONLY_RECOVERY error code indicates that a WAL mode database cannot be
// opened because the database file needs to be recovered and recovery requires write access
// but only read access is available.
SQLITE_READONLY_RECOVERY = 264;
/// The SQLITE_IOERR_READ error code is an extended error code for SQLITE_IOERR indicating
// an I/O error in the VFS layer while trying to read from a file on disk.
// - This error might result from a hardware malfunction or because a filesystem came
// unmounted while the file was open.
SQLITE_IOERR_READ = 266;
/// The SQLITE_CORRUPT_VTAB error code is an extended error code for SQLITE_CORRUPT used
// by virtual tables.
// - A virtual table might return SQLITE_CORRUPT_VTAB to indicate that content in the
// virtual table is corrupt.
SQLITE_CORRUPT_VTAB = 267;
/// The SQLITE_CONSTRAINT_CHECK error code is an extended error code for SQLITE_CONSTRAINT
// indicating that a CHECK constraint failed.
SQLITE_CONSTRAINT_CHECK = 275;
/// The SQLITE_NOTICE_RECOVER_WAL result code is passed to the callback of sqlite3.log()
// when a WAL mode database file is recovered.
SQLITE_NOTICE_RECOVER_WAL = 283;
/// The SQLITE_WARNING_AUTOINDEX result code is passed to the callback of sqlite3.log()
// whenever automatic indexing is used.
// - This can serve as a warning to application designers that the database might benefit
// from additional indexes.
SQLITE_WARNING_AUTOINDEX = 284;
/// The SQLITE_ERROR_RETRY is used internally to provoke sqlite3.prepare_v2()(or one of its
// sibling routines for creating prepared statements) to try again to prepare a statement
// that failed with an error on the previous attempt.
SQLITE_ERROR_RETRY = 513;
/// The SQLITE_ABORT_ROLLBACK error code is an extended error code for SQLITE_ABORT indicating
// that an SQL statement aborted because the transaction that was active when the SQL statement
// first started was rolled back.
// - Pending write operations always fail with this error when a rollback occurs.
// - A ROLLBACK will cause a pending read operation to fail only if the schema was changed within
// the transaction being rolled back.
SQLITE_ABORT_ROLLBACK = 516;
/// The SQLITE_BUSY_SNAPSHOT error code is an extended error code for SQLITE_BUSY that occurs
// on WAL mode databases when a database connection tries to promote a read transaction into
// a write transaction but finds that another database connection has already written to the
// database and thus invalidated prior reads.
// - The following scenario illustrates how an SQLITE_BUSY_SNAPSHOT error might arise:
// - Process A starts a read transaction on the database and does one or more SELECT statement.
// - Process A keeps the transaction open.
// - Process B updates the database, changing values previous read by process A.
// - Process A now tries to write to the database. But process A's view of the database content is
// now obsolete because process B has modified the database file after process A read from it.
// Hence process A gets an SQLITE_BUSY_SNAPSHOT error.
SQLITE_BUSY_SNAPSHOT = 517;
/// The SQLITE_LOCKED_VTAB result code is not used by the SQLite core, but it is available for
// use by extensions.
// - Virtual table implementations can return this result code to indicate that they cannot
// complete the current operation because of locks held by other threads or processes.
// - The R-Tree extension returns this result code when an attempt is made to update the R-Tree
// while another prepared statement is actively reading the R-Tree.
// - The update cannot proceed because any change to an R-Tree might involve reshuffling and
// rebalancing of nodes, which would disrupt read cursors, causing some rows to be repeated and
// other rows to be omitted.
SQLITE_LOCKED_VTAB = 518;
/// The SQLITE_READONLY_CANTLOCK error code is an extended error code for SQLITE_READONLY.
// - The SQLITE_READONLY_CANTLOCK error code indicates that SQLite is unable to obtain a read
// lock on a WAL mode database because the shared-memory file associated with that database
// is read-only.
SQLITE_READONLY_CANTLOCK = 520;
/// The SQLITE_IOERR_SHORT_READ error code is an extended error code for SQLITE_IOERR indicating
// that a read attempt in the VFS layer was unable to obtain as many bytes as was requested.
// - This might be due to a truncated file.
SQLITE_IOERR_SHORT_READ = 522;
/// The SQLITE_CORRUPT_SEQUENCE result code means that the schema of the sqlite_sequence table
//is corrupt.
// - The sqlite_sequence table is used to help implement the AUTOINCREMENT feature.
// - The sqlite_sequence table should have the following format:
// CREATE TABLE sqlite_sequence(name,seq);
// - If SQLite discovers that the sqlite_sequence table has any other format, it returns the
// SQLITE_CORRUPT_SEQUENCE error.
SQLITE_CORRUPT_SEQUENCE = 523;
/// The SQLITE_CANTOPEN_ISDIR error code is an extended error code for SQLITE_CANTOPEN indicating
// that a file open operation failed because the file is really a directory.
SQLITE_CANTOPEN_ISDIR = 526;
/// The SQLITE_CONSTRAINT_COMMITHOOK error code is an extended error code for SQLITE_CONSTRAINT
// indicating that a commit hook callback returned non-zero that thus caused the SQL statement
// to be rolled back.
SQLITE_CONSTRAINT_COMMITHOOK = 531;
/// The SQLITE_NOTICE_RECOVER_ROLLBACK result code is passed to the callback of sqlite3.log() when
// a hot journal is rolled back.
SQLITE_NOTICE_RECOVER_ROLLBACK = 539;
/// The SQLITE_ERROR_SNAPSHOT result code might be returned when attempting to start a read transaction
// on an historical version of the database by using the sqlite3.snapshot_open() interface.
// - If the historical snapshot is no longer available, then the read transaction will fail with the
// SQLITE_ERROR_SNAPSHOT.
SQLITE_ERROR_SNAPSHOT = 769;
/// The SQLITE_BUSY_TIMEOUT error code indicates that a blocking Posix advisory file lock request in
// the VFS layer failed due to a timeout.
// - Blocking Posix advisory locks are only available as a proprietary SQLite extension and even then
// are only supported if SQLite is compiled with the SQLITE_EANBLE_SETLK_TIMEOUT compile-time option.
SQLITE_BUSY_TIMEOUT = 773;
/// The SQLITE_READONLY_ROLLBACK error code is an extended error code for SQLITE_READONLY.
// The SQLITE_READONLY_ROLLBACK error code indicates that a database cannot be opened because it has
// a hot journal that needs to be rolled back but cannot because the database is readonly.
SQLITE_READONLY_ROLLBACK = 776;
/// The SQLITE_IOERR_WRITE error code is an extended error code for SQLITE_IOERR indicating an I/O
// error in the VFS layer while trying to write into a file on disk.
// - This error might result from a hardware malfunction or because a filesystem came unmounted while
// the file was open.
// - This error should not occur if the filesystem is full as there is a separate error code
// (SQLITE_FULL) for that purpose.
SQLITE_IOERR_WRITE = 778;
/// The SQLITE_CORRUPT_INDEX result code means that SQLite detected an entry is or was missing
// from an index.
// - This is a special case of the SQLITE_CORRUPT error code that suggests that the problem
// might be resolved by running the REINDEX command, assuming no other problems exist elsewhere
// in the database file.
SQLITE_CORRUPT_INDEX = 779;
/// The SQLITE_CANTOPEN_FULLPATH error code is an extended error code for SQLITE_CANTOPEN indicating
// that a file open operation failed because the operating system was unable to convert the filename
// into a full pathname.
SQLITE_CANTOPEN_FULLPATH = 782;
/// The SQLITE_CONSTRAINT_FOREIGNKEY error code is an extended error code for SQLITE_CONSTRAINT
// indicating that a foreign key constraint failed.
SQLITE_CONSTRAINT_FOREIGNKEY = 787;
/// The SQLITE_READONLY_DBMOVED error code is an extended error code for SQLITE_READONLY.
// - The SQLITE_READONLY_DBMOVED error code indicates that a database cannot be modified because the
// database file has been moved since it was opened, and so any attempt to modify the database might
// result in database corruption if the processes crashes because the rollback journal would not be
// correctly named.
SQLITE_READONLY_DBMOVED = 1032;
/// The SQLITE_IOERR_FSYNC error code is an extended error code for SQLITE_IOERR indicating an I/O error
// in the VFS layer while trying to flush previously written content out of OS and/or disk-control
// buffers and into persistent storage.
// - In other words, this code indicates a problem with the fsync() system call in unix or the
// FlushFileBuffers() system call in windows.
SQLITE_IOERR_FSYNC = 1034;
/// The SQLITE_CANTOPEN_CONVPATH error code is an extended error code for SQLITE_CANTOPEN used only by
// Cygwin VFS and indicating that the cygwin_conv_path() system call failed while trying to open a file.
// - See also: SQLITE_IOERR_CONVPATH
SQLITE_CANTOPEN_CONVPATH = 1038;
/// The SQLITE_CONSTRAINT_FUNCTION error code is not currently used by the SQLite core.
// - However, this error code is available for use by extension functions.
SQLITE_CONSTRAINT_FUNCTION = 1043;
/// The SQLITE_READONLY_CANTINIT result code originates in the xShmMap method of a VFS to indicate that
// the shared memory region used by WAL mode exists buts its content is unreliable and unusable by the
// current process since the current process does not have write permission on the shared memory region.
// - The shared memory region for WAL mode is normally a file with a "-wal" suffix that is mmapped into
// the process space.
// - If the current process does not have write permission on that file, then it cannot write into shared memory.
// - Higher level logic within SQLite will normally intercept the error code and create a temporary in-memory
// shared memory region so that the current process can at least read the content of the database.
// - This result code should not reach the application interface layer.
SQLITE_READONLY_CANTINIT = 1288;
/// The SQLITE_IOERR_DIR_FSYNC error code is an extended error code for SQLITE_IOERR indicating an I/O error
// in the VFS layer while trying to invoke fsync() on a directory.
// - The unix VFS attempts to fsync() directories after creating or deleting certain files to ensure that
// those files will still appear in the filesystem following a power loss or system crash.
// - This error code indicates a problem attempting to perform that fsync().
SQLITE_IOERR_DIR_FSYNC = 1290;
/// The SQLITE_CANTOPEN_DIRTYWAL result code is not used at this time.
SQLITE_CANTOPEN_DIRTYWAL = 1294;
/// The SQLITE_CONSTRAINT_NOTNULL error code is an extended error code for
// SQLITE_CONSTRAINT indicating that a NOT NULL constraint failed.
SQLITE_CONSTRAINT_NOTNULL = 1299;
/// The SQLITE_READONLY_DIRECTORY result code indicates that the database is read-only because process does
// not have permission to create a journal file in the same directory as the database and the creation of a
// journal file is a prerequisite for writing.
SQLITE_READONLY_DIRECTORY = 1544;
/// The SQLITE_IOERR_TRUNCATE error code is an extended error code for SQLITE_IOERR indicating an I/O error
// in the VFS layer while trying to truncate a file to a smaller size.
SQLITE_IOERR_TRUNCATE = 1546;
/// The SQLITE_CANTOPEN_SYMLINK result code is returned by the sqlite3.open() interface and its siblings when
// the SQLITE_OPEN_NOFOLLOW flag is used and the database file is a symbolic link.
SQLITE_CANTOPEN_SYMLINK = 1550;
/// The SQLITE_CONSTRAINT_PRIMARYKEY error code is an extended error code for SQLITE_CONSTRAINT indicating
// that a PRIMARY KEY constraint failed.
SQLITE_CONSTRAINT_PRIMARYKEY = 1555;
/// The SQLITE_IOERR_FSTAT error code is an extended error code for SQLITE_IOERR indicating an I/O error
// in the VFS layer while trying to invoke fstat() (or the equivalent) on a file in order to determine
// information such as the file size or access permissions.
SQLITE_IOERR_FSTAT = 1802;
/// The SQLITE_CONSTRAINT_TRIGGER error code is an extended error code for SQLITE_CONSTRAINT indicating
// that a RAISE function within a trigger fired, causing the SQL statement to abort.
SQLITE_CONSTRAINT_TRIGGER = 1811;
/// The SQLITE_IOERR_UNLOCK error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within xUnlock method on the sqlite3_io_methods object.
SQLITE_IOERR_UNLOCK = 2058;
/// The SQLITE_CONSTRAINT_UNIQUE error code is an extended error code for SQLITE_CONSTRAINT indicating
// that a UNIQUE constraint failed.
SQLITE_CONSTRAINT_UNIQUE = 2067;
/// The SQLITE_IOERR_UNLOCK error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within xLock method on the sqlite3_io_methods object while trying to obtain a read lock.
SQLITE_IOERR_RDLOCK = 2314;
/// The SQLITE_CONSTRAINT_VTAB error code is not currently used by the SQLite core. However, this error
// code is available for use by application-defined virtual tables.
SQLITE_CONSTRAINT_VTAB = 2323;
/// The SQLITE_IOERR_UNLOCK error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within xDelete method on the sqlite3_vfs object.
SQLITE_IOERR_DELETE = 2570;
/// The SQLITE_CONSTRAINT_ROWID error code is an extended error code for SQLITE_CONSTRAINT indicating
// that a rowid is not unique.
SQLITE_CONSTRAINT_ROWID = 2579;
/// The SQLITE_CONSTRAINT_PINNED error code is an extended error code for SQLITE_CONSTRAINT indicating
// that an UPDATE trigger attempted do delete the row that was being updated in the middle of the update.
SQLITE_CONSTRAINT_PINNED = 2835;
/// The SQLITE_IOERR_NOMEM error code is sometimes returned by the VFS layer to indicate that an operation
// could not be completed due to the inability to allocate sufficient memory.
// This error code is normally converted into SQLITE_NOMEM by the higher layers of SQLite before being
// returned to the application.
SQLITE_IOERR_NOMEM = 3082;
/// The SQLITE_IOERR_ACCESS error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xAccess method on the sqlite3_vfs object.
SQLITE_IOERR_ACCESS = 3338;
/// The SQLITE_IOERR_CHECKRESERVEDLOCK error code is an extended error code for SQLITE_IOERR indicating
// an I/O error within the xCheckReservedLock method on the sqlite3_io_methods object.
SQLITE_IOERR_CHECKRESERVEDLOCK = 3594;
/// The SQLITE_IOERR_LOCK error code is an extended error code for SQLITE_IOERR indicating an I/O error
// in the advisory file locking logic.
// - Usually an SQLITE_IOERR_LOCK error indicates a problem obtaining a PENDING lock.
// - However it can also indicate miscellaneous locking errors on some of the specialized VFSes used on Macs.
SQLITE_IOERR_LOCK = 3850;
/// The SQLITE_IOERR_ACCESS error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xClose method on the sqlite3_io_methods object.
SQLITE_IOERR_DIR_CLOSE = 4362;
/// The SQLITE_IOERR_SHMOPEN error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xShmMap method on the sqlite3_io_methods object while trying to open a new shared memory segment.
SQLITE_IOERR_SHMOPEN = 4618;
/// The SQLITE_IOERR_SHMSIZE error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xShmMap method on the sqlite3_io_methods object while trying to enlarge a "shm" file as part
// of WAL mode transaction processing. This error may indicate that the underlying filesystem volume is
// out of space.
SQLITE_IOERR_SHMSIZE = 4874;
/// The SQLITE_IOERR_SHMMAP error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xShmMap method on the sqlite3_io_methods object while trying to map a shared memory segment
// into the process address space.
SQLITE_IOERR_SHMMAP = 5386;
/// The SQLITE_IOERR_SEEK error code is an extended error code for SQLITE_IOERR indicating an I/O error
// within the xRead or xWrite methods on the sqlite3_io_methods object while trying to seek a file descriptor
// to the beginning point of the file where the read or write is to occur.
SQLITE_IOERR_SEEK = 5642;
/// The SQLITE_IOERR_DELETE_NOENT error code is an extended error code for SQLITE_IOERR indicating that the
// xDelete method on the sqlite3_vfs object failed because the file being deleted does not exist.
SQLITE_IOERR_DELETE_NOENT = 5898;
/// The SQLITE_IOERR_MMAP error code is an extended error code for SQLITE_IOERR indicating an I/O error within
// the xFetch or xUnfetch methods on the sqlite3_io_methods object while trying to map or unmap part of the
// database file into the process address space.
SQLITE_IOERR_MMAP = 6154;
/// The SQLITE_IOERR_GETTEMPPATH error code is an extended error code for SQLITE_IOERR indicating that the VFS
// is unable to determine a suitable directory in which to place temporary files.
SQLITE_IOERR_GETTEMPPATH = 6410;
/// The SQLITE_IOERR_CONVPATH error code is an extended error code for SQLITE_IOERR used only by Cygwin VFS
// and indicating that the cygwin_conv_path() system call failed.
// - See also: SQLITE_CANTOPEN_CONVPATH
SQLITE_IOERR_CONVPATH = 6666;
/// The SQLITE_IOERR_VNODE error code is a code reserved for use by extensions.
SQLITE_IOERR_VNODE = 6922;
/// The SQLITE_IOERR_AUTH error code is a code reserved for use by extensions.
SQLITE_IOERR_AUTH = 7178;
/// The SQLITE_IOERR_BEGIN_ATOMIC error code indicates that the underlying operating system reported and error
// on the SQLITE_FCNTL_BEGIN_ATOMIC_WRITE file-control.
// - This only comes up when SQLITE_ENABLE_ATOMIC_WRITE is enabled and the database is hosted on a filesystem
// that supports atomic writes.
SQLITE_IOERR_BEGIN_ATOMIC = 7434;
/// The SQLITE_IOERR_COMMIT_ATOMIC error code indicates that the underlying operating system reported and error
// on the SQLITE_FCNTL_COMMIT_ATOMIC_WRITE file-control.
// - This only comes up when SQLITE_ENABLE_ATOMIC_WRITE is enabled and the database is hosted on a filesystem
// that supports atomic writes.
SQLITE_IOERR_COMMIT_ATOMIC = 7690;
/// The SQLITE_IOERR_ROLLBACK_ATOMIC error code indicates that the underlying operating system reported and error
// on the SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE file-control. This only comes up when SQLITE_ENABLE_ATOMIC_WRITE is
// enabled and the database is hosted on a filesystem that supports atomic writes.
SQLITE_IOERR_ROLLBACK_ATOMIC = 7946;
/// The SQLITE_IOERR_DATA error code is an extended error code for SQLITE_IOERR used only by checksum VFS shim to
// indicate that the checksum on a page of the database file is incorrect.
SQLITE_IOERR_DATA = 8202;
/// The SQLITE_IOERR_CORRUPTFS error code is an extended error code for
// SQLITE_IOERR used only by a VFS to indicate that a seek or read failure
// was due to the request not falling within the file's boundary rather than
// an ordinary device failure. This often indicates a corrupt filesystem.
SQLITE_IOERR_CORRUPTFS = 8458;
/// The database is opened in read-only mode
// - if the database does not already exist, an error is returned
// - Ok for sqlite3.open_v2()
SQLITE_OPEN_READONLY = $00000001;
/// The database is opened for reading and writing if possible, or reading
// only if the file is write protected by the operating system
// - In either case the database must already exist, otherwise an error is
// returned
// - Ok for sqlite3.open_v2()
SQLITE_OPEN_READWRITE = $00000002;
/// In conjunction with SQLITE_OPEN_READWRITE, optionally create the database
// file if it does not exist
// - The database is opened for reading and writing if possible, or reading
// only if the file is write protected by the operating system
// - In either case the database must already exist, otherwise an error is returned
SQLITE_OPEN_CREATE = $00000004;
/// URI filename interpretation is enabled if the SQLITE_OPEN_URI flag is set
// in the fourth argument to sqlite3.open_v2(), or if it has been enabled
// globally using the SQLITE_CONFIG_URI option with the sqlite3.config() method
// or by the SQLITE_USE_URI compile-time option.
// - As of SQLite version 3.7.7, URI filename interpretation is turned off by
// default, but future releases of SQLite might enable URI filename
// interpretation by default
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_URI = $00000040; // Ok for sqlite3_open_v2()
/// If the SQLITE_OPEN_NOMUTEX flag is set, then the database will remain in
// memory
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_MEMORY = $00000080; // Ok for sqlite3_open_v2()
/// If the SQLITE_OPEN_NOMUTEX flag is set, then the database connection opens
// in the multi-thread threading mode as long as the single-thread mode has
// not been set at compile-time or start-time
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_NOMUTEX = $00008000; // Ok for sqlite3_open_v2()
/// If the SQLITE_OPEN_FULLMUTEX flag is set then the database connection opens
// in the serialized threading mode unless single-thread was previously selected
// at compile-time or start-time
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_FULLMUTEX = $00010000; // Ok for sqlite3_open_v2()
/// The SQLITE_OPEN_SHAREDCACHE flag causes the database connection to be
// eligible to use shared cache mode, regardless of whether or not shared
// cache is enabled using sqlite3.enable_shared_cache()
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_SHAREDCACHE = $00020000; // Ok for sqlite3_open_v2()
/// The SQLITE_OPEN_PRIVATECACHE flag causes the database connection to not
// participate in shared cache mode even if it is enabled
// - Ok for sqlite3.open_v2(), in conjuction with SQLITE_OPEN_READONLY,
// SQLITE_OPEN_READWRITE, (SQLITE_OPEN_READWRITE or SQLITE_OPEN_CREATE)
SQLITE_OPEN_PRIVATECACHE = $00040000;
{
SQLITE_OPEN_DELETEONCLOSE = $00000008; // VFS only
SQLITE_OPEN_EXCLUSIVE = $00000010; // VFS only
SQLITE_OPEN_AUTOPROXY = $00000020; // VFS only
SQLITE_OPEN_MAIN_DB = $00000100; // VFS only
SQLITE_OPEN_TEMP_DB = $00000200; // VFS only
SQLITE_OPEN_TRANSIENT_DB = $00000400; // VFS only
SQLITE_OPEN_MAIN_JOURNAL = $00000800; // VFS only
SQLITE_OPEN_TEMP_JOURNAL = $00001000; // VFS only
SQLITE_OPEN_SUBJOURNAL = $00002000; // VFS only
SQLITE_OPEN_MASTER_JOURNAL = $00004000; // VFS only
SQLITE_OPEN_WAL = $00080000; // VFS only
}
/// DestroyPtr set to SQLITE_STATIC if data is constant and will never change
// - SQLite assumes that the text or BLOB result is in constant space and
// does not copy the content of the parameter nor call a destructor on the
// content when it has finished using that result
SQLITE_STATIC = pointer(0);
/// DestroyPtr set to SQLITE_TRANSIENT for SQLite3 to make a private copy of
// the data into space obtained from from sqlite3.malloc() before it returns
// - this is the default behavior in our framework
// - note that we discovered that under Win64, sqlite3.result_text() expects
// SQLITE_TRANSIENT_VIRTUALTABLE=pointer(integer(-1)) and not pointer(-1)
SQLITE_TRANSIENT = pointer(-1);
/// DestroyPtr set to SQLITE_TRANSIENT_VIRTUALTABLE for setting results to
// SQlite3 virtual tables columns
// - due to a bug of the SQlite3 engine under Win64
SQLITE_TRANSIENT_VIRTUALTABLE = pointer(integer(-1));
/// pseudo database file name used to create an in-memory database
// - an SQLite database is normally stored in a single ordinary disk file -
// however, in certain circumstances, the database might be stored in memory,
// if you pass SQLITE_MEMORY_DATABASE_NAME to TSqlDatabase.Create() instead of
// a real disk file name
// - this instance will cease to exist as soon as the database connection
// is closed, i.e. when calling TSqlDatabase.Free
// - every ':memory:' database is distinct from every other - so, creating two
// TSqlDatabase instances each with the filename SQLITE_MEMORY_DATABASE_NAME
// will create two independent in-memory databases
SQLITE_MEMORY_DATABASE_NAME = ':memory:';
/// This option sets the threading mode to Single-thread
// - In other words, it disables all mutexing and puts SQLite into a mode where it
// can only be used by a single thread. If SQLite is compiled with the
// SQLITE_THREADSAFE=0 compile-time option then it is not possible to change the
// threading mode from its default value of Single-thread and so sqlite3.config()
// will return SQLITE_ERROR if called with the SQLITE_CONFIG_SINGLETHREAD
// configuration option.
// - There are no arguments to this option.
SQLITE_CONFIG_SINGLETHREAD = 1;
///This option sets the threading mode to Multi-thread
// - In other words, it disables mutexing on database connection and prepared
// statement objects.
// - The application is responsible for serializing access to database connections
// and prepared statements.
// - But other mutexes are enabled so that SQLite will be safe to use in a
// multi-threaded environment as long as no two threads attempt to use the same
// database connection at the same time.
// - If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then
// it is not possible to set the Multi-thread threading mode and sqlite3.config()
// will return SQLITE_ERROR if called with the SQLITE_CONFIG_MULTITHREAD
// configuration option.
// - There are no arguments to this option.
SQLITE_CONFIG_MULTITHREAD = 2;
/// This option sets the threading mode to Serialized
// - In other words, this option enables all mutexes including the recursive mutexes
// on database connection and prepared statement objects.
// - In this mode (which is the default when SQLite is compiled with SQLITE_THREADSAFE=1)
// the SQLite library will itself serialize access to database connections and prepared
// statements so that the application is free to use the same database connection
// or the same prepared statement in different threads at the same time.
// - If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then
// it is not possible to set the Serialized threading mode and sqlite3.config()
// will return SQLITE_ERROR if called with the SQLITE_CONFIG_SERIALIZED
// configuration option.
// - There are no arguments to this option.
SQLITE_CONFIG_SERIALIZED = 3;
/// The argument specifies alternative low-level memory allocation routines to
// be used in place of the memory allocation routines built into SQLite
// - SQLite makes its own private copy of the content of the TSqlite3MemMethods
// structure before the sqlite3.config() call returns.
// - This option takes a single argument which is a pointer to an instance of
// the TSqlite3MemMethods structure.
SQLITE_CONFIG_MALLOC = 4;
/// This option takes a single argument which is a pointer to an instance of
// the TSqlite3MemMethods structure
// - The TSqlite3MemMethods structure is filled with the currently defined memory
// allocation routines.
// - This option can be used to overload the default memory allocation routines
// with a wrapper that simulations memory allocation failure or tracks memory
// usage, for example.
SQLITE_CONFIG_GETMALLOC = 5;
/// This option is no longer used
SQLITE_CONFIG_SCRATCH = 6;
/// This option specifies a static memory buffer that SQLite can use for the database
// page cache with the default page cache implementation
// - This configuration should not be used if an application-define page cache
// implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
// - There are three arguments to this option: A pointer to 8-byte aligned memory,
// the size of each page buffer (sz), and the number of pages (N).
// - The sz argument should be the size of the largest database page (a power of
// two between 512 and 32768) plus a little extra for each page header.
// - The page header size is 20 to 40 bytes depending on the host architecture.
// - It is harmless, apart from the wasted memory, to make sz a little too large.
// - The first argument should point to an allocation of at least sz*N bytes of memory.
// - SQLite will use the memory provided by the first argument to satisfy its memory
// needs for the first N pages that it adds to cache. If additional page cache memory
// is needed beyond what is provided by this option, then SQLite goes to sqlite3.malloc()
// for the additional storage space.
// - The pointer in the first argument must be aligned to an 8-byte boundary or subsequent
// behavior of SQLite will be undefined.
SQLITE_CONFIG_PAGECACHE = 7;
/// This option specifies a static memory buffer that SQLite will use for all of
// its dynamic memory allocation needs beyond those provided for by
// SQLITE_CONFIG_SCRATCH and SQLITE_CONFIG_PAGECACHE
// - There are three arguments: An 8-byte aligned pointer to the memory, the number
// of bytes in the memory buffer, and the minimum allocation size.
// - If the first pointer (the memory pointer) is nil, then SQLite reverts
// to using its default memory allocator (the system malloc() implementation),
// undoing any prior invocation of SQLITE_CONFIG_MALLOC.
// - If the memory pointer is not nil and either SQLITE_ENABLE_MEMSYS3 or
// SQLITE_ENABLE_MEMSYS5 are defined, then the alternative memory allocator is
// engaged to handle all of SQLites memory allocation needs.
// - The first pointer (the memory pointer) must be aligned to an 8-byte boundary
// or subsequent behavior of SQLite will be undefined.
// - The minimum allocation size is capped at 2**12. Reasonable values for the
// minimum allocation size are 2**5 through 2**8.
SQLITE_CONFIG_HEAP = 8;
/// This option takes single argument of type int, interpreted as a boolean,
// which enables or disables the collection of memory allocation statistics
// - When memory allocation statistics are disabled, the following SQLite
// interfaces become non-operational:
// - sqlite3.memory_used()
// - sqlite3.memory_highwater()
// - sqlite3.soft_heap_limit64()
// - sqlite3.status()
// - Memory allocation statistics are enabled by default unless SQLite is compiled
// with SQLITE_DEFAULT_MEMSTATUS=0 in which case memory allocation statistics
// are disabled by default - which is the case our static in sqlite3mc.c
SQLITE_CONFIG_MEMSTATUS = 9;
/// This option takes a single argument which is a pointer to an instance of the
// sqlite3_mutex_methods structure
// - The argument specifies alternative low-level mutex routines to be used in
// place the mutex routines built into SQLite. SQLite makes a copy of the content
// of the sqlite3_mutex_methods structure before the call to sqlite3.config() returns.
// - If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then
// the entire mutexing subsystem is omitted from the build and hence calls to
// sqlite3.config() with the SQLITE_CONFIG_MUTEX configuration option will
// return SQLITE_ERROR.
SQLITE_CONFIG_MUTEX = 10;
/// This option takes a single argument which is a pointer to an instance of
// the sqlite3_mutex_methods structure
// - The sqlite3_mutex_methods structure is filled with the currently defined
// mutex routines.
// - This option can be used to overload the default mutex allocation routines
// with a wrapper used to track mutex usage for performance profiling or testing,
// for example.
// - If SQLite is compiled with the SQLITE_THREADSAFE=0 compile-time option then
// the entire mutexing subsystem is omitted from the build and hence calls to
// sqlite3.config() with the SQLITE_CONFIG_GETMUTEX configuration option will
// return SQLITE_ERROR.
SQLITE_CONFIG_GETMUTEX = 11;
/// This option takes two arguments that determine the default memory allocation
// for the lookaside memory allocator on each database connection
// - The first argument is the size of each lookaside buffer slot and the second
// is the number of slots allocated to each database connection.
// - This option sets the default lookaside size.
// - The SQLITE_DBCONFIG_LOOKASIDE verb to sqlite3.db_config() can be used to
// change the lookaside configuration on individual connections.
SQLITE_CONFIG_LOOKASIDE = 13;
/// These options are obsolete and should not be used by new code
// - They are retained for backwards compatibility but are now no-ops.
SQLITE_CONFIG_PCACHE = 14;
/// These options are obsolete and should not be used by new code
// - They are retained for backwards compatibility but are now no-ops.
SQLITE_CONFIG_GETPCACHE = 15;
/// This option takes two arguments: a pointer to a function with a call
// signature of void(*)(void*,int,const char*), and a pointer to void
// - If the function pointer is not nil, it is invoked by sqlite3.log()
// to process each logging event.
// - If the function pointer is nil, the sqlite3.log() interface becomes a no-op.
// - The void pointer that is the second argument to SQLITE_CONFIG_LOG is passed
// through as the first parameter to the application-defined logger function whenever
// that function is invoked.
// - The second parameter to the logger function is a copy of the first parameter
// to the corresponding sqlite3.log() call and is intended to be a result code or
// an extended result code.
// - The third parameter passed to the logger is log message after formatting via
// sqlite3.snprintf().
// - The SQLite logging interface is not reentrant; the logger function supplied
// by the application must not invoke any SQLite interface.
// - In a multi-threaded application, the application-defined logger function must
// be threadsafe.
SQLITE_CONFIG_LOG = 16;
/// This option takes a single argument of type int
// - If non-zero, then URI handling is globally enabled.
// - If the parameter is zero, then URI handling is globally disabled.
// - If URI handling is globally enabled, all filenames passed to sqlite3_open(),
// sqlite3.open_v2(), sqlite3.open16() or specified as part of ATTACH commands are
// interpreted as URIs, regardless of whether or not the SQLITE_OPEN_URI flag is
// set when the database connection is opened.
// - If it is globally disabled, filenames are only interpreted as URIs if the
// SQLITE_OPEN_URI flag is set when the database connection is opened.
// - By default, URI handling is globally disabled.
// - The default value may be changed by compiling with the SQLITE_USE_URI
// symbol defined.
SQLITE_CONFIG_URI = 17;
/// This option takes a single argument which is a pointer to an
// sqlite3_pcache_methods2 object
// - This object specifies the interface to a custom page cache implementation.
// - SQLite makes a copy of the object and uses it for page cache memory allocations.
SQLITE_CONFIG_PCACHE2 = 18;
/// This option takes a single argument which is a pointer to an
// sqlite3_pcache_methods2 object
// - SQLite copies of the current page cache implementation into that object.
SQLITE_CONFIG_GETPCACHE2 = 19;
/// This option takes a single integer argument which is interpreted
// as a boolean in order to enable or disable the use of covering indices
// for full table scans in the query optimizer.
// - The default setting is determined by the SQLITE_ALLOW_COVERING_INDEX_SCAN
// compile-time option, or is "on" if that compile-time option is omitted.
// - The ability to disable the use of covering indices for full table scans
// is because some incorrectly coded legacy applications might malfunction
// when the optimization is enabled. Providing the ability to disable the
// optimization allows the older, buggy application code to work without
// change even with newer versions of SQLite.
SQLITE_CONFIG_COVERING_INDEX_SCAN = 20;
/// This option is used to configure the SQLite global error log.
// - The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a function
// with a call signature of void(*)(void*,int,const char*), and a pointer
// to void.
// - If the function pointer is not nil, it is invoked by sqlite3_log()
// to process each logging event. If the function pointer is nil, the
// sqlite3_log() interface becomes a no-op.
// - The void pointer that is the second argument to SQLITE_CONFIG_LOG is
// passed through as the first parameter to the application-defined logger
// function whenever that function is invoked. The second parameter to the
// logger function is a copy of the first parameter to the corresponding
// sqlite3_log() call and is intended to be a result code or an extended
// result code. The third parameter passed to the logger is log message
// after formatting via sqlite3_snprintf().
// - The SQLite logging interface is not reentrant; the logger function
// supplied by the application must not invoke any SQLite interface.
// - In a multi-threaded application, the application-defined logger function
// must be threadsafe.
SQLITE_CONFIG_SQLLOG = 21;
/// This option takes two 64-bit integer (sqlite3_int64) values that are the
// default mmap size limit (the default setting for PRAGMA mmap_size) and
// the maximum allowed mmap size limit.
// - The default setting can be overridden by each database connection using
// either the PRAGMA mmap_size command, or by using the SQLITE_FCNTL_MMAP_SIZE
// file control. The maximum allowed mmap size will be silently truncated if
// necessary so that it does not exceed the compile-time maximum mmap size
// set by the SQLITE_MAX_MMAP_SIZE compile-time option.
// - If either argument to this option is negative, then that argument is
// changed to its compile-time default.
SQLITE_CONFIG_MMAP_SIZE = 22;
/// Available if SQLite is compiled for Windows with the SQLITE_WIN32_MALLOC.
SQLITE_CONFIG_WIN32_HEAPSIZE = 23;
/// This option takes a single parameter which is a pointer to an integer
// and writes into that integer the number of extra bytes per page required
// for each page in SQLITE_CONFIG_PAGECACHE.
// - The amount of extra space required can change depending on the compiler,
// target platform, and SQLite version.
SQLITE_CONFIG_PCACHE_HDRSZ = 24;
/// This option takes a single parameter which is an unsigned integer and
// sets the "Minimum PMA Size" for the multithreaded sorter to that integer.
// - The default minimum PMA Size is set by the SQLITE_SORTER_PMASZ
// compile-time option. New threads are launched to help with sort operations
// when multithreaded sorting is enabled (using the PRAGMA threads command)
// and the amount of content to be sorted exceeds the page size times the
// minimum of the PRAGMA cache_size setting and this value.
SQLITE_CONFIG_PMASZ = 25;
/// This option takes a single parameter which becomes the statement journal
// spill-to-disk threshold.
// - Statement journals are held in memory until their size (in bytes) exceeds
// this threshold, at which point they are written to disk. Or if the
// threshold is -1, statement journals are always held exclusively in memory.
// - Since many statement journals never become large, setting the spill
// threshold to a value such as 64KiB can greatly reduce the amount of
// I/O required to support statement rollback.
// - The default value for this setting is controlled by the
// SQLITE_STMTJRNL_SPILL compile-time option.
SQLITE_CONFIG_STMTJRNL_SPILL = 26;
/// This option takes single argument of type int, interpreted as a boolean,
// which if true provides a hint to SQLite that it should avoid large memory
// allocations if possible.
// - SQLite will run faster if it is free to make large memory allocations,
// but some application might prefer to run slower in exchange for guarantees
// about memory fragmentation that are possible if large allocations are avoided.
// - This hint is normally off.
SQLITE_CONFIG_SMALL_MALLOC = 27;
/// This option accepts a single parameter of type (int) - the new value of
// the sorter-reference size threshold.
// - Usually, when SQLite uses an external sort to order records according to
// an ORDER BY clause, all fields required by the caller are present in the
// sorted records. However, if SQLite determines based on the declared type
// of a table column that its values are likely to be very large - larger than
// the configured sorter-reference size threshold - then a reference is stored
// in each sorted record and the required column values loaded from the
// database as records are returned in sorted order.
// - The default value for this option is to never use this optimization.
// - Specifying a negative value for this option restores the default behaviour.
// - This option is only available if SQLite is compiled with the
// SQLITE_ENABLE_SORTER_REFERENCES compile-time option.
SQLITE_CONFIG_SORTERREF_SIZE = 28;
/// This option accepts a single parameter sqlite3_int64 parameter which is
// the default maximum size for an in-memory database created
// using sqlite3_deserialize().
// - This default maximum size can be adjusted up or down for individual
// databases using the SQLITE_FCNTL_SIZE_LIMIT file-control.
// - If this configuration setting is never used, then the default maximum is
// determined by the SQLITE_MEMDB_DEFAULT_MAXSIZE compile-time option.
// - If that compile-time option is not set, then the default maximum is
// 1073741824.
SQLITE_CONFIG_MEMDB_MAXSIZE = 29;
/// This option takes three additional arguments that determine the lookaside
// memory allocator configuration for the database connection.
// - The first argument (the third parameter to sqlite3_db_config() is a
// pointer to a memory buffer to use for lookaside memory.
// - The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb may be nil
// in which case SQLite will allocate the lookaside buffer itself using
// sqlite3_malloc().
// - The second argument is the size of each lookaside buffer slot.
// - The third argument is the number of slots.
// - The size of the buffer in the first argument must be greater than or
// equal to the product of the second and third arguments.
// - The buffer must be aligned to an 8-byte boundary.
// - If the second argument to SQLITE_DBCONFIG_LOOKASIDE is not a multiple
// of 8, it is internally rounded down to the next smaller multiple of 8.
// - The lookaside memory configuration for a database connection can only be
// changed when that connection is not currently using lookaside memory,
// or in other words when the "current value" returned by
// sqlite3_db_status(D,SQLITE_CONFIG_LOOKASIDE,...) is zero. Any attempt to
// change the lookaside memory configuration when lookaside memory is in use
// leaves the configuration unchanged and returns SQLITE_BUSY.
SQLITE_DBCONFIG_LOOKASIDE = 1001;
/// This option is used to enable or disable the enforcement of foreign key
// constraints.
// - There should be two additional arguments.
// - The first argument is an integer which is 0 to disable FK enforcement,
// positive to enable FK enforcement or negative to leave FK enforcement unchanged.
// - The second parameter is a pointer to an integer into which is written
// 0 or 1 to indicate whether FK enforcement is off or on following this call.
// - The second parameter may be a nil pointer, in which case the FK
// enforcement setting is not reported back.
SQLITE_DBCONFIG_ENABLE_FKEY = 1002;
/// This option is used to enable or disable triggers.
// - There should be two additional arguments.
// - The first argument is an integer which is 0 to disable triggers,
// positive to enable triggers or negative to leave the setting unchanged.
// - The second parameter is a pointer to an integer into which is written
// 0 or 1 to indicate whether triggers are disabled or enabled following
// this call.
// - The second parameter may be a nil pointer, in which case the trigger
// setting is not reported back.
// - Originally this option disabled all triggers. However, since SQLite
// version 3.35.0, TEMP triggers are still allowed even if this option is off.
// So, in other words, this option now only disables triggers in the main
// database schema or in the schemas of ATTACH-ed databases.
SQLITE_DBCONFIG_ENABLE_TRIGGER = 1003;
/// This option is used to enable or disable the fts3_tokenizer() function
// which is part of the FTS3 full-text search engine extension.
// - There should be two additional arguments.
// - The first argument is an integer which is 0 to disable fts3_tokenizer()
// or positive to enable fts3_tokenizer() or negative to leave the setting
// unchanged.
// - The second parameter is a pointer to an integer into which is
// written 0 or 1 to indicate whether fts3_tokenizer is disabled or enabled
// following this call. The second parameter may be a nil pointer, in which
// case the new setting is not reported back.
SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER = 1004;
/// This option is used to enable or disable the sqlite3_load_extension()
// interface independently of the load_extension() SQL function.
// - The sqlite3_enable_load_extension() API enables or disables both the
// C-API sqlite3_load_extension() and the SQL function load_extension().
// - There should be two additional arguments.
// - When the first argument to this interface is 1, then only the C-API
// is enabled and the SQL function remains disabled.
// - If the first argument to this interface is 0, then both the C-API
// and the SQL function are disabled.
// - If the first argument is -1, then no changes are made to state of either
// the C-API or the SQL function.
// - The second parameter is a pointer to an integer into which is written
// 0 or 1 to indicate whether sqlite3_load_extension() interface is disabled
// or enabled following this call.
// - The second parameter may be a nil pointer, in which case the new
// setting is not reported back.
SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION = 1005;
/// Calls of the form sqlite3.vtab_config(db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X)
// are supported, where X is an integer.
// - If X is zero, then the virtual table whose xCreate or xConnect method invoked
// sqlite3.vtab_config() does not support constraints.
// - In this configuration (which is the default) if a call to the xUpdate method
// returns SQLITE_CONSTRAINT, then the entire statement is rolled back as if OR ABORT
// had been specified as part of the users SQL statement, regardless of the actual
// ON CONFLICT mode specified.
// - If X is non-zero, then the virtual table implementation guarantees that if
// xUpdate returns SQLITE_CONSTRAINT, it will do so before any modifications to
// internal or persistent data structures have been made.
// - If the ON CONFLICT mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite is able
// to roll back a statement or database transaction, and abandon or continue processing
// the current SQL statement as appropriate.
// - If the ON CONFLICT mode is REPLACE and the xUpdate method returns SQLITE_CONSTRAINT,
// SQLite handles this as if the ON CONFLICT mode had been ABORT.
// - Virtual table implementations that are required to handle OR REPLACE must do so within
// the xUpdate method.
// - If a call to the sqlite3_vtab_on_conflict() function indicates that the current
// ON CONFLICT policy is REPLACE, the virtual table implementation should silently
// replace the appropriate rows within the xUpdate callback and return SQLITE_OK.
// Or, if this is not possible, it may return SQLITE_CONSTRAINT, in which case SQLite falls
// back to OR ABORT constraint handling.
SQLITE_VTAB_CONSTRAINT_SUPPORT = 1;
/// Calls of the form sqlite3_vtab_config(db,SQLITE_VTAB_INNOCUOUS) from within the
// the xConnect or xCreate methods of a virtual table implmentation identify that
// virtual table as being safe to use from within triggers and views.
// - Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the virtual table can do
// no serious harm even if it is controlled by a malicious hacker.
// - Developers should avoid setting the SQLITE_VTAB_INNOCUOUS flag unless absolutely necessary.
SQLITE_VTAB_INNOCUOUS = 2;
/// Calls of the form sqlite3.vtab_config(db,SQLITE_VTAB_DIRECTONLY) from within the
// the xConnect or xCreate methods of a virtual table implmentation prohibits that
// virtual table from being used from within triggers and views.