amalgalite 1.1.2-x86-mswin32 → 1.3.0-x86-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.md +49 -0
  3. data/{HISTORY.rdoc → HISTORY.md} +96 -73
  4. data/LICENSE +2 -2
  5. data/Manifest.txt +104 -0
  6. data/README.md +73 -0
  7. data/Rakefile +25 -0
  8. data/TODO.md +50 -0
  9. data/ext/amalgalite/{amalgalite3.c → c/amalgalite.c} +12 -12
  10. data/ext/amalgalite/{amalgalite3.h → c/amalgalite.h} +5 -5
  11. data/ext/amalgalite/{amalgalite3_blob.c → c/amalgalite_blob.c} +2 -2
  12. data/ext/amalgalite/{amalgalite3_constants.c → c/amalgalite_constants.c} +2 -2
  13. data/ext/amalgalite/{amalgalite3_database.c → c/amalgalite_database.c} +49 -21
  14. data/ext/amalgalite/{amalgalite3_requires_bootstrap.c → c/amalgalite_requires_bootstrap.c} +131 -58
  15. data/ext/amalgalite/{amalgalite3_statement.c → c/amalgalite_statement.c} +2 -2
  16. data/ext/amalgalite/{extconf.rb → c/extconf.rb} +4 -4
  17. data/ext/amalgalite/{gen_constants.rb → c/gen_constants.rb} +3 -3
  18. data/ext/amalgalite/c/notes.txt +134 -0
  19. data/ext/amalgalite/{sqlite3.c → c/sqlite3.c} +94602 -80497
  20. data/ext/amalgalite/{sqlite3.h → c/sqlite3.h} +1047 -216
  21. data/ext/amalgalite/{sqlite3_options.h → c/sqlite3_options.h} +0 -0
  22. data/ext/amalgalite/{sqlite3ext.h → c/sqlite3ext.h} +40 -13
  23. data/lib/amalgalite.rb +13 -6
  24. data/lib/amalgalite/1.8/amalgalite.so +0 -0
  25. data/lib/amalgalite/1.9/amalgalite.so +0 -0
  26. data/lib/amalgalite/2.0/amalgalite.so +0 -0
  27. data/lib/amalgalite/column.rb +7 -5
  28. data/lib/amalgalite/database.rb +18 -10
  29. data/lib/amalgalite/packer.rb +5 -2
  30. data/lib/amalgalite/requires.rb +47 -16
  31. data/lib/amalgalite/schema.rb +63 -36
  32. data/lib/amalgalite/sqlite3/version.rb +0 -1
  33. data/lib/amalgalite/statement.rb +7 -5
  34. data/lib/amalgalite/table.rb +9 -8
  35. data/lib/amalgalite/type_maps/default_map.rb +0 -1
  36. data/lib/amalgalite/type_maps/storage_map.rb +0 -2
  37. data/lib/amalgalite/type_maps/text_map.rb +0 -1
  38. data/lib/amalgalite/version.rb +3 -32
  39. data/spec/aggregate_spec.rb +1 -1
  40. data/spec/amalgalite_spec.rb +1 -1
  41. data/spec/blob_spec.rb +1 -1
  42. data/spec/boolean_spec.rb +2 -1
  43. data/spec/busy_handler.rb +1 -1
  44. data/spec/database_spec.rb +16 -11
  45. data/spec/default_map_spec.rb +1 -1
  46. data/spec/function_spec.rb +1 -1
  47. data/spec/integeration_spec.rb +2 -1
  48. data/spec/packer_spec.rb +4 -4
  49. data/spec/paths_spec.rb +1 -1
  50. data/spec/progress_handler_spec.rb +4 -5
  51. data/spec/requires_spec.rb +36 -2
  52. data/spec/rtree_spec.rb +6 -5
  53. data/spec/schema_spec.rb +28 -20
  54. data/spec/spec_helper.rb +2 -7
  55. data/spec/sqlite3/constants_spec.rb +1 -1
  56. data/spec/sqlite3/database_status_spec.rb +4 -4
  57. data/spec/sqlite3/status_spec.rb +5 -5
  58. data/spec/sqlite3/version_spec.rb +7 -7
  59. data/spec/sqlite3_spec.rb +3 -3
  60. data/spec/statement_spec.rb +3 -4
  61. data/spec/storage_map_spec.rb +1 -1
  62. data/spec/tap_spec.rb +4 -4
  63. data/spec/text_map_spec.rb +1 -1
  64. data/spec/type_map_spec.rb +1 -1
  65. data/spec/version_spec.rb +2 -9
  66. data/tasks/custom.rake +99 -0
  67. data/tasks/default.rake +277 -0
  68. data/tasks/extension.rake +28 -202
  69. data/tasks/this.rb +209 -0
  70. metadata +102 -191
  71. data/README.rdoc +0 -54
  72. data/gemspec.rb +0 -63
  73. data/lib/amalgalite/1.8/amalgalite3.so +0 -0
  74. data/lib/amalgalite/1.9/amalgalite3.so +0 -0
  75. data/tasks/announce.rake +0 -44
  76. data/tasks/config.rb +0 -107
  77. data/tasks/distribution.rake +0 -77
  78. data/tasks/documentation.rake +0 -36
  79. data/tasks/rspec.rake +0 -30
  80. data/tasks/utils.rb +0 -80
@@ -107,9 +107,9 @@ extern "C" {
107
107
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108
108
  ** [sqlite_version()] and [sqlite_source_id()].
109
109
  */
110
- #define SQLITE_VERSION "3.7.5"
111
- #define SQLITE_VERSION_NUMBER 3007005
112
- #define SQLITE_SOURCE_ID "2011-01-28 17:03:50 ed759d5a9edb3bba5f48f243df47be29e3fe8cd7"
110
+ #define SQLITE_VERSION "3.7.15.2"
111
+ #define SQLITE_VERSION_NUMBER 3007015
112
+ #define SQLITE_SOURCE_ID "2013-01-09 11:53:05 c0e09560d26f0a6456be9dd3447f5311eb4f238f"
113
113
 
114
114
  /*
115
115
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -177,7 +177,7 @@ SQLITE_API const char *sqlite3_compileoption_get(int N);
177
177
  ** CAPI3REF: Test To See If The Library Is Threadsafe
178
178
  **
179
179
  ** ^The sqlite3_threadsafe() function returns zero if and only if
180
- ** SQLite was compiled mutexing code omitted due to the
180
+ ** SQLite was compiled with mutexing code omitted due to the
181
181
  ** [SQLITE_THREADSAFE] compile-time option being set to 0.
182
182
  **
183
183
  ** SQLite can be compiled with or without mutexes. When
@@ -219,7 +219,8 @@ SQLITE_API int sqlite3_threadsafe(void);
219
219
  ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
220
220
  ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
221
221
  ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()]
222
- ** is its destructor. There are many other interfaces (such as
222
+ ** and [sqlite3_close_v2()] are its destructors. There are many other
223
+ ** interfaces (such as
223
224
  ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and
224
225
  ** [sqlite3_busy_timeout()] to name but three) that are methods on an
225
226
  ** sqlite3 object.
@@ -266,28 +267,46 @@ typedef sqlite_uint64 sqlite3_uint64;
266
267
  /*
267
268
  ** CAPI3REF: Closing A Database Connection
268
269
  **
269
- ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
270
- ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
271
- ** successfully destroyed and all associated resources are deallocated.
272
- **
273
- ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
274
- ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
275
- ** the [sqlite3] object prior to attempting to close the object. ^If
270
+ ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
271
+ ** for the [sqlite3] object.
272
+ ** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if
273
+ ** the [sqlite3] object is successfully destroyed and all associated
274
+ ** resources are deallocated.
275
+ **
276
+ ** ^If the database connection is associated with unfinalized prepared
277
+ ** statements or unfinished sqlite3_backup objects then sqlite3_close()
278
+ ** will leave the database connection open and return [SQLITE_BUSY].
279
+ ** ^If sqlite3_close_v2() is called with unfinalized prepared statements
280
+ ** and unfinished sqlite3_backups, then the database connection becomes
281
+ ** an unusable "zombie" which will automatically be deallocated when the
282
+ ** last prepared statement is finalized or the last sqlite3_backup is
283
+ ** finished. The sqlite3_close_v2() interface is intended for use with
284
+ ** host languages that are garbage collected, and where the order in which
285
+ ** destructors are called is arbitrary.
286
+ **
287
+ ** Applications should [sqlite3_finalize | finalize] all [prepared statements],
288
+ ** [sqlite3_blob_close | close] all [BLOB handles], and
289
+ ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated
290
+ ** with the [sqlite3] object prior to attempting to close the object. ^If
276
291
  ** sqlite3_close() is called on a [database connection] that still has
277
- ** outstanding [prepared statements] or [BLOB handles], then it returns
278
- ** SQLITE_BUSY.
292
+ ** outstanding [prepared statements], [BLOB handles], and/or
293
+ ** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation
294
+ ** of resources is deferred until all [prepared statements], [BLOB handles],
295
+ ** and [sqlite3_backup] objects are also destroyed.
279
296
  **
280
- ** ^If [sqlite3_close()] is invoked while a transaction is open,
297
+ ** ^If an [sqlite3] object is destroyed while a transaction is open,
281
298
  ** the transaction is automatically rolled back.
282
299
  **
283
- ** The C parameter to [sqlite3_close(C)] must be either a NULL
300
+ ** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)]
301
+ ** must be either a NULL
284
302
  ** pointer or an [sqlite3] object pointer obtained
285
303
  ** from [sqlite3_open()], [sqlite3_open16()], or
286
304
  ** [sqlite3_open_v2()], and not previously closed.
287
- ** ^Calling sqlite3_close() with a NULL pointer argument is a
288
- ** harmless no-op.
305
+ ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
306
+ ** argument is a harmless no-op.
289
307
  */
290
- SQLITE_API int sqlite3_close(sqlite3 *);
308
+ SQLITE_API int sqlite3_close(sqlite3*);
309
+ SQLITE_API int sqlite3_close_v2(sqlite3*);
291
310
 
292
311
  /*
293
312
  ** The type for a callback function.
@@ -310,7 +329,7 @@ typedef int (*sqlite3_callback)(void*,int,char**, char**);
310
329
  ** argument. ^If the callback function of the 3rd argument to
311
330
  ** sqlite3_exec() is not NULL, then it is invoked for each result row
312
331
  ** coming out of the evaluated SQL statements. ^The 4th argument to
313
- ** to sqlite3_exec() is relayed through to the 1st argument of each
332
+ ** sqlite3_exec() is relayed through to the 1st argument of each
314
333
  ** callback invocation. ^If the callback pointer to sqlite3_exec()
315
334
  ** is NULL, then no callback is ever invoked and result rows are
316
335
  ** ignored.
@@ -371,11 +390,12 @@ SQLITE_API int sqlite3_exec(
371
390
  ** KEYWORDS: {result code} {result codes}
372
391
  **
373
392
  ** Many SQLite functions return an integer result code from the set shown
374
- ** here in order to indicates success or failure.
393
+ ** here in order to indicate success or failure.
375
394
  **
376
395
  ** New error codes may be added in future versions of SQLite.
377
396
  **
378
- ** See also: [SQLITE_IOERR_READ | extended result codes]
397
+ ** See also: [SQLITE_IOERR_READ | extended result codes],
398
+ ** [sqlite3_vtab_on_conflict()] [SQLITE_ROLLBACK | result codes].
379
399
  */
380
400
  #define SQLITE_OK 0 /* Successful result */
381
401
  /* beginning-of-error-codes */
@@ -452,17 +472,25 @@ SQLITE_API int sqlite3_exec(
452
472
  #define SQLITE_IOERR_SHMOPEN (SQLITE_IOERR | (18<<8))
453
473
  #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
454
474
  #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
475
+ #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
476
+ #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
477
+ #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
455
478
  #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
456
479
  #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
457
480
  #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
481
+ #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
482
+ #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
483
+ #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
484
+ #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
485
+ #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
486
+ #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
458
487
 
459
488
  /*
460
489
  ** CAPI3REF: Flags For File Open Operations
461
490
  **
462
491
  ** These bit values are intended for use in the
463
492
  ** 3rd parameter to the [sqlite3_open_v2()] interface and
464
- ** in the 4th parameter to the xOpen method of the
465
- ** [sqlite3_vfs] object.
493
+ ** in the 4th parameter to the [sqlite3_vfs.xOpen] method.
466
494
  */
467
495
  #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */
468
496
  #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
@@ -470,6 +498,8 @@ SQLITE_API int sqlite3_exec(
470
498
  #define SQLITE_OPEN_DELETEONCLOSE 0x00000008 /* VFS only */
471
499
  #define SQLITE_OPEN_EXCLUSIVE 0x00000010 /* VFS only */
472
500
  #define SQLITE_OPEN_AUTOPROXY 0x00000020 /* VFS only */
501
+ #define SQLITE_OPEN_URI 0x00000040 /* Ok for sqlite3_open_v2() */
502
+ #define SQLITE_OPEN_MEMORY 0x00000080 /* Ok for sqlite3_open_v2() */
473
503
  #define SQLITE_OPEN_MAIN_DB 0x00000100 /* VFS only */
474
504
  #define SQLITE_OPEN_TEMP_DB 0x00000200 /* VFS only */
475
505
  #define SQLITE_OPEN_TRANSIENT_DB 0x00000400 /* VFS only */
@@ -483,11 +513,13 @@ SQLITE_API int sqlite3_exec(
483
513
  #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
484
514
  #define SQLITE_OPEN_WAL 0x00080000 /* VFS only */
485
515
 
516
+ /* Reserved: 0x00F00000 */
517
+
486
518
  /*
487
519
  ** CAPI3REF: Device Characteristics
488
520
  **
489
521
  ** The xDeviceCharacteristics method of the [sqlite3_io_methods]
490
- ** object returns an integer which is a vector of the these
522
+ ** object returns an integer which is a vector of these
491
523
  ** bit values expressing I/O characteristics of the mass storage
492
524
  ** device that holds the file that the [sqlite3_io_methods]
493
525
  ** refers to.
@@ -501,7 +533,11 @@ SQLITE_API int sqlite3_exec(
501
533
  ** first then the size of the file is extended, never the other
502
534
  ** way around. The SQLITE_IOCAP_SEQUENTIAL property means that
503
535
  ** information is written to disk in the same order as calls
504
- ** to xWrite().
536
+ ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
537
+ ** after reboot following a crash or power loss, the only bytes in a
538
+ ** file that were written at the application level might have changed
539
+ ** and that adjacent bytes, even bytes within the same sector are
540
+ ** guaranteed to be unchanged.
505
541
  */
506
542
  #define SQLITE_IOCAP_ATOMIC 0x00000001
507
543
  #define SQLITE_IOCAP_ATOMIC512 0x00000002
@@ -515,6 +551,7 @@ SQLITE_API int sqlite3_exec(
515
551
  #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
516
552
  #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
517
553
  #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
554
+ #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
518
555
 
519
556
  /*
520
557
  ** CAPI3REF: File Locking Levels
@@ -578,17 +615,18 @@ struct sqlite3_file {
578
615
  /*
579
616
  ** CAPI3REF: OS Interface File Virtual Methods Object
580
617
  **
581
- ** Every file opened by the [sqlite3_vfs] xOpen method populates an
618
+ ** Every file opened by the [sqlite3_vfs.xOpen] method populates an
582
619
  ** [sqlite3_file] object (or, more commonly, a subclass of the
583
620
  ** [sqlite3_file] object) with a pointer to an instance of this object.
584
621
  ** This object defines the methods used to perform various operations
585
622
  ** against the open file represented by the [sqlite3_file] object.
586
623
  **
587
- ** If the xOpen method sets the sqlite3_file.pMethods element
624
+ ** If the [sqlite3_vfs.xOpen] method sets the sqlite3_file.pMethods element
588
625
  ** to a non-NULL pointer, then the sqlite3_io_methods.xClose method
589
- ** may be invoked even if the xOpen reported that it failed. The
590
- ** only way to prevent a call to xClose following a failed xOpen
591
- ** is for the xOpen to set the sqlite3_file.pMethods element to NULL.
626
+ ** may be invoked even if the [sqlite3_vfs.xOpen] reported that it failed. The
627
+ ** only way to prevent a call to xClose following a failed [sqlite3_vfs.xOpen]
628
+ ** is for the [sqlite3_vfs.xOpen] to set the sqlite3_file.pMethods element
629
+ ** to NULL.
592
630
  **
593
631
  ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or
594
632
  ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync().
@@ -702,7 +740,8 @@ struct sqlite3_io_methods {
702
740
  ** into an integer that the pArg argument points to. This capability
703
741
  ** is used during testing and only needs to be supported when SQLITE_TEST
704
742
  ** is defined.
705
- **
743
+ ** <ul>
744
+ ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
706
745
  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
707
746
  ** layer a hint of how large the database file will grow to be during the
708
747
  ** current transaction. This hint is not guaranteed to be accurate but it
@@ -710,6 +749,7 @@ struct sqlite3_io_methods {
710
749
  ** file space based on this hint in order to help writes to the database
711
750
  ** file run faster.
712
751
  **
752
+ ** <li>[[SQLITE_FCNTL_CHUNK_SIZE]]
713
753
  ** The [SQLITE_FCNTL_CHUNK_SIZE] opcode is used to request that the VFS
714
754
  ** extends and truncates the database file in chunks of a size specified
715
755
  ** by the user. The fourth argument to [sqlite3_file_control()] should
@@ -718,11 +758,13 @@ struct sqlite3_io_methods {
718
758
  ** chunks (say 1MB at a time), may reduce file-system fragmentation and
719
759
  ** improve performance on some systems.
720
760
  **
761
+ ** <li>[[SQLITE_FCNTL_FILE_POINTER]]
721
762
  ** The [SQLITE_FCNTL_FILE_POINTER] opcode is used to obtain a pointer
722
763
  ** to the [sqlite3_file] object associated with a particular database
723
764
  ** connection. See the [sqlite3_file_control()] documentation for
724
765
  ** additional information.
725
766
  **
767
+ ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
726
768
  ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by
727
769
  ** SQLite and sent to all VFSes in place of a call to the xSync method
728
770
  ** when the database connection has [PRAGMA synchronous] set to OFF.)^
@@ -730,18 +772,129 @@ struct sqlite3_io_methods {
730
772
  ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most
731
773
  ** VFSes do not need this signal and should silently ignore this opcode.
732
774
  ** Applications should not call [sqlite3_file_control()] with this
733
- ** opcode as doing so may disrupt the operation of the specilized VFSes
775
+ ** opcode as doing so may disrupt the operation of the specialized VFSes
734
776
  ** that do require it.
777
+ **
778
+ ** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
779
+ ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
780
+ ** retry counts and intervals for certain disk I/O operations for the
781
+ ** windows [VFS] in order to provide robustness in the presence of
782
+ ** anti-virus programs. By default, the windows VFS will retry file read,
783
+ ** file write, and file delete operations up to 10 times, with a delay
784
+ ** of 25 milliseconds before the first retry and with the delay increasing
785
+ ** by an additional 25 milliseconds with each subsequent retry. This
786
+ ** opcode allows these two values (10 retries and 25 milliseconds of delay)
787
+ ** to be adjusted. The values are changed for all database connections
788
+ ** within the same process. The argument is a pointer to an array of two
789
+ ** integers where the first integer i the new retry count and the second
790
+ ** integer is the delay. If either integer is negative, then the setting
791
+ ** is not changed but instead the prior value of that setting is written
792
+ ** into the array entry, allowing the current retry settings to be
793
+ ** interrogated. The zDbName parameter is ignored.
794
+ **
795
+ ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
796
+ ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
797
+ ** persistent [WAL | Write Ahead Log] setting. By default, the auxiliary
798
+ ** write ahead log and shared memory files used for transaction control
799
+ ** are automatically deleted when the latest connection to the database
800
+ ** closes. Setting persistent WAL mode causes those files to persist after
801
+ ** close. Persisting the files is useful when other processes that do not
802
+ ** have write permission on the directory containing the database file want
803
+ ** to read the database file, as the WAL and shared memory files must exist
804
+ ** in order for the database to be readable. The fourth parameter to
805
+ ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
806
+ ** That integer is 0 to disable persistent WAL mode or 1 to enable persistent
807
+ ** WAL mode. If the integer is -1, then it is overwritten with the current
808
+ ** WAL persistence setting.
809
+ **
810
+ ** <li>[[SQLITE_FCNTL_POWERSAFE_OVERWRITE]]
811
+ ** ^The [SQLITE_FCNTL_POWERSAFE_OVERWRITE] opcode is used to set or query the
812
+ ** persistent "powersafe-overwrite" or "PSOW" setting. The PSOW setting
813
+ ** determines the [SQLITE_IOCAP_POWERSAFE_OVERWRITE] bit of the
814
+ ** xDeviceCharacteristics methods. The fourth parameter to
815
+ ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
816
+ ** That integer is 0 to disable zero-damage mode or 1 to enable zero-damage
817
+ ** mode. If the integer is -1, then it is overwritten with the current
818
+ ** zero-damage mode setting.
819
+ **
820
+ ** <li>[[SQLITE_FCNTL_OVERWRITE]]
821
+ ** ^The [SQLITE_FCNTL_OVERWRITE] opcode is invoked by SQLite after opening
822
+ ** a write transaction to indicate that, unless it is rolled back for some
823
+ ** reason, the entire database file will be overwritten by the current
824
+ ** transaction. This is used by VACUUM operations.
825
+ **
826
+ ** <li>[[SQLITE_FCNTL_VFSNAME]]
827
+ ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of
828
+ ** all [VFSes] in the VFS stack. The names are of all VFS shims and the
829
+ ** final bottom-level VFS are written into memory obtained from
830
+ ** [sqlite3_malloc()] and the result is stored in the char* variable
831
+ ** that the fourth parameter of [sqlite3_file_control()] points to.
832
+ ** The caller is responsible for freeing the memory when done. As with
833
+ ** all file-control actions, there is no guarantee that this will actually
834
+ ** do anything. Callers should initialize the char* variable to a NULL
835
+ ** pointer in case this file-control is not implemented. This file-control
836
+ ** is intended for diagnostic use only.
837
+ **
838
+ ** <li>[[SQLITE_FCNTL_PRAGMA]]
839
+ ** ^Whenever a [PRAGMA] statement is parsed, an [SQLITE_FCNTL_PRAGMA]
840
+ ** file control is sent to the open [sqlite3_file] object corresponding
841
+ ** to the database file to which the pragma statement refers. ^The argument
842
+ ** to the [SQLITE_FCNTL_PRAGMA] file control is an array of
843
+ ** pointers to strings (char**) in which the second element of the array
844
+ ** is the name of the pragma and the third element is the argument to the
845
+ ** pragma or NULL if the pragma has no argument. ^The handler for an
846
+ ** [SQLITE_FCNTL_PRAGMA] file control can optionally make the first element
847
+ ** of the char** argument point to a string obtained from [sqlite3_mprintf()]
848
+ ** or the equivalent and that string will become the result of the pragma or
849
+ ** the error message if the pragma fails. ^If the
850
+ ** [SQLITE_FCNTL_PRAGMA] file control returns [SQLITE_NOTFOUND], then normal
851
+ ** [PRAGMA] processing continues. ^If the [SQLITE_FCNTL_PRAGMA]
852
+ ** file control returns [SQLITE_OK], then the parser assumes that the
853
+ ** VFS has handled the PRAGMA itself and the parser generates a no-op
854
+ ** prepared statement. ^If the [SQLITE_FCNTL_PRAGMA] file control returns
855
+ ** any result code other than [SQLITE_OK] or [SQLITE_NOTFOUND], that means
856
+ ** that the VFS encountered an error while handling the [PRAGMA] and the
857
+ ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
858
+ ** file control occurs at the beginning of pragma statement analysis and so
859
+ ** it is able to override built-in [PRAGMA] statements.
860
+ **
861
+ ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
862
+ ** ^This file-control may be invoked by SQLite on the database file handle
863
+ ** shortly after it is opened in order to provide a custom VFS with access
864
+ ** to the connections busy-handler callback. The argument is of type (void **)
865
+ ** - an array of two (void *) values. The first (void *) actually points
866
+ ** to a function of type (int (*)(void *)). In order to invoke the connections
867
+ ** busy-handler, this function should be invoked with the second (void *) in
868
+ ** the array as the only argument. If it returns non-zero, then the operation
869
+ ** should be retried. If it returns zero, the custom VFS should abandon the
870
+ ** current operation.
871
+ **
872
+ ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
873
+ ** ^Application can invoke this file-control to have SQLite generate a
874
+ ** temporary filename using the same algorithm that is followed to generate
875
+ ** temporary filenames for TEMP tables and other internal uses. The
876
+ ** argument should be a char** which will be filled with the filename
877
+ ** written into memory obtained from [sqlite3_malloc()]. The caller should
878
+ ** invoke [sqlite3_free()] on the result to avoid a memory leak.
879
+ **
880
+ ** </ul>
735
881
  */
736
- #define SQLITE_FCNTL_LOCKSTATE 1
737
- #define SQLITE_GET_LOCKPROXYFILE 2
738
- #define SQLITE_SET_LOCKPROXYFILE 3
739
- #define SQLITE_LAST_ERRNO 4
740
- #define SQLITE_FCNTL_SIZE_HINT 5
741
- #define SQLITE_FCNTL_CHUNK_SIZE 6
742
- #define SQLITE_FCNTL_FILE_POINTER 7
743
- #define SQLITE_FCNTL_SYNC_OMITTED 8
744
-
882
+ #define SQLITE_FCNTL_LOCKSTATE 1
883
+ #define SQLITE_GET_LOCKPROXYFILE 2
884
+ #define SQLITE_SET_LOCKPROXYFILE 3
885
+ #define SQLITE_LAST_ERRNO 4
886
+ #define SQLITE_FCNTL_SIZE_HINT 5
887
+ #define SQLITE_FCNTL_CHUNK_SIZE 6
888
+ #define SQLITE_FCNTL_FILE_POINTER 7
889
+ #define SQLITE_FCNTL_SYNC_OMITTED 8
890
+ #define SQLITE_FCNTL_WIN32_AV_RETRY 9
891
+ #define SQLITE_FCNTL_PERSIST_WAL 10
892
+ #define SQLITE_FCNTL_OVERWRITE 11
893
+ #define SQLITE_FCNTL_VFSNAME 12
894
+ #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
895
+ #define SQLITE_FCNTL_PRAGMA 14
896
+ #define SQLITE_FCNTL_BUSYHANDLER 15
897
+ #define SQLITE_FCNTL_TEMPFILENAME 16
745
898
 
746
899
  /*
747
900
  ** CAPI3REF: Mutex Handle
@@ -760,7 +913,8 @@ typedef struct sqlite3_mutex sqlite3_mutex;
760
913
  **
761
914
  ** An instance of the sqlite3_vfs object defines the interface between
762
915
  ** the SQLite core and the underlying operating system. The "vfs"
763
- ** in the name of the object stands for "virtual file system".
916
+ ** in the name of the object stands for "virtual file system". See
917
+ ** the [VFS | VFS documentation] for further information.
764
918
  **
765
919
  ** The value of the iVersion field is initially 1 but may be larger in
766
920
  ** future versions of SQLite. Additional fields may be appended to this
@@ -789,12 +943,13 @@ typedef struct sqlite3_mutex sqlite3_mutex;
789
943
  ** The zName field holds the name of the VFS module. The name must
790
944
  ** be unique across all VFS modules.
791
945
  **
946
+ ** [[sqlite3_vfs.xOpen]]
792
947
  ** ^SQLite guarantees that the zFilename parameter to xOpen
793
948
  ** is either a NULL pointer or string obtained
794
949
  ** from xFullPathname() with an optional suffix added.
795
950
  ** ^If a suffix is added to the zFilename parameter, it will
796
951
  ** consist of a single "-" character followed by no more than
797
- ** 10 alphanumeric and/or "-" characters.
952
+ ** 11 alphanumeric and/or "-" characters.
798
953
  ** ^SQLite further guarantees that
799
954
  ** the string will be valid and unchanged until xClose() is
800
955
  ** called. Because of the previous sentence,
@@ -866,6 +1021,7 @@ typedef struct sqlite3_mutex sqlite3_mutex;
866
1021
  ** element will be valid after xOpen returns regardless of the success
867
1022
  ** or failure of the xOpen call.
868
1023
  **
1024
+ ** [[sqlite3_vfs.xAccess]]
869
1025
  ** ^The flags argument to xAccess() may be [SQLITE_ACCESS_EXISTS]
870
1026
  ** to test for the existence of a file, or [SQLITE_ACCESS_READWRITE] to
871
1027
  ** test whether a file is readable and writable, or [SQLITE_ACCESS_READ]
@@ -890,16 +1046,29 @@ typedef struct sqlite3_mutex sqlite3_mutex;
890
1046
  ** method returns a Julian Day Number for the current date and time as
891
1047
  ** a floating point value.
892
1048
  ** ^The xCurrentTimeInt64() method returns, as an integer, the Julian
893
- ** Day Number multipled by 86400000 (the number of milliseconds in
1049
+ ** Day Number multiplied by 86400000 (the number of milliseconds in
894
1050
  ** a 24-hour day).
895
1051
  ** ^SQLite will use the xCurrentTimeInt64() method to get the current
896
1052
  ** date and time if that method is available (if iVersion is 2 or
897
1053
  ** greater and the function pointer is not NULL) and will fall back
898
1054
  ** to xCurrentTime() if xCurrentTimeInt64() is unavailable.
1055
+ **
1056
+ ** ^The xSetSystemCall(), xGetSystemCall(), and xNestSystemCall() interfaces
1057
+ ** are not used by the SQLite core. These optional interfaces are provided
1058
+ ** by some VFSes to facilitate testing of the VFS code. By overriding
1059
+ ** system calls with functions under its control, a test program can
1060
+ ** simulate faults and error conditions that would otherwise be difficult
1061
+ ** or impossible to induce. The set of system calls that can be overridden
1062
+ ** varies from one VFS to another, and from one version of the same VFS to the
1063
+ ** next. Applications that use these interfaces must be prepared for any
1064
+ ** or all of these interfaces to be NULL or for their behavior to change
1065
+ ** from one release to the next. Applications must not attempt to access
1066
+ ** any of these methods if the iVersion of the VFS is less than 3.
899
1067
  */
900
1068
  typedef struct sqlite3_vfs sqlite3_vfs;
1069
+ typedef void (*sqlite3_syscall_ptr)(void);
901
1070
  struct sqlite3_vfs {
902
- int iVersion; /* Structure version number (currently 2) */
1071
+ int iVersion; /* Structure version number (currently 3) */
903
1072
  int szOsFile; /* Size of subclassed sqlite3_file */
904
1073
  int mxPathname; /* Maximum file pathname length */
905
1074
  sqlite3_vfs *pNext; /* Next registered VFS */
@@ -925,6 +1094,13 @@ struct sqlite3_vfs {
925
1094
  int (*xCurrentTimeInt64)(sqlite3_vfs*, sqlite3_int64*);
926
1095
  /*
927
1096
  ** The methods above are in versions 1 and 2 of the sqlite_vfs object.
1097
+ ** Those below are for version 3 and greater.
1098
+ */
1099
+ int (*xSetSystemCall)(sqlite3_vfs*, const char *zName, sqlite3_syscall_ptr);
1100
+ sqlite3_syscall_ptr (*xGetSystemCall)(sqlite3_vfs*, const char *zName);
1101
+ const char *(*xNextSystemCall)(sqlite3_vfs*, const char *zName);
1102
+ /*
1103
+ ** The methods above are in versions 1 through 3 of the sqlite_vfs object.
928
1104
  ** New fields may be appended in figure versions. The iVersion
929
1105
  ** value will increment whenever this happens.
930
1106
  */
@@ -1092,9 +1268,9 @@ SQLITE_API int sqlite3_os_end(void);
1092
1268
  ** implementation of an application-defined [sqlite3_os_init()].
1093
1269
  **
1094
1270
  ** The first argument to sqlite3_config() is an integer
1095
- ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
1271
+ ** [configuration option] that determines
1096
1272
  ** what property of SQLite is to be configured. Subsequent arguments
1097
- ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
1273
+ ** vary depending on the [configuration option]
1098
1274
  ** in the first argument.
1099
1275
  **
1100
1276
  ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
@@ -1109,17 +1285,12 @@ SQLITE_API int sqlite3_config(int, ...);
1109
1285
  ** The sqlite3_db_config() interface is used to make configuration
1110
1286
  ** changes to a [database connection]. The interface is similar to
1111
1287
  ** [sqlite3_config()] except that the changes apply to a single
1112
- ** [database connection] (specified in the first argument). The
1113
- ** sqlite3_db_config() interface should only be used immediately after
1114
- ** the database connection is created using [sqlite3_open()],
1115
- ** [sqlite3_open16()], or [sqlite3_open_v2()].
1288
+ ** [database connection] (specified in the first argument).
1116
1289
  **
1117
1290
  ** The second argument to sqlite3_db_config(D,V,...) is the
1118
- ** configuration verb - an integer code that indicates what
1119
- ** aspect of the [database connection] is being configured.
1120
- ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
1121
- ** New verbs are likely to be added in future releases of SQLite.
1122
- ** Additional arguments depend on the verb.
1291
+ ** [SQLITE_DBCONFIG_LOOKASIDE | configuration verb] - an integer code
1292
+ ** that indicates what aspect of the [database connection] is being configured.
1293
+ ** Subsequent arguments vary depending on the configuration verb.
1123
1294
  **
1124
1295
  ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1125
1296
  ** the call is considered successful.
@@ -1151,16 +1322,10 @@ SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1151
1322
  ** order to verify that SQLite recovers gracefully from such
1152
1323
  ** conditions.
1153
1324
  **
1154
- ** The xMalloc and xFree methods must work like the
1155
- ** malloc() and free() functions from the standard C library.
1156
- ** The xRealloc method must work like realloc() from the standard C library
1157
- ** with the exception that if the second argument to xRealloc is zero,
1158
- ** xRealloc must be a no-op - it must not perform any allocation or
1159
- ** deallocation. ^SQLite guarantees that the second argument to
1325
+ ** The xMalloc, xRealloc, and xFree methods must work like the
1326
+ ** malloc(), realloc() and free() functions from the standard C library.
1327
+ ** ^SQLite guarantees that the second argument to
1160
1328
  ** xRealloc is always a value returned by a prior call to xRoundup.
1161
- ** And so in cases where xRoundup always returns a positive number,
1162
- ** xRealloc can perform exactly as the standard library realloc() and
1163
- ** still be in compliance with this specification.
1164
1329
  **
1165
1330
  ** xSize should return the allocated size of a memory allocation
1166
1331
  ** previously obtained from xMalloc or xRealloc. The allocated size
@@ -1209,6 +1374,7 @@ struct sqlite3_mem_methods {
1209
1374
 
1210
1375
  /*
1211
1376
  ** CAPI3REF: Configuration Options
1377
+ ** KEYWORDS: {configuration option}
1212
1378
  **
1213
1379
  ** These constants are the available integer configuration options that
1214
1380
  ** can be passed as the first argument to the [sqlite3_config()] interface.
@@ -1221,7 +1387,7 @@ struct sqlite3_mem_methods {
1221
1387
  ** is invoked.
1222
1388
  **
1223
1389
  ** <dl>
1224
- ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1390
+ ** [[SQLITE_CONFIG_SINGLETHREAD]] <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1225
1391
  ** <dd>There are no arguments to this option. ^This option sets the
1226
1392
  ** [threading mode] to Single-thread. In other words, it disables
1227
1393
  ** all mutexing and puts SQLite into a mode where it can only be used
@@ -1232,7 +1398,7 @@ struct sqlite3_mem_methods {
1232
1398
  ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
1233
1399
  ** configuration option.</dd>
1234
1400
  **
1235
- ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1401
+ ** [[SQLITE_CONFIG_MULTITHREAD]] <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1236
1402
  ** <dd>There are no arguments to this option. ^This option sets the
1237
1403
  ** [threading mode] to Multi-thread. In other words, it disables
1238
1404
  ** mutexing on [database connection] and [prepared statement] objects.
@@ -1246,7 +1412,7 @@ struct sqlite3_mem_methods {
1246
1412
  ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1247
1413
  ** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
1248
1414
  **
1249
- ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1415
+ ** [[SQLITE_CONFIG_SERIALIZED]] <dt>SQLITE_CONFIG_SERIALIZED</dt>
1250
1416
  ** <dd>There are no arguments to this option. ^This option sets the
1251
1417
  ** [threading mode] to Serialized. In other words, this option enables
1252
1418
  ** all mutexes including the recursive
@@ -1262,7 +1428,7 @@ struct sqlite3_mem_methods {
1262
1428
  ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1263
1429
  ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
1264
1430
  **
1265
- ** <dt>SQLITE_CONFIG_MALLOC</dt>
1431
+ ** [[SQLITE_CONFIG_MALLOC]] <dt>SQLITE_CONFIG_MALLOC</dt>
1266
1432
  ** <dd> ^(This option takes a single argument which is a pointer to an
1267
1433
  ** instance of the [sqlite3_mem_methods] structure. The argument specifies
1268
1434
  ** alternative low-level memory allocation routines to be used in place of
@@ -1270,7 +1436,7 @@ struct sqlite3_mem_methods {
1270
1436
  ** its own private copy of the content of the [sqlite3_mem_methods] structure
1271
1437
  ** before the [sqlite3_config()] call returns.</dd>
1272
1438
  **
1273
- ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1439
+ ** [[SQLITE_CONFIG_GETMALLOC]] <dt>SQLITE_CONFIG_GETMALLOC</dt>
1274
1440
  ** <dd> ^(This option takes a single argument which is a pointer to an
1275
1441
  ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1276
1442
  ** structure is filled with the currently defined memory allocation routines.)^
@@ -1278,7 +1444,7 @@ struct sqlite3_mem_methods {
1278
1444
  ** routines with a wrapper that simulations memory allocation failure or
1279
1445
  ** tracks memory usage, for example. </dd>
1280
1446
  **
1281
- ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1447
+ ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1282
1448
  ** <dd> ^This option takes single argument of type int, interpreted as a
1283
1449
  ** boolean, which enables or disables the collection of memory allocation
1284
1450
  ** statistics. ^(When memory allocation statistics are disabled, the
@@ -1294,10 +1460,10 @@ struct sqlite3_mem_methods {
1294
1460
  ** allocation statistics are disabled by default.
1295
1461
  ** </dd>
1296
1462
  **
1297
- ** <dt>SQLITE_CONFIG_SCRATCH</dt>
1463
+ ** [[SQLITE_CONFIG_SCRATCH]] <dt>SQLITE_CONFIG_SCRATCH</dt>
1298
1464
  ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1299
1465
  ** scratch memory. There are three arguments: A pointer an 8-byte
1300
- ** aligned memory buffer from which the scrach allocations will be
1466
+ ** aligned memory buffer from which the scratch allocations will be
1301
1467
  ** drawn, the size of each scratch allocation (sz),
1302
1468
  ** and the maximum number of scratch allocations (N). The sz
1303
1469
  ** argument must be a multiple of 16.
@@ -1310,11 +1476,11 @@ struct sqlite3_mem_methods {
1310
1476
  ** scratch memory beyond what is provided by this configuration option, then
1311
1477
  ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
1312
1478
  **
1313
- ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1479
+ ** [[SQLITE_CONFIG_PAGECACHE]] <dt>SQLITE_CONFIG_PAGECACHE</dt>
1314
1480
  ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1315
- ** the database page cache with the default page cache implemenation.
1481
+ ** the database page cache with the default page cache implementation.
1316
1482
  ** This configuration should not be used if an application-define page
1317
- ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1483
+ ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE2 option.
1318
1484
  ** There are three arguments to this option: A pointer to 8-byte aligned
1319
1485
  ** memory, the size of each page buffer (sz), and the number of pages (N).
1320
1486
  ** The sz argument should be the size of the largest database page
@@ -1331,7 +1497,7 @@ struct sqlite3_mem_methods {
1331
1497
  ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1332
1498
  ** will be undefined.</dd>
1333
1499
  **
1334
- ** <dt>SQLITE_CONFIG_HEAP</dt>
1500
+ ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt>
1335
1501
  ** <dd> ^This option specifies a static memory buffer that SQLite will use
1336
1502
  ** for all of its dynamic memory allocation needs beyond those provided
1337
1503
  ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
@@ -1344,9 +1510,11 @@ struct sqlite3_mem_methods {
1344
1510
  ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1345
1511
  ** allocator is engaged to handle all of SQLites memory allocation needs.
1346
1512
  ** The first pointer (the memory pointer) must be aligned to an 8-byte
1347
- ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1513
+ ** boundary or subsequent behavior of SQLite will be undefined.
1514
+ ** The minimum allocation size is capped at 2**12. Reasonable values
1515
+ ** for the minimum allocation size are 2**5 through 2**8.</dd>
1348
1516
  **
1349
- ** <dt>SQLITE_CONFIG_MUTEX</dt>
1517
+ ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt>
1350
1518
  ** <dd> ^(This option takes a single argument which is a pointer to an
1351
1519
  ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
1352
1520
  ** alternative low-level mutex routines to be used in place
@@ -1358,7 +1526,7 @@ struct sqlite3_mem_methods {
1358
1526
  ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1359
1527
  ** return [SQLITE_ERROR].</dd>
1360
1528
  **
1361
- ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1529
+ ** [[SQLITE_CONFIG_GETMUTEX]] <dt>SQLITE_CONFIG_GETMUTEX</dt>
1362
1530
  ** <dd> ^(This option takes a single argument which is a pointer to an
1363
1531
  ** instance of the [sqlite3_mutex_methods] structure. The
1364
1532
  ** [sqlite3_mutex_methods]
@@ -1371,7 +1539,7 @@ struct sqlite3_mem_methods {
1371
1539
  ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1372
1540
  ** return [SQLITE_ERROR].</dd>
1373
1541
  **
1374
- ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1542
+ ** [[SQLITE_CONFIG_LOOKASIDE]] <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1375
1543
  ** <dd> ^(This option takes two arguments that determine the default
1376
1544
  ** memory allocation for the lookaside memory allocator on each
1377
1545
  ** [database connection]. The first argument is the
@@ -1381,18 +1549,18 @@ struct sqlite3_mem_methods {
1381
1549
  ** verb to [sqlite3_db_config()] can be used to change the lookaside
1382
1550
  ** configuration on individual connections.)^ </dd>
1383
1551
  **
1384
- ** <dt>SQLITE_CONFIG_PCACHE</dt>
1552
+ ** [[SQLITE_CONFIG_PCACHE2]] <dt>SQLITE_CONFIG_PCACHE2</dt>
1385
1553
  ** <dd> ^(This option takes a single argument which is a pointer to
1386
- ** an [sqlite3_pcache_methods] object. This object specifies the interface
1554
+ ** an [sqlite3_pcache_methods2] object. This object specifies the interface
1387
1555
  ** to a custom page cache implementation.)^ ^SQLite makes a copy of the
1388
1556
  ** object and uses it for page cache memory allocations.</dd>
1389
1557
  **
1390
- ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1558
+ ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt>
1391
1559
  ** <dd> ^(This option takes a single argument which is a pointer to an
1392
- ** [sqlite3_pcache_methods] object. SQLite copies of the current
1560
+ ** [sqlite3_pcache_methods2] object. SQLite copies of the current
1393
1561
  ** page cache implementation into that object.)^ </dd>
1394
1562
  **
1395
- ** <dt>SQLITE_CONFIG_LOG</dt>
1563
+ ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
1396
1564
  ** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
1397
1565
  ** function with a call signature of void(*)(void*,int,const char*),
1398
1566
  ** and a pointer to void. ^If the function pointer is not NULL, it is
@@ -1410,6 +1578,51 @@ struct sqlite3_mem_methods {
1410
1578
  ** In a multi-threaded application, the application-defined logger
1411
1579
  ** function must be threadsafe. </dd>
1412
1580
  **
1581
+ ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1582
+ ** <dd> This option takes a single argument of type int. If non-zero, then
1583
+ ** URI handling is globally enabled. If the parameter is zero, then URI handling
1584
+ ** is globally disabled. If URI handling is globally enabled, all filenames
1585
+ ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1586
+ ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1587
+ ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1588
+ ** connection is opened. If it is globally disabled, filenames are
1589
+ ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1590
+ ** database connection is opened. By default, URI handling is globally
1591
+ ** disabled. The default value may be changed by compiling with the
1592
+ ** [SQLITE_USE_URI] symbol defined.
1593
+ **
1594
+ ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1595
+ ** <dd> This option takes a single integer argument which is interpreted as
1596
+ ** a boolean in order to enable or disable the use of covering indices for
1597
+ ** full table scans in the query optimizer. The default setting is determined
1598
+ ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1599
+ ** if that compile-time option is omitted.
1600
+ ** The ability to disable the use of covering indices for full table scans
1601
+ ** is because some incorrectly coded legacy applications might malfunction
1602
+ ** malfunction when the optimization is enabled. Providing the ability to
1603
+ ** disable the optimization allows the older, buggy application code to work
1604
+ ** without change even with newer versions of SQLite.
1605
+ **
1606
+ ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1607
+ ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
1608
+ ** <dd> These options are obsolete and should not be used by new code.
1609
+ ** They are retained for backwards compatibility but are now no-ops.
1610
+ ** </dl>
1611
+ **
1612
+ ** [[SQLITE_CONFIG_SQLLOG]]
1613
+ ** <dt>SQLITE_CONFIG_SQLLOG
1614
+ ** <dd>This option is only available if sqlite is compiled with the
1615
+ ** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should
1616
+ ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
1617
+ ** The second should be of type (void*). The callback is invoked by the library
1618
+ ** in three separate circumstances, identified by the value passed as the
1619
+ ** fourth parameter. If the fourth parameter is 0, then the database connection
1620
+ ** passed as the second argument has just been opened. The third argument
1621
+ ** points to a buffer containing the name of the main database file. If the
1622
+ ** fourth parameter is 1, then the SQL statement that the third parameter
1623
+ ** points to has just been executed. Or, if the fourth parameter is 2, then
1624
+ ** the connection being passed as the second parameter is being closed. The
1625
+ ** third parameter is passed NULL In this case.
1413
1626
  ** </dl>
1414
1627
  */
1415
1628
  #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
@@ -1425,9 +1638,14 @@ struct sqlite3_mem_methods {
1425
1638
  #define SQLITE_CONFIG_GETMUTEX 11 /* sqlite3_mutex_methods* */
1426
1639
  /* previously SQLITE_CONFIG_CHUNKALLOC 12 which is now unused. */
1427
1640
  #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1428
- #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
1429
- #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
1641
+ #define SQLITE_CONFIG_PCACHE 14 /* no-op */
1642
+ #define SQLITE_CONFIG_GETPCACHE 15 /* no-op */
1430
1643
  #define SQLITE_CONFIG_LOG 16 /* xFunc, void* */
1644
+ #define SQLITE_CONFIG_URI 17 /* int */
1645
+ #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
1646
+ #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
1647
+ #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
1648
+ #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
1431
1649
 
1432
1650
  /*
1433
1651
  ** CAPI3REF: Database Connection Configuration Options
@@ -1447,7 +1665,7 @@ struct sqlite3_mem_methods {
1447
1665
  ** <dd> ^This option takes three additional arguments that determine the
1448
1666
  ** [lookaside memory allocator] configuration for the [database connection].
1449
1667
  ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
1450
- ** pointer to an memory buffer to use for lookaside memory.
1668
+ ** pointer to a memory buffer to use for lookaside memory.
1451
1669
  ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
1452
1670
  ** may be NULL in which case SQLite will allocate the
1453
1671
  ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
@@ -1465,9 +1683,31 @@ struct sqlite3_mem_methods {
1465
1683
  ** memory is in use leaves the configuration unchanged and returns
1466
1684
  ** [SQLITE_BUSY].)^</dd>
1467
1685
  **
1686
+ ** <dt>SQLITE_DBCONFIG_ENABLE_FKEY</dt>
1687
+ ** <dd> ^This option is used to enable or disable the enforcement of
1688
+ ** [foreign key constraints]. There should be two additional arguments.
1689
+ ** The first argument is an integer which is 0 to disable FK enforcement,
1690
+ ** positive to enable FK enforcement or negative to leave FK enforcement
1691
+ ** unchanged. The second parameter is a pointer to an integer into which
1692
+ ** is written 0 or 1 to indicate whether FK enforcement is off or on
1693
+ ** following this call. The second parameter may be a NULL pointer, in
1694
+ ** which case the FK enforcement setting is not reported back. </dd>
1695
+ **
1696
+ ** <dt>SQLITE_DBCONFIG_ENABLE_TRIGGER</dt>
1697
+ ** <dd> ^This option is used to enable or disable [CREATE TRIGGER | triggers].
1698
+ ** There should be two additional arguments.
1699
+ ** The first argument is an integer which is 0 to disable triggers,
1700
+ ** positive to enable triggers or negative to leave the setting unchanged.
1701
+ ** The second parameter is a pointer to an integer into which
1702
+ ** is written 0 or 1 to indicate whether triggers are disabled or enabled
1703
+ ** following this call. The second parameter may be a NULL pointer, in
1704
+ ** which case the trigger setting is not reported back. </dd>
1705
+ **
1468
1706
  ** </dl>
1469
1707
  */
1470
- #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1708
+ #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1709
+ #define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
1710
+ #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
1471
1711
 
1472
1712
 
1473
1713
  /*
@@ -1491,13 +1731,17 @@ SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1491
1731
  **
1492
1732
  ** ^This routine returns the [rowid] of the most recent
1493
1733
  ** successful [INSERT] into the database from the [database connection]
1494
- ** in the first argument. ^If no successful [INSERT]s
1734
+ ** in the first argument. ^As of SQLite version 3.7.7, this routines
1735
+ ** records the last insert rowid of both ordinary tables and [virtual tables].
1736
+ ** ^If no successful [INSERT]s
1495
1737
  ** have ever occurred on that database connection, zero is returned.
1496
1738
  **
1497
- ** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1498
- ** row is returned by this routine as long as the trigger is running.
1499
- ** But once the trigger terminates, the value returned by this routine
1500
- ** reverts to the last value inserted before the trigger fired.)^
1739
+ ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
1740
+ ** method, then this routine will return the [rowid] of the inserted
1741
+ ** row as long as the trigger or virtual table method is running.
1742
+ ** But once the trigger or virtual table method ends, the value returned
1743
+ ** by this routine reverts to what it was before the trigger or virtual
1744
+ ** table method began.)^
1501
1745
  **
1502
1746
  ** ^An [INSERT] that fails due to a constraint violation is not a
1503
1747
  ** successful [INSERT] and does not change the value returned by this
@@ -1886,7 +2130,7 @@ SQLITE_API void sqlite3_free_table(char **result);
1886
2130
  ** All of the usual printf() formatting options apply. In addition, there
1887
2131
  ** is are "%q", "%Q", and "%z" options.
1888
2132
  **
1889
- ** ^(The %q option works like %s in that it substitutes a null-terminated
2133
+ ** ^(The %q option works like %s in that it substitutes a nul-terminated
1890
2134
  ** string from the argument list. But %q also doubles every '\'' character.
1891
2135
  ** %q is designed for use inside a string literal.)^ By doubling each '\''
1892
2136
  ** character it escapes that character and allows it to be inserted into
@@ -1999,12 +2243,12 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
1999
2243
  ** implementation of these routines to be omitted. That capability
2000
2244
  ** is no longer provided. Only built-in memory allocators can be used.
2001
2245
  **
2002
- ** The Windows OS interface layer calls
2246
+ ** Prior to SQLite version 3.7.10, the Windows OS interface layer called
2003
2247
  ** the system malloc() and free() directly when converting
2004
2248
  ** filenames between the UTF-8 encoding used by SQLite
2005
2249
  ** and whatever filename encoding is used by the particular Windows
2006
- ** installation. Memory allocation errors are detected, but
2007
- ** they are reported back as [SQLITE_CANTOPEN] or
2250
+ ** installation. Memory allocation errors were detected, but
2251
+ ** they were reported back as [SQLITE_CANTOPEN] or
2008
2252
  ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
2009
2253
  **
2010
2254
  ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
@@ -2069,7 +2313,7 @@ SQLITE_API void sqlite3_randomness(int N, void *P);
2069
2313
  /*
2070
2314
  ** CAPI3REF: Compile-Time Authorization Callbacks
2071
2315
  **
2072
- ** ^This routine registers a authorizer callback with a particular
2316
+ ** ^This routine registers an authorizer callback with a particular
2073
2317
  ** [database connection], supplied in the first argument.
2074
2318
  ** ^The authorizer callback is invoked as SQL statements are being compiled
2075
2319
  ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2160,6 +2404,9 @@ SQLITE_API int sqlite3_set_authorizer(
2160
2404
  ** to signal SQLite whether or not the action is permitted. See the
2161
2405
  ** [sqlite3_set_authorizer | authorizer documentation] for additional
2162
2406
  ** information.
2407
+ **
2408
+ ** Note that SQLITE_IGNORE is also used as a [SQLITE_ROLLBACK | return code]
2409
+ ** from the [sqlite3_vtab_on_conflict()] interface.
2163
2410
  */
2164
2411
  #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
2165
2412
  #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
@@ -2282,7 +2529,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2282
2529
  /*
2283
2530
  ** CAPI3REF: Opening A New Database Connection
2284
2531
  **
2285
- ** ^These routines open an SQLite database file whose name is given by the
2532
+ ** ^These routines open an SQLite database file as specified by the
2286
2533
  ** filename argument. ^The filename argument is interpreted as UTF-8 for
2287
2534
  ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2288
2535
  ** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -2309,7 +2556,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2309
2556
  ** sqlite3_open_v2() can take one of
2310
2557
  ** the following three values, optionally combined with the
2311
2558
  ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2312
- ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
2559
+ ** [SQLITE_OPEN_PRIVATECACHE], and/or [SQLITE_OPEN_URI] flags:)^
2313
2560
  **
2314
2561
  ** <dl>
2315
2562
  ** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
@@ -2328,9 +2575,8 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2328
2575
  ** </dl>
2329
2576
  **
2330
2577
  ** If the 3rd parameter to sqlite3_open_v2() is not one of the
2331
- ** combinations shown above or one of the combinations shown above combined
2332
- ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
2333
- ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_PRIVATECACHE] flags,
2578
+ ** combinations shown above optionally combined with other
2579
+ ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
2334
2580
  ** then the behavior is undefined.
2335
2581
  **
2336
2582
  ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
@@ -2345,6 +2591,11 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2345
2591
  ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2346
2592
  ** participate in [shared cache mode] even if it is enabled.
2347
2593
  **
2594
+ ** ^The fourth parameter to sqlite3_open_v2() is the name of the
2595
+ ** [sqlite3_vfs] object that defines the operating system interface that
2596
+ ** the new database connection should use. ^If the fourth parameter is
2597
+ ** a NULL pointer then the default [sqlite3_vfs] object is used.
2598
+ **
2348
2599
  ** ^If the filename is ":memory:", then a private, temporary in-memory database
2349
2600
  ** is created for the connection. ^This in-memory database will vanish when
2350
2601
  ** the database connection is closed. Future versions of SQLite might
@@ -2357,16 +2608,125 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2357
2608
  ** on-disk database will be created. ^This private database will be
2358
2609
  ** automatically deleted as soon as the database connection is closed.
2359
2610
  **
2360
- ** ^The fourth parameter to sqlite3_open_v2() is the name of the
2361
- ** [sqlite3_vfs] object that defines the operating system interface that
2362
- ** the new database connection should use. ^If the fourth parameter is
2363
- ** a NULL pointer then the default [sqlite3_vfs] object is used.
2611
+ ** [[URI filenames in sqlite3_open()]] <h3>URI Filenames</h3>
2612
+ **
2613
+ ** ^If [URI filename] interpretation is enabled, and the filename argument
2614
+ ** begins with "file:", then the filename is interpreted as a URI. ^URI
2615
+ ** filename interpretation is enabled if the [SQLITE_OPEN_URI] flag is
2616
+ ** set in the fourth argument to sqlite3_open_v2(), or if it has
2617
+ ** been enabled globally using the [SQLITE_CONFIG_URI] option with the
2618
+ ** [sqlite3_config()] method or by the [SQLITE_USE_URI] compile-time option.
2619
+ ** As of SQLite version 3.7.7, URI filename interpretation is turned off
2620
+ ** by default, but future releases of SQLite might enable URI filename
2621
+ ** interpretation by default. See "[URI filenames]" for additional
2622
+ ** information.
2623
+ **
2624
+ ** URI filenames are parsed according to RFC 3986. ^If the URI contains an
2625
+ ** authority, then it must be either an empty string or the string
2626
+ ** "localhost". ^If the authority is not an empty string or "localhost", an
2627
+ ** error is returned to the caller. ^The fragment component of a URI, if
2628
+ ** present, is ignored.
2629
+ **
2630
+ ** ^SQLite uses the path component of the URI as the name of the disk file
2631
+ ** which contains the database. ^If the path begins with a '/' character,
2632
+ ** then it is interpreted as an absolute path. ^If the path does not begin
2633
+ ** with a '/' (meaning that the authority section is omitted from the URI)
2634
+ ** then the path is interpreted as a relative path.
2635
+ ** ^On windows, the first component of an absolute path
2636
+ ** is a drive specification (e.g. "C:").
2637
+ **
2638
+ ** [[core URI query parameters]]
2639
+ ** The query component of a URI may contain parameters that are interpreted
2640
+ ** either by SQLite itself, or by a [VFS | custom VFS implementation].
2641
+ ** SQLite interprets the following three query parameters:
2642
+ **
2643
+ ** <ul>
2644
+ ** <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
2645
+ ** a VFS object that provides the operating system interface that should
2646
+ ** be used to access the database file on disk. ^If this option is set to
2647
+ ** an empty string the default VFS object is used. ^Specifying an unknown
2648
+ ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is
2649
+ ** present, then the VFS specified by the option takes precedence over
2650
+ ** the value passed as the fourth parameter to sqlite3_open_v2().
2651
+ **
2652
+ ** <li> <b>mode</b>: ^(The mode parameter may be set to either "ro", "rw",
2653
+ ** "rwc", or "memory". Attempting to set it to any other value is
2654
+ ** an error)^.
2655
+ ** ^If "ro" is specified, then the database is opened for read-only
2656
+ ** access, just as if the [SQLITE_OPEN_READONLY] flag had been set in the
2657
+ ** third argument to sqlite3_open_v2(). ^If the mode option is set to
2658
+ ** "rw", then the database is opened for read-write (but not create)
2659
+ ** access, as if SQLITE_OPEN_READWRITE (but not SQLITE_OPEN_CREATE) had
2660
+ ** been set. ^Value "rwc" is equivalent to setting both
2661
+ ** SQLITE_OPEN_READWRITE and SQLITE_OPEN_CREATE. ^If the mode option is
2662
+ ** set to "memory" then a pure [in-memory database] that never reads
2663
+ ** or writes from disk is used. ^It is an error to specify a value for
2664
+ ** the mode parameter that is less restrictive than that specified by
2665
+ ** the flags passed in the third parameter to sqlite3_open_v2().
2666
+ **
2667
+ ** <li> <b>cache</b>: ^The cache parameter may be set to either "shared" or
2668
+ ** "private". ^Setting it to "shared" is equivalent to setting the
2669
+ ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
2670
+ ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is
2671
+ ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
2672
+ ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in
2673
+ ** a URI filename, its value overrides any behaviour requested by setting
2674
+ ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
2675
+ ** </ul>
2676
+ **
2677
+ ** ^Specifying an unknown parameter in the query component of a URI is not an
2678
+ ** error. Future versions of SQLite might understand additional query
2679
+ ** parameters. See "[query parameters with special meaning to SQLite]" for
2680
+ ** additional information.
2681
+ **
2682
+ ** [[URI filename examples]] <h3>URI filename examples</h3>
2683
+ **
2684
+ ** <table border="1" align=center cellpadding=5>
2685
+ ** <tr><th> URI filenames <th> Results
2686
+ ** <tr><td> file:data.db <td>
2687
+ ** Open the file "data.db" in the current directory.
2688
+ ** <tr><td> file:/home/fred/data.db<br>
2689
+ ** file:///home/fred/data.db <br>
2690
+ ** file://localhost/home/fred/data.db <br> <td>
2691
+ ** Open the database file "/home/fred/data.db".
2692
+ ** <tr><td> file://darkstar/home/fred/data.db <td>
2693
+ ** An error. "darkstar" is not a recognized authority.
2694
+ ** <tr><td style="white-space:nowrap">
2695
+ ** file:///C:/Documents%20and%20Settings/fred/Desktop/data.db
2696
+ ** <td> Windows only: Open the file "data.db" on fred's desktop on drive
2697
+ ** C:. Note that the %20 escaping in this example is not strictly
2698
+ ** necessary - space characters can be used literally
2699
+ ** in URI filenames.
2700
+ ** <tr><td> file:data.db?mode=ro&cache=private <td>
2701
+ ** Open file "data.db" in the current directory for read-only access.
2702
+ ** Regardless of whether or not shared-cache mode is enabled by
2703
+ ** default, use a private cache.
2704
+ ** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td>
2705
+ ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock".
2706
+ ** <tr><td> file:data.db?mode=readonly <td>
2707
+ ** An error. "readonly" is not a valid option for the "mode" parameter.
2708
+ ** </table>
2709
+ **
2710
+ ** ^URI hexadecimal escape sequences (%HH) are supported within the path and
2711
+ ** query components of a URI. A hexadecimal escape sequence consists of a
2712
+ ** percent sign - "%" - followed by exactly two hexadecimal digits
2713
+ ** specifying an octet value. ^Before the path or query components of a
2714
+ ** URI filename are interpreted, they are encoded using UTF-8 and all
2715
+ ** hexadecimal escape sequences replaced by a single byte containing the
2716
+ ** corresponding octet. If this process generates an invalid UTF-8 encoding,
2717
+ ** the results are undefined.
2364
2718
  **
2365
2719
  ** <b>Note to Windows users:</b> The encoding used for the filename argument
2366
2720
  ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2367
2721
  ** codepage is currently defined. Filenames containing international
2368
2722
  ** characters must be converted to UTF-8 prior to passing them into
2369
2723
  ** sqlite3_open() or sqlite3_open_v2().
2724
+ **
2725
+ ** <b>Note to Windows Runtime users:</b> The temporary directory must be set
2726
+ ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
2727
+ ** features that require the use of temporary files may fail.
2728
+ **
2729
+ ** See also: [sqlite3_temp_directory]
2370
2730
  */
2371
2731
  SQLITE_API int sqlite3_open(
2372
2732
  const char *filename, /* Database filename (UTF-8) */
@@ -2383,6 +2743,50 @@ SQLITE_API int sqlite3_open_v2(
2383
2743
  const char *zVfs /* Name of VFS module to use */
2384
2744
  );
2385
2745
 
2746
+ /*
2747
+ ** CAPI3REF: Obtain Values For URI Parameters
2748
+ **
2749
+ ** These are utility routines, useful to VFS implementations, that check
2750
+ ** to see if a database file was a URI that contained a specific query
2751
+ ** parameter, and if so obtains the value of that query parameter.
2752
+ **
2753
+ ** If F is the database filename pointer passed into the xOpen() method of
2754
+ ** a VFS implementation when the flags parameter to xOpen() has one or
2755
+ ** more of the [SQLITE_OPEN_URI] or [SQLITE_OPEN_MAIN_DB] bits set and
2756
+ ** P is the name of the query parameter, then
2757
+ ** sqlite3_uri_parameter(F,P) returns the value of the P
2758
+ ** parameter if it exists or a NULL pointer if P does not appear as a
2759
+ ** query parameter on F. If P is a query parameter of F
2760
+ ** has no explicit value, then sqlite3_uri_parameter(F,P) returns
2761
+ ** a pointer to an empty string.
2762
+ **
2763
+ ** The sqlite3_uri_boolean(F,P,B) routine assumes that P is a boolean
2764
+ ** parameter and returns true (1) or false (0) according to the value
2765
+ ** of P. The sqlite3_uri_boolean(F,P,B) routine returns true (1) if the
2766
+ ** value of query parameter P is one of "yes", "true", or "on" in any
2767
+ ** case or if the value begins with a non-zero number. The
2768
+ ** sqlite3_uri_boolean(F,P,B) routines returns false (0) if the value of
2769
+ ** query parameter P is one of "no", "false", or "off" in any case or
2770
+ ** if the value begins with a numeric zero. If P is not a query
2771
+ ** parameter on F or if the value of P is does not match any of the
2772
+ ** above, then sqlite3_uri_boolean(F,P,B) returns (B!=0).
2773
+ **
2774
+ ** The sqlite3_uri_int64(F,P,D) routine converts the value of P into a
2775
+ ** 64-bit signed integer and returns that integer, or D if P does not
2776
+ ** exist. If the value of P is something other than an integer, then
2777
+ ** zero is returned.
2778
+ **
2779
+ ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
2780
+ ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
2781
+ ** is not a database file pathname pointer that SQLite passed into the xOpen
2782
+ ** VFS method, then the behavior of this routine is undefined and probably
2783
+ ** undesirable.
2784
+ */
2785
+ SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
2786
+ SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
2787
+ SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
2788
+
2789
+
2386
2790
  /*
2387
2791
  ** CAPI3REF: Error Codes And Messages
2388
2792
  **
@@ -2402,6 +2806,11 @@ SQLITE_API int sqlite3_open_v2(
2402
2806
  ** However, the error string might be overwritten or deallocated by
2403
2807
  ** subsequent calls to other SQLite interface functions.)^
2404
2808
  **
2809
+ ** ^The sqlite3_errstr() interface returns the English-language text
2810
+ ** that describes the [result code], as UTF-8.
2811
+ ** ^(Memory to hold the error message string is managed internally
2812
+ ** and must not be freed by the application)^.
2813
+ **
2405
2814
  ** When the serialized [threading mode] is in use, it might be the
2406
2815
  ** case that a second error occurs on a separate thread in between
2407
2816
  ** the time of the first error and the call to these interfaces.
@@ -2420,6 +2829,7 @@ SQLITE_API int sqlite3_errcode(sqlite3 *db);
2420
2829
  SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
2421
2830
  SQLITE_API const char *sqlite3_errmsg(sqlite3*);
2422
2831
  SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
2832
+ SQLITE_API const char *sqlite3_errstr(int);
2423
2833
 
2424
2834
  /*
2425
2835
  ** CAPI3REF: SQL Statement Object
@@ -2498,43 +2908,45 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2498
2908
  ** Additional information is available at [limits | Limits in SQLite].
2499
2909
  **
2500
2910
  ** <dl>
2501
- ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2911
+ ** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2502
2912
  ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^
2503
2913
  **
2504
- ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2914
+ ** [[SQLITE_LIMIT_SQL_LENGTH]] ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2505
2915
  ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
2506
2916
  **
2507
- ** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
2917
+ ** [[SQLITE_LIMIT_COLUMN]] ^(<dt>SQLITE_LIMIT_COLUMN</dt>
2508
2918
  ** <dd>The maximum number of columns in a table definition or in the
2509
2919
  ** result set of a [SELECT] or the maximum number of columns in an index
2510
2920
  ** or in an ORDER BY or GROUP BY clause.</dd>)^
2511
2921
  **
2512
- ** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2922
+ ** [[SQLITE_LIMIT_EXPR_DEPTH]] ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2513
2923
  ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
2514
2924
  **
2515
- ** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2925
+ ** [[SQLITE_LIMIT_COMPOUND_SELECT]] ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2516
2926
  ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
2517
2927
  **
2518
- ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
2928
+ ** [[SQLITE_LIMIT_VDBE_OP]] ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
2519
2929
  ** <dd>The maximum number of instructions in a virtual machine program
2520
2930
  ** used to implement an SQL statement. This limit is not currently
2521
2931
  ** enforced, though that might be added in some future release of
2522
2932
  ** SQLite.</dd>)^
2523
2933
  **
2524
- ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2934
+ ** [[SQLITE_LIMIT_FUNCTION_ARG]] ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2525
2935
  ** <dd>The maximum number of arguments on a function.</dd>)^
2526
2936
  **
2527
- ** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2937
+ ** [[SQLITE_LIMIT_ATTACHED]] ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2528
2938
  ** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
2529
2939
  **
2940
+ ** [[SQLITE_LIMIT_LIKE_PATTERN_LENGTH]]
2530
2941
  ** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2531
2942
  ** <dd>The maximum length of the pattern argument to the [LIKE] or
2532
2943
  ** [GLOB] operators.</dd>)^
2533
2944
  **
2945
+ ** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
2534
2946
  ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2535
2947
  ** <dd>The maximum index number of any [parameter] in an SQL statement.)^
2536
2948
  **
2537
- ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2949
+ ** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2538
2950
  ** <dd>The maximum depth of recursion for triggers.</dd>)^
2539
2951
  ** </dl>
2540
2952
  */
@@ -2574,7 +2986,8 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2574
2986
  ** that the supplied string is nul-terminated, then there is a small
2575
2987
  ** performance advantage to be gained by passing an nByte parameter that
2576
2988
  ** is equal to the number of bytes in the input string <i>including</i>
2577
- ** the nul-terminator bytes.
2989
+ ** the nul-terminator bytes as this saves SQLite from having to
2990
+ ** make a copy of the input string.
2578
2991
  **
2579
2992
  ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
2580
2993
  ** past the end of the first SQL statement in zSql. These routines only
@@ -2625,7 +3038,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2625
3038
  ** ^The specific value of WHERE-clause [parameter] might influence the
2626
3039
  ** choice of query plan if the parameter is the left-hand side of a [LIKE]
2627
3040
  ** or [GLOB] operator or if the parameter is compared to an indexed column
2628
- ** and the [SQLITE_ENABLE_STAT2] compile-time option is enabled.
3041
+ ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
2629
3042
  ** the
2630
3043
  ** </li>
2631
3044
  ** </ol>
@@ -2671,7 +3084,7 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
2671
3084
  /*
2672
3085
  ** CAPI3REF: Determine If An SQL Statement Writes The Database
2673
3086
  **
2674
- ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3087
+ ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
2675
3088
  ** and only if the [prepared statement] X makes no direct changes to
2676
3089
  ** the content of the database file.
2677
3090
  **
@@ -2699,6 +3112,25 @@ SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
2699
3112
  */
2700
3113
  SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
2701
3114
 
3115
+ /*
3116
+ ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3117
+ **
3118
+ ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3119
+ ** [prepared statement] S has been stepped at least once using
3120
+ ** [sqlite3_step(S)] but has not run to completion and/or has not
3121
+ ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
3122
+ ** interface returns false if S is a NULL pointer. If S is not a
3123
+ ** NULL pointer and is not a pointer to a valid [prepared statement]
3124
+ ** object, then the behavior is undefined and probably undesirable.
3125
+ **
3126
+ ** This interface can be used in combination [sqlite3_next_stmt()]
3127
+ ** to locate all prepared statements associated with a database
3128
+ ** connection that are in need of being reset. This can be used,
3129
+ ** for example, in diagnostic routines to search for prepared
3130
+ ** statements that are holding a transaction open.
3131
+ */
3132
+ SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3133
+
2702
3134
  /*
2703
3135
  ** CAPI3REF: Dynamically Typed Value Object
2704
3136
  ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
@@ -2715,7 +3147,7 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
2715
3147
  ** whether or not it requires a protected sqlite3_value.
2716
3148
  **
2717
3149
  ** The terms "protected" and "unprotected" refer to whether or not
2718
- ** a mutex is held. A internal mutex is held for a protected
3150
+ ** a mutex is held. An internal mutex is held for a protected
2719
3151
  ** sqlite3_value object but no mutex is held for an unprotected
2720
3152
  ** sqlite3_value object. If SQLite is compiled to be single-threaded
2721
3153
  ** (with [SQLITE_THREADSAFE=0] and with [sqlite3_threadsafe()] returning 0)
@@ -2793,8 +3225,18 @@ typedef struct sqlite3_context sqlite3_context;
2793
3225
  ** ^(In those routines that have a fourth argument, its value is the
2794
3226
  ** number of bytes in the parameter. To be clear: the value is the
2795
3227
  ** number of <u>bytes</u> in the value, not the number of characters.)^
2796
- ** ^If the fourth parameter is negative, the length of the string is
3228
+ ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
3229
+ ** is negative, then the length of the string is
2797
3230
  ** the number of bytes up to the first zero terminator.
3231
+ ** If the fourth parameter to sqlite3_bind_blob() is negative, then
3232
+ ** the behavior is undefined.
3233
+ ** If a non-negative fourth parameter is provided to sqlite3_bind_text()
3234
+ ** or sqlite3_bind_text16() then that parameter must be the byte offset
3235
+ ** where the NUL terminator would occur assuming the string were NUL
3236
+ ** terminated. If any NUL characters occur at byte offsets less than
3237
+ ** the value of the fourth parameter then the resulting string value will
3238
+ ** contain embedded NULs. The result of expressions involving strings
3239
+ ** with embedded NULs is undefined.
2798
3240
  **
2799
3241
  ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
2800
3242
  ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
@@ -2939,7 +3381,9 @@ SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
2939
3381
  ** column number. ^The leftmost column is number 0.
2940
3382
  **
2941
3383
  ** ^The returned string pointer is valid until either the [prepared statement]
2942
- ** is destroyed by [sqlite3_finalize()] or until the next call to
3384
+ ** is destroyed by [sqlite3_finalize()] or until the statement is automatically
3385
+ ** reprepared by the first call to [sqlite3_step()] for a particular run
3386
+ ** or until the next call to
2943
3387
  ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
2944
3388
  **
2945
3389
  ** ^If sqlite3_malloc() fails during the processing of either routine
@@ -2965,7 +3409,9 @@ SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
2965
3409
  ** the database name, the _table_ routines return the table name, and
2966
3410
  ** the origin_ routines return the column name.
2967
3411
  ** ^The returned string is valid until the [prepared statement] is destroyed
2968
- ** using [sqlite3_finalize()] or until the same information is requested
3412
+ ** using [sqlite3_finalize()] or until the statement is automatically
3413
+ ** reprepared by the first call to [sqlite3_step()] for a particular run
3414
+ ** or until the same information is requested
2969
3415
  ** again in a different encoding.
2970
3416
  **
2971
3417
  ** ^The names returned are the original un-aliased names of the
@@ -3059,7 +3505,7 @@ SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3059
3505
  ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3060
3506
  ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3061
3507
  ** or occurs outside of an explicit transaction, then you can retry the
3062
- ** statement. If the statement is not a [COMMIT] and occurs within a
3508
+ ** statement. If the statement is not a [COMMIT] and occurs within an
3063
3509
  ** explicit transaction then you should rollback the transaction before
3064
3510
  ** continuing.
3065
3511
  **
@@ -3124,6 +3570,12 @@ SQLITE_API int sqlite3_step(sqlite3_stmt*);
3124
3570
  ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
3125
3571
  ** interfaces) then sqlite3_data_count(P) returns 0.
3126
3572
  ** ^The sqlite3_data_count(P) routine also returns 0 if P is a NULL pointer.
3573
+ ** ^The sqlite3_data_count(P) routine returns 0 if the previous call to
3574
+ ** [sqlite3_step](P) returned [SQLITE_DONE]. ^The sqlite3_data_count(P)
3575
+ ** will return non-zero if previous call to [sqlite3_step](P) returned
3576
+ ** [SQLITE_ROW], except in the case of the [PRAGMA incremental_vacuum]
3577
+ ** where it always returns zero since each step of that multi-step
3578
+ ** pragma returns 0 columns of data.
3127
3579
  **
3128
3580
  ** See also: [sqlite3_column_count()]
3129
3581
  */
@@ -3223,7 +3675,7 @@ SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3223
3675
  ** bytes in the string, not the number of characters.
3224
3676
  **
3225
3677
  ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3226
- ** even empty strings, are always zero terminated. ^The return
3678
+ ** even empty strings, are always zero-terminated. ^The return
3227
3679
  ** value from sqlite3_column_blob() for a zero-length BLOB is a NULL pointer.
3228
3680
  **
3229
3681
  ** ^The object returned by [sqlite3_column_value()] is an
@@ -3338,7 +3790,7 @@ SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3338
3790
  ** CAPI3REF: Destroy A Prepared Statement Object
3339
3791
  **
3340
3792
  ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3341
- ** ^If the most recent evaluation of the statement encountered no errors or
3793
+ ** ^If the most recent evaluation of the statement encountered no errors
3342
3794
  ** or if the statement is never been evaluated, then sqlite3_finalize() returns
3343
3795
  ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
3344
3796
  ** sqlite3_finalize(S) returns the appropriate [error code] or
@@ -3397,7 +3849,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3397
3849
  ** are used to add SQL functions or aggregates or to redefine the behavior
3398
3850
  ** of existing SQL functions or aggregates. The only differences between
3399
3851
  ** these routines are the text encoding expected for
3400
- ** the the second parameter (the name of the function being created)
3852
+ ** the second parameter (the name of the function being created)
3401
3853
  ** and the presence or absence of a destructor callback for
3402
3854
  ** the application data pointer.
3403
3855
  **
@@ -3442,7 +3894,7 @@ SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3442
3894
  ** callback only; NULL pointers must be passed as the xStep and xFinal
3443
3895
  ** parameters. ^An aggregate SQL function requires an implementation of xStep
3444
3896
  ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
3445
- ** SQL function or aggregate, pass NULL poiners for all three function
3897
+ ** SQL function or aggregate, pass NULL pointers for all three function
3446
3898
  ** callbacks.
3447
3899
  **
3448
3900
  ** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
@@ -3774,11 +4226,11 @@ typedef void (*sqlite3_destructor_type)(void*);
3774
4226
  ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
3775
4227
  ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
3776
4228
  **
3777
- ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
3778
- ** indicating that a string or BLOB is too long to represent.
4229
+ ** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an
4230
+ ** error indicating that a string or BLOB is too long to represent.
3779
4231
  **
3780
- ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
3781
- ** indicating that a memory allocation failed.
4232
+ ** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an
4233
+ ** error indicating that a memory allocation failed.
3782
4234
  **
3783
4235
  ** ^The sqlite3_result_int() interface sets the return value
3784
4236
  ** of the application-defined function to be the 32-bit signed integer
@@ -3803,7 +4255,12 @@ typedef void (*sqlite3_destructor_type)(void*);
3803
4255
  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
3804
4256
  ** is non-negative, then as many bytes (not characters) of the text
3805
4257
  ** pointed to by the 2nd parameter are taken as the application-defined
3806
- ** function result.
4258
+ ** function result. If the 3rd parameter is non-negative, then it
4259
+ ** must be the byte offset into the string where the NUL terminator would
4260
+ ** appear if the string where NUL terminated. If any NUL characters occur
4261
+ ** in the string at a byte offset that is less than the value of the 3rd
4262
+ ** parameter, then the resulting string will contain embedded NULs and the
4263
+ ** result of expressions operating on strings with embedded NULs is undefined.
3807
4264
  ** ^If the 4th parameter to the sqlite3_result_text* interfaces
3808
4265
  ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
3809
4266
  ** function as the destructor on the text or BLOB result when it has
@@ -3876,7 +4333,7 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
3876
4333
  ** ^The [SQLITE_UTF16_ALIGNED] value for eTextRep forces strings to begin
3877
4334
  ** on an even byte address.
3878
4335
  **
3879
- ** ^The fourth argument, pArg, is a application data pointer that is passed
4336
+ ** ^The fourth argument, pArg, is an application data pointer that is passed
3880
4337
  ** through as the first argument to the collating function callback.
3881
4338
  **
3882
4339
  ** ^The fifth argument, xCallback, is a pointer to the collating function.
@@ -3892,7 +4349,7 @@ SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
3892
4349
  ** by the eTextRep argument. The collating function must return an
3893
4350
  ** integer that is negative, zero, or positive
3894
4351
  ** if the first string is less than, equal to, or greater than the second,
3895
- ** respectively. A collating function must alway return the same answer
4352
+ ** respectively. A collating function must always return the same answer
3896
4353
  ** given the same inputs. If two or more collating functions are registered
3897
4354
  ** to the same collation name (using different eTextRep values) then all
3898
4355
  ** must give an equivalent answer when invoked with equivalent strings.
@@ -4080,9 +4537,61 @@ SQLITE_API int sqlite3_sleep(int);
4080
4537
  ** Hence, if this variable is modified directly, either it should be
4081
4538
  ** made NULL or made to point to memory obtained from [sqlite3_malloc]
4082
4539
  ** or else the use of the [temp_store_directory pragma] should be avoided.
4540
+ **
4541
+ ** <b>Note to Windows Runtime users:</b> The temporary directory must be set
4542
+ ** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various
4543
+ ** features that require the use of temporary files may fail. Here is an
4544
+ ** example of how to do this using C++ with the Windows Runtime:
4545
+ **
4546
+ ** <blockquote><pre>
4547
+ ** LPCWSTR zPath = Windows::Storage::ApplicationData::Current->
4548
+ ** &nbsp; TemporaryFolder->Path->Data();
4549
+ ** char zPathBuf&#91;MAX_PATH + 1&#93;;
4550
+ ** memset(zPathBuf, 0, sizeof(zPathBuf));
4551
+ ** WideCharToMultiByte(CP_UTF8, 0, zPath, -1, zPathBuf, sizeof(zPathBuf),
4552
+ ** &nbsp; NULL, NULL);
4553
+ ** sqlite3_temp_directory = sqlite3_mprintf("%s", zPathBuf);
4554
+ ** </pre></blockquote>
4083
4555
  */
4084
4556
  SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
4085
4557
 
4558
+ /*
4559
+ ** CAPI3REF: Name Of The Folder Holding Database Files
4560
+ **
4561
+ ** ^(If this global variable is made to point to a string which is
4562
+ ** the name of a folder (a.k.a. directory), then all database files
4563
+ ** specified with a relative pathname and created or accessed by
4564
+ ** SQLite when using a built-in windows [sqlite3_vfs | VFS] will be assumed
4565
+ ** to be relative to that directory.)^ ^If this variable is a NULL
4566
+ ** pointer, then SQLite assumes that all database files specified
4567
+ ** with a relative pathname are relative to the current directory
4568
+ ** for the process. Only the windows VFS makes use of this global
4569
+ ** variable; it is ignored by the unix VFS.
4570
+ **
4571
+ ** Changing the value of this variable while a database connection is
4572
+ ** open can result in a corrupt database.
4573
+ **
4574
+ ** It is not safe to read or modify this variable in more than one
4575
+ ** thread at a time. It is not safe to read or modify this variable
4576
+ ** if a [database connection] is being used at the same time in a separate
4577
+ ** thread.
4578
+ ** It is intended that this variable be set once
4579
+ ** as part of process initialization and before any SQLite interface
4580
+ ** routines have been called and that this variable remain unchanged
4581
+ ** thereafter.
4582
+ **
4583
+ ** ^The [data_store_directory pragma] may modify this variable and cause
4584
+ ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
4585
+ ** the [data_store_directory pragma] always assumes that any string
4586
+ ** that this variable points to is held in memory obtained from
4587
+ ** [sqlite3_malloc] and the pragma may attempt to free that memory
4588
+ ** using [sqlite3_free].
4589
+ ** Hence, if this variable is modified directly, either it should be
4590
+ ** made NULL or made to point to memory obtained from [sqlite3_malloc]
4591
+ ** or else the use of the [data_store_directory pragma] should be avoided.
4592
+ */
4593
+ SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
4594
+
4086
4595
  /*
4087
4596
  ** CAPI3REF: Test For Auto-Commit Mode
4088
4597
  ** KEYWORDS: {autocommit mode}
@@ -4118,6 +4627,31 @@ SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4118
4627
  */
4119
4628
  SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4120
4629
 
4630
+ /*
4631
+ ** CAPI3REF: Return The Filename For A Database Connection
4632
+ **
4633
+ ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
4634
+ ** associated with database N of connection D. ^The main database file
4635
+ ** has the name "main". If there is no attached database N on the database
4636
+ ** connection D, or if database N is a temporary or in-memory database, then
4637
+ ** a NULL pointer is returned.
4638
+ **
4639
+ ** ^The filename returned by this function is the output of the
4640
+ ** xFullPathname method of the [VFS]. ^In other words, the filename
4641
+ ** will be an absolute pathname, even if the filename used
4642
+ ** to open the database originally was a URI or relative pathname.
4643
+ */
4644
+ SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4645
+
4646
+ /*
4647
+ ** CAPI3REF: Determine if a database is read-only
4648
+ **
4649
+ ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
4650
+ ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
4651
+ ** the name of a database on connection D.
4652
+ */
4653
+ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4654
+
4121
4655
  /*
4122
4656
  ** CAPI3REF: Find the next prepared statement
4123
4657
  **
@@ -4153,13 +4687,15 @@ SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4153
4687
  ** on the same [database connection] D, or NULL for
4154
4688
  ** the first call for each function on D.
4155
4689
  **
4690
+ ** The commit and rollback hook callbacks are not reentrant.
4156
4691
  ** The callback implementation must not do anything that will modify
4157
4692
  ** the database connection that invoked the callback. Any actions
4158
4693
  ** to modify the database connection must be deferred until after the
4159
4694
  ** completion of the [sqlite3_step()] call that triggered the commit
4160
4695
  ** or rollback hook in the first place.
4161
- ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4162
- ** database connections for the meaning of "modify" in this paragraph.
4696
+ ** Note that running any other SQL statements, including SELECT statements,
4697
+ ** or merely calling [sqlite3_prepare_v2()] and [sqlite3_step()] will modify
4698
+ ** the database connections for the meaning of "modify" in this paragraph.
4163
4699
  **
4164
4700
  ** ^Registering a NULL function disables the callback.
4165
4701
  **
@@ -4234,7 +4770,6 @@ SQLITE_API void *sqlite3_update_hook(
4234
4770
 
4235
4771
  /*
4236
4772
  ** CAPI3REF: Enable Or Disable Shared Pager Cache
4237
- ** KEYWORDS: {shared cache}
4238
4773
  **
4239
4774
  ** ^(This routine enables or disables the sharing of the database cache
4240
4775
  ** and schema data structures between [database connection | connections]
@@ -4257,6 +4792,9 @@ SQLITE_API void *sqlite3_update_hook(
4257
4792
  ** future releases of SQLite. Applications that care about shared
4258
4793
  ** cache setting should set it explicitly.
4259
4794
  **
4795
+ ** This interface is threadsafe on processors where writing a
4796
+ ** 32-bit integer is atomic.
4797
+ **
4260
4798
  ** See Also: [SQLite Shared-Cache Mode]
4261
4799
  */
4262
4800
  SQLITE_API int sqlite3_enable_shared_cache(int);
@@ -4272,9 +4810,24 @@ SQLITE_API int sqlite3_enable_shared_cache(int);
4272
4810
  ** which might be more or less than the amount requested.
4273
4811
  ** ^The sqlite3_release_memory() routine is a no-op returning zero
4274
4812
  ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
4813
+ **
4814
+ ** See also: [sqlite3_db_release_memory()]
4275
4815
  */
4276
4816
  SQLITE_API int sqlite3_release_memory(int);
4277
4817
 
4818
+ /*
4819
+ ** CAPI3REF: Free Memory Used By A Database Connection
4820
+ **
4821
+ ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
4822
+ ** memory as possible from database connection D. Unlike the
4823
+ ** [sqlite3_release_memory()] interface, this interface is effect even
4824
+ ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
4825
+ ** omitted.
4826
+ **
4827
+ ** See also: [sqlite3_release_memory()]
4828
+ */
4829
+ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
4830
+
4278
4831
  /*
4279
4832
  ** CAPI3REF: Impose A Limit On Heap Size
4280
4833
  **
@@ -4289,7 +4842,8 @@ SQLITE_API int sqlite3_release_memory(int);
4289
4842
  ** is advisory only.
4290
4843
  **
4291
4844
  ** ^The return value from sqlite3_soft_heap_limit64() is the size of
4292
- ** the soft heap limit prior to the call. ^If the argument N is negative
4845
+ ** the soft heap limit prior to the call, or negative in the case of an
4846
+ ** error. ^If the argument N is negative
4293
4847
  ** then no change is made to the soft heap limit. Hence, the current
4294
4848
  ** size of the soft heap limit can be determined by invoking
4295
4849
  ** sqlite3_soft_heap_limit64() with a negative argument.
@@ -4304,8 +4858,8 @@ SQLITE_API int sqlite3_release_memory(int);
4304
4858
  ** <li> Memory accounting is disabled using a combination of the
4305
4859
  ** [sqlite3_config]([SQLITE_CONFIG_MEMSTATUS],...) start-time option and
4306
4860
  ** the [SQLITE_DEFAULT_MEMSTATUS] compile-time option.
4307
- ** <li> An alternative page cache implementation is specifed using
4308
- ** [sqlite3_config]([SQLITE_CONFIG_PCACHE],...).
4861
+ ** <li> An alternative page cache implementation is specified using
4862
+ ** [sqlite3_config]([SQLITE_CONFIG_PCACHE2],...).
4309
4863
  ** <li> The page cache allocates from its own memory pool supplied
4310
4864
  ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than
4311
4865
  ** from the heap.
@@ -4525,7 +5079,7 @@ typedef struct sqlite3_module sqlite3_module;
4525
5079
  ** CAPI3REF: Virtual Table Object
4526
5080
  ** KEYWORDS: sqlite3_module {virtual table module}
4527
5081
  **
4528
- ** This structure, sometimes called a a "virtual table module",
5082
+ ** This structure, sometimes called a "virtual table module",
4529
5083
  ** defines the implementation of a [virtual tables].
4530
5084
  ** This structure consists mostly of methods for the module.
4531
5085
  **
@@ -4565,6 +5119,11 @@ struct sqlite3_module {
4565
5119
  void (**pxFunc)(sqlite3_context*,int,sqlite3_value**),
4566
5120
  void **ppArg);
4567
5121
  int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
5122
+ /* The methods above are in version 1 of the sqlite_module object. Those
5123
+ ** below are for version 2 and greater. */
5124
+ int (*xSavepoint)(sqlite3_vtab *pVTab, int);
5125
+ int (*xRelease)(sqlite3_vtab *pVTab, int);
5126
+ int (*xRollbackTo)(sqlite3_vtab *pVTab, int);
4568
5127
  };
4569
5128
 
4570
5129
  /*
@@ -4837,7 +5396,7 @@ typedef struct sqlite3_blob sqlite3_blob;
4837
5396
  ** This is true if any column of the row is changed, even a column
4838
5397
  ** other than the one the BLOB handle is open on.)^
4839
5398
  ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4840
- ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
5399
+ ** an expired BLOB handle fail with a return code of [SQLITE_ABORT].
4841
5400
  ** ^(Changes written into a BLOB prior to the BLOB expiring are not
4842
5401
  ** rolled back by the expiration of the BLOB. Such changes will eventually
4843
5402
  ** commit if the transaction continues to completion.)^
@@ -5041,17 +5600,16 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5041
5600
  ** implementations are available in the SQLite core:
5042
5601
  **
5043
5602
  ** <ul>
5044
- ** <li> SQLITE_MUTEX_OS2
5045
- ** <li> SQLITE_MUTEX_PTHREAD
5603
+ ** <li> SQLITE_MUTEX_PTHREADS
5046
5604
  ** <li> SQLITE_MUTEX_W32
5047
5605
  ** <li> SQLITE_MUTEX_NOOP
5048
5606
  ** </ul>)^
5049
5607
  **
5050
5608
  ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5051
5609
  ** that does no real locking and is appropriate for use in
5052
- ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5053
- ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5054
- ** are appropriate for use on OS/2, Unix, and Windows.
5610
+ ** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and
5611
+ ** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix
5612
+ ** and Windows.
5055
5613
  **
5056
5614
  ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5057
5615
  ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
@@ -5240,14 +5798,14 @@ struct sqlite3_mutex_methods {
5240
5798
  ** ^These routines should return true if the mutex in their argument
5241
5799
  ** is held or not held, respectively, by the calling thread.
5242
5800
  **
5243
- ** ^The implementation is not required to provided versions of these
5801
+ ** ^The implementation is not required to provide versions of these
5244
5802
  ** routines that actually work. If the implementation does not provide working
5245
5803
  ** versions of these routines, it should at least provide stubs that always
5246
5804
  ** return true so that one does not get spurious assertion failures.
5247
5805
  **
5248
5806
  ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
5249
5807
  ** the routine should return 1. This seems counter-intuitive since
5250
- ** clearly the mutex cannot be held if it does not exist. But the
5808
+ ** clearly the mutex cannot be held if it does not exist. But
5251
5809
  ** the reason the mutex does not exist is because the build is not
5252
5810
  ** using mutexes. And we do not want the assert() containing the
5253
5811
  ** call to sqlite3_mutex_held() to fail, so a non-zero return is
@@ -5368,9 +5926,10 @@ SQLITE_API int sqlite3_test_control(int op, ...);
5368
5926
  #define SQLITE_TESTCTRL_RESERVE 14
5369
5927
  #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
5370
5928
  #define SQLITE_TESTCTRL_ISKEYWORD 16
5371
- #define SQLITE_TESTCTRL_PGHDRSZ 17
5372
- #define SQLITE_TESTCTRL_SCRATCHMALLOC 18
5373
- #define SQLITE_TESTCTRL_LAST 18
5929
+ #define SQLITE_TESTCTRL_SCRATCHMALLOC 17
5930
+ #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
5931
+ #define SQLITE_TESTCTRL_EXPLAIN_STMT 19
5932
+ #define SQLITE_TESTCTRL_LAST 19
5374
5933
 
5375
5934
  /*
5376
5935
  ** CAPI3REF: SQLite Runtime Status
@@ -5379,7 +5938,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
5379
5938
  ** about the performance of SQLite, and optionally to reset various
5380
5939
  ** highwater marks. ^The first argument is an integer code for
5381
5940
  ** the specific parameter to measure. ^(Recognized integer codes
5382
- ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
5941
+ ** are of the form [status parameters | SQLITE_STATUS_...].)^
5383
5942
  ** ^The current value of the parameter is returned into *pCurrent.
5384
5943
  ** ^The highest recorded value is returned in *pHighwater. ^If the
5385
5944
  ** resetFlag is true, then the highest record value is reset after
@@ -5406,12 +5965,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5406
5965
 
5407
5966
  /*
5408
5967
  ** CAPI3REF: Status Parameters
5968
+ ** KEYWORDS: {status parameters}
5409
5969
  **
5410
5970
  ** These integer constants designate various run-time status parameters
5411
5971
  ** that can be returned by [sqlite3_status()].
5412
5972
  **
5413
5973
  ** <dl>
5414
- ** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
5974
+ ** [[SQLITE_STATUS_MEMORY_USED]] ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
5415
5975
  ** <dd>This parameter is the current amount of memory checked out
5416
5976
  ** using [sqlite3_malloc()], either directly or indirectly. The
5417
5977
  ** figure includes calls made to [sqlite3_malloc()] by the application
@@ -5421,23 +5981,24 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5421
5981
  ** this parameter. The amount returned is the sum of the allocation
5422
5982
  ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
5423
5983
  **
5424
- ** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5984
+ ** [[SQLITE_STATUS_MALLOC_SIZE]] ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5425
5985
  ** <dd>This parameter records the largest memory allocation request
5426
5986
  ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
5427
5987
  ** internal equivalents). Only the value returned in the
5428
5988
  ** *pHighwater parameter to [sqlite3_status()] is of interest.
5429
5989
  ** The value written into the *pCurrent parameter is undefined.</dd>)^
5430
5990
  **
5431
- ** ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
5991
+ ** [[SQLITE_STATUS_MALLOC_COUNT]] ^(<dt>SQLITE_STATUS_MALLOC_COUNT</dt>
5432
5992
  ** <dd>This parameter records the number of separate memory allocations
5433
5993
  ** currently checked out.</dd>)^
5434
5994
  **
5435
- ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5995
+ ** [[SQLITE_STATUS_PAGECACHE_USED]] ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5436
5996
  ** <dd>This parameter returns the number of pages used out of the
5437
5997
  ** [pagecache memory allocator] that was configured using
5438
5998
  ** [SQLITE_CONFIG_PAGECACHE]. The
5439
5999
  ** value returned is in pages, not in bytes.</dd>)^
5440
6000
  **
6001
+ ** [[SQLITE_STATUS_PAGECACHE_OVERFLOW]]
5441
6002
  ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5442
6003
  ** <dd>This parameter returns the number of bytes of page cache
5443
6004
  ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE]
@@ -5447,13 +6008,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5447
6008
  ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5448
6009
  ** no space was left in the page cache.</dd>)^
5449
6010
  **
5450
- ** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
6011
+ ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5451
6012
  ** <dd>This parameter records the largest memory allocation request
5452
6013
  ** handed to [pagecache memory allocator]. Only the value returned in the
5453
6014
  ** *pHighwater parameter to [sqlite3_status()] is of interest.
5454
6015
  ** The value written into the *pCurrent parameter is undefined.</dd>)^
5455
6016
  **
5456
- ** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
6017
+ ** [[SQLITE_STATUS_SCRATCH_USED]] ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
5457
6018
  ** <dd>This parameter returns the number of allocations used out of the
5458
6019
  ** [scratch memory allocator] configured using
5459
6020
  ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
@@ -5461,7 +6022,7 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5461
6022
  ** outstanding at time, this parameter also reports the number of threads
5462
6023
  ** using scratch memory at the same time.</dd>)^
5463
6024
  **
5464
- ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
6025
+ ** [[SQLITE_STATUS_SCRATCH_OVERFLOW]] ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5465
6026
  ** <dd>This parameter returns the number of bytes of scratch memory
5466
6027
  ** allocation which could not be satisfied by the [SQLITE_CONFIG_SCRATCH]
5467
6028
  ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
@@ -5471,13 +6032,13 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5471
6032
  ** slots were available.
5472
6033
  ** </dd>)^
5473
6034
  **
5474
- ** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
6035
+ ** [[SQLITE_STATUS_SCRATCH_SIZE]] ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5475
6036
  ** <dd>This parameter records the largest memory allocation request
5476
6037
  ** handed to [scratch memory allocator]. Only the value returned in the
5477
6038
  ** *pHighwater parameter to [sqlite3_status()] is of interest.
5478
6039
  ** The value written into the *pCurrent parameter is undefined.</dd>)^
5479
6040
  **
5480
- ** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
6041
+ ** [[SQLITE_STATUS_PARSER_STACK]] ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
5481
6042
  ** <dd>This parameter records the deepest parser stack. It is only
5482
6043
  ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
5483
6044
  ** </dl>
@@ -5502,9 +6063,9 @@ SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetF
5502
6063
  ** about a single [database connection]. ^The first argument is the
5503
6064
  ** database connection object to be interrogated. ^The second argument
5504
6065
  ** is an integer constant, taken from the set of
5505
- ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros, that
6066
+ ** [SQLITE_DBSTATUS options], that
5506
6067
  ** determines the parameter to interrogate. The set of
5507
- ** [SQLITE_DBSTATUS_LOOKASIDE_USED | SQLITE_DBSTATUS_*] macros is likely
6068
+ ** [SQLITE_DBSTATUS options] is likely
5508
6069
  ** to grow in future releases of SQLite.
5509
6070
  **
5510
6071
  ** ^The current value of the requested parameter is written into *pCur
@@ -5521,6 +6082,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
5521
6082
 
5522
6083
  /*
5523
6084
  ** CAPI3REF: Status Parameters for database connections
6085
+ ** KEYWORDS: {SQLITE_DBSTATUS options}
5524
6086
  **
5525
6087
  ** These constants are the available integer "verbs" that can be passed as
5526
6088
  ** the second argument to the [sqlite3_db_status()] interface.
@@ -5532,38 +6094,37 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
5532
6094
  ** if a discontinued or unsupported verb is invoked.
5533
6095
  **
5534
6096
  ** <dl>
5535
- ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
6097
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_USED]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5536
6098
  ** <dd>This parameter returns the number of lookaside memory slots currently
5537
6099
  ** checked out.</dd>)^
5538
6100
  **
5539
- ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
6101
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt>
5540
6102
  ** <dd>This parameter returns the number malloc attempts that were
5541
6103
  ** satisfied using lookaside memory. Only the high-water value is meaningful;
5542
- ** the current value is always zero.
5543
- ** checked out.</dd>)^
6104
+ ** the current value is always zero.)^
5544
6105
  **
6106
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]]
5545
6107
  ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt>
5546
6108
  ** <dd>This parameter returns the number malloc attempts that might have
5547
6109
  ** been satisfied using lookaside memory but failed due to the amount of
5548
6110
  ** memory requested being larger than the lookaside slot size.
5549
6111
  ** Only the high-water value is meaningful;
5550
- ** the current value is always zero.
5551
- ** checked out.</dd>)^
6112
+ ** the current value is always zero.)^
5552
6113
  **
6114
+ ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]]
5553
6115
  ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt>
5554
6116
  ** <dd>This parameter returns the number malloc attempts that might have
5555
6117
  ** been satisfied using lookaside memory but failed due to all lookaside
5556
6118
  ** memory already being in use.
5557
6119
  ** Only the high-water value is meaningful;
5558
- ** the current value is always zero.
5559
- ** checked out.</dd>)^
6120
+ ** the current value is always zero.)^
5560
6121
  **
5561
- ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
6122
+ ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
5562
6123
  ** <dd>This parameter returns the approximate number of of bytes of heap
5563
6124
  ** memory used by all pager caches associated with the database connection.)^
5564
6125
  ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
5565
6126
  **
5566
- ** ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
6127
+ ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
5567
6128
  ** <dd>This parameter returns the approximate number of of bytes of heap
5568
6129
  ** memory used to store the schema for all databases associated
5569
6130
  ** with the connection - main, temp, and any [ATTACH]-ed databases.)^
@@ -5572,12 +6133,35 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
5572
6133
  ** [shared cache mode] being enabled.
5573
6134
  ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
5574
6135
  **
5575
- ** ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
6136
+ ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
5576
6137
  ** <dd>This parameter returns the approximate number of of bytes of heap
5577
6138
  ** and lookaside memory used by all prepared statements associated with
5578
6139
  ** the database connection.)^
5579
6140
  ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
5580
6141
  ** </dd>
6142
+ **
6143
+ ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt>
6144
+ ** <dd>This parameter returns the number of pager cache hits that have
6145
+ ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_HIT
6146
+ ** is always 0.
6147
+ ** </dd>
6148
+ **
6149
+ ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6150
+ ** <dd>This parameter returns the number of pager cache misses that have
6151
+ ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6152
+ ** is always 0.
6153
+ ** </dd>
6154
+ **
6155
+ ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6156
+ ** <dd>This parameter returns the number of dirty cache entries that have
6157
+ ** been written to disk. Specifically, the number of pages written to the
6158
+ ** wal file in wal mode databases, or the number of pages written to the
6159
+ ** database file in rollback mode databases. Any pages written as part of
6160
+ ** transaction rollback or database recovery operations are not included.
6161
+ ** If an IO or other error occurs while writing a page to disk, the effect
6162
+ ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6163
+ ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6164
+ ** </dd>
5581
6165
  ** </dl>
5582
6166
  */
5583
6167
  #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
@@ -5587,14 +6171,17 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
5587
6171
  #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
5588
6172
  #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
5589
6173
  #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
5590
- #define SQLITE_DBSTATUS_MAX 6 /* Largest defined DBSTATUS */
6174
+ #define SQLITE_DBSTATUS_CACHE_HIT 7
6175
+ #define SQLITE_DBSTATUS_CACHE_MISS 8
6176
+ #define SQLITE_DBSTATUS_CACHE_WRITE 9
6177
+ #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
5591
6178
 
5592
6179
 
5593
6180
  /*
5594
6181
  ** CAPI3REF: Prepared Statement Status
5595
6182
  **
5596
6183
  ** ^(Each prepared statement maintains various
5597
- ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
6184
+ ** [SQLITE_STMTSTATUS counters] that measure the number
5598
6185
  ** of times it has performed specific operations.)^ These counters can
5599
6186
  ** be used to monitor the performance characteristics of the prepared
5600
6187
  ** statements. For example, if the number of table steps greatly exceeds
@@ -5605,7 +6192,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
5605
6192
  ** ^(This interface is used to retrieve and reset counter values from
5606
6193
  ** a [prepared statement]. The first argument is the prepared statement
5607
6194
  ** object to be interrogated. The second argument
5608
- ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
6195
+ ** is an integer code for a specific [SQLITE_STMTSTATUS counter]
5609
6196
  ** to be interrogated.)^
5610
6197
  ** ^The current value of the requested counter is returned.
5611
6198
  ** ^If the resetFlg is true, then the counter is reset to zero after this
@@ -5617,30 +6204,30 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5617
6204
 
5618
6205
  /*
5619
6206
  ** CAPI3REF: Status Parameters for prepared statements
6207
+ ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
5620
6208
  **
5621
6209
  ** These preprocessor macros define integer codes that name counter
5622
6210
  ** values associated with the [sqlite3_stmt_status()] interface.
5623
6211
  ** The meanings of the various counters are as follows:
5624
6212
  **
5625
6213
  ** <dl>
5626
- ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
6214
+ ** [[SQLITE_STMTSTATUS_FULLSCAN_STEP]] <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5627
6215
  ** <dd>^This is the number of times that SQLite has stepped forward in
5628
6216
  ** a table as part of a full table scan. Large numbers for this counter
5629
6217
  ** may indicate opportunities for performance improvement through
5630
6218
  ** careful use of indices.</dd>
5631
6219
  **
5632
- ** <dt>SQLITE_STMTSTATUS_SORT</dt>
6220
+ ** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt>
5633
6221
  ** <dd>^This is the number of sort operations that have occurred.
5634
6222
  ** A non-zero value in this counter may indicate an opportunity to
5635
6223
  ** improvement performance through careful use of indices.</dd>
5636
6224
  **
5637
- ** <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
6225
+ ** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt>
5638
6226
  ** <dd>^This is the number of rows inserted into transient indices that
5639
6227
  ** were created automatically in order to help joins run faster.
5640
6228
  ** A non-zero value in this counter may indicate an opportunity to
5641
6229
  ** improvement performance by adding permanent indices that do not
5642
6230
  ** need to be reinitialized each time the statement is run.</dd>
5643
- **
5644
6231
  ** </dl>
5645
6232
  */
5646
6233
  #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
@@ -5656,17 +6243,33 @@ SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5656
6243
  ** sqlite3_pcache object except by holding and passing pointers
5657
6244
  ** to the object.
5658
6245
  **
5659
- ** See [sqlite3_pcache_methods] for additional information.
6246
+ ** See [sqlite3_pcache_methods2] for additional information.
5660
6247
  */
5661
6248
  typedef struct sqlite3_pcache sqlite3_pcache;
5662
6249
 
6250
+ /*
6251
+ ** CAPI3REF: Custom Page Cache Object
6252
+ **
6253
+ ** The sqlite3_pcache_page object represents a single page in the
6254
+ ** page cache. The page cache will allocate instances of this
6255
+ ** object. Various methods of the page cache use pointers to instances
6256
+ ** of this object as parameters or as their return value.
6257
+ **
6258
+ ** See [sqlite3_pcache_methods2] for additional information.
6259
+ */
6260
+ typedef struct sqlite3_pcache_page sqlite3_pcache_page;
6261
+ struct sqlite3_pcache_page {
6262
+ void *pBuf; /* The content of the page */
6263
+ void *pExtra; /* Extra information associated with the page */
6264
+ };
6265
+
5663
6266
  /*
5664
6267
  ** CAPI3REF: Application Defined Page Cache.
5665
6268
  ** KEYWORDS: {page cache}
5666
6269
  **
5667
- ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
6270
+ ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE2], ...) interface can
5668
6271
  ** register an alternative page cache implementation by passing in an
5669
- ** instance of the sqlite3_pcache_methods structure.)^
6272
+ ** instance of the sqlite3_pcache_methods2 structure.)^
5670
6273
  ** In many applications, most of the heap memory allocated by
5671
6274
  ** SQLite is used for the page cache.
5672
6275
  ** By implementing a
@@ -5680,21 +6283,23 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5680
6283
  ** extreme measure that is only needed by the most demanding applications.
5681
6284
  ** The built-in page cache is recommended for most uses.
5682
6285
  **
5683
- ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
6286
+ ** ^(The contents of the sqlite3_pcache_methods2 structure are copied to an
5684
6287
  ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
5685
6288
  ** the application may discard the parameter after the call to
5686
6289
  ** [sqlite3_config()] returns.)^
5687
6290
  **
6291
+ ** [[the xInit() page cache method]]
5688
6292
  ** ^(The xInit() method is called once for each effective
5689
6293
  ** call to [sqlite3_initialize()])^
5690
6294
  ** (usually only once during the lifetime of the process). ^(The xInit()
5691
- ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
6295
+ ** method is passed a copy of the sqlite3_pcache_methods2.pArg value.)^
5692
6296
  ** The intent of the xInit() method is to set up global data structures
5693
6297
  ** required by the custom page cache implementation.
5694
6298
  ** ^(If the xInit() method is NULL, then the
5695
6299
  ** built-in default page cache is used instead of the application defined
5696
6300
  ** page cache.)^
5697
6301
  **
6302
+ ** [[the xShutdown() page cache method]]
5698
6303
  ** ^The xShutdown() method is called by [sqlite3_shutdown()].
5699
6304
  ** It can be used to clean up
5700
6305
  ** any outstanding resources before process shutdown, if required.
@@ -5709,21 +6314,20 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5709
6314
  ** ^SQLite will never invoke xInit() more than once without an intervening
5710
6315
  ** call to xShutdown().
5711
6316
  **
6317
+ ** [[the xCreate() page cache methods]]
5712
6318
  ** ^SQLite invokes the xCreate() method to construct a new cache instance.
5713
6319
  ** SQLite will typically create one cache instance for each open database file,
5714
6320
  ** though this is not guaranteed. ^The
5715
6321
  ** first parameter, szPage, is the size in bytes of the pages that must
5716
- ** be allocated by the cache. ^szPage will not be a power of two. ^szPage
5717
- ** will the page size of the database file that is to be cached plus an
5718
- ** increment (here called "R") of less than 250. SQLite will use the
5719
- ** extra R bytes on each page to store metadata about the underlying
5720
- ** database page on disk. The value of R depends
6322
+ ** be allocated by the cache. ^szPage will always a power of two. ^The
6323
+ ** second parameter szExtra is a number of bytes of extra storage
6324
+ ** associated with each page cache entry. ^The szExtra parameter will
6325
+ ** a number less than 250. SQLite will use the
6326
+ ** extra szExtra bytes on each page to store metadata about the underlying
6327
+ ** database page on disk. The value passed into szExtra depends
5721
6328
  ** on the SQLite version, the target platform, and how SQLite was compiled.
5722
- ** ^(R is constant for a particular build of SQLite. Except, there are two
5723
- ** distinct values of R when SQLite is compiled with the proprietary
5724
- ** ZIPVFS extension.)^ ^The second argument to
5725
- ** xCreate(), bPurgeable, is true if the cache being created will
5726
- ** be used to cache database pages of a file stored on disk, or
6329
+ ** ^The third argument to xCreate(), bPurgeable, is true if the cache being
6330
+ ** created will be used to cache database pages of a file stored on disk, or
5727
6331
  ** false if it is used for an in-memory database. The cache implementation
5728
6332
  ** does not have to do anything special based with the value of bPurgeable;
5729
6333
  ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
@@ -5733,6 +6337,7 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5733
6337
  ** ^Hence, a cache created with bPurgeable false will
5734
6338
  ** never contain any unpinned pages.
5735
6339
  **
6340
+ ** [[the xCachesize() page cache method]]
5736
6341
  ** ^(The xCachesize() method may be called at any time by SQLite to set the
5737
6342
  ** suggested maximum cache-size (number of pages stored by) the cache
5738
6343
  ** instance passed as the first argument. This is the value configured using
@@ -5740,15 +6345,22 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5740
6345
  ** parameter, the implementation is not required to do anything with this
5741
6346
  ** value; it is advisory only.
5742
6347
  **
6348
+ ** [[the xPagecount() page cache methods]]
5743
6349
  ** The xPagecount() method must return the number of pages currently
5744
6350
  ** stored in the cache, both pinned and unpinned.
5745
6351
  **
6352
+ ** [[the xFetch() page cache methods]]
5746
6353
  ** The xFetch() method locates a page in the cache and returns a pointer to
5747
- ** the page, or a NULL pointer.
5748
- ** A "page", in this context, means a buffer of szPage bytes aligned at an
5749
- ** 8-byte boundary. The page to be fetched is determined by the key. ^The
5750
- ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5751
- ** is considered to be "pinned".
6354
+ ** an sqlite3_pcache_page object associated with that page, or a NULL pointer.
6355
+ ** The pBuf element of the returned sqlite3_pcache_page object will be a
6356
+ ** pointer to a buffer of szPage bytes used to store the content of a
6357
+ ** single database page. The pExtra element of sqlite3_pcache_page will be
6358
+ ** a pointer to the szExtra bytes of extra storage that SQLite has requested
6359
+ ** for each entry in the page cache.
6360
+ **
6361
+ ** The page to be fetched is determined by the key. ^The minimum key value
6362
+ ** is 1. After it has been retrieved using xFetch, the page is considered
6363
+ ** to be "pinned".
5752
6364
  **
5753
6365
  ** If the requested page is already in the page cache, then the page cache
5754
6366
  ** implementation must return a pointer to the page buffer with its content
@@ -5771,6 +6383,7 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5771
6383
  ** attempt to unpin one or more cache pages by spilling the content of
5772
6384
  ** pinned pages to disk and synching the operating system disk cache.
5773
6385
  **
6386
+ ** [[the xUnpin() page cache method]]
5774
6387
  ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
5775
6388
  ** as its second argument. If the third parameter, discard, is non-zero,
5776
6389
  ** then the page must be evicted from the cache.
@@ -5783,6 +6396,7 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5783
6396
  ** call to xUnpin() unpins the page regardless of the number of prior calls
5784
6397
  ** to xFetch().
5785
6398
  **
6399
+ ** [[the xRekey() page cache methods]]
5786
6400
  ** The xRekey() method is used to change the key value associated with the
5787
6401
  ** page passed as the second argument. If the cache
5788
6402
  ** previously contains an entry associated with newKey, it must be
@@ -5795,11 +6409,41 @@ typedef struct sqlite3_pcache sqlite3_pcache;
5795
6409
  ** of these pages are pinned, they are implicitly unpinned, meaning that
5796
6410
  ** they can be safely discarded.
5797
6411
  **
6412
+ ** [[the xDestroy() page cache method]]
5798
6413
  ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
5799
6414
  ** All resources associated with the specified cache should be freed. ^After
5800
6415
  ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
5801
- ** handle invalid, and will not use it with any other sqlite3_pcache_methods
6416
+ ** handle invalid, and will not use it with any other sqlite3_pcache_methods2
5802
6417
  ** functions.
6418
+ **
6419
+ ** [[the xShrink() page cache method]]
6420
+ ** ^SQLite invokes the xShrink() method when it wants the page cache to
6421
+ ** free up as much of heap memory as possible. The page cache implementation
6422
+ ** is not obligated to free any memory, but well-behaved implementations should
6423
+ ** do their best.
6424
+ */
6425
+ typedef struct sqlite3_pcache_methods2 sqlite3_pcache_methods2;
6426
+ struct sqlite3_pcache_methods2 {
6427
+ int iVersion;
6428
+ void *pArg;
6429
+ int (*xInit)(void*);
6430
+ void (*xShutdown)(void*);
6431
+ sqlite3_pcache *(*xCreate)(int szPage, int szExtra, int bPurgeable);
6432
+ void (*xCachesize)(sqlite3_pcache*, int nCachesize);
6433
+ int (*xPagecount)(sqlite3_pcache*);
6434
+ sqlite3_pcache_page *(*xFetch)(sqlite3_pcache*, unsigned key, int createFlag);
6435
+ void (*xUnpin)(sqlite3_pcache*, sqlite3_pcache_page*, int discard);
6436
+ void (*xRekey)(sqlite3_pcache*, sqlite3_pcache_page*,
6437
+ unsigned oldKey, unsigned newKey);
6438
+ void (*xTruncate)(sqlite3_pcache*, unsigned iLimit);
6439
+ void (*xDestroy)(sqlite3_pcache*);
6440
+ void (*xShrink)(sqlite3_pcache*);
6441
+ };
6442
+
6443
+ /*
6444
+ ** This is the obsolete pcache_methods object that has now been replaced
6445
+ ** by sqlite3_pcache_methods2. This object is not used by SQLite. It is
6446
+ ** retained in the header file for backwards compatibility only.
5803
6447
  */
5804
6448
  typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
5805
6449
  struct sqlite3_pcache_methods {
@@ -5816,6 +6460,7 @@ struct sqlite3_pcache_methods {
5816
6460
  void (*xDestroy)(sqlite3_pcache*);
5817
6461
  };
5818
6462
 
6463
+
5819
6464
  /*
5820
6465
  ** CAPI3REF: Online Backup Object
5821
6466
  **
@@ -5857,7 +6502,7 @@ typedef struct sqlite3_backup sqlite3_backup;
5857
6502
  ** There should be exactly one call to sqlite3_backup_finish() for each
5858
6503
  ** successful call to sqlite3_backup_init().
5859
6504
  **
5860
- ** <b>sqlite3_backup_init()</b>
6505
+ ** [[sqlite3_backup_init()]] <b>sqlite3_backup_init()</b>
5861
6506
  **
5862
6507
  ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
5863
6508
  ** [database connection] associated with the destination database
@@ -5884,7 +6529,7 @@ typedef struct sqlite3_backup sqlite3_backup;
5884
6529
  ** sqlite3_backup_finish() functions to perform the specified backup
5885
6530
  ** operation.
5886
6531
  **
5887
- ** <b>sqlite3_backup_step()</b>
6532
+ ** [[sqlite3_backup_step()]] <b>sqlite3_backup_step()</b>
5888
6533
  **
5889
6534
  ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
5890
6535
  ** the source and destination databases specified by [sqlite3_backup] object B.
@@ -5941,7 +6586,7 @@ typedef struct sqlite3_backup sqlite3_backup;
5941
6586
  ** by the backup operation, then the backup database is automatically
5942
6587
  ** updated at the same time.
5943
6588
  **
5944
- ** <b>sqlite3_backup_finish()</b>
6589
+ ** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b>
5945
6590
  **
5946
6591
  ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5947
6592
  ** application wishes to abandon the backup operation, the application
@@ -5964,7 +6609,8 @@ typedef struct sqlite3_backup sqlite3_backup;
5964
6609
  ** is not a permanent error and does not affect the return value of
5965
6610
  ** sqlite3_backup_finish().
5966
6611
  **
5967
- ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
6612
+ ** [[sqlite3_backup__remaining()]] [[sqlite3_backup_pagecount()]]
6613
+ ** <b>sqlite3_backup_remaining() and sqlite3_backup_pagecount()</b>
5968
6614
  **
5969
6615
  ** ^Each call to sqlite3_backup_step() sets two values inside
5970
6616
  ** the [sqlite3_backup] object: the number of pages still to be backed
@@ -6144,11 +6790,12 @@ SQLITE_API int sqlite3_unlock_notify(
6144
6790
  /*
6145
6791
  ** CAPI3REF: String Comparison
6146
6792
  **
6147
- ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
6148
- ** compare the contents of two buffers containing UTF-8 strings in a
6149
- ** case-independent fashion, using the same definition of case independence
6150
- ** that SQLite uses internally when comparing identifiers.
6793
+ ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
6794
+ ** and extensions to compare the contents of two buffers containing UTF-8
6795
+ ** strings in a case-independent fashion, using the same definition of "case
6796
+ ** independence" that SQLite uses internally when comparing identifiers.
6151
6797
  */
6798
+ SQLITE_API int sqlite3_stricmp(const char *, const char *);
6152
6799
  SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
6153
6800
 
6154
6801
  /*
@@ -6255,9 +6902,189 @@ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
6255
6902
  ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the
6256
6903
  ** [wal_autocheckpoint pragma] can be used to cause this interface to be
6257
6904
  ** run whenever the WAL reaches a certain size threshold.
6905
+ **
6906
+ ** See also: [sqlite3_wal_checkpoint_v2()]
6258
6907
  */
6259
6908
  SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
6260
6909
 
6910
+ /*
6911
+ ** CAPI3REF: Checkpoint a database
6912
+ **
6913
+ ** Run a checkpoint operation on WAL database zDb attached to database
6914
+ ** handle db. The specific operation is determined by the value of the
6915
+ ** eMode parameter:
6916
+ **
6917
+ ** <dl>
6918
+ ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd>
6919
+ ** Checkpoint as many frames as possible without waiting for any database
6920
+ ** readers or writers to finish. Sync the db file if all frames in the log
6921
+ ** are checkpointed. This mode is the same as calling
6922
+ ** sqlite3_wal_checkpoint(). The busy-handler callback is never invoked.
6923
+ **
6924
+ ** <dt>SQLITE_CHECKPOINT_FULL<dd>
6925
+ ** This mode blocks (calls the busy-handler callback) until there is no
6926
+ ** database writer and all readers are reading from the most recent database
6927
+ ** snapshot. It then checkpoints all frames in the log file and syncs the
6928
+ ** database file. This call blocks database writers while it is running,
6929
+ ** but not database readers.
6930
+ **
6931
+ ** <dt>SQLITE_CHECKPOINT_RESTART<dd>
6932
+ ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after
6933
+ ** checkpointing the log file it blocks (calls the busy-handler callback)
6934
+ ** until all readers are reading from the database file only. This ensures
6935
+ ** that the next client to write to the database file restarts the log file
6936
+ ** from the beginning. This call blocks database writers while it is running,
6937
+ ** but not database readers.
6938
+ ** </dl>
6939
+ **
6940
+ ** If pnLog is not NULL, then *pnLog is set to the total number of frames in
6941
+ ** the log file before returning. If pnCkpt is not NULL, then *pnCkpt is set to
6942
+ ** the total number of checkpointed frames (including any that were already
6943
+ ** checkpointed when this function is called). *pnLog and *pnCkpt may be
6944
+ ** populated even if sqlite3_wal_checkpoint_v2() returns other than SQLITE_OK.
6945
+ ** If no values are available because of an error, they are both set to -1
6946
+ ** before returning to communicate this to the caller.
6947
+ **
6948
+ ** All calls obtain an exclusive "checkpoint" lock on the database file. If
6949
+ ** any other process is running a checkpoint operation at the same time, the
6950
+ ** lock cannot be obtained and SQLITE_BUSY is returned. Even if there is a
6951
+ ** busy-handler configured, it will not be invoked in this case.
6952
+ **
6953
+ ** The SQLITE_CHECKPOINT_FULL and RESTART modes also obtain the exclusive
6954
+ ** "writer" lock on the database file. If the writer lock cannot be obtained
6955
+ ** immediately, and a busy-handler is configured, it is invoked and the writer
6956
+ ** lock retried until either the busy-handler returns 0 or the lock is
6957
+ ** successfully obtained. The busy-handler is also invoked while waiting for
6958
+ ** database readers as described above. If the busy-handler returns 0 before
6959
+ ** the writer lock is obtained or while waiting for database readers, the
6960
+ ** checkpoint operation proceeds from that point in the same way as
6961
+ ** SQLITE_CHECKPOINT_PASSIVE - checkpointing as many frames as possible
6962
+ ** without blocking any further. SQLITE_BUSY is returned in this case.
6963
+ **
6964
+ ** If parameter zDb is NULL or points to a zero length string, then the
6965
+ ** specified operation is attempted on all WAL databases. In this case the
6966
+ ** values written to output parameters *pnLog and *pnCkpt are undefined. If
6967
+ ** an SQLITE_BUSY error is encountered when processing one or more of the
6968
+ ** attached WAL databases, the operation is still attempted on any remaining
6969
+ ** attached databases and SQLITE_BUSY is returned to the caller. If any other
6970
+ ** error occurs while processing an attached database, processing is abandoned
6971
+ ** and the error code returned to the caller immediately. If no error
6972
+ ** (SQLITE_BUSY or otherwise) is encountered while processing the attached
6973
+ ** databases, SQLITE_OK is returned.
6974
+ **
6975
+ ** If database zDb is the name of an attached database that is not in WAL
6976
+ ** mode, SQLITE_OK is returned and both *pnLog and *pnCkpt set to -1. If
6977
+ ** zDb is not NULL (or a zero length string) and is not the name of any
6978
+ ** attached database, SQLITE_ERROR is returned to the caller.
6979
+ */
6980
+ SQLITE_API int sqlite3_wal_checkpoint_v2(
6981
+ sqlite3 *db, /* Database handle */
6982
+ const char *zDb, /* Name of attached database (or NULL) */
6983
+ int eMode, /* SQLITE_CHECKPOINT_* value */
6984
+ int *pnLog, /* OUT: Size of WAL log in frames */
6985
+ int *pnCkpt /* OUT: Total number of frames checkpointed */
6986
+ );
6987
+
6988
+ /*
6989
+ ** CAPI3REF: Checkpoint operation parameters
6990
+ **
6991
+ ** These constants can be used as the 3rd parameter to
6992
+ ** [sqlite3_wal_checkpoint_v2()]. See the [sqlite3_wal_checkpoint_v2()]
6993
+ ** documentation for additional information about the meaning and use of
6994
+ ** each of these values.
6995
+ */
6996
+ #define SQLITE_CHECKPOINT_PASSIVE 0
6997
+ #define SQLITE_CHECKPOINT_FULL 1
6998
+ #define SQLITE_CHECKPOINT_RESTART 2
6999
+
7000
+ /*
7001
+ ** CAPI3REF: Virtual Table Interface Configuration
7002
+ **
7003
+ ** This function may be called by either the [xConnect] or [xCreate] method
7004
+ ** of a [virtual table] implementation to configure
7005
+ ** various facets of the virtual table interface.
7006
+ **
7007
+ ** If this interface is invoked outside the context of an xConnect or
7008
+ ** xCreate virtual table method then the behavior is undefined.
7009
+ **
7010
+ ** At present, there is only one option that may be configured using
7011
+ ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7012
+ ** may be added in the future.
7013
+ */
7014
+ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7015
+
7016
+ /*
7017
+ ** CAPI3REF: Virtual Table Configuration Options
7018
+ **
7019
+ ** These macros define the various options to the
7020
+ ** [sqlite3_vtab_config()] interface that [virtual table] implementations
7021
+ ** can use to customize and optimize their behavior.
7022
+ **
7023
+ ** <dl>
7024
+ ** <dt>SQLITE_VTAB_CONSTRAINT_SUPPORT
7025
+ ** <dd>Calls of the form
7026
+ ** [sqlite3_vtab_config](db,SQLITE_VTAB_CONSTRAINT_SUPPORT,X) are supported,
7027
+ ** where X is an integer. If X is zero, then the [virtual table] whose
7028
+ ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not
7029
+ ** support constraints. In this configuration (which is the default) if
7030
+ ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire
7031
+ ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been
7032
+ ** specified as part of the users SQL statement, regardless of the actual
7033
+ ** ON CONFLICT mode specified.
7034
+ **
7035
+ ** If X is non-zero, then the virtual table implementation guarantees
7036
+ ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before
7037
+ ** any modifications to internal or persistent data structures have been made.
7038
+ ** If the [ON CONFLICT] mode is ABORT, FAIL, IGNORE or ROLLBACK, SQLite
7039
+ ** is able to roll back a statement or database transaction, and abandon
7040
+ ** or continue processing the current SQL statement as appropriate.
7041
+ ** If the ON CONFLICT mode is REPLACE and the [xUpdate] method returns
7042
+ ** [SQLITE_CONSTRAINT], SQLite handles this as if the ON CONFLICT mode
7043
+ ** had been ABORT.
7044
+ **
7045
+ ** Virtual table implementations that are required to handle OR REPLACE
7046
+ ** must do so within the [xUpdate] method. If a call to the
7047
+ ** [sqlite3_vtab_on_conflict()] function indicates that the current ON
7048
+ ** CONFLICT policy is REPLACE, the virtual table implementation should
7049
+ ** silently replace the appropriate rows within the xUpdate callback and
7050
+ ** return SQLITE_OK. Or, if this is not possible, it may return
7051
+ ** SQLITE_CONSTRAINT, in which case SQLite falls back to OR ABORT
7052
+ ** constraint handling.
7053
+ ** </dl>
7054
+ */
7055
+ #define SQLITE_VTAB_CONSTRAINT_SUPPORT 1
7056
+
7057
+ /*
7058
+ ** CAPI3REF: Determine The Virtual Table Conflict Policy
7059
+ **
7060
+ ** This function may only be called from within a call to the [xUpdate] method
7061
+ ** of a [virtual table] implementation for an INSERT or UPDATE operation. ^The
7062
+ ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7063
+ ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7064
+ ** of the SQL statement that triggered the call to the [xUpdate] method of the
7065
+ ** [virtual table].
7066
+ */
7067
+ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7068
+
7069
+ /*
7070
+ ** CAPI3REF: Conflict resolution modes
7071
+ **
7072
+ ** These constants are returned by [sqlite3_vtab_on_conflict()] to
7073
+ ** inform a [virtual table] implementation what the [ON CONFLICT] mode
7074
+ ** is for the SQL statement being evaluated.
7075
+ **
7076
+ ** Note that the [SQLITE_IGNORE] constant is also used as a potential
7077
+ ** return value from the [sqlite3_set_authorizer()] callback and that
7078
+ ** [SQLITE_ABORT] is also a [result code].
7079
+ */
7080
+ #define SQLITE_ROLLBACK 1
7081
+ /* #define SQLITE_IGNORE 2 // Also used by sqlite3_authorizer() callback */
7082
+ #define SQLITE_FAIL 3
7083
+ /* #define SQLITE_ABORT 4 // Also an error code */
7084
+ #define SQLITE_REPLACE 5
7085
+
7086
+
7087
+
6261
7088
  /*
6262
7089
  ** Undo the hack that converts floating point types to integer for
6263
7090
  ** builds on processors without floating point support.
@@ -6303,7 +7130,11 @@ typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
6303
7130
  SQLITE_API int sqlite3_rtree_geometry_callback(
6304
7131
  sqlite3 *db,
6305
7132
  const char *zGeom,
6306
- int (*xGeom)(sqlite3_rtree_geometry *, int nCoord, double *aCoord, int *pRes),
7133
+ #ifdef SQLITE_RTREE_INT_ONLY
7134
+ int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),
7135
+ #else
7136
+ int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),
7137
+ #endif
6307
7138
  void *pContext
6308
7139
  );
6309
7140