comparison include/sqlite3.h @ 21:a2ad87cad48b

Enhanced the convenience of Cache dialog.
author pyon@macmini
date Wed, 17 Dec 2014 00:52:43 +0900
parents 0c0701a935f8
children
comparison
equal deleted inserted replaced
20:226774bf49fc 21:a2ad87cad48b
105 ** 105 **
106 ** See also: [sqlite3_libversion()], 106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()], 107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()]. 108 ** [sqlite_version()] and [sqlite_source_id()].
109 */ 109 */
110 #define SQLITE_VERSION "3.7.16" 110 #define SQLITE_VERSION "3.8.5"
111 #define SQLITE_VERSION_NUMBER 3007016 111 #define SQLITE_VERSION_NUMBER 3008005
112 #define SQLITE_SOURCE_ID "2013-03-18 11:39:23 66d5f2b76750f3520eb7a495f6247206758f5b90" 112 #define SQLITE_SOURCE_ID "2014-06-04 14:06:34 b1ed4f2a34ba66c29b130f8d13e9092758019212"
113 113
114 /* 114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers 115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid 116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 ** 117 **
368 ** Restrictions: 368 ** Restrictions:
369 ** 369 **
370 ** <ul> 370 ** <ul>
371 ** <li> The application must insure that the 1st parameter to sqlite3_exec() 371 ** <li> The application must insure that the 1st parameter to sqlite3_exec()
372 ** is a valid and open [database connection]. 372 ** is a valid and open [database connection].
373 ** <li> The application must not close [database connection] specified by 373 ** <li> The application must not close the [database connection] specified by
374 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running. 374 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
375 ** <li> The application must not modify the SQL statement text passed into 375 ** <li> The application must not modify the SQL statement text passed into
376 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running. 376 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
377 ** </ul> 377 ** </ul>
378 */ 378 */
423 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */ 423 #define SQLITE_NOLFS 22 /* Uses OS features not supported on host */
424 #define SQLITE_AUTH 23 /* Authorization denied */ 424 #define SQLITE_AUTH 23 /* Authorization denied */
425 #define SQLITE_FORMAT 24 /* Auxiliary database format error */ 425 #define SQLITE_FORMAT 24 /* Auxiliary database format error */
426 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */ 426 #define SQLITE_RANGE 25 /* 2nd parameter to sqlite3_bind out of range */
427 #define SQLITE_NOTADB 26 /* File opened that is not a database file */ 427 #define SQLITE_NOTADB 26 /* File opened that is not a database file */
428 #define SQLITE_NOTICE 27 /* Notifications from sqlite3_log() */
429 #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
428 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ 430 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
429 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ 431 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
430 /* end-of-error-codes */ 432 /* end-of-error-codes */
431 433
432 /* 434 /*
443 ** about errors. The extended result codes are enabled or disabled 445 ** about errors. The extended result codes are enabled or disabled
444 ** on a per database connection basis using the 446 ** on a per database connection basis using the
445 ** [sqlite3_extended_result_codes()] API. 447 ** [sqlite3_extended_result_codes()] API.
446 ** 448 **
447 ** Some of the available extended result codes are listed here. 449 ** Some of the available extended result codes are listed here.
448 ** One may expect the number of extended result codes will be expand 450 ** One may expect the number of extended result codes will increase
449 ** over time. Software that uses extended result codes should expect 451 ** over time. Software that uses extended result codes should expect
450 ** to see new result codes in future releases of SQLite. 452 ** to see new result codes in future releases of SQLite.
451 ** 453 **
452 ** The SQLITE_OK result code will never be extended. It will always 454 ** The SQLITE_OK result code will never be extended. It will always
453 ** be exactly zero. 455 ** be exactly zero.
473 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8)) 475 #define SQLITE_IOERR_SHMSIZE (SQLITE_IOERR | (19<<8))
474 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8)) 476 #define SQLITE_IOERR_SHMLOCK (SQLITE_IOERR | (20<<8))
475 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8)) 477 #define SQLITE_IOERR_SHMMAP (SQLITE_IOERR | (21<<8))
476 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8)) 478 #define SQLITE_IOERR_SEEK (SQLITE_IOERR | (22<<8))
477 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8)) 479 #define SQLITE_IOERR_DELETE_NOENT (SQLITE_IOERR | (23<<8))
480 #define SQLITE_IOERR_MMAP (SQLITE_IOERR | (24<<8))
481 #define SQLITE_IOERR_GETTEMPPATH (SQLITE_IOERR | (25<<8))
482 #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8))
478 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) 483 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
479 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) 484 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
485 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
480 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8)) 486 #define SQLITE_CANTOPEN_NOTEMPDIR (SQLITE_CANTOPEN | (1<<8))
481 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8)) 487 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
482 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8)) 488 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
489 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
483 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8)) 490 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
484 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8)) 491 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
485 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8)) 492 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
486 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8)) 493 #define SQLITE_READONLY_ROLLBACK (SQLITE_READONLY | (3<<8))
494 #define SQLITE_READONLY_DBMOVED (SQLITE_READONLY | (4<<8))
487 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8)) 495 #define SQLITE_ABORT_ROLLBACK (SQLITE_ABORT | (2<<8))
488 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8)) 496 #define SQLITE_CONSTRAINT_CHECK (SQLITE_CONSTRAINT | (1<<8))
489 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8)) 497 #define SQLITE_CONSTRAINT_COMMITHOOK (SQLITE_CONSTRAINT | (2<<8))
490 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8)) 498 #define SQLITE_CONSTRAINT_FOREIGNKEY (SQLITE_CONSTRAINT | (3<<8))
491 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8)) 499 #define SQLITE_CONSTRAINT_FUNCTION (SQLITE_CONSTRAINT | (4<<8))
492 #define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8)) 500 #define SQLITE_CONSTRAINT_NOTNULL (SQLITE_CONSTRAINT | (5<<8))
493 #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8)) 501 #define SQLITE_CONSTRAINT_PRIMARYKEY (SQLITE_CONSTRAINT | (6<<8))
494 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) 502 #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8))
495 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) 503 #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8))
496 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) 504 #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8))
505 #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8))
506 #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
507 #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
508 #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
497 509
498 /* 510 /*
499 ** CAPI3REF: Flags For File Open Operations 511 ** CAPI3REF: Flags For File Open Operations
500 ** 512 **
501 ** These bit values are intended for use in the 513 ** These bit values are intended for use in the
545 ** information is written to disk in the same order as calls 557 ** information is written to disk in the same order as calls
546 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that 558 ** to xWrite(). The SQLITE_IOCAP_POWERSAFE_OVERWRITE property means that
547 ** after reboot following a crash or power loss, the only bytes in a 559 ** after reboot following a crash or power loss, the only bytes in a
548 ** file that were written at the application level might have changed 560 ** file that were written at the application level might have changed
549 ** and that adjacent bytes, even bytes within the same sector are 561 ** and that adjacent bytes, even bytes within the same sector are
550 ** guaranteed to be unchanged. 562 ** guaranteed to be unchanged. The SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN
563 ** flag indicate that a file cannot be deleted when open. The
564 ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on
565 ** read-only media and cannot be changed even by processes with
566 ** elevated privileges.
551 */ 567 */
552 #define SQLITE_IOCAP_ATOMIC 0x00000001 568 #define SQLITE_IOCAP_ATOMIC 0x00000001
553 #define SQLITE_IOCAP_ATOMIC512 0x00000002 569 #define SQLITE_IOCAP_ATOMIC512 0x00000002
554 #define SQLITE_IOCAP_ATOMIC1K 0x00000004 570 #define SQLITE_IOCAP_ATOMIC1K 0x00000004
555 #define SQLITE_IOCAP_ATOMIC2K 0x00000008 571 #define SQLITE_IOCAP_ATOMIC2K 0x00000008
560 #define SQLITE_IOCAP_ATOMIC64K 0x00000100 576 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
561 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 577 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
562 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 578 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
563 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 579 #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800
564 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 580 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000
581 #define SQLITE_IOCAP_IMMUTABLE 0x00002000
565 582
566 /* 583 /*
567 ** CAPI3REF: File Locking Levels 584 ** CAPI3REF: File Locking Levels
568 ** 585 **
569 ** SQLite uses one of these integer values as the second 586 ** SQLite uses one of these integer values as the second
731 int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**); 748 int (*xShmMap)(sqlite3_file*, int iPg, int pgsz, int, void volatile**);
732 int (*xShmLock)(sqlite3_file*, int offset, int n, int flags); 749 int (*xShmLock)(sqlite3_file*, int offset, int n, int flags);
733 void (*xShmBarrier)(sqlite3_file*); 750 void (*xShmBarrier)(sqlite3_file*);
734 int (*xShmUnmap)(sqlite3_file*, int deleteFlag); 751 int (*xShmUnmap)(sqlite3_file*, int deleteFlag);
735 /* Methods above are valid for version 2 */ 752 /* Methods above are valid for version 2 */
753 int (*xFetch)(sqlite3_file*, sqlite3_int64 iOfst, int iAmt, void **pp);
754 int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
755 /* Methods above are valid for version 3 */
736 /* Additional methods may be added in future releases */ 756 /* Additional methods may be added in future releases */
737 }; 757 };
738 758
739 /* 759 /*
740 ** CAPI3REF: Standard File Control Opcodes 760 ** CAPI3REF: Standard File Control Opcodes
773 ** to the [sqlite3_file] object associated with a particular database 793 ** to the [sqlite3_file] object associated with a particular database
774 ** connection. See the [sqlite3_file_control()] documentation for 794 ** connection. See the [sqlite3_file_control()] documentation for
775 ** additional information. 795 ** additional information.
776 ** 796 **
777 ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]] 797 ** <li>[[SQLITE_FCNTL_SYNC_OMITTED]]
778 ** ^(The [SQLITE_FCNTL_SYNC_OMITTED] opcode is generated internally by 798 ** No longer in use.
779 ** SQLite and sent to all VFSes in place of a call to the xSync method 799 **
780 ** when the database connection has [PRAGMA synchronous] set to OFF.)^ 800 ** <li>[[SQLITE_FCNTL_SYNC]]
781 ** Some specialized VFSes need this signal in order to operate correctly 801 ** The [SQLITE_FCNTL_SYNC] opcode is generated internally by SQLite and
782 ** when [PRAGMA synchronous | PRAGMA synchronous=OFF] is set, but most 802 ** sent to the VFS immediately before the xSync method is invoked on a
783 ** VFSes do not need this signal and should silently ignore this opcode. 803 ** database file descriptor. Or, if the xSync method is not invoked
784 ** Applications should not call [sqlite3_file_control()] with this 804 ** because the user has configured SQLite with
785 ** opcode as doing so may disrupt the operation of the specialized VFSes 805 ** [PRAGMA synchronous | PRAGMA synchronous=OFF] it is invoked in place
786 ** that do require it. 806 ** of the xSync method. In most cases, the pointer argument passed with
807 ** this file-control is NULL. However, if the database file is being synced
808 ** as part of a multi-database commit, the argument points to a nul-terminated
809 ** string containing the transactions master-journal file name. VFSes that
810 ** do not need this signal should silently ignore this opcode. Applications
811 ** should not call [sqlite3_file_control()] with this opcode as doing so may
812 ** disrupt the operation of the specialized VFSes that do require it.
813 **
814 ** <li>[[SQLITE_FCNTL_COMMIT_PHASETWO]]
815 ** The [SQLITE_FCNTL_COMMIT_PHASETWO] opcode is generated internally by SQLite
816 ** and sent to the VFS after a transaction has been committed immediately
817 ** but before the database is unlocked. VFSes that do not need this signal
818 ** should silently ignore this opcode. Applications should not call
819 ** [sqlite3_file_control()] with this opcode as doing so may disrupt the
820 ** operation of the specialized VFSes that do require it.
787 ** 821 **
788 ** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]] 822 ** <li>[[SQLITE_FCNTL_WIN32_AV_RETRY]]
789 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic 823 ** ^The [SQLITE_FCNTL_WIN32_AV_RETRY] opcode is used to configure automatic
790 ** retry counts and intervals for certain disk I/O operations for the 824 ** retry counts and intervals for certain disk I/O operations for the
791 ** windows [VFS] in order to provide robustness in the presence of 825 ** windows [VFS] in order to provide robustness in the presence of
867 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA] 901 ** compilation of the PRAGMA fails with an error. ^The [SQLITE_FCNTL_PRAGMA]
868 ** file control occurs at the beginning of pragma statement analysis and so 902 ** file control occurs at the beginning of pragma statement analysis and so
869 ** it is able to override built-in [PRAGMA] statements. 903 ** it is able to override built-in [PRAGMA] statements.
870 ** 904 **
871 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]] 905 ** <li>[[SQLITE_FCNTL_BUSYHANDLER]]
872 ** ^This file-control may be invoked by SQLite on the database file handle 906 ** ^The [SQLITE_FCNTL_BUSYHANDLER]
907 ** file-control may be invoked by SQLite on the database file handle
873 ** shortly after it is opened in order to provide a custom VFS with access 908 ** shortly after it is opened in order to provide a custom VFS with access
874 ** to the connections busy-handler callback. The argument is of type (void **) 909 ** to the connections busy-handler callback. The argument is of type (void **)
875 ** - an array of two (void *) values. The first (void *) actually points 910 ** - an array of two (void *) values. The first (void *) actually points
876 ** to a function of type (int (*)(void *)). In order to invoke the connections 911 ** to a function of type (int (*)(void *)). In order to invoke the connections
877 ** busy-handler, this function should be invoked with the second (void *) in 912 ** busy-handler, this function should be invoked with the second (void *) in
878 ** the array as the only argument. If it returns non-zero, then the operation 913 ** the array as the only argument. If it returns non-zero, then the operation
879 ** should be retried. If it returns zero, the custom VFS should abandon the 914 ** should be retried. If it returns zero, the custom VFS should abandon the
880 ** current operation. 915 ** current operation.
881 ** 916 **
882 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]] 917 ** <li>[[SQLITE_FCNTL_TEMPFILENAME]]
883 ** ^Application can invoke this file-control to have SQLite generate a 918 ** ^Application can invoke the [SQLITE_FCNTL_TEMPFILENAME] file-control
919 ** to have SQLite generate a
884 ** temporary filename using the same algorithm that is followed to generate 920 ** temporary filename using the same algorithm that is followed to generate
885 ** temporary filenames for TEMP tables and other internal uses. The 921 ** temporary filenames for TEMP tables and other internal uses. The
886 ** argument should be a char** which will be filled with the filename 922 ** argument should be a char** which will be filled with the filename
887 ** written into memory obtained from [sqlite3_malloc()]. The caller should 923 ** written into memory obtained from [sqlite3_malloc()]. The caller should
888 ** invoke [sqlite3_free()] on the result to avoid a memory leak. 924 ** invoke [sqlite3_free()] on the result to avoid a memory leak.
925 **
926 ** <li>[[SQLITE_FCNTL_MMAP_SIZE]]
927 ** The [SQLITE_FCNTL_MMAP_SIZE] file control is used to query or set the
928 ** maximum number of bytes that will be used for memory-mapped I/O.
929 ** The argument is a pointer to a value of type sqlite3_int64 that
930 ** is an advisory maximum number of bytes in the file to memory map. The
931 ** pointer is overwritten with the old value. The limit is not changed if
932 ** the value originally pointed to is negative, and so the current limit
933 ** can be queried by passing in a pointer to a negative number. This
934 ** file-control is used internally to implement [PRAGMA mmap_size].
935 **
936 ** <li>[[SQLITE_FCNTL_TRACE]]
937 ** The [SQLITE_FCNTL_TRACE] file control provides advisory information
938 ** to the VFS about what the higher layers of the SQLite stack are doing.
939 ** This file control is used by some VFS activity tracing [shims].
940 ** The argument is a zero-terminated string. Higher layers in the
941 ** SQLite stack may generate instances of this file control if
942 ** the [SQLITE_USE_FCNTL_TRACE] compile-time option is enabled.
943 **
944 ** <li>[[SQLITE_FCNTL_HAS_MOVED]]
945 ** The [SQLITE_FCNTL_HAS_MOVED] file control interprets its argument as a
946 ** pointer to an integer and it writes a boolean into that integer depending
947 ** on whether or not the file has been renamed, moved, or deleted since it
948 ** was first opened.
949 **
950 ** <li>[[SQLITE_FCNTL_WIN32_SET_HANDLE]]
951 ** The [SQLITE_FCNTL_WIN32_SET_HANDLE] opcode is used for debugging. This
952 ** opcode causes the xFileControl method to swap the file handle with the one
953 ** pointed to by the pArg argument. This capability is used during testing
954 ** and only needs to be supported when SQLITE_TEST is defined.
889 ** 955 **
890 ** </ul> 956 ** </ul>
891 */ 957 */
892 #define SQLITE_FCNTL_LOCKSTATE 1 958 #define SQLITE_FCNTL_LOCKSTATE 1
893 #define SQLITE_GET_LOCKPROXYFILE 2 959 #define SQLITE_GET_LOCKPROXYFILE 2
903 #define SQLITE_FCNTL_VFSNAME 12 969 #define SQLITE_FCNTL_VFSNAME 12
904 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13 970 #define SQLITE_FCNTL_POWERSAFE_OVERWRITE 13
905 #define SQLITE_FCNTL_PRAGMA 14 971 #define SQLITE_FCNTL_PRAGMA 14
906 #define SQLITE_FCNTL_BUSYHANDLER 15 972 #define SQLITE_FCNTL_BUSYHANDLER 15
907 #define SQLITE_FCNTL_TEMPFILENAME 16 973 #define SQLITE_FCNTL_TEMPFILENAME 16
974 #define SQLITE_FCNTL_MMAP_SIZE 18
975 #define SQLITE_FCNTL_TRACE 19
976 #define SQLITE_FCNTL_HAS_MOVED 20
977 #define SQLITE_FCNTL_SYNC 21
978 #define SQLITE_FCNTL_COMMIT_PHASETWO 22
979 #define SQLITE_FCNTL_WIN32_SET_HANDLE 23
908 980
909 /* 981 /*
910 ** CAPI3REF: Mutex Handle 982 ** CAPI3REF: Mutex Handle
911 ** 983 **
912 ** The mutex module within SQLite defines [sqlite3_mutex] to be an 984 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
1347 ** of 8. Some allocators round up to a larger multiple or to a power of 2. 1419 ** of 8. Some allocators round up to a larger multiple or to a power of 2.
1348 ** Every memory allocation request coming in through [sqlite3_malloc()] 1420 ** Every memory allocation request coming in through [sqlite3_malloc()]
1349 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0, 1421 ** or [sqlite3_realloc()] first calls xRoundup. If xRoundup returns 0,
1350 ** that causes the corresponding memory allocation to fail. 1422 ** that causes the corresponding memory allocation to fail.
1351 ** 1423 **
1352 ** The xInit method initializes the memory allocator. (For example, 1424 ** The xInit method initializes the memory allocator. For example,
1353 ** it might allocate any require mutexes or initialize internal data 1425 ** it might allocate any require mutexes or initialize internal data
1354 ** structures. The xShutdown method is invoked (indirectly) by 1426 ** structures. The xShutdown method is invoked (indirectly) by
1355 ** [sqlite3_shutdown()] and should deallocate any resources acquired 1427 ** [sqlite3_shutdown()] and should deallocate any resources acquired
1356 ** by xInit. The pAppData pointer is used as the only parameter to 1428 ** by xInit. The pAppData pointer is used as the only parameter to
1357 ** xInit and xShutdown. 1429 ** xInit and xShutdown.
1569 ** <dd> ^(This option takes a single argument which is a pointer to an 1641 ** <dd> ^(This option takes a single argument which is a pointer to an
1570 ** [sqlite3_pcache_methods2] object. SQLite copies of the current 1642 ** [sqlite3_pcache_methods2] object. SQLite copies of the current
1571 ** page cache implementation into that object.)^ </dd> 1643 ** page cache implementation into that object.)^ </dd>
1572 ** 1644 **
1573 ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt> 1645 ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt>
1574 ** <dd> ^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a 1646 ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite
1647 ** global [error log].
1648 ** (^The SQLITE_CONFIG_LOG option takes two arguments: a pointer to a
1575 ** function with a call signature of void(*)(void*,int,const char*), 1649 ** function with a call signature of void(*)(void*,int,const char*),
1576 ** and a pointer to void. ^If the function pointer is not NULL, it is 1650 ** and a pointer to void. ^If the function pointer is not NULL, it is
1577 ** invoked by [sqlite3_log()] to process each logging event. ^If the 1651 ** invoked by [sqlite3_log()] to process each logging event. ^If the
1578 ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op. 1652 ** function pointer is NULL, the [sqlite3_log()] interface becomes a no-op.
1579 ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is 1653 ** ^The void pointer that is the second argument to SQLITE_CONFIG_LOG is
1587 ** supplied by the application must not invoke any SQLite interface. 1661 ** supplied by the application must not invoke any SQLite interface.
1588 ** In a multi-threaded application, the application-defined logger 1662 ** In a multi-threaded application, the application-defined logger
1589 ** function must be threadsafe. </dd> 1663 ** function must be threadsafe. </dd>
1590 ** 1664 **
1591 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI 1665 ** [[SQLITE_CONFIG_URI]] <dt>SQLITE_CONFIG_URI
1592 ** <dd> This option takes a single argument of type int. If non-zero, then 1666 ** <dd>^(This option takes a single argument of type int. If non-zero, then
1593 ** URI handling is globally enabled. If the parameter is zero, then URI handling 1667 ** URI handling is globally enabled. If the parameter is zero, then URI handling
1594 ** is globally disabled. If URI handling is globally enabled, all filenames 1668 ** is globally disabled.)^ ^If URI handling is globally enabled, all filenames
1595 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or 1669 ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or
1596 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless 1670 ** specified as part of [ATTACH] commands are interpreted as URIs, regardless
1597 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database 1671 ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database
1598 ** connection is opened. If it is globally disabled, filenames are 1672 ** connection is opened. ^If it is globally disabled, filenames are
1599 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the 1673 ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the
1600 ** database connection is opened. By default, URI handling is globally 1674 ** database connection is opened. ^(By default, URI handling is globally
1601 ** disabled. The default value may be changed by compiling with the 1675 ** disabled. The default value may be changed by compiling with the
1602 ** [SQLITE_USE_URI] symbol defined. 1676 ** [SQLITE_USE_URI] symbol defined.)^
1603 ** 1677 **
1604 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN 1678 ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]] <dt>SQLITE_CONFIG_COVERING_INDEX_SCAN
1605 ** <dd> This option takes a single integer argument which is interpreted as 1679 ** <dd>^This option takes a single integer argument which is interpreted as
1606 ** a boolean in order to enable or disable the use of covering indices for 1680 ** a boolean in order to enable or disable the use of covering indices for
1607 ** full table scans in the query optimizer. The default setting is determined 1681 ** full table scans in the query optimizer. ^The default setting is determined
1608 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" 1682 ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on"
1609 ** if that compile-time option is omitted. 1683 ** if that compile-time option is omitted.
1610 ** The ability to disable the use of covering indices for full table scans 1684 ** The ability to disable the use of covering indices for full table scans
1611 ** is because some incorrectly coded legacy applications might malfunction 1685 ** is because some incorrectly coded legacy applications might malfunction
1612 ** malfunction when the optimization is enabled. Providing the ability to 1686 ** when the optimization is enabled. Providing the ability to
1613 ** disable the optimization allows the older, buggy application code to work 1687 ** disable the optimization allows the older, buggy application code to work
1614 ** without change even with newer versions of SQLite. 1688 ** without change even with newer versions of SQLite.
1615 ** 1689 **
1616 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]] 1690 ** [[SQLITE_CONFIG_PCACHE]] [[SQLITE_CONFIG_GETPCACHE]]
1617 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE 1691 ** <dt>SQLITE_CONFIG_PCACHE and SQLITE_CONFIG_GETPCACHE
1618 ** <dd> These options are obsolete and should not be used by new code. 1692 ** <dd> These options are obsolete and should not be used by new code.
1619 ** They are retained for backwards compatibility but are now no-ops. 1693 ** They are retained for backwards compatibility but are now no-ops.
1620 ** </dl> 1694 ** </dd>
1621 ** 1695 **
1622 ** [[SQLITE_CONFIG_SQLLOG]] 1696 ** [[SQLITE_CONFIG_SQLLOG]]
1623 ** <dt>SQLITE_CONFIG_SQLLOG 1697 ** <dt>SQLITE_CONFIG_SQLLOG
1624 ** <dd>This option is only available if sqlite is compiled with the 1698 ** <dd>This option is only available if sqlite is compiled with the
1625 ** SQLITE_ENABLE_SQLLOG pre-processor macro defined. The first argument should 1699 ** [SQLITE_ENABLE_SQLLOG] pre-processor macro defined. The first argument should
1626 ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int). 1700 ** be a pointer to a function of type void(*)(void*,sqlite3*,const char*, int).
1627 ** The second should be of type (void*). The callback is invoked by the library 1701 ** The second should be of type (void*). The callback is invoked by the library
1628 ** in three separate circumstances, identified by the value passed as the 1702 ** in three separate circumstances, identified by the value passed as the
1629 ** fourth parameter. If the fourth parameter is 0, then the database connection 1703 ** fourth parameter. If the fourth parameter is 0, then the database connection
1630 ** passed as the second argument has just been opened. The third argument 1704 ** passed as the second argument has just been opened. The third argument
1631 ** points to a buffer containing the name of the main database file. If the 1705 ** points to a buffer containing the name of the main database file. If the
1632 ** fourth parameter is 1, then the SQL statement that the third parameter 1706 ** fourth parameter is 1, then the SQL statement that the third parameter
1633 ** points to has just been executed. Or, if the fourth parameter is 2, then 1707 ** points to has just been executed. Or, if the fourth parameter is 2, then
1634 ** the connection being passed as the second parameter is being closed. The 1708 ** the connection being passed as the second parameter is being closed. The
1635 ** third parameter is passed NULL In this case. 1709 ** third parameter is passed NULL In this case. An example of using this
1710 ** configuration option can be seen in the "test_sqllog.c" source file in
1711 ** the canonical SQLite source tree.</dd>
1712 **
1713 ** [[SQLITE_CONFIG_MMAP_SIZE]]
1714 ** <dt>SQLITE_CONFIG_MMAP_SIZE
1715 ** <dd>^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values
1716 ** that are the default mmap size limit (the default setting for
1717 ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit.
1718 ** ^The default setting can be overridden by each database connection using
1719 ** either the [PRAGMA mmap_size] command, or by using the
1720 ** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size
1721 ** cannot be changed at run-time. Nor may the maximum allowed mmap size
1722 ** exceed the compile-time maximum mmap size set by the
1723 ** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^
1724 ** ^If either argument to this option is negative, then that argument is
1725 ** changed to its compile-time default.
1726 **
1727 ** [[SQLITE_CONFIG_WIN32_HEAPSIZE]]
1728 ** <dt>SQLITE_CONFIG_WIN32_HEAPSIZE
1729 ** <dd>^This option is only available if SQLite is compiled for Windows
1730 ** with the [SQLITE_WIN32_MALLOC] pre-processor macro defined.
1731 ** SQLITE_CONFIG_WIN32_HEAPSIZE takes a 32-bit unsigned integer value
1732 ** that specifies the maximum size of the created heap.
1636 ** </dl> 1733 ** </dl>
1637 */ 1734 */
1638 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ 1735 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1639 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ 1736 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
1640 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */ 1737 #define SQLITE_CONFIG_SERIALIZED 3 /* nil */
1654 #define SQLITE_CONFIG_URI 17 /* int */ 1751 #define SQLITE_CONFIG_URI 17 /* int */
1655 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */ 1752 #define SQLITE_CONFIG_PCACHE2 18 /* sqlite3_pcache_methods2* */
1656 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */ 1753 #define SQLITE_CONFIG_GETPCACHE2 19 /* sqlite3_pcache_methods2* */
1657 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */ 1754 #define SQLITE_CONFIG_COVERING_INDEX_SCAN 20 /* int */
1658 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */ 1755 #define SQLITE_CONFIG_SQLLOG 21 /* xSqllog, void* */
1756 #define SQLITE_CONFIG_MMAP_SIZE 22 /* sqlite3_int64, sqlite3_int64 */
1757 #define SQLITE_CONFIG_WIN32_HEAPSIZE 23 /* int nByte */
1659 1758
1660 /* 1759 /*
1661 ** CAPI3REF: Database Connection Configuration Options 1760 ** CAPI3REF: Database Connection Configuration Options
1662 ** 1761 **
1663 ** These constants are the available integer configuration options that 1762 ** These constants are the available integer configuration options that
1730 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); 1829 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1731 1830
1732 /* 1831 /*
1733 ** CAPI3REF: Last Insert Rowid 1832 ** CAPI3REF: Last Insert Rowid
1734 ** 1833 **
1735 ** ^Each entry in an SQLite table has a unique 64-bit signed 1834 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
1835 ** has a unique 64-bit signed
1736 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available 1836 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1737 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those 1837 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1738 ** names are not also used by explicitly declared columns. ^If 1838 ** names are not also used by explicitly declared columns. ^If
1739 ** the table has a column of type [INTEGER PRIMARY KEY] then that column 1839 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1740 ** is another alias for the rowid. 1840 ** is another alias for the rowid.
1741 ** 1841 **
1742 ** ^This routine returns the [rowid] of the most recent 1842 ** ^The sqlite3_last_insert_rowid(D) interface returns the [rowid] of the
1743 ** successful [INSERT] into the database from the [database connection] 1843 ** most recent successful [INSERT] into a rowid table or [virtual table]
1744 ** in the first argument. ^As of SQLite version 3.7.7, this routines 1844 ** on database connection D.
1745 ** records the last insert rowid of both ordinary tables and [virtual tables]. 1845 ** ^Inserts into [WITHOUT ROWID] tables are not recorded.
1746 ** ^If no successful [INSERT]s 1846 ** ^If no successful [INSERT]s into rowid tables
1747 ** have ever occurred on that database connection, zero is returned. 1847 ** have ever occurred on the database connection D,
1848 ** then sqlite3_last_insert_rowid(D) returns zero.
1748 ** 1849 **
1749 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table] 1850 ** ^(If an [INSERT] occurs within a trigger or within a [virtual table]
1750 ** method, then this routine will return the [rowid] of the inserted 1851 ** method, then this routine will return the [rowid] of the inserted
1751 ** row as long as the trigger or virtual table method is running. 1852 ** row as long as the trigger or virtual table method is running.
1752 ** But once the trigger or virtual table method ends, the value returned 1853 ** But once the trigger or virtual table method ends, the value returned
2308 ** already uses the largest possible [ROWID]. The PRNG is also used for 2409 ** already uses the largest possible [ROWID]. The PRNG is also used for
2309 ** the build-in random() and randomblob() SQL functions. This interface allows 2410 ** the build-in random() and randomblob() SQL functions. This interface allows
2310 ** applications to access the same PRNG for other purposes. 2411 ** applications to access the same PRNG for other purposes.
2311 ** 2412 **
2312 ** ^A call to this routine stores N bytes of randomness into buffer P. 2413 ** ^A call to this routine stores N bytes of randomness into buffer P.
2313 ** 2414 ** ^If N is less than one, then P can be a NULL pointer.
2314 ** ^The first time this routine is invoked (either internally or by 2415 **
2315 ** the application) the PRNG is seeded using randomness obtained 2416 ** ^If this routine has not been previously called or if the previous
2316 ** from the xRandomness method of the default [sqlite3_vfs] object. 2417 ** call had N less than one, then the PRNG is seeded using randomness
2317 ** ^On all subsequent invocations, the pseudo-randomness is generated 2418 ** obtained from the xRandomness method of the default [sqlite3_vfs] object.
2419 ** ^If the previous call to this routine had an N of 1 or more then
2420 ** the pseudo-randomness is generated
2318 ** internally and without recourse to the [sqlite3_vfs] xRandomness 2421 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2319 ** method. 2422 ** method.
2320 */ 2423 */
2321 SQLITE_API void sqlite3_randomness(int N, void *P); 2424 SQLITE_API void sqlite3_randomness(int N, void *P);
2322 2425
2472 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */ 2575 #define SQLITE_CREATE_VTABLE 29 /* Table Name Module Name */
2473 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */ 2576 #define SQLITE_DROP_VTABLE 30 /* Table Name Module Name */
2474 #define SQLITE_FUNCTION 31 /* NULL Function Name */ 2577 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2475 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ 2578 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2476 #define SQLITE_COPY 0 /* No longer used */ 2579 #define SQLITE_COPY 0 /* No longer used */
2580 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2477 2581
2478 /* 2582 /*
2479 ** CAPI3REF: Tracing And Profiling Functions 2583 ** CAPI3REF: Tracing And Profiling Functions
2480 ** 2584 **
2481 ** These routines register callback functions that can be used for 2585 ** These routines register callback functions that can be used for
2486 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the 2590 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2487 ** SQL statement text as the statement first begins executing. 2591 ** SQL statement text as the statement first begins executing.
2488 ** ^(Additional sqlite3_trace() callbacks might occur 2592 ** ^(Additional sqlite3_trace() callbacks might occur
2489 ** as each triggered subprogram is entered. The callbacks for triggers 2593 ** as each triggered subprogram is entered. The callbacks for triggers
2490 ** contain a UTF-8 SQL comment that identifies the trigger.)^ 2594 ** contain a UTF-8 SQL comment that identifies the trigger.)^
2595 **
2596 ** The [SQLITE_TRACE_SIZE_LIMIT] compile-time option can be used to limit
2597 ** the length of [bound parameter] expansion in the output of sqlite3_trace().
2491 ** 2598 **
2492 ** ^The callback function registered by sqlite3_profile() is invoked 2599 ** ^The callback function registered by sqlite3_profile() is invoked
2493 ** as each SQL statement finishes. ^The profile callback contains 2600 ** as each SQL statement finishes. ^The profile callback contains
2494 ** the original statement text and an estimate of wall-clock time 2601 ** the original statement text and an estimate of wall-clock time
2495 ** of how long that statement took to run. ^The profile callback 2602 ** of how long that statement took to run. ^The profile callback
2512 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for 2619 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2513 ** database connection D. An example use for this 2620 ** database connection D. An example use for this
2514 ** interface is to keep a GUI updated during a large query. 2621 ** interface is to keep a GUI updated during a large query.
2515 ** 2622 **
2516 ** ^The parameter P is passed through as the only parameter to the 2623 ** ^The parameter P is passed through as the only parameter to the
2517 ** callback function X. ^The parameter N is the number of 2624 ** callback function X. ^The parameter N is the approximate number of
2518 ** [virtual machine instructions] that are evaluated between successive 2625 ** [virtual machine instructions] that are evaluated between successive
2519 ** invocations of the callback X. 2626 ** invocations of the callback X. ^If N is less than one then the progress
2627 ** handler is disabled.
2520 ** 2628 **
2521 ** ^Only a single progress handler may be defined at one time per 2629 ** ^Only a single progress handler may be defined at one time per
2522 ** [database connection]; setting a new progress handler cancels the 2630 ** [database connection]; setting a new progress handler cancels the
2523 ** old one. ^Setting parameter X to NULL disables the progress handler. 2631 ** old one. ^Setting parameter X to NULL disables the progress handler.
2524 ** ^The progress handler is also disabled by setting N to a value less 2632 ** ^The progress handler is also disabled by setting N to a value less
2678 ** "private". ^Setting it to "shared" is equivalent to setting the 2786 ** "private". ^Setting it to "shared" is equivalent to setting the
2679 ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to 2787 ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to
2680 ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is 2788 ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is
2681 ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. 2789 ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit.
2682 ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in 2790 ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in
2683 ** a URI filename, its value overrides any behaviour requested by setting 2791 ** a URI filename, its value overrides any behavior requested by setting
2684 ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. 2792 ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
2793 **
2794 ** <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
2795 ** "1") or "false" (or "off" or "no" or "0") to indicate that the
2796 ** [powersafe overwrite] property does or does not apply to the
2797 ** storage media on which the database file resides. ^The psow query
2798 ** parameter only works for the built-in unix and Windows VFSes.
2799 **
2800 ** <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
2801 ** which if set disables file locking in rollback journal modes. This
2802 ** is useful for accessing a database on a filesystem that does not
2803 ** support locking. Caution: Database corruption might result if two
2804 ** or more processes write to the same database and any one of those
2805 ** processes uses nolock=1.
2806 **
2807 ** <li> <b>immutable</b>: ^The immutable parameter is a boolean query
2808 ** parameter that indicates that the database file is stored on
2809 ** read-only media. ^When immutable is set, SQLite assumes that the
2810 ** database file cannot be changed, even by a process with higher
2811 ** privilege, and so the database is opened read-only and all locking
2812 ** and change detection is disabled. Caution: Setting the immutable
2813 ** property on a database file that does in fact change can result
2814 ** in incorrect query results and/or [SQLITE_CORRUPT] errors.
2815 ** See also: [SQLITE_IOCAP_IMMUTABLE].
2816 **
2685 ** </ul> 2817 ** </ul>
2686 ** 2818 **
2687 ** ^Specifying an unknown parameter in the query component of a URI is not an 2819 ** ^Specifying an unknown parameter in the query component of a URI is not an
2688 ** error. Future versions of SQLite might understand additional query 2820 ** error. Future versions of SQLite might understand additional query
2689 ** parameters. See "[query parameters with special meaning to SQLite]" for 2821 ** parameters. See "[query parameters with special meaning to SQLite]" for
2709 ** in URI filenames. 2841 ** in URI filenames.
2710 ** <tr><td> file:data.db?mode=ro&cache=private <td> 2842 ** <tr><td> file:data.db?mode=ro&cache=private <td>
2711 ** Open file "data.db" in the current directory for read-only access. 2843 ** Open file "data.db" in the current directory for read-only access.
2712 ** Regardless of whether or not shared-cache mode is enabled by 2844 ** Regardless of whether or not shared-cache mode is enabled by
2713 ** default, use a private cache. 2845 ** default, use a private cache.
2714 ** <tr><td> file:/home/fred/data.db?vfs=unix-nolock <td> 2846 ** <tr><td> file:/home/fred/data.db?vfs=unix-dotfile <td>
2715 ** Open file "/home/fred/data.db". Use the special VFS "unix-nolock". 2847 ** Open file "/home/fred/data.db". Use the special VFS "unix-dotfile"
2848 ** that uses dot-files in place of posix advisory locking.
2716 ** <tr><td> file:data.db?mode=readonly <td> 2849 ** <tr><td> file:data.db?mode=readonly <td>
2717 ** An error. "readonly" is not a valid option for the "mode" parameter. 2850 ** An error. "readonly" is not a valid option for the "mode" parameter.
2718 ** </table> 2851 ** </table>
2719 ** 2852 **
2720 ** ^URI hexadecimal escape sequences (%HH) are supported within the path and 2853 ** ^URI hexadecimal escape sequences (%HH) are supported within the path and
3025 ** 3158 **
3026 ** <ol> 3159 ** <ol>
3027 ** <li> 3160 ** <li>
3028 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it 3161 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
3029 ** always used to do, [sqlite3_step()] will automatically recompile the SQL 3162 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
3030 ** statement and try to run it again. 3163 ** statement and try to run it again. As many as [SQLITE_MAX_SCHEMA_RETRY]
3164 ** retries will occur before sqlite3_step() gives up and returns an error.
3031 ** </li> 3165 ** </li>
3032 ** 3166 **
3033 ** <li> 3167 ** <li>
3034 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed 3168 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
3035 ** [error codes] or [extended error codes]. ^The legacy behavior was that 3169 ** [error codes] or [extended error codes]. ^The legacy behavior was that
3047 ** to the [sqlite3_bind_text | bindings] of that [parameter]. 3181 ** to the [sqlite3_bind_text | bindings] of that [parameter].
3048 ** ^The specific value of WHERE-clause [parameter] might influence the 3182 ** ^The specific value of WHERE-clause [parameter] might influence the
3049 ** choice of query plan if the parameter is the left-hand side of a [LIKE] 3183 ** choice of query plan if the parameter is the left-hand side of a [LIKE]
3050 ** or [GLOB] operator or if the parameter is compared to an indexed column 3184 ** or [GLOB] operator or if the parameter is compared to an indexed column
3051 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled. 3185 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3052 ** the
3053 ** </li> 3186 ** </li>
3054 ** </ol> 3187 ** </ol>
3055 */ 3188 */
3056 SQLITE_API int sqlite3_prepare( 3189 SQLITE_API int sqlite3_prepare(
3057 sqlite3 *db, /* Database handle */ 3190 sqlite3 *db, /* Database handle */
3229 ** for "?NNN" parameters is the value of NNN. 3362 ** for "?NNN" parameters is the value of NNN.
3230 ** ^The NNN value must be between 1 and the [sqlite3_limit()] 3363 ** ^The NNN value must be between 1 and the [sqlite3_limit()]
3231 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). 3364 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
3232 ** 3365 **
3233 ** ^The third argument is the value to bind to the parameter. 3366 ** ^The third argument is the value to bind to the parameter.
3367 ** ^If the third parameter to sqlite3_bind_text() or sqlite3_bind_text16()
3368 ** or sqlite3_bind_blob() is a NULL pointer then the fourth parameter
3369 ** is ignored and the end result is the same as sqlite3_bind_null().
3234 ** 3370 **
3235 ** ^(In those routines that have a fourth argument, its value is the 3371 ** ^(In those routines that have a fourth argument, its value is the
3236 ** number of bytes in the parameter. To be clear: the value is the 3372 ** number of bytes in the parameter. To be clear: the value is the
3237 ** number of <u>bytes</u> in the value, not the number of characters.)^ 3373 ** number of <u>bytes</u> in the value, not the number of characters.)^
3238 ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() 3374 ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16()
3706 ** <table border="1"> 3842 ** <table border="1">
3707 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion 3843 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
3708 ** 3844 **
3709 ** <tr><td> NULL <td> INTEGER <td> Result is 0 3845 ** <tr><td> NULL <td> INTEGER <td> Result is 0
3710 ** <tr><td> NULL <td> FLOAT <td> Result is 0.0 3846 ** <tr><td> NULL <td> FLOAT <td> Result is 0.0
3711 ** <tr><td> NULL <td> TEXT <td> Result is NULL pointer 3847 ** <tr><td> NULL <td> TEXT <td> Result is a NULL pointer
3712 ** <tr><td> NULL <td> BLOB <td> Result is NULL pointer 3848 ** <tr><td> NULL <td> BLOB <td> Result is a NULL pointer
3713 ** <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float 3849 ** <tr><td> INTEGER <td> FLOAT <td> Convert from integer to float
3714 ** <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer 3850 ** <tr><td> INTEGER <td> TEXT <td> ASCII rendering of the integer
3715 ** <tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT 3851 ** <tr><td> INTEGER <td> BLOB <td> Same as INTEGER->TEXT
3716 ** <tr><td> FLOAT <td> INTEGER <td> Convert from float to integer 3852 ** <tr><td> FLOAT <td> INTEGER <td> [CAST] to INTEGER
3717 ** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float 3853 ** <tr><td> FLOAT <td> TEXT <td> ASCII rendering of the float
3718 ** <tr><td> FLOAT <td> BLOB <td> Same as FLOAT->TEXT 3854 ** <tr><td> FLOAT <td> BLOB <td> [CAST] to BLOB
3719 ** <tr><td> TEXT <td> INTEGER <td> Use atoi() 3855 ** <tr><td> TEXT <td> INTEGER <td> [CAST] to INTEGER
3720 ** <tr><td> TEXT <td> FLOAT <td> Use atof() 3856 ** <tr><td> TEXT <td> FLOAT <td> [CAST] to REAL
3721 ** <tr><td> TEXT <td> BLOB <td> No change 3857 ** <tr><td> TEXT <td> BLOB <td> No change
3722 ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi() 3858 ** <tr><td> BLOB <td> INTEGER <td> [CAST] to INTEGER
3723 ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof() 3859 ** <tr><td> BLOB <td> FLOAT <td> [CAST] to REAL
3724 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed 3860 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
3725 ** </table> 3861 ** </table>
3726 ** </blockquote>)^ 3862 ** </blockquote>)^
3727 ** 3863 **
3728 ** The table above makes reference to standard C library functions atoi() 3864 ** The table above makes reference to standard C library functions atoi()
3774 ** 3910 **
3775 ** ^The pointers returned are valid until a type conversion occurs as 3911 ** ^The pointers returned are valid until a type conversion occurs as
3776 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or 3912 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3777 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings 3913 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
3778 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned 3914 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
3779 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into 3915 ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3780 ** [sqlite3_free()]. 3916 ** [sqlite3_free()].
3781 ** 3917 **
3782 ** ^(If a memory allocation error occurs during the evaluation of any 3918 ** ^(If a memory allocation error occurs during the evaluation of any
3783 ** of these routines, a default value is returned. The default value 3919 ** of these routines, a default value is returned. The default value
3784 ** is either the integer 0, the floating point number 0.0, or a NULL 3920 ** is either the integer 0, the floating point number 0.0, or a NULL
3883 ** parameter is less than -1 or greater than 127 then the behavior is 4019 ** parameter is less than -1 or greater than 127 then the behavior is
3884 ** undefined. 4020 ** undefined.
3885 ** 4021 **
3886 ** ^The fourth parameter, eTextRep, specifies what 4022 ** ^The fourth parameter, eTextRep, specifies what
3887 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for 4023 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
3888 ** its parameters. Every SQL function implementation must be able to work 4024 ** its parameters. The application should set this parameter to
3889 ** with UTF-8, UTF-16le, or UTF-16be. But some implementations may be 4025 ** [SQLITE_UTF16LE] if the function implementation invokes
3890 ** more efficient with one encoding than another. ^An application may 4026 ** [sqlite3_value_text16le()] on an input, or [SQLITE_UTF16BE] if the
3891 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple 4027 ** implementation invokes [sqlite3_value_text16be()] on an input, or
3892 ** times with the same function but with different values of eTextRep. 4028 ** [SQLITE_UTF16] if [sqlite3_value_text16()] is used, or [SQLITE_UTF8]
4029 ** otherwise. ^The same SQL function may be registered multiple times using
4030 ** different preferred text encodings, with different implementations for
4031 ** each encoding.
3893 ** ^When multiple implementations of the same function are available, SQLite 4032 ** ^When multiple implementations of the same function are available, SQLite
3894 ** will pick the one that involves the least amount of data conversion. 4033 ** will pick the one that involves the least amount of data conversion.
3895 ** If there is only a single implementation which does not care what text 4034 **
3896 ** encoding is used, then the fourth argument should be [SQLITE_ANY]. 4035 ** ^The fourth parameter may optionally be ORed with [SQLITE_DETERMINISTIC]
4036 ** to signal that the function will always return the same result given
4037 ** the same inputs within a single SQL statement. Most SQL functions are
4038 ** deterministic. The built-in [random()] SQL function is an example of a
4039 ** function that is not deterministic. The SQLite query planner is able to
4040 ** perform additional optimizations on deterministic functions, so use
4041 ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
3897 ** 4042 **
3898 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the 4043 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
3899 ** function can gain access to this pointer using [sqlite3_user_data()].)^ 4044 ** function can gain access to this pointer using [sqlite3_user_data()].)^
3900 ** 4045 **
3901 ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are 4046 ** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
3977 */ 4122 */
3978 #define SQLITE_UTF8 1 4123 #define SQLITE_UTF8 1
3979 #define SQLITE_UTF16LE 2 4124 #define SQLITE_UTF16LE 2
3980 #define SQLITE_UTF16BE 3 4125 #define SQLITE_UTF16BE 3
3981 #define SQLITE_UTF16 4 /* Use native byte order */ 4126 #define SQLITE_UTF16 4 /* Use native byte order */
3982 #define SQLITE_ANY 5 /* sqlite3_create_function only */ 4127 #define SQLITE_ANY 5 /* Deprecated */
3983 #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */ 4128 #define SQLITE_UTF16_ALIGNED 8 /* sqlite3_create_collation only */
4129
4130 /*
4131 ** CAPI3REF: Function Flags
4132 **
4133 ** These constants may be ORed together with the
4134 ** [SQLITE_UTF8 | preferred text encoding] as the fourth argument
4135 ** to [sqlite3_create_function()], [sqlite3_create_function16()], or
4136 ** [sqlite3_create_function_v2()].
4137 */
4138 #define SQLITE_DETERMINISTIC 0x800
3984 4139
3985 /* 4140 /*
3986 ** CAPI3REF: Deprecated Functions 4141 ** CAPI3REF: Deprecated Functions
3987 ** DEPRECATED 4142 ** DEPRECATED
3988 ** 4143 **
3996 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*); 4151 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
3997 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*); 4152 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
3998 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*); 4153 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
3999 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void); 4154 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4000 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); 4155 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4001 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); 4156 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4157 void*,sqlite3_int64);
4002 #endif 4158 #endif
4003 4159
4004 /* 4160 /*
4005 ** CAPI3REF: Obtaining SQL Function Parameter Values 4161 ** CAPI3REF: Obtaining SQL Function Parameter Values
4006 ** 4162 **
4076 ** an aggregate query, the xStep() callback of the aggregate function 4232 ** an aggregate query, the xStep() callback of the aggregate function
4077 ** implementation is never called and xFinal() is called exactly once. 4233 ** implementation is never called and xFinal() is called exactly once.
4078 ** In those cases, sqlite3_aggregate_context() might be called for the 4234 ** In those cases, sqlite3_aggregate_context() might be called for the
4079 ** first time from within xFinal().)^ 4235 ** first time from within xFinal().)^
4080 ** 4236 **
4081 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is 4237 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
4082 ** less than or equal to zero or if a memory allocate error occurs. 4238 ** when first called if N is less than or equal to zero or if a memory
4239 ** allocate error occurs.
4083 ** 4240 **
4084 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is 4241 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
4085 ** determined by the N parameter on first successful call. Changing the 4242 ** determined by the N parameter on first successful call. Changing the
4086 ** value of N in subsequent call to sqlite3_aggregate_context() within 4243 ** value of N in subsequent call to sqlite3_aggregate_context() within
4087 ** the same aggregate function instance will not resize the memory 4244 ** the same aggregate function instance will not resize the memory
4088 ** allocation.)^ 4245 ** allocation.)^ Within the xFinal callback, it is customary to set
4246 ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no
4247 ** pointless memory allocations occur.
4089 ** 4248 **
4090 ** ^SQLite automatically frees the memory allocated by 4249 ** ^SQLite automatically frees the memory allocated by
4091 ** sqlite3_aggregate_context() when the aggregate query concludes. 4250 ** sqlite3_aggregate_context() when the aggregate query concludes.
4092 ** 4251 **
4093 ** The first parameter must be a copy of the 4252 ** The first parameter must be a copy of the
4126 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); 4285 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4127 4286
4128 /* 4287 /*
4129 ** CAPI3REF: Function Auxiliary Data 4288 ** CAPI3REF: Function Auxiliary Data
4130 ** 4289 **
4131 ** The following two functions may be used by scalar SQL functions to 4290 ** These functions may be used by (non-aggregate) SQL functions to
4132 ** associate metadata with argument values. If the same value is passed to 4291 ** associate metadata with argument values. If the same value is passed to
4133 ** multiple invocations of the same SQL function during query execution, under 4292 ** multiple invocations of the same SQL function during query execution, under
4134 ** some circumstances the associated metadata may be preserved. This may 4293 ** some circumstances the associated metadata may be preserved. An example
4135 ** be used, for example, to add a regular-expression matching scalar 4294 ** of where this might be useful is in a regular-expression matching
4136 ** function. The compiled version of the regular expression is stored as 4295 ** function. The compiled version of the regular expression can be stored as
4137 ** metadata associated with the SQL value passed as the regular expression 4296 ** metadata associated with the pattern string.
4138 ** pattern. The compiled regular expression can be reused on multiple 4297 ** Then as long as the pattern string remains the same,
4139 ** invocations of the same function so that the original pattern string 4298 ** the compiled regular expression can be reused on multiple
4140 ** does not need to be recompiled on each invocation. 4299 ** invocations of the same function.
4141 ** 4300 **
4142 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata 4301 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
4143 ** associated by the sqlite3_set_auxdata() function with the Nth argument 4302 ** associated by the sqlite3_set_auxdata() function with the Nth argument
4144 ** value to the application-defined function. ^If no metadata has been ever 4303 ** value to the application-defined function. ^If there is no metadata
4145 ** been set for the Nth argument of the function, or if the corresponding 4304 ** associated with the function argument, this sqlite3_get_auxdata() interface
4146 ** function parameter has changed since the meta-data was set, 4305 ** returns a NULL pointer.
4147 ** then sqlite3_get_auxdata() returns a NULL pointer. 4306 **
4148 ** 4307 ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
4149 ** ^The sqlite3_set_auxdata() interface saves the metadata 4308 ** argument of the application-defined function. ^Subsequent
4150 ** pointed to by its 3rd parameter as the metadata for the N-th 4309 ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
4151 ** argument of the application-defined function. Subsequent 4310 ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
4152 ** calls to sqlite3_get_auxdata() might return this data, if it has 4311 ** NULL if the metadata has been discarded.
4153 ** not been destroyed. 4312 ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
4154 ** ^If it is not NULL, SQLite will invoke the destructor 4313 ** SQLite will invoke the destructor function X with parameter P exactly
4155 ** function given by the 4th parameter to sqlite3_set_auxdata() on 4314 ** once, when the metadata is discarded.
4156 ** the metadata when the corresponding function parameter changes 4315 ** SQLite is free to discard the metadata at any time, including: <ul>
4157 ** or when the SQL statement completes, whichever comes first. 4316 ** <li> when the corresponding function parameter changes, or
4158 ** 4317 ** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
4159 ** SQLite is free to call the destructor and drop metadata on any 4318 ** SQL statement, or
4160 ** parameter of any function at any time. ^The only guarantee is that 4319 ** <li> when sqlite3_set_auxdata() is invoked again on the same parameter, or
4161 ** the destructor will be called before the metadata is dropped. 4320 ** <li> during the original sqlite3_set_auxdata() call when a memory
4321 ** allocation error occurs. </ul>)^
4322 **
4323 ** Note the last bullet in particular. The destructor X in
4324 ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
4325 ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
4326 ** should be called near the end of the function implementation and the
4327 ** function implementation should not make any use of P after
4328 ** sqlite3_set_auxdata() has been called.
4162 ** 4329 **
4163 ** ^(In practice, metadata is preserved between function calls for 4330 ** ^(In practice, metadata is preserved between function calls for
4164 ** expressions that are constant at compile time. This includes literal 4331 ** function parameters that are compile-time constants, including literal
4165 ** values and [parameters].)^ 4332 ** values and [parameters] and expressions composed from the same.)^
4166 ** 4333 **
4167 ** These routines must be called from the same thread in which 4334 ** These routines must be called from the same thread in which
4168 ** the SQL function is running. 4335 ** the SQL function is running.
4169 */ 4336 */
4170 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); 4337 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4181 ** SQLITE_TRANSIENT value means that the content will likely change in 4348 ** SQLITE_TRANSIENT value means that the content will likely change in
4182 ** the near future and that SQLite should make its own private copy of 4349 ** the near future and that SQLite should make its own private copy of
4183 ** the content before returning. 4350 ** the content before returning.
4184 ** 4351 **
4185 ** The typedef is necessary to work around problems in certain 4352 ** The typedef is necessary to work around problems in certain
4186 ** C++ compilers. See ticket #2191. 4353 ** C++ compilers.
4187 */ 4354 */
4188 typedef void (*sqlite3_destructor_type)(void*); 4355 typedef void (*sqlite3_destructor_type)(void*);
4189 #define SQLITE_STATIC ((sqlite3_destructor_type)0) 4356 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4190 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) 4357 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4191 4358
4465 */ 4632 */
4466 SQLITE_API int sqlite3_key( 4633 SQLITE_API int sqlite3_key(
4467 sqlite3 *db, /* Database to be rekeyed */ 4634 sqlite3 *db, /* Database to be rekeyed */
4468 const void *pKey, int nKey /* The key */ 4635 const void *pKey, int nKey /* The key */
4469 ); 4636 );
4637 SQLITE_API int sqlite3_key_v2(
4638 sqlite3 *db, /* Database to be rekeyed */
4639 const char *zDbName, /* Name of the database */
4640 const void *pKey, int nKey /* The key */
4641 );
4470 4642
4471 /* 4643 /*
4472 ** Change the key on an open database. If the current database is not 4644 ** Change the key on an open database. If the current database is not
4473 ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the 4645 ** encrypted, this routine will encrypt it. If pNew==0 or nNew==0, the
4474 ** database is decrypted. 4646 ** database is decrypted.
4476 ** The code to implement this API is not available in the public release 4648 ** The code to implement this API is not available in the public release
4477 ** of SQLite. 4649 ** of SQLite.
4478 */ 4650 */
4479 SQLITE_API int sqlite3_rekey( 4651 SQLITE_API int sqlite3_rekey(
4480 sqlite3 *db, /* Database to be rekeyed */ 4652 sqlite3 *db, /* Database to be rekeyed */
4653 const void *pKey, int nKey /* The new key */
4654 );
4655 SQLITE_API int sqlite3_rekey_v2(
4656 sqlite3 *db, /* Database to be rekeyed */
4657 const char *zDbName, /* Name of the database */
4481 const void *pKey, int nKey /* The new key */ 4658 const void *pKey, int nKey /* The new key */
4482 ); 4659 );
4483 4660
4484 /* 4661 /*
4485 ** Specify the activation key for a SEE database. Unless 4662 ** Specify the activation key for a SEE database. Unless
4729 /* 4906 /*
4730 ** CAPI3REF: Data Change Notification Callbacks 4907 ** CAPI3REF: Data Change Notification Callbacks
4731 ** 4908 **
4732 ** ^The sqlite3_update_hook() interface registers a callback function 4909 ** ^The sqlite3_update_hook() interface registers a callback function
4733 ** with the [database connection] identified by the first argument 4910 ** with the [database connection] identified by the first argument
4734 ** to be invoked whenever a row is updated, inserted or deleted. 4911 ** to be invoked whenever a row is updated, inserted or deleted in
4912 ** a rowid table.
4735 ** ^Any callback set by a previous call to this function 4913 ** ^Any callback set by a previous call to this function
4736 ** for the same database connection is overridden. 4914 ** for the same database connection is overridden.
4737 ** 4915 **
4738 ** ^The second argument is a pointer to the function to invoke when a 4916 ** ^The second argument is a pointer to the function to invoke when a
4739 ** row is updated, inserted or deleted. 4917 ** row is updated, inserted or deleted in a rowid table.
4740 ** ^The first argument to the callback is a copy of the third argument 4918 ** ^The first argument to the callback is a copy of the third argument
4741 ** to sqlite3_update_hook(). 4919 ** to sqlite3_update_hook().
4742 ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE], 4920 ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
4743 ** or [SQLITE_UPDATE], depending on the operation that caused the callback 4921 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
4744 ** to be invoked. 4922 ** to be invoked.
4747 ** ^The final callback parameter is the [rowid] of the row. 4925 ** ^The final callback parameter is the [rowid] of the row.
4748 ** ^In the case of an update, this is the [rowid] after the update takes place. 4926 ** ^In the case of an update, this is the [rowid] after the update takes place.
4749 ** 4927 **
4750 ** ^(The update hook is not invoked when internal system tables are 4928 ** ^(The update hook is not invoked when internal system tables are
4751 ** modified (i.e. sqlite_master and sqlite_sequence).)^ 4929 ** modified (i.e. sqlite_master and sqlite_sequence).)^
4930 ** ^The update hook is not invoked when [WITHOUT ROWID] tables are modified.
4752 ** 4931 **
4753 ** ^In the current implementation, the update hook 4932 ** ^In the current implementation, the update hook
4754 ** is not invoked when duplication rows are deleted because of an 4933 ** is not invoked when duplication rows are deleted because of an
4755 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook 4934 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
4756 ** invoked when rows are deleted using the [truncate optimization]. 4935 ** invoked when rows are deleted using the [truncate optimization].
4828 /* 5007 /*
4829 ** CAPI3REF: Free Memory Used By A Database Connection 5008 ** CAPI3REF: Free Memory Used By A Database Connection
4830 ** 5009 **
4831 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap 5010 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
4832 ** memory as possible from database connection D. Unlike the 5011 ** memory as possible from database connection D. Unlike the
4833 ** [sqlite3_release_memory()] interface, this interface is effect even 5012 ** [sqlite3_release_memory()] interface, this interface is in effect even
4834 ** when then [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is 5013 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
4835 ** omitted. 5014 ** omitted.
4836 ** 5015 **
4837 ** See also: [sqlite3_release_memory()] 5016 ** See also: [sqlite3_release_memory()]
4838 */ 5017 */
4839 SQLITE_API int sqlite3_db_release_memory(sqlite3*); 5018 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
4980 ** CAPI3REF: Load An Extension 5159 ** CAPI3REF: Load An Extension
4981 ** 5160 **
4982 ** ^This interface loads an SQLite extension library from the named file. 5161 ** ^This interface loads an SQLite extension library from the named file.
4983 ** 5162 **
4984 ** ^The sqlite3_load_extension() interface attempts to load an 5163 ** ^The sqlite3_load_extension() interface attempts to load an
4985 ** SQLite extension library contained in the file zFile. 5164 ** [SQLite extension] library contained in the file zFile. If
5165 ** the file cannot be loaded directly, attempts are made to load
5166 ** with various operating-system specific extensions added.
5167 ** So for example, if "samplelib" cannot be loaded, then names like
5168 ** "samplelib.so" or "samplelib.dylib" or "samplelib.dll" might
5169 ** be tried also.
4986 ** 5170 **
4987 ** ^The entry point is zProc. 5171 ** ^The entry point is zProc.
4988 ** ^zProc may be 0, in which case the name of the entry point 5172 ** ^(zProc may be 0, in which case SQLite will try to come up with an
4989 ** defaults to "sqlite3_extension_init". 5173 ** entry point name on its own. It first tries "sqlite3_extension_init".
5174 ** If that does not work, it constructs a name "sqlite3_X_init" where the
5175 ** X is consists of the lower-case equivalent of all ASCII alphabetic
5176 ** characters in the filename from the last "/" to the first following
5177 ** "." and omitting any initial "lib".)^
4990 ** ^The sqlite3_load_extension() interface returns 5178 ** ^The sqlite3_load_extension() interface returns
4991 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. 5179 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4992 ** ^If an error occurs and pzErrMsg is not 0, then the 5180 ** ^If an error occurs and pzErrMsg is not 0, then the
4993 ** [sqlite3_load_extension()] interface shall attempt to 5181 ** [sqlite3_load_extension()] interface shall attempt to
4994 ** fill *pzErrMsg with error message text stored in memory 5182 ** fill *pzErrMsg with error message text stored in memory
5010 5198
5011 /* 5199 /*
5012 ** CAPI3REF: Enable Or Disable Extension Loading 5200 ** CAPI3REF: Enable Or Disable Extension Loading
5013 ** 5201 **
5014 ** ^So as not to open security holes in older applications that are 5202 ** ^So as not to open security holes in older applications that are
5015 ** unprepared to deal with extension loading, and as a means of disabling 5203 ** unprepared to deal with [extension loading], and as a means of disabling
5016 ** extension loading while evaluating user-entered SQL, the following API 5204 ** [extension loading] while evaluating user-entered SQL, the following API
5017 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. 5205 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
5018 ** 5206 **
5019 ** ^Extension loading is off by default. See ticket #1863. 5207 ** ^Extension loading is off by default.
5020 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1 5208 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5021 ** to turn extension loading on and call it with onoff==0 to turn 5209 ** to turn extension loading on and call it with onoff==0 to turn
5022 ** it back off again. 5210 ** it back off again.
5023 */ 5211 */
5024 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); 5212 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5026 /* 5214 /*
5027 ** CAPI3REF: Automatically Load Statically Linked Extensions 5215 ** CAPI3REF: Automatically Load Statically Linked Extensions
5028 ** 5216 **
5029 ** ^This interface causes the xEntryPoint() function to be invoked for 5217 ** ^This interface causes the xEntryPoint() function to be invoked for
5030 ** each new [database connection] that is created. The idea here is that 5218 ** each new [database connection] that is created. The idea here is that
5031 ** xEntryPoint() is the entry point for a statically linked SQLite extension 5219 ** xEntryPoint() is the entry point for a statically linked [SQLite extension]
5032 ** that is to be automatically loaded into all new database connections. 5220 ** that is to be automatically loaded into all new database connections.
5033 ** 5221 **
5034 ** ^(Even though the function prototype shows that xEntryPoint() takes 5222 ** ^(Even though the function prototype shows that xEntryPoint() takes
5035 ** no arguments and returns void, SQLite invokes xEntryPoint() with three 5223 ** no arguments and returns void, SQLite invokes xEntryPoint() with three
5036 ** arguments and expects and integer result as if the signature of the 5224 ** arguments and expects and integer result as if the signature of the
5054 ** 5242 **
5055 ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already 5243 ** ^Calling sqlite3_auto_extension(X) with an entry point X that is already
5056 ** on the list of automatic extensions is a harmless no-op. ^No entry point 5244 ** on the list of automatic extensions is a harmless no-op. ^No entry point
5057 ** will be called more than once for each database connection that is opened. 5245 ** will be called more than once for each database connection that is opened.
5058 ** 5246 **
5059 ** See also: [sqlite3_reset_auto_extension()]. 5247 ** See also: [sqlite3_reset_auto_extension()]
5248 ** and [sqlite3_cancel_auto_extension()]
5060 */ 5249 */
5061 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); 5250 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5251
5252 /*
5253 ** CAPI3REF: Cancel Automatic Extension Loading
5254 **
5255 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
5256 ** initialization routine X that was registered using a prior call to
5257 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5258 ** routine returns 1 if initialization routine X was successfully
5259 ** unregistered and it returns 0 if X was not on the list of initialization
5260 ** routines.
5261 */
5262 SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5062 5263
5063 /* 5264 /*
5064 ** CAPI3REF: Reset Automatic Extension Loading 5265 ** CAPI3REF: Reset Automatic Extension Loading
5065 ** 5266 **
5066 ** ^This interface disables all automatic extensions previously 5267 ** ^This interface disables all automatic extensions previously
5182 ** 5383 **
5183 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in 5384 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
5184 ** the correct order to satisfy the ORDER BY clause so that no separate 5385 ** the correct order to satisfy the ORDER BY clause so that no separate
5185 ** sorting step is required. 5386 ** sorting step is required.
5186 ** 5387 **
5187 ** ^The estimatedCost value is an estimate of the cost of doing the 5388 ** ^The estimatedCost value is an estimate of the cost of a particular
5188 ** particular lookup. A full scan of a table with N entries should have 5389 ** strategy. A cost of N indicates that the cost of the strategy is similar
5189 ** a cost of N. A binary search of a table of N entries should have a 5390 ** to a linear scan of an SQLite table with N rows. A cost of log(N)
5190 ** cost of approximately log(N). 5391 ** indicates that the expense of the operation is similar to that of a
5392 ** binary search on a unique indexed field of an SQLite table with N rows.
5393 **
5394 ** ^The estimatedRows value is an estimate of the number of rows that
5395 ** will be returned by the strategy.
5396 **
5397 ** IMPORTANT: The estimatedRows field was added to the sqlite3_index_info
5398 ** structure for SQLite version 3.8.2. If a virtual table extension is
5399 ** used with an SQLite version earlier than 3.8.2, the results of attempting
5400 ** to read or write the estimatedRows field are undefined (but are likely
5401 ** to included crashing the application). The estimatedRows field should
5402 ** therefore only be used if [sqlite3_libversion_number()] returns a
5403 ** value greater than or equal to 3008002.
5191 */ 5404 */
5192 struct sqlite3_index_info { 5405 struct sqlite3_index_info {
5193 /* Inputs */ 5406 /* Inputs */
5194 int nConstraint; /* Number of entries in aConstraint */ 5407 int nConstraint; /* Number of entries in aConstraint */
5195 struct sqlite3_index_constraint { 5408 struct sqlite3_index_constraint {
5210 } *aConstraintUsage; 5423 } *aConstraintUsage;
5211 int idxNum; /* Number used to identify the index */ 5424 int idxNum; /* Number used to identify the index */
5212 char *idxStr; /* String, possibly obtained from sqlite3_malloc */ 5425 char *idxStr; /* String, possibly obtained from sqlite3_malloc */
5213 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */ 5426 int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
5214 int orderByConsumed; /* True if output is already ordered */ 5427 int orderByConsumed; /* True if output is already ordered */
5215 double estimatedCost; /* Estimated cost of using this index */ 5428 double estimatedCost; /* Estimated cost of using this index */
5429 /* Fields below are only available in SQLite 3.8.2 and later */
5430 sqlite3_int64 estimatedRows; /* Estimated number of rows returned */
5216 }; 5431 };
5217 5432
5218 /* 5433 /*
5219 ** CAPI3REF: Virtual Table Constraint Operator Codes 5434 ** CAPI3REF: Virtual Table Constraint Operator Codes
5220 ** 5435 **
5413 ** 5628 **
5414 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of 5629 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
5415 ** the opened blob. ^The size of a blob may not be changed by this 5630 ** the opened blob. ^The size of a blob may not be changed by this
5416 ** interface. Use the [UPDATE] SQL command to change the size of a 5631 ** interface. Use the [UPDATE] SQL command to change the size of a
5417 ** blob. 5632 ** blob.
5633 **
5634 ** ^The [sqlite3_blob_open()] interface will fail for a [WITHOUT ROWID]
5635 ** table. Incremental BLOB I/O is not possible on [WITHOUT ROWID] tables.
5418 ** 5636 **
5419 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces 5637 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
5420 ** and the built-in [zeroblob] SQL function can be used, if desired, 5638 ** and the built-in [zeroblob] SQL function can be used, if desired,
5421 ** to create an empty, zero-filled blob in which to read or write using 5639 ** to create an empty, zero-filled blob in which to read or write using
5422 ** this interface. 5640 ** this interface.
5937 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 6155 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
5938 #define SQLITE_TESTCTRL_ISKEYWORD 16 6156 #define SQLITE_TESTCTRL_ISKEYWORD 16
5939 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 6157 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17
5940 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 6158 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
5941 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 6159 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19
5942 #define SQLITE_TESTCTRL_LAST 19 6160 #define SQLITE_TESTCTRL_NEVER_CORRUPT 20
6161 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21
6162 #define SQLITE_TESTCTRL_BYTEORDER 22
6163 #define SQLITE_TESTCTRL_LAST 22
5943 6164
5944 /* 6165 /*
5945 ** CAPI3REF: SQLite Runtime Status 6166 ** CAPI3REF: SQLite Runtime Status
5946 ** 6167 **
5947 ** ^This interface is used to retrieve runtime status information 6168 ** ^This interface is used to retrieve runtime status information
6170 ** transaction rollback or database recovery operations are not included. 6391 ** transaction rollback or database recovery operations are not included.
6171 ** If an IO or other error occurs while writing a page to disk, the effect 6392 ** If an IO or other error occurs while writing a page to disk, the effect
6172 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The 6393 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined.)^ ^The
6173 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0. 6394 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6174 ** </dd> 6395 ** </dd>
6396 **
6397 ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt>
6398 ** <dd>This parameter returns zero for the current value if and only if
6399 ** all foreign key constraints (deferred or immediate) have been
6400 ** resolved.)^ ^The highwater mark is always 0.
6401 ** </dd>
6175 ** </dl> 6402 ** </dl>
6176 */ 6403 */
6177 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 6404 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6178 #define SQLITE_DBSTATUS_CACHE_USED 1 6405 #define SQLITE_DBSTATUS_CACHE_USED 1
6179 #define SQLITE_DBSTATUS_SCHEMA_USED 2 6406 #define SQLITE_DBSTATUS_SCHEMA_USED 2
6182 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5 6409 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6183 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6 6410 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6184 #define SQLITE_DBSTATUS_CACHE_HIT 7 6411 #define SQLITE_DBSTATUS_CACHE_HIT 7
6185 #define SQLITE_DBSTATUS_CACHE_MISS 8 6412 #define SQLITE_DBSTATUS_CACHE_MISS 8
6186 #define SQLITE_DBSTATUS_CACHE_WRITE 9 6413 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6187 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */ 6414 #define SQLITE_DBSTATUS_DEFERRED_FKS 10
6415 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6188 6416
6189 6417
6190 /* 6418 /*
6191 ** CAPI3REF: Prepared Statement Status 6419 ** CAPI3REF: Prepared Statement Status
6192 ** 6420 **
6236 ** <dd>^This is the number of rows inserted into transient indices that 6464 ** <dd>^This is the number of rows inserted into transient indices that
6237 ** were created automatically in order to help joins run faster. 6465 ** were created automatically in order to help joins run faster.
6238 ** A non-zero value in this counter may indicate an opportunity to 6466 ** A non-zero value in this counter may indicate an opportunity to
6239 ** improvement performance by adding permanent indices that do not 6467 ** improvement performance by adding permanent indices that do not
6240 ** need to be reinitialized each time the statement is run.</dd> 6468 ** need to be reinitialized each time the statement is run.</dd>
6469 **
6470 ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt>
6471 ** <dd>^This is the number of virtual machine operations executed
6472 ** by the prepared statement if that number is less than or equal
6473 ** to 2147483647. The number of virtual machine operations can be
6474 ** used as a proxy for the total work done by the prepared statement.
6475 ** If the number of virtual machine operations exceeds 2147483647
6476 ** then the value returned by this statement status code is undefined.
6477 ** </dd>
6241 ** </dl> 6478 ** </dl>
6242 */ 6479 */
6243 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1 6480 #define SQLITE_STMTSTATUS_FULLSCAN_STEP 1
6244 #define SQLITE_STMTSTATUS_SORT 2 6481 #define SQLITE_STMTSTATUS_SORT 2
6245 #define SQLITE_STMTSTATUS_AUTOINDEX 3 6482 #define SQLITE_STMTSTATUS_AUTOINDEX 3
6483 #define SQLITE_STMTSTATUS_VM_STEP 4
6246 6484
6247 /* 6485 /*
6248 ** CAPI3REF: Custom Page Cache Object 6486 ** CAPI3REF: Custom Page Cache Object
6249 ** 6487 **
6250 ** The sqlite3_pcache type is opaque. It is implemented by 6488 ** The sqlite3_pcache type is opaque. It is implemented by
6377 ** intact. If the requested page is not already in the cache, then the 6615 ** intact. If the requested page is not already in the cache, then the
6378 ** cache implementation should use the value of the createFlag 6616 ** cache implementation should use the value of the createFlag
6379 ** parameter to help it determined what action to take: 6617 ** parameter to help it determined what action to take:
6380 ** 6618 **
6381 ** <table border=1 width=85% align=center> 6619 ** <table border=1 width=85% align=center>
6382 ** <tr><th> createFlag <th> Behaviour when page is not already in cache 6620 ** <tr><th> createFlag <th> Behavior when page is not already in cache
6383 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. 6621 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
6384 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. 6622 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
6385 ** Otherwise return NULL. 6623 ** Otherwise return NULL.
6386 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return 6624 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
6387 ** NULL if allocating a new page is effectively impossible. 6625 ** NULL if allocating a new page is effectively impossible.
6807 */ 7045 */
6808 SQLITE_API int sqlite3_stricmp(const char *, const char *); 7046 SQLITE_API int sqlite3_stricmp(const char *, const char *);
6809 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); 7047 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
6810 7048
6811 /* 7049 /*
7050 ** CAPI3REF: String Globbing
7051 *
7052 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
7053 ** the glob pattern P, and it returns non-zero if string X does not match
7054 ** the glob pattern P. ^The definition of glob pattern matching used in
7055 ** [sqlite3_strglob(P,X)] is the same as for the "X GLOB P" operator in the
7056 ** SQL dialect used by SQLite. ^The sqlite3_strglob(P,X) function is case
7057 ** sensitive.
7058 **
7059 ** Note that this routine returns zero on a match and non-zero if the strings
7060 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7061 */
7062 SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7063
7064 /*
6812 ** CAPI3REF: Error Logging Interface 7065 ** CAPI3REF: Error Logging Interface
6813 ** 7066 **
6814 ** ^The [sqlite3_log()] interface writes a message into the error log 7067 ** ^The [sqlite3_log()] interface writes a message into the [error log]
6815 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()]. 7068 ** established by the [SQLITE_CONFIG_LOG] option to [sqlite3_config()].
6816 ** ^If logging is enabled, the zFormat string and subsequent arguments are 7069 ** ^If logging is enabled, the zFormat string and subsequent arguments are
6817 ** used with [sqlite3_snprintf()] to generate the final output string. 7070 ** used with [sqlite3_snprintf()] to generate the final output string.
6818 ** 7071 **
6819 ** The sqlite3_log() interface is intended for use by extensions such as 7072 ** The sqlite3_log() interface is intended for use by extensions such as
7104 #endif 7357 #endif
7105 7358
7106 #ifdef __cplusplus 7359 #ifdef __cplusplus
7107 } /* End of the 'extern "C"' block */ 7360 } /* End of the 'extern "C"' block */
7108 #endif 7361 #endif
7109 #endif 7362 #endif /* _SQLITE3_H_ */
7110 7363
7111 /* 7364 /*
7112 ** 2010 August 30 7365 ** 2010 August 30
7113 ** 7366 **
7114 ** The author disclaims copyright to this source code. In place of 7367 ** The author disclaims copyright to this source code. In place of
7128 #ifdef __cplusplus 7381 #ifdef __cplusplus
7129 extern "C" { 7382 extern "C" {
7130 #endif 7383 #endif
7131 7384
7132 typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry; 7385 typedef struct sqlite3_rtree_geometry sqlite3_rtree_geometry;
7386 typedef struct sqlite3_rtree_query_info sqlite3_rtree_query_info;
7387
7388 /* The double-precision datatype used by RTree depends on the
7389 ** SQLITE_RTREE_INT_ONLY compile-time option.
7390 */
7391 #ifdef SQLITE_RTREE_INT_ONLY
7392 typedef sqlite3_int64 sqlite3_rtree_dbl;
7393 #else
7394 typedef double sqlite3_rtree_dbl;
7395 #endif
7133 7396
7134 /* 7397 /*
7135 ** Register a geometry callback named zGeom that can be used as part of an 7398 ** Register a geometry callback named zGeom that can be used as part of an
7136 ** R-Tree geometry query as follows: 7399 ** R-Tree geometry query as follows:
7137 ** 7400 **
7138 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...) 7401 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7139 */ 7402 */
7140 SQLITE_API int sqlite3_rtree_geometry_callback( 7403 SQLITE_API int sqlite3_rtree_geometry_callback(
7141 sqlite3 *db, 7404 sqlite3 *db,
7142 const char *zGeom, 7405 const char *zGeom,
7143 #ifdef SQLITE_RTREE_INT_ONLY 7406 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7144 int (*xGeom)(sqlite3_rtree_geometry*, int n, sqlite3_int64 *a, int *pRes),
7145 #else
7146 int (*xGeom)(sqlite3_rtree_geometry*, int n, double *a, int *pRes),
7147 #endif
7148 void *pContext 7407 void *pContext
7149 ); 7408 );
7150 7409
7151 7410
7152 /* 7411 /*
7154 ** argument to callbacks registered using rtree_geometry_callback(). 7413 ** argument to callbacks registered using rtree_geometry_callback().
7155 */ 7414 */
7156 struct sqlite3_rtree_geometry { 7415 struct sqlite3_rtree_geometry {
7157 void *pContext; /* Copy of pContext passed to s_r_g_c() */ 7416 void *pContext; /* Copy of pContext passed to s_r_g_c() */
7158 int nParam; /* Size of array aParam[] */ 7417 int nParam; /* Size of array aParam[] */
7159 double *aParam; /* Parameters passed to SQL geom function */ 7418 sqlite3_rtree_dbl *aParam; /* Parameters passed to SQL geom function */
7160 void *pUser; /* Callback implementation user data */ 7419 void *pUser; /* Callback implementation user data */
7161 void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */ 7420 void (*xDelUser)(void *); /* Called by SQLite to clean up pUser */
7162 }; 7421 };
7163 7422
7423 /*
7424 ** Register a 2nd-generation geometry callback named zScore that can be
7425 ** used as part of an R-Tree geometry query as follows:
7426 **
7427 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7428 */
7429 SQLITE_API int sqlite3_rtree_query_callback(
7430 sqlite3 *db,
7431 const char *zQueryFunc,
7432 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7433 void *pContext,
7434 void (*xDestructor)(void*)
7435 );
7436
7437
7438 /*
7439 ** A pointer to a structure of the following type is passed as the
7440 ** argument to scored geometry callback registered using
7441 ** sqlite3_rtree_query_callback().
7442 **
7443 ** Note that the first 5 fields of this structure are identical to
7444 ** sqlite3_rtree_geometry. This structure is a subclass of
7445 ** sqlite3_rtree_geometry.
7446 */
7447 struct sqlite3_rtree_query_info {
7448 void *pContext; /* pContext from when function registered */
7449 int nParam; /* Number of function parameters */
7450 sqlite3_rtree_dbl *aParam; /* value of function parameters */
7451 void *pUser; /* callback can use this, if desired */
7452 void (*xDelUser)(void*); /* function to free pUser */
7453 sqlite3_rtree_dbl *aCoord; /* Coordinates of node or entry to check */
7454 unsigned int *anQueue; /* Number of pending entries in the queue */
7455 int nCoord; /* Number of coordinates */
7456 int iLevel; /* Level of current node or entry */
7457 int mxLevel; /* The largest iLevel value in the tree */
7458 sqlite3_int64 iRowid; /* Rowid for current entry */
7459 sqlite3_rtree_dbl rParentScore; /* Score of parent node */
7460 int eParentWithin; /* Visibility of parent node */
7461 int eWithin; /* OUT: Visiblity */
7462 sqlite3_rtree_dbl rScore; /* OUT: Write the score here */
7463 };
7464
7465 /*
7466 ** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.
7467 */
7468 #define NOT_WITHIN 0 /* Object completely outside of query region */
7469 #define PARTLY_WITHIN 1 /* Object partially overlaps query region */
7470 #define FULLY_WITHIN 2 /* Object fully contained within query region */
7471
7164 7472
7165 #ifdef __cplusplus 7473 #ifdef __cplusplus
7166 } /* end of the 'extern "C"' block */ 7474 } /* end of the 'extern "C"' block */
7167 #endif 7475 #endif
7168 7476