Fossil SCM

Update the built-in SQLite to version 3.6.22 RC 1.

drh 2010-01-04 13:16 UTC trunk
Commit 57225017b09f9cd620963a0a0b35fc8f488afca5
2 files changed +4026 -3038 +1410 -1525
+4026 -3038
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.6.21. By combining all the individual C code files into this
3
+** version 3.6.22. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a one translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% are more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -603,88 +603,81 @@
603603
#ifdef SQLITE_VERSION_NUMBER
604604
# undef SQLITE_VERSION_NUMBER
605605
#endif
606606
607607
/*
608
-** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
609
-**
610
-** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
611
-** the sqlite3.h file specify the version of SQLite with which
612
-** that header file is associated.
613
-**
614
-** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
615
-** The W value is major version number and is always 3 in SQLite3.
616
-** The W value only changes when backwards compatibility is
617
-** broken and we intend to never break backwards compatibility.
618
-** The X value is the minor version number and only changes when
619
-** there are major feature enhancements that are forwards compatible
620
-** but not backwards compatible.
621
-** The Y value is the release number and is incremented with
622
-** each release but resets back to 0 whenever X is incremented.
623
-** The Z value only appears on branch releases.
624
-**
625
-** The SQLITE_VERSION_NUMBER is an integer that is computed as
626
-** follows:
627
-**
628
-** <blockquote><pre>
629
-** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
630
-** </pre></blockquote>
608
+** CAPI3REF: Compile-Time Library Version Numbers
609
+**
610
+** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
611
+** evaluates to a string literal that is the SQLite version in the
612
+** format "X.Y.Z" where X is the major version number (always 3 for
613
+** SQLite3) and Y is the minor version number and Z is the release number.)^
614
+** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
615
+** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
616
+** numbers used in [SQLITE_VERSION].)^
617
+** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
618
+** be larger than the release from which it is derived. Either Y will
619
+** be held constant and Z will be incremented or else Y will be incremented
620
+** and Z will be reset to zero.
631621
**
632622
** Since version 3.6.18, SQLite source code has been stored in the
633
-** <a href="http://www.fossil-scm.org/">fossil configuration management
634
-** system</a>. The SQLITE_SOURCE_ID
635
-** macro is a string which identifies a particular check-in of SQLite
636
-** within its configuration management system. The string contains the
637
-** date and time of the check-in (UTC) and an SHA1 hash of the entire
638
-** source tree.
623
+** <a href="http://www.fossil-scm.org/">Fossil configuration management
624
+** system</a>. ^The SQLITE_SOURCE_ID macro evalutes to
625
+** a string which identifies a particular check-in of SQLite
626
+** within its configuration management system. ^The SQLITE_SOURCE_ID
627
+** string contains the date and time of the check-in (UTC) and an SHA1
628
+** hash of the entire source tree.
639629
**
640630
** See also: [sqlite3_libversion()],
641631
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
642632
** [sqlite_version()] and [sqlite_source_id()].
643
-**
644
-** Requirements: [H10011] [H10014]
645633
*/
646
-#define SQLITE_VERSION "3.6.21"
647
-#define SQLITE_VERSION_NUMBER 3006021
648
-#define SQLITE_SOURCE_ID "2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c"
634
+#define SQLITE_VERSION "3.6.22"
635
+#define SQLITE_VERSION_NUMBER 3006022
636
+#define SQLITE_SOURCE_ID "2010-01-02 19:02:02 51f7ee844057086789dcfcdcba7daf45343cae62"
649637
650638
/*
651
-** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
639
+** CAPI3REF: Run-Time Library Version Numbers
652640
** KEYWORDS: sqlite3_version
653641
**
654642
** These interfaces provide the same information as the [SQLITE_VERSION],
655
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
656
-** but are associated with the library instead of the header file. Cautious
643
+** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
644
+** but are associated with the library instead of the header file. ^(Cautious
657645
** programmers might include assert() statements in their application to
658646
** verify that values returned by these interfaces match the macros in
659647
** the header, and thus insure that the application is
660648
** compiled with matching library and header files.
661649
**
662650
** <blockquote><pre>
663651
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
664652
** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
665
-** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
666
-** </pre></blockquote>
653
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
654
+** </pre></blockquote>)^
667655
**
668
-** The sqlite3_libversion() function returns the same information as is
669
-** in the sqlite3_version[] string constant. The function is provided
670
-** for use in DLLs since DLL users usually do not have direct access to string
671
-** constants within the DLL. Similarly, the sqlite3_sourceid() function
672
-** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
673
-** the header file.
656
+** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
657
+** macro. ^The sqlite3_libversion() function returns a pointer to the
658
+** to the sqlite3_version[] string constant. The sqlite3_libversion()
659
+** function is provided for use in DLLs since DLL users usually do not have
660
+** direct access to string constants within the DLL. ^The
661
+** sqlite3_libversion_number() function returns an integer equal to
662
+** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer
663
+** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
664
+** C preprocessor macro.
674665
**
675666
** See also: [sqlite_version()] and [sqlite_source_id()].
676
-**
677
-** Requirements: [H10021] [H10022] [H10023]
678667
*/
679668
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
680669
SQLITE_API const char *sqlite3_libversion(void);
681670
SQLITE_API const char *sqlite3_sourceid(void);
682671
SQLITE_API int sqlite3_libversion_number(void);
683672
684673
/*
685
-** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
674
+** CAPI3REF: Test To See If The Library Is Threadsafe
675
+**
676
+** ^The sqlite3_threadsafe() function returns zero if and only if
677
+** SQLite was compiled mutexing code omitted due to the
678
+** [SQLITE_THREADSAFE] compile-time option being set to 0.
686679
**
687680
** SQLite can be compiled with or without mutexes. When
688681
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
689682
** are enabled and SQLite is threadsafe. When the
690683
** [SQLITE_THREADSAFE] macro is 0,
@@ -692,33 +685,33 @@
692685
** to use SQLite concurrently from more than one thread.
693686
**
694687
** Enabling mutexes incurs a measurable performance penalty.
695688
** So if speed is of utmost importance, it makes sense to disable
696689
** the mutexes. But for maximum safety, mutexes should be enabled.
697
-** The default behavior is for mutexes to be enabled.
690
+** ^The default behavior is for mutexes to be enabled.
698691
**
699692
** This interface can be used by an application to make sure that the
700693
** version of SQLite that it is linking against was compiled with
701694
** the desired setting of the [SQLITE_THREADSAFE] macro.
702695
**
703696
** This interface only reports on the compile-time mutex setting
704697
** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
705
-** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
698
+** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
706699
** can be fully or partially disabled using a call to [sqlite3_config()]
707700
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
708
-** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows
709
-** only the default compile-time setting, not any run-time changes
710
-** to that setting.
701
+** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
702
+** sqlite3_threadsafe() function shows only the compile-time setting of
703
+** thread safety, not any run-time changes to that setting made by
704
+** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
705
+** is unchanged by calls to sqlite3_config().)^
711706
**
712707
** See the [threading mode] documentation for additional information.
713
-**
714
-** Requirements: [H10101] [H10102]
715708
*/
716709
SQLITE_API int sqlite3_threadsafe(void);
717710
718711
/*
719
-** CAPI3REF: Database Connection Handle {H12000} <S40200>
712
+** CAPI3REF: Database Connection Handle
720713
** KEYWORDS: {database connection} {database connections}
721714
**
722715
** Each open SQLite database is represented by a pointer to an instance of
723716
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
724717
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -729,21 +722,24 @@
729722
** sqlite3 object.
730723
*/
731724
typedef struct sqlite3 sqlite3;
732725
733726
/*
734
-** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
727
+** CAPI3REF: 64-Bit Integer Types
735728
** KEYWORDS: sqlite_int64 sqlite_uint64
736729
**
737730
** Because there is no cross-platform way to specify 64-bit integer types
738731
** SQLite includes typedefs for 64-bit signed and unsigned integers.
739732
**
740733
** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
741734
** The sqlite_int64 and sqlite_uint64 types are supported for backwards
742735
** compatibility only.
743736
**
744
-** Requirements: [H10201] [H10202]
737
+** ^The sqlite3_int64 and sqlite_int64 types can store integer values
738
+** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
739
+** sqlite3_uint64 and sqlite_uint64 types can store integer values
740
+** between 0 and +18446744073709551615 inclusive.
745741
*/
746742
#ifdef SQLITE_INT64_TYPE
747743
typedef SQLITE_INT64_TYPE sqlite_int64;
748744
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
749745
#elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -763,28 +759,32 @@
763759
#ifdef SQLITE_OMIT_FLOATING_POINT
764760
# define double sqlite3_int64
765761
#endif
766762
767763
/*
768
-** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
764
+** CAPI3REF: Closing A Database Connection
769765
**
770
-** This routine is the destructor for the [sqlite3] object.
766
+** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
767
+** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
768
+** successfullly destroyed and all associated resources are deallocated.
771769
**
772770
** Applications must [sqlite3_finalize | finalize] all [prepared statements]
773771
** and [sqlite3_blob_close | close] all [BLOB handles] associated with
774
-** the [sqlite3] object prior to attempting to close the object.
772
+** the [sqlite3] object prior to attempting to close the object. ^If
773
+** sqlite3_close() is called on a [database connection] that still has
774
+** outstanding [prepared statements] or [BLOB handles], then it returns
775
+** SQLITE_BUSY.
775776
**
776
-** If [sqlite3_close()] is invoked while a transaction is open,
777
+** ^If [sqlite3_close()] is invoked while a transaction is open,
777778
** the transaction is automatically rolled back.
778779
**
779780
** The C parameter to [sqlite3_close(C)] must be either a NULL
780781
** pointer or an [sqlite3] object pointer obtained
781782
** from [sqlite3_open()], [sqlite3_open16()], or
782783
** [sqlite3_open_v2()], and not previously closed.
783
-**
784
-** Requirements:
785
-** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
784
+** ^Calling sqlite3_close() with a NULL pointer argument is a
785
+** harmless no-op.
786786
*/
787787
SQLITE_API int sqlite3_close(sqlite3 *);
788788
789789
/*
790790
** The type for a callback function.
@@ -792,52 +792,69 @@
792792
** compatibility and is not documented.
793793
*/
794794
typedef int (*sqlite3_callback)(void*,int,char**, char**);
795795
796796
/*
797
-** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
798
-**
799
-** The sqlite3_exec() interface is a convenient way of running one or more
800
-** SQL statements without having to write a lot of C code. The UTF-8 encoded
801
-** SQL statements are passed in as the second parameter to sqlite3_exec().
802
-** The statements are evaluated one by one until either an error or
803
-** an interrupt is encountered, or until they are all done. The 3rd parameter
804
-** is an optional callback that is invoked once for each row of any query
805
-** results produced by the SQL statements. The 5th parameter tells where
806
-** to write any error messages.
807
-**
808
-** The error message passed back through the 5th parameter is held
809
-** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak,
810
-** the calling application should call [sqlite3_free()] on any error
811
-** message returned through the 5th parameter when it has finished using
812
-** the error message.
813
-**
814
-** If the SQL statement in the 2nd parameter is NULL or an empty string
815
-** or a string containing only whitespace and comments, then no SQL
816
-** statements are evaluated and the database is not changed.
817
-**
818
-** The sqlite3_exec() interface is implemented in terms of
819
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
820
-** The sqlite3_exec() routine does nothing to the database that cannot be done
821
-** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
822
-**
823
-** The first parameter to [sqlite3_exec()] must be an valid and open
824
-** [database connection].
825
-**
826
-** The database connection must not be closed while
827
-** [sqlite3_exec()] is running.
828
-**
829
-** The calling function should use [sqlite3_free()] to free
830
-** the memory that *errmsg is left pointing at once the error
831
-** message is no longer needed.
832
-**
833
-** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
834
-** must remain unchanged while [sqlite3_exec()] is running.
835
-**
836
-** Requirements:
837
-** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
838
-** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
797
+** CAPI3REF: One-Step Query Execution Interface
798
+**
799
+** The sqlite3_exec() interface is a convenience wrapper around
800
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
801
+** that allows an application to run multiple statements of SQL
802
+** without having to use a lot of C code.
803
+**
804
+** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
805
+** semicolon-separate SQL statements passed into its 2nd argument,
806
+** in the context of the [database connection] passed in as its 1st
807
+** argument. ^If the callback function of the 3rd argument to
808
+** sqlite3_exec() is not NULL, then it is invoked for each result row
809
+** coming out of the evaluated SQL statements. ^The 4th argument to
810
+** to sqlite3_exec() is relayed through to the 1st argument of each
811
+** callback invocation. ^If the callback pointer to sqlite3_exec()
812
+** is NULL, then no callback is ever invoked and result rows are
813
+** ignored.
814
+**
815
+** ^If an error occurs while evaluating the SQL statements passed into
816
+** sqlite3_exec(), then execution of the current statement stops and
817
+** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
818
+** is not NULL then any error message is written into memory obtained
819
+** from [sqlite3_malloc()] and passed back through the 5th parameter.
820
+** To avoid memory leaks, the application should invoke [sqlite3_free()]
821
+** on error message strings returned through the 5th parameter of
822
+** of sqlite3_exec() after the error message string is no longer needed.
823
+** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
824
+** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
825
+** NULL before returning.
826
+**
827
+** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
828
+** routine returns SQLITE_ABORT without invoking the callback again and
829
+** without running any subsequent SQL statements.
830
+**
831
+** ^The 2nd argument to the sqlite3_exec() callback function is the
832
+** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
833
+** callback is an array of pointers to strings obtained as if from
834
+** [sqlite3_column_text()], one for each column. ^If an element of a
835
+** result row is NULL then the corresponding string pointer for the
836
+** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
837
+** sqlite3_exec() callback is an array of pointers to strings where each
838
+** entry represents the name of corresponding result column as obtained
839
+** from [sqlite3_column_name()].
840
+**
841
+** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
842
+** to an empty string, or a pointer that contains only whitespace and/or
843
+** SQL comments, then no SQL statements are evaluated and the database
844
+** is not changed.
845
+**
846
+** Restrictions:
847
+**
848
+** <ul>
849
+** <li> The application must insure that the 1st parameter to sqlite3_exec()
850
+** is a valid and open [database connection].
851
+** <li> The application must not close [database connection] specified by
852
+** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
853
+** <li> The application must not modify the SQL statement text passed into
854
+** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
855
+** </ul>
839856
*/
840857
SQLITE_API int sqlite3_exec(
841858
sqlite3*, /* An open database */
842859
const char *sql, /* SQL to be evaluated */
843860
int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -844,11 +861,11 @@
844861
void *, /* 1st argument to callback */
845862
char **errmsg /* Error msg written here */
846863
);
847864
848865
/*
849
-** CAPI3REF: Result Codes {H10210} <S10700>
866
+** CAPI3REF: Result Codes
850867
** KEYWORDS: SQLITE_OK {error code} {error codes}
851868
** KEYWORDS: {result code} {result codes}
852869
**
853870
** Many SQLite functions return an integer result code from the set shown
854871
** here in order to indicates success or failure.
@@ -888,11 +905,11 @@
888905
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
889906
#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
890907
/* end-of-error-codes */
891908
892909
/*
893
-** CAPI3REF: Extended Result Codes {H10220} <S10700>
910
+** CAPI3REF: Extended Result Codes
894911
** KEYWORDS: {extended error code} {extended error codes}
895912
** KEYWORDS: {extended result code} {extended result codes}
896913
**
897914
** In its default configuration, SQLite API routines return one of 26 integer
898915
** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -930,11 +947,11 @@
930947
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
931948
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
932949
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
933950
934951
/*
935
-** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
952
+** CAPI3REF: Flags For File Open Operations
936953
**
937954
** These bit values are intended for use in the
938955
** 3rd parameter to the [sqlite3_open_v2()] interface and
939956
** in the 4th parameter to the xOpen method of the
940957
** [sqlite3_vfs] object.
@@ -955,11 +972,11 @@
955972
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
956973
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
957974
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
958975
959976
/*
960
-** CAPI3REF: Device Characteristics {H10240} <H11120>
977
+** CAPI3REF: Device Characteristics
961978
**
962979
** The xDeviceCapabilities method of the [sqlite3_io_methods]
963980
** object returns an integer which is a vector of the these
964981
** bit values expressing I/O characteristics of the mass storage
965982
** device that holds the file that the [sqlite3_io_methods]
@@ -987,11 +1004,11 @@
9871004
#define SQLITE_IOCAP_ATOMIC64K 0x00000100
9881005
#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
9891006
#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
9901007
9911008
/*
992
-** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
1009
+** CAPI3REF: File Locking Levels
9931010
**
9941011
** SQLite uses one of these integer values as the second
9951012
** argument to calls it makes to the xLock() and xUnlock() methods
9961013
** of an [sqlite3_io_methods] object.
9971014
*/
@@ -1000,11 +1017,11 @@
10001017
#define SQLITE_LOCK_RESERVED 2
10011018
#define SQLITE_LOCK_PENDING 3
10021019
#define SQLITE_LOCK_EXCLUSIVE 4
10031020
10041021
/*
1005
-** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
1022
+** CAPI3REF: Synchronization Type Flags
10061023
**
10071024
** When SQLite invokes the xSync() method of an
10081025
** [sqlite3_io_methods] object it uses a combination of
10091026
** these integer values as the second argument.
10101027
**
@@ -1018,11 +1035,11 @@
10181035
#define SQLITE_SYNC_NORMAL 0x00002
10191036
#define SQLITE_SYNC_FULL 0x00003
10201037
#define SQLITE_SYNC_DATAONLY 0x00010
10211038
10221039
/*
1023
-** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
1040
+** CAPI3REF: OS Interface Open File Handle
10241041
**
10251042
** An [sqlite3_file] object represents an open file in the
10261043
** [sqlite3_vfs | OS interface layer]. Individual OS interface
10271044
** implementations will
10281045
** want to subclass this object by appending additional fields
@@ -1034,11 +1051,11 @@
10341051
struct sqlite3_file {
10351052
const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
10361053
};
10371054
10381055
/*
1039
-** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
1056
+** CAPI3REF: OS Interface File Virtual Methods Object
10401057
**
10411058
** Every file opened by the [sqlite3_vfs] xOpen method populates an
10421059
** [sqlite3_file] object (or, more commonly, a subclass of the
10431060
** [sqlite3_file] object) with a pointer to an instance of this object.
10441061
** This object defines the methods used to perform various operations
@@ -1139,11 +1156,11 @@
11391156
int (*xDeviceCharacteristics)(sqlite3_file*);
11401157
/* Additional methods may be added in future releases */
11411158
};
11421159
11431160
/*
1144
-** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
1161
+** CAPI3REF: Standard File Control Opcodes
11451162
**
11461163
** These integer constants are opcodes for the xFileControl method
11471164
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
11481165
** interface.
11491166
**
@@ -1159,11 +1176,11 @@
11591176
#define SQLITE_GET_LOCKPROXYFILE 2
11601177
#define SQLITE_SET_LOCKPROXYFILE 3
11611178
#define SQLITE_LAST_ERRNO 4
11621179
11631180
/*
1164
-** CAPI3REF: Mutex Handle {H17110} <S20130>
1181
+** CAPI3REF: Mutex Handle
11651182
**
11661183
** The mutex module within SQLite defines [sqlite3_mutex] to be an
11671184
** abstract type for a mutex object. The SQLite core never looks
11681185
** at the internal representation of an [sqlite3_mutex]. It only
11691186
** deals with pointers to the [sqlite3_mutex] object.
@@ -1171,11 +1188,11 @@
11711188
** Mutexes are created using [sqlite3_mutex_alloc()].
11721189
*/
11731190
typedef struct sqlite3_mutex sqlite3_mutex;
11741191
11751192
/*
1176
-** CAPI3REF: OS Interface Object {H11140} <S20100>
1193
+** CAPI3REF: OS Interface Object
11771194
**
11781195
** An instance of the sqlite3_vfs object defines the interface between
11791196
** the SQLite core and the underlying operating system. The "vfs"
11801197
** in the name of the object stands for "virtual file system".
11811198
**
@@ -1325,14 +1342,14 @@
13251342
/* New fields may be appended in figure versions. The iVersion
13261343
** value will increment whenever this happens. */
13271344
};
13281345
13291346
/*
1330
-** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
1347
+** CAPI3REF: Flags for the xAccess VFS method
13311348
**
13321349
** These integer constants can be used as the third parameter to
1333
-** the xAccess method of an [sqlite3_vfs] object. {END} They determine
1350
+** the xAccess method of an [sqlite3_vfs] object. They determine
13341351
** what kind of permissions the xAccess method is looking for.
13351352
** With SQLITE_ACCESS_EXISTS, the xAccess method
13361353
** simply checks whether the file exists.
13371354
** With SQLITE_ACCESS_READWRITE, the xAccess method
13381355
** checks whether the file is both readable and writable.
@@ -1342,52 +1359,52 @@
13421359
#define SQLITE_ACCESS_EXISTS 0
13431360
#define SQLITE_ACCESS_READWRITE 1
13441361
#define SQLITE_ACCESS_READ 2
13451362
13461363
/*
1347
-** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
1364
+** CAPI3REF: Initialize The SQLite Library
13481365
**
1349
-** The sqlite3_initialize() routine initializes the
1350
-** SQLite library. The sqlite3_shutdown() routine
1366
+** ^The sqlite3_initialize() routine initializes the
1367
+** SQLite library. ^The sqlite3_shutdown() routine
13511368
** deallocates any resources that were allocated by sqlite3_initialize().
13521369
** These routines are designed to aid in process initialization and
13531370
** shutdown on embedded systems. Workstation applications using
13541371
** SQLite normally do not need to invoke either of these routines.
13551372
**
13561373
** A call to sqlite3_initialize() is an "effective" call if it is
13571374
** the first time sqlite3_initialize() is invoked during the lifetime of
13581375
** the process, or if it is the first time sqlite3_initialize() is invoked
1359
-** following a call to sqlite3_shutdown(). Only an effective call
1376
+** following a call to sqlite3_shutdown(). ^(Only an effective call
13601377
** of sqlite3_initialize() does any initialization. All other calls
1361
-** are harmless no-ops.
1378
+** are harmless no-ops.)^
13621379
**
13631380
** A call to sqlite3_shutdown() is an "effective" call if it is the first
1364
-** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only
1381
+** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
13651382
** an effective call to sqlite3_shutdown() does any deinitialization.
1366
-** All other valid calls to sqlite3_shutdown() are harmless no-ops.
1383
+** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
13671384
**
13681385
** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
13691386
** is not. The sqlite3_shutdown() interface must only be called from a
13701387
** single thread. All open [database connections] must be closed and all
13711388
** other SQLite resources must be deallocated prior to invoking
13721389
** sqlite3_shutdown().
13731390
**
1374
-** Among other things, sqlite3_initialize() will invoke
1375
-** sqlite3_os_init(). Similarly, sqlite3_shutdown()
1391
+** Among other things, ^sqlite3_initialize() will invoke
1392
+** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
13761393
** will invoke sqlite3_os_end().
13771394
**
1378
-** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
1379
-** If for some reason, sqlite3_initialize() is unable to initialize
1395
+** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
1396
+** ^If for some reason, sqlite3_initialize() is unable to initialize
13801397
** the library (perhaps it is unable to allocate a needed resource such
13811398
** as a mutex) it returns an [error code] other than [SQLITE_OK].
13821399
**
1383
-** The sqlite3_initialize() routine is called internally by many other
1400
+** ^The sqlite3_initialize() routine is called internally by many other
13841401
** SQLite interfaces so that an application usually does not need to
13851402
** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
13861403
** calls sqlite3_initialize() so the SQLite library will be automatically
13871404
** initialized when [sqlite3_open()] is called if it has not be initialized
1388
-** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
1405
+** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
13891406
** compile-time option, then the automatic calls to sqlite3_initialize()
13901407
** are omitted and the application must call sqlite3_initialize() directly
13911408
** prior to using any other SQLite interface. For maximum portability,
13921409
** it is recommended that applications always invoke sqlite3_initialize()
13931410
** directly prior to using any other SQLite interface. Future releases
@@ -1422,11 +1439,11 @@
14221439
SQLITE_API int sqlite3_shutdown(void);
14231440
SQLITE_API int sqlite3_os_init(void);
14241441
SQLITE_API int sqlite3_os_end(void);
14251442
14261443
/*
1427
-** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
1444
+** CAPI3REF: Configuring The SQLite Library
14281445
** EXPERIMENTAL
14291446
**
14301447
** The sqlite3_config() interface is used to make global configuration
14311448
** changes to SQLite in order to tune SQLite to the specific needs of
14321449
** the application. The default configuration is recommended for most
@@ -1436,39 +1453,36 @@
14361453
** The sqlite3_config() interface is not threadsafe. The application
14371454
** must insure that no other SQLite interfaces are invoked by other
14381455
** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
14391456
** may only be invoked prior to library initialization using
14401457
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1441
-** Note, however, that sqlite3_config() can be called as part of the
1458
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1459
+** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1460
+** Note, however, that ^sqlite3_config() can be called as part of the
14421461
** implementation of an application-defined [sqlite3_os_init()].
14431462
**
14441463
** The first argument to sqlite3_config() is an integer
14451464
** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
14461465
** what property of SQLite is to be configured. Subsequent arguments
14471466
** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
14481467
** in the first argument.
14491468
**
1450
-** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1451
-** If the option is unknown or SQLite is unable to set the option
1469
+** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1470
+** ^If the option is unknown or SQLite is unable to set the option
14521471
** then this routine returns a non-zero [error code].
1453
-**
1454
-** Requirements:
1455
-** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
1456
-** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
1457
-** [H14162] [H14165] [H14168]
14581472
*/
14591473
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
14601474
14611475
/*
1462
-** CAPI3REF: Configure database connections {H14200} <S20000>
1476
+** CAPI3REF: Configure database connections
14631477
** EXPERIMENTAL
14641478
**
14651479
** The sqlite3_db_config() interface is used to make configuration
14661480
** changes to a [database connection]. The interface is similar to
14671481
** [sqlite3_config()] except that the changes apply to a single
14681482
** [database connection] (specified in the first argument). The
1469
-** sqlite3_db_config() interface can only be used immediately after
1483
+** sqlite3_db_config() interface should only be used immediately after
14701484
** the database connection is created using [sqlite3_open()],
14711485
** [sqlite3_open16()], or [sqlite3_open_v2()].
14721486
**
14731487
** The second argument to sqlite3_db_config(D,V,...) is the
14741488
** configuration verb - an integer code that indicates what
@@ -1475,17 +1489,17 @@
14751489
** aspect of the [database connection] is being configured.
14761490
** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
14771491
** New verbs are likely to be added in future releases of SQLite.
14781492
** Additional arguments depend on the verb.
14791493
**
1480
-** Requirements:
1481
-** [H14203] [H14206] [H14209] [H14212] [H14215]
1494
+** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1495
+** the call is considered successful.
14821496
*/
14831497
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
14841498
14851499
/*
1486
-** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
1500
+** CAPI3REF: Memory Allocation Routines
14871501
** EXPERIMENTAL
14881502
**
14891503
** An instance of this object defines the interface between SQLite
14901504
** and low-level memory allocation routines.
14911505
**
@@ -1511,11 +1525,11 @@
15111525
** The xMalloc and xFree methods must work like the
15121526
** malloc() and free() functions from the standard C library.
15131527
** The xRealloc method must work like realloc() from the standard C library
15141528
** with the exception that if the second argument to xRealloc is zero,
15151529
** xRealloc must be a no-op - it must not perform any allocation or
1516
-** deallocation. SQLite guaranteeds that the second argument to
1530
+** deallocation. ^SQLite guarantees that the second argument to
15171531
** xRealloc is always a value returned by a prior call to xRoundup.
15181532
** And so in cases where xRoundup always returns a positive number,
15191533
** xRealloc can perform exactly as the standard library realloc() and
15201534
** still be in compliance with this specification.
15211535
**
@@ -1563,11 +1577,11 @@
15631577
void (*xShutdown)(void*); /* Deinitialize the memory allocator */
15641578
void *pAppData; /* Argument to xInit() and xShutdown() */
15651579
};
15661580
15671581
/*
1568
-** CAPI3REF: Configuration Options {H10160} <S20000>
1582
+** CAPI3REF: Configuration Options
15691583
** EXPERIMENTAL
15701584
**
15711585
** These constants are the available integer configuration options that
15721586
** can be passed as the first argument to the [sqlite3_config()] interface.
15731587
**
@@ -1578,151 +1592,181 @@
15781592
** non-zero [error code] if a discontinued or unsupported configuration option
15791593
** is invoked.
15801594
**
15811595
** <dl>
15821596
** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1583
-** <dd>There are no arguments to this option. This option disables
1597
+** <dd>There are no arguments to this option. ^This option sets the
1598
+** [threading mode] to Single-thread. In other words, it disables
15841599
** all mutexing and puts SQLite into a mode where it can only be used
1585
-** by a single thread.</dd>
1600
+** by a single thread. ^If SQLite is compiled with
1601
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1602
+** it is not possible to change the [threading mode] from its default
1603
+** value of Single-thread and so [sqlite3_config()] will return
1604
+** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
1605
+** configuration option.</dd>
15861606
**
15871607
** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1588
-** <dd>There are no arguments to this option. This option disables
1608
+** <dd>There are no arguments to this option. ^This option sets the
1609
+** [threading mode] to Multi-thread. In other words, it disables
15891610
** mutexing on [database connection] and [prepared statement] objects.
15901611
** The application is responsible for serializing access to
15911612
** [database connections] and [prepared statements]. But other mutexes
15921613
** are enabled so that SQLite will be safe to use in a multi-threaded
15931614
** environment as long as no two threads attempt to use the same
1594
-** [database connection] at the same time. See the [threading mode]
1595
-** documentation for additional information.</dd>
1615
+** [database connection] at the same time. ^If SQLite is compiled with
1616
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1617
+** it is not possible to set the Multi-thread [threading mode] and
1618
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1619
+** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
15961620
**
15971621
** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1598
-** <dd>There are no arguments to this option. This option enables
1622
+** <dd>There are no arguments to this option. ^This option sets the
1623
+** [threading mode] to Serialized. In other words, this option enables
15991624
** all mutexes including the recursive
16001625
** mutexes on [database connection] and [prepared statement] objects.
16011626
** In this mode (which is the default when SQLite is compiled with
16021627
** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
16031628
** to [database connections] and [prepared statements] so that the
16041629
** application is free to use the same [database connection] or the
16051630
** same [prepared statement] in different threads at the same time.
1606
-** See the [threading mode] documentation for additional information.</dd>
1631
+** ^If SQLite is compiled with
1632
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1633
+** it is not possible to set the Serialized [threading mode] and
1634
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1635
+** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
16071636
**
16081637
** <dt>SQLITE_CONFIG_MALLOC</dt>
1609
-** <dd>This option takes a single argument which is a pointer to an
1638
+** <dd> ^(This option takes a single argument which is a pointer to an
16101639
** instance of the [sqlite3_mem_methods] structure. The argument specifies
16111640
** alternative low-level memory allocation routines to be used in place of
1612
-** the memory allocation routines built into SQLite.</dd>
1641
+** the memory allocation routines built into SQLite.)^ ^SQLite makes
1642
+** its own private copy of the content of the [sqlite3_mem_methods] structure
1643
+** before the [sqlite3_config()] call returns.</dd>
16131644
**
16141645
** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1615
-** <dd>This option takes a single argument which is a pointer to an
1646
+** <dd> ^(This option takes a single argument which is a pointer to an
16161647
** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1617
-** structure is filled with the currently defined memory allocation routines.
1648
+** structure is filled with the currently defined memory allocation routines.)^
16181649
** This option can be used to overload the default memory allocation
16191650
** routines with a wrapper that simulations memory allocation failure or
1620
-** tracks memory usage, for example.</dd>
1651
+** tracks memory usage, for example. </dd>
16211652
**
16221653
** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1623
-** <dd>This option takes single argument of type int, interpreted as a
1654
+** <dd> ^This option takes single argument of type int, interpreted as a
16241655
** boolean, which enables or disables the collection of memory allocation
1625
-** statistics. When disabled, the following SQLite interfaces become
1626
-** non-operational:
1656
+** statistics. ^(When memory allocation statistics are disabled, the
1657
+** following SQLite interfaces become non-operational:
16271658
** <ul>
16281659
** <li> [sqlite3_memory_used()]
16291660
** <li> [sqlite3_memory_highwater()]
16301661
** <li> [sqlite3_soft_heap_limit()]
16311662
** <li> [sqlite3_status()]
1632
-** </ul>
1663
+** </ul>)^
1664
+** ^Memory allocation statistics are enabled by default unless SQLite is
1665
+** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1666
+** allocation statistics are disabled by default.
16331667
** </dd>
16341668
**
16351669
** <dt>SQLITE_CONFIG_SCRATCH</dt>
1636
-** <dd>This option specifies a static memory buffer that SQLite can use for
1670
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
16371671
** scratch memory. There are three arguments: A pointer an 8-byte
16381672
** aligned memory buffer from which the scrach allocations will be
16391673
** drawn, the size of each scratch allocation (sz),
16401674
** and the maximum number of scratch allocations (N). The sz
16411675
** argument must be a multiple of 16. The sz parameter should be a few bytes
16421676
** larger than the actual scratch space required due to internal overhead.
1643
-** The first argument should pointer to an 8-byte aligned buffer
1677
+** The first argument must be a pointer to an 8-byte aligned buffer
16441678
** of at least sz*N bytes of memory.
1645
-** SQLite will use no more than one scratch buffer at once per thread, so
1646
-** N should be set to the expected maximum number of threads. The sz
1647
-** parameter should be 6 times the size of the largest database page size.
1648
-** Scratch buffers are used as part of the btree balance operation. If
1649
-** The btree balancer needs additional memory beyond what is provided by
1650
-** scratch buffers or if no scratch buffer space is specified, then SQLite
1651
-** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
1679
+** ^SQLite will use no more than one scratch buffer per thread. So
1680
+** N should be set to the expected maximum number of threads. ^SQLite will
1681
+** never require a scratch buffer that is more than 6 times the database
1682
+** page size. ^If SQLite needs needs additional scratch memory beyond
1683
+** what is provided by this configuration option, then
1684
+** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
16521685
**
16531686
** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1654
-** <dd>This option specifies a static memory buffer that SQLite can use for
1687
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
16551688
** the database page cache with the default page cache implemenation.
16561689
** This configuration should not be used if an application-define page
16571690
** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
16581691
** There are three arguments to this option: A pointer to 8-byte aligned
16591692
** memory, the size of each page buffer (sz), and the number of pages (N).
16601693
** The sz argument should be the size of the largest database page
16611694
** (a power of two between 512 and 32768) plus a little extra for each
1662
-** page header. The page header size is 20 to 40 bytes depending on
1663
-** the host architecture. It is harmless, apart from the wasted memory,
1695
+** page header. ^The page header size is 20 to 40 bytes depending on
1696
+** the host architecture. ^It is harmless, apart from the wasted memory,
16641697
** to make sz a little too large. The first
16651698
** argument should point to an allocation of at least sz*N bytes of memory.
1666
-** SQLite will use the memory provided by the first argument to satisfy its
1667
-** memory needs for the first N pages that it adds to cache. If additional
1699
+** ^SQLite will use the memory provided by the first argument to satisfy its
1700
+** memory needs for the first N pages that it adds to cache. ^If additional
16681701
** page cache memory is needed beyond what is provided by this option, then
16691702
** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1670
-** The implementation might use one or more of the N buffers to hold
1703
+** ^The implementation might use one or more of the N buffers to hold
16711704
** memory accounting information. The pointer in the first argument must
16721705
** be aligned to an 8-byte boundary or subsequent behavior of SQLite
16731706
** will be undefined.</dd>
16741707
**
16751708
** <dt>SQLITE_CONFIG_HEAP</dt>
1676
-** <dd>This option specifies a static memory buffer that SQLite will use
1709
+** <dd> ^This option specifies a static memory buffer that SQLite will use
16771710
** for all of its dynamic memory allocation needs beyond those provided
16781711
** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
16791712
** There are three arguments: An 8-byte aligned pointer to the memory,
16801713
** the number of bytes in the memory buffer, and the minimum allocation size.
1681
-** If the first pointer (the memory pointer) is NULL, then SQLite reverts
1714
+** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
16821715
** to using its default memory allocator (the system malloc() implementation),
1683
-** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the
1716
+** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
16841717
** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
16851718
** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
16861719
** allocator is engaged to handle all of SQLites memory allocation needs.
16871720
** The first pointer (the memory pointer) must be aligned to an 8-byte
16881721
** boundary or subsequent behavior of SQLite will be undefined.</dd>
16891722
**
16901723
** <dt>SQLITE_CONFIG_MUTEX</dt>
1691
-** <dd>This option takes a single argument which is a pointer to an
1724
+** <dd> ^(This option takes a single argument which is a pointer to an
16921725
** instance of the [sqlite3_mutex_methods] structure. The argument specifies
16931726
** alternative low-level mutex routines to be used in place
1694
-** the mutex routines built into SQLite.</dd>
1727
+** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
1728
+** content of the [sqlite3_mutex_methods] structure before the call to
1729
+** [sqlite3_config()] returns. ^If SQLite is compiled with
1730
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1731
+** the entire mutexing subsystem is omitted from the build and hence calls to
1732
+** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1733
+** return [SQLITE_ERROR].</dd>
16951734
**
16961735
** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1697
-** <dd>This option takes a single argument which is a pointer to an
1736
+** <dd> ^(This option takes a single argument which is a pointer to an
16981737
** instance of the [sqlite3_mutex_methods] structure. The
16991738
** [sqlite3_mutex_methods]
1700
-** structure is filled with the currently defined mutex routines.
1739
+** structure is filled with the currently defined mutex routines.)^
17011740
** This option can be used to overload the default mutex allocation
17021741
** routines with a wrapper used to track mutex usage for performance
1703
-** profiling or testing, for example.</dd>
1742
+** profiling or testing, for example. ^If SQLite is compiled with
1743
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1744
+** the entire mutexing subsystem is omitted from the build and hence calls to
1745
+** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1746
+** return [SQLITE_ERROR].</dd>
17041747
**
17051748
** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1706
-** <dd>This option takes two arguments that determine the default
1707
-** memory allocation lookaside optimization. The first argument is the
1749
+** <dd> ^(This option takes two arguments that determine the default
1750
+** memory allocation for the lookaside memory allocator on each
1751
+** [database connection]. The first argument is the
17081752
** size of each lookaside buffer slot and the second is the number of
1709
-** slots allocated to each database connection. This option sets the
1710
-** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1753
+** slots allocated to each database connection.)^ ^(This option sets the
1754
+** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
17111755
** verb to [sqlite3_db_config()] can be used to change the lookaside
1712
-** configuration on individual connections.</dd>
1756
+** configuration on individual connections.)^ </dd>
17131757
**
17141758
** <dt>SQLITE_CONFIG_PCACHE</dt>
1715
-** <dd>This option takes a single argument which is a pointer to
1759
+** <dd> ^(This option takes a single argument which is a pointer to
17161760
** an [sqlite3_pcache_methods] object. This object specifies the interface
1717
-** to a custom page cache implementation. SQLite makes a copy of the
1761
+** to a custom page cache implementation.)^ ^SQLite makes a copy of the
17181762
** object and uses it for page cache memory allocations.</dd>
17191763
**
17201764
** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1721
-** <dd>This option takes a single argument which is a pointer to an
1765
+** <dd> ^(This option takes a single argument which is a pointer to an
17221766
** [sqlite3_pcache_methods] object. SQLite copies of the current
1723
-** page cache implementation into that object.</dd>
1767
+** page cache implementation into that object.)^ </dd>
17241768
**
17251769
** </dl>
17261770
*/
17271771
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
17281772
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1739,94 +1783,90 @@
17391783
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
17401784
#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
17411785
#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
17421786
17431787
/*
1744
-** CAPI3REF: Configuration Options {H10170} <S20000>
1788
+** CAPI3REF: Configuration Options
17451789
** EXPERIMENTAL
17461790
**
17471791
** These constants are the available integer configuration options that
17481792
** can be passed as the second argument to the [sqlite3_db_config()] interface.
17491793
**
17501794
** New configuration options may be added in future releases of SQLite.
17511795
** Existing configuration options might be discontinued. Applications
17521796
** should check the return code from [sqlite3_db_config()] to make sure that
1753
-** the call worked. The [sqlite3_db_config()] interface will return a
1797
+** the call worked. ^The [sqlite3_db_config()] interface will return a
17541798
** non-zero [error code] if a discontinued or unsupported configuration option
17551799
** is invoked.
17561800
**
17571801
** <dl>
17581802
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1759
-** <dd>This option takes three additional arguments that determine the
1803
+** <dd> ^This option takes three additional arguments that determine the
17601804
** [lookaside memory allocator] configuration for the [database connection].
1761
-** The first argument (the third parameter to [sqlite3_db_config()] is a
1805
+** ^The first argument (the third parameter to [sqlite3_db_config()] is a
17621806
** pointer to an memory buffer to use for lookaside memory.
1763
-** The first argument may be NULL in which case SQLite will allocate the
1764
-** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the
1765
-** size of each lookaside buffer slot and the third argument is the number of
1807
+** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
1808
+** may be NULL in which case SQLite will allocate the
1809
+** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
1810
+** size of each lookaside buffer slot. ^The third argument is the number of
17661811
** slots. The size of the buffer in the first argument must be greater than
17671812
** or equal to the product of the second and third arguments. The buffer
1768
-** must be aligned to an 8-byte boundary. If the second argument is not
1769
-** a multiple of 8, it is internally rounded down to the next smaller
1813
+** must be aligned to an 8-byte boundary. ^If the second argument to
1814
+** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
1815
+** rounded down to the next smaller
17701816
** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
17711817
**
17721818
** </dl>
17731819
*/
17741820
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
17751821
17761822
17771823
/*
1778
-** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
1779
-**
1780
-** The sqlite3_extended_result_codes() routine enables or disables the
1781
-** [extended result codes] feature of SQLite. The extended result
1782
-** codes are disabled by default for historical compatibility considerations.
1783
-**
1784
-** Requirements:
1785
-** [H12201] [H12202]
1824
+** CAPI3REF: Enable Or Disable Extended Result Codes
1825
+**
1826
+** ^The sqlite3_extended_result_codes() routine enables or disables the
1827
+** [extended result codes] feature of SQLite. ^The extended result
1828
+** codes are disabled by default for historical compatibility.
17861829
*/
17871830
SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
17881831
17891832
/*
1790
-** CAPI3REF: Last Insert Rowid {H12220} <S10700>
1833
+** CAPI3REF: Last Insert Rowid
17911834
**
1792
-** Each entry in an SQLite table has a unique 64-bit signed
1793
-** integer key called the [ROWID | "rowid"]. The rowid is always available
1835
+** ^Each entry in an SQLite table has a unique 64-bit signed
1836
+** integer key called the [ROWID | "rowid"]. ^The rowid is always available
17941837
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1795
-** names are not also used by explicitly declared columns. If
1838
+** names are not also used by explicitly declared columns. ^If
17961839
** the table has a column of type [INTEGER PRIMARY KEY] then that column
17971840
** is another alias for the rowid.
17981841
**
1799
-** This routine returns the [rowid] of the most recent
1842
+** ^This routine returns the [rowid] of the most recent
18001843
** successful [INSERT] into the database from the [database connection]
1801
-** in the first argument. If no successful [INSERT]s
1844
+** in the first argument. ^If no successful [INSERT]s
18021845
** have ever occurred on that database connection, zero is returned.
18031846
**
1804
-** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1847
+** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
18051848
** row is returned by this routine as long as the trigger is running.
18061849
** But once the trigger terminates, the value returned by this routine
1807
-** reverts to the last value inserted before the trigger fired.
1850
+** reverts to the last value inserted before the trigger fired.)^
18081851
**
1809
-** An [INSERT] that fails due to a constraint violation is not a
1852
+** ^An [INSERT] that fails due to a constraint violation is not a
18101853
** successful [INSERT] and does not change the value returned by this
1811
-** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1854
+** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
18121855
** and INSERT OR ABORT make no changes to the return value of this
1813
-** routine when their insertion fails. When INSERT OR REPLACE
1856
+** routine when their insertion fails. ^(When INSERT OR REPLACE
18141857
** encounters a constraint violation, it does not fail. The
18151858
** INSERT continues to completion after deleting rows that caused
18161859
** the constraint problem so INSERT OR REPLACE will always change
1817
-** the return value of this interface.
1860
+** the return value of this interface.)^
18181861
**
1819
-** For the purposes of this routine, an [INSERT] is considered to
1862
+** ^For the purposes of this routine, an [INSERT] is considered to
18201863
** be successful even if it is subsequently rolled back.
18211864
**
18221865
** This function is accessible to SQL statements via the
18231866
** [last_insert_rowid() SQL function].
18241867
**
1825
-** Requirements:
1826
-** [H12221] [H12223]
1827
-**
18281868
** If a separate thread performs a new [INSERT] on the same
18291869
** database connection while the [sqlite3_last_insert_rowid()]
18301870
** function is running and thus changes the last insert [rowid],
18311871
** then the value returned by [sqlite3_last_insert_rowid()] is
18321872
** unpredictable and might not equal either the old or the new
@@ -1833,164 +1873,154 @@
18331873
** last insert [rowid].
18341874
*/
18351875
SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
18361876
18371877
/*
1838
-** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
1878
+** CAPI3REF: Count The Number Of Rows Modified
18391879
**
1840
-** This function returns the number of database rows that were changed
1880
+** ^This function returns the number of database rows that were changed
18411881
** or inserted or deleted by the most recently completed SQL statement
18421882
** on the [database connection] specified by the first parameter.
1843
-** Only changes that are directly specified by the [INSERT], [UPDATE],
1883
+** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
18441884
** or [DELETE] statement are counted. Auxiliary changes caused by
1845
-** triggers or [foreign key actions] are not counted. Use the
1885
+** triggers or [foreign key actions] are not counted.)^ Use the
18461886
** [sqlite3_total_changes()] function to find the total number of changes
18471887
** including changes caused by triggers and foreign key actions.
18481888
**
1849
-** Changes to a view that are simulated by an [INSTEAD OF trigger]
1889
+** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
18501890
** are not counted. Only real table changes are counted.
18511891
**
1852
-** A "row change" is a change to a single row of a single table
1892
+** ^(A "row change" is a change to a single row of a single table
18531893
** caused by an INSERT, DELETE, or UPDATE statement. Rows that
18541894
** are changed as side effects of [REPLACE] constraint resolution,
18551895
** rollback, ABORT processing, [DROP TABLE], or by any other
1856
-** mechanisms do not count as direct row changes.
1896
+** mechanisms do not count as direct row changes.)^
18571897
**
18581898
** A "trigger context" is a scope of execution that begins and
18591899
** ends with the script of a [CREATE TRIGGER | trigger].
18601900
** Most SQL statements are
18611901
** evaluated outside of any trigger. This is the "top level"
18621902
** trigger context. If a trigger fires from the top level, a
18631903
** new trigger context is entered for the duration of that one
18641904
** trigger. Subtriggers create subcontexts for their duration.
18651905
**
1866
-** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1906
+** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
18671907
** not create a new trigger context.
18681908
**
1869
-** This function returns the number of direct row changes in the
1909
+** ^This function returns the number of direct row changes in the
18701910
** most recent INSERT, UPDATE, or DELETE statement within the same
18711911
** trigger context.
18721912
**
1873
-** Thus, when called from the top level, this function returns the
1913
+** ^Thus, when called from the top level, this function returns the
18741914
** number of changes in the most recent INSERT, UPDATE, or DELETE
1875
-** that also occurred at the top level. Within the body of a trigger,
1915
+** that also occurred at the top level. ^(Within the body of a trigger,
18761916
** the sqlite3_changes() interface can be called to find the number of
18771917
** changes in the most recently completed INSERT, UPDATE, or DELETE
18781918
** statement within the body of the same trigger.
18791919
** However, the number returned does not include changes
1880
-** caused by subtriggers since those have their own context.
1920
+** caused by subtriggers since those have their own context.)^
18811921
**
18821922
** See also the [sqlite3_total_changes()] interface, the
18831923
** [count_changes pragma], and the [changes() SQL function].
18841924
**
1885
-** Requirements:
1886
-** [H12241] [H12243]
1887
-**
18881925
** If a separate thread makes changes on the same database connection
18891926
** while [sqlite3_changes()] is running then the value returned
18901927
** is unpredictable and not meaningful.
18911928
*/
18921929
SQLITE_API int sqlite3_changes(sqlite3*);
18931930
18941931
/*
1895
-** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1932
+** CAPI3REF: Total Number Of Rows Modified
18961933
**
1897
-** This function returns the number of row changes caused by [INSERT],
1934
+** ^This function returns the number of row changes caused by [INSERT],
18981935
** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1899
-** The count includes all changes from all [CREATE TRIGGER | trigger]
1900
-** contexts and changes made by [foreign key actions]. However,
1936
+** ^(The count returned by sqlite3_total_changes() includes all changes
1937
+** from all [CREATE TRIGGER | trigger] contexts and changes made by
1938
+** [foreign key actions]. However,
19011939
** the count does not include changes used to implement [REPLACE] constraints,
19021940
** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
19031941
** count does not include rows of views that fire an [INSTEAD OF trigger],
19041942
** though if the INSTEAD OF trigger makes changes of its own, those changes
1905
-** are counted.
1906
-** The changes are counted as soon as the statement that makes them is
1907
-** completed (when the statement handle is passed to [sqlite3_reset()] or
1908
-** [sqlite3_finalize()]).
1943
+** are counted.)^
1944
+** ^The sqlite3_total_changes() function counts the changes as soon as
1945
+** the statement that makes them is completed (when the statement handle
1946
+** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
19091947
**
19101948
** See also the [sqlite3_changes()] interface, the
19111949
** [count_changes pragma], and the [total_changes() SQL function].
19121950
**
1913
-** Requirements:
1914
-** [H12261] [H12263]
1915
-**
19161951
** If a separate thread makes changes on the same database connection
19171952
** while [sqlite3_total_changes()] is running then the value
19181953
** returned is unpredictable and not meaningful.
19191954
*/
19201955
SQLITE_API int sqlite3_total_changes(sqlite3*);
19211956
19221957
/*
1923
-** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
1958
+** CAPI3REF: Interrupt A Long-Running Query
19241959
**
1925
-** This function causes any pending database operation to abort and
1960
+** ^This function causes any pending database operation to abort and
19261961
** return at its earliest opportunity. This routine is typically
19271962
** called in response to a user action such as pressing "Cancel"
19281963
** or Ctrl-C where the user wants a long query operation to halt
19291964
** immediately.
19301965
**
1931
-** It is safe to call this routine from a thread different from the
1966
+** ^It is safe to call this routine from a thread different from the
19321967
** thread that is currently running the database operation. But it
19331968
** is not safe to call this routine with a [database connection] that
19341969
** is closed or might close before sqlite3_interrupt() returns.
19351970
**
1936
-** If an SQL operation is very nearly finished at the time when
1971
+** ^If an SQL operation is very nearly finished at the time when
19371972
** sqlite3_interrupt() is called, then it might not have an opportunity
19381973
** to be interrupted and might continue to completion.
19391974
**
1940
-** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1941
-** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1975
+** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1976
+** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
19421977
** that is inside an explicit transaction, then the entire transaction
19431978
** will be rolled back automatically.
19441979
**
1945
-** The sqlite3_interrupt(D) call is in effect until all currently running
1946
-** SQL statements on [database connection] D complete. Any new SQL statements
1980
+** ^The sqlite3_interrupt(D) call is in effect until all currently running
1981
+** SQL statements on [database connection] D complete. ^Any new SQL statements
19471982
** that are started after the sqlite3_interrupt() call and before the
19481983
** running statements reaches zero are interrupted as if they had been
1949
-** running prior to the sqlite3_interrupt() call. New SQL statements
1984
+** running prior to the sqlite3_interrupt() call. ^New SQL statements
19501985
** that are started after the running statement count reaches zero are
19511986
** not effected by the sqlite3_interrupt().
1952
-** A call to sqlite3_interrupt(D) that occurs when there are no running
1987
+** ^A call to sqlite3_interrupt(D) that occurs when there are no running
19531988
** SQL statements is a no-op and has no effect on SQL statements
19541989
** that are started after the sqlite3_interrupt() call returns.
19551990
**
1956
-** Requirements:
1957
-** [H12271] [H12272]
1958
-**
19591991
** If the database connection closes while [sqlite3_interrupt()]
19601992
** is running then bad things will likely happen.
19611993
*/
19621994
SQLITE_API void sqlite3_interrupt(sqlite3*);
19631995
19641996
/*
1965
-** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
1997
+** CAPI3REF: Determine If An SQL Statement Is Complete
19661998
**
19671999
** These routines are useful during command-line input to determine if the
19682000
** currently entered text seems to form a complete SQL statement or
19692001
** if additional input is needed before sending the text into
1970
-** SQLite for parsing. These routines return 1 if the input string
1971
-** appears to be a complete SQL statement. A statement is judged to be
2002
+** SQLite for parsing. ^These routines return 1 if the input string
2003
+** appears to be a complete SQL statement. ^A statement is judged to be
19722004
** complete if it ends with a semicolon token and is not a prefix of a
1973
-** well-formed CREATE TRIGGER statement. Semicolons that are embedded within
2005
+** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
19742006
** string literals or quoted identifier names or comments are not
19752007
** independent tokens (they are part of the token in which they are
1976
-** embedded) and thus do not count as a statement terminator. Whitespace
2008
+** embedded) and thus do not count as a statement terminator. ^Whitespace
19772009
** and comments that follow the final semicolon are ignored.
19782010
**
1979
-** These routines return 0 if the statement is incomplete. If a
2011
+** ^These routines return 0 if the statement is incomplete. ^If a
19802012
** memory allocation fails, then SQLITE_NOMEM is returned.
19812013
**
1982
-** These routines do not parse the SQL statements thus
2014
+** ^These routines do not parse the SQL statements thus
19832015
** will not detect syntactically incorrect SQL.
19842016
**
1985
-** If SQLite has not been initialized using [sqlite3_initialize()] prior
2017
+** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
19862018
** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
19872019
** automatically by sqlite3_complete16(). If that initialization fails,
19882020
** then the return value from sqlite3_complete16() will be non-zero
1989
-** regardless of whether or not the input SQL is complete.
1990
-**
1991
-** Requirements: [H10511] [H10512]
2021
+** regardless of whether or not the input SQL is complete.)^
19922022
**
19932023
** The input to [sqlite3_complete()] must be a zero-terminated
19942024
** UTF-8 string.
19952025
**
19962026
** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1998,31 +2028,31 @@
19982028
*/
19992029
SQLITE_API int sqlite3_complete(const char *sql);
20002030
SQLITE_API int sqlite3_complete16(const void *sql);
20012031
20022032
/*
2003
-** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
2033
+** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
20042034
**
2005
-** This routine sets a callback function that might be invoked whenever
2035
+** ^This routine sets a callback function that might be invoked whenever
20062036
** an attempt is made to open a database table that another thread
20072037
** or process has locked.
20082038
**
2009
-** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
2010
-** is returned immediately upon encountering the lock. If the busy callback
2011
-** is not NULL, then the callback will be invoked with two arguments.
2039
+** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
2040
+** is returned immediately upon encountering the lock. ^If the busy callback
2041
+** is not NULL, then the callback might be invoked with two arguments.
20122042
**
2013
-** The first argument to the handler is a copy of the void* pointer which
2014
-** is the third argument to sqlite3_busy_handler(). The second argument to
2015
-** the handler callback is the number of times that the busy handler has
2016
-** been invoked for this locking event. If the
2043
+** ^The first argument to the busy handler is a copy of the void* pointer which
2044
+** is the third argument to sqlite3_busy_handler(). ^The second argument to
2045
+** the busy handler callback is the number of times that the busy handler has
2046
+** been invoked for this locking event. ^If the
20172047
** busy callback returns 0, then no additional attempts are made to
20182048
** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
2019
-** If the callback returns non-zero, then another attempt
2049
+** ^If the callback returns non-zero, then another attempt
20202050
** is made to open the database for reading and the cycle repeats.
20212051
**
20222052
** The presence of a busy handler does not guarantee that it will be invoked
2023
-** when there is lock contention. If SQLite determines that invoking the busy
2053
+** when there is lock contention. ^If SQLite determines that invoking the busy
20242054
** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
20252055
** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
20262056
** Consider a scenario where one process is holding a read lock that
20272057
** it is trying to promote to a reserved lock and
20282058
** a second process is holding a reserved lock that it is trying
@@ -2032,69 +2062,63 @@
20322062
** invoke the busy handlers, neither will make any progress. Therefore,
20332063
** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
20342064
** will induce the first process to release its read lock and allow
20352065
** the second process to proceed.
20362066
**
2037
-** The default busy callback is NULL.
2067
+** ^The default busy callback is NULL.
20382068
**
2039
-** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
2069
+** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
20402070
** when SQLite is in the middle of a large transaction where all the
20412071
** changes will not fit into the in-memory cache. SQLite will
20422072
** already hold a RESERVED lock on the database file, but it needs
20432073
** to promote this lock to EXCLUSIVE so that it can spill cache
20442074
** pages into the database file without harm to concurrent
2045
-** readers. If it is unable to promote the lock, then the in-memory
2075
+** readers. ^If it is unable to promote the lock, then the in-memory
20462076
** cache will be left in an inconsistent state and so the error
20472077
** code is promoted from the relatively benign [SQLITE_BUSY] to
2048
-** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion
2078
+** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion
20492079
** forces an automatic rollback of the changes. See the
20502080
** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
20512081
** CorruptionFollowingBusyError</a> wiki page for a discussion of why
20522082
** this is important.
20532083
**
2054
-** There can only be a single busy handler defined for each
2084
+** ^(There can only be a single busy handler defined for each
20552085
** [database connection]. Setting a new busy handler clears any
2056
-** previously set handler. Note that calling [sqlite3_busy_timeout()]
2086
+** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()]
20572087
** will also set or clear the busy handler.
20582088
**
20592089
** The busy callback should not take any actions which modify the
20602090
** database connection that invoked the busy handler. Any such actions
20612091
** result in undefined behavior.
20622092
**
2063
-** Requirements:
2064
-** [H12311] [H12312] [H12314] [H12316] [H12318]
2065
-**
20662093
** A busy handler must not close the database connection
20672094
** or [prepared statement] that invoked the busy handler.
20682095
*/
20692096
SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
20702097
20712098
/*
2072
-** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
2099
+** CAPI3REF: Set A Busy Timeout
20732100
**
2074
-** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2075
-** for a specified amount of time when a table is locked. The handler
2101
+** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2102
+** for a specified amount of time when a table is locked. ^The handler
20762103
** will sleep multiple times until at least "ms" milliseconds of sleeping
2077
-** have accumulated. {H12343} After "ms" milliseconds of sleeping,
2104
+** have accumulated. ^After at least "ms" milliseconds of sleeping,
20782105
** the handler returns 0 which causes [sqlite3_step()] to return
20792106
** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
20802107
**
2081
-** Calling this routine with an argument less than or equal to zero
2108
+** ^Calling this routine with an argument less than or equal to zero
20822109
** turns off all busy handlers.
20832110
**
2084
-** There can only be a single busy handler for a particular
2111
+** ^(There can only be a single busy handler for a particular
20852112
** [database connection] any any given moment. If another busy handler
20862113
** was defined (using [sqlite3_busy_handler()]) prior to calling
2087
-** this routine, that other busy handler is cleared.
2088
-**
2089
-** Requirements:
2090
-** [H12341] [H12343] [H12344]
2114
+** this routine, that other busy handler is cleared.)^
20912115
*/
20922116
SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
20932117
20942118
/*
2095
-** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
2119
+** CAPI3REF: Convenience Routines For Running Queries
20962120
**
20972121
** Definition: A <b>result table</b> is memory data structure created by the
20982122
** [sqlite3_get_table()] interface. A result table records the
20992123
** complete query results from one or more queries.
21002124
**
@@ -2138,31 +2162,29 @@
21382162
** azResult&#91;5] = "28";
21392163
** azResult&#91;6] = "Cindy";
21402164
** azResult&#91;7] = "21";
21412165
** </pre></blockquote>
21422166
**
2143
-** The sqlite3_get_table() function evaluates one or more
2167
+** ^The sqlite3_get_table() function evaluates one or more
21442168
** semicolon-separated SQL statements in the zero-terminated UTF-8
2145
-** string of its 2nd parameter. It returns a result table to the
2169
+** string of its 2nd parameter and returns a result table to the
21462170
** pointer given in its 3rd parameter.
21472171
**
2148
-** After the calling function has finished using the result, it should
2149
-** pass the pointer to the result table to sqlite3_free_table() in order to
2172
+** After the application has finished with the result from sqlite3_get_table(),
2173
+** it should pass the result table pointer to sqlite3_free_table() in order to
21502174
** release the memory that was malloced. Because of the way the
21512175
** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
21522176
** function must not try to call [sqlite3_free()] directly. Only
21532177
** [sqlite3_free_table()] is able to release the memory properly and safely.
21542178
**
2155
-** The sqlite3_get_table() interface is implemented as a wrapper around
2179
+** ^(The sqlite3_get_table() interface is implemented as a wrapper around
21562180
** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
21572181
** to any internal data structures of SQLite. It uses only the public
21582182
** interface defined here. As a consequence, errors that occur in the
21592183
** wrapper layer outside of the internal [sqlite3_exec()] call are not
2160
-** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()].
2161
-**
2162
-** Requirements:
2163
-** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
2184
+** reflected in subsequent calls to [sqlite3_errcode()] or
2185
+** [sqlite3_errmsg()].)^
21642186
*/
21652187
SQLITE_API int sqlite3_get_table(
21662188
sqlite3 *db, /* An open database */
21672189
const char *zSql, /* SQL to be evaluated */
21682190
char ***pazResult, /* Results of the query */
@@ -2171,49 +2193,49 @@
21712193
char **pzErrmsg /* Error msg written here */
21722194
);
21732195
SQLITE_API void sqlite3_free_table(char **result);
21742196
21752197
/*
2176
-** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
2198
+** CAPI3REF: Formatted String Printing Functions
21772199
**
21782200
** These routines are work-alikes of the "printf()" family of functions
21792201
** from the standard C library.
21802202
**
2181
-** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
2203
+** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
21822204
** results into memory obtained from [sqlite3_malloc()].
21832205
** The strings returned by these two routines should be
2184
-** released by [sqlite3_free()]. Both routines return a
2206
+** released by [sqlite3_free()]. ^Both routines return a
21852207
** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
21862208
** memory to hold the resulting string.
21872209
**
2188
-** In sqlite3_snprintf() routine is similar to "snprintf()" from
2210
+** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
21892211
** the standard C library. The result is written into the
21902212
** buffer supplied as the second parameter whose size is given by
21912213
** the first parameter. Note that the order of the
2192
-** first two parameters is reversed from snprintf(). This is an
2214
+** first two parameters is reversed from snprintf().)^ This is an
21932215
** historical accident that cannot be fixed without breaking
2194
-** backwards compatibility. Note also that sqlite3_snprintf()
2216
+** backwards compatibility. ^(Note also that sqlite3_snprintf()
21952217
** returns a pointer to its buffer instead of the number of
2196
-** characters actually written into the buffer. We admit that
2218
+** characters actually written into the buffer.)^ We admit that
21972219
** the number of characters written would be a more useful return
21982220
** value but we cannot change the implementation of sqlite3_snprintf()
21992221
** now without breaking compatibility.
22002222
**
2201
-** As long as the buffer size is greater than zero, sqlite3_snprintf()
2202
-** guarantees that the buffer is always zero-terminated. The first
2223
+** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
2224
+** guarantees that the buffer is always zero-terminated. ^The first
22032225
** parameter "n" is the total size of the buffer, including space for
22042226
** the zero terminator. So the longest string that can be completely
22052227
** written will be n-1 characters.
22062228
**
22072229
** These routines all implement some additional formatting
22082230
** options that are useful for constructing SQL statements.
22092231
** All of the usual printf() formatting options apply. In addition, there
22102232
** is are "%q", "%Q", and "%z" options.
22112233
**
2212
-** The %q option works like %s in that it substitutes a null-terminated
2234
+** ^(The %q option works like %s in that it substitutes a null-terminated
22132235
** string from the argument list. But %q also doubles every '\'' character.
2214
-** %q is designed for use inside a string literal. By doubling each '\''
2236
+** %q is designed for use inside a string literal.)^ By doubling each '\''
22152237
** character it escapes that character and allows it to be inserted into
22162238
** the string.
22172239
**
22182240
** For example, assume the string variable zText contains text as follows:
22192241
**
@@ -2244,14 +2266,14 @@
22442266
** </pre></blockquote>
22452267
**
22462268
** This second example is an SQL syntax error. As a general rule you should
22472269
** always use %q instead of %s when inserting text into a string literal.
22482270
**
2249
-** The %Q option works like %q except it also adds single quotes around
2271
+** ^(The %Q option works like %q except it also adds single quotes around
22502272
** the outside of the total string. Additionally, if the parameter in the
22512273
** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
2252
-** single quotes) in place of the %Q option. So, for example, one could say:
2274
+** single quotes).)^ So, for example, one could say:
22532275
**
22542276
** <blockquote><pre>
22552277
** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
22562278
** sqlite3_exec(db, zSQL, 0, 0, 0);
22572279
** sqlite3_free(zSQL);
@@ -2258,75 +2280,63 @@
22582280
** </pre></blockquote>
22592281
**
22602282
** The code above will render a correct SQL statement in the zSQL
22612283
** variable even if the zText variable is a NULL pointer.
22622284
**
2263
-** The "%z" formatting option works exactly like "%s" with the
2285
+** ^(The "%z" formatting option works like "%s" but with the
22642286
** addition that after the string has been read and copied into
2265
-** the result, [sqlite3_free()] is called on the input string. {END}
2266
-**
2267
-** Requirements:
2268
-** [H17403] [H17406] [H17407]
2287
+** the result, [sqlite3_free()] is called on the input string.)^
22692288
*/
22702289
SQLITE_API char *sqlite3_mprintf(const char*,...);
22712290
SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
22722291
SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
22732292
22742293
/*
2275
-** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
2294
+** CAPI3REF: Memory Allocation Subsystem
22762295
**
2277
-** The SQLite core uses these three routines for all of its own
2296
+** The SQLite core uses these three routines for all of its own
22782297
** internal memory allocation needs. "Core" in the previous sentence
22792298
** does not include operating-system specific VFS implementation. The
22802299
** Windows VFS uses native malloc() and free() for some operations.
22812300
**
2282
-** The sqlite3_malloc() routine returns a pointer to a block
2301
+** ^The sqlite3_malloc() routine returns a pointer to a block
22832302
** of memory at least N bytes in length, where N is the parameter.
2284
-** If sqlite3_malloc() is unable to obtain sufficient free
2285
-** memory, it returns a NULL pointer. If the parameter N to
2303
+** ^If sqlite3_malloc() is unable to obtain sufficient free
2304
+** memory, it returns a NULL pointer. ^If the parameter N to
22862305
** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
22872306
** a NULL pointer.
22882307
**
2289
-** Calling sqlite3_free() with a pointer previously returned
2308
+** ^Calling sqlite3_free() with a pointer previously returned
22902309
** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
2291
-** that it might be reused. The sqlite3_free() routine is
2310
+** that it might be reused. ^The sqlite3_free() routine is
22922311
** a no-op if is called with a NULL pointer. Passing a NULL pointer
22932312
** to sqlite3_free() is harmless. After being freed, memory
22942313
** should neither be read nor written. Even reading previously freed
22952314
** memory might result in a segmentation fault or other severe error.
22962315
** Memory corruption, a segmentation fault, or other severe error
22972316
** might result if sqlite3_free() is called with a non-NULL pointer that
22982317
** was not obtained from sqlite3_malloc() or sqlite3_realloc().
22992318
**
2300
-** The sqlite3_realloc() interface attempts to resize a
2319
+** ^(The sqlite3_realloc() interface attempts to resize a
23012320
** prior memory allocation to be at least N bytes, where N is the
23022321
** second parameter. The memory allocation to be resized is the first
2303
-** parameter. If the first parameter to sqlite3_realloc()
2322
+** parameter.)^ ^ If the first parameter to sqlite3_realloc()
23042323
** is a NULL pointer then its behavior is identical to calling
23052324
** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
2306
-** If the second parameter to sqlite3_realloc() is zero or
2325
+** ^If the second parameter to sqlite3_realloc() is zero or
23072326
** negative then the behavior is exactly the same as calling
23082327
** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
2309
-** sqlite3_realloc() returns a pointer to a memory allocation
2328
+** ^sqlite3_realloc() returns a pointer to a memory allocation
23102329
** of at least N bytes in size or NULL if sufficient memory is unavailable.
2311
-** If M is the size of the prior allocation, then min(N,M) bytes
2330
+** ^If M is the size of the prior allocation, then min(N,M) bytes
23122331
** of the prior allocation are copied into the beginning of buffer returned
23132332
** by sqlite3_realloc() and the prior allocation is freed.
2314
-** If sqlite3_realloc() returns NULL, then the prior allocation
2333
+** ^If sqlite3_realloc() returns NULL, then the prior allocation
23152334
** is not freed.
23162335
**
2317
-** The memory returned by sqlite3_malloc() and sqlite3_realloc()
2318
-** is always aligned to at least an 8 byte boundary. {END}
2319
-**
2320
-** The default implementation of the memory allocation subsystem uses
2321
-** the malloc(), realloc() and free() provided by the standard C library.
2322
-** {H17382} However, if SQLite is compiled with the
2323
-** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
2324
-** is an integer), then SQLite create a static array of at least
2325
-** <i>NNN</i> bytes in size and uses that array for all of its dynamic
2326
-** memory allocation needs. {END} Additional memory allocator options
2327
-** may be added in future releases.
2336
+** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
2337
+** is always aligned to at least an 8 byte boundary.
23282338
**
23292339
** In SQLite version 3.5.0 and 3.5.1, it was possible to define
23302340
** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
23312341
** implementation of these routines to be omitted. That capability
23322342
** is no longer provided. Only built-in memory allocators can be used.
@@ -2337,14 +2347,10 @@
23372347
** and whatever filename encoding is used by the particular Windows
23382348
** installation. Memory allocation errors are detected, but
23392349
** they are reported back as [SQLITE_CANTOPEN] or
23402350
** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
23412351
**
2342
-** Requirements:
2343
-** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
2344
-** [H17321] [H17322] [H17323]
2345
-**
23462352
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
23472353
** must be either NULL or else pointers obtained from a prior
23482354
** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
23492355
** not yet been released.
23502356
**
@@ -2355,85 +2361,95 @@
23552361
SQLITE_API void *sqlite3_malloc(int);
23562362
SQLITE_API void *sqlite3_realloc(void*, int);
23572363
SQLITE_API void sqlite3_free(void*);
23582364
23592365
/*
2360
-** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
2366
+** CAPI3REF: Memory Allocator Statistics
23612367
**
23622368
** SQLite provides these two interfaces for reporting on the status
23632369
** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
23642370
** routines, which form the built-in memory allocation subsystem.
23652371
**
2366
-** Requirements:
2367
-** [H17371] [H17373] [H17374] [H17375]
2372
+** ^The [sqlite3_memory_used()] routine returns the number of bytes
2373
+** of memory currently outstanding (malloced but not freed).
2374
+** ^The [sqlite3_memory_highwater()] routine returns the maximum
2375
+** value of [sqlite3_memory_used()] since the high-water mark
2376
+** was last reset. ^The values returned by [sqlite3_memory_used()] and
2377
+** [sqlite3_memory_highwater()] include any overhead
2378
+** added by SQLite in its implementation of [sqlite3_malloc()],
2379
+** but not overhead added by the any underlying system library
2380
+** routines that [sqlite3_malloc()] may call.
2381
+**
2382
+** ^The memory high-water mark is reset to the current value of
2383
+** [sqlite3_memory_used()] if and only if the parameter to
2384
+** [sqlite3_memory_highwater()] is true. ^The value returned
2385
+** by [sqlite3_memory_highwater(1)] is the high-water mark
2386
+** prior to the reset.
23682387
*/
23692388
SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
23702389
SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
23712390
23722391
/*
2373
-** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
2392
+** CAPI3REF: Pseudo-Random Number Generator
23742393
**
23752394
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
23762395
** select random [ROWID | ROWIDs] when inserting new records into a table that
23772396
** already uses the largest possible [ROWID]. The PRNG is also used for
23782397
** the build-in random() and randomblob() SQL functions. This interface allows
23792398
** applications to access the same PRNG for other purposes.
23802399
**
2381
-** A call to this routine stores N bytes of randomness into buffer P.
2400
+** ^A call to this routine stores N bytes of randomness into buffer P.
23822401
**
2383
-** The first time this routine is invoked (either internally or by
2402
+** ^The first time this routine is invoked (either internally or by
23842403
** the application) the PRNG is seeded using randomness obtained
23852404
** from the xRandomness method of the default [sqlite3_vfs] object.
2386
-** On all subsequent invocations, the pseudo-randomness is generated
2405
+** ^On all subsequent invocations, the pseudo-randomness is generated
23872406
** internally and without recourse to the [sqlite3_vfs] xRandomness
23882407
** method.
2389
-**
2390
-** Requirements:
2391
-** [H17392]
23922408
*/
23932409
SQLITE_API void sqlite3_randomness(int N, void *P);
23942410
23952411
/*
2396
-** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
2412
+** CAPI3REF: Compile-Time Authorization Callbacks
23972413
**
2398
-** This routine registers a authorizer callback with a particular
2414
+** ^This routine registers a authorizer callback with a particular
23992415
** [database connection], supplied in the first argument.
2400
-** The authorizer callback is invoked as SQL statements are being compiled
2416
+** ^The authorizer callback is invoked as SQL statements are being compiled
24012417
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2402
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various
2418
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
24032419
** points during the compilation process, as logic is being created
24042420
** to perform various actions, the authorizer callback is invoked to
2405
-** see if those actions are allowed. The authorizer callback should
2421
+** see if those actions are allowed. ^The authorizer callback should
24062422
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
24072423
** specific action but allow the SQL statement to continue to be
24082424
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2409
-** rejected with an error. If the authorizer callback returns
2425
+** rejected with an error. ^If the authorizer callback returns
24102426
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
24112427
** then the [sqlite3_prepare_v2()] or equivalent call that triggered
24122428
** the authorizer will fail with an error message.
24132429
**
24142430
** When the callback returns [SQLITE_OK], that means the operation
2415
-** requested is ok. When the callback returns [SQLITE_DENY], the
2431
+** requested is ok. ^When the callback returns [SQLITE_DENY], the
24162432
** [sqlite3_prepare_v2()] or equivalent call that triggered the
24172433
** authorizer will fail with an error message explaining that
24182434
** access is denied.
24192435
**
2420
-** The first parameter to the authorizer callback is a copy of the third
2421
-** parameter to the sqlite3_set_authorizer() interface. The second parameter
2436
+** ^The first parameter to the authorizer callback is a copy of the third
2437
+** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
24222438
** to the callback is an integer [SQLITE_COPY | action code] that specifies
2423
-** the particular action to be authorized. The third through sixth parameters
2439
+** the particular action to be authorized. ^The third through sixth parameters
24242440
** to the callback are zero-terminated strings that contain additional
24252441
** details about the action to be authorized.
24262442
**
2427
-** If the action code is [SQLITE_READ]
2443
+** ^If the action code is [SQLITE_READ]
24282444
** and the callback returns [SQLITE_IGNORE] then the
24292445
** [prepared statement] statement is constructed to substitute
24302446
** a NULL value in place of the table column that would have
24312447
** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
24322448
** return can be used to deny an untrusted user access to individual
24332449
** columns of a table.
2434
-** If the action code is [SQLITE_DELETE] and the callback returns
2450
+** ^If the action code is [SQLITE_DELETE] and the callback returns
24352451
** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
24362452
** [truncate optimization] is disabled and all rows are deleted individually.
24372453
**
24382454
** An authorizer is used when [sqlite3_prepare | preparing]
24392455
** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -2449,43 +2465,39 @@
24492465
** Applications that need to process SQL from untrusted sources
24502466
** might also consider lowering resource limits using [sqlite3_limit()]
24512467
** and limiting database size using the [max_page_count] [PRAGMA]
24522468
** in addition to using an authorizer.
24532469
**
2454
-** Only a single authorizer can be in place on a database connection
2470
+** ^(Only a single authorizer can be in place on a database connection
24552471
** at a time. Each call to sqlite3_set_authorizer overrides the
2456
-** previous call. Disable the authorizer by installing a NULL callback.
2472
+** previous call.)^ ^Disable the authorizer by installing a NULL callback.
24572473
** The authorizer is disabled by default.
24582474
**
24592475
** The authorizer callback must not do anything that will modify
24602476
** the database connection that invoked the authorizer callback.
24612477
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
24622478
** database connections for the meaning of "modify" in this paragraph.
24632479
**
2464
-** When [sqlite3_prepare_v2()] is used to prepare a statement, the
2480
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
24652481
** statement might be re-prepared during [sqlite3_step()] due to a
24662482
** schema change. Hence, the application should ensure that the
24672483
** correct authorizer callback remains in place during the [sqlite3_step()].
24682484
**
2469
-** Note that the authorizer callback is invoked only during
2485
+** ^Note that the authorizer callback is invoked only during
24702486
** [sqlite3_prepare()] or its variants. Authorization is not
24712487
** performed during statement evaluation in [sqlite3_step()], unless
24722488
** as stated in the previous paragraph, sqlite3_step() invokes
24732489
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2474
-**
2475
-** Requirements:
2476
-** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
2477
-** [H12511] [H12512] [H12520] [H12521] [H12522]
24782490
*/
24792491
SQLITE_API int sqlite3_set_authorizer(
24802492
sqlite3*,
24812493
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
24822494
void *pUserData
24832495
);
24842496
24852497
/*
2486
-** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
2498
+** CAPI3REF: Authorizer Return Codes
24872499
**
24882500
** The [sqlite3_set_authorizer | authorizer callback function] must
24892501
** return either [SQLITE_OK] or one of these two constants in order
24902502
** to signal SQLite whether or not the action is permitted. See the
24912503
** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -2493,11 +2505,11 @@
24932505
*/
24942506
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
24952507
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
24962508
24972509
/*
2498
-** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
2510
+** CAPI3REF: Authorizer Action Codes
24992511
**
25002512
** The [sqlite3_set_authorizer()] interface registers a callback function
25012513
** that is invoked to authorize certain SQL statement actions. The
25022514
** second parameter to the callback is an integer code that specifies
25032515
** what action is being authorized. These are the integer action codes that
@@ -2504,19 +2516,16 @@
25042516
** the authorizer callback may be passed.
25052517
**
25062518
** These action code values signify what kind of operation is to be
25072519
** authorized. The 3rd and 4th parameters to the authorization
25082520
** callback function will be parameters or NULL depending on which of these
2509
-** codes is used as the second parameter. The 5th parameter to the
2521
+** codes is used as the second parameter. ^(The 5th parameter to the
25102522
** authorizer callback is the name of the database ("main", "temp",
2511
-** etc.) if applicable. The 6th parameter to the authorizer callback
2523
+** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback
25122524
** is the name of the inner-most trigger or view that is responsible for
25132525
** the access attempt or NULL if this access attempt is directly from
25142526
** top-level SQL code.
2515
-**
2516
-** Requirements:
2517
-** [H12551] [H12552] [H12553] [H12554]
25182527
*/
25192528
/******************************************* 3rd ************ 4th ***********/
25202529
#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
25212530
#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
25222531
#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2550,150 +2559,142 @@
25502559
#define SQLITE_FUNCTION 31 /* NULL Function Name */
25512560
#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
25522561
#define SQLITE_COPY 0 /* No longer used */
25532562
25542563
/*
2555
-** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
2564
+** CAPI3REF: Tracing And Profiling Functions
25562565
** EXPERIMENTAL
25572566
**
25582567
** These routines register callback functions that can be used for
25592568
** tracing and profiling the execution of SQL statements.
25602569
**
2561
-** The callback function registered by sqlite3_trace() is invoked at
2570
+** ^The callback function registered by sqlite3_trace() is invoked at
25622571
** various times when an SQL statement is being run by [sqlite3_step()].
2563
-** The callback returns a UTF-8 rendering of the SQL statement text
2564
-** as the statement first begins executing. Additional callbacks occur
2572
+** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2573
+** SQL statement text as the statement first begins executing.
2574
+** ^(Additional sqlite3_trace() callbacks might occur
25652575
** as each triggered subprogram is entered. The callbacks for triggers
2566
-** contain a UTF-8 SQL comment that identifies the trigger.
2576
+** contain a UTF-8 SQL comment that identifies the trigger.)^
25672577
**
2568
-** The callback function registered by sqlite3_profile() is invoked
2569
-** as each SQL statement finishes. The profile callback contains
2578
+** ^The callback function registered by sqlite3_profile() is invoked
2579
+** as each SQL statement finishes. ^The profile callback contains
25702580
** the original statement text and an estimate of wall-clock time
25712581
** of how long that statement took to run.
2572
-**
2573
-** Requirements:
2574
-** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
2575
-** [H12290]
25762582
*/
25772583
SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
25782584
SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
25792585
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
25802586
25812587
/*
2582
-** CAPI3REF: Query Progress Callbacks {H12910} <S60400>
2588
+** CAPI3REF: Query Progress Callbacks
25832589
**
2584
-** This routine configures a callback function - the
2590
+** ^This routine configures a callback function - the
25852591
** progress callback - that is invoked periodically during long
25862592
** running calls to [sqlite3_exec()], [sqlite3_step()] and
25872593
** [sqlite3_get_table()]. An example use for this
25882594
** interface is to keep a GUI updated during a large query.
25892595
**
2590
-** If the progress callback returns non-zero, the operation is
2596
+** ^If the progress callback returns non-zero, the operation is
25912597
** interrupted. This feature can be used to implement a
25922598
** "Cancel" button on a GUI progress dialog box.
25932599
**
25942600
** The progress handler must not do anything that will modify
25952601
** the database connection that invoked the progress handler.
25962602
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
25972603
** database connections for the meaning of "modify" in this paragraph.
25982604
**
2599
-** Requirements:
2600
-** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
2601
-**
26022605
*/
26032606
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
26042607
26052608
/*
2606
-** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
2609
+** CAPI3REF: Opening A New Database Connection
26072610
**
2608
-** These routines open an SQLite database file whose name is given by the
2609
-** filename argument. The filename argument is interpreted as UTF-8 for
2611
+** ^These routines open an SQLite database file whose name is given by the
2612
+** filename argument. ^The filename argument is interpreted as UTF-8 for
26102613
** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2611
-** order for sqlite3_open16(). A [database connection] handle is usually
2614
+** order for sqlite3_open16(). ^(A [database connection] handle is usually
26122615
** returned in *ppDb, even if an error occurs. The only exception is that
26132616
** if SQLite is unable to allocate memory to hold the [sqlite3] object,
26142617
** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2615
-** object. If the database is opened (and/or created) successfully, then
2616
-** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The
2618
+** object.)^ ^(If the database is opened (and/or created) successfully, then
2619
+** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
26172620
** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2618
-** an English language description of the error.
2621
+** an English language description of the error following a failure of any
2622
+** of the sqlite3_open() routines.
26192623
**
2620
-** The default encoding for the database will be UTF-8 if
2624
+** ^The default encoding for the database will be UTF-8 if
26212625
** sqlite3_open() or sqlite3_open_v2() is called and
26222626
** UTF-16 in the native byte order if sqlite3_open16() is used.
26232627
**
26242628
** Whether or not an error occurs when it is opened, resources
26252629
** associated with the [database connection] handle should be released by
26262630
** passing it to [sqlite3_close()] when it is no longer required.
26272631
**
26282632
** The sqlite3_open_v2() interface works like sqlite3_open()
26292633
** except that it accepts two additional parameters for additional control
2630
-** over the new database connection. The flags parameter can take one of
2634
+** over the new database connection. ^(The flags parameter to
2635
+** sqlite3_open_v2() can take one of
26312636
** the following three values, optionally combined with the
26322637
** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2633
-** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
2638
+** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
26342639
**
26352640
** <dl>
2636
-** <dt>[SQLITE_OPEN_READONLY]</dt>
2641
+** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
26372642
** <dd>The database is opened in read-only mode. If the database does not
2638
-** already exist, an error is returned.</dd>
2643
+** already exist, an error is returned.</dd>)^
26392644
**
2640
-** <dt>[SQLITE_OPEN_READWRITE]</dt>
2645
+** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
26412646
** <dd>The database is opened for reading and writing if possible, or reading
26422647
** only if the file is write protected by the operating system. In either
2643
-** case the database must already exist, otherwise an error is returned.</dd>
2648
+** case the database must already exist, otherwise an error is returned.</dd>)^
26442649
**
2645
-** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2650
+** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
26462651
** <dd>The database is opened for reading and writing, and is creates it if
26472652
** it does not already exist. This is the behavior that is always used for
2648
-** sqlite3_open() and sqlite3_open16().</dd>
2653
+** sqlite3_open() and sqlite3_open16().</dd>)^
26492654
** </dl>
26502655
**
26512656
** If the 3rd parameter to sqlite3_open_v2() is not one of the
26522657
** combinations shown above or one of the combinations shown above combined
26532658
** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
26542659
** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
26552660
** then the behavior is undefined.
26562661
**
2657
-** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2662
+** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
26582663
** opens in the multi-thread [threading mode] as long as the single-thread
2659
-** mode has not been set at compile-time or start-time. If the
2664
+** mode has not been set at compile-time or start-time. ^If the
26602665
** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
26612666
** in the serialized [threading mode] unless single-thread was
26622667
** previously selected at compile-time or start-time.
2663
-** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2668
+** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
26642669
** eligible to use [shared cache mode], regardless of whether or not shared
2665
-** cache is enabled using [sqlite3_enable_shared_cache()]. The
2670
+** cache is enabled using [sqlite3_enable_shared_cache()]. ^The
26662671
** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
26672672
** participate in [shared cache mode] even if it is enabled.
26682673
**
2669
-** If the filename is ":memory:", then a private, temporary in-memory database
2670
-** is created for the connection. This in-memory database will vanish when
2674
+** ^If the filename is ":memory:", then a private, temporary in-memory database
2675
+** is created for the connection. ^This in-memory database will vanish when
26712676
** the database connection is closed. Future versions of SQLite might
26722677
** make use of additional special filenames that begin with the ":" character.
26732678
** It is recommended that when a database filename actually does begin with
26742679
** a ":" character you should prefix the filename with a pathname such as
26752680
** "./" to avoid ambiguity.
26762681
**
2677
-** If the filename is an empty string, then a private, temporary
2678
-** on-disk database will be created. This private database will be
2682
+** ^If the filename is an empty string, then a private, temporary
2683
+** on-disk database will be created. ^This private database will be
26792684
** automatically deleted as soon as the database connection is closed.
26802685
**
2681
-** The fourth parameter to sqlite3_open_v2() is the name of the
2686
+** ^The fourth parameter to sqlite3_open_v2() is the name of the
26822687
** [sqlite3_vfs] object that defines the operating system interface that
2683
-** the new database connection should use. If the fourth parameter is
2688
+** the new database connection should use. ^If the fourth parameter is
26842689
** a NULL pointer then the default [sqlite3_vfs] object is used.
26852690
**
26862691
** <b>Note to Windows users:</b> The encoding used for the filename argument
26872692
** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
26882693
** codepage is currently defined. Filenames containing international
26892694
** characters must be converted to UTF-8 prior to passing them into
26902695
** sqlite3_open() or sqlite3_open_v2().
2691
-**
2692
-** Requirements:
2693
-** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
2694
-** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
26952696
*/
26962697
SQLITE_API int sqlite3_open(
26972698
const char *filename, /* Database filename (UTF-8) */
26982699
sqlite3 **ppDb /* OUT: SQLite db handle */
26992700
);
@@ -2707,27 +2708,27 @@
27072708
int flags, /* Flags */
27082709
const char *zVfs /* Name of VFS module to use */
27092710
);
27102711
27112712
/*
2712
-** CAPI3REF: Error Codes And Messages {H12800} <S60200>
2713
+** CAPI3REF: Error Codes And Messages
27132714
**
2714
-** The sqlite3_errcode() interface returns the numeric [result code] or
2715
+** ^The sqlite3_errcode() interface returns the numeric [result code] or
27152716
** [extended result code] for the most recent failed sqlite3_* API call
27162717
** associated with a [database connection]. If a prior API call failed
27172718
** but the most recent API call succeeded, the return value from
2718
-** sqlite3_errcode() is undefined. The sqlite3_extended_errcode()
2719
+** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
27192720
** interface is the same except that it always returns the
27202721
** [extended result code] even when extended result codes are
27212722
** disabled.
27222723
**
2723
-** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2724
+** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
27242725
** text that describes the error, as either UTF-8 or UTF-16 respectively.
2725
-** Memory to hold the error message string is managed internally.
2726
+** ^(Memory to hold the error message string is managed internally.
27262727
** The application does not need to worry about freeing the result.
27272728
** However, the error string might be overwritten or deallocated by
2728
-** subsequent calls to other SQLite interface functions.
2729
+** subsequent calls to other SQLite interface functions.)^
27292730
**
27302731
** When the serialized [threading mode] is in use, it might be the
27312732
** case that a second error occurs on a separate thread in between
27322733
** the time of the first error and the call to these interfaces.
27332734
** When that happens, the second error will be reported since these
@@ -2738,21 +2739,18 @@
27382739
** all calls to the interfaces listed here are completed.
27392740
**
27402741
** If an interface fails with SQLITE_MISUSE, that means the interface
27412742
** was invoked incorrectly by the application. In that case, the
27422743
** error code and message may or may not be set.
2743
-**
2744
-** Requirements:
2745
-** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
27462744
*/
27472745
SQLITE_API int sqlite3_errcode(sqlite3 *db);
27482746
SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
27492747
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
27502748
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
27512749
27522750
/*
2753
-** CAPI3REF: SQL Statement Object {H13000} <H13010>
2751
+** CAPI3REF: SQL Statement Object
27542752
** KEYWORDS: {prepared statement} {prepared statements}
27552753
**
27562754
** An instance of this object represents a single SQL statement.
27572755
** This object is variously known as a "prepared statement" or a
27582756
** "compiled SQL statement" or simply as a "statement".
@@ -2774,29 +2772,29 @@
27742772
** information.
27752773
*/
27762774
typedef struct sqlite3_stmt sqlite3_stmt;
27772775
27782776
/*
2779
-** CAPI3REF: Run-time Limits {H12760} <S20600>
2777
+** CAPI3REF: Run-time Limits
27802778
**
2781
-** This interface allows the size of various constructs to be limited
2779
+** ^(This interface allows the size of various constructs to be limited
27822780
** on a connection by connection basis. The first parameter is the
27832781
** [database connection] whose limit is to be set or queried. The
27842782
** second parameter is one of the [limit categories] that define a
27852783
** class of constructs to be size limited. The third parameter is the
2786
-** new limit for that construct. The function returns the old limit.
2784
+** new limit for that construct. The function returns the old limit.)^
27872785
**
2788
-** If the new limit is a negative number, the limit is unchanged.
2789
-** For the limit category of SQLITE_LIMIT_XYZ there is a
2786
+** ^If the new limit is a negative number, the limit is unchanged.
2787
+** ^(For the limit category of SQLITE_LIMIT_XYZ there is a
27902788
** [limits | hard upper bound]
27912789
** set by a compile-time C preprocessor macro named
27922790
** [limits | SQLITE_MAX_XYZ].
2793
-** (The "_LIMIT_" in the name is changed to "_MAX_".)
2794
-** Attempts to increase a limit above its hard upper bound are
2795
-** silently truncated to the hard upper limit.
2791
+** (The "_LIMIT_" in the name is changed to "_MAX_".))^
2792
+** ^Attempts to increase a limit above its hard upper bound are
2793
+** silently truncated to the hard upper bound.
27962794
**
2797
-** Run time limits are intended for use in applications that manage
2795
+** Run-time limits are intended for use in applications that manage
27982796
** both their own internal database and also databases that are controlled
27992797
** by untrusted external sources. An example application might be a
28002798
** web browser that has its own databases for storing history and
28012799
** separate databases controlled by JavaScript applications downloaded
28022800
** off the Internet. The internal databases can be given the
@@ -2806,63 +2804,60 @@
28062804
** interface to further control untrusted SQL. The size of the database
28072805
** created by an untrusted script can be contained using the
28082806
** [max_page_count] [PRAGMA].
28092807
**
28102808
** New run-time limit categories may be added in future releases.
2811
-**
2812
-** Requirements:
2813
-** [H12762] [H12766] [H12769]
28142809
*/
28152810
SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
28162811
28172812
/*
2818
-** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
2813
+** CAPI3REF: Run-Time Limit Categories
28192814
** KEYWORDS: {limit category} {*limit categories}
28202815
**
28212816
** These constants define various performance limits
28222817
** that can be lowered at run-time using [sqlite3_limit()].
28232818
** The synopsis of the meanings of the various limits is shown below.
28242819
** Additional information is available at [limits | Limits in SQLite].
28252820
**
28262821
** <dl>
2827
-** <dt>SQLITE_LIMIT_LENGTH</dt>
2828
-** <dd>The maximum size of any string or BLOB or table row.<dd>
2822
+** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2823
+** <dd>The maximum size of any string or BLOB or table row.<dd>)^
28292824
**
2830
-** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2831
-** <dd>The maximum length of an SQL statement.</dd>
2825
+** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2826
+** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
28322827
**
2833
-** <dt>SQLITE_LIMIT_COLUMN</dt>
2828
+** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
28342829
** <dd>The maximum number of columns in a table definition or in the
28352830
** result set of a [SELECT] or the maximum number of columns in an index
2836
-** or in an ORDER BY or GROUP BY clause.</dd>
2837
-**
2838
-** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2839
-** <dd>The maximum depth of the parse tree on any expression.</dd>
2840
-**
2841
-** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2842
-** <dd>The maximum number of terms in a compound SELECT statement.</dd>
2843
-**
2844
-** <dt>SQLITE_LIMIT_VDBE_OP</dt>
2831
+** or in an ORDER BY or GROUP BY clause.</dd>)^
2832
+**
2833
+** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2834
+** <dd>The maximum depth of the parse tree on any expression.</dd>)^
2835
+**
2836
+** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2837
+** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
2838
+**
2839
+** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
28452840
** <dd>The maximum number of instructions in a virtual machine program
2846
-** used to implement an SQL statement.</dd>
2847
-**
2848
-** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2849
-** <dd>The maximum number of arguments on a function.</dd>
2850
-**
2851
-** <dt>SQLITE_LIMIT_ATTACHED</dt>
2852
-** <dd>The maximum number of [ATTACH | attached databases].</dd>
2853
-**
2854
-** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2841
+** used to implement an SQL statement.</dd>)^
2842
+**
2843
+** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2844
+** <dd>The maximum number of arguments on a function.</dd>)^
2845
+**
2846
+** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2847
+** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
2848
+**
2849
+** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
28552850
** <dd>The maximum length of the pattern argument to the [LIKE] or
2856
-** [GLOB] operators.</dd>
2851
+** [GLOB] operators.</dd>)^
28572852
**
2858
-** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2853
+** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
28592854
** <dd>The maximum number of variables in an SQL statement that can
2860
-** be bound.</dd>
2855
+** be bound.</dd>)^
28612856
**
2862
-** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2863
-** <dd>The maximum depth of recursion for triggers.</dd>
2857
+** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2858
+** <dd>The maximum depth of recursion for triggers.</dd>)^
28642859
** </dl>
28652860
*/
28662861
#define SQLITE_LIMIT_LENGTH 0
28672862
#define SQLITE_LIMIT_SQL_LENGTH 1
28682863
#define SQLITE_LIMIT_COLUMN 2
@@ -2874,11 +2869,11 @@
28742869
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
28752870
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
28762871
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
28772872
28782873
/*
2879
-** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
2874
+** CAPI3REF: Compiling An SQL Statement
28802875
** KEYWORDS: {SQL statement compiler}
28812876
**
28822877
** To execute an SQL query, it must first be compiled into a byte-code
28832878
** program using one of these routines.
28842879
**
@@ -2889,61 +2884,62 @@
28892884
** The second argument, "zSql", is the statement to be compiled, encoded
28902885
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
28912886
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
28922887
** use UTF-16.
28932888
**
2894
-** If the nByte argument is less than zero, then zSql is read up to the
2895
-** first zero terminator. If nByte is non-negative, then it is the maximum
2896
-** number of bytes read from zSql. When nByte is non-negative, the
2889
+** ^If the nByte argument is less than zero, then zSql is read up to the
2890
+** first zero terminator. ^If nByte is non-negative, then it is the maximum
2891
+** number of bytes read from zSql. ^When nByte is non-negative, the
28972892
** zSql string ends at either the first '\000' or '\u0000' character or
28982893
** the nByte-th byte, whichever comes first. If the caller knows
28992894
** that the supplied string is nul-terminated, then there is a small
29002895
** performance advantage to be gained by passing an nByte parameter that
29012896
** is equal to the number of bytes in the input string <i>including</i>
29022897
** the nul-terminator bytes.
29032898
**
2904
-** If pzTail is not NULL then *pzTail is made to point to the first byte
2899
+** ^If pzTail is not NULL then *pzTail is made to point to the first byte
29052900
** past the end of the first SQL statement in zSql. These routines only
29062901
** compile the first statement in zSql, so *pzTail is left pointing to
29072902
** what remains uncompiled.
29082903
**
2909
-** *ppStmt is left pointing to a compiled [prepared statement] that can be
2910
-** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2911
-** to NULL. If the input text contains no SQL (if the input is an empty
2904
+** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
2905
+** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
2906
+** to NULL. ^If the input text contains no SQL (if the input is an empty
29122907
** string or a comment) then *ppStmt is set to NULL.
29132908
** The calling procedure is responsible for deleting the compiled
29142909
** SQL statement using [sqlite3_finalize()] after it has finished with it.
29152910
** ppStmt may not be NULL.
29162911
**
2917
-** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2912
+** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
2913
+** otherwise an [error code] is returned.
29182914
**
29192915
** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
29202916
** recommended for all new programs. The two older interfaces are retained
29212917
** for backwards compatibility, but their use is discouraged.
2922
-** In the "v2" interfaces, the prepared statement
2918
+** ^In the "v2" interfaces, the prepared statement
29232919
** that is returned (the [sqlite3_stmt] object) contains a copy of the
29242920
** original SQL text. This causes the [sqlite3_step()] interface to
29252921
** behave differently in three ways:
29262922
**
29272923
** <ol>
29282924
** <li>
2929
-** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2925
+** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
29302926
** always used to do, [sqlite3_step()] will automatically recompile the SQL
2931
-** statement and try to run it again. If the schema has changed in
2927
+** statement and try to run it again. ^If the schema has changed in
29322928
** a way that makes the statement no longer valid, [sqlite3_step()] will still
29332929
** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
29342930
** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
29352931
** error go away. Note: use [sqlite3_errmsg()] to find the text
29362932
** of the parsing error that results in an [SQLITE_SCHEMA] return.
29372933
** </li>
29382934
**
29392935
** <li>
2940
-** When an error occurs, [sqlite3_step()] will return one of the detailed
2941
-** [error codes] or [extended error codes]. The legacy behavior was that
2936
+** ^When an error occurs, [sqlite3_step()] will return one of the detailed
2937
+** [error codes] or [extended error codes]. ^The legacy behavior was that
29422938
** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2943
-** and you would have to make a second call to [sqlite3_reset()] in order
2944
-** to find the underlying cause of the problem. With the "v2" prepare
2939
+** and the application would have to make a second call to [sqlite3_reset()]
2940
+** in order to find the underlying cause of the problem. With the "v2" prepare
29452941
** interfaces, the underlying reason for the error is returned immediately.
29462942
** </li>
29472943
**
29482944
** <li>
29492945
** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2951,14 +2947,10 @@
29512947
** automatically recompiled (as if there had been a schema change) on the first
29522948
** [sqlite3_step()] call following any change to the
29532949
** [sqlite3_bind_text | bindings] of the [parameter].
29542950
** </li>
29552951
** </ol>
2956
-**
2957
-** Requirements:
2958
-** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
2959
-**
29602952
*/
29612953
SQLITE_API int sqlite3_prepare(
29622954
sqlite3 *db, /* Database handle */
29632955
const char *zSql, /* SQL statement, UTF-8 encoded */
29642956
int nByte, /* Maximum length of zSql in bytes. */
@@ -2986,28 +2978,25 @@
29862978
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
29872979
const void **pzTail /* OUT: Pointer to unused portion of zSql */
29882980
);
29892981
29902982
/*
2991
-** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
2983
+** CAPI3REF: Retrieving Statement SQL
29922984
**
2993
-** This interface can be used to retrieve a saved copy of the original
2985
+** ^This interface can be used to retrieve a saved copy of the original
29942986
** SQL text used to create a [prepared statement] if that statement was
29952987
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
2996
-**
2997
-** Requirements:
2998
-** [H13101] [H13102] [H13103]
29992988
*/
30002989
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
30012990
30022991
/*
3003
-** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
2992
+** CAPI3REF: Dynamically Typed Value Object
30042993
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
30052994
**
30062995
** SQLite uses the sqlite3_value object to represent all values
30072996
** that can be stored in a database table. SQLite uses dynamic typing
3008
-** for the values it stores. Values stored in sqlite3_value objects
2997
+** for the values it stores. ^Values stored in sqlite3_value objects
30092998
** can be integers, floating point values, strings, BLOBs, or NULL.
30102999
**
30113000
** An sqlite3_value object may be either "protected" or "unprotected".
30123001
** Some interfaces require a protected sqlite3_value. Other interfaces
30133002
** will accept either a protected or an unprotected sqlite3_value.
@@ -3025,26 +3014,26 @@
30253014
** sqlite3_value objects and they can be used interchangeably. However,
30263015
** for maximum code portability it is recommended that applications
30273016
** still make the distinction between between protected and unprotected
30283017
** sqlite3_value objects even when not strictly required.
30293018
**
3030
-** The sqlite3_value objects that are passed as parameters into the
3019
+** ^The sqlite3_value objects that are passed as parameters into the
30313020
** implementation of [application-defined SQL functions] are protected.
3032
-** The sqlite3_value object returned by
3021
+** ^The sqlite3_value object returned by
30333022
** [sqlite3_column_value()] is unprotected.
30343023
** Unprotected sqlite3_value objects may only be used with
30353024
** [sqlite3_result_value()] and [sqlite3_bind_value()].
30363025
** The [sqlite3_value_blob | sqlite3_value_type()] family of
30373026
** interfaces require protected sqlite3_value objects.
30383027
*/
30393028
typedef struct Mem sqlite3_value;
30403029
30413030
/*
3042
-** CAPI3REF: SQL Function Context Object {H16001} <S20200>
3031
+** CAPI3REF: SQL Function Context Object
30433032
**
30443033
** The context in which an SQL function executes is stored in an
3045
-** sqlite3_context object. A pointer to an sqlite3_context object
3034
+** sqlite3_context object. ^A pointer to an sqlite3_context object
30463035
** is always first parameter to [application-defined SQL functions].
30473036
** The application-defined SQL function implementation will pass this
30483037
** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
30493038
** [sqlite3_aggregate_context()], [sqlite3_user_data()],
30503039
** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -3051,15 +3040,15 @@
30513040
** and/or [sqlite3_set_auxdata()].
30523041
*/
30533042
typedef struct sqlite3_context sqlite3_context;
30543043
30553044
/*
3056
-** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
3045
+** CAPI3REF: Binding Values To Prepared Statements
30573046
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
30583047
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
30593048
**
3060
-** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
3049
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
30613050
** literals may be replaced by a [parameter] that matches one of following
30623051
** templates:
30633052
**
30643053
** <ul>
30653054
** <li> ?
@@ -3068,76 +3057,70 @@
30683057
** <li> @VVV
30693058
** <li> $VVV
30703059
** </ul>
30713060
**
30723061
** In the templates above, NNN represents an integer literal,
3073
-** and VVV represents an alphanumeric identifer. The values of these
3062
+** and VVV represents an alphanumeric identifer.)^ ^The values of these
30743063
** parameters (also called "host parameter names" or "SQL parameters")
30753064
** can be set using the sqlite3_bind_*() routines defined here.
30763065
**
3077
-** The first argument to the sqlite3_bind_*() routines is always
3066
+** ^The first argument to the sqlite3_bind_*() routines is always
30783067
** a pointer to the [sqlite3_stmt] object returned from
30793068
** [sqlite3_prepare_v2()] or its variants.
30803069
**
3081
-** The second argument is the index of the SQL parameter to be set.
3082
-** The leftmost SQL parameter has an index of 1. When the same named
3070
+** ^The second argument is the index of the SQL parameter to be set.
3071
+** ^The leftmost SQL parameter has an index of 1. ^When the same named
30833072
** SQL parameter is used more than once, second and subsequent
30843073
** occurrences have the same index as the first occurrence.
3085
-** The index for named parameters can be looked up using the
3086
-** [sqlite3_bind_parameter_index()] API if desired. The index
3074
+** ^The index for named parameters can be looked up using the
3075
+** [sqlite3_bind_parameter_index()] API if desired. ^The index
30873076
** for "?NNN" parameters is the value of NNN.
3088
-** The NNN value must be between 1 and the [sqlite3_limit()]
3077
+** ^The NNN value must be between 1 and the [sqlite3_limit()]
30893078
** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
30903079
**
3091
-** The third argument is the value to bind to the parameter.
3080
+** ^The third argument is the value to bind to the parameter.
30923081
**
3093
-** In those routines that have a fourth argument, its value is the
3082
+** ^(In those routines that have a fourth argument, its value is the
30943083
** number of bytes in the parameter. To be clear: the value is the
3095
-** number of <u>bytes</u> in the value, not the number of characters.
3096
-** If the fourth parameter is negative, the length of the string is
3084
+** number of <u>bytes</u> in the value, not the number of characters.)^
3085
+** ^If the fourth parameter is negative, the length of the string is
30973086
** the number of bytes up to the first zero terminator.
30983087
**
3099
-** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
3088
+** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
31003089
** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
3101
-** string after SQLite has finished with it. If the fifth argument is
3090
+** string after SQLite has finished with it. ^If the fifth argument is
31023091
** the special value [SQLITE_STATIC], then SQLite assumes that the
31033092
** information is in static, unmanaged space and does not need to be freed.
3104
-** If the fifth argument has the value [SQLITE_TRANSIENT], then
3093
+** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
31053094
** SQLite makes its own private copy of the data immediately, before
31063095
** the sqlite3_bind_*() routine returns.
31073096
**
3108
-** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
3109
-** is filled with zeroes. A zeroblob uses a fixed amount of memory
3097
+** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
3098
+** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
31103099
** (just an integer to hold its size) while it is being processed.
31113100
** Zeroblobs are intended to serve as placeholders for BLOBs whose
31123101
** content is later written using
31133102
** [sqlite3_blob_open | incremental BLOB I/O] routines.
3114
-** A negative value for the zeroblob results in a zero-length BLOB.
3115
-**
3116
-** The sqlite3_bind_*() routines must be called after
3117
-** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
3118
-** before [sqlite3_step()].
3119
-** Bindings are not cleared by the [sqlite3_reset()] routine.
3120
-** Unbound parameters are interpreted as NULL.
3121
-**
3122
-** These routines return [SQLITE_OK] on success or an error code if
3123
-** anything goes wrong. [SQLITE_RANGE] is returned if the parameter
3124
-** index is out of range. [SQLITE_NOMEM] is returned if malloc() fails.
3125
-** [SQLITE_MISUSE] might be returned if these routines are called on a
3126
-** virtual machine that is the wrong state or which has already been finalized.
3127
-** Detection of misuse is unreliable. Applications should not depend
3128
-** on SQLITE_MISUSE returns. SQLITE_MISUSE is intended to indicate a
3129
-** a logic error in the application. Future versions of SQLite might
3130
-** panic rather than return SQLITE_MISUSE.
3103
+** ^A negative value for the zeroblob results in a zero-length BLOB.
3104
+**
3105
+** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
3106
+** for the [prepared statement] or with a prepared statement for which
3107
+** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
3108
+** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
3109
+** routine is passed a [prepared statement] that has been finalized, the
3110
+** result is undefined and probably harmful.
3111
+**
3112
+** ^Bindings are not cleared by the [sqlite3_reset()] routine.
3113
+** ^Unbound parameters are interpreted as NULL.
3114
+**
3115
+** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
3116
+** [error code] if anything goes wrong.
3117
+** ^[SQLITE_RANGE] is returned if the parameter
3118
+** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
31313119
**
31323120
** See also: [sqlite3_bind_parameter_count()],
31333121
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3134
-**
3135
-** Requirements:
3136
-** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
3137
-** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
3138
-**
31393122
*/
31403123
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
31413124
SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
31423125
SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
31433126
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -3146,175 +3129,155 @@
31463129
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
31473130
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
31483131
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
31493132
31503133
/*
3151
-** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
3134
+** CAPI3REF: Number Of SQL Parameters
31523135
**
3153
-** This routine can be used to find the number of [SQL parameters]
3136
+** ^This routine can be used to find the number of [SQL parameters]
31543137
** in a [prepared statement]. SQL parameters are tokens of the
31553138
** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
31563139
** placeholders for values that are [sqlite3_bind_blob | bound]
31573140
** to the parameters at a later time.
31583141
**
3159
-** This routine actually returns the index of the largest (rightmost)
3142
+** ^(This routine actually returns the index of the largest (rightmost)
31603143
** parameter. For all forms except ?NNN, this will correspond to the
3161
-** number of unique parameters. If parameters of the ?NNN are used,
3162
-** there may be gaps in the list.
3144
+** number of unique parameters. If parameters of the ?NNN form are used,
3145
+** there may be gaps in the list.)^
31633146
**
31643147
** See also: [sqlite3_bind_blob|sqlite3_bind()],
31653148
** [sqlite3_bind_parameter_name()], and
31663149
** [sqlite3_bind_parameter_index()].
3167
-**
3168
-** Requirements:
3169
-** [H13601]
31703150
*/
31713151
SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
31723152
31733153
/*
3174
-** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
3154
+** CAPI3REF: Name Of A Host Parameter
31753155
**
3176
-** This routine returns a pointer to the name of the n-th
3177
-** [SQL parameter] in a [prepared statement].
3178
-** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3156
+** ^The sqlite3_bind_parameter_name(P,N) interface returns
3157
+** the name of the N-th [SQL parameter] in the [prepared statement] P.
3158
+** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
31793159
** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
31803160
** respectively.
31813161
** In other words, the initial ":" or "$" or "@" or "?"
3182
-** is included as part of the name.
3183
-** Parameters of the form "?" without a following integer have no name
3184
-** and are also referred to as "anonymous parameters".
3185
-**
3186
-** The first host parameter has an index of 1, not 0.
3187
-**
3188
-** If the value n is out of range or if the n-th parameter is
3189
-** nameless, then NULL is returned. The returned string is
3162
+** is included as part of the name.)^
3163
+** ^Parameters of the form "?" without a following integer have no name
3164
+** and are referred to as "nameless" or "anonymous parameters".
3165
+**
3166
+** ^The first host parameter has an index of 1, not 0.
3167
+**
3168
+** ^If the value N is out of range or if the N-th parameter is
3169
+** nameless, then NULL is returned. ^The returned string is
31903170
** always in UTF-8 encoding even if the named parameter was
31913171
** originally specified as UTF-16 in [sqlite3_prepare16()] or
31923172
** [sqlite3_prepare16_v2()].
31933173
**
31943174
** See also: [sqlite3_bind_blob|sqlite3_bind()],
31953175
** [sqlite3_bind_parameter_count()], and
31963176
** [sqlite3_bind_parameter_index()].
3197
-**
3198
-** Requirements:
3199
-** [H13621]
32003177
*/
32013178
SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
32023179
32033180
/*
3204
-** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
3181
+** CAPI3REF: Index Of A Parameter With A Given Name
32053182
**
3206
-** Return the index of an SQL parameter given its name. The
3183
+** ^Return the index of an SQL parameter given its name. ^The
32073184
** index value returned is suitable for use as the second
3208
-** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero
3209
-** is returned if no matching parameter is found. The parameter
3185
+** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3186
+** is returned if no matching parameter is found. ^The parameter
32103187
** name must be given in UTF-8 even if the original statement
32113188
** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
32123189
**
32133190
** See also: [sqlite3_bind_blob|sqlite3_bind()],
32143191
** [sqlite3_bind_parameter_count()], and
32153192
** [sqlite3_bind_parameter_index()].
3216
-**
3217
-** Requirements:
3218
-** [H13641]
32193193
*/
32203194
SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
32213195
32223196
/*
3223
-** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
3197
+** CAPI3REF: Reset All Bindings On A Prepared Statement
32243198
**
3225
-** Contrary to the intuition of many, [sqlite3_reset()] does not reset
3199
+** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
32263200
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3227
-** Use this routine to reset all host parameters to NULL.
3228
-**
3229
-** Requirements:
3230
-** [H13661]
3201
+** ^Use this routine to reset all host parameters to NULL.
32313202
*/
32323203
SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
32333204
32343205
/*
3235
-** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
3236
-**
3237
-** Return the number of columns in the result set returned by the
3238
-** [prepared statement]. This routine returns 0 if pStmt is an SQL
3239
-** statement that does not return data (for example an [UPDATE]).
3240
-**
3241
-** Requirements:
3242
-** [H13711]
3206
+** CAPI3REF: Number Of Columns In A Result Set
3207
+**
3208
+** ^Return the number of columns in the result set returned by the
3209
+** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3210
+** statement that does not return data (for example an [UPDATE]).
32433211
*/
32443212
SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
32453213
32463214
/*
3247
-** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
3215
+** CAPI3REF: Column Names In A Result Set
32483216
**
3249
-** These routines return the name assigned to a particular column
3250
-** in the result set of a [SELECT] statement. The sqlite3_column_name()
3217
+** ^These routines return the name assigned to a particular column
3218
+** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
32513219
** interface returns a pointer to a zero-terminated UTF-8 string
32523220
** and sqlite3_column_name16() returns a pointer to a zero-terminated
3253
-** UTF-16 string. The first parameter is the [prepared statement]
3254
-** that implements the [SELECT] statement. The second parameter is the
3255
-** column number. The leftmost column is number 0.
3221
+** UTF-16 string. ^The first parameter is the [prepared statement]
3222
+** that implements the [SELECT] statement. ^The second parameter is the
3223
+** column number. ^The leftmost column is number 0.
32563224
**
3257
-** The returned string pointer is valid until either the [prepared statement]
3225
+** ^The returned string pointer is valid until either the [prepared statement]
32583226
** is destroyed by [sqlite3_finalize()] or until the next call to
32593227
** sqlite3_column_name() or sqlite3_column_name16() on the same column.
32603228
**
3261
-** If sqlite3_malloc() fails during the processing of either routine
3229
+** ^If sqlite3_malloc() fails during the processing of either routine
32623230
** (for example during a conversion from UTF-8 to UTF-16) then a
32633231
** NULL pointer is returned.
32643232
**
3265
-** The name of a result column is the value of the "AS" clause for
3233
+** ^The name of a result column is the value of the "AS" clause for
32663234
** that column, if there is an AS clause. If there is no AS clause
32673235
** then the name of the column is unspecified and may change from
32683236
** one release of SQLite to the next.
3269
-**
3270
-** Requirements:
3271
-** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
32723237
*/
32733238
SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
32743239
SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
32753240
32763241
/*
3277
-** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
3242
+** CAPI3REF: Source Of Data In A Query Result
32783243
**
3279
-** These routines provide a means to determine what column of what
3280
-** table in which database a result of a [SELECT] statement comes from.
3281
-** The name of the database or table or column can be returned as
3282
-** either a UTF-8 or UTF-16 string. The _database_ routines return
3244
+** ^These routines provide a means to determine the database, table, and
3245
+** table column that is the origin of a particular result column in
3246
+** [SELECT] statement.
3247
+** ^The name of the database or table or column can be returned as
3248
+** either a UTF-8 or UTF-16 string. ^The _database_ routines return
32833249
** the database name, the _table_ routines return the table name, and
32843250
** the origin_ routines return the column name.
3285
-** The returned string is valid until the [prepared statement] is destroyed
3251
+** ^The returned string is valid until the [prepared statement] is destroyed
32863252
** using [sqlite3_finalize()] or until the same information is requested
32873253
** again in a different encoding.
32883254
**
3289
-** The names returned are the original un-aliased names of the
3255
+** ^The names returned are the original un-aliased names of the
32903256
** database, table, and column.
32913257
**
3292
-** The first argument to the following calls is a [prepared statement].
3293
-** These functions return information about the Nth column returned by
3258
+** ^The first argument to these interfaces is a [prepared statement].
3259
+** ^These functions return information about the Nth result column returned by
32943260
** the statement, where N is the second function argument.
3261
+** ^The left-most column is column 0 for these routines.
32953262
**
3296
-** If the Nth column returned by the statement is an expression or
3263
+** ^If the Nth column returned by the statement is an expression or
32973264
** subquery and is not a column value, then all of these functions return
3298
-** NULL. These routine might also return NULL if a memory allocation error
3299
-** occurs. Otherwise, they return the name of the attached database, table
3300
-** and column that query result column was extracted from.
3301
-**
3302
-** As with all other SQLite APIs, those postfixed with "16" return
3303
-** UTF-16 encoded strings, the other functions return UTF-8. {END}
3304
-**
3305
-** These APIs are only available if the library was compiled with the
3306
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
3307
-**
3308
-** {A13751}
3265
+** NULL. ^These routine might also return NULL if a memory allocation error
3266
+** occurs. ^Otherwise, they return the name of the attached database, table,
3267
+** or column that query result column was extracted from.
3268
+**
3269
+** ^As with all other SQLite APIs, those whose names end with "16" return
3270
+** UTF-16 encoded strings and the other functions return UTF-8.
3271
+**
3272
+** ^These APIs are only available if the library was compiled with the
3273
+** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
3274
+**
33093275
** If two or more threads call one or more of these routines against the same
33103276
** prepared statement and column at the same time then the results are
33113277
** undefined.
33123278
**
3313
-** Requirements:
3314
-** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
3315
-**
33163279
** If two or more threads call one or more
33173280
** [sqlite3_column_database_name | column metadata interfaces]
33183281
** for the same [prepared statement] and result column
33193282
** at the same time then the results are undefined.
33203283
*/
@@ -3324,46 +3287,43 @@
33243287
SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
33253288
SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
33263289
SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
33273290
33283291
/*
3329
-** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
3292
+** CAPI3REF: Declared Datatype Of A Query Result
33303293
**
3331
-** The first parameter is a [prepared statement].
3294
+** ^(The first parameter is a [prepared statement].
33323295
** If this statement is a [SELECT] statement and the Nth column of the
33333296
** returned result set of that [SELECT] is a table column (not an
33343297
** expression or subquery) then the declared type of the table
3335
-** column is returned. If the Nth column of the result set is an
3298
+** column is returned.)^ ^If the Nth column of the result set is an
33363299
** expression or subquery, then a NULL pointer is returned.
3337
-** The returned string is always UTF-8 encoded. {END}
3300
+** ^The returned string is always UTF-8 encoded.
33383301
**
3339
-** For example, given the database schema:
3302
+** ^(For example, given the database schema:
33403303
**
33413304
** CREATE TABLE t1(c1 VARIANT);
33423305
**
33433306
** and the following statement to be compiled:
33443307
**
33453308
** SELECT c1 + 1, c1 FROM t1;
33463309
**
33473310
** this routine would return the string "VARIANT" for the second result
3348
-** column (i==1), and a NULL pointer for the first result column (i==0).
3311
+** column (i==1), and a NULL pointer for the first result column (i==0).)^
33493312
**
3350
-** SQLite uses dynamic run-time typing. So just because a column
3313
+** ^SQLite uses dynamic run-time typing. ^So just because a column
33513314
** is declared to contain a particular type does not mean that the
33523315
** data stored in that column is of the declared type. SQLite is
3353
-** strongly typed, but the typing is dynamic not static. Type
3316
+** strongly typed, but the typing is dynamic not static. ^Type
33543317
** is associated with individual values, not with the containers
33553318
** used to hold those values.
3356
-**
3357
-** Requirements:
3358
-** [H13761] [H13762] [H13763]
33593319
*/
33603320
SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
33613321
SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
33623322
33633323
/*
3364
-** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
3324
+** CAPI3REF: Evaluate An SQL Statement
33653325
**
33663326
** After a [prepared statement] has been prepared using either
33673327
** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
33683328
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
33693329
** must be called one or more times to evaluate the statement.
@@ -3373,39 +3333,39 @@
33733333
** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
33743334
** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
33753335
** new "v2" interface is recommended for new applications but the legacy
33763336
** interface will continue to be supported.
33773337
**
3378
-** In the legacy interface, the return value will be either [SQLITE_BUSY],
3338
+** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
33793339
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
3380
-** With the "v2" interface, any of the other [result codes] or
3340
+** ^With the "v2" interface, any of the other [result codes] or
33813341
** [extended result codes] might be returned as well.
33823342
**
3383
-** [SQLITE_BUSY] means that the database engine was unable to acquire the
3384
-** database locks it needs to do its job. If the statement is a [COMMIT]
3343
+** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3344
+** database locks it needs to do its job. ^If the statement is a [COMMIT]
33853345
** or occurs outside of an explicit transaction, then you can retry the
33863346
** statement. If the statement is not a [COMMIT] and occurs within a
33873347
** explicit transaction then you should rollback the transaction before
33883348
** continuing.
33893349
**
3390
-** [SQLITE_DONE] means that the statement has finished executing
3350
+** ^[SQLITE_DONE] means that the statement has finished executing
33913351
** successfully. sqlite3_step() should not be called again on this virtual
33923352
** machine without first calling [sqlite3_reset()] to reset the virtual
33933353
** machine back to its initial state.
33943354
**
3395
-** If the SQL statement being executed returns any data, then [SQLITE_ROW]
3355
+** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
33963356
** is returned each time a new row of data is ready for processing by the
33973357
** caller. The values may be accessed using the [column access functions].
33983358
** sqlite3_step() is called again to retrieve the next row of data.
33993359
**
3400
-** [SQLITE_ERROR] means that a run-time error (such as a constraint
3360
+** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
34013361
** violation) has occurred. sqlite3_step() should not be called again on
34023362
** the VM. More information may be found by calling [sqlite3_errmsg()].
3403
-** With the legacy interface, a more specific error code (for example,
3363
+** ^With the legacy interface, a more specific error code (for example,
34043364
** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
34053365
** can be obtained by calling [sqlite3_reset()] on the
3406
-** [prepared statement]. In the "v2" interface,
3366
+** [prepared statement]. ^In the "v2" interface,
34073367
** the more specific error code is returned directly by sqlite3_step().
34083368
**
34093369
** [SQLITE_MISUSE] means that the this routine was called inappropriately.
34103370
** Perhaps it was called on a [prepared statement] that has
34113371
** already been [sqlite3_finalize | finalized] or on one that had
@@ -3422,39 +3382,34 @@
34223382
** with the "v2" interface. If you prepare all of your SQL statements
34233383
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
34243384
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
34253385
** then the more specific [error codes] are returned directly
34263386
** by sqlite3_step(). The use of the "v2" interface is recommended.
3427
-**
3428
-** Requirements:
3429
-** [H13202] [H15304] [H15306] [H15308] [H15310]
34303387
*/
34313388
SQLITE_API int sqlite3_step(sqlite3_stmt*);
34323389
34333390
/*
3434
-** CAPI3REF: Number of columns in a result set {H13770} <S10700>
3391
+** CAPI3REF: Number of columns in a result set
34353392
**
3436
-** Returns the number of values in the current row of the result set.
3437
-**
3438
-** Requirements:
3439
-** [H13771] [H13772]
3393
+** ^The sqlite3_data_count(P) the number of columns in the
3394
+** of the result set of [prepared statement] P.
34403395
*/
34413396
SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
34423397
34433398
/*
3444
-** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
3399
+** CAPI3REF: Fundamental Datatypes
34453400
** KEYWORDS: SQLITE_TEXT
34463401
**
3447
-** {H10266} Every value in SQLite has one of five fundamental datatypes:
3402
+** ^(Every value in SQLite has one of five fundamental datatypes:
34483403
**
34493404
** <ul>
34503405
** <li> 64-bit signed integer
34513406
** <li> 64-bit IEEE floating point number
34523407
** <li> string
34533408
** <li> BLOB
34543409
** <li> NULL
3455
-** </ul> {END}
3410
+** </ul>)^
34563411
**
34573412
** These constants are codes for each of those types.
34583413
**
34593414
** Note that the SQLITE_TEXT constant was also used in SQLite version 2
34603415
** for a completely different meaning. Software that links against both
@@ -3471,22 +3426,22 @@
34713426
# define SQLITE_TEXT 3
34723427
#endif
34733428
#define SQLITE3_TEXT 3
34743429
34753430
/*
3476
-** CAPI3REF: Result Values From A Query {H13800} <S10700>
3431
+** CAPI3REF: Result Values From A Query
34773432
** KEYWORDS: {column access functions}
34783433
**
3479
-** These routines form the "result set query" interface.
3434
+** These routines form the "result set" interface.
34803435
**
3481
-** These routines return information about a single column of the current
3482
-** result row of a query. In every case the first argument is a pointer
3436
+** ^These routines return information about a single column of the current
3437
+** result row of a query. ^In every case the first argument is a pointer
34833438
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
34843439
** that was returned from [sqlite3_prepare_v2()] or one of its variants)
34853440
** and the second argument is the index of the column for which information
3486
-** should be returned. The leftmost column of the result set has the index 0.
3487
-** The number of columns in the result can be determined using
3441
+** should be returned. ^The leftmost column of the result set has the index 0.
3442
+** ^The number of columns in the result can be determined using
34883443
** [sqlite3_column_count()].
34893444
**
34903445
** If the SQL statement does not currently point to a valid row, or if the
34913446
** column index is out of range, the result is undefined.
34923447
** These routines may only be called when the most recent call to
@@ -3497,52 +3452,52 @@
34973452
** something other than [SQLITE_ROW], the results are undefined.
34983453
** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
34993454
** are called from a different thread while any of these routines
35003455
** are pending, then the results are undefined.
35013456
**
3502
-** The sqlite3_column_type() routine returns the
3457
+** ^The sqlite3_column_type() routine returns the
35033458
** [SQLITE_INTEGER | datatype code] for the initial data type
3504
-** of the result column. The returned value is one of [SQLITE_INTEGER],
3459
+** of the result column. ^The returned value is one of [SQLITE_INTEGER],
35053460
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
35063461
** returned by sqlite3_column_type() is only meaningful if no type
35073462
** conversions have occurred as described below. After a type conversion,
35083463
** the value returned by sqlite3_column_type() is undefined. Future
35093464
** versions of SQLite may change the behavior of sqlite3_column_type()
35103465
** following a type conversion.
35113466
**
3512
-** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
3467
+** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
35133468
** routine returns the number of bytes in that BLOB or string.
3514
-** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
3469
+** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
35153470
** the string to UTF-8 and then returns the number of bytes.
3516
-** If the result is a numeric value then sqlite3_column_bytes() uses
3471
+** ^If the result is a numeric value then sqlite3_column_bytes() uses
35173472
** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
35183473
** the number of bytes in that string.
3519
-** The value returned does not include the zero terminator at the end
3520
-** of the string. For clarity: the value returned is the number of
3474
+** ^The value returned does not include the zero terminator at the end
3475
+** of the string. ^For clarity: the value returned is the number of
35213476
** bytes in the string, not the number of characters.
35223477
**
3523
-** Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3524
-** even empty strings, are always zero terminated. The return
3478
+** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3479
+** even empty strings, are always zero terminated. ^The return
35253480
** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
35263481
** pointer, possibly even a NULL pointer.
35273482
**
3528
-** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
3483
+** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
35293484
** but leaves the result in UTF-16 in native byte order instead of UTF-8.
3530
-** The zero terminator is not included in this count.
3485
+** ^The zero terminator is not included in this count.
35313486
**
3532
-** The object returned by [sqlite3_column_value()] is an
3487
+** ^The object returned by [sqlite3_column_value()] is an
35333488
** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
35343489
** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
35353490
** If the [unprotected sqlite3_value] object returned by
35363491
** [sqlite3_column_value()] is used in any other way, including calls
35373492
** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
35383493
** or [sqlite3_value_bytes()], then the behavior is undefined.
35393494
**
3540
-** These routines attempt to convert the value where appropriate. For
3495
+** These routines attempt to convert the value where appropriate. ^For
35413496
** example, if the internal representation is FLOAT and a text result
35423497
** is requested, [sqlite3_snprintf()] is used internally to perform the
3543
-** conversion automatically. The following table details the conversions
3498
+** conversion automatically. ^(The following table details the conversions
35443499
** that are applied:
35453500
**
35463501
** <blockquote>
35473502
** <table border="1">
35483503
** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3562,22 +3517,22 @@
35623517
** <tr><td> TEXT <td> BLOB <td> No change
35633518
** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
35643519
** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
35653520
** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
35663521
** </table>
3567
-** </blockquote>
3522
+** </blockquote>)^
35683523
**
35693524
** The table above makes reference to standard C library functions atoi()
35703525
** and atof(). SQLite does not really use these functions. It has its
35713526
** own equivalent internal routines. The atoi() and atof() names are
35723527
** used in the table for brevity and because they are familiar to most
35733528
** C programmers.
35743529
**
3575
-** Note that when type conversions occur, pointers returned by prior
3530
+** ^Note that when type conversions occur, pointers returned by prior
35763531
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
35773532
** sqlite3_column_text16() may be invalidated.
3578
-** Type conversions and pointer invalidations might occur
3533
+** ^(Type conversions and pointer invalidations might occur
35793534
** in the following cases:
35803535
**
35813536
** <ul>
35823537
** <li> The initial content is a BLOB and sqlite3_column_text() or
35833538
** sqlite3_column_text16() is called. A zero-terminator might
@@ -3586,51 +3541,47 @@
35863541
** sqlite3_column_text16() is called. The content must be converted
35873542
** to UTF-16.</li>
35883543
** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
35893544
** sqlite3_column_text() is called. The content must be converted
35903545
** to UTF-8.</li>
3591
-** </ul>
3546
+** </ul>)^
35923547
**
3593
-** Conversions between UTF-16be and UTF-16le are always done in place and do
3548
+** ^Conversions between UTF-16be and UTF-16le are always done in place and do
35943549
** not invalidate a prior pointer, though of course the content of the buffer
35953550
** that the prior pointer points to will have been modified. Other kinds
35963551
** of conversion are done in place when it is possible, but sometimes they
35973552
** are not possible and in those cases prior pointers are invalidated.
35983553
**
3599
-** The safest and easiest to remember policy is to invoke these routines
3554
+** ^(The safest and easiest to remember policy is to invoke these routines
36003555
** in one of the following ways:
36013556
**
36023557
** <ul>
36033558
** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
36043559
** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
36053560
** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3606
-** </ul>
3561
+** </ul>)^
36073562
**
36083563
** In other words, you should call sqlite3_column_text(),
36093564
** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
36103565
** into the desired format, then invoke sqlite3_column_bytes() or
36113566
** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
36123567
** to sqlite3_column_text() or sqlite3_column_blob() with calls to
36133568
** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
36143569
** with calls to sqlite3_column_bytes().
36153570
**
3616
-** The pointers returned are valid until a type conversion occurs as
3571
+** ^The pointers returned are valid until a type conversion occurs as
36173572
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3618
-** [sqlite3_finalize()] is called. The memory space used to hold strings
3573
+** [sqlite3_finalize()] is called. ^The memory space used to hold strings
36193574
** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
36203575
** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
36213576
** [sqlite3_free()].
36223577
**
3623
-** If a memory allocation error occurs during the evaluation of any
3578
+** ^(If a memory allocation error occurs during the evaluation of any
36243579
** of these routines, a default value is returned. The default value
36253580
** is either the integer 0, the floating point number 0.0, or a NULL
36263581
** pointer. Subsequent calls to [sqlite3_errcode()] will return
3627
-** [SQLITE_NOMEM].
3628
-**
3629
-** Requirements:
3630
-** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
3631
-** [H13827] [H13830]
3582
+** [SQLITE_NOMEM].)^
36323583
*/
36333584
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
36343585
SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
36353586
SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
36363587
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3640,139 +3591,132 @@
36403591
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
36413592
SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
36423593
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
36433594
36443595
/*
3645
-** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
3596
+** CAPI3REF: Destroy A Prepared Statement Object
36463597
**
3647
-** The sqlite3_finalize() function is called to delete a [prepared statement].
3648
-** If the statement was executed successfully or not executed at all, then
3649
-** SQLITE_OK is returned. If execution of the statement failed then an
3598
+** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3599
+** ^If the statement was executed successfully or not executed at all, then
3600
+** SQLITE_OK is returned. ^If execution of the statement failed then an
36503601
** [error code] or [extended error code] is returned.
36513602
**
3652
-** This routine can be called at any point during the execution of the
3653
-** [prepared statement]. If the virtual machine has not
3603
+** ^This routine can be called at any point during the execution of the
3604
+** [prepared statement]. ^If the virtual machine has not
36543605
** completed execution when this routine is called, that is like
36553606
** encountering an error or an [sqlite3_interrupt | interrupt].
3656
-** Incomplete updates may be rolled back and transactions canceled,
3607
+** ^Incomplete updates may be rolled back and transactions canceled,
36573608
** depending on the circumstances, and the
36583609
** [error code] returned will be [SQLITE_ABORT].
3659
-**
3660
-** Requirements:
3661
-** [H11302] [H11304]
36623610
*/
36633611
SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
36643612
36653613
/*
3666
-** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
3614
+** CAPI3REF: Reset A Prepared Statement Object
36673615
**
36683616
** The sqlite3_reset() function is called to reset a [prepared statement]
36693617
** object back to its initial state, ready to be re-executed.
3670
-** Any SQL statement variables that had values bound to them using
3618
+** ^Any SQL statement variables that had values bound to them using
36713619
** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
36723620
** Use [sqlite3_clear_bindings()] to reset the bindings.
36733621
**
3674
-** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
3675
-** back to the beginning of its program.
3676
-**
3677
-** {H11334} If the most recent call to [sqlite3_step(S)] for the
3678
-** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3679
-** or if [sqlite3_step(S)] has never before been called on S,
3680
-** then [sqlite3_reset(S)] returns [SQLITE_OK].
3681
-**
3682
-** {H11336} If the most recent call to [sqlite3_step(S)] for the
3683
-** [prepared statement] S indicated an error, then
3684
-** [sqlite3_reset(S)] returns an appropriate [error code].
3685
-**
3686
-** {H11338} The [sqlite3_reset(S)] interface does not change the values
3687
-** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3622
+** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
3623
+** back to the beginning of its program.
3624
+**
3625
+** ^If the most recent call to [sqlite3_step(S)] for the
3626
+** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3627
+** or if [sqlite3_step(S)] has never before been called on S,
3628
+** then [sqlite3_reset(S)] returns [SQLITE_OK].
3629
+**
3630
+** ^If the most recent call to [sqlite3_step(S)] for the
3631
+** [prepared statement] S indicated an error, then
3632
+** [sqlite3_reset(S)] returns an appropriate [error code].
3633
+**
3634
+** ^The [sqlite3_reset(S)] interface does not change the values
3635
+** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
36883636
*/
36893637
SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
36903638
36913639
/*
3692
-** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
3640
+** CAPI3REF: Create Or Redefine SQL Functions
36933641
** KEYWORDS: {function creation routines}
36943642
** KEYWORDS: {application-defined SQL function}
36953643
** KEYWORDS: {application-defined SQL functions}
36963644
**
3697
-** These two functions (collectively known as "function creation routines")
3645
+** ^These two functions (collectively known as "function creation routines")
36983646
** are used to add SQL functions or aggregates or to redefine the behavior
36993647
** of existing SQL functions or aggregates. The only difference between the
37003648
** two is that the second parameter, the name of the (scalar) function or
37013649
** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
37023650
** for sqlite3_create_function16().
37033651
**
3704
-** The first parameter is the [database connection] to which the SQL
3705
-** function is to be added. If a single program uses more than one database
3706
-** connection internally, then SQL functions must be added individually to
3707
-** each database connection.
3652
+** ^The first parameter is the [database connection] to which the SQL
3653
+** function is to be added. ^If an application uses more than one database
3654
+** connection then application-defined SQL functions must be added
3655
+** to each database connection separately.
37083656
**
37093657
** The second parameter is the name of the SQL function to be created or
3710
-** redefined. The length of the name is limited to 255 bytes, exclusive of
3658
+** redefined. ^The length of the name is limited to 255 bytes, exclusive of
37113659
** the zero-terminator. Note that the name length limit is in bytes, not
3712
-** characters. Any attempt to create a function with a longer name
3660
+** characters. ^Any attempt to create a function with a longer name
37133661
** will result in [SQLITE_ERROR] being returned.
37143662
**
3715
-** The third parameter (nArg)
3663
+** ^The third parameter (nArg)
37163664
** is the number of arguments that the SQL function or
3717
-** aggregate takes. If this parameter is -1, then the SQL function or
3665
+** aggregate takes. ^If this parameter is -1, then the SQL function or
37183666
** aggregate may take any number of arguments between 0 and the limit
37193667
** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
37203668
** parameter is less than -1 or greater than 127 then the behavior is
37213669
** undefined.
37223670
**
37233671
** The fourth parameter, eTextRep, specifies what
37243672
** [SQLITE_UTF8 | text encoding] this SQL function prefers for
37253673
** its parameters. Any SQL function implementation should be able to work
37263674
** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3727
-** more efficient with one encoding than another. An application may
3675
+** more efficient with one encoding than another. ^An application may
37283676
** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
37293677
** times with the same function but with different values of eTextRep.
3730
-** When multiple implementations of the same function are available, SQLite
3678
+** ^When multiple implementations of the same function are available, SQLite
37313679
** will pick the one that involves the least amount of data conversion.
37323680
** If there is only a single implementation which does not care what text
37333681
** encoding is used, then the fourth argument should be [SQLITE_ANY].
37343682
**
3735
-** The fifth parameter is an arbitrary pointer. The implementation of the
3736
-** function can gain access to this pointer using [sqlite3_user_data()].
3683
+** ^(The fifth parameter is an arbitrary pointer. The implementation of the
3684
+** function can gain access to this pointer using [sqlite3_user_data()].)^
37373685
**
37383686
** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
37393687
** pointers to C-language functions that implement the SQL function or
3740
-** aggregate. A scalar SQL function requires an implementation of the xFunc
3741
-** callback only, NULL pointers should be passed as the xStep and xFinal
3742
-** parameters. An aggregate SQL function requires an implementation of xStep
3743
-** and xFinal and NULL should be passed for xFunc. To delete an existing
3688
+** aggregate. ^A scalar SQL function requires an implementation of the xFunc
3689
+** callback only; NULL pointers should be passed as the xStep and xFinal
3690
+** parameters. ^An aggregate SQL function requires an implementation of xStep
3691
+** and xFinal and NULL should be passed for xFunc. ^To delete an existing
37443692
** SQL function or aggregate, pass NULL for all three function callbacks.
37453693
**
3746
-** It is permitted to register multiple implementations of the same
3694
+** ^It is permitted to register multiple implementations of the same
37473695
** functions with the same name but with either differing numbers of
3748
-** arguments or differing preferred text encodings. SQLite will use
3696
+** arguments or differing preferred text encodings. ^SQLite will use
37493697
** the implementation that most closely matches the way in which the
3750
-** SQL function is used. A function implementation with a non-negative
3698
+** SQL function is used. ^A function implementation with a non-negative
37513699
** nArg parameter is a better match than a function implementation with
3752
-** a negative nArg. A function where the preferred text encoding
3700
+** a negative nArg. ^A function where the preferred text encoding
37533701
** matches the database encoding is a better
37543702
** match than a function where the encoding is different.
3755
-** A function where the encoding difference is between UTF16le and UTF16be
3703
+** ^A function where the encoding difference is between UTF16le and UTF16be
37563704
** is a closer match than a function where the encoding difference is
37573705
** between UTF8 and UTF16.
37583706
**
3759
-** Built-in functions may be overloaded by new application-defined functions.
3760
-** The first application-defined function with a given name overrides all
3707
+** ^Built-in functions may be overloaded by new application-defined functions.
3708
+** ^The first application-defined function with a given name overrides all
37613709
** built-in functions in the same [database connection] with the same name.
3762
-** Subsequent application-defined functions of the same name only override
3710
+** ^Subsequent application-defined functions of the same name only override
37633711
** prior application-defined functions that are an exact match for the
37643712
** number of parameters and preferred encoding.
37653713
**
3766
-** An application-defined function is permitted to call other
3714
+** ^An application-defined function is permitted to call other
37673715
** SQLite interfaces. However, such calls must not
37683716
** close the database connection nor finalize or reset the prepared
37693717
** statement in which the function is running.
3770
-**
3771
-** Requirements:
3772
-** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
3773
-** [H16130] [H16133] [H16136] [H16139] [H16142]
37743718
*/
37753719
SQLITE_API int sqlite3_create_function(
37763720
sqlite3 *db,
37773721
const char *zFunctionName,
37783722
int nArg,
@@ -3792,11 +3736,11 @@
37923736
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
37933737
void (*xFinal)(sqlite3_context*)
37943738
);
37953739
37963740
/*
3797
-** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
3741
+** CAPI3REF: Text Encodings
37983742
**
37993743
** These constant define integer codes that represent the various
38003744
** text encodings supported by SQLite.
38013745
*/
38023746
#define SQLITE_UTF8 1
@@ -3824,11 +3768,11 @@
38243768
SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
38253769
SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
38263770
#endif
38273771
38283772
/*
3829
-** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
3773
+** CAPI3REF: Obtaining SQL Function Parameter Values
38303774
**
38313775
** The C-language implementation of SQL functions and aggregates uses
38323776
** this set of interface routines to access the parameter values on
38333777
** the function or aggregate.
38343778
**
@@ -3842,39 +3786,35 @@
38423786
**
38433787
** These routines work only with [protected sqlite3_value] objects.
38443788
** Any attempt to use these routines on an [unprotected sqlite3_value]
38453789
** object results in undefined behavior.
38463790
**
3847
-** These routines work just like the corresponding [column access functions]
3791
+** ^These routines work just like the corresponding [column access functions]
38483792
** except that these routines take a single [protected sqlite3_value] object
38493793
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
38503794
**
3851
-** The sqlite3_value_text16() interface extracts a UTF-16 string
3852
-** in the native byte-order of the host machine. The
3795
+** ^The sqlite3_value_text16() interface extracts a UTF-16 string
3796
+** in the native byte-order of the host machine. ^The
38533797
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
38543798
** extract UTF-16 strings as big-endian and little-endian respectively.
38553799
**
3856
-** The sqlite3_value_numeric_type() interface attempts to apply
3800
+** ^(The sqlite3_value_numeric_type() interface attempts to apply
38573801
** numeric affinity to the value. This means that an attempt is
38583802
** made to convert the value to an integer or floating point. If
38593803
** such a conversion is possible without loss of information (in other
38603804
** words, if the value is a string that looks like a number)
38613805
** then the conversion is performed. Otherwise no conversion occurs.
3862
-** The [SQLITE_INTEGER | datatype] after conversion is returned.
3806
+** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
38633807
**
38643808
** Please pay particular attention to the fact that the pointer returned
38653809
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
38663810
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
38673811
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
38683812
** or [sqlite3_value_text16()].
38693813
**
38703814
** These routines must be called from the same thread as
38713815
** the SQL function that supplied the [sqlite3_value*] parameters.
3872
-**
3873
-** Requirements:
3874
-** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
3875
-** [H15127] [H15130] [H15133] [H15136]
38763816
*/
38773817
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
38783818
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
38793819
SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
38803820
SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3886,70 +3826,77 @@
38863826
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
38873827
SQLITE_API int sqlite3_value_type(sqlite3_value*);
38883828
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
38893829
38903830
/*
3891
-** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
3892
-**
3893
-** The implementation of aggregate SQL functions use this routine to allocate
3894
-** a structure for storing their state.
3895
-**
3896
-** The first time the sqlite3_aggregate_context() routine is called for a
3897
-** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
3898
-** memory, and returns a pointer to it. On second and subsequent calls to
3899
-** sqlite3_aggregate_context() for the same aggregate function index,
3900
-** the same buffer is returned. The implementation of the aggregate can use
3901
-** the returned buffer to accumulate data.
3902
-**
3903
-** SQLite automatically frees the allocated buffer when the aggregate
3904
-** query concludes.
3905
-**
3906
-** The first parameter should be a copy of the
3831
+** CAPI3REF: Obtain Aggregate Function Context
3832
+**
3833
+** Implementions of aggregate SQL functions use this
3834
+** routine to allocate memory for storing their state.
3835
+**
3836
+** ^The first time the sqlite3_aggregate_context(C,N) routine is called
3837
+** for a particular aggregate function, SQLite
3838
+** allocates N of memory, zeroes out that memory, and returns a pointer
3839
+** to the new memory. ^On second and subsequent calls to
3840
+** sqlite3_aggregate_context() for the same aggregate function instance,
3841
+** the same buffer is returned. Sqlite3_aggregate_context() is normally
3842
+** called once for each invocation of the xStep callback and then one
3843
+** last time when the xFinal callback is invoked. ^(When no rows match
3844
+** an aggregate query, the xStep() callback of the aggregate function
3845
+** implementation is never called and xFinal() is called exactly once.
3846
+** In those cases, sqlite3_aggregate_context() might be called for the
3847
+** first time from within xFinal().)^
3848
+**
3849
+** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
3850
+** less than or equal to zero or if a memory allocate error occurs.
3851
+**
3852
+** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
3853
+** determined by the N parameter on first successful call. Changing the
3854
+** value of N in subsequent call to sqlite3_aggregate_context() within
3855
+** the same aggregate function instance will not resize the memory
3856
+** allocation.)^
3857
+**
3858
+** ^SQLite automatically frees the memory allocated by
3859
+** sqlite3_aggregate_context() when the aggregate query concludes.
3860
+**
3861
+** The first parameter must be a copy of the
39073862
** [sqlite3_context | SQL function context] that is the first parameter
3908
-** to the callback routine that implements the aggregate function.
3863
+** to the xStep or xFinal callback routine that implements the aggregate
3864
+** function.
39093865
**
39103866
** This routine must be called from the same thread in which
39113867
** the aggregate SQL function is running.
3912
-**
3913
-** Requirements:
3914
-** [H16211] [H16213] [H16215] [H16217]
39153868
*/
39163869
SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
39173870
39183871
/*
3919
-** CAPI3REF: User Data For Functions {H16240} <S20200>
3872
+** CAPI3REF: User Data For Functions
39203873
**
3921
-** The sqlite3_user_data() interface returns a copy of
3874
+** ^The sqlite3_user_data() interface returns a copy of
39223875
** the pointer that was the pUserData parameter (the 5th parameter)
39233876
** of the [sqlite3_create_function()]
39243877
** and [sqlite3_create_function16()] routines that originally
3925
-** registered the application defined function. {END}
3878
+** registered the application defined function.
39263879
**
39273880
** This routine must be called from the same thread in which
39283881
** the application-defined function is running.
3929
-**
3930
-** Requirements:
3931
-** [H16243]
39323882
*/
39333883
SQLITE_API void *sqlite3_user_data(sqlite3_context*);
39343884
39353885
/*
3936
-** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
3886
+** CAPI3REF: Database Connection For Functions
39373887
**
3938
-** The sqlite3_context_db_handle() interface returns a copy of
3888
+** ^The sqlite3_context_db_handle() interface returns a copy of
39393889
** the pointer to the [database connection] (the 1st parameter)
39403890
** of the [sqlite3_create_function()]
39413891
** and [sqlite3_create_function16()] routines that originally
39423892
** registered the application defined function.
3943
-**
3944
-** Requirements:
3945
-** [H16253]
39463893
*/
39473894
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
39483895
39493896
/*
3950
-** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
3897
+** CAPI3REF: Function Auxiliary Data
39513898
**
39523899
** The following two functions may be used by scalar SQL functions to
39533900
** associate metadata with argument values. If the same value is passed to
39543901
** multiple invocations of the same SQL function during query execution, under
39553902
** some circumstances the associated metadata may be preserved. This may
@@ -3958,52 +3905,49 @@
39583905
** metadata associated with the SQL value passed as the regular expression
39593906
** pattern. The compiled regular expression can be reused on multiple
39603907
** invocations of the same function so that the original pattern string
39613908
** does not need to be recompiled on each invocation.
39623909
**
3963
-** The sqlite3_get_auxdata() interface returns a pointer to the metadata
3910
+** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
39643911
** associated by the sqlite3_set_auxdata() function with the Nth argument
3965
-** value to the application-defined function. If no metadata has been ever
3912
+** value to the application-defined function. ^If no metadata has been ever
39663913
** been set for the Nth argument of the function, or if the corresponding
39673914
** function parameter has changed since the meta-data was set,
39683915
** then sqlite3_get_auxdata() returns a NULL pointer.
39693916
**
3970
-** The sqlite3_set_auxdata() interface saves the metadata
3917
+** ^The sqlite3_set_auxdata() interface saves the metadata
39713918
** pointed to by its 3rd parameter as the metadata for the N-th
39723919
** argument of the application-defined function. Subsequent
39733920
** calls to sqlite3_get_auxdata() might return this data, if it has
39743921
** not been destroyed.
3975
-** If it is not NULL, SQLite will invoke the destructor
3922
+** ^If it is not NULL, SQLite will invoke the destructor
39763923
** function given by the 4th parameter to sqlite3_set_auxdata() on
39773924
** the metadata when the corresponding function parameter changes
39783925
** or when the SQL statement completes, whichever comes first.
39793926
**
39803927
** SQLite is free to call the destructor and drop metadata on any
3981
-** parameter of any function at any time. The only guarantee is that
3928
+** parameter of any function at any time. ^The only guarantee is that
39823929
** the destructor will be called before the metadata is dropped.
39833930
**
3984
-** In practice, metadata is preserved between function calls for
3931
+** ^(In practice, metadata is preserved between function calls for
39853932
** expressions that are constant at compile time. This includes literal
3986
-** values and SQL variables.
3933
+** values and [parameters].)^
39873934
**
39883935
** These routines must be called from the same thread in which
39893936
** the SQL function is running.
3990
-**
3991
-** Requirements:
3992
-** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
39933937
*/
39943938
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
39953939
SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
39963940
39973941
39983942
/*
3999
-** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
3943
+** CAPI3REF: Constants Defining Special Destructor Behavior
40003944
**
40013945
** These are special values for the destructor that is passed in as the
4002
-** final argument to routines like [sqlite3_result_blob()]. If the destructor
3946
+** final argument to routines like [sqlite3_result_blob()]. ^If the destructor
40033947
** argument is SQLITE_STATIC, it means that the content pointer is constant
4004
-** and will never change. It does not need to be destroyed. The
3948
+** and will never change. It does not need to be destroyed. ^The
40053949
** SQLITE_TRANSIENT value means that the content will likely change in
40063950
** the near future and that SQLite should make its own private copy of
40073951
** the content before returning.
40083952
**
40093953
** The typedef is necessary to work around problems in certain
@@ -4012,11 +3956,11 @@
40123956
typedef void (*sqlite3_destructor_type)(void*);
40133957
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
40143958
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
40153959
40163960
/*
4017
-** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
3961
+** CAPI3REF: Setting The Result Of An SQL Function
40183962
**
40193963
** These routines are used by the xFunc or xFinal callbacks that
40203964
** implement SQL functions and aggregates. See
40213965
** [sqlite3_create_function()] and [sqlite3_create_function16()]
40223966
** for additional information.
@@ -4023,107 +3967,102 @@
40233967
**
40243968
** These functions work very much like the [parameter binding] family of
40253969
** functions used to bind values to host parameters in prepared statements.
40263970
** Refer to the [SQL parameter] documentation for additional information.
40273971
**
4028
-** The sqlite3_result_blob() interface sets the result from
3972
+** ^The sqlite3_result_blob() interface sets the result from
40293973
** an application-defined function to be the BLOB whose content is pointed
40303974
** to by the second parameter and which is N bytes long where N is the
40313975
** third parameter.
40323976
**
4033
-** The sqlite3_result_zeroblob() interfaces set the result of
3977
+** ^The sqlite3_result_zeroblob() interfaces set the result of
40343978
** the application-defined function to be a BLOB containing all zero
40353979
** bytes and N bytes in size, where N is the value of the 2nd parameter.
40363980
**
4037
-** The sqlite3_result_double() interface sets the result from
3981
+** ^The sqlite3_result_double() interface sets the result from
40383982
** an application-defined function to be a floating point value specified
40393983
** by its 2nd argument.
40403984
**
4041
-** The sqlite3_result_error() and sqlite3_result_error16() functions
3985
+** ^The sqlite3_result_error() and sqlite3_result_error16() functions
40423986
** cause the implemented SQL function to throw an exception.
4043
-** SQLite uses the string pointed to by the
3987
+** ^SQLite uses the string pointed to by the
40443988
** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
4045
-** as the text of an error message. SQLite interprets the error
4046
-** message string from sqlite3_result_error() as UTF-8. SQLite
3989
+** as the text of an error message. ^SQLite interprets the error
3990
+** message string from sqlite3_result_error() as UTF-8. ^SQLite
40473991
** interprets the string from sqlite3_result_error16() as UTF-16 in native
4048
-** byte order. If the third parameter to sqlite3_result_error()
3992
+** byte order. ^If the third parameter to sqlite3_result_error()
40493993
** or sqlite3_result_error16() is negative then SQLite takes as the error
40503994
** message all text up through the first zero character.
4051
-** If the third parameter to sqlite3_result_error() or
3995
+** ^If the third parameter to sqlite3_result_error() or
40523996
** sqlite3_result_error16() is non-negative then SQLite takes that many
40533997
** bytes (not characters) from the 2nd parameter as the error message.
4054
-** The sqlite3_result_error() and sqlite3_result_error16()
3998
+** ^The sqlite3_result_error() and sqlite3_result_error16()
40553999
** routines make a private copy of the error message text before
40564000
** they return. Hence, the calling function can deallocate or
40574001
** modify the text after they return without harm.
4058
-** The sqlite3_result_error_code() function changes the error code
4059
-** returned by SQLite as a result of an error in a function. By default,
4060
-** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error()
4002
+** ^The sqlite3_result_error_code() function changes the error code
4003
+** returned by SQLite as a result of an error in a function. ^By default,
4004
+** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
40614005
** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
40624006
**
4063
-** The sqlite3_result_toobig() interface causes SQLite to throw an error
4064
-** indicating that a string or BLOB is to long to represent.
4007
+** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
4008
+** indicating that a string or BLOB is too long to represent.
40654009
**
4066
-** The sqlite3_result_nomem() interface causes SQLite to throw an error
4010
+** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
40674011
** indicating that a memory allocation failed.
40684012
**
4069
-** The sqlite3_result_int() interface sets the return value
4013
+** ^The sqlite3_result_int() interface sets the return value
40704014
** of the application-defined function to be the 32-bit signed integer
40714015
** value given in the 2nd argument.
4072
-** The sqlite3_result_int64() interface sets the return value
4016
+** ^The sqlite3_result_int64() interface sets the return value
40734017
** of the application-defined function to be the 64-bit signed integer
40744018
** value given in the 2nd argument.
40754019
**
4076
-** The sqlite3_result_null() interface sets the return value
4020
+** ^The sqlite3_result_null() interface sets the return value
40774021
** of the application-defined function to be NULL.
40784022
**
4079
-** The sqlite3_result_text(), sqlite3_result_text16(),
4023
+** ^The sqlite3_result_text(), sqlite3_result_text16(),
40804024
** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
40814025
** set the return value of the application-defined function to be
40824026
** a text string which is represented as UTF-8, UTF-16 native byte order,
40834027
** UTF-16 little endian, or UTF-16 big endian, respectively.
4084
-** SQLite takes the text result from the application from
4028
+** ^SQLite takes the text result from the application from
40854029
** the 2nd parameter of the sqlite3_result_text* interfaces.
4086
-** If the 3rd parameter to the sqlite3_result_text* interfaces
4030
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
40874031
** is negative, then SQLite takes result text from the 2nd parameter
40884032
** through the first zero character.
4089
-** If the 3rd parameter to the sqlite3_result_text* interfaces
4033
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
40904034
** is non-negative, then as many bytes (not characters) of the text
40914035
** pointed to by the 2nd parameter are taken as the application-defined
40924036
** function result.
4093
-** If the 4th parameter to the sqlite3_result_text* interfaces
4037
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
40944038
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
40954039
** function as the destructor on the text or BLOB result when it has
40964040
** finished using that result.
4097
-** If the 4th parameter to the sqlite3_result_text* interfaces or to
4041
+** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
40984042
** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
40994043
** assumes that the text or BLOB result is in constant space and does not
41004044
** copy the content of the parameter nor call a destructor on the content
41014045
** when it has finished using that result.
4102
-** If the 4th parameter to the sqlite3_result_text* interfaces
4046
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
41034047
** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
41044048
** then SQLite makes a copy of the result into space obtained from
41054049
** from [sqlite3_malloc()] before it returns.
41064050
**
4107
-** The sqlite3_result_value() interface sets the result of
4051
+** ^The sqlite3_result_value() interface sets the result of
41084052
** the application-defined function to be a copy the
4109
-** [unprotected sqlite3_value] object specified by the 2nd parameter. The
4053
+** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
41104054
** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
41114055
** so that the [sqlite3_value] specified in the parameter may change or
41124056
** be deallocated after sqlite3_result_value() returns without harm.
4113
-** A [protected sqlite3_value] object may always be used where an
4057
+** ^A [protected sqlite3_value] object may always be used where an
41144058
** [unprotected sqlite3_value] object is required, so either
41154059
** kind of [sqlite3_value] object can be used with this interface.
41164060
**
41174061
** If these routines are called from within the different thread
41184062
** than the one containing the application-defined function that received
41194063
** the [sqlite3_context] pointer, the results are undefined.
4120
-**
4121
-** Requirements:
4122
-** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
4123
-** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
4124
-** [H16451] [H16454] [H16457] [H16460] [H16463]
41254064
*/
41264065
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
41274066
SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
41284067
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
41294068
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -4139,58 +4078,54 @@
41394078
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
41404079
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
41414080
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
41424081
41434082
/*
4144
-** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
4083
+** CAPI3REF: Define New Collating Sequences
41454084
**
41464085
** These functions are used to add new collation sequences to the
41474086
** [database connection] specified as the first argument.
41484087
**
4149
-** The name of the new collation sequence is specified as a UTF-8 string
4088
+** ^The name of the new collation sequence is specified as a UTF-8 string
41504089
** for sqlite3_create_collation() and sqlite3_create_collation_v2()
4151
-** and a UTF-16 string for sqlite3_create_collation16(). In all cases
4090
+** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
41524091
** the name is passed as the second function argument.
41534092
**
4154
-** The third argument may be one of the constants [SQLITE_UTF8],
4093
+** ^The third argument may be one of the constants [SQLITE_UTF8],
41554094
** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
41564095
** routine expects to be passed pointers to strings encoded using UTF-8,
4157
-** UTF-16 little-endian, or UTF-16 big-endian, respectively. The
4096
+** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
41584097
** third argument might also be [SQLITE_UTF16] to indicate that the routine
41594098
** expects pointers to be UTF-16 strings in the native byte order, or the
41604099
** argument can be [SQLITE_UTF16_ALIGNED] if the
41614100
** the routine expects pointers to 16-bit word aligned strings
41624101
** of UTF-16 in the native byte order.
41634102
**
41644103
** A pointer to the user supplied routine must be passed as the fifth
4165
-** argument. If it is NULL, this is the same as deleting the collation
4104
+** argument. ^If it is NULL, this is the same as deleting the collation
41664105
** sequence (so that SQLite cannot call it anymore).
4167
-** Each time the application supplied function is invoked, it is passed
4106
+** ^Each time the application supplied function is invoked, it is passed
41684107
** as its first parameter a copy of the void* passed as the fourth argument
41694108
** to sqlite3_create_collation() or sqlite3_create_collation16().
41704109
**
4171
-** The remaining arguments to the application-supplied routine are two strings,
4110
+** ^The remaining arguments to the application-supplied routine are two strings,
41724111
** each represented by a (length, data) pair and encoded in the encoding
41734112
** that was passed as the third argument when the collation sequence was
4174
-** registered. {END} The application defined collation routine should
4113
+** registered. The application defined collation routine should
41754114
** return negative, zero or positive if the first string is less than,
41764115
** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
41774116
**
4178
-** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
4117
+** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
41794118
** except that it takes an extra argument which is a destructor for
4180
-** the collation. The destructor is called when the collation is
4119
+** the collation. ^The destructor is called when the collation is
41814120
** destroyed and is passed a copy of the fourth parameter void* pointer
41824121
** of the sqlite3_create_collation_v2().
4183
-** Collations are destroyed when they are overridden by later calls to the
4122
+** ^Collations are destroyed when they are overridden by later calls to the
41844123
** collation creation functions or when the [database connection] is closed
41854124
** using [sqlite3_close()].
41864125
**
41874126
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4188
-**
4189
-** Requirements:
4190
-** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
4191
-** [H16624] [H16627] [H16630]
41924127
*/
41934128
SQLITE_API int sqlite3_create_collation(
41944129
sqlite3*,
41954130
const char *zName,
41964131
int eTextRep,
@@ -4212,37 +4147,34 @@
42124147
void*,
42134148
int(*xCompare)(void*,int,const void*,int,const void*)
42144149
);
42154150
42164151
/*
4217
-** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
4152
+** CAPI3REF: Collation Needed Callbacks
42184153
**
4219
-** To avoid having to register all collation sequences before a database
4154
+** ^To avoid having to register all collation sequences before a database
42204155
** can be used, a single callback function may be registered with the
4221
-** [database connection] to be called whenever an undefined collation
4156
+** [database connection] to be invoked whenever an undefined collation
42224157
** sequence is required.
42234158
**
4224
-** If the function is registered using the sqlite3_collation_needed() API,
4159
+** ^If the function is registered using the sqlite3_collation_needed() API,
42254160
** then it is passed the names of undefined collation sequences as strings
4226
-** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
4161
+** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
42274162
** the names are passed as UTF-16 in machine native byte order.
4228
-** A call to either function replaces any existing callback.
4163
+** ^A call to either function replaces the existing collation-needed callback.
42294164
**
4230
-** When the callback is invoked, the first argument passed is a copy
4165
+** ^(When the callback is invoked, the first argument passed is a copy
42314166
** of the second argument to sqlite3_collation_needed() or
42324167
** sqlite3_collation_needed16(). The second argument is the database
42334168
** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
42344169
** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
42354170
** sequence function required. The fourth parameter is the name of the
4236
-** required collation sequence.
4171
+** required collation sequence.)^
42374172
**
42384173
** The callback function should register the desired collation using
42394174
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
42404175
** [sqlite3_create_collation_v2()].
4241
-**
4242
-** Requirements:
4243
-** [H16702] [H16704] [H16706]
42444176
*/
42454177
SQLITE_API int sqlite3_collation_needed(
42464178
sqlite3*,
42474179
void*,
42484180
void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -4277,33 +4209,32 @@
42774209
sqlite3 *db, /* Database to be rekeyed */
42784210
const void *pKey, int nKey /* The new key */
42794211
);
42804212
42814213
/*
4282
-** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
4214
+** CAPI3REF: Suspend Execution For A Short Time
42834215
**
4284
-** The sqlite3_sleep() function causes the current thread to suspend execution
4216
+** ^The sqlite3_sleep() function causes the current thread to suspend execution
42854217
** for at least a number of milliseconds specified in its parameter.
42864218
**
4287
-** If the operating system does not support sleep requests with
4219
+** ^If the operating system does not support sleep requests with
42884220
** millisecond time resolution, then the time will be rounded up to
4289
-** the nearest second. The number of milliseconds of sleep actually
4221
+** the nearest second. ^The number of milliseconds of sleep actually
42904222
** requested from the operating system is returned.
42914223
**
4292
-** SQLite implements this interface by calling the xSleep()
4224
+** ^SQLite implements this interface by calling the xSleep()
42934225
** method of the default [sqlite3_vfs] object.
4294
-**
4295
-** Requirements: [H10533] [H10536]
42964226
*/
42974227
SQLITE_API int sqlite3_sleep(int);
42984228
42994229
/*
4300
-** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
4230
+** CAPI3REF: Name Of The Folder Holding Temporary Files
43014231
**
4302
-** If this global variable is made to point to a string which is
4232
+** ^(If this global variable is made to point to a string which is
43034233
** the name of a folder (a.k.a. directory), then all temporary files
4304
-** created by SQLite will be placed in that directory. If this variable
4234
+** created by SQLite when using a built-in [sqlite3_vfs | VFS]
4235
+** will be placed in that directory.)^ ^If this variable
43054236
** is a NULL pointer, then SQLite performs a search for an appropriate
43064237
** temporary file directory.
43074238
**
43084239
** It is not safe to read or modify this variable in more than one
43094240
** thread at a time. It is not safe to read or modify this variable
@@ -4312,12 +4243,12 @@
43124243
** It is intended that this variable be set once
43134244
** as part of process initialization and before any SQLite interface
43144245
** routines have been called and that this variable remain unchanged
43154246
** thereafter.
43164247
**
4317
-** The [temp_store_directory pragma] may modify this variable and cause
4318
-** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
4248
+** ^The [temp_store_directory pragma] may modify this variable and cause
4249
+** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
43194250
** the [temp_store_directory pragma] always assumes that any string
43204251
** that this variable points to is held in memory obtained from
43214252
** [sqlite3_malloc] and the pragma may attempt to free that memory
43224253
** using [sqlite3_free].
43234254
** Hence, if this variable is modified directly, either it should be
@@ -4325,18 +4256,18 @@
43254256
** or else the use of the [temp_store_directory pragma] should be avoided.
43264257
*/
43274258
SQLITE_API char *sqlite3_temp_directory;
43284259
43294260
/*
4330
-** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
4261
+** CAPI3REF: Test For Auto-Commit Mode
43314262
** KEYWORDS: {autocommit mode}
43324263
**
4333
-** The sqlite3_get_autocommit() interface returns non-zero or
4264
+** ^The sqlite3_get_autocommit() interface returns non-zero or
43344265
** zero if the given database connection is or is not in autocommit mode,
4335
-** respectively. Autocommit mode is on by default.
4336
-** Autocommit mode is disabled by a [BEGIN] statement.
4337
-** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
4266
+** respectively. ^Autocommit mode is on by default.
4267
+** ^Autocommit mode is disabled by a [BEGIN] statement.
4268
+** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
43384269
**
43394270
** If certain kinds of errors occur on a statement within a multi-statement
43404271
** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
43414272
** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
43424273
** transaction might be rolled back automatically. The only way to
@@ -4344,124 +4275,116 @@
43444275
** an error is to use this function.
43454276
**
43464277
** If another thread changes the autocommit status of the database
43474278
** connection while this routine is running, then the return value
43484279
** is undefined.
4349
-**
4350
-** Requirements: [H12931] [H12932] [H12933] [H12934]
43514280
*/
43524281
SQLITE_API int sqlite3_get_autocommit(sqlite3*);
43534282
43544283
/*
4355
-** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
4284
+** CAPI3REF: Find The Database Handle Of A Prepared Statement
43564285
**
4357
-** The sqlite3_db_handle interface returns the [database connection] handle
4358
-** to which a [prepared statement] belongs. The [database connection]
4359
-** returned by sqlite3_db_handle is the same [database connection] that was the first argument
4286
+** ^The sqlite3_db_handle interface returns the [database connection] handle
4287
+** to which a [prepared statement] belongs. ^The [database connection]
4288
+** returned by sqlite3_db_handle is the same [database connection]
4289
+** that was the first argument
43604290
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
43614291
** create the statement in the first place.
4362
-**
4363
-** Requirements: [H13123]
43644292
*/
43654293
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
43664294
43674295
/*
4368
-** CAPI3REF: Find the next prepared statement {H13140} <S60600>
4296
+** CAPI3REF: Find the next prepared statement
43694297
**
4370
-** This interface returns a pointer to the next [prepared statement] after
4371
-** pStmt associated with the [database connection] pDb. If pStmt is NULL
4298
+** ^This interface returns a pointer to the next [prepared statement] after
4299
+** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
43724300
** then this interface returns a pointer to the first prepared statement
4373
-** associated with the database connection pDb. If no prepared statement
4301
+** associated with the database connection pDb. ^If no prepared statement
43744302
** satisfies the conditions of this routine, it returns NULL.
43754303
**
43764304
** The [database connection] pointer D in a call to
43774305
** [sqlite3_next_stmt(D,S)] must refer to an open database
43784306
** connection and in particular must not be a NULL pointer.
4379
-**
4380
-** Requirements: [H13143] [H13146] [H13149] [H13152]
43814307
*/
43824308
SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
43834309
43844310
/*
4385
-** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
4311
+** CAPI3REF: Commit And Rollback Notification Callbacks
43864312
**
4387
-** The sqlite3_commit_hook() interface registers a callback
4313
+** ^The sqlite3_commit_hook() interface registers a callback
43884314
** function to be invoked whenever a transaction is [COMMIT | committed].
4389
-** Any callback set by a previous call to sqlite3_commit_hook()
4315
+** ^Any callback set by a previous call to sqlite3_commit_hook()
43904316
** for the same database connection is overridden.
4391
-** The sqlite3_rollback_hook() interface registers a callback
4317
+** ^The sqlite3_rollback_hook() interface registers a callback
43924318
** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
4393
-** Any callback set by a previous call to sqlite3_commit_hook()
4319
+** ^Any callback set by a previous call to sqlite3_rollback_hook()
43944320
** for the same database connection is overridden.
4395
-** The pArg argument is passed through to the callback.
4396
-** If the callback on a commit hook function returns non-zero,
4321
+** ^The pArg argument is passed through to the callback.
4322
+** ^If the callback on a commit hook function returns non-zero,
43974323
** then the commit is converted into a rollback.
43984324
**
4399
-** If another function was previously registered, its
4400
-** pArg value is returned. Otherwise NULL is returned.
4325
+** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
4326
+** return the P argument from the previous call of the same function
4327
+** on the same [database connection] D, or NULL for
4328
+** the first call for each function on D.
44014329
**
44024330
** The callback implementation must not do anything that will modify
44034331
** the database connection that invoked the callback. Any actions
44044332
** to modify the database connection must be deferred until after the
44054333
** completion of the [sqlite3_step()] call that triggered the commit
44064334
** or rollback hook in the first place.
44074335
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
44084336
** database connections for the meaning of "modify" in this paragraph.
44094337
**
4410
-** Registering a NULL function disables the callback.
4338
+** ^Registering a NULL function disables the callback.
44114339
**
4412
-** When the commit hook callback routine returns zero, the [COMMIT]
4413
-** operation is allowed to continue normally. If the commit hook
4340
+** ^When the commit hook callback routine returns zero, the [COMMIT]
4341
+** operation is allowed to continue normally. ^If the commit hook
44144342
** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
4415
-** The rollback hook is invoked on a rollback that results from a commit
4343
+** ^The rollback hook is invoked on a rollback that results from a commit
44164344
** hook returning non-zero, just as it would be with any other rollback.
44174345
**
4418
-** For the purposes of this API, a transaction is said to have been
4346
+** ^For the purposes of this API, a transaction is said to have been
44194347
** rolled back if an explicit "ROLLBACK" statement is executed, or
44204348
** an error or constraint causes an implicit rollback to occur.
4421
-** The rollback callback is not invoked if a transaction is
4349
+** ^The rollback callback is not invoked if a transaction is
44224350
** automatically rolled back because the database connection is closed.
4423
-** The rollback callback is not invoked if a transaction is
4351
+** ^The rollback callback is not invoked if a transaction is
44244352
** rolled back because a commit callback returned non-zero.
4425
-** <todo> Check on this </todo>
44264353
**
44274354
** See also the [sqlite3_update_hook()] interface.
4428
-**
4429
-** Requirements:
4430
-** [H12951] [H12952] [H12953] [H12954] [H12955]
4431
-** [H12961] [H12962] [H12963] [H12964]
44324355
*/
44334356
SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
44344357
SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
44354358
44364359
/*
4437
-** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
4360
+** CAPI3REF: Data Change Notification Callbacks
44384361
**
4439
-** The sqlite3_update_hook() interface registers a callback function
4362
+** ^The sqlite3_update_hook() interface registers a callback function
44404363
** with the [database connection] identified by the first argument
44414364
** to be invoked whenever a row is updated, inserted or deleted.
4442
-** Any callback set by a previous call to this function
4365
+** ^Any callback set by a previous call to this function
44434366
** for the same database connection is overridden.
44444367
**
4445
-** The second argument is a pointer to the function to invoke when a
4368
+** ^The second argument is a pointer to the function to invoke when a
44464369
** row is updated, inserted or deleted.
4447
-** The first argument to the callback is a copy of the third argument
4370
+** ^The first argument to the callback is a copy of the third argument
44484371
** to sqlite3_update_hook().
4449
-** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
4372
+** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
44504373
** or [SQLITE_UPDATE], depending on the operation that caused the callback
44514374
** to be invoked.
4452
-** The third and fourth arguments to the callback contain pointers to the
4375
+** ^The third and fourth arguments to the callback contain pointers to the
44534376
** database and table name containing the affected row.
4454
-** The final callback parameter is the [rowid] of the row.
4455
-** In the case of an update, this is the [rowid] after the update takes place.
4377
+** ^The final callback parameter is the [rowid] of the row.
4378
+** ^In the case of an update, this is the [rowid] after the update takes place.
44564379
**
4457
-** The update hook is not invoked when internal system tables are
4458
-** modified (i.e. sqlite_master and sqlite_sequence).
4380
+** ^(The update hook is not invoked when internal system tables are
4381
+** modified (i.e. sqlite_master and sqlite_sequence).)^
44594382
**
4460
-** In the current implementation, the update hook
4383
+** ^In the current implementation, the update hook
44614384
** is not invoked when duplication rows are deleted because of an
4462
-** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook
4385
+** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
44634386
** invoked when rows are deleted using the [truncate optimization].
44644387
** The exceptions defined in this paragraph might change in a future
44654388
** release of SQLite.
44664389
**
44674390
** The update hook implementation must not do anything that will modify
@@ -4469,169 +4392,157 @@
44694392
** to modify the database connection must be deferred until after the
44704393
** completion of the [sqlite3_step()] call that triggered the update hook.
44714394
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
44724395
** database connections for the meaning of "modify" in this paragraph.
44734396
**
4474
-** If another function was previously registered, its pArg value
4475
-** is returned. Otherwise NULL is returned.
4397
+** ^The sqlite3_update_hook(D,C,P) function
4398
+** returns the P argument from the previous call
4399
+** on the same [database connection] D, or NULL for
4400
+** the first call on D.
44764401
**
44774402
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
44784403
** interfaces.
4479
-**
4480
-** Requirements:
4481
-** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
44824404
*/
44834405
SQLITE_API void *sqlite3_update_hook(
44844406
sqlite3*,
44854407
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
44864408
void*
44874409
);
44884410
44894411
/*
4490
-** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
4412
+** CAPI3REF: Enable Or Disable Shared Pager Cache
44914413
** KEYWORDS: {shared cache}
44924414
**
4493
-** This routine enables or disables the sharing of the database cache
4415
+** ^(This routine enables or disables the sharing of the database cache
44944416
** and schema data structures between [database connection | connections]
44954417
** to the same database. Sharing is enabled if the argument is true
4496
-** and disabled if the argument is false.
4418
+** and disabled if the argument is false.)^
44974419
**
4498
-** Cache sharing is enabled and disabled for an entire process.
4420
+** ^Cache sharing is enabled and disabled for an entire process.
44994421
** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
45004422
** sharing was enabled or disabled for each thread separately.
45014423
**
4502
-** The cache sharing mode set by this interface effects all subsequent
4424
+** ^(The cache sharing mode set by this interface effects all subsequent
45034425
** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
45044426
** Existing database connections continue use the sharing mode
4505
-** that was in effect at the time they were opened.
4506
-**
4507
-** Virtual tables cannot be used with a shared cache. When shared
4508
-** cache is enabled, the [sqlite3_create_module()] API used to register
4509
-** virtual tables will always return an error.
4510
-**
4511
-** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
4512
-** successfully. An [error code] is returned otherwise.
4513
-**
4514
-** Shared cache is disabled by default. But this might change in
4427
+** that was in effect at the time they were opened.)^
4428
+**
4429
+** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
4430
+** successfully. An [error code] is returned otherwise.)^
4431
+**
4432
+** ^Shared cache is disabled by default. But this might change in
45154433
** future releases of SQLite. Applications that care about shared
45164434
** cache setting should set it explicitly.
45174435
**
45184436
** See Also: [SQLite Shared-Cache Mode]
4519
-**
4520
-** Requirements: [H10331] [H10336] [H10337] [H10339]
45214437
*/
45224438
SQLITE_API int sqlite3_enable_shared_cache(int);
45234439
45244440
/*
4525
-** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
4441
+** CAPI3REF: Attempt To Free Heap Memory
45264442
**
4527
-** The sqlite3_release_memory() interface attempts to free N bytes
4443
+** ^The sqlite3_release_memory() interface attempts to free N bytes
45284444
** of heap memory by deallocating non-essential memory allocations
4529
-** held by the database library. {END} Memory used to cache database
4445
+** held by the database library. Memory used to cache database
45304446
** pages to improve performance is an example of non-essential memory.
4531
-** sqlite3_release_memory() returns the number of bytes actually freed,
4447
+** ^sqlite3_release_memory() returns the number of bytes actually freed,
45324448
** which might be more or less than the amount requested.
4533
-**
4534
-** Requirements: [H17341] [H17342]
45354449
*/
45364450
SQLITE_API int sqlite3_release_memory(int);
45374451
45384452
/*
4539
-** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
4453
+** CAPI3REF: Impose A Limit On Heap Size
45404454
**
4541
-** The sqlite3_soft_heap_limit() interface places a "soft" limit
4455
+** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
45424456
** on the amount of heap memory that may be allocated by SQLite.
4543
-** If an internal allocation is requested that would exceed the
4457
+** ^If an internal allocation is requested that would exceed the
45444458
** soft heap limit, [sqlite3_release_memory()] is invoked one or
45454459
** more times to free up some space before the allocation is performed.
45464460
**
4547
-** The limit is called "soft", because if [sqlite3_release_memory()]
4461
+** ^The limit is called "soft" because if [sqlite3_release_memory()]
45484462
** cannot free sufficient memory to prevent the limit from being exceeded,
45494463
** the memory is allocated anyway and the current operation proceeds.
45504464
**
4551
-** A negative or zero value for N means that there is no soft heap limit and
4465
+** ^A negative or zero value for N means that there is no soft heap limit and
45524466
** [sqlite3_release_memory()] will only be called when memory is exhausted.
4553
-** The default value for the soft heap limit is zero.
4467
+** ^The default value for the soft heap limit is zero.
45544468
**
4555
-** SQLite makes a best effort to honor the soft heap limit.
4469
+** ^(SQLite makes a best effort to honor the soft heap limit.
45564470
** But if the soft heap limit cannot be honored, execution will
4557
-** continue without error or notification. This is why the limit is
4471
+** continue without error or notification.)^ This is why the limit is
45584472
** called a "soft" limit. It is advisory only.
45594473
**
45604474
** Prior to SQLite version 3.5.0, this routine only constrained the memory
45614475
** allocated by a single thread - the same thread in which this routine
45624476
** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
45634477
** applied to all threads. The value specified for the soft heap limit
45644478
** is an upper bound on the total memory allocation for all threads. In
45654479
** version 3.5.0 there is no mechanism for limiting the heap usage for
45664480
** individual threads.
4567
-**
4568
-** Requirements:
4569
-** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
45704481
*/
45714482
SQLITE_API void sqlite3_soft_heap_limit(int);
45724483
45734484
/*
4574
-** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
4485
+** CAPI3REF: Extract Metadata About A Column Of A Table
45754486
**
4576
-** This routine returns metadata about a specific column of a specific
4487
+** ^This routine returns metadata about a specific column of a specific
45774488
** database table accessible using the [database connection] handle
45784489
** passed as the first function argument.
45794490
**
4580
-** The column is identified by the second, third and fourth parameters to
4581
-** this function. The second parameter is either the name of the database
4582
-** (i.e. "main", "temp" or an attached database) containing the specified
4583
-** table or NULL. If it is NULL, then all attached databases are searched
4491
+** ^The column is identified by the second, third and fourth parameters to
4492
+** this function. ^The second parameter is either the name of the database
4493
+** (i.e. "main", "temp", or an attached database) containing the specified
4494
+** table or NULL. ^If it is NULL, then all attached databases are searched
45844495
** for the table using the same algorithm used by the database engine to
45854496
** resolve unqualified table references.
45864497
**
4587
-** The third and fourth parameters to this function are the table and column
4498
+** ^The third and fourth parameters to this function are the table and column
45884499
** name of the desired column, respectively. Neither of these parameters
45894500
** may be NULL.
45904501
**
4591
-** Metadata is returned by writing to the memory locations passed as the 5th
4592
-** and subsequent parameters to this function. Any of these arguments may be
4502
+** ^Metadata is returned by writing to the memory locations passed as the 5th
4503
+** and subsequent parameters to this function. ^Any of these arguments may be
45934504
** NULL, in which case the corresponding element of metadata is omitted.
45944505
**
4595
-** <blockquote>
4506
+** ^(<blockquote>
45964507
** <table border="1">
45974508
** <tr><th> Parameter <th> Output<br>Type <th> Description
45984509
**
45994510
** <tr><td> 5th <td> const char* <td> Data type
46004511
** <tr><td> 6th <td> const char* <td> Name of default collation sequence
46014512
** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
46024513
** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
46034514
** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
46044515
** </table>
4605
-** </blockquote>
4516
+** </blockquote>)^
46064517
**
4607
-** The memory pointed to by the character pointers returned for the
4518
+** ^The memory pointed to by the character pointers returned for the
46084519
** declaration type and collation sequence is valid only until the next
46094520
** call to any SQLite API function.
46104521
**
4611
-** If the specified table is actually a view, an [error code] is returned.
4522
+** ^If the specified table is actually a view, an [error code] is returned.
46124523
**
4613
-** If the specified column is "rowid", "oid" or "_rowid_" and an
4524
+** ^If the specified column is "rowid", "oid" or "_rowid_" and an
46144525
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4615
-** parameters are set for the explicitly declared column. If there is no
4526
+** parameters are set for the explicitly declared column. ^(If there is no
46164527
** explicitly declared [INTEGER PRIMARY KEY] column, then the output
46174528
** parameters are set as follows:
46184529
**
46194530
** <pre>
46204531
** data type: "INTEGER"
46214532
** collation sequence: "BINARY"
46224533
** not null: 0
46234534
** primary key: 1
46244535
** auto increment: 0
4625
-** </pre>
4536
+** </pre>)^
46264537
**
4627
-** This function may load one or more schemas from database files. If an
4538
+** ^(This function may load one or more schemas from database files. If an
46284539
** error occurs during this process, or if the requested table or column
46294540
** cannot be found, an [error code] is returned and an error message left
4630
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).
4541
+** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
46314542
**
4632
-** This API is only available if the library was compiled with the
4543
+** ^This API is only available if the library was compiled with the
46334544
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
46344545
*/
46354546
SQLITE_API int sqlite3_table_column_metadata(
46364547
sqlite3 *db, /* Connection handle */
46374548
const char *zDbName, /* Database name or NULL */
@@ -4643,34 +4554,31 @@
46434554
int *pPrimaryKey, /* OUTPUT: True if column part of PK */
46444555
int *pAutoinc /* OUTPUT: True if column is auto-increment */
46454556
);
46464557
46474558
/*
4648
-** CAPI3REF: Load An Extension {H12600} <S20500>
4649
-**
4650
-** This interface loads an SQLite extension library from the named file.
4651
-**
4652
-** {H12601} The sqlite3_load_extension() interface attempts to load an
4653
-** SQLite extension library contained in the file zFile.
4654
-**
4655
-** {H12602} The entry point is zProc.
4656
-**
4657
-** {H12603} zProc may be 0, in which case the name of the entry point
4658
-** defaults to "sqlite3_extension_init".
4659
-**
4660
-** {H12604} The sqlite3_load_extension() interface shall return
4661
-** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4662
-**
4663
-** {H12605} If an error occurs and pzErrMsg is not 0, then the
4664
-** [sqlite3_load_extension()] interface shall attempt to
4665
-** fill *pzErrMsg with error message text stored in memory
4666
-** obtained from [sqlite3_malloc()]. {END} The calling function
4667
-** should free this memory by calling [sqlite3_free()].
4668
-**
4669
-** {H12606} Extension loading must be enabled using
4670
-** [sqlite3_enable_load_extension()] prior to calling this API,
4671
-** otherwise an error will be returned.
4559
+** CAPI3REF: Load An Extension
4560
+**
4561
+** ^This interface loads an SQLite extension library from the named file.
4562
+**
4563
+** ^The sqlite3_load_extension() interface attempts to load an
4564
+** SQLite extension library contained in the file zFile.
4565
+**
4566
+** ^The entry point is zProc.
4567
+** ^zProc may be 0, in which case the name of the entry point
4568
+** defaults to "sqlite3_extension_init".
4569
+** ^The sqlite3_load_extension() interface returns
4570
+** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4571
+** ^If an error occurs and pzErrMsg is not 0, then the
4572
+** [sqlite3_load_extension()] interface shall attempt to
4573
+** fill *pzErrMsg with error message text stored in memory
4574
+** obtained from [sqlite3_malloc()]. The calling function
4575
+** should free this memory by calling [sqlite3_free()].
4576
+**
4577
+** ^Extension loading must be enabled using
4578
+** [sqlite3_enable_load_extension()] prior to calling this API,
4579
+** otherwise an error will be returned.
46724580
**
46734581
** See also the [load_extension() SQL function].
46744582
*/
46754583
SQLITE_API int sqlite3_load_extension(
46764584
sqlite3 *db, /* Load the extension into this database connection */
@@ -4678,65 +4586,53 @@
46784586
const char *zProc, /* Entry point. Derived from zFile if 0 */
46794587
char **pzErrMsg /* Put error message here if not 0 */
46804588
);
46814589
46824590
/*
4683
-** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
4591
+** CAPI3REF: Enable Or Disable Extension Loading
46844592
**
4685
-** So as not to open security holes in older applications that are
4593
+** ^So as not to open security holes in older applications that are
46864594
** unprepared to deal with extension loading, and as a means of disabling
46874595
** extension loading while evaluating user-entered SQL, the following API
46884596
** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
46894597
**
4690
-** Extension loading is off by default. See ticket #1863.
4691
-**
4692
-** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
4693
-** to turn extension loading on and call it with onoff==0 to turn
4694
-** it back off again.
4695
-**
4696
-** {H12622} Extension loading is off by default.
4598
+** ^Extension loading is off by default. See ticket #1863.
4599
+** ^Call the sqlite3_enable_load_extension() routine with onoff==1
4600
+** to turn extension loading on and call it with onoff==0 to turn
4601
+** it back off again.
46974602
*/
46984603
SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
46994604
47004605
/*
4701
-** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
4606
+** CAPI3REF: Automatically Load An Extensions
47024607
**
4703
-** This API can be invoked at program startup in order to register
4608
+** ^This API can be invoked at program startup in order to register
47044609
** one or more statically linked extensions that will be available
4705
-** to all new [database connections]. {END}
4706
-**
4707
-** This routine stores a pointer to the extension in an array that is
4708
-** obtained from [sqlite3_malloc()]. If you run a memory leak checker
4709
-** on your program and it reports a leak because of this array, invoke
4710
-** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
4711
-**
4712
-** {H12641} This function registers an extension entry point that is
4713
-** automatically invoked whenever a new [database connection]
4714
-** is opened using [sqlite3_open()], [sqlite3_open16()],
4715
-** or [sqlite3_open_v2()].
4716
-**
4717
-** {H12642} Duplicate extensions are detected so calling this routine
4718
-** multiple times with the same extension is harmless.
4719
-**
4720
-** {H12643} This routine stores a pointer to the extension in an array
4721
-** that is obtained from [sqlite3_malloc()].
4722
-**
4723
-** {H12644} Automatic extensions apply across all threads.
4610
+** to all new [database connections].
4611
+**
4612
+** ^(This routine stores a pointer to the extension entry point
4613
+** in an array that is obtained from [sqlite3_malloc()]. That memory
4614
+** is deallocated by [sqlite3_reset_auto_extension()].)^
4615
+**
4616
+** ^This function registers an extension entry point that is
4617
+** automatically invoked whenever a new [database connection]
4618
+** is opened using [sqlite3_open()], [sqlite3_open16()],
4619
+** or [sqlite3_open_v2()].
4620
+** ^Duplicate extensions are detected so calling this routine
4621
+** multiple times with the same extension is harmless.
4622
+** ^Automatic extensions apply across all threads.
47244623
*/
47254624
SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
47264625
47274626
/*
4728
-** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
4729
-**
4730
-** This function disables all previously registered automatic
4731
-** extensions. {END} It undoes the effect of all prior
4732
-** [sqlite3_auto_extension()] calls.
4733
-**
4734
-** {H12661} This function disables all previously registered
4735
-** automatic extensions.
4736
-**
4737
-** {H12662} This function disables automatic extensions in all threads.
4627
+** CAPI3REF: Reset Automatic Extension Loading
4628
+**
4629
+** ^(This function disables all previously registered automatic
4630
+** extensions. It undoes the effect of all prior
4631
+** [sqlite3_auto_extension()] calls.)^
4632
+**
4633
+** ^This function disables automatic extensions in all threads.
47384634
*/
47394635
SQLITE_API void sqlite3_reset_auto_extension(void);
47404636
47414637
/*
47424638
****** EXPERIMENTAL - subject to change without notice **************
@@ -4756,22 +4652,22 @@
47564652
typedef struct sqlite3_index_info sqlite3_index_info;
47574653
typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
47584654
typedef struct sqlite3_module sqlite3_module;
47594655
47604656
/*
4761
-** CAPI3REF: Virtual Table Object {H18000} <S20400>
4657
+** CAPI3REF: Virtual Table Object
47624658
** KEYWORDS: sqlite3_module {virtual table module}
47634659
** EXPERIMENTAL
47644660
**
47654661
** This structure, sometimes called a a "virtual table module",
47664662
** defines the implementation of a [virtual tables].
47674663
** This structure consists mostly of methods for the module.
47684664
**
4769
-** A virtual table module is created by filling in a persistent
4665
+** ^A virtual table module is created by filling in a persistent
47704666
** instance of this structure and passing a pointer to that instance
47714667
** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4772
-** The registration remains valid until it is replaced by a different
4668
+** ^The registration remains valid until it is replaced by a different
47734669
** module or until the [database connection] closes. The content
47744670
** of this structure must not change while it is registered with
47754671
** any database connection.
47764672
*/
47774673
struct sqlite3_module {
@@ -4803,56 +4699,56 @@
48034699
void **ppArg);
48044700
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
48054701
};
48064702
48074703
/*
4808
-** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
4704
+** CAPI3REF: Virtual Table Indexing Information
48094705
** KEYWORDS: sqlite3_index_info
48104706
** EXPERIMENTAL
48114707
**
48124708
** The sqlite3_index_info structure and its substructures is used to
48134709
** pass information into and receive the reply from the [xBestIndex]
48144710
** method of a [virtual table module]. The fields under **Inputs** are the
48154711
** inputs to xBestIndex and are read-only. xBestIndex inserts its
48164712
** results into the **Outputs** fields.
48174713
**
4818
-** The aConstraint[] array records WHERE clause constraints of the form:
4714
+** ^(The aConstraint[] array records WHERE clause constraints of the form:
48194715
**
48204716
** <pre>column OP expr</pre>
48214717
**
4822
-** where OP is =, &lt;, &lt;=, &gt;, or &gt;=. The particular operator is
4823
-** stored in aConstraint[].op. The index of the column is stored in
4824
-** aConstraint[].iColumn. aConstraint[].usable is TRUE if the
4718
+** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^ ^(The particular operator is
4719
+** stored in aConstraint[].op.)^ ^(The index of the column is stored in
4720
+** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the
48254721
** expr on the right-hand side can be evaluated (and thus the constraint
4826
-** is usable) and false if it cannot.
4722
+** is usable) and false if it cannot.)^
48274723
**
4828
-** The optimizer automatically inverts terms of the form "expr OP column"
4724
+** ^The optimizer automatically inverts terms of the form "expr OP column"
48294725
** and makes other simplifications to the WHERE clause in an attempt to
48304726
** get as many WHERE clause terms into the form shown above as possible.
4831
-** The aConstraint[] array only reports WHERE clause terms in the correct
4832
-** form that refer to the particular virtual table being queried.
4727
+** ^The aConstraint[] array only reports WHERE clause terms that are
4728
+** relevant to the particular virtual table being queried.
48334729
**
4834
-** Information about the ORDER BY clause is stored in aOrderBy[].
4835
-** Each term of aOrderBy records a column of the ORDER BY clause.
4730
+** ^Information about the ORDER BY clause is stored in aOrderBy[].
4731
+** ^Each term of aOrderBy records a column of the ORDER BY clause.
48364732
**
48374733
** The [xBestIndex] method must fill aConstraintUsage[] with information
4838
-** about what parameters to pass to xFilter. If argvIndex>0 then
4734
+** about what parameters to pass to xFilter. ^If argvIndex>0 then
48394735
** the right-hand side of the corresponding aConstraint[] is evaluated
4840
-** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
4736
+** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
48414737
** is true, then the constraint is assumed to be fully handled by the
4842
-** virtual table and is not checked again by SQLite.
4738
+** virtual table and is not checked again by SQLite.)^
48434739
**
4844
-** The idxNum and idxPtr values are recorded and passed into the
4740
+** ^The idxNum and idxPtr values are recorded and passed into the
48454741
** [xFilter] method.
4846
-** [sqlite3_free()] is used to free idxPtr if and only iff
4742
+** ^[sqlite3_free()] is used to free idxPtr if and only if
48474743
** needToFreeIdxPtr is true.
48484744
**
4849
-** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4745
+** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
48504746
** the correct order to satisfy the ORDER BY clause so that no separate
48514747
** sorting step is required.
48524748
**
4853
-** The estimatedCost value is an estimate of the cost of doing the
4749
+** ^The estimatedCost value is an estimate of the cost of doing the
48544750
** particular lookup. A full scan of a table with N entries should have
48554751
** a cost of N. A binary search of a table of N entries should have a
48564752
** cost of approximately log(N).
48574753
*/
48584754
struct sqlite3_index_info {
@@ -4886,70 +4782,63 @@
48864782
#define SQLITE_INDEX_CONSTRAINT_LT 16
48874783
#define SQLITE_INDEX_CONSTRAINT_GE 32
48884784
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
48894785
48904786
/*
4891
-** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
4787
+** CAPI3REF: Register A Virtual Table Implementation
48924788
** EXPERIMENTAL
48934789
**
4894
-** This routine is used to register a new [virtual table module] name.
4895
-** Module names must be registered before
4896
-** creating a new [virtual table] using the module, or before using a
4790
+** ^These routines are used to register a new [virtual table module] name.
4791
+** ^Module names must be registered before
4792
+** creating a new [virtual table] using the module and before using a
48974793
** preexisting [virtual table] for the module.
48984794
**
4899
-** The module name is registered on the [database connection] specified
4900
-** by the first parameter. The name of the module is given by the
4901
-** second parameter. The third parameter is a pointer to
4902
-** the implementation of the [virtual table module]. The fourth
4795
+** ^The module name is registered on the [database connection] specified
4796
+** by the first parameter. ^The name of the module is given by the
4797
+** second parameter. ^The third parameter is a pointer to
4798
+** the implementation of the [virtual table module]. ^The fourth
49034799
** parameter is an arbitrary client data pointer that is passed through
49044800
** into the [xCreate] and [xConnect] methods of the virtual table module
49054801
** when a new virtual table is be being created or reinitialized.
49064802
**
4907
-** This interface has exactly the same effect as calling
4908
-** [sqlite3_create_module_v2()] with a NULL client data destructor.
4803
+** ^The sqlite3_create_module_v2() interface has a fifth parameter which
4804
+** is a pointer to a destructor for the pClientData. ^SQLite will
4805
+** invoke the destructor function (if it is not NULL) when SQLite
4806
+** no longer needs the pClientData pointer. ^The sqlite3_create_module()
4807
+** interface is equivalent to sqlite3_create_module_v2() with a NULL
4808
+** destructor.
49094809
*/
49104810
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
49114811
sqlite3 *db, /* SQLite connection to register module with */
49124812
const char *zName, /* Name of the module */
49134813
const sqlite3_module *p, /* Methods for the module */
49144814
void *pClientData /* Client data for xCreate/xConnect */
49154815
);
4916
-
4917
-/*
4918
-** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
4919
-** EXPERIMENTAL
4920
-**
4921
-** This routine is identical to the [sqlite3_create_module()] method,
4922
-** except that it has an extra parameter to specify
4923
-** a destructor function for the client data pointer. SQLite will
4924
-** invoke the destructor function (if it is not NULL) when SQLite
4925
-** no longer needs the pClientData pointer.
4926
-*/
49274816
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
49284817
sqlite3 *db, /* SQLite connection to register module with */
49294818
const char *zName, /* Name of the module */
49304819
const sqlite3_module *p, /* Methods for the module */
49314820
void *pClientData, /* Client data for xCreate/xConnect */
49324821
void(*xDestroy)(void*) /* Module destructor function */
49334822
);
49344823
49354824
/*
4936
-** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
4825
+** CAPI3REF: Virtual Table Instance Object
49374826
** KEYWORDS: sqlite3_vtab
49384827
** EXPERIMENTAL
49394828
**
49404829
** Every [virtual table module] implementation uses a subclass
4941
-** of the following structure to describe a particular instance
4830
+** of this object to describe a particular instance
49424831
** of the [virtual table]. Each subclass will
49434832
** be tailored to the specific needs of the module implementation.
49444833
** The purpose of this superclass is to define certain fields that are
49454834
** common to all module implementations.
49464835
**
4947
-** Virtual tables methods can set an error message by assigning a
4836
+** ^Virtual tables methods can set an error message by assigning a
49484837
** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
49494838
** take care that any prior string is freed by a call to [sqlite3_free()]
4950
-** prior to assigning a new string to zErrMsg. After the error message
4839
+** prior to assigning a new string to zErrMsg. ^After the error message
49514840
** is delivered up to the client application, the string will be automatically
49524841
** freed by sqlite3_free() and the zErrMsg field will be zeroed.
49534842
*/
49544843
struct sqlite3_vtab {
49554844
const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4957,20 +4846,20 @@
49574846
char *zErrMsg; /* Error message from sqlite3_mprintf() */
49584847
/* Virtual table implementations will typically add additional fields */
49594848
};
49604849
49614850
/*
4962
-** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400>
4851
+** CAPI3REF: Virtual Table Cursor Object
49634852
** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
49644853
** EXPERIMENTAL
49654854
**
49664855
** Every [virtual table module] implementation uses a subclass of the
49674856
** following structure to describe cursors that point into the
49684857
** [virtual table] and are used
49694858
** to loop through the virtual table. Cursors are created using the
49704859
** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4971
-** by the [sqlite3_module.xClose | xClose] method. Cussors are used
4860
+** by the [sqlite3_module.xClose | xClose] method. Cursors are used
49724861
** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
49734862
** of the module. Each module implementation will define
49744863
** the content of a cursor structure to suit its own needs.
49754864
**
49764865
** This superclass exists in order to define fields of the cursor that
@@ -4980,32 +4869,32 @@
49804869
sqlite3_vtab *pVtab; /* Virtual table of this cursor */
49814870
/* Virtual table implementations will typically add additional fields */
49824871
};
49834872
49844873
/*
4985
-** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
4874
+** CAPI3REF: Declare The Schema Of A Virtual Table
49864875
** EXPERIMENTAL
49874876
**
4988
-** The [xCreate] and [xConnect] methods of a
4877
+** ^The [xCreate] and [xConnect] methods of a
49894878
** [virtual table module] call this interface
49904879
** to declare the format (the names and datatypes of the columns) of
49914880
** the virtual tables they implement.
49924881
*/
49934882
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
49944883
49954884
/*
4996
-** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
4885
+** CAPI3REF: Overload A Function For A Virtual Table
49974886
** EXPERIMENTAL
49984887
**
4999
-** Virtual tables can provide alternative implementations of functions
4888
+** ^(Virtual tables can provide alternative implementations of functions
50004889
** using the [xFindFunction] method of the [virtual table module].
50014890
** But global versions of those functions
5002
-** must exist in order to be overloaded.
4891
+** must exist in order to be overloaded.)^
50034892
**
5004
-** This API makes sure a global version of a function with a particular
4893
+** ^(This API makes sure a global version of a function with a particular
50054894
** name and number of parameters exists. If no such function exists
5006
-** before this API is called, a new function is created. The implementation
4895
+** before this API is called, a new function is created.)^ ^The implementation
50074896
** of the new function always causes an exception to be thrown. So
50084897
** the new function is not good for anything by itself. Its only
50094898
** purpose is to be a placeholder function that can be overloaded
50104899
** by a [virtual table].
50114900
*/
@@ -5022,81 +4911,78 @@
50224911
**
50234912
****** EXPERIMENTAL - subject to change without notice **************
50244913
*/
50254914
50264915
/*
5027
-** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
4916
+** CAPI3REF: A Handle To An Open BLOB
50284917
** KEYWORDS: {BLOB handle} {BLOB handles}
50294918
**
50304919
** An instance of this object represents an open BLOB on which
50314920
** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
5032
-** Objects of this type are created by [sqlite3_blob_open()]
4921
+** ^Objects of this type are created by [sqlite3_blob_open()]
50334922
** and destroyed by [sqlite3_blob_close()].
5034
-** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
4923
+** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
50354924
** can be used to read or write small subsections of the BLOB.
5036
-** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
4925
+** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
50374926
*/
50384927
typedef struct sqlite3_blob sqlite3_blob;
50394928
50404929
/*
5041
-** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
4930
+** CAPI3REF: Open A BLOB For Incremental I/O
50424931
**
5043
-** This interfaces opens a [BLOB handle | handle] to the BLOB located
4932
+** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
50444933
** in row iRow, column zColumn, table zTable in database zDb;
50454934
** in other words, the same BLOB that would be selected by:
50464935
**
50474936
** <pre>
50484937
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
5049
-** </pre> {END}
4938
+** </pre>)^
50504939
**
5051
-** If the flags parameter is non-zero, then the BLOB is opened for read
5052
-** and write access. If it is zero, the BLOB is opened for read access.
5053
-** It is not possible to open a column that is part of an index or primary
4940
+** ^If the flags parameter is non-zero, then the BLOB is opened for read
4941
+** and write access. ^If it is zero, the BLOB is opened for read access.
4942
+** ^It is not possible to open a column that is part of an index or primary
50544943
** key for writing. ^If [foreign key constraints] are enabled, it is
50554944
** not possible to open a column that is part of a [child key] for writing.
50564945
**
5057
-** Note that the database name is not the filename that contains
4946
+** ^Note that the database name is not the filename that contains
50584947
** the database but rather the symbolic name of the database that
5059
-** is assigned when the database is connected using [ATTACH].
5060
-** For the main database file, the database name is "main".
5061
-** For TEMP tables, the database name is "temp".
4948
+** appears after the AS keyword when the database is connected using [ATTACH].
4949
+** ^For the main database file, the database name is "main".
4950
+** ^For TEMP tables, the database name is "temp".
50624951
**
5063
-** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
4952
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
50644953
** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
5065
-** to be a null pointer.
5066
-** This function sets the [database connection] error code and message
4954
+** to be a null pointer.)^
4955
+** ^This function sets the [database connection] error code and message
50674956
** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
5068
-** functions. Note that the *ppBlob variable is always initialized in a
4957
+** functions. ^Note that the *ppBlob variable is always initialized in a
50694958
** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
50704959
** regardless of the success or failure of this routine.
50714960
**
5072
-** If the row that a BLOB handle points to is modified by an
4961
+** ^(If the row that a BLOB handle points to is modified by an
50734962
** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
50744963
** then the BLOB handle is marked as "expired".
50754964
** This is true if any column of the row is changed, even a column
5076
-** other than the one the BLOB handle is open on.
5077
-** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4965
+** other than the one the BLOB handle is open on.)^
4966
+** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
50784967
** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
5079
-** Changes written into a BLOB prior to the BLOB expiring are not
5080
-** rollback by the expiration of the BLOB. Such changes will eventually
5081
-** commit if the transaction continues to completion.
4968
+** ^(Changes written into a BLOB prior to the BLOB expiring are not
4969
+** rolled back by the expiration of the BLOB. Such changes will eventually
4970
+** commit if the transaction continues to completion.)^
50824971
**
5083
-** Use the [sqlite3_blob_bytes()] interface to determine the size of
5084
-** the opened blob. The size of a blob may not be changed by this
4972
+** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
4973
+** the opened blob. ^The size of a blob may not be changed by this
50854974
** interface. Use the [UPDATE] SQL command to change the size of a
50864975
** blob.
50874976
**
5088
-** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
4977
+** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
50894978
** and the built-in [zeroblob] SQL function can be used, if desired,
50904979
** to create an empty, zero-filled blob in which to read or write using
50914980
** this interface.
50924981
**
50934982
** To avoid a resource leak, every open [BLOB handle] should eventually
50944983
** be released by a call to [sqlite3_blob_close()].
5095
-**
5096
-** Requirements:
5097
-** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
50984984
*/
50994985
SQLITE_API int sqlite3_blob_open(
51004986
sqlite3*,
51014987
const char *zDb,
51024988
const char *zTable,
@@ -5105,201 +4991,185 @@
51054991
int flags,
51064992
sqlite3_blob **ppBlob
51074993
);
51084994
51094995
/*
5110
-** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
4996
+** CAPI3REF: Close A BLOB Handle
51114997
**
5112
-** Closes an open [BLOB handle].
4998
+** ^Closes an open [BLOB handle].
51134999
**
5114
-** Closing a BLOB shall cause the current transaction to commit
5000
+** ^Closing a BLOB shall cause the current transaction to commit
51155001
** if there are no other BLOBs, no pending prepared statements, and the
51165002
** database connection is in [autocommit mode].
5117
-** If any writes were made to the BLOB, they might be held in cache
5003
+** ^If any writes were made to the BLOB, they might be held in cache
51185004
** until the close operation if they will fit.
51195005
**
5120
-** Closing the BLOB often forces the changes
5006
+** ^(Closing the BLOB often forces the changes
51215007
** out to disk and so if any I/O errors occur, they will likely occur
51225008
** at the time when the BLOB is closed. Any errors that occur during
5123
-** closing are reported as a non-zero return value.
5124
-**
5125
-** The BLOB is closed unconditionally. Even if this routine returns
5126
-** an error code, the BLOB is still closed.
5127
-**
5128
-** Calling this routine with a null pointer (which as would be returned
5129
-** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
5130
-**
5131
-** Requirements:
5132
-** [H17833] [H17836] [H17839]
5009
+** closing are reported as a non-zero return value.)^
5010
+**
5011
+** ^(The BLOB is closed unconditionally. Even if this routine returns
5012
+** an error code, the BLOB is still closed.)^
5013
+**
5014
+** ^Calling this routine with a null pointer (such as would be returned
5015
+** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
51335016
*/
51345017
SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
51355018
51365019
/*
5137
-** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
5020
+** CAPI3REF: Return The Size Of An Open BLOB
51385021
**
5139
-** Returns the size in bytes of the BLOB accessible via the
5140
-** successfully opened [BLOB handle] in its only argument. The
5022
+** ^Returns the size in bytes of the BLOB accessible via the
5023
+** successfully opened [BLOB handle] in its only argument. ^The
51415024
** incremental blob I/O routines can only read or overwriting existing
51425025
** blob content; they cannot change the size of a blob.
51435026
**
51445027
** This routine only works on a [BLOB handle] which has been created
51455028
** by a prior successful call to [sqlite3_blob_open()] and which has not
51465029
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
51475030
** to this routine results in undefined and probably undesirable behavior.
5148
-**
5149
-** Requirements:
5150
-** [H17843]
51515031
*/
51525032
SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
51535033
51545034
/*
5155
-** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
5035
+** CAPI3REF: Read Data From A BLOB Incrementally
51565036
**
5157
-** This function is used to read data from an open [BLOB handle] into a
5037
+** ^(This function is used to read data from an open [BLOB handle] into a
51585038
** caller-supplied buffer. N bytes of data are copied into buffer Z
5159
-** from the open BLOB, starting at offset iOffset.
5039
+** from the open BLOB, starting at offset iOffset.)^
51605040
**
5161
-** If offset iOffset is less than N bytes from the end of the BLOB,
5162
-** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is
5041
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
5042
+** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
51635043
** less than zero, [SQLITE_ERROR] is returned and no data is read.
5164
-** The size of the blob (and hence the maximum value of N+iOffset)
5044
+** ^The size of the blob (and hence the maximum value of N+iOffset)
51655045
** can be determined using the [sqlite3_blob_bytes()] interface.
51665046
**
5167
-** An attempt to read from an expired [BLOB handle] fails with an
5047
+** ^An attempt to read from an expired [BLOB handle] fails with an
51685048
** error code of [SQLITE_ABORT].
51695049
**
5170
-** On success, SQLITE_OK is returned.
5171
-** Otherwise, an [error code] or an [extended error code] is returned.
5050
+** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
5051
+** Otherwise, an [error code] or an [extended error code] is returned.)^
51725052
**
51735053
** This routine only works on a [BLOB handle] which has been created
51745054
** by a prior successful call to [sqlite3_blob_open()] and which has not
51755055
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
51765056
** to this routine results in undefined and probably undesirable behavior.
51775057
**
51785058
** See also: [sqlite3_blob_write()].
5179
-**
5180
-** Requirements:
5181
-** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
51825059
*/
51835060
SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
51845061
51855062
/*
5186
-** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
5063
+** CAPI3REF: Write Data Into A BLOB Incrementally
51875064
**
5188
-** This function is used to write data into an open [BLOB handle] from a
5189
-** caller-supplied buffer. N bytes of data are copied from the buffer Z
5065
+** ^This function is used to write data into an open [BLOB handle] from a
5066
+** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
51905067
** into the open BLOB, starting at offset iOffset.
51915068
**
5192
-** If the [BLOB handle] passed as the first argument was not opened for
5069
+** ^If the [BLOB handle] passed as the first argument was not opened for
51935070
** writing (the flags parameter to [sqlite3_blob_open()] was zero),
51945071
** this function returns [SQLITE_READONLY].
51955072
**
5196
-** This function may only modify the contents of the BLOB; it is
5073
+** ^This function may only modify the contents of the BLOB; it is
51975074
** not possible to increase the size of a BLOB using this API.
5198
-** If offset iOffset is less than N bytes from the end of the BLOB,
5199
-** [SQLITE_ERROR] is returned and no data is written. If N is
5075
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
5076
+** [SQLITE_ERROR] is returned and no data is written. ^If N is
52005077
** less than zero [SQLITE_ERROR] is returned and no data is written.
52015078
** The size of the BLOB (and hence the maximum value of N+iOffset)
52025079
** can be determined using the [sqlite3_blob_bytes()] interface.
52035080
**
5204
-** An attempt to write to an expired [BLOB handle] fails with an
5205
-** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred
5081
+** ^An attempt to write to an expired [BLOB handle] fails with an
5082
+** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
52065083
** before the [BLOB handle] expired are not rolled back by the
52075084
** expiration of the handle, though of course those changes might
52085085
** have been overwritten by the statement that expired the BLOB handle
52095086
** or by other independent statements.
52105087
**
5211
-** On success, SQLITE_OK is returned.
5212
-** Otherwise, an [error code] or an [extended error code] is returned.
5088
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
5089
+** Otherwise, an [error code] or an [extended error code] is returned.)^
52135090
**
52145091
** This routine only works on a [BLOB handle] which has been created
52155092
** by a prior successful call to [sqlite3_blob_open()] and which has not
52165093
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
52175094
** to this routine results in undefined and probably undesirable behavior.
52185095
**
52195096
** See also: [sqlite3_blob_read()].
5220
-**
5221
-** Requirements:
5222
-** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
5223
-** [H17888]
52245097
*/
52255098
SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
52265099
52275100
/*
5228
-** CAPI3REF: Virtual File System Objects {H11200} <S20100>
5101
+** CAPI3REF: Virtual File System Objects
52295102
**
52305103
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
52315104
** that SQLite uses to interact
52325105
** with the underlying operating system. Most SQLite builds come with a
52335106
** single default VFS that is appropriate for the host computer.
52345107
** New VFSes can be registered and existing VFSes can be unregistered.
52355108
** The following interfaces are provided.
52365109
**
5237
-** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
5238
-** Names are case sensitive.
5239
-** Names are zero-terminated UTF-8 strings.
5240
-** If there is no match, a NULL pointer is returned.
5241
-** If zVfsName is NULL then the default VFS is returned.
5110
+** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
5111
+** ^Names are case sensitive.
5112
+** ^Names are zero-terminated UTF-8 strings.
5113
+** ^If there is no match, a NULL pointer is returned.
5114
+** ^If zVfsName is NULL then the default VFS is returned.
52425115
**
5243
-** New VFSes are registered with sqlite3_vfs_register().
5244
-** Each new VFS becomes the default VFS if the makeDflt flag is set.
5245
-** The same VFS can be registered multiple times without injury.
5246
-** To make an existing VFS into the default VFS, register it again
5116
+** ^New VFSes are registered with sqlite3_vfs_register().
5117
+** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
5118
+** ^The same VFS can be registered multiple times without injury.
5119
+** ^To make an existing VFS into the default VFS, register it again
52475120
** with the makeDflt flag set. If two different VFSes with the
52485121
** same name are registered, the behavior is undefined. If a
52495122
** VFS is registered with a name that is NULL or an empty string,
52505123
** then the behavior is undefined.
52515124
**
5252
-** Unregister a VFS with the sqlite3_vfs_unregister() interface.
5253
-** If the default VFS is unregistered, another VFS is chosen as
5254
-** the default. The choice for the new VFS is arbitrary.
5255
-**
5256
-** Requirements:
5257
-** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
5125
+** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
5126
+** ^(If the default VFS is unregistered, another VFS is chosen as
5127
+** the default. The choice for the new VFS is arbitrary.)^
52585128
*/
52595129
SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
52605130
SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
52615131
SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
52625132
52635133
/*
5264
-** CAPI3REF: Mutexes {H17000} <S20000>
5134
+** CAPI3REF: Mutexes
52655135
**
52665136
** The SQLite core uses these routines for thread
52675137
** synchronization. Though they are intended for internal
52685138
** use by SQLite, code that links against SQLite is
52695139
** permitted to use any of these routines.
52705140
**
52715141
** The SQLite source code contains multiple implementations
52725142
** of these mutex routines. An appropriate implementation
5273
-** is selected automatically at compile-time. The following
5143
+** is selected automatically at compile-time. ^(The following
52745144
** implementations are available in the SQLite core:
52755145
**
52765146
** <ul>
52775147
** <li> SQLITE_MUTEX_OS2
52785148
** <li> SQLITE_MUTEX_PTHREAD
52795149
** <li> SQLITE_MUTEX_W32
52805150
** <li> SQLITE_MUTEX_NOOP
5281
-** </ul>
5151
+** </ul>)^
52825152
**
5283
-** The SQLITE_MUTEX_NOOP implementation is a set of routines
5153
+** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
52845154
** that does no real locking and is appropriate for use in
5285
-** a single-threaded application. The SQLITE_MUTEX_OS2,
5155
+** a single-threaded application. ^The SQLITE_MUTEX_OS2,
52865156
** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
52875157
** are appropriate for use on OS/2, Unix, and Windows.
52885158
**
5289
-** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5159
+** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
52905160
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
52915161
** implementation is included with the library. In this case the
52925162
** application must supply a custom mutex implementation using the
52935163
** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
52945164
** before calling sqlite3_initialize() or any other public sqlite3_
5295
-** function that calls sqlite3_initialize().
5165
+** function that calls sqlite3_initialize().)^
52965166
**
5297
-** {H17011} The sqlite3_mutex_alloc() routine allocates a new
5298
-** mutex and returns a pointer to it. {H17012} If it returns NULL
5299
-** that means that a mutex could not be allocated. {H17013} SQLite
5300
-** will unwind its stack and return an error. {H17014} The argument
5167
+** ^The sqlite3_mutex_alloc() routine allocates a new
5168
+** mutex and returns a pointer to it. ^If it returns NULL
5169
+** that means that a mutex could not be allocated. ^SQLite
5170
+** will unwind its stack and return an error. ^(The argument
53015171
** to sqlite3_mutex_alloc() is one of these integer constants:
53025172
**
53035173
** <ul>
53045174
** <li> SQLITE_MUTEX_FAST
53055175
** <li> SQLITE_MUTEX_RECURSIVE
@@ -5307,68 +5177,70 @@
53075177
** <li> SQLITE_MUTEX_STATIC_MEM
53085178
** <li> SQLITE_MUTEX_STATIC_MEM2
53095179
** <li> SQLITE_MUTEX_STATIC_PRNG
53105180
** <li> SQLITE_MUTEX_STATIC_LRU
53115181
** <li> SQLITE_MUTEX_STATIC_LRU2
5312
-** </ul>
5182
+** </ul>)^
53135183
**
5314
-** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
5315
-** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
5316
-** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
5184
+** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
5185
+** cause sqlite3_mutex_alloc() to create
5186
+** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
5187
+** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
53175188
** The mutex implementation does not need to make a distinction
53185189
** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5319
-** not want to. {H17016} But SQLite will only request a recursive mutex in
5320
-** cases where it really needs one. {END} If a faster non-recursive mutex
5190
+** not want to. ^SQLite will only request a recursive mutex in
5191
+** cases where it really needs one. ^If a faster non-recursive mutex
53215192
** implementation is available on the host platform, the mutex subsystem
53225193
** might return such a mutex in response to SQLITE_MUTEX_FAST.
53235194
**
5324
-** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
5325
-** a pointer to a static preexisting mutex. {END} Six static mutexes are
5195
+** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
5196
+** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
5197
+** a pointer to a static preexisting mutex. ^Six static mutexes are
53265198
** used by the current version of SQLite. Future versions of SQLite
53275199
** may add additional static mutexes. Static mutexes are for internal
53285200
** use by SQLite only. Applications that use SQLite mutexes should
53295201
** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
53305202
** SQLITE_MUTEX_RECURSIVE.
53315203
**
5332
-** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
5204
+** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
53335205
** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
5334
-** returns a different mutex on every call. {H17034} But for the static
5206
+** returns a different mutex on every call. ^But for the static
53355207
** mutex types, the same mutex is returned on every call that has
53365208
** the same type number.
53375209
**
5338
-** {H17019} The sqlite3_mutex_free() routine deallocates a previously
5339
-** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
5340
-** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
5341
-** use when they are deallocated. {A17022} Attempting to deallocate a static
5342
-** mutex results in undefined behavior. {H17023} SQLite never deallocates
5343
-** a static mutex. {END}
5210
+** ^The sqlite3_mutex_free() routine deallocates a previously
5211
+** allocated dynamic mutex. ^SQLite is careful to deallocate every
5212
+** dynamic mutex that it allocates. The dynamic mutexes must not be in
5213
+** use when they are deallocated. Attempting to deallocate a static
5214
+** mutex results in undefined behavior. ^SQLite never deallocates
5215
+** a static mutex.
53445216
**
5345
-** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
5346
-** to enter a mutex. {H17024} If another thread is already within the mutex,
5217
+** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
5218
+** to enter a mutex. ^If another thread is already within the mutex,
53475219
** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
5348
-** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK]
5349
-** upon successful entry. {H17026} Mutexes created using
5220
+** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
5221
+** upon successful entry. ^(Mutexes created using
53505222
** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
5351
-** {H17027} In such cases the,
5223
+** In such cases the,
53525224
** mutex must be exited an equal number of times before another thread
5353
-** can enter. {A17028} If the same thread tries to enter any other
5225
+** can enter.)^ ^(If the same thread tries to enter any other
53545226
** kind of mutex more than once, the behavior is undefined.
5355
-** {H17029} SQLite will never exhibit
5356
-** such behavior in its own use of mutexes.
5227
+** SQLite will never exhibit
5228
+** such behavior in its own use of mutexes.)^
53575229
**
5358
-** Some systems (for example, Windows 95) do not support the operation
5230
+** ^(Some systems (for example, Windows 95) do not support the operation
53595231
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
5360
-** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses
5361
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
5232
+** will always return SQLITE_BUSY. The SQLite core only ever uses
5233
+** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
53625234
**
5363
-** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
5364
-** previously entered by the same thread. {A17032} The behavior
5235
+** ^The sqlite3_mutex_leave() routine exits a mutex that was
5236
+** previously entered by the same thread. ^(The behavior
53655237
** is undefined if the mutex is not currently entered by the
5366
-** calling thread or is not currently allocated. {H17033} SQLite will
5367
-** never do either. {END}
5238
+** calling thread or is not currently allocated. SQLite will
5239
+** never do either.)^
53685240
**
5369
-** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
5241
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
53705242
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
53715243
** behave as no-ops.
53725244
**
53735245
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
53745246
*/
@@ -5377,11 +5249,11 @@
53775249
SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
53785250
SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
53795251
SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
53805252
53815253
/*
5382
-** CAPI3REF: Mutex Methods Object {H17120} <S20130>
5254
+** CAPI3REF: Mutex Methods Object
53835255
** EXPERIMENTAL
53845256
**
53855257
** An instance of this structure defines the low-level routines
53865258
** used to allocate and use mutexes.
53875259
**
@@ -5393,23 +5265,23 @@
53935265
** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
53945266
** Additionally, an instance of this structure can be used as an
53955267
** output variable when querying the system for the current mutex
53965268
** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
53975269
**
5398
-** The xMutexInit method defined by this structure is invoked as
5270
+** ^The xMutexInit method defined by this structure is invoked as
53995271
** part of system initialization by the sqlite3_initialize() function.
5400
-** {H17001} The xMutexInit routine shall be called by SQLite once for each
5272
+** ^The xMutexInit routine is calle by SQLite exactly once for each
54015273
** effective call to [sqlite3_initialize()].
54025274
**
5403
-** The xMutexEnd method defined by this structure is invoked as
5275
+** ^The xMutexEnd method defined by this structure is invoked as
54045276
** part of system shutdown by the sqlite3_shutdown() function. The
54055277
** implementation of this method is expected to release all outstanding
54065278
** resources obtained by the mutex methods implementation, especially
5407
-** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
5408
-** interface shall be invoked once for each call to [sqlite3_shutdown()].
5279
+** those obtained by the xMutexInit method. ^The xMutexEnd()
5280
+** interface is invoked exactly once for each call to [sqlite3_shutdown()].
54095281
**
5410
-** The remaining seven methods defined by this structure (xMutexAlloc,
5282
+** ^(The remaining seven methods defined by this structure (xMutexAlloc,
54115283
** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
54125284
** xMutexNotheld) implement the following interfaces (respectively):
54135285
**
54145286
** <ul>
54155287
** <li> [sqlite3_mutex_alloc()] </li>
@@ -5417,31 +5289,31 @@
54175289
** <li> [sqlite3_mutex_enter()] </li>
54185290
** <li> [sqlite3_mutex_try()] </li>
54195291
** <li> [sqlite3_mutex_leave()] </li>
54205292
** <li> [sqlite3_mutex_held()] </li>
54215293
** <li> [sqlite3_mutex_notheld()] </li>
5422
-** </ul>
5294
+** </ul>)^
54235295
**
54245296
** The only difference is that the public sqlite3_XXX functions enumerated
54255297
** above silently ignore any invocations that pass a NULL pointer instead
54265298
** of a valid mutex handle. The implementations of the methods defined
54275299
** by this structure are not required to handle this case, the results
54285300
** of passing a NULL pointer instead of a valid mutex handle are undefined
54295301
** (i.e. it is acceptable to provide an implementation that segfaults if
54305302
** it is passed a NULL pointer).
54315303
**
5432
-** The xMutexInit() method must be threadsafe. It must be harmless to
5304
+** The xMutexInit() method must be threadsafe. ^It must be harmless to
54335305
** invoke xMutexInit() mutiple times within the same process and without
54345306
** intervening calls to xMutexEnd(). Second and subsequent calls to
54355307
** xMutexInit() must be no-ops.
54365308
**
5437
-** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
5438
-** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
5439
-** allocation for a static mutex. However xMutexAlloc() may use SQLite
5309
+** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
5310
+** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
5311
+** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
54405312
** memory allocation for a fast or recursive mutex.
54415313
**
5442
-** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
5314
+** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
54435315
** called, but only if the prior call to xMutexInit returned SQLITE_OK.
54445316
** If xMutexInit fails in any way, it is expected to clean up after itself
54455317
** prior to returning.
54465318
*/
54475319
typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -5456,43 +5328,45 @@
54565328
int (*xMutexHeld)(sqlite3_mutex *);
54575329
int (*xMutexNotheld)(sqlite3_mutex *);
54585330
};
54595331
54605332
/*
5461
-** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
5333
+** CAPI3REF: Mutex Verification Routines
54625334
**
54635335
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
5464
-** are intended for use inside assert() statements. {H17081} The SQLite core
5336
+** are intended for use inside assert() statements. ^The SQLite core
54655337
** never uses these routines except inside an assert() and applications
5466
-** are advised to follow the lead of the core. {H17082} The core only
5338
+** are advised to follow the lead of the core. ^The SQLite core only
54675339
** provides implementations for these routines when it is compiled
5468
-** with the SQLITE_DEBUG flag. {A17087} External mutex implementations
5340
+** with the SQLITE_DEBUG flag. ^External mutex implementations
54695341
** are only required to provide these routines if SQLITE_DEBUG is
54705342
** defined and if NDEBUG is not defined.
54715343
**
5472
-** {H17083} These routines should return true if the mutex in their argument
5344
+** ^These routines should return true if the mutex in their argument
54735345
** is held or not held, respectively, by the calling thread.
54745346
**
5475
-** {X17084} The implementation is not required to provided versions of these
5347
+** ^The implementation is not required to provided versions of these
54765348
** routines that actually work. If the implementation does not provide working
54775349
** versions of these routines, it should at least provide stubs that always
54785350
** return true so that one does not get spurious assertion failures.
54795351
**
5480
-** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
5481
-** the routine should return 1. {END} This seems counter-intuitive since
5352
+** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
5353
+** the routine should return 1. This seems counter-intuitive since
54825354
** clearly the mutex cannot be held if it does not exist. But the
54835355
** the reason the mutex does not exist is because the build is not
54845356
** using mutexes. And we do not want the assert() containing the
54855357
** call to sqlite3_mutex_held() to fail, so a non-zero return is
5486
-** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld()
5358
+** the appropriate thing to do. ^The sqlite3_mutex_notheld()
54875359
** interface should also return 1 when given a NULL pointer.
54885360
*/
5361
+#ifndef NDEBUG
54895362
SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
54905363
SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
5364
+#endif
54915365
54925366
/*
5493
-** CAPI3REF: Mutex Types {H17001} <H17000>
5367
+** CAPI3REF: Mutex Types
54945368
**
54955369
** The [sqlite3_mutex_alloc()] interface takes a single argument
54965370
** which is one of these integer constants.
54975371
**
54985372
** The set of static mutexes may change from one SQLite release to the
@@ -5508,52 +5382,54 @@
55085382
#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
55095383
#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
55105384
#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
55115385
55125386
/*
5513
-** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
5387
+** CAPI3REF: Retrieve the mutex for a database connection
55145388
**
5515
-** This interface returns a pointer the [sqlite3_mutex] object that
5389
+** ^This interface returns a pointer the [sqlite3_mutex] object that
55165390
** serializes access to the [database connection] given in the argument
55175391
** when the [threading mode] is Serialized.
5518
-** If the [threading mode] is Single-thread or Multi-thread then this
5392
+** ^If the [threading mode] is Single-thread or Multi-thread then this
55195393
** routine returns a NULL pointer.
55205394
*/
55215395
SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
55225396
55235397
/*
5524
-** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
5398
+** CAPI3REF: Low-Level Control Of Database Files
55255399
**
5526
-** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
5400
+** ^The [sqlite3_file_control()] interface makes a direct call to the
55275401
** xFileControl method for the [sqlite3_io_methods] object associated
5528
-** with a particular database identified by the second argument. {H11302} The
5529
-** name of the database is the name assigned to the database by the
5530
-** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
5531
-** database. {H11303} To control the main database file, use the name "main"
5532
-** or a NULL pointer. {H11304} The third and fourth parameters to this routine
5402
+** with a particular database identified by the second argument. ^The
5403
+** name of the database "main" for the main database or "temp" for the
5404
+** TEMP database, or the name that appears after the AS keyword for
5405
+** databases that are added using the [ATTACH] SQL command.
5406
+** ^A NULL pointer can be used in place of "main" to refer to the
5407
+** main database file.
5408
+** ^The third and fourth parameters to this routine
55335409
** are passed directly through to the second and third parameters of
5534
-** the xFileControl method. {H11305} The return value of the xFileControl
5410
+** the xFileControl method. ^The return value of the xFileControl
55355411
** method becomes the return value of this routine.
55365412
**
5537
-** {H11306} If the second parameter (zDbName) does not match the name of any
5538
-** open database file, then SQLITE_ERROR is returned. {H11307} This error
5413
+** ^If the second parameter (zDbName) does not match the name of any
5414
+** open database file, then SQLITE_ERROR is returned. ^This error
55395415
** code is not remembered and will not be recalled by [sqlite3_errcode()]
5540
-** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
5541
-** also return SQLITE_ERROR. {A11309} There is no way to distinguish between
5416
+** or [sqlite3_errmsg()]. The underlying xFileControl method might
5417
+** also return SQLITE_ERROR. There is no way to distinguish between
55425418
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
5543
-** xFileControl method. {END}
5419
+** xFileControl method.
55445420
**
55455421
** See also: [SQLITE_FCNTL_LOCKSTATE]
55465422
*/
55475423
SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
55485424
55495425
/*
5550
-** CAPI3REF: Testing Interface {H11400} <S30800>
5426
+** CAPI3REF: Testing Interface
55515427
**
5552
-** The sqlite3_test_control() interface is used to read out internal
5428
+** ^The sqlite3_test_control() interface is used to read out internal
55535429
** state of SQLite and to inject faults into SQLite for testing
5554
-** purposes. The first parameter is an operation code that determines
5430
+** purposes. ^The first parameter is an operation code that determines
55555431
** the number, meaning, and operation of all subsequent parameters.
55565432
**
55575433
** This interface is not for use by applications. It exists solely
55585434
** for verifying the correct operation of the SQLite library. Depending
55595435
** on how the SQLite library is compiled, this interface might not exist.
@@ -5564,20 +5440,21 @@
55645440
** operate consistently from one release to the next.
55655441
*/
55665442
SQLITE_API int sqlite3_test_control(int op, ...);
55675443
55685444
/*
5569
-** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
5445
+** CAPI3REF: Testing Interface Operation Codes
55705446
**
55715447
** These constants are the valid operation code parameters used
55725448
** as the first argument to [sqlite3_test_control()].
55735449
**
55745450
** These parameters and their meanings are subject to change
55755451
** without notice. These values are for testing purposes only.
55765452
** Applications should not use any of these parameters or the
55775453
** [sqlite3_test_control()] interface.
55785454
*/
5455
+#define SQLITE_TESTCTRL_FIRST 5
55795456
#define SQLITE_TESTCTRL_PRNG_SAVE 5
55805457
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
55815458
#define SQLITE_TESTCTRL_PRNG_RESET 7
55825459
#define SQLITE_TESTCTRL_BITVEC_TEST 8
55835460
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5584,31 +5461,34 @@
55845461
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
55855462
#define SQLITE_TESTCTRL_PENDING_BYTE 11
55865463
#define SQLITE_TESTCTRL_ASSERT 12
55875464
#define SQLITE_TESTCTRL_ALWAYS 13
55885465
#define SQLITE_TESTCTRL_RESERVE 14
5466
+#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
5467
+#define SQLITE_TESTCTRL_ISKEYWORD 16
5468
+#define SQLITE_TESTCTRL_LAST 16
55895469
55905470
/*
5591
-** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
5471
+** CAPI3REF: SQLite Runtime Status
55925472
** EXPERIMENTAL
55935473
**
5594
-** This interface is used to retrieve runtime status information
5474
+** ^This interface is used to retrieve runtime status information
55955475
** about the preformance of SQLite, and optionally to reset various
5596
-** highwater marks. The first argument is an integer code for
5597
-** the specific parameter to measure. Recognized integer codes
5598
-** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].
5599
-** The current value of the parameter is returned into *pCurrent.
5600
-** The highest recorded value is returned in *pHighwater. If the
5476
+** highwater marks. ^The first argument is an integer code for
5477
+** the specific parameter to measure. ^(Recognized integer codes
5478
+** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
5479
+** ^The current value of the parameter is returned into *pCurrent.
5480
+** ^The highest recorded value is returned in *pHighwater. ^If the
56015481
** resetFlag is true, then the highest record value is reset after
5602
-** *pHighwater is written. Some parameters do not record the highest
5482
+** *pHighwater is written. ^(Some parameters do not record the highest
56035483
** value. For those parameters
5604
-** nothing is written into *pHighwater and the resetFlag is ignored.
5605
-** Other parameters record only the highwater mark and not the current
5606
-** value. For these latter parameters nothing is written into *pCurrent.
5484
+** nothing is written into *pHighwater and the resetFlag is ignored.)^
5485
+** ^(Other parameters record only the highwater mark and not the current
5486
+** value. For these latter parameters nothing is written into *pCurrent.)^
56075487
**
5608
-** This routine returns SQLITE_OK on success and a non-zero
5609
-** [error code] on failure.
5488
+** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
5489
+** non-zero [error code] on failure.
56105490
**
56115491
** This routine is threadsafe but is not atomic. This routine can be
56125492
** called while other threads are running the same or different SQLite
56135493
** interfaces. However the values returned in *pCurrent and
56145494
** *pHighwater reflect the status of SQLite at different points in time
@@ -5619,82 +5499,82 @@
56195499
*/
56205500
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
56215501
56225502
56235503
/*
5624
-** CAPI3REF: Status Parameters {H17250} <H17200>
5504
+** CAPI3REF: Status Parameters
56255505
** EXPERIMENTAL
56265506
**
56275507
** These integer constants designate various run-time status parameters
56285508
** that can be returned by [sqlite3_status()].
56295509
**
56305510
** <dl>
5631
-** <dt>SQLITE_STATUS_MEMORY_USED</dt>
5511
+** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
56325512
** <dd>This parameter is the current amount of memory checked out
56335513
** using [sqlite3_malloc()], either directly or indirectly. The
56345514
** figure includes calls made to [sqlite3_malloc()] by the application
56355515
** and internal memory usage by the SQLite library. Scratch memory
56365516
** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
56375517
** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
56385518
** this parameter. The amount returned is the sum of the allocation
5639
-** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
5519
+** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
56405520
**
5641
-** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5521
+** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
56425522
** <dd>This parameter records the largest memory allocation request
56435523
** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
56445524
** internal equivalents). Only the value returned in the
56455525
** *pHighwater parameter to [sqlite3_status()] is of interest.
5646
-** The value written into the *pCurrent parameter is undefined.</dd>
5526
+** The value written into the *pCurrent parameter is undefined.</dd>)^
56475527
**
5648
-** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5528
+** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
56495529
** <dd>This parameter returns the number of pages used out of the
56505530
** [pagecache memory allocator] that was configured using
56515531
** [SQLITE_CONFIG_PAGECACHE]. The
5652
-** value returned is in pages, not in bytes.</dd>
5532
+** value returned is in pages, not in bytes.</dd>)^
56535533
**
5654
-** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5534
+** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
56555535
** <dd>This parameter returns the number of bytes of page cache
56565536
** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
56575537
** buffer and where forced to overflow to [sqlite3_malloc()]. The
56585538
** returned value includes allocations that overflowed because they
56595539
** where too large (they were larger than the "sz" parameter to
56605540
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5661
-** no space was left in the page cache.</dd>
5541
+** no space was left in the page cache.</dd>)^
56625542
**
5663
-** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5543
+** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
56645544
** <dd>This parameter records the largest memory allocation request
56655545
** handed to [pagecache memory allocator]. Only the value returned in the
56665546
** *pHighwater parameter to [sqlite3_status()] is of interest.
5667
-** The value written into the *pCurrent parameter is undefined.</dd>
5547
+** The value written into the *pCurrent parameter is undefined.</dd>)^
56685548
**
5669
-** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
5549
+** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
56705550
** <dd>This parameter returns the number of allocations used out of the
56715551
** [scratch memory allocator] configured using
56725552
** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
56735553
** in bytes. Since a single thread may only have one scratch allocation
56745554
** outstanding at time, this parameter also reports the number of threads
5675
-** using scratch memory at the same time.</dd>
5555
+** using scratch memory at the same time.</dd>)^
56765556
**
5677
-** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5557
+** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
56785558
** <dd>This parameter returns the number of bytes of scratch memory
56795559
** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
56805560
** buffer and where forced to overflow to [sqlite3_malloc()]. The values
56815561
** returned include overflows because the requested allocation was too
56825562
** larger (that is, because the requested allocation was larger than the
56835563
** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
56845564
** slots were available.
5685
-** </dd>
5565
+** </dd>)^
56865566
**
5687
-** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5567
+** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
56885568
** <dd>This parameter records the largest memory allocation request
56895569
** handed to [scratch memory allocator]. Only the value returned in the
56905570
** *pHighwater parameter to [sqlite3_status()] is of interest.
5691
-** The value written into the *pCurrent parameter is undefined.</dd>
5571
+** The value written into the *pCurrent parameter is undefined.</dd>)^
56925572
**
5693
-** <dt>SQLITE_STATUS_PARSER_STACK</dt>
5573
+** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
56945574
** <dd>This parameter records the deepest parser stack. It is only
5695
-** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
5575
+** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
56965576
** </dl>
56975577
**
56985578
** New status parameters may be added from time to time.
56995579
*/
57005580
#define SQLITE_STATUS_MEMORY_USED 0
@@ -5706,31 +5586,31 @@
57065586
#define SQLITE_STATUS_PARSER_STACK 6
57075587
#define SQLITE_STATUS_PAGECACHE_SIZE 7
57085588
#define SQLITE_STATUS_SCRATCH_SIZE 8
57095589
57105590
/*
5711
-** CAPI3REF: Database Connection Status {H17500} <S60200>
5591
+** CAPI3REF: Database Connection Status
57125592
** EXPERIMENTAL
57135593
**
5714
-** This interface is used to retrieve runtime status information
5715
-** about a single [database connection]. The first argument is the
5716
-** database connection object to be interrogated. The second argument
5717
-** is the parameter to interrogate. Currently, the only allowed value
5594
+** ^This interface is used to retrieve runtime status information
5595
+** about a single [database connection]. ^The first argument is the
5596
+** database connection object to be interrogated. ^The second argument
5597
+** is the parameter to interrogate. ^Currently, the only allowed value
57185598
** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
57195599
** Additional options will likely appear in future releases of SQLite.
57205600
**
5721
-** The current value of the requested parameter is written into *pCur
5722
-** and the highest instantaneous value is written into *pHiwtr. If
5601
+** ^The current value of the requested parameter is written into *pCur
5602
+** and the highest instantaneous value is written into *pHiwtr. ^If
57235603
** the resetFlg is true, then the highest instantaneous value is
57245604
** reset back down to the current value.
57255605
**
57265606
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
57275607
*/
57285608
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
57295609
57305610
/*
5731
-** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
5611
+** CAPI3REF: Status Parameters for database connections
57325612
** EXPERIMENTAL
57335613
**
57345614
** These constants are the available integer "verbs" that can be passed as
57355615
** the second argument to the [sqlite3_db_status()] interface.
57365616
**
@@ -5739,61 +5619,61 @@
57395619
** [sqlite3_db_status()] to make sure that the call worked.
57405620
** The [sqlite3_db_status()] interface will return a non-zero error code
57415621
** if a discontinued or unsupported verb is invoked.
57425622
**
57435623
** <dl>
5744
-** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5624
+** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
57455625
** <dd>This parameter returns the number of lookaside memory slots currently
5746
-** checked out.</dd>
5626
+** checked out.</dd>)^
57475627
** </dl>
57485628
*/
57495629
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
57505630
57515631
57525632
/*
5753
-** CAPI3REF: Prepared Statement Status {H17550} <S60200>
5633
+** CAPI3REF: Prepared Statement Status
57545634
** EXPERIMENTAL
57555635
**
5756
-** Each prepared statement maintains various
5636
+** ^(Each prepared statement maintains various
57575637
** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5758
-** of times it has performed specific operations. These counters can
5638
+** of times it has performed specific operations.)^ These counters can
57595639
** be used to monitor the performance characteristics of the prepared
57605640
** statements. For example, if the number of table steps greatly exceeds
57615641
** the number of table searches or result rows, that would tend to indicate
57625642
** that the prepared statement is using a full table scan rather than
57635643
** an index.
57645644
**
5765
-** This interface is used to retrieve and reset counter values from
5645
+** ^(This interface is used to retrieve and reset counter values from
57665646
** a [prepared statement]. The first argument is the prepared statement
57675647
** object to be interrogated. The second argument
57685648
** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5769
-** to be interrogated.
5770
-** The current value of the requested counter is returned.
5771
-** If the resetFlg is true, then the counter is reset to zero after this
5649
+** to be interrogated.)^
5650
+** ^The current value of the requested counter is returned.
5651
+** ^If the resetFlg is true, then the counter is reset to zero after this
57725652
** interface call returns.
57735653
**
57745654
** See also: [sqlite3_status()] and [sqlite3_db_status()].
57755655
*/
57765656
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
57775657
57785658
/*
5779
-** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
5659
+** CAPI3REF: Status Parameters for prepared statements
57805660
** EXPERIMENTAL
57815661
**
57825662
** These preprocessor macros define integer codes that name counter
57835663
** values associated with the [sqlite3_stmt_status()] interface.
57845664
** The meanings of the various counters are as follows:
57855665
**
57865666
** <dl>
57875667
** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5788
-** <dd>This is the number of times that SQLite has stepped forward in
5668
+** <dd>^This is the number of times that SQLite has stepped forward in
57895669
** a table as part of a full table scan. Large numbers for this counter
57905670
** may indicate opportunities for performance improvement through
57915671
** careful use of indices.</dd>
57925672
**
57935673
** <dt>SQLITE_STMTSTATUS_SORT</dt>
5794
-** <dd>This is the number of sort operations that have occurred.
5674
+** <dd>^This is the number of sort operations that have occurred.
57955675
** A non-zero value in this counter may indicate an opportunity to
57965676
** improvement performance through careful use of indices.</dd>
57975677
**
57985678
** </dl>
57995679
*/
@@ -5817,84 +5697,84 @@
58175697
/*
58185698
** CAPI3REF: Application Defined Page Cache.
58195699
** KEYWORDS: {page cache}
58205700
** EXPERIMENTAL
58215701
**
5822
-** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5702
+** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
58235703
** register an alternative page cache implementation by passing in an
5824
-** instance of the sqlite3_pcache_methods structure. The majority of the
5704
+** instance of the sqlite3_pcache_methods structure.)^ The majority of the
58255705
** heap memory used by SQLite is used by the page cache to cache data read
58265706
** from, or ready to be written to, the database file. By implementing a
58275707
** custom page cache using this API, an application can control more
58285708
** precisely the amount of memory consumed by SQLite, the way in which
58295709
** that memory is allocated and released, and the policies used to
58305710
** determine exactly which parts of a database file are cached and for
58315711
** how long.
58325712
**
5833
-** The contents of the sqlite3_pcache_methods structure are copied to an
5713
+** ^(The contents of the sqlite3_pcache_methods structure are copied to an
58345714
** internal buffer by SQLite within the call to [sqlite3_config]. Hence
58355715
** the application may discard the parameter after the call to
5836
-** [sqlite3_config()] returns.
5837
-**
5838
-** The xInit() method is called once for each call to [sqlite3_initialize()]
5839
-** (usually only once during the lifetime of the process). It is passed
5840
-** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
5841
-** up global structures and mutexes required by the custom page cache
5842
-** implementation.
5843
-**
5844
-** The xShutdown() method is called from within [sqlite3_shutdown()],
5716
+** [sqlite3_config()] returns.)^
5717
+**
5718
+** ^The xInit() method is called once for each call to [sqlite3_initialize()]
5719
+** (usually only once during the lifetime of the process). ^(The xInit()
5720
+** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
5721
+** ^The xInit() method can set up up global structures and/or any mutexes
5722
+** required by the custom page cache implementation.
5723
+**
5724
+** ^The xShutdown() method is called from within [sqlite3_shutdown()],
58455725
** if the application invokes this API. It can be used to clean up
58465726
** any outstanding resources before process shutdown, if required.
58475727
**
5848
-** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5849
-** the xInit method, so the xInit method need not be threadsafe. The
5728
+** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5729
+** the xInit method, so the xInit method need not be threadsafe. ^The
58505730
** xShutdown method is only called from [sqlite3_shutdown()] so it does
58515731
** not need to be threadsafe either. All other methods must be threadsafe
58525732
** in multithreaded applications.
58535733
**
5854
-** SQLite will never invoke xInit() more than once without an intervening
5734
+** ^SQLite will never invoke xInit() more than once without an intervening
58555735
** call to xShutdown().
58565736
**
5857
-** The xCreate() method is used to construct a new cache instance. SQLite
5737
+** ^The xCreate() method is used to construct a new cache instance. SQLite
58585738
** will typically create one cache instance for each open database file,
5859
-** though this is not guaranteed. The
5739
+** though this is not guaranteed. ^The
58605740
** first parameter, szPage, is the size in bytes of the pages that must
5861
-** be allocated by the cache. szPage will not be a power of two. szPage
5741
+** be allocated by the cache. ^szPage will not be a power of two. ^szPage
58625742
** will the page size of the database file that is to be cached plus an
5863
-** increment (here called "R") of about 100 or 200. SQLite will use the
5743
+** increment (here called "R") of about 100 or 200. ^SQLite will use the
58645744
** extra R bytes on each page to store metadata about the underlying
58655745
** database page on disk. The value of R depends
58665746
** on the SQLite version, the target platform, and how SQLite was compiled.
5867
-** R is constant for a particular build of SQLite. The second argument to
5747
+** ^R is constant for a particular build of SQLite. ^The second argument to
58685748
** xCreate(), bPurgeable, is true if the cache being created will
58695749
** be used to cache database pages of a file stored on disk, or
5870
-** false if it is used for an in-memory database. The cache implementation
5750
+** false if it is used for an in-memory database. ^The cache implementation
58715751
** does not have to do anything special based with the value of bPurgeable;
5872
-** it is purely advisory. On a cache where bPurgeable is false, SQLite will
5752
+** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
58735753
** never invoke xUnpin() except to deliberately delete a page.
5874
-** In other words, a cache created with bPurgeable set to false will
5754
+** ^In other words, a cache created with bPurgeable set to false will
58755755
** never contain any unpinned pages.
58765756
**
5877
-** The xCachesize() method may be called at any time by SQLite to set the
5757
+** ^(The xCachesize() method may be called at any time by SQLite to set the
58785758
** suggested maximum cache-size (number of pages stored by) the cache
58795759
** instance passed as the first argument. This is the value configured using
5880
-** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter,
5881
-** the implementation is not required to do anything with this
5760
+** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable
5761
+** parameter, the implementation is not required to do anything with this
58825762
** value; it is advisory only.
58835763
**
5884
-** The xPagecount() method should return the number of pages currently
5764
+** ^The xPagecount() method should return the number of pages currently
58855765
** stored in the cache.
58865766
**
5887
-** The xFetch() method is used to fetch a page and return a pointer to it.
5888
-** A 'page', in this context, is a buffer of szPage bytes aligned at an
5889
-** 8-byte boundary. The page to be fetched is determined by the key. The
5767
+** ^The xFetch() method is used to fetch a page and return a pointer to it.
5768
+** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
5769
+** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
58905770
** mimimum key value is 1. After it has been retrieved using xFetch, the page
58915771
** is considered to be "pinned".
58925772
**
5893
-** If the requested page is already in the page cache, then the page cache
5773
+** ^If the requested page is already in the page cache, then the page cache
58945774
** implementation must return a pointer to the page buffer with its content
5895
-** intact. If the requested page is not already in the cache, then the
5775
+** intact. ^(If the requested page is not already in the cache, then the
58965776
** behavior of the cache implementation is determined by the value of the
58975777
** createFlag parameter passed to xFetch, according to the following table:
58985778
**
58995779
** <table border=1 width=85% align=center>
59005780
** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5901,45 +5781,45 @@
59015781
** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
59025782
** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
59035783
** Otherwise return NULL.
59045784
** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
59055785
** NULL if allocating a new page is effectively impossible.
5906
-** </table>
5786
+** </table>)^
59075787
**
59085788
** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
59095789
** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
59105790
** attempt to unpin one or more cache pages by spilling the content of
59115791
** pinned pages to disk and synching the operating system disk cache. After
59125792
** attempting to unpin pages, the xFetch() method will be invoked again with
59135793
** a createFlag of 2.
59145794
**
5915
-** xUnpin() is called by SQLite with a pointer to a currently pinned page
5916
-** as its second argument. If the third parameter, discard, is non-zero,
5795
+** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
5796
+** as its second argument. ^(If the third parameter, discard, is non-zero,
59175797
** then the page should be evicted from the cache. In this case SQLite
59185798
** assumes that the next time the page is retrieved from the cache using
5919
-** the xFetch() method, it will be zeroed. If the discard parameter is
5920
-** zero, then the page is considered to be unpinned. The cache implementation
5799
+** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
5800
+** zero, then the page is considered to be unpinned. ^The cache implementation
59215801
** may choose to evict unpinned pages at any time.
59225802
**
5923
-** The cache is not required to perform any reference counting. A single
5803
+** ^(The cache is not required to perform any reference counting. A single
59245804
** call to xUnpin() unpins the page regardless of the number of prior calls
5925
-** to xFetch().
5805
+** to xFetch().)^
59265806
**
5927
-** The xRekey() method is used to change the key value associated with the
5928
-** page passed as the second argument from oldKey to newKey. If the cache
5807
+** ^The xRekey() method is used to change the key value associated with the
5808
+** page passed as the second argument from oldKey to newKey. ^If the cache
59295809
** previously contains an entry associated with newKey, it should be
5930
-** discarded. Any prior cache entry associated with newKey is guaranteed not
5810
+** discarded. ^Any prior cache entry associated with newKey is guaranteed not
59315811
** to be pinned.
59325812
**
5933
-** When SQLite calls the xTruncate() method, the cache must discard all
5813
+** ^When SQLite calls the xTruncate() method, the cache must discard all
59345814
** existing cache entries with page numbers (keys) greater than or equal
5935
-** to the value of the iLimit parameter passed to xTruncate(). If any
5815
+** to the value of the iLimit parameter passed to xTruncate(). ^If any
59365816
** of these pages are pinned, they are implicitly unpinned, meaning that
59375817
** they can be safely discarded.
59385818
**
5939
-** The xDestroy() method is used to delete a cache allocated by xCreate().
5940
-** All resources associated with the specified cache should be freed. After
5819
+** ^The xDestroy() method is used to delete a cache allocated by xCreate().
5820
+** All resources associated with the specified cache should be freed. ^After
59415821
** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
59425822
** handle invalid, and will not use it with any other sqlite3_pcache_methods
59435823
** functions.
59445824
*/
59455825
typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5960,11 +5840,11 @@
59605840
/*
59615841
** CAPI3REF: Online Backup Object
59625842
** EXPERIMENTAL
59635843
**
59645844
** The sqlite3_backup object records state information about an ongoing
5965
-** online backup operation. The sqlite3_backup object is created by
5845
+** online backup operation. ^The sqlite3_backup object is created by
59665846
** a call to [sqlite3_backup_init()] and is destroyed by a call to
59675847
** [sqlite3_backup_finish()].
59685848
**
59695849
** See Also: [Using the SQLite Online Backup API]
59705850
*/
@@ -5972,168 +5852,173 @@
59725852
59735853
/*
59745854
** CAPI3REF: Online Backup API.
59755855
** EXPERIMENTAL
59765856
**
5977
-** This API is used to overwrite the contents of one database with that
5978
-** of another. It is useful either for creating backups of databases or
5857
+** The backup API copies the content of one database into another.
5858
+** It is useful either for creating backups of databases or
59795859
** for copying in-memory databases to or from persistent files.
59805860
**
59815861
** See Also: [Using the SQLite Online Backup API]
59825862
**
5983
-** Exclusive access is required to the destination database for the
5984
-** duration of the operation. However the source database is only
5985
-** read-locked while it is actually being read, it is not locked
5986
-** continuously for the entire operation. Thus, the backup may be
5987
-** performed on a live database without preventing other users from
5988
-** writing to the database for an extended period of time.
5863
+** ^Exclusive access is required to the destination database for the
5864
+** duration of the operation. ^However the source database is only
5865
+** read-locked while it is actually being read; it is not locked
5866
+** continuously for the entire backup operation. ^Thus, the backup may be
5867
+** performed on a live source database without preventing other users from
5868
+** reading or writing to the source database while the backup is underway.
59895869
**
5990
-** To perform a backup operation:
5870
+** ^(To perform a backup operation:
59915871
** <ol>
59925872
** <li><b>sqlite3_backup_init()</b> is called once to initialize the
59935873
** backup,
59945874
** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
59955875
** the data between the two databases, and finally
59965876
** <li><b>sqlite3_backup_finish()</b> is called to release all resources
59975877
** associated with the backup operation.
5998
-** </ol>
5878
+** </ol>)^
59995879
** There should be exactly one call to sqlite3_backup_finish() for each
60005880
** successful call to sqlite3_backup_init().
60015881
**
60025882
** <b>sqlite3_backup_init()</b>
60035883
**
6004
-** The first two arguments passed to [sqlite3_backup_init()] are the database
6005
-** handle associated with the destination database and the database name
6006
-** used to attach the destination database to the handle. The database name
6007
-** is "main" for the main database, "temp" for the temporary database, or
6008
-** the name specified as part of the [ATTACH] statement if the destination is
6009
-** an attached database. The third and fourth arguments passed to
6010
-** sqlite3_backup_init() identify the [database connection]
6011
-** and database name used
6012
-** to access the source database. The values passed for the source and
6013
-** destination [database connection] parameters must not be the same.
5884
+** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
5885
+** [database connection] associated with the destination database
5886
+** and the database name, respectively.
5887
+** ^The database name is "main" for the main database, "temp" for the
5888
+** temporary database, or the name specified after the AS keyword in
5889
+** an [ATTACH] statement for an attached database.
5890
+** ^The S and M arguments passed to
5891
+** sqlite3_backup_init(D,N,S,M) identify the [database connection]
5892
+** and database name of the source database, respectively.
5893
+** ^The source and destination [database connections] (parameters S and D)
5894
+** must be different or else sqlite3_backup_init(D,N,S,M) will file with
5895
+** an error.
60145896
**
6015
-** If an error occurs within sqlite3_backup_init(), then NULL is returned
6016
-** and an error code and error message written into the [database connection]
6017
-** passed as the first argument. They may be retrieved using the
6018
-** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
6019
-** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
6020
-** returned. This pointer may be used with the sqlite3_backup_step() and
5897
+** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
5898
+** returned and an error code and error message are store3d in the
5899
+** destination [database connection] D.
5900
+** ^The error code and message for the failed call to sqlite3_backup_init()
5901
+** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
5902
+** [sqlite3_errmsg16()] functions.
5903
+** ^A successful call to sqlite3_backup_init() returns a pointer to an
5904
+** [sqlite3_backup] object.
5905
+** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
60215906
** sqlite3_backup_finish() functions to perform the specified backup
60225907
** operation.
60235908
**
60245909
** <b>sqlite3_backup_step()</b>
60255910
**
6026
-** Function [sqlite3_backup_step()] is used to copy up to nPage pages between
6027
-** the source and destination databases, where nPage is the value of the
6028
-** second parameter passed to sqlite3_backup_step(). If nPage is a negative
6029
-** value, all remaining source pages are copied. If the required pages are
6030
-** succesfully copied, but there are still more pages to copy before the
6031
-** backup is complete, it returns [SQLITE_OK]. If no error occured and there
6032
-** are no more pages to copy, then [SQLITE_DONE] is returned. If an error
6033
-** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
5911
+** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
5912
+** the source and destination databases specified by [sqlite3_backup] object B.
5913
+** ^If N is negative, all remaining source pages are copied.
5914
+** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
5915
+** are still more pages to be copied, then the function resturns [SQLITE_OK].
5916
+** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
5917
+** from source to destination, then it returns [SQLITE_DONE].
5918
+** ^If an error occurs while running sqlite3_backup_step(B,N),
5919
+** then an [error code] is returned. ^As well as [SQLITE_OK] and
60345920
** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
60355921
** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
60365922
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
60375923
**
6038
-** As well as the case where the destination database file was opened for
6039
-** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
5924
+** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
5925
+** database was opened read-only or if
60405926
** the destination is an in-memory database with a different page size
60415927
** from the source database.
60425928
**
6043
-** If sqlite3_backup_step() cannot obtain a required file-system lock, then
5929
+** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
60445930
** the [sqlite3_busy_handler | busy-handler function]
6045
-** is invoked (if one is specified). If the
5931
+** is invoked (if one is specified). ^If the
60465932
** busy-handler returns non-zero before the lock is available, then
6047
-** [SQLITE_BUSY] is returned to the caller. In this case the call to
6048
-** sqlite3_backup_step() can be retried later. If the source
5933
+** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
5934
+** sqlite3_backup_step() can be retried later. ^If the source
60495935
** [database connection]
60505936
** is being used to write to the source database when sqlite3_backup_step()
6051
-** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
6052
-** case the call to sqlite3_backup_step() can be retried later on. If
5937
+** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
5938
+** case the call to sqlite3_backup_step() can be retried later on. ^(If
60535939
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
60545940
** [SQLITE_READONLY] is returned, then
60555941
** there is no point in retrying the call to sqlite3_backup_step(). These
6056
-** errors are considered fatal. At this point the application must accept
5942
+** errors are considered fatal.)^ The application must accept
60575943
** that the backup operation has failed and pass the backup operation handle
60585944
** to the sqlite3_backup_finish() to release associated resources.
60595945
**
6060
-** Following the first call to sqlite3_backup_step(), an exclusive lock is
6061
-** obtained on the destination file. It is not released until either
5946
+** ^The first call to sqlite3_backup_step() obtains an exclusive lock
5947
+** on the destination file. ^The exclusive lock is not released until either
60625948
** sqlite3_backup_finish() is called or the backup operation is complete
6063
-** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time
6064
-** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
6065
-** the source database file. This lock is released before the
6066
-** sqlite3_backup_step() call returns. Because the source database is not
6067
-** locked between calls to sqlite3_backup_step(), it may be modified mid-way
6068
-** through the backup procedure. If the source database is modified by an
5949
+** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to
5950
+** sqlite3_backup_step() obtains a [shared lock] on the source database that
5951
+** lasts for the duration of the sqlite3_backup_step() call.
5952
+** ^Because the source database is not locked between calls to
5953
+** sqlite3_backup_step(), the source database may be modified mid-way
5954
+** through the backup process. ^If the source database is modified by an
60695955
** external process or via a database connection other than the one being
6070
-** used by the backup operation, then the backup will be transparently
6071
-** restarted by the next call to sqlite3_backup_step(). If the source
5956
+** used by the backup operation, then the backup will be automatically
5957
+** restarted by the next call to sqlite3_backup_step(). ^If the source
60725958
** database is modified by the using the same database connection as is used
6073
-** by the backup operation, then the backup database is transparently
5959
+** by the backup operation, then the backup database is automatically
60745960
** updated at the same time.
60755961
**
60765962
** <b>sqlite3_backup_finish()</b>
60775963
**
6078
-** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the
6079
-** application wishes to abandon the backup operation, the [sqlite3_backup]
6080
-** object should be passed to sqlite3_backup_finish(). This releases all
6081
-** resources associated with the backup operation. If sqlite3_backup_step()
6082
-** has not yet returned [SQLITE_DONE], then any active write-transaction on the
6083
-** destination database is rolled back. The [sqlite3_backup] object is invalid
5964
+** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5965
+** application wishes to abandon the backup operation, the application
5966
+** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
5967
+** ^The sqlite3_backup_finish() interfaces releases all
5968
+** resources associated with the [sqlite3_backup] object.
5969
+** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
5970
+** active write-transaction on the destination database is rolled back.
5971
+** The [sqlite3_backup] object is invalid
60845972
** and may not be used following a call to sqlite3_backup_finish().
60855973
**
6086
-** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
6087
-** occurred, regardless or whether or not sqlite3_backup_step() was called
6088
-** a sufficient number of times to complete the backup operation. Or, if
6089
-** an out-of-memory condition or IO error occured during a call to
6090
-** sqlite3_backup_step() then [SQLITE_NOMEM] or an
6091
-** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
6092
-** is returned. In this case the error code and an error message are
6093
-** written to the destination [database connection].
5974
+** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
5975
+** sqlite3_backup_step() errors occurred, regardless or whether or not
5976
+** sqlite3_backup_step() completed.
5977
+** ^If an out-of-memory condition or IO error occurred during any prior
5978
+** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
5979
+** sqlite3_backup_finish() returns the corresponding [error code].
60945980
**
6095
-** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
6096
-** not a permanent error and does not affect the return value of
5981
+** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
5982
+** is not a permanent error and does not affect the return value of
60975983
** sqlite3_backup_finish().
60985984
**
60995985
** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
61005986
**
6101
-** Each call to sqlite3_backup_step() sets two values stored internally
6102
-** by an [sqlite3_backup] object. The number of pages still to be backed
6103
-** up, which may be queried by sqlite3_backup_remaining(), and the total
6104
-** number of pages in the source database file, which may be queried by
6105
-** sqlite3_backup_pagecount().
5987
+** ^Each call to sqlite3_backup_step() sets two values inside
5988
+** the [sqlite3_backup] object: the number of pages still to be backed
5989
+** up and the total number of pages in the source databae file.
5990
+** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
5991
+** retrieve these two values, respectively.
61065992
**
6107
-** The values returned by these functions are only updated by
6108
-** sqlite3_backup_step(). If the source database is modified during a backup
5993
+** ^The values returned by these functions are only updated by
5994
+** sqlite3_backup_step(). ^If the source database is modified during a backup
61095995
** operation, then the values are not updated to account for any extra
61105996
** pages that need to be updated or the size of the source database file
61115997
** changing.
61125998
**
61135999
** <b>Concurrent Usage of Database Handles</b>
61146000
**
6115
-** The source [database connection] may be used by the application for other
6001
+** ^The source [database connection] may be used by the application for other
61166002
** purposes while a backup operation is underway or being initialized.
6117
-** If SQLite is compiled and configured to support threadsafe database
6003
+** ^If SQLite is compiled and configured to support threadsafe database
61186004
** connections, then the source database connection may be used concurrently
61196005
** from within other threads.
61206006
**
6121
-** However, the application must guarantee that the destination database
6122
-** connection handle is not passed to any other API (by any thread) after
6007
+** However, the application must guarantee that the destination
6008
+** [database connection] is not passed to any other API (by any thread) after
61236009
** sqlite3_backup_init() is called and before the corresponding call to
6124
-** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
6125
-** for this, if the application does use the destination [database connection]
6126
-** for some other purpose during a backup operation, things may appear to
6127
-** work correctly but in fact be subtly malfunctioning. Use of the
6128
-** destination database connection while a backup is in progress might
6129
-** also cause a mutex deadlock.
6010
+** sqlite3_backup_finish(). SQLite does not currently check to see
6011
+** if the application incorrectly accesses the destination [database connection]
6012
+** and so no error code is reported, but the operations may malfunction
6013
+** nevertheless. Use of the destination database connection while a
6014
+** backup is in progress might also also cause a mutex deadlock.
61306015
**
6131
-** Furthermore, if running in [shared cache mode], the application must
6016
+** If running in [shared cache mode], the application must
61326017
** guarantee that the shared cache used by the destination database
61336018
** is not accessed while the backup is running. In practice this means
6134
-** that the application must guarantee that the file-system file being
6019
+** that the application must guarantee that the disk file being
61356020
** backed up to is not accessed by any connection within the process,
61366021
** not just the specific connection that was passed to sqlite3_backup_init().
61376022
**
61386023
** The [sqlite3_backup] object itself is partially threadsafe. Multiple
61396024
** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -6155,60 +6040,60 @@
61556040
61566041
/*
61576042
** CAPI3REF: Unlock Notification
61586043
** EXPERIMENTAL
61596044
**
6160
-** When running in shared-cache mode, a database operation may fail with
6045
+** ^When running in shared-cache mode, a database operation may fail with
61616046
** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
61626047
** individual tables within the shared-cache cannot be obtained. See
61636048
** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6164
-** This API may be used to register a callback that SQLite will invoke
6049
+** ^This API may be used to register a callback that SQLite will invoke
61656050
** when the connection currently holding the required lock relinquishes it.
6166
-** This API is only available if the library was compiled with the
6051
+** ^This API is only available if the library was compiled with the
61676052
** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
61686053
**
61696054
** See Also: [Using the SQLite Unlock Notification Feature].
61706055
**
6171
-** Shared-cache locks are released when a database connection concludes
6056
+** ^Shared-cache locks are released when a database connection concludes
61726057
** its current transaction, either by committing it or rolling it back.
61736058
**
6174
-** When a connection (known as the blocked connection) fails to obtain a
6059
+** ^When a connection (known as the blocked connection) fails to obtain a
61756060
** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
61766061
** identity of the database connection (the blocking connection) that
6177
-** has locked the required resource is stored internally. After an
6062
+** has locked the required resource is stored internally. ^After an
61786063
** application receives an SQLITE_LOCKED error, it may call the
61796064
** sqlite3_unlock_notify() method with the blocked connection handle as
61806065
** the first argument to register for a callback that will be invoked
6181
-** when the blocking connections current transaction is concluded. The
6066
+** when the blocking connections current transaction is concluded. ^The
61826067
** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
61836068
** call that concludes the blocking connections transaction.
61846069
**
6185
-** If sqlite3_unlock_notify() is called in a multi-threaded application,
6070
+** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
61866071
** there is a chance that the blocking connection will have already
61876072
** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
61886073
** If this happens, then the specified callback is invoked immediately,
6189
-** from within the call to sqlite3_unlock_notify().
6074
+** from within the call to sqlite3_unlock_notify().)^
61906075
**
6191
-** If the blocked connection is attempting to obtain a write-lock on a
6076
+** ^If the blocked connection is attempting to obtain a write-lock on a
61926077
** shared-cache table, and more than one other connection currently holds
61936078
** a read-lock on the same table, then SQLite arbitrarily selects one of
61946079
** the other connections to use as the blocking connection.
61956080
**
6196
-** There may be at most one unlock-notify callback registered by a
6081
+** ^(There may be at most one unlock-notify callback registered by a
61976082
** blocked connection. If sqlite3_unlock_notify() is called when the
61986083
** blocked connection already has a registered unlock-notify callback,
6199
-** then the new callback replaces the old. If sqlite3_unlock_notify() is
6084
+** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
62006085
** called with a NULL pointer as its second argument, then any existing
6201
-** unlock-notify callback is cancelled. The blocked connections
6086
+** unlock-notify callback is cancelled. ^The blocked connections
62026087
** unlock-notify callback may also be canceled by closing the blocked
62036088
** connection using [sqlite3_close()].
62046089
**
62056090
** The unlock-notify callback is not reentrant. If an application invokes
62066091
** any sqlite3_xxx API functions from within an unlock-notify callback, a
62076092
** crash or deadlock may be the result.
62086093
**
6209
-** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
6094
+** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
62106095
** returns SQLITE_OK.
62116096
**
62126097
** <b>Callback Invocation Details</b>
62136098
**
62146099
** When an unlock-notify callback is registered, the application provides a
@@ -6218,11 +6103,11 @@
62186103
** an unlock-notify callback is a pointer to an array of void* pointers,
62196104
** and the second is the number of entries in the array.
62206105
**
62216106
** When a blocking connections transaction is concluded, there may be
62226107
** more than one blocked connection that has registered for an unlock-notify
6223
-** callback. If two or more such blocked connections have specified the
6108
+** callback. ^If two or more such blocked connections have specified the
62246109
** same callback function, then instead of invoking the callback function
62256110
** multiple times, it is invoked once with the set of void* context pointers
62266111
** specified by the blocked connections bundled together into an array.
62276112
** This gives the application an opportunity to prioritize any actions
62286113
** related to the set of unblocked database connections.
@@ -6236,20 +6121,20 @@
62366121
** connection Y's transaction to be concluded, and similarly connection
62376122
** Y is waiting on connection X's transaction, then neither connection
62386123
** will proceed and the system may remain deadlocked indefinitely.
62396124
**
62406125
** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
6241
-** detection. If a given call to sqlite3_unlock_notify() would put the
6126
+** detection. ^If a given call to sqlite3_unlock_notify() would put the
62426127
** system in a deadlocked state, then SQLITE_LOCKED is returned and no
62436128
** unlock-notify callback is registered. The system is said to be in
62446129
** a deadlocked state if connection A has registered for an unlock-notify
62456130
** callback on the conclusion of connection B's transaction, and connection
62466131
** B has itself registered for an unlock-notify callback when connection
6247
-** A's transaction is concluded. Indirect deadlock is also detected, so
6132
+** A's transaction is concluded. ^Indirect deadlock is also detected, so
62486133
** the system is also considered to be deadlocked if connection B has
62496134
** registered for an unlock-notify callback on the conclusion of connection
6250
-** C's transaction, where connection C is waiting on connection A. Any
6135
+** C's transaction, where connection C is waiting on connection A. ^Any
62516136
** number of levels of indirection are allowed.
62526137
**
62536138
** <b>The "DROP TABLE" Exception</b>
62546139
**
62556140
** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -6261,14 +6146,14 @@
62616146
** sqlite3_unlock_notify() results in the unlock-notify callback being
62626147
** invoked immediately. If the application then re-attempts the "DROP TABLE"
62636148
** or "DROP INDEX" query, an infinite loop might be the result.
62646149
**
62656150
** One way around this problem is to check the extended error code returned
6266
-** by an sqlite3_step() call. If there is a blocking connection, then the
6151
+** by an sqlite3_step() call. ^(If there is a blocking connection, then the
62676152
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
62686153
** the special "DROP TABLE/INDEX" case, the extended error code is just
6269
-** SQLITE_LOCKED.
6154
+** SQLITE_LOCKED.)^
62706155
*/
62716156
SQLITE_API int sqlite3_unlock_notify(
62726157
sqlite3 *pBlocked, /* Waiting connection */
62736158
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
62746159
void *pNotifyArg /* Argument to pass to xNotify */
@@ -6277,11 +6162,11 @@
62776162
62786163
/*
62796164
** CAPI3REF: String Comparison
62806165
** EXPERIMENTAL
62816166
**
6282
-** The [sqlite3_strnicmp()] API allows applications and extensions to
6167
+** ^The [sqlite3_strnicmp()] API allows applications and extensions to
62836168
** compare the contents of two buffers containing UTF-8 strings in a
62846169
** case-indendent fashion, using the same definition of case independence
62856170
** that SQLite uses internally when comparing identifiers.
62866171
*/
62876172
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
@@ -6507,34 +6392,34 @@
65076392
#define TK_UNIQUE 100
65086393
#define TK_CHECK 101
65096394
#define TK_REFERENCES 102
65106395
#define TK_AUTOINCR 103
65116396
#define TK_ON 104
6512
-#define TK_DELETE 105
6513
-#define TK_UPDATE 106
6514
-#define TK_SET 107
6515
-#define TK_DEFERRABLE 108
6516
-#define TK_FOREIGN 109
6517
-#define TK_DROP 110
6518
-#define TK_UNION 111
6519
-#define TK_ALL 112
6520
-#define TK_EXCEPT 113
6521
-#define TK_INTERSECT 114
6522
-#define TK_SELECT 115
6523
-#define TK_DISTINCT 116
6524
-#define TK_DOT 117
6525
-#define TK_FROM 118
6526
-#define TK_JOIN 119
6527
-#define TK_USING 120
6528
-#define TK_ORDER 121
6529
-#define TK_GROUP 122
6530
-#define TK_HAVING 123
6531
-#define TK_LIMIT 124
6532
-#define TK_WHERE 125
6533
-#define TK_INTO 126
6534
-#define TK_VALUES 127
6535
-#define TK_INSERT 128
6397
+#define TK_INSERT 105
6398
+#define TK_DELETE 106
6399
+#define TK_UPDATE 107
6400
+#define TK_SET 108
6401
+#define TK_DEFERRABLE 109
6402
+#define TK_FOREIGN 110
6403
+#define TK_DROP 111
6404
+#define TK_UNION 112
6405
+#define TK_ALL 113
6406
+#define TK_EXCEPT 114
6407
+#define TK_INTERSECT 115
6408
+#define TK_SELECT 116
6409
+#define TK_DISTINCT 117
6410
+#define TK_DOT 118
6411
+#define TK_FROM 119
6412
+#define TK_JOIN 120
6413
+#define TK_USING 121
6414
+#define TK_ORDER 122
6415
+#define TK_GROUP 123
6416
+#define TK_HAVING 124
6417
+#define TK_LIMIT 125
6418
+#define TK_WHERE 126
6419
+#define TK_INTO 127
6420
+#define TK_VALUES 128
65366421
#define TK_INTEGER 129
65376422
#define TK_FLOAT 130
65386423
#define TK_BLOB 131
65396424
#define TK_REGISTER 132
65406425
#define TK_VARIABLE 133
@@ -8506,41 +8391,47 @@
85068391
** A macro to discover the encoding of a database.
85078392
*/
85088393
#define ENC(db) ((db)->aDb[0].pSchema->enc)
85098394
85108395
/*
8511
-** Possible values for the sqlite.flags and or Db.flags fields.
8512
-**
8513
-** On sqlite.flags, the SQLITE_InTrans value means that we have
8514
-** executed a BEGIN. On Db.flags, SQLITE_InTrans means a statement
8515
-** transaction is active on that particular database file.
8396
+** Possible values for the sqlite3.flags.
85168397
*/
8517
-#define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
8518
-#define SQLITE_InTrans 0x00000008 /* True if in a transaction */
8519
-#define SQLITE_InternChanges 0x00000010 /* Uncommitted Hash table changes */
8520
-#define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */
8521
-#define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
8522
-#define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
8398
+#define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */
8399
+#define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */
8400
+#define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
8401
+#define SQLITE_ShortColNames 0x00000800 /* Show short columns names */
8402
+#define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */
85238403
/* DELETE, or UPDATE and return */
85248404
/* the count using a callback. */
8525
-#define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
8405
+#define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */
85268406
/* result set is empty */
8527
-#define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
8528
-#define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
8529
-#define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
8530
-#define SQLITE_NoReadlock 0x00001000 /* Readlocks are omitted when
8407
+#define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
8408
+#define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */
8409
+#define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */
8410
+#define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when
85318411
** accessing read-only databases */
8532
-#define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
8533
-#define SQLITE_ReadUncommitted 0x00004000 /* For shared-cache mode */
8534
-#define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
8535
-#define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */
8536
-#define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8537
-
8538
-#define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8539
-#define SQLITE_ReverseOrder 0x00100000 /* Reverse unordered SELECTs */
8540
-#define SQLITE_RecTriggers 0x00200000 /* Enable recursive triggers */
8541
-#define SQLITE_ForeignKeys 0x00400000 /* Enforce foreign key constraints */
8412
+#define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */
8413
+#define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */
8414
+#define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */
8415
+#define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */
8416
+#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
8417
+#define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */
8418
+#define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */
8419
+#define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */
8420
+#define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */
8421
+
8422
+/*
8423
+** Bits of the sqlite3.flags field that are used by the
8424
+** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface.
8425
+** These must be the low-order bits of the flags field.
8426
+*/
8427
+#define SQLITE_QueryFlattener 0x01 /* Disable query flattening */
8428
+#define SQLITE_ColumnCache 0x02 /* Disable the column cache */
8429
+#define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */
8430
+#define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */
8431
+#define SQLITE_IndexCover 0x10 /* Disable index covering table */
8432
+#define SQLITE_OptMask 0x1f /* Mask of all disablable opts */
85428433
85438434
/*
85448435
** Possible values for the sqlite.magic field.
85458436
** The numbers are obtained at random and have no special meaning, other
85468437
** than being distinct from one another.
@@ -9250,18 +9141,17 @@
92509141
#define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */
92519142
#define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */
92529143
#define EP_DblQuoted 0x0040 /* token.z was originally in "..." */
92539144
#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
92549145
#define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
9255
-#define EP_AnyAff 0x0200 /* Can take a cached column of any affinity */
9256
-#define EP_FixedDest 0x0400 /* Result needed in a specific register */
9257
-#define EP_IntValue 0x0800 /* Integer value contained in u.iValue */
9258
-#define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */
9259
-
9260
-#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
9261
-#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
9262
-#define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
9146
+#define EP_FixedDest 0x0200 /* Result needed in a specific register */
9147
+#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
9148
+#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
9149
+
9150
+#define EP_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
9151
+#define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
9152
+#define EP_Static 0x4000 /* Held in memory not obtained from malloc() */
92639153
92649154
/*
92659155
** The following are the meanings of bits in the Expr.flags2 field.
92669156
*/
92679157
#define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */
@@ -9502,10 +9392,11 @@
95029392
#define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
95039393
#define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
95049394
#define WHERE_OMIT_OPEN 0x0010 /* Table cursor are already open */
95059395
#define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */
95069396
#define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */
9397
+#define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */
95079398
95089399
/*
95099400
** The WHERE clause processing routine has two halves. The
95109401
** first part does the start of the WHERE loop and the second
95119402
** half does the tail of the WHERE loop. An instance of
@@ -9514,10 +9405,11 @@
95149405
*/
95159406
struct WhereInfo {
95169407
Parse *pParse; /* Parsing and code generating context */
95179408
u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
95189409
u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */
9410
+ u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
95199411
SrcList *pTabList; /* List of tables in the join */
95209412
int iTop; /* The very beginning of the WHERE loop */
95219413
int iContinue; /* Jump here to continue with next record */
95229414
int iBreak; /* Jump here to break out of the loop */
95239415
int nLevel; /* Number of nested loop */
@@ -9733,11 +9625,10 @@
97339625
u8 nColCache; /* Number of entries in the column cache */
97349626
u8 iColCache; /* Next entry of the cache to replace */
97359627
struct yColCache {
97369628
int iTable; /* Table cursor number */
97379629
int iColumn; /* Table column number */
9738
- u8 affChange; /* True if this register has had an affinity change */
97399630
u8 tempReg; /* iReg is a temp register that needs to be freed */
97409631
int iLevel; /* Nesting level */
97419632
int iReg; /* Reg with value of this column. 0 means none. */
97429633
int lru; /* Least recently used entry has the smallest value */
97439634
} aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */
@@ -10252,17 +10143,17 @@
1025210143
#endif
1025310144
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
1025410145
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
1025510146
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16);
1025610147
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
10257
-SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, int);
10148
+SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
1025810149
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
1025910150
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
1026010151
SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
1026110152
SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
1026210153
SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);
10263
-SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int);
10154
+SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
1026410155
SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
1026510156
SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
1026610157
SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse*,int,int);
1026710158
SQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int);
1026810159
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
@@ -48266,22 +48157,25 @@
4826648157
**
4826748158
** When p->explain==1, each instruction is listed. When
4826848159
** p->explain==2, only OP_Explain instructions are listed and these
4826948160
** are shown in a different format. p->explain==2 is used to implement
4827048161
** EXPLAIN QUERY PLAN.
48162
+**
48163
+** When p->explain==1, first the main program is listed, then each of
48164
+** the trigger subprograms are listed one by one.
4827148165
*/
4827248166
SQLITE_PRIVATE int sqlite3VdbeList(
4827348167
Vdbe *p /* The VDBE */
4827448168
){
48275
- int nRow; /* Total number of rows to return */
48169
+ int nRow; /* Stop when row count reaches this */
4827648170
int nSub = 0; /* Number of sub-vdbes seen so far */
4827748171
SubProgram **apSub = 0; /* Array of sub-vdbes */
48278
- Mem *pSub = 0;
48279
- sqlite3 *db = p->db;
48280
- int i;
48281
- int rc = SQLITE_OK;
48282
- Mem *pMem = p->pResultSet = &p->aMem[1];
48172
+ Mem *pSub = 0; /* Memory cell hold array of subprogs */
48173
+ sqlite3 *db = p->db; /* The database connection */
48174
+ int i; /* Loop counter */
48175
+ int rc = SQLITE_OK; /* Return code */
48176
+ Mem *pMem = p->pResultSet = &p->aMem[1]; /* First Mem of result set */
4828348177
4828448178
assert( p->explain );
4828548179
assert( p->magic==VDBE_MAGIC_RUN );
4828648180
assert( db->magic==SQLITE_MAGIC_BUSY );
4828748181
assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
@@ -48297,16 +48191,28 @@
4829748191
** sqlite3_column_text16() failed. */
4829848192
db->mallocFailed = 1;
4829948193
return SQLITE_ERROR;
4830048194
}
4830148195
48302
- /* Figure out total number of rows that will be returned by this
48303
- ** EXPLAIN program. */
48196
+ /* When the number of output rows reaches nRow, that means the
48197
+ ** listing has finished and sqlite3_step() should return SQLITE_DONE.
48198
+ ** nRow is the sum of the number of rows in the main program, plus
48199
+ ** the sum of the number of rows in all trigger subprograms encountered
48200
+ ** so far. The nRow value will increase as new trigger subprograms are
48201
+ ** encountered, but p->pc will eventually catch up to nRow.
48202
+ */
4830448203
nRow = p->nOp;
4830548204
if( p->explain==1 ){
48205
+ /* The first 8 memory cells are used for the result set. So we will
48206
+ ** commandeer the 9th cell to use as storage for an array of pointers
48207
+ ** to trigger subprograms. The VDBE is guaranteed to have at least 9
48208
+ ** cells. */
48209
+ assert( p->nMem>9 );
4830648210
pSub = &p->aMem[9];
4830748211
if( pSub->flags&MEM_Blob ){
48212
+ /* On the first call to sqlite3_step(), pSub will hold a NULL. It is
48213
+ ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */
4830848214
nSub = pSub->n/sizeof(Vdbe*);
4830948215
apSub = (SubProgram **)pSub->z;
4831048216
}
4831148217
for(i=0; i<nSub; i++){
4831248218
nRow += apSub[i]->nOp;
@@ -48325,12 +48231,16 @@
4832548231
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc));
4832648232
}else{
4832748233
char *z;
4832848234
Op *pOp;
4832948235
if( i<p->nOp ){
48236
+ /* The output line number is small enough that we are still in the
48237
+ ** main program. */
4833048238
pOp = &p->aOp[i];
4833148239
}else{
48240
+ /* We are currently listing subprograms. Figure out which one and
48241
+ ** pick up the appropriate opcode. */
4833248242
int j;
4833348243
i -= p->nOp;
4833448244
for(j=0; i>=apSub[j]->nOp; j++){
4833548245
i -= apSub[j]->nOp;
4833648246
}
@@ -48348,10 +48258,15 @@
4834848258
pMem->n = sqlite3Strlen30(pMem->z);
4834948259
pMem->type = SQLITE_TEXT;
4835048260
pMem->enc = SQLITE_UTF8;
4835148261
pMem++;
4835248262
48263
+ /* When an OP_Program opcode is encounter (the only opcode that has
48264
+ ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
48265
+ ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
48266
+ ** has not already been seen.
48267
+ */
4835348268
if( pOp->p4type==P4_SUBPROGRAM ){
4835448269
int nByte = (nSub+1)*sizeof(SubProgram*);
4835548270
int j;
4835648271
for(j=0; j<nSub; j++){
4835748272
if( apSub[j]==pOp->p4.pProgram ) break;
@@ -48479,42 +48394,47 @@
4847948394
}
4848048395
}
4848148396
#endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
4848248397
4848348398
/*
48484
-** Allocate space from a fixed size buffer. Make *pp point to the
48485
-** allocated space. (Note: pp is a char* rather than a void** to
48486
-** work around the pointer aliasing rules of C.) *pp should initially
48487
-** be zero. If *pp is not zero, that means that the space has already
48488
-** been allocated and this routine is a noop.
48399
+** Allocate space from a fixed size buffer and return a pointer to
48400
+** that space. If insufficient space is available, return NULL.
48401
+**
48402
+** The pBuf parameter is the initial value of a pointer which will
48403
+** receive the new memory. pBuf is normally NULL. If pBuf is not
48404
+** NULL, it means that memory space has already been allocated and that
48405
+** this routine should not allocate any new memory. When pBuf is not
48406
+** NULL simply return pBuf. Only allocate new memory space when pBuf
48407
+** is NULL.
4848948408
**
4849048409
** nByte is the number of bytes of space needed.
4849148410
**
48492
-** *ppFrom point to available space and pEnd points to the end of the
48493
-** available space.
48411
+** *ppFrom points to available space and pEnd points to the end of the
48412
+** available space. When space is allocated, *ppFrom is advanced past
48413
+** the end of the allocated space.
4849448414
**
4849548415
** *pnByte is a counter of the number of bytes of space that have failed
4849648416
** to allocate. If there is insufficient space in *ppFrom to satisfy the
4849748417
** request, then increment *pnByte by the amount of the request.
4849848418
*/
48499
-static void allocSpace(
48500
- char *pp, /* IN/OUT: Set *pp to point to allocated buffer */
48419
+static void *allocSpace(
48420
+ void *pBuf, /* Where return pointer will be stored */
4850148421
int nByte, /* Number of bytes to allocate */
4850248422
u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
4850348423
u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
4850448424
int *pnByte /* If allocation cannot be made, increment *pnByte */
4850548425
){
4850648426
assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
48507
- if( (*(void**)pp)==0 ){
48508
- nByte = ROUND8(nByte);
48509
- if( &(*ppFrom)[nByte] <= pEnd ){
48510
- *(void**)pp = (void *)*ppFrom;
48511
- *ppFrom += nByte;
48512
- }else{
48513
- *pnByte += nByte;
48514
- }
48515
- }
48427
+ if( pBuf ) return pBuf;
48428
+ nByte = ROUND8(nByte);
48429
+ if( &(*ppFrom)[nByte] <= pEnd ){
48430
+ pBuf = (void*)*ppFrom;
48431
+ *ppFrom += nByte;
48432
+ }else{
48433
+ *pnByte += nByte;
48434
+ }
48435
+ return pBuf;
4851648436
}
4851748437
4851848438
/*
4851948439
** Prepare a virtual machine for execution. This involves things such
4852048440
** as allocating stack space and initializing the program counter.
@@ -48569,31 +48489,41 @@
4856948489
** an array to marshal SQL function arguments in. This is only done the
4857048490
** first time this function is called for a given VDBE, not when it is
4857148491
** being called from sqlite3_reset() to reset the virtual machine.
4857248492
*/
4857348493
if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
48574
- u8 *zCsr = (u8 *)&p->aOp[p->nOp];
48575
- u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
48576
- int nByte;
48494
+ u8 *zCsr = (u8 *)&p->aOp[p->nOp]; /* Memory avaliable for alloation */
48495
+ u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc]; /* First byte past available mem */
48496
+ int nByte; /* How much extra memory needed */
48497
+
4857748498
resolveP2Values(p, &nArg);
4857848499
p->usesStmtJournal = (u8)usesStmtJournal;
4857948500
if( isExplain && nMem<10 ){
4858048501
nMem = 10;
4858148502
}
4858248503
memset(zCsr, 0, zEnd-zCsr);
4858348504
zCsr += (zCsr - (u8*)0)&7;
4858448505
assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
4858548506
48507
+ /* Memory for registers, parameters, cursor, etc, is allocated in two
48508
+ ** passes. On the first pass, we try to reuse unused space at the
48509
+ ** end of the opcode array. If we are unable to satisfy all memory
48510
+ ** requirements by reusing the opcode array tail, then the second
48511
+ ** pass will fill in the rest using a fresh allocation.
48512
+ **
48513
+ ** This two-pass approach that reuses as much memory as possible from
48514
+ ** the leftover space at the end of the opcode array can significantly
48515
+ ** reduce the amount of memory held by a prepared statement.
48516
+ */
4858648517
do {
4858748518
nByte = 0;
48588
- allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
48589
- allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
48590
- allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
48591
- allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
48592
- allocSpace((char*)&p->apCsr,
48593
- nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
48594
- );
48519
+ p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
48520
+ p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
48521
+ p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
48522
+ p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
48523
+ p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
48524
+ &zCsr, zEnd, &nByte);
4859548525
if( nByte ){
4859648526
p->pFree = sqlite3DbMallocZero(db, nByte);
4859748527
}
4859848528
zCsr = p->pFree;
4859948529
zEnd = &zCsr[nByte];
@@ -48931,14 +48861,15 @@
4893148861
** still have 'null' as the master journal pointer, so they will roll
4893248862
** back independently if a failure occurs.
4893348863
*/
4893448864
for(i=0; i<db->nDb; i++){
4893548865
Btree *pBt = db->aDb[i].pBt;
48936
- if( i==1 ) continue; /* Ignore the TEMP database */
4893748866
if( sqlite3BtreeIsInTrans(pBt) ){
4893848867
char const *zFile = sqlite3BtreeGetJournalname(pBt);
48939
- if( zFile[0]==0 ) continue; /* Ignore :memory: databases */
48868
+ if( zFile==0 || zFile[0]==0 ){
48869
+ continue; /* Ignore TEMP and :memory: databases */
48870
+ }
4894048871
if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
4894148872
needSync = 1;
4894248873
}
4894348874
rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
4894448875
offset += sqlite3Strlen30(zFile)+1;
@@ -50780,12 +50711,13 @@
5078050711
SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
5078150712
Mem *pMem;
5078250713
assert( p && p->pFunc && p->pFunc->xStep );
5078350714
assert( sqlite3_mutex_held(p->s.db->mutex) );
5078450715
pMem = p->pMem;
50716
+ testcase( nByte<0 );
5078550717
if( (pMem->flags & MEM_Agg)==0 ){
50786
- if( nByte==0 ){
50718
+ if( nByte<=0 ){
5078750719
sqlite3VdbeMemReleaseExternal(pMem);
5078850720
pMem->flags = MEM_Null;
5078950721
pMem->z = 0;
5079050722
}else{
5079150723
sqlite3VdbeMemGrow(pMem, nByte, 0);
@@ -55878,19 +55810,19 @@
5587855810
rc = sqlite3BtreeLast(u.be.pC->pCursor, &u.be.res);
5587955811
if( rc!=SQLITE_OK ){
5588055812
goto abort_due_to_error;
5588155813
}
5588255814
if( u.be.res ){
55883
- u.be.v = 1;
55815
+ u.be.v = 1; /* IMP: R-61914-48074 */
5588455816
}else{
5588555817
assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) );
5588655818
rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v);
5588755819
assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
5588855820
if( u.be.v==MAX_ROWID ){
5588955821
u.be.pC->useRandomRowid = 1;
5589055822
}else{
55891
- u.be.v++;
55823
+ u.be.v++; /* IMP: R-29538-34987 */
5589255824
}
5589355825
}
5589455826
}
5589555827
5589655828
#ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -55910,11 +55842,11 @@
5591055842
5591155843
REGISTER_TRACE(pOp->p3, u.be.pMem);
5591255844
sqlite3VdbeMemIntegerify(u.be.pMem);
5591355845
assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
5591455846
if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
55915
- rc = SQLITE_FULL;
55847
+ rc = SQLITE_FULL; /* IMP: R-12275-61338 */
5591655848
goto abort_due_to_error;
5591755849
}
5591855850
if( u.be.v<u.be.pMem->u.i+1 ){
5591955851
u.be.v = u.be.pMem->u.i + 1;
5592055852
}
@@ -55923,10 +55855,15 @@
5592355855
#endif
5592455856
5592555857
sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0);
5592655858
}
5592755859
if( u.be.pC->useRandomRowid ){
55860
+ /* IMPLEMENTATION-OF: R-48598-02938 If the largest ROWID is equal to the
55861
+ ** largest possible integer (9223372036854775807) then the database
55862
+ ** engine starts picking candidate ROWIDs at random until it finds one
55863
+ ** that is not previously used.
55864
+ */
5592855865
assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
5592955866
** an AUTOINCREMENT table. */
5593055867
u.be.v = db->lastRowid;
5593155868
u.be.cnt = 0;
5593255869
do{
@@ -55938,11 +55875,11 @@
5593855875
}
5593955876
rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res);
5594055877
u.be.cnt++;
5594155878
}while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
5594255879
if( rc==SQLITE_OK && u.be.res==0 ){
55943
- rc = SQLITE_FULL;
55880
+ rc = SQLITE_FULL; /* IMP: R-38219-53002 */
5594455881
goto abort_due_to_error;
5594555882
}
5594655883
}
5594755884
u.be.pC->rowidIsValid = 0;
5594855885
u.be.pC->deferredMoveto = 0;
@@ -59317,22 +59254,21 @@
5931759254
5931859255
if( pTab ){
5931959256
int iCol;
5932059257
pSchema = pTab->pSchema;
5932159258
cntTab++;
59322
- if( sqlite3IsRowid(zCol) ){
59323
- iCol = -1;
59324
- }else{
59325
- for(iCol=0; iCol<pTab->nCol; iCol++){
59326
- Column *pCol = &pTab->aCol[iCol];
59327
- if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
59328
- if( iCol==pTab->iPKey ){
59329
- iCol = -1;
59330
- }
59331
- break;
59332
- }
59333
- }
59259
+ for(iCol=0; iCol<pTab->nCol; iCol++){
59260
+ Column *pCol = &pTab->aCol[iCol];
59261
+ if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
59262
+ if( iCol==pTab->iPKey ){
59263
+ iCol = -1;
59264
+ }
59265
+ break;
59266
+ }
59267
+ }
59268
+ if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){
59269
+ iCol = -1; /* IMP: R-44911-55124 */
5933459270
}
5933559271
if( iCol<pTab->nCol ){
5933659272
cnt++;
5933759273
if( iCol<0 ){
5933859274
pExpr->affinity = SQLITE_AFF_INTEGER;
@@ -59356,11 +59292,11 @@
5935659292
/*
5935759293
** Perhaps the name is a reference to the ROWID
5935859294
*/
5935959295
if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
5936059296
cnt = 1;
59361
- pExpr->iColumn = -1;
59297
+ pExpr->iColumn = -1; /* IMP: R-44911-55124 */
5936259298
pExpr->affinity = SQLITE_AFF_INTEGER;
5936359299
}
5936459300
5936559301
/*
5936659302
** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
@@ -60500,34 +60436,10 @@
6050060436
}
6050160437
}
6050260438
return pColl;
6050360439
}
6050460440
60505
-/*
60506
-** Generate the operands for a comparison operation. Before
60507
-** generating the code for each operand, set the EP_AnyAff
60508
-** flag on the expression so that it will be able to used a
60509
-** cached column value that has previously undergone an
60510
-** affinity change.
60511
-*/
60512
-static void codeCompareOperands(
60513
- Parse *pParse, /* Parsing and code generating context */
60514
- Expr *pLeft, /* The left operand */
60515
- int *pRegLeft, /* Register where left operand is stored */
60516
- int *pFreeLeft, /* Free this register when done */
60517
- Expr *pRight, /* The right operand */
60518
- int *pRegRight, /* Register where right operand is stored */
60519
- int *pFreeRight /* Write temp register for right operand there */
60520
-){
60521
- while( pLeft->op==TK_UPLUS ) pLeft = pLeft->pLeft;
60522
- pLeft->flags |= EP_AnyAff;
60523
- *pRegLeft = sqlite3ExprCodeTemp(pParse, pLeft, pFreeLeft);
60524
- while( pRight->op==TK_UPLUS ) pRight = pRight->pLeft;
60525
- pRight->flags |= EP_AnyAff;
60526
- *pRegRight = sqlite3ExprCodeTemp(pParse, pRight, pFreeRight);
60527
-}
60528
-
6052960441
/*
6053060442
** Generate code for a comparison operator.
6053160443
*/
6053260444
static int codeCompare(
6053360445
Parse *pParse, /* The parsing (and code generating) context */
@@ -62255,30 +62167,43 @@
6225562167
struct yColCache *p;
6225662168
6225762169
assert( iReg>0 ); /* Register numbers are always positive */
6225862170
assert( iCol>=-1 && iCol<32768 ); /* Finite column numbers */
6225962171
62260
- /* First replace any existing entry */
62172
+ /* The SQLITE_ColumnCache flag disables the column cache. This is used
62173
+ ** for testing only - to verify that SQLite always gets the same answer
62174
+ ** with and without the column cache.
62175
+ */
62176
+ if( pParse->db->flags & SQLITE_ColumnCache ) return;
62177
+
62178
+ /* First replace any existing entry.
62179
+ **
62180
+ ** Actually, the way the column cache is currently used, we are guaranteed
62181
+ ** that the object will never already be in cache. Verify this guarantee.
62182
+ */
62183
+#ifndef NDEBUG
6226162184
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62185
+#if 0 /* This code wold remove the entry from the cache if it existed */
6226262186
if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
6226362187
cacheEntryClear(pParse, p);
6226462188
p->iLevel = pParse->iCacheLevel;
6226562189
p->iReg = iReg;
62266
- p->affChange = 0;
6226762190
p->lru = pParse->iCacheCnt++;
6226862191
return;
6226962192
}
62193
+#endif
62194
+ assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
6227062195
}
62196
+#endif
6227162197
6227262198
/* Find an empty slot and replace it */
6227362199
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
6227462200
if( p->iReg==0 ){
6227562201
p->iLevel = pParse->iCacheLevel;
6227662202
p->iTable = iTab;
6227762203
p->iColumn = iCol;
6227862204
p->iReg = iReg;
62279
- p->affChange = 0;
6228062205
p->tempReg = 0;
6228162206
p->lru = pParse->iCacheCnt++;
6228262207
return;
6228362208
}
6228462209
}
@@ -62296,26 +62221,27 @@
6229662221
p = &pParse->aColCache[idxLru];
6229762222
p->iLevel = pParse->iCacheLevel;
6229862223
p->iTable = iTab;
6229962224
p->iColumn = iCol;
6230062225
p->iReg = iReg;
62301
- p->affChange = 0;
6230262226
p->tempReg = 0;
6230362227
p->lru = pParse->iCacheCnt++;
6230462228
return;
6230562229
}
6230662230
}
6230762231
6230862232
/*
62309
-** Indicate that a register is being overwritten. Purge the register
62310
-** from the column cache.
62233
+** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.
62234
+** Purge the range of registers from the column cache.
6231162235
*/
62312
-SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg){
62236
+SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){
6231362237
int i;
62238
+ int iLast = iReg + nReg - 1;
6231462239
struct yColCache *p;
6231562240
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62316
- if( p->iReg==iReg ){
62241
+ int r = p->iReg;
62242
+ if( r>=iReg && r<=iLast ){
6231762243
cacheEntryClear(pParse, p);
6231862244
p->iReg = 0;
6231962245
}
6232062246
}
6232162247
}
@@ -62370,32 +62296,24 @@
6237062296
** is made to store the column value in register iReg, but this is
6237162297
** not guaranteed. The location of the column value is returned.
6237262298
**
6237362299
** There must be an open cursor to pTab in iTable when this routine
6237462300
** is called. If iColumn<0 then code is generated that extracts the rowid.
62375
-**
62376
-** This routine might attempt to reuse the value of the column that
62377
-** has already been loaded into a register. The value will always
62378
-** be used if it has not undergone any affinity changes. But if
62379
-** an affinity change has occurred, then the cached value will only be
62380
-** used if allowAffChng is true.
6238162301
*/
6238262302
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
6238362303
Parse *pParse, /* Parsing and code generating context */
6238462304
Table *pTab, /* Description of the table we are reading from */
6238562305
int iColumn, /* Index of the table column */
6238662306
int iTable, /* The cursor pointing to the table */
62387
- int iReg, /* Store results here */
62388
- int allowAffChng /* True if prior affinity changes are OK */
62307
+ int iReg /* Store results here */
6238962308
){
6239062309
Vdbe *v = pParse->pVdbe;
6239162310
int i;
6239262311
struct yColCache *p;
6239362312
6239462313
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62395
- if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn
62396
- && (!p->affChange || allowAffChng) ){
62314
+ if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn ){
6239762315
p->lru = pParse->iCacheCnt++;
6239862316
sqlite3ExprCachePinRegister(pParse, p->iReg);
6239962317
return p->iReg;
6240062318
}
6240162319
}
@@ -62429,19 +62347,11 @@
6242962347
/*
6243062348
** Record the fact that an affinity change has occurred on iCount
6243162349
** registers starting with iStart.
6243262350
*/
6243362351
SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
62434
- int iEnd = iStart + iCount - 1;
62435
- int i;
62436
- struct yColCache *p;
62437
- for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62438
- int r = p->iReg;
62439
- if( r>=iStart && r<=iEnd ){
62440
- p->affChange = 1;
62441
- }
62442
- }
62352
+ sqlite3ExprCacheRemove(pParse, iStart, iCount);
6244362353
}
6244462354
6244562355
/*
6244662356
** Generate code to move content from registers iFrom...iFrom+nReg-1
6244762357
** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.
@@ -62469,23 +62379,28 @@
6246962379
for(i=0; i<nReg; i++){
6247062380
sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, iFrom+i, iTo+i);
6247162381
}
6247262382
}
6247362383
62384
+#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
6247462385
/*
6247562386
** Return true if any register in the range iFrom..iTo (inclusive)
6247662387
** is used as part of the column cache.
62388
+**
62389
+** This routine is used within assert() and testcase() macros only
62390
+** and does not appear in a normal build.
6247762391
*/
6247862392
static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
6247962393
int i;
6248062394
struct yColCache *p;
6248162395
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
6248262396
int r = p->iReg;
62483
- if( r>=iFrom && r<=iTo ) return 1;
62397
+ if( r>=iFrom && r<=iTo ) return 1; /*NO_TEST*/
6248462398
}
6248562399
return 0;
6248662400
}
62401
+#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
6248762402
6248862403
/*
6248962404
** If the last instruction coded is an ephemeral copy of any of
6249062405
** the registers in the nReg registers beginning with iReg, then
6249162406
** convert the last instruction from OP_SCopy to OP_Copy.
@@ -62602,14 +62517,12 @@
6260262517
if( pExpr->iTable<0 ){
6260362518
/* This only happens when coding check constraints */
6260462519
assert( pParse->ckBase>0 );
6260562520
inReg = pExpr->iColumn + pParse->ckBase;
6260662521
}else{
62607
- testcase( (pExpr->flags & EP_AnyAff)!=0 );
6260862522
inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
62609
- pExpr->iColumn, pExpr->iTable, target,
62610
- pExpr->flags & EP_AnyAff);
62523
+ pExpr->iColumn, pExpr->iTable, target);
6261162524
}
6261262525
break;
6261362526
}
6261462527
case TK_INTEGER: {
6261562528
codeInteger(v, pExpr, 0, target);
@@ -62722,12 +62635,12 @@
6272262635
testcase( op==TK_LE );
6272362636
testcase( op==TK_GT );
6272462637
testcase( op==TK_GE );
6272562638
testcase( op==TK_EQ );
6272662639
testcase( op==TK_NE );
62727
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62728
- pExpr->pRight, &r2, &regFree2);
62640
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
62641
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6272962642
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6273062643
r1, r2, inReg, SQLITE_STOREP2);
6273162644
testcase( regFree1==0 );
6273262645
testcase( regFree2==0 );
6273362646
break;
@@ -62734,12 +62647,12 @@
6273462647
}
6273562648
case TK_IS:
6273662649
case TK_ISNOT: {
6273762650
testcase( op==TK_IS );
6273862651
testcase( op==TK_ISNOT );
62739
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62740
- pExpr->pRight, &r2, &regFree2);
62652
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
62653
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6274162654
op = (op==TK_IS) ? TK_EQ : TK_NE;
6274262655
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6274362656
r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
6274462657
testcase( regFree1==0 );
6274562658
testcase( regFree2==0 );
@@ -62879,11 +62792,11 @@
6287962792
int endCoalesce = sqlite3VdbeMakeLabel(v);
6288062793
assert( nFarg>=2 );
6288162794
sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
6288262795
for(i=1; i<nFarg; i++){
6288362796
sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
62884
- sqlite3ExprCacheRemove(pParse, target);
62797
+ sqlite3ExprCacheRemove(pParse, target, 1);
6288562798
sqlite3ExprCachePush(pParse);
6288662799
sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
6288762800
sqlite3ExprCachePop(pParse, 1);
6288862801
}
6288962802
sqlite3VdbeResolveLabel(v, endCoalesce);
@@ -62934,11 +62847,10 @@
6293462847
(char*)pDef, P4_FUNCDEF);
6293562848
sqlite3VdbeChangeP5(v, (u8)nFarg);
6293662849
if( nFarg ){
6293762850
sqlite3ReleaseTempRange(pParse, r1, nFarg);
6293862851
}
62939
- sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
6294062852
break;
6294162853
}
6294262854
#ifndef SQLITE_OMIT_SUBQUERY
6294362855
case TK_EXISTS:
6294462856
case TK_SELECT: {
@@ -62975,12 +62887,12 @@
6297562887
case TK_BETWEEN: {
6297662888
Expr *pLeft = pExpr->pLeft;
6297762889
struct ExprList_item *pLItem = pExpr->x.pList->a;
6297862890
Expr *pRight = pLItem->pExpr;
6297962891
62980
- codeCompareOperands(pParse, pLeft, &r1, &regFree1,
62981
- pRight, &r2, &regFree2);
62892
+ r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
62893
+ r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
6298262894
testcase( regFree1==0 );
6298362895
testcase( regFree2==0 );
6298462896
r3 = sqlite3GetTempReg(pParse);
6298562897
r4 = sqlite3GetTempReg(pParse);
6298662898
codeCompare(pParse, pLeft, pRight, OP_Ge,
@@ -63511,12 +63423,12 @@
6351163423
testcase( op==TK_GT );
6351263424
testcase( op==TK_GE );
6351363425
testcase( op==TK_EQ );
6351463426
testcase( op==TK_NE );
6351563427
testcase( jumpIfNull==0 );
63516
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63517
- pExpr->pRight, &r2, &regFree2);
63428
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63429
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6351863430
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6351963431
r1, r2, dest, jumpIfNull);
6352063432
testcase( regFree1==0 );
6352163433
testcase( regFree2==0 );
6352263434
break;
@@ -63523,12 +63435,12 @@
6352363435
}
6352463436
case TK_IS:
6352563437
case TK_ISNOT: {
6352663438
testcase( op==TK_IS );
6352763439
testcase( op==TK_ISNOT );
63528
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63529
- pExpr->pRight, &r2, &regFree2);
63440
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63441
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6353063442
op = (op==TK_IS) ? TK_EQ : TK_NE;
6353163443
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6353263444
r1, r2, dest, SQLITE_NULLEQ);
6353363445
testcase( regFree1==0 );
6353463446
testcase( regFree2==0 );
@@ -63654,12 +63566,12 @@
6365463566
testcase( op==TK_GT );
6365563567
testcase( op==TK_GE );
6365663568
testcase( op==TK_EQ );
6365763569
testcase( op==TK_NE );
6365863570
testcase( jumpIfNull==0 );
63659
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63660
- pExpr->pRight, &r2, &regFree2);
63571
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63572
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6366163573
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6366263574
r1, r2, dest, jumpIfNull);
6366363575
testcase( regFree1==0 );
6366463576
testcase( regFree2==0 );
6366563577
break;
@@ -63666,12 +63578,12 @@
6366663578
}
6366763579
case TK_IS:
6366863580
case TK_ISNOT: {
6366963581
testcase( pExpr->op==TK_IS );
6367063582
testcase( pExpr->op==TK_ISNOT );
63671
- codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63672
- pExpr->pRight, &r2, &regFree2);
63583
+ r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63584
+ r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
6367363585
op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
6367463586
codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
6367563587
r1, r2, dest, SQLITE_NULLEQ);
6367663588
testcase( regFree1==0 );
6367763589
testcase( regFree2==0 );
@@ -64014,20 +63926,22 @@
6401463926
*/
6401563927
SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
6401663928
int i, n;
6401763929
i = pParse->iRangeReg;
6401863930
n = pParse->nRangeReg;
64019
- if( nReg<=n && !usedAsColumnCache(pParse, i, i+n-1) ){
63931
+ if( nReg<=n ){
63932
+ assert( !usedAsColumnCache(pParse, i, i+n-1) );
6402063933
pParse->iRangeReg += nReg;
6402163934
pParse->nRangeReg -= nReg;
6402263935
}else{
6402363936
i = pParse->nMem+1;
6402463937
pParse->nMem += nReg;
6402563938
}
6402663939
return i;
6402763940
}
6402863941
SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
63942
+ sqlite3ExprCacheRemove(pParse, iReg, nReg);
6402963943
if( nReg>pParse->nRangeReg ){
6403063944
pParse->nRangeReg = nReg;
6403163945
pParse->iRangeReg = iReg;
6403263946
}
6403363947
}
@@ -66818,11 +66732,12 @@
6681866732
Table *p;
6681966733
Db *pDb;
6682066734
6682166735
assert( db!=0 );
6682266736
assert( iDb>=0 && iDb<db->nDb );
66823
- assert( zTabName && zTabName[0] );
66737
+ assert( zTabName );
66738
+ testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
6682466739
pDb = &db->aDb[iDb];
6682566740
p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
6682666741
sqlite3Strlen30(zTabName),0);
6682766742
sqlite3DeleteTable(p);
6682866743
db->flags |= SQLITE_InternChanges;
@@ -69685,11 +69600,10 @@
6968569600
sqlite3ErrorMsg(pParse, "unable to open a temporary database "
6968669601
"file for storing temporary tables");
6968769602
pParse->rc = rc;
6968869603
return 1;
6968969604
}
69690
- assert( (db->flags & SQLITE_InTrans)==0 || db->autoCommit );
6969169605
assert( db->aDb[1].pSchema );
6969269606
sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt),
6969369607
db->dfltJournalMode);
6969469608
}
6969569609
return 0;
@@ -70791,11 +70705,11 @@
7079170705
/* Collect rowids of every row to be deleted.
7079270706
*/
7079370707
sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
7079470708
pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,WHERE_DUPLICATES_OK);
7079570709
if( pWInfo==0 ) goto delete_from_cleanup;
70796
- regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
70710
+ regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
7079770711
sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
7079870712
if( db->flags & SQLITE_CountRows ){
7079970713
sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
7080070714
}
7080170715
sqlite3WhereEnd(pWInfo);
@@ -71057,11 +70971,10 @@
7105770971
}
7105870972
}
7105970973
if( doMakeRec ){
7106070974
sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
7106170975
sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
71062
- sqlite3ExprCacheAffinityChange(pParse, regBase, nCol+1);
7106370976
}
7106470977
sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
7106570978
return regBase;
7106670979
}
7106770980
@@ -71180,33 +71093,45 @@
7118071093
}
7118171094
}
7118271095
}
7118371096
7118471097
/*
71185
-** Implementation of the abs() function
71098
+** Implementation of the abs() function.
71099
+**
71100
+** IMP: R-23979-26855 The abs(X) function returns the absolute value of
71101
+** the numeric argument X.
7118671102
*/
7118771103
static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
7118871104
assert( argc==1 );
7118971105
UNUSED_PARAMETER(argc);
7119071106
switch( sqlite3_value_type(argv[0]) ){
7119171107
case SQLITE_INTEGER: {
7119271108
i64 iVal = sqlite3_value_int64(argv[0]);
7119371109
if( iVal<0 ){
7119471110
if( (iVal<<1)==0 ){
71111
+ /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then
71112
+ ** abs(X) throws an integer overflow error since there is no
71113
+ ** equivalent positive 64-bit two complement value. */
7119571114
sqlite3_result_error(context, "integer overflow", -1);
7119671115
return;
7119771116
}
7119871117
iVal = -iVal;
7119971118
}
7120071119
sqlite3_result_int64(context, iVal);
7120171120
break;
7120271121
}
7120371122
case SQLITE_NULL: {
71123
+ /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */
7120471124
sqlite3_result_null(context);
7120571125
break;
7120671126
}
7120771127
default: {
71128
+ /* Because sqlite3_value_double() returns 0.0 if the argument is not
71129
+ ** something that can be converted into a number, we have:
71130
+ ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that
71131
+ ** cannot be converted to a numeric value.
71132
+ */
7120871133
double rVal = sqlite3_value_double(argv[0]);
7120971134
if( rVal<0 ) rVal = -rVal;
7121071135
sqlite3_result_double(context, rVal);
7121171136
break;
7121271137
}
@@ -72104,13 +72029,20 @@
7210472029
}
7210572030
sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
7210672031
}
7210772032
7210872033
72034
+/* IMP: R-25361-16150 This function is omitted from SQLite by default. It
72035
+** is only available if the SQLITE_SOUNDEX compile-time option is used
72036
+** when SQLite is built.
72037
+*/
7210972038
#ifdef SQLITE_SOUNDEX
7211072039
/*
7211172040
** Compute the soundex encoding of a word.
72041
+**
72042
+** IMP: R-59782-00072 The soundex(X) function returns a string that is the
72043
+** soundex encoding of the string X.
7211272044
*/
7211372045
static void soundexFunc(
7211472046
sqlite3_context *context,
7211572047
int argc,
7211672048
sqlite3_value **argv
@@ -72150,14 +72082,16 @@
7215072082
zResult[j++] = '0';
7215172083
}
7215272084
zResult[j] = 0;
7215372085
sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);
7215472086
}else{
72087
+ /* IMP: R-64894-50321 The string "?000" is returned if the argument
72088
+ ** is NULL or contains no ASCII alphabetic characters. */
7215572089
sqlite3_result_text(context, "?000", 4, SQLITE_STATIC);
7215672090
}
7215772091
}
72158
-#endif
72092
+#endif /* SQLITE_SOUNDEX */
7215972093
7216072094
#ifndef SQLITE_OMIT_LOAD_EXTENSION
7216172095
/*
7216272096
** A function that loads a shared-library extension then returns NULL.
7216372097
*/
@@ -78623,11 +78557,11 @@
7862378557
if( rc!=SQLITE_OK ) return;
7862478558
openedTransaction = 1;
7862578559
}
7862678560
7862778561
/* Read the schema cookie from the database. If it does not match the
78628
- ** value stored as part of the in the in-memory schema representation,
78562
+ ** value stored as part of the in-memory schema representation,
7862978563
** set Parse.rc to SQLITE_SCHEMA. */
7863078564
sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);
7863178565
if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){
7863278566
pParse->rc = SQLITE_SCHEMA;
7863378567
}
@@ -79215,10 +79149,43 @@
7921579149
for(i=0; i<pTab->nCol; i++){
7921679150
if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
7921779151
}
7921879152
return -1;
7921979153
}
79154
+
79155
+/*
79156
+** Search the first N tables in pSrc, from left to right, looking for a
79157
+** table that has a column named zCol.
79158
+**
79159
+** When found, set *piTab and *piCol to the table index and column index
79160
+** of the matching column and return TRUE.
79161
+**
79162
+** If not found, return FALSE.
79163
+*/
79164
+static int tableAndColumnIndex(
79165
+ SrcList *pSrc, /* Array of tables to search */
79166
+ int N, /* Number of tables in pSrc->a[] to search */
79167
+ const char *zCol, /* Name of the column we are looking for */
79168
+ int *piTab, /* Write index of pSrc->a[] here */
79169
+ int *piCol /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
79170
+){
79171
+ int i; /* For looping over tables in pSrc */
79172
+ int iCol; /* Index of column matching zCol */
79173
+
79174
+ assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */
79175
+ for(i=0; i<N; i++){
79176
+ iCol = columnIndex(pSrc->a[i].pTab, zCol);
79177
+ if( iCol>=0 ){
79178
+ if( piTab ){
79179
+ *piTab = i;
79180
+ *piCol = iCol;
79181
+ }
79182
+ return 1;
79183
+ }
79184
+ }
79185
+ return 0;
79186
+}
7922079187
7922179188
/*
7922279189
** This function is used to add terms implied by JOIN syntax to the
7922379190
** WHERE clause expression of a SELECT statement. The new term, which
7922479191
** is ANDed with the existing WHERE clause, is of the form:
@@ -79230,27 +79197,29 @@
7923079197
** column iColRight of tab2.
7923179198
*/
7923279199
static void addWhereTerm(
7923379200
Parse *pParse, /* Parsing context */
7923479201
SrcList *pSrc, /* List of tables in FROM clause */
79235
- int iSrc, /* Index of first table to join in pSrc */
79202
+ int iLeft, /* Index of first table to join in pSrc */
7923679203
int iColLeft, /* Index of column in first table */
79204
+ int iRight, /* Index of second table in pSrc */
7923779205
int iColRight, /* Index of column in second table */
7923879206
int isOuterJoin, /* True if this is an OUTER join */
7923979207
Expr **ppWhere /* IN/OUT: The WHERE clause to add to */
7924079208
){
7924179209
sqlite3 *db = pParse->db;
7924279210
Expr *pE1;
7924379211
Expr *pE2;
7924479212
Expr *pEq;
7924579213
79246
- assert( pSrc->nSrc>(iSrc+1) );
79247
- assert( pSrc->a[iSrc].pTab );
79248
- assert( pSrc->a[iSrc+1].pTab );
79214
+ assert( iLeft<iRight );
79215
+ assert( pSrc->nSrc>iRight );
79216
+ assert( pSrc->a[iLeft].pTab );
79217
+ assert( pSrc->a[iRight].pTab );
7924979218
79250
- pE1 = sqlite3CreateColumnExpr(db, pSrc, iSrc, iColLeft);
79251
- pE2 = sqlite3CreateColumnExpr(db, pSrc, iSrc+1, iColRight);
79219
+ pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);
79220
+ pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);
7925279221
7925379222
pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
7925479223
if( pEq && isOuterJoin ){
7925579224
ExprSetProperty(pEq, EP_FromJoin);
7925679225
assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
@@ -79335,15 +79304,19 @@
7933579304
if( pRight->pOn || pRight->pUsing ){
7933679305
sqlite3ErrorMsg(pParse, "a NATURAL join may not have "
7933779306
"an ON or USING clause", 0);
7933879307
return 1;
7933979308
}
79340
- for(j=0; j<pLeftTab->nCol; j++){
79341
- char *zName = pLeftTab->aCol[j].zName;
79342
- int iRightCol = columnIndex(pRightTab, zName);
79343
- if( iRightCol>=0 ){
79344
- addWhereTerm(pParse, pSrc, i, j, iRightCol, isOuter, &p->pWhere);
79309
+ for(j=0; j<pRightTab->nCol; j++){
79310
+ char *zName; /* Name of column in the right table */
79311
+ int iLeft; /* Matching left table */
79312
+ int iLeftCol; /* Matching column in the left table */
79313
+
79314
+ zName = pRightTab->aCol[j].zName;
79315
+ if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){
79316
+ addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,
79317
+ isOuter, &p->pWhere);
7934579318
}
7934679319
}
7934779320
}
7934879321
7934979322
/* Disallow both ON and USING clauses in the same join
@@ -79371,19 +79344,26 @@
7937179344
** not contained in both tables to be joined.
7937279345
*/
7937379346
if( pRight->pUsing ){
7937479347
IdList *pList = pRight->pUsing;
7937579348
for(j=0; j<pList->nId; j++){
79376
- char *zName = pList->a[j].zName;
79377
- int iLeftCol = columnIndex(pLeftTab, zName);
79378
- int iRightCol = columnIndex(pRightTab, zName);
79379
- if( iLeftCol<0 || iRightCol<0 ){
79349
+ char *zName; /* Name of the term in the USING clause */
79350
+ int iLeft; /* Table on the left with matching column name */
79351
+ int iLeftCol; /* Column number of matching column on the left */
79352
+ int iRightCol; /* Column number of matching column on the right */
79353
+
79354
+ zName = pList->a[j].zName;
79355
+ iRightCol = columnIndex(pRightTab, zName);
79356
+ if( iRightCol<0
79357
+ || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)
79358
+ ){
7938079359
sqlite3ErrorMsg(pParse, "cannot join using column %s - column "
7938179360
"not present in both tables", zName);
7938279361
return 1;
7938379362
}
79384
- addWhereTerm(pParse, pSrc, i, iLeftCol, iRightCol, isOuter, &p->pWhere);
79363
+ addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,
79364
+ isOuter, &p->pWhere);
7938579365
}
7938679366
}
7938779367
}
7938879368
return 0;
7938979369
}
@@ -79938,11 +79918,11 @@
7993879918
if( pS ){
7993979919
/* The "table" is actually a sub-select or a view in the FROM clause
7994079920
** of the SELECT statement. Return the declaration type and origin
7994179921
** data for the result-set column of the sub-select.
7994279922
*/
79943
- if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){
79923
+ if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
7994479924
/* If iCol is less than zero, then the expression requests the
7994579925
** rowid of the sub-select or view. This expression is legal (see
7994679926
** test case misc2.2.2) - it always evaluates to NULL.
7994779927
*/
7994879928
NameContext sNC;
@@ -81499,11 +81479,11 @@
8149981479
** (10) The subquery does not use aggregates or the outer query does not
8150081480
** use LIMIT.
8150181481
**
8150281482
** (11) The subquery and the outer query do not both have ORDER BY clauses.
8150381483
**
81504
-** (12) Not implemented. Subsumed into restriction (3). Was previously
81484
+** (**) Not implemented. Subsumed into restriction (3). Was previously
8150581485
** a separate restriction deriving from ticket #350.
8150681486
**
8150781487
** (13) The subquery and outer query do not both use LIMIT
8150881488
**
8150981489
** (14) The subquery does not use OFFSET
@@ -81573,10 +81553,11 @@
8157381553
8157481554
/* Check to see if flattening is permitted. Return 0 if not.
8157581555
*/
8157681556
assert( p!=0 );
8157781557
assert( p->pPrior==0 ); /* Unable to flatten compound queries */
81558
+ if( db->flags & SQLITE_QueryFlattener ) return 0;
8157881559
pSrc = p->pSrc;
8157981560
assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
8158081561
pSubitem = &pSrc->a[iFrom];
8158181562
iParent = pSubitem->iCursor;
8158281563
pSub = pSubitem->pSelect;
@@ -82196,18 +82177,18 @@
8219682177
assert(IsVirtual(pTab));
8219782178
continue;
8219882179
}
8219982180
8220082181
if( i>0 && zTName==0 ){
82201
- struct SrcList_item *pLeft = &pTabList->a[i-1];
82202
- if( (pLeft[1].jointype & JT_NATURAL)!=0 &&
82203
- columnIndex(pLeft->pTab, zName)>=0 ){
82182
+ if( (pFrom->jointype & JT_NATURAL)!=0
82183
+ && tableAndColumnIndex(pTabList, i, zName, 0, 0)
82184
+ ){
8220482185
/* In a NATURAL join, omit the join columns from the
82205
- ** table on the right */
82186
+ ** table to the right of the join */
8220682187
continue;
8220782188
}
82208
- if( sqlite3IdListIndex(pLeft[1].pUsing, zName)>=0 ){
82189
+ if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){
8220982190
/* In a join with a USING clause, omit columns in the
8221082191
** using clause from the table on the right. */
8221182192
continue;
8221282193
}
8221382194
}
@@ -82470,12 +82451,12 @@
8247082451
sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
8247182452
}
8247282453
sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
8247382454
(void*)pF->pFunc, P4_FUNCDEF);
8247482455
sqlite3VdbeChangeP5(v, (u8)nArg);
82475
- sqlite3ReleaseTempRange(pParse, regAgg, nArg);
8247682456
sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
82457
+ sqlite3ReleaseTempRange(pParse, regAgg, nArg);
8247782458
if( addrNext ){
8247882459
sqlite3VdbeResolveLabel(v, addrNext);
8247982460
sqlite3ExprCacheClear(pParse);
8248082461
}
8248182462
}
@@ -82897,11 +82878,11 @@
8289782878
if( pCol->iSorterColumn>=j ){
8289882879
int r1 = j + regBase;
8289982880
int r2;
8290082881
8290182882
r2 = sqlite3ExprCodeGetColumn(pParse,
82902
- pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
82883
+ pCol->pTab, pCol->iColumn, pCol->iTable, r1);
8290382884
if( r1!=r2 ){
8290482885
sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
8290582886
}
8290682887
j++;
8290782888
}
@@ -85309,10 +85290,11 @@
8530985290
Btree *pTemp; /* The temporary database we vacuum into */
8531085291
char *zSql = 0; /* SQL statements */
8531185292
int saved_flags; /* Saved value of the db->flags */
8531285293
int saved_nChange; /* Saved value of db->nChange */
8531385294
int saved_nTotalChange; /* Saved value of db->nTotalChange */
85295
+ void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */
8531485296
Db *pDb = 0; /* Database to detach at end of vacuum */
8531585297
int isMemDb; /* True if vacuuming a :memory: database */
8531685298
int nRes;
8531785299
8531885300
if( !db->autoCommit ){
@@ -85324,12 +85306,14 @@
8532485306
** restored before returning. Then set the writable-schema flag, and
8532585307
** disable CHECK and foreign key constraints. */
8532685308
saved_flags = db->flags;
8532785309
saved_nChange = db->nChange;
8532885310
saved_nTotalChange = db->nTotalChange;
85311
+ saved_xTrace = db->xTrace;
8532985312
db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
8533085313
db->flags &= ~SQLITE_ForeignKeys;
85314
+ db->xTrace = 0;
8533185315
8533285316
pMain = db->aDb[0].pBt;
8533385317
isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
8533485318
8533585319
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -85506,10 +85490,11 @@
8550685490
end_of_vacuum:
8550785491
/* Restore the original value of db->flags */
8550885492
db->flags = saved_flags;
8550985493
db->nChange = saved_nChange;
8551085494
db->nTotalChange = saved_nTotalChange;
85495
+ db->xTrace = saved_xTrace;
8551185496
8551285497
/* Currently there is an SQL level transaction open on the vacuum
8551385498
** database. No locks are held on any other files (since the main file
8551485499
** was committed at the btree level). So it safe to end the transaction
8551585500
** by manually setting the autoCommit flag to true and detaching the
@@ -86200,24 +86185,24 @@
8620086185
rc = SQLITE_NOMEM;
8620186186
}else{
8620286187
pParse->declareVtab = 1;
8620386188
pParse->db = db;
8620486189
86205
- if(
86206
- SQLITE_OK == sqlite3RunParser(pParse, zCreateTable, &zErr) &&
86207
- pParse->pNewTable &&
86208
- !pParse->pNewTable->pSelect &&
86209
- (pParse->pNewTable->tabFlags & TF_Virtual)==0
86190
+ if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
86191
+ && pParse->pNewTable
86192
+ && !db->mallocFailed
86193
+ && !pParse->pNewTable->pSelect
86194
+ && (pParse->pNewTable->tabFlags & TF_Virtual)==0
8621086195
){
8621186196
if( !pTab->aCol ){
8621286197
pTab->aCol = pParse->pNewTable->aCol;
8621386198
pTab->nCol = pParse->pNewTable->nCol;
8621486199
pParse->pNewTable->nCol = 0;
8621586200
pParse->pNewTable->aCol = 0;
8621686201
}
8621786202
db->pVTab = 0;
86218
- } else {
86203
+ }else{
8621986204
sqlite3Error(db, SQLITE_ERROR, zErr);
8622086205
sqlite3DbFree(db, zErr);
8622186206
rc = SQLITE_ERROR;
8622286207
}
8622386208
pParse->declareVtab = 0;
@@ -89653,11 +89638,11 @@
8965389638
** range (if any).
8965489639
*/
8965589640
nConstraint = nEq;
8965689641
if( pRangeEnd ){
8965789642
Expr *pRight = pRangeEnd->pExpr->pRight;
89658
- sqlite3ExprCacheRemove(pParse, regBase+nEq);
89643
+ sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
8965989644
sqlite3ExprCode(pParse, pRight, regBase+nEq);
8966089645
sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
8966189646
if( zAff ){
8966289647
if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
8966389648
/* Since the comparison is to be performed with no conversions
@@ -89758,30 +89743,50 @@
8975889743
** B: <after the loop>
8975989744
**
8976089745
*/
8976189746
WhereClause *pOrWc; /* The OR-clause broken out into subterms */
8976289747
WhereTerm *pFinal; /* Final subterm within the OR-clause. */
89763
- SrcList oneTab; /* Shortened table list */
89748
+ SrcList *pOrTab; /* Shortened table list or OR-clause generation */
8976489749
8976589750
int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
8976689751
int regRowset = 0; /* Register for RowSet object */
8976789752
int regRowid = 0; /* Register holding rowid */
8976889753
int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */
8976989754
int iRetInit; /* Address of regReturn init */
89755
+ int untestedTerms = 0; /* Some terms not completely tested */
8977089756
int ii;
8977189757
8977289758
pTerm = pLevel->plan.u.pTerm;
8977389759
assert( pTerm!=0 );
8977489760
assert( pTerm->eOperator==WO_OR );
8977589761
assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
8977689762
pOrWc = &pTerm->u.pOrInfo->wc;
8977789763
pFinal = &pOrWc->a[pOrWc->nTerm-1];
89764
+ pLevel->op = OP_Return;
89765
+ pLevel->p1 = regReturn;
8977889766
89779
- /* Set up a SrcList containing just the table being scanned by this loop. */
89780
- oneTab.nSrc = 1;
89781
- oneTab.nAlloc = 1;
89782
- oneTab.a[0] = *pTabItem;
89767
+ /* Set up a new SrcList ni pOrTab containing the table being scanned
89768
+ ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
89769
+ ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
89770
+ */
89771
+ if( pWInfo->nLevel>1 ){
89772
+ int nNotReady; /* The number of notReady tables */
89773
+ struct SrcList_item *origSrc; /* Original list of tables */
89774
+ nNotReady = pWInfo->nLevel - iLevel - 1;
89775
+ pOrTab = sqlite3StackAllocRaw(pParse->db,
89776
+ sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
89777
+ if( pOrTab==0 ) return notReady;
89778
+ pOrTab->nAlloc = (i16)(nNotReady + 1);
89779
+ pOrTab->nSrc = pOrTab->nAlloc;
89780
+ memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
89781
+ origSrc = pWInfo->pTabList->a;
89782
+ for(k=1; k<=nNotReady; k++){
89783
+ memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
89784
+ }
89785
+ }else{
89786
+ pOrTab = pWInfo->pTabList;
89787
+ }
8978389788
8978489789
/* Initialize the rowset register to contain NULL. An SQL NULL is
8978589790
** equivalent to an empty rowset.
8978689791
**
8978789792
** Also initialize regReturn to contain the address of the instruction
@@ -89802,36 +89807,42 @@
8980289807
for(ii=0; ii<pOrWc->nTerm; ii++){
8980389808
WhereTerm *pOrTerm = &pOrWc->a[ii];
8980489809
if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){
8980589810
WhereInfo *pSubWInfo; /* Info for single OR-term scan */
8980689811
/* Loop through table entries that match term pOrTerm. */
89807
- pSubWInfo = sqlite3WhereBegin(pParse, &oneTab, pOrTerm->pExpr, 0,
89808
- WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | WHERE_FORCE_TABLE);
89812
+ pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm->pExpr, 0,
89813
+ WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE |
89814
+ WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY);
8980989815
if( pSubWInfo ){
8981089816
if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
8981189817
int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
8981289818
int r;
8981389819
r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
89814
- regRowid, 0);
89820
+ regRowid);
8981589821
sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
8981689822
sqlite3VdbeCurrentAddr(v)+2, r, iSet);
8981789823
}
8981889824
sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
89825
+
89826
+ /* The pSubWInfo->untestedTerms flag means that this OR term
89827
+ ** contained one or more AND term from a notReady table. The
89828
+ ** terms from the notReady table could not be tested and will
89829
+ ** need to be tested later.
89830
+ */
89831
+ if( pSubWInfo->untestedTerms ) untestedTerms = 1;
8981989832
8982089833
/* Finish the loop through table entries that match term pOrTerm. */
8982189834
sqlite3WhereEnd(pSubWInfo);
8982289835
}
8982389836
}
8982489837
}
8982589838
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
89826
- /* sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); */
8982789839
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
8982889840
sqlite3VdbeResolveLabel(v, iLoopBody);
8982989841
89830
- pLevel->op = OP_Return;
89831
- pLevel->p1 = regReturn;
89832
- disableTerm(pLevel, pTerm);
89842
+ if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
89843
+ if( !untestedTerms ) disableTerm(pLevel, pTerm);
8983389844
}else
8983489845
#endif /* SQLITE_OMIT_OR_OPTIMIZATION */
8983589846
8983689847
{
8983789848
/* Case 5: There is no usable index. We must do a complete
@@ -89855,11 +89866,16 @@
8985589866
for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
8985689867
Expr *pE;
8985789868
testcase( pTerm->wtFlags & TERM_VIRTUAL );
8985889869
testcase( pTerm->wtFlags & TERM_CODED );
8985989870
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89860
- if( (pTerm->prereqAll & notReady)!=0 ) continue;
89871
+ if( (pTerm->prereqAll & notReady)!=0 ){
89872
+ testcase( pWInfo->untestedTerms==0
89873
+ && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
89874
+ pWInfo->untestedTerms = 1;
89875
+ continue;
89876
+ }
8986189877
pE = pTerm->pExpr;
8986289878
assert( pE!=0 );
8986389879
if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
8986489880
continue;
8986589881
}
@@ -89878,11 +89894,14 @@
8987889894
sqlite3ExprCacheClear(pParse);
8987989895
for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
8988089896
testcase( pTerm->wtFlags & TERM_VIRTUAL );
8988189897
testcase( pTerm->wtFlags & TERM_CODED );
8988289898
if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89883
- if( (pTerm->prereqAll & notReady)!=0 ) continue;
89899
+ if( (pTerm->prereqAll & notReady)!=0 ){
89900
+ assert( pWInfo->untestedTerms );
89901
+ continue;
89902
+ }
8988489903
assert( pTerm->pExpr );
8988589904
sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
8988689905
pTerm->wtFlags |= TERM_CODED;
8988789906
}
8988889907
}
@@ -90021,10 +90040,11 @@
9002190040
ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */
9002290041
u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */
9002390042
){
9002490043
int i; /* Loop counter */
9002590044
int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
90045
+ int nTabList; /* Number of elements in pTabList */
9002690046
WhereInfo *pWInfo; /* Will become the return value of this function */
9002790047
Vdbe *v = pParse->pVdbe; /* The virtual database engine */
9002890048
Bitmask notReady; /* Cursors that are not yet positioned */
9002990049
WhereMaskSet *pMaskSet; /* The expression mask set */
9003090050
WhereClause *pWC; /* Decomposition of the WHERE clause */
@@ -90039,29 +90059,36 @@
9003990059
*/
9004090060
if( pTabList->nSrc>BMS ){
9004190061
sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
9004290062
return 0;
9004390063
}
90064
+
90065
+ /* This function normally generates a nested loop for all tables in
90066
+ ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should
90067
+ ** only generate code for the first table in pTabList and assume that
90068
+ ** any cursors associated with subsequent tables are uninitialized.
90069
+ */
90070
+ nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
9004490071
9004590072
/* Allocate and initialize the WhereInfo structure that will become the
9004690073
** return value. A single allocation is used to store the WhereInfo
9004790074
** struct, the contents of WhereInfo.a[], the WhereClause structure
9004890075
** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
9004990076
** field (type Bitmask) it must be aligned on an 8-byte boundary on
9005090077
** some architectures. Hence the ROUND8() below.
9005190078
*/
9005290079
db = pParse->db;
90053
- nByteWInfo = ROUND8(sizeof(WhereInfo)+(pTabList->nSrc-1)*sizeof(WhereLevel));
90080
+ nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));
9005490081
pWInfo = sqlite3DbMallocZero(db,
9005590082
nByteWInfo +
9005690083
sizeof(WhereClause) +
9005790084
sizeof(WhereMaskSet)
9005890085
);
9005990086
if( db->mallocFailed ){
9006090087
goto whereBeginError;
9006190088
}
90062
- pWInfo->nLevel = pTabList->nSrc;
90089
+ pWInfo->nLevel = nTabList;
9006390090
pWInfo->pParse = pParse;
9006490091
pWInfo->pTabList = pTabList;
9006590092
pWInfo->iBreak = sqlite3VdbeMakeLabel(v);
9006690093
pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo];
9006790094
pWInfo->wctrlFlags = wctrlFlags;
@@ -90076,11 +90103,11 @@
9007690103
whereSplit(pWC, pWhere, TK_AND);
9007790104
9007890105
/* Special case: a WHERE clause that is constant. Evaluate the
9007990106
** expression and either jump over all of the code or fall thru.
9008090107
*/
90081
- if( pWhere && (pTabList->nSrc==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
90108
+ if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
9008290109
sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);
9008390110
pWhere = 0;
9008490111
}
9008590112
9008690113
/* Assign a bit from the bitmask to every term in the FROM clause.
@@ -90096,10 +90123,15 @@
9009690123
**
9009790124
** Configure the WhereClause.vmask variable so that bits that correspond
9009890125
** to virtual table cursors are set. This is used to selectively disable
9009990126
** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful
9010090127
** with virtual tables.
90128
+ **
90129
+ ** Note that bitmasks are created for all pTabList->nSrc tables in
90130
+ ** pTabList, not just the first nTabList tables. nTabList is normally
90131
+ ** equal to pTabList->nSrc but might be shortened to 1 if the
90132
+ ** WHERE_ONETABLE_ONLY flag is set.
9010190133
*/
9010290134
assert( pWC->vmask==0 && pMaskSet->n==0 );
9010390135
for(i=0; i<pTabList->nSrc; i++){
9010490136
createMask(pMaskSet, pTabList->a[i].iCursor);
9010590137
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -90147,11 +90179,11 @@
9014790179
notReady = ~(Bitmask)0;
9014890180
pTabItem = pTabList->a;
9014990181
pLevel = pWInfo->a;
9015090182
andFlags = ~0;
9015190183
WHERETRACE(("*** Optimizer Start ***\n"));
90152
- for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
90184
+ for(i=iFrom=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
9015390185
WhereCost bestPlan; /* Most efficient plan seen so far */
9015490186
Index *pIdx; /* Index for FROM table at pTabItem */
9015590187
int j; /* For looping over FROM tables */
9015690188
int bestJ = -1; /* The value of j */
9015790189
Bitmask m; /* Bitmask value for j or bestJ */
@@ -90192,12 +90224,12 @@
9019290224
** algorithm may choose to use t2 for the outer loop, which is a much
9019390225
** costlier approach.
9019490226
*/
9019590227
for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){
9019690228
Bitmask mask = (isOptimal ? 0 : notReady);
90197
- assert( (pTabList->nSrc-iFrom)>1 || isOptimal );
90198
- for(j=iFrom, pTabItem=&pTabList->a[j]; j<pTabList->nSrc; j++, pTabItem++){
90229
+ assert( (nTabList-iFrom)>1 || isOptimal );
90230
+ for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){
9019990231
int doNotReorder; /* True if this table should not be reordered */
9020090232
WhereCost sCost; /* Cost information from best[Virtual]Index() */
9020190233
ExprList *pOrderBy; /* ORDER BY clause for index to optimize */
9020290234
9020390235
doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
@@ -90290,11 +90322,11 @@
9029090322
9029190323
/* Open all tables in the pTabList and any indices selected for
9029290324
** searching those tables.
9029390325
*/
9029490326
sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
90295
- for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
90327
+ for(i=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
9029690328
Table *pTab; /* Table to open */
9029790329
int iDb; /* Index of database containing table/index */
9029890330
9029990331
#ifndef SQLITE_OMIT_EXPLAIN
9030090332
if( pParse->explain==2 ){
@@ -90369,11 +90401,11 @@
9036990401
/* Generate the code to do the search. Each iteration of the for
9037090402
** loop below generates code for a single nested loop of the VM
9037190403
** program.
9037290404
*/
9037390405
notReady = ~(Bitmask)0;
90374
- for(i=0; i<pTabList->nSrc; i++){
90406
+ for(i=0; i<nTabList; i++){
9037590407
notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady);
9037690408
pWInfo->iContinue = pWInfo->a[i].addrCont;
9037790409
}
9037890410
9037990411
#ifdef SQLITE_TEST /* For testing and debugging use only */
@@ -90381,11 +90413,11 @@
9038190413
** and the index used to access it (if any). If the table itself
9038290414
** is not used, its name is just '{}'. If no index is used
9038390415
** the index is listed as "{}". If the primary key is used the
9038490416
** index name is '*'.
9038590417
*/
90386
- for(i=0; i<pTabList->nSrc; i++){
90418
+ for(i=0; i<nTabList; i++){
9038790419
char *z;
9038890420
int n;
9038990421
pLevel = &pWInfo->a[i];
9039090422
pTabItem = &pTabList->a[pLevel->iFrom];
9039190423
z = pTabItem->zAlias;
@@ -90449,11 +90481,11 @@
9044990481
sqlite3 *db = pParse->db;
9045090482
9045190483
/* Generate loop termination code.
9045290484
*/
9045390485
sqlite3ExprCacheClear(pParse);
90454
- for(i=pTabList->nSrc-1; i>=0; i--){
90486
+ for(i=pWInfo->nLevel-1; i>=0; i--){
9045590487
pLevel = &pWInfo->a[i];
9045690488
sqlite3VdbeResolveLabel(v, pLevel->addrCont);
9045790489
if( pLevel->op!=OP_Noop ){
9045890490
sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
9045990491
sqlite3VdbeChangeP5(v, pLevel->p5);
@@ -90495,11 +90527,12 @@
9049590527
*/
9049690528
sqlite3VdbeResolveLabel(v, pWInfo->iBreak);
9049790529
9049890530
/* Close all of the cursors that were opened by sqlite3WhereBegin.
9049990531
*/
90500
- for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
90532
+ assert( pWInfo->nLevel==1 || pWInfo->nLevel==pTabList->nSrc );
90533
+ for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){
9050190534
struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
9050290535
Table *pTab = pTabItem->pTab;
9050390536
assert( pTab!=0 );
9050490537
if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
9050590538
if( (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 ){
@@ -90767,12 +90800,12 @@
9076790800
#endif
9076890801
#define sqlite3ParserARG_SDECL Parse *pParse;
9076990802
#define sqlite3ParserARG_PDECL ,Parse *pParse
9077090803
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
9077190804
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
90772
-#define YYNSTATE 629
90773
-#define YYNRULE 329
90805
+#define YYNSTATE 631
90806
+#define YYNRULE 330
9077490807
#define YYFALLBACK 1
9077590808
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
9077690809
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
9077790810
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
9077890811
@@ -90840,473 +90873,474 @@
9084090873
** shifting non-terminals after a reduce.
9084190874
** yy_default[] Default action for each state.
9084290875
*/
9084390876
#define YY_ACTTAB_COUNT (1543)
9084490877
static const YYACTIONTYPE yy_action[] = {
90845
- /* 0 */ 312, 49, 554, 46, 147, 172, 626, 596, 55, 55,
90846
- /* 10 */ 55, 55, 301, 53, 53, 53, 53, 52, 52, 51,
90847
- /* 20 */ 51, 51, 50, 237, 617, 616, 615, 622, 621, 607,
90848
- /* 30 */ 589, 583, 48, 53, 53, 53, 53, 52, 52, 51,
90849
- /* 40 */ 51, 51, 50, 237, 51, 51, 51, 50, 237, 56,
90850
- /* 50 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90851
- /* 60 */ 55, 55, 216, 53, 53, 53, 53, 52, 52, 51,
90852
- /* 70 */ 51, 51, 50, 237, 312, 596, 49, 329, 46, 147,
90878
+ /* 0 */ 313, 49, 556, 46, 147, 172, 628, 598, 55, 55,
90879
+ /* 10 */ 55, 55, 302, 53, 53, 53, 53, 52, 52, 51,
90880
+ /* 20 */ 51, 51, 50, 238, 603, 66, 624, 623, 604, 598,
90881
+ /* 30 */ 591, 585, 48, 53, 53, 53, 53, 52, 52, 51,
90882
+ /* 40 */ 51, 51, 50, 238, 51, 51, 51, 50, 238, 56,
90883
+ /* 50 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90884
+ /* 60 */ 55, 55, 609, 53, 53, 53, 53, 52, 52, 51,
90885
+ /* 70 */ 51, 51, 50, 238, 313, 598, 672, 330, 411, 217,
9085390886
/* 80 */ 32, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90854
- /* 90 */ 50, 237, 329, 622, 621, 619, 618, 166, 433, 547,
90855
- /* 100 */ 381, 378, 377, 549, 589, 583, 389, 490, 166, 58,
90856
- /* 110 */ 376, 381, 378, 377, 390, 299, 622, 621, 480, 67,
90857
- /* 120 */ 670, 376, 620, 56, 57, 47, 581, 580, 582, 582,
90858
- /* 130 */ 54, 54, 55, 55, 55, 55, 253, 53, 53, 53,
90859
- /* 140 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 408,
90860
- /* 150 */ 225, 578, 578, 133, 177, 139, 283, 384, 278, 383,
90861
- /* 160 */ 169, 619, 618, 601, 197, 225, 274, 602, 439, 146,
90862
- /* 170 */ 139, 283, 384, 278, 383, 169, 569, 235, 589, 583,
90863
- /* 180 */ 250, 274, 252, 620, 619, 618, 546, 436, 440, 441,
90864
- /* 190 */ 168, 622, 621, 547, 438, 437, 192, 56, 57, 47,
90865
- /* 200 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90866
- /* 210 */ 6, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90867
- /* 220 */ 50, 237, 312, 282, 52, 52, 51, 51, 51, 50,
90868
- /* 230 */ 237, 490, 183, 281, 547, 166, 439, 565, 381, 378,
90869
- /* 240 */ 377, 596, 606, 67, 327, 172, 620, 596, 376, 442,
90870
- /* 250 */ 236, 620, 589, 583, 306, 423, 440, 339, 251, 619,
90871
- /* 260 */ 618, 331, 574, 573, 7, 524, 194, 481, 16, 594,
90872
- /* 270 */ 189, 56, 57, 47, 581, 580, 582, 582, 54, 54,
90873
- /* 280 */ 55, 55, 55, 55, 545, 53, 53, 53, 53, 52,
90874
- /* 290 */ 52, 51, 51, 51, 50, 237, 312, 410, 464, 421,
90875
- /* 300 */ 592, 592, 592, 671, 146, 410, 1, 205, 410, 596,
90876
- /* 310 */ 622, 621, 413, 420, 949, 596, 949, 340, 236, 530,
90877
- /* 320 */ 413, 600, 74, 413, 236, 552, 589, 583, 547, 600,
90878
- /* 330 */ 95, 68, 600, 88, 551, 622, 621, 465, 542, 38,
90879
- /* 340 */ 49, 599, 46, 147, 465, 56, 57, 47, 581, 580,
90880
- /* 350 */ 582, 582, 54, 54, 55, 55, 55, 55, 424, 53,
90881
- /* 360 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90882
- /* 370 */ 312, 397, 395, 232, 529, 577, 387, 533, 619, 618,
90883
- /* 380 */ 605, 492, 560, 588, 587, 350, 257, 622, 621, 495,
90884
- /* 390 */ 564, 356, 350, 257, 49, 239, 46, 147, 559, 357,
90885
- /* 400 */ 589, 583, 239, 619, 618, 585, 584, 408, 258, 578,
90886
- /* 410 */ 578, 672, 209, 35, 558, 258, 401, 622, 621, 56,
90887
- /* 420 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90888
- /* 430 */ 55, 55, 586, 53, 53, 53, 53, 52, 52, 51,
90889
- /* 440 */ 51, 51, 50, 237, 312, 560, 599, 410, 526, 531,
90890
- /* 450 */ 184, 514, 513, 474, 366, 619, 618, 576, 410, 65,
90891
- /* 460 */ 176, 559, 413, 408, 311, 578, 578, 567, 491, 215,
90892
- /* 470 */ 352, 600, 94, 413, 589, 583, 474, 558, 408, 518,
90893
- /* 480 */ 578, 578, 600, 95, 470, 619, 618, 62, 420, 948,
90894
- /* 490 */ 517, 948, 349, 56, 57, 47, 581, 580, 582, 582,
90895
- /* 500 */ 54, 54, 55, 55, 55, 55, 175, 53, 53, 53,
90896
- /* 510 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 490,
90897
- /* 520 */ 157, 410, 509, 292, 393, 373, 348, 410, 623, 410,
90898
- /* 530 */ 428, 67, 611, 424, 620, 410, 413, 540, 408, 171,
90899
- /* 540 */ 578, 578, 413, 620, 413, 600, 73, 620, 589, 583,
90900
- /* 550 */ 413, 600, 80, 600, 88, 238, 168, 306, 422, 600,
90901
- /* 560 */ 80, 201, 18, 468, 406, 574, 573, 56, 57, 47,
90902
- /* 570 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90903
- /* 580 */ 579, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90904
- /* 590 */ 50, 237, 312, 44, 233, 599, 271, 320, 341, 472,
90905
- /* 600 */ 410, 874, 421, 473, 503, 319, 410, 200, 144, 66,
90906
- /* 610 */ 327, 483, 508, 596, 274, 413, 239, 364, 484, 382,
90907
- /* 620 */ 30, 413, 589, 583, 600, 69, 502, 236, 342, 575,
90908
- /* 630 */ 600, 97, 199, 198, 209, 959, 186, 418, 2, 566,
90909
- /* 640 */ 269, 56, 57, 47, 581, 580, 582, 582, 54, 54,
90910
- /* 650 */ 55, 55, 55, 55, 410, 53, 53, 53, 53, 52,
90911
- /* 660 */ 52, 51, 51, 51, 50, 237, 312, 263, 599, 413,
90912
- /* 670 */ 410, 21, 190, 358, 410, 326, 410, 202, 600, 100,
90913
- /* 680 */ 386, 596, 620, 562, 265, 413, 267, 410, 620, 413,
90914
- /* 690 */ 563, 413, 352, 4, 600, 98, 589, 583, 600, 106,
90915
- /* 700 */ 600, 104, 413, 174, 601, 629, 627, 333, 602, 34,
90916
- /* 710 */ 337, 600, 108, 561, 359, 56, 57, 47, 581, 580,
90917
- /* 720 */ 582, 582, 54, 54, 55, 55, 55, 55, 410, 53,
90918
- /* 730 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90919
- /* 740 */ 312, 410, 499, 413, 167, 567, 405, 215, 504, 505,
90920
- /* 750 */ 316, 557, 600, 109, 353, 13, 413, 410, 12, 410,
90921
- /* 760 */ 538, 410, 335, 358, 223, 600, 134, 571, 571, 620,
90922
- /* 770 */ 589, 583, 413, 20, 413, 620, 413, 272, 620, 167,
90923
- /* 780 */ 167, 600, 135, 600, 61, 600, 105, 317, 148, 56,
90924
- /* 790 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90925
- /* 800 */ 55, 55, 410, 53, 53, 53, 53, 52, 52, 51,
90926
- /* 810 */ 51, 51, 50, 237, 312, 410, 275, 413, 410, 275,
90927
- /* 820 */ 275, 222, 410, 330, 363, 544, 600, 103, 132, 360,
90928
- /* 830 */ 413, 620, 522, 413, 620, 620, 410, 413, 170, 600,
90929
- /* 840 */ 96, 603, 600, 102, 589, 583, 600, 77, 374, 536,
90930
- /* 850 */ 167, 413, 143, 325, 256, 28, 224, 324, 511, 528,
90931
- /* 860 */ 600, 99, 527, 56, 57, 47, 581, 580, 582, 582,
90932
- /* 870 */ 54, 54, 55, 55, 55, 55, 410, 53, 53, 53,
90933
- /* 880 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 410,
90934
- /* 890 */ 275, 413, 410, 469, 275, 167, 458, 39, 171, 37,
90935
- /* 900 */ 600, 138, 214, 144, 413, 620, 142, 413, 410, 620,
90936
- /* 910 */ 410, 358, 239, 600, 137, 230, 600, 136, 589, 583,
90937
- /* 920 */ 457, 263, 23, 413, 351, 413, 620, 323, 445, 501,
90938
- /* 930 */ 23, 322, 600, 76, 600, 93, 620, 56, 45, 47,
90939
- /* 940 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90940
- /* 950 */ 410, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90941
- /* 960 */ 50, 237, 312, 410, 262, 413, 410, 426, 263, 308,
90942
- /* 970 */ 203, 213, 212, 380, 600, 92, 520, 519, 413, 130,
90943
- /* 980 */ 538, 413, 538, 620, 410, 628, 2, 600, 75, 273,
90944
- /* 990 */ 600, 91, 589, 583, 375, 620, 129, 620, 27, 413,
90945
- /* 1000 */ 425, 307, 221, 128, 599, 599, 599, 281, 600, 90,
90946
- /* 1010 */ 371, 452, 57, 47, 581, 580, 582, 582, 54, 54,
90947
- /* 1020 */ 55, 55, 55, 55, 410, 53, 53, 53, 53, 52,
90948
- /* 1030 */ 52, 51, 51, 51, 50, 237, 312, 410, 263, 413,
90949
- /* 1040 */ 410, 263, 263, 365, 208, 321, 206, 542, 600, 101,
90950
- /* 1050 */ 50, 237, 413, 620, 610, 413, 620, 620, 410, 542,
90951
- /* 1060 */ 165, 600, 89, 188, 600, 87, 589, 583, 478, 620,
90952
- /* 1070 */ 467, 519, 125, 413, 569, 235, 542, 367, 599, 475,
90953
- /* 1080 */ 599, 450, 600, 86, 449, 448, 231, 47, 581, 580,
90954
- /* 1090 */ 582, 582, 54, 54, 55, 55, 55, 55, 287, 53,
90955
- /* 1100 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90956
- /* 1110 */ 43, 404, 410, 3, 410, 285, 260, 414, 621, 263,
90957
- /* 1120 */ 609, 627, 333, 43, 404, 410, 3, 413, 407, 413,
90958
- /* 1130 */ 414, 621, 171, 263, 620, 620, 600, 85, 600, 72,
90959
- /* 1140 */ 413, 407, 124, 140, 353, 604, 409, 402, 620, 600,
90960
- /* 1150 */ 71, 291, 471, 495, 160, 123, 593, 565, 620, 620,
90961
- /* 1160 */ 402, 620, 220, 15, 463, 460, 620, 417, 625, 159,
90962
- /* 1170 */ 565, 620, 399, 240, 158, 126, 219, 40, 41, 532,
90963
- /* 1180 */ 410, 207, 121, 120, 42, 412, 411, 620, 263, 594,
90964
- /* 1190 */ 40, 41, 556, 543, 25, 413, 11, 42, 412, 411,
90965
- /* 1200 */ 24, 118, 594, 620, 600, 84, 455, 620, 620, 43,
90966
- /* 1210 */ 404, 218, 3, 539, 156, 599, 414, 621, 113, 239,
90967
- /* 1220 */ 592, 592, 592, 591, 590, 14, 155, 407, 620, 537,
90968
- /* 1230 */ 451, 247, 444, 592, 592, 592, 591, 590, 14, 343,
90969
- /* 1240 */ 410, 111, 410, 277, 620, 410, 402, 410, 507, 110,
90970
- /* 1250 */ 10, 64, 204, 336, 435, 413, 565, 413, 620, 276,
90971
- /* 1260 */ 413, 434, 413, 620, 600, 83, 600, 95, 334, 600,
90972
- /* 1270 */ 82, 600, 81, 150, 620, 488, 40, 41, 270, 268,
90973
- /* 1280 */ 266, 191, 332, 42, 412, 411, 599, 410, 594, 241,
90974
- /* 1290 */ 620, 410, 264, 620, 620, 620, 33, 404, 419, 3,
90975
- /* 1300 */ 107, 229, 413, 414, 621, 149, 413, 620, 397, 181,
90976
- /* 1310 */ 259, 600, 70, 398, 407, 600, 17, 315, 314, 592,
90977
- /* 1320 */ 592, 592, 591, 590, 14, 620, 127, 361, 624, 217,
90978
- /* 1330 */ 462, 461, 354, 402, 304, 303, 302, 179, 300, 254,
90979
- /* 1340 */ 614, 453, 620, 565, 454, 620, 620, 620, 613, 612,
90980
- /* 1350 */ 443, 416, 180, 246, 620, 151, 415, 245, 243, 620,
90981
- /* 1360 */ 178, 598, 242, 40, 41, 620, 244, 8, 620, 239,
90982
- /* 1370 */ 42, 412, 411, 620, 410, 594, 410, 620, 60, 153,
90983
- /* 1380 */ 429, 465, 622, 621, 296, 154, 30, 145, 152, 413,
90984
- /* 1390 */ 388, 413, 295, 394, 294, 620, 31, 392, 600, 79,
90985
- /* 1400 */ 600, 78, 620, 290, 396, 413, 592, 592, 592, 591,
90986
- /* 1410 */ 590, 14, 620, 293, 600, 9, 597, 59, 620, 36,
90987
- /* 1420 */ 555, 173, 565, 234, 185, 288, 29, 541, 391, 345,
90988
- /* 1430 */ 248, 286, 521, 535, 313, 284, 385, 328, 534, 239,
90989
- /* 1440 */ 516, 515, 196, 195, 279, 310, 511, 512, 510, 131,
90990
- /* 1450 */ 524, 227, 258, 228, 594, 309, 487, 486, 493, 226,
90991
- /* 1460 */ 372, 485, 164, 338, 479, 163, 368, 370, 162, 26,
90992
- /* 1470 */ 211, 477, 261, 161, 141, 476, 362, 466, 122, 187,
90993
- /* 1480 */ 119, 456, 347, 117, 346, 592, 592, 592, 116, 115,
90994
- /* 1490 */ 114, 447, 112, 182, 318, 22, 432, 19, 431, 430,
90995
- /* 1500 */ 63, 427, 608, 193, 297, 595, 572, 570, 403, 553,
90996
- /* 1510 */ 550, 289, 280, 508, 498, 497, 496, 494, 379, 355,
90997
- /* 1520 */ 459, 255, 249, 344, 446, 305, 5, 568, 548, 298,
90998
- /* 1530 */ 298, 210, 369, 298, 400, 506, 500, 489, 525, 523,
90999
- /* 1540 */ 482, 239, 237,
90887
+ /* 90 */ 50, 238, 330, 414, 621, 620, 166, 598, 673, 382,
90888
+ /* 100 */ 379, 378, 602, 73, 591, 585, 307, 424, 166, 58,
90889
+ /* 110 */ 377, 382, 379, 378, 516, 515, 624, 623, 254, 200,
90890
+ /* 120 */ 199, 198, 377, 56, 57, 47, 583, 582, 584, 584,
90891
+ /* 130 */ 54, 54, 55, 55, 55, 55, 581, 53, 53, 53,
90892
+ /* 140 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 270,
90893
+ /* 150 */ 226, 422, 283, 133, 177, 139, 284, 385, 279, 384,
90894
+ /* 160 */ 169, 197, 251, 282, 253, 226, 411, 275, 440, 167,
90895
+ /* 170 */ 139, 284, 385, 279, 384, 169, 571, 236, 591, 585,
90896
+ /* 180 */ 240, 414, 275, 622, 621, 620, 674, 437, 441, 442,
90897
+ /* 190 */ 602, 88, 352, 266, 439, 268, 438, 56, 57, 47,
90898
+ /* 200 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90899
+ /* 210 */ 465, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90900
+ /* 220 */ 50, 238, 313, 471, 52, 52, 51, 51, 51, 50,
90901
+ /* 230 */ 238, 234, 166, 491, 567, 382, 379, 378, 1, 440,
90902
+ /* 240 */ 252, 176, 624, 623, 608, 67, 377, 513, 622, 443,
90903
+ /* 250 */ 237, 577, 591, 585, 622, 172, 466, 598, 554, 441,
90904
+ /* 260 */ 340, 409, 526, 580, 580, 349, 596, 553, 194, 482,
90905
+ /* 270 */ 175, 56, 57, 47, 583, 582, 584, 584, 54, 54,
90906
+ /* 280 */ 55, 55, 55, 55, 562, 53, 53, 53, 53, 52,
90907
+ /* 290 */ 52, 51, 51, 51, 50, 238, 313, 594, 594, 594,
90908
+ /* 300 */ 561, 578, 469, 65, 259, 351, 258, 411, 624, 623,
90909
+ /* 310 */ 621, 620, 332, 576, 575, 240, 560, 568, 520, 411,
90910
+ /* 320 */ 341, 237, 414, 624, 623, 598, 591, 585, 542, 519,
90911
+ /* 330 */ 171, 602, 95, 68, 414, 624, 623, 624, 623, 38,
90912
+ /* 340 */ 877, 506, 507, 602, 88, 56, 57, 47, 583, 582,
90913
+ /* 350 */ 584, 584, 54, 54, 55, 55, 55, 55, 532, 53,
90914
+ /* 360 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90915
+ /* 370 */ 313, 411, 579, 398, 531, 237, 621, 620, 388, 625,
90916
+ /* 380 */ 500, 206, 167, 396, 233, 312, 414, 387, 569, 492,
90917
+ /* 390 */ 216, 621, 620, 566, 622, 602, 74, 533, 210, 491,
90918
+ /* 400 */ 591, 585, 548, 621, 620, 621, 620, 300, 598, 466,
90919
+ /* 410 */ 481, 67, 603, 35, 622, 601, 604, 547, 6, 56,
90920
+ /* 420 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90921
+ /* 430 */ 55, 55, 601, 53, 53, 53, 53, 52, 52, 51,
90922
+ /* 440 */ 51, 51, 50, 238, 313, 411, 184, 409, 528, 580,
90923
+ /* 450 */ 580, 551, 962, 186, 419, 2, 353, 259, 351, 258,
90924
+ /* 460 */ 414, 409, 411, 580, 580, 44, 411, 544, 240, 602,
90925
+ /* 470 */ 94, 190, 7, 62, 591, 585, 598, 414, 350, 607,
90926
+ /* 480 */ 493, 414, 409, 317, 580, 580, 602, 95, 496, 565,
90927
+ /* 490 */ 602, 80, 203, 56, 57, 47, 583, 582, 584, 584,
90928
+ /* 500 */ 54, 54, 55, 55, 55, 55, 535, 53, 53, 53,
90929
+ /* 510 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 202,
90930
+ /* 520 */ 564, 293, 511, 49, 562, 46, 147, 411, 394, 183,
90931
+ /* 530 */ 563, 549, 505, 549, 174, 409, 322, 580, 580, 39,
90932
+ /* 540 */ 561, 37, 414, 624, 623, 192, 473, 383, 591, 585,
90933
+ /* 550 */ 474, 602, 80, 601, 504, 544, 560, 364, 402, 210,
90934
+ /* 560 */ 421, 952, 361, 952, 365, 201, 144, 56, 57, 47,
90935
+ /* 570 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90936
+ /* 580 */ 559, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90937
+ /* 590 */ 50, 238, 313, 601, 232, 264, 272, 321, 374, 484,
90938
+ /* 600 */ 510, 146, 342, 146, 328, 425, 485, 407, 576, 575,
90939
+ /* 610 */ 622, 621, 620, 49, 168, 46, 147, 353, 546, 491,
90940
+ /* 620 */ 204, 240, 591, 585, 421, 951, 549, 951, 549, 168,
90941
+ /* 630 */ 429, 67, 390, 343, 622, 434, 307, 423, 338, 360,
90942
+ /* 640 */ 391, 56, 57, 47, 583, 582, 584, 584, 54, 54,
90943
+ /* 650 */ 55, 55, 55, 55, 601, 53, 53, 53, 53, 52,
90944
+ /* 660 */ 52, 51, 51, 51, 50, 238, 313, 34, 318, 425,
90945
+ /* 670 */ 237, 21, 359, 273, 411, 167, 411, 276, 411, 540,
90946
+ /* 680 */ 411, 422, 13, 318, 619, 618, 617, 622, 275, 414,
90947
+ /* 690 */ 336, 414, 622, 414, 622, 414, 591, 585, 602, 69,
90948
+ /* 700 */ 602, 97, 602, 100, 602, 98, 631, 629, 334, 475,
90949
+ /* 710 */ 475, 367, 319, 148, 327, 56, 57, 47, 583, 582,
90950
+ /* 720 */ 584, 584, 54, 54, 55, 55, 55, 55, 411, 53,
90951
+ /* 730 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90952
+ /* 740 */ 313, 411, 331, 414, 411, 49, 276, 46, 147, 569,
90953
+ /* 750 */ 406, 216, 602, 106, 573, 573, 414, 354, 524, 414,
90954
+ /* 760 */ 411, 622, 411, 224, 4, 602, 104, 605, 602, 108,
90955
+ /* 770 */ 591, 585, 622, 20, 375, 414, 167, 414, 215, 144,
90956
+ /* 780 */ 470, 239, 167, 225, 602, 109, 602, 134, 18, 56,
90957
+ /* 790 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90958
+ /* 800 */ 55, 55, 411, 53, 53, 53, 53, 52, 52, 51,
90959
+ /* 810 */ 51, 51, 50, 238, 313, 411, 276, 414, 12, 459,
90960
+ /* 820 */ 276, 171, 411, 16, 223, 189, 602, 135, 354, 170,
90961
+ /* 830 */ 414, 622, 630, 2, 411, 622, 540, 414, 143, 602,
90962
+ /* 840 */ 61, 359, 132, 622, 591, 585, 602, 105, 458, 414,
90963
+ /* 850 */ 23, 622, 446, 326, 23, 538, 622, 325, 602, 103,
90964
+ /* 860 */ 427, 530, 309, 56, 57, 47, 583, 582, 584, 584,
90965
+ /* 870 */ 54, 54, 55, 55, 55, 55, 411, 53, 53, 53,
90966
+ /* 880 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 411,
90967
+ /* 890 */ 264, 414, 411, 276, 359, 219, 157, 214, 357, 366,
90968
+ /* 900 */ 602, 96, 522, 521, 414, 622, 358, 414, 622, 622,
90969
+ /* 910 */ 411, 613, 612, 602, 102, 142, 602, 77, 591, 585,
90970
+ /* 920 */ 529, 540, 231, 426, 308, 414, 622, 622, 468, 521,
90971
+ /* 930 */ 324, 601, 257, 263, 602, 99, 622, 56, 45, 47,
90972
+ /* 940 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90973
+ /* 950 */ 411, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90974
+ /* 960 */ 50, 238, 313, 264, 264, 414, 411, 213, 209, 544,
90975
+ /* 970 */ 544, 207, 611, 28, 602, 138, 50, 238, 622, 622,
90976
+ /* 980 */ 381, 414, 503, 140, 323, 222, 274, 622, 590, 589,
90977
+ /* 990 */ 602, 137, 591, 585, 629, 334, 606, 30, 622, 571,
90978
+ /* 1000 */ 236, 601, 601, 130, 496, 601, 453, 451, 288, 286,
90979
+ /* 1010 */ 587, 586, 57, 47, 583, 582, 584, 584, 54, 54,
90980
+ /* 1020 */ 55, 55, 55, 55, 411, 53, 53, 53, 53, 52,
90981
+ /* 1030 */ 52, 51, 51, 51, 50, 238, 313, 588, 411, 414,
90982
+ /* 1040 */ 411, 264, 410, 129, 595, 400, 27, 376, 602, 136,
90983
+ /* 1050 */ 128, 165, 479, 414, 282, 414, 622, 622, 411, 622,
90984
+ /* 1060 */ 622, 411, 602, 76, 602, 93, 591, 585, 188, 372,
90985
+ /* 1070 */ 368, 125, 476, 414, 261, 160, 414, 171, 124, 472,
90986
+ /* 1080 */ 123, 15, 602, 92, 450, 602, 75, 47, 583, 582,
90987
+ /* 1090 */ 584, 584, 54, 54, 55, 55, 55, 55, 464, 53,
90988
+ /* 1100 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90989
+ /* 1110 */ 43, 405, 264, 3, 558, 264, 545, 415, 623, 159,
90990
+ /* 1120 */ 541, 158, 539, 278, 25, 461, 121, 622, 408, 622,
90991
+ /* 1130 */ 622, 622, 24, 43, 405, 622, 3, 622, 622, 120,
90992
+ /* 1140 */ 415, 623, 11, 456, 411, 156, 452, 403, 509, 277,
90993
+ /* 1150 */ 118, 408, 489, 113, 205, 449, 271, 567, 221, 414,
90994
+ /* 1160 */ 269, 267, 155, 622, 622, 111, 411, 622, 602, 95,
90995
+ /* 1170 */ 403, 622, 411, 110, 10, 622, 622, 40, 41, 534,
90996
+ /* 1180 */ 567, 414, 64, 264, 42, 413, 412, 414, 601, 596,
90997
+ /* 1190 */ 602, 91, 445, 436, 150, 435, 602, 90, 622, 265,
90998
+ /* 1200 */ 40, 41, 337, 242, 411, 191, 333, 42, 413, 412,
90999
+ /* 1210 */ 398, 420, 596, 316, 622, 399, 260, 107, 230, 414,
91000
+ /* 1220 */ 594, 594, 594, 593, 592, 14, 220, 411, 602, 101,
91001
+ /* 1230 */ 240, 622, 43, 405, 362, 3, 149, 315, 626, 415,
91002
+ /* 1240 */ 623, 127, 414, 594, 594, 594, 593, 592, 14, 622,
91003
+ /* 1250 */ 408, 602, 89, 411, 181, 33, 405, 463, 3, 411,
91004
+ /* 1260 */ 264, 462, 415, 623, 616, 615, 614, 355, 414, 403,
91005
+ /* 1270 */ 417, 416, 622, 408, 414, 622, 622, 602, 87, 567,
91006
+ /* 1280 */ 418, 627, 622, 602, 86, 8, 241, 180, 126, 255,
91007
+ /* 1290 */ 600, 178, 403, 240, 208, 455, 395, 294, 444, 40,
91008
+ /* 1300 */ 41, 297, 567, 248, 622, 296, 42, 413, 412, 247,
91009
+ /* 1310 */ 622, 596, 244, 622, 30, 60, 31, 243, 430, 624,
91010
+ /* 1320 */ 623, 292, 40, 41, 622, 295, 145, 622, 601, 42,
91011
+ /* 1330 */ 413, 412, 622, 622, 596, 393, 622, 397, 599, 59,
91012
+ /* 1340 */ 235, 622, 594, 594, 594, 593, 592, 14, 218, 291,
91013
+ /* 1350 */ 622, 36, 344, 305, 304, 303, 179, 301, 411, 567,
91014
+ /* 1360 */ 454, 557, 173, 185, 622, 594, 594, 594, 593, 592,
91015
+ /* 1370 */ 14, 411, 29, 414, 151, 289, 246, 523, 411, 196,
91016
+ /* 1380 */ 195, 335, 602, 85, 411, 245, 414, 526, 392, 543,
91017
+ /* 1390 */ 411, 596, 287, 414, 285, 602, 72, 537, 153, 414,
91018
+ /* 1400 */ 466, 411, 602, 71, 154, 414, 411, 152, 602, 84,
91019
+ /* 1410 */ 386, 536, 329, 411, 602, 83, 414, 518, 280, 411,
91020
+ /* 1420 */ 513, 414, 594, 594, 594, 602, 82, 517, 414, 311,
91021
+ /* 1430 */ 602, 81, 411, 514, 414, 512, 131, 602, 70, 229,
91022
+ /* 1440 */ 228, 227, 494, 602, 17, 411, 488, 414, 259, 346,
91023
+ /* 1450 */ 249, 389, 487, 486, 314, 164, 602, 79, 310, 240,
91024
+ /* 1460 */ 414, 373, 480, 163, 262, 371, 414, 162, 369, 602,
91025
+ /* 1470 */ 78, 212, 478, 26, 477, 602, 9, 161, 467, 363,
91026
+ /* 1480 */ 141, 122, 339, 187, 119, 457, 348, 117, 347, 116,
91027
+ /* 1490 */ 115, 114, 448, 112, 182, 320, 22, 433, 19, 432,
91028
+ /* 1500 */ 431, 63, 428, 610, 193, 298, 597, 574, 572, 404,
91029
+ /* 1510 */ 555, 552, 290, 281, 510, 499, 498, 497, 495, 380,
91030
+ /* 1520 */ 356, 460, 256, 250, 345, 447, 306, 5, 570, 550,
91031
+ /* 1530 */ 299, 211, 370, 401, 550, 508, 502, 501, 490, 527,
91032
+ /* 1540 */ 525, 483, 238,
9100091033
};
9100191034
static const YYCODETYPE yy_lookahead[] = {
9100291035
/* 0 */ 19, 222, 223, 224, 225, 24, 1, 26, 77, 78,
9100391036
/* 10 */ 79, 80, 15, 82, 83, 84, 85, 86, 87, 88,
91004
- /* 20 */ 89, 90, 91, 92, 7, 8, 9, 26, 27, 23,
91037
+ /* 20 */ 89, 90, 91, 92, 113, 22, 26, 27, 117, 26,
9100591038
/* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88,
9100691039
/* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68,
9100791040
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91008
- /* 60 */ 79, 80, 22, 82, 83, 84, 85, 86, 87, 88,
91009
- /* 70 */ 89, 90, 91, 92, 19, 94, 222, 19, 224, 225,
91041
+ /* 60 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
91042
+ /* 70 */ 89, 90, 91, 92, 19, 94, 118, 19, 150, 22,
9101091043
/* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91011
- /* 90 */ 91, 92, 19, 26, 27, 94, 95, 96, 244, 25,
91012
- /* 100 */ 99, 100, 101, 25, 49, 50, 19, 150, 96, 54,
91013
- /* 110 */ 109, 99, 100, 101, 27, 158, 26, 27, 161, 162,
91014
- /* 120 */ 117, 109, 165, 68, 69, 70, 71, 72, 73, 74,
91015
- /* 130 */ 75, 76, 77, 78, 79, 80, 16, 82, 83, 84,
91016
- /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 111,
91017
- /* 150 */ 92, 113, 114, 24, 96, 97, 98, 99, 100, 101,
91018
- /* 160 */ 102, 94, 95, 112, 25, 92, 108, 116, 150, 95,
91044
+ /* 90 */ 91, 92, 19, 165, 94, 95, 96, 94, 118, 99,
91045
+ /* 100 */ 100, 101, 174, 175, 49, 50, 22, 23, 96, 54,
91046
+ /* 110 */ 110, 99, 100, 101, 7, 8, 26, 27, 16, 105,
91047
+ /* 120 */ 106, 107, 110, 68, 69, 70, 71, 72, 73, 74,
91048
+ /* 130 */ 75, 76, 77, 78, 79, 80, 113, 82, 83, 84,
91049
+ /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 16,
91050
+ /* 150 */ 92, 67, 98, 24, 96, 97, 98, 99, 100, 101,
91051
+ /* 160 */ 102, 25, 60, 109, 62, 92, 150, 109, 150, 25,
9101991052
/* 170 */ 97, 98, 99, 100, 101, 102, 86, 87, 49, 50,
91020
- /* 180 */ 60, 108, 62, 165, 94, 95, 119, 97, 170, 171,
91021
- /* 190 */ 50, 26, 27, 119, 104, 105, 118, 68, 69, 70,
91053
+ /* 180 */ 116, 165, 109, 165, 94, 95, 118, 97, 170, 171,
91054
+ /* 190 */ 174, 175, 128, 60, 104, 62, 106, 68, 69, 70,
9102291055
/* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91023
- /* 210 */ 22, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91024
- /* 220 */ 91, 92, 19, 98, 86, 87, 88, 89, 90, 91,
91025
- /* 230 */ 92, 150, 23, 108, 25, 96, 150, 66, 99, 100,
91026
- /* 240 */ 101, 26, 161, 162, 104, 24, 165, 26, 109, 231,
91027
- /* 250 */ 232, 165, 49, 50, 22, 23, 170, 171, 138, 94,
91028
- /* 260 */ 95, 169, 170, 171, 76, 94, 185, 186, 22, 98,
91029
- /* 270 */ 24, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91030
- /* 280 */ 77, 78, 79, 80, 119, 82, 83, 84, 85, 86,
91031
- /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 11, 67,
91032
- /* 300 */ 129, 130, 131, 117, 95, 150, 22, 160, 150, 94,
91033
- /* 310 */ 26, 27, 165, 22, 23, 94, 25, 231, 232, 23,
91034
- /* 320 */ 165, 174, 175, 165, 232, 32, 49, 50, 119, 174,
91035
- /* 330 */ 175, 22, 174, 175, 41, 26, 27, 57, 166, 136,
91036
- /* 340 */ 222, 194, 224, 225, 57, 68, 69, 70, 71, 72,
91037
- /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 67, 82,
91056
+ /* 210 */ 11, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91057
+ /* 220 */ 91, 92, 19, 21, 86, 87, 88, 89, 90, 91,
91058
+ /* 230 */ 92, 215, 96, 150, 66, 99, 100, 101, 22, 150,
91059
+ /* 240 */ 138, 118, 26, 27, 161, 162, 110, 103, 165, 231,
91060
+ /* 250 */ 232, 23, 49, 50, 165, 24, 57, 26, 32, 170,
91061
+ /* 260 */ 171, 112, 94, 114, 115, 63, 98, 41, 185, 186,
91062
+ /* 270 */ 118, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91063
+ /* 280 */ 77, 78, 79, 80, 12, 82, 83, 84, 85, 86,
91064
+ /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
91065
+ /* 300 */ 28, 23, 100, 25, 105, 106, 107, 150, 26, 27,
91066
+ /* 310 */ 94, 95, 169, 170, 171, 116, 44, 23, 46, 150,
91067
+ /* 320 */ 231, 232, 165, 26, 27, 94, 49, 50, 23, 57,
91068
+ /* 330 */ 25, 174, 175, 22, 165, 26, 27, 26, 27, 136,
91069
+ /* 340 */ 138, 97, 98, 174, 175, 68, 69, 70, 71, 72,
91070
+ /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 23, 82,
9103891071
/* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91039
- /* 370 */ 19, 216, 214, 215, 23, 23, 221, 205, 94, 95,
91040
- /* 380 */ 172, 173, 12, 49, 50, 105, 106, 26, 27, 181,
91041
- /* 390 */ 23, 19, 105, 106, 222, 115, 224, 225, 28, 27,
91042
- /* 400 */ 49, 50, 115, 94, 95, 71, 72, 111, 128, 113,
91043
- /* 410 */ 114, 117, 160, 136, 44, 128, 46, 26, 27, 68,
91072
+ /* 370 */ 19, 150, 23, 216, 23, 232, 94, 95, 221, 150,
91073
+ /* 380 */ 23, 160, 25, 214, 215, 163, 165, 88, 166, 167,
91074
+ /* 390 */ 168, 94, 95, 23, 165, 174, 175, 88, 160, 150,
91075
+ /* 400 */ 49, 50, 120, 94, 95, 94, 95, 158, 26, 57,
91076
+ /* 410 */ 161, 162, 113, 136, 165, 194, 117, 120, 22, 68,
9104491077
/* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91045
- /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
91046
- /* 440 */ 89, 90, 91, 92, 19, 12, 194, 150, 23, 88,
91047
- /* 450 */ 23, 7, 8, 105, 106, 94, 95, 23, 150, 25,
91048
- /* 460 */ 117, 28, 165, 111, 163, 113, 114, 166, 167, 168,
91049
- /* 470 */ 218, 174, 175, 165, 49, 50, 128, 44, 111, 46,
91050
- /* 480 */ 113, 114, 174, 175, 21, 94, 95, 235, 22, 23,
91051
- /* 490 */ 57, 25, 240, 68, 69, 70, 71, 72, 73, 74,
91052
- /* 500 */ 75, 76, 77, 78, 79, 80, 117, 82, 83, 84,
91053
- /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
91054
- /* 520 */ 25, 150, 23, 226, 216, 19, 63, 150, 150, 150,
91055
- /* 530 */ 161, 162, 150, 67, 165, 150, 165, 23, 111, 25,
91056
- /* 540 */ 113, 114, 165, 165, 165, 174, 175, 165, 49, 50,
91057
- /* 550 */ 165, 174, 175, 174, 175, 197, 50, 22, 23, 174,
91058
- /* 560 */ 175, 160, 204, 100, 169, 170, 171, 68, 69, 70,
91078
+ /* 430 */ 79, 80, 194, 82, 83, 84, 85, 86, 87, 88,
91079
+ /* 440 */ 89, 90, 91, 92, 19, 150, 23, 112, 23, 114,
91080
+ /* 450 */ 115, 25, 142, 143, 144, 145, 218, 105, 106, 107,
91081
+ /* 460 */ 165, 112, 150, 114, 115, 22, 150, 166, 116, 174,
91082
+ /* 470 */ 175, 22, 76, 235, 49, 50, 94, 165, 240, 172,
91083
+ /* 480 */ 173, 165, 112, 155, 114, 115, 174, 175, 181, 11,
91084
+ /* 490 */ 174, 175, 22, 68, 69, 70, 71, 72, 73, 74,
91085
+ /* 500 */ 75, 76, 77, 78, 79, 80, 205, 82, 83, 84,
91086
+ /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 160,
91087
+ /* 520 */ 23, 226, 23, 222, 12, 224, 225, 150, 216, 23,
91088
+ /* 530 */ 23, 25, 36, 25, 25, 112, 220, 114, 115, 135,
91089
+ /* 540 */ 28, 137, 165, 26, 27, 119, 30, 51, 49, 50,
91090
+ /* 550 */ 34, 174, 175, 194, 58, 166, 44, 229, 46, 160,
91091
+ /* 560 */ 22, 23, 234, 25, 48, 206, 207, 68, 69, 70,
9105991092
/* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91060
- /* 580 */ 112, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91061
- /* 590 */ 91, 92, 19, 22, 215, 194, 23, 220, 97, 30,
91062
- /* 600 */ 150, 138, 67, 34, 36, 220, 150, 206, 207, 22,
91063
- /* 610 */ 104, 181, 182, 26, 108, 165, 115, 48, 188, 51,
91064
- /* 620 */ 125, 165, 49, 50, 174, 175, 58, 232, 127, 23,
91065
- /* 630 */ 174, 175, 105, 106, 160, 142, 143, 144, 145, 23,
91066
- /* 640 */ 16, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91067
- /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
91068
- /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 165,
91069
- /* 670 */ 150, 24, 22, 150, 150, 107, 150, 22, 174, 175,
91070
- /* 680 */ 88, 94, 165, 23, 60, 165, 62, 150, 165, 165,
91071
- /* 690 */ 11, 165, 218, 35, 174, 175, 49, 50, 174, 175,
91072
- /* 700 */ 174, 175, 165, 25, 112, 0, 1, 2, 116, 25,
91073
- /* 710 */ 193, 174, 175, 23, 240, 68, 69, 70, 71, 72,
91093
+ /* 580 */ 23, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91094
+ /* 590 */ 91, 92, 19, 194, 205, 150, 23, 220, 19, 181,
91095
+ /* 600 */ 182, 95, 97, 95, 108, 67, 188, 169, 170, 171,
91096
+ /* 610 */ 165, 94, 95, 222, 50, 224, 225, 218, 120, 150,
91097
+ /* 620 */ 160, 116, 49, 50, 22, 23, 120, 25, 120, 50,
91098
+ /* 630 */ 161, 162, 19, 128, 165, 244, 22, 23, 193, 240,
91099
+ /* 640 */ 27, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91100
+ /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
91101
+ /* 660 */ 87, 88, 89, 90, 91, 92, 19, 25, 104, 67,
91102
+ /* 670 */ 232, 24, 150, 23, 150, 25, 150, 150, 150, 150,
91103
+ /* 680 */ 150, 67, 25, 104, 7, 8, 9, 165, 109, 165,
91104
+ /* 690 */ 245, 165, 165, 165, 165, 165, 49, 50, 174, 175,
91105
+ /* 700 */ 174, 175, 174, 175, 174, 175, 0, 1, 2, 105,
91106
+ /* 710 */ 106, 107, 248, 249, 187, 68, 69, 70, 71, 72,
9107491107
/* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
9107591108
/* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91076
- /* 740 */ 19, 150, 23, 165, 25, 166, 167, 168, 97, 98,
91077
- /* 750 */ 155, 23, 174, 175, 150, 25, 165, 150, 35, 150,
91078
- /* 760 */ 150, 150, 245, 150, 241, 174, 175, 129, 130, 165,
91079
- /* 770 */ 49, 50, 165, 52, 165, 165, 165, 23, 165, 25,
91080
- /* 780 */ 25, 174, 175, 174, 175, 174, 175, 248, 249, 68,
91109
+ /* 740 */ 19, 150, 213, 165, 150, 222, 150, 224, 225, 166,
91110
+ /* 750 */ 167, 168, 174, 175, 129, 130, 165, 150, 165, 165,
91111
+ /* 760 */ 150, 165, 150, 241, 35, 174, 175, 174, 174, 175,
91112
+ /* 770 */ 49, 50, 165, 52, 23, 165, 25, 165, 206, 207,
91113
+ /* 780 */ 23, 197, 25, 187, 174, 175, 174, 175, 204, 68,
9108191114
/* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
9108291115
/* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
91083
- /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 150, 150,
91084
- /* 820 */ 150, 217, 150, 213, 229, 119, 174, 175, 22, 234,
91085
- /* 830 */ 165, 165, 165, 165, 165, 165, 150, 165, 35, 174,
91086
- /* 840 */ 175, 174, 174, 175, 49, 50, 174, 175, 23, 27,
91087
- /* 850 */ 25, 165, 117, 187, 241, 22, 187, 187, 103, 23,
91088
- /* 860 */ 174, 175, 23, 68, 69, 70, 71, 72, 73, 74,
91116
+ /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 35, 23,
91117
+ /* 820 */ 150, 25, 150, 22, 217, 24, 174, 175, 150, 35,
91118
+ /* 830 */ 165, 165, 144, 145, 150, 165, 150, 165, 118, 174,
91119
+ /* 840 */ 175, 150, 22, 165, 49, 50, 174, 175, 23, 165,
91120
+ /* 850 */ 25, 165, 23, 187, 25, 27, 165, 187, 174, 175,
91121
+ /* 860 */ 23, 23, 25, 68, 69, 70, 71, 72, 73, 74,
9108991122
/* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
9109091123
/* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
91091
- /* 890 */ 150, 165, 150, 23, 150, 25, 23, 135, 25, 137,
91092
- /* 900 */ 174, 175, 206, 207, 165, 165, 39, 165, 150, 165,
91093
- /* 910 */ 150, 150, 115, 174, 175, 52, 174, 175, 49, 50,
91094
- /* 920 */ 23, 150, 25, 165, 127, 165, 165, 187, 23, 29,
91095
- /* 930 */ 25, 187, 174, 175, 174, 175, 165, 68, 69, 70,
91124
+ /* 890 */ 150, 165, 150, 150, 150, 217, 25, 160, 19, 213,
91125
+ /* 900 */ 174, 175, 190, 191, 165, 165, 27, 165, 165, 165,
91126
+ /* 910 */ 150, 150, 150, 174, 175, 39, 174, 175, 49, 50,
91127
+ /* 920 */ 23, 150, 52, 250, 251, 165, 165, 165, 190, 191,
91128
+ /* 930 */ 187, 194, 241, 193, 174, 175, 165, 68, 69, 70,
9109691129
/* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
9109791130
/* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91098
- /* 960 */ 91, 92, 19, 150, 193, 165, 150, 23, 150, 25,
91099
- /* 970 */ 160, 160, 160, 52, 174, 175, 190, 191, 165, 22,
91100
- /* 980 */ 150, 165, 150, 165, 150, 144, 145, 174, 175, 23,
91101
- /* 990 */ 174, 175, 49, 50, 52, 165, 22, 165, 22, 165,
91102
- /* 1000 */ 250, 251, 241, 22, 194, 194, 194, 108, 174, 175,
91103
- /* 1010 */ 19, 193, 69, 70, 71, 72, 73, 74, 75, 76,
91131
+ /* 960 */ 91, 92, 19, 150, 150, 165, 150, 160, 160, 166,
91132
+ /* 970 */ 166, 160, 150, 22, 174, 175, 91, 92, 165, 165,
91133
+ /* 980 */ 52, 165, 29, 150, 213, 241, 23, 165, 49, 50,
91134
+ /* 990 */ 174, 175, 49, 50, 1, 2, 173, 126, 165, 86,
91135
+ /* 1000 */ 87, 194, 194, 22, 181, 194, 193, 193, 205, 205,
91136
+ /* 1010 */ 71, 72, 69, 70, 71, 72, 73, 74, 75, 76,
9110491137
/* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
91105
- /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
91106
- /* 1040 */ 150, 150, 150, 213, 160, 213, 160, 166, 174, 175,
91107
- /* 1050 */ 91, 92, 165, 165, 150, 165, 165, 165, 150, 166,
91108
- /* 1060 */ 102, 174, 175, 24, 174, 175, 49, 50, 20, 165,
91109
- /* 1070 */ 190, 191, 104, 165, 86, 87, 166, 43, 194, 59,
91110
- /* 1080 */ 194, 193, 174, 175, 193, 193, 205, 70, 71, 72,
91111
- /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 205, 82,
91138
+ /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 98, 150, 165,
91139
+ /* 1040 */ 150, 150, 150, 22, 150, 150, 22, 52, 174, 175,
91140
+ /* 1050 */ 22, 102, 20, 165, 109, 165, 165, 165, 150, 165,
91141
+ /* 1060 */ 165, 150, 174, 175, 174, 175, 49, 50, 24, 19,
91142
+ /* 1070 */ 43, 104, 59, 165, 138, 104, 165, 25, 53, 53,
91143
+ /* 1080 */ 22, 5, 174, 175, 193, 174, 175, 70, 71, 72,
91144
+ /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 1, 82,
9111291145
/* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91113
- /* 1110 */ 19, 20, 150, 22, 150, 205, 138, 26, 27, 150,
91114
- /* 1120 */ 150, 1, 2, 19, 20, 150, 22, 165, 37, 165,
91115
- /* 1130 */ 26, 27, 25, 150, 165, 165, 174, 175, 174, 175,
91116
- /* 1140 */ 165, 37, 53, 150, 150, 173, 150, 56, 165, 174,
91117
- /* 1150 */ 175, 150, 53, 181, 104, 22, 150, 66, 165, 165,
91118
- /* 1160 */ 56, 165, 193, 5, 1, 27, 165, 146, 147, 117,
91119
- /* 1170 */ 66, 165, 150, 152, 35, 154, 193, 86, 87, 88,
91120
- /* 1180 */ 150, 160, 107, 126, 93, 94, 95, 165, 150, 98,
91121
- /* 1190 */ 86, 87, 150, 150, 76, 165, 22, 93, 94, 95,
91122
- /* 1200 */ 76, 118, 98, 165, 174, 175, 1, 165, 165, 19,
91123
- /* 1210 */ 20, 217, 22, 150, 16, 194, 26, 27, 118, 115,
91124
- /* 1220 */ 129, 130, 131, 132, 133, 134, 120, 37, 165, 150,
91125
- /* 1230 */ 20, 193, 127, 129, 130, 131, 132, 133, 134, 218,
91126
- /* 1240 */ 150, 107, 150, 150, 165, 150, 56, 150, 150, 126,
91127
- /* 1250 */ 22, 16, 160, 65, 23, 165, 66, 165, 165, 150,
91128
- /* 1260 */ 165, 23, 165, 165, 174, 175, 174, 175, 247, 174,
91129
- /* 1270 */ 175, 174, 175, 15, 165, 150, 86, 87, 150, 150,
91130
- /* 1280 */ 150, 22, 3, 93, 94, 95, 194, 150, 98, 140,
91131
- /* 1290 */ 165, 150, 150, 165, 165, 165, 19, 20, 4, 22,
91132
- /* 1300 */ 164, 180, 165, 26, 27, 249, 165, 165, 216, 6,
91133
- /* 1310 */ 150, 174, 175, 221, 37, 174, 175, 252, 252, 129,
91134
- /* 1320 */ 130, 131, 132, 133, 134, 165, 180, 150, 149, 5,
91135
- /* 1330 */ 150, 150, 150, 56, 10, 11, 12, 13, 14, 150,
91136
- /* 1340 */ 149, 17, 165, 66, 150, 165, 165, 165, 149, 13,
91137
- /* 1350 */ 150, 149, 151, 150, 165, 31, 159, 33, 150, 165,
91138
- /* 1360 */ 151, 194, 150, 86, 87, 165, 42, 25, 165, 115,
91139
- /* 1370 */ 93, 94, 95, 165, 150, 98, 150, 165, 22, 55,
91140
- /* 1380 */ 150, 57, 26, 27, 199, 61, 125, 150, 64, 165,
91141
- /* 1390 */ 150, 165, 200, 122, 201, 165, 123, 150, 174, 175,
91142
- /* 1400 */ 174, 175, 165, 150, 121, 165, 129, 130, 131, 132,
91143
- /* 1410 */ 133, 134, 165, 202, 174, 175, 203, 124, 165, 135,
91144
- /* 1420 */ 157, 117, 66, 227, 157, 210, 104, 211, 120, 105,
91145
- /* 1430 */ 106, 210, 176, 211, 110, 210, 104, 47, 211, 115,
91146
- /* 1440 */ 176, 184, 86, 87, 176, 179, 103, 178, 176, 22,
91147
- /* 1450 */ 94, 92, 128, 230, 98, 179, 176, 176, 184, 230,
91148
- /* 1460 */ 18, 176, 156, 139, 157, 156, 45, 157, 156, 135,
91149
- /* 1470 */ 157, 157, 238, 156, 68, 239, 157, 189, 189, 219,
91150
- /* 1480 */ 22, 199, 157, 192, 18, 129, 130, 131, 192, 192,
91151
- /* 1490 */ 192, 199, 189, 219, 157, 243, 40, 243, 157, 157,
91152
- /* 1500 */ 246, 38, 153, 196, 198, 166, 233, 233, 228, 177,
91153
- /* 1510 */ 177, 209, 177, 182, 177, 166, 177, 166, 178, 242,
91154
- /* 1520 */ 199, 242, 209, 209, 199, 148, 196, 166, 208, 195,
91155
- /* 1530 */ 195, 236, 237, 195, 191, 183, 183, 186, 174, 174,
91156
- /* 1540 */ 186, 115, 92,
91146
+ /* 1110 */ 19, 20, 150, 22, 150, 150, 150, 26, 27, 118,
91147
+ /* 1120 */ 150, 35, 150, 150, 76, 27, 108, 165, 37, 165,
91148
+ /* 1130 */ 165, 165, 76, 19, 20, 165, 22, 165, 165, 127,
91149
+ /* 1140 */ 26, 27, 22, 1, 150, 16, 20, 56, 150, 150,
91150
+ /* 1150 */ 119, 37, 150, 119, 160, 193, 150, 66, 193, 165,
91151
+ /* 1160 */ 150, 150, 121, 165, 165, 108, 150, 165, 174, 175,
91152
+ /* 1170 */ 56, 165, 150, 127, 22, 165, 165, 86, 87, 88,
91153
+ /* 1180 */ 66, 165, 16, 150, 93, 94, 95, 165, 194, 98,
91154
+ /* 1190 */ 174, 175, 128, 23, 15, 23, 174, 175, 165, 150,
91155
+ /* 1200 */ 86, 87, 65, 140, 150, 22, 3, 93, 94, 95,
91156
+ /* 1210 */ 216, 4, 98, 252, 165, 221, 150, 164, 180, 165,
91157
+ /* 1220 */ 129, 130, 131, 132, 133, 134, 193, 150, 174, 175,
91158
+ /* 1230 */ 116, 165, 19, 20, 150, 22, 249, 252, 149, 26,
91159
+ /* 1240 */ 27, 180, 165, 129, 130, 131, 132, 133, 134, 165,
91160
+ /* 1250 */ 37, 174, 175, 150, 6, 19, 20, 150, 22, 150,
91161
+ /* 1260 */ 150, 150, 26, 27, 149, 149, 13, 150, 165, 56,
91162
+ /* 1270 */ 149, 159, 165, 37, 165, 165, 165, 174, 175, 66,
91163
+ /* 1280 */ 146, 147, 165, 174, 175, 25, 152, 151, 154, 150,
91164
+ /* 1290 */ 194, 151, 56, 116, 160, 150, 123, 202, 150, 86,
91165
+ /* 1300 */ 87, 199, 66, 193, 165, 200, 93, 94, 95, 150,
91166
+ /* 1310 */ 165, 98, 150, 165, 126, 22, 124, 150, 150, 26,
91167
+ /* 1320 */ 27, 150, 86, 87, 165, 201, 150, 165, 194, 93,
91168
+ /* 1330 */ 94, 95, 165, 165, 98, 150, 165, 122, 203, 125,
91169
+ /* 1340 */ 227, 165, 129, 130, 131, 132, 133, 134, 5, 150,
91170
+ /* 1350 */ 165, 135, 218, 10, 11, 12, 13, 14, 150, 66,
91171
+ /* 1360 */ 17, 157, 118, 157, 165, 129, 130, 131, 132, 133,
91172
+ /* 1370 */ 134, 150, 104, 165, 31, 210, 33, 176, 150, 86,
91173
+ /* 1380 */ 87, 247, 174, 175, 150, 42, 165, 94, 121, 211,
91174
+ /* 1390 */ 150, 98, 210, 165, 210, 174, 175, 211, 55, 165,
91175
+ /* 1400 */ 57, 150, 174, 175, 61, 165, 150, 64, 174, 175,
91176
+ /* 1410 */ 104, 211, 47, 150, 174, 175, 165, 176, 176, 150,
91177
+ /* 1420 */ 103, 165, 129, 130, 131, 174, 175, 184, 165, 179,
91178
+ /* 1430 */ 174, 175, 150, 178, 165, 176, 22, 174, 175, 230,
91179
+ /* 1440 */ 92, 230, 184, 174, 175, 150, 176, 165, 105, 106,
91180
+ /* 1450 */ 107, 150, 176, 176, 111, 156, 174, 175, 179, 116,
91181
+ /* 1460 */ 165, 18, 157, 156, 238, 157, 165, 156, 45, 174,
91182
+ /* 1470 */ 175, 157, 157, 135, 239, 174, 175, 156, 189, 157,
91183
+ /* 1480 */ 68, 189, 139, 219, 22, 199, 157, 192, 18, 192,
91184
+ /* 1490 */ 192, 192, 199, 189, 219, 157, 243, 40, 243, 157,
91185
+ /* 1500 */ 157, 246, 38, 153, 196, 198, 166, 233, 233, 228,
91186
+ /* 1510 */ 177, 177, 209, 177, 182, 177, 166, 177, 166, 178,
91187
+ /* 1520 */ 242, 199, 242, 209, 209, 199, 148, 196, 166, 208,
91188
+ /* 1530 */ 195, 236, 237, 191, 208, 183, 183, 183, 186, 174,
91189
+ /* 1540 */ 174, 186, 92,
9115791190
};
91158
-#define YY_SHIFT_USE_DFLT (-70)
91159
-#define YY_SHIFT_COUNT (417)
91160
-#define YY_SHIFT_MIN (-69)
91161
-#define YY_SHIFT_MAX (1466)
91191
+#define YY_SHIFT_USE_DFLT (-90)
91192
+#define YY_SHIFT_COUNT (418)
91193
+#define YY_SHIFT_MIN (-89)
91194
+#define YY_SHIFT_MAX (1470)
9116291195
static const short yy_shift_ofst[] = {
91163
- /* 0 */ 1120, 1104, 1324, 1104, 1190, 1190, 90, 90, 1, -19,
91164
- /* 10 */ 1190, 1190, 1190, 1190, 1190, 280, 391, 721, 1091, 1190,
91165
- /* 20 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91166
- /* 30 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91167
- /* 40 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1277, 1190, 1190,
91168
- /* 50 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91169
- /* 60 */ 1190, -49, 287, 391, 391, 988, 988, 215, 1426, 55,
91196
+ /* 0 */ 993, 1114, 1343, 1114, 1213, 1213, 90, 90, 0, -19,
91197
+ /* 10 */ 1213, 1213, 1213, 1213, 1213, 352, 517, 721, 1091, 1213,
91198
+ /* 20 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91199
+ /* 30 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91200
+ /* 40 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1236, 1213, 1213,
91201
+ /* 50 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91202
+ /* 60 */ 1213, -49, 199, 517, 517, 913, 913, 382, 1177, 55,
9117091203
/* 70 */ 647, 573, 499, 425, 351, 277, 203, 129, 795, 795,
9117191204
/* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795,
9117291205
/* 90 */ 795, 795, 795, 795, 795, 795, 869, 795, 943, 1017,
9117391206
/* 100 */ 1017, -69, -69, -69, -69, -1, -1, 58, 138, -44,
91174
- /* 110 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91175
- /* 120 */ 391, 391, 391, 391, 391, 391, 463, 506, 391, 391,
91176
- /* 130 */ 391, 391, 391, 215, 959, 1450, -70, -70, -70, 1356,
91177
- /* 140 */ 73, 433, 433, 361, 309, 165, 67, 284, 466, 291,
91178
- /* 150 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91179
- /* 160 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91180
- /* 170 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91181
- /* 180 */ 391, 391, 501, 221, 221, 221, 705, 797, 1426, 1426,
91182
- /* 190 */ 1426, -70, -70, -70, 139, 171, 171, 12, 568, 568,
91183
- /* 200 */ 209, 427, 370, 367, 352, 296, 38, 38, 38, 38,
91184
- /* 210 */ 348, 569, 38, 38, 74, 587, 592, 17, 495, 87,
91185
- /* 220 */ 87, 372, 495, 372, 755, 215, 293, 215, 293, 140,
91186
- /* 230 */ 293, 87, 293, 293, 762, 638, 638, 215, 78, 51,
91187
- /* 240 */ 246, 1463, 1304, 1304, 1456, 1456, 1304, 1458, 1406, 1261,
91188
- /* 250 */ 1466, 1466, 1466, 1466, 1304, 1261, 1458, 1406, 1406, 1304,
91189
- /* 260 */ 1442, 1334, 1421, 1304, 1304, 1442, 1304, 1442, 1304, 1442,
91190
- /* 270 */ 1427, 1332, 1332, 1332, 1390, 1359, 1359, 1427, 1332, 1343,
91191
- /* 280 */ 1332, 1390, 1332, 1332, 1308, 1322, 1308, 1322, 1308, 1322,
91192
- /* 290 */ 1304, 1304, 1284, 1293, 1283, 1273, 1271, 1261, 1254, 1342,
91193
- /* 300 */ 1336, 1336, 1303, 1303, 1303, 1303, -70, -70, -70, -70,
91194
- /* 310 */ -70, -70, 334, 120, 535, 232, 624, 944, 188, 905,
91195
- /* 320 */ 897, 873, 870, 825, 754, 719, 651, 527, 444, 125,
91196
- /* 330 */ 514, 434, 1294, 1279, 1259, 1149, 1258, 1188, 1235, 1238,
91197
- /* 340 */ 1231, 1105, 1228, 1123, 1134, 1100, 1210, 1106, 1198, 1205,
91198
- /* 350 */ 1083, 1174, 1057, 1124, 1118, 1075, 1138, 1139, 1052, 1163,
91199
- /* 360 */ 1158, 1133, 1050, 978, 1099, 1107, 1089, 1020, 1034, 968,
91200
- /* 370 */ 1039, 1048, 991, 899, 958, 981, 942, 976, 974, 966,
91201
- /* 380 */ 957, 921, 900, 833, 863, 867, 839, 836, 735, 822,
91202
- /* 390 */ 803, 806, 706, 684, 723, 730, 658, 684, 728, 690,
91203
- /* 400 */ 678, 660, 655, 679, 650, 616, 606, 571, 468, 389,
91204
- /* 410 */ 343, 294, 186, 3, 40, 6, -3, 5,
91207
+ /* 110 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91208
+ /* 120 */ 517, 517, 517, 517, 517, 517, 202, 579, 517, 517,
91209
+ /* 130 */ 517, 517, 517, 382, 885, 1450, -90, -90, -90, 1293,
91210
+ /* 140 */ 73, 272, 272, 309, 311, 297, 282, 216, 602, 538,
91211
+ /* 150 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91212
+ /* 160 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91213
+ /* 170 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91214
+ /* 180 */ 517, 517, 505, 231, 231, 231, 706, 64, 1177, 1177,
91215
+ /* 190 */ 1177, -90, -90, -90, 136, 168, 168, 12, 496, 496,
91216
+ /* 200 */ 496, 506, 423, 512, 370, 349, 335, 149, 149, 149,
91217
+ /* 210 */ 149, 604, 516, 149, 149, 508, 3, 299, 677, 871,
91218
+ /* 220 */ 613, 613, 879, 871, 879, 144, 382, 226, 382, 226,
91219
+ /* 230 */ 564, 226, 613, 226, 226, 404, 625, 625, 382, 426,
91220
+ /* 240 */ -89, 801, 1464, 1244, 1244, 1457, 1457, 1244, 1462, 1412,
91221
+ /* 250 */ 1188, 1470, 1470, 1470, 1470, 1244, 1188, 1462, 1412, 1412,
91222
+ /* 260 */ 1244, 1443, 1338, 1423, 1244, 1244, 1443, 1244, 1443, 1244,
91223
+ /* 270 */ 1443, 1414, 1306, 1306, 1306, 1365, 1348, 1348, 1414, 1306,
91224
+ /* 280 */ 1317, 1306, 1365, 1306, 1306, 1267, 1268, 1267, 1268, 1267,
91225
+ /* 290 */ 1268, 1244, 1244, 1216, 1214, 1215, 1192, 1173, 1188, 1177,
91226
+ /* 300 */ 1260, 1253, 1253, 1248, 1248, 1248, 1248, -90, -90, -90,
91227
+ /* 310 */ -90, -90, -90, 939, 102, 614, 84, 133, 14, 837,
91228
+ /* 320 */ 396, 829, 825, 796, 757, 751, 650, 357, 244, 107,
91229
+ /* 330 */ 54, 305, 278, 1207, 1203, 1183, 1063, 1179, 1137, 1166,
91230
+ /* 340 */ 1172, 1170, 1064, 1152, 1046, 1057, 1034, 1126, 1041, 1129,
91231
+ /* 350 */ 1142, 1031, 1120, 1012, 1056, 1048, 1018, 1098, 1086, 1001,
91232
+ /* 360 */ 1097, 1076, 1058, 971, 936, 1026, 1052, 1025, 1013, 1027,
91233
+ /* 370 */ 967, 1044, 1032, 1050, 945, 949, 1028, 995, 1024, 1021,
91234
+ /* 380 */ 963, 981, 928, 953, 951, 870, 876, 897, 838, 720,
91235
+ /* 390 */ 828, 794, 820, 498, 642, 783, 657, 729, 642, 557,
91236
+ /* 400 */ 507, 509, 497, 470, 478, 449, 294, 228, 443, 23,
91237
+ /* 410 */ 152, 123, 68, -20, -42, 57, 39, -3, 5,
9120591238
};
9120691239
#define YY_REDUCE_USE_DFLT (-222)
91207
-#define YY_REDUCE_COUNT (311)
91240
+#define YY_REDUCE_COUNT (312)
9120891241
#define YY_REDUCE_MIN (-221)
91209
-#define YY_REDUCE_MAX (1377)
91242
+#define YY_REDUCE_MAX (1378)
9121091243
static const short yy_reduce_ofst[] = {
91211
- /* 0 */ 493, 1092, 1021, 147, 158, 155, 86, 18, 81, 172,
91212
- /* 10 */ 385, 377, 308, 379, 297, 252, -43, -146, 1240, 1226,
91213
- /* 20 */ 1224, 1141, 1137, 1097, 1095, 1090, 1030, 975, 964, 962,
91214
- /* 30 */ 908, 890, 887, 874, 834, 816, 813, 800, 760, 758,
91215
- /* 40 */ 742, 739, 726, 686, 672, 668, 665, 652, 611, 609,
91216
- /* 50 */ 607, 591, 578, 537, 526, 524, 520, 504, 456, 450,
91217
- /* 60 */ 371, -221, 474, 369, 517, 395, 92, 301, 401, 118,
91218
- /* 70 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91219
- /* 80 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91220
- /* 90 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91221
- /* 100 */ 118, 118, 118, 118, 118, 118, 118, 208, 118, 118,
91222
- /* 110 */ 1038, 994, 983, 969, 892, 891, 888, 818, 761, 832,
91223
- /* 120 */ 613, 604, 523, 744, 830, 771, 595, 430, 740, 670,
91224
- /* 130 */ 669, 666, 610, 579, 118, 118, 118, 118, 118, 667,
91225
- /* 140 */ 972, 880, 786, 996, 1253, 1247, 1237, 1001, 750, 750,
91226
- /* 150 */ 1230, 1212, 1208, 1203, 1200, 1194, 1189, 1182, 1181, 1180,
91227
- /* 160 */ 1177, 1160, 1142, 1130, 1129, 1128, 1125, 1109, 1098, 1093,
91228
- /* 170 */ 1079, 1063, 1043, 1042, 1022, 1006, 996, 993, 970, 904,
91229
- /* 180 */ 382, 378, 886, 910, 893, 881, 841, 884, 812, 811,
91230
- /* 190 */ 810, 539, 696, 358, 1354, 1365, 1364, 1351, 1353, 1352,
91231
- /* 200 */ 1320, 1338, 1343, 1338, 1338, 1338, 1338, 1338, 1338, 1338,
91232
- /* 210 */ 1295, 1295, 1335, 1334, 1320, 1361, 1330, 1377, 1325, 1314,
91233
- /* 220 */ 1313, 1279, 1321, 1277, 1340, 1351, 1339, 1349, 1337, 1331,
91234
- /* 230 */ 1335, 1302, 1333, 1332, 1280, 1274, 1273, 1339, 1306, 1307,
91235
- /* 240 */ 1349, 1254, 1342, 1341, 1254, 1252, 1337, 1274, 1303, 1292,
91236
- /* 250 */ 1298, 1297, 1296, 1291, 1325, 1282, 1260, 1289, 1288, 1319,
91237
- /* 260 */ 1317, 1236, 1234, 1314, 1313, 1312, 1310, 1309, 1307, 1306,
91238
- /* 270 */ 1276, 1285, 1281, 1280, 1274, 1229, 1223, 1266, 1272, 1269,
91239
- /* 280 */ 1268, 1257, 1264, 1256, 1227, 1225, 1222, 1221, 1216, 1215,
91240
- /* 290 */ 1267, 1263, 1196, 1213, 1211, 1193, 1192, 1185, 1167, 1197,
91241
- /* 300 */ 1209, 1201, 1202, 1199, 1191, 1179, 1066, 1065, 1056, 1146,
91242
- /* 310 */ 1121, 1136,
91244
+ /* 0 */ 310, 994, 1134, 221, 169, 157, 89, 18, 83, 301,
91245
+ /* 10 */ 377, 316, 312, 16, 295, 238, 249, 391, 1301, 1295,
91246
+ /* 20 */ 1282, 1269, 1263, 1256, 1251, 1240, 1234, 1228, 1221, 1208,
91247
+ /* 30 */ 1109, 1103, 1077, 1054, 1022, 1016, 911, 908, 890, 888,
91248
+ /* 40 */ 874, 816, 800, 760, 742, 739, 726, 684, 672, 665,
91249
+ /* 50 */ 652, 612, 610, 594, 591, 578, 530, 528, 526, 524,
91250
+ /* 60 */ -72, -221, 399, 469, 445, 438, 143, 222, 359, 523,
91251
+ /* 70 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91252
+ /* 80 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91253
+ /* 90 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91254
+ /* 100 */ 523, 523, 523, 523, 523, 523, 523, 307, 523, 523,
91255
+ /* 110 */ 1110, 678, 1033, 965, 962, 891, 814, 813, 744, 771,
91256
+ /* 120 */ 691, 607, 522, 743, 686, 740, 328, 418, 670, 666,
91257
+ /* 130 */ 596, 527, 529, 583, 523, 523, 523, 523, 523, 593,
91258
+ /* 140 */ 823, 738, 712, 892, 1199, 1185, 1176, 1171, 673, 673,
91259
+ /* 150 */ 1168, 1167, 1162, 1159, 1148, 1145, 1139, 1117, 1111, 1107,
91260
+ /* 160 */ 1084, 1066, 1049, 1011, 1010, 1006, 1002, 999, 998, 973,
91261
+ /* 170 */ 972, 970, 966, 964, 895, 894, 892, 833, 822, 762,
91262
+ /* 180 */ 761, 229, 811, 804, 803, 389, 688, 808, 807, 737,
91263
+ /* 190 */ 460, 464, 572, 584, 1355, 1366, 1365, 1352, 1354, 1353,
91264
+ /* 200 */ 1352, 1326, 1335, 1342, 1335, 1335, 1335, 1335, 1335, 1335,
91265
+ /* 210 */ 1335, 1295, 1295, 1335, 1335, 1321, 1362, 1331, 1378, 1326,
91266
+ /* 220 */ 1315, 1314, 1280, 1322, 1278, 1341, 1352, 1340, 1350, 1338,
91267
+ /* 230 */ 1332, 1336, 1303, 1334, 1333, 1281, 1275, 1274, 1340, 1307,
91268
+ /* 240 */ 1308, 1350, 1255, 1343, 1342, 1255, 1253, 1338, 1275, 1304,
91269
+ /* 250 */ 1293, 1299, 1298, 1297, 1295, 1329, 1286, 1264, 1292, 1289,
91270
+ /* 260 */ 1322, 1321, 1235, 1226, 1315, 1314, 1311, 1308, 1307, 1305,
91271
+ /* 270 */ 1299, 1279, 1277, 1276, 1270, 1258, 1211, 1209, 1250, 1259,
91272
+ /* 280 */ 1255, 1242, 1243, 1241, 1201, 1200, 1184, 1186, 1182, 1178,
91273
+ /* 290 */ 1165, 1206, 1204, 1113, 1135, 1095, 1124, 1105, 1102, 1096,
91274
+ /* 300 */ 1112, 1140, 1136, 1121, 1116, 1115, 1089, 985, 961, 987,
91275
+ /* 310 */ 1061, 1038, 1053,
9124391276
};
9124491277
static const YYACTIONTYPE yy_default[] = {
91245
- /* 0 */ 634, 869, 958, 958, 958, 869, 898, 898, 958, 757,
91246
- /* 10 */ 958, 958, 958, 958, 867, 958, 958, 932, 958, 958,
91247
- /* 20 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91248
- /* 30 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91249
- /* 40 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91250
- /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91251
- /* 60 */ 958, 841, 958, 958, 958, 898, 898, 673, 761, 792,
91252
- /* 70 */ 958, 958, 958, 958, 958, 958, 958, 958, 931, 933,
91253
- /* 80 */ 807, 806, 800, 799, 911, 772, 797, 790, 783, 794,
91254
- /* 90 */ 870, 863, 864, 862, 866, 871, 958, 793, 829, 847,
91255
- /* 100 */ 828, 846, 853, 845, 831, 840, 830, 665, 832, 833,
91256
- /* 110 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91257
- /* 120 */ 958, 958, 958, 958, 958, 958, 660, 726, 958, 958,
91258
- /* 130 */ 958, 958, 958, 958, 834, 835, 850, 849, 848, 958,
91259
- /* 140 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91260
- /* 150 */ 958, 938, 936, 958, 882, 958, 958, 958, 958, 958,
91261
- /* 160 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91262
- /* 170 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91263
- /* 180 */ 958, 640, 958, 757, 757, 757, 634, 958, 958, 958,
91264
- /* 190 */ 958, 950, 761, 751, 717, 958, 958, 958, 958, 958,
91265
- /* 200 */ 958, 958, 958, 958, 958, 958, 802, 740, 921, 923,
91266
- /* 210 */ 958, 904, 738, 662, 759, 675, 749, 642, 796, 774,
91267
- /* 220 */ 774, 916, 796, 916, 699, 958, 786, 958, 786, 696,
91268
- /* 230 */ 786, 774, 786, 786, 865, 958, 958, 958, 758, 749,
91269
- /* 240 */ 958, 943, 765, 765, 935, 935, 765, 808, 730, 796,
91270
- /* 250 */ 737, 737, 737, 737, 765, 796, 808, 730, 730, 765,
91271
- /* 260 */ 657, 910, 908, 765, 765, 657, 765, 657, 765, 657,
91272
- /* 270 */ 875, 728, 728, 728, 713, 879, 879, 875, 728, 699,
91273
- /* 280 */ 728, 713, 728, 728, 778, 773, 778, 773, 778, 773,
91274
- /* 290 */ 765, 765, 958, 791, 779, 789, 787, 796, 958, 716,
91275
- /* 300 */ 650, 650, 639, 639, 639, 639, 955, 955, 950, 701,
91276
- /* 310 */ 701, 683, 958, 958, 958, 958, 958, 958, 884, 958,
91277
- /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91278
- /* 330 */ 958, 958, 958, 635, 945, 958, 958, 942, 958, 958,
91279
- /* 340 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91280
- /* 350 */ 958, 958, 958, 958, 958, 958, 958, 958, 914, 958,
91281
- /* 360 */ 958, 958, 958, 958, 958, 907, 906, 958, 958, 958,
91282
- /* 370 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91283
- /* 380 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91284
- /* 390 */ 958, 958, 958, 788, 958, 780, 958, 868, 958, 958,
91285
- /* 400 */ 958, 958, 958, 958, 958, 958, 958, 958, 743, 817,
91286
- /* 410 */ 958, 816, 820, 815, 667, 958, 648, 958, 631, 636,
91287
- /* 420 */ 954, 957, 956, 953, 952, 951, 946, 944, 941, 940,
91288
- /* 430 */ 939, 937, 934, 930, 888, 886, 893, 892, 891, 890,
91289
- /* 440 */ 889, 887, 885, 883, 803, 801, 798, 795, 929, 881,
91290
- /* 450 */ 739, 736, 735, 656, 947, 913, 922, 920, 809, 919,
91291
- /* 460 */ 918, 917, 915, 912, 899, 805, 804, 731, 873, 872,
91292
- /* 470 */ 659, 903, 902, 901, 905, 909, 900, 767, 658, 655,
91293
- /* 480 */ 664, 720, 719, 727, 725, 724, 723, 722, 721, 718,
91294
- /* 490 */ 666, 674, 685, 712, 698, 697, 878, 880, 877, 876,
91295
- /* 500 */ 705, 710, 709, 708, 707, 706, 704, 703, 702, 695,
91296
- /* 510 */ 694, 700, 693, 715, 714, 711, 692, 734, 733, 732,
91297
- /* 520 */ 729, 691, 690, 689, 820, 688, 687, 826, 825, 813,
91298
- /* 530 */ 857, 754, 753, 752, 764, 763, 776, 775, 811, 810,
91299
- /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
91300
- /* 550 */ 782, 785, 784, 781, 842, 859, 766, 856, 928, 927,
91301
- /* 560 */ 926, 925, 924, 861, 860, 827, 824, 678, 679, 897,
91302
- /* 570 */ 895, 896, 894, 681, 680, 677, 676, 858, 745, 744,
91303
- /* 580 */ 854, 851, 843, 838, 855, 852, 844, 839, 837, 836,
91304
- /* 590 */ 822, 821, 819, 818, 814, 823, 669, 746, 742, 741,
91305
- /* 600 */ 812, 748, 747, 686, 684, 682, 663, 661, 654, 652,
91306
- /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
91307
- /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
91278
+ /* 0 */ 636, 872, 961, 961, 961, 872, 901, 901, 961, 760,
91279
+ /* 10 */ 961, 961, 961, 961, 870, 961, 961, 935, 961, 961,
91280
+ /* 20 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91281
+ /* 30 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91282
+ /* 40 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91283
+ /* 50 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91284
+ /* 60 */ 961, 844, 961, 961, 961, 901, 901, 675, 764, 795,
91285
+ /* 70 */ 961, 961, 961, 961, 961, 961, 961, 961, 934, 936,
91286
+ /* 80 */ 810, 809, 803, 802, 914, 775, 800, 793, 786, 797,
91287
+ /* 90 */ 873, 866, 867, 865, 869, 874, 961, 796, 832, 850,
91288
+ /* 100 */ 831, 849, 856, 848, 834, 843, 833, 667, 835, 836,
91289
+ /* 110 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91290
+ /* 120 */ 961, 961, 961, 961, 961, 961, 662, 729, 961, 961,
91291
+ /* 130 */ 961, 961, 961, 961, 837, 838, 853, 852, 851, 961,
91292
+ /* 140 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91293
+ /* 150 */ 961, 941, 939, 961, 885, 961, 961, 961, 961, 961,
91294
+ /* 160 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91295
+ /* 170 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91296
+ /* 180 */ 961, 642, 961, 760, 760, 760, 636, 961, 961, 961,
91297
+ /* 190 */ 961, 953, 764, 754, 720, 961, 961, 961, 961, 961,
91298
+ /* 200 */ 961, 961, 961, 961, 961, 961, 961, 805, 743, 924,
91299
+ /* 210 */ 926, 961, 907, 741, 664, 762, 677, 752, 644, 799,
91300
+ /* 220 */ 777, 777, 919, 799, 919, 701, 961, 789, 961, 789,
91301
+ /* 230 */ 698, 789, 777, 789, 789, 868, 961, 961, 961, 761,
91302
+ /* 240 */ 752, 961, 946, 768, 768, 938, 938, 768, 811, 733,
91303
+ /* 250 */ 799, 740, 740, 740, 740, 768, 799, 811, 733, 733,
91304
+ /* 260 */ 768, 659, 913, 911, 768, 768, 659, 768, 659, 768,
91305
+ /* 270 */ 659, 878, 731, 731, 731, 716, 882, 882, 878, 731,
91306
+ /* 280 */ 701, 731, 716, 731, 731, 781, 776, 781, 776, 781,
91307
+ /* 290 */ 776, 768, 768, 961, 794, 782, 792, 790, 799, 961,
91308
+ /* 300 */ 719, 652, 652, 641, 641, 641, 641, 958, 958, 953,
91309
+ /* 310 */ 703, 703, 685, 961, 961, 961, 961, 961, 961, 961,
91310
+ /* 320 */ 887, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91311
+ /* 330 */ 961, 961, 961, 961, 637, 948, 961, 961, 945, 961,
91312
+ /* 340 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91313
+ /* 350 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 917,
91314
+ /* 360 */ 961, 961, 961, 961, 961, 961, 910, 909, 961, 961,
91315
+ /* 370 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91316
+ /* 380 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91317
+ /* 390 */ 961, 961, 961, 961, 791, 961, 783, 961, 871, 961,
91318
+ /* 400 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 746,
91319
+ /* 410 */ 820, 961, 819, 823, 818, 669, 961, 650, 961, 633,
91320
+ /* 420 */ 638, 957, 960, 959, 956, 955, 954, 949, 947, 944,
91321
+ /* 430 */ 943, 942, 940, 937, 933, 891, 889, 896, 895, 894,
91322
+ /* 440 */ 893, 892, 890, 888, 886, 806, 804, 801, 798, 932,
91323
+ /* 450 */ 884, 742, 739, 738, 658, 950, 916, 925, 923, 812,
91324
+ /* 460 */ 922, 921, 920, 918, 915, 902, 808, 807, 734, 876,
91325
+ /* 470 */ 875, 661, 906, 905, 904, 908, 912, 903, 770, 660,
91326
+ /* 480 */ 657, 666, 723, 722, 730, 728, 727, 726, 725, 724,
91327
+ /* 490 */ 721, 668, 676, 687, 715, 700, 699, 881, 883, 880,
91328
+ /* 500 */ 879, 708, 707, 713, 712, 711, 710, 709, 706, 705,
91329
+ /* 510 */ 704, 697, 696, 702, 695, 718, 717, 714, 694, 737,
91330
+ /* 520 */ 736, 735, 732, 693, 692, 691, 823, 690, 689, 829,
91331
+ /* 530 */ 828, 816, 860, 757, 756, 755, 767, 766, 779, 778,
91332
+ /* 540 */ 814, 813, 780, 765, 759, 758, 774, 773, 772, 771,
91333
+ /* 550 */ 763, 753, 785, 788, 787, 784, 845, 862, 769, 859,
91334
+ /* 560 */ 931, 930, 929, 928, 927, 864, 863, 830, 827, 680,
91335
+ /* 570 */ 681, 900, 898, 899, 897, 683, 682, 679, 678, 861,
91336
+ /* 580 */ 748, 747, 857, 854, 846, 841, 858, 855, 847, 842,
91337
+ /* 590 */ 840, 839, 825, 824, 822, 821, 817, 826, 671, 749,
91338
+ /* 600 */ 745, 744, 815, 751, 750, 688, 686, 684, 665, 663,
91339
+ /* 610 */ 656, 654, 653, 655, 651, 649, 648, 647, 646, 645,
91340
+ /* 620 */ 674, 673, 672, 670, 669, 643, 640, 639, 635, 634,
91341
+ /* 630 */ 632,
9130891342
};
9130991343
9131091344
/* The next table maps tokens into fallback tokens. If a construct
9131191345
** like the following:
9131291346
**
@@ -91487,17 +91521,17 @@
9148791521
"LSHIFT", "RSHIFT", "PLUS", "MINUS",
9148891522
"STAR", "SLASH", "REM", "CONCAT",
9148991523
"COLLATE", "BITNOT", "STRING", "JOIN_KW",
9149091524
"CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
9149191525
"UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
91492
- "ON", "DELETE", "UPDATE", "SET",
91493
- "DEFERRABLE", "FOREIGN", "DROP", "UNION",
91494
- "ALL", "EXCEPT", "INTERSECT", "SELECT",
91495
- "DISTINCT", "DOT", "FROM", "JOIN",
91496
- "USING", "ORDER", "GROUP", "HAVING",
91497
- "LIMIT", "WHERE", "INTO", "VALUES",
91498
- "INSERT", "INTEGER", "FLOAT", "BLOB",
91526
+ "ON", "INSERT", "DELETE", "UPDATE",
91527
+ "SET", "DEFERRABLE", "FOREIGN", "DROP",
91528
+ "UNION", "ALL", "EXCEPT", "INTERSECT",
91529
+ "SELECT", "DISTINCT", "DOT", "FROM",
91530
+ "JOIN", "USING", "ORDER", "GROUP",
91531
+ "HAVING", "LIMIT", "WHERE", "INTO",
91532
+ "VALUES", "INTEGER", "FLOAT", "BLOB",
9149991533
"REGISTER", "VARIABLE", "CASE", "WHEN",
9150091534
"THEN", "ELSE", "INDEX", "ALTER",
9150191535
"ADD", "error", "input", "cmdlist",
9150291536
"ecmd", "explain", "cmdx", "cmd",
9150391537
"transtype", "trans_opt", "nm", "savepoint_opt",
@@ -91607,264 +91641,265 @@
9160791641
/* 70 */ "autoinc ::=",
9160891642
/* 71 */ "autoinc ::= AUTOINCR",
9160991643
/* 72 */ "refargs ::=",
9161091644
/* 73 */ "refargs ::= refargs refarg",
9161191645
/* 74 */ "refarg ::= MATCH nm",
91612
- /* 75 */ "refarg ::= ON DELETE refact",
91613
- /* 76 */ "refarg ::= ON UPDATE refact",
91614
- /* 77 */ "refact ::= SET NULL",
91615
- /* 78 */ "refact ::= SET DEFAULT",
91616
- /* 79 */ "refact ::= CASCADE",
91617
- /* 80 */ "refact ::= RESTRICT",
91618
- /* 81 */ "refact ::= NO ACTION",
91619
- /* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
91620
- /* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
91621
- /* 84 */ "init_deferred_pred_opt ::=",
91622
- /* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
91623
- /* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
91624
- /* 87 */ "conslist_opt ::=",
91625
- /* 88 */ "conslist_opt ::= COMMA conslist",
91626
- /* 89 */ "conslist ::= conslist COMMA tcons",
91627
- /* 90 */ "conslist ::= conslist tcons",
91628
- /* 91 */ "conslist ::= tcons",
91629
- /* 92 */ "tcons ::= CONSTRAINT nm",
91630
- /* 93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
91631
- /* 94 */ "tcons ::= UNIQUE LP idxlist RP onconf",
91632
- /* 95 */ "tcons ::= CHECK LP expr RP onconf",
91633
- /* 96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
91634
- /* 97 */ "defer_subclause_opt ::=",
91635
- /* 98 */ "defer_subclause_opt ::= defer_subclause",
91636
- /* 99 */ "onconf ::=",
91637
- /* 100 */ "onconf ::= ON CONFLICT resolvetype",
91638
- /* 101 */ "orconf ::=",
91639
- /* 102 */ "orconf ::= OR resolvetype",
91640
- /* 103 */ "resolvetype ::= raisetype",
91641
- /* 104 */ "resolvetype ::= IGNORE",
91642
- /* 105 */ "resolvetype ::= REPLACE",
91643
- /* 106 */ "cmd ::= DROP TABLE ifexists fullname",
91644
- /* 107 */ "ifexists ::= IF EXISTS",
91645
- /* 108 */ "ifexists ::=",
91646
- /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91647
- /* 110 */ "cmd ::= DROP VIEW ifexists fullname",
91648
- /* 111 */ "cmd ::= select",
91649
- /* 112 */ "select ::= oneselect",
91650
- /* 113 */ "select ::= select multiselect_op oneselect",
91651
- /* 114 */ "multiselect_op ::= UNION",
91652
- /* 115 */ "multiselect_op ::= UNION ALL",
91653
- /* 116 */ "multiselect_op ::= EXCEPT|INTERSECT",
91654
- /* 117 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91655
- /* 118 */ "distinct ::= DISTINCT",
91656
- /* 119 */ "distinct ::= ALL",
91657
- /* 120 */ "distinct ::=",
91658
- /* 121 */ "sclp ::= selcollist COMMA",
91659
- /* 122 */ "sclp ::=",
91660
- /* 123 */ "selcollist ::= sclp expr as",
91661
- /* 124 */ "selcollist ::= sclp STAR",
91662
- /* 125 */ "selcollist ::= sclp nm DOT STAR",
91663
- /* 126 */ "as ::= AS nm",
91664
- /* 127 */ "as ::= ids",
91665
- /* 128 */ "as ::=",
91666
- /* 129 */ "from ::=",
91667
- /* 130 */ "from ::= FROM seltablist",
91668
- /* 131 */ "stl_prefix ::= seltablist joinop",
91669
- /* 132 */ "stl_prefix ::=",
91670
- /* 133 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
91671
- /* 134 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
91672
- /* 135 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
91673
- /* 136 */ "dbnm ::=",
91674
- /* 137 */ "dbnm ::= DOT nm",
91675
- /* 138 */ "fullname ::= nm dbnm",
91676
- /* 139 */ "joinop ::= COMMA|JOIN",
91677
- /* 140 */ "joinop ::= JOIN_KW JOIN",
91678
- /* 141 */ "joinop ::= JOIN_KW nm JOIN",
91679
- /* 142 */ "joinop ::= JOIN_KW nm nm JOIN",
91680
- /* 143 */ "on_opt ::= ON expr",
91681
- /* 144 */ "on_opt ::=",
91682
- /* 145 */ "indexed_opt ::=",
91683
- /* 146 */ "indexed_opt ::= INDEXED BY nm",
91684
- /* 147 */ "indexed_opt ::= NOT INDEXED",
91685
- /* 148 */ "using_opt ::= USING LP inscollist RP",
91686
- /* 149 */ "using_opt ::=",
91687
- /* 150 */ "orderby_opt ::=",
91688
- /* 151 */ "orderby_opt ::= ORDER BY sortlist",
91689
- /* 152 */ "sortlist ::= sortlist COMMA sortitem sortorder",
91690
- /* 153 */ "sortlist ::= sortitem sortorder",
91691
- /* 154 */ "sortitem ::= expr",
91692
- /* 155 */ "sortorder ::= ASC",
91693
- /* 156 */ "sortorder ::= DESC",
91694
- /* 157 */ "sortorder ::=",
91695
- /* 158 */ "groupby_opt ::=",
91696
- /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
91697
- /* 160 */ "having_opt ::=",
91698
- /* 161 */ "having_opt ::= HAVING expr",
91699
- /* 162 */ "limit_opt ::=",
91700
- /* 163 */ "limit_opt ::= LIMIT expr",
91701
- /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
91702
- /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
91703
- /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
91704
- /* 167 */ "where_opt ::=",
91705
- /* 168 */ "where_opt ::= WHERE expr",
91706
- /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
91707
- /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
91708
- /* 171 */ "setlist ::= nm EQ expr",
91709
- /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
91710
- /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
91711
- /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
91712
- /* 175 */ "insert_cmd ::= INSERT orconf",
91713
- /* 176 */ "insert_cmd ::= REPLACE",
91714
- /* 177 */ "itemlist ::= itemlist COMMA expr",
91715
- /* 178 */ "itemlist ::= expr",
91716
- /* 179 */ "inscollist_opt ::=",
91717
- /* 180 */ "inscollist_opt ::= LP inscollist RP",
91718
- /* 181 */ "inscollist ::= inscollist COMMA nm",
91719
- /* 182 */ "inscollist ::= nm",
91720
- /* 183 */ "expr ::= term",
91721
- /* 184 */ "expr ::= LP expr RP",
91722
- /* 185 */ "term ::= NULL",
91723
- /* 186 */ "expr ::= id",
91724
- /* 187 */ "expr ::= JOIN_KW",
91725
- /* 188 */ "expr ::= nm DOT nm",
91726
- /* 189 */ "expr ::= nm DOT nm DOT nm",
91727
- /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
91728
- /* 191 */ "term ::= STRING",
91729
- /* 192 */ "expr ::= REGISTER",
91730
- /* 193 */ "expr ::= VARIABLE",
91731
- /* 194 */ "expr ::= expr COLLATE ids",
91732
- /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
91733
- /* 196 */ "expr ::= ID LP distinct exprlist RP",
91734
- /* 197 */ "expr ::= ID LP STAR RP",
91735
- /* 198 */ "term ::= CTIME_KW",
91736
- /* 199 */ "expr ::= expr AND expr",
91737
- /* 200 */ "expr ::= expr OR expr",
91738
- /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
91739
- /* 202 */ "expr ::= expr EQ|NE expr",
91740
- /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
91741
- /* 204 */ "expr ::= expr PLUS|MINUS expr",
91742
- /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
91743
- /* 206 */ "expr ::= expr CONCAT expr",
91744
- /* 207 */ "likeop ::= LIKE_KW",
91745
- /* 208 */ "likeop ::= NOT LIKE_KW",
91746
- /* 209 */ "likeop ::= MATCH",
91747
- /* 210 */ "likeop ::= NOT MATCH",
91748
- /* 211 */ "escape ::= ESCAPE expr",
91749
- /* 212 */ "escape ::=",
91750
- /* 213 */ "expr ::= expr likeop expr escape",
91751
- /* 214 */ "expr ::= expr ISNULL|NOTNULL",
91752
- /* 215 */ "expr ::= expr NOT NULL",
91753
- /* 216 */ "expr ::= expr IS expr",
91754
- /* 217 */ "expr ::= expr IS NOT expr",
91755
- /* 218 */ "expr ::= NOT expr",
91756
- /* 219 */ "expr ::= BITNOT expr",
91757
- /* 220 */ "expr ::= MINUS expr",
91758
- /* 221 */ "expr ::= PLUS expr",
91759
- /* 222 */ "between_op ::= BETWEEN",
91760
- /* 223 */ "between_op ::= NOT BETWEEN",
91761
- /* 224 */ "expr ::= expr between_op expr AND expr",
91762
- /* 225 */ "in_op ::= IN",
91763
- /* 226 */ "in_op ::= NOT IN",
91764
- /* 227 */ "expr ::= expr in_op LP exprlist RP",
91765
- /* 228 */ "expr ::= LP select RP",
91766
- /* 229 */ "expr ::= expr in_op LP select RP",
91767
- /* 230 */ "expr ::= expr in_op nm dbnm",
91768
- /* 231 */ "expr ::= EXISTS LP select RP",
91769
- /* 232 */ "expr ::= CASE case_operand case_exprlist case_else END",
91770
- /* 233 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
91771
- /* 234 */ "case_exprlist ::= WHEN expr THEN expr",
91772
- /* 235 */ "case_else ::= ELSE expr",
91773
- /* 236 */ "case_else ::=",
91774
- /* 237 */ "case_operand ::= expr",
91775
- /* 238 */ "case_operand ::=",
91776
- /* 239 */ "exprlist ::= nexprlist",
91777
- /* 240 */ "exprlist ::=",
91778
- /* 241 */ "nexprlist ::= nexprlist COMMA expr",
91779
- /* 242 */ "nexprlist ::= expr",
91780
- /* 243 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
91781
- /* 244 */ "uniqueflag ::= UNIQUE",
91782
- /* 245 */ "uniqueflag ::=",
91783
- /* 246 */ "idxlist_opt ::=",
91784
- /* 247 */ "idxlist_opt ::= LP idxlist RP",
91785
- /* 248 */ "idxlist ::= idxlist COMMA nm collate sortorder",
91786
- /* 249 */ "idxlist ::= nm collate sortorder",
91787
- /* 250 */ "collate ::=",
91788
- /* 251 */ "collate ::= COLLATE ids",
91789
- /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
91790
- /* 253 */ "cmd ::= VACUUM",
91791
- /* 254 */ "cmd ::= VACUUM nm",
91792
- /* 255 */ "cmd ::= PRAGMA nm dbnm",
91793
- /* 256 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
91794
- /* 257 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
91795
- /* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
91796
- /* 259 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
91797
- /* 260 */ "nmnum ::= plus_num",
91798
- /* 261 */ "nmnum ::= nm",
91799
- /* 262 */ "nmnum ::= ON",
91800
- /* 263 */ "nmnum ::= DELETE",
91801
- /* 264 */ "nmnum ::= DEFAULT",
91802
- /* 265 */ "plus_num ::= plus_opt number",
91803
- /* 266 */ "minus_num ::= MINUS number",
91804
- /* 267 */ "number ::= INTEGER|FLOAT",
91805
- /* 268 */ "plus_opt ::= PLUS",
91806
- /* 269 */ "plus_opt ::=",
91807
- /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
91808
- /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
91809
- /* 272 */ "trigger_time ::= BEFORE",
91810
- /* 273 */ "trigger_time ::= AFTER",
91811
- /* 274 */ "trigger_time ::= INSTEAD OF",
91812
- /* 275 */ "trigger_time ::=",
91813
- /* 276 */ "trigger_event ::= DELETE|INSERT",
91814
- /* 277 */ "trigger_event ::= UPDATE",
91815
- /* 278 */ "trigger_event ::= UPDATE OF inscollist",
91816
- /* 279 */ "foreach_clause ::=",
91817
- /* 280 */ "foreach_clause ::= FOR EACH ROW",
91818
- /* 281 */ "when_clause ::=",
91819
- /* 282 */ "when_clause ::= WHEN expr",
91820
- /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
91821
- /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI",
91822
- /* 285 */ "trnm ::= nm",
91823
- /* 286 */ "trnm ::= nm DOT nm",
91824
- /* 287 */ "tridxby ::=",
91825
- /* 288 */ "tridxby ::= INDEXED BY nm",
91826
- /* 289 */ "tridxby ::= NOT INDEXED",
91827
- /* 290 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
91828
- /* 291 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
91829
- /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
91830
- /* 293 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
91831
- /* 294 */ "trigger_cmd ::= select",
91832
- /* 295 */ "expr ::= RAISE LP IGNORE RP",
91833
- /* 296 */ "expr ::= RAISE LP raisetype COMMA nm RP",
91834
- /* 297 */ "raisetype ::= ROLLBACK",
91835
- /* 298 */ "raisetype ::= ABORT",
91836
- /* 299 */ "raisetype ::= FAIL",
91837
- /* 300 */ "cmd ::= DROP TRIGGER ifexists fullname",
91838
- /* 301 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
91839
- /* 302 */ "cmd ::= DETACH database_kw_opt expr",
91840
- /* 303 */ "key_opt ::=",
91841
- /* 304 */ "key_opt ::= KEY expr",
91842
- /* 305 */ "database_kw_opt ::= DATABASE",
91843
- /* 306 */ "database_kw_opt ::=",
91844
- /* 307 */ "cmd ::= REINDEX",
91845
- /* 308 */ "cmd ::= REINDEX nm dbnm",
91846
- /* 309 */ "cmd ::= ANALYZE",
91847
- /* 310 */ "cmd ::= ANALYZE nm dbnm",
91848
- /* 311 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
91849
- /* 312 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
91850
- /* 313 */ "add_column_fullname ::= fullname",
91851
- /* 314 */ "kwcolumn_opt ::=",
91852
- /* 315 */ "kwcolumn_opt ::= COLUMNKW",
91853
- /* 316 */ "cmd ::= create_vtab",
91854
- /* 317 */ "cmd ::= create_vtab LP vtabarglist RP",
91855
- /* 318 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
91856
- /* 319 */ "vtabarglist ::= vtabarg",
91857
- /* 320 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
91858
- /* 321 */ "vtabarg ::=",
91859
- /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
91860
- /* 323 */ "vtabargtoken ::= ANY",
91861
- /* 324 */ "vtabargtoken ::= lp anylist RP",
91862
- /* 325 */ "lp ::= LP",
91863
- /* 326 */ "anylist ::=",
91864
- /* 327 */ "anylist ::= anylist LP anylist RP",
91865
- /* 328 */ "anylist ::= anylist ANY",
91646
+ /* 75 */ "refarg ::= ON INSERT refact",
91647
+ /* 76 */ "refarg ::= ON DELETE refact",
91648
+ /* 77 */ "refarg ::= ON UPDATE refact",
91649
+ /* 78 */ "refact ::= SET NULL",
91650
+ /* 79 */ "refact ::= SET DEFAULT",
91651
+ /* 80 */ "refact ::= CASCADE",
91652
+ /* 81 */ "refact ::= RESTRICT",
91653
+ /* 82 */ "refact ::= NO ACTION",
91654
+ /* 83 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
91655
+ /* 84 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
91656
+ /* 85 */ "init_deferred_pred_opt ::=",
91657
+ /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
91658
+ /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
91659
+ /* 88 */ "conslist_opt ::=",
91660
+ /* 89 */ "conslist_opt ::= COMMA conslist",
91661
+ /* 90 */ "conslist ::= conslist COMMA tcons",
91662
+ /* 91 */ "conslist ::= conslist tcons",
91663
+ /* 92 */ "conslist ::= tcons",
91664
+ /* 93 */ "tcons ::= CONSTRAINT nm",
91665
+ /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
91666
+ /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
91667
+ /* 96 */ "tcons ::= CHECK LP expr RP onconf",
91668
+ /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
91669
+ /* 98 */ "defer_subclause_opt ::=",
91670
+ /* 99 */ "defer_subclause_opt ::= defer_subclause",
91671
+ /* 100 */ "onconf ::=",
91672
+ /* 101 */ "onconf ::= ON CONFLICT resolvetype",
91673
+ /* 102 */ "orconf ::=",
91674
+ /* 103 */ "orconf ::= OR resolvetype",
91675
+ /* 104 */ "resolvetype ::= raisetype",
91676
+ /* 105 */ "resolvetype ::= IGNORE",
91677
+ /* 106 */ "resolvetype ::= REPLACE",
91678
+ /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
91679
+ /* 108 */ "ifexists ::= IF EXISTS",
91680
+ /* 109 */ "ifexists ::=",
91681
+ /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91682
+ /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
91683
+ /* 112 */ "cmd ::= select",
91684
+ /* 113 */ "select ::= oneselect",
91685
+ /* 114 */ "select ::= select multiselect_op oneselect",
91686
+ /* 115 */ "multiselect_op ::= UNION",
91687
+ /* 116 */ "multiselect_op ::= UNION ALL",
91688
+ /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
91689
+ /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91690
+ /* 119 */ "distinct ::= DISTINCT",
91691
+ /* 120 */ "distinct ::= ALL",
91692
+ /* 121 */ "distinct ::=",
91693
+ /* 122 */ "sclp ::= selcollist COMMA",
91694
+ /* 123 */ "sclp ::=",
91695
+ /* 124 */ "selcollist ::= sclp expr as",
91696
+ /* 125 */ "selcollist ::= sclp STAR",
91697
+ /* 126 */ "selcollist ::= sclp nm DOT STAR",
91698
+ /* 127 */ "as ::= AS nm",
91699
+ /* 128 */ "as ::= ids",
91700
+ /* 129 */ "as ::=",
91701
+ /* 130 */ "from ::=",
91702
+ /* 131 */ "from ::= FROM seltablist",
91703
+ /* 132 */ "stl_prefix ::= seltablist joinop",
91704
+ /* 133 */ "stl_prefix ::=",
91705
+ /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
91706
+ /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
91707
+ /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
91708
+ /* 137 */ "dbnm ::=",
91709
+ /* 138 */ "dbnm ::= DOT nm",
91710
+ /* 139 */ "fullname ::= nm dbnm",
91711
+ /* 140 */ "joinop ::= COMMA|JOIN",
91712
+ /* 141 */ "joinop ::= JOIN_KW JOIN",
91713
+ /* 142 */ "joinop ::= JOIN_KW nm JOIN",
91714
+ /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
91715
+ /* 144 */ "on_opt ::= ON expr",
91716
+ /* 145 */ "on_opt ::=",
91717
+ /* 146 */ "indexed_opt ::=",
91718
+ /* 147 */ "indexed_opt ::= INDEXED BY nm",
91719
+ /* 148 */ "indexed_opt ::= NOT INDEXED",
91720
+ /* 149 */ "using_opt ::= USING LP inscollist RP",
91721
+ /* 150 */ "using_opt ::=",
91722
+ /* 151 */ "orderby_opt ::=",
91723
+ /* 152 */ "orderby_opt ::= ORDER BY sortlist",
91724
+ /* 153 */ "sortlist ::= sortlist COMMA sortitem sortorder",
91725
+ /* 154 */ "sortlist ::= sortitem sortorder",
91726
+ /* 155 */ "sortitem ::= expr",
91727
+ /* 156 */ "sortorder ::= ASC",
91728
+ /* 157 */ "sortorder ::= DESC",
91729
+ /* 158 */ "sortorder ::=",
91730
+ /* 159 */ "groupby_opt ::=",
91731
+ /* 160 */ "groupby_opt ::= GROUP BY nexprlist",
91732
+ /* 161 */ "having_opt ::=",
91733
+ /* 162 */ "having_opt ::= HAVING expr",
91734
+ /* 163 */ "limit_opt ::=",
91735
+ /* 164 */ "limit_opt ::= LIMIT expr",
91736
+ /* 165 */ "limit_opt ::= LIMIT expr OFFSET expr",
91737
+ /* 166 */ "limit_opt ::= LIMIT expr COMMA expr",
91738
+ /* 167 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
91739
+ /* 168 */ "where_opt ::=",
91740
+ /* 169 */ "where_opt ::= WHERE expr",
91741
+ /* 170 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
91742
+ /* 171 */ "setlist ::= setlist COMMA nm EQ expr",
91743
+ /* 172 */ "setlist ::= nm EQ expr",
91744
+ /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
91745
+ /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
91746
+ /* 175 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
91747
+ /* 176 */ "insert_cmd ::= INSERT orconf",
91748
+ /* 177 */ "insert_cmd ::= REPLACE",
91749
+ /* 178 */ "itemlist ::= itemlist COMMA expr",
91750
+ /* 179 */ "itemlist ::= expr",
91751
+ /* 180 */ "inscollist_opt ::=",
91752
+ /* 181 */ "inscollist_opt ::= LP inscollist RP",
91753
+ /* 182 */ "inscollist ::= inscollist COMMA nm",
91754
+ /* 183 */ "inscollist ::= nm",
91755
+ /* 184 */ "expr ::= term",
91756
+ /* 185 */ "expr ::= LP expr RP",
91757
+ /* 186 */ "term ::= NULL",
91758
+ /* 187 */ "expr ::= id",
91759
+ /* 188 */ "expr ::= JOIN_KW",
91760
+ /* 189 */ "expr ::= nm DOT nm",
91761
+ /* 190 */ "expr ::= nm DOT nm DOT nm",
91762
+ /* 191 */ "term ::= INTEGER|FLOAT|BLOB",
91763
+ /* 192 */ "term ::= STRING",
91764
+ /* 193 */ "expr ::= REGISTER",
91765
+ /* 194 */ "expr ::= VARIABLE",
91766
+ /* 195 */ "expr ::= expr COLLATE ids",
91767
+ /* 196 */ "expr ::= CAST LP expr AS typetoken RP",
91768
+ /* 197 */ "expr ::= ID LP distinct exprlist RP",
91769
+ /* 198 */ "expr ::= ID LP STAR RP",
91770
+ /* 199 */ "term ::= CTIME_KW",
91771
+ /* 200 */ "expr ::= expr AND expr",
91772
+ /* 201 */ "expr ::= expr OR expr",
91773
+ /* 202 */ "expr ::= expr LT|GT|GE|LE expr",
91774
+ /* 203 */ "expr ::= expr EQ|NE expr",
91775
+ /* 204 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
91776
+ /* 205 */ "expr ::= expr PLUS|MINUS expr",
91777
+ /* 206 */ "expr ::= expr STAR|SLASH|REM expr",
91778
+ /* 207 */ "expr ::= expr CONCAT expr",
91779
+ /* 208 */ "likeop ::= LIKE_KW",
91780
+ /* 209 */ "likeop ::= NOT LIKE_KW",
91781
+ /* 210 */ "likeop ::= MATCH",
91782
+ /* 211 */ "likeop ::= NOT MATCH",
91783
+ /* 212 */ "escape ::= ESCAPE expr",
91784
+ /* 213 */ "escape ::=",
91785
+ /* 214 */ "expr ::= expr likeop expr escape",
91786
+ /* 215 */ "expr ::= expr ISNULL|NOTNULL",
91787
+ /* 216 */ "expr ::= expr NOT NULL",
91788
+ /* 217 */ "expr ::= expr IS expr",
91789
+ /* 218 */ "expr ::= expr IS NOT expr",
91790
+ /* 219 */ "expr ::= NOT expr",
91791
+ /* 220 */ "expr ::= BITNOT expr",
91792
+ /* 221 */ "expr ::= MINUS expr",
91793
+ /* 222 */ "expr ::= PLUS expr",
91794
+ /* 223 */ "between_op ::= BETWEEN",
91795
+ /* 224 */ "between_op ::= NOT BETWEEN",
91796
+ /* 225 */ "expr ::= expr between_op expr AND expr",
91797
+ /* 226 */ "in_op ::= IN",
91798
+ /* 227 */ "in_op ::= NOT IN",
91799
+ /* 228 */ "expr ::= expr in_op LP exprlist RP",
91800
+ /* 229 */ "expr ::= LP select RP",
91801
+ /* 230 */ "expr ::= expr in_op LP select RP",
91802
+ /* 231 */ "expr ::= expr in_op nm dbnm",
91803
+ /* 232 */ "expr ::= EXISTS LP select RP",
91804
+ /* 233 */ "expr ::= CASE case_operand case_exprlist case_else END",
91805
+ /* 234 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
91806
+ /* 235 */ "case_exprlist ::= WHEN expr THEN expr",
91807
+ /* 236 */ "case_else ::= ELSE expr",
91808
+ /* 237 */ "case_else ::=",
91809
+ /* 238 */ "case_operand ::= expr",
91810
+ /* 239 */ "case_operand ::=",
91811
+ /* 240 */ "exprlist ::= nexprlist",
91812
+ /* 241 */ "exprlist ::=",
91813
+ /* 242 */ "nexprlist ::= nexprlist COMMA expr",
91814
+ /* 243 */ "nexprlist ::= expr",
91815
+ /* 244 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
91816
+ /* 245 */ "uniqueflag ::= UNIQUE",
91817
+ /* 246 */ "uniqueflag ::=",
91818
+ /* 247 */ "idxlist_opt ::=",
91819
+ /* 248 */ "idxlist_opt ::= LP idxlist RP",
91820
+ /* 249 */ "idxlist ::= idxlist COMMA nm collate sortorder",
91821
+ /* 250 */ "idxlist ::= nm collate sortorder",
91822
+ /* 251 */ "collate ::=",
91823
+ /* 252 */ "collate ::= COLLATE ids",
91824
+ /* 253 */ "cmd ::= DROP INDEX ifexists fullname",
91825
+ /* 254 */ "cmd ::= VACUUM",
91826
+ /* 255 */ "cmd ::= VACUUM nm",
91827
+ /* 256 */ "cmd ::= PRAGMA nm dbnm",
91828
+ /* 257 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
91829
+ /* 258 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
91830
+ /* 259 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
91831
+ /* 260 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
91832
+ /* 261 */ "nmnum ::= plus_num",
91833
+ /* 262 */ "nmnum ::= nm",
91834
+ /* 263 */ "nmnum ::= ON",
91835
+ /* 264 */ "nmnum ::= DELETE",
91836
+ /* 265 */ "nmnum ::= DEFAULT",
91837
+ /* 266 */ "plus_num ::= plus_opt number",
91838
+ /* 267 */ "minus_num ::= MINUS number",
91839
+ /* 268 */ "number ::= INTEGER|FLOAT",
91840
+ /* 269 */ "plus_opt ::= PLUS",
91841
+ /* 270 */ "plus_opt ::=",
91842
+ /* 271 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
91843
+ /* 272 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
91844
+ /* 273 */ "trigger_time ::= BEFORE",
91845
+ /* 274 */ "trigger_time ::= AFTER",
91846
+ /* 275 */ "trigger_time ::= INSTEAD OF",
91847
+ /* 276 */ "trigger_time ::=",
91848
+ /* 277 */ "trigger_event ::= DELETE|INSERT",
91849
+ /* 278 */ "trigger_event ::= UPDATE",
91850
+ /* 279 */ "trigger_event ::= UPDATE OF inscollist",
91851
+ /* 280 */ "foreach_clause ::=",
91852
+ /* 281 */ "foreach_clause ::= FOR EACH ROW",
91853
+ /* 282 */ "when_clause ::=",
91854
+ /* 283 */ "when_clause ::= WHEN expr",
91855
+ /* 284 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
91856
+ /* 285 */ "trigger_cmd_list ::= trigger_cmd SEMI",
91857
+ /* 286 */ "trnm ::= nm",
91858
+ /* 287 */ "trnm ::= nm DOT nm",
91859
+ /* 288 */ "tridxby ::=",
91860
+ /* 289 */ "tridxby ::= INDEXED BY nm",
91861
+ /* 290 */ "tridxby ::= NOT INDEXED",
91862
+ /* 291 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
91863
+ /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
91864
+ /* 293 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
91865
+ /* 294 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
91866
+ /* 295 */ "trigger_cmd ::= select",
91867
+ /* 296 */ "expr ::= RAISE LP IGNORE RP",
91868
+ /* 297 */ "expr ::= RAISE LP raisetype COMMA nm RP",
91869
+ /* 298 */ "raisetype ::= ROLLBACK",
91870
+ /* 299 */ "raisetype ::= ABORT",
91871
+ /* 300 */ "raisetype ::= FAIL",
91872
+ /* 301 */ "cmd ::= DROP TRIGGER ifexists fullname",
91873
+ /* 302 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
91874
+ /* 303 */ "cmd ::= DETACH database_kw_opt expr",
91875
+ /* 304 */ "key_opt ::=",
91876
+ /* 305 */ "key_opt ::= KEY expr",
91877
+ /* 306 */ "database_kw_opt ::= DATABASE",
91878
+ /* 307 */ "database_kw_opt ::=",
91879
+ /* 308 */ "cmd ::= REINDEX",
91880
+ /* 309 */ "cmd ::= REINDEX nm dbnm",
91881
+ /* 310 */ "cmd ::= ANALYZE",
91882
+ /* 311 */ "cmd ::= ANALYZE nm dbnm",
91883
+ /* 312 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
91884
+ /* 313 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
91885
+ /* 314 */ "add_column_fullname ::= fullname",
91886
+ /* 315 */ "kwcolumn_opt ::=",
91887
+ /* 316 */ "kwcolumn_opt ::= COLUMNKW",
91888
+ /* 317 */ "cmd ::= create_vtab",
91889
+ /* 318 */ "cmd ::= create_vtab LP vtabarglist RP",
91890
+ /* 319 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
91891
+ /* 320 */ "vtabarglist ::= vtabarg",
91892
+ /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
91893
+ /* 322 */ "vtabarg ::=",
91894
+ /* 323 */ "vtabarg ::= vtabarg vtabargtoken",
91895
+ /* 324 */ "vtabargtoken ::= ANY",
91896
+ /* 325 */ "vtabargtoken ::= lp anylist RP",
91897
+ /* 326 */ "lp ::= LP",
91898
+ /* 327 */ "anylist ::=",
91899
+ /* 328 */ "anylist ::= anylist LP anylist RP",
91900
+ /* 329 */ "anylist ::= anylist ANY",
9186691901
};
9186791902
#endif /* NDEBUG */
9186891903
9186991904
9187091905
#if YYSTACKDEPTH<=0
@@ -92326,10 +92361,11 @@
9232692361
{ 180, 0 },
9232792362
{ 180, 2 },
9232892363
{ 182, 2 },
9232992364
{ 182, 3 },
9233092365
{ 182, 3 },
92366
+ { 182, 3 },
9233192367
{ 183, 2 },
9233292368
{ 183, 2 },
9233392369
{ 183, 1 },
9233492370
{ 183, 1 },
9233592371
{ 183, 2 },
@@ -92653,12 +92689,12 @@
9265392689
{yygotominor.yy328 = TK_DEFERRED;}
9265492690
break;
9265592691
case 14: /* transtype ::= DEFERRED */
9265692692
case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
9265792693
case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
92658
- case 114: /* multiselect_op ::= UNION */ yytestcase(yyruleno==114);
92659
- case 116: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==116);
92694
+ case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
92695
+ case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
9266092696
{yygotominor.yy328 = yymsp[0].major;}
9266192697
break;
9266292698
case 17: /* cmd ::= COMMIT trans_opt */
9266392699
case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
9266492700
{sqlite3CommitTransaction(pParse);}
@@ -92693,29 +92729,29 @@
9269392729
}
9269492730
break;
9269592731
case 28: /* ifnotexists ::= */
9269692732
case 31: /* temp ::= */ yytestcase(yyruleno==31);
9269792733
case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
92698
- case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);
92699
- case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
92700
- case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
92701
- case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
92702
- case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
92703
- case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
92704
- case 120: /* distinct ::= */ yytestcase(yyruleno==120);
92705
- case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222);
92706
- case 225: /* in_op ::= IN */ yytestcase(yyruleno==225);
92734
+ case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
92735
+ case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
92736
+ case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
92737
+ case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
92738
+ case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
92739
+ case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
92740
+ case 121: /* distinct ::= */ yytestcase(yyruleno==121);
92741
+ case 223: /* between_op ::= BETWEEN */ yytestcase(yyruleno==223);
92742
+ case 226: /* in_op ::= IN */ yytestcase(yyruleno==226);
9270792743
{yygotominor.yy328 = 0;}
9270892744
break;
9270992745
case 29: /* ifnotexists ::= IF NOT EXISTS */
9271092746
case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
9271192747
case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
92712
- case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85);
92713
- case 107: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==107);
92714
- case 118: /* distinct ::= DISTINCT */ yytestcase(yyruleno==118);
92715
- case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223);
92716
- case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226);
92748
+ case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
92749
+ case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
92750
+ case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
92751
+ case 224: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==224);
92752
+ case 227: /* in_op ::= NOT IN */ yytestcase(yyruleno==227);
9271792753
{yygotominor.yy328 = 1;}
9271892754
break;
9271992755
case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
9272092756
{
9272192757
sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -92745,24 +92781,24 @@
9274592781
case 41: /* nm ::= id */ yytestcase(yyruleno==41);
9274692782
case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
9274792783
case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
9274892784
case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
9274992785
case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
92750
- case 126: /* as ::= AS nm */ yytestcase(yyruleno==126);
92751
- case 127: /* as ::= ids */ yytestcase(yyruleno==127);
92752
- case 137: /* dbnm ::= DOT nm */ yytestcase(yyruleno==137);
92753
- case 146: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==146);
92754
- case 251: /* collate ::= COLLATE ids */ yytestcase(yyruleno==251);
92755
- case 260: /* nmnum ::= plus_num */ yytestcase(yyruleno==260);
92756
- case 261: /* nmnum ::= nm */ yytestcase(yyruleno==261);
92757
- case 262: /* nmnum ::= ON */ yytestcase(yyruleno==262);
92758
- case 263: /* nmnum ::= DELETE */ yytestcase(yyruleno==263);
92759
- case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264);
92760
- case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265);
92761
- case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
92762
- case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
92763
- case 285: /* trnm ::= nm */ yytestcase(yyruleno==285);
92786
+ case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
92787
+ case 128: /* as ::= ids */ yytestcase(yyruleno==128);
92788
+ case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
92789
+ case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
92790
+ case 252: /* collate ::= COLLATE ids */ yytestcase(yyruleno==252);
92791
+ case 261: /* nmnum ::= plus_num */ yytestcase(yyruleno==261);
92792
+ case 262: /* nmnum ::= nm */ yytestcase(yyruleno==262);
92793
+ case 263: /* nmnum ::= ON */ yytestcase(yyruleno==263);
92794
+ case 264: /* nmnum ::= DELETE */ yytestcase(yyruleno==264);
92795
+ case 265: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==265);
92796
+ case 266: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==266);
92797
+ case 267: /* minus_num ::= MINUS number */ yytestcase(yyruleno==267);
92798
+ case 268: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==268);
92799
+ case 286: /* trnm ::= nm */ yytestcase(yyruleno==286);
9276492800
{yygotominor.yy0 = yymsp[0].minor.yy0;}
9276592801
break;
9276692802
case 45: /* type ::= typetoken */
9276792803
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
9276892804
break;
@@ -92830,101 +92866,102 @@
9283092866
break;
9283192867
case 73: /* refargs ::= refargs refarg */
9283292868
{ yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
9283392869
break;
9283492870
case 74: /* refarg ::= MATCH nm */
92871
+ case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75);
9283592872
{ yygotominor.yy429.value = 0; yygotominor.yy429.mask = 0x000000; }
9283692873
break;
92837
- case 75: /* refarg ::= ON DELETE refact */
92874
+ case 76: /* refarg ::= ON DELETE refact */
9283892875
{ yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
9283992876
break;
92840
- case 76: /* refarg ::= ON UPDATE refact */
92877
+ case 77: /* refarg ::= ON UPDATE refact */
9284192878
{ yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
9284292879
break;
92843
- case 77: /* refact ::= SET NULL */
92880
+ case 78: /* refact ::= SET NULL */
9284492881
{ yygotominor.yy328 = OE_SetNull; /* EV: R-33326-45252 */}
9284592882
break;
92846
- case 78: /* refact ::= SET DEFAULT */
92883
+ case 79: /* refact ::= SET DEFAULT */
9284792884
{ yygotominor.yy328 = OE_SetDflt; /* EV: R-33326-45252 */}
9284892885
break;
92849
- case 79: /* refact ::= CASCADE */
92886
+ case 80: /* refact ::= CASCADE */
9285092887
{ yygotominor.yy328 = OE_Cascade; /* EV: R-33326-45252 */}
9285192888
break;
92852
- case 80: /* refact ::= RESTRICT */
92889
+ case 81: /* refact ::= RESTRICT */
9285392890
{ yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
9285492891
break;
92855
- case 81: /* refact ::= NO ACTION */
92892
+ case 82: /* refact ::= NO ACTION */
9285692893
{ yygotominor.yy328 = OE_None; /* EV: R-33326-45252 */}
9285792894
break;
92858
- case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
92859
- case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
92860
- case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
92861
- case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
92895
+ case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
92896
+ case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
92897
+ case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
92898
+ case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
9286292899
{yygotominor.yy328 = yymsp[0].minor.yy328;}
9286392900
break;
92864
- case 87: /* conslist_opt ::= */
92901
+ case 88: /* conslist_opt ::= */
9286592902
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
9286692903
break;
92867
- case 88: /* conslist_opt ::= COMMA conslist */
92904
+ case 89: /* conslist_opt ::= COMMA conslist */
9286892905
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
9286992906
break;
92870
- case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
92907
+ case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
9287192908
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);}
9287292909
break;
92873
- case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */
92910
+ case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
9287492911
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);}
9287592912
break;
92876
- case 95: /* tcons ::= CHECK LP expr RP onconf */
92913
+ case 96: /* tcons ::= CHECK LP expr RP onconf */
9287792914
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
9287892915
break;
92879
- case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
92916
+ case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
9288092917
{
9288192918
sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328);
9288292919
sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328);
9288392920
}
9288492921
break;
92885
- case 99: /* onconf ::= */
92922
+ case 100: /* onconf ::= */
9288692923
{yygotominor.yy328 = OE_Default;}
9288792924
break;
92888
- case 101: /* orconf ::= */
92925
+ case 102: /* orconf ::= */
9288992926
{yygotominor.yy186 = OE_Default;}
9289092927
break;
92891
- case 102: /* orconf ::= OR resolvetype */
92928
+ case 103: /* orconf ::= OR resolvetype */
9289292929
{yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
9289392930
break;
92894
- case 104: /* resolvetype ::= IGNORE */
92931
+ case 105: /* resolvetype ::= IGNORE */
9289592932
{yygotominor.yy328 = OE_Ignore;}
9289692933
break;
92897
- case 105: /* resolvetype ::= REPLACE */
92934
+ case 106: /* resolvetype ::= REPLACE */
9289892935
{yygotominor.yy328 = OE_Replace;}
9289992936
break;
92900
- case 106: /* cmd ::= DROP TABLE ifexists fullname */
92937
+ case 107: /* cmd ::= DROP TABLE ifexists fullname */
9290192938
{
9290292939
sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
9290392940
}
9290492941
break;
92905
- case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
92942
+ case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
9290692943
{
9290792944
sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328);
9290892945
}
9290992946
break;
92910
- case 110: /* cmd ::= DROP VIEW ifexists fullname */
92947
+ case 111: /* cmd ::= DROP VIEW ifexists fullname */
9291192948
{
9291292949
sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
9291392950
}
9291492951
break;
92915
- case 111: /* cmd ::= select */
92952
+ case 112: /* cmd ::= select */
9291692953
{
9291792954
SelectDest dest = {SRT_Output, 0, 0, 0, 0};
9291892955
sqlite3Select(pParse, yymsp[0].minor.yy3, &dest);
9291992956
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
9292092957
}
9292192958
break;
92922
- case 112: /* select ::= oneselect */
92959
+ case 113: /* select ::= oneselect */
9292392960
{yygotominor.yy3 = yymsp[0].minor.yy3;}
9292492961
break;
92925
- case 113: /* select ::= select multiselect_op oneselect */
92962
+ case 114: /* select ::= select multiselect_op oneselect */
9292692963
{
9292792964
if( yymsp[0].minor.yy3 ){
9292892965
yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
9292992966
yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3;
9293092967
}else{
@@ -92931,83 +92968,83 @@
9293192968
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
9293292969
}
9293392970
yygotominor.yy3 = yymsp[0].minor.yy3;
9293492971
}
9293592972
break;
92936
- case 115: /* multiselect_op ::= UNION ALL */
92973
+ case 116: /* multiselect_op ::= UNION ALL */
9293792974
{yygotominor.yy328 = TK_ALL;}
9293892975
break;
92939
- case 117: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
92976
+ case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
9294092977
{
9294192978
yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy65,yymsp[-4].minor.yy132,yymsp[-3].minor.yy14,yymsp[-2].minor.yy132,yymsp[-1].minor.yy14,yymsp[-7].minor.yy328,yymsp[0].minor.yy476.pLimit,yymsp[0].minor.yy476.pOffset);
9294292979
}
9294392980
break;
92944
- case 121: /* sclp ::= selcollist COMMA */
92945
- case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247);
92981
+ case 122: /* sclp ::= selcollist COMMA */
92982
+ case 248: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==248);
9294692983
{yygotominor.yy14 = yymsp[-1].minor.yy14;}
9294792984
break;
92948
- case 122: /* sclp ::= */
92949
- case 150: /* orderby_opt ::= */ yytestcase(yyruleno==150);
92950
- case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
92951
- case 240: /* exprlist ::= */ yytestcase(yyruleno==240);
92952
- case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246);
92985
+ case 123: /* sclp ::= */
92986
+ case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
92987
+ case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159);
92988
+ case 241: /* exprlist ::= */ yytestcase(yyruleno==241);
92989
+ case 247: /* idxlist_opt ::= */ yytestcase(yyruleno==247);
9295392990
{yygotominor.yy14 = 0;}
9295492991
break;
92955
- case 123: /* selcollist ::= sclp expr as */
92992
+ case 124: /* selcollist ::= sclp expr as */
9295692993
{
9295792994
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr);
9295892995
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1);
9295992996
sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346);
9296092997
}
9296192998
break;
92962
- case 124: /* selcollist ::= sclp STAR */
92999
+ case 125: /* selcollist ::= sclp STAR */
9296393000
{
9296493001
Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
9296593002
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
9296693003
}
9296793004
break;
92968
- case 125: /* selcollist ::= sclp nm DOT STAR */
93005
+ case 126: /* selcollist ::= sclp nm DOT STAR */
9296993006
{
9297093007
Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
9297193008
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
9297293009
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
9297393010
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
9297493011
}
9297593012
break;
92976
- case 128: /* as ::= */
93013
+ case 129: /* as ::= */
9297793014
{yygotominor.yy0.n = 0;}
9297893015
break;
92979
- case 129: /* from ::= */
93016
+ case 130: /* from ::= */
9298093017
{yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
9298193018
break;
92982
- case 130: /* from ::= FROM seltablist */
93019
+ case 131: /* from ::= FROM seltablist */
9298393020
{
9298493021
yygotominor.yy65 = yymsp[0].minor.yy65;
9298593022
sqlite3SrcListShiftJoinType(yygotominor.yy65);
9298693023
}
9298793024
break;
92988
- case 131: /* stl_prefix ::= seltablist joinop */
93025
+ case 132: /* stl_prefix ::= seltablist joinop */
9298993026
{
9299093027
yygotominor.yy65 = yymsp[-1].minor.yy65;
9299193028
if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328;
9299293029
}
9299393030
break;
92994
- case 132: /* stl_prefix ::= */
93031
+ case 133: /* stl_prefix ::= */
9299593032
{yygotominor.yy65 = 0;}
9299693033
break;
92997
- case 133: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
93034
+ case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
9299893035
{
9299993036
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
9300093037
sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0);
9300193038
}
9300293039
break;
93003
- case 134: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
93040
+ case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
9300493041
{
9300593042
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
9300693043
}
9300793044
break;
93008
- case 135: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
93045
+ case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
9300993046
{
9301093047
if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){
9301193048
yygotominor.yy65 = yymsp[-4].minor.yy65;
9301293049
}else{
9301393050
Select *pSubquery;
@@ -93015,180 +93052,180 @@
9301593052
pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,0,0,0);
9301693053
yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
9301793054
}
9301893055
}
9301993056
break;
93020
- case 136: /* dbnm ::= */
93021
- case 145: /* indexed_opt ::= */ yytestcase(yyruleno==145);
93057
+ case 137: /* dbnm ::= */
93058
+ case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
9302293059
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
9302393060
break;
93024
- case 138: /* fullname ::= nm dbnm */
93061
+ case 139: /* fullname ::= nm dbnm */
9302593062
{yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
9302693063
break;
93027
- case 139: /* joinop ::= COMMA|JOIN */
93064
+ case 140: /* joinop ::= COMMA|JOIN */
9302893065
{ yygotominor.yy328 = JT_INNER; }
9302993066
break;
93030
- case 140: /* joinop ::= JOIN_KW JOIN */
93067
+ case 141: /* joinop ::= JOIN_KW JOIN */
9303193068
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
9303293069
break;
93033
- case 141: /* joinop ::= JOIN_KW nm JOIN */
93070
+ case 142: /* joinop ::= JOIN_KW nm JOIN */
9303493071
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
9303593072
break;
93036
- case 142: /* joinop ::= JOIN_KW nm nm JOIN */
93073
+ case 143: /* joinop ::= JOIN_KW nm nm JOIN */
9303793074
{ yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
9303893075
break;
93039
- case 143: /* on_opt ::= ON expr */
93040
- case 154: /* sortitem ::= expr */ yytestcase(yyruleno==154);
93041
- case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
93042
- case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
93043
- case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235);
93044
- case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237);
93076
+ case 144: /* on_opt ::= ON expr */
93077
+ case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155);
93078
+ case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162);
93079
+ case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169);
93080
+ case 236: /* case_else ::= ELSE expr */ yytestcase(yyruleno==236);
93081
+ case 238: /* case_operand ::= expr */ yytestcase(yyruleno==238);
9304593082
{yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;}
9304693083
break;
93047
- case 144: /* on_opt ::= */
93048
- case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
93049
- case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
93050
- case 236: /* case_else ::= */ yytestcase(yyruleno==236);
93051
- case 238: /* case_operand ::= */ yytestcase(yyruleno==238);
93084
+ case 145: /* on_opt ::= */
93085
+ case 161: /* having_opt ::= */ yytestcase(yyruleno==161);
93086
+ case 168: /* where_opt ::= */ yytestcase(yyruleno==168);
93087
+ case 237: /* case_else ::= */ yytestcase(yyruleno==237);
93088
+ case 239: /* case_operand ::= */ yytestcase(yyruleno==239);
9305293089
{yygotominor.yy132 = 0;}
9305393090
break;
93054
- case 147: /* indexed_opt ::= NOT INDEXED */
93091
+ case 148: /* indexed_opt ::= NOT INDEXED */
9305593092
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
9305693093
break;
93057
- case 148: /* using_opt ::= USING LP inscollist RP */
93058
- case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
93094
+ case 149: /* using_opt ::= USING LP inscollist RP */
93095
+ case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181);
9305993096
{yygotominor.yy408 = yymsp[-1].minor.yy408;}
9306093097
break;
93061
- case 149: /* using_opt ::= */
93062
- case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
93098
+ case 150: /* using_opt ::= */
93099
+ case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180);
9306393100
{yygotominor.yy408 = 0;}
9306493101
break;
93065
- case 151: /* orderby_opt ::= ORDER BY sortlist */
93066
- case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
93067
- case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239);
93102
+ case 152: /* orderby_opt ::= ORDER BY sortlist */
93103
+ case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160);
93104
+ case 240: /* exprlist ::= nexprlist */ yytestcase(yyruleno==240);
9306893105
{yygotominor.yy14 = yymsp[0].minor.yy14;}
9306993106
break;
93070
- case 152: /* sortlist ::= sortlist COMMA sortitem sortorder */
93107
+ case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */
9307193108
{
9307293109
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy132);
9307393110
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
9307493111
}
9307593112
break;
93076
- case 153: /* sortlist ::= sortitem sortorder */
93113
+ case 154: /* sortlist ::= sortitem sortorder */
9307793114
{
9307893115
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy132);
9307993116
if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328;
9308093117
}
9308193118
break;
93082
- case 155: /* sortorder ::= ASC */
93083
- case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
93119
+ case 156: /* sortorder ::= ASC */
93120
+ case 158: /* sortorder ::= */ yytestcase(yyruleno==158);
9308493121
{yygotominor.yy328 = SQLITE_SO_ASC;}
9308593122
break;
93086
- case 156: /* sortorder ::= DESC */
93123
+ case 157: /* sortorder ::= DESC */
9308793124
{yygotominor.yy328 = SQLITE_SO_DESC;}
9308893125
break;
93089
- case 162: /* limit_opt ::= */
93126
+ case 163: /* limit_opt ::= */
9309093127
{yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
9309193128
break;
93092
- case 163: /* limit_opt ::= LIMIT expr */
93129
+ case 164: /* limit_opt ::= LIMIT expr */
9309393130
{yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
9309493131
break;
93095
- case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
93132
+ case 165: /* limit_opt ::= LIMIT expr OFFSET expr */
9309693133
{yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
9309793134
break;
93098
- case 165: /* limit_opt ::= LIMIT expr COMMA expr */
93135
+ case 166: /* limit_opt ::= LIMIT expr COMMA expr */
9309993136
{yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
9310093137
break;
93101
- case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
93138
+ case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
9310293139
{
9310393140
sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0);
9310493141
sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132);
9310593142
}
9310693143
break;
93107
- case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
93144
+ case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
9310893145
{
9310993146
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0);
9311093147
sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list");
9311193148
sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186);
9311293149
}
9311393150
break;
93114
- case 170: /* setlist ::= setlist COMMA nm EQ expr */
93151
+ case 171: /* setlist ::= setlist COMMA nm EQ expr */
9311593152
{
9311693153
yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr);
9311793154
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
9311893155
}
9311993156
break;
93120
- case 171: /* setlist ::= nm EQ expr */
93157
+ case 172: /* setlist ::= nm EQ expr */
9312193158
{
9312293159
yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr);
9312393160
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
9312493161
}
9312593162
break;
93126
- case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
93163
+ case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
9312793164
{sqlite3Insert(pParse, yymsp[-5].minor.yy65, yymsp[-1].minor.yy14, 0, yymsp[-4].minor.yy408, yymsp[-7].minor.yy186);}
9312893165
break;
93129
- case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
93166
+ case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
9313093167
{sqlite3Insert(pParse, yymsp[-2].minor.yy65, 0, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);}
9313193168
break;
93132
- case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
93169
+ case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
9313393170
{sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);}
9313493171
break;
93135
- case 175: /* insert_cmd ::= INSERT orconf */
93172
+ case 176: /* insert_cmd ::= INSERT orconf */
9313693173
{yygotominor.yy186 = yymsp[0].minor.yy186;}
9313793174
break;
93138
- case 176: /* insert_cmd ::= REPLACE */
93175
+ case 177: /* insert_cmd ::= REPLACE */
9313993176
{yygotominor.yy186 = OE_Replace;}
9314093177
break;
93141
- case 177: /* itemlist ::= itemlist COMMA expr */
93142
- case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241);
93178
+ case 178: /* itemlist ::= itemlist COMMA expr */
93179
+ case 242: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==242);
9314393180
{yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);}
9314493181
break;
93145
- case 178: /* itemlist ::= expr */
93146
- case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242);
93182
+ case 179: /* itemlist ::= expr */
93183
+ case 243: /* nexprlist ::= expr */ yytestcase(yyruleno==243);
9314793184
{yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
9314893185
break;
93149
- case 181: /* inscollist ::= inscollist COMMA nm */
93186
+ case 182: /* inscollist ::= inscollist COMMA nm */
9315093187
{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
9315193188
break;
93152
- case 182: /* inscollist ::= nm */
93189
+ case 183: /* inscollist ::= nm */
9315393190
{yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
9315493191
break;
93155
- case 183: /* expr ::= term */
93156
- case 211: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==211);
93192
+ case 184: /* expr ::= term */
93193
+ case 212: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==212);
9315793194
{yygotominor.yy346 = yymsp[0].minor.yy346;}
9315893195
break;
93159
- case 184: /* expr ::= LP expr RP */
93196
+ case 185: /* expr ::= LP expr RP */
9316093197
{yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
9316193198
break;
93162
- case 185: /* term ::= NULL */
93163
- case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
93164
- case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
93199
+ case 186: /* term ::= NULL */
93200
+ case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191);
93201
+ case 192: /* term ::= STRING */ yytestcase(yyruleno==192);
9316593202
{spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
9316693203
break;
93167
- case 186: /* expr ::= id */
93168
- case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
93204
+ case 187: /* expr ::= id */
93205
+ case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188);
9316993206
{spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
9317093207
break;
93171
- case 188: /* expr ::= nm DOT nm */
93208
+ case 189: /* expr ::= nm DOT nm */
9317293209
{
9317393210
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
9317493211
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
9317593212
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
9317693213
spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
9317793214
}
9317893215
break;
93179
- case 189: /* expr ::= nm DOT nm DOT nm */
93216
+ case 190: /* expr ::= nm DOT nm DOT nm */
9318093217
{
9318193218
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
9318293219
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
9318393220
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
9318493221
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
9318593222
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
9318693223
spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
9318793224
}
9318893225
break;
93189
- case 192: /* expr ::= REGISTER */
93226
+ case 193: /* expr ::= REGISTER */
9319093227
{
9319193228
/* When doing a nested parse, one can include terms in an expression
9319293229
** that look like this: #1 #2 ... These terms refer to registers
9319393230
** in the virtual machine. #N is the N-th register. */
9319493231
if( pParse->nested==0 ){
@@ -93199,31 +93236,31 @@
9319993236
if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable);
9320093237
}
9320193238
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
9320293239
}
9320393240
break;
93204
- case 193: /* expr ::= VARIABLE */
93241
+ case 194: /* expr ::= VARIABLE */
9320593242
{
9320693243
spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
9320793244
sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr);
9320893245
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
9320993246
}
9321093247
break;
93211
- case 194: /* expr ::= expr COLLATE ids */
93248
+ case 195: /* expr ::= expr COLLATE ids */
9321293249
{
9321393250
yygotominor.yy346.pExpr = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
9321493251
yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
9321593252
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9321693253
}
9321793254
break;
93218
- case 195: /* expr ::= CAST LP expr AS typetoken RP */
93255
+ case 196: /* expr ::= CAST LP expr AS typetoken RP */
9321993256
{
9322093257
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0);
9322193258
spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
9322293259
}
9322393260
break;
93224
- case 196: /* expr ::= ID LP distinct exprlist RP */
93261
+ case 197: /* expr ::= ID LP distinct exprlist RP */
9322593262
{
9322693263
if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
9322793264
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
9322893265
}
9322993266
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
@@ -93231,17 +93268,17 @@
9323193268
if( yymsp[-2].minor.yy328 && yygotominor.yy346.pExpr ){
9323293269
yygotominor.yy346.pExpr->flags |= EP_Distinct;
9323393270
}
9323493271
}
9323593272
break;
93236
- case 197: /* expr ::= ID LP STAR RP */
93273
+ case 198: /* expr ::= ID LP STAR RP */
9323793274
{
9323893275
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
9323993276
spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
9324093277
}
9324193278
break;
93242
- case 198: /* term ::= CTIME_KW */
93279
+ case 199: /* term ::= CTIME_KW */
9324393280
{
9324493281
/* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
9324593282
** treated as functions that return constants */
9324693283
yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
9324793284
if( yygotominor.yy346.pExpr ){
@@ -93248,32 +93285,32 @@
9324893285
yygotominor.yy346.pExpr->op = TK_CONST_FUNC;
9324993286
}
9325093287
spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
9325193288
}
9325293289
break;
93253
- case 199: /* expr ::= expr AND expr */
93254
- case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
93255
- case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
93256
- case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
93257
- case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
93258
- case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
93259
- case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
93260
- case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
93290
+ case 200: /* expr ::= expr AND expr */
93291
+ case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201);
93292
+ case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202);
93293
+ case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203);
93294
+ case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204);
93295
+ case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205);
93296
+ case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206);
93297
+ case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207);
9326193298
{spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);}
9326293299
break;
93263
- case 207: /* likeop ::= LIKE_KW */
93264
- case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
93300
+ case 208: /* likeop ::= LIKE_KW */
93301
+ case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210);
9326593302
{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;}
9326693303
break;
93267
- case 208: /* likeop ::= NOT LIKE_KW */
93268
- case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
93304
+ case 209: /* likeop ::= NOT LIKE_KW */
93305
+ case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211);
9326993306
{yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 1;}
9327093307
break;
93271
- case 212: /* escape ::= */
93308
+ case 213: /* escape ::= */
9327293309
{memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));}
9327393310
break;
93274
- case 213: /* expr ::= expr likeop expr escape */
93311
+ case 214: /* expr ::= expr likeop expr escape */
9327593312
{
9327693313
ExprList *pList;
9327793314
pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr);
9327893315
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy346.pExpr);
9327993316
if( yymsp[0].minor.yy346.pExpr ){
@@ -93284,39 +93321,39 @@
9328493321
yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
9328593322
yygotominor.yy346.zEnd = yymsp[-1].minor.yy346.zEnd;
9328693323
if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
9328793324
}
9328893325
break;
93289
- case 214: /* expr ::= expr ISNULL|NOTNULL */
93326
+ case 215: /* expr ::= expr ISNULL|NOTNULL */
9329093327
{spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
9329193328
break;
93292
- case 215: /* expr ::= expr NOT NULL */
93329
+ case 216: /* expr ::= expr NOT NULL */
9329393330
{spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
9329493331
break;
93295
- case 216: /* expr ::= expr IS expr */
93332
+ case 217: /* expr ::= expr IS expr */
9329693333
{
9329793334
spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
9329893335
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
9329993336
}
9330093337
break;
93301
- case 217: /* expr ::= expr IS NOT expr */
93338
+ case 218: /* expr ::= expr IS NOT expr */
9330293339
{
9330393340
spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
9330493341
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
9330593342
}
9330693343
break;
93307
- case 218: /* expr ::= NOT expr */
93308
- case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
93344
+ case 219: /* expr ::= NOT expr */
93345
+ case 220: /* expr ::= BITNOT expr */ yytestcase(yyruleno==220);
9330993346
{spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
9331093347
break;
93311
- case 220: /* expr ::= MINUS expr */
93348
+ case 221: /* expr ::= MINUS expr */
9331293349
{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
9331393350
break;
93314
- case 221: /* expr ::= PLUS expr */
93351
+ case 222: /* expr ::= PLUS expr */
9331593352
{spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
9331693353
break;
93317
- case 224: /* expr ::= expr between_op expr AND expr */
93354
+ case 225: /* expr ::= expr between_op expr AND expr */
9331893355
{
9331993356
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
9332093357
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
9332193358
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0);
9332293359
if( yygotominor.yy346.pExpr ){
@@ -93327,11 +93364,11 @@
9332793364
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
9332893365
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
9332993366
yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
9333093367
}
9333193368
break;
93332
- case 227: /* expr ::= expr in_op LP exprlist RP */
93369
+ case 228: /* expr ::= expr in_op LP exprlist RP */
9333393370
{
9333493371
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
9333593372
if( yygotominor.yy346.pExpr ){
9333693373
yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
9333793374
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93341,11 +93378,11 @@
9334193378
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
9334293379
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
9334393380
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9334493381
}
9334593382
break;
93346
- case 228: /* expr ::= LP select RP */
93383
+ case 229: /* expr ::= LP select RP */
9334793384
{
9334893385
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
9334993386
if( yygotominor.yy346.pExpr ){
9335093387
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
9335193388
ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93355,11 +93392,11 @@
9335593392
}
9335693393
yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z;
9335793394
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9335893395
}
9335993396
break;
93360
- case 229: /* expr ::= expr in_op LP select RP */
93397
+ case 230: /* expr ::= expr in_op LP select RP */
9336193398
{
9336293399
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
9336393400
if( yygotominor.yy346.pExpr ){
9336493401
yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
9336593402
ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93370,11 +93407,11 @@
9337093407
if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
9337193408
yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
9337293409
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9337393410
}
9337493411
break;
93375
- case 230: /* expr ::= expr in_op nm dbnm */
93412
+ case 231: /* expr ::= expr in_op nm dbnm */
9337693413
{
9337793414
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
9337893415
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
9337993416
if( yygotominor.yy346.pExpr ){
9338093417
yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -93386,11 +93423,11 @@
9338693423
if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
9338793424
yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
9338893425
yygotominor.yy346.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
9338993426
}
9339093427
break;
93391
- case 231: /* expr ::= EXISTS LP select RP */
93428
+ case 232: /* expr ::= EXISTS LP select RP */
9339293429
{
9339393430
Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
9339493431
if( p ){
9339593432
p->x.pSelect = yymsp[-1].minor.yy3;
9339693433
ExprSetProperty(p, EP_xIsSelect);
@@ -93400,11 +93437,11 @@
9340093437
}
9340193438
yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
9340293439
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9340393440
}
9340493441
break;
93405
- case 232: /* expr ::= CASE case_operand case_exprlist case_else END */
93442
+ case 233: /* expr ::= CASE case_operand case_exprlist case_else END */
9340693443
{
9340793444
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, yymsp[-1].minor.yy132, 0);
9340893445
if( yygotominor.yy346.pExpr ){
9340993446
yygotominor.yy346.pExpr->x.pList = yymsp[-2].minor.yy14;
9341093447
sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93413,37 +93450,37 @@
9341393450
}
9341493451
yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z;
9341593452
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9341693453
}
9341793454
break;
93418
- case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
93455
+ case 234: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
9341993456
{
9342093457
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr);
9342193458
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
9342293459
}
9342393460
break;
93424
- case 234: /* case_exprlist ::= WHEN expr THEN expr */
93461
+ case 235: /* case_exprlist ::= WHEN expr THEN expr */
9342593462
{
9342693463
yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
9342793464
yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
9342893465
}
9342993466
break;
93430
- case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
93467
+ case 244: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
9343193468
{
9343293469
sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
9343393470
sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy14, yymsp[-9].minor.yy328,
9343493471
&yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy328);
9343593472
}
9343693473
break;
93437
- case 244: /* uniqueflag ::= UNIQUE */
93438
- case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298);
93474
+ case 245: /* uniqueflag ::= UNIQUE */
93475
+ case 299: /* raisetype ::= ABORT */ yytestcase(yyruleno==299);
9343993476
{yygotominor.yy328 = OE_Abort;}
9344093477
break;
93441
- case 245: /* uniqueflag ::= */
93478
+ case 246: /* uniqueflag ::= */
9344293479
{yygotominor.yy328 = OE_None;}
9344393480
break;
93444
- case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */
93481
+ case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */
9344593482
{
9344693483
Expr *p = 0;
9344793484
if( yymsp[-1].minor.yy0.n>0 ){
9344893485
p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
9344993486
sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93452,11 +93489,11 @@
9345293489
sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
9345393490
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
9345493491
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
9345593492
}
9345693493
break;
93457
- case 249: /* idxlist ::= nm collate sortorder */
93494
+ case 250: /* idxlist ::= nm collate sortorder */
9345893495
{
9345993496
Expr *p = 0;
9346093497
if( yymsp[-1].minor.yy0.n>0 ){
9346193498
p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
9346293499
sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93465,212 +93502,212 @@
9346593502
sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
9346693503
sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
9346793504
if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
9346893505
}
9346993506
break;
93470
- case 250: /* collate ::= */
93507
+ case 251: /* collate ::= */
9347193508
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
9347293509
break;
93473
- case 252: /* cmd ::= DROP INDEX ifexists fullname */
93510
+ case 253: /* cmd ::= DROP INDEX ifexists fullname */
9347493511
{sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
9347593512
break;
93476
- case 253: /* cmd ::= VACUUM */
93477
- case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254);
93513
+ case 254: /* cmd ::= VACUUM */
93514
+ case 255: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==255);
9347893515
{sqlite3Vacuum(pParse);}
9347993516
break;
93480
- case 255: /* cmd ::= PRAGMA nm dbnm */
93517
+ case 256: /* cmd ::= PRAGMA nm dbnm */
9348193518
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
9348293519
break;
93483
- case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
93520
+ case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
9348493521
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
9348593522
break;
93486
- case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
93523
+ case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
9348793524
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
9348893525
break;
93489
- case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
93526
+ case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
9349093527
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
9349193528
break;
93492
- case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
93529
+ case 260: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
9349393530
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
9349493531
break;
93495
- case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
93532
+ case 271: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
9349693533
{
9349793534
Token all;
9349893535
all.z = yymsp[-3].minor.yy0.z;
9349993536
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
9350093537
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
9350193538
}
9350293539
break;
93503
- case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
93540
+ case 272: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
9350493541
{
9350593542
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328);
9350693543
yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
9350793544
}
9350893545
break;
93509
- case 272: /* trigger_time ::= BEFORE */
93510
- case 275: /* trigger_time ::= */ yytestcase(yyruleno==275);
93546
+ case 273: /* trigger_time ::= BEFORE */
93547
+ case 276: /* trigger_time ::= */ yytestcase(yyruleno==276);
9351193548
{ yygotominor.yy328 = TK_BEFORE; }
9351293549
break;
93513
- case 273: /* trigger_time ::= AFTER */
93550
+ case 274: /* trigger_time ::= AFTER */
9351493551
{ yygotominor.yy328 = TK_AFTER; }
9351593552
break;
93516
- case 274: /* trigger_time ::= INSTEAD OF */
93553
+ case 275: /* trigger_time ::= INSTEAD OF */
9351793554
{ yygotominor.yy328 = TK_INSTEAD;}
9351893555
break;
93519
- case 276: /* trigger_event ::= DELETE|INSERT */
93520
- case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277);
93556
+ case 277: /* trigger_event ::= DELETE|INSERT */
93557
+ case 278: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==278);
9352193558
{yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
9352293559
break;
93523
- case 278: /* trigger_event ::= UPDATE OF inscollist */
93560
+ case 279: /* trigger_event ::= UPDATE OF inscollist */
9352493561
{yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
9352593562
break;
93526
- case 281: /* when_clause ::= */
93527
- case 303: /* key_opt ::= */ yytestcase(yyruleno==303);
93563
+ case 282: /* when_clause ::= */
93564
+ case 304: /* key_opt ::= */ yytestcase(yyruleno==304);
9352893565
{ yygotominor.yy132 = 0; }
9352993566
break;
93530
- case 282: /* when_clause ::= WHEN expr */
93531
- case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304);
93567
+ case 283: /* when_clause ::= WHEN expr */
93568
+ case 305: /* key_opt ::= KEY expr */ yytestcase(yyruleno==305);
9353293569
{ yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
9353393570
break;
93534
- case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
93571
+ case 284: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
9353593572
{
9353693573
assert( yymsp[-2].minor.yy473!=0 );
9353793574
yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473;
9353893575
yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473;
9353993576
yygotominor.yy473 = yymsp[-2].minor.yy473;
9354093577
}
9354193578
break;
93542
- case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
93579
+ case 285: /* trigger_cmd_list ::= trigger_cmd SEMI */
9354393580
{
9354493581
assert( yymsp[-1].minor.yy473!=0 );
9354593582
yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473;
9354693583
yygotominor.yy473 = yymsp[-1].minor.yy473;
9354793584
}
9354893585
break;
93549
- case 286: /* trnm ::= nm DOT nm */
93586
+ case 287: /* trnm ::= nm DOT nm */
9355093587
{
9355193588
yygotominor.yy0 = yymsp[0].minor.yy0;
9355293589
sqlite3ErrorMsg(pParse,
9355393590
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
9355493591
"statements within triggers");
9355593592
}
9355693593
break;
93557
- case 288: /* tridxby ::= INDEXED BY nm */
93594
+ case 289: /* tridxby ::= INDEXED BY nm */
9355893595
{
9355993596
sqlite3ErrorMsg(pParse,
9356093597
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
9356193598
"within triggers");
9356293599
}
9356393600
break;
93564
- case 289: /* tridxby ::= NOT INDEXED */
93601
+ case 290: /* tridxby ::= NOT INDEXED */
9356593602
{
9356693603
sqlite3ErrorMsg(pParse,
9356793604
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
9356893605
"within triggers");
9356993606
}
9357093607
break;
93571
- case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
93608
+ case 291: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
9357293609
{ yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); }
9357393610
break;
93574
- case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
93611
+ case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
9357593612
{yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy408, yymsp[-1].minor.yy14, 0, yymsp[-7].minor.yy186);}
9357693613
break;
93577
- case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
93614
+ case 293: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
9357893615
{yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, 0, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);}
9357993616
break;
93580
- case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
93617
+ case 294: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
9358193618
{yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
9358293619
break;
93583
- case 294: /* trigger_cmd ::= select */
93620
+ case 295: /* trigger_cmd ::= select */
9358493621
{yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
9358593622
break;
93586
- case 295: /* expr ::= RAISE LP IGNORE RP */
93623
+ case 296: /* expr ::= RAISE LP IGNORE RP */
9358793624
{
9358893625
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
9358993626
if( yygotominor.yy346.pExpr ){
9359093627
yygotominor.yy346.pExpr->affinity = OE_Ignore;
9359193628
}
9359293629
yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
9359393630
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9359493631
}
9359593632
break;
93596
- case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */
93633
+ case 297: /* expr ::= RAISE LP raisetype COMMA nm RP */
9359793634
{
9359893635
yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
9359993636
if( yygotominor.yy346.pExpr ) {
9360093637
yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328;
9360193638
}
9360293639
yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z;
9360393640
yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
9360493641
}
9360593642
break;
93606
- case 297: /* raisetype ::= ROLLBACK */
93643
+ case 298: /* raisetype ::= ROLLBACK */
9360793644
{yygotominor.yy328 = OE_Rollback;}
9360893645
break;
93609
- case 299: /* raisetype ::= FAIL */
93646
+ case 300: /* raisetype ::= FAIL */
9361093647
{yygotominor.yy328 = OE_Fail;}
9361193648
break;
93612
- case 300: /* cmd ::= DROP TRIGGER ifexists fullname */
93649
+ case 301: /* cmd ::= DROP TRIGGER ifexists fullname */
9361393650
{
9361493651
sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
9361593652
}
9361693653
break;
93617
- case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
93654
+ case 302: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
9361893655
{
9361993656
sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132);
9362093657
}
9362193658
break;
93622
- case 302: /* cmd ::= DETACH database_kw_opt expr */
93659
+ case 303: /* cmd ::= DETACH database_kw_opt expr */
9362393660
{
9362493661
sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
9362593662
}
9362693663
break;
93627
- case 307: /* cmd ::= REINDEX */
93664
+ case 308: /* cmd ::= REINDEX */
9362893665
{sqlite3Reindex(pParse, 0, 0);}
9362993666
break;
93630
- case 308: /* cmd ::= REINDEX nm dbnm */
93667
+ case 309: /* cmd ::= REINDEX nm dbnm */
9363193668
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
9363293669
break;
93633
- case 309: /* cmd ::= ANALYZE */
93670
+ case 310: /* cmd ::= ANALYZE */
9363493671
{sqlite3Analyze(pParse, 0, 0);}
9363593672
break;
93636
- case 310: /* cmd ::= ANALYZE nm dbnm */
93673
+ case 311: /* cmd ::= ANALYZE nm dbnm */
9363793674
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
9363893675
break;
93639
- case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
93676
+ case 312: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
9364093677
{
9364193678
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
9364293679
}
9364393680
break;
93644
- case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
93681
+ case 313: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
9364593682
{
9364693683
sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
9364793684
}
9364893685
break;
93649
- case 313: /* add_column_fullname ::= fullname */
93686
+ case 314: /* add_column_fullname ::= fullname */
9365093687
{
9365193688
pParse->db->lookaside.bEnabled = 0;
9365293689
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
9365393690
}
9365493691
break;
93655
- case 316: /* cmd ::= create_vtab */
93692
+ case 317: /* cmd ::= create_vtab */
9365693693
{sqlite3VtabFinishParse(pParse,0);}
9365793694
break;
93658
- case 317: /* cmd ::= create_vtab LP vtabarglist RP */
93695
+ case 318: /* cmd ::= create_vtab LP vtabarglist RP */
9365993696
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
9366093697
break;
93661
- case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
93698
+ case 319: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
9366293699
{
9366393700
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
9366493701
}
9366593702
break;
93666
- case 321: /* vtabarg ::= */
93703
+ case 322: /* vtabarg ::= */
9366793704
{sqlite3VtabArgInit(pParse);}
9366893705
break;
93669
- case 323: /* vtabargtoken ::= ANY */
93670
- case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324);
93671
- case 325: /* lp ::= LP */ yytestcase(yyruleno==325);
93706
+ case 324: /* vtabargtoken ::= ANY */
93707
+ case 325: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==325);
93708
+ case 326: /* lp ::= LP */ yytestcase(yyruleno==326);
9367293709
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
9367393710
break;
9367493711
default:
9367593712
/* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
9367693713
/* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -93691,29 +93728,29 @@
9369193728
/* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
9369293729
/* (54) carglist ::= */ yytestcase(yyruleno==54);
9369393730
/* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
9369493731
/* (56) carg ::= ccons */ yytestcase(yyruleno==56);
9369593732
/* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
93696
- /* (89) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==89);
93697
- /* (90) conslist ::= conslist tcons */ yytestcase(yyruleno==90);
93698
- /* (91) conslist ::= tcons */ yytestcase(yyruleno==91);
93699
- /* (92) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==92);
93700
- /* (268) plus_opt ::= PLUS */ yytestcase(yyruleno==268);
93701
- /* (269) plus_opt ::= */ yytestcase(yyruleno==269);
93702
- /* (279) foreach_clause ::= */ yytestcase(yyruleno==279);
93703
- /* (280) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==280);
93704
- /* (287) tridxby ::= */ yytestcase(yyruleno==287);
93705
- /* (305) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==305);
93706
- /* (306) database_kw_opt ::= */ yytestcase(yyruleno==306);
93707
- /* (314) kwcolumn_opt ::= */ yytestcase(yyruleno==314);
93708
- /* (315) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==315);
93709
- /* (319) vtabarglist ::= vtabarg */ yytestcase(yyruleno==319);
93710
- /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==320);
93711
- /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
93712
- /* (326) anylist ::= */ yytestcase(yyruleno==326);
93713
- /* (327) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==327);
93714
- /* (328) anylist ::= anylist ANY */ yytestcase(yyruleno==328);
93733
+ /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
93734
+ /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
93735
+ /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
93736
+ /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
93737
+ /* (269) plus_opt ::= PLUS */ yytestcase(yyruleno==269);
93738
+ /* (270) plus_opt ::= */ yytestcase(yyruleno==270);
93739
+ /* (280) foreach_clause ::= */ yytestcase(yyruleno==280);
93740
+ /* (281) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==281);
93741
+ /* (288) tridxby ::= */ yytestcase(yyruleno==288);
93742
+ /* (306) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==306);
93743
+ /* (307) database_kw_opt ::= */ yytestcase(yyruleno==307);
93744
+ /* (315) kwcolumn_opt ::= */ yytestcase(yyruleno==315);
93745
+ /* (316) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==316);
93746
+ /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
93747
+ /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
93748
+ /* (323) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==323);
93749
+ /* (327) anylist ::= */ yytestcase(yyruleno==327);
93750
+ /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
93751
+ /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);
9371593752
break;
9371693753
};
9371793754
yygoto = yyRuleInfo[yyruleno].lhs;
9371893755
yysize = yyRuleInfo[yyruleno].nrhs;
9371993756
yypParser->yyidx -= yysize;
@@ -94300,10 +94337,11 @@
9430094337
return TK_ID;
9430194338
}
9430294339
SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
9430394340
return keywordCode((char*)z, n);
9430494341
}
94342
+#define SQLITE_N_KEYWORD 121
9430594343
9430694344
/************** End of keywordhash.h *****************************************/
9430794345
/************** Continuing where we left off in tokenize.c *******************/
9430894346
9430994347
@@ -94363,12 +94401,13 @@
9436394401
*tokenType = TK_SPACE;
9436494402
return i;
9436594403
}
9436694404
case '-': {
9436794405
if( z[1]=='-' ){
94406
+ /* IMP: R-15891-05542 -- syntax diagram for comments */
9436894407
for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
94369
- *tokenType = TK_SPACE;
94408
+ *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
9437094409
return i;
9437194410
}
9437294411
*tokenType = TK_MINUS;
9437394412
return 1;
9437494413
}
@@ -94395,13 +94434,14 @@
9439594434
case '/': {
9439694435
if( z[1]!='*' || z[2]==0 ){
9439794436
*tokenType = TK_SLASH;
9439894437
return 1;
9439994438
}
94439
+ /* IMP: R-15891-05542 -- syntax diagram for comments */
9440094440
for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
9440194441
if( c ) i++;
94402
- *tokenType = TK_SPACE;
94442
+ *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
9440394443
return i;
9440494444
}
9440594445
case '%': {
9440694446
*tokenType = TK_REM;
9440794447
return 1;
@@ -94806,61 +94846,66 @@
9480694846
** comments on that procedure for additional information.
9480794847
*/
9480894848
#define tkSEMI 0
9480994849
#define tkWS 1
9481094850
#define tkOTHER 2
94851
+#ifndef SQLITE_OMIT_TRIGGER
9481194852
#define tkEXPLAIN 3
9481294853
#define tkCREATE 4
9481394854
#define tkTEMP 5
9481494855
#define tkTRIGGER 6
9481594856
#define tkEND 7
94857
+#endif
9481694858
9481794859
/*
9481894860
** Return TRUE if the given SQL string ends in a semicolon.
9481994861
**
9482094862
** Special handling is require for CREATE TRIGGER statements.
9482194863
** Whenever the CREATE TRIGGER keywords are seen, the statement
9482294864
** must end with ";END;".
9482394865
**
94824
-** This implementation uses a state machine with 7 states:
94866
+** This implementation uses a state machine with 8 states:
9482594867
**
94826
-** (0) START At the beginning or end of an SQL statement. This routine
94868
+** (0) INVALID We have not yet seen a non-whitespace character.
94869
+**
94870
+** (1) START At the beginning or end of an SQL statement. This routine
9482794871
** returns 1 if it ends in the START state and 0 if it ends
9482894872
** in any other state.
9482994873
**
94830
-** (1) NORMAL We are in the middle of statement which ends with a single
94874
+** (2) NORMAL We are in the middle of statement which ends with a single
9483194875
** semicolon.
9483294876
**
94833
-** (2) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
94877
+** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
9483494878
** a statement.
9483594879
**
94836
-** (3) CREATE The keyword CREATE has been seen at the beginning of a
94880
+** (4) CREATE The keyword CREATE has been seen at the beginning of a
9483794881
** statement, possibly preceeded by EXPLAIN and/or followed by
9483894882
** TEMP or TEMPORARY
9483994883
**
94840
-** (4) TRIGGER We are in the middle of a trigger definition that must be
94884
+** (5) TRIGGER We are in the middle of a trigger definition that must be
9484194885
** ended by a semicolon, the keyword END, and another semicolon.
9484294886
**
94843
-** (5) SEMI We've seen the first semicolon in the ";END;" that occurs at
94887
+** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at
9484494888
** the end of a trigger definition.
9484594889
**
94846
-** (6) END We've seen the ";END" of the ";END;" that occurs at the end
94890
+** (7) END We've seen the ";END" of the ";END;" that occurs at the end
9484794891
** of a trigger difinition.
9484894892
**
9484994893
** Transitions between states above are determined by tokens extracted
9485094894
** from the input. The following tokens are significant:
9485194895
**
9485294896
** (0) tkSEMI A semicolon.
94853
-** (1) tkWS Whitespace
94897
+** (1) tkWS Whitespace.
9485494898
** (2) tkOTHER Any other SQL token.
9485594899
** (3) tkEXPLAIN The "explain" keyword.
9485694900
** (4) tkCREATE The "create" keyword.
9485794901
** (5) tkTEMP The "temp" or "temporary" keyword.
9485894902
** (6) tkTRIGGER The "trigger" keyword.
9485994903
** (7) tkEND The "end" keyword.
9486094904
**
9486194905
** Whitespace never causes a state transition and is always ignored.
94906
+** This means that a SQL string of all whitespace is invalid.
9486294907
**
9486394908
** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
9486494909
** to recognize the end of a trigger can be omitted. All we have to do
9486594910
** is look for a semicolon that is not part of an string or comment.
9486694911
*/
@@ -94870,30 +94915,32 @@
9487094915
9487194916
#ifndef SQLITE_OMIT_TRIGGER
9487294917
/* A complex statement machine used to detect the end of a CREATE TRIGGER
9487394918
** statement. This is the normal case.
9487494919
*/
94875
- static const u8 trans[7][8] = {
94920
+ static const u8 trans[8][8] = {
9487694921
/* Token: */
94877
- /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
94878
- /* 0 START: */ { 0, 0, 1, 2, 3, 1, 1, 1, },
94879
- /* 1 NORMAL: */ { 0, 1, 1, 1, 1, 1, 1, 1, },
94880
- /* 2 EXPLAIN: */ { 0, 2, 2, 1, 3, 1, 1, 1, },
94881
- /* 3 CREATE: */ { 0, 3, 1, 1, 1, 3, 4, 1, },
94882
- /* 4 TRIGGER: */ { 5, 4, 4, 4, 4, 4, 4, 4, },
94883
- /* 5 SEMI: */ { 5, 5, 4, 4, 4, 4, 4, 6, },
94884
- /* 6 END: */ { 0, 6, 4, 4, 4, 4, 4, 4, },
94922
+ /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
94923
+ /* 0 INVALID: */ { 1, 0, 2, 3, 4, 2, 2, 2, },
94924
+ /* 1 START: */ { 1, 1, 2, 3, 4, 2, 2, 2, },
94925
+ /* 2 NORMAL: */ { 1, 2, 2, 2, 2, 2, 2, 2, },
94926
+ /* 3 EXPLAIN: */ { 1, 3, 3, 2, 4, 2, 2, 2, },
94927
+ /* 4 CREATE: */ { 1, 4, 2, 2, 2, 4, 5, 2, },
94928
+ /* 5 TRIGGER: */ { 6, 5, 5, 5, 5, 5, 5, 5, },
94929
+ /* 6 SEMI: */ { 6, 6, 5, 5, 5, 5, 5, 7, },
94930
+ /* 7 END: */ { 1, 7, 5, 5, 5, 5, 5, 5, },
9488594931
};
9488694932
#else
94887
- /* If triggers are not suppored by this compile then the statement machine
94933
+ /* If triggers are not supported by this compile then the statement machine
9488894934
** used to detect the end of a statement is much simplier
9488994935
*/
94890
- static const u8 trans[2][3] = {
94936
+ static const u8 trans[3][3] = {
9489194937
/* Token: */
9489294938
/* State: ** SEMI WS OTHER */
94893
- /* 0 START: */ { 0, 0, 1, },
94894
- /* 1 NORMAL: */ { 0, 1, 1, },
94939
+ /* 0 INVALID: */ { 1, 0, 2, },
94940
+ /* 1 START: */ { 1, 1, 2, },
94941
+ /* 2 NORMAL: */ { 1, 2, 2, },
9489594942
};
9489694943
#endif /* SQLITE_OMIT_TRIGGER */
9489794944
9489894945
while( *zSql ){
9489994946
switch( *zSql ){
@@ -94925,11 +94972,11 @@
9492594972
if( zSql[1]!='-' ){
9492694973
token = tkOTHER;
9492794974
break;
9492894975
}
9492994976
while( *zSql && *zSql!='\n' ){ zSql++; }
94930
- if( *zSql==0 ) return state==0;
94977
+ if( *zSql==0 ) return state==1;
9493194978
token = tkWS;
9493294979
break;
9493394980
}
9493494981
case '[': { /* Microsoft-style identifiers in [...] */
9493594982
zSql++;
@@ -95009,11 +95056,11 @@
9500995056
}
9501095057
}
9501195058
state = trans[state][token];
9501295059
zSql++;
9501395060
}
95014
- return state==0;
95061
+ return state==1;
9501595062
}
9501695063
9501795064
#ifndef SQLITE_OMIT_UTF16
9501895065
/*
9501995066
** This routine is the same as the sqlite3_complete() routine described
@@ -95397,11 +95444,11 @@
9539795444
switch( op ){
9539895445
9539995446
/* Mutex configuration options are only available in a threadsafe
9540095447
** compile.
9540195448
*/
95402
-#if SQLITE_THREADSAFE
95449
+#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0
9540395450
case SQLITE_CONFIG_SINGLETHREAD: {
9540495451
/* Disable all mutexing */
9540595452
sqlite3GlobalConfig.bCoreMutex = 0;
9540695453
sqlite3GlobalConfig.bFullMutex = 0;
9540795454
break;
@@ -97413,10 +97460,44 @@
9741397460
sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);
9741497461
sqlite3_mutex_leave(db->mutex);
9741597462
break;
9741697463
}
9741797464
97465
+ /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)
97466
+ **
97467
+ ** Enable or disable various optimizations for testing purposes. The
97468
+ ** argument N is a bitmask of optimizations to be disabled. For normal
97469
+ ** operation N should be 0. The idea is that a test program (like the
97470
+ ** SQL Logic Test or SLT test module) can run the same SQL multiple times
97471
+ ** with various optimizations disabled to verify that the same answer
97472
+ ** is obtained in every case.
97473
+ */
97474
+ case SQLITE_TESTCTRL_OPTIMIZATIONS: {
97475
+ sqlite3 *db = va_arg(ap, sqlite3*);
97476
+ int x = va_arg(ap,int);
97477
+ db->flags = (x & SQLITE_OptMask) | (db->flags & ~SQLITE_OptMask);
97478
+ break;
97479
+ }
97480
+
97481
+#ifdef SQLITE_N_KEYWORD
97482
+ /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
97483
+ **
97484
+ ** If zWord is a keyword recognized by the parser, then return the
97485
+ ** number of keywords. Or if zWord is not a keyword, return 0.
97486
+ **
97487
+ ** This test feature is only available in the amalgamation since
97488
+ ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
97489
+ ** is built using separate source files.
97490
+ */
97491
+ case SQLITE_TESTCTRL_ISKEYWORD: {
97492
+ const char *zWord = va_arg(ap, const char*);
97493
+ int n = sqlite3Strlen30(zWord);
97494
+ rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;
97495
+ break;
97496
+ }
97497
+#endif
97498
+
9741897499
}
9741997500
va_end(ap);
9742097501
#endif /* SQLITE_OMIT_BUILTIN_TEST */
9742197502
return rc;
9742297503
}
@@ -98203,10 +98284,14 @@
9820398284
9820498285
struct sqlite3_tokenizer_cursor {
9820598286
sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */
9820698287
/* Tokenizer implementations will typically add additional fields */
9820798288
};
98289
+
98290
+int fts3_global_term_cnt(int iTerm, int iCol);
98291
+int fts3_term_cnt(int iTerm, int iCol);
98292
+
9820898293
9820998294
#endif /* _FTS3_TOKENIZER_H_ */
9821098295
9821198296
/************** End of fts3_tokenizer.h **************************************/
9821298297
/************** Continuing where we left off in fts3Int.h ********************/
@@ -98287,18 +98372,20 @@
9828798372
*/
9828898373
SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);
9828998374
SQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);
9829098375
SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);
9829198376
SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);
98377
+SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);
9829298378
9829398379
/*
9829498380
** Shorthand for the functions above
9829598381
*/
98296
-#define fts3HashInit sqlite3Fts3HashInit
98297
-#define fts3HashInsert sqlite3Fts3HashInsert
98298
-#define fts3HashFind sqlite3Fts3HashFind
98299
-#define fts3HashClear sqlite3Fts3HashClear
98382
+#define fts3HashInit sqlite3Fts3HashInit
98383
+#define fts3HashInsert sqlite3Fts3HashInsert
98384
+#define fts3HashFind sqlite3Fts3HashFind
98385
+#define fts3HashClear sqlite3Fts3HashClear
98386
+#define fts3HashFindElem sqlite3Fts3HashFindElem
9830098387
9830198388
/*
9830298389
** Macros for looping over all elements of a hash table. The idiom is
9830398390
** like this:
9830498391
**
@@ -98371,10 +98458,12 @@
9837198458
/*
9837298459
** Internal types used by SQLite.
9837398460
*/
9837498461
typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
9837598462
typedef short int i16; /* 2-byte (or larger) signed integer */
98463
+typedef unsigned int u32; /* 4-byte unsigned integer */
98464
+typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
9837698465
/*
9837798466
** Macro used to suppress compiler warnings for unused parameters.
9837898467
*/
9837998468
#define UNUSED_PARAMETER(x) (void)(x)
9838098469
#endif
@@ -98421,14 +98510,15 @@
9842198510
int nNodeSize; /* Soft limit for node size */
9842298511
9842398512
/* The following hash table is used to buffer pending index updates during
9842498513
** transactions. Variable nPendingData estimates the memory size of the
9842598514
** pending data, including hash table overhead, but not malloc overhead.
98426
- ** When nPendingData exceeds FTS3_MAX_PENDING_DATA, the buffer is flushed
98515
+ ** When nPendingData exceeds nMaxPendingData, the buffer is flushed
9842798516
** automatically. Variable iPrevDocid is the docid of the most recently
9842898517
** inserted record.
9842998518
*/
98519
+ int nMaxPendingData;
9843098520
int nPendingData;
9843198521
sqlite_int64 iPrevDocid;
9843298522
Fts3Hash pendingTerms;
9843398523
};
9843498524
@@ -98446,10 +98536,12 @@
9844698536
Fts3Expr *pExpr; /* Parsed MATCH query string */
9844798537
sqlite3_int64 iPrevId; /* Previous id read from aDoclist */
9844898538
char *pNextId; /* Pointer into the body of aDoclist */
9844998539
char *aDoclist; /* List of docids for full-text queries */
9845098540
int nDoclist; /* Size of buffer at aDoclist */
98541
+ int isMatchinfoOk; /* True when aMatchinfo[] matches iPrevId */
98542
+ u32 *aMatchinfo;
9845198543
};
9845298544
9845398545
/*
9845498546
** The Fts3Cursor.eSearch member is always set to one of the following.
9845598547
** Actualy, Fts3Cursor.eSearch can be greater than or equal to
@@ -98486,18 +98578,35 @@
9848698578
} aToken[1]; /* One entry for each token in the phrase */
9848798579
};
9848898580
9848998581
/*
9849098582
** A tree of these objects forms the RHS of a MATCH operator.
98583
+**
98584
+** If Fts3Expr.eType is either FTSQUERY_NEAR or FTSQUERY_PHRASE and isLoaded
98585
+** is true, then aDoclist points to a malloced buffer, size nDoclist bytes,
98586
+** containing the results of the NEAR or phrase query in FTS3 doclist
98587
+** format. As usual, the initial "Length" field found in doclists stored
98588
+** on disk is omitted from this buffer.
98589
+**
98590
+** Variable pCurrent always points to the start of a docid field within
98591
+** aDoclist. Since the doclist is usually scanned in docid order, this can
98592
+** be used to accelerate seeking to the required docid within the doclist.
9849198593
*/
9849298594
struct Fts3Expr {
9849398595
int eType; /* One of the FTSQUERY_XXX values defined below */
9849498596
int nNear; /* Valid if eType==FTSQUERY_NEAR */
9849598597
Fts3Expr *pParent; /* pParent->pLeft==this or pParent->pRight==this */
9849698598
Fts3Expr *pLeft; /* Left operand */
9849798599
Fts3Expr *pRight; /* Right operand */
9849898600
Fts3Phrase *pPhrase; /* Valid if eType==FTSQUERY_PHRASE */
98601
+
98602
+ int isLoaded; /* True if aDoclist/nDoclist are initialized. */
98603
+ char *aDoclist; /* Buffer containing doclist */
98604
+ int nDoclist; /* Size of aDoclist in bytes */
98605
+
98606
+ sqlite3_int64 iCurrent;
98607
+ char *pCurrent;
9849998608
};
9850098609
9850198610
/*
9850298611
** Candidate values for Fts3Query.eType. Note that the order of the first
9850398612
** four values is in order of precedence when parsing expressions. For
@@ -98526,10 +98635,11 @@
9852698635
SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);
9852798636
SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);
9852898637
SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);
9852998638
SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(Fts3Table *,int, sqlite3_int64,
9853098639
sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);
98640
+SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(Fts3Table*,const char*,int,int,Fts3SegReader**);
9853198641
SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *, Fts3SegReader *);
9853298642
SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate(
9853398643
Fts3Table *, Fts3SegReader **, int, Fts3SegFilter *,
9853498644
int (*)(Fts3Table *, void *, char *, int, char *, int), void *
9853598645
);
@@ -98555,10 +98665,13 @@
9855598665
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
9855698666
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
9855798667
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
9855898668
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
9855998669
98670
+SQLITE_PRIVATE char *sqlite3Fts3FindPositions(Fts3Expr *, sqlite3_int64, int);
98671
+SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *, Fts3Expr *);
98672
+
9856098673
/* fts3_tokenizer.c */
9856198674
SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
9856298675
SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
9856398676
SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash,
9856498677
const char *, sqlite3_tokenizer **, const char **, char **
@@ -98567,18 +98680,22 @@
9856798680
/* fts3_snippet.c */
9856898681
SQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);
9856998682
SQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context*, Fts3Cursor*,
9857098683
const char *, const char *, const char *
9857198684
);
98685
+SQLITE_PRIVATE void sqlite3Fts3Snippet2(sqlite3_context *, Fts3Cursor *, const char *,
98686
+ const char *, const char *, int, int
98687
+);
98688
+SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *);
9857298689
9857398690
/* fts3_expr.c */
9857498691
SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *,
9857598692
char **, int, int, const char *, int, Fts3Expr **
9857698693
);
9857798694
SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
9857898695
#ifdef SQLITE_TEST
98579
-SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
98696
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
9858098697
#endif
9858198698
9858298699
#endif /* _FTSINT_H */
9858398700
9858498701
/************** End of fts3Int.h *********************************************/
@@ -98587,74 +98704,10 @@
9858798704
9858898705
#ifndef SQLITE_CORE
9858998706
SQLITE_EXTENSION_INIT1
9859098707
#endif
9859198708
98592
-
98593
-
98594
-/* TODO(shess) MAN, this thing needs some refactoring. At minimum, it
98595
-** would be nice to order the file better, perhaps something along the
98596
-** lines of:
98597
-**
98598
-** - utility functions
98599
-** - table setup functions
98600
-** - table update functions
98601
-** - table query functions
98602
-**
98603
-** Put the query functions last because they're likely to reference
98604
-** typedefs or functions from the table update section.
98605
-*/
98606
-
98607
-#if 0
98608
-# define FTSTRACE(A) printf A; fflush(stdout)
98609
-#else
98610
-# define FTSTRACE(A)
98611
-#endif
98612
-
98613
-typedef enum DocListType {
98614
- DL_DOCIDS, /* docids only */
98615
- DL_POSITIONS, /* docids + positions */
98616
- DL_POSITIONS_OFFSETS /* docids + positions + offsets */
98617
-} DocListType;
98618
-
98619
-/*
98620
-** By default, only positions and not offsets are stored in the doclists.
98621
-** To change this so that offsets are stored too, compile with
98622
-**
98623
-** -DDL_DEFAULT=DL_POSITIONS_OFFSETS
98624
-**
98625
-** If DL_DEFAULT is set to DL_DOCIDS, your table can only be inserted
98626
-** into (no deletes or updates).
98627
-*/
98628
-#ifndef DL_DEFAULT
98629
-# define DL_DEFAULT DL_POSITIONS
98630
-#endif
98631
-
98632
-enum {
98633
- POS_END = 0, /* end of this position list */
98634
- POS_COLUMN, /* followed by new column number */
98635
- POS_BASE
98636
-};
98637
-
98638
-/* utility functions */
98639
-
98640
-/* CLEAR() and SCRAMBLE() abstract memset() on a pointer to a single
98641
-** record to prevent errors of the form:
98642
-**
98643
-** my_function(SomeType *b){
98644
-** memset(b, '\0', sizeof(b)); // sizeof(b)!=sizeof(*b)
98645
-** }
98646
-*/
98647
-/* TODO(shess) Obvious candidates for a header file. */
98648
-#define CLEAR(b) memset(b, '\0', sizeof(*(b)))
98649
-
98650
-#ifndef NDEBUG
98651
-# define SCRAMBLE(b) memset(b, 0x55, sizeof(*(b)))
98652
-#else
98653
-# define SCRAMBLE(b)
98654
-#endif
98655
-
9865698709
/*
9865798710
** Write a 64-bit variable-length integer to memory starting at p[0].
9865898711
** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
9865998712
** The number of bytes written is returned.
9866098713
*/
@@ -98676,17 +98729,13 @@
9867698729
** The value is stored in *v.
9867798730
*/
9867898731
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
9867998732
const unsigned char *q = (const unsigned char *) p;
9868098733
sqlite_uint64 x = 0, y = 1;
98681
- while( (*q & 0x80) == 0x80 ){
98734
+ while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){
9868298735
x += y * (*q++ & 0x7f);
9868398736
y <<= 7;
98684
- if( q - (unsigned char *)p >= FTS3_VARINT_MAX ){ /* bad data */
98685
- assert( 0 );
98686
- return 0;
98687
- }
9868898737
}
9868998738
x += y * (*q++);
9869098739
*v = (sqlite_int64) x;
9869198740
return (int) (q - (unsigned char *)p);
9869298741
}
@@ -98697,11 +98746,10 @@
9869798746
*/
9869898747
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
9869998748
sqlite_int64 i;
9870098749
int ret = sqlite3Fts3GetVarint(p, &i);
9870198750
*pi = (int) i;
98702
- assert( *pi==i );
9870398751
return ret;
9870498752
}
9870598753
9870698754
/*
9870798755
** Return the number of bytes required to store the value passed as the
@@ -98726,35 +98774,33 @@
9872698774
**
9872798775
** "abc" becomes abc
9872898776
** 'xyz' becomes xyz
9872998777
** [pqr] becomes pqr
9873098778
** `mno` becomes mno
98779
+**
9873198780
*/
9873298781
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){
98733
- int quote;
98734
- int i, j;
98782
+ char quote; /* Quote character (if any ) */
9873598783
9873698784
quote = z[0];
98737
- switch( quote ){
98738
- case '\'': break;
98739
- case '"': break;
98740
- case '`': break; /* For MySQL compatibility */
98741
- case '[': quote = ']'; break; /* For MS SqlServer compatibility */
98742
- default: return;
98743
- }
98744
- for(i=1, j=0; z[i]; i++){
98745
- if( z[i]==quote ){
98746
- if( z[i+1]==quote ){
98747
- z[j++] = (char)quote;
98748
- i++;
98749
- }else{
98750
- z[j++] = 0;
98751
- break;
98752
- }
98753
- }else{
98754
- z[j++] = z[i];
98755
- }
98785
+ if( quote=='[' || quote=='\'' || quote=='"' || quote=='`' ){
98786
+ int iIn = 1; /* Index of next byte to read from input */
98787
+ int iOut = 0; /* Index of next byte to write to output */
98788
+
98789
+ /* If the first byte was a '[', then the close-quote character is a ']' */
98790
+ if( quote=='[' ) quote = ']';
98791
+
98792
+ while( ALWAYS(z[iIn]) ){
98793
+ if( z[iIn]==quote ){
98794
+ if( z[iIn+1]!=quote ) break;
98795
+ z[iOut++] = quote;
98796
+ iIn += 2;
98797
+ }else{
98798
+ z[iOut++] = z[iIn++];
98799
+ }
98800
+ }
98801
+ z[iOut] = '\0';
9875698802
}
9875798803
}
9875898804
9875998805
static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){
9876098806
sqlite3_int64 iVal;
@@ -98919,11 +98965,11 @@
9891998965
** argv[0] -> module name
9892098966
** argv[1] -> database name
9892198967
** argv[2] -> table name
9892298968
** argv[...] -> "column name" and other module argument fields.
9892398969
*/
98924
-int fts3InitVtab(
98970
+static int fts3InitVtab(
9892598971
int isCreate, /* True for xCreate, false for xConnect */
9892698972
sqlite3 *db, /* The SQLite database connection */
9892798973
void *pAux, /* Hash table containing tokenizers */
9892898974
int argc, /* Number of elements in argv array */
9892998975
const char * const *argv, /* xCreate/xConnect argument array */
@@ -98943,18 +98989,10 @@
9894398989
int nName;
9894498990
9894598991
const char *zTokenizer = 0; /* Name of tokenizer to use */
9894698992
sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
9894798993
98948
-#ifdef SQLITE_TEST
98949
- const char *zTestParam = 0;
98950
- if( strncmp(argv[argc-1], "test:", 5)==0 ){
98951
- zTestParam = argv[argc-1];
98952
- argc--;
98953
- }
98954
-#endif
98955
-
9895698994
nDb = (int)strlen(argv[1]) + 1;
9895798995
nName = (int)strlen(argv[2]) + 1;
9895898996
for(i=3; i<argc; i++){
9895998997
char const *z = argv[i];
9896098998
rc = sqlite3Fts3InitTokenizer(pHash, z, &pTokenizer, &zTokenizer, pzErr);
@@ -98995,10 +99033,11 @@
9899599033
p->nColumn = nCol;
9899699034
p->nPendingData = 0;
9899799035
p->azColumn = (char **)&p[1];
9899899036
p->pTokenizer = pTokenizer;
9899999037
p->nNodeSize = 1000;
99038
+ p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
9900099039
zCsr = (char *)&p->azColumn[nCol];
9900199040
9900299041
fts3HashInit(&p->pendingTerms, FTS3_HASH_STRING, 1);
9900399042
9900499043
/* Fill in the zName and zDb fields of the vtab structure. */
@@ -99038,15 +99077,10 @@
9903899077
}
9903999078
9904099079
rc = fts3DeclareVtab(p);
9904199080
if( rc!=SQLITE_OK ) goto fts3_init_out;
9904299081
99043
-#ifdef SQLITE_TEST
99044
- if( zTestParam ){
99045
- p->nNodeSize = atoi(&zTestParam[5]);
99046
- }
99047
-#endif
9904899082
*ppVTab = &p->base;
9904999083
9905099084
fts3_init_out:
9905199085
assert( p || (pTokenizer && rc!=SQLITE_OK) );
9905299086
if( rc!=SQLITE_OK ){
@@ -99105,35 +99139,35 @@
9910599139
pInfo->estimatedCost = 500000;
9910699140
for(i=0; i<pInfo->nConstraint; i++){
9910799141
struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
9910899142
if( pCons->usable==0 ) continue;
9910999143
99110
- /* A direct lookup on the rowid or docid column. This is the best
99111
- ** strategy in all cases. Assign a cost of 1.0 and return early.
99112
- */
99144
+ /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
9911399145
if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
9911499146
&& (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
9911599147
){
9911699148
pInfo->idxNum = FTS3_DOCID_SEARCH;
9911799149
pInfo->estimatedCost = 1.0;
9911899150
iCons = i;
99119
- break;
9912099151
}
9912199152
9912299153
/* A MATCH constraint. Use a full-text search.
9912399154
**
9912499155
** If there is more than one MATCH constraint available, use the first
9912599156
** one encountered. If there is both a MATCH constraint and a direct
99126
- ** rowid/docid lookup, prefer the rowid/docid strategy.
99157
+ ** rowid/docid lookup, prefer the MATCH strategy. This is done even
99158
+ ** though the rowid/docid lookup is faster than a MATCH query, selecting
99159
+ ** it would lead to an "unable to use function MATCH in the requested
99160
+ ** context" error.
9912799161
*/
99128
- if( iCons<0
99129
- && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH
99162
+ if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH
9913099163
&& pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
9913199164
){
9913299165
pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
9913399166
pInfo->estimatedCost = 2.0;
9913499167
iCons = i;
99168
+ break;
9913599169
}
9913699170
}
9913799171
9913899172
if( iCons>=0 ){
9913999173
pInfo->aConstraintUsage[iCons].argvIndex = 1;
@@ -99175,25 +99209,33 @@
9917599209
static int fulltextClose(sqlite3_vtab_cursor *pCursor){
9917699210
Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
9917799211
sqlite3_finalize(pCsr->pStmt);
9917899212
sqlite3Fts3ExprFree(pCsr->pExpr);
9917999213
sqlite3_free(pCsr->aDoclist);
99214
+ sqlite3_free(pCsr->aMatchinfo);
9918099215
sqlite3_free(pCsr);
9918199216
return SQLITE_OK;
9918299217
}
9918399218
99184
-static int fts3CursorSeek(Fts3Cursor *pCsr){
99219
+static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
9918599220
if( pCsr->isRequireSeek ){
9918699221
pCsr->isRequireSeek = 0;
9918799222
sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
9918899223
if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
9918999224
return SQLITE_OK;
9919099225
}else{
99191
- int rc;
99226
+ int rc = sqlite3_reset(pCsr->pStmt);
99227
+ if( rc==SQLITE_OK ){
99228
+ /* If no row was found and no error has occured, then the %_content
99229
+ ** table is missing a row that is present in the full-text index.
99230
+ ** The data structures are corrupt.
99231
+ */
99232
+ rc = SQLITE_CORRUPT;
99233
+ }
9919299234
pCsr->isEof = 1;
99193
- if( SQLITE_OK==(rc = sqlite3_reset(pCsr->pStmt)) ){
99194
- rc = SQLITE_ERROR;
99235
+ if( pContext ){
99236
+ sqlite3_result_error_code(pContext, rc);
9919599237
}
9919699238
return rc;
9919799239
}
9919899240
}else{
9919999241
return SQLITE_OK;
@@ -99213,10 +99255,11 @@
9921399255
pCsr->isEof = 1;
9921499256
}else{
9921599257
sqlite3_reset(pCsr->pStmt);
9921699258
fts3GetDeltaVarint(&pCsr->pNextId, &pCsr->iPrevId);
9921799259
pCsr->isRequireSeek = 1;
99260
+ pCsr->isMatchinfoOk = 1;
9921899261
}
9921999262
return rc;
9922099263
}
9922199264
9922299265
@@ -99328,15 +99371,31 @@
9932899371
assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );
9932999372
*pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);
9933099373
*piPrev = iVal;
9933199374
}
9933299375
99376
+/*
99377
+** When this function is called, *ppPoslist is assumed to point to the
99378
+** start of a position-list.
99379
+*/
9933399380
static void fts3PoslistCopy(char **pp, char **ppPoslist){
9933499381
char *pEnd = *ppPoslist;
9933599382
char c = 0;
99383
+
99384
+ /* The end of a position list is marked by a zero encoded as an FTS3
99385
+ ** varint. A single 0x00 byte. Except, if the 0x00 byte is preceded by
99386
+ ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail
99387
+ ** of some other, multi-byte, value.
99388
+ **
99389
+ ** The following block moves pEnd to point to the first byte that is not
99390
+ ** immediately preceded by a byte with the 0x80 bit set. Then increments
99391
+ ** pEnd once more so that it points to the byte immediately following the
99392
+ ** last byte in the position-list.
99393
+ */
9933699394
while( *pEnd | c ) c = *pEnd++ & 0x80;
9933799395
pEnd++;
99396
+
9933899397
if( pp ){
9933999398
int n = (int)(pEnd - *ppPoslist);
9934099399
char *p = *pp;
9934199400
memcpy(p, *ppPoslist, n);
9934299401
p += n;
@@ -99539,13 +99598,14 @@
9953999598
fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
9954099599
}else{
9954199600
if( (*p1&0xFE)==0 ) break;
9954299601
fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
9954399602
}
99603
+ }
9954499604
99545
- }
99546
- if( pSave && pp ){
99605
+ if( pSave ){
99606
+ assert( pp && p );
9954799607
p = pSave;
9954899608
}
9954999609
9955099610
fts3ColumnlistCopy(0, &p1);
9955199611
fts3ColumnlistCopy(0, &p2);
@@ -99680,15 +99740,12 @@
9968099740
|| mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
9968199741
|| mergetype==MERGE_NEAR || mergetype==MERGE_POS_NEAR
9968299742
);
9968399743
9968499744
if( !aBuffer ){
99685
- return SQLITE_NOMEM;
99686
- }
99687
- if( n1==0 && n2==0 ){
9968899745
*pnBuffer = 0;
99689
- return SQLITE_OK;
99746
+ return SQLITE_NOMEM;
9969099747
}
9969199748
9969299749
/* Read the first docid from each doclist */
9969399750
fts3GetDeltaVarint2(&p1, pEnd1, &i1);
9969499751
fts3GetDeltaVarint2(&p2, pEnd2, &i2);
@@ -99770,11 +99827,11 @@
9977099827
default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); {
9977199828
char *aTmp = 0;
9977299829
char **ppPos = 0;
9977399830
if( mergetype==MERGE_POS_NEAR ){
9977499831
ppPos = &p;
99775
- aTmp = sqlite3_malloc(2*(n1+n2));
99832
+ aTmp = sqlite3_malloc(2*(n1+n2+1));
9977699833
if( !aTmp ){
9977799834
return SQLITE_NOMEM;
9977899835
}
9977999836
}
9978099837
@@ -99890,16 +99947,24 @@
9989099947
char **ppOut /* OUT: Malloced result buffer */
9989199948
){
9989299949
int i;
9989399950
TermSelect tsc;
9989499951
Fts3SegFilter filter; /* Segment term filter configuration */
99895
- Fts3SegReader **apSegment = 0; /* Array of segments to read data from */
99952
+ Fts3SegReader **apSegment; /* Array of segments to read data from */
9989699953
int nSegment = 0; /* Size of apSegment array */
99897
- int nAlloc = 0; /* Allocated size of segment array */
99954
+ int nAlloc = 16; /* Allocated size of segment array */
9989899955
int rc; /* Return code */
99899
- sqlite3_stmt *pStmt; /* SQL statement to scan %_segdir table */
99956
+ sqlite3_stmt *pStmt = 0; /* SQL statement to scan %_segdir table */
9990099957
int iAge = 0; /* Used to assign ages to segments */
99958
+
99959
+ apSegment = (Fts3SegReader **)sqlite3_malloc(sizeof(Fts3SegReader*)*nAlloc);
99960
+ if( !apSegment ) return SQLITE_NOMEM;
99961
+ rc = sqlite3Fts3SegReaderPending(p, zTerm, nTerm, isPrefix, &apSegment[0]);
99962
+ if( rc!=SQLITE_OK ) goto finished;
99963
+ if( apSegment[0] ){
99964
+ nSegment = 1;
99965
+ }
9990199966
9990299967
/* Loop through the entire %_segdir table. For each segment, create a
9990399968
** Fts3SegReader to iterate through the subset of the segment leaves
9990499969
** that may contain a term that matches zTerm/nTerm. For non-prefix
9990599970
** searches, this is always a single leaf. For prefix searches, this
@@ -100013,12 +100078,10 @@
100013100078
int rc = SQLITE_OK;
100014100079
int ii;
100015100080
int iCol = pPhrase->iColumn;
100016100081
int isTermPos = (pPhrase->nToken>1 || isReqPos);
100017100082
100018
- assert( p->nPendingData==0 );
100019
-
100020100083
for(ii=0; ii<pPhrase->nToken; ii++){
100021100084
struct PhraseToken *pTok = &pPhrase->aToken[ii];
100022100085
char *z = pTok->z; /* Next token of the phrase */
100023100086
int n = pTok->n; /* Size of z in bytes */
100024100087
int isPrefix = pTok->isPrefix;/* True if token is a prefix */
@@ -100046,10 +100109,11 @@
100046100109
}
100047100110
fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
100048100111
sqlite3_free(pOut);
100049100112
pOut = pList;
100050100113
}
100114
+ assert( nOut==0 || pOut!=0 );
100051100115
}
100052100116
100053100117
if( rc==SQLITE_OK ){
100054100118
*paOut = pOut;
100055100119
*pnOut = nOut;
@@ -100065,39 +100129,46 @@
100065100129
*/
100066100130
static int evalFts3Expr(
100067100131
Fts3Table *p, /* Virtual table handle */
100068100132
Fts3Expr *pExpr, /* Parsed fts3 expression */
100069100133
char **paOut, /* OUT: Pointer to malloc'd result buffer */
100070
- int *pnOut /* OUT: Size of buffer at *paOut */
100134
+ int *pnOut, /* OUT: Size of buffer at *paOut */
100135
+ int isReqPos /* Require positions in output buffer */
100071100136
){
100072100137
int rc = SQLITE_OK; /* Return code */
100073100138
100074100139
/* Zero the output parameters. */
100075100140
*paOut = 0;
100076100141
*pnOut = 0;
100077100142
100078100143
if( pExpr ){
100144
+ assert( pExpr->eType==FTSQUERY_PHRASE
100145
+ || pExpr->eType==FTSQUERY_NEAR
100146
+ || isReqPos==0
100147
+ );
100079100148
if( pExpr->eType==FTSQUERY_PHRASE ){
100080
- int isReqPos = (pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR);
100081
- rc = fts3PhraseSelect(p, pExpr->pPhrase, isReqPos, paOut, pnOut);
100149
+ rc = fts3PhraseSelect(p, pExpr->pPhrase,
100150
+ isReqPos || (pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR),
100151
+ paOut, pnOut
100152
+ );
100082100153
}else{
100083100154
char *aLeft;
100084100155
char *aRight;
100085100156
int nLeft;
100086100157
int nRight;
100087100158
100088
- if( SQLITE_OK==(rc = evalFts3Expr(p, pExpr->pRight, &aRight, &nRight))
100089
- && SQLITE_OK==(rc = evalFts3Expr(p, pExpr->pLeft, &aLeft, &nLeft))
100159
+ if( 0==(rc = evalFts3Expr(p, pExpr->pRight, &aRight, &nRight, isReqPos))
100160
+ && 0==(rc = evalFts3Expr(p, pExpr->pLeft, &aLeft, &nLeft, isReqPos))
100090100161
){
100091100162
assert( pExpr->eType==FTSQUERY_NEAR || pExpr->eType==FTSQUERY_OR
100092100163
|| pExpr->eType==FTSQUERY_AND || pExpr->eType==FTSQUERY_NOT
100093100164
);
100094100165
switch( pExpr->eType ){
100095100166
case FTSQUERY_NEAR: {
100096100167
Fts3Expr *pLeft;
100097100168
Fts3Expr *pRight;
100098
- int mergetype = MERGE_NEAR;
100169
+ int mergetype = isReqPos ? MERGE_POS_NEAR : MERGE_NEAR;
100099100170
int nParam1;
100100100171
int nParam2;
100101100172
char *aBuffer;
100102100173
100103100174
if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
@@ -100203,10 +100274,11 @@
100203100274
assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );
100204100275
100205100276
/* In case the cursor has been used before, clear it now. */
100206100277
sqlite3_finalize(pCsr->pStmt);
100207100278
sqlite3_free(pCsr->aDoclist);
100279
+ sqlite3Fts3ExprFree(pCsr->pExpr);
100208100280
memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
100209100281
100210100282
/* Compile a SELECT statement for this cursor. For a full-table-scan, the
100211100283
** statement loops through all rows of the %_content table. For a
100212100284
** full-text query or docid lookup, the statement retrieves a single
@@ -100229,19 +100301,17 @@
100229100301
const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);
100230100302
100231100303
if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
100232100304
return SQLITE_NOMEM;
100233100305
}
100234
- rc = sqlite3Fts3PendingTermsFlush(p);
100235
- if( rc!=SQLITE_OK ) return rc;
100236100306
100237100307
rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
100238100308
iCol, zQuery, -1, &pCsr->pExpr
100239100309
);
100240100310
if( rc!=SQLITE_OK ) return rc;
100241100311
100242
- rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist);
100312
+ rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
100243100313
pCsr->pNextId = pCsr->aDoclist;
100244100314
pCsr->iPrevId = 0;
100245100315
}
100246100316
100247100317
if( rc!=SQLITE_OK ) return rc;
@@ -100286,25 +100356,26 @@
100286100356
Fts3Table *p = (Fts3Table *)pCursor->pVtab;
100287100357
100288100358
/* The column value supplied by SQLite must be in range. */
100289100359
assert( iCol>=0 && iCol<=p->nColumn+1 );
100290100360
100291
- rc = fts3CursorSeek(pCsr);
100292
- if( rc==SQLITE_OK ){
100293
- if( iCol==p->nColumn+1 ){
100294
- /* This call is a request for the "docid" column. Since "docid" is an
100295
- ** alias for "rowid", use the xRowid() method to obtain the value.
100296
- */
100297
- sqlite3_int64 iRowid;
100298
- rc = fts3RowidMethod(pCursor, &iRowid);
100299
- sqlite3_result_int64(pContext, iRowid);
100300
- }else if( iCol==p->nColumn ){
100301
- /* The extra column whose name is the same as the table.
100302
- ** Return a blob which is a pointer to the cursor.
100303
- */
100304
- sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
100305
- }else{
100361
+ if( iCol==p->nColumn+1 ){
100362
+ /* This call is a request for the "docid" column. Since "docid" is an
100363
+ ** alias for "rowid", use the xRowid() method to obtain the value.
100364
+ */
100365
+ sqlite3_int64 iRowid;
100366
+ rc = fts3RowidMethod(pCursor, &iRowid);
100367
+ sqlite3_result_int64(pContext, iRowid);
100368
+ }else if( iCol==p->nColumn ){
100369
+ /* The extra column whose name is the same as the table.
100370
+ ** Return a blob which is a pointer to the cursor.
100371
+ */
100372
+ sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
100373
+ rc = SQLITE_OK;
100374
+ }else{
100375
+ rc = fts3CursorSeek(0, pCsr);
100376
+ if( rc==SQLITE_OK ){
100306100377
sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1));
100307100378
}
100308100379
}
100309100380
return rc;
100310100381
}
@@ -100357,10 +100428,67 @@
100357100428
*/
100358100429
static int fts3RollbackMethod(sqlite3_vtab *pVtab){
100359100430
sqlite3Fts3PendingTermsClear((Fts3Table *)pVtab);
100360100431
return SQLITE_OK;
100361100432
}
100433
+
100434
+/*
100435
+** Load the doclist associated with expression pExpr to pExpr->aDoclist.
100436
+** The loaded doclist contains positions as well as the document ids.
100437
+** This is used by the matchinfo(), snippet() and offsets() auxillary
100438
+** functions.
100439
+*/
100440
+SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *pTab, Fts3Expr *pExpr){
100441
+ return evalFts3Expr(pTab, pExpr, &pExpr->aDoclist, &pExpr->nDoclist, 1);
100442
+}
100443
+
100444
+/*
100445
+** After ExprLoadDoclist() (see above) has been called, this function is
100446
+** used to iterate through the position lists that make up the doclist
100447
+** stored in pExpr->aDoclist.
100448
+*/
100449
+SQLITE_PRIVATE char *sqlite3Fts3FindPositions(
100450
+ Fts3Expr *pExpr, /* Access this expressions doclist */
100451
+ sqlite3_int64 iDocid, /* Docid associated with requested pos-list */
100452
+ int iCol /* Column of requested pos-list */
100453
+){
100454
+ assert( pExpr->isLoaded );
100455
+ if( pExpr->aDoclist ){
100456
+ char *pEnd = &pExpr->aDoclist[pExpr->nDoclist];
100457
+ char *pCsr = pExpr->pCurrent;
100458
+
100459
+ assert( pCsr );
100460
+ while( pCsr<pEnd ){
100461
+ if( pExpr->iCurrent<iDocid ){
100462
+ fts3PoslistCopy(0, &pCsr);
100463
+ fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
100464
+ pExpr->pCurrent = pCsr;
100465
+ }else{
100466
+ if( pExpr->iCurrent==iDocid ){
100467
+ int iThis = 0;
100468
+ if( iCol<0 ){
100469
+ /* If iCol is negative, return a pointer to the start of the
100470
+ ** position-list (instead of a pointer to the start of a list
100471
+ ** of offsets associated with a specific column).
100472
+ */
100473
+ return pCsr;
100474
+ }
100475
+ while( iThis<iCol ){
100476
+ fts3ColumnlistCopy(0, &pCsr);
100477
+ if( *pCsr==0x00 ) return 0;
100478
+ pCsr++;
100479
+ pCsr += sqlite3Fts3GetVarint32(pCsr, &iThis);
100480
+ }
100481
+ if( iCol==iThis ) return pCsr;
100482
+ }
100483
+ return 0;
100484
+ }
100485
+ }
100486
+ }
100487
+
100488
+ return 0;
100489
+}
100362100490
100363100491
/*
100364100492
** Helper function used by the implementation of the overloaded snippet(),
100365100493
** offsets() and optimize() SQL functions.
100366100494
**
@@ -100418,12 +100546,56 @@
100418100546
switch( nVal ){
100419100547
case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
100420100548
case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
100421100549
case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
100422100550
}
100551
+ if( !zEllipsis || !zEnd || !zStart ){
100552
+ sqlite3_result_error_nomem(pContext);
100553
+ }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100554
+ sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis);
100555
+ }
100556
+}
100423100557
100424
- sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis);
100558
+/*
100559
+** Implementation of the snippet2() function for FTS3
100560
+*/
100561
+static void fts3Snippet2Func(
100562
+ sqlite3_context *pContext, /* SQLite function call context */
100563
+ int nVal, /* Size of apVal[] array */
100564
+ sqlite3_value **apVal /* Array of arguments */
100565
+){
100566
+ Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
100567
+ const char *zStart = "<b>";
100568
+ const char *zEnd = "</b>";
100569
+ const char *zEllipsis = "<b>...</b>";
100570
+ int iCol = -1;
100571
+ int nToken = 10;
100572
+
100573
+ /* There must be at least one argument passed to this function (otherwise
100574
+ ** the non-overloaded version would have been called instead of this one).
100575
+ */
100576
+ assert( nVal>=1 );
100577
+
100578
+ if( nVal>6 ){
100579
+ sqlite3_result_error(pContext,
100580
+ "wrong number of arguments to function snippet()", -1);
100581
+ return;
100582
+ }
100583
+ if( fts3FunctionArg(pContext, "snippet", apVal[0], &pCsr) ) return;
100584
+
100585
+ switch( nVal ){
100586
+ case 6: nToken = sqlite3_value_int(apVal[5]);
100587
+ case 5: iCol = sqlite3_value_int(apVal[4]);
100588
+ case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
100589
+ case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
100590
+ case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
100591
+ }
100592
+ if( !zEllipsis || !zEnd || !zStart ){
100593
+ sqlite3_result_error_nomem(pContext);
100594
+ }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100595
+ sqlite3Fts3Snippet2(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
100596
+ }
100425100597
}
100426100598
100427100599
/*
100428100600
** Implementation of the offsets() function for FTS3
100429100601
*/
@@ -100437,11 +100609,13 @@
100437100609
UNUSED_PARAMETER(nVal);
100438100610
100439100611
assert( nVal==1 );
100440100612
if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return;
100441100613
assert( pCsr );
100442
- sqlite3Fts3Offsets(pContext, pCsr);
100614
+ if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100615
+ sqlite3Fts3Offsets(pContext, pCsr);
100616
+ }
100443100617
}
100444100618
100445100619
/*
100446100620
** Implementation of the special optimize() function for FTS3. This
100447100621
** function merges all segments in the database to a single segment.
@@ -100479,10 +100653,31 @@
100479100653
default:
100480100654
sqlite3_result_error_code(pContext, rc);
100481100655
break;
100482100656
}
100483100657
}
100658
+
100659
+/*
100660
+** Implementation of the matchinfo() function for FTS3
100661
+*/
100662
+static void fts3MatchinfoFunc(
100663
+ sqlite3_context *pContext, /* SQLite function call context */
100664
+ int nVal, /* Size of argument array */
100665
+ sqlite3_value **apVal /* Array of arguments */
100666
+){
100667
+ Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
100668
+
100669
+ if( nVal!=1 ){
100670
+ sqlite3_result_error(pContext,
100671
+ "wrong number of arguments to function matchinfo()", -1);
100672
+ return;
100673
+ }
100674
+
100675
+ if( SQLITE_OK==fts3FunctionArg(pContext, "matchinfo", apVal[0], &pCsr) ){
100676
+ sqlite3Fts3Matchinfo(pContext, pCsr);
100677
+ }
100678
+}
100484100679
100485100680
/*
100486100681
** This routine implements the xFindFunction method for the FTS3
100487100682
** virtual table.
100488100683
*/
@@ -100496,12 +100691,14 @@
100496100691
struct Overloaded {
100497100692
const char *zName;
100498100693
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
100499100694
} aOverload[] = {
100500100695
{ "snippet", fts3SnippetFunc },
100696
+ { "snippet2", fts3Snippet2Func },
100501100697
{ "offsets", fts3OffsetsFunc },
100502100698
{ "optimize", fts3OptimizeFunc },
100699
+ { "matchinfo", fts3MatchinfoFunc },
100503100700
};
100504100701
int i; /* Iterator variable */
100505100702
100506100703
UNUSED_PARAMETER(pVtab);
100507100704
UNUSED_PARAMETER(nArg);
@@ -100602,17 +100799,18 @@
100602100799
SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
100603100800
int rc = SQLITE_OK;
100604100801
Fts3Hash *pHash = 0;
100605100802
const sqlite3_tokenizer_module *pSimple = 0;
100606100803
const sqlite3_tokenizer_module *pPorter = 0;
100804
+
100805
+#ifdef SQLITE_ENABLE_ICU
100607100806
const sqlite3_tokenizer_module *pIcu = 0;
100807
+ sqlite3Fts3IcuTokenizerModule(&pIcu);
100808
+#endif
100608100809
100609100810
sqlite3Fts3SimpleTokenizerModule(&pSimple);
100610100811
sqlite3Fts3PorterTokenizerModule(&pPorter);
100611
-#ifdef SQLITE_ENABLE_ICU
100612
- sqlite3Fts3IcuTokenizerModule(&pIcu);
100613
-#endif
100614100812
100615100813
/* Allocate and initialise the hash-table used to store tokenizers. */
100616100814
pHash = sqlite3_malloc(sizeof(Fts3Hash));
100617100815
if( !pHash ){
100618100816
rc = SQLITE_NOMEM;
@@ -100622,28 +100820,34 @@
100622100820
100623100821
/* Load the built-in tokenizers into the hash table */
100624100822
if( rc==SQLITE_OK ){
100625100823
if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
100626100824
|| sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
100825
+#ifdef SQLITE_ENABLE_ICU
100627100826
|| (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
100827
+#endif
100628100828
){
100629100829
rc = SQLITE_NOMEM;
100630100830
}
100631100831
}
100632100832
100633100833
#ifdef SQLITE_TEST
100634
- sqlite3Fts3ExprInitTestInterface(db);
100834
+ if( rc==SQLITE_OK ){
100835
+ rc = sqlite3Fts3ExprInitTestInterface(db);
100836
+ }
100635100837
#endif
100636100838
100637100839
/* Create the virtual table wrapper around the hash-table and overload
100638100840
** the two scalar functions. If this is successful, register the
100639100841
** module with sqlite.
100640100842
*/
100641100843
if( SQLITE_OK==rc
100642100844
&& SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
100643100845
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
100846
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet2", -1))
100644100847
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
100848
+ && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", -1))
100645100849
&& SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
100646100850
){
100647100851
return sqlite3_create_module_v2(
100648100852
db, "fts3", &fts3Module, (void *)pHash, hashDestroy
100649100853
);
@@ -100850,11 +101054,11 @@
100850101054
100851101055
/*
100852101056
** Enlarge a memory allocation. If an out-of-memory allocation occurs,
100853101057
** then free the old allocation.
100854101058
*/
100855
-void *fts3ReallocOrFree(void *pOrig, int nNew){
101059
+static void *fts3ReallocOrFree(void *pOrig, int nNew){
100856101060
void *pRet = sqlite3_realloc(pOrig, nNew);
100857101061
if( !pRet ){
100858101062
sqlite3_free(pOrig);
100859101063
}
100860101064
return pRet;
@@ -101404,10 +101608,11 @@
101404101608
*/
101405101609
SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *p){
101406101610
if( p ){
101407101611
sqlite3Fts3ExprFree(p->pLeft);
101408101612
sqlite3Fts3ExprFree(p->pRight);
101613
+ sqlite3_free(p->aDoclist);
101409101614
sqlite3_free(p);
101410101615
}
101411101616
}
101412101617
101413101618
/****************************************************************************
@@ -101581,12 +101786,12 @@
101581101786
101582101787
/*
101583101788
** Register the query expression parser test function fts3_exprtest()
101584101789
** with database connection db.
101585101790
*/
101586
-SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3* db){
101587
- sqlite3_create_function(
101791
+SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){
101792
+ return sqlite3_create_function(
101588101793
db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
101589101794
);
101590101795
}
101591101796
101592101797
#endif
@@ -101868,26 +102073,36 @@
101868102073
assert( pH->count==0 );
101869102074
fts3HashClear(pH);
101870102075
}
101871102076
}
101872102077
101873
-/* Attempt to locate an element of the hash table pH with a key
101874
-** that matches pKey,nKey. Return the data for this element if it is
101875
-** found, or NULL if there is no match.
101876
-*/
101877
-SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){
101878
- int h; /* A hash on key */
101879
- Fts3HashElem *elem; /* The element that matches key */
102078
+SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(
102079
+ const Fts3Hash *pH,
102080
+ const void *pKey,
102081
+ int nKey
102082
+){
102083
+ int h; /* A hash on key */
101880102084
int (*xHash)(const void*,int); /* The hash function */
101881102085
101882102086
if( pH==0 || pH->ht==0 ) return 0;
101883102087
xHash = ftsHashFunction(pH->keyClass);
101884102088
assert( xHash!=0 );
101885102089
h = (*xHash)(pKey,nKey);
101886102090
assert( (pH->htsize & (pH->htsize-1))==0 );
101887
- elem = fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
101888
- return elem ? elem->data : 0;
102091
+ return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
102092
+}
102093
+
102094
+/*
102095
+** Attempt to locate an element of the hash table pH with a key
102096
+** that matches pKey,nKey. Return the data for this element if it is
102097
+** found, or NULL if there is no match.
102098
+*/
102099
+SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){
102100
+ Fts3HashElem *pElem; /* The element that matches key (if any) */
102101
+
102102
+ pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);
102103
+ return pElem ? pElem->data : 0;
101889102104
}
101890102105
101891102106
/* Insert an element into the hash table pH. The key is pKey,nKey
101892102107
** and the data is "data".
101893102108
**
@@ -102720,18 +102935,18 @@
102720102935
const char *z2 = 0;
102721102936
102722102937
/* Find the start of the next token. */
102723102938
z1 = zStr;
102724102939
while( z2==0 ){
102725
- switch( *z1 ){
102940
+ char c = *z1;
102941
+ switch( c ){
102726102942
case '\0': return 0; /* No more tokens here */
102727102943
case '\'':
102728102944
case '"':
102729102945
case '`': {
102730
- z2 = &z1[1];
102731
- while( *z2 && (z2[0]!=*z1 || z2[1]==*z1) ) z2++;
102732
- if( *z2 ) z2++;
102946
+ z2 = z1;
102947
+ while( *++z2 && (*z2!=c || *++z2==c) );
102733102948
break;
102734102949
}
102735102950
case '[':
102736102951
z2 = &z1[1];
102737102952
while( *z2 && z2[0]!=']' ) z2++;
@@ -103065,14 +103280,14 @@
103065103280
const char *zName
103066103281
){
103067103282
int rc = SQLITE_OK;
103068103283
void *p = (void *)pHash;
103069103284
const int any = SQLITE_ANY;
103285
+
103286
+#ifdef SQLITE_TEST
103070103287
char *zTest = 0;
103071103288
char *zTest2 = 0;
103072
-
103073
-#ifdef SQLITE_TEST
103074103289
void *pdb = (void *)db;
103075103290
zTest = sqlite3_mprintf("%s_test", zName);
103076103291
zTest2 = sqlite3_mprintf("%s_internal_test", zName);
103077103292
if( !zTest || !zTest2 ){
103078103293
rc = SQLITE_NOMEM;
@@ -103085,14 +103300,17 @@
103085103300
#ifdef SQLITE_TEST
103086103301
|| SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))
103087103302
|| SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))
103088103303
|| SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))
103089103304
#endif
103090
- );
103305
+ );
103091103306
103307
+#ifdef SQLITE_TEST
103092103308
sqlite3_free(zTest);
103093103309
sqlite3_free(zTest2);
103310
+#endif
103311
+
103094103312
return rc;
103095103313
}
103096103314
103097103315
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
103098103316
@@ -103350,11 +103568,11 @@
103350103568
typedef struct SegmentNode SegmentNode;
103351103569
typedef struct SegmentWriter SegmentWriter;
103352103570
103353103571
/*
103354103572
** Data structure used while accumulating terms in the pending-terms hash
103355
-** table. The hash table entry maps from term (a string) to a malloced
103573
+** table. The hash table entry maps from term (a string) to a malloc'd
103356103574
** instance of this structure.
103357103575
*/
103358103576
struct PendingList {
103359103577
int nData;
103360103578
char *aData;
@@ -103372,19 +103590,26 @@
103372103590
** terms when querying the full-text index. See functions:
103373103591
**
103374103592
** sqlite3Fts3SegReaderNew()
103375103593
** sqlite3Fts3SegReaderFree()
103376103594
** sqlite3Fts3SegReaderIterate()
103595
+**
103596
+** Methods used to manipulate Fts3SegReader structures:
103597
+**
103598
+** fts3SegReaderNext()
103599
+** fts3SegReaderFirstDocid()
103600
+** fts3SegReaderNextDocid()
103377103601
*/
103378103602
struct Fts3SegReader {
103379
- int iIdx; /* Index within level */
103603
+ int iIdx; /* Index within level, or 0x7FFFFFFF for PT */
103380103604
sqlite3_int64 iStartBlock;
103381103605
sqlite3_int64 iEndBlock;
103382103606
sqlite3_stmt *pStmt; /* SQL Statement to access leaf nodes */
103383103607
char *aNode; /* Pointer to node data (or NULL) */
103384103608
int nNode; /* Size of buffer at aNode (or 0) */
103385103609
int nTermAlloc; /* Allocated size of zTerm buffer */
103610
+ Fts3HashElem **ppNextElem;
103386103611
103387103612
/* Variables set by fts3SegReaderNext(). These may be read directly
103388103613
** by the caller. They are valid from the time SegmentReaderNew() returns
103389103614
** until SegmentReaderNext() returns something other than SQLITE_OK
103390103615
** (i.e. SQLITE_DONE).
@@ -103396,10 +103621,12 @@
103396103621
103397103622
/* The following variables are used to iterate through the current doclist */
103398103623
char *pOffsetList;
103399103624
sqlite3_int64 iDocid;
103400103625
};
103626
+
103627
+#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)
103401103628
103402103629
/*
103403103630
** An instance of this structure is used to create a segment b-tree in the
103404103631
** database. The internal details of this type are only accessed by the
103405103632
** following functions:
@@ -103600,17 +103827,17 @@
103600103827
103601103828
if( pzBlock ){
103602103829
sqlite3_bind_int64(pStmt, 1, iBlock);
103603103830
rc = sqlite3_step(pStmt);
103604103831
if( rc!=SQLITE_ROW ){
103605
- return SQLITE_CORRUPT;
103832
+ return (rc==SQLITE_DONE ? SQLITE_CORRUPT : rc);
103606103833
}
103607103834
103608103835
*pnBlock = sqlite3_column_bytes(pStmt, 0);
103609103836
*pzBlock = (char *)sqlite3_column_blob(pStmt, 0);
103610
- if( !*pzBlock ){
103611
- return SQLITE_NOMEM;
103837
+ if( sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
103838
+ return SQLITE_CORRUPT;
103612103839
}
103613103840
}
103614103841
return SQLITE_OK;
103615103842
}
103616103843
@@ -103821,11 +104048,11 @@
103821104048
** forced-flush would provide better performance. I suspect that if
103822104049
** we ordered the doclists by size and flushed the largest until the
103823104050
** buffer was half empty, that would let the less frequent terms
103824104051
** generate longer doclists.
103825104052
*/
103826
- if( iDocid<=p->iPrevDocid || p->nPendingData>FTS3_MAX_PENDING_DATA ){
104053
+ if( iDocid<=p->iPrevDocid || p->nPendingData>p->nMaxPendingData ){
103827104054
int rc = sqlite3Fts3PendingTermsFlush(p);
103828104055
if( rc!=SQLITE_OK ) return rc;
103829104056
}
103830104057
p->iPrevDocid = iDocid;
103831104058
return SQLITE_OK;
@@ -104048,10 +104275,25 @@
104048104275
pNext = &pReader->aDoclist[pReader->nDoclist];
104049104276
}
104050104277
104051104278
if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){
104052104279
int rc;
104280
+ if( fts3SegReaderIsPending(pReader) ){
104281
+ Fts3HashElem *pElem = *(pReader->ppNextElem);
104282
+ if( pElem==0 ){
104283
+ pReader->aNode = 0;
104284
+ }else{
104285
+ PendingList *pList = (PendingList *)fts3HashData(pElem);
104286
+ pReader->zTerm = (char *)fts3HashKey(pElem);
104287
+ pReader->nTerm = fts3HashKeysize(pElem);
104288
+ pReader->nNode = pReader->nDoclist = pList->nData + 1;
104289
+ pReader->aNode = pReader->aDoclist = pList->aData;
104290
+ pReader->ppNextElem++;
104291
+ assert( pReader->aNode );
104292
+ }
104293
+ return SQLITE_OK;
104294
+ }
104053104295
if( !pReader->pStmt ){
104054104296
pReader->aNode = 0;
104055104297
return SQLITE_OK;
104056104298
}
104057104299
rc = sqlite3_step(pReader->pStmt);
@@ -104157,11 +104399,13 @@
104157104399
*/
104158104400
assert( p->nLeavesStmt<p->nLeavesTotal );
104159104401
sqlite3_reset(pReader->pStmt);
104160104402
p->aLeavesStmt[p->nLeavesStmt++] = pReader->pStmt;
104161104403
}
104162
- sqlite3_free(pReader->zTerm);
104404
+ if( !fts3SegReaderIsPending(pReader) ){
104405
+ sqlite3_free(pReader->zTerm);
104406
+ }
104163104407
sqlite3_free(pReader);
104164104408
}
104165104409
}
104166104410
104167104411
/*
@@ -104254,10 +104498,107 @@
104254104498
sqlite3Fts3SegReaderFree(p, pReader);
104255104499
}
104256104500
return rc;
104257104501
}
104258104502
104503
+/*
104504
+** This is a comparison function used as a qsort() callback when sorting
104505
+** an array of pending terms by term. This occurs as part of flushing
104506
+** the contents of the pending-terms hash table to the database.
104507
+*/
104508
+static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
104509
+ char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
104510
+ char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
104511
+ int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
104512
+ int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
104513
+
104514
+ int n = (n1<n2 ? n1 : n2);
104515
+ int c = memcmp(z1, z2, n);
104516
+ if( c==0 ){
104517
+ c = n1 - n2;
104518
+ }
104519
+ return c;
104520
+}
104521
+
104522
+/*
104523
+** This function is used to allocate an Fts3SegReader that iterates through
104524
+** a subset of the terms stored in the Fts3Table.pendingTerms array.
104525
+*/
104526
+SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(
104527
+ Fts3Table *p, /* Virtual table handle */
104528
+ const char *zTerm, /* Term to search for */
104529
+ int nTerm, /* Size of buffer zTerm */
104530
+ int isPrefix, /* True for a term-prefix query */
104531
+ Fts3SegReader **ppReader /* OUT: SegReader for pending-terms */
104532
+){
104533
+ Fts3SegReader *pReader = 0; /* Fts3SegReader object to return */
104534
+ Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */
104535
+ int nElem = 0; /* Size of array at aElem */
104536
+ int rc = SQLITE_OK; /* Return Code */
104537
+
104538
+ if( isPrefix ){
104539
+ int nAlloc = 0; /* Size of allocated array at aElem */
104540
+ Fts3HashElem *pE = 0; /* Iterator variable */
104541
+
104542
+ for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){
104543
+ char *zKey = (char *)fts3HashKey(pE);
104544
+ int nKey = fts3HashKeysize(pE);
104545
+ if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){
104546
+ if( nElem==nAlloc ){
104547
+ Fts3HashElem **aElem2;
104548
+ nAlloc += 16;
104549
+ aElem2 = (Fts3HashElem **)sqlite3_realloc(
104550
+ aElem, nAlloc*sizeof(Fts3HashElem *)
104551
+ );
104552
+ if( !aElem2 ){
104553
+ rc = SQLITE_NOMEM;
104554
+ nElem = 0;
104555
+ break;
104556
+ }
104557
+ aElem = aElem2;
104558
+ }
104559
+ aElem[nElem++] = pE;
104560
+ }
104561
+ }
104562
+
104563
+ /* If more than one term matches the prefix, sort the Fts3HashElem
104564
+ ** objects in term order using qsort(). This uses the same comparison
104565
+ ** callback as is used when flushing terms to disk.
104566
+ */
104567
+ if( nElem>1 ){
104568
+ qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);
104569
+ }
104570
+
104571
+ }else{
104572
+ Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm);
104573
+ if( pE ){
104574
+ aElem = &pE;
104575
+ nElem = 1;
104576
+ }
104577
+ }
104578
+
104579
+ if( nElem>0 ){
104580
+ int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);
104581
+ pReader = (Fts3SegReader *)sqlite3_malloc(nByte);
104582
+ if( !pReader ){
104583
+ rc = SQLITE_NOMEM;
104584
+ }else{
104585
+ memset(pReader, 0, nByte);
104586
+ pReader->iIdx = 0x7FFFFFFF;
104587
+ pReader->ppNextElem = (Fts3HashElem **)&pReader[1];
104588
+ memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));
104589
+ fts3SegReaderNext(pReader);
104590
+ }
104591
+ }
104592
+
104593
+ if( isPrefix ){
104594
+ sqlite3_free(aElem);
104595
+ }
104596
+ *ppReader = pReader;
104597
+ return rc;
104598
+}
104599
+
104259104600
104260104601
/*
104261104602
** The second argument to this function is expected to be a statement of
104262104603
** the form:
104263104604
**
@@ -104297,11 +104638,11 @@
104297104638
** Compare the entries pointed to by two Fts3SegReader structures.
104298104639
** Comparison is as follows:
104299104640
**
104300104641
** 1) EOF is greater than not EOF.
104301104642
**
104302
-** 2) The current terms (if any) are compared with memcmp(). If one
104643
+** 2) The current terms (if any) are compared using memcmp(). If one
104303104644
** term is a prefix of another, the longer term is considered the
104304104645
** larger.
104305104646
**
104306104647
** 3) By segment age. An older segment is considered larger.
104307104648
*/
@@ -104425,15 +104766,13 @@
104425104766
){
104426104767
sqlite3_stmt *pStmt;
104427104768
int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
104428104769
if( rc==SQLITE_OK ){
104429104770
sqlite3_bind_int64(pStmt, 1, iBlock);
104430
- rc = sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
104431
- if( rc==SQLITE_OK ){
104432
- sqlite3_step(pStmt);
104433
- rc = sqlite3_reset(pStmt);
104434
- }
104771
+ sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
104772
+ sqlite3_step(pStmt);
104773
+ rc = sqlite3_reset(pStmt);
104435104774
}
104436104775
return rc;
104437104776
}
104438104777
104439104778
/*
@@ -104455,15 +104794,13 @@
104455104794
sqlite3_bind_int(pStmt, 1, iLevel);
104456104795
sqlite3_bind_int(pStmt, 2, iIdx);
104457104796
sqlite3_bind_int64(pStmt, 3, iStartBlock);
104458104797
sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
104459104798
sqlite3_bind_int64(pStmt, 5, iEndBlock);
104460
- rc = sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
104461
- if( rc==SQLITE_OK ){
104462
- sqlite3_step(pStmt);
104463
- rc = sqlite3_reset(pStmt);
104464
- }
104799
+ sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
104800
+ sqlite3_step(pStmt);
104801
+ rc = sqlite3_reset(pStmt);
104465104802
}
104466104803
return rc;
104467104804
}
104468104805
104469104806
/*
@@ -105038,20 +105375,36 @@
105038105375
/*
105039105376
** sqlite3Fts3SegReaderIterate() callback used when merging multiple
105040105377
** segments to create a single, larger segment.
105041105378
*/
105042105379
static int fts3MergeCallback(
105043
- Fts3Table *p,
105044
- void *pContext,
105045
- char *zTerm,
105046
- int nTerm,
105047
- char *aDoclist,
105048
- int nDoclist
105380
+ Fts3Table *p, /* FTS3 Virtual table handle */
105381
+ void *pContext, /* Pointer to SegmentWriter* to write with */
105382
+ char *zTerm, /* Term to write to the db */
105383
+ int nTerm, /* Number of bytes in zTerm */
105384
+ char *aDoclist, /* Doclist associated with zTerm */
105385
+ int nDoclist /* Number of bytes in doclist */
105049105386
){
105050105387
SegmentWriter **ppW = (SegmentWriter **)pContext;
105051105388
return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
105052105389
}
105390
+
105391
+/*
105392
+** sqlite3Fts3SegReaderIterate() callback used when flushing the contents
105393
+** of the pending-terms hash table to the database.
105394
+*/
105395
+static int fts3FlushCallback(
105396
+ Fts3Table *p, /* FTS3 Virtual table handle */
105397
+ void *pContext, /* Pointer to SegmentWriter* to write with */
105398
+ char *zTerm, /* Term to write to the db */
105399
+ int nTerm, /* Number of bytes in zTerm */
105400
+ char *aDoclist, /* Doclist associated with zTerm */
105401
+ int nDoclist /* Number of bytes in doclist */
105402
+){
105403
+ SegmentWriter **ppW = (SegmentWriter **)pContext;
105404
+ return fts3SegWriterAdd(p, ppW, 0, zTerm, nTerm, aDoclist, nDoclist);
105405
+}
105053105406
105054105407
/*
105055105408
** This function is used to iterate through a contiguous set of terms
105056105409
** stored in the full-text index. It merges data contained in one or
105057105410
** more segments to support this.
@@ -105110,12 +105463,11 @@
105110105463
const char *zTerm = pFilter->zTerm;
105111105464
for(i=0; i<nSegment; i++){
105112105465
Fts3SegReader *pSeg = apSegment[i];
105113105466
while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ){
105114105467
rc = fts3SegReaderNext(pSeg);
105115
- if( rc!=SQLITE_OK ) goto finished;
105116
- }
105468
+ if( rc!=SQLITE_OK ) goto finished; }
105117105469
}
105118105470
}
105119105471
105120105472
fts3SegReaderSort(apSegment, nSegment, nSegment, fts3SegReaderCmp);
105121105473
while( apSegment[0]->aNode ){
@@ -105145,11 +105497,12 @@
105145105497
&& 0==memcmp(zTerm, apSegment[nMerge]->zTerm, nTerm)
105146105498
){
105147105499
nMerge++;
105148105500
}
105149105501
105150
- if( nMerge==1 && !isIgnoreEmpty && !isColFilter && isRequirePos ){
105502
+ assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
105503
+ if( nMerge==1 && !isIgnoreEmpty ){
105151105504
Fts3SegReader *p0 = apSegment[0];
105152105505
rc = xFunc(p, pContext, zTerm, nTerm, p0->aDoclist, p0->nDoclist);
105153105506
if( rc!=SQLITE_OK ) goto finished;
105154105507
}else{
105155105508
int nDoclist = 0; /* Size of doclist */
@@ -105169,13 +105522,13 @@
105169105522
int nList;
105170105523
int nByte;
105171105524
sqlite3_int64 iDocid = apSegment[0]->iDocid;
105172105525
fts3SegReaderNextDocid(apSegment[0], &pList, &nList);
105173105526
j = 1;
105174
- while( j<nMerge
105175
- && apSegment[j]->pOffsetList
105176
- && apSegment[j]->iDocid==iDocid
105527
+ while( j<nMerge
105528
+ && apSegment[j]->pOffsetList
105529
+ && apSegment[j]->iDocid==iDocid
105177105530
){
105178105531
fts3SegReaderNextDocid(apSegment[j], 0, 0);
105179105532
j++;
105180105533
}
105181105534
@@ -105247,25 +105600,30 @@
105247105600
static int fts3SegmentMerge(Fts3Table *p, int iLevel){
105248105601
int i; /* Iterator variable */
105249105602
int rc; /* Return code */
105250105603
int iIdx; /* Index of new segment */
105251105604
int iNewLevel; /* Level to create new segment at */
105252
- sqlite3_stmt *pStmt;
105605
+ sqlite3_stmt *pStmt = 0;
105253105606
SegmentWriter *pWriter = 0;
105254105607
int nSegment = 0; /* Number of segments being merged */
105255105608
Fts3SegReader **apSegment = 0; /* Array of Segment iterators */
105609
+ Fts3SegReader *pPending = 0; /* Iterator for pending-terms */
105256105610
Fts3SegFilter filter; /* Segment term filter condition */
105257105611
105258105612
if( iLevel<0 ){
105259105613
/* This call is to merge all segments in the database to a single
105260105614
** segment. The level of the new segment is equal to the the numerically
105261105615
** greatest segment level currently present in the database. The index
105262105616
** of the new segment is always 0.
105263105617
*/
105264105618
iIdx = 0;
105619
+ rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pPending);
105620
+ if( rc!=SQLITE_OK ) goto finished;
105265105621
rc = fts3SegmentCountMax(p, &nSegment, &iNewLevel);
105266
- if( nSegment==1 ){
105622
+ if( rc!=SQLITE_OK ) goto finished;
105623
+ nSegment += (pPending!=0);
105624
+ if( nSegment<=1 ){
105267105625
return SQLITE_DONE;
105268105626
}
105269105627
}else{
105270105628
/* This call is to merge all segments at level iLevel. Find the next
105271105629
** available segment index at level iLevel+1. The call to
@@ -105272,21 +105630,22 @@
105272105630
** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to
105273105631
** a single iLevel+2 segment if necessary.
105274105632
*/
105275105633
iNewLevel = iLevel+1;
105276105634
rc = fts3AllocateSegdirIdx(p, iNewLevel, &iIdx);
105277
- if( rc!=SQLITE_OK ) return rc;
105635
+ if( rc!=SQLITE_OK ) goto finished;
105278105636
rc = fts3SegmentCount(p, iLevel, &nSegment);
105637
+ if( rc!=SQLITE_OK ) goto finished;
105279105638
}
105280
- if( rc!=SQLITE_OK ) return rc;
105281105639
assert( nSegment>0 );
105282105640
assert( iNewLevel>=0 );
105283105641
105284105642
/* Allocate space for an array of pointers to segment iterators. */
105285105643
apSegment = (Fts3SegReader**)sqlite3_malloc(sizeof(Fts3SegReader *)*nSegment);
105286105644
if( !apSegment ){
105287
- return SQLITE_NOMEM;
105645
+ rc = SQLITE_NOMEM;
105646
+ goto finished;
105288105647
}
105289105648
memset(apSegment, 0, sizeof(Fts3SegReader *)*nSegment);
105290105649
105291105650
/* Allocate a Fts3SegReader structure for each segment being merged. A
105292105651
** Fts3SegReader stores the state data required to iterate through all
@@ -105301,10 +105660,14 @@
105301105660
if( rc!=SQLITE_OK ){
105302105661
goto finished;
105303105662
}
105304105663
}
105305105664
rc = sqlite3_reset(pStmt);
105665
+ if( pPending ){
105666
+ apSegment[i] = pPending;
105667
+ pPending = 0;
105668
+ }
105306105669
pStmt = 0;
105307105670
if( rc!=SQLITE_OK ) goto finished;
105308105671
105309105672
memset(&filter, 0, sizeof(Fts3SegFilter));
105310105673
filter.flags = FTS3_SEGMENT_REQUIRE_POS;
@@ -105325,94 +105688,105 @@
105325105688
for(i=0; i<nSegment; i++){
105326105689
sqlite3Fts3SegReaderFree(p, apSegment[i]);
105327105690
}
105328105691
sqlite3_free(apSegment);
105329105692
}
105693
+ sqlite3Fts3SegReaderFree(p, pPending);
105330105694
sqlite3_reset(pStmt);
105331105695
return rc;
105332105696
}
105333105697
105334
-/*
105335
-** This is a comparison function used as a qsort() callback when sorting
105336
-** an array of pending terms by term. This occurs as part of flushing
105337
-** the contents of the pending-terms hash table to the database.
105338
-*/
105339
-static int qsortCompare(const void *lhs, const void *rhs){
105340
- char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
105341
- char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
105342
- int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
105343
- int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
105344
-
105345
- int n = (n1<n2 ? n1 : n2);
105346
- int c = memcmp(z1, z2, n);
105347
- if( c==0 ){
105348
- c = n1 - n2;
105349
- }
105350
- return c;
105351
-}
105352
-
105353105698
105354105699
/*
105355105700
** Flush the contents of pendingTerms to a level 0 segment.
105356105701
*/
105357105702
SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
105358
- Fts3HashElem *pElem;
105359
- int idx, rc, i;
105360
- Fts3HashElem **apElem; /* Array of pointers to hash elements */
105361
- int nElem; /* Number of terms in new segment */
105703
+ int rc; /* Return Code */
105704
+ int idx; /* Index of new segment created */
105362105705
SegmentWriter *pWriter = 0; /* Used to write the segment */
105706
+ Fts3SegReader *pReader = 0; /* Used to iterate through the hash table */
105363105707
105364
- /* Find the number of terms that will make up the new segment. If there
105365
- ** are no terms, return early (do not bother to write an empty segment).
105708
+ /* Allocate a SegReader object to iterate through the contents of the
105709
+ ** pending-terms table. If an error occurs, or if there are no terms
105710
+ ** in the pending-terms table, return immediately.
105366105711
*/
105367
- nElem = fts3HashCount(&p->pendingTerms);
105368
- if( nElem==0 ){
105369
- assert( p->nPendingData==0 );
105370
- return SQLITE_OK;
105712
+ rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pReader);
105713
+ if( rc!=SQLITE_OK || pReader==0 ){
105714
+ return rc;
105371105715
}
105372105716
105373
- /* Determine the next index at level 0, merging as necessary. */
105717
+ /* Determine the next index at level 0. If level 0 is already full, this
105718
+ ** call may merge all existing level 0 segments into a single level 1
105719
+ ** segment.
105720
+ */
105374105721
rc = fts3AllocateSegdirIdx(p, 0, &idx);
105375
- if( rc!=SQLITE_OK ){
105376
- return rc;
105377
- }
105378
-
105379
- apElem = sqlite3_malloc(nElem*sizeof(Fts3HashElem *));
105380
- if( !apElem ){
105381
- return SQLITE_NOMEM;
105382
- }
105383
-
105384
- i = 0;
105385
- for(pElem=fts3HashFirst(&p->pendingTerms); pElem; pElem=fts3HashNext(pElem)){
105386
- apElem[i++] = pElem;
105387
- }
105388
- assert( i==nElem );
105389
-
105390
- /* TODO(shess) Should we allow user-defined collation sequences,
105391
- ** here? I think we only need that once we support prefix searches.
105392
- ** Also, should we be using qsort()?
105722
+
105723
+ /* If no errors have occured, iterate through the contents of the
105724
+ ** pending-terms hash table using the Fts3SegReader iterator. The callback
105725
+ ** writes each term (along with its doclist) to the database via the
105726
+ ** SegmentWriter handle pWriter.
105393105727
*/
105394
- if( nElem>1 ){
105395
- qsort(apElem, nElem, sizeof(Fts3HashElem *), qsortCompare);
105396
- }
105397
-
105398
-
105399
- /* Write the segment tree into the database. */
105400
- for(i=0; rc==SQLITE_OK && i<nElem; i++){
105401
- const char *z = fts3HashKey(apElem[i]);
105402
- int n = fts3HashKeysize(apElem[i]);
105403
- PendingList *pList = fts3HashData(apElem[i]);
105404
- rc = fts3SegWriterAdd(p, &pWriter, 0, z, n, pList->aData, pList->nData+1);
105405
- }
105728
+ if( rc==SQLITE_OK ){
105729
+ void *c = (void *)&pWriter; /* SegReaderIterate() callback context */
105730
+ Fts3SegFilter f; /* SegReaderIterate() parameters */
105731
+
105732
+ memset(&f, 0, sizeof(Fts3SegFilter));
105733
+ f.flags = FTS3_SEGMENT_REQUIRE_POS;
105734
+ rc = sqlite3Fts3SegReaderIterate(p, &pReader, 1, &f, fts3FlushCallback, c);
105735
+ }
105736
+ assert( pWriter || rc!=SQLITE_OK );
105737
+
105738
+ /* If no errors have occured, flush the SegmentWriter object to the
105739
+ ** database. Then delete the SegmentWriter and Fts3SegReader objects
105740
+ ** allocated by this function.
105741
+ */
105406105742
if( rc==SQLITE_OK ){
105407105743
rc = fts3SegWriterFlush(p, pWriter, 0, idx);
105408105744
}
105409
-
105410
- /* Free all allocated resources before returning */
105411105745
fts3SegWriterFree(pWriter);
105412
- sqlite3_free(apElem);
105413
- sqlite3Fts3PendingTermsClear(p);
105746
+ sqlite3Fts3SegReaderFree(p, pReader);
105747
+
105748
+ if( rc==SQLITE_OK ){
105749
+ sqlite3Fts3PendingTermsClear(p);
105750
+ }
105751
+ return rc;
105752
+}
105753
+
105754
+/*
105755
+** Handle a 'special' INSERT of the form:
105756
+**
105757
+** "INSERT INTO tbl(tbl) VALUES(<expr>)"
105758
+**
105759
+** Argument pVal contains the result of <expr>. Currently the only
105760
+** meaningful value to insert is the text 'optimize'.
105761
+*/
105762
+static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
105763
+ int rc; /* Return Code */
105764
+ const char *zVal = (const char *)sqlite3_value_text(pVal);
105765
+ int nVal = sqlite3_value_bytes(pVal);
105766
+
105767
+ if( !zVal ){
105768
+ return SQLITE_NOMEM;
105769
+ }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
105770
+ rc = fts3SegmentMerge(p, -1);
105771
+ if( rc==SQLITE_DONE ){
105772
+ rc = SQLITE_OK;
105773
+ }else{
105774
+ sqlite3Fts3PendingTermsClear(p);
105775
+ }
105776
+#ifdef SQLITE_TEST
105777
+ }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
105778
+ p->nNodeSize = atoi(&zVal[9]);
105779
+ rc = SQLITE_OK;
105780
+ }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
105781
+ p->nMaxPendingData = atoi(&zVal[11]);
105782
+ rc = SQLITE_OK;
105783
+#endif
105784
+ }else{
105785
+ rc = SQLITE_ERROR;
105786
+ }
105787
+
105414105788
return rc;
105415105789
}
105416105790
105417105791
/*
105418105792
** This function does the work for the xUpdate method of FTS3 virtual
@@ -105426,10 +105800,11 @@
105426105800
){
105427105801
Fts3Table *p = (Fts3Table *)pVtab;
105428105802
int rc = SQLITE_OK; /* Return Code */
105429105803
int isRemove = 0; /* True for an UPDATE or DELETE */
105430105804
sqlite3_int64 iRemove = 0; /* Rowid removed by UPDATE or DELETE */
105805
+
105431105806
105432105807
/* If this is a DELETE or UPDATE operation, remove the old record. */
105433105808
if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
105434105809
int isEmpty;
105435105810
rc = fts3IsEmpty(p, apVal, &isEmpty);
@@ -105450,10 +105825,12 @@
105450105825
rc = fts3SqlExec(p, SQL_DELETE_CONTENT, apVal);
105451105826
}
105452105827
}
105453105828
}
105454105829
}
105830
+ }else if( sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL ){
105831
+ return fts3SpecialInsert(p, apVal[p->nColumn+2]);
105455105832
}
105456105833
105457105834
/* If this is an INSERT or UPDATE operation, insert the new record. */
105458105835
if( nArg>1 && rc==SQLITE_OK ){
105459105836
rc = fts3InsertData(p, apVal, pRowid);
@@ -105475,18 +105852,19 @@
105475105852
*/
105476105853
SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){
105477105854
int rc;
105478105855
rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0);
105479105856
if( rc==SQLITE_OK ){
105480
- rc = sqlite3Fts3PendingTermsFlush(p);
105481
- if( rc==SQLITE_OK ){
105482
- rc = fts3SegmentMerge(p, -1);
105483
- }
105857
+ rc = fts3SegmentMerge(p, -1);
105484105858
if( rc==SQLITE_OK ){
105485105859
rc = sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
105860
+ if( rc==SQLITE_OK ){
105861
+ sqlite3Fts3PendingTermsClear(p);
105862
+ }
105486105863
}else{
105487
- sqlite3_exec(p->db, "ROLLBACK TO fts3 ; RELEASE fts3", 0, 0, 0);
105864
+ sqlite3_exec(p->db, "ROLLBACK TO fts3", 0, 0, 0);
105865
+ sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
105488105866
}
105489105867
}
105490105868
return rc;
105491105869
}
105492105870
@@ -106220,10 +106598,620 @@
106220106598
}else{
106221106599
sqlite3_result_error_nomem(pCtx);
106222106600
}
106223106601
fts3SnippetFree(p);
106224106602
}
106603
+
106604
+/*************************************************************************
106605
+** Below this point is the alternative, experimental snippet() implementation.
106606
+*/
106607
+
106608
+#define SNIPPET_BUFFER_CHUNK 64
106609
+#define SNIPPET_BUFFER_SIZE SNIPPET_BUFFER_CHUNK*4
106610
+#define SNIPPET_BUFFER_MASK (SNIPPET_BUFFER_SIZE-1)
106611
+
106612
+static void fts3GetDeltaPosition(char **pp, int *piPos){
106613
+ int iVal;
106614
+ *pp += sqlite3Fts3GetVarint32(*pp, &iVal);
106615
+ *piPos += (iVal-2);
106616
+}
106617
+
106618
+/*
106619
+** Iterate through all phrase nodes in an FTS3 query, except those that
106620
+** are part of a sub-tree that is the right-hand-side of a NOT operator.
106621
+** For each phrase node found, the supplied callback function is invoked.
106622
+**
106623
+** If the callback function returns anything other than SQLITE_OK,
106624
+** the iteration is abandoned and the error code returned immediately.
106625
+** Otherwise, SQLITE_OK is returned after a callback has been made for
106626
+** all eligible phrase nodes.
106627
+*/
106628
+static int fts3ExprIterate(
106629
+ Fts3Expr *pExpr, /* Expression to iterate phrases of */
106630
+ int (*x)(Fts3Expr *, void *), /* Callback function to invoke for phrases */
106631
+ void *pCtx /* Second argument to pass to callback */
106632
+){
106633
+ int rc;
106634
+ int eType = pExpr->eType;
106635
+ if( eType==FTSQUERY_NOT ){
106636
+ rc = SQLITE_OK;
106637
+ }else if( eType!=FTSQUERY_PHRASE ){
106638
+ assert( pExpr->pLeft && pExpr->pRight );
106639
+ rc = fts3ExprIterate(pExpr->pLeft, x, pCtx);
106640
+ if( rc==SQLITE_OK ){
106641
+ rc = fts3ExprIterate(pExpr->pRight, x, pCtx);
106642
+ }
106643
+ }else{
106644
+ rc = x(pExpr, pCtx);
106645
+ }
106646
+ return rc;
106647
+}
106648
+
106649
+typedef struct LoadDoclistCtx LoadDoclistCtx;
106650
+struct LoadDoclistCtx {
106651
+ Fts3Table *pTab; /* FTS3 Table */
106652
+ int nPhrase; /* Number of phrases so far */
106653
+};
106654
+
106655
+static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, void *ctx){
106656
+ int rc = SQLITE_OK;
106657
+ LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;
106658
+ p->nPhrase++;
106659
+ if( pExpr->isLoaded==0 ){
106660
+ rc = sqlite3Fts3ExprLoadDoclist(p->pTab, pExpr);
106661
+ pExpr->isLoaded = 1;
106662
+ if( rc==SQLITE_OK && pExpr->aDoclist ){
106663
+ pExpr->pCurrent = pExpr->aDoclist;
106664
+ pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent);
106665
+ }
106666
+ }
106667
+ return rc;
106668
+}
106669
+
106670
+static int fts3ExprLoadDoclists(Fts3Cursor *pCsr, int *pnPhrase){
106671
+ int rc;
106672
+ LoadDoclistCtx sCtx = {0, 0};
106673
+ sCtx.pTab = (Fts3Table *)pCsr->base.pVtab;
106674
+ rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
106675
+ *pnPhrase = sCtx.nPhrase;
106676
+ return rc;
106677
+}
106678
+
106679
+/*
106680
+** Each call to this function populates a chunk of a snippet-buffer
106681
+** SNIPPET_BUFFER_CHUNK bytes in size.
106682
+**
106683
+** Return true if the end of the data has been reached (and all subsequent
106684
+** calls to fts3LoadSnippetBuffer() with the same arguments will be no-ops),
106685
+** or false otherwise.
106686
+*/
106687
+static int fts3LoadSnippetBuffer(
106688
+ int iPos, /* Document token offset to load data for */
106689
+ u8 *aBuffer, /* Circular snippet buffer to populate */
106690
+ int nList, /* Number of position lists in appList */
106691
+ char **apList, /* IN/OUT: nList position list pointers */
106692
+ int *aiPrev /* IN/OUT: Previous positions read */
106693
+){
106694
+ int i;
106695
+ int nFin = 0;
106696
+
106697
+ assert( (iPos&(SNIPPET_BUFFER_CHUNK-1))==0 );
106698
+
106699
+ memset(&aBuffer[iPos&SNIPPET_BUFFER_MASK], 0, SNIPPET_BUFFER_CHUNK);
106700
+
106701
+ for(i=0; i<nList; i++){
106702
+ int iPrev = aiPrev[i];
106703
+ char *pList = apList[i];
106704
+
106705
+ if( !pList ){
106706
+ nFin++;
106707
+ continue;
106708
+ }
106709
+
106710
+ while( iPrev<(iPos+SNIPPET_BUFFER_CHUNK) ){
106711
+ if( iPrev>=iPos ){
106712
+ aBuffer[iPrev&SNIPPET_BUFFER_MASK] = i+1;
106713
+ }
106714
+ if( 0==((*pList)&0xFE) ){
106715
+ nFin++;
106716
+ break;
106717
+ }
106718
+ fts3GetDeltaPosition(&pList, &iPrev);
106719
+ }
106720
+
106721
+ aiPrev[i] = iPrev;
106722
+ apList[i] = pList;
106723
+ }
106724
+
106725
+ return (nFin==nList);
106726
+}
106727
+
106728
+typedef struct SnippetCtx SnippetCtx;
106729
+struct SnippetCtx {
106730
+ Fts3Cursor *pCsr;
106731
+ int iCol;
106732
+ int iPhrase;
106733
+ int *aiPrev;
106734
+ int *anToken;
106735
+ char **apList;
106736
+};
106737
+
106738
+static int fts3SnippetFindPositions(Fts3Expr *pExpr, void *ctx){
106739
+ SnippetCtx *p = (SnippetCtx *)ctx;
106740
+ int iPhrase = p->iPhrase++;
106741
+ char *pCsr;
106742
+
106743
+ p->anToken[iPhrase] = pExpr->pPhrase->nToken;
106744
+ pCsr = sqlite3Fts3FindPositions(pExpr, p->pCsr->iPrevId, p->iCol);
106745
+
106746
+ if( pCsr ){
106747
+ int iVal;
106748
+ pCsr += sqlite3Fts3GetVarint32(pCsr, &iVal);
106749
+ p->apList[iPhrase] = pCsr;
106750
+ p->aiPrev[iPhrase] = iVal-2;
106751
+ }
106752
+ return SQLITE_OK;
106753
+}
106754
+
106755
+static void fts3SnippetCnt(
106756
+ int iIdx,
106757
+ int nSnippet,
106758
+ int *anCnt,
106759
+ u8 *aBuffer,
106760
+ int *anToken,
106761
+ u64 *pHlmask
106762
+){
106763
+ int iSub = (iIdx-1)&SNIPPET_BUFFER_MASK;
106764
+ int iAdd = (iIdx+nSnippet-1)&SNIPPET_BUFFER_MASK;
106765
+ int iSub2 = (iIdx+(nSnippet/3)-1)&SNIPPET_BUFFER_MASK;
106766
+ int iAdd2 = (iIdx+(nSnippet*2/3)-1)&SNIPPET_BUFFER_MASK;
106767
+
106768
+ u64 h = *pHlmask;
106769
+
106770
+ anCnt[ aBuffer[iSub] ]--;
106771
+ anCnt[ aBuffer[iSub2] ]--;
106772
+ anCnt[ aBuffer[iAdd] ]++;
106773
+ anCnt[ aBuffer[iAdd2] ]++;
106774
+
106775
+ h = h >> 1;
106776
+ if( aBuffer[iAdd] ){
106777
+ int j;
106778
+ for(j=anToken[aBuffer[iAdd]-1]; j>=1; j--){
106779
+ h |= (u64)1 << (nSnippet-j);
106780
+ }
106781
+ }
106782
+ *pHlmask = h;
106783
+}
106784
+
106785
+static int fts3SnippetScore(int n, int *anCnt){
106786
+ int j;
106787
+ int iScore = 0;
106788
+ for(j=1; j<=n; j++){
106789
+ int nCnt = anCnt[j];
106790
+ iScore += nCnt + (nCnt ? 1000 : 0);
106791
+ }
106792
+ return iScore;
106793
+}
106794
+
106795
+static int fts3BestSnippet(
106796
+ int nSnippet, /* Desired snippet length */
106797
+ Fts3Cursor *pCsr, /* Cursor to create snippet for */
106798
+ int iCol, /* Index of column to create snippet from */
106799
+ int *piPos, /* OUT: Starting token for best snippet */
106800
+ u64 *pHlmask /* OUT: Highlight mask for best snippet */
106801
+){
106802
+ int rc; /* Return Code */
106803
+ u8 aBuffer[SNIPPET_BUFFER_SIZE];/* Circular snippet buffer */
106804
+ int *aiPrev; /* Used by fts3LoadSnippetBuffer() */
106805
+ int *anToken; /* Number of tokens in each phrase */
106806
+ char **apList; /* Array of position lists */
106807
+ int *anCnt; /* Running totals of phrase occurences */
106808
+ int nList;
106809
+
106810
+ int i;
106811
+
106812
+ u64 hlmask = 0; /* Current mask of highlighted terms */
106813
+ u64 besthlmask = 0; /* Mask of highlighted terms for iBestPos */
106814
+ int iBestPos = 0; /* Starting position of 'best' snippet */
106815
+ int iBestScore = 0; /* Score of best snippet higher->better */
106816
+ SnippetCtx sCtx;
106817
+
106818
+ /* Iterate through the phrases in the expression to count them. The same
106819
+ ** callback makes sure the doclists are loaded for each phrase.
106820
+ */
106821
+ rc = fts3ExprLoadDoclists(pCsr, &nList);
106822
+ if( rc!=SQLITE_OK ){
106823
+ return rc;
106824
+ }
106825
+
106826
+ /* Now that it is known how many phrases there are, allocate and zero
106827
+ ** the required arrays using malloc().
106828
+ */
106829
+ apList = sqlite3_malloc(
106830
+ sizeof(u8*)*nList + /* apList */
106831
+ sizeof(int)*(nList) + /* anToken */
106832
+ sizeof(int)*nList + /* aiPrev */
106833
+ sizeof(int)*(nList+1) /* anCnt */
106834
+ );
106835
+ if( !apList ){
106836
+ return SQLITE_NOMEM;
106837
+ }
106838
+ memset(apList, 0, sizeof(u8*)*nList+sizeof(int)*nList+sizeof(int)*nList);
106839
+ anToken = (int *)&apList[nList];
106840
+ aiPrev = &anToken[nList];
106841
+ anCnt = &aiPrev[nList];
106842
+
106843
+ /* Initialize the contents of the aiPrev and aiList arrays. */
106844
+ sCtx.pCsr = pCsr;
106845
+ sCtx.iCol = iCol;
106846
+ sCtx.apList = apList;
106847
+ sCtx.aiPrev = aiPrev;
106848
+ sCtx.anToken = anToken;
106849
+ sCtx.iPhrase = 0;
106850
+ (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sCtx);
106851
+
106852
+ /* Load the first two chunks of data into the buffer. */
106853
+ memset(aBuffer, 0, SNIPPET_BUFFER_SIZE);
106854
+ fts3LoadSnippetBuffer(0, aBuffer, nList, apList, aiPrev);
106855
+ fts3LoadSnippetBuffer(SNIPPET_BUFFER_CHUNK, aBuffer, nList, apList, aiPrev);
106856
+
106857
+ /* Set the initial contents of the highlight-mask and anCnt[] array. */
106858
+ for(i=1-nSnippet; i<=0; i++){
106859
+ fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
106860
+ }
106861
+ iBestScore = fts3SnippetScore(nList, anCnt);
106862
+ besthlmask = hlmask;
106863
+ iBestPos = 0;
106864
+
106865
+ for(i=1; 1; i++){
106866
+ int iScore;
106867
+
106868
+ if( 0==(i&(SNIPPET_BUFFER_CHUNK-1)) ){
106869
+ int iLoad = i + SNIPPET_BUFFER_CHUNK;
106870
+ if( fts3LoadSnippetBuffer(iLoad, aBuffer, nList, apList, aiPrev) ) break;
106871
+ }
106872
+
106873
+ /* Figure out how highly a snippet starting at token offset i scores
106874
+ ** according to fts3SnippetScore(). If it is higher than any previously
106875
+ ** considered position, save the current position, score and hlmask as
106876
+ ** the best snippet candidate found so far.
106877
+ */
106878
+ fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
106879
+ iScore = fts3SnippetScore(nList, anCnt);
106880
+ if( iScore>iBestScore ){
106881
+ iBestPos = i;
106882
+ iBestScore = iScore;
106883
+ besthlmask = hlmask;
106884
+ }
106885
+ }
106886
+
106887
+ sqlite3_free(apList);
106888
+ *piPos = iBestPos;
106889
+ *pHlmask = besthlmask;
106890
+ return SQLITE_OK;
106891
+}
106892
+
106893
+typedef struct StrBuffer StrBuffer;
106894
+struct StrBuffer {
106895
+ char *z;
106896
+ int n;
106897
+ int nAlloc;
106898
+};
106899
+
106900
+static int fts3StringAppend(
106901
+ StrBuffer *pStr,
106902
+ const char *zAppend,
106903
+ int nAppend
106904
+){
106905
+ if( nAppend<0 ){
106906
+ nAppend = strlen(zAppend);
106907
+ }
106908
+
106909
+ if( pStr->n+nAppend+1>=pStr->nAlloc ){
106910
+ int nAlloc = pStr->nAlloc+nAppend+100;
106911
+ char *zNew = sqlite3_realloc(pStr->z, nAlloc);
106912
+ if( !zNew ){
106913
+ return SQLITE_NOMEM;
106914
+ }
106915
+ pStr->z = zNew;
106916
+ pStr->nAlloc = nAlloc;
106917
+ }
106918
+
106919
+ memcpy(&pStr->z[pStr->n], zAppend, nAppend);
106920
+ pStr->n += nAppend;
106921
+ pStr->z[pStr->n] = '\0';
106922
+
106923
+ return SQLITE_OK;
106924
+}
106925
+
106926
+static int fts3SnippetText(
106927
+ Fts3Cursor *pCsr, /* FTS3 Cursor */
106928
+ const char *zDoc, /* Document to extract snippet from */
106929
+ int nDoc, /* Size of zDoc in bytes */
106930
+ int nSnippet, /* Number of tokens in extracted snippet */
106931
+ int iPos, /* Index of first document token in snippet */
106932
+ u64 hlmask, /* Bitmask of terms to highlight in snippet */
106933
+ const char *zOpen, /* String inserted before highlighted term */
106934
+ const char *zClose, /* String inserted after highlighted term */
106935
+ const char *zEllipsis,
106936
+ char **pzSnippet /* OUT: Snippet text */
106937
+){
106938
+ Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
106939
+ int rc; /* Return code */
106940
+ int iCurrent = 0;
106941
+ int iStart = 0;
106942
+ int iEnd;
106943
+
106944
+ sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
106945
+ sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */
106946
+ const char *ZDUMMY; /* Dummy arguments used with tokenizer */
106947
+ int DUMMY1, DUMMY2, DUMMY3; /* Dummy arguments used with tokenizer */
106948
+
106949
+ StrBuffer res = {0, 0, 0}; /* Result string */
106950
+
106951
+ /* Open a token cursor on the document. Read all tokens up to and
106952
+ ** including token iPos (the first token of the snippet). Set variable
106953
+ ** iStart to the byte offset in zDoc of the start of token iPos.
106954
+ */
106955
+ pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;
106956
+ rc = pMod->xOpen(pTab->pTokenizer, zDoc, nDoc, &pC);
106957
+ while( rc==SQLITE_OK && iCurrent<iPos ){
106958
+ rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iStart, &DUMMY2, &iCurrent);
106959
+ }
106960
+ iEnd = iStart;
106961
+
106962
+ if( rc==SQLITE_OK && iStart>0 ){
106963
+ rc = fts3StringAppend(&res, zEllipsis, -1);
106964
+ }
106965
+
106966
+ while( rc==SQLITE_OK ){
106967
+ int iBegin;
106968
+ int iFin;
106969
+ rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
106970
+
106971
+ if( rc==SQLITE_OK ){
106972
+ if( iCurrent>=(iPos+nSnippet) ){
106973
+ rc = SQLITE_DONE;
106974
+ }else{
106975
+ iEnd = iFin;
106976
+ if( hlmask & ((u64)1 << (iCurrent-iPos)) ){
106977
+ if( fts3StringAppend(&res, &zDoc[iStart], iBegin-iStart)
106978
+ || fts3StringAppend(&res, zOpen, -1)
106979
+ || fts3StringAppend(&res, &zDoc[iBegin], iEnd-iBegin)
106980
+ || fts3StringAppend(&res, zClose, -1)
106981
+ ){
106982
+ rc = SQLITE_NOMEM;
106983
+ }
106984
+ iStart = iEnd;
106985
+ }
106986
+ }
106987
+ }
106988
+ }
106989
+ assert( rc!=SQLITE_OK );
106990
+ if( rc==SQLITE_DONE ){
106991
+ rc = fts3StringAppend(&res, &zDoc[iStart], iEnd-iStart);
106992
+ if( rc==SQLITE_OK ){
106993
+ rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
106994
+ if( rc==SQLITE_OK ){
106995
+ rc = fts3StringAppend(&res, zEllipsis, -1);
106996
+ }else if( rc==SQLITE_DONE ){
106997
+ rc = fts3StringAppend(&res, &zDoc[iEnd], -1);
106998
+ }
106999
+ }
107000
+ }
107001
+
107002
+ pMod->xClose(pC);
107003
+ if( rc!=SQLITE_OK ){
107004
+ sqlite3_free(res.z);
107005
+ }else{
107006
+ *pzSnippet = res.z;
107007
+ }
107008
+ return rc;
107009
+}
107010
+
107011
+
107012
+/*
107013
+** An instance of this structure is used to collect the 'global' part of
107014
+** the matchinfo statistics. The 'global' part consists of the following:
107015
+**
107016
+** 1. The number of phrases in the query (nPhrase).
107017
+**
107018
+** 2. The number of columns in the FTS3 table (nCol).
107019
+**
107020
+** 3. A matrix of (nPhrase*nCol) integers containing the sum of the
107021
+** number of hits for each phrase in each column across all rows
107022
+** of the table.
107023
+**
107024
+** The total size of the global matchinfo array, assuming the number of
107025
+** columns is N and the number of phrases is P is:
107026
+**
107027
+** 2 + P*(N+1)
107028
+**
107029
+** The number of hits for the 3rd phrase in the second column is found
107030
+** using the expression:
107031
+**
107032
+** aGlobal[2 + P*(1+2) + 1]
107033
+*/
107034
+typedef struct MatchInfo MatchInfo;
107035
+struct MatchInfo {
107036
+ Fts3Table *pTab; /* FTS3 Table */
107037
+ Fts3Cursor *pCursor; /* FTS3 Cursor */
107038
+ int iPhrase; /* Number of phrases so far */
107039
+ int nCol; /* Number of columns in table */
107040
+ u32 *aGlobal; /* Pre-allocated buffer */
107041
+};
107042
+
107043
+/*
107044
+** This function is used to count the entries in a column-list (delta-encoded
107045
+** list of term offsets within a single column of a single row).
107046
+*/
107047
+static int fts3ColumnlistCount(char **ppCollist){
107048
+ char *pEnd = *ppCollist;
107049
+ char c = 0;
107050
+ int nEntry = 0;
107051
+
107052
+ /* A column-list is terminated by either a 0x01 or 0x00. */
107053
+ while( 0xFE & (*pEnd | c) ){
107054
+ c = *pEnd++ & 0x80;
107055
+ if( !c ) nEntry++;
107056
+ }
107057
+
107058
+ *ppCollist = pEnd;
107059
+ return nEntry;
107060
+}
107061
+
107062
+static void fts3LoadColumnlistCounts(char **pp, u32 *aOut){
107063
+ char *pCsr = *pp;
107064
+ while( *pCsr ){
107065
+ sqlite3_int64 iCol = 0;
107066
+ if( *pCsr==0x01 ){
107067
+ pCsr++;
107068
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
107069
+ }
107070
+ aOut[iCol] += fts3ColumnlistCount(&pCsr);
107071
+ }
107072
+ pCsr++;
107073
+ *pp = pCsr;
107074
+}
107075
+
107076
+/*
107077
+** fts3ExprIterate() callback used to collect the "global" matchinfo stats
107078
+** for a single query.
107079
+*/
107080
+static int fts3ExprGlobalMatchinfoCb(
107081
+ Fts3Expr *pExpr, /* Phrase expression node */
107082
+ void *pCtx /* Pointer to MatchInfo structure */
107083
+){
107084
+ MatchInfo *p = (MatchInfo *)pCtx;
107085
+ char *pCsr;
107086
+ char *pEnd;
107087
+ const int iStart = 2 + p->nCol*p->iPhrase;
107088
+
107089
+ assert( pExpr->isLoaded );
107090
+
107091
+ /* Fill in the global hit count matrix row for this phrase. */
107092
+ pCsr = pExpr->aDoclist;
107093
+ pEnd = &pExpr->aDoclist[pExpr->nDoclist];
107094
+ while( pCsr<pEnd ){
107095
+ while( *pCsr++ & 0x80 );
107096
+ fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iStart]);
107097
+ }
107098
+
107099
+ p->iPhrase++;
107100
+ return SQLITE_OK;
107101
+}
107102
+
107103
+static int fts3ExprLocalMatchinfoCb(
107104
+ Fts3Expr *pExpr, /* Phrase expression node */
107105
+ void *pCtx /* Pointer to MatchInfo structure */
107106
+){
107107
+ MatchInfo *p = (MatchInfo *)pCtx;
107108
+ int iPhrase = p->iPhrase++;
107109
+
107110
+ if( pExpr->aDoclist ){
107111
+ char *pCsr;
107112
+ int iOffset = 2 + p->nCol*(p->aGlobal[0]+iPhrase);
107113
+
107114
+ memset(&p->aGlobal[iOffset], 0, p->nCol*sizeof(u32));
107115
+ pCsr = sqlite3Fts3FindPositions(pExpr, p->pCursor->iPrevId, -1);
107116
+ if( pCsr ) fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iOffset]);
107117
+ }
107118
+
107119
+ return SQLITE_OK;
107120
+}
107121
+
107122
+/*
107123
+** Populate pCsr->aMatchinfo[] with data for the current row. The 'matchinfo'
107124
+** data is an array of 32-bit unsigned integers (C type u32).
107125
+*/
107126
+static int fts3GetMatchinfo(Fts3Cursor *pCsr){
107127
+ MatchInfo g;
107128
+ Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
107129
+ if( pCsr->aMatchinfo==0 ){
107130
+ int rc;
107131
+ int nPhrase;
107132
+ int nMatchinfo;
107133
+
107134
+ g.pTab = pTab;
107135
+ g.nCol = pTab->nColumn;
107136
+ g.iPhrase = 0;
107137
+ rc = fts3ExprLoadDoclists(pCsr, &nPhrase);
107138
+ if( rc!=SQLITE_OK ){
107139
+ return rc;
107140
+ }
107141
+
107142
+ nMatchinfo = 2 + 2*g.nCol*nPhrase;
107143
+
107144
+ g.iPhrase = 0;
107145
+ g.aGlobal = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo);
107146
+ if( !g.aGlobal ){
107147
+ return SQLITE_NOMEM;
107148
+ }
107149
+ memset(g.aGlobal, 0, sizeof(u32)*nMatchinfo);
107150
+
107151
+ g.aGlobal[0] = nPhrase;
107152
+ g.aGlobal[1] = g.nCol;
107153
+ (void)fts3ExprIterate(pCsr->pExpr, fts3ExprGlobalMatchinfoCb, (void *)&g);
107154
+
107155
+ pCsr->aMatchinfo = g.aGlobal;
107156
+ }
107157
+
107158
+ g.pTab = pTab;
107159
+ g.pCursor = pCsr;
107160
+ g.nCol = pTab->nColumn;
107161
+ g.iPhrase = 0;
107162
+ g.aGlobal = pCsr->aMatchinfo;
107163
+
107164
+ if( pCsr->isMatchinfoOk ){
107165
+ (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLocalMatchinfoCb, (void *)&g);
107166
+ pCsr->isMatchinfoOk = 0;
107167
+ }
107168
+
107169
+ return SQLITE_OK;
107170
+}
107171
+
107172
+SQLITE_PRIVATE void sqlite3Fts3Snippet2(
107173
+ sqlite3_context *pCtx, /* SQLite function call context */
107174
+ Fts3Cursor *pCsr, /* Cursor object */
107175
+ const char *zStart, /* Snippet start text - "<b>" */
107176
+ const char *zEnd, /* Snippet end text - "</b>" */
107177
+ const char *zEllipsis, /* Snippet ellipsis text - "<b>...</b>" */
107178
+ int iCol, /* Extract snippet from this column */
107179
+ int nToken /* Approximate number of tokens in snippet */
107180
+){
107181
+ int rc;
107182
+ int iPos = 0;
107183
+ u64 hlmask = 0;
107184
+ char *z = 0;
107185
+ int nDoc;
107186
+ const char *zDoc;
107187
+
107188
+ rc = fts3BestSnippet(nToken, pCsr, iCol, &iPos, &hlmask);
107189
+
107190
+ nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);
107191
+ zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);
107192
+
107193
+ if( rc==SQLITE_OK ){
107194
+ rc = fts3SnippetText(
107195
+ pCsr, zDoc, nDoc, nToken, iPos, hlmask, zStart, zEnd, zEllipsis, &z);
107196
+ }
107197
+ if( rc!=SQLITE_OK ){
107198
+ sqlite3_result_error_code(pCtx, rc);
107199
+ }else{
107200
+ sqlite3_result_text(pCtx, z, -1, sqlite3_free);
107201
+ }
107202
+}
107203
+
107204
+SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *pCsr){
107205
+ int rc = fts3GetMatchinfo(pCsr);
107206
+ if( rc!=SQLITE_OK ){
107207
+ sqlite3_result_error_code(pContext, rc);
107208
+ }else{
107209
+ int n = sizeof(u32)*(2+pCsr->aMatchinfo[0]*pCsr->aMatchinfo[1]*2);
107210
+ sqlite3_result_blob(pContext, pCsr->aMatchinfo, n, SQLITE_TRANSIENT);
107211
+ }
107212
+}
106225107213
106226107214
#endif
106227107215
106228107216
/************** End of fts3_snippet.c ****************************************/
106229107217
/************** Begin file rtree.c *******************************************/
@@ -109539,11 +110527,11 @@
109539110527
int nArg; /* Number of arguments */
109540110528
int enc; /* Optimal text encoding */
109541110529
void *pContext; /* sqlite3_user_data() context */
109542110530
void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
109543110531
} scalars[] = {
109544
- {"regexp",-1, SQLITE_ANY, 0, icuRegexpFunc},
110532
+ {"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc},
109545110533
109546110534
{"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16},
109547110535
{"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16},
109548110536
{"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
109549110537
{"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
109550110538
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.21. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -603,88 +603,81 @@
603 #ifdef SQLITE_VERSION_NUMBER
604 # undef SQLITE_VERSION_NUMBER
605 #endif
606
607 /*
608 ** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
609 **
610 ** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
611 ** the sqlite3.h file specify the version of SQLite with which
612 ** that header file is associated.
613 **
614 ** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
615 ** The W value is major version number and is always 3 in SQLite3.
616 ** The W value only changes when backwards compatibility is
617 ** broken and we intend to never break backwards compatibility.
618 ** The X value is the minor version number and only changes when
619 ** there are major feature enhancements that are forwards compatible
620 ** but not backwards compatible.
621 ** The Y value is the release number and is incremented with
622 ** each release but resets back to 0 whenever X is incremented.
623 ** The Z value only appears on branch releases.
624 **
625 ** The SQLITE_VERSION_NUMBER is an integer that is computed as
626 ** follows:
627 **
628 ** <blockquote><pre>
629 ** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
630 ** </pre></blockquote>
631 **
632 ** Since version 3.6.18, SQLite source code has been stored in the
633 ** <a href="http://www.fossil-scm.org/">fossil configuration management
634 ** system</a>. The SQLITE_SOURCE_ID
635 ** macro is a string which identifies a particular check-in of SQLite
636 ** within its configuration management system. The string contains the
637 ** date and time of the check-in (UTC) and an SHA1 hash of the entire
638 ** source tree.
639 **
640 ** See also: [sqlite3_libversion()],
641 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
642 ** [sqlite_version()] and [sqlite_source_id()].
643 **
644 ** Requirements: [H10011] [H10014]
645 */
646 #define SQLITE_VERSION "3.6.21"
647 #define SQLITE_VERSION_NUMBER 3006021
648 #define SQLITE_SOURCE_ID "2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c"
649
650 /*
651 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
652 ** KEYWORDS: sqlite3_version
653 **
654 ** These interfaces provide the same information as the [SQLITE_VERSION],
655 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
656 ** but are associated with the library instead of the header file. Cautious
657 ** programmers might include assert() statements in their application to
658 ** verify that values returned by these interfaces match the macros in
659 ** the header, and thus insure that the application is
660 ** compiled with matching library and header files.
661 **
662 ** <blockquote><pre>
663 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
664 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
665 ** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
666 ** </pre></blockquote>
667 **
668 ** The sqlite3_libversion() function returns the same information as is
669 ** in the sqlite3_version[] string constant. The function is provided
670 ** for use in DLLs since DLL users usually do not have direct access to string
671 ** constants within the DLL. Similarly, the sqlite3_sourceid() function
672 ** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
673 ** the header file.
 
 
 
674 **
675 ** See also: [sqlite_version()] and [sqlite_source_id()].
676 **
677 ** Requirements: [H10021] [H10022] [H10023]
678 */
679 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
680 SQLITE_API const char *sqlite3_libversion(void);
681 SQLITE_API const char *sqlite3_sourceid(void);
682 SQLITE_API int sqlite3_libversion_number(void);
683
684 /*
685 ** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
 
 
 
 
686 **
687 ** SQLite can be compiled with or without mutexes. When
688 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
689 ** are enabled and SQLite is threadsafe. When the
690 ** [SQLITE_THREADSAFE] macro is 0,
@@ -692,33 +685,33 @@
692 ** to use SQLite concurrently from more than one thread.
693 **
694 ** Enabling mutexes incurs a measurable performance penalty.
695 ** So if speed is of utmost importance, it makes sense to disable
696 ** the mutexes. But for maximum safety, mutexes should be enabled.
697 ** The default behavior is for mutexes to be enabled.
698 **
699 ** This interface can be used by an application to make sure that the
700 ** version of SQLite that it is linking against was compiled with
701 ** the desired setting of the [SQLITE_THREADSAFE] macro.
702 **
703 ** This interface only reports on the compile-time mutex setting
704 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
705 ** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
706 ** can be fully or partially disabled using a call to [sqlite3_config()]
707 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
708 ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows
709 ** only the default compile-time setting, not any run-time changes
710 ** to that setting.
 
 
711 **
712 ** See the [threading mode] documentation for additional information.
713 **
714 ** Requirements: [H10101] [H10102]
715 */
716 SQLITE_API int sqlite3_threadsafe(void);
717
718 /*
719 ** CAPI3REF: Database Connection Handle {H12000} <S40200>
720 ** KEYWORDS: {database connection} {database connections}
721 **
722 ** Each open SQLite database is represented by a pointer to an instance of
723 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
724 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -729,21 +722,24 @@
729 ** sqlite3 object.
730 */
731 typedef struct sqlite3 sqlite3;
732
733 /*
734 ** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
735 ** KEYWORDS: sqlite_int64 sqlite_uint64
736 **
737 ** Because there is no cross-platform way to specify 64-bit integer types
738 ** SQLite includes typedefs for 64-bit signed and unsigned integers.
739 **
740 ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
741 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
742 ** compatibility only.
743 **
744 ** Requirements: [H10201] [H10202]
 
 
 
745 */
746 #ifdef SQLITE_INT64_TYPE
747 typedef SQLITE_INT64_TYPE sqlite_int64;
748 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
749 #elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -763,28 +759,32 @@
763 #ifdef SQLITE_OMIT_FLOATING_POINT
764 # define double sqlite3_int64
765 #endif
766
767 /*
768 ** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
769 **
770 ** This routine is the destructor for the [sqlite3] object.
 
 
771 **
772 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
773 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
774 ** the [sqlite3] object prior to attempting to close the object.
 
 
 
775 **
776 ** If [sqlite3_close()] is invoked while a transaction is open,
777 ** the transaction is automatically rolled back.
778 **
779 ** The C parameter to [sqlite3_close(C)] must be either a NULL
780 ** pointer or an [sqlite3] object pointer obtained
781 ** from [sqlite3_open()], [sqlite3_open16()], or
782 ** [sqlite3_open_v2()], and not previously closed.
783 **
784 ** Requirements:
785 ** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
786 */
787 SQLITE_API int sqlite3_close(sqlite3 *);
788
789 /*
790 ** The type for a callback function.
@@ -792,52 +792,69 @@
792 ** compatibility and is not documented.
793 */
794 typedef int (*sqlite3_callback)(void*,int,char**, char**);
795
796 /*
797 ** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
798 **
799 ** The sqlite3_exec() interface is a convenient way of running one or more
800 ** SQL statements without having to write a lot of C code. The UTF-8 encoded
801 ** SQL statements are passed in as the second parameter to sqlite3_exec().
802 ** The statements are evaluated one by one until either an error or
803 ** an interrupt is encountered, or until they are all done. The 3rd parameter
804 ** is an optional callback that is invoked once for each row of any query
805 ** results produced by the SQL statements. The 5th parameter tells where
806 ** to write any error messages.
807 **
808 ** The error message passed back through the 5th parameter is held
809 ** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak,
810 ** the calling application should call [sqlite3_free()] on any error
811 ** message returned through the 5th parameter when it has finished using
812 ** the error message.
813 **
814 ** If the SQL statement in the 2nd parameter is NULL or an empty string
815 ** or a string containing only whitespace and comments, then no SQL
816 ** statements are evaluated and the database is not changed.
817 **
818 ** The sqlite3_exec() interface is implemented in terms of
819 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
820 ** The sqlite3_exec() routine does nothing to the database that cannot be done
821 ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
822 **
823 ** The first parameter to [sqlite3_exec()] must be an valid and open
824 ** [database connection].
825 **
826 ** The database connection must not be closed while
827 ** [sqlite3_exec()] is running.
828 **
829 ** The calling function should use [sqlite3_free()] to free
830 ** the memory that *errmsg is left pointing at once the error
831 ** message is no longer needed.
832 **
833 ** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
834 ** must remain unchanged while [sqlite3_exec()] is running.
835 **
836 ** Requirements:
837 ** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
838 ** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839 */
840 SQLITE_API int sqlite3_exec(
841 sqlite3*, /* An open database */
842 const char *sql, /* SQL to be evaluated */
843 int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -844,11 +861,11 @@
844 void *, /* 1st argument to callback */
845 char **errmsg /* Error msg written here */
846 );
847
848 /*
849 ** CAPI3REF: Result Codes {H10210} <S10700>
850 ** KEYWORDS: SQLITE_OK {error code} {error codes}
851 ** KEYWORDS: {result code} {result codes}
852 **
853 ** Many SQLite functions return an integer result code from the set shown
854 ** here in order to indicates success or failure.
@@ -888,11 +905,11 @@
888 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
889 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
890 /* end-of-error-codes */
891
892 /*
893 ** CAPI3REF: Extended Result Codes {H10220} <S10700>
894 ** KEYWORDS: {extended error code} {extended error codes}
895 ** KEYWORDS: {extended result code} {extended result codes}
896 **
897 ** In its default configuration, SQLite API routines return one of 26 integer
898 ** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -930,11 +947,11 @@
930 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
931 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
932 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
933
934 /*
935 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
936 **
937 ** These bit values are intended for use in the
938 ** 3rd parameter to the [sqlite3_open_v2()] interface and
939 ** in the 4th parameter to the xOpen method of the
940 ** [sqlite3_vfs] object.
@@ -955,11 +972,11 @@
955 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
956 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
957 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
958
959 /*
960 ** CAPI3REF: Device Characteristics {H10240} <H11120>
961 **
962 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
963 ** object returns an integer which is a vector of the these
964 ** bit values expressing I/O characteristics of the mass storage
965 ** device that holds the file that the [sqlite3_io_methods]
@@ -987,11 +1004,11 @@
987 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
988 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
989 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
990
991 /*
992 ** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
993 **
994 ** SQLite uses one of these integer values as the second
995 ** argument to calls it makes to the xLock() and xUnlock() methods
996 ** of an [sqlite3_io_methods] object.
997 */
@@ -1000,11 +1017,11 @@
1000 #define SQLITE_LOCK_RESERVED 2
1001 #define SQLITE_LOCK_PENDING 3
1002 #define SQLITE_LOCK_EXCLUSIVE 4
1003
1004 /*
1005 ** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
1006 **
1007 ** When SQLite invokes the xSync() method of an
1008 ** [sqlite3_io_methods] object it uses a combination of
1009 ** these integer values as the second argument.
1010 **
@@ -1018,11 +1035,11 @@
1018 #define SQLITE_SYNC_NORMAL 0x00002
1019 #define SQLITE_SYNC_FULL 0x00003
1020 #define SQLITE_SYNC_DATAONLY 0x00010
1021
1022 /*
1023 ** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
1024 **
1025 ** An [sqlite3_file] object represents an open file in the
1026 ** [sqlite3_vfs | OS interface layer]. Individual OS interface
1027 ** implementations will
1028 ** want to subclass this object by appending additional fields
@@ -1034,11 +1051,11 @@
1034 struct sqlite3_file {
1035 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
1036 };
1037
1038 /*
1039 ** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
1040 **
1041 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
1042 ** [sqlite3_file] object (or, more commonly, a subclass of the
1043 ** [sqlite3_file] object) with a pointer to an instance of this object.
1044 ** This object defines the methods used to perform various operations
@@ -1139,11 +1156,11 @@
1139 int (*xDeviceCharacteristics)(sqlite3_file*);
1140 /* Additional methods may be added in future releases */
1141 };
1142
1143 /*
1144 ** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
1145 **
1146 ** These integer constants are opcodes for the xFileControl method
1147 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
1148 ** interface.
1149 **
@@ -1159,11 +1176,11 @@
1159 #define SQLITE_GET_LOCKPROXYFILE 2
1160 #define SQLITE_SET_LOCKPROXYFILE 3
1161 #define SQLITE_LAST_ERRNO 4
1162
1163 /*
1164 ** CAPI3REF: Mutex Handle {H17110} <S20130>
1165 **
1166 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
1167 ** abstract type for a mutex object. The SQLite core never looks
1168 ** at the internal representation of an [sqlite3_mutex]. It only
1169 ** deals with pointers to the [sqlite3_mutex] object.
@@ -1171,11 +1188,11 @@
1171 ** Mutexes are created using [sqlite3_mutex_alloc()].
1172 */
1173 typedef struct sqlite3_mutex sqlite3_mutex;
1174
1175 /*
1176 ** CAPI3REF: OS Interface Object {H11140} <S20100>
1177 **
1178 ** An instance of the sqlite3_vfs object defines the interface between
1179 ** the SQLite core and the underlying operating system. The "vfs"
1180 ** in the name of the object stands for "virtual file system".
1181 **
@@ -1325,14 +1342,14 @@
1325 /* New fields may be appended in figure versions. The iVersion
1326 ** value will increment whenever this happens. */
1327 };
1328
1329 /*
1330 ** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
1331 **
1332 ** These integer constants can be used as the third parameter to
1333 ** the xAccess method of an [sqlite3_vfs] object. {END} They determine
1334 ** what kind of permissions the xAccess method is looking for.
1335 ** With SQLITE_ACCESS_EXISTS, the xAccess method
1336 ** simply checks whether the file exists.
1337 ** With SQLITE_ACCESS_READWRITE, the xAccess method
1338 ** checks whether the file is both readable and writable.
@@ -1342,52 +1359,52 @@
1342 #define SQLITE_ACCESS_EXISTS 0
1343 #define SQLITE_ACCESS_READWRITE 1
1344 #define SQLITE_ACCESS_READ 2
1345
1346 /*
1347 ** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
1348 **
1349 ** The sqlite3_initialize() routine initializes the
1350 ** SQLite library. The sqlite3_shutdown() routine
1351 ** deallocates any resources that were allocated by sqlite3_initialize().
1352 ** These routines are designed to aid in process initialization and
1353 ** shutdown on embedded systems. Workstation applications using
1354 ** SQLite normally do not need to invoke either of these routines.
1355 **
1356 ** A call to sqlite3_initialize() is an "effective" call if it is
1357 ** the first time sqlite3_initialize() is invoked during the lifetime of
1358 ** the process, or if it is the first time sqlite3_initialize() is invoked
1359 ** following a call to sqlite3_shutdown(). Only an effective call
1360 ** of sqlite3_initialize() does any initialization. All other calls
1361 ** are harmless no-ops.
1362 **
1363 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
1364 ** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only
1365 ** an effective call to sqlite3_shutdown() does any deinitialization.
1366 ** All other valid calls to sqlite3_shutdown() are harmless no-ops.
1367 **
1368 ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
1369 ** is not. The sqlite3_shutdown() interface must only be called from a
1370 ** single thread. All open [database connections] must be closed and all
1371 ** other SQLite resources must be deallocated prior to invoking
1372 ** sqlite3_shutdown().
1373 **
1374 ** Among other things, sqlite3_initialize() will invoke
1375 ** sqlite3_os_init(). Similarly, sqlite3_shutdown()
1376 ** will invoke sqlite3_os_end().
1377 **
1378 ** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
1379 ** If for some reason, sqlite3_initialize() is unable to initialize
1380 ** the library (perhaps it is unable to allocate a needed resource such
1381 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
1382 **
1383 ** The sqlite3_initialize() routine is called internally by many other
1384 ** SQLite interfaces so that an application usually does not need to
1385 ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
1386 ** calls sqlite3_initialize() so the SQLite library will be automatically
1387 ** initialized when [sqlite3_open()] is called if it has not be initialized
1388 ** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
1389 ** compile-time option, then the automatic calls to sqlite3_initialize()
1390 ** are omitted and the application must call sqlite3_initialize() directly
1391 ** prior to using any other SQLite interface. For maximum portability,
1392 ** it is recommended that applications always invoke sqlite3_initialize()
1393 ** directly prior to using any other SQLite interface. Future releases
@@ -1422,11 +1439,11 @@
1422 SQLITE_API int sqlite3_shutdown(void);
1423 SQLITE_API int sqlite3_os_init(void);
1424 SQLITE_API int sqlite3_os_end(void);
1425
1426 /*
1427 ** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
1428 ** EXPERIMENTAL
1429 **
1430 ** The sqlite3_config() interface is used to make global configuration
1431 ** changes to SQLite in order to tune SQLite to the specific needs of
1432 ** the application. The default configuration is recommended for most
@@ -1436,39 +1453,36 @@
1436 ** The sqlite3_config() interface is not threadsafe. The application
1437 ** must insure that no other SQLite interfaces are invoked by other
1438 ** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
1439 ** may only be invoked prior to library initialization using
1440 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1441 ** Note, however, that sqlite3_config() can be called as part of the
 
 
1442 ** implementation of an application-defined [sqlite3_os_init()].
1443 **
1444 ** The first argument to sqlite3_config() is an integer
1445 ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
1446 ** what property of SQLite is to be configured. Subsequent arguments
1447 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
1448 ** in the first argument.
1449 **
1450 ** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1451 ** If the option is unknown or SQLite is unable to set the option
1452 ** then this routine returns a non-zero [error code].
1453 **
1454 ** Requirements:
1455 ** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
1456 ** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
1457 ** [H14162] [H14165] [H14168]
1458 */
1459 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
1460
1461 /*
1462 ** CAPI3REF: Configure database connections {H14200} <S20000>
1463 ** EXPERIMENTAL
1464 **
1465 ** The sqlite3_db_config() interface is used to make configuration
1466 ** changes to a [database connection]. The interface is similar to
1467 ** [sqlite3_config()] except that the changes apply to a single
1468 ** [database connection] (specified in the first argument). The
1469 ** sqlite3_db_config() interface can only be used immediately after
1470 ** the database connection is created using [sqlite3_open()],
1471 ** [sqlite3_open16()], or [sqlite3_open_v2()].
1472 **
1473 ** The second argument to sqlite3_db_config(D,V,...) is the
1474 ** configuration verb - an integer code that indicates what
@@ -1475,17 +1489,17 @@
1475 ** aspect of the [database connection] is being configured.
1476 ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
1477 ** New verbs are likely to be added in future releases of SQLite.
1478 ** Additional arguments depend on the verb.
1479 **
1480 ** Requirements:
1481 ** [H14203] [H14206] [H14209] [H14212] [H14215]
1482 */
1483 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
1484
1485 /*
1486 ** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
1487 ** EXPERIMENTAL
1488 **
1489 ** An instance of this object defines the interface between SQLite
1490 ** and low-level memory allocation routines.
1491 **
@@ -1511,11 +1525,11 @@
1511 ** The xMalloc and xFree methods must work like the
1512 ** malloc() and free() functions from the standard C library.
1513 ** The xRealloc method must work like realloc() from the standard C library
1514 ** with the exception that if the second argument to xRealloc is zero,
1515 ** xRealloc must be a no-op - it must not perform any allocation or
1516 ** deallocation. SQLite guaranteeds that the second argument to
1517 ** xRealloc is always a value returned by a prior call to xRoundup.
1518 ** And so in cases where xRoundup always returns a positive number,
1519 ** xRealloc can perform exactly as the standard library realloc() and
1520 ** still be in compliance with this specification.
1521 **
@@ -1563,11 +1577,11 @@
1563 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
1564 void *pAppData; /* Argument to xInit() and xShutdown() */
1565 };
1566
1567 /*
1568 ** CAPI3REF: Configuration Options {H10160} <S20000>
1569 ** EXPERIMENTAL
1570 **
1571 ** These constants are the available integer configuration options that
1572 ** can be passed as the first argument to the [sqlite3_config()] interface.
1573 **
@@ -1578,151 +1592,181 @@
1578 ** non-zero [error code] if a discontinued or unsupported configuration option
1579 ** is invoked.
1580 **
1581 ** <dl>
1582 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1583 ** <dd>There are no arguments to this option. This option disables
 
1584 ** all mutexing and puts SQLite into a mode where it can only be used
1585 ** by a single thread.</dd>
 
 
 
 
 
1586 **
1587 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1588 ** <dd>There are no arguments to this option. This option disables
 
1589 ** mutexing on [database connection] and [prepared statement] objects.
1590 ** The application is responsible for serializing access to
1591 ** [database connections] and [prepared statements]. But other mutexes
1592 ** are enabled so that SQLite will be safe to use in a multi-threaded
1593 ** environment as long as no two threads attempt to use the same
1594 ** [database connection] at the same time. See the [threading mode]
1595 ** documentation for additional information.</dd>
 
 
 
1596 **
1597 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1598 ** <dd>There are no arguments to this option. This option enables
 
1599 ** all mutexes including the recursive
1600 ** mutexes on [database connection] and [prepared statement] objects.
1601 ** In this mode (which is the default when SQLite is compiled with
1602 ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
1603 ** to [database connections] and [prepared statements] so that the
1604 ** application is free to use the same [database connection] or the
1605 ** same [prepared statement] in different threads at the same time.
1606 ** See the [threading mode] documentation for additional information.</dd>
 
 
 
 
1607 **
1608 ** <dt>SQLITE_CONFIG_MALLOC</dt>
1609 ** <dd>This option takes a single argument which is a pointer to an
1610 ** instance of the [sqlite3_mem_methods] structure. The argument specifies
1611 ** alternative low-level memory allocation routines to be used in place of
1612 ** the memory allocation routines built into SQLite.</dd>
 
 
1613 **
1614 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1615 ** <dd>This option takes a single argument which is a pointer to an
1616 ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1617 ** structure is filled with the currently defined memory allocation routines.
1618 ** This option can be used to overload the default memory allocation
1619 ** routines with a wrapper that simulations memory allocation failure or
1620 ** tracks memory usage, for example.</dd>
1621 **
1622 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1623 ** <dd>This option takes single argument of type int, interpreted as a
1624 ** boolean, which enables or disables the collection of memory allocation
1625 ** statistics. When disabled, the following SQLite interfaces become
1626 ** non-operational:
1627 ** <ul>
1628 ** <li> [sqlite3_memory_used()]
1629 ** <li> [sqlite3_memory_highwater()]
1630 ** <li> [sqlite3_soft_heap_limit()]
1631 ** <li> [sqlite3_status()]
1632 ** </ul>
 
 
 
1633 ** </dd>
1634 **
1635 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
1636 ** <dd>This option specifies a static memory buffer that SQLite can use for
1637 ** scratch memory. There are three arguments: A pointer an 8-byte
1638 ** aligned memory buffer from which the scrach allocations will be
1639 ** drawn, the size of each scratch allocation (sz),
1640 ** and the maximum number of scratch allocations (N). The sz
1641 ** argument must be a multiple of 16. The sz parameter should be a few bytes
1642 ** larger than the actual scratch space required due to internal overhead.
1643 ** The first argument should pointer to an 8-byte aligned buffer
1644 ** of at least sz*N bytes of memory.
1645 ** SQLite will use no more than one scratch buffer at once per thread, so
1646 ** N should be set to the expected maximum number of threads. The sz
1647 ** parameter should be 6 times the size of the largest database page size.
1648 ** Scratch buffers are used as part of the btree balance operation. If
1649 ** The btree balancer needs additional memory beyond what is provided by
1650 ** scratch buffers or if no scratch buffer space is specified, then SQLite
1651 ** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
1652 **
1653 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1654 ** <dd>This option specifies a static memory buffer that SQLite can use for
1655 ** the database page cache with the default page cache implemenation.
1656 ** This configuration should not be used if an application-define page
1657 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1658 ** There are three arguments to this option: A pointer to 8-byte aligned
1659 ** memory, the size of each page buffer (sz), and the number of pages (N).
1660 ** The sz argument should be the size of the largest database page
1661 ** (a power of two between 512 and 32768) plus a little extra for each
1662 ** page header. The page header size is 20 to 40 bytes depending on
1663 ** the host architecture. It is harmless, apart from the wasted memory,
1664 ** to make sz a little too large. The first
1665 ** argument should point to an allocation of at least sz*N bytes of memory.
1666 ** SQLite will use the memory provided by the first argument to satisfy its
1667 ** memory needs for the first N pages that it adds to cache. If additional
1668 ** page cache memory is needed beyond what is provided by this option, then
1669 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1670 ** The implementation might use one or more of the N buffers to hold
1671 ** memory accounting information. The pointer in the first argument must
1672 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1673 ** will be undefined.</dd>
1674 **
1675 ** <dt>SQLITE_CONFIG_HEAP</dt>
1676 ** <dd>This option specifies a static memory buffer that SQLite will use
1677 ** for all of its dynamic memory allocation needs beyond those provided
1678 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
1679 ** There are three arguments: An 8-byte aligned pointer to the memory,
1680 ** the number of bytes in the memory buffer, and the minimum allocation size.
1681 ** If the first pointer (the memory pointer) is NULL, then SQLite reverts
1682 ** to using its default memory allocator (the system malloc() implementation),
1683 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the
1684 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
1685 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1686 ** allocator is engaged to handle all of SQLites memory allocation needs.
1687 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1688 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1689 **
1690 ** <dt>SQLITE_CONFIG_MUTEX</dt>
1691 ** <dd>This option takes a single argument which is a pointer to an
1692 ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
1693 ** alternative low-level mutex routines to be used in place
1694 ** the mutex routines built into SQLite.</dd>
 
 
 
 
 
 
1695 **
1696 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1697 ** <dd>This option takes a single argument which is a pointer to an
1698 ** instance of the [sqlite3_mutex_methods] structure. The
1699 ** [sqlite3_mutex_methods]
1700 ** structure is filled with the currently defined mutex routines.
1701 ** This option can be used to overload the default mutex allocation
1702 ** routines with a wrapper used to track mutex usage for performance
1703 ** profiling or testing, for example.</dd>
 
 
 
 
1704 **
1705 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1706 ** <dd>This option takes two arguments that determine the default
1707 ** memory allocation lookaside optimization. The first argument is the
 
1708 ** size of each lookaside buffer slot and the second is the number of
1709 ** slots allocated to each database connection. This option sets the
1710 ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1711 ** verb to [sqlite3_db_config()] can be used to change the lookaside
1712 ** configuration on individual connections.</dd>
1713 **
1714 ** <dt>SQLITE_CONFIG_PCACHE</dt>
1715 ** <dd>This option takes a single argument which is a pointer to
1716 ** an [sqlite3_pcache_methods] object. This object specifies the interface
1717 ** to a custom page cache implementation. SQLite makes a copy of the
1718 ** object and uses it for page cache memory allocations.</dd>
1719 **
1720 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1721 ** <dd>This option takes a single argument which is a pointer to an
1722 ** [sqlite3_pcache_methods] object. SQLite copies of the current
1723 ** page cache implementation into that object.</dd>
1724 **
1725 ** </dl>
1726 */
1727 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1728 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1739,94 +1783,90 @@
1739 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1740 #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
1741 #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
1742
1743 /*
1744 ** CAPI3REF: Configuration Options {H10170} <S20000>
1745 ** EXPERIMENTAL
1746 **
1747 ** These constants are the available integer configuration options that
1748 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1749 **
1750 ** New configuration options may be added in future releases of SQLite.
1751 ** Existing configuration options might be discontinued. Applications
1752 ** should check the return code from [sqlite3_db_config()] to make sure that
1753 ** the call worked. The [sqlite3_db_config()] interface will return a
1754 ** non-zero [error code] if a discontinued or unsupported configuration option
1755 ** is invoked.
1756 **
1757 ** <dl>
1758 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1759 ** <dd>This option takes three additional arguments that determine the
1760 ** [lookaside memory allocator] configuration for the [database connection].
1761 ** The first argument (the third parameter to [sqlite3_db_config()] is a
1762 ** pointer to an memory buffer to use for lookaside memory.
1763 ** The first argument may be NULL in which case SQLite will allocate the
1764 ** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the
1765 ** size of each lookaside buffer slot and the third argument is the number of
 
1766 ** slots. The size of the buffer in the first argument must be greater than
1767 ** or equal to the product of the second and third arguments. The buffer
1768 ** must be aligned to an 8-byte boundary. If the second argument is not
1769 ** a multiple of 8, it is internally rounded down to the next smaller
 
1770 ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
1771 **
1772 ** </dl>
1773 */
1774 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1775
1776
1777 /*
1778 ** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
1779 **
1780 ** The sqlite3_extended_result_codes() routine enables or disables the
1781 ** [extended result codes] feature of SQLite. The extended result
1782 ** codes are disabled by default for historical compatibility considerations.
1783 **
1784 ** Requirements:
1785 ** [H12201] [H12202]
1786 */
1787 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1788
1789 /*
1790 ** CAPI3REF: Last Insert Rowid {H12220} <S10700>
1791 **
1792 ** Each entry in an SQLite table has a unique 64-bit signed
1793 ** integer key called the [ROWID | "rowid"]. The rowid is always available
1794 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1795 ** names are not also used by explicitly declared columns. If
1796 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1797 ** is another alias for the rowid.
1798 **
1799 ** This routine returns the [rowid] of the most recent
1800 ** successful [INSERT] into the database from the [database connection]
1801 ** in the first argument. If no successful [INSERT]s
1802 ** have ever occurred on that database connection, zero is returned.
1803 **
1804 ** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1805 ** row is returned by this routine as long as the trigger is running.
1806 ** But once the trigger terminates, the value returned by this routine
1807 ** reverts to the last value inserted before the trigger fired.
1808 **
1809 ** An [INSERT] that fails due to a constraint violation is not a
1810 ** successful [INSERT] and does not change the value returned by this
1811 ** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1812 ** and INSERT OR ABORT make no changes to the return value of this
1813 ** routine when their insertion fails. When INSERT OR REPLACE
1814 ** encounters a constraint violation, it does not fail. The
1815 ** INSERT continues to completion after deleting rows that caused
1816 ** the constraint problem so INSERT OR REPLACE will always change
1817 ** the return value of this interface.
1818 **
1819 ** For the purposes of this routine, an [INSERT] is considered to
1820 ** be successful even if it is subsequently rolled back.
1821 **
1822 ** This function is accessible to SQL statements via the
1823 ** [last_insert_rowid() SQL function].
1824 **
1825 ** Requirements:
1826 ** [H12221] [H12223]
1827 **
1828 ** If a separate thread performs a new [INSERT] on the same
1829 ** database connection while the [sqlite3_last_insert_rowid()]
1830 ** function is running and thus changes the last insert [rowid],
1831 ** then the value returned by [sqlite3_last_insert_rowid()] is
1832 ** unpredictable and might not equal either the old or the new
@@ -1833,164 +1873,154 @@
1833 ** last insert [rowid].
1834 */
1835 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1836
1837 /*
1838 ** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
1839 **
1840 ** This function returns the number of database rows that were changed
1841 ** or inserted or deleted by the most recently completed SQL statement
1842 ** on the [database connection] specified by the first parameter.
1843 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1844 ** or [DELETE] statement are counted. Auxiliary changes caused by
1845 ** triggers or [foreign key actions] are not counted. Use the
1846 ** [sqlite3_total_changes()] function to find the total number of changes
1847 ** including changes caused by triggers and foreign key actions.
1848 **
1849 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1850 ** are not counted. Only real table changes are counted.
1851 **
1852 ** A "row change" is a change to a single row of a single table
1853 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
1854 ** are changed as side effects of [REPLACE] constraint resolution,
1855 ** rollback, ABORT processing, [DROP TABLE], or by any other
1856 ** mechanisms do not count as direct row changes.
1857 **
1858 ** A "trigger context" is a scope of execution that begins and
1859 ** ends with the script of a [CREATE TRIGGER | trigger].
1860 ** Most SQL statements are
1861 ** evaluated outside of any trigger. This is the "top level"
1862 ** trigger context. If a trigger fires from the top level, a
1863 ** new trigger context is entered for the duration of that one
1864 ** trigger. Subtriggers create subcontexts for their duration.
1865 **
1866 ** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1867 ** not create a new trigger context.
1868 **
1869 ** This function returns the number of direct row changes in the
1870 ** most recent INSERT, UPDATE, or DELETE statement within the same
1871 ** trigger context.
1872 **
1873 ** Thus, when called from the top level, this function returns the
1874 ** number of changes in the most recent INSERT, UPDATE, or DELETE
1875 ** that also occurred at the top level. Within the body of a trigger,
1876 ** the sqlite3_changes() interface can be called to find the number of
1877 ** changes in the most recently completed INSERT, UPDATE, or DELETE
1878 ** statement within the body of the same trigger.
1879 ** However, the number returned does not include changes
1880 ** caused by subtriggers since those have their own context.
1881 **
1882 ** See also the [sqlite3_total_changes()] interface, the
1883 ** [count_changes pragma], and the [changes() SQL function].
1884 **
1885 ** Requirements:
1886 ** [H12241] [H12243]
1887 **
1888 ** If a separate thread makes changes on the same database connection
1889 ** while [sqlite3_changes()] is running then the value returned
1890 ** is unpredictable and not meaningful.
1891 */
1892 SQLITE_API int sqlite3_changes(sqlite3*);
1893
1894 /*
1895 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1896 **
1897 ** This function returns the number of row changes caused by [INSERT],
1898 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1899 ** The count includes all changes from all [CREATE TRIGGER | trigger]
1900 ** contexts and changes made by [foreign key actions]. However,
 
1901 ** the count does not include changes used to implement [REPLACE] constraints,
1902 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1903 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1904 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1905 ** are counted.
1906 ** The changes are counted as soon as the statement that makes them is
1907 ** completed (when the statement handle is passed to [sqlite3_reset()] or
1908 ** [sqlite3_finalize()]).
1909 **
1910 ** See also the [sqlite3_changes()] interface, the
1911 ** [count_changes pragma], and the [total_changes() SQL function].
1912 **
1913 ** Requirements:
1914 ** [H12261] [H12263]
1915 **
1916 ** If a separate thread makes changes on the same database connection
1917 ** while [sqlite3_total_changes()] is running then the value
1918 ** returned is unpredictable and not meaningful.
1919 */
1920 SQLITE_API int sqlite3_total_changes(sqlite3*);
1921
1922 /*
1923 ** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
1924 **
1925 ** This function causes any pending database operation to abort and
1926 ** return at its earliest opportunity. This routine is typically
1927 ** called in response to a user action such as pressing "Cancel"
1928 ** or Ctrl-C where the user wants a long query operation to halt
1929 ** immediately.
1930 **
1931 ** It is safe to call this routine from a thread different from the
1932 ** thread that is currently running the database operation. But it
1933 ** is not safe to call this routine with a [database connection] that
1934 ** is closed or might close before sqlite3_interrupt() returns.
1935 **
1936 ** If an SQL operation is very nearly finished at the time when
1937 ** sqlite3_interrupt() is called, then it might not have an opportunity
1938 ** to be interrupted and might continue to completion.
1939 **
1940 ** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1941 ** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1942 ** that is inside an explicit transaction, then the entire transaction
1943 ** will be rolled back automatically.
1944 **
1945 ** The sqlite3_interrupt(D) call is in effect until all currently running
1946 ** SQL statements on [database connection] D complete. Any new SQL statements
1947 ** that are started after the sqlite3_interrupt() call and before the
1948 ** running statements reaches zero are interrupted as if they had been
1949 ** running prior to the sqlite3_interrupt() call. New SQL statements
1950 ** that are started after the running statement count reaches zero are
1951 ** not effected by the sqlite3_interrupt().
1952 ** A call to sqlite3_interrupt(D) that occurs when there are no running
1953 ** SQL statements is a no-op and has no effect on SQL statements
1954 ** that are started after the sqlite3_interrupt() call returns.
1955 **
1956 ** Requirements:
1957 ** [H12271] [H12272]
1958 **
1959 ** If the database connection closes while [sqlite3_interrupt()]
1960 ** is running then bad things will likely happen.
1961 */
1962 SQLITE_API void sqlite3_interrupt(sqlite3*);
1963
1964 /*
1965 ** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
1966 **
1967 ** These routines are useful during command-line input to determine if the
1968 ** currently entered text seems to form a complete SQL statement or
1969 ** if additional input is needed before sending the text into
1970 ** SQLite for parsing. These routines return 1 if the input string
1971 ** appears to be a complete SQL statement. A statement is judged to be
1972 ** complete if it ends with a semicolon token and is not a prefix of a
1973 ** well-formed CREATE TRIGGER statement. Semicolons that are embedded within
1974 ** string literals or quoted identifier names or comments are not
1975 ** independent tokens (they are part of the token in which they are
1976 ** embedded) and thus do not count as a statement terminator. Whitespace
1977 ** and comments that follow the final semicolon are ignored.
1978 **
1979 ** These routines return 0 if the statement is incomplete. If a
1980 ** memory allocation fails, then SQLITE_NOMEM is returned.
1981 **
1982 ** These routines do not parse the SQL statements thus
1983 ** will not detect syntactically incorrect SQL.
1984 **
1985 ** If SQLite has not been initialized using [sqlite3_initialize()] prior
1986 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
1987 ** automatically by sqlite3_complete16(). If that initialization fails,
1988 ** then the return value from sqlite3_complete16() will be non-zero
1989 ** regardless of whether or not the input SQL is complete.
1990 **
1991 ** Requirements: [H10511] [H10512]
1992 **
1993 ** The input to [sqlite3_complete()] must be a zero-terminated
1994 ** UTF-8 string.
1995 **
1996 ** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1998,31 +2028,31 @@
1998 */
1999 SQLITE_API int sqlite3_complete(const char *sql);
2000 SQLITE_API int sqlite3_complete16(const void *sql);
2001
2002 /*
2003 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
2004 **
2005 ** This routine sets a callback function that might be invoked whenever
2006 ** an attempt is made to open a database table that another thread
2007 ** or process has locked.
2008 **
2009 ** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
2010 ** is returned immediately upon encountering the lock. If the busy callback
2011 ** is not NULL, then the callback will be invoked with two arguments.
2012 **
2013 ** The first argument to the handler is a copy of the void* pointer which
2014 ** is the third argument to sqlite3_busy_handler(). The second argument to
2015 ** the handler callback is the number of times that the busy handler has
2016 ** been invoked for this locking event. If the
2017 ** busy callback returns 0, then no additional attempts are made to
2018 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
2019 ** If the callback returns non-zero, then another attempt
2020 ** is made to open the database for reading and the cycle repeats.
2021 **
2022 ** The presence of a busy handler does not guarantee that it will be invoked
2023 ** when there is lock contention. If SQLite determines that invoking the busy
2024 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
2025 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
2026 ** Consider a scenario where one process is holding a read lock that
2027 ** it is trying to promote to a reserved lock and
2028 ** a second process is holding a reserved lock that it is trying
@@ -2032,69 +2062,63 @@
2032 ** invoke the busy handlers, neither will make any progress. Therefore,
2033 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
2034 ** will induce the first process to release its read lock and allow
2035 ** the second process to proceed.
2036 **
2037 ** The default busy callback is NULL.
2038 **
2039 ** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
2040 ** when SQLite is in the middle of a large transaction where all the
2041 ** changes will not fit into the in-memory cache. SQLite will
2042 ** already hold a RESERVED lock on the database file, but it needs
2043 ** to promote this lock to EXCLUSIVE so that it can spill cache
2044 ** pages into the database file without harm to concurrent
2045 ** readers. If it is unable to promote the lock, then the in-memory
2046 ** cache will be left in an inconsistent state and so the error
2047 ** code is promoted from the relatively benign [SQLITE_BUSY] to
2048 ** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion
2049 ** forces an automatic rollback of the changes. See the
2050 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
2051 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
2052 ** this is important.
2053 **
2054 ** There can only be a single busy handler defined for each
2055 ** [database connection]. Setting a new busy handler clears any
2056 ** previously set handler. Note that calling [sqlite3_busy_timeout()]
2057 ** will also set or clear the busy handler.
2058 **
2059 ** The busy callback should not take any actions which modify the
2060 ** database connection that invoked the busy handler. Any such actions
2061 ** result in undefined behavior.
2062 **
2063 ** Requirements:
2064 ** [H12311] [H12312] [H12314] [H12316] [H12318]
2065 **
2066 ** A busy handler must not close the database connection
2067 ** or [prepared statement] that invoked the busy handler.
2068 */
2069 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2070
2071 /*
2072 ** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
2073 **
2074 ** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2075 ** for a specified amount of time when a table is locked. The handler
2076 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2077 ** have accumulated. {H12343} After "ms" milliseconds of sleeping,
2078 ** the handler returns 0 which causes [sqlite3_step()] to return
2079 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
2080 **
2081 ** Calling this routine with an argument less than or equal to zero
2082 ** turns off all busy handlers.
2083 **
2084 ** There can only be a single busy handler for a particular
2085 ** [database connection] any any given moment. If another busy handler
2086 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2087 ** this routine, that other busy handler is cleared.
2088 **
2089 ** Requirements:
2090 ** [H12341] [H12343] [H12344]
2091 */
2092 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2093
2094 /*
2095 ** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
2096 **
2097 ** Definition: A <b>result table</b> is memory data structure created by the
2098 ** [sqlite3_get_table()] interface. A result table records the
2099 ** complete query results from one or more queries.
2100 **
@@ -2138,31 +2162,29 @@
2138 ** azResult&#91;5] = "28";
2139 ** azResult&#91;6] = "Cindy";
2140 ** azResult&#91;7] = "21";
2141 ** </pre></blockquote>
2142 **
2143 ** The sqlite3_get_table() function evaluates one or more
2144 ** semicolon-separated SQL statements in the zero-terminated UTF-8
2145 ** string of its 2nd parameter. It returns a result table to the
2146 ** pointer given in its 3rd parameter.
2147 **
2148 ** After the calling function has finished using the result, it should
2149 ** pass the pointer to the result table to sqlite3_free_table() in order to
2150 ** release the memory that was malloced. Because of the way the
2151 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
2152 ** function must not try to call [sqlite3_free()] directly. Only
2153 ** [sqlite3_free_table()] is able to release the memory properly and safely.
2154 **
2155 ** The sqlite3_get_table() interface is implemented as a wrapper around
2156 ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
2157 ** to any internal data structures of SQLite. It uses only the public
2158 ** interface defined here. As a consequence, errors that occur in the
2159 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2160 ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()].
2161 **
2162 ** Requirements:
2163 ** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
2164 */
2165 SQLITE_API int sqlite3_get_table(
2166 sqlite3 *db, /* An open database */
2167 const char *zSql, /* SQL to be evaluated */
2168 char ***pazResult, /* Results of the query */
@@ -2171,49 +2193,49 @@
2171 char **pzErrmsg /* Error msg written here */
2172 );
2173 SQLITE_API void sqlite3_free_table(char **result);
2174
2175 /*
2176 ** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
2177 **
2178 ** These routines are work-alikes of the "printf()" family of functions
2179 ** from the standard C library.
2180 **
2181 ** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
2182 ** results into memory obtained from [sqlite3_malloc()].
2183 ** The strings returned by these two routines should be
2184 ** released by [sqlite3_free()]. Both routines return a
2185 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
2186 ** memory to hold the resulting string.
2187 **
2188 ** In sqlite3_snprintf() routine is similar to "snprintf()" from
2189 ** the standard C library. The result is written into the
2190 ** buffer supplied as the second parameter whose size is given by
2191 ** the first parameter. Note that the order of the
2192 ** first two parameters is reversed from snprintf(). This is an
2193 ** historical accident that cannot be fixed without breaking
2194 ** backwards compatibility. Note also that sqlite3_snprintf()
2195 ** returns a pointer to its buffer instead of the number of
2196 ** characters actually written into the buffer. We admit that
2197 ** the number of characters written would be a more useful return
2198 ** value but we cannot change the implementation of sqlite3_snprintf()
2199 ** now without breaking compatibility.
2200 **
2201 ** As long as the buffer size is greater than zero, sqlite3_snprintf()
2202 ** guarantees that the buffer is always zero-terminated. The first
2203 ** parameter "n" is the total size of the buffer, including space for
2204 ** the zero terminator. So the longest string that can be completely
2205 ** written will be n-1 characters.
2206 **
2207 ** These routines all implement some additional formatting
2208 ** options that are useful for constructing SQL statements.
2209 ** All of the usual printf() formatting options apply. In addition, there
2210 ** is are "%q", "%Q", and "%z" options.
2211 **
2212 ** The %q option works like %s in that it substitutes a null-terminated
2213 ** string from the argument list. But %q also doubles every '\'' character.
2214 ** %q is designed for use inside a string literal. By doubling each '\''
2215 ** character it escapes that character and allows it to be inserted into
2216 ** the string.
2217 **
2218 ** For example, assume the string variable zText contains text as follows:
2219 **
@@ -2244,14 +2266,14 @@
2244 ** </pre></blockquote>
2245 **
2246 ** This second example is an SQL syntax error. As a general rule you should
2247 ** always use %q instead of %s when inserting text into a string literal.
2248 **
2249 ** The %Q option works like %q except it also adds single quotes around
2250 ** the outside of the total string. Additionally, if the parameter in the
2251 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
2252 ** single quotes) in place of the %Q option. So, for example, one could say:
2253 **
2254 ** <blockquote><pre>
2255 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
2256 ** sqlite3_exec(db, zSQL, 0, 0, 0);
2257 ** sqlite3_free(zSQL);
@@ -2258,75 +2280,63 @@
2258 ** </pre></blockquote>
2259 **
2260 ** The code above will render a correct SQL statement in the zSQL
2261 ** variable even if the zText variable is a NULL pointer.
2262 **
2263 ** The "%z" formatting option works exactly like "%s" with the
2264 ** addition that after the string has been read and copied into
2265 ** the result, [sqlite3_free()] is called on the input string. {END}
2266 **
2267 ** Requirements:
2268 ** [H17403] [H17406] [H17407]
2269 */
2270 SQLITE_API char *sqlite3_mprintf(const char*,...);
2271 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2272 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2273
2274 /*
2275 ** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
2276 **
2277 ** The SQLite core uses these three routines for all of its own
2278 ** internal memory allocation needs. "Core" in the previous sentence
2279 ** does not include operating-system specific VFS implementation. The
2280 ** Windows VFS uses native malloc() and free() for some operations.
2281 **
2282 ** The sqlite3_malloc() routine returns a pointer to a block
2283 ** of memory at least N bytes in length, where N is the parameter.
2284 ** If sqlite3_malloc() is unable to obtain sufficient free
2285 ** memory, it returns a NULL pointer. If the parameter N to
2286 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
2287 ** a NULL pointer.
2288 **
2289 ** Calling sqlite3_free() with a pointer previously returned
2290 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
2291 ** that it might be reused. The sqlite3_free() routine is
2292 ** a no-op if is called with a NULL pointer. Passing a NULL pointer
2293 ** to sqlite3_free() is harmless. After being freed, memory
2294 ** should neither be read nor written. Even reading previously freed
2295 ** memory might result in a segmentation fault or other severe error.
2296 ** Memory corruption, a segmentation fault, or other severe error
2297 ** might result if sqlite3_free() is called with a non-NULL pointer that
2298 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
2299 **
2300 ** The sqlite3_realloc() interface attempts to resize a
2301 ** prior memory allocation to be at least N bytes, where N is the
2302 ** second parameter. The memory allocation to be resized is the first
2303 ** parameter. If the first parameter to sqlite3_realloc()
2304 ** is a NULL pointer then its behavior is identical to calling
2305 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
2306 ** If the second parameter to sqlite3_realloc() is zero or
2307 ** negative then the behavior is exactly the same as calling
2308 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
2309 ** sqlite3_realloc() returns a pointer to a memory allocation
2310 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
2311 ** If M is the size of the prior allocation, then min(N,M) bytes
2312 ** of the prior allocation are copied into the beginning of buffer returned
2313 ** by sqlite3_realloc() and the prior allocation is freed.
2314 ** If sqlite3_realloc() returns NULL, then the prior allocation
2315 ** is not freed.
2316 **
2317 ** The memory returned by sqlite3_malloc() and sqlite3_realloc()
2318 ** is always aligned to at least an 8 byte boundary. {END}
2319 **
2320 ** The default implementation of the memory allocation subsystem uses
2321 ** the malloc(), realloc() and free() provided by the standard C library.
2322 ** {H17382} However, if SQLite is compiled with the
2323 ** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
2324 ** is an integer), then SQLite create a static array of at least
2325 ** <i>NNN</i> bytes in size and uses that array for all of its dynamic
2326 ** memory allocation needs. {END} Additional memory allocator options
2327 ** may be added in future releases.
2328 **
2329 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2330 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
2331 ** implementation of these routines to be omitted. That capability
2332 ** is no longer provided. Only built-in memory allocators can be used.
@@ -2337,14 +2347,10 @@
2337 ** and whatever filename encoding is used by the particular Windows
2338 ** installation. Memory allocation errors are detected, but
2339 ** they are reported back as [SQLITE_CANTOPEN] or
2340 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
2341 **
2342 ** Requirements:
2343 ** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
2344 ** [H17321] [H17322] [H17323]
2345 **
2346 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
2347 ** must be either NULL or else pointers obtained from a prior
2348 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
2349 ** not yet been released.
2350 **
@@ -2355,85 +2361,95 @@
2355 SQLITE_API void *sqlite3_malloc(int);
2356 SQLITE_API void *sqlite3_realloc(void*, int);
2357 SQLITE_API void sqlite3_free(void*);
2358
2359 /*
2360 ** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
2361 **
2362 ** SQLite provides these two interfaces for reporting on the status
2363 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
2364 ** routines, which form the built-in memory allocation subsystem.
2365 **
2366 ** Requirements:
2367 ** [H17371] [H17373] [H17374] [H17375]
 
 
 
 
 
 
 
 
 
 
 
 
 
2368 */
2369 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2370 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2371
2372 /*
2373 ** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
2374 **
2375 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
2376 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2377 ** already uses the largest possible [ROWID]. The PRNG is also used for
2378 ** the build-in random() and randomblob() SQL functions. This interface allows
2379 ** applications to access the same PRNG for other purposes.
2380 **
2381 ** A call to this routine stores N bytes of randomness into buffer P.
2382 **
2383 ** The first time this routine is invoked (either internally or by
2384 ** the application) the PRNG is seeded using randomness obtained
2385 ** from the xRandomness method of the default [sqlite3_vfs] object.
2386 ** On all subsequent invocations, the pseudo-randomness is generated
2387 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2388 ** method.
2389 **
2390 ** Requirements:
2391 ** [H17392]
2392 */
2393 SQLITE_API void sqlite3_randomness(int N, void *P);
2394
2395 /*
2396 ** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
2397 **
2398 ** This routine registers a authorizer callback with a particular
2399 ** [database connection], supplied in the first argument.
2400 ** The authorizer callback is invoked as SQL statements are being compiled
2401 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2402 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various
2403 ** points during the compilation process, as logic is being created
2404 ** to perform various actions, the authorizer callback is invoked to
2405 ** see if those actions are allowed. The authorizer callback should
2406 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2407 ** specific action but allow the SQL statement to continue to be
2408 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2409 ** rejected with an error. If the authorizer callback returns
2410 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2411 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2412 ** the authorizer will fail with an error message.
2413 **
2414 ** When the callback returns [SQLITE_OK], that means the operation
2415 ** requested is ok. When the callback returns [SQLITE_DENY], the
2416 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2417 ** authorizer will fail with an error message explaining that
2418 ** access is denied.
2419 **
2420 ** The first parameter to the authorizer callback is a copy of the third
2421 ** parameter to the sqlite3_set_authorizer() interface. The second parameter
2422 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2423 ** the particular action to be authorized. The third through sixth parameters
2424 ** to the callback are zero-terminated strings that contain additional
2425 ** details about the action to be authorized.
2426 **
2427 ** If the action code is [SQLITE_READ]
2428 ** and the callback returns [SQLITE_IGNORE] then the
2429 ** [prepared statement] statement is constructed to substitute
2430 ** a NULL value in place of the table column that would have
2431 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2432 ** return can be used to deny an untrusted user access to individual
2433 ** columns of a table.
2434 ** If the action code is [SQLITE_DELETE] and the callback returns
2435 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2436 ** [truncate optimization] is disabled and all rows are deleted individually.
2437 **
2438 ** An authorizer is used when [sqlite3_prepare | preparing]
2439 ** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -2449,43 +2465,39 @@
2449 ** Applications that need to process SQL from untrusted sources
2450 ** might also consider lowering resource limits using [sqlite3_limit()]
2451 ** and limiting database size using the [max_page_count] [PRAGMA]
2452 ** in addition to using an authorizer.
2453 **
2454 ** Only a single authorizer can be in place on a database connection
2455 ** at a time. Each call to sqlite3_set_authorizer overrides the
2456 ** previous call. Disable the authorizer by installing a NULL callback.
2457 ** The authorizer is disabled by default.
2458 **
2459 ** The authorizer callback must not do anything that will modify
2460 ** the database connection that invoked the authorizer callback.
2461 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2462 ** database connections for the meaning of "modify" in this paragraph.
2463 **
2464 ** When [sqlite3_prepare_v2()] is used to prepare a statement, the
2465 ** statement might be re-prepared during [sqlite3_step()] due to a
2466 ** schema change. Hence, the application should ensure that the
2467 ** correct authorizer callback remains in place during the [sqlite3_step()].
2468 **
2469 ** Note that the authorizer callback is invoked only during
2470 ** [sqlite3_prepare()] or its variants. Authorization is not
2471 ** performed during statement evaluation in [sqlite3_step()], unless
2472 ** as stated in the previous paragraph, sqlite3_step() invokes
2473 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2474 **
2475 ** Requirements:
2476 ** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
2477 ** [H12511] [H12512] [H12520] [H12521] [H12522]
2478 */
2479 SQLITE_API int sqlite3_set_authorizer(
2480 sqlite3*,
2481 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2482 void *pUserData
2483 );
2484
2485 /*
2486 ** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
2487 **
2488 ** The [sqlite3_set_authorizer | authorizer callback function] must
2489 ** return either [SQLITE_OK] or one of these two constants in order
2490 ** to signal SQLite whether or not the action is permitted. See the
2491 ** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -2493,11 +2505,11 @@
2493 */
2494 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
2495 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
2496
2497 /*
2498 ** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
2499 **
2500 ** The [sqlite3_set_authorizer()] interface registers a callback function
2501 ** that is invoked to authorize certain SQL statement actions. The
2502 ** second parameter to the callback is an integer code that specifies
2503 ** what action is being authorized. These are the integer action codes that
@@ -2504,19 +2516,16 @@
2504 ** the authorizer callback may be passed.
2505 **
2506 ** These action code values signify what kind of operation is to be
2507 ** authorized. The 3rd and 4th parameters to the authorization
2508 ** callback function will be parameters or NULL depending on which of these
2509 ** codes is used as the second parameter. The 5th parameter to the
2510 ** authorizer callback is the name of the database ("main", "temp",
2511 ** etc.) if applicable. The 6th parameter to the authorizer callback
2512 ** is the name of the inner-most trigger or view that is responsible for
2513 ** the access attempt or NULL if this access attempt is directly from
2514 ** top-level SQL code.
2515 **
2516 ** Requirements:
2517 ** [H12551] [H12552] [H12553] [H12554]
2518 */
2519 /******************************************* 3rd ************ 4th ***********/
2520 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
2521 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
2522 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2550,150 +2559,142 @@
2550 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2551 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2552 #define SQLITE_COPY 0 /* No longer used */
2553
2554 /*
2555 ** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
2556 ** EXPERIMENTAL
2557 **
2558 ** These routines register callback functions that can be used for
2559 ** tracing and profiling the execution of SQL statements.
2560 **
2561 ** The callback function registered by sqlite3_trace() is invoked at
2562 ** various times when an SQL statement is being run by [sqlite3_step()].
2563 ** The callback returns a UTF-8 rendering of the SQL statement text
2564 ** as the statement first begins executing. Additional callbacks occur
 
2565 ** as each triggered subprogram is entered. The callbacks for triggers
2566 ** contain a UTF-8 SQL comment that identifies the trigger.
2567 **
2568 ** The callback function registered by sqlite3_profile() is invoked
2569 ** as each SQL statement finishes. The profile callback contains
2570 ** the original statement text and an estimate of wall-clock time
2571 ** of how long that statement took to run.
2572 **
2573 ** Requirements:
2574 ** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
2575 ** [H12290]
2576 */
2577 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2578 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2579 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2580
2581 /*
2582 ** CAPI3REF: Query Progress Callbacks {H12910} <S60400>
2583 **
2584 ** This routine configures a callback function - the
2585 ** progress callback - that is invoked periodically during long
2586 ** running calls to [sqlite3_exec()], [sqlite3_step()] and
2587 ** [sqlite3_get_table()]. An example use for this
2588 ** interface is to keep a GUI updated during a large query.
2589 **
2590 ** If the progress callback returns non-zero, the operation is
2591 ** interrupted. This feature can be used to implement a
2592 ** "Cancel" button on a GUI progress dialog box.
2593 **
2594 ** The progress handler must not do anything that will modify
2595 ** the database connection that invoked the progress handler.
2596 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2597 ** database connections for the meaning of "modify" in this paragraph.
2598 **
2599 ** Requirements:
2600 ** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
2601 **
2602 */
2603 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2604
2605 /*
2606 ** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
2607 **
2608 ** These routines open an SQLite database file whose name is given by the
2609 ** filename argument. The filename argument is interpreted as UTF-8 for
2610 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2611 ** order for sqlite3_open16(). A [database connection] handle is usually
2612 ** returned in *ppDb, even if an error occurs. The only exception is that
2613 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
2614 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2615 ** object. If the database is opened (and/or created) successfully, then
2616 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The
2617 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2618 ** an English language description of the error.
 
2619 **
2620 ** The default encoding for the database will be UTF-8 if
2621 ** sqlite3_open() or sqlite3_open_v2() is called and
2622 ** UTF-16 in the native byte order if sqlite3_open16() is used.
2623 **
2624 ** Whether or not an error occurs when it is opened, resources
2625 ** associated with the [database connection] handle should be released by
2626 ** passing it to [sqlite3_close()] when it is no longer required.
2627 **
2628 ** The sqlite3_open_v2() interface works like sqlite3_open()
2629 ** except that it accepts two additional parameters for additional control
2630 ** over the new database connection. The flags parameter can take one of
 
2631 ** the following three values, optionally combined with the
2632 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2633 ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
2634 **
2635 ** <dl>
2636 ** <dt>[SQLITE_OPEN_READONLY]</dt>
2637 ** <dd>The database is opened in read-only mode. If the database does not
2638 ** already exist, an error is returned.</dd>
2639 **
2640 ** <dt>[SQLITE_OPEN_READWRITE]</dt>
2641 ** <dd>The database is opened for reading and writing if possible, or reading
2642 ** only if the file is write protected by the operating system. In either
2643 ** case the database must already exist, otherwise an error is returned.</dd>
2644 **
2645 ** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2646 ** <dd>The database is opened for reading and writing, and is creates it if
2647 ** it does not already exist. This is the behavior that is always used for
2648 ** sqlite3_open() and sqlite3_open16().</dd>
2649 ** </dl>
2650 **
2651 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
2652 ** combinations shown above or one of the combinations shown above combined
2653 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
2654 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
2655 ** then the behavior is undefined.
2656 **
2657 ** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2658 ** opens in the multi-thread [threading mode] as long as the single-thread
2659 ** mode has not been set at compile-time or start-time. If the
2660 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
2661 ** in the serialized [threading mode] unless single-thread was
2662 ** previously selected at compile-time or start-time.
2663 ** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2664 ** eligible to use [shared cache mode], regardless of whether or not shared
2665 ** cache is enabled using [sqlite3_enable_shared_cache()]. The
2666 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2667 ** participate in [shared cache mode] even if it is enabled.
2668 **
2669 ** If the filename is ":memory:", then a private, temporary in-memory database
2670 ** is created for the connection. This in-memory database will vanish when
2671 ** the database connection is closed. Future versions of SQLite might
2672 ** make use of additional special filenames that begin with the ":" character.
2673 ** It is recommended that when a database filename actually does begin with
2674 ** a ":" character you should prefix the filename with a pathname such as
2675 ** "./" to avoid ambiguity.
2676 **
2677 ** If the filename is an empty string, then a private, temporary
2678 ** on-disk database will be created. This private database will be
2679 ** automatically deleted as soon as the database connection is closed.
2680 **
2681 ** The fourth parameter to sqlite3_open_v2() is the name of the
2682 ** [sqlite3_vfs] object that defines the operating system interface that
2683 ** the new database connection should use. If the fourth parameter is
2684 ** a NULL pointer then the default [sqlite3_vfs] object is used.
2685 **
2686 ** <b>Note to Windows users:</b> The encoding used for the filename argument
2687 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2688 ** codepage is currently defined. Filenames containing international
2689 ** characters must be converted to UTF-8 prior to passing them into
2690 ** sqlite3_open() or sqlite3_open_v2().
2691 **
2692 ** Requirements:
2693 ** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
2694 ** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
2695 */
2696 SQLITE_API int sqlite3_open(
2697 const char *filename, /* Database filename (UTF-8) */
2698 sqlite3 **ppDb /* OUT: SQLite db handle */
2699 );
@@ -2707,27 +2708,27 @@
2707 int flags, /* Flags */
2708 const char *zVfs /* Name of VFS module to use */
2709 );
2710
2711 /*
2712 ** CAPI3REF: Error Codes And Messages {H12800} <S60200>
2713 **
2714 ** The sqlite3_errcode() interface returns the numeric [result code] or
2715 ** [extended result code] for the most recent failed sqlite3_* API call
2716 ** associated with a [database connection]. If a prior API call failed
2717 ** but the most recent API call succeeded, the return value from
2718 ** sqlite3_errcode() is undefined. The sqlite3_extended_errcode()
2719 ** interface is the same except that it always returns the
2720 ** [extended result code] even when extended result codes are
2721 ** disabled.
2722 **
2723 ** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2724 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
2725 ** Memory to hold the error message string is managed internally.
2726 ** The application does not need to worry about freeing the result.
2727 ** However, the error string might be overwritten or deallocated by
2728 ** subsequent calls to other SQLite interface functions.
2729 **
2730 ** When the serialized [threading mode] is in use, it might be the
2731 ** case that a second error occurs on a separate thread in between
2732 ** the time of the first error and the call to these interfaces.
2733 ** When that happens, the second error will be reported since these
@@ -2738,21 +2739,18 @@
2738 ** all calls to the interfaces listed here are completed.
2739 **
2740 ** If an interface fails with SQLITE_MISUSE, that means the interface
2741 ** was invoked incorrectly by the application. In that case, the
2742 ** error code and message may or may not be set.
2743 **
2744 ** Requirements:
2745 ** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
2746 */
2747 SQLITE_API int sqlite3_errcode(sqlite3 *db);
2748 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
2749 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
2750 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
2751
2752 /*
2753 ** CAPI3REF: SQL Statement Object {H13000} <H13010>
2754 ** KEYWORDS: {prepared statement} {prepared statements}
2755 **
2756 ** An instance of this object represents a single SQL statement.
2757 ** This object is variously known as a "prepared statement" or a
2758 ** "compiled SQL statement" or simply as a "statement".
@@ -2774,29 +2772,29 @@
2774 ** information.
2775 */
2776 typedef struct sqlite3_stmt sqlite3_stmt;
2777
2778 /*
2779 ** CAPI3REF: Run-time Limits {H12760} <S20600>
2780 **
2781 ** This interface allows the size of various constructs to be limited
2782 ** on a connection by connection basis. The first parameter is the
2783 ** [database connection] whose limit is to be set or queried. The
2784 ** second parameter is one of the [limit categories] that define a
2785 ** class of constructs to be size limited. The third parameter is the
2786 ** new limit for that construct. The function returns the old limit.
2787 **
2788 ** If the new limit is a negative number, the limit is unchanged.
2789 ** For the limit category of SQLITE_LIMIT_XYZ there is a
2790 ** [limits | hard upper bound]
2791 ** set by a compile-time C preprocessor macro named
2792 ** [limits | SQLITE_MAX_XYZ].
2793 ** (The "_LIMIT_" in the name is changed to "_MAX_".)
2794 ** Attempts to increase a limit above its hard upper bound are
2795 ** silently truncated to the hard upper limit.
2796 **
2797 ** Run time limits are intended for use in applications that manage
2798 ** both their own internal database and also databases that are controlled
2799 ** by untrusted external sources. An example application might be a
2800 ** web browser that has its own databases for storing history and
2801 ** separate databases controlled by JavaScript applications downloaded
2802 ** off the Internet. The internal databases can be given the
@@ -2806,63 +2804,60 @@
2806 ** interface to further control untrusted SQL. The size of the database
2807 ** created by an untrusted script can be contained using the
2808 ** [max_page_count] [PRAGMA].
2809 **
2810 ** New run-time limit categories may be added in future releases.
2811 **
2812 ** Requirements:
2813 ** [H12762] [H12766] [H12769]
2814 */
2815 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2816
2817 /*
2818 ** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
2819 ** KEYWORDS: {limit category} {*limit categories}
2820 **
2821 ** These constants define various performance limits
2822 ** that can be lowered at run-time using [sqlite3_limit()].
2823 ** The synopsis of the meanings of the various limits is shown below.
2824 ** Additional information is available at [limits | Limits in SQLite].
2825 **
2826 ** <dl>
2827 ** <dt>SQLITE_LIMIT_LENGTH</dt>
2828 ** <dd>The maximum size of any string or BLOB or table row.<dd>
2829 **
2830 ** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2831 ** <dd>The maximum length of an SQL statement.</dd>
2832 **
2833 ** <dt>SQLITE_LIMIT_COLUMN</dt>
2834 ** <dd>The maximum number of columns in a table definition or in the
2835 ** result set of a [SELECT] or the maximum number of columns in an index
2836 ** or in an ORDER BY or GROUP BY clause.</dd>
2837 **
2838 ** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2839 ** <dd>The maximum depth of the parse tree on any expression.</dd>
2840 **
2841 ** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2842 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>
2843 **
2844 ** <dt>SQLITE_LIMIT_VDBE_OP</dt>
2845 ** <dd>The maximum number of instructions in a virtual machine program
2846 ** used to implement an SQL statement.</dd>
2847 **
2848 ** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2849 ** <dd>The maximum number of arguments on a function.</dd>
2850 **
2851 ** <dt>SQLITE_LIMIT_ATTACHED</dt>
2852 ** <dd>The maximum number of [ATTACH | attached databases].</dd>
2853 **
2854 ** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2855 ** <dd>The maximum length of the pattern argument to the [LIKE] or
2856 ** [GLOB] operators.</dd>
2857 **
2858 ** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2859 ** <dd>The maximum number of variables in an SQL statement that can
2860 ** be bound.</dd>
2861 **
2862 ** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2863 ** <dd>The maximum depth of recursion for triggers.</dd>
2864 ** </dl>
2865 */
2866 #define SQLITE_LIMIT_LENGTH 0
2867 #define SQLITE_LIMIT_SQL_LENGTH 1
2868 #define SQLITE_LIMIT_COLUMN 2
@@ -2874,11 +2869,11 @@
2874 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
2875 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
2876 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
2877
2878 /*
2879 ** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
2880 ** KEYWORDS: {SQL statement compiler}
2881 **
2882 ** To execute an SQL query, it must first be compiled into a byte-code
2883 ** program using one of these routines.
2884 **
@@ -2889,61 +2884,62 @@
2889 ** The second argument, "zSql", is the statement to be compiled, encoded
2890 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2891 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2892 ** use UTF-16.
2893 **
2894 ** If the nByte argument is less than zero, then zSql is read up to the
2895 ** first zero terminator. If nByte is non-negative, then it is the maximum
2896 ** number of bytes read from zSql. When nByte is non-negative, the
2897 ** zSql string ends at either the first '\000' or '\u0000' character or
2898 ** the nByte-th byte, whichever comes first. If the caller knows
2899 ** that the supplied string is nul-terminated, then there is a small
2900 ** performance advantage to be gained by passing an nByte parameter that
2901 ** is equal to the number of bytes in the input string <i>including</i>
2902 ** the nul-terminator bytes.
2903 **
2904 ** If pzTail is not NULL then *pzTail is made to point to the first byte
2905 ** past the end of the first SQL statement in zSql. These routines only
2906 ** compile the first statement in zSql, so *pzTail is left pointing to
2907 ** what remains uncompiled.
2908 **
2909 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2910 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2911 ** to NULL. If the input text contains no SQL (if the input is an empty
2912 ** string or a comment) then *ppStmt is set to NULL.
2913 ** The calling procedure is responsible for deleting the compiled
2914 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2915 ** ppStmt may not be NULL.
2916 **
2917 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
 
2918 **
2919 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2920 ** recommended for all new programs. The two older interfaces are retained
2921 ** for backwards compatibility, but their use is discouraged.
2922 ** In the "v2" interfaces, the prepared statement
2923 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
2924 ** original SQL text. This causes the [sqlite3_step()] interface to
2925 ** behave differently in three ways:
2926 **
2927 ** <ol>
2928 ** <li>
2929 ** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2930 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
2931 ** statement and try to run it again. If the schema has changed in
2932 ** a way that makes the statement no longer valid, [sqlite3_step()] will still
2933 ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
2934 ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
2935 ** error go away. Note: use [sqlite3_errmsg()] to find the text
2936 ** of the parsing error that results in an [SQLITE_SCHEMA] return.
2937 ** </li>
2938 **
2939 ** <li>
2940 ** When an error occurs, [sqlite3_step()] will return one of the detailed
2941 ** [error codes] or [extended error codes]. The legacy behavior was that
2942 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2943 ** and you would have to make a second call to [sqlite3_reset()] in order
2944 ** to find the underlying cause of the problem. With the "v2" prepare
2945 ** interfaces, the underlying reason for the error is returned immediately.
2946 ** </li>
2947 **
2948 ** <li>
2949 ** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2951,14 +2947,10 @@
2951 ** automatically recompiled (as if there had been a schema change) on the first
2952 ** [sqlite3_step()] call following any change to the
2953 ** [sqlite3_bind_text | bindings] of the [parameter].
2954 ** </li>
2955 ** </ol>
2956 **
2957 ** Requirements:
2958 ** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
2959 **
2960 */
2961 SQLITE_API int sqlite3_prepare(
2962 sqlite3 *db, /* Database handle */
2963 const char *zSql, /* SQL statement, UTF-8 encoded */
2964 int nByte, /* Maximum length of zSql in bytes. */
@@ -2986,28 +2978,25 @@
2986 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
2987 const void **pzTail /* OUT: Pointer to unused portion of zSql */
2988 );
2989
2990 /*
2991 ** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
2992 **
2993 ** This interface can be used to retrieve a saved copy of the original
2994 ** SQL text used to create a [prepared statement] if that statement was
2995 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
2996 **
2997 ** Requirements:
2998 ** [H13101] [H13102] [H13103]
2999 */
3000 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3001
3002 /*
3003 ** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
3004 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3005 **
3006 ** SQLite uses the sqlite3_value object to represent all values
3007 ** that can be stored in a database table. SQLite uses dynamic typing
3008 ** for the values it stores. Values stored in sqlite3_value objects
3009 ** can be integers, floating point values, strings, BLOBs, or NULL.
3010 **
3011 ** An sqlite3_value object may be either "protected" or "unprotected".
3012 ** Some interfaces require a protected sqlite3_value. Other interfaces
3013 ** will accept either a protected or an unprotected sqlite3_value.
@@ -3025,26 +3014,26 @@
3025 ** sqlite3_value objects and they can be used interchangeably. However,
3026 ** for maximum code portability it is recommended that applications
3027 ** still make the distinction between between protected and unprotected
3028 ** sqlite3_value objects even when not strictly required.
3029 **
3030 ** The sqlite3_value objects that are passed as parameters into the
3031 ** implementation of [application-defined SQL functions] are protected.
3032 ** The sqlite3_value object returned by
3033 ** [sqlite3_column_value()] is unprotected.
3034 ** Unprotected sqlite3_value objects may only be used with
3035 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
3036 ** The [sqlite3_value_blob | sqlite3_value_type()] family of
3037 ** interfaces require protected sqlite3_value objects.
3038 */
3039 typedef struct Mem sqlite3_value;
3040
3041 /*
3042 ** CAPI3REF: SQL Function Context Object {H16001} <S20200>
3043 **
3044 ** The context in which an SQL function executes is stored in an
3045 ** sqlite3_context object. A pointer to an sqlite3_context object
3046 ** is always first parameter to [application-defined SQL functions].
3047 ** The application-defined SQL function implementation will pass this
3048 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
3049 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
3050 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -3051,15 +3040,15 @@
3051 ** and/or [sqlite3_set_auxdata()].
3052 */
3053 typedef struct sqlite3_context sqlite3_context;
3054
3055 /*
3056 ** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
3057 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3058 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3059 **
3060 ** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
3061 ** literals may be replaced by a [parameter] that matches one of following
3062 ** templates:
3063 **
3064 ** <ul>
3065 ** <li> ?
@@ -3068,76 +3057,70 @@
3068 ** <li> @VVV
3069 ** <li> $VVV
3070 ** </ul>
3071 **
3072 ** In the templates above, NNN represents an integer literal,
3073 ** and VVV represents an alphanumeric identifer. The values of these
3074 ** parameters (also called "host parameter names" or "SQL parameters")
3075 ** can be set using the sqlite3_bind_*() routines defined here.
3076 **
3077 ** The first argument to the sqlite3_bind_*() routines is always
3078 ** a pointer to the [sqlite3_stmt] object returned from
3079 ** [sqlite3_prepare_v2()] or its variants.
3080 **
3081 ** The second argument is the index of the SQL parameter to be set.
3082 ** The leftmost SQL parameter has an index of 1. When the same named
3083 ** SQL parameter is used more than once, second and subsequent
3084 ** occurrences have the same index as the first occurrence.
3085 ** The index for named parameters can be looked up using the
3086 ** [sqlite3_bind_parameter_index()] API if desired. The index
3087 ** for "?NNN" parameters is the value of NNN.
3088 ** The NNN value must be between 1 and the [sqlite3_limit()]
3089 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
3090 **
3091 ** The third argument is the value to bind to the parameter.
3092 **
3093 ** In those routines that have a fourth argument, its value is the
3094 ** number of bytes in the parameter. To be clear: the value is the
3095 ** number of <u>bytes</u> in the value, not the number of characters.
3096 ** If the fourth parameter is negative, the length of the string is
3097 ** the number of bytes up to the first zero terminator.
3098 **
3099 ** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
3100 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
3101 ** string after SQLite has finished with it. If the fifth argument is
3102 ** the special value [SQLITE_STATIC], then SQLite assumes that the
3103 ** information is in static, unmanaged space and does not need to be freed.
3104 ** If the fifth argument has the value [SQLITE_TRANSIENT], then
3105 ** SQLite makes its own private copy of the data immediately, before
3106 ** the sqlite3_bind_*() routine returns.
3107 **
3108 ** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
3109 ** is filled with zeroes. A zeroblob uses a fixed amount of memory
3110 ** (just an integer to hold its size) while it is being processed.
3111 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
3112 ** content is later written using
3113 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
3114 ** A negative value for the zeroblob results in a zero-length BLOB.
3115 **
3116 ** The sqlite3_bind_*() routines must be called after
3117 ** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
3118 ** before [sqlite3_step()].
3119 ** Bindings are not cleared by the [sqlite3_reset()] routine.
3120 ** Unbound parameters are interpreted as NULL.
3121 **
3122 ** These routines return [SQLITE_OK] on success or an error code if
3123 ** anything goes wrong. [SQLITE_RANGE] is returned if the parameter
3124 ** index is out of range. [SQLITE_NOMEM] is returned if malloc() fails.
3125 ** [SQLITE_MISUSE] might be returned if these routines are called on a
3126 ** virtual machine that is the wrong state or which has already been finalized.
3127 ** Detection of misuse is unreliable. Applications should not depend
3128 ** on SQLITE_MISUSE returns. SQLITE_MISUSE is intended to indicate a
3129 ** a logic error in the application. Future versions of SQLite might
3130 ** panic rather than return SQLITE_MISUSE.
3131 **
3132 ** See also: [sqlite3_bind_parameter_count()],
3133 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3134 **
3135 ** Requirements:
3136 ** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
3137 ** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
3138 **
3139 */
3140 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3141 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3142 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3143 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -3146,175 +3129,155 @@
3146 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3147 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3148 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3149
3150 /*
3151 ** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
3152 **
3153 ** This routine can be used to find the number of [SQL parameters]
3154 ** in a [prepared statement]. SQL parameters are tokens of the
3155 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3156 ** placeholders for values that are [sqlite3_bind_blob | bound]
3157 ** to the parameters at a later time.
3158 **
3159 ** This routine actually returns the index of the largest (rightmost)
3160 ** parameter. For all forms except ?NNN, this will correspond to the
3161 ** number of unique parameters. If parameters of the ?NNN are used,
3162 ** there may be gaps in the list.
3163 **
3164 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3165 ** [sqlite3_bind_parameter_name()], and
3166 ** [sqlite3_bind_parameter_index()].
3167 **
3168 ** Requirements:
3169 ** [H13601]
3170 */
3171 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3172
3173 /*
3174 ** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
3175 **
3176 ** This routine returns a pointer to the name of the n-th
3177 ** [SQL parameter] in a [prepared statement].
3178 ** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3179 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
3180 ** respectively.
3181 ** In other words, the initial ":" or "$" or "@" or "?"
3182 ** is included as part of the name.
3183 ** Parameters of the form "?" without a following integer have no name
3184 ** and are also referred to as "anonymous parameters".
3185 **
3186 ** The first host parameter has an index of 1, not 0.
3187 **
3188 ** If the value n is out of range or if the n-th parameter is
3189 ** nameless, then NULL is returned. The returned string is
3190 ** always in UTF-8 encoding even if the named parameter was
3191 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
3192 ** [sqlite3_prepare16_v2()].
3193 **
3194 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3195 ** [sqlite3_bind_parameter_count()], and
3196 ** [sqlite3_bind_parameter_index()].
3197 **
3198 ** Requirements:
3199 ** [H13621]
3200 */
3201 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3202
3203 /*
3204 ** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
3205 **
3206 ** Return the index of an SQL parameter given its name. The
3207 ** index value returned is suitable for use as the second
3208 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero
3209 ** is returned if no matching parameter is found. The parameter
3210 ** name must be given in UTF-8 even if the original statement
3211 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
3212 **
3213 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3214 ** [sqlite3_bind_parameter_count()], and
3215 ** [sqlite3_bind_parameter_index()].
3216 **
3217 ** Requirements:
3218 ** [H13641]
3219 */
3220 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3221
3222 /*
3223 ** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
3224 **
3225 ** Contrary to the intuition of many, [sqlite3_reset()] does not reset
3226 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3227 ** Use this routine to reset all host parameters to NULL.
3228 **
3229 ** Requirements:
3230 ** [H13661]
3231 */
3232 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3233
3234 /*
3235 ** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
3236 **
3237 ** Return the number of columns in the result set returned by the
3238 ** [prepared statement]. This routine returns 0 if pStmt is an SQL
3239 ** statement that does not return data (for example an [UPDATE]).
3240 **
3241 ** Requirements:
3242 ** [H13711]
3243 */
3244 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3245
3246 /*
3247 ** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
3248 **
3249 ** These routines return the name assigned to a particular column
3250 ** in the result set of a [SELECT] statement. The sqlite3_column_name()
3251 ** interface returns a pointer to a zero-terminated UTF-8 string
3252 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
3253 ** UTF-16 string. The first parameter is the [prepared statement]
3254 ** that implements the [SELECT] statement. The second parameter is the
3255 ** column number. The leftmost column is number 0.
3256 **
3257 ** The returned string pointer is valid until either the [prepared statement]
3258 ** is destroyed by [sqlite3_finalize()] or until the next call to
3259 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
3260 **
3261 ** If sqlite3_malloc() fails during the processing of either routine
3262 ** (for example during a conversion from UTF-8 to UTF-16) then a
3263 ** NULL pointer is returned.
3264 **
3265 ** The name of a result column is the value of the "AS" clause for
3266 ** that column, if there is an AS clause. If there is no AS clause
3267 ** then the name of the column is unspecified and may change from
3268 ** one release of SQLite to the next.
3269 **
3270 ** Requirements:
3271 ** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
3272 */
3273 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3274 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3275
3276 /*
3277 ** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
3278 **
3279 ** These routines provide a means to determine what column of what
3280 ** table in which database a result of a [SELECT] statement comes from.
3281 ** The name of the database or table or column can be returned as
3282 ** either a UTF-8 or UTF-16 string. The _database_ routines return
 
3283 ** the database name, the _table_ routines return the table name, and
3284 ** the origin_ routines return the column name.
3285 ** The returned string is valid until the [prepared statement] is destroyed
3286 ** using [sqlite3_finalize()] or until the same information is requested
3287 ** again in a different encoding.
3288 **
3289 ** The names returned are the original un-aliased names of the
3290 ** database, table, and column.
3291 **
3292 ** The first argument to the following calls is a [prepared statement].
3293 ** These functions return information about the Nth column returned by
3294 ** the statement, where N is the second function argument.
 
3295 **
3296 ** If the Nth column returned by the statement is an expression or
3297 ** subquery and is not a column value, then all of these functions return
3298 ** NULL. These routine might also return NULL if a memory allocation error
3299 ** occurs. Otherwise, they return the name of the attached database, table
3300 ** and column that query result column was extracted from.
3301 **
3302 ** As with all other SQLite APIs, those postfixed with "16" return
3303 ** UTF-16 encoded strings, the other functions return UTF-8. {END}
3304 **
3305 ** These APIs are only available if the library was compiled with the
3306 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
3307 **
3308 ** {A13751}
3309 ** If two or more threads call one or more of these routines against the same
3310 ** prepared statement and column at the same time then the results are
3311 ** undefined.
3312 **
3313 ** Requirements:
3314 ** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
3315 **
3316 ** If two or more threads call one or more
3317 ** [sqlite3_column_database_name | column metadata interfaces]
3318 ** for the same [prepared statement] and result column
3319 ** at the same time then the results are undefined.
3320 */
@@ -3324,46 +3287,43 @@
3324 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3325 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3326 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3327
3328 /*
3329 ** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
3330 **
3331 ** The first parameter is a [prepared statement].
3332 ** If this statement is a [SELECT] statement and the Nth column of the
3333 ** returned result set of that [SELECT] is a table column (not an
3334 ** expression or subquery) then the declared type of the table
3335 ** column is returned. If the Nth column of the result set is an
3336 ** expression or subquery, then a NULL pointer is returned.
3337 ** The returned string is always UTF-8 encoded. {END}
3338 **
3339 ** For example, given the database schema:
3340 **
3341 ** CREATE TABLE t1(c1 VARIANT);
3342 **
3343 ** and the following statement to be compiled:
3344 **
3345 ** SELECT c1 + 1, c1 FROM t1;
3346 **
3347 ** this routine would return the string "VARIANT" for the second result
3348 ** column (i==1), and a NULL pointer for the first result column (i==0).
3349 **
3350 ** SQLite uses dynamic run-time typing. So just because a column
3351 ** is declared to contain a particular type does not mean that the
3352 ** data stored in that column is of the declared type. SQLite is
3353 ** strongly typed, but the typing is dynamic not static. Type
3354 ** is associated with individual values, not with the containers
3355 ** used to hold those values.
3356 **
3357 ** Requirements:
3358 ** [H13761] [H13762] [H13763]
3359 */
3360 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3361 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3362
3363 /*
3364 ** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
3365 **
3366 ** After a [prepared statement] has been prepared using either
3367 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3368 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3369 ** must be called one or more times to evaluate the statement.
@@ -3373,39 +3333,39 @@
3373 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
3374 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
3375 ** new "v2" interface is recommended for new applications but the legacy
3376 ** interface will continue to be supported.
3377 **
3378 ** In the legacy interface, the return value will be either [SQLITE_BUSY],
3379 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
3380 ** With the "v2" interface, any of the other [result codes] or
3381 ** [extended result codes] might be returned as well.
3382 **
3383 ** [SQLITE_BUSY] means that the database engine was unable to acquire the
3384 ** database locks it needs to do its job. If the statement is a [COMMIT]
3385 ** or occurs outside of an explicit transaction, then you can retry the
3386 ** statement. If the statement is not a [COMMIT] and occurs within a
3387 ** explicit transaction then you should rollback the transaction before
3388 ** continuing.
3389 **
3390 ** [SQLITE_DONE] means that the statement has finished executing
3391 ** successfully. sqlite3_step() should not be called again on this virtual
3392 ** machine without first calling [sqlite3_reset()] to reset the virtual
3393 ** machine back to its initial state.
3394 **
3395 ** If the SQL statement being executed returns any data, then [SQLITE_ROW]
3396 ** is returned each time a new row of data is ready for processing by the
3397 ** caller. The values may be accessed using the [column access functions].
3398 ** sqlite3_step() is called again to retrieve the next row of data.
3399 **
3400 ** [SQLITE_ERROR] means that a run-time error (such as a constraint
3401 ** violation) has occurred. sqlite3_step() should not be called again on
3402 ** the VM. More information may be found by calling [sqlite3_errmsg()].
3403 ** With the legacy interface, a more specific error code (for example,
3404 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
3405 ** can be obtained by calling [sqlite3_reset()] on the
3406 ** [prepared statement]. In the "v2" interface,
3407 ** the more specific error code is returned directly by sqlite3_step().
3408 **
3409 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
3410 ** Perhaps it was called on a [prepared statement] that has
3411 ** already been [sqlite3_finalize | finalized] or on one that had
@@ -3422,39 +3382,34 @@
3422 ** with the "v2" interface. If you prepare all of your SQL statements
3423 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3424 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3425 ** then the more specific [error codes] are returned directly
3426 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3427 **
3428 ** Requirements:
3429 ** [H13202] [H15304] [H15306] [H15308] [H15310]
3430 */
3431 SQLITE_API int sqlite3_step(sqlite3_stmt*);
3432
3433 /*
3434 ** CAPI3REF: Number of columns in a result set {H13770} <S10700>
3435 **
3436 ** Returns the number of values in the current row of the result set.
3437 **
3438 ** Requirements:
3439 ** [H13771] [H13772]
3440 */
3441 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3442
3443 /*
3444 ** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
3445 ** KEYWORDS: SQLITE_TEXT
3446 **
3447 ** {H10266} Every value in SQLite has one of five fundamental datatypes:
3448 **
3449 ** <ul>
3450 ** <li> 64-bit signed integer
3451 ** <li> 64-bit IEEE floating point number
3452 ** <li> string
3453 ** <li> BLOB
3454 ** <li> NULL
3455 ** </ul> {END}
3456 **
3457 ** These constants are codes for each of those types.
3458 **
3459 ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
3460 ** for a completely different meaning. Software that links against both
@@ -3471,22 +3426,22 @@
3471 # define SQLITE_TEXT 3
3472 #endif
3473 #define SQLITE3_TEXT 3
3474
3475 /*
3476 ** CAPI3REF: Result Values From A Query {H13800} <S10700>
3477 ** KEYWORDS: {column access functions}
3478 **
3479 ** These routines form the "result set query" interface.
3480 **
3481 ** These routines return information about a single column of the current
3482 ** result row of a query. In every case the first argument is a pointer
3483 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
3484 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
3485 ** and the second argument is the index of the column for which information
3486 ** should be returned. The leftmost column of the result set has the index 0.
3487 ** The number of columns in the result can be determined using
3488 ** [sqlite3_column_count()].
3489 **
3490 ** If the SQL statement does not currently point to a valid row, or if the
3491 ** column index is out of range, the result is undefined.
3492 ** These routines may only be called when the most recent call to
@@ -3497,52 +3452,52 @@
3497 ** something other than [SQLITE_ROW], the results are undefined.
3498 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
3499 ** are called from a different thread while any of these routines
3500 ** are pending, then the results are undefined.
3501 **
3502 ** The sqlite3_column_type() routine returns the
3503 ** [SQLITE_INTEGER | datatype code] for the initial data type
3504 ** of the result column. The returned value is one of [SQLITE_INTEGER],
3505 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
3506 ** returned by sqlite3_column_type() is only meaningful if no type
3507 ** conversions have occurred as described below. After a type conversion,
3508 ** the value returned by sqlite3_column_type() is undefined. Future
3509 ** versions of SQLite may change the behavior of sqlite3_column_type()
3510 ** following a type conversion.
3511 **
3512 ** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
3513 ** routine returns the number of bytes in that BLOB or string.
3514 ** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
3515 ** the string to UTF-8 and then returns the number of bytes.
3516 ** If the result is a numeric value then sqlite3_column_bytes() uses
3517 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
3518 ** the number of bytes in that string.
3519 ** The value returned does not include the zero terminator at the end
3520 ** of the string. For clarity: the value returned is the number of
3521 ** bytes in the string, not the number of characters.
3522 **
3523 ** Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3524 ** even empty strings, are always zero terminated. The return
3525 ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
3526 ** pointer, possibly even a NULL pointer.
3527 **
3528 ** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
3529 ** but leaves the result in UTF-16 in native byte order instead of UTF-8.
3530 ** The zero terminator is not included in this count.
3531 **
3532 ** The object returned by [sqlite3_column_value()] is an
3533 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
3534 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
3535 ** If the [unprotected sqlite3_value] object returned by
3536 ** [sqlite3_column_value()] is used in any other way, including calls
3537 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
3538 ** or [sqlite3_value_bytes()], then the behavior is undefined.
3539 **
3540 ** These routines attempt to convert the value where appropriate. For
3541 ** example, if the internal representation is FLOAT and a text result
3542 ** is requested, [sqlite3_snprintf()] is used internally to perform the
3543 ** conversion automatically. The following table details the conversions
3544 ** that are applied:
3545 **
3546 ** <blockquote>
3547 ** <table border="1">
3548 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3562,22 +3517,22 @@
3562 ** <tr><td> TEXT <td> BLOB <td> No change
3563 ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
3564 ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
3565 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
3566 ** </table>
3567 ** </blockquote>
3568 **
3569 ** The table above makes reference to standard C library functions atoi()
3570 ** and atof(). SQLite does not really use these functions. It has its
3571 ** own equivalent internal routines. The atoi() and atof() names are
3572 ** used in the table for brevity and because they are familiar to most
3573 ** C programmers.
3574 **
3575 ** Note that when type conversions occur, pointers returned by prior
3576 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
3577 ** sqlite3_column_text16() may be invalidated.
3578 ** Type conversions and pointer invalidations might occur
3579 ** in the following cases:
3580 **
3581 ** <ul>
3582 ** <li> The initial content is a BLOB and sqlite3_column_text() or
3583 ** sqlite3_column_text16() is called. A zero-terminator might
@@ -3586,51 +3541,47 @@
3586 ** sqlite3_column_text16() is called. The content must be converted
3587 ** to UTF-16.</li>
3588 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
3589 ** sqlite3_column_text() is called. The content must be converted
3590 ** to UTF-8.</li>
3591 ** </ul>
3592 **
3593 ** Conversions between UTF-16be and UTF-16le are always done in place and do
3594 ** not invalidate a prior pointer, though of course the content of the buffer
3595 ** that the prior pointer points to will have been modified. Other kinds
3596 ** of conversion are done in place when it is possible, but sometimes they
3597 ** are not possible and in those cases prior pointers are invalidated.
3598 **
3599 ** The safest and easiest to remember policy is to invoke these routines
3600 ** in one of the following ways:
3601 **
3602 ** <ul>
3603 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
3604 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
3605 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3606 ** </ul>
3607 **
3608 ** In other words, you should call sqlite3_column_text(),
3609 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
3610 ** into the desired format, then invoke sqlite3_column_bytes() or
3611 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
3612 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
3613 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
3614 ** with calls to sqlite3_column_bytes().
3615 **
3616 ** The pointers returned are valid until a type conversion occurs as
3617 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3618 ** [sqlite3_finalize()] is called. The memory space used to hold strings
3619 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
3620 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3621 ** [sqlite3_free()].
3622 **
3623 ** If a memory allocation error occurs during the evaluation of any
3624 ** of these routines, a default value is returned. The default value
3625 ** is either the integer 0, the floating point number 0.0, or a NULL
3626 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
3627 ** [SQLITE_NOMEM].
3628 **
3629 ** Requirements:
3630 ** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
3631 ** [H13827] [H13830]
3632 */
3633 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
3634 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
3635 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
3636 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3640,139 +3591,132 @@
3640 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
3641 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
3642 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3643
3644 /*
3645 ** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
3646 **
3647 ** The sqlite3_finalize() function is called to delete a [prepared statement].
3648 ** If the statement was executed successfully or not executed at all, then
3649 ** SQLITE_OK is returned. If execution of the statement failed then an
3650 ** [error code] or [extended error code] is returned.
3651 **
3652 ** This routine can be called at any point during the execution of the
3653 ** [prepared statement]. If the virtual machine has not
3654 ** completed execution when this routine is called, that is like
3655 ** encountering an error or an [sqlite3_interrupt | interrupt].
3656 ** Incomplete updates may be rolled back and transactions canceled,
3657 ** depending on the circumstances, and the
3658 ** [error code] returned will be [SQLITE_ABORT].
3659 **
3660 ** Requirements:
3661 ** [H11302] [H11304]
3662 */
3663 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
3664
3665 /*
3666 ** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
3667 **
3668 ** The sqlite3_reset() function is called to reset a [prepared statement]
3669 ** object back to its initial state, ready to be re-executed.
3670 ** Any SQL statement variables that had values bound to them using
3671 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
3672 ** Use [sqlite3_clear_bindings()] to reset the bindings.
3673 **
3674 ** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
3675 ** back to the beginning of its program.
3676 **
3677 ** {H11334} If the most recent call to [sqlite3_step(S)] for the
3678 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3679 ** or if [sqlite3_step(S)] has never before been called on S,
3680 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
3681 **
3682 ** {H11336} If the most recent call to [sqlite3_step(S)] for the
3683 ** [prepared statement] S indicated an error, then
3684 ** [sqlite3_reset(S)] returns an appropriate [error code].
3685 **
3686 ** {H11338} The [sqlite3_reset(S)] interface does not change the values
3687 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3688 */
3689 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3690
3691 /*
3692 ** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
3693 ** KEYWORDS: {function creation routines}
3694 ** KEYWORDS: {application-defined SQL function}
3695 ** KEYWORDS: {application-defined SQL functions}
3696 **
3697 ** These two functions (collectively known as "function creation routines")
3698 ** are used to add SQL functions or aggregates or to redefine the behavior
3699 ** of existing SQL functions or aggregates. The only difference between the
3700 ** two is that the second parameter, the name of the (scalar) function or
3701 ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
3702 ** for sqlite3_create_function16().
3703 **
3704 ** The first parameter is the [database connection] to which the SQL
3705 ** function is to be added. If a single program uses more than one database
3706 ** connection internally, then SQL functions must be added individually to
3707 ** each database connection.
3708 **
3709 ** The second parameter is the name of the SQL function to be created or
3710 ** redefined. The length of the name is limited to 255 bytes, exclusive of
3711 ** the zero-terminator. Note that the name length limit is in bytes, not
3712 ** characters. Any attempt to create a function with a longer name
3713 ** will result in [SQLITE_ERROR] being returned.
3714 **
3715 ** The third parameter (nArg)
3716 ** is the number of arguments that the SQL function or
3717 ** aggregate takes. If this parameter is -1, then the SQL function or
3718 ** aggregate may take any number of arguments between 0 and the limit
3719 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
3720 ** parameter is less than -1 or greater than 127 then the behavior is
3721 ** undefined.
3722 **
3723 ** The fourth parameter, eTextRep, specifies what
3724 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
3725 ** its parameters. Any SQL function implementation should be able to work
3726 ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3727 ** more efficient with one encoding than another. An application may
3728 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
3729 ** times with the same function but with different values of eTextRep.
3730 ** When multiple implementations of the same function are available, SQLite
3731 ** will pick the one that involves the least amount of data conversion.
3732 ** If there is only a single implementation which does not care what text
3733 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
3734 **
3735 ** The fifth parameter is an arbitrary pointer. The implementation of the
3736 ** function can gain access to this pointer using [sqlite3_user_data()].
3737 **
3738 ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
3739 ** pointers to C-language functions that implement the SQL function or
3740 ** aggregate. A scalar SQL function requires an implementation of the xFunc
3741 ** callback only, NULL pointers should be passed as the xStep and xFinal
3742 ** parameters. An aggregate SQL function requires an implementation of xStep
3743 ** and xFinal and NULL should be passed for xFunc. To delete an existing
3744 ** SQL function or aggregate, pass NULL for all three function callbacks.
3745 **
3746 ** It is permitted to register multiple implementations of the same
3747 ** functions with the same name but with either differing numbers of
3748 ** arguments or differing preferred text encodings. SQLite will use
3749 ** the implementation that most closely matches the way in which the
3750 ** SQL function is used. A function implementation with a non-negative
3751 ** nArg parameter is a better match than a function implementation with
3752 ** a negative nArg. A function where the preferred text encoding
3753 ** matches the database encoding is a better
3754 ** match than a function where the encoding is different.
3755 ** A function where the encoding difference is between UTF16le and UTF16be
3756 ** is a closer match than a function where the encoding difference is
3757 ** between UTF8 and UTF16.
3758 **
3759 ** Built-in functions may be overloaded by new application-defined functions.
3760 ** The first application-defined function with a given name overrides all
3761 ** built-in functions in the same [database connection] with the same name.
3762 ** Subsequent application-defined functions of the same name only override
3763 ** prior application-defined functions that are an exact match for the
3764 ** number of parameters and preferred encoding.
3765 **
3766 ** An application-defined function is permitted to call other
3767 ** SQLite interfaces. However, such calls must not
3768 ** close the database connection nor finalize or reset the prepared
3769 ** statement in which the function is running.
3770 **
3771 ** Requirements:
3772 ** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
3773 ** [H16130] [H16133] [H16136] [H16139] [H16142]
3774 */
3775 SQLITE_API int sqlite3_create_function(
3776 sqlite3 *db,
3777 const char *zFunctionName,
3778 int nArg,
@@ -3792,11 +3736,11 @@
3792 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
3793 void (*xFinal)(sqlite3_context*)
3794 );
3795
3796 /*
3797 ** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
3798 **
3799 ** These constant define integer codes that represent the various
3800 ** text encodings supported by SQLite.
3801 */
3802 #define SQLITE_UTF8 1
@@ -3824,11 +3768,11 @@
3824 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
3825 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
3826 #endif
3827
3828 /*
3829 ** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
3830 **
3831 ** The C-language implementation of SQL functions and aggregates uses
3832 ** this set of interface routines to access the parameter values on
3833 ** the function or aggregate.
3834 **
@@ -3842,39 +3786,35 @@
3842 **
3843 ** These routines work only with [protected sqlite3_value] objects.
3844 ** Any attempt to use these routines on an [unprotected sqlite3_value]
3845 ** object results in undefined behavior.
3846 **
3847 ** These routines work just like the corresponding [column access functions]
3848 ** except that these routines take a single [protected sqlite3_value] object
3849 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
3850 **
3851 ** The sqlite3_value_text16() interface extracts a UTF-16 string
3852 ** in the native byte-order of the host machine. The
3853 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
3854 ** extract UTF-16 strings as big-endian and little-endian respectively.
3855 **
3856 ** The sqlite3_value_numeric_type() interface attempts to apply
3857 ** numeric affinity to the value. This means that an attempt is
3858 ** made to convert the value to an integer or floating point. If
3859 ** such a conversion is possible without loss of information (in other
3860 ** words, if the value is a string that looks like a number)
3861 ** then the conversion is performed. Otherwise no conversion occurs.
3862 ** The [SQLITE_INTEGER | datatype] after conversion is returned.
3863 **
3864 ** Please pay particular attention to the fact that the pointer returned
3865 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
3866 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
3867 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
3868 ** or [sqlite3_value_text16()].
3869 **
3870 ** These routines must be called from the same thread as
3871 ** the SQL function that supplied the [sqlite3_value*] parameters.
3872 **
3873 ** Requirements:
3874 ** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
3875 ** [H15127] [H15130] [H15133] [H15136]
3876 */
3877 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
3878 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
3879 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
3880 SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3886,70 +3826,77 @@
3886 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
3887 SQLITE_API int sqlite3_value_type(sqlite3_value*);
3888 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
3889
3890 /*
3891 ** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
3892 **
3893 ** The implementation of aggregate SQL functions use this routine to allocate
3894 ** a structure for storing their state.
3895 **
3896 ** The first time the sqlite3_aggregate_context() routine is called for a
3897 ** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
3898 ** memory, and returns a pointer to it. On second and subsequent calls to
3899 ** sqlite3_aggregate_context() for the same aggregate function index,
3900 ** the same buffer is returned. The implementation of the aggregate can use
3901 ** the returned buffer to accumulate data.
3902 **
3903 ** SQLite automatically frees the allocated buffer when the aggregate
3904 ** query concludes.
3905 **
3906 ** The first parameter should be a copy of the
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3907 ** [sqlite3_context | SQL function context] that is the first parameter
3908 ** to the callback routine that implements the aggregate function.
 
3909 **
3910 ** This routine must be called from the same thread in which
3911 ** the aggregate SQL function is running.
3912 **
3913 ** Requirements:
3914 ** [H16211] [H16213] [H16215] [H16217]
3915 */
3916 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
3917
3918 /*
3919 ** CAPI3REF: User Data For Functions {H16240} <S20200>
3920 **
3921 ** The sqlite3_user_data() interface returns a copy of
3922 ** the pointer that was the pUserData parameter (the 5th parameter)
3923 ** of the [sqlite3_create_function()]
3924 ** and [sqlite3_create_function16()] routines that originally
3925 ** registered the application defined function. {END}
3926 **
3927 ** This routine must be called from the same thread in which
3928 ** the application-defined function is running.
3929 **
3930 ** Requirements:
3931 ** [H16243]
3932 */
3933 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
3934
3935 /*
3936 ** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
3937 **
3938 ** The sqlite3_context_db_handle() interface returns a copy of
3939 ** the pointer to the [database connection] (the 1st parameter)
3940 ** of the [sqlite3_create_function()]
3941 ** and [sqlite3_create_function16()] routines that originally
3942 ** registered the application defined function.
3943 **
3944 ** Requirements:
3945 ** [H16253]
3946 */
3947 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
3948
3949 /*
3950 ** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
3951 **
3952 ** The following two functions may be used by scalar SQL functions to
3953 ** associate metadata with argument values. If the same value is passed to
3954 ** multiple invocations of the same SQL function during query execution, under
3955 ** some circumstances the associated metadata may be preserved. This may
@@ -3958,52 +3905,49 @@
3958 ** metadata associated with the SQL value passed as the regular expression
3959 ** pattern. The compiled regular expression can be reused on multiple
3960 ** invocations of the same function so that the original pattern string
3961 ** does not need to be recompiled on each invocation.
3962 **
3963 ** The sqlite3_get_auxdata() interface returns a pointer to the metadata
3964 ** associated by the sqlite3_set_auxdata() function with the Nth argument
3965 ** value to the application-defined function. If no metadata has been ever
3966 ** been set for the Nth argument of the function, or if the corresponding
3967 ** function parameter has changed since the meta-data was set,
3968 ** then sqlite3_get_auxdata() returns a NULL pointer.
3969 **
3970 ** The sqlite3_set_auxdata() interface saves the metadata
3971 ** pointed to by its 3rd parameter as the metadata for the N-th
3972 ** argument of the application-defined function. Subsequent
3973 ** calls to sqlite3_get_auxdata() might return this data, if it has
3974 ** not been destroyed.
3975 ** If it is not NULL, SQLite will invoke the destructor
3976 ** function given by the 4th parameter to sqlite3_set_auxdata() on
3977 ** the metadata when the corresponding function parameter changes
3978 ** or when the SQL statement completes, whichever comes first.
3979 **
3980 ** SQLite is free to call the destructor and drop metadata on any
3981 ** parameter of any function at any time. The only guarantee is that
3982 ** the destructor will be called before the metadata is dropped.
3983 **
3984 ** In practice, metadata is preserved between function calls for
3985 ** expressions that are constant at compile time. This includes literal
3986 ** values and SQL variables.
3987 **
3988 ** These routines must be called from the same thread in which
3989 ** the SQL function is running.
3990 **
3991 ** Requirements:
3992 ** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
3993 */
3994 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
3995 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
3996
3997
3998 /*
3999 ** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
4000 **
4001 ** These are special values for the destructor that is passed in as the
4002 ** final argument to routines like [sqlite3_result_blob()]. If the destructor
4003 ** argument is SQLITE_STATIC, it means that the content pointer is constant
4004 ** and will never change. It does not need to be destroyed. The
4005 ** SQLITE_TRANSIENT value means that the content will likely change in
4006 ** the near future and that SQLite should make its own private copy of
4007 ** the content before returning.
4008 **
4009 ** The typedef is necessary to work around problems in certain
@@ -4012,11 +3956,11 @@
4012 typedef void (*sqlite3_destructor_type)(void*);
4013 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4014 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4015
4016 /*
4017 ** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
4018 **
4019 ** These routines are used by the xFunc or xFinal callbacks that
4020 ** implement SQL functions and aggregates. See
4021 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4022 ** for additional information.
@@ -4023,107 +3967,102 @@
4023 **
4024 ** These functions work very much like the [parameter binding] family of
4025 ** functions used to bind values to host parameters in prepared statements.
4026 ** Refer to the [SQL parameter] documentation for additional information.
4027 **
4028 ** The sqlite3_result_blob() interface sets the result from
4029 ** an application-defined function to be the BLOB whose content is pointed
4030 ** to by the second parameter and which is N bytes long where N is the
4031 ** third parameter.
4032 **
4033 ** The sqlite3_result_zeroblob() interfaces set the result of
4034 ** the application-defined function to be a BLOB containing all zero
4035 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
4036 **
4037 ** The sqlite3_result_double() interface sets the result from
4038 ** an application-defined function to be a floating point value specified
4039 ** by its 2nd argument.
4040 **
4041 ** The sqlite3_result_error() and sqlite3_result_error16() functions
4042 ** cause the implemented SQL function to throw an exception.
4043 ** SQLite uses the string pointed to by the
4044 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
4045 ** as the text of an error message. SQLite interprets the error
4046 ** message string from sqlite3_result_error() as UTF-8. SQLite
4047 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
4048 ** byte order. If the third parameter to sqlite3_result_error()
4049 ** or sqlite3_result_error16() is negative then SQLite takes as the error
4050 ** message all text up through the first zero character.
4051 ** If the third parameter to sqlite3_result_error() or
4052 ** sqlite3_result_error16() is non-negative then SQLite takes that many
4053 ** bytes (not characters) from the 2nd parameter as the error message.
4054 ** The sqlite3_result_error() and sqlite3_result_error16()
4055 ** routines make a private copy of the error message text before
4056 ** they return. Hence, the calling function can deallocate or
4057 ** modify the text after they return without harm.
4058 ** The sqlite3_result_error_code() function changes the error code
4059 ** returned by SQLite as a result of an error in a function. By default,
4060 ** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error()
4061 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
4062 **
4063 ** The sqlite3_result_toobig() interface causes SQLite to throw an error
4064 ** indicating that a string or BLOB is to long to represent.
4065 **
4066 ** The sqlite3_result_nomem() interface causes SQLite to throw an error
4067 ** indicating that a memory allocation failed.
4068 **
4069 ** The sqlite3_result_int() interface sets the return value
4070 ** of the application-defined function to be the 32-bit signed integer
4071 ** value given in the 2nd argument.
4072 ** The sqlite3_result_int64() interface sets the return value
4073 ** of the application-defined function to be the 64-bit signed integer
4074 ** value given in the 2nd argument.
4075 **
4076 ** The sqlite3_result_null() interface sets the return value
4077 ** of the application-defined function to be NULL.
4078 **
4079 ** The sqlite3_result_text(), sqlite3_result_text16(),
4080 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
4081 ** set the return value of the application-defined function to be
4082 ** a text string which is represented as UTF-8, UTF-16 native byte order,
4083 ** UTF-16 little endian, or UTF-16 big endian, respectively.
4084 ** SQLite takes the text result from the application from
4085 ** the 2nd parameter of the sqlite3_result_text* interfaces.
4086 ** If the 3rd parameter to the sqlite3_result_text* interfaces
4087 ** is negative, then SQLite takes result text from the 2nd parameter
4088 ** through the first zero character.
4089 ** If the 3rd parameter to the sqlite3_result_text* interfaces
4090 ** is non-negative, then as many bytes (not characters) of the text
4091 ** pointed to by the 2nd parameter are taken as the application-defined
4092 ** function result.
4093 ** If the 4th parameter to the sqlite3_result_text* interfaces
4094 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
4095 ** function as the destructor on the text or BLOB result when it has
4096 ** finished using that result.
4097 ** If the 4th parameter to the sqlite3_result_text* interfaces or to
4098 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
4099 ** assumes that the text or BLOB result is in constant space and does not
4100 ** copy the content of the parameter nor call a destructor on the content
4101 ** when it has finished using that result.
4102 ** If the 4th parameter to the sqlite3_result_text* interfaces
4103 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
4104 ** then SQLite makes a copy of the result into space obtained from
4105 ** from [sqlite3_malloc()] before it returns.
4106 **
4107 ** The sqlite3_result_value() interface sets the result of
4108 ** the application-defined function to be a copy the
4109 ** [unprotected sqlite3_value] object specified by the 2nd parameter. The
4110 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
4111 ** so that the [sqlite3_value] specified in the parameter may change or
4112 ** be deallocated after sqlite3_result_value() returns without harm.
4113 ** A [protected sqlite3_value] object may always be used where an
4114 ** [unprotected sqlite3_value] object is required, so either
4115 ** kind of [sqlite3_value] object can be used with this interface.
4116 **
4117 ** If these routines are called from within the different thread
4118 ** than the one containing the application-defined function that received
4119 ** the [sqlite3_context] pointer, the results are undefined.
4120 **
4121 ** Requirements:
4122 ** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
4123 ** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
4124 ** [H16451] [H16454] [H16457] [H16460] [H16463]
4125 */
4126 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4127 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4128 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4129 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -4139,58 +4078,54 @@
4139 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4140 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4141 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4142
4143 /*
4144 ** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
4145 **
4146 ** These functions are used to add new collation sequences to the
4147 ** [database connection] specified as the first argument.
4148 **
4149 ** The name of the new collation sequence is specified as a UTF-8 string
4150 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
4151 ** and a UTF-16 string for sqlite3_create_collation16(). In all cases
4152 ** the name is passed as the second function argument.
4153 **
4154 ** The third argument may be one of the constants [SQLITE_UTF8],
4155 ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
4156 ** routine expects to be passed pointers to strings encoded using UTF-8,
4157 ** UTF-16 little-endian, or UTF-16 big-endian, respectively. The
4158 ** third argument might also be [SQLITE_UTF16] to indicate that the routine
4159 ** expects pointers to be UTF-16 strings in the native byte order, or the
4160 ** argument can be [SQLITE_UTF16_ALIGNED] if the
4161 ** the routine expects pointers to 16-bit word aligned strings
4162 ** of UTF-16 in the native byte order.
4163 **
4164 ** A pointer to the user supplied routine must be passed as the fifth
4165 ** argument. If it is NULL, this is the same as deleting the collation
4166 ** sequence (so that SQLite cannot call it anymore).
4167 ** Each time the application supplied function is invoked, it is passed
4168 ** as its first parameter a copy of the void* passed as the fourth argument
4169 ** to sqlite3_create_collation() or sqlite3_create_collation16().
4170 **
4171 ** The remaining arguments to the application-supplied routine are two strings,
4172 ** each represented by a (length, data) pair and encoded in the encoding
4173 ** that was passed as the third argument when the collation sequence was
4174 ** registered. {END} The application defined collation routine should
4175 ** return negative, zero or positive if the first string is less than,
4176 ** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
4177 **
4178 ** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
4179 ** except that it takes an extra argument which is a destructor for
4180 ** the collation. The destructor is called when the collation is
4181 ** destroyed and is passed a copy of the fourth parameter void* pointer
4182 ** of the sqlite3_create_collation_v2().
4183 ** Collations are destroyed when they are overridden by later calls to the
4184 ** collation creation functions or when the [database connection] is closed
4185 ** using [sqlite3_close()].
4186 **
4187 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4188 **
4189 ** Requirements:
4190 ** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
4191 ** [H16624] [H16627] [H16630]
4192 */
4193 SQLITE_API int sqlite3_create_collation(
4194 sqlite3*,
4195 const char *zName,
4196 int eTextRep,
@@ -4212,37 +4147,34 @@
4212 void*,
4213 int(*xCompare)(void*,int,const void*,int,const void*)
4214 );
4215
4216 /*
4217 ** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
4218 **
4219 ** To avoid having to register all collation sequences before a database
4220 ** can be used, a single callback function may be registered with the
4221 ** [database connection] to be called whenever an undefined collation
4222 ** sequence is required.
4223 **
4224 ** If the function is registered using the sqlite3_collation_needed() API,
4225 ** then it is passed the names of undefined collation sequences as strings
4226 ** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
4227 ** the names are passed as UTF-16 in machine native byte order.
4228 ** A call to either function replaces any existing callback.
4229 **
4230 ** When the callback is invoked, the first argument passed is a copy
4231 ** of the second argument to sqlite3_collation_needed() or
4232 ** sqlite3_collation_needed16(). The second argument is the database
4233 ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
4234 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
4235 ** sequence function required. The fourth parameter is the name of the
4236 ** required collation sequence.
4237 **
4238 ** The callback function should register the desired collation using
4239 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4240 ** [sqlite3_create_collation_v2()].
4241 **
4242 ** Requirements:
4243 ** [H16702] [H16704] [H16706]
4244 */
4245 SQLITE_API int sqlite3_collation_needed(
4246 sqlite3*,
4247 void*,
4248 void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -4277,33 +4209,32 @@
4277 sqlite3 *db, /* Database to be rekeyed */
4278 const void *pKey, int nKey /* The new key */
4279 );
4280
4281 /*
4282 ** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
4283 **
4284 ** The sqlite3_sleep() function causes the current thread to suspend execution
4285 ** for at least a number of milliseconds specified in its parameter.
4286 **
4287 ** If the operating system does not support sleep requests with
4288 ** millisecond time resolution, then the time will be rounded up to
4289 ** the nearest second. The number of milliseconds of sleep actually
4290 ** requested from the operating system is returned.
4291 **
4292 ** SQLite implements this interface by calling the xSleep()
4293 ** method of the default [sqlite3_vfs] object.
4294 **
4295 ** Requirements: [H10533] [H10536]
4296 */
4297 SQLITE_API int sqlite3_sleep(int);
4298
4299 /*
4300 ** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
4301 **
4302 ** If this global variable is made to point to a string which is
4303 ** the name of a folder (a.k.a. directory), then all temporary files
4304 ** created by SQLite will be placed in that directory. If this variable
 
4305 ** is a NULL pointer, then SQLite performs a search for an appropriate
4306 ** temporary file directory.
4307 **
4308 ** It is not safe to read or modify this variable in more than one
4309 ** thread at a time. It is not safe to read or modify this variable
@@ -4312,12 +4243,12 @@
4312 ** It is intended that this variable be set once
4313 ** as part of process initialization and before any SQLite interface
4314 ** routines have been called and that this variable remain unchanged
4315 ** thereafter.
4316 **
4317 ** The [temp_store_directory pragma] may modify this variable and cause
4318 ** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
4319 ** the [temp_store_directory pragma] always assumes that any string
4320 ** that this variable points to is held in memory obtained from
4321 ** [sqlite3_malloc] and the pragma may attempt to free that memory
4322 ** using [sqlite3_free].
4323 ** Hence, if this variable is modified directly, either it should be
@@ -4325,18 +4256,18 @@
4325 ** or else the use of the [temp_store_directory pragma] should be avoided.
4326 */
4327 SQLITE_API char *sqlite3_temp_directory;
4328
4329 /*
4330 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
4331 ** KEYWORDS: {autocommit mode}
4332 **
4333 ** The sqlite3_get_autocommit() interface returns non-zero or
4334 ** zero if the given database connection is or is not in autocommit mode,
4335 ** respectively. Autocommit mode is on by default.
4336 ** Autocommit mode is disabled by a [BEGIN] statement.
4337 ** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
4338 **
4339 ** If certain kinds of errors occur on a statement within a multi-statement
4340 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
4341 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
4342 ** transaction might be rolled back automatically. The only way to
@@ -4344,124 +4275,116 @@
4344 ** an error is to use this function.
4345 **
4346 ** If another thread changes the autocommit status of the database
4347 ** connection while this routine is running, then the return value
4348 ** is undefined.
4349 **
4350 ** Requirements: [H12931] [H12932] [H12933] [H12934]
4351 */
4352 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4353
4354 /*
4355 ** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
4356 **
4357 ** The sqlite3_db_handle interface returns the [database connection] handle
4358 ** to which a [prepared statement] belongs. The [database connection]
4359 ** returned by sqlite3_db_handle is the same [database connection] that was the first argument
 
4360 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4361 ** create the statement in the first place.
4362 **
4363 ** Requirements: [H13123]
4364 */
4365 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4366
4367 /*
4368 ** CAPI3REF: Find the next prepared statement {H13140} <S60600>
4369 **
4370 ** This interface returns a pointer to the next [prepared statement] after
4371 ** pStmt associated with the [database connection] pDb. If pStmt is NULL
4372 ** then this interface returns a pointer to the first prepared statement
4373 ** associated with the database connection pDb. If no prepared statement
4374 ** satisfies the conditions of this routine, it returns NULL.
4375 **
4376 ** The [database connection] pointer D in a call to
4377 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4378 ** connection and in particular must not be a NULL pointer.
4379 **
4380 ** Requirements: [H13143] [H13146] [H13149] [H13152]
4381 */
4382 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4383
4384 /*
4385 ** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
4386 **
4387 ** The sqlite3_commit_hook() interface registers a callback
4388 ** function to be invoked whenever a transaction is [COMMIT | committed].
4389 ** Any callback set by a previous call to sqlite3_commit_hook()
4390 ** for the same database connection is overridden.
4391 ** The sqlite3_rollback_hook() interface registers a callback
4392 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
4393 ** Any callback set by a previous call to sqlite3_commit_hook()
4394 ** for the same database connection is overridden.
4395 ** The pArg argument is passed through to the callback.
4396 ** If the callback on a commit hook function returns non-zero,
4397 ** then the commit is converted into a rollback.
4398 **
4399 ** If another function was previously registered, its
4400 ** pArg value is returned. Otherwise NULL is returned.
 
 
4401 **
4402 ** The callback implementation must not do anything that will modify
4403 ** the database connection that invoked the callback. Any actions
4404 ** to modify the database connection must be deferred until after the
4405 ** completion of the [sqlite3_step()] call that triggered the commit
4406 ** or rollback hook in the first place.
4407 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4408 ** database connections for the meaning of "modify" in this paragraph.
4409 **
4410 ** Registering a NULL function disables the callback.
4411 **
4412 ** When the commit hook callback routine returns zero, the [COMMIT]
4413 ** operation is allowed to continue normally. If the commit hook
4414 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
4415 ** The rollback hook is invoked on a rollback that results from a commit
4416 ** hook returning non-zero, just as it would be with any other rollback.
4417 **
4418 ** For the purposes of this API, a transaction is said to have been
4419 ** rolled back if an explicit "ROLLBACK" statement is executed, or
4420 ** an error or constraint causes an implicit rollback to occur.
4421 ** The rollback callback is not invoked if a transaction is
4422 ** automatically rolled back because the database connection is closed.
4423 ** The rollback callback is not invoked if a transaction is
4424 ** rolled back because a commit callback returned non-zero.
4425 ** <todo> Check on this </todo>
4426 **
4427 ** See also the [sqlite3_update_hook()] interface.
4428 **
4429 ** Requirements:
4430 ** [H12951] [H12952] [H12953] [H12954] [H12955]
4431 ** [H12961] [H12962] [H12963] [H12964]
4432 */
4433 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
4434 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
4435
4436 /*
4437 ** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
4438 **
4439 ** The sqlite3_update_hook() interface registers a callback function
4440 ** with the [database connection] identified by the first argument
4441 ** to be invoked whenever a row is updated, inserted or deleted.
4442 ** Any callback set by a previous call to this function
4443 ** for the same database connection is overridden.
4444 **
4445 ** The second argument is a pointer to the function to invoke when a
4446 ** row is updated, inserted or deleted.
4447 ** The first argument to the callback is a copy of the third argument
4448 ** to sqlite3_update_hook().
4449 ** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
4450 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
4451 ** to be invoked.
4452 ** The third and fourth arguments to the callback contain pointers to the
4453 ** database and table name containing the affected row.
4454 ** The final callback parameter is the [rowid] of the row.
4455 ** In the case of an update, this is the [rowid] after the update takes place.
4456 **
4457 ** The update hook is not invoked when internal system tables are
4458 ** modified (i.e. sqlite_master and sqlite_sequence).
4459 **
4460 ** In the current implementation, the update hook
4461 ** is not invoked when duplication rows are deleted because of an
4462 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook
4463 ** invoked when rows are deleted using the [truncate optimization].
4464 ** The exceptions defined in this paragraph might change in a future
4465 ** release of SQLite.
4466 **
4467 ** The update hook implementation must not do anything that will modify
@@ -4469,169 +4392,157 @@
4469 ** to modify the database connection must be deferred until after the
4470 ** completion of the [sqlite3_step()] call that triggered the update hook.
4471 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4472 ** database connections for the meaning of "modify" in this paragraph.
4473 **
4474 ** If another function was previously registered, its pArg value
4475 ** is returned. Otherwise NULL is returned.
 
 
4476 **
4477 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
4478 ** interfaces.
4479 **
4480 ** Requirements:
4481 ** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
4482 */
4483 SQLITE_API void *sqlite3_update_hook(
4484 sqlite3*,
4485 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
4486 void*
4487 );
4488
4489 /*
4490 ** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
4491 ** KEYWORDS: {shared cache}
4492 **
4493 ** This routine enables or disables the sharing of the database cache
4494 ** and schema data structures between [database connection | connections]
4495 ** to the same database. Sharing is enabled if the argument is true
4496 ** and disabled if the argument is false.
4497 **
4498 ** Cache sharing is enabled and disabled for an entire process.
4499 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
4500 ** sharing was enabled or disabled for each thread separately.
4501 **
4502 ** The cache sharing mode set by this interface effects all subsequent
4503 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
4504 ** Existing database connections continue use the sharing mode
4505 ** that was in effect at the time they were opened.
4506 **
4507 ** Virtual tables cannot be used with a shared cache. When shared
4508 ** cache is enabled, the [sqlite3_create_module()] API used to register
4509 ** virtual tables will always return an error.
4510 **
4511 ** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
4512 ** successfully. An [error code] is returned otherwise.
4513 **
4514 ** Shared cache is disabled by default. But this might change in
4515 ** future releases of SQLite. Applications that care about shared
4516 ** cache setting should set it explicitly.
4517 **
4518 ** See Also: [SQLite Shared-Cache Mode]
4519 **
4520 ** Requirements: [H10331] [H10336] [H10337] [H10339]
4521 */
4522 SQLITE_API int sqlite3_enable_shared_cache(int);
4523
4524 /*
4525 ** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
4526 **
4527 ** The sqlite3_release_memory() interface attempts to free N bytes
4528 ** of heap memory by deallocating non-essential memory allocations
4529 ** held by the database library. {END} Memory used to cache database
4530 ** pages to improve performance is an example of non-essential memory.
4531 ** sqlite3_release_memory() returns the number of bytes actually freed,
4532 ** which might be more or less than the amount requested.
4533 **
4534 ** Requirements: [H17341] [H17342]
4535 */
4536 SQLITE_API int sqlite3_release_memory(int);
4537
4538 /*
4539 ** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
4540 **
4541 ** The sqlite3_soft_heap_limit() interface places a "soft" limit
4542 ** on the amount of heap memory that may be allocated by SQLite.
4543 ** If an internal allocation is requested that would exceed the
4544 ** soft heap limit, [sqlite3_release_memory()] is invoked one or
4545 ** more times to free up some space before the allocation is performed.
4546 **
4547 ** The limit is called "soft", because if [sqlite3_release_memory()]
4548 ** cannot free sufficient memory to prevent the limit from being exceeded,
4549 ** the memory is allocated anyway and the current operation proceeds.
4550 **
4551 ** A negative or zero value for N means that there is no soft heap limit and
4552 ** [sqlite3_release_memory()] will only be called when memory is exhausted.
4553 ** The default value for the soft heap limit is zero.
4554 **
4555 ** SQLite makes a best effort to honor the soft heap limit.
4556 ** But if the soft heap limit cannot be honored, execution will
4557 ** continue without error or notification. This is why the limit is
4558 ** called a "soft" limit. It is advisory only.
4559 **
4560 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
4561 ** allocated by a single thread - the same thread in which this routine
4562 ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
4563 ** applied to all threads. The value specified for the soft heap limit
4564 ** is an upper bound on the total memory allocation for all threads. In
4565 ** version 3.5.0 there is no mechanism for limiting the heap usage for
4566 ** individual threads.
4567 **
4568 ** Requirements:
4569 ** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
4570 */
4571 SQLITE_API void sqlite3_soft_heap_limit(int);
4572
4573 /*
4574 ** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
4575 **
4576 ** This routine returns metadata about a specific column of a specific
4577 ** database table accessible using the [database connection] handle
4578 ** passed as the first function argument.
4579 **
4580 ** The column is identified by the second, third and fourth parameters to
4581 ** this function. The second parameter is either the name of the database
4582 ** (i.e. "main", "temp" or an attached database) containing the specified
4583 ** table or NULL. If it is NULL, then all attached databases are searched
4584 ** for the table using the same algorithm used by the database engine to
4585 ** resolve unqualified table references.
4586 **
4587 ** The third and fourth parameters to this function are the table and column
4588 ** name of the desired column, respectively. Neither of these parameters
4589 ** may be NULL.
4590 **
4591 ** Metadata is returned by writing to the memory locations passed as the 5th
4592 ** and subsequent parameters to this function. Any of these arguments may be
4593 ** NULL, in which case the corresponding element of metadata is omitted.
4594 **
4595 ** <blockquote>
4596 ** <table border="1">
4597 ** <tr><th> Parameter <th> Output<br>Type <th> Description
4598 **
4599 ** <tr><td> 5th <td> const char* <td> Data type
4600 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
4601 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
4602 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
4603 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
4604 ** </table>
4605 ** </blockquote>
4606 **
4607 ** The memory pointed to by the character pointers returned for the
4608 ** declaration type and collation sequence is valid only until the next
4609 ** call to any SQLite API function.
4610 **
4611 ** If the specified table is actually a view, an [error code] is returned.
4612 **
4613 ** If the specified column is "rowid", "oid" or "_rowid_" and an
4614 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4615 ** parameters are set for the explicitly declared column. If there is no
4616 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
4617 ** parameters are set as follows:
4618 **
4619 ** <pre>
4620 ** data type: "INTEGER"
4621 ** collation sequence: "BINARY"
4622 ** not null: 0
4623 ** primary key: 1
4624 ** auto increment: 0
4625 ** </pre>
4626 **
4627 ** This function may load one or more schemas from database files. If an
4628 ** error occurs during this process, or if the requested table or column
4629 ** cannot be found, an [error code] is returned and an error message left
4630 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).
4631 **
4632 ** This API is only available if the library was compiled with the
4633 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
4634 */
4635 SQLITE_API int sqlite3_table_column_metadata(
4636 sqlite3 *db, /* Connection handle */
4637 const char *zDbName, /* Database name or NULL */
@@ -4643,34 +4554,31 @@
4643 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
4644 int *pAutoinc /* OUTPUT: True if column is auto-increment */
4645 );
4646
4647 /*
4648 ** CAPI3REF: Load An Extension {H12600} <S20500>
4649 **
4650 ** This interface loads an SQLite extension library from the named file.
4651 **
4652 ** {H12601} The sqlite3_load_extension() interface attempts to load an
4653 ** SQLite extension library contained in the file zFile.
4654 **
4655 ** {H12602} The entry point is zProc.
4656 **
4657 ** {H12603} zProc may be 0, in which case the name of the entry point
4658 ** defaults to "sqlite3_extension_init".
4659 **
4660 ** {H12604} The sqlite3_load_extension() interface shall return
4661 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4662 **
4663 ** {H12605} If an error occurs and pzErrMsg is not 0, then the
4664 ** [sqlite3_load_extension()] interface shall attempt to
4665 ** fill *pzErrMsg with error message text stored in memory
4666 ** obtained from [sqlite3_malloc()]. {END} The calling function
4667 ** should free this memory by calling [sqlite3_free()].
4668 **
4669 ** {H12606} Extension loading must be enabled using
4670 ** [sqlite3_enable_load_extension()] prior to calling this API,
4671 ** otherwise an error will be returned.
4672 **
4673 ** See also the [load_extension() SQL function].
4674 */
4675 SQLITE_API int sqlite3_load_extension(
4676 sqlite3 *db, /* Load the extension into this database connection */
@@ -4678,65 +4586,53 @@
4678 const char *zProc, /* Entry point. Derived from zFile if 0 */
4679 char **pzErrMsg /* Put error message here if not 0 */
4680 );
4681
4682 /*
4683 ** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
4684 **
4685 ** So as not to open security holes in older applications that are
4686 ** unprepared to deal with extension loading, and as a means of disabling
4687 ** extension loading while evaluating user-entered SQL, the following API
4688 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
4689 **
4690 ** Extension loading is off by default. See ticket #1863.
4691 **
4692 ** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
4693 ** to turn extension loading on and call it with onoff==0 to turn
4694 ** it back off again.
4695 **
4696 ** {H12622} Extension loading is off by default.
4697 */
4698 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
4699
4700 /*
4701 ** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
4702 **
4703 ** This API can be invoked at program startup in order to register
4704 ** one or more statically linked extensions that will be available
4705 ** to all new [database connections]. {END}
4706 **
4707 ** This routine stores a pointer to the extension in an array that is
4708 ** obtained from [sqlite3_malloc()]. If you run a memory leak checker
4709 ** on your program and it reports a leak because of this array, invoke
4710 ** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
4711 **
4712 ** {H12641} This function registers an extension entry point that is
4713 ** automatically invoked whenever a new [database connection]
4714 ** is opened using [sqlite3_open()], [sqlite3_open16()],
4715 ** or [sqlite3_open_v2()].
4716 **
4717 ** {H12642} Duplicate extensions are detected so calling this routine
4718 ** multiple times with the same extension is harmless.
4719 **
4720 ** {H12643} This routine stores a pointer to the extension in an array
4721 ** that is obtained from [sqlite3_malloc()].
4722 **
4723 ** {H12644} Automatic extensions apply across all threads.
4724 */
4725 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
4726
4727 /*
4728 ** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
4729 **
4730 ** This function disables all previously registered automatic
4731 ** extensions. {END} It undoes the effect of all prior
4732 ** [sqlite3_auto_extension()] calls.
4733 **
4734 ** {H12661} This function disables all previously registered
4735 ** automatic extensions.
4736 **
4737 ** {H12662} This function disables automatic extensions in all threads.
4738 */
4739 SQLITE_API void sqlite3_reset_auto_extension(void);
4740
4741 /*
4742 ****** EXPERIMENTAL - subject to change without notice **************
@@ -4756,22 +4652,22 @@
4756 typedef struct sqlite3_index_info sqlite3_index_info;
4757 typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
4758 typedef struct sqlite3_module sqlite3_module;
4759
4760 /*
4761 ** CAPI3REF: Virtual Table Object {H18000} <S20400>
4762 ** KEYWORDS: sqlite3_module {virtual table module}
4763 ** EXPERIMENTAL
4764 **
4765 ** This structure, sometimes called a a "virtual table module",
4766 ** defines the implementation of a [virtual tables].
4767 ** This structure consists mostly of methods for the module.
4768 **
4769 ** A virtual table module is created by filling in a persistent
4770 ** instance of this structure and passing a pointer to that instance
4771 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4772 ** The registration remains valid until it is replaced by a different
4773 ** module or until the [database connection] closes. The content
4774 ** of this structure must not change while it is registered with
4775 ** any database connection.
4776 */
4777 struct sqlite3_module {
@@ -4803,56 +4699,56 @@
4803 void **ppArg);
4804 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
4805 };
4806
4807 /*
4808 ** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
4809 ** KEYWORDS: sqlite3_index_info
4810 ** EXPERIMENTAL
4811 **
4812 ** The sqlite3_index_info structure and its substructures is used to
4813 ** pass information into and receive the reply from the [xBestIndex]
4814 ** method of a [virtual table module]. The fields under **Inputs** are the
4815 ** inputs to xBestIndex and are read-only. xBestIndex inserts its
4816 ** results into the **Outputs** fields.
4817 **
4818 ** The aConstraint[] array records WHERE clause constraints of the form:
4819 **
4820 ** <pre>column OP expr</pre>
4821 **
4822 ** where OP is =, &lt;, &lt;=, &gt;, or &gt;=. The particular operator is
4823 ** stored in aConstraint[].op. The index of the column is stored in
4824 ** aConstraint[].iColumn. aConstraint[].usable is TRUE if the
4825 ** expr on the right-hand side can be evaluated (and thus the constraint
4826 ** is usable) and false if it cannot.
4827 **
4828 ** The optimizer automatically inverts terms of the form "expr OP column"
4829 ** and makes other simplifications to the WHERE clause in an attempt to
4830 ** get as many WHERE clause terms into the form shown above as possible.
4831 ** The aConstraint[] array only reports WHERE clause terms in the correct
4832 ** form that refer to the particular virtual table being queried.
4833 **
4834 ** Information about the ORDER BY clause is stored in aOrderBy[].
4835 ** Each term of aOrderBy records a column of the ORDER BY clause.
4836 **
4837 ** The [xBestIndex] method must fill aConstraintUsage[] with information
4838 ** about what parameters to pass to xFilter. If argvIndex>0 then
4839 ** the right-hand side of the corresponding aConstraint[] is evaluated
4840 ** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
4841 ** is true, then the constraint is assumed to be fully handled by the
4842 ** virtual table and is not checked again by SQLite.
4843 **
4844 ** The idxNum and idxPtr values are recorded and passed into the
4845 ** [xFilter] method.
4846 ** [sqlite3_free()] is used to free idxPtr if and only iff
4847 ** needToFreeIdxPtr is true.
4848 **
4849 ** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4850 ** the correct order to satisfy the ORDER BY clause so that no separate
4851 ** sorting step is required.
4852 **
4853 ** The estimatedCost value is an estimate of the cost of doing the
4854 ** particular lookup. A full scan of a table with N entries should have
4855 ** a cost of N. A binary search of a table of N entries should have a
4856 ** cost of approximately log(N).
4857 */
4858 struct sqlite3_index_info {
@@ -4886,70 +4782,63 @@
4886 #define SQLITE_INDEX_CONSTRAINT_LT 16
4887 #define SQLITE_INDEX_CONSTRAINT_GE 32
4888 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
4889
4890 /*
4891 ** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
4892 ** EXPERIMENTAL
4893 **
4894 ** This routine is used to register a new [virtual table module] name.
4895 ** Module names must be registered before
4896 ** creating a new [virtual table] using the module, or before using a
4897 ** preexisting [virtual table] for the module.
4898 **
4899 ** The module name is registered on the [database connection] specified
4900 ** by the first parameter. The name of the module is given by the
4901 ** second parameter. The third parameter is a pointer to
4902 ** the implementation of the [virtual table module]. The fourth
4903 ** parameter is an arbitrary client data pointer that is passed through
4904 ** into the [xCreate] and [xConnect] methods of the virtual table module
4905 ** when a new virtual table is be being created or reinitialized.
4906 **
4907 ** This interface has exactly the same effect as calling
4908 ** [sqlite3_create_module_v2()] with a NULL client data destructor.
 
 
 
 
4909 */
4910 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
4911 sqlite3 *db, /* SQLite connection to register module with */
4912 const char *zName, /* Name of the module */
4913 const sqlite3_module *p, /* Methods for the module */
4914 void *pClientData /* Client data for xCreate/xConnect */
4915 );
4916
4917 /*
4918 ** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
4919 ** EXPERIMENTAL
4920 **
4921 ** This routine is identical to the [sqlite3_create_module()] method,
4922 ** except that it has an extra parameter to specify
4923 ** a destructor function for the client data pointer. SQLite will
4924 ** invoke the destructor function (if it is not NULL) when SQLite
4925 ** no longer needs the pClientData pointer.
4926 */
4927 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
4928 sqlite3 *db, /* SQLite connection to register module with */
4929 const char *zName, /* Name of the module */
4930 const sqlite3_module *p, /* Methods for the module */
4931 void *pClientData, /* Client data for xCreate/xConnect */
4932 void(*xDestroy)(void*) /* Module destructor function */
4933 );
4934
4935 /*
4936 ** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
4937 ** KEYWORDS: sqlite3_vtab
4938 ** EXPERIMENTAL
4939 **
4940 ** Every [virtual table module] implementation uses a subclass
4941 ** of the following structure to describe a particular instance
4942 ** of the [virtual table]. Each subclass will
4943 ** be tailored to the specific needs of the module implementation.
4944 ** The purpose of this superclass is to define certain fields that are
4945 ** common to all module implementations.
4946 **
4947 ** Virtual tables methods can set an error message by assigning a
4948 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
4949 ** take care that any prior string is freed by a call to [sqlite3_free()]
4950 ** prior to assigning a new string to zErrMsg. After the error message
4951 ** is delivered up to the client application, the string will be automatically
4952 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
4953 */
4954 struct sqlite3_vtab {
4955 const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4957,20 +4846,20 @@
4957 char *zErrMsg; /* Error message from sqlite3_mprintf() */
4958 /* Virtual table implementations will typically add additional fields */
4959 };
4960
4961 /*
4962 ** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400>
4963 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
4964 ** EXPERIMENTAL
4965 **
4966 ** Every [virtual table module] implementation uses a subclass of the
4967 ** following structure to describe cursors that point into the
4968 ** [virtual table] and are used
4969 ** to loop through the virtual table. Cursors are created using the
4970 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4971 ** by the [sqlite3_module.xClose | xClose] method. Cussors are used
4972 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
4973 ** of the module. Each module implementation will define
4974 ** the content of a cursor structure to suit its own needs.
4975 **
4976 ** This superclass exists in order to define fields of the cursor that
@@ -4980,32 +4869,32 @@
4980 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
4981 /* Virtual table implementations will typically add additional fields */
4982 };
4983
4984 /*
4985 ** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
4986 ** EXPERIMENTAL
4987 **
4988 ** The [xCreate] and [xConnect] methods of a
4989 ** [virtual table module] call this interface
4990 ** to declare the format (the names and datatypes of the columns) of
4991 ** the virtual tables they implement.
4992 */
4993 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
4994
4995 /*
4996 ** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
4997 ** EXPERIMENTAL
4998 **
4999 ** Virtual tables can provide alternative implementations of functions
5000 ** using the [xFindFunction] method of the [virtual table module].
5001 ** But global versions of those functions
5002 ** must exist in order to be overloaded.
5003 **
5004 ** This API makes sure a global version of a function with a particular
5005 ** name and number of parameters exists. If no such function exists
5006 ** before this API is called, a new function is created. The implementation
5007 ** of the new function always causes an exception to be thrown. So
5008 ** the new function is not good for anything by itself. Its only
5009 ** purpose is to be a placeholder function that can be overloaded
5010 ** by a [virtual table].
5011 */
@@ -5022,81 +4911,78 @@
5022 **
5023 ****** EXPERIMENTAL - subject to change without notice **************
5024 */
5025
5026 /*
5027 ** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
5028 ** KEYWORDS: {BLOB handle} {BLOB handles}
5029 **
5030 ** An instance of this object represents an open BLOB on which
5031 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
5032 ** Objects of this type are created by [sqlite3_blob_open()]
5033 ** and destroyed by [sqlite3_blob_close()].
5034 ** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
5035 ** can be used to read or write small subsections of the BLOB.
5036 ** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
5037 */
5038 typedef struct sqlite3_blob sqlite3_blob;
5039
5040 /*
5041 ** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
5042 **
5043 ** This interfaces opens a [BLOB handle | handle] to the BLOB located
5044 ** in row iRow, column zColumn, table zTable in database zDb;
5045 ** in other words, the same BLOB that would be selected by:
5046 **
5047 ** <pre>
5048 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
5049 ** </pre> {END}
5050 **
5051 ** If the flags parameter is non-zero, then the BLOB is opened for read
5052 ** and write access. If it is zero, the BLOB is opened for read access.
5053 ** It is not possible to open a column that is part of an index or primary
5054 ** key for writing. ^If [foreign key constraints] are enabled, it is
5055 ** not possible to open a column that is part of a [child key] for writing.
5056 **
5057 ** Note that the database name is not the filename that contains
5058 ** the database but rather the symbolic name of the database that
5059 ** is assigned when the database is connected using [ATTACH].
5060 ** For the main database file, the database name is "main".
5061 ** For TEMP tables, the database name is "temp".
5062 **
5063 ** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
5064 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
5065 ** to be a null pointer.
5066 ** This function sets the [database connection] error code and message
5067 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
5068 ** functions. Note that the *ppBlob variable is always initialized in a
5069 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
5070 ** regardless of the success or failure of this routine.
5071 **
5072 ** If the row that a BLOB handle points to is modified by an
5073 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
5074 ** then the BLOB handle is marked as "expired".
5075 ** This is true if any column of the row is changed, even a column
5076 ** other than the one the BLOB handle is open on.
5077 ** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
5078 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
5079 ** Changes written into a BLOB prior to the BLOB expiring are not
5080 ** rollback by the expiration of the BLOB. Such changes will eventually
5081 ** commit if the transaction continues to completion.
5082 **
5083 ** Use the [sqlite3_blob_bytes()] interface to determine the size of
5084 ** the opened blob. The size of a blob may not be changed by this
5085 ** interface. Use the [UPDATE] SQL command to change the size of a
5086 ** blob.
5087 **
5088 ** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
5089 ** and the built-in [zeroblob] SQL function can be used, if desired,
5090 ** to create an empty, zero-filled blob in which to read or write using
5091 ** this interface.
5092 **
5093 ** To avoid a resource leak, every open [BLOB handle] should eventually
5094 ** be released by a call to [sqlite3_blob_close()].
5095 **
5096 ** Requirements:
5097 ** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
5098 */
5099 SQLITE_API int sqlite3_blob_open(
5100 sqlite3*,
5101 const char *zDb,
5102 const char *zTable,
@@ -5105,201 +4991,185 @@
5105 int flags,
5106 sqlite3_blob **ppBlob
5107 );
5108
5109 /*
5110 ** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
5111 **
5112 ** Closes an open [BLOB handle].
5113 **
5114 ** Closing a BLOB shall cause the current transaction to commit
5115 ** if there are no other BLOBs, no pending prepared statements, and the
5116 ** database connection is in [autocommit mode].
5117 ** If any writes were made to the BLOB, they might be held in cache
5118 ** until the close operation if they will fit.
5119 **
5120 ** Closing the BLOB often forces the changes
5121 ** out to disk and so if any I/O errors occur, they will likely occur
5122 ** at the time when the BLOB is closed. Any errors that occur during
5123 ** closing are reported as a non-zero return value.
5124 **
5125 ** The BLOB is closed unconditionally. Even if this routine returns
5126 ** an error code, the BLOB is still closed.
5127 **
5128 ** Calling this routine with a null pointer (which as would be returned
5129 ** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
5130 **
5131 ** Requirements:
5132 ** [H17833] [H17836] [H17839]
5133 */
5134 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5135
5136 /*
5137 ** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
5138 **
5139 ** Returns the size in bytes of the BLOB accessible via the
5140 ** successfully opened [BLOB handle] in its only argument. The
5141 ** incremental blob I/O routines can only read or overwriting existing
5142 ** blob content; they cannot change the size of a blob.
5143 **
5144 ** This routine only works on a [BLOB handle] which has been created
5145 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5146 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5147 ** to this routine results in undefined and probably undesirable behavior.
5148 **
5149 ** Requirements:
5150 ** [H17843]
5151 */
5152 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5153
5154 /*
5155 ** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
5156 **
5157 ** This function is used to read data from an open [BLOB handle] into a
5158 ** caller-supplied buffer. N bytes of data are copied into buffer Z
5159 ** from the open BLOB, starting at offset iOffset.
5160 **
5161 ** If offset iOffset is less than N bytes from the end of the BLOB,
5162 ** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is
5163 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
5164 ** The size of the blob (and hence the maximum value of N+iOffset)
5165 ** can be determined using the [sqlite3_blob_bytes()] interface.
5166 **
5167 ** An attempt to read from an expired [BLOB handle] fails with an
5168 ** error code of [SQLITE_ABORT].
5169 **
5170 ** On success, SQLITE_OK is returned.
5171 ** Otherwise, an [error code] or an [extended error code] is returned.
5172 **
5173 ** This routine only works on a [BLOB handle] which has been created
5174 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5175 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5176 ** to this routine results in undefined and probably undesirable behavior.
5177 **
5178 ** See also: [sqlite3_blob_write()].
5179 **
5180 ** Requirements:
5181 ** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
5182 */
5183 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5184
5185 /*
5186 ** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
5187 **
5188 ** This function is used to write data into an open [BLOB handle] from a
5189 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
5190 ** into the open BLOB, starting at offset iOffset.
5191 **
5192 ** If the [BLOB handle] passed as the first argument was not opened for
5193 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
5194 ** this function returns [SQLITE_READONLY].
5195 **
5196 ** This function may only modify the contents of the BLOB; it is
5197 ** not possible to increase the size of a BLOB using this API.
5198 ** If offset iOffset is less than N bytes from the end of the BLOB,
5199 ** [SQLITE_ERROR] is returned and no data is written. If N is
5200 ** less than zero [SQLITE_ERROR] is returned and no data is written.
5201 ** The size of the BLOB (and hence the maximum value of N+iOffset)
5202 ** can be determined using the [sqlite3_blob_bytes()] interface.
5203 **
5204 ** An attempt to write to an expired [BLOB handle] fails with an
5205 ** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred
5206 ** before the [BLOB handle] expired are not rolled back by the
5207 ** expiration of the handle, though of course those changes might
5208 ** have been overwritten by the statement that expired the BLOB handle
5209 ** or by other independent statements.
5210 **
5211 ** On success, SQLITE_OK is returned.
5212 ** Otherwise, an [error code] or an [extended error code] is returned.
5213 **
5214 ** This routine only works on a [BLOB handle] which has been created
5215 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5216 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5217 ** to this routine results in undefined and probably undesirable behavior.
5218 **
5219 ** See also: [sqlite3_blob_read()].
5220 **
5221 ** Requirements:
5222 ** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
5223 ** [H17888]
5224 */
5225 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5226
5227 /*
5228 ** CAPI3REF: Virtual File System Objects {H11200} <S20100>
5229 **
5230 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
5231 ** that SQLite uses to interact
5232 ** with the underlying operating system. Most SQLite builds come with a
5233 ** single default VFS that is appropriate for the host computer.
5234 ** New VFSes can be registered and existing VFSes can be unregistered.
5235 ** The following interfaces are provided.
5236 **
5237 ** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
5238 ** Names are case sensitive.
5239 ** Names are zero-terminated UTF-8 strings.
5240 ** If there is no match, a NULL pointer is returned.
5241 ** If zVfsName is NULL then the default VFS is returned.
5242 **
5243 ** New VFSes are registered with sqlite3_vfs_register().
5244 ** Each new VFS becomes the default VFS if the makeDflt flag is set.
5245 ** The same VFS can be registered multiple times without injury.
5246 ** To make an existing VFS into the default VFS, register it again
5247 ** with the makeDflt flag set. If two different VFSes with the
5248 ** same name are registered, the behavior is undefined. If a
5249 ** VFS is registered with a name that is NULL or an empty string,
5250 ** then the behavior is undefined.
5251 **
5252 ** Unregister a VFS with the sqlite3_vfs_unregister() interface.
5253 ** If the default VFS is unregistered, another VFS is chosen as
5254 ** the default. The choice for the new VFS is arbitrary.
5255 **
5256 ** Requirements:
5257 ** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
5258 */
5259 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5260 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5261 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5262
5263 /*
5264 ** CAPI3REF: Mutexes {H17000} <S20000>
5265 **
5266 ** The SQLite core uses these routines for thread
5267 ** synchronization. Though they are intended for internal
5268 ** use by SQLite, code that links against SQLite is
5269 ** permitted to use any of these routines.
5270 **
5271 ** The SQLite source code contains multiple implementations
5272 ** of these mutex routines. An appropriate implementation
5273 ** is selected automatically at compile-time. The following
5274 ** implementations are available in the SQLite core:
5275 **
5276 ** <ul>
5277 ** <li> SQLITE_MUTEX_OS2
5278 ** <li> SQLITE_MUTEX_PTHREAD
5279 ** <li> SQLITE_MUTEX_W32
5280 ** <li> SQLITE_MUTEX_NOOP
5281 ** </ul>
5282 **
5283 ** The SQLITE_MUTEX_NOOP implementation is a set of routines
5284 ** that does no real locking and is appropriate for use in
5285 ** a single-threaded application. The SQLITE_MUTEX_OS2,
5286 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5287 ** are appropriate for use on OS/2, Unix, and Windows.
5288 **
5289 ** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5290 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5291 ** implementation is included with the library. In this case the
5292 ** application must supply a custom mutex implementation using the
5293 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
5294 ** before calling sqlite3_initialize() or any other public sqlite3_
5295 ** function that calls sqlite3_initialize().
5296 **
5297 ** {H17011} The sqlite3_mutex_alloc() routine allocates a new
5298 ** mutex and returns a pointer to it. {H17012} If it returns NULL
5299 ** that means that a mutex could not be allocated. {H17013} SQLite
5300 ** will unwind its stack and return an error. {H17014} The argument
5301 ** to sqlite3_mutex_alloc() is one of these integer constants:
5302 **
5303 ** <ul>
5304 ** <li> SQLITE_MUTEX_FAST
5305 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -5307,68 +5177,70 @@
5307 ** <li> SQLITE_MUTEX_STATIC_MEM
5308 ** <li> SQLITE_MUTEX_STATIC_MEM2
5309 ** <li> SQLITE_MUTEX_STATIC_PRNG
5310 ** <li> SQLITE_MUTEX_STATIC_LRU
5311 ** <li> SQLITE_MUTEX_STATIC_LRU2
5312 ** </ul>
5313 **
5314 ** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
5315 ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
5316 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
 
5317 ** The mutex implementation does not need to make a distinction
5318 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5319 ** not want to. {H17016} But SQLite will only request a recursive mutex in
5320 ** cases where it really needs one. {END} If a faster non-recursive mutex
5321 ** implementation is available on the host platform, the mutex subsystem
5322 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
5323 **
5324 ** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
5325 ** a pointer to a static preexisting mutex. {END} Six static mutexes are
 
5326 ** used by the current version of SQLite. Future versions of SQLite
5327 ** may add additional static mutexes. Static mutexes are for internal
5328 ** use by SQLite only. Applications that use SQLite mutexes should
5329 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
5330 ** SQLITE_MUTEX_RECURSIVE.
5331 **
5332 ** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
5333 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
5334 ** returns a different mutex on every call. {H17034} But for the static
5335 ** mutex types, the same mutex is returned on every call that has
5336 ** the same type number.
5337 **
5338 ** {H17019} The sqlite3_mutex_free() routine deallocates a previously
5339 ** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
5340 ** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
5341 ** use when they are deallocated. {A17022} Attempting to deallocate a static
5342 ** mutex results in undefined behavior. {H17023} SQLite never deallocates
5343 ** a static mutex. {END}
5344 **
5345 ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
5346 ** to enter a mutex. {H17024} If another thread is already within the mutex,
5347 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
5348 ** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK]
5349 ** upon successful entry. {H17026} Mutexes created using
5350 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
5351 ** {H17027} In such cases the,
5352 ** mutex must be exited an equal number of times before another thread
5353 ** can enter. {A17028} If the same thread tries to enter any other
5354 ** kind of mutex more than once, the behavior is undefined.
5355 ** {H17029} SQLite will never exhibit
5356 ** such behavior in its own use of mutexes.
5357 **
5358 ** Some systems (for example, Windows 95) do not support the operation
5359 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
5360 ** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses
5361 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
5362 **
5363 ** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
5364 ** previously entered by the same thread. {A17032} The behavior
5365 ** is undefined if the mutex is not currently entered by the
5366 ** calling thread or is not currently allocated. {H17033} SQLite will
5367 ** never do either. {END}
5368 **
5369 ** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
5370 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
5371 ** behave as no-ops.
5372 **
5373 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
5374 */
@@ -5377,11 +5249,11 @@
5377 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
5378 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
5379 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
5380
5381 /*
5382 ** CAPI3REF: Mutex Methods Object {H17120} <S20130>
5383 ** EXPERIMENTAL
5384 **
5385 ** An instance of this structure defines the low-level routines
5386 ** used to allocate and use mutexes.
5387 **
@@ -5393,23 +5265,23 @@
5393 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
5394 ** Additionally, an instance of this structure can be used as an
5395 ** output variable when querying the system for the current mutex
5396 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
5397 **
5398 ** The xMutexInit method defined by this structure is invoked as
5399 ** part of system initialization by the sqlite3_initialize() function.
5400 ** {H17001} The xMutexInit routine shall be called by SQLite once for each
5401 ** effective call to [sqlite3_initialize()].
5402 **
5403 ** The xMutexEnd method defined by this structure is invoked as
5404 ** part of system shutdown by the sqlite3_shutdown() function. The
5405 ** implementation of this method is expected to release all outstanding
5406 ** resources obtained by the mutex methods implementation, especially
5407 ** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
5408 ** interface shall be invoked once for each call to [sqlite3_shutdown()].
5409 **
5410 ** The remaining seven methods defined by this structure (xMutexAlloc,
5411 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
5412 ** xMutexNotheld) implement the following interfaces (respectively):
5413 **
5414 ** <ul>
5415 ** <li> [sqlite3_mutex_alloc()] </li>
@@ -5417,31 +5289,31 @@
5417 ** <li> [sqlite3_mutex_enter()] </li>
5418 ** <li> [sqlite3_mutex_try()] </li>
5419 ** <li> [sqlite3_mutex_leave()] </li>
5420 ** <li> [sqlite3_mutex_held()] </li>
5421 ** <li> [sqlite3_mutex_notheld()] </li>
5422 ** </ul>
5423 **
5424 ** The only difference is that the public sqlite3_XXX functions enumerated
5425 ** above silently ignore any invocations that pass a NULL pointer instead
5426 ** of a valid mutex handle. The implementations of the methods defined
5427 ** by this structure are not required to handle this case, the results
5428 ** of passing a NULL pointer instead of a valid mutex handle are undefined
5429 ** (i.e. it is acceptable to provide an implementation that segfaults if
5430 ** it is passed a NULL pointer).
5431 **
5432 ** The xMutexInit() method must be threadsafe. It must be harmless to
5433 ** invoke xMutexInit() mutiple times within the same process and without
5434 ** intervening calls to xMutexEnd(). Second and subsequent calls to
5435 ** xMutexInit() must be no-ops.
5436 **
5437 ** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
5438 ** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
5439 ** allocation for a static mutex. However xMutexAlloc() may use SQLite
5440 ** memory allocation for a fast or recursive mutex.
5441 **
5442 ** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
5443 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
5444 ** If xMutexInit fails in any way, it is expected to clean up after itself
5445 ** prior to returning.
5446 */
5447 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -5456,43 +5328,45 @@
5456 int (*xMutexHeld)(sqlite3_mutex *);
5457 int (*xMutexNotheld)(sqlite3_mutex *);
5458 };
5459
5460 /*
5461 ** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
5462 **
5463 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
5464 ** are intended for use inside assert() statements. {H17081} The SQLite core
5465 ** never uses these routines except inside an assert() and applications
5466 ** are advised to follow the lead of the core. {H17082} The core only
5467 ** provides implementations for these routines when it is compiled
5468 ** with the SQLITE_DEBUG flag. {A17087} External mutex implementations
5469 ** are only required to provide these routines if SQLITE_DEBUG is
5470 ** defined and if NDEBUG is not defined.
5471 **
5472 ** {H17083} These routines should return true if the mutex in their argument
5473 ** is held or not held, respectively, by the calling thread.
5474 **
5475 ** {X17084} The implementation is not required to provided versions of these
5476 ** routines that actually work. If the implementation does not provide working
5477 ** versions of these routines, it should at least provide stubs that always
5478 ** return true so that one does not get spurious assertion failures.
5479 **
5480 ** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
5481 ** the routine should return 1. {END} This seems counter-intuitive since
5482 ** clearly the mutex cannot be held if it does not exist. But the
5483 ** the reason the mutex does not exist is because the build is not
5484 ** using mutexes. And we do not want the assert() containing the
5485 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
5486 ** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld()
5487 ** interface should also return 1 when given a NULL pointer.
5488 */
 
5489 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
5490 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
 
5491
5492 /*
5493 ** CAPI3REF: Mutex Types {H17001} <H17000>
5494 **
5495 ** The [sqlite3_mutex_alloc()] interface takes a single argument
5496 ** which is one of these integer constants.
5497 **
5498 ** The set of static mutexes may change from one SQLite release to the
@@ -5508,52 +5382,54 @@
5508 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
5509 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
5510 #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
5511
5512 /*
5513 ** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
5514 **
5515 ** This interface returns a pointer the [sqlite3_mutex] object that
5516 ** serializes access to the [database connection] given in the argument
5517 ** when the [threading mode] is Serialized.
5518 ** If the [threading mode] is Single-thread or Multi-thread then this
5519 ** routine returns a NULL pointer.
5520 */
5521 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
5522
5523 /*
5524 ** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
5525 **
5526 ** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
5527 ** xFileControl method for the [sqlite3_io_methods] object associated
5528 ** with a particular database identified by the second argument. {H11302} The
5529 ** name of the database is the name assigned to the database by the
5530 ** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
5531 ** database. {H11303} To control the main database file, use the name "main"
5532 ** or a NULL pointer. {H11304} The third and fourth parameters to this routine
 
 
5533 ** are passed directly through to the second and third parameters of
5534 ** the xFileControl method. {H11305} The return value of the xFileControl
5535 ** method becomes the return value of this routine.
5536 **
5537 ** {H11306} If the second parameter (zDbName) does not match the name of any
5538 ** open database file, then SQLITE_ERROR is returned. {H11307} This error
5539 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
5540 ** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
5541 ** also return SQLITE_ERROR. {A11309} There is no way to distinguish between
5542 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
5543 ** xFileControl method. {END}
5544 **
5545 ** See also: [SQLITE_FCNTL_LOCKSTATE]
5546 */
5547 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
5548
5549 /*
5550 ** CAPI3REF: Testing Interface {H11400} <S30800>
5551 **
5552 ** The sqlite3_test_control() interface is used to read out internal
5553 ** state of SQLite and to inject faults into SQLite for testing
5554 ** purposes. The first parameter is an operation code that determines
5555 ** the number, meaning, and operation of all subsequent parameters.
5556 **
5557 ** This interface is not for use by applications. It exists solely
5558 ** for verifying the correct operation of the SQLite library. Depending
5559 ** on how the SQLite library is compiled, this interface might not exist.
@@ -5564,20 +5440,21 @@
5564 ** operate consistently from one release to the next.
5565 */
5566 SQLITE_API int sqlite3_test_control(int op, ...);
5567
5568 /*
5569 ** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
5570 **
5571 ** These constants are the valid operation code parameters used
5572 ** as the first argument to [sqlite3_test_control()].
5573 **
5574 ** These parameters and their meanings are subject to change
5575 ** without notice. These values are for testing purposes only.
5576 ** Applications should not use any of these parameters or the
5577 ** [sqlite3_test_control()] interface.
5578 */
 
5579 #define SQLITE_TESTCTRL_PRNG_SAVE 5
5580 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
5581 #define SQLITE_TESTCTRL_PRNG_RESET 7
5582 #define SQLITE_TESTCTRL_BITVEC_TEST 8
5583 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5584,31 +5461,34 @@
5584 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
5585 #define SQLITE_TESTCTRL_PENDING_BYTE 11
5586 #define SQLITE_TESTCTRL_ASSERT 12
5587 #define SQLITE_TESTCTRL_ALWAYS 13
5588 #define SQLITE_TESTCTRL_RESERVE 14
 
 
 
5589
5590 /*
5591 ** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
5592 ** EXPERIMENTAL
5593 **
5594 ** This interface is used to retrieve runtime status information
5595 ** about the preformance of SQLite, and optionally to reset various
5596 ** highwater marks. The first argument is an integer code for
5597 ** the specific parameter to measure. Recognized integer codes
5598 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].
5599 ** The current value of the parameter is returned into *pCurrent.
5600 ** The highest recorded value is returned in *pHighwater. If the
5601 ** resetFlag is true, then the highest record value is reset after
5602 ** *pHighwater is written. Some parameters do not record the highest
5603 ** value. For those parameters
5604 ** nothing is written into *pHighwater and the resetFlag is ignored.
5605 ** Other parameters record only the highwater mark and not the current
5606 ** value. For these latter parameters nothing is written into *pCurrent.
5607 **
5608 ** This routine returns SQLITE_OK on success and a non-zero
5609 ** [error code] on failure.
5610 **
5611 ** This routine is threadsafe but is not atomic. This routine can be
5612 ** called while other threads are running the same or different SQLite
5613 ** interfaces. However the values returned in *pCurrent and
5614 ** *pHighwater reflect the status of SQLite at different points in time
@@ -5619,82 +5499,82 @@
5619 */
5620 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
5621
5622
5623 /*
5624 ** CAPI3REF: Status Parameters {H17250} <H17200>
5625 ** EXPERIMENTAL
5626 **
5627 ** These integer constants designate various run-time status parameters
5628 ** that can be returned by [sqlite3_status()].
5629 **
5630 ** <dl>
5631 ** <dt>SQLITE_STATUS_MEMORY_USED</dt>
5632 ** <dd>This parameter is the current amount of memory checked out
5633 ** using [sqlite3_malloc()], either directly or indirectly. The
5634 ** figure includes calls made to [sqlite3_malloc()] by the application
5635 ** and internal memory usage by the SQLite library. Scratch memory
5636 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
5637 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
5638 ** this parameter. The amount returned is the sum of the allocation
5639 ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
5640 **
5641 ** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5642 ** <dd>This parameter records the largest memory allocation request
5643 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
5644 ** internal equivalents). Only the value returned in the
5645 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5646 ** The value written into the *pCurrent parameter is undefined.</dd>
5647 **
5648 ** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5649 ** <dd>This parameter returns the number of pages used out of the
5650 ** [pagecache memory allocator] that was configured using
5651 ** [SQLITE_CONFIG_PAGECACHE]. The
5652 ** value returned is in pages, not in bytes.</dd>
5653 **
5654 ** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5655 ** <dd>This parameter returns the number of bytes of page cache
5656 ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
5657 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
5658 ** returned value includes allocations that overflowed because they
5659 ** where too large (they were larger than the "sz" parameter to
5660 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5661 ** no space was left in the page cache.</dd>
5662 **
5663 ** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5664 ** <dd>This parameter records the largest memory allocation request
5665 ** handed to [pagecache memory allocator]. Only the value returned in the
5666 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5667 ** The value written into the *pCurrent parameter is undefined.</dd>
5668 **
5669 ** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
5670 ** <dd>This parameter returns the number of allocations used out of the
5671 ** [scratch memory allocator] configured using
5672 ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
5673 ** in bytes. Since a single thread may only have one scratch allocation
5674 ** outstanding at time, this parameter also reports the number of threads
5675 ** using scratch memory at the same time.</dd>
5676 **
5677 ** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5678 ** <dd>This parameter returns the number of bytes of scratch memory
5679 ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
5680 ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
5681 ** returned include overflows because the requested allocation was too
5682 ** larger (that is, because the requested allocation was larger than the
5683 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
5684 ** slots were available.
5685 ** </dd>
5686 **
5687 ** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5688 ** <dd>This parameter records the largest memory allocation request
5689 ** handed to [scratch memory allocator]. Only the value returned in the
5690 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5691 ** The value written into the *pCurrent parameter is undefined.</dd>
5692 **
5693 ** <dt>SQLITE_STATUS_PARSER_STACK</dt>
5694 ** <dd>This parameter records the deepest parser stack. It is only
5695 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
5696 ** </dl>
5697 **
5698 ** New status parameters may be added from time to time.
5699 */
5700 #define SQLITE_STATUS_MEMORY_USED 0
@@ -5706,31 +5586,31 @@
5706 #define SQLITE_STATUS_PARSER_STACK 6
5707 #define SQLITE_STATUS_PAGECACHE_SIZE 7
5708 #define SQLITE_STATUS_SCRATCH_SIZE 8
5709
5710 /*
5711 ** CAPI3REF: Database Connection Status {H17500} <S60200>
5712 ** EXPERIMENTAL
5713 **
5714 ** This interface is used to retrieve runtime status information
5715 ** about a single [database connection]. The first argument is the
5716 ** database connection object to be interrogated. The second argument
5717 ** is the parameter to interrogate. Currently, the only allowed value
5718 ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
5719 ** Additional options will likely appear in future releases of SQLite.
5720 **
5721 ** The current value of the requested parameter is written into *pCur
5722 ** and the highest instantaneous value is written into *pHiwtr. If
5723 ** the resetFlg is true, then the highest instantaneous value is
5724 ** reset back down to the current value.
5725 **
5726 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
5727 */
5728 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
5729
5730 /*
5731 ** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
5732 ** EXPERIMENTAL
5733 **
5734 ** These constants are the available integer "verbs" that can be passed as
5735 ** the second argument to the [sqlite3_db_status()] interface.
5736 **
@@ -5739,61 +5619,61 @@
5739 ** [sqlite3_db_status()] to make sure that the call worked.
5740 ** The [sqlite3_db_status()] interface will return a non-zero error code
5741 ** if a discontinued or unsupported verb is invoked.
5742 **
5743 ** <dl>
5744 ** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5745 ** <dd>This parameter returns the number of lookaside memory slots currently
5746 ** checked out.</dd>
5747 ** </dl>
5748 */
5749 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
5750
5751
5752 /*
5753 ** CAPI3REF: Prepared Statement Status {H17550} <S60200>
5754 ** EXPERIMENTAL
5755 **
5756 ** Each prepared statement maintains various
5757 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5758 ** of times it has performed specific operations. These counters can
5759 ** be used to monitor the performance characteristics of the prepared
5760 ** statements. For example, if the number of table steps greatly exceeds
5761 ** the number of table searches or result rows, that would tend to indicate
5762 ** that the prepared statement is using a full table scan rather than
5763 ** an index.
5764 **
5765 ** This interface is used to retrieve and reset counter values from
5766 ** a [prepared statement]. The first argument is the prepared statement
5767 ** object to be interrogated. The second argument
5768 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5769 ** to be interrogated.
5770 ** The current value of the requested counter is returned.
5771 ** If the resetFlg is true, then the counter is reset to zero after this
5772 ** interface call returns.
5773 **
5774 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
5775 */
5776 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5777
5778 /*
5779 ** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
5780 ** EXPERIMENTAL
5781 **
5782 ** These preprocessor macros define integer codes that name counter
5783 ** values associated with the [sqlite3_stmt_status()] interface.
5784 ** The meanings of the various counters are as follows:
5785 **
5786 ** <dl>
5787 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5788 ** <dd>This is the number of times that SQLite has stepped forward in
5789 ** a table as part of a full table scan. Large numbers for this counter
5790 ** may indicate opportunities for performance improvement through
5791 ** careful use of indices.</dd>
5792 **
5793 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
5794 ** <dd>This is the number of sort operations that have occurred.
5795 ** A non-zero value in this counter may indicate an opportunity to
5796 ** improvement performance through careful use of indices.</dd>
5797 **
5798 ** </dl>
5799 */
@@ -5817,84 +5697,84 @@
5817 /*
5818 ** CAPI3REF: Application Defined Page Cache.
5819 ** KEYWORDS: {page cache}
5820 ** EXPERIMENTAL
5821 **
5822 ** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5823 ** register an alternative page cache implementation by passing in an
5824 ** instance of the sqlite3_pcache_methods structure. The majority of the
5825 ** heap memory used by SQLite is used by the page cache to cache data read
5826 ** from, or ready to be written to, the database file. By implementing a
5827 ** custom page cache using this API, an application can control more
5828 ** precisely the amount of memory consumed by SQLite, the way in which
5829 ** that memory is allocated and released, and the policies used to
5830 ** determine exactly which parts of a database file are cached and for
5831 ** how long.
5832 **
5833 ** The contents of the sqlite3_pcache_methods structure are copied to an
5834 ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
5835 ** the application may discard the parameter after the call to
5836 ** [sqlite3_config()] returns.
5837 **
5838 ** The xInit() method is called once for each call to [sqlite3_initialize()]
5839 ** (usually only once during the lifetime of the process). It is passed
5840 ** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
5841 ** up global structures and mutexes required by the custom page cache
5842 ** implementation.
5843 **
5844 ** The xShutdown() method is called from within [sqlite3_shutdown()],
5845 ** if the application invokes this API. It can be used to clean up
5846 ** any outstanding resources before process shutdown, if required.
5847 **
5848 ** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5849 ** the xInit method, so the xInit method need not be threadsafe. The
5850 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
5851 ** not need to be threadsafe either. All other methods must be threadsafe
5852 ** in multithreaded applications.
5853 **
5854 ** SQLite will never invoke xInit() more than once without an intervening
5855 ** call to xShutdown().
5856 **
5857 ** The xCreate() method is used to construct a new cache instance. SQLite
5858 ** will typically create one cache instance for each open database file,
5859 ** though this is not guaranteed. The
5860 ** first parameter, szPage, is the size in bytes of the pages that must
5861 ** be allocated by the cache. szPage will not be a power of two. szPage
5862 ** will the page size of the database file that is to be cached plus an
5863 ** increment (here called "R") of about 100 or 200. SQLite will use the
5864 ** extra R bytes on each page to store metadata about the underlying
5865 ** database page on disk. The value of R depends
5866 ** on the SQLite version, the target platform, and how SQLite was compiled.
5867 ** R is constant for a particular build of SQLite. The second argument to
5868 ** xCreate(), bPurgeable, is true if the cache being created will
5869 ** be used to cache database pages of a file stored on disk, or
5870 ** false if it is used for an in-memory database. The cache implementation
5871 ** does not have to do anything special based with the value of bPurgeable;
5872 ** it is purely advisory. On a cache where bPurgeable is false, SQLite will
5873 ** never invoke xUnpin() except to deliberately delete a page.
5874 ** In other words, a cache created with bPurgeable set to false will
5875 ** never contain any unpinned pages.
5876 **
5877 ** The xCachesize() method may be called at any time by SQLite to set the
5878 ** suggested maximum cache-size (number of pages stored by) the cache
5879 ** instance passed as the first argument. This is the value configured using
5880 ** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter,
5881 ** the implementation is not required to do anything with this
5882 ** value; it is advisory only.
5883 **
5884 ** The xPagecount() method should return the number of pages currently
5885 ** stored in the cache.
5886 **
5887 ** The xFetch() method is used to fetch a page and return a pointer to it.
5888 ** A 'page', in this context, is a buffer of szPage bytes aligned at an
5889 ** 8-byte boundary. The page to be fetched is determined by the key. The
5890 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5891 ** is considered to be "pinned".
5892 **
5893 ** If the requested page is already in the page cache, then the page cache
5894 ** implementation must return a pointer to the page buffer with its content
5895 ** intact. If the requested page is not already in the cache, then the
5896 ** behavior of the cache implementation is determined by the value of the
5897 ** createFlag parameter passed to xFetch, according to the following table:
5898 **
5899 ** <table border=1 width=85% align=center>
5900 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5901,45 +5781,45 @@
5901 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
5902 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
5903 ** Otherwise return NULL.
5904 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
5905 ** NULL if allocating a new page is effectively impossible.
5906 ** </table>
5907 **
5908 ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
5909 ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
5910 ** attempt to unpin one or more cache pages by spilling the content of
5911 ** pinned pages to disk and synching the operating system disk cache. After
5912 ** attempting to unpin pages, the xFetch() method will be invoked again with
5913 ** a createFlag of 2.
5914 **
5915 ** xUnpin() is called by SQLite with a pointer to a currently pinned page
5916 ** as its second argument. If the third parameter, discard, is non-zero,
5917 ** then the page should be evicted from the cache. In this case SQLite
5918 ** assumes that the next time the page is retrieved from the cache using
5919 ** the xFetch() method, it will be zeroed. If the discard parameter is
5920 ** zero, then the page is considered to be unpinned. The cache implementation
5921 ** may choose to evict unpinned pages at any time.
5922 **
5923 ** The cache is not required to perform any reference counting. A single
5924 ** call to xUnpin() unpins the page regardless of the number of prior calls
5925 ** to xFetch().
5926 **
5927 ** The xRekey() method is used to change the key value associated with the
5928 ** page passed as the second argument from oldKey to newKey. If the cache
5929 ** previously contains an entry associated with newKey, it should be
5930 ** discarded. Any prior cache entry associated with newKey is guaranteed not
5931 ** to be pinned.
5932 **
5933 ** When SQLite calls the xTruncate() method, the cache must discard all
5934 ** existing cache entries with page numbers (keys) greater than or equal
5935 ** to the value of the iLimit parameter passed to xTruncate(). If any
5936 ** of these pages are pinned, they are implicitly unpinned, meaning that
5937 ** they can be safely discarded.
5938 **
5939 ** The xDestroy() method is used to delete a cache allocated by xCreate().
5940 ** All resources associated with the specified cache should be freed. After
5941 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
5942 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
5943 ** functions.
5944 */
5945 typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5960,11 +5840,11 @@
5960 /*
5961 ** CAPI3REF: Online Backup Object
5962 ** EXPERIMENTAL
5963 **
5964 ** The sqlite3_backup object records state information about an ongoing
5965 ** online backup operation. The sqlite3_backup object is created by
5966 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
5967 ** [sqlite3_backup_finish()].
5968 **
5969 ** See Also: [Using the SQLite Online Backup API]
5970 */
@@ -5972,168 +5852,173 @@
5972
5973 /*
5974 ** CAPI3REF: Online Backup API.
5975 ** EXPERIMENTAL
5976 **
5977 ** This API is used to overwrite the contents of one database with that
5978 ** of another. It is useful either for creating backups of databases or
5979 ** for copying in-memory databases to or from persistent files.
5980 **
5981 ** See Also: [Using the SQLite Online Backup API]
5982 **
5983 ** Exclusive access is required to the destination database for the
5984 ** duration of the operation. However the source database is only
5985 ** read-locked while it is actually being read, it is not locked
5986 ** continuously for the entire operation. Thus, the backup may be
5987 ** performed on a live database without preventing other users from
5988 ** writing to the database for an extended period of time.
5989 **
5990 ** To perform a backup operation:
5991 ** <ol>
5992 ** <li><b>sqlite3_backup_init()</b> is called once to initialize the
5993 ** backup,
5994 ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
5995 ** the data between the two databases, and finally
5996 ** <li><b>sqlite3_backup_finish()</b> is called to release all resources
5997 ** associated with the backup operation.
5998 ** </ol>
5999 ** There should be exactly one call to sqlite3_backup_finish() for each
6000 ** successful call to sqlite3_backup_init().
6001 **
6002 ** <b>sqlite3_backup_init()</b>
6003 **
6004 ** The first two arguments passed to [sqlite3_backup_init()] are the database
6005 ** handle associated with the destination database and the database name
6006 ** used to attach the destination database to the handle. The database name
6007 ** is "main" for the main database, "temp" for the temporary database, or
6008 ** the name specified as part of the [ATTACH] statement if the destination is
6009 ** an attached database. The third and fourth arguments passed to
6010 ** sqlite3_backup_init() identify the [database connection]
6011 ** and database name used
6012 ** to access the source database. The values passed for the source and
6013 ** destination [database connection] parameters must not be the same.
 
 
6014 **
6015 ** If an error occurs within sqlite3_backup_init(), then NULL is returned
6016 ** and an error code and error message written into the [database connection]
6017 ** passed as the first argument. They may be retrieved using the
6018 ** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
6019 ** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
6020 ** returned. This pointer may be used with the sqlite3_backup_step() and
 
 
 
6021 ** sqlite3_backup_finish() functions to perform the specified backup
6022 ** operation.
6023 **
6024 ** <b>sqlite3_backup_step()</b>
6025 **
6026 ** Function [sqlite3_backup_step()] is used to copy up to nPage pages between
6027 ** the source and destination databases, where nPage is the value of the
6028 ** second parameter passed to sqlite3_backup_step(). If nPage is a negative
6029 ** value, all remaining source pages are copied. If the required pages are
6030 ** succesfully copied, but there are still more pages to copy before the
6031 ** backup is complete, it returns [SQLITE_OK]. If no error occured and there
6032 ** are no more pages to copy, then [SQLITE_DONE] is returned. If an error
6033 ** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
 
6034 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
6035 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
6036 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
6037 **
6038 ** As well as the case where the destination database file was opened for
6039 ** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
6040 ** the destination is an in-memory database with a different page size
6041 ** from the source database.
6042 **
6043 ** If sqlite3_backup_step() cannot obtain a required file-system lock, then
6044 ** the [sqlite3_busy_handler | busy-handler function]
6045 ** is invoked (if one is specified). If the
6046 ** busy-handler returns non-zero before the lock is available, then
6047 ** [SQLITE_BUSY] is returned to the caller. In this case the call to
6048 ** sqlite3_backup_step() can be retried later. If the source
6049 ** [database connection]
6050 ** is being used to write to the source database when sqlite3_backup_step()
6051 ** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
6052 ** case the call to sqlite3_backup_step() can be retried later on. If
6053 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
6054 ** [SQLITE_READONLY] is returned, then
6055 ** there is no point in retrying the call to sqlite3_backup_step(). These
6056 ** errors are considered fatal. At this point the application must accept
6057 ** that the backup operation has failed and pass the backup operation handle
6058 ** to the sqlite3_backup_finish() to release associated resources.
6059 **
6060 ** Following the first call to sqlite3_backup_step(), an exclusive lock is
6061 ** obtained on the destination file. It is not released until either
6062 ** sqlite3_backup_finish() is called or the backup operation is complete
6063 ** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time
6064 ** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
6065 ** the source database file. This lock is released before the
6066 ** sqlite3_backup_step() call returns. Because the source database is not
6067 ** locked between calls to sqlite3_backup_step(), it may be modified mid-way
6068 ** through the backup procedure. If the source database is modified by an
6069 ** external process or via a database connection other than the one being
6070 ** used by the backup operation, then the backup will be transparently
6071 ** restarted by the next call to sqlite3_backup_step(). If the source
6072 ** database is modified by the using the same database connection as is used
6073 ** by the backup operation, then the backup database is transparently
6074 ** updated at the same time.
6075 **
6076 ** <b>sqlite3_backup_finish()</b>
6077 **
6078 ** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the
6079 ** application wishes to abandon the backup operation, the [sqlite3_backup]
6080 ** object should be passed to sqlite3_backup_finish(). This releases all
6081 ** resources associated with the backup operation. If sqlite3_backup_step()
6082 ** has not yet returned [SQLITE_DONE], then any active write-transaction on the
6083 ** destination database is rolled back. The [sqlite3_backup] object is invalid
 
 
6084 ** and may not be used following a call to sqlite3_backup_finish().
6085 **
6086 ** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
6087 ** occurred, regardless or whether or not sqlite3_backup_step() was called
6088 ** a sufficient number of times to complete the backup operation. Or, if
6089 ** an out-of-memory condition or IO error occured during a call to
6090 ** sqlite3_backup_step() then [SQLITE_NOMEM] or an
6091 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
6092 ** is returned. In this case the error code and an error message are
6093 ** written to the destination [database connection].
6094 **
6095 ** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
6096 ** not a permanent error and does not affect the return value of
6097 ** sqlite3_backup_finish().
6098 **
6099 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
6100 **
6101 ** Each call to sqlite3_backup_step() sets two values stored internally
6102 ** by an [sqlite3_backup] object. The number of pages still to be backed
6103 ** up, which may be queried by sqlite3_backup_remaining(), and the total
6104 ** number of pages in the source database file, which may be queried by
6105 ** sqlite3_backup_pagecount().
6106 **
6107 ** The values returned by these functions are only updated by
6108 ** sqlite3_backup_step(). If the source database is modified during a backup
6109 ** operation, then the values are not updated to account for any extra
6110 ** pages that need to be updated or the size of the source database file
6111 ** changing.
6112 **
6113 ** <b>Concurrent Usage of Database Handles</b>
6114 **
6115 ** The source [database connection] may be used by the application for other
6116 ** purposes while a backup operation is underway or being initialized.
6117 ** If SQLite is compiled and configured to support threadsafe database
6118 ** connections, then the source database connection may be used concurrently
6119 ** from within other threads.
6120 **
6121 ** However, the application must guarantee that the destination database
6122 ** connection handle is not passed to any other API (by any thread) after
6123 ** sqlite3_backup_init() is called and before the corresponding call to
6124 ** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
6125 ** for this, if the application does use the destination [database connection]
6126 ** for some other purpose during a backup operation, things may appear to
6127 ** work correctly but in fact be subtly malfunctioning. Use of the
6128 ** destination database connection while a backup is in progress might
6129 ** also cause a mutex deadlock.
6130 **
6131 ** Furthermore, if running in [shared cache mode], the application must
6132 ** guarantee that the shared cache used by the destination database
6133 ** is not accessed while the backup is running. In practice this means
6134 ** that the application must guarantee that the file-system file being
6135 ** backed up to is not accessed by any connection within the process,
6136 ** not just the specific connection that was passed to sqlite3_backup_init().
6137 **
6138 ** The [sqlite3_backup] object itself is partially threadsafe. Multiple
6139 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -6155,60 +6040,60 @@
6155
6156 /*
6157 ** CAPI3REF: Unlock Notification
6158 ** EXPERIMENTAL
6159 **
6160 ** When running in shared-cache mode, a database operation may fail with
6161 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
6162 ** individual tables within the shared-cache cannot be obtained. See
6163 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6164 ** This API may be used to register a callback that SQLite will invoke
6165 ** when the connection currently holding the required lock relinquishes it.
6166 ** This API is only available if the library was compiled with the
6167 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
6168 **
6169 ** See Also: [Using the SQLite Unlock Notification Feature].
6170 **
6171 ** Shared-cache locks are released when a database connection concludes
6172 ** its current transaction, either by committing it or rolling it back.
6173 **
6174 ** When a connection (known as the blocked connection) fails to obtain a
6175 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
6176 ** identity of the database connection (the blocking connection) that
6177 ** has locked the required resource is stored internally. After an
6178 ** application receives an SQLITE_LOCKED error, it may call the
6179 ** sqlite3_unlock_notify() method with the blocked connection handle as
6180 ** the first argument to register for a callback that will be invoked
6181 ** when the blocking connections current transaction is concluded. The
6182 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
6183 ** call that concludes the blocking connections transaction.
6184 **
6185 ** If sqlite3_unlock_notify() is called in a multi-threaded application,
6186 ** there is a chance that the blocking connection will have already
6187 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
6188 ** If this happens, then the specified callback is invoked immediately,
6189 ** from within the call to sqlite3_unlock_notify().
6190 **
6191 ** If the blocked connection is attempting to obtain a write-lock on a
6192 ** shared-cache table, and more than one other connection currently holds
6193 ** a read-lock on the same table, then SQLite arbitrarily selects one of
6194 ** the other connections to use as the blocking connection.
6195 **
6196 ** There may be at most one unlock-notify callback registered by a
6197 ** blocked connection. If sqlite3_unlock_notify() is called when the
6198 ** blocked connection already has a registered unlock-notify callback,
6199 ** then the new callback replaces the old. If sqlite3_unlock_notify() is
6200 ** called with a NULL pointer as its second argument, then any existing
6201 ** unlock-notify callback is cancelled. The blocked connections
6202 ** unlock-notify callback may also be canceled by closing the blocked
6203 ** connection using [sqlite3_close()].
6204 **
6205 ** The unlock-notify callback is not reentrant. If an application invokes
6206 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
6207 ** crash or deadlock may be the result.
6208 **
6209 ** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
6210 ** returns SQLITE_OK.
6211 **
6212 ** <b>Callback Invocation Details</b>
6213 **
6214 ** When an unlock-notify callback is registered, the application provides a
@@ -6218,11 +6103,11 @@
6218 ** an unlock-notify callback is a pointer to an array of void* pointers,
6219 ** and the second is the number of entries in the array.
6220 **
6221 ** When a blocking connections transaction is concluded, there may be
6222 ** more than one blocked connection that has registered for an unlock-notify
6223 ** callback. If two or more such blocked connections have specified the
6224 ** same callback function, then instead of invoking the callback function
6225 ** multiple times, it is invoked once with the set of void* context pointers
6226 ** specified by the blocked connections bundled together into an array.
6227 ** This gives the application an opportunity to prioritize any actions
6228 ** related to the set of unblocked database connections.
@@ -6236,20 +6121,20 @@
6236 ** connection Y's transaction to be concluded, and similarly connection
6237 ** Y is waiting on connection X's transaction, then neither connection
6238 ** will proceed and the system may remain deadlocked indefinitely.
6239 **
6240 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
6241 ** detection. If a given call to sqlite3_unlock_notify() would put the
6242 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
6243 ** unlock-notify callback is registered. The system is said to be in
6244 ** a deadlocked state if connection A has registered for an unlock-notify
6245 ** callback on the conclusion of connection B's transaction, and connection
6246 ** B has itself registered for an unlock-notify callback when connection
6247 ** A's transaction is concluded. Indirect deadlock is also detected, so
6248 ** the system is also considered to be deadlocked if connection B has
6249 ** registered for an unlock-notify callback on the conclusion of connection
6250 ** C's transaction, where connection C is waiting on connection A. Any
6251 ** number of levels of indirection are allowed.
6252 **
6253 ** <b>The "DROP TABLE" Exception</b>
6254 **
6255 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -6261,14 +6146,14 @@
6261 ** sqlite3_unlock_notify() results in the unlock-notify callback being
6262 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
6263 ** or "DROP INDEX" query, an infinite loop might be the result.
6264 **
6265 ** One way around this problem is to check the extended error code returned
6266 ** by an sqlite3_step() call. If there is a blocking connection, then the
6267 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
6268 ** the special "DROP TABLE/INDEX" case, the extended error code is just
6269 ** SQLITE_LOCKED.
6270 */
6271 SQLITE_API int sqlite3_unlock_notify(
6272 sqlite3 *pBlocked, /* Waiting connection */
6273 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
6274 void *pNotifyArg /* Argument to pass to xNotify */
@@ -6277,11 +6162,11 @@
6277
6278 /*
6279 ** CAPI3REF: String Comparison
6280 ** EXPERIMENTAL
6281 **
6282 ** The [sqlite3_strnicmp()] API allows applications and extensions to
6283 ** compare the contents of two buffers containing UTF-8 strings in a
6284 ** case-indendent fashion, using the same definition of case independence
6285 ** that SQLite uses internally when comparing identifiers.
6286 */
6287 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
@@ -6507,34 +6392,34 @@
6507 #define TK_UNIQUE 100
6508 #define TK_CHECK 101
6509 #define TK_REFERENCES 102
6510 #define TK_AUTOINCR 103
6511 #define TK_ON 104
6512 #define TK_DELETE 105
6513 #define TK_UPDATE 106
6514 #define TK_SET 107
6515 #define TK_DEFERRABLE 108
6516 #define TK_FOREIGN 109
6517 #define TK_DROP 110
6518 #define TK_UNION 111
6519 #define TK_ALL 112
6520 #define TK_EXCEPT 113
6521 #define TK_INTERSECT 114
6522 #define TK_SELECT 115
6523 #define TK_DISTINCT 116
6524 #define TK_DOT 117
6525 #define TK_FROM 118
6526 #define TK_JOIN 119
6527 #define TK_USING 120
6528 #define TK_ORDER 121
6529 #define TK_GROUP 122
6530 #define TK_HAVING 123
6531 #define TK_LIMIT 124
6532 #define TK_WHERE 125
6533 #define TK_INTO 126
6534 #define TK_VALUES 127
6535 #define TK_INSERT 128
6536 #define TK_INTEGER 129
6537 #define TK_FLOAT 130
6538 #define TK_BLOB 131
6539 #define TK_REGISTER 132
6540 #define TK_VARIABLE 133
@@ -8506,41 +8391,47 @@
8506 ** A macro to discover the encoding of a database.
8507 */
8508 #define ENC(db) ((db)->aDb[0].pSchema->enc)
8509
8510 /*
8511 ** Possible values for the sqlite.flags and or Db.flags fields.
8512 **
8513 ** On sqlite.flags, the SQLITE_InTrans value means that we have
8514 ** executed a BEGIN. On Db.flags, SQLITE_InTrans means a statement
8515 ** transaction is active on that particular database file.
8516 */
8517 #define SQLITE_VdbeTrace 0x00000001 /* True to trace VDBE execution */
8518 #define SQLITE_InTrans 0x00000008 /* True if in a transaction */
8519 #define SQLITE_InternChanges 0x00000010 /* Uncommitted Hash table changes */
8520 #define SQLITE_FullColNames 0x00000020 /* Show full column names on SELECT */
8521 #define SQLITE_ShortColNames 0x00000040 /* Show short columns names */
8522 #define SQLITE_CountRows 0x00000080 /* Count rows changed by INSERT, */
8523 /* DELETE, or UPDATE and return */
8524 /* the count using a callback. */
8525 #define SQLITE_NullCallback 0x00000100 /* Invoke the callback once if the */
8526 /* result set is empty */
8527 #define SQLITE_SqlTrace 0x00000200 /* Debug print SQL as it executes */
8528 #define SQLITE_VdbeListing 0x00000400 /* Debug listings of VDBE programs */
8529 #define SQLITE_WriteSchema 0x00000800 /* OK to update SQLITE_MASTER */
8530 #define SQLITE_NoReadlock 0x00001000 /* Readlocks are omitted when
8531 ** accessing read-only databases */
8532 #define SQLITE_IgnoreChecks 0x00002000 /* Do not enforce check constraints */
8533 #define SQLITE_ReadUncommitted 0x00004000 /* For shared-cache mode */
8534 #define SQLITE_LegacyFileFmt 0x00008000 /* Create new databases in format 1 */
8535 #define SQLITE_FullFSync 0x00010000 /* Use full fsync on the backend */
8536 #define SQLITE_LoadExtension 0x00020000 /* Enable load_extension */
8537
8538 #define SQLITE_RecoveryMode 0x00040000 /* Ignore schema errors */
8539 #define SQLITE_ReverseOrder 0x00100000 /* Reverse unordered SELECTs */
8540 #define SQLITE_RecTriggers 0x00200000 /* Enable recursive triggers */
8541 #define SQLITE_ForeignKeys 0x00400000 /* Enforce foreign key constraints */
 
 
 
 
 
 
 
 
 
 
 
8542
8543 /*
8544 ** Possible values for the sqlite.magic field.
8545 ** The numbers are obtained at random and have no special meaning, other
8546 ** than being distinct from one another.
@@ -9250,18 +9141,17 @@
9250 #define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */
9251 #define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */
9252 #define EP_DblQuoted 0x0040 /* token.z was originally in "..." */
9253 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
9254 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
9255 #define EP_AnyAff 0x0200 /* Can take a cached column of any affinity */
9256 #define EP_FixedDest 0x0400 /* Result needed in a specific register */
9257 #define EP_IntValue 0x0800 /* Integer value contained in u.iValue */
9258 #define EP_xIsSelect 0x1000 /* x.pSelect is valid (otherwise x.pList is) */
9259
9260 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
9261 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
9262 #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
9263
9264 /*
9265 ** The following are the meanings of bits in the Expr.flags2 field.
9266 */
9267 #define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */
@@ -9502,10 +9392,11 @@
9502 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
9503 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
9504 #define WHERE_OMIT_OPEN 0x0010 /* Table cursor are already open */
9505 #define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */
9506 #define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */
 
9507
9508 /*
9509 ** The WHERE clause processing routine has two halves. The
9510 ** first part does the start of the WHERE loop and the second
9511 ** half does the tail of the WHERE loop. An instance of
@@ -9514,10 +9405,11 @@
9514 */
9515 struct WhereInfo {
9516 Parse *pParse; /* Parsing and code generating context */
9517 u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
9518 u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */
 
9519 SrcList *pTabList; /* List of tables in the join */
9520 int iTop; /* The very beginning of the WHERE loop */
9521 int iContinue; /* Jump here to continue with next record */
9522 int iBreak; /* Jump here to break out of the loop */
9523 int nLevel; /* Number of nested loop */
@@ -9733,11 +9625,10 @@
9733 u8 nColCache; /* Number of entries in the column cache */
9734 u8 iColCache; /* Next entry of the cache to replace */
9735 struct yColCache {
9736 int iTable; /* Table cursor number */
9737 int iColumn; /* Table column number */
9738 u8 affChange; /* True if this register has had an affinity change */
9739 u8 tempReg; /* iReg is a temp register that needs to be freed */
9740 int iLevel; /* Nesting level */
9741 int iReg; /* Reg with value of this column. 0 means none. */
9742 int lru; /* Least recently used entry has the smallest value */
9743 } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */
@@ -10252,17 +10143,17 @@
10252 #endif
10253 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
10254 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
10255 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16);
10256 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
10257 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, int);
10258 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
10259 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
10260 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
10261 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
10262 SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);
10263 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int);
10264 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
10265 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
10266 SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse*,int,int);
10267 SQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int);
10268 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
@@ -48266,22 +48157,25 @@
48266 **
48267 ** When p->explain==1, each instruction is listed. When
48268 ** p->explain==2, only OP_Explain instructions are listed and these
48269 ** are shown in a different format. p->explain==2 is used to implement
48270 ** EXPLAIN QUERY PLAN.
 
 
 
48271 */
48272 SQLITE_PRIVATE int sqlite3VdbeList(
48273 Vdbe *p /* The VDBE */
48274 ){
48275 int nRow; /* Total number of rows to return */
48276 int nSub = 0; /* Number of sub-vdbes seen so far */
48277 SubProgram **apSub = 0; /* Array of sub-vdbes */
48278 Mem *pSub = 0;
48279 sqlite3 *db = p->db;
48280 int i;
48281 int rc = SQLITE_OK;
48282 Mem *pMem = p->pResultSet = &p->aMem[1];
48283
48284 assert( p->explain );
48285 assert( p->magic==VDBE_MAGIC_RUN );
48286 assert( db->magic==SQLITE_MAGIC_BUSY );
48287 assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
@@ -48297,16 +48191,28 @@
48297 ** sqlite3_column_text16() failed. */
48298 db->mallocFailed = 1;
48299 return SQLITE_ERROR;
48300 }
48301
48302 /* Figure out total number of rows that will be returned by this
48303 ** EXPLAIN program. */
 
 
 
 
 
48304 nRow = p->nOp;
48305 if( p->explain==1 ){
 
 
 
 
 
48306 pSub = &p->aMem[9];
48307 if( pSub->flags&MEM_Blob ){
 
 
48308 nSub = pSub->n/sizeof(Vdbe*);
48309 apSub = (SubProgram **)pSub->z;
48310 }
48311 for(i=0; i<nSub; i++){
48312 nRow += apSub[i]->nOp;
@@ -48325,12 +48231,16 @@
48325 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc));
48326 }else{
48327 char *z;
48328 Op *pOp;
48329 if( i<p->nOp ){
 
 
48330 pOp = &p->aOp[i];
48331 }else{
 
 
48332 int j;
48333 i -= p->nOp;
48334 for(j=0; i>=apSub[j]->nOp; j++){
48335 i -= apSub[j]->nOp;
48336 }
@@ -48348,10 +48258,15 @@
48348 pMem->n = sqlite3Strlen30(pMem->z);
48349 pMem->type = SQLITE_TEXT;
48350 pMem->enc = SQLITE_UTF8;
48351 pMem++;
48352
 
 
 
 
 
48353 if( pOp->p4type==P4_SUBPROGRAM ){
48354 int nByte = (nSub+1)*sizeof(SubProgram*);
48355 int j;
48356 for(j=0; j<nSub; j++){
48357 if( apSub[j]==pOp->p4.pProgram ) break;
@@ -48479,42 +48394,47 @@
48479 }
48480 }
48481 #endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
48482
48483 /*
48484 ** Allocate space from a fixed size buffer. Make *pp point to the
48485 ** allocated space. (Note: pp is a char* rather than a void** to
48486 ** work around the pointer aliasing rules of C.) *pp should initially
48487 ** be zero. If *pp is not zero, that means that the space has already
48488 ** been allocated and this routine is a noop.
 
 
 
 
48489 **
48490 ** nByte is the number of bytes of space needed.
48491 **
48492 ** *ppFrom point to available space and pEnd points to the end of the
48493 ** available space.
 
48494 **
48495 ** *pnByte is a counter of the number of bytes of space that have failed
48496 ** to allocate. If there is insufficient space in *ppFrom to satisfy the
48497 ** request, then increment *pnByte by the amount of the request.
48498 */
48499 static void allocSpace(
48500 char *pp, /* IN/OUT: Set *pp to point to allocated buffer */
48501 int nByte, /* Number of bytes to allocate */
48502 u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
48503 u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
48504 int *pnByte /* If allocation cannot be made, increment *pnByte */
48505 ){
48506 assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
48507 if( (*(void**)pp)==0 ){
48508 nByte = ROUND8(nByte);
48509 if( &(*ppFrom)[nByte] <= pEnd ){
48510 *(void**)pp = (void *)*ppFrom;
48511 *ppFrom += nByte;
48512 }else{
48513 *pnByte += nByte;
48514 }
48515 }
48516 }
48517
48518 /*
48519 ** Prepare a virtual machine for execution. This involves things such
48520 ** as allocating stack space and initializing the program counter.
@@ -48569,31 +48489,41 @@
48569 ** an array to marshal SQL function arguments in. This is only done the
48570 ** first time this function is called for a given VDBE, not when it is
48571 ** being called from sqlite3_reset() to reset the virtual machine.
48572 */
48573 if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
48574 u8 *zCsr = (u8 *)&p->aOp[p->nOp];
48575 u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc];
48576 int nByte;
 
48577 resolveP2Values(p, &nArg);
48578 p->usesStmtJournal = (u8)usesStmtJournal;
48579 if( isExplain && nMem<10 ){
48580 nMem = 10;
48581 }
48582 memset(zCsr, 0, zEnd-zCsr);
48583 zCsr += (zCsr - (u8*)0)&7;
48584 assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
48585
 
 
 
 
 
 
 
 
 
 
48586 do {
48587 nByte = 0;
48588 allocSpace((char*)&p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
48589 allocSpace((char*)&p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
48590 allocSpace((char*)&p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
48591 allocSpace((char*)&p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
48592 allocSpace((char*)&p->apCsr,
48593 nCursor*sizeof(VdbeCursor*), &zCsr, zEnd, &nByte
48594 );
48595 if( nByte ){
48596 p->pFree = sqlite3DbMallocZero(db, nByte);
48597 }
48598 zCsr = p->pFree;
48599 zEnd = &zCsr[nByte];
@@ -48931,14 +48861,15 @@
48931 ** still have 'null' as the master journal pointer, so they will roll
48932 ** back independently if a failure occurs.
48933 */
48934 for(i=0; i<db->nDb; i++){
48935 Btree *pBt = db->aDb[i].pBt;
48936 if( i==1 ) continue; /* Ignore the TEMP database */
48937 if( sqlite3BtreeIsInTrans(pBt) ){
48938 char const *zFile = sqlite3BtreeGetJournalname(pBt);
48939 if( zFile[0]==0 ) continue; /* Ignore :memory: databases */
 
 
48940 if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
48941 needSync = 1;
48942 }
48943 rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
48944 offset += sqlite3Strlen30(zFile)+1;
@@ -50780,12 +50711,13 @@
50780 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
50781 Mem *pMem;
50782 assert( p && p->pFunc && p->pFunc->xStep );
50783 assert( sqlite3_mutex_held(p->s.db->mutex) );
50784 pMem = p->pMem;
 
50785 if( (pMem->flags & MEM_Agg)==0 ){
50786 if( nByte==0 ){
50787 sqlite3VdbeMemReleaseExternal(pMem);
50788 pMem->flags = MEM_Null;
50789 pMem->z = 0;
50790 }else{
50791 sqlite3VdbeMemGrow(pMem, nByte, 0);
@@ -55878,19 +55810,19 @@
55878 rc = sqlite3BtreeLast(u.be.pC->pCursor, &u.be.res);
55879 if( rc!=SQLITE_OK ){
55880 goto abort_due_to_error;
55881 }
55882 if( u.be.res ){
55883 u.be.v = 1;
55884 }else{
55885 assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) );
55886 rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v);
55887 assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
55888 if( u.be.v==MAX_ROWID ){
55889 u.be.pC->useRandomRowid = 1;
55890 }else{
55891 u.be.v++;
55892 }
55893 }
55894 }
55895
55896 #ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -55910,11 +55842,11 @@
55910
55911 REGISTER_TRACE(pOp->p3, u.be.pMem);
55912 sqlite3VdbeMemIntegerify(u.be.pMem);
55913 assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
55914 if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
55915 rc = SQLITE_FULL;
55916 goto abort_due_to_error;
55917 }
55918 if( u.be.v<u.be.pMem->u.i+1 ){
55919 u.be.v = u.be.pMem->u.i + 1;
55920 }
@@ -55923,10 +55855,15 @@
55923 #endif
55924
55925 sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0);
55926 }
55927 if( u.be.pC->useRandomRowid ){
 
 
 
 
 
55928 assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
55929 ** an AUTOINCREMENT table. */
55930 u.be.v = db->lastRowid;
55931 u.be.cnt = 0;
55932 do{
@@ -55938,11 +55875,11 @@
55938 }
55939 rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res);
55940 u.be.cnt++;
55941 }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
55942 if( rc==SQLITE_OK && u.be.res==0 ){
55943 rc = SQLITE_FULL;
55944 goto abort_due_to_error;
55945 }
55946 }
55947 u.be.pC->rowidIsValid = 0;
55948 u.be.pC->deferredMoveto = 0;
@@ -59317,22 +59254,21 @@
59317
59318 if( pTab ){
59319 int iCol;
59320 pSchema = pTab->pSchema;
59321 cntTab++;
59322 if( sqlite3IsRowid(zCol) ){
59323 iCol = -1;
59324 }else{
59325 for(iCol=0; iCol<pTab->nCol; iCol++){
59326 Column *pCol = &pTab->aCol[iCol];
59327 if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
59328 if( iCol==pTab->iPKey ){
59329 iCol = -1;
59330 }
59331 break;
59332 }
59333 }
59334 }
59335 if( iCol<pTab->nCol ){
59336 cnt++;
59337 if( iCol<0 ){
59338 pExpr->affinity = SQLITE_AFF_INTEGER;
@@ -59356,11 +59292,11 @@
59356 /*
59357 ** Perhaps the name is a reference to the ROWID
59358 */
59359 if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
59360 cnt = 1;
59361 pExpr->iColumn = -1;
59362 pExpr->affinity = SQLITE_AFF_INTEGER;
59363 }
59364
59365 /*
59366 ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
@@ -60500,34 +60436,10 @@
60500 }
60501 }
60502 return pColl;
60503 }
60504
60505 /*
60506 ** Generate the operands for a comparison operation. Before
60507 ** generating the code for each operand, set the EP_AnyAff
60508 ** flag on the expression so that it will be able to used a
60509 ** cached column value that has previously undergone an
60510 ** affinity change.
60511 */
60512 static void codeCompareOperands(
60513 Parse *pParse, /* Parsing and code generating context */
60514 Expr *pLeft, /* The left operand */
60515 int *pRegLeft, /* Register where left operand is stored */
60516 int *pFreeLeft, /* Free this register when done */
60517 Expr *pRight, /* The right operand */
60518 int *pRegRight, /* Register where right operand is stored */
60519 int *pFreeRight /* Write temp register for right operand there */
60520 ){
60521 while( pLeft->op==TK_UPLUS ) pLeft = pLeft->pLeft;
60522 pLeft->flags |= EP_AnyAff;
60523 *pRegLeft = sqlite3ExprCodeTemp(pParse, pLeft, pFreeLeft);
60524 while( pRight->op==TK_UPLUS ) pRight = pRight->pLeft;
60525 pRight->flags |= EP_AnyAff;
60526 *pRegRight = sqlite3ExprCodeTemp(pParse, pRight, pFreeRight);
60527 }
60528
60529 /*
60530 ** Generate code for a comparison operator.
60531 */
60532 static int codeCompare(
60533 Parse *pParse, /* The parsing (and code generating) context */
@@ -62255,30 +62167,43 @@
62255 struct yColCache *p;
62256
62257 assert( iReg>0 ); /* Register numbers are always positive */
62258 assert( iCol>=-1 && iCol<32768 ); /* Finite column numbers */
62259
62260 /* First replace any existing entry */
 
 
 
 
 
 
 
 
 
 
 
62261 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
 
62262 if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
62263 cacheEntryClear(pParse, p);
62264 p->iLevel = pParse->iCacheLevel;
62265 p->iReg = iReg;
62266 p->affChange = 0;
62267 p->lru = pParse->iCacheCnt++;
62268 return;
62269 }
 
 
62270 }
 
62271
62272 /* Find an empty slot and replace it */
62273 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62274 if( p->iReg==0 ){
62275 p->iLevel = pParse->iCacheLevel;
62276 p->iTable = iTab;
62277 p->iColumn = iCol;
62278 p->iReg = iReg;
62279 p->affChange = 0;
62280 p->tempReg = 0;
62281 p->lru = pParse->iCacheCnt++;
62282 return;
62283 }
62284 }
@@ -62296,26 +62221,27 @@
62296 p = &pParse->aColCache[idxLru];
62297 p->iLevel = pParse->iCacheLevel;
62298 p->iTable = iTab;
62299 p->iColumn = iCol;
62300 p->iReg = iReg;
62301 p->affChange = 0;
62302 p->tempReg = 0;
62303 p->lru = pParse->iCacheCnt++;
62304 return;
62305 }
62306 }
62307
62308 /*
62309 ** Indicate that a register is being overwritten. Purge the register
62310 ** from the column cache.
62311 */
62312 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg){
62313 int i;
 
62314 struct yColCache *p;
62315 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62316 if( p->iReg==iReg ){
 
62317 cacheEntryClear(pParse, p);
62318 p->iReg = 0;
62319 }
62320 }
62321 }
@@ -62370,32 +62296,24 @@
62370 ** is made to store the column value in register iReg, but this is
62371 ** not guaranteed. The location of the column value is returned.
62372 **
62373 ** There must be an open cursor to pTab in iTable when this routine
62374 ** is called. If iColumn<0 then code is generated that extracts the rowid.
62375 **
62376 ** This routine might attempt to reuse the value of the column that
62377 ** has already been loaded into a register. The value will always
62378 ** be used if it has not undergone any affinity changes. But if
62379 ** an affinity change has occurred, then the cached value will only be
62380 ** used if allowAffChng is true.
62381 */
62382 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
62383 Parse *pParse, /* Parsing and code generating context */
62384 Table *pTab, /* Description of the table we are reading from */
62385 int iColumn, /* Index of the table column */
62386 int iTable, /* The cursor pointing to the table */
62387 int iReg, /* Store results here */
62388 int allowAffChng /* True if prior affinity changes are OK */
62389 ){
62390 Vdbe *v = pParse->pVdbe;
62391 int i;
62392 struct yColCache *p;
62393
62394 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62395 if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn
62396 && (!p->affChange || allowAffChng) ){
62397 p->lru = pParse->iCacheCnt++;
62398 sqlite3ExprCachePinRegister(pParse, p->iReg);
62399 return p->iReg;
62400 }
62401 }
@@ -62429,19 +62347,11 @@
62429 /*
62430 ** Record the fact that an affinity change has occurred on iCount
62431 ** registers starting with iStart.
62432 */
62433 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
62434 int iEnd = iStart + iCount - 1;
62435 int i;
62436 struct yColCache *p;
62437 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62438 int r = p->iReg;
62439 if( r>=iStart && r<=iEnd ){
62440 p->affChange = 1;
62441 }
62442 }
62443 }
62444
62445 /*
62446 ** Generate code to move content from registers iFrom...iFrom+nReg-1
62447 ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.
@@ -62469,23 +62379,28 @@
62469 for(i=0; i<nReg; i++){
62470 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, iFrom+i, iTo+i);
62471 }
62472 }
62473
 
62474 /*
62475 ** Return true if any register in the range iFrom..iTo (inclusive)
62476 ** is used as part of the column cache.
 
 
 
62477 */
62478 static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
62479 int i;
62480 struct yColCache *p;
62481 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62482 int r = p->iReg;
62483 if( r>=iFrom && r<=iTo ) return 1;
62484 }
62485 return 0;
62486 }
 
62487
62488 /*
62489 ** If the last instruction coded is an ephemeral copy of any of
62490 ** the registers in the nReg registers beginning with iReg, then
62491 ** convert the last instruction from OP_SCopy to OP_Copy.
@@ -62602,14 +62517,12 @@
62602 if( pExpr->iTable<0 ){
62603 /* This only happens when coding check constraints */
62604 assert( pParse->ckBase>0 );
62605 inReg = pExpr->iColumn + pParse->ckBase;
62606 }else{
62607 testcase( (pExpr->flags & EP_AnyAff)!=0 );
62608 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
62609 pExpr->iColumn, pExpr->iTable, target,
62610 pExpr->flags & EP_AnyAff);
62611 }
62612 break;
62613 }
62614 case TK_INTEGER: {
62615 codeInteger(v, pExpr, 0, target);
@@ -62722,12 +62635,12 @@
62722 testcase( op==TK_LE );
62723 testcase( op==TK_GT );
62724 testcase( op==TK_GE );
62725 testcase( op==TK_EQ );
62726 testcase( op==TK_NE );
62727 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62728 pExpr->pRight, &r2, &regFree2);
62729 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62730 r1, r2, inReg, SQLITE_STOREP2);
62731 testcase( regFree1==0 );
62732 testcase( regFree2==0 );
62733 break;
@@ -62734,12 +62647,12 @@
62734 }
62735 case TK_IS:
62736 case TK_ISNOT: {
62737 testcase( op==TK_IS );
62738 testcase( op==TK_ISNOT );
62739 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
62740 pExpr->pRight, &r2, &regFree2);
62741 op = (op==TK_IS) ? TK_EQ : TK_NE;
62742 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62743 r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
62744 testcase( regFree1==0 );
62745 testcase( regFree2==0 );
@@ -62879,11 +62792,11 @@
62879 int endCoalesce = sqlite3VdbeMakeLabel(v);
62880 assert( nFarg>=2 );
62881 sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
62882 for(i=1; i<nFarg; i++){
62883 sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
62884 sqlite3ExprCacheRemove(pParse, target);
62885 sqlite3ExprCachePush(pParse);
62886 sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
62887 sqlite3ExprCachePop(pParse, 1);
62888 }
62889 sqlite3VdbeResolveLabel(v, endCoalesce);
@@ -62934,11 +62847,10 @@
62934 (char*)pDef, P4_FUNCDEF);
62935 sqlite3VdbeChangeP5(v, (u8)nFarg);
62936 if( nFarg ){
62937 sqlite3ReleaseTempRange(pParse, r1, nFarg);
62938 }
62939 sqlite3ExprCacheAffinityChange(pParse, r1, nFarg);
62940 break;
62941 }
62942 #ifndef SQLITE_OMIT_SUBQUERY
62943 case TK_EXISTS:
62944 case TK_SELECT: {
@@ -62975,12 +62887,12 @@
62975 case TK_BETWEEN: {
62976 Expr *pLeft = pExpr->pLeft;
62977 struct ExprList_item *pLItem = pExpr->x.pList->a;
62978 Expr *pRight = pLItem->pExpr;
62979
62980 codeCompareOperands(pParse, pLeft, &r1, &regFree1,
62981 pRight, &r2, &regFree2);
62982 testcase( regFree1==0 );
62983 testcase( regFree2==0 );
62984 r3 = sqlite3GetTempReg(pParse);
62985 r4 = sqlite3GetTempReg(pParse);
62986 codeCompare(pParse, pLeft, pRight, OP_Ge,
@@ -63511,12 +63423,12 @@
63511 testcase( op==TK_GT );
63512 testcase( op==TK_GE );
63513 testcase( op==TK_EQ );
63514 testcase( op==TK_NE );
63515 testcase( jumpIfNull==0 );
63516 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63517 pExpr->pRight, &r2, &regFree2);
63518 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63519 r1, r2, dest, jumpIfNull);
63520 testcase( regFree1==0 );
63521 testcase( regFree2==0 );
63522 break;
@@ -63523,12 +63435,12 @@
63523 }
63524 case TK_IS:
63525 case TK_ISNOT: {
63526 testcase( op==TK_IS );
63527 testcase( op==TK_ISNOT );
63528 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63529 pExpr->pRight, &r2, &regFree2);
63530 op = (op==TK_IS) ? TK_EQ : TK_NE;
63531 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63532 r1, r2, dest, SQLITE_NULLEQ);
63533 testcase( regFree1==0 );
63534 testcase( regFree2==0 );
@@ -63654,12 +63566,12 @@
63654 testcase( op==TK_GT );
63655 testcase( op==TK_GE );
63656 testcase( op==TK_EQ );
63657 testcase( op==TK_NE );
63658 testcase( jumpIfNull==0 );
63659 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63660 pExpr->pRight, &r2, &regFree2);
63661 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63662 r1, r2, dest, jumpIfNull);
63663 testcase( regFree1==0 );
63664 testcase( regFree2==0 );
63665 break;
@@ -63666,12 +63578,12 @@
63666 }
63667 case TK_IS:
63668 case TK_ISNOT: {
63669 testcase( pExpr->op==TK_IS );
63670 testcase( pExpr->op==TK_ISNOT );
63671 codeCompareOperands(pParse, pExpr->pLeft, &r1, &regFree1,
63672 pExpr->pRight, &r2, &regFree2);
63673 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
63674 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63675 r1, r2, dest, SQLITE_NULLEQ);
63676 testcase( regFree1==0 );
63677 testcase( regFree2==0 );
@@ -64014,20 +63926,22 @@
64014 */
64015 SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
64016 int i, n;
64017 i = pParse->iRangeReg;
64018 n = pParse->nRangeReg;
64019 if( nReg<=n && !usedAsColumnCache(pParse, i, i+n-1) ){
 
64020 pParse->iRangeReg += nReg;
64021 pParse->nRangeReg -= nReg;
64022 }else{
64023 i = pParse->nMem+1;
64024 pParse->nMem += nReg;
64025 }
64026 return i;
64027 }
64028 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
 
64029 if( nReg>pParse->nRangeReg ){
64030 pParse->nRangeReg = nReg;
64031 pParse->iRangeReg = iReg;
64032 }
64033 }
@@ -66818,11 +66732,12 @@
66818 Table *p;
66819 Db *pDb;
66820
66821 assert( db!=0 );
66822 assert( iDb>=0 && iDb<db->nDb );
66823 assert( zTabName && zTabName[0] );
 
66824 pDb = &db->aDb[iDb];
66825 p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
66826 sqlite3Strlen30(zTabName),0);
66827 sqlite3DeleteTable(p);
66828 db->flags |= SQLITE_InternChanges;
@@ -69685,11 +69600,10 @@
69685 sqlite3ErrorMsg(pParse, "unable to open a temporary database "
69686 "file for storing temporary tables");
69687 pParse->rc = rc;
69688 return 1;
69689 }
69690 assert( (db->flags & SQLITE_InTrans)==0 || db->autoCommit );
69691 assert( db->aDb[1].pSchema );
69692 sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt),
69693 db->dfltJournalMode);
69694 }
69695 return 0;
@@ -70791,11 +70705,11 @@
70791 /* Collect rowids of every row to be deleted.
70792 */
70793 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
70794 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,WHERE_DUPLICATES_OK);
70795 if( pWInfo==0 ) goto delete_from_cleanup;
70796 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
70797 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
70798 if( db->flags & SQLITE_CountRows ){
70799 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
70800 }
70801 sqlite3WhereEnd(pWInfo);
@@ -71057,11 +70971,10 @@
71057 }
71058 }
71059 if( doMakeRec ){
71060 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
71061 sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
71062 sqlite3ExprCacheAffinityChange(pParse, regBase, nCol+1);
71063 }
71064 sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
71065 return regBase;
71066 }
71067
@@ -71180,33 +71093,45 @@
71180 }
71181 }
71182 }
71183
71184 /*
71185 ** Implementation of the abs() function
 
 
 
71186 */
71187 static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
71188 assert( argc==1 );
71189 UNUSED_PARAMETER(argc);
71190 switch( sqlite3_value_type(argv[0]) ){
71191 case SQLITE_INTEGER: {
71192 i64 iVal = sqlite3_value_int64(argv[0]);
71193 if( iVal<0 ){
71194 if( (iVal<<1)==0 ){
 
 
 
71195 sqlite3_result_error(context, "integer overflow", -1);
71196 return;
71197 }
71198 iVal = -iVal;
71199 }
71200 sqlite3_result_int64(context, iVal);
71201 break;
71202 }
71203 case SQLITE_NULL: {
 
71204 sqlite3_result_null(context);
71205 break;
71206 }
71207 default: {
 
 
 
 
 
71208 double rVal = sqlite3_value_double(argv[0]);
71209 if( rVal<0 ) rVal = -rVal;
71210 sqlite3_result_double(context, rVal);
71211 break;
71212 }
@@ -72104,13 +72029,20 @@
72104 }
72105 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
72106 }
72107
72108
 
 
 
 
72109 #ifdef SQLITE_SOUNDEX
72110 /*
72111 ** Compute the soundex encoding of a word.
 
 
 
72112 */
72113 static void soundexFunc(
72114 sqlite3_context *context,
72115 int argc,
72116 sqlite3_value **argv
@@ -72150,14 +72082,16 @@
72150 zResult[j++] = '0';
72151 }
72152 zResult[j] = 0;
72153 sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);
72154 }else{
 
 
72155 sqlite3_result_text(context, "?000", 4, SQLITE_STATIC);
72156 }
72157 }
72158 #endif
72159
72160 #ifndef SQLITE_OMIT_LOAD_EXTENSION
72161 /*
72162 ** A function that loads a shared-library extension then returns NULL.
72163 */
@@ -78623,11 +78557,11 @@
78623 if( rc!=SQLITE_OK ) return;
78624 openedTransaction = 1;
78625 }
78626
78627 /* Read the schema cookie from the database. If it does not match the
78628 ** value stored as part of the in the in-memory schema representation,
78629 ** set Parse.rc to SQLITE_SCHEMA. */
78630 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);
78631 if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){
78632 pParse->rc = SQLITE_SCHEMA;
78633 }
@@ -79215,10 +79149,43 @@
79215 for(i=0; i<pTab->nCol; i++){
79216 if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
79217 }
79218 return -1;
79219 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79220
79221 /*
79222 ** This function is used to add terms implied by JOIN syntax to the
79223 ** WHERE clause expression of a SELECT statement. The new term, which
79224 ** is ANDed with the existing WHERE clause, is of the form:
@@ -79230,27 +79197,29 @@
79230 ** column iColRight of tab2.
79231 */
79232 static void addWhereTerm(
79233 Parse *pParse, /* Parsing context */
79234 SrcList *pSrc, /* List of tables in FROM clause */
79235 int iSrc, /* Index of first table to join in pSrc */
79236 int iColLeft, /* Index of column in first table */
 
79237 int iColRight, /* Index of column in second table */
79238 int isOuterJoin, /* True if this is an OUTER join */
79239 Expr **ppWhere /* IN/OUT: The WHERE clause to add to */
79240 ){
79241 sqlite3 *db = pParse->db;
79242 Expr *pE1;
79243 Expr *pE2;
79244 Expr *pEq;
79245
79246 assert( pSrc->nSrc>(iSrc+1) );
79247 assert( pSrc->a[iSrc].pTab );
79248 assert( pSrc->a[iSrc+1].pTab );
 
79249
79250 pE1 = sqlite3CreateColumnExpr(db, pSrc, iSrc, iColLeft);
79251 pE2 = sqlite3CreateColumnExpr(db, pSrc, iSrc+1, iColRight);
79252
79253 pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
79254 if( pEq && isOuterJoin ){
79255 ExprSetProperty(pEq, EP_FromJoin);
79256 assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
@@ -79335,15 +79304,19 @@
79335 if( pRight->pOn || pRight->pUsing ){
79336 sqlite3ErrorMsg(pParse, "a NATURAL join may not have "
79337 "an ON or USING clause", 0);
79338 return 1;
79339 }
79340 for(j=0; j<pLeftTab->nCol; j++){
79341 char *zName = pLeftTab->aCol[j].zName;
79342 int iRightCol = columnIndex(pRightTab, zName);
79343 if( iRightCol>=0 ){
79344 addWhereTerm(pParse, pSrc, i, j, iRightCol, isOuter, &p->pWhere);
 
 
 
 
79345 }
79346 }
79347 }
79348
79349 /* Disallow both ON and USING clauses in the same join
@@ -79371,19 +79344,26 @@
79371 ** not contained in both tables to be joined.
79372 */
79373 if( pRight->pUsing ){
79374 IdList *pList = pRight->pUsing;
79375 for(j=0; j<pList->nId; j++){
79376 char *zName = pList->a[j].zName;
79377 int iLeftCol = columnIndex(pLeftTab, zName);
79378 int iRightCol = columnIndex(pRightTab, zName);
79379 if( iLeftCol<0 || iRightCol<0 ){
 
 
 
 
 
 
79380 sqlite3ErrorMsg(pParse, "cannot join using column %s - column "
79381 "not present in both tables", zName);
79382 return 1;
79383 }
79384 addWhereTerm(pParse, pSrc, i, iLeftCol, iRightCol, isOuter, &p->pWhere);
 
79385 }
79386 }
79387 }
79388 return 0;
79389 }
@@ -79938,11 +79918,11 @@
79938 if( pS ){
79939 /* The "table" is actually a sub-select or a view in the FROM clause
79940 ** of the SELECT statement. Return the declaration type and origin
79941 ** data for the result-set column of the sub-select.
79942 */
79943 if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){
79944 /* If iCol is less than zero, then the expression requests the
79945 ** rowid of the sub-select or view. This expression is legal (see
79946 ** test case misc2.2.2) - it always evaluates to NULL.
79947 */
79948 NameContext sNC;
@@ -81499,11 +81479,11 @@
81499 ** (10) The subquery does not use aggregates or the outer query does not
81500 ** use LIMIT.
81501 **
81502 ** (11) The subquery and the outer query do not both have ORDER BY clauses.
81503 **
81504 ** (12) Not implemented. Subsumed into restriction (3). Was previously
81505 ** a separate restriction deriving from ticket #350.
81506 **
81507 ** (13) The subquery and outer query do not both use LIMIT
81508 **
81509 ** (14) The subquery does not use OFFSET
@@ -81573,10 +81553,11 @@
81573
81574 /* Check to see if flattening is permitted. Return 0 if not.
81575 */
81576 assert( p!=0 );
81577 assert( p->pPrior==0 ); /* Unable to flatten compound queries */
 
81578 pSrc = p->pSrc;
81579 assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
81580 pSubitem = &pSrc->a[iFrom];
81581 iParent = pSubitem->iCursor;
81582 pSub = pSubitem->pSelect;
@@ -82196,18 +82177,18 @@
82196 assert(IsVirtual(pTab));
82197 continue;
82198 }
82199
82200 if( i>0 && zTName==0 ){
82201 struct SrcList_item *pLeft = &pTabList->a[i-1];
82202 if( (pLeft[1].jointype & JT_NATURAL)!=0 &&
82203 columnIndex(pLeft->pTab, zName)>=0 ){
82204 /* In a NATURAL join, omit the join columns from the
82205 ** table on the right */
82206 continue;
82207 }
82208 if( sqlite3IdListIndex(pLeft[1].pUsing, zName)>=0 ){
82209 /* In a join with a USING clause, omit columns in the
82210 ** using clause from the table on the right. */
82211 continue;
82212 }
82213 }
@@ -82470,12 +82451,12 @@
82470 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
82471 }
82472 sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
82473 (void*)pF->pFunc, P4_FUNCDEF);
82474 sqlite3VdbeChangeP5(v, (u8)nArg);
82475 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
82476 sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
 
82477 if( addrNext ){
82478 sqlite3VdbeResolveLabel(v, addrNext);
82479 sqlite3ExprCacheClear(pParse);
82480 }
82481 }
@@ -82897,11 +82878,11 @@
82897 if( pCol->iSorterColumn>=j ){
82898 int r1 = j + regBase;
82899 int r2;
82900
82901 r2 = sqlite3ExprCodeGetColumn(pParse,
82902 pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
82903 if( r1!=r2 ){
82904 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
82905 }
82906 j++;
82907 }
@@ -85309,10 +85290,11 @@
85309 Btree *pTemp; /* The temporary database we vacuum into */
85310 char *zSql = 0; /* SQL statements */
85311 int saved_flags; /* Saved value of the db->flags */
85312 int saved_nChange; /* Saved value of db->nChange */
85313 int saved_nTotalChange; /* Saved value of db->nTotalChange */
 
85314 Db *pDb = 0; /* Database to detach at end of vacuum */
85315 int isMemDb; /* True if vacuuming a :memory: database */
85316 int nRes;
85317
85318 if( !db->autoCommit ){
@@ -85324,12 +85306,14 @@
85324 ** restored before returning. Then set the writable-schema flag, and
85325 ** disable CHECK and foreign key constraints. */
85326 saved_flags = db->flags;
85327 saved_nChange = db->nChange;
85328 saved_nTotalChange = db->nTotalChange;
 
85329 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
85330 db->flags &= ~SQLITE_ForeignKeys;
 
85331
85332 pMain = db->aDb[0].pBt;
85333 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
85334
85335 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -85506,10 +85490,11 @@
85506 end_of_vacuum:
85507 /* Restore the original value of db->flags */
85508 db->flags = saved_flags;
85509 db->nChange = saved_nChange;
85510 db->nTotalChange = saved_nTotalChange;
 
85511
85512 /* Currently there is an SQL level transaction open on the vacuum
85513 ** database. No locks are held on any other files (since the main file
85514 ** was committed at the btree level). So it safe to end the transaction
85515 ** by manually setting the autoCommit flag to true and detaching the
@@ -86200,24 +86185,24 @@
86200 rc = SQLITE_NOMEM;
86201 }else{
86202 pParse->declareVtab = 1;
86203 pParse->db = db;
86204
86205 if(
86206 SQLITE_OK == sqlite3RunParser(pParse, zCreateTable, &zErr) &&
86207 pParse->pNewTable &&
86208 !pParse->pNewTable->pSelect &&
86209 (pParse->pNewTable->tabFlags & TF_Virtual)==0
86210 ){
86211 if( !pTab->aCol ){
86212 pTab->aCol = pParse->pNewTable->aCol;
86213 pTab->nCol = pParse->pNewTable->nCol;
86214 pParse->pNewTable->nCol = 0;
86215 pParse->pNewTable->aCol = 0;
86216 }
86217 db->pVTab = 0;
86218 } else {
86219 sqlite3Error(db, SQLITE_ERROR, zErr);
86220 sqlite3DbFree(db, zErr);
86221 rc = SQLITE_ERROR;
86222 }
86223 pParse->declareVtab = 0;
@@ -89653,11 +89638,11 @@
89653 ** range (if any).
89654 */
89655 nConstraint = nEq;
89656 if( pRangeEnd ){
89657 Expr *pRight = pRangeEnd->pExpr->pRight;
89658 sqlite3ExprCacheRemove(pParse, regBase+nEq);
89659 sqlite3ExprCode(pParse, pRight, regBase+nEq);
89660 sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
89661 if( zAff ){
89662 if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
89663 /* Since the comparison is to be performed with no conversions
@@ -89758,30 +89743,50 @@
89758 ** B: <after the loop>
89759 **
89760 */
89761 WhereClause *pOrWc; /* The OR-clause broken out into subterms */
89762 WhereTerm *pFinal; /* Final subterm within the OR-clause. */
89763 SrcList oneTab; /* Shortened table list */
89764
89765 int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
89766 int regRowset = 0; /* Register for RowSet object */
89767 int regRowid = 0; /* Register holding rowid */
89768 int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */
89769 int iRetInit; /* Address of regReturn init */
 
89770 int ii;
89771
89772 pTerm = pLevel->plan.u.pTerm;
89773 assert( pTerm!=0 );
89774 assert( pTerm->eOperator==WO_OR );
89775 assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
89776 pOrWc = &pTerm->u.pOrInfo->wc;
89777 pFinal = &pOrWc->a[pOrWc->nTerm-1];
 
 
89778
89779 /* Set up a SrcList containing just the table being scanned by this loop. */
89780 oneTab.nSrc = 1;
89781 oneTab.nAlloc = 1;
89782 oneTab.a[0] = *pTabItem;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
89783
89784 /* Initialize the rowset register to contain NULL. An SQL NULL is
89785 ** equivalent to an empty rowset.
89786 **
89787 ** Also initialize regReturn to contain the address of the instruction
@@ -89802,36 +89807,42 @@
89802 for(ii=0; ii<pOrWc->nTerm; ii++){
89803 WhereTerm *pOrTerm = &pOrWc->a[ii];
89804 if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){
89805 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
89806 /* Loop through table entries that match term pOrTerm. */
89807 pSubWInfo = sqlite3WhereBegin(pParse, &oneTab, pOrTerm->pExpr, 0,
89808 WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE | WHERE_FORCE_TABLE);
 
89809 if( pSubWInfo ){
89810 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
89811 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
89812 int r;
89813 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
89814 regRowid, 0);
89815 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
89816 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
89817 }
89818 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
 
 
 
 
 
 
 
89819
89820 /* Finish the loop through table entries that match term pOrTerm. */
89821 sqlite3WhereEnd(pSubWInfo);
89822 }
89823 }
89824 }
89825 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
89826 /* sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); */
89827 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
89828 sqlite3VdbeResolveLabel(v, iLoopBody);
89829
89830 pLevel->op = OP_Return;
89831 pLevel->p1 = regReturn;
89832 disableTerm(pLevel, pTerm);
89833 }else
89834 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
89835
89836 {
89837 /* Case 5: There is no usable index. We must do a complete
@@ -89855,11 +89866,16 @@
89855 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
89856 Expr *pE;
89857 testcase( pTerm->wtFlags & TERM_VIRTUAL );
89858 testcase( pTerm->wtFlags & TERM_CODED );
89859 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89860 if( (pTerm->prereqAll & notReady)!=0 ) continue;
 
 
 
 
 
89861 pE = pTerm->pExpr;
89862 assert( pE!=0 );
89863 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
89864 continue;
89865 }
@@ -89878,11 +89894,14 @@
89878 sqlite3ExprCacheClear(pParse);
89879 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
89880 testcase( pTerm->wtFlags & TERM_VIRTUAL );
89881 testcase( pTerm->wtFlags & TERM_CODED );
89882 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89883 if( (pTerm->prereqAll & notReady)!=0 ) continue;
 
 
 
89884 assert( pTerm->pExpr );
89885 sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
89886 pTerm->wtFlags |= TERM_CODED;
89887 }
89888 }
@@ -90021,10 +90040,11 @@
90021 ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */
90022 u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */
90023 ){
90024 int i; /* Loop counter */
90025 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
 
90026 WhereInfo *pWInfo; /* Will become the return value of this function */
90027 Vdbe *v = pParse->pVdbe; /* The virtual database engine */
90028 Bitmask notReady; /* Cursors that are not yet positioned */
90029 WhereMaskSet *pMaskSet; /* The expression mask set */
90030 WhereClause *pWC; /* Decomposition of the WHERE clause */
@@ -90039,29 +90059,36 @@
90039 */
90040 if( pTabList->nSrc>BMS ){
90041 sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
90042 return 0;
90043 }
 
 
 
 
 
 
 
90044
90045 /* Allocate and initialize the WhereInfo structure that will become the
90046 ** return value. A single allocation is used to store the WhereInfo
90047 ** struct, the contents of WhereInfo.a[], the WhereClause structure
90048 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
90049 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
90050 ** some architectures. Hence the ROUND8() below.
90051 */
90052 db = pParse->db;
90053 nByteWInfo = ROUND8(sizeof(WhereInfo)+(pTabList->nSrc-1)*sizeof(WhereLevel));
90054 pWInfo = sqlite3DbMallocZero(db,
90055 nByteWInfo +
90056 sizeof(WhereClause) +
90057 sizeof(WhereMaskSet)
90058 );
90059 if( db->mallocFailed ){
90060 goto whereBeginError;
90061 }
90062 pWInfo->nLevel = pTabList->nSrc;
90063 pWInfo->pParse = pParse;
90064 pWInfo->pTabList = pTabList;
90065 pWInfo->iBreak = sqlite3VdbeMakeLabel(v);
90066 pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo];
90067 pWInfo->wctrlFlags = wctrlFlags;
@@ -90076,11 +90103,11 @@
90076 whereSplit(pWC, pWhere, TK_AND);
90077
90078 /* Special case: a WHERE clause that is constant. Evaluate the
90079 ** expression and either jump over all of the code or fall thru.
90080 */
90081 if( pWhere && (pTabList->nSrc==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
90082 sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);
90083 pWhere = 0;
90084 }
90085
90086 /* Assign a bit from the bitmask to every term in the FROM clause.
@@ -90096,10 +90123,15 @@
90096 **
90097 ** Configure the WhereClause.vmask variable so that bits that correspond
90098 ** to virtual table cursors are set. This is used to selectively disable
90099 ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful
90100 ** with virtual tables.
 
 
 
 
 
90101 */
90102 assert( pWC->vmask==0 && pMaskSet->n==0 );
90103 for(i=0; i<pTabList->nSrc; i++){
90104 createMask(pMaskSet, pTabList->a[i].iCursor);
90105 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -90147,11 +90179,11 @@
90147 notReady = ~(Bitmask)0;
90148 pTabItem = pTabList->a;
90149 pLevel = pWInfo->a;
90150 andFlags = ~0;
90151 WHERETRACE(("*** Optimizer Start ***\n"));
90152 for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
90153 WhereCost bestPlan; /* Most efficient plan seen so far */
90154 Index *pIdx; /* Index for FROM table at pTabItem */
90155 int j; /* For looping over FROM tables */
90156 int bestJ = -1; /* The value of j */
90157 Bitmask m; /* Bitmask value for j or bestJ */
@@ -90192,12 +90224,12 @@
90192 ** algorithm may choose to use t2 for the outer loop, which is a much
90193 ** costlier approach.
90194 */
90195 for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){
90196 Bitmask mask = (isOptimal ? 0 : notReady);
90197 assert( (pTabList->nSrc-iFrom)>1 || isOptimal );
90198 for(j=iFrom, pTabItem=&pTabList->a[j]; j<pTabList->nSrc; j++, pTabItem++){
90199 int doNotReorder; /* True if this table should not be reordered */
90200 WhereCost sCost; /* Cost information from best[Virtual]Index() */
90201 ExprList *pOrderBy; /* ORDER BY clause for index to optimize */
90202
90203 doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
@@ -90290,11 +90322,11 @@
90290
90291 /* Open all tables in the pTabList and any indices selected for
90292 ** searching those tables.
90293 */
90294 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
90295 for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
90296 Table *pTab; /* Table to open */
90297 int iDb; /* Index of database containing table/index */
90298
90299 #ifndef SQLITE_OMIT_EXPLAIN
90300 if( pParse->explain==2 ){
@@ -90369,11 +90401,11 @@
90369 /* Generate the code to do the search. Each iteration of the for
90370 ** loop below generates code for a single nested loop of the VM
90371 ** program.
90372 */
90373 notReady = ~(Bitmask)0;
90374 for(i=0; i<pTabList->nSrc; i++){
90375 notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady);
90376 pWInfo->iContinue = pWInfo->a[i].addrCont;
90377 }
90378
90379 #ifdef SQLITE_TEST /* For testing and debugging use only */
@@ -90381,11 +90413,11 @@
90381 ** and the index used to access it (if any). If the table itself
90382 ** is not used, its name is just '{}'. If no index is used
90383 ** the index is listed as "{}". If the primary key is used the
90384 ** index name is '*'.
90385 */
90386 for(i=0; i<pTabList->nSrc; i++){
90387 char *z;
90388 int n;
90389 pLevel = &pWInfo->a[i];
90390 pTabItem = &pTabList->a[pLevel->iFrom];
90391 z = pTabItem->zAlias;
@@ -90449,11 +90481,11 @@
90449 sqlite3 *db = pParse->db;
90450
90451 /* Generate loop termination code.
90452 */
90453 sqlite3ExprCacheClear(pParse);
90454 for(i=pTabList->nSrc-1; i>=0; i--){
90455 pLevel = &pWInfo->a[i];
90456 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
90457 if( pLevel->op!=OP_Noop ){
90458 sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
90459 sqlite3VdbeChangeP5(v, pLevel->p5);
@@ -90495,11 +90527,12 @@
90495 */
90496 sqlite3VdbeResolveLabel(v, pWInfo->iBreak);
90497
90498 /* Close all of the cursors that were opened by sqlite3WhereBegin.
90499 */
90500 for(i=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
 
90501 struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
90502 Table *pTab = pTabItem->pTab;
90503 assert( pTab!=0 );
90504 if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
90505 if( (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 ){
@@ -90767,12 +90800,12 @@
90767 #endif
90768 #define sqlite3ParserARG_SDECL Parse *pParse;
90769 #define sqlite3ParserARG_PDECL ,Parse *pParse
90770 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
90771 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
90772 #define YYNSTATE 629
90773 #define YYNRULE 329
90774 #define YYFALLBACK 1
90775 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
90776 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
90777 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
90778
@@ -90840,473 +90873,474 @@
90840 ** shifting non-terminals after a reduce.
90841 ** yy_default[] Default action for each state.
90842 */
90843 #define YY_ACTTAB_COUNT (1543)
90844 static const YYACTIONTYPE yy_action[] = {
90845 /* 0 */ 312, 49, 554, 46, 147, 172, 626, 596, 55, 55,
90846 /* 10 */ 55, 55, 301, 53, 53, 53, 53, 52, 52, 51,
90847 /* 20 */ 51, 51, 50, 237, 617, 616, 615, 622, 621, 607,
90848 /* 30 */ 589, 583, 48, 53, 53, 53, 53, 52, 52, 51,
90849 /* 40 */ 51, 51, 50, 237, 51, 51, 51, 50, 237, 56,
90850 /* 50 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90851 /* 60 */ 55, 55, 216, 53, 53, 53, 53, 52, 52, 51,
90852 /* 70 */ 51, 51, 50, 237, 312, 596, 49, 329, 46, 147,
90853 /* 80 */ 32, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90854 /* 90 */ 50, 237, 329, 622, 621, 619, 618, 166, 433, 547,
90855 /* 100 */ 381, 378, 377, 549, 589, 583, 389, 490, 166, 58,
90856 /* 110 */ 376, 381, 378, 377, 390, 299, 622, 621, 480, 67,
90857 /* 120 */ 670, 376, 620, 56, 57, 47, 581, 580, 582, 582,
90858 /* 130 */ 54, 54, 55, 55, 55, 55, 253, 53, 53, 53,
90859 /* 140 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 408,
90860 /* 150 */ 225, 578, 578, 133, 177, 139, 283, 384, 278, 383,
90861 /* 160 */ 169, 619, 618, 601, 197, 225, 274, 602, 439, 146,
90862 /* 170 */ 139, 283, 384, 278, 383, 169, 569, 235, 589, 583,
90863 /* 180 */ 250, 274, 252, 620, 619, 618, 546, 436, 440, 441,
90864 /* 190 */ 168, 622, 621, 547, 438, 437, 192, 56, 57, 47,
90865 /* 200 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90866 /* 210 */ 6, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90867 /* 220 */ 50, 237, 312, 282, 52, 52, 51, 51, 51, 50,
90868 /* 230 */ 237, 490, 183, 281, 547, 166, 439, 565, 381, 378,
90869 /* 240 */ 377, 596, 606, 67, 327, 172, 620, 596, 376, 442,
90870 /* 250 */ 236, 620, 589, 583, 306, 423, 440, 339, 251, 619,
90871 /* 260 */ 618, 331, 574, 573, 7, 524, 194, 481, 16, 594,
90872 /* 270 */ 189, 56, 57, 47, 581, 580, 582, 582, 54, 54,
90873 /* 280 */ 55, 55, 55, 55, 545, 53, 53, 53, 53, 52,
90874 /* 290 */ 52, 51, 51, 51, 50, 237, 312, 410, 464, 421,
90875 /* 300 */ 592, 592, 592, 671, 146, 410, 1, 205, 410, 596,
90876 /* 310 */ 622, 621, 413, 420, 949, 596, 949, 340, 236, 530,
90877 /* 320 */ 413, 600, 74, 413, 236, 552, 589, 583, 547, 600,
90878 /* 330 */ 95, 68, 600, 88, 551, 622, 621, 465, 542, 38,
90879 /* 340 */ 49, 599, 46, 147, 465, 56, 57, 47, 581, 580,
90880 /* 350 */ 582, 582, 54, 54, 55, 55, 55, 55, 424, 53,
90881 /* 360 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90882 /* 370 */ 312, 397, 395, 232, 529, 577, 387, 533, 619, 618,
90883 /* 380 */ 605, 492, 560, 588, 587, 350, 257, 622, 621, 495,
90884 /* 390 */ 564, 356, 350, 257, 49, 239, 46, 147, 559, 357,
90885 /* 400 */ 589, 583, 239, 619, 618, 585, 584, 408, 258, 578,
90886 /* 410 */ 578, 672, 209, 35, 558, 258, 401, 622, 621, 56,
90887 /* 420 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90888 /* 430 */ 55, 55, 586, 53, 53, 53, 53, 52, 52, 51,
90889 /* 440 */ 51, 51, 50, 237, 312, 560, 599, 410, 526, 531,
90890 /* 450 */ 184, 514, 513, 474, 366, 619, 618, 576, 410, 65,
90891 /* 460 */ 176, 559, 413, 408, 311, 578, 578, 567, 491, 215,
90892 /* 470 */ 352, 600, 94, 413, 589, 583, 474, 558, 408, 518,
90893 /* 480 */ 578, 578, 600, 95, 470, 619, 618, 62, 420, 948,
90894 /* 490 */ 517, 948, 349, 56, 57, 47, 581, 580, 582, 582,
90895 /* 500 */ 54, 54, 55, 55, 55, 55, 175, 53, 53, 53,
90896 /* 510 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 490,
90897 /* 520 */ 157, 410, 509, 292, 393, 373, 348, 410, 623, 410,
90898 /* 530 */ 428, 67, 611, 424, 620, 410, 413, 540, 408, 171,
90899 /* 540 */ 578, 578, 413, 620, 413, 600, 73, 620, 589, 583,
90900 /* 550 */ 413, 600, 80, 600, 88, 238, 168, 306, 422, 600,
90901 /* 560 */ 80, 201, 18, 468, 406, 574, 573, 56, 57, 47,
90902 /* 570 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90903 /* 580 */ 579, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90904 /* 590 */ 50, 237, 312, 44, 233, 599, 271, 320, 341, 472,
90905 /* 600 */ 410, 874, 421, 473, 503, 319, 410, 200, 144, 66,
90906 /* 610 */ 327, 483, 508, 596, 274, 413, 239, 364, 484, 382,
90907 /* 620 */ 30, 413, 589, 583, 600, 69, 502, 236, 342, 575,
90908 /* 630 */ 600, 97, 199, 198, 209, 959, 186, 418, 2, 566,
90909 /* 640 */ 269, 56, 57, 47, 581, 580, 582, 582, 54, 54,
90910 /* 650 */ 55, 55, 55, 55, 410, 53, 53, 53, 53, 52,
90911 /* 660 */ 52, 51, 51, 51, 50, 237, 312, 263, 599, 413,
90912 /* 670 */ 410, 21, 190, 358, 410, 326, 410, 202, 600, 100,
90913 /* 680 */ 386, 596, 620, 562, 265, 413, 267, 410, 620, 413,
90914 /* 690 */ 563, 413, 352, 4, 600, 98, 589, 583, 600, 106,
90915 /* 700 */ 600, 104, 413, 174, 601, 629, 627, 333, 602, 34,
90916 /* 710 */ 337, 600, 108, 561, 359, 56, 57, 47, 581, 580,
90917 /* 720 */ 582, 582, 54, 54, 55, 55, 55, 55, 410, 53,
90918 /* 730 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90919 /* 740 */ 312, 410, 499, 413, 167, 567, 405, 215, 504, 505,
90920 /* 750 */ 316, 557, 600, 109, 353, 13, 413, 410, 12, 410,
90921 /* 760 */ 538, 410, 335, 358, 223, 600, 134, 571, 571, 620,
90922 /* 770 */ 589, 583, 413, 20, 413, 620, 413, 272, 620, 167,
90923 /* 780 */ 167, 600, 135, 600, 61, 600, 105, 317, 148, 56,
90924 /* 790 */ 57, 47, 581, 580, 582, 582, 54, 54, 55, 55,
90925 /* 800 */ 55, 55, 410, 53, 53, 53, 53, 52, 52, 51,
90926 /* 810 */ 51, 51, 50, 237, 312, 410, 275, 413, 410, 275,
90927 /* 820 */ 275, 222, 410, 330, 363, 544, 600, 103, 132, 360,
90928 /* 830 */ 413, 620, 522, 413, 620, 620, 410, 413, 170, 600,
90929 /* 840 */ 96, 603, 600, 102, 589, 583, 600, 77, 374, 536,
90930 /* 850 */ 167, 413, 143, 325, 256, 28, 224, 324, 511, 528,
90931 /* 860 */ 600, 99, 527, 56, 57, 47, 581, 580, 582, 582,
90932 /* 870 */ 54, 54, 55, 55, 55, 55, 410, 53, 53, 53,
90933 /* 880 */ 53, 52, 52, 51, 51, 51, 50, 237, 312, 410,
90934 /* 890 */ 275, 413, 410, 469, 275, 167, 458, 39, 171, 37,
90935 /* 900 */ 600, 138, 214, 144, 413, 620, 142, 413, 410, 620,
90936 /* 910 */ 410, 358, 239, 600, 137, 230, 600, 136, 589, 583,
90937 /* 920 */ 457, 263, 23, 413, 351, 413, 620, 323, 445, 501,
90938 /* 930 */ 23, 322, 600, 76, 600, 93, 620, 56, 45, 47,
90939 /* 940 */ 581, 580, 582, 582, 54, 54, 55, 55, 55, 55,
90940 /* 950 */ 410, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90941 /* 960 */ 50, 237, 312, 410, 262, 413, 410, 426, 263, 308,
90942 /* 970 */ 203, 213, 212, 380, 600, 92, 520, 519, 413, 130,
90943 /* 980 */ 538, 413, 538, 620, 410, 628, 2, 600, 75, 273,
90944 /* 990 */ 600, 91, 589, 583, 375, 620, 129, 620, 27, 413,
90945 /* 1000 */ 425, 307, 221, 128, 599, 599, 599, 281, 600, 90,
90946 /* 1010 */ 371, 452, 57, 47, 581, 580, 582, 582, 54, 54,
90947 /* 1020 */ 55, 55, 55, 55, 410, 53, 53, 53, 53, 52,
90948 /* 1030 */ 52, 51, 51, 51, 50, 237, 312, 410, 263, 413,
90949 /* 1040 */ 410, 263, 263, 365, 208, 321, 206, 542, 600, 101,
90950 /* 1050 */ 50, 237, 413, 620, 610, 413, 620, 620, 410, 542,
90951 /* 1060 */ 165, 600, 89, 188, 600, 87, 589, 583, 478, 620,
90952 /* 1070 */ 467, 519, 125, 413, 569, 235, 542, 367, 599, 475,
90953 /* 1080 */ 599, 450, 600, 86, 449, 448, 231, 47, 581, 580,
90954 /* 1090 */ 582, 582, 54, 54, 55, 55, 55, 55, 287, 53,
90955 /* 1100 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 237,
90956 /* 1110 */ 43, 404, 410, 3, 410, 285, 260, 414, 621, 263,
90957 /* 1120 */ 609, 627, 333, 43, 404, 410, 3, 413, 407, 413,
90958 /* 1130 */ 414, 621, 171, 263, 620, 620, 600, 85, 600, 72,
90959 /* 1140 */ 413, 407, 124, 140, 353, 604, 409, 402, 620, 600,
90960 /* 1150 */ 71, 291, 471, 495, 160, 123, 593, 565, 620, 620,
90961 /* 1160 */ 402, 620, 220, 15, 463, 460, 620, 417, 625, 159,
90962 /* 1170 */ 565, 620, 399, 240, 158, 126, 219, 40, 41, 532,
90963 /* 1180 */ 410, 207, 121, 120, 42, 412, 411, 620, 263, 594,
90964 /* 1190 */ 40, 41, 556, 543, 25, 413, 11, 42, 412, 411,
90965 /* 1200 */ 24, 118, 594, 620, 600, 84, 455, 620, 620, 43,
90966 /* 1210 */ 404, 218, 3, 539, 156, 599, 414, 621, 113, 239,
90967 /* 1220 */ 592, 592, 592, 591, 590, 14, 155, 407, 620, 537,
90968 /* 1230 */ 451, 247, 444, 592, 592, 592, 591, 590, 14, 343,
90969 /* 1240 */ 410, 111, 410, 277, 620, 410, 402, 410, 507, 110,
90970 /* 1250 */ 10, 64, 204, 336, 435, 413, 565, 413, 620, 276,
90971 /* 1260 */ 413, 434, 413, 620, 600, 83, 600, 95, 334, 600,
90972 /* 1270 */ 82, 600, 81, 150, 620, 488, 40, 41, 270, 268,
90973 /* 1280 */ 266, 191, 332, 42, 412, 411, 599, 410, 594, 241,
90974 /* 1290 */ 620, 410, 264, 620, 620, 620, 33, 404, 419, 3,
90975 /* 1300 */ 107, 229, 413, 414, 621, 149, 413, 620, 397, 181,
90976 /* 1310 */ 259, 600, 70, 398, 407, 600, 17, 315, 314, 592,
90977 /* 1320 */ 592, 592, 591, 590, 14, 620, 127, 361, 624, 217,
90978 /* 1330 */ 462, 461, 354, 402, 304, 303, 302, 179, 300, 254,
90979 /* 1340 */ 614, 453, 620, 565, 454, 620, 620, 620, 613, 612,
90980 /* 1350 */ 443, 416, 180, 246, 620, 151, 415, 245, 243, 620,
90981 /* 1360 */ 178, 598, 242, 40, 41, 620, 244, 8, 620, 239,
90982 /* 1370 */ 42, 412, 411, 620, 410, 594, 410, 620, 60, 153,
90983 /* 1380 */ 429, 465, 622, 621, 296, 154, 30, 145, 152, 413,
90984 /* 1390 */ 388, 413, 295, 394, 294, 620, 31, 392, 600, 79,
90985 /* 1400 */ 600, 78, 620, 290, 396, 413, 592, 592, 592, 591,
90986 /* 1410 */ 590, 14, 620, 293, 600, 9, 597, 59, 620, 36,
90987 /* 1420 */ 555, 173, 565, 234, 185, 288, 29, 541, 391, 345,
90988 /* 1430 */ 248, 286, 521, 535, 313, 284, 385, 328, 534, 239,
90989 /* 1440 */ 516, 515, 196, 195, 279, 310, 511, 512, 510, 131,
90990 /* 1450 */ 524, 227, 258, 228, 594, 309, 487, 486, 493, 226,
90991 /* 1460 */ 372, 485, 164, 338, 479, 163, 368, 370, 162, 26,
90992 /* 1470 */ 211, 477, 261, 161, 141, 476, 362, 466, 122, 187,
90993 /* 1480 */ 119, 456, 347, 117, 346, 592, 592, 592, 116, 115,
90994 /* 1490 */ 114, 447, 112, 182, 318, 22, 432, 19, 431, 430,
90995 /* 1500 */ 63, 427, 608, 193, 297, 595, 572, 570, 403, 553,
90996 /* 1510 */ 550, 289, 280, 508, 498, 497, 496, 494, 379, 355,
90997 /* 1520 */ 459, 255, 249, 344, 446, 305, 5, 568, 548, 298,
90998 /* 1530 */ 298, 210, 369, 298, 400, 506, 500, 489, 525, 523,
90999 /* 1540 */ 482, 239, 237,
91000 };
91001 static const YYCODETYPE yy_lookahead[] = {
91002 /* 0 */ 19, 222, 223, 224, 225, 24, 1, 26, 77, 78,
91003 /* 10 */ 79, 80, 15, 82, 83, 84, 85, 86, 87, 88,
91004 /* 20 */ 89, 90, 91, 92, 7, 8, 9, 26, 27, 23,
91005 /* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88,
91006 /* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68,
91007 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91008 /* 60 */ 79, 80, 22, 82, 83, 84, 85, 86, 87, 88,
91009 /* 70 */ 89, 90, 91, 92, 19, 94, 222, 19, 224, 225,
91010 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91011 /* 90 */ 91, 92, 19, 26, 27, 94, 95, 96, 244, 25,
91012 /* 100 */ 99, 100, 101, 25, 49, 50, 19, 150, 96, 54,
91013 /* 110 */ 109, 99, 100, 101, 27, 158, 26, 27, 161, 162,
91014 /* 120 */ 117, 109, 165, 68, 69, 70, 71, 72, 73, 74,
91015 /* 130 */ 75, 76, 77, 78, 79, 80, 16, 82, 83, 84,
91016 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 111,
91017 /* 150 */ 92, 113, 114, 24, 96, 97, 98, 99, 100, 101,
91018 /* 160 */ 102, 94, 95, 112, 25, 92, 108, 116, 150, 95,
91019 /* 170 */ 97, 98, 99, 100, 101, 102, 86, 87, 49, 50,
91020 /* 180 */ 60, 108, 62, 165, 94, 95, 119, 97, 170, 171,
91021 /* 190 */ 50, 26, 27, 119, 104, 105, 118, 68, 69, 70,
91022 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91023 /* 210 */ 22, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91024 /* 220 */ 91, 92, 19, 98, 86, 87, 88, 89, 90, 91,
91025 /* 230 */ 92, 150, 23, 108, 25, 96, 150, 66, 99, 100,
91026 /* 240 */ 101, 26, 161, 162, 104, 24, 165, 26, 109, 231,
91027 /* 250 */ 232, 165, 49, 50, 22, 23, 170, 171, 138, 94,
91028 /* 260 */ 95, 169, 170, 171, 76, 94, 185, 186, 22, 98,
91029 /* 270 */ 24, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91030 /* 280 */ 77, 78, 79, 80, 119, 82, 83, 84, 85, 86,
91031 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 11, 67,
91032 /* 300 */ 129, 130, 131, 117, 95, 150, 22, 160, 150, 94,
91033 /* 310 */ 26, 27, 165, 22, 23, 94, 25, 231, 232, 23,
91034 /* 320 */ 165, 174, 175, 165, 232, 32, 49, 50, 119, 174,
91035 /* 330 */ 175, 22, 174, 175, 41, 26, 27, 57, 166, 136,
91036 /* 340 */ 222, 194, 224, 225, 57, 68, 69, 70, 71, 72,
91037 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 67, 82,
91038 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91039 /* 370 */ 19, 216, 214, 215, 23, 23, 221, 205, 94, 95,
91040 /* 380 */ 172, 173, 12, 49, 50, 105, 106, 26, 27, 181,
91041 /* 390 */ 23, 19, 105, 106, 222, 115, 224, 225, 28, 27,
91042 /* 400 */ 49, 50, 115, 94, 95, 71, 72, 111, 128, 113,
91043 /* 410 */ 114, 117, 160, 136, 44, 128, 46, 26, 27, 68,
91044 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91045 /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
91046 /* 440 */ 89, 90, 91, 92, 19, 12, 194, 150, 23, 88,
91047 /* 450 */ 23, 7, 8, 105, 106, 94, 95, 23, 150, 25,
91048 /* 460 */ 117, 28, 165, 111, 163, 113, 114, 166, 167, 168,
91049 /* 470 */ 218, 174, 175, 165, 49, 50, 128, 44, 111, 46,
91050 /* 480 */ 113, 114, 174, 175, 21, 94, 95, 235, 22, 23,
91051 /* 490 */ 57, 25, 240, 68, 69, 70, 71, 72, 73, 74,
91052 /* 500 */ 75, 76, 77, 78, 79, 80, 117, 82, 83, 84,
91053 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
91054 /* 520 */ 25, 150, 23, 226, 216, 19, 63, 150, 150, 150,
91055 /* 530 */ 161, 162, 150, 67, 165, 150, 165, 23, 111, 25,
91056 /* 540 */ 113, 114, 165, 165, 165, 174, 175, 165, 49, 50,
91057 /* 550 */ 165, 174, 175, 174, 175, 197, 50, 22, 23, 174,
91058 /* 560 */ 175, 160, 204, 100, 169, 170, 171, 68, 69, 70,
91059 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91060 /* 580 */ 112, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91061 /* 590 */ 91, 92, 19, 22, 215, 194, 23, 220, 97, 30,
91062 /* 600 */ 150, 138, 67, 34, 36, 220, 150, 206, 207, 22,
91063 /* 610 */ 104, 181, 182, 26, 108, 165, 115, 48, 188, 51,
91064 /* 620 */ 125, 165, 49, 50, 174, 175, 58, 232, 127, 23,
91065 /* 630 */ 174, 175, 105, 106, 160, 142, 143, 144, 145, 23,
91066 /* 640 */ 16, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91067 /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
91068 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 165,
91069 /* 670 */ 150, 24, 22, 150, 150, 107, 150, 22, 174, 175,
91070 /* 680 */ 88, 94, 165, 23, 60, 165, 62, 150, 165, 165,
91071 /* 690 */ 11, 165, 218, 35, 174, 175, 49, 50, 174, 175,
91072 /* 700 */ 174, 175, 165, 25, 112, 0, 1, 2, 116, 25,
91073 /* 710 */ 193, 174, 175, 23, 240, 68, 69, 70, 71, 72,
91074 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
91075 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91076 /* 740 */ 19, 150, 23, 165, 25, 166, 167, 168, 97, 98,
91077 /* 750 */ 155, 23, 174, 175, 150, 25, 165, 150, 35, 150,
91078 /* 760 */ 150, 150, 245, 150, 241, 174, 175, 129, 130, 165,
91079 /* 770 */ 49, 50, 165, 52, 165, 165, 165, 23, 165, 25,
91080 /* 780 */ 25, 174, 175, 174, 175, 174, 175, 248, 249, 68,
91081 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91082 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
91083 /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 150, 150,
91084 /* 820 */ 150, 217, 150, 213, 229, 119, 174, 175, 22, 234,
91085 /* 830 */ 165, 165, 165, 165, 165, 165, 150, 165, 35, 174,
91086 /* 840 */ 175, 174, 174, 175, 49, 50, 174, 175, 23, 27,
91087 /* 850 */ 25, 165, 117, 187, 241, 22, 187, 187, 103, 23,
91088 /* 860 */ 174, 175, 23, 68, 69, 70, 71, 72, 73, 74,
91089 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
91090 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
91091 /* 890 */ 150, 165, 150, 23, 150, 25, 23, 135, 25, 137,
91092 /* 900 */ 174, 175, 206, 207, 165, 165, 39, 165, 150, 165,
91093 /* 910 */ 150, 150, 115, 174, 175, 52, 174, 175, 49, 50,
91094 /* 920 */ 23, 150, 25, 165, 127, 165, 165, 187, 23, 29,
91095 /* 930 */ 25, 187, 174, 175, 174, 175, 165, 68, 69, 70,
91096 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91097 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91098 /* 960 */ 91, 92, 19, 150, 193, 165, 150, 23, 150, 25,
91099 /* 970 */ 160, 160, 160, 52, 174, 175, 190, 191, 165, 22,
91100 /* 980 */ 150, 165, 150, 165, 150, 144, 145, 174, 175, 23,
91101 /* 990 */ 174, 175, 49, 50, 52, 165, 22, 165, 22, 165,
91102 /* 1000 */ 250, 251, 241, 22, 194, 194, 194, 108, 174, 175,
91103 /* 1010 */ 19, 193, 69, 70, 71, 72, 73, 74, 75, 76,
91104 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
91105 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
91106 /* 1040 */ 150, 150, 150, 213, 160, 213, 160, 166, 174, 175,
91107 /* 1050 */ 91, 92, 165, 165, 150, 165, 165, 165, 150, 166,
91108 /* 1060 */ 102, 174, 175, 24, 174, 175, 49, 50, 20, 165,
91109 /* 1070 */ 190, 191, 104, 165, 86, 87, 166, 43, 194, 59,
91110 /* 1080 */ 194, 193, 174, 175, 193, 193, 205, 70, 71, 72,
91111 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 205, 82,
91112 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91113 /* 1110 */ 19, 20, 150, 22, 150, 205, 138, 26, 27, 150,
91114 /* 1120 */ 150, 1, 2, 19, 20, 150, 22, 165, 37, 165,
91115 /* 1130 */ 26, 27, 25, 150, 165, 165, 174, 175, 174, 175,
91116 /* 1140 */ 165, 37, 53, 150, 150, 173, 150, 56, 165, 174,
91117 /* 1150 */ 175, 150, 53, 181, 104, 22, 150, 66, 165, 165,
91118 /* 1160 */ 56, 165, 193, 5, 1, 27, 165, 146, 147, 117,
91119 /* 1170 */ 66, 165, 150, 152, 35, 154, 193, 86, 87, 88,
91120 /* 1180 */ 150, 160, 107, 126, 93, 94, 95, 165, 150, 98,
91121 /* 1190 */ 86, 87, 150, 150, 76, 165, 22, 93, 94, 95,
91122 /* 1200 */ 76, 118, 98, 165, 174, 175, 1, 165, 165, 19,
91123 /* 1210 */ 20, 217, 22, 150, 16, 194, 26, 27, 118, 115,
91124 /* 1220 */ 129, 130, 131, 132, 133, 134, 120, 37, 165, 150,
91125 /* 1230 */ 20, 193, 127, 129, 130, 131, 132, 133, 134, 218,
91126 /* 1240 */ 150, 107, 150, 150, 165, 150, 56, 150, 150, 126,
91127 /* 1250 */ 22, 16, 160, 65, 23, 165, 66, 165, 165, 150,
91128 /* 1260 */ 165, 23, 165, 165, 174, 175, 174, 175, 247, 174,
91129 /* 1270 */ 175, 174, 175, 15, 165, 150, 86, 87, 150, 150,
91130 /* 1280 */ 150, 22, 3, 93, 94, 95, 194, 150, 98, 140,
91131 /* 1290 */ 165, 150, 150, 165, 165, 165, 19, 20, 4, 22,
91132 /* 1300 */ 164, 180, 165, 26, 27, 249, 165, 165, 216, 6,
91133 /* 1310 */ 150, 174, 175, 221, 37, 174, 175, 252, 252, 129,
91134 /* 1320 */ 130, 131, 132, 133, 134, 165, 180, 150, 149, 5,
91135 /* 1330 */ 150, 150, 150, 56, 10, 11, 12, 13, 14, 150,
91136 /* 1340 */ 149, 17, 165, 66, 150, 165, 165, 165, 149, 13,
91137 /* 1350 */ 150, 149, 151, 150, 165, 31, 159, 33, 150, 165,
91138 /* 1360 */ 151, 194, 150, 86, 87, 165, 42, 25, 165, 115,
91139 /* 1370 */ 93, 94, 95, 165, 150, 98, 150, 165, 22, 55,
91140 /* 1380 */ 150, 57, 26, 27, 199, 61, 125, 150, 64, 165,
91141 /* 1390 */ 150, 165, 200, 122, 201, 165, 123, 150, 174, 175,
91142 /* 1400 */ 174, 175, 165, 150, 121, 165, 129, 130, 131, 132,
91143 /* 1410 */ 133, 134, 165, 202, 174, 175, 203, 124, 165, 135,
91144 /* 1420 */ 157, 117, 66, 227, 157, 210, 104, 211, 120, 105,
91145 /* 1430 */ 106, 210, 176, 211, 110, 210, 104, 47, 211, 115,
91146 /* 1440 */ 176, 184, 86, 87, 176, 179, 103, 178, 176, 22,
91147 /* 1450 */ 94, 92, 128, 230, 98, 179, 176, 176, 184, 230,
91148 /* 1460 */ 18, 176, 156, 139, 157, 156, 45, 157, 156, 135,
91149 /* 1470 */ 157, 157, 238, 156, 68, 239, 157, 189, 189, 219,
91150 /* 1480 */ 22, 199, 157, 192, 18, 129, 130, 131, 192, 192,
91151 /* 1490 */ 192, 199, 189, 219, 157, 243, 40, 243, 157, 157,
91152 /* 1500 */ 246, 38, 153, 196, 198, 166, 233, 233, 228, 177,
91153 /* 1510 */ 177, 209, 177, 182, 177, 166, 177, 166, 178, 242,
91154 /* 1520 */ 199, 242, 209, 209, 199, 148, 196, 166, 208, 195,
91155 /* 1530 */ 195, 236, 237, 195, 191, 183, 183, 186, 174, 174,
91156 /* 1540 */ 186, 115, 92,
91157 };
91158 #define YY_SHIFT_USE_DFLT (-70)
91159 #define YY_SHIFT_COUNT (417)
91160 #define YY_SHIFT_MIN (-69)
91161 #define YY_SHIFT_MAX (1466)
91162 static const short yy_shift_ofst[] = {
91163 /* 0 */ 1120, 1104, 1324, 1104, 1190, 1190, 90, 90, 1, -19,
91164 /* 10 */ 1190, 1190, 1190, 1190, 1190, 280, 391, 721, 1091, 1190,
91165 /* 20 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91166 /* 30 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91167 /* 40 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1277, 1190, 1190,
91168 /* 50 */ 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190, 1190,
91169 /* 60 */ 1190, -49, 287, 391, 391, 988, 988, 215, 1426, 55,
91170 /* 70 */ 647, 573, 499, 425, 351, 277, 203, 129, 795, 795,
91171 /* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795,
91172 /* 90 */ 795, 795, 795, 795, 795, 795, 869, 795, 943, 1017,
91173 /* 100 */ 1017, -69, -69, -69, -69, -1, -1, 58, 138, -44,
91174 /* 110 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91175 /* 120 */ 391, 391, 391, 391, 391, 391, 463, 506, 391, 391,
91176 /* 130 */ 391, 391, 391, 215, 959, 1450, -70, -70, -70, 1356,
91177 /* 140 */ 73, 433, 433, 361, 309, 165, 67, 284, 466, 291,
91178 /* 150 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91179 /* 160 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91180 /* 170 */ 391, 391, 391, 391, 391, 391, 391, 391, 391, 391,
91181 /* 180 */ 391, 391, 501, 221, 221, 221, 705, 797, 1426, 1426,
91182 /* 190 */ 1426, -70, -70, -70, 139, 171, 171, 12, 568, 568,
91183 /* 200 */ 209, 427, 370, 367, 352, 296, 38, 38, 38, 38,
91184 /* 210 */ 348, 569, 38, 38, 74, 587, 592, 17, 495, 87,
91185 /* 220 */ 87, 372, 495, 372, 755, 215, 293, 215, 293, 140,
91186 /* 230 */ 293, 87, 293, 293, 762, 638, 638, 215, 78, 51,
91187 /* 240 */ 246, 1463, 1304, 1304, 1456, 1456, 1304, 1458, 1406, 1261,
91188 /* 250 */ 1466, 1466, 1466, 1466, 1304, 1261, 1458, 1406, 1406, 1304,
91189 /* 260 */ 1442, 1334, 1421, 1304, 1304, 1442, 1304, 1442, 1304, 1442,
91190 /* 270 */ 1427, 1332, 1332, 1332, 1390, 1359, 1359, 1427, 1332, 1343,
91191 /* 280 */ 1332, 1390, 1332, 1332, 1308, 1322, 1308, 1322, 1308, 1322,
91192 /* 290 */ 1304, 1304, 1284, 1293, 1283, 1273, 1271, 1261, 1254, 1342,
91193 /* 300 */ 1336, 1336, 1303, 1303, 1303, 1303, -70, -70, -70, -70,
91194 /* 310 */ -70, -70, 334, 120, 535, 232, 624, 944, 188, 905,
91195 /* 320 */ 897, 873, 870, 825, 754, 719, 651, 527, 444, 125,
91196 /* 330 */ 514, 434, 1294, 1279, 1259, 1149, 1258, 1188, 1235, 1238,
91197 /* 340 */ 1231, 1105, 1228, 1123, 1134, 1100, 1210, 1106, 1198, 1205,
91198 /* 350 */ 1083, 1174, 1057, 1124, 1118, 1075, 1138, 1139, 1052, 1163,
91199 /* 360 */ 1158, 1133, 1050, 978, 1099, 1107, 1089, 1020, 1034, 968,
91200 /* 370 */ 1039, 1048, 991, 899, 958, 981, 942, 976, 974, 966,
91201 /* 380 */ 957, 921, 900, 833, 863, 867, 839, 836, 735, 822,
91202 /* 390 */ 803, 806, 706, 684, 723, 730, 658, 684, 728, 690,
91203 /* 400 */ 678, 660, 655, 679, 650, 616, 606, 571, 468, 389,
91204 /* 410 */ 343, 294, 186, 3, 40, 6, -3, 5,
91205 };
91206 #define YY_REDUCE_USE_DFLT (-222)
91207 #define YY_REDUCE_COUNT (311)
91208 #define YY_REDUCE_MIN (-221)
91209 #define YY_REDUCE_MAX (1377)
91210 static const short yy_reduce_ofst[] = {
91211 /* 0 */ 493, 1092, 1021, 147, 158, 155, 86, 18, 81, 172,
91212 /* 10 */ 385, 377, 308, 379, 297, 252, -43, -146, 1240, 1226,
91213 /* 20 */ 1224, 1141, 1137, 1097, 1095, 1090, 1030, 975, 964, 962,
91214 /* 30 */ 908, 890, 887, 874, 834, 816, 813, 800, 760, 758,
91215 /* 40 */ 742, 739, 726, 686, 672, 668, 665, 652, 611, 609,
91216 /* 50 */ 607, 591, 578, 537, 526, 524, 520, 504, 456, 450,
91217 /* 60 */ 371, -221, 474, 369, 517, 395, 92, 301, 401, 118,
91218 /* 70 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91219 /* 80 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91220 /* 90 */ 118, 118, 118, 118, 118, 118, 118, 118, 118, 118,
91221 /* 100 */ 118, 118, 118, 118, 118, 118, 118, 208, 118, 118,
91222 /* 110 */ 1038, 994, 983, 969, 892, 891, 888, 818, 761, 832,
91223 /* 120 */ 613, 604, 523, 744, 830, 771, 595, 430, 740, 670,
91224 /* 130 */ 669, 666, 610, 579, 118, 118, 118, 118, 118, 667,
91225 /* 140 */ 972, 880, 786, 996, 1253, 1247, 1237, 1001, 750, 750,
91226 /* 150 */ 1230, 1212, 1208, 1203, 1200, 1194, 1189, 1182, 1181, 1180,
91227 /* 160 */ 1177, 1160, 1142, 1130, 1129, 1128, 1125, 1109, 1098, 1093,
91228 /* 170 */ 1079, 1063, 1043, 1042, 1022, 1006, 996, 993, 970, 904,
91229 /* 180 */ 382, 378, 886, 910, 893, 881, 841, 884, 812, 811,
91230 /* 190 */ 810, 539, 696, 358, 1354, 1365, 1364, 1351, 1353, 1352,
91231 /* 200 */ 1320, 1338, 1343, 1338, 1338, 1338, 1338, 1338, 1338, 1338,
91232 /* 210 */ 1295, 1295, 1335, 1334, 1320, 1361, 1330, 1377, 1325, 1314,
91233 /* 220 */ 1313, 1279, 1321, 1277, 1340, 1351, 1339, 1349, 1337, 1331,
91234 /* 230 */ 1335, 1302, 1333, 1332, 1280, 1274, 1273, 1339, 1306, 1307,
91235 /* 240 */ 1349, 1254, 1342, 1341, 1254, 1252, 1337, 1274, 1303, 1292,
91236 /* 250 */ 1298, 1297, 1296, 1291, 1325, 1282, 1260, 1289, 1288, 1319,
91237 /* 260 */ 1317, 1236, 1234, 1314, 1313, 1312, 1310, 1309, 1307, 1306,
91238 /* 270 */ 1276, 1285, 1281, 1280, 1274, 1229, 1223, 1266, 1272, 1269,
91239 /* 280 */ 1268, 1257, 1264, 1256, 1227, 1225, 1222, 1221, 1216, 1215,
91240 /* 290 */ 1267, 1263, 1196, 1213, 1211, 1193, 1192, 1185, 1167, 1197,
91241 /* 300 */ 1209, 1201, 1202, 1199, 1191, 1179, 1066, 1065, 1056, 1146,
91242 /* 310 */ 1121, 1136,
91243 };
91244 static const YYACTIONTYPE yy_default[] = {
91245 /* 0 */ 634, 869, 958, 958, 958, 869, 898, 898, 958, 757,
91246 /* 10 */ 958, 958, 958, 958, 867, 958, 958, 932, 958, 958,
91247 /* 20 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91248 /* 30 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91249 /* 40 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91250 /* 50 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91251 /* 60 */ 958, 841, 958, 958, 958, 898, 898, 673, 761, 792,
91252 /* 70 */ 958, 958, 958, 958, 958, 958, 958, 958, 931, 933,
91253 /* 80 */ 807, 806, 800, 799, 911, 772, 797, 790, 783, 794,
91254 /* 90 */ 870, 863, 864, 862, 866, 871, 958, 793, 829, 847,
91255 /* 100 */ 828, 846, 853, 845, 831, 840, 830, 665, 832, 833,
91256 /* 110 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91257 /* 120 */ 958, 958, 958, 958, 958, 958, 660, 726, 958, 958,
91258 /* 130 */ 958, 958, 958, 958, 834, 835, 850, 849, 848, 958,
91259 /* 140 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91260 /* 150 */ 958, 938, 936, 958, 882, 958, 958, 958, 958, 958,
91261 /* 160 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91262 /* 170 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91263 /* 180 */ 958, 640, 958, 757, 757, 757, 634, 958, 958, 958,
91264 /* 190 */ 958, 950, 761, 751, 717, 958, 958, 958, 958, 958,
91265 /* 200 */ 958, 958, 958, 958, 958, 958, 802, 740, 921, 923,
91266 /* 210 */ 958, 904, 738, 662, 759, 675, 749, 642, 796, 774,
91267 /* 220 */ 774, 916, 796, 916, 699, 958, 786, 958, 786, 696,
91268 /* 230 */ 786, 774, 786, 786, 865, 958, 958, 958, 758, 749,
91269 /* 240 */ 958, 943, 765, 765, 935, 935, 765, 808, 730, 796,
91270 /* 250 */ 737, 737, 737, 737, 765, 796, 808, 730, 730, 765,
91271 /* 260 */ 657, 910, 908, 765, 765, 657, 765, 657, 765, 657,
91272 /* 270 */ 875, 728, 728, 728, 713, 879, 879, 875, 728, 699,
91273 /* 280 */ 728, 713, 728, 728, 778, 773, 778, 773, 778, 773,
91274 /* 290 */ 765, 765, 958, 791, 779, 789, 787, 796, 958, 716,
91275 /* 300 */ 650, 650, 639, 639, 639, 639, 955, 955, 950, 701,
91276 /* 310 */ 701, 683, 958, 958, 958, 958, 958, 958, 884, 958,
91277 /* 320 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91278 /* 330 */ 958, 958, 958, 635, 945, 958, 958, 942, 958, 958,
91279 /* 340 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91280 /* 350 */ 958, 958, 958, 958, 958, 958, 958, 958, 914, 958,
91281 /* 360 */ 958, 958, 958, 958, 958, 907, 906, 958, 958, 958,
91282 /* 370 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91283 /* 380 */ 958, 958, 958, 958, 958, 958, 958, 958, 958, 958,
91284 /* 390 */ 958, 958, 958, 788, 958, 780, 958, 868, 958, 958,
91285 /* 400 */ 958, 958, 958, 958, 958, 958, 958, 958, 743, 817,
91286 /* 410 */ 958, 816, 820, 815, 667, 958, 648, 958, 631, 636,
91287 /* 420 */ 954, 957, 956, 953, 952, 951, 946, 944, 941, 940,
91288 /* 430 */ 939, 937, 934, 930, 888, 886, 893, 892, 891, 890,
91289 /* 440 */ 889, 887, 885, 883, 803, 801, 798, 795, 929, 881,
91290 /* 450 */ 739, 736, 735, 656, 947, 913, 922, 920, 809, 919,
91291 /* 460 */ 918, 917, 915, 912, 899, 805, 804, 731, 873, 872,
91292 /* 470 */ 659, 903, 902, 901, 905, 909, 900, 767, 658, 655,
91293 /* 480 */ 664, 720, 719, 727, 725, 724, 723, 722, 721, 718,
91294 /* 490 */ 666, 674, 685, 712, 698, 697, 878, 880, 877, 876,
91295 /* 500 */ 705, 710, 709, 708, 707, 706, 704, 703, 702, 695,
91296 /* 510 */ 694, 700, 693, 715, 714, 711, 692, 734, 733, 732,
91297 /* 520 */ 729, 691, 690, 689, 820, 688, 687, 826, 825, 813,
91298 /* 530 */ 857, 754, 753, 752, 764, 763, 776, 775, 811, 810,
91299 /* 540 */ 777, 762, 756, 755, 771, 770, 769, 768, 760, 750,
91300 /* 550 */ 782, 785, 784, 781, 842, 859, 766, 856, 928, 927,
91301 /* 560 */ 926, 925, 924, 861, 860, 827, 824, 678, 679, 897,
91302 /* 570 */ 895, 896, 894, 681, 680, 677, 676, 858, 745, 744,
91303 /* 580 */ 854, 851, 843, 838, 855, 852, 844, 839, 837, 836,
91304 /* 590 */ 822, 821, 819, 818, 814, 823, 669, 746, 742, 741,
91305 /* 600 */ 812, 748, 747, 686, 684, 682, 663, 661, 654, 652,
91306 /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
91307 /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
 
91308 };
91309
91310 /* The next table maps tokens into fallback tokens. If a construct
91311 ** like the following:
91312 **
@@ -91487,17 +91521,17 @@
91487 "LSHIFT", "RSHIFT", "PLUS", "MINUS",
91488 "STAR", "SLASH", "REM", "CONCAT",
91489 "COLLATE", "BITNOT", "STRING", "JOIN_KW",
91490 "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
91491 "UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
91492 "ON", "DELETE", "UPDATE", "SET",
91493 "DEFERRABLE", "FOREIGN", "DROP", "UNION",
91494 "ALL", "EXCEPT", "INTERSECT", "SELECT",
91495 "DISTINCT", "DOT", "FROM", "JOIN",
91496 "USING", "ORDER", "GROUP", "HAVING",
91497 "LIMIT", "WHERE", "INTO", "VALUES",
91498 "INSERT", "INTEGER", "FLOAT", "BLOB",
91499 "REGISTER", "VARIABLE", "CASE", "WHEN",
91500 "THEN", "ELSE", "INDEX", "ALTER",
91501 "ADD", "error", "input", "cmdlist",
91502 "ecmd", "explain", "cmdx", "cmd",
91503 "transtype", "trans_opt", "nm", "savepoint_opt",
@@ -91607,264 +91641,265 @@
91607 /* 70 */ "autoinc ::=",
91608 /* 71 */ "autoinc ::= AUTOINCR",
91609 /* 72 */ "refargs ::=",
91610 /* 73 */ "refargs ::= refargs refarg",
91611 /* 74 */ "refarg ::= MATCH nm",
91612 /* 75 */ "refarg ::= ON DELETE refact",
91613 /* 76 */ "refarg ::= ON UPDATE refact",
91614 /* 77 */ "refact ::= SET NULL",
91615 /* 78 */ "refact ::= SET DEFAULT",
91616 /* 79 */ "refact ::= CASCADE",
91617 /* 80 */ "refact ::= RESTRICT",
91618 /* 81 */ "refact ::= NO ACTION",
91619 /* 82 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
91620 /* 83 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
91621 /* 84 */ "init_deferred_pred_opt ::=",
91622 /* 85 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
91623 /* 86 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
91624 /* 87 */ "conslist_opt ::=",
91625 /* 88 */ "conslist_opt ::= COMMA conslist",
91626 /* 89 */ "conslist ::= conslist COMMA tcons",
91627 /* 90 */ "conslist ::= conslist tcons",
91628 /* 91 */ "conslist ::= tcons",
91629 /* 92 */ "tcons ::= CONSTRAINT nm",
91630 /* 93 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
91631 /* 94 */ "tcons ::= UNIQUE LP idxlist RP onconf",
91632 /* 95 */ "tcons ::= CHECK LP expr RP onconf",
91633 /* 96 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
91634 /* 97 */ "defer_subclause_opt ::=",
91635 /* 98 */ "defer_subclause_opt ::= defer_subclause",
91636 /* 99 */ "onconf ::=",
91637 /* 100 */ "onconf ::= ON CONFLICT resolvetype",
91638 /* 101 */ "orconf ::=",
91639 /* 102 */ "orconf ::= OR resolvetype",
91640 /* 103 */ "resolvetype ::= raisetype",
91641 /* 104 */ "resolvetype ::= IGNORE",
91642 /* 105 */ "resolvetype ::= REPLACE",
91643 /* 106 */ "cmd ::= DROP TABLE ifexists fullname",
91644 /* 107 */ "ifexists ::= IF EXISTS",
91645 /* 108 */ "ifexists ::=",
91646 /* 109 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91647 /* 110 */ "cmd ::= DROP VIEW ifexists fullname",
91648 /* 111 */ "cmd ::= select",
91649 /* 112 */ "select ::= oneselect",
91650 /* 113 */ "select ::= select multiselect_op oneselect",
91651 /* 114 */ "multiselect_op ::= UNION",
91652 /* 115 */ "multiselect_op ::= UNION ALL",
91653 /* 116 */ "multiselect_op ::= EXCEPT|INTERSECT",
91654 /* 117 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91655 /* 118 */ "distinct ::= DISTINCT",
91656 /* 119 */ "distinct ::= ALL",
91657 /* 120 */ "distinct ::=",
91658 /* 121 */ "sclp ::= selcollist COMMA",
91659 /* 122 */ "sclp ::=",
91660 /* 123 */ "selcollist ::= sclp expr as",
91661 /* 124 */ "selcollist ::= sclp STAR",
91662 /* 125 */ "selcollist ::= sclp nm DOT STAR",
91663 /* 126 */ "as ::= AS nm",
91664 /* 127 */ "as ::= ids",
91665 /* 128 */ "as ::=",
91666 /* 129 */ "from ::=",
91667 /* 130 */ "from ::= FROM seltablist",
91668 /* 131 */ "stl_prefix ::= seltablist joinop",
91669 /* 132 */ "stl_prefix ::=",
91670 /* 133 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
91671 /* 134 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
91672 /* 135 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
91673 /* 136 */ "dbnm ::=",
91674 /* 137 */ "dbnm ::= DOT nm",
91675 /* 138 */ "fullname ::= nm dbnm",
91676 /* 139 */ "joinop ::= COMMA|JOIN",
91677 /* 140 */ "joinop ::= JOIN_KW JOIN",
91678 /* 141 */ "joinop ::= JOIN_KW nm JOIN",
91679 /* 142 */ "joinop ::= JOIN_KW nm nm JOIN",
91680 /* 143 */ "on_opt ::= ON expr",
91681 /* 144 */ "on_opt ::=",
91682 /* 145 */ "indexed_opt ::=",
91683 /* 146 */ "indexed_opt ::= INDEXED BY nm",
91684 /* 147 */ "indexed_opt ::= NOT INDEXED",
91685 /* 148 */ "using_opt ::= USING LP inscollist RP",
91686 /* 149 */ "using_opt ::=",
91687 /* 150 */ "orderby_opt ::=",
91688 /* 151 */ "orderby_opt ::= ORDER BY sortlist",
91689 /* 152 */ "sortlist ::= sortlist COMMA sortitem sortorder",
91690 /* 153 */ "sortlist ::= sortitem sortorder",
91691 /* 154 */ "sortitem ::= expr",
91692 /* 155 */ "sortorder ::= ASC",
91693 /* 156 */ "sortorder ::= DESC",
91694 /* 157 */ "sortorder ::=",
91695 /* 158 */ "groupby_opt ::=",
91696 /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
91697 /* 160 */ "having_opt ::=",
91698 /* 161 */ "having_opt ::= HAVING expr",
91699 /* 162 */ "limit_opt ::=",
91700 /* 163 */ "limit_opt ::= LIMIT expr",
91701 /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
91702 /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
91703 /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
91704 /* 167 */ "where_opt ::=",
91705 /* 168 */ "where_opt ::= WHERE expr",
91706 /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
91707 /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
91708 /* 171 */ "setlist ::= nm EQ expr",
91709 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
91710 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
91711 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
91712 /* 175 */ "insert_cmd ::= INSERT orconf",
91713 /* 176 */ "insert_cmd ::= REPLACE",
91714 /* 177 */ "itemlist ::= itemlist COMMA expr",
91715 /* 178 */ "itemlist ::= expr",
91716 /* 179 */ "inscollist_opt ::=",
91717 /* 180 */ "inscollist_opt ::= LP inscollist RP",
91718 /* 181 */ "inscollist ::= inscollist COMMA nm",
91719 /* 182 */ "inscollist ::= nm",
91720 /* 183 */ "expr ::= term",
91721 /* 184 */ "expr ::= LP expr RP",
91722 /* 185 */ "term ::= NULL",
91723 /* 186 */ "expr ::= id",
91724 /* 187 */ "expr ::= JOIN_KW",
91725 /* 188 */ "expr ::= nm DOT nm",
91726 /* 189 */ "expr ::= nm DOT nm DOT nm",
91727 /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
91728 /* 191 */ "term ::= STRING",
91729 /* 192 */ "expr ::= REGISTER",
91730 /* 193 */ "expr ::= VARIABLE",
91731 /* 194 */ "expr ::= expr COLLATE ids",
91732 /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
91733 /* 196 */ "expr ::= ID LP distinct exprlist RP",
91734 /* 197 */ "expr ::= ID LP STAR RP",
91735 /* 198 */ "term ::= CTIME_KW",
91736 /* 199 */ "expr ::= expr AND expr",
91737 /* 200 */ "expr ::= expr OR expr",
91738 /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
91739 /* 202 */ "expr ::= expr EQ|NE expr",
91740 /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
91741 /* 204 */ "expr ::= expr PLUS|MINUS expr",
91742 /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
91743 /* 206 */ "expr ::= expr CONCAT expr",
91744 /* 207 */ "likeop ::= LIKE_KW",
91745 /* 208 */ "likeop ::= NOT LIKE_KW",
91746 /* 209 */ "likeop ::= MATCH",
91747 /* 210 */ "likeop ::= NOT MATCH",
91748 /* 211 */ "escape ::= ESCAPE expr",
91749 /* 212 */ "escape ::=",
91750 /* 213 */ "expr ::= expr likeop expr escape",
91751 /* 214 */ "expr ::= expr ISNULL|NOTNULL",
91752 /* 215 */ "expr ::= expr NOT NULL",
91753 /* 216 */ "expr ::= expr IS expr",
91754 /* 217 */ "expr ::= expr IS NOT expr",
91755 /* 218 */ "expr ::= NOT expr",
91756 /* 219 */ "expr ::= BITNOT expr",
91757 /* 220 */ "expr ::= MINUS expr",
91758 /* 221 */ "expr ::= PLUS expr",
91759 /* 222 */ "between_op ::= BETWEEN",
91760 /* 223 */ "between_op ::= NOT BETWEEN",
91761 /* 224 */ "expr ::= expr between_op expr AND expr",
91762 /* 225 */ "in_op ::= IN",
91763 /* 226 */ "in_op ::= NOT IN",
91764 /* 227 */ "expr ::= expr in_op LP exprlist RP",
91765 /* 228 */ "expr ::= LP select RP",
91766 /* 229 */ "expr ::= expr in_op LP select RP",
91767 /* 230 */ "expr ::= expr in_op nm dbnm",
91768 /* 231 */ "expr ::= EXISTS LP select RP",
91769 /* 232 */ "expr ::= CASE case_operand case_exprlist case_else END",
91770 /* 233 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
91771 /* 234 */ "case_exprlist ::= WHEN expr THEN expr",
91772 /* 235 */ "case_else ::= ELSE expr",
91773 /* 236 */ "case_else ::=",
91774 /* 237 */ "case_operand ::= expr",
91775 /* 238 */ "case_operand ::=",
91776 /* 239 */ "exprlist ::= nexprlist",
91777 /* 240 */ "exprlist ::=",
91778 /* 241 */ "nexprlist ::= nexprlist COMMA expr",
91779 /* 242 */ "nexprlist ::= expr",
91780 /* 243 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
91781 /* 244 */ "uniqueflag ::= UNIQUE",
91782 /* 245 */ "uniqueflag ::=",
91783 /* 246 */ "idxlist_opt ::=",
91784 /* 247 */ "idxlist_opt ::= LP idxlist RP",
91785 /* 248 */ "idxlist ::= idxlist COMMA nm collate sortorder",
91786 /* 249 */ "idxlist ::= nm collate sortorder",
91787 /* 250 */ "collate ::=",
91788 /* 251 */ "collate ::= COLLATE ids",
91789 /* 252 */ "cmd ::= DROP INDEX ifexists fullname",
91790 /* 253 */ "cmd ::= VACUUM",
91791 /* 254 */ "cmd ::= VACUUM nm",
91792 /* 255 */ "cmd ::= PRAGMA nm dbnm",
91793 /* 256 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
91794 /* 257 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
91795 /* 258 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
91796 /* 259 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
91797 /* 260 */ "nmnum ::= plus_num",
91798 /* 261 */ "nmnum ::= nm",
91799 /* 262 */ "nmnum ::= ON",
91800 /* 263 */ "nmnum ::= DELETE",
91801 /* 264 */ "nmnum ::= DEFAULT",
91802 /* 265 */ "plus_num ::= plus_opt number",
91803 /* 266 */ "minus_num ::= MINUS number",
91804 /* 267 */ "number ::= INTEGER|FLOAT",
91805 /* 268 */ "plus_opt ::= PLUS",
91806 /* 269 */ "plus_opt ::=",
91807 /* 270 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
91808 /* 271 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
91809 /* 272 */ "trigger_time ::= BEFORE",
91810 /* 273 */ "trigger_time ::= AFTER",
91811 /* 274 */ "trigger_time ::= INSTEAD OF",
91812 /* 275 */ "trigger_time ::=",
91813 /* 276 */ "trigger_event ::= DELETE|INSERT",
91814 /* 277 */ "trigger_event ::= UPDATE",
91815 /* 278 */ "trigger_event ::= UPDATE OF inscollist",
91816 /* 279 */ "foreach_clause ::=",
91817 /* 280 */ "foreach_clause ::= FOR EACH ROW",
91818 /* 281 */ "when_clause ::=",
91819 /* 282 */ "when_clause ::= WHEN expr",
91820 /* 283 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
91821 /* 284 */ "trigger_cmd_list ::= trigger_cmd SEMI",
91822 /* 285 */ "trnm ::= nm",
91823 /* 286 */ "trnm ::= nm DOT nm",
91824 /* 287 */ "tridxby ::=",
91825 /* 288 */ "tridxby ::= INDEXED BY nm",
91826 /* 289 */ "tridxby ::= NOT INDEXED",
91827 /* 290 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
91828 /* 291 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
91829 /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
91830 /* 293 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
91831 /* 294 */ "trigger_cmd ::= select",
91832 /* 295 */ "expr ::= RAISE LP IGNORE RP",
91833 /* 296 */ "expr ::= RAISE LP raisetype COMMA nm RP",
91834 /* 297 */ "raisetype ::= ROLLBACK",
91835 /* 298 */ "raisetype ::= ABORT",
91836 /* 299 */ "raisetype ::= FAIL",
91837 /* 300 */ "cmd ::= DROP TRIGGER ifexists fullname",
91838 /* 301 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
91839 /* 302 */ "cmd ::= DETACH database_kw_opt expr",
91840 /* 303 */ "key_opt ::=",
91841 /* 304 */ "key_opt ::= KEY expr",
91842 /* 305 */ "database_kw_opt ::= DATABASE",
91843 /* 306 */ "database_kw_opt ::=",
91844 /* 307 */ "cmd ::= REINDEX",
91845 /* 308 */ "cmd ::= REINDEX nm dbnm",
91846 /* 309 */ "cmd ::= ANALYZE",
91847 /* 310 */ "cmd ::= ANALYZE nm dbnm",
91848 /* 311 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
91849 /* 312 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
91850 /* 313 */ "add_column_fullname ::= fullname",
91851 /* 314 */ "kwcolumn_opt ::=",
91852 /* 315 */ "kwcolumn_opt ::= COLUMNKW",
91853 /* 316 */ "cmd ::= create_vtab",
91854 /* 317 */ "cmd ::= create_vtab LP vtabarglist RP",
91855 /* 318 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
91856 /* 319 */ "vtabarglist ::= vtabarg",
91857 /* 320 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
91858 /* 321 */ "vtabarg ::=",
91859 /* 322 */ "vtabarg ::= vtabarg vtabargtoken",
91860 /* 323 */ "vtabargtoken ::= ANY",
91861 /* 324 */ "vtabargtoken ::= lp anylist RP",
91862 /* 325 */ "lp ::= LP",
91863 /* 326 */ "anylist ::=",
91864 /* 327 */ "anylist ::= anylist LP anylist RP",
91865 /* 328 */ "anylist ::= anylist ANY",
 
91866 };
91867 #endif /* NDEBUG */
91868
91869
91870 #if YYSTACKDEPTH<=0
@@ -92326,10 +92361,11 @@
92326 { 180, 0 },
92327 { 180, 2 },
92328 { 182, 2 },
92329 { 182, 3 },
92330 { 182, 3 },
 
92331 { 183, 2 },
92332 { 183, 2 },
92333 { 183, 1 },
92334 { 183, 1 },
92335 { 183, 2 },
@@ -92653,12 +92689,12 @@
92653 {yygotominor.yy328 = TK_DEFERRED;}
92654 break;
92655 case 14: /* transtype ::= DEFERRED */
92656 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
92657 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
92658 case 114: /* multiselect_op ::= UNION */ yytestcase(yyruleno==114);
92659 case 116: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==116);
92660 {yygotominor.yy328 = yymsp[0].major;}
92661 break;
92662 case 17: /* cmd ::= COMMIT trans_opt */
92663 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
92664 {sqlite3CommitTransaction(pParse);}
@@ -92693,29 +92729,29 @@
92693 }
92694 break;
92695 case 28: /* ifnotexists ::= */
92696 case 31: /* temp ::= */ yytestcase(yyruleno==31);
92697 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
92698 case 82: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==82);
92699 case 84: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==84);
92700 case 86: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==86);
92701 case 97: /* defer_subclause_opt ::= */ yytestcase(yyruleno==97);
92702 case 108: /* ifexists ::= */ yytestcase(yyruleno==108);
92703 case 119: /* distinct ::= ALL */ yytestcase(yyruleno==119);
92704 case 120: /* distinct ::= */ yytestcase(yyruleno==120);
92705 case 222: /* between_op ::= BETWEEN */ yytestcase(yyruleno==222);
92706 case 225: /* in_op ::= IN */ yytestcase(yyruleno==225);
92707 {yygotominor.yy328 = 0;}
92708 break;
92709 case 29: /* ifnotexists ::= IF NOT EXISTS */
92710 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
92711 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
92712 case 85: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==85);
92713 case 107: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==107);
92714 case 118: /* distinct ::= DISTINCT */ yytestcase(yyruleno==118);
92715 case 223: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==223);
92716 case 226: /* in_op ::= NOT IN */ yytestcase(yyruleno==226);
92717 {yygotominor.yy328 = 1;}
92718 break;
92719 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
92720 {
92721 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -92745,24 +92781,24 @@
92745 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
92746 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
92747 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
92748 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
92749 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
92750 case 126: /* as ::= AS nm */ yytestcase(yyruleno==126);
92751 case 127: /* as ::= ids */ yytestcase(yyruleno==127);
92752 case 137: /* dbnm ::= DOT nm */ yytestcase(yyruleno==137);
92753 case 146: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==146);
92754 case 251: /* collate ::= COLLATE ids */ yytestcase(yyruleno==251);
92755 case 260: /* nmnum ::= plus_num */ yytestcase(yyruleno==260);
92756 case 261: /* nmnum ::= nm */ yytestcase(yyruleno==261);
92757 case 262: /* nmnum ::= ON */ yytestcase(yyruleno==262);
92758 case 263: /* nmnum ::= DELETE */ yytestcase(yyruleno==263);
92759 case 264: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==264);
92760 case 265: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==265);
92761 case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
92762 case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
92763 case 285: /* trnm ::= nm */ yytestcase(yyruleno==285);
92764 {yygotominor.yy0 = yymsp[0].minor.yy0;}
92765 break;
92766 case 45: /* type ::= typetoken */
92767 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
92768 break;
@@ -92830,101 +92866,102 @@
92830 break;
92831 case 73: /* refargs ::= refargs refarg */
92832 { yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
92833 break;
92834 case 74: /* refarg ::= MATCH nm */
 
92835 { yygotominor.yy429.value = 0; yygotominor.yy429.mask = 0x000000; }
92836 break;
92837 case 75: /* refarg ::= ON DELETE refact */
92838 { yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
92839 break;
92840 case 76: /* refarg ::= ON UPDATE refact */
92841 { yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
92842 break;
92843 case 77: /* refact ::= SET NULL */
92844 { yygotominor.yy328 = OE_SetNull; /* EV: R-33326-45252 */}
92845 break;
92846 case 78: /* refact ::= SET DEFAULT */
92847 { yygotominor.yy328 = OE_SetDflt; /* EV: R-33326-45252 */}
92848 break;
92849 case 79: /* refact ::= CASCADE */
92850 { yygotominor.yy328 = OE_Cascade; /* EV: R-33326-45252 */}
92851 break;
92852 case 80: /* refact ::= RESTRICT */
92853 { yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
92854 break;
92855 case 81: /* refact ::= NO ACTION */
92856 { yygotominor.yy328 = OE_None; /* EV: R-33326-45252 */}
92857 break;
92858 case 83: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
92859 case 98: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==98);
92860 case 100: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==100);
92861 case 103: /* resolvetype ::= raisetype */ yytestcase(yyruleno==103);
92862 {yygotominor.yy328 = yymsp[0].minor.yy328;}
92863 break;
92864 case 87: /* conslist_opt ::= */
92865 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
92866 break;
92867 case 88: /* conslist_opt ::= COMMA conslist */
92868 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
92869 break;
92870 case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
92871 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);}
92872 break;
92873 case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */
92874 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);}
92875 break;
92876 case 95: /* tcons ::= CHECK LP expr RP onconf */
92877 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
92878 break;
92879 case 96: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
92880 {
92881 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328);
92882 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328);
92883 }
92884 break;
92885 case 99: /* onconf ::= */
92886 {yygotominor.yy328 = OE_Default;}
92887 break;
92888 case 101: /* orconf ::= */
92889 {yygotominor.yy186 = OE_Default;}
92890 break;
92891 case 102: /* orconf ::= OR resolvetype */
92892 {yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
92893 break;
92894 case 104: /* resolvetype ::= IGNORE */
92895 {yygotominor.yy328 = OE_Ignore;}
92896 break;
92897 case 105: /* resolvetype ::= REPLACE */
92898 {yygotominor.yy328 = OE_Replace;}
92899 break;
92900 case 106: /* cmd ::= DROP TABLE ifexists fullname */
92901 {
92902 sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
92903 }
92904 break;
92905 case 109: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
92906 {
92907 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328);
92908 }
92909 break;
92910 case 110: /* cmd ::= DROP VIEW ifexists fullname */
92911 {
92912 sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
92913 }
92914 break;
92915 case 111: /* cmd ::= select */
92916 {
92917 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
92918 sqlite3Select(pParse, yymsp[0].minor.yy3, &dest);
92919 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
92920 }
92921 break;
92922 case 112: /* select ::= oneselect */
92923 {yygotominor.yy3 = yymsp[0].minor.yy3;}
92924 break;
92925 case 113: /* select ::= select multiselect_op oneselect */
92926 {
92927 if( yymsp[0].minor.yy3 ){
92928 yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
92929 yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3;
92930 }else{
@@ -92931,83 +92968,83 @@
92931 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
92932 }
92933 yygotominor.yy3 = yymsp[0].minor.yy3;
92934 }
92935 break;
92936 case 115: /* multiselect_op ::= UNION ALL */
92937 {yygotominor.yy328 = TK_ALL;}
92938 break;
92939 case 117: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
92940 {
92941 yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy65,yymsp[-4].minor.yy132,yymsp[-3].minor.yy14,yymsp[-2].minor.yy132,yymsp[-1].minor.yy14,yymsp[-7].minor.yy328,yymsp[0].minor.yy476.pLimit,yymsp[0].minor.yy476.pOffset);
92942 }
92943 break;
92944 case 121: /* sclp ::= selcollist COMMA */
92945 case 247: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==247);
92946 {yygotominor.yy14 = yymsp[-1].minor.yy14;}
92947 break;
92948 case 122: /* sclp ::= */
92949 case 150: /* orderby_opt ::= */ yytestcase(yyruleno==150);
92950 case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
92951 case 240: /* exprlist ::= */ yytestcase(yyruleno==240);
92952 case 246: /* idxlist_opt ::= */ yytestcase(yyruleno==246);
92953 {yygotominor.yy14 = 0;}
92954 break;
92955 case 123: /* selcollist ::= sclp expr as */
92956 {
92957 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr);
92958 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1);
92959 sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346);
92960 }
92961 break;
92962 case 124: /* selcollist ::= sclp STAR */
92963 {
92964 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
92965 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
92966 }
92967 break;
92968 case 125: /* selcollist ::= sclp nm DOT STAR */
92969 {
92970 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
92971 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
92972 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
92973 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
92974 }
92975 break;
92976 case 128: /* as ::= */
92977 {yygotominor.yy0.n = 0;}
92978 break;
92979 case 129: /* from ::= */
92980 {yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
92981 break;
92982 case 130: /* from ::= FROM seltablist */
92983 {
92984 yygotominor.yy65 = yymsp[0].minor.yy65;
92985 sqlite3SrcListShiftJoinType(yygotominor.yy65);
92986 }
92987 break;
92988 case 131: /* stl_prefix ::= seltablist joinop */
92989 {
92990 yygotominor.yy65 = yymsp[-1].minor.yy65;
92991 if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328;
92992 }
92993 break;
92994 case 132: /* stl_prefix ::= */
92995 {yygotominor.yy65 = 0;}
92996 break;
92997 case 133: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
92998 {
92999 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93000 sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0);
93001 }
93002 break;
93003 case 134: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
93004 {
93005 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93006 }
93007 break;
93008 case 135: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
93009 {
93010 if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){
93011 yygotominor.yy65 = yymsp[-4].minor.yy65;
93012 }else{
93013 Select *pSubquery;
@@ -93015,180 +93052,180 @@
93015 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,0,0,0);
93016 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93017 }
93018 }
93019 break;
93020 case 136: /* dbnm ::= */
93021 case 145: /* indexed_opt ::= */ yytestcase(yyruleno==145);
93022 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
93023 break;
93024 case 138: /* fullname ::= nm dbnm */
93025 {yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
93026 break;
93027 case 139: /* joinop ::= COMMA|JOIN */
93028 { yygotominor.yy328 = JT_INNER; }
93029 break;
93030 case 140: /* joinop ::= JOIN_KW JOIN */
93031 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
93032 break;
93033 case 141: /* joinop ::= JOIN_KW nm JOIN */
93034 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
93035 break;
93036 case 142: /* joinop ::= JOIN_KW nm nm JOIN */
93037 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
93038 break;
93039 case 143: /* on_opt ::= ON expr */
93040 case 154: /* sortitem ::= expr */ yytestcase(yyruleno==154);
93041 case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
93042 case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
93043 case 235: /* case_else ::= ELSE expr */ yytestcase(yyruleno==235);
93044 case 237: /* case_operand ::= expr */ yytestcase(yyruleno==237);
93045 {yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;}
93046 break;
93047 case 144: /* on_opt ::= */
93048 case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
93049 case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
93050 case 236: /* case_else ::= */ yytestcase(yyruleno==236);
93051 case 238: /* case_operand ::= */ yytestcase(yyruleno==238);
93052 {yygotominor.yy132 = 0;}
93053 break;
93054 case 147: /* indexed_opt ::= NOT INDEXED */
93055 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
93056 break;
93057 case 148: /* using_opt ::= USING LP inscollist RP */
93058 case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
93059 {yygotominor.yy408 = yymsp[-1].minor.yy408;}
93060 break;
93061 case 149: /* using_opt ::= */
93062 case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
93063 {yygotominor.yy408 = 0;}
93064 break;
93065 case 151: /* orderby_opt ::= ORDER BY sortlist */
93066 case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
93067 case 239: /* exprlist ::= nexprlist */ yytestcase(yyruleno==239);
93068 {yygotominor.yy14 = yymsp[0].minor.yy14;}
93069 break;
93070 case 152: /* sortlist ::= sortlist COMMA sortitem sortorder */
93071 {
93072 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy132);
93073 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93074 }
93075 break;
93076 case 153: /* sortlist ::= sortitem sortorder */
93077 {
93078 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy132);
93079 if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328;
93080 }
93081 break;
93082 case 155: /* sortorder ::= ASC */
93083 case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
93084 {yygotominor.yy328 = SQLITE_SO_ASC;}
93085 break;
93086 case 156: /* sortorder ::= DESC */
93087 {yygotominor.yy328 = SQLITE_SO_DESC;}
93088 break;
93089 case 162: /* limit_opt ::= */
93090 {yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
93091 break;
93092 case 163: /* limit_opt ::= LIMIT expr */
93093 {yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
93094 break;
93095 case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
93096 {yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
93097 break;
93098 case 165: /* limit_opt ::= LIMIT expr COMMA expr */
93099 {yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
93100 break;
93101 case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
93102 {
93103 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0);
93104 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132);
93105 }
93106 break;
93107 case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
93108 {
93109 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0);
93110 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list");
93111 sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186);
93112 }
93113 break;
93114 case 170: /* setlist ::= setlist COMMA nm EQ expr */
93115 {
93116 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr);
93117 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93118 }
93119 break;
93120 case 171: /* setlist ::= nm EQ expr */
93121 {
93122 yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr);
93123 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93124 }
93125 break;
93126 case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
93127 {sqlite3Insert(pParse, yymsp[-5].minor.yy65, yymsp[-1].minor.yy14, 0, yymsp[-4].minor.yy408, yymsp[-7].minor.yy186);}
93128 break;
93129 case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
93130 {sqlite3Insert(pParse, yymsp[-2].minor.yy65, 0, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);}
93131 break;
93132 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
93133 {sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);}
93134 break;
93135 case 175: /* insert_cmd ::= INSERT orconf */
93136 {yygotominor.yy186 = yymsp[0].minor.yy186;}
93137 break;
93138 case 176: /* insert_cmd ::= REPLACE */
93139 {yygotominor.yy186 = OE_Replace;}
93140 break;
93141 case 177: /* itemlist ::= itemlist COMMA expr */
93142 case 241: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==241);
93143 {yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);}
93144 break;
93145 case 178: /* itemlist ::= expr */
93146 case 242: /* nexprlist ::= expr */ yytestcase(yyruleno==242);
93147 {yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
93148 break;
93149 case 181: /* inscollist ::= inscollist COMMA nm */
93150 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
93151 break;
93152 case 182: /* inscollist ::= nm */
93153 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
93154 break;
93155 case 183: /* expr ::= term */
93156 case 211: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==211);
93157 {yygotominor.yy346 = yymsp[0].minor.yy346;}
93158 break;
93159 case 184: /* expr ::= LP expr RP */
93160 {yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
93161 break;
93162 case 185: /* term ::= NULL */
93163 case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
93164 case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
93165 {spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
93166 break;
93167 case 186: /* expr ::= id */
93168 case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
93169 {spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
93170 break;
93171 case 188: /* expr ::= nm DOT nm */
93172 {
93173 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
93174 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
93175 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
93176 spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
93177 }
93178 break;
93179 case 189: /* expr ::= nm DOT nm DOT nm */
93180 {
93181 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
93182 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
93183 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
93184 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
93185 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
93186 spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
93187 }
93188 break;
93189 case 192: /* expr ::= REGISTER */
93190 {
93191 /* When doing a nested parse, one can include terms in an expression
93192 ** that look like this: #1 #2 ... These terms refer to registers
93193 ** in the virtual machine. #N is the N-th register. */
93194 if( pParse->nested==0 ){
@@ -93199,31 +93236,31 @@
93199 if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable);
93200 }
93201 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93202 }
93203 break;
93204 case 193: /* expr ::= VARIABLE */
93205 {
93206 spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
93207 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr);
93208 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93209 }
93210 break;
93211 case 194: /* expr ::= expr COLLATE ids */
93212 {
93213 yygotominor.yy346.pExpr = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
93214 yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
93215 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93216 }
93217 break;
93218 case 195: /* expr ::= CAST LP expr AS typetoken RP */
93219 {
93220 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0);
93221 spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
93222 }
93223 break;
93224 case 196: /* expr ::= ID LP distinct exprlist RP */
93225 {
93226 if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
93227 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
93228 }
93229 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
@@ -93231,17 +93268,17 @@
93231 if( yymsp[-2].minor.yy328 && yygotominor.yy346.pExpr ){
93232 yygotominor.yy346.pExpr->flags |= EP_Distinct;
93233 }
93234 }
93235 break;
93236 case 197: /* expr ::= ID LP STAR RP */
93237 {
93238 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
93239 spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
93240 }
93241 break;
93242 case 198: /* term ::= CTIME_KW */
93243 {
93244 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
93245 ** treated as functions that return constants */
93246 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
93247 if( yygotominor.yy346.pExpr ){
@@ -93248,32 +93285,32 @@
93248 yygotominor.yy346.pExpr->op = TK_CONST_FUNC;
93249 }
93250 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93251 }
93252 break;
93253 case 199: /* expr ::= expr AND expr */
93254 case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
93255 case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
93256 case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
93257 case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
93258 case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
93259 case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
93260 case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
93261 {spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);}
93262 break;
93263 case 207: /* likeop ::= LIKE_KW */
93264 case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
93265 {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;}
93266 break;
93267 case 208: /* likeop ::= NOT LIKE_KW */
93268 case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
93269 {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 1;}
93270 break;
93271 case 212: /* escape ::= */
93272 {memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));}
93273 break;
93274 case 213: /* expr ::= expr likeop expr escape */
93275 {
93276 ExprList *pList;
93277 pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr);
93278 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy346.pExpr);
93279 if( yymsp[0].minor.yy346.pExpr ){
@@ -93284,39 +93321,39 @@
93284 yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
93285 yygotominor.yy346.zEnd = yymsp[-1].minor.yy346.zEnd;
93286 if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
93287 }
93288 break;
93289 case 214: /* expr ::= expr ISNULL|NOTNULL */
93290 {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
93291 break;
93292 case 215: /* expr ::= expr NOT NULL */
93293 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
93294 break;
93295 case 216: /* expr ::= expr IS expr */
93296 {
93297 spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
93298 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
93299 }
93300 break;
93301 case 217: /* expr ::= expr IS NOT expr */
93302 {
93303 spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
93304 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
93305 }
93306 break;
93307 case 218: /* expr ::= NOT expr */
93308 case 219: /* expr ::= BITNOT expr */ yytestcase(yyruleno==219);
93309 {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93310 break;
93311 case 220: /* expr ::= MINUS expr */
93312 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93313 break;
93314 case 221: /* expr ::= PLUS expr */
93315 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93316 break;
93317 case 224: /* expr ::= expr between_op expr AND expr */
93318 {
93319 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
93320 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
93321 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93322 if( yygotominor.yy346.pExpr ){
@@ -93327,11 +93364,11 @@
93327 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93328 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93329 yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
93330 }
93331 break;
93332 case 227: /* expr ::= expr in_op LP exprlist RP */
93333 {
93334 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93335 if( yygotominor.yy346.pExpr ){
93336 yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
93337 sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93341,11 +93378,11 @@
93341 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93342 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93343 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93344 }
93345 break;
93346 case 228: /* expr ::= LP select RP */
93347 {
93348 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
93349 if( yygotominor.yy346.pExpr ){
93350 yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
93351 ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93355,11 +93392,11 @@
93355 }
93356 yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z;
93357 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93358 }
93359 break;
93360 case 229: /* expr ::= expr in_op LP select RP */
93361 {
93362 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93363 if( yygotominor.yy346.pExpr ){
93364 yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
93365 ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93370,11 +93407,11 @@
93370 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93371 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93372 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93373 }
93374 break;
93375 case 230: /* expr ::= expr in_op nm dbnm */
93376 {
93377 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
93378 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
93379 if( yygotominor.yy346.pExpr ){
93380 yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -93386,11 +93423,11 @@
93386 if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93387 yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
93388 yygotominor.yy346.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
93389 }
93390 break;
93391 case 231: /* expr ::= EXISTS LP select RP */
93392 {
93393 Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
93394 if( p ){
93395 p->x.pSelect = yymsp[-1].minor.yy3;
93396 ExprSetProperty(p, EP_xIsSelect);
@@ -93400,11 +93437,11 @@
93400 }
93401 yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
93402 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93403 }
93404 break;
93405 case 232: /* expr ::= CASE case_operand case_exprlist case_else END */
93406 {
93407 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, yymsp[-1].minor.yy132, 0);
93408 if( yygotominor.yy346.pExpr ){
93409 yygotominor.yy346.pExpr->x.pList = yymsp[-2].minor.yy14;
93410 sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93413,37 +93450,37 @@
93413 }
93414 yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z;
93415 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93416 }
93417 break;
93418 case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
93419 {
93420 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr);
93421 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
93422 }
93423 break;
93424 case 234: /* case_exprlist ::= WHEN expr THEN expr */
93425 {
93426 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
93427 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
93428 }
93429 break;
93430 case 243: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
93431 {
93432 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
93433 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy14, yymsp[-9].minor.yy328,
93434 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy328);
93435 }
93436 break;
93437 case 244: /* uniqueflag ::= UNIQUE */
93438 case 298: /* raisetype ::= ABORT */ yytestcase(yyruleno==298);
93439 {yygotominor.yy328 = OE_Abort;}
93440 break;
93441 case 245: /* uniqueflag ::= */
93442 {yygotominor.yy328 = OE_None;}
93443 break;
93444 case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */
93445 {
93446 Expr *p = 0;
93447 if( yymsp[-1].minor.yy0.n>0 ){
93448 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
93449 sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93452,11 +93489,11 @@
93452 sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
93453 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
93454 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93455 }
93456 break;
93457 case 249: /* idxlist ::= nm collate sortorder */
93458 {
93459 Expr *p = 0;
93460 if( yymsp[-1].minor.yy0.n>0 ){
93461 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
93462 sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93465,212 +93502,212 @@
93465 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93466 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
93467 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93468 }
93469 break;
93470 case 250: /* collate ::= */
93471 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
93472 break;
93473 case 252: /* cmd ::= DROP INDEX ifexists fullname */
93474 {sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
93475 break;
93476 case 253: /* cmd ::= VACUUM */
93477 case 254: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==254);
93478 {sqlite3Vacuum(pParse);}
93479 break;
93480 case 255: /* cmd ::= PRAGMA nm dbnm */
93481 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
93482 break;
93483 case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
93484 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
93485 break;
93486 case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
93487 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
93488 break;
93489 case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
93490 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
93491 break;
93492 case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
93493 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
93494 break;
93495 case 270: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
93496 {
93497 Token all;
93498 all.z = yymsp[-3].minor.yy0.z;
93499 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
93500 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
93501 }
93502 break;
93503 case 271: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
93504 {
93505 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328);
93506 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
93507 }
93508 break;
93509 case 272: /* trigger_time ::= BEFORE */
93510 case 275: /* trigger_time ::= */ yytestcase(yyruleno==275);
93511 { yygotominor.yy328 = TK_BEFORE; }
93512 break;
93513 case 273: /* trigger_time ::= AFTER */
93514 { yygotominor.yy328 = TK_AFTER; }
93515 break;
93516 case 274: /* trigger_time ::= INSTEAD OF */
93517 { yygotominor.yy328 = TK_INSTEAD;}
93518 break;
93519 case 276: /* trigger_event ::= DELETE|INSERT */
93520 case 277: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==277);
93521 {yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
93522 break;
93523 case 278: /* trigger_event ::= UPDATE OF inscollist */
93524 {yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
93525 break;
93526 case 281: /* when_clause ::= */
93527 case 303: /* key_opt ::= */ yytestcase(yyruleno==303);
93528 { yygotominor.yy132 = 0; }
93529 break;
93530 case 282: /* when_clause ::= WHEN expr */
93531 case 304: /* key_opt ::= KEY expr */ yytestcase(yyruleno==304);
93532 { yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
93533 break;
93534 case 283: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
93535 {
93536 assert( yymsp[-2].minor.yy473!=0 );
93537 yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473;
93538 yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473;
93539 yygotominor.yy473 = yymsp[-2].minor.yy473;
93540 }
93541 break;
93542 case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */
93543 {
93544 assert( yymsp[-1].minor.yy473!=0 );
93545 yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473;
93546 yygotominor.yy473 = yymsp[-1].minor.yy473;
93547 }
93548 break;
93549 case 286: /* trnm ::= nm DOT nm */
93550 {
93551 yygotominor.yy0 = yymsp[0].minor.yy0;
93552 sqlite3ErrorMsg(pParse,
93553 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
93554 "statements within triggers");
93555 }
93556 break;
93557 case 288: /* tridxby ::= INDEXED BY nm */
93558 {
93559 sqlite3ErrorMsg(pParse,
93560 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
93561 "within triggers");
93562 }
93563 break;
93564 case 289: /* tridxby ::= NOT INDEXED */
93565 {
93566 sqlite3ErrorMsg(pParse,
93567 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
93568 "within triggers");
93569 }
93570 break;
93571 case 290: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
93572 { yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); }
93573 break;
93574 case 291: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
93575 {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy408, yymsp[-1].minor.yy14, 0, yymsp[-7].minor.yy186);}
93576 break;
93577 case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
93578 {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, 0, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);}
93579 break;
93580 case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
93581 {yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
93582 break;
93583 case 294: /* trigger_cmd ::= select */
93584 {yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
93585 break;
93586 case 295: /* expr ::= RAISE LP IGNORE RP */
93587 {
93588 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
93589 if( yygotominor.yy346.pExpr ){
93590 yygotominor.yy346.pExpr->affinity = OE_Ignore;
93591 }
93592 yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
93593 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93594 }
93595 break;
93596 case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */
93597 {
93598 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
93599 if( yygotominor.yy346.pExpr ) {
93600 yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328;
93601 }
93602 yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z;
93603 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93604 }
93605 break;
93606 case 297: /* raisetype ::= ROLLBACK */
93607 {yygotominor.yy328 = OE_Rollback;}
93608 break;
93609 case 299: /* raisetype ::= FAIL */
93610 {yygotominor.yy328 = OE_Fail;}
93611 break;
93612 case 300: /* cmd ::= DROP TRIGGER ifexists fullname */
93613 {
93614 sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
93615 }
93616 break;
93617 case 301: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
93618 {
93619 sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132);
93620 }
93621 break;
93622 case 302: /* cmd ::= DETACH database_kw_opt expr */
93623 {
93624 sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
93625 }
93626 break;
93627 case 307: /* cmd ::= REINDEX */
93628 {sqlite3Reindex(pParse, 0, 0);}
93629 break;
93630 case 308: /* cmd ::= REINDEX nm dbnm */
93631 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
93632 break;
93633 case 309: /* cmd ::= ANALYZE */
93634 {sqlite3Analyze(pParse, 0, 0);}
93635 break;
93636 case 310: /* cmd ::= ANALYZE nm dbnm */
93637 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
93638 break;
93639 case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
93640 {
93641 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
93642 }
93643 break;
93644 case 312: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
93645 {
93646 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
93647 }
93648 break;
93649 case 313: /* add_column_fullname ::= fullname */
93650 {
93651 pParse->db->lookaside.bEnabled = 0;
93652 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
93653 }
93654 break;
93655 case 316: /* cmd ::= create_vtab */
93656 {sqlite3VtabFinishParse(pParse,0);}
93657 break;
93658 case 317: /* cmd ::= create_vtab LP vtabarglist RP */
93659 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
93660 break;
93661 case 318: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
93662 {
93663 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
93664 }
93665 break;
93666 case 321: /* vtabarg ::= */
93667 {sqlite3VtabArgInit(pParse);}
93668 break;
93669 case 323: /* vtabargtoken ::= ANY */
93670 case 324: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==324);
93671 case 325: /* lp ::= LP */ yytestcase(yyruleno==325);
93672 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
93673 break;
93674 default:
93675 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
93676 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -93691,29 +93728,29 @@
93691 /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
93692 /* (54) carglist ::= */ yytestcase(yyruleno==54);
93693 /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
93694 /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
93695 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
93696 /* (89) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==89);
93697 /* (90) conslist ::= conslist tcons */ yytestcase(yyruleno==90);
93698 /* (91) conslist ::= tcons */ yytestcase(yyruleno==91);
93699 /* (92) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==92);
93700 /* (268) plus_opt ::= PLUS */ yytestcase(yyruleno==268);
93701 /* (269) plus_opt ::= */ yytestcase(yyruleno==269);
93702 /* (279) foreach_clause ::= */ yytestcase(yyruleno==279);
93703 /* (280) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==280);
93704 /* (287) tridxby ::= */ yytestcase(yyruleno==287);
93705 /* (305) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==305);
93706 /* (306) database_kw_opt ::= */ yytestcase(yyruleno==306);
93707 /* (314) kwcolumn_opt ::= */ yytestcase(yyruleno==314);
93708 /* (315) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==315);
93709 /* (319) vtabarglist ::= vtabarg */ yytestcase(yyruleno==319);
93710 /* (320) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==320);
93711 /* (322) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==322);
93712 /* (326) anylist ::= */ yytestcase(yyruleno==326);
93713 /* (327) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==327);
93714 /* (328) anylist ::= anylist ANY */ yytestcase(yyruleno==328);
93715 break;
93716 };
93717 yygoto = yyRuleInfo[yyruleno].lhs;
93718 yysize = yyRuleInfo[yyruleno].nrhs;
93719 yypParser->yyidx -= yysize;
@@ -94300,10 +94337,11 @@
94300 return TK_ID;
94301 }
94302 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
94303 return keywordCode((char*)z, n);
94304 }
 
94305
94306 /************** End of keywordhash.h *****************************************/
94307 /************** Continuing where we left off in tokenize.c *******************/
94308
94309
@@ -94363,12 +94401,13 @@
94363 *tokenType = TK_SPACE;
94364 return i;
94365 }
94366 case '-': {
94367 if( z[1]=='-' ){
 
94368 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
94369 *tokenType = TK_SPACE;
94370 return i;
94371 }
94372 *tokenType = TK_MINUS;
94373 return 1;
94374 }
@@ -94395,13 +94434,14 @@
94395 case '/': {
94396 if( z[1]!='*' || z[2]==0 ){
94397 *tokenType = TK_SLASH;
94398 return 1;
94399 }
 
94400 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
94401 if( c ) i++;
94402 *tokenType = TK_SPACE;
94403 return i;
94404 }
94405 case '%': {
94406 *tokenType = TK_REM;
94407 return 1;
@@ -94806,61 +94846,66 @@
94806 ** comments on that procedure for additional information.
94807 */
94808 #define tkSEMI 0
94809 #define tkWS 1
94810 #define tkOTHER 2
 
94811 #define tkEXPLAIN 3
94812 #define tkCREATE 4
94813 #define tkTEMP 5
94814 #define tkTRIGGER 6
94815 #define tkEND 7
 
94816
94817 /*
94818 ** Return TRUE if the given SQL string ends in a semicolon.
94819 **
94820 ** Special handling is require for CREATE TRIGGER statements.
94821 ** Whenever the CREATE TRIGGER keywords are seen, the statement
94822 ** must end with ";END;".
94823 **
94824 ** This implementation uses a state machine with 7 states:
94825 **
94826 ** (0) START At the beginning or end of an SQL statement. This routine
 
 
94827 ** returns 1 if it ends in the START state and 0 if it ends
94828 ** in any other state.
94829 **
94830 ** (1) NORMAL We are in the middle of statement which ends with a single
94831 ** semicolon.
94832 **
94833 ** (2) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
94834 ** a statement.
94835 **
94836 ** (3) CREATE The keyword CREATE has been seen at the beginning of a
94837 ** statement, possibly preceeded by EXPLAIN and/or followed by
94838 ** TEMP or TEMPORARY
94839 **
94840 ** (4) TRIGGER We are in the middle of a trigger definition that must be
94841 ** ended by a semicolon, the keyword END, and another semicolon.
94842 **
94843 ** (5) SEMI We've seen the first semicolon in the ";END;" that occurs at
94844 ** the end of a trigger definition.
94845 **
94846 ** (6) END We've seen the ";END" of the ";END;" that occurs at the end
94847 ** of a trigger difinition.
94848 **
94849 ** Transitions between states above are determined by tokens extracted
94850 ** from the input. The following tokens are significant:
94851 **
94852 ** (0) tkSEMI A semicolon.
94853 ** (1) tkWS Whitespace
94854 ** (2) tkOTHER Any other SQL token.
94855 ** (3) tkEXPLAIN The "explain" keyword.
94856 ** (4) tkCREATE The "create" keyword.
94857 ** (5) tkTEMP The "temp" or "temporary" keyword.
94858 ** (6) tkTRIGGER The "trigger" keyword.
94859 ** (7) tkEND The "end" keyword.
94860 **
94861 ** Whitespace never causes a state transition and is always ignored.
 
94862 **
94863 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
94864 ** to recognize the end of a trigger can be omitted. All we have to do
94865 ** is look for a semicolon that is not part of an string or comment.
94866 */
@@ -94870,30 +94915,32 @@
94870
94871 #ifndef SQLITE_OMIT_TRIGGER
94872 /* A complex statement machine used to detect the end of a CREATE TRIGGER
94873 ** statement. This is the normal case.
94874 */
94875 static const u8 trans[7][8] = {
94876 /* Token: */
94877 /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
94878 /* 0 START: */ { 0, 0, 1, 2, 3, 1, 1, 1, },
94879 /* 1 NORMAL: */ { 0, 1, 1, 1, 1, 1, 1, 1, },
94880 /* 2 EXPLAIN: */ { 0, 2, 2, 1, 3, 1, 1, 1, },
94881 /* 3 CREATE: */ { 0, 3, 1, 1, 1, 3, 4, 1, },
94882 /* 4 TRIGGER: */ { 5, 4, 4, 4, 4, 4, 4, 4, },
94883 /* 5 SEMI: */ { 5, 5, 4, 4, 4, 4, 4, 6, },
94884 /* 6 END: */ { 0, 6, 4, 4, 4, 4, 4, 4, },
 
94885 };
94886 #else
94887 /* If triggers are not suppored by this compile then the statement machine
94888 ** used to detect the end of a statement is much simplier
94889 */
94890 static const u8 trans[2][3] = {
94891 /* Token: */
94892 /* State: ** SEMI WS OTHER */
94893 /* 0 START: */ { 0, 0, 1, },
94894 /* 1 NORMAL: */ { 0, 1, 1, },
 
94895 };
94896 #endif /* SQLITE_OMIT_TRIGGER */
94897
94898 while( *zSql ){
94899 switch( *zSql ){
@@ -94925,11 +94972,11 @@
94925 if( zSql[1]!='-' ){
94926 token = tkOTHER;
94927 break;
94928 }
94929 while( *zSql && *zSql!='\n' ){ zSql++; }
94930 if( *zSql==0 ) return state==0;
94931 token = tkWS;
94932 break;
94933 }
94934 case '[': { /* Microsoft-style identifiers in [...] */
94935 zSql++;
@@ -95009,11 +95056,11 @@
95009 }
95010 }
95011 state = trans[state][token];
95012 zSql++;
95013 }
95014 return state==0;
95015 }
95016
95017 #ifndef SQLITE_OMIT_UTF16
95018 /*
95019 ** This routine is the same as the sqlite3_complete() routine described
@@ -95397,11 +95444,11 @@
95397 switch( op ){
95398
95399 /* Mutex configuration options are only available in a threadsafe
95400 ** compile.
95401 */
95402 #if SQLITE_THREADSAFE
95403 case SQLITE_CONFIG_SINGLETHREAD: {
95404 /* Disable all mutexing */
95405 sqlite3GlobalConfig.bCoreMutex = 0;
95406 sqlite3GlobalConfig.bFullMutex = 0;
95407 break;
@@ -97413,10 +97460,44 @@
97413 sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);
97414 sqlite3_mutex_leave(db->mutex);
97415 break;
97416 }
97417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97418 }
97419 va_end(ap);
97420 #endif /* SQLITE_OMIT_BUILTIN_TEST */
97421 return rc;
97422 }
@@ -98203,10 +98284,14 @@
98203
98204 struct sqlite3_tokenizer_cursor {
98205 sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */
98206 /* Tokenizer implementations will typically add additional fields */
98207 };
 
 
 
 
98208
98209 #endif /* _FTS3_TOKENIZER_H_ */
98210
98211 /************** End of fts3_tokenizer.h **************************************/
98212 /************** Continuing where we left off in fts3Int.h ********************/
@@ -98287,18 +98372,20 @@
98287 */
98288 SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);
98289 SQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);
98290 SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);
98291 SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);
 
98292
98293 /*
98294 ** Shorthand for the functions above
98295 */
98296 #define fts3HashInit sqlite3Fts3HashInit
98297 #define fts3HashInsert sqlite3Fts3HashInsert
98298 #define fts3HashFind sqlite3Fts3HashFind
98299 #define fts3HashClear sqlite3Fts3HashClear
 
98300
98301 /*
98302 ** Macros for looping over all elements of a hash table. The idiom is
98303 ** like this:
98304 **
@@ -98371,10 +98458,12 @@
98371 /*
98372 ** Internal types used by SQLite.
98373 */
98374 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
98375 typedef short int i16; /* 2-byte (or larger) signed integer */
 
 
98376 /*
98377 ** Macro used to suppress compiler warnings for unused parameters.
98378 */
98379 #define UNUSED_PARAMETER(x) (void)(x)
98380 #endif
@@ -98421,14 +98510,15 @@
98421 int nNodeSize; /* Soft limit for node size */
98422
98423 /* The following hash table is used to buffer pending index updates during
98424 ** transactions. Variable nPendingData estimates the memory size of the
98425 ** pending data, including hash table overhead, but not malloc overhead.
98426 ** When nPendingData exceeds FTS3_MAX_PENDING_DATA, the buffer is flushed
98427 ** automatically. Variable iPrevDocid is the docid of the most recently
98428 ** inserted record.
98429 */
 
98430 int nPendingData;
98431 sqlite_int64 iPrevDocid;
98432 Fts3Hash pendingTerms;
98433 };
98434
@@ -98446,10 +98536,12 @@
98446 Fts3Expr *pExpr; /* Parsed MATCH query string */
98447 sqlite3_int64 iPrevId; /* Previous id read from aDoclist */
98448 char *pNextId; /* Pointer into the body of aDoclist */
98449 char *aDoclist; /* List of docids for full-text queries */
98450 int nDoclist; /* Size of buffer at aDoclist */
 
 
98451 };
98452
98453 /*
98454 ** The Fts3Cursor.eSearch member is always set to one of the following.
98455 ** Actualy, Fts3Cursor.eSearch can be greater than or equal to
@@ -98486,18 +98578,35 @@
98486 } aToken[1]; /* One entry for each token in the phrase */
98487 };
98488
98489 /*
98490 ** A tree of these objects forms the RHS of a MATCH operator.
 
 
 
 
 
 
 
 
 
 
98491 */
98492 struct Fts3Expr {
98493 int eType; /* One of the FTSQUERY_XXX values defined below */
98494 int nNear; /* Valid if eType==FTSQUERY_NEAR */
98495 Fts3Expr *pParent; /* pParent->pLeft==this or pParent->pRight==this */
98496 Fts3Expr *pLeft; /* Left operand */
98497 Fts3Expr *pRight; /* Right operand */
98498 Fts3Phrase *pPhrase; /* Valid if eType==FTSQUERY_PHRASE */
 
 
 
 
 
 
 
98499 };
98500
98501 /*
98502 ** Candidate values for Fts3Query.eType. Note that the order of the first
98503 ** four values is in order of precedence when parsing expressions. For
@@ -98526,10 +98635,11 @@
98526 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);
98527 SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);
98528 SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);
98529 SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(Fts3Table *,int, sqlite3_int64,
98530 sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);
 
98531 SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *, Fts3SegReader *);
98532 SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate(
98533 Fts3Table *, Fts3SegReader **, int, Fts3SegFilter *,
98534 int (*)(Fts3Table *, void *, char *, int, char *, int), void *
98535 );
@@ -98555,10 +98665,13 @@
98555 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
98556 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
98557 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
98558 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
98559
 
 
 
98560 /* fts3_tokenizer.c */
98561 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
98562 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
98563 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash,
98564 const char *, sqlite3_tokenizer **, const char **, char **
@@ -98567,18 +98680,22 @@
98567 /* fts3_snippet.c */
98568 SQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);
98569 SQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context*, Fts3Cursor*,
98570 const char *, const char *, const char *
98571 );
 
 
 
 
98572
98573 /* fts3_expr.c */
98574 SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *,
98575 char **, int, int, const char *, int, Fts3Expr **
98576 );
98577 SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
98578 #ifdef SQLITE_TEST
98579 SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
98580 #endif
98581
98582 #endif /* _FTSINT_H */
98583
98584 /************** End of fts3Int.h *********************************************/
@@ -98587,74 +98704,10 @@
98587
98588 #ifndef SQLITE_CORE
98589 SQLITE_EXTENSION_INIT1
98590 #endif
98591
98592
98593
98594 /* TODO(shess) MAN, this thing needs some refactoring. At minimum, it
98595 ** would be nice to order the file better, perhaps something along the
98596 ** lines of:
98597 **
98598 ** - utility functions
98599 ** - table setup functions
98600 ** - table update functions
98601 ** - table query functions
98602 **
98603 ** Put the query functions last because they're likely to reference
98604 ** typedefs or functions from the table update section.
98605 */
98606
98607 #if 0
98608 # define FTSTRACE(A) printf A; fflush(stdout)
98609 #else
98610 # define FTSTRACE(A)
98611 #endif
98612
98613 typedef enum DocListType {
98614 DL_DOCIDS, /* docids only */
98615 DL_POSITIONS, /* docids + positions */
98616 DL_POSITIONS_OFFSETS /* docids + positions + offsets */
98617 } DocListType;
98618
98619 /*
98620 ** By default, only positions and not offsets are stored in the doclists.
98621 ** To change this so that offsets are stored too, compile with
98622 **
98623 ** -DDL_DEFAULT=DL_POSITIONS_OFFSETS
98624 **
98625 ** If DL_DEFAULT is set to DL_DOCIDS, your table can only be inserted
98626 ** into (no deletes or updates).
98627 */
98628 #ifndef DL_DEFAULT
98629 # define DL_DEFAULT DL_POSITIONS
98630 #endif
98631
98632 enum {
98633 POS_END = 0, /* end of this position list */
98634 POS_COLUMN, /* followed by new column number */
98635 POS_BASE
98636 };
98637
98638 /* utility functions */
98639
98640 /* CLEAR() and SCRAMBLE() abstract memset() on a pointer to a single
98641 ** record to prevent errors of the form:
98642 **
98643 ** my_function(SomeType *b){
98644 ** memset(b, '\0', sizeof(b)); // sizeof(b)!=sizeof(*b)
98645 ** }
98646 */
98647 /* TODO(shess) Obvious candidates for a header file. */
98648 #define CLEAR(b) memset(b, '\0', sizeof(*(b)))
98649
98650 #ifndef NDEBUG
98651 # define SCRAMBLE(b) memset(b, 0x55, sizeof(*(b)))
98652 #else
98653 # define SCRAMBLE(b)
98654 #endif
98655
98656 /*
98657 ** Write a 64-bit variable-length integer to memory starting at p[0].
98658 ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
98659 ** The number of bytes written is returned.
98660 */
@@ -98676,17 +98729,13 @@
98676 ** The value is stored in *v.
98677 */
98678 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
98679 const unsigned char *q = (const unsigned char *) p;
98680 sqlite_uint64 x = 0, y = 1;
98681 while( (*q & 0x80) == 0x80 ){
98682 x += y * (*q++ & 0x7f);
98683 y <<= 7;
98684 if( q - (unsigned char *)p >= FTS3_VARINT_MAX ){ /* bad data */
98685 assert( 0 );
98686 return 0;
98687 }
98688 }
98689 x += y * (*q++);
98690 *v = (sqlite_int64) x;
98691 return (int) (q - (unsigned char *)p);
98692 }
@@ -98697,11 +98746,10 @@
98697 */
98698 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
98699 sqlite_int64 i;
98700 int ret = sqlite3Fts3GetVarint(p, &i);
98701 *pi = (int) i;
98702 assert( *pi==i );
98703 return ret;
98704 }
98705
98706 /*
98707 ** Return the number of bytes required to store the value passed as the
@@ -98726,35 +98774,33 @@
98726 **
98727 ** "abc" becomes abc
98728 ** 'xyz' becomes xyz
98729 ** [pqr] becomes pqr
98730 ** `mno` becomes mno
 
98731 */
98732 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){
98733 int quote;
98734 int i, j;
98735
98736 quote = z[0];
98737 switch( quote ){
98738 case '\'': break;
98739 case '"': break;
98740 case '`': break; /* For MySQL compatibility */
98741 case '[': quote = ']'; break; /* For MS SqlServer compatibility */
98742 default: return;
98743 }
98744 for(i=1, j=0; z[i]; i++){
98745 if( z[i]==quote ){
98746 if( z[i+1]==quote ){
98747 z[j++] = (char)quote;
98748 i++;
98749 }else{
98750 z[j++] = 0;
98751 break;
98752 }
98753 }else{
98754 z[j++] = z[i];
98755 }
98756 }
98757 }
98758
98759 static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){
98760 sqlite3_int64 iVal;
@@ -98919,11 +98965,11 @@
98919 ** argv[0] -> module name
98920 ** argv[1] -> database name
98921 ** argv[2] -> table name
98922 ** argv[...] -> "column name" and other module argument fields.
98923 */
98924 int fts3InitVtab(
98925 int isCreate, /* True for xCreate, false for xConnect */
98926 sqlite3 *db, /* The SQLite database connection */
98927 void *pAux, /* Hash table containing tokenizers */
98928 int argc, /* Number of elements in argv array */
98929 const char * const *argv, /* xCreate/xConnect argument array */
@@ -98943,18 +98989,10 @@
98943 int nName;
98944
98945 const char *zTokenizer = 0; /* Name of tokenizer to use */
98946 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
98947
98948 #ifdef SQLITE_TEST
98949 const char *zTestParam = 0;
98950 if( strncmp(argv[argc-1], "test:", 5)==0 ){
98951 zTestParam = argv[argc-1];
98952 argc--;
98953 }
98954 #endif
98955
98956 nDb = (int)strlen(argv[1]) + 1;
98957 nName = (int)strlen(argv[2]) + 1;
98958 for(i=3; i<argc; i++){
98959 char const *z = argv[i];
98960 rc = sqlite3Fts3InitTokenizer(pHash, z, &pTokenizer, &zTokenizer, pzErr);
@@ -98995,10 +99033,11 @@
98995 p->nColumn = nCol;
98996 p->nPendingData = 0;
98997 p->azColumn = (char **)&p[1];
98998 p->pTokenizer = pTokenizer;
98999 p->nNodeSize = 1000;
 
99000 zCsr = (char *)&p->azColumn[nCol];
99001
99002 fts3HashInit(&p->pendingTerms, FTS3_HASH_STRING, 1);
99003
99004 /* Fill in the zName and zDb fields of the vtab structure. */
@@ -99038,15 +99077,10 @@
99038 }
99039
99040 rc = fts3DeclareVtab(p);
99041 if( rc!=SQLITE_OK ) goto fts3_init_out;
99042
99043 #ifdef SQLITE_TEST
99044 if( zTestParam ){
99045 p->nNodeSize = atoi(&zTestParam[5]);
99046 }
99047 #endif
99048 *ppVTab = &p->base;
99049
99050 fts3_init_out:
99051 assert( p || (pTokenizer && rc!=SQLITE_OK) );
99052 if( rc!=SQLITE_OK ){
@@ -99105,35 +99139,35 @@
99105 pInfo->estimatedCost = 500000;
99106 for(i=0; i<pInfo->nConstraint; i++){
99107 struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
99108 if( pCons->usable==0 ) continue;
99109
99110 /* A direct lookup on the rowid or docid column. This is the best
99111 ** strategy in all cases. Assign a cost of 1.0 and return early.
99112 */
99113 if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
99114 && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
99115 ){
99116 pInfo->idxNum = FTS3_DOCID_SEARCH;
99117 pInfo->estimatedCost = 1.0;
99118 iCons = i;
99119 break;
99120 }
99121
99122 /* A MATCH constraint. Use a full-text search.
99123 **
99124 ** If there is more than one MATCH constraint available, use the first
99125 ** one encountered. If there is both a MATCH constraint and a direct
99126 ** rowid/docid lookup, prefer the rowid/docid strategy.
 
 
 
99127 */
99128 if( iCons<0
99129 && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH
99130 && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
99131 ){
99132 pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
99133 pInfo->estimatedCost = 2.0;
99134 iCons = i;
 
99135 }
99136 }
99137
99138 if( iCons>=0 ){
99139 pInfo->aConstraintUsage[iCons].argvIndex = 1;
@@ -99175,25 +99209,33 @@
99175 static int fulltextClose(sqlite3_vtab_cursor *pCursor){
99176 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
99177 sqlite3_finalize(pCsr->pStmt);
99178 sqlite3Fts3ExprFree(pCsr->pExpr);
99179 sqlite3_free(pCsr->aDoclist);
 
99180 sqlite3_free(pCsr);
99181 return SQLITE_OK;
99182 }
99183
99184 static int fts3CursorSeek(Fts3Cursor *pCsr){
99185 if( pCsr->isRequireSeek ){
99186 pCsr->isRequireSeek = 0;
99187 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
99188 if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
99189 return SQLITE_OK;
99190 }else{
99191 int rc;
 
 
 
 
 
 
 
99192 pCsr->isEof = 1;
99193 if( SQLITE_OK==(rc = sqlite3_reset(pCsr->pStmt)) ){
99194 rc = SQLITE_ERROR;
99195 }
99196 return rc;
99197 }
99198 }else{
99199 return SQLITE_OK;
@@ -99213,10 +99255,11 @@
99213 pCsr->isEof = 1;
99214 }else{
99215 sqlite3_reset(pCsr->pStmt);
99216 fts3GetDeltaVarint(&pCsr->pNextId, &pCsr->iPrevId);
99217 pCsr->isRequireSeek = 1;
 
99218 }
99219 return rc;
99220 }
99221
99222
@@ -99328,15 +99371,31 @@
99328 assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );
99329 *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);
99330 *piPrev = iVal;
99331 }
99332
 
 
 
 
99333 static void fts3PoslistCopy(char **pp, char **ppPoslist){
99334 char *pEnd = *ppPoslist;
99335 char c = 0;
 
 
 
 
 
 
 
 
 
 
 
99336 while( *pEnd | c ) c = *pEnd++ & 0x80;
99337 pEnd++;
 
99338 if( pp ){
99339 int n = (int)(pEnd - *ppPoslist);
99340 char *p = *pp;
99341 memcpy(p, *ppPoslist, n);
99342 p += n;
@@ -99539,13 +99598,14 @@
99539 fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
99540 }else{
99541 if( (*p1&0xFE)==0 ) break;
99542 fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
99543 }
 
99544
99545 }
99546 if( pSave && pp ){
99547 p = pSave;
99548 }
99549
99550 fts3ColumnlistCopy(0, &p1);
99551 fts3ColumnlistCopy(0, &p2);
@@ -99680,15 +99740,12 @@
99680 || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
99681 || mergetype==MERGE_NEAR || mergetype==MERGE_POS_NEAR
99682 );
99683
99684 if( !aBuffer ){
99685 return SQLITE_NOMEM;
99686 }
99687 if( n1==0 && n2==0 ){
99688 *pnBuffer = 0;
99689 return SQLITE_OK;
99690 }
99691
99692 /* Read the first docid from each doclist */
99693 fts3GetDeltaVarint2(&p1, pEnd1, &i1);
99694 fts3GetDeltaVarint2(&p2, pEnd2, &i2);
@@ -99770,11 +99827,11 @@
99770 default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); {
99771 char *aTmp = 0;
99772 char **ppPos = 0;
99773 if( mergetype==MERGE_POS_NEAR ){
99774 ppPos = &p;
99775 aTmp = sqlite3_malloc(2*(n1+n2));
99776 if( !aTmp ){
99777 return SQLITE_NOMEM;
99778 }
99779 }
99780
@@ -99890,16 +99947,24 @@
99890 char **ppOut /* OUT: Malloced result buffer */
99891 ){
99892 int i;
99893 TermSelect tsc;
99894 Fts3SegFilter filter; /* Segment term filter configuration */
99895 Fts3SegReader **apSegment = 0; /* Array of segments to read data from */
99896 int nSegment = 0; /* Size of apSegment array */
99897 int nAlloc = 0; /* Allocated size of segment array */
99898 int rc; /* Return code */
99899 sqlite3_stmt *pStmt; /* SQL statement to scan %_segdir table */
99900 int iAge = 0; /* Used to assign ages to segments */
 
 
 
 
 
 
 
 
99901
99902 /* Loop through the entire %_segdir table. For each segment, create a
99903 ** Fts3SegReader to iterate through the subset of the segment leaves
99904 ** that may contain a term that matches zTerm/nTerm. For non-prefix
99905 ** searches, this is always a single leaf. For prefix searches, this
@@ -100013,12 +100078,10 @@
100013 int rc = SQLITE_OK;
100014 int ii;
100015 int iCol = pPhrase->iColumn;
100016 int isTermPos = (pPhrase->nToken>1 || isReqPos);
100017
100018 assert( p->nPendingData==0 );
100019
100020 for(ii=0; ii<pPhrase->nToken; ii++){
100021 struct PhraseToken *pTok = &pPhrase->aToken[ii];
100022 char *z = pTok->z; /* Next token of the phrase */
100023 int n = pTok->n; /* Size of z in bytes */
100024 int isPrefix = pTok->isPrefix;/* True if token is a prefix */
@@ -100046,10 +100109,11 @@
100046 }
100047 fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
100048 sqlite3_free(pOut);
100049 pOut = pList;
100050 }
 
100051 }
100052
100053 if( rc==SQLITE_OK ){
100054 *paOut = pOut;
100055 *pnOut = nOut;
@@ -100065,39 +100129,46 @@
100065 */
100066 static int evalFts3Expr(
100067 Fts3Table *p, /* Virtual table handle */
100068 Fts3Expr *pExpr, /* Parsed fts3 expression */
100069 char **paOut, /* OUT: Pointer to malloc'd result buffer */
100070 int *pnOut /* OUT: Size of buffer at *paOut */
 
100071 ){
100072 int rc = SQLITE_OK; /* Return code */
100073
100074 /* Zero the output parameters. */
100075 *paOut = 0;
100076 *pnOut = 0;
100077
100078 if( pExpr ){
 
 
 
 
100079 if( pExpr->eType==FTSQUERY_PHRASE ){
100080 int isReqPos = (pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR);
100081 rc = fts3PhraseSelect(p, pExpr->pPhrase, isReqPos, paOut, pnOut);
 
 
100082 }else{
100083 char *aLeft;
100084 char *aRight;
100085 int nLeft;
100086 int nRight;
100087
100088 if( SQLITE_OK==(rc = evalFts3Expr(p, pExpr->pRight, &aRight, &nRight))
100089 && SQLITE_OK==(rc = evalFts3Expr(p, pExpr->pLeft, &aLeft, &nLeft))
100090 ){
100091 assert( pExpr->eType==FTSQUERY_NEAR || pExpr->eType==FTSQUERY_OR
100092 || pExpr->eType==FTSQUERY_AND || pExpr->eType==FTSQUERY_NOT
100093 );
100094 switch( pExpr->eType ){
100095 case FTSQUERY_NEAR: {
100096 Fts3Expr *pLeft;
100097 Fts3Expr *pRight;
100098 int mergetype = MERGE_NEAR;
100099 int nParam1;
100100 int nParam2;
100101 char *aBuffer;
100102
100103 if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
@@ -100203,10 +100274,11 @@
100203 assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );
100204
100205 /* In case the cursor has been used before, clear it now. */
100206 sqlite3_finalize(pCsr->pStmt);
100207 sqlite3_free(pCsr->aDoclist);
 
100208 memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
100209
100210 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
100211 ** statement loops through all rows of the %_content table. For a
100212 ** full-text query or docid lookup, the statement retrieves a single
@@ -100229,19 +100301,17 @@
100229 const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);
100230
100231 if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
100232 return SQLITE_NOMEM;
100233 }
100234 rc = sqlite3Fts3PendingTermsFlush(p);
100235 if( rc!=SQLITE_OK ) return rc;
100236
100237 rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
100238 iCol, zQuery, -1, &pCsr->pExpr
100239 );
100240 if( rc!=SQLITE_OK ) return rc;
100241
100242 rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist);
100243 pCsr->pNextId = pCsr->aDoclist;
100244 pCsr->iPrevId = 0;
100245 }
100246
100247 if( rc!=SQLITE_OK ) return rc;
@@ -100286,25 +100356,26 @@
100286 Fts3Table *p = (Fts3Table *)pCursor->pVtab;
100287
100288 /* The column value supplied by SQLite must be in range. */
100289 assert( iCol>=0 && iCol<=p->nColumn+1 );
100290
100291 rc = fts3CursorSeek(pCsr);
100292 if( rc==SQLITE_OK ){
100293 if( iCol==p->nColumn+1 ){
100294 /* This call is a request for the "docid" column. Since "docid" is an
100295 ** alias for "rowid", use the xRowid() method to obtain the value.
100296 */
100297 sqlite3_int64 iRowid;
100298 rc = fts3RowidMethod(pCursor, &iRowid);
100299 sqlite3_result_int64(pContext, iRowid);
100300 }else if( iCol==p->nColumn ){
100301 /* The extra column whose name is the same as the table.
100302 ** Return a blob which is a pointer to the cursor.
100303 */
100304 sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
100305 }else{
 
100306 sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1));
100307 }
100308 }
100309 return rc;
100310 }
@@ -100357,10 +100428,67 @@
100357 */
100358 static int fts3RollbackMethod(sqlite3_vtab *pVtab){
100359 sqlite3Fts3PendingTermsClear((Fts3Table *)pVtab);
100360 return SQLITE_OK;
100361 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100362
100363 /*
100364 ** Helper function used by the implementation of the overloaded snippet(),
100365 ** offsets() and optimize() SQL functions.
100366 **
@@ -100418,12 +100546,56 @@
100418 switch( nVal ){
100419 case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
100420 case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
100421 case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
100422 }
 
 
 
 
 
 
100423
100424 sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100425 }
100426
100427 /*
100428 ** Implementation of the offsets() function for FTS3
100429 */
@@ -100437,11 +100609,13 @@
100437 UNUSED_PARAMETER(nVal);
100438
100439 assert( nVal==1 );
100440 if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return;
100441 assert( pCsr );
100442 sqlite3Fts3Offsets(pContext, pCsr);
 
 
100443 }
100444
100445 /*
100446 ** Implementation of the special optimize() function for FTS3. This
100447 ** function merges all segments in the database to a single segment.
@@ -100479,10 +100653,31 @@
100479 default:
100480 sqlite3_result_error_code(pContext, rc);
100481 break;
100482 }
100483 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100484
100485 /*
100486 ** This routine implements the xFindFunction method for the FTS3
100487 ** virtual table.
100488 */
@@ -100496,12 +100691,14 @@
100496 struct Overloaded {
100497 const char *zName;
100498 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
100499 } aOverload[] = {
100500 { "snippet", fts3SnippetFunc },
 
100501 { "offsets", fts3OffsetsFunc },
100502 { "optimize", fts3OptimizeFunc },
 
100503 };
100504 int i; /* Iterator variable */
100505
100506 UNUSED_PARAMETER(pVtab);
100507 UNUSED_PARAMETER(nArg);
@@ -100602,17 +100799,18 @@
100602 SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
100603 int rc = SQLITE_OK;
100604 Fts3Hash *pHash = 0;
100605 const sqlite3_tokenizer_module *pSimple = 0;
100606 const sqlite3_tokenizer_module *pPorter = 0;
 
 
100607 const sqlite3_tokenizer_module *pIcu = 0;
 
 
100608
100609 sqlite3Fts3SimpleTokenizerModule(&pSimple);
100610 sqlite3Fts3PorterTokenizerModule(&pPorter);
100611 #ifdef SQLITE_ENABLE_ICU
100612 sqlite3Fts3IcuTokenizerModule(&pIcu);
100613 #endif
100614
100615 /* Allocate and initialise the hash-table used to store tokenizers. */
100616 pHash = sqlite3_malloc(sizeof(Fts3Hash));
100617 if( !pHash ){
100618 rc = SQLITE_NOMEM;
@@ -100622,28 +100820,34 @@
100622
100623 /* Load the built-in tokenizers into the hash table */
100624 if( rc==SQLITE_OK ){
100625 if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
100626 || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
 
100627 || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
 
100628 ){
100629 rc = SQLITE_NOMEM;
100630 }
100631 }
100632
100633 #ifdef SQLITE_TEST
100634 sqlite3Fts3ExprInitTestInterface(db);
 
 
100635 #endif
100636
100637 /* Create the virtual table wrapper around the hash-table and overload
100638 ** the two scalar functions. If this is successful, register the
100639 ** module with sqlite.
100640 */
100641 if( SQLITE_OK==rc
100642 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
100643 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
 
100644 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
 
100645 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
100646 ){
100647 return sqlite3_create_module_v2(
100648 db, "fts3", &fts3Module, (void *)pHash, hashDestroy
100649 );
@@ -100850,11 +101054,11 @@
100850
100851 /*
100852 ** Enlarge a memory allocation. If an out-of-memory allocation occurs,
100853 ** then free the old allocation.
100854 */
100855 void *fts3ReallocOrFree(void *pOrig, int nNew){
100856 void *pRet = sqlite3_realloc(pOrig, nNew);
100857 if( !pRet ){
100858 sqlite3_free(pOrig);
100859 }
100860 return pRet;
@@ -101404,10 +101608,11 @@
101404 */
101405 SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *p){
101406 if( p ){
101407 sqlite3Fts3ExprFree(p->pLeft);
101408 sqlite3Fts3ExprFree(p->pRight);
 
101409 sqlite3_free(p);
101410 }
101411 }
101412
101413 /****************************************************************************
@@ -101581,12 +101786,12 @@
101581
101582 /*
101583 ** Register the query expression parser test function fts3_exprtest()
101584 ** with database connection db.
101585 */
101586 SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3* db){
101587 sqlite3_create_function(
101588 db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
101589 );
101590 }
101591
101592 #endif
@@ -101868,26 +102073,36 @@
101868 assert( pH->count==0 );
101869 fts3HashClear(pH);
101870 }
101871 }
101872
101873 /* Attempt to locate an element of the hash table pH with a key
101874 ** that matches pKey,nKey. Return the data for this element if it is
101875 ** found, or NULL if there is no match.
101876 */
101877 SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){
101878 int h; /* A hash on key */
101879 Fts3HashElem *elem; /* The element that matches key */
101880 int (*xHash)(const void*,int); /* The hash function */
101881
101882 if( pH==0 || pH->ht==0 ) return 0;
101883 xHash = ftsHashFunction(pH->keyClass);
101884 assert( xHash!=0 );
101885 h = (*xHash)(pKey,nKey);
101886 assert( (pH->htsize & (pH->htsize-1))==0 );
101887 elem = fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
101888 return elem ? elem->data : 0;
 
 
 
 
 
 
 
 
 
 
 
101889 }
101890
101891 /* Insert an element into the hash table pH. The key is pKey,nKey
101892 ** and the data is "data".
101893 **
@@ -102720,18 +102935,18 @@
102720 const char *z2 = 0;
102721
102722 /* Find the start of the next token. */
102723 z1 = zStr;
102724 while( z2==0 ){
102725 switch( *z1 ){
 
102726 case '\0': return 0; /* No more tokens here */
102727 case '\'':
102728 case '"':
102729 case '`': {
102730 z2 = &z1[1];
102731 while( *z2 && (z2[0]!=*z1 || z2[1]==*z1) ) z2++;
102732 if( *z2 ) z2++;
102733 break;
102734 }
102735 case '[':
102736 z2 = &z1[1];
102737 while( *z2 && z2[0]!=']' ) z2++;
@@ -103065,14 +103280,14 @@
103065 const char *zName
103066 ){
103067 int rc = SQLITE_OK;
103068 void *p = (void *)pHash;
103069 const int any = SQLITE_ANY;
 
 
103070 char *zTest = 0;
103071 char *zTest2 = 0;
103072
103073 #ifdef SQLITE_TEST
103074 void *pdb = (void *)db;
103075 zTest = sqlite3_mprintf("%s_test", zName);
103076 zTest2 = sqlite3_mprintf("%s_internal_test", zName);
103077 if( !zTest || !zTest2 ){
103078 rc = SQLITE_NOMEM;
@@ -103085,14 +103300,17 @@
103085 #ifdef SQLITE_TEST
103086 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))
103087 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))
103088 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))
103089 #endif
103090 );
103091
 
103092 sqlite3_free(zTest);
103093 sqlite3_free(zTest2);
 
 
103094 return rc;
103095 }
103096
103097 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
103098
@@ -103350,11 +103568,11 @@
103350 typedef struct SegmentNode SegmentNode;
103351 typedef struct SegmentWriter SegmentWriter;
103352
103353 /*
103354 ** Data structure used while accumulating terms in the pending-terms hash
103355 ** table. The hash table entry maps from term (a string) to a malloced
103356 ** instance of this structure.
103357 */
103358 struct PendingList {
103359 int nData;
103360 char *aData;
@@ -103372,19 +103590,26 @@
103372 ** terms when querying the full-text index. See functions:
103373 **
103374 ** sqlite3Fts3SegReaderNew()
103375 ** sqlite3Fts3SegReaderFree()
103376 ** sqlite3Fts3SegReaderIterate()
 
 
 
 
 
 
103377 */
103378 struct Fts3SegReader {
103379 int iIdx; /* Index within level */
103380 sqlite3_int64 iStartBlock;
103381 sqlite3_int64 iEndBlock;
103382 sqlite3_stmt *pStmt; /* SQL Statement to access leaf nodes */
103383 char *aNode; /* Pointer to node data (or NULL) */
103384 int nNode; /* Size of buffer at aNode (or 0) */
103385 int nTermAlloc; /* Allocated size of zTerm buffer */
 
103386
103387 /* Variables set by fts3SegReaderNext(). These may be read directly
103388 ** by the caller. They are valid from the time SegmentReaderNew() returns
103389 ** until SegmentReaderNext() returns something other than SQLITE_OK
103390 ** (i.e. SQLITE_DONE).
@@ -103396,10 +103621,12 @@
103396
103397 /* The following variables are used to iterate through the current doclist */
103398 char *pOffsetList;
103399 sqlite3_int64 iDocid;
103400 };
 
 
103401
103402 /*
103403 ** An instance of this structure is used to create a segment b-tree in the
103404 ** database. The internal details of this type are only accessed by the
103405 ** following functions:
@@ -103600,17 +103827,17 @@
103600
103601 if( pzBlock ){
103602 sqlite3_bind_int64(pStmt, 1, iBlock);
103603 rc = sqlite3_step(pStmt);
103604 if( rc!=SQLITE_ROW ){
103605 return SQLITE_CORRUPT;
103606 }
103607
103608 *pnBlock = sqlite3_column_bytes(pStmt, 0);
103609 *pzBlock = (char *)sqlite3_column_blob(pStmt, 0);
103610 if( !*pzBlock ){
103611 return SQLITE_NOMEM;
103612 }
103613 }
103614 return SQLITE_OK;
103615 }
103616
@@ -103821,11 +104048,11 @@
103821 ** forced-flush would provide better performance. I suspect that if
103822 ** we ordered the doclists by size and flushed the largest until the
103823 ** buffer was half empty, that would let the less frequent terms
103824 ** generate longer doclists.
103825 */
103826 if( iDocid<=p->iPrevDocid || p->nPendingData>FTS3_MAX_PENDING_DATA ){
103827 int rc = sqlite3Fts3PendingTermsFlush(p);
103828 if( rc!=SQLITE_OK ) return rc;
103829 }
103830 p->iPrevDocid = iDocid;
103831 return SQLITE_OK;
@@ -104048,10 +104275,25 @@
104048 pNext = &pReader->aDoclist[pReader->nDoclist];
104049 }
104050
104051 if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){
104052 int rc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104053 if( !pReader->pStmt ){
104054 pReader->aNode = 0;
104055 return SQLITE_OK;
104056 }
104057 rc = sqlite3_step(pReader->pStmt);
@@ -104157,11 +104399,13 @@
104157 */
104158 assert( p->nLeavesStmt<p->nLeavesTotal );
104159 sqlite3_reset(pReader->pStmt);
104160 p->aLeavesStmt[p->nLeavesStmt++] = pReader->pStmt;
104161 }
104162 sqlite3_free(pReader->zTerm);
 
 
104163 sqlite3_free(pReader);
104164 }
104165 }
104166
104167 /*
@@ -104254,10 +104498,107 @@
104254 sqlite3Fts3SegReaderFree(p, pReader);
104255 }
104256 return rc;
104257 }
104258
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104259
104260 /*
104261 ** The second argument to this function is expected to be a statement of
104262 ** the form:
104263 **
@@ -104297,11 +104638,11 @@
104297 ** Compare the entries pointed to by two Fts3SegReader structures.
104298 ** Comparison is as follows:
104299 **
104300 ** 1) EOF is greater than not EOF.
104301 **
104302 ** 2) The current terms (if any) are compared with memcmp(). If one
104303 ** term is a prefix of another, the longer term is considered the
104304 ** larger.
104305 **
104306 ** 3) By segment age. An older segment is considered larger.
104307 */
@@ -104425,15 +104766,13 @@
104425 ){
104426 sqlite3_stmt *pStmt;
104427 int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
104428 if( rc==SQLITE_OK ){
104429 sqlite3_bind_int64(pStmt, 1, iBlock);
104430 rc = sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
104431 if( rc==SQLITE_OK ){
104432 sqlite3_step(pStmt);
104433 rc = sqlite3_reset(pStmt);
104434 }
104435 }
104436 return rc;
104437 }
104438
104439 /*
@@ -104455,15 +104794,13 @@
104455 sqlite3_bind_int(pStmt, 1, iLevel);
104456 sqlite3_bind_int(pStmt, 2, iIdx);
104457 sqlite3_bind_int64(pStmt, 3, iStartBlock);
104458 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
104459 sqlite3_bind_int64(pStmt, 5, iEndBlock);
104460 rc = sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
104461 if( rc==SQLITE_OK ){
104462 sqlite3_step(pStmt);
104463 rc = sqlite3_reset(pStmt);
104464 }
104465 }
104466 return rc;
104467 }
104468
104469 /*
@@ -105038,20 +105375,36 @@
105038 /*
105039 ** sqlite3Fts3SegReaderIterate() callback used when merging multiple
105040 ** segments to create a single, larger segment.
105041 */
105042 static int fts3MergeCallback(
105043 Fts3Table *p,
105044 void *pContext,
105045 char *zTerm,
105046 int nTerm,
105047 char *aDoclist,
105048 int nDoclist
105049 ){
105050 SegmentWriter **ppW = (SegmentWriter **)pContext;
105051 return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
105052 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105053
105054 /*
105055 ** This function is used to iterate through a contiguous set of terms
105056 ** stored in the full-text index. It merges data contained in one or
105057 ** more segments to support this.
@@ -105110,12 +105463,11 @@
105110 const char *zTerm = pFilter->zTerm;
105111 for(i=0; i<nSegment; i++){
105112 Fts3SegReader *pSeg = apSegment[i];
105113 while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ){
105114 rc = fts3SegReaderNext(pSeg);
105115 if( rc!=SQLITE_OK ) goto finished;
105116 }
105117 }
105118 }
105119
105120 fts3SegReaderSort(apSegment, nSegment, nSegment, fts3SegReaderCmp);
105121 while( apSegment[0]->aNode ){
@@ -105145,11 +105497,12 @@
105145 && 0==memcmp(zTerm, apSegment[nMerge]->zTerm, nTerm)
105146 ){
105147 nMerge++;
105148 }
105149
105150 if( nMerge==1 && !isIgnoreEmpty && !isColFilter && isRequirePos ){
 
105151 Fts3SegReader *p0 = apSegment[0];
105152 rc = xFunc(p, pContext, zTerm, nTerm, p0->aDoclist, p0->nDoclist);
105153 if( rc!=SQLITE_OK ) goto finished;
105154 }else{
105155 int nDoclist = 0; /* Size of doclist */
@@ -105169,13 +105522,13 @@
105169 int nList;
105170 int nByte;
105171 sqlite3_int64 iDocid = apSegment[0]->iDocid;
105172 fts3SegReaderNextDocid(apSegment[0], &pList, &nList);
105173 j = 1;
105174 while( j<nMerge
105175 && apSegment[j]->pOffsetList
105176 && apSegment[j]->iDocid==iDocid
105177 ){
105178 fts3SegReaderNextDocid(apSegment[j], 0, 0);
105179 j++;
105180 }
105181
@@ -105247,25 +105600,30 @@
105247 static int fts3SegmentMerge(Fts3Table *p, int iLevel){
105248 int i; /* Iterator variable */
105249 int rc; /* Return code */
105250 int iIdx; /* Index of new segment */
105251 int iNewLevel; /* Level to create new segment at */
105252 sqlite3_stmt *pStmt;
105253 SegmentWriter *pWriter = 0;
105254 int nSegment = 0; /* Number of segments being merged */
105255 Fts3SegReader **apSegment = 0; /* Array of Segment iterators */
 
105256 Fts3SegFilter filter; /* Segment term filter condition */
105257
105258 if( iLevel<0 ){
105259 /* This call is to merge all segments in the database to a single
105260 ** segment. The level of the new segment is equal to the the numerically
105261 ** greatest segment level currently present in the database. The index
105262 ** of the new segment is always 0.
105263 */
105264 iIdx = 0;
 
 
105265 rc = fts3SegmentCountMax(p, &nSegment, &iNewLevel);
105266 if( nSegment==1 ){
 
 
105267 return SQLITE_DONE;
105268 }
105269 }else{
105270 /* This call is to merge all segments at level iLevel. Find the next
105271 ** available segment index at level iLevel+1. The call to
@@ -105272,21 +105630,22 @@
105272 ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to
105273 ** a single iLevel+2 segment if necessary.
105274 */
105275 iNewLevel = iLevel+1;
105276 rc = fts3AllocateSegdirIdx(p, iNewLevel, &iIdx);
105277 if( rc!=SQLITE_OK ) return rc;
105278 rc = fts3SegmentCount(p, iLevel, &nSegment);
 
105279 }
105280 if( rc!=SQLITE_OK ) return rc;
105281 assert( nSegment>0 );
105282 assert( iNewLevel>=0 );
105283
105284 /* Allocate space for an array of pointers to segment iterators. */
105285 apSegment = (Fts3SegReader**)sqlite3_malloc(sizeof(Fts3SegReader *)*nSegment);
105286 if( !apSegment ){
105287 return SQLITE_NOMEM;
 
105288 }
105289 memset(apSegment, 0, sizeof(Fts3SegReader *)*nSegment);
105290
105291 /* Allocate a Fts3SegReader structure for each segment being merged. A
105292 ** Fts3SegReader stores the state data required to iterate through all
@@ -105301,10 +105660,14 @@
105301 if( rc!=SQLITE_OK ){
105302 goto finished;
105303 }
105304 }
105305 rc = sqlite3_reset(pStmt);
 
 
 
 
105306 pStmt = 0;
105307 if( rc!=SQLITE_OK ) goto finished;
105308
105309 memset(&filter, 0, sizeof(Fts3SegFilter));
105310 filter.flags = FTS3_SEGMENT_REQUIRE_POS;
@@ -105325,94 +105688,105 @@
105325 for(i=0; i<nSegment; i++){
105326 sqlite3Fts3SegReaderFree(p, apSegment[i]);
105327 }
105328 sqlite3_free(apSegment);
105329 }
 
105330 sqlite3_reset(pStmt);
105331 return rc;
105332 }
105333
105334 /*
105335 ** This is a comparison function used as a qsort() callback when sorting
105336 ** an array of pending terms by term. This occurs as part of flushing
105337 ** the contents of the pending-terms hash table to the database.
105338 */
105339 static int qsortCompare(const void *lhs, const void *rhs){
105340 char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
105341 char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
105342 int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
105343 int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
105344
105345 int n = (n1<n2 ? n1 : n2);
105346 int c = memcmp(z1, z2, n);
105347 if( c==0 ){
105348 c = n1 - n2;
105349 }
105350 return c;
105351 }
105352
105353
105354 /*
105355 ** Flush the contents of pendingTerms to a level 0 segment.
105356 */
105357 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
105358 Fts3HashElem *pElem;
105359 int idx, rc, i;
105360 Fts3HashElem **apElem; /* Array of pointers to hash elements */
105361 int nElem; /* Number of terms in new segment */
105362 SegmentWriter *pWriter = 0; /* Used to write the segment */
 
105363
105364 /* Find the number of terms that will make up the new segment. If there
105365 ** are no terms, return early (do not bother to write an empty segment).
 
105366 */
105367 nElem = fts3HashCount(&p->pendingTerms);
105368 if( nElem==0 ){
105369 assert( p->nPendingData==0 );
105370 return SQLITE_OK;
105371 }
105372
105373 /* Determine the next index at level 0, merging as necessary. */
 
 
 
105374 rc = fts3AllocateSegdirIdx(p, 0, &idx);
105375 if( rc!=SQLITE_OK ){
105376 return rc;
105377 }
105378
105379 apElem = sqlite3_malloc(nElem*sizeof(Fts3HashElem *));
105380 if( !apElem ){
105381 return SQLITE_NOMEM;
105382 }
105383
105384 i = 0;
105385 for(pElem=fts3HashFirst(&p->pendingTerms); pElem; pElem=fts3HashNext(pElem)){
105386 apElem[i++] = pElem;
105387 }
105388 assert( i==nElem );
105389
105390 /* TODO(shess) Should we allow user-defined collation sequences,
105391 ** here? I think we only need that once we support prefix searches.
105392 ** Also, should we be using qsort()?
105393 */
105394 if( nElem>1 ){
105395 qsort(apElem, nElem, sizeof(Fts3HashElem *), qsortCompare);
105396 }
105397
105398
105399 /* Write the segment tree into the database. */
105400 for(i=0; rc==SQLITE_OK && i<nElem; i++){
105401 const char *z = fts3HashKey(apElem[i]);
105402 int n = fts3HashKeysize(apElem[i]);
105403 PendingList *pList = fts3HashData(apElem[i]);
105404 rc = fts3SegWriterAdd(p, &pWriter, 0, z, n, pList->aData, pList->nData+1);
105405 }
 
 
105406 if( rc==SQLITE_OK ){
105407 rc = fts3SegWriterFlush(p, pWriter, 0, idx);
105408 }
105409
105410 /* Free all allocated resources before returning */
105411 fts3SegWriterFree(pWriter);
105412 sqlite3_free(apElem);
105413 sqlite3Fts3PendingTermsClear(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105414 return rc;
105415 }
105416
105417 /*
105418 ** This function does the work for the xUpdate method of FTS3 virtual
@@ -105426,10 +105800,11 @@
105426 ){
105427 Fts3Table *p = (Fts3Table *)pVtab;
105428 int rc = SQLITE_OK; /* Return Code */
105429 int isRemove = 0; /* True for an UPDATE or DELETE */
105430 sqlite3_int64 iRemove = 0; /* Rowid removed by UPDATE or DELETE */
 
105431
105432 /* If this is a DELETE or UPDATE operation, remove the old record. */
105433 if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
105434 int isEmpty;
105435 rc = fts3IsEmpty(p, apVal, &isEmpty);
@@ -105450,10 +105825,12 @@
105450 rc = fts3SqlExec(p, SQL_DELETE_CONTENT, apVal);
105451 }
105452 }
105453 }
105454 }
 
 
105455 }
105456
105457 /* If this is an INSERT or UPDATE operation, insert the new record. */
105458 if( nArg>1 && rc==SQLITE_OK ){
105459 rc = fts3InsertData(p, apVal, pRowid);
@@ -105475,18 +105852,19 @@
105475 */
105476 SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){
105477 int rc;
105478 rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0);
105479 if( rc==SQLITE_OK ){
105480 rc = sqlite3Fts3PendingTermsFlush(p);
105481 if( rc==SQLITE_OK ){
105482 rc = fts3SegmentMerge(p, -1);
105483 }
105484 if( rc==SQLITE_OK ){
105485 rc = sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
 
 
 
105486 }else{
105487 sqlite3_exec(p->db, "ROLLBACK TO fts3 ; RELEASE fts3", 0, 0, 0);
 
105488 }
105489 }
105490 return rc;
105491 }
105492
@@ -106220,10 +106598,620 @@
106220 }else{
106221 sqlite3_result_error_nomem(pCtx);
106222 }
106223 fts3SnippetFree(p);
106224 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106225
106226 #endif
106227
106228 /************** End of fts3_snippet.c ****************************************/
106229 /************** Begin file rtree.c *******************************************/
@@ -109539,11 +110527,11 @@
109539 int nArg; /* Number of arguments */
109540 int enc; /* Optimal text encoding */
109541 void *pContext; /* sqlite3_user_data() context */
109542 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
109543 } scalars[] = {
109544 {"regexp",-1, SQLITE_ANY, 0, icuRegexpFunc},
109545
109546 {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16},
109547 {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16},
109548 {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
109549 {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
109550
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.6.22. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a one translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% are more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -603,88 +603,81 @@
603 #ifdef SQLITE_VERSION_NUMBER
604 # undef SQLITE_VERSION_NUMBER
605 #endif
606
607 /*
608 ** CAPI3REF: Compile-Time Library Version Numbers
609 **
610 ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
611 ** evaluates to a string literal that is the SQLite version in the
612 ** format "X.Y.Z" where X is the major version number (always 3 for
613 ** SQLite3) and Y is the minor version number and Z is the release number.)^
614 ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
615 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
616 ** numbers used in [SQLITE_VERSION].)^
617 ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
618 ** be larger than the release from which it is derived. Either Y will
619 ** be held constant and Z will be incremented or else Y will be incremented
620 ** and Z will be reset to zero.
 
 
 
 
 
 
 
 
 
 
621 **
622 ** Since version 3.6.18, SQLite source code has been stored in the
623 ** <a href="http://www.fossil-scm.org/">Fossil configuration management
624 ** system</a>. ^The SQLITE_SOURCE_ID macro evalutes to
625 ** a string which identifies a particular check-in of SQLite
626 ** within its configuration management system. ^The SQLITE_SOURCE_ID
627 ** string contains the date and time of the check-in (UTC) and an SHA1
628 ** hash of the entire source tree.
629 **
630 ** See also: [sqlite3_libversion()],
631 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
632 ** [sqlite_version()] and [sqlite_source_id()].
 
 
633 */
634 #define SQLITE_VERSION "3.6.22"
635 #define SQLITE_VERSION_NUMBER 3006022
636 #define SQLITE_SOURCE_ID "2010-01-02 19:02:02 51f7ee844057086789dcfcdcba7daf45343cae62"
637
638 /*
639 ** CAPI3REF: Run-Time Library Version Numbers
640 ** KEYWORDS: sqlite3_version
641 **
642 ** These interfaces provide the same information as the [SQLITE_VERSION],
643 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
644 ** but are associated with the library instead of the header file. ^(Cautious
645 ** programmers might include assert() statements in their application to
646 ** verify that values returned by these interfaces match the macros in
647 ** the header, and thus insure that the application is
648 ** compiled with matching library and header files.
649 **
650 ** <blockquote><pre>
651 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
652 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
653 ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
654 ** </pre></blockquote>)^
655 **
656 ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
657 ** macro. ^The sqlite3_libversion() function returns a pointer to the
658 ** to the sqlite3_version[] string constant. The sqlite3_libversion()
659 ** function is provided for use in DLLs since DLL users usually do not have
660 ** direct access to string constants within the DLL. ^The
661 ** sqlite3_libversion_number() function returns an integer equal to
662 ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer
663 ** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
664 ** C preprocessor macro.
665 **
666 ** See also: [sqlite_version()] and [sqlite_source_id()].
 
 
667 */
668 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
669 SQLITE_API const char *sqlite3_libversion(void);
670 SQLITE_API const char *sqlite3_sourceid(void);
671 SQLITE_API int sqlite3_libversion_number(void);
672
673 /*
674 ** CAPI3REF: Test To See If The Library Is Threadsafe
675 **
676 ** ^The sqlite3_threadsafe() function returns zero if and only if
677 ** SQLite was compiled mutexing code omitted due to the
678 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
679 **
680 ** SQLite can be compiled with or without mutexes. When
681 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
682 ** are enabled and SQLite is threadsafe. When the
683 ** [SQLITE_THREADSAFE] macro is 0,
@@ -692,33 +685,33 @@
685 ** to use SQLite concurrently from more than one thread.
686 **
687 ** Enabling mutexes incurs a measurable performance penalty.
688 ** So if speed is of utmost importance, it makes sense to disable
689 ** the mutexes. But for maximum safety, mutexes should be enabled.
690 ** ^The default behavior is for mutexes to be enabled.
691 **
692 ** This interface can be used by an application to make sure that the
693 ** version of SQLite that it is linking against was compiled with
694 ** the desired setting of the [SQLITE_THREADSAFE] macro.
695 **
696 ** This interface only reports on the compile-time mutex setting
697 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
698 ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
699 ** can be fully or partially disabled using a call to [sqlite3_config()]
700 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
701 ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
702 ** sqlite3_threadsafe() function shows only the compile-time setting of
703 ** thread safety, not any run-time changes to that setting made by
704 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
705 ** is unchanged by calls to sqlite3_config().)^
706 **
707 ** See the [threading mode] documentation for additional information.
 
 
708 */
709 SQLITE_API int sqlite3_threadsafe(void);
710
711 /*
712 ** CAPI3REF: Database Connection Handle
713 ** KEYWORDS: {database connection} {database connections}
714 **
715 ** Each open SQLite database is represented by a pointer to an instance of
716 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
717 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -729,21 +722,24 @@
722 ** sqlite3 object.
723 */
724 typedef struct sqlite3 sqlite3;
725
726 /*
727 ** CAPI3REF: 64-Bit Integer Types
728 ** KEYWORDS: sqlite_int64 sqlite_uint64
729 **
730 ** Because there is no cross-platform way to specify 64-bit integer types
731 ** SQLite includes typedefs for 64-bit signed and unsigned integers.
732 **
733 ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
734 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
735 ** compatibility only.
736 **
737 ** ^The sqlite3_int64 and sqlite_int64 types can store integer values
738 ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
739 ** sqlite3_uint64 and sqlite_uint64 types can store integer values
740 ** between 0 and +18446744073709551615 inclusive.
741 */
742 #ifdef SQLITE_INT64_TYPE
743 typedef SQLITE_INT64_TYPE sqlite_int64;
744 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
745 #elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -763,28 +759,32 @@
759 #ifdef SQLITE_OMIT_FLOATING_POINT
760 # define double sqlite3_int64
761 #endif
762
763 /*
764 ** CAPI3REF: Closing A Database Connection
765 **
766 ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
767 ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
768 ** successfullly destroyed and all associated resources are deallocated.
769 **
770 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
771 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
772 ** the [sqlite3] object prior to attempting to close the object. ^If
773 ** sqlite3_close() is called on a [database connection] that still has
774 ** outstanding [prepared statements] or [BLOB handles], then it returns
775 ** SQLITE_BUSY.
776 **
777 ** ^If [sqlite3_close()] is invoked while a transaction is open,
778 ** the transaction is automatically rolled back.
779 **
780 ** The C parameter to [sqlite3_close(C)] must be either a NULL
781 ** pointer or an [sqlite3] object pointer obtained
782 ** from [sqlite3_open()], [sqlite3_open16()], or
783 ** [sqlite3_open_v2()], and not previously closed.
784 ** ^Calling sqlite3_close() with a NULL pointer argument is a
785 ** harmless no-op.
 
786 */
787 SQLITE_API int sqlite3_close(sqlite3 *);
788
789 /*
790 ** The type for a callback function.
@@ -792,52 +792,69 @@
792 ** compatibility and is not documented.
793 */
794 typedef int (*sqlite3_callback)(void*,int,char**, char**);
795
796 /*
797 ** CAPI3REF: One-Step Query Execution Interface
798 **
799 ** The sqlite3_exec() interface is a convenience wrapper around
800 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
801 ** that allows an application to run multiple statements of SQL
802 ** without having to use a lot of C code.
803 **
804 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
805 ** semicolon-separate SQL statements passed into its 2nd argument,
806 ** in the context of the [database connection] passed in as its 1st
807 ** argument. ^If the callback function of the 3rd argument to
808 ** sqlite3_exec() is not NULL, then it is invoked for each result row
809 ** coming out of the evaluated SQL statements. ^The 4th argument to
810 ** to sqlite3_exec() is relayed through to the 1st argument of each
811 ** callback invocation. ^If the callback pointer to sqlite3_exec()
812 ** is NULL, then no callback is ever invoked and result rows are
813 ** ignored.
814 **
815 ** ^If an error occurs while evaluating the SQL statements passed into
816 ** sqlite3_exec(), then execution of the current statement stops and
817 ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
818 ** is not NULL then any error message is written into memory obtained
819 ** from [sqlite3_malloc()] and passed back through the 5th parameter.
820 ** To avoid memory leaks, the application should invoke [sqlite3_free()]
821 ** on error message strings returned through the 5th parameter of
822 ** of sqlite3_exec() after the error message string is no longer needed.
823 ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
824 ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
825 ** NULL before returning.
826 **
827 ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
828 ** routine returns SQLITE_ABORT without invoking the callback again and
829 ** without running any subsequent SQL statements.
830 **
831 ** ^The 2nd argument to the sqlite3_exec() callback function is the
832 ** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
833 ** callback is an array of pointers to strings obtained as if from
834 ** [sqlite3_column_text()], one for each column. ^If an element of a
835 ** result row is NULL then the corresponding string pointer for the
836 ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
837 ** sqlite3_exec() callback is an array of pointers to strings where each
838 ** entry represents the name of corresponding result column as obtained
839 ** from [sqlite3_column_name()].
840 **
841 ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
842 ** to an empty string, or a pointer that contains only whitespace and/or
843 ** SQL comments, then no SQL statements are evaluated and the database
844 ** is not changed.
845 **
846 ** Restrictions:
847 **
848 ** <ul>
849 ** <li> The application must insure that the 1st parameter to sqlite3_exec()
850 ** is a valid and open [database connection].
851 ** <li> The application must not close [database connection] specified by
852 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
853 ** <li> The application must not modify the SQL statement text passed into
854 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
855 ** </ul>
856 */
857 SQLITE_API int sqlite3_exec(
858 sqlite3*, /* An open database */
859 const char *sql, /* SQL to be evaluated */
860 int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -844,11 +861,11 @@
861 void *, /* 1st argument to callback */
862 char **errmsg /* Error msg written here */
863 );
864
865 /*
866 ** CAPI3REF: Result Codes
867 ** KEYWORDS: SQLITE_OK {error code} {error codes}
868 ** KEYWORDS: {result code} {result codes}
869 **
870 ** Many SQLite functions return an integer result code from the set shown
871 ** here in order to indicates success or failure.
@@ -888,11 +905,11 @@
905 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
906 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
907 /* end-of-error-codes */
908
909 /*
910 ** CAPI3REF: Extended Result Codes
911 ** KEYWORDS: {extended error code} {extended error codes}
912 ** KEYWORDS: {extended result code} {extended result codes}
913 **
914 ** In its default configuration, SQLite API routines return one of 26 integer
915 ** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -930,11 +947,11 @@
947 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
948 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
949 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
950
951 /*
952 ** CAPI3REF: Flags For File Open Operations
953 **
954 ** These bit values are intended for use in the
955 ** 3rd parameter to the [sqlite3_open_v2()] interface and
956 ** in the 4th parameter to the xOpen method of the
957 ** [sqlite3_vfs] object.
@@ -955,11 +972,11 @@
972 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
973 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
974 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
975
976 /*
977 ** CAPI3REF: Device Characteristics
978 **
979 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
980 ** object returns an integer which is a vector of the these
981 ** bit values expressing I/O characteristics of the mass storage
982 ** device that holds the file that the [sqlite3_io_methods]
@@ -987,11 +1004,11 @@
1004 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
1005 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
1006 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
1007
1008 /*
1009 ** CAPI3REF: File Locking Levels
1010 **
1011 ** SQLite uses one of these integer values as the second
1012 ** argument to calls it makes to the xLock() and xUnlock() methods
1013 ** of an [sqlite3_io_methods] object.
1014 */
@@ -1000,11 +1017,11 @@
1017 #define SQLITE_LOCK_RESERVED 2
1018 #define SQLITE_LOCK_PENDING 3
1019 #define SQLITE_LOCK_EXCLUSIVE 4
1020
1021 /*
1022 ** CAPI3REF: Synchronization Type Flags
1023 **
1024 ** When SQLite invokes the xSync() method of an
1025 ** [sqlite3_io_methods] object it uses a combination of
1026 ** these integer values as the second argument.
1027 **
@@ -1018,11 +1035,11 @@
1035 #define SQLITE_SYNC_NORMAL 0x00002
1036 #define SQLITE_SYNC_FULL 0x00003
1037 #define SQLITE_SYNC_DATAONLY 0x00010
1038
1039 /*
1040 ** CAPI3REF: OS Interface Open File Handle
1041 **
1042 ** An [sqlite3_file] object represents an open file in the
1043 ** [sqlite3_vfs | OS interface layer]. Individual OS interface
1044 ** implementations will
1045 ** want to subclass this object by appending additional fields
@@ -1034,11 +1051,11 @@
1051 struct sqlite3_file {
1052 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
1053 };
1054
1055 /*
1056 ** CAPI3REF: OS Interface File Virtual Methods Object
1057 **
1058 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
1059 ** [sqlite3_file] object (or, more commonly, a subclass of the
1060 ** [sqlite3_file] object) with a pointer to an instance of this object.
1061 ** This object defines the methods used to perform various operations
@@ -1139,11 +1156,11 @@
1156 int (*xDeviceCharacteristics)(sqlite3_file*);
1157 /* Additional methods may be added in future releases */
1158 };
1159
1160 /*
1161 ** CAPI3REF: Standard File Control Opcodes
1162 **
1163 ** These integer constants are opcodes for the xFileControl method
1164 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
1165 ** interface.
1166 **
@@ -1159,11 +1176,11 @@
1176 #define SQLITE_GET_LOCKPROXYFILE 2
1177 #define SQLITE_SET_LOCKPROXYFILE 3
1178 #define SQLITE_LAST_ERRNO 4
1179
1180 /*
1181 ** CAPI3REF: Mutex Handle
1182 **
1183 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
1184 ** abstract type for a mutex object. The SQLite core never looks
1185 ** at the internal representation of an [sqlite3_mutex]. It only
1186 ** deals with pointers to the [sqlite3_mutex] object.
@@ -1171,11 +1188,11 @@
1188 ** Mutexes are created using [sqlite3_mutex_alloc()].
1189 */
1190 typedef struct sqlite3_mutex sqlite3_mutex;
1191
1192 /*
1193 ** CAPI3REF: OS Interface Object
1194 **
1195 ** An instance of the sqlite3_vfs object defines the interface between
1196 ** the SQLite core and the underlying operating system. The "vfs"
1197 ** in the name of the object stands for "virtual file system".
1198 **
@@ -1325,14 +1342,14 @@
1342 /* New fields may be appended in figure versions. The iVersion
1343 ** value will increment whenever this happens. */
1344 };
1345
1346 /*
1347 ** CAPI3REF: Flags for the xAccess VFS method
1348 **
1349 ** These integer constants can be used as the third parameter to
1350 ** the xAccess method of an [sqlite3_vfs] object. They determine
1351 ** what kind of permissions the xAccess method is looking for.
1352 ** With SQLITE_ACCESS_EXISTS, the xAccess method
1353 ** simply checks whether the file exists.
1354 ** With SQLITE_ACCESS_READWRITE, the xAccess method
1355 ** checks whether the file is both readable and writable.
@@ -1342,52 +1359,52 @@
1359 #define SQLITE_ACCESS_EXISTS 0
1360 #define SQLITE_ACCESS_READWRITE 1
1361 #define SQLITE_ACCESS_READ 2
1362
1363 /*
1364 ** CAPI3REF: Initialize The SQLite Library
1365 **
1366 ** ^The sqlite3_initialize() routine initializes the
1367 ** SQLite library. ^The sqlite3_shutdown() routine
1368 ** deallocates any resources that were allocated by sqlite3_initialize().
1369 ** These routines are designed to aid in process initialization and
1370 ** shutdown on embedded systems. Workstation applications using
1371 ** SQLite normally do not need to invoke either of these routines.
1372 **
1373 ** A call to sqlite3_initialize() is an "effective" call if it is
1374 ** the first time sqlite3_initialize() is invoked during the lifetime of
1375 ** the process, or if it is the first time sqlite3_initialize() is invoked
1376 ** following a call to sqlite3_shutdown(). ^(Only an effective call
1377 ** of sqlite3_initialize() does any initialization. All other calls
1378 ** are harmless no-ops.)^
1379 **
1380 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
1381 ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
1382 ** an effective call to sqlite3_shutdown() does any deinitialization.
1383 ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
1384 **
1385 ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
1386 ** is not. The sqlite3_shutdown() interface must only be called from a
1387 ** single thread. All open [database connections] must be closed and all
1388 ** other SQLite resources must be deallocated prior to invoking
1389 ** sqlite3_shutdown().
1390 **
1391 ** Among other things, ^sqlite3_initialize() will invoke
1392 ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
1393 ** will invoke sqlite3_os_end().
1394 **
1395 ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
1396 ** ^If for some reason, sqlite3_initialize() is unable to initialize
1397 ** the library (perhaps it is unable to allocate a needed resource such
1398 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
1399 **
1400 ** ^The sqlite3_initialize() routine is called internally by many other
1401 ** SQLite interfaces so that an application usually does not need to
1402 ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
1403 ** calls sqlite3_initialize() so the SQLite library will be automatically
1404 ** initialized when [sqlite3_open()] is called if it has not be initialized
1405 ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
1406 ** compile-time option, then the automatic calls to sqlite3_initialize()
1407 ** are omitted and the application must call sqlite3_initialize() directly
1408 ** prior to using any other SQLite interface. For maximum portability,
1409 ** it is recommended that applications always invoke sqlite3_initialize()
1410 ** directly prior to using any other SQLite interface. Future releases
@@ -1422,11 +1439,11 @@
1439 SQLITE_API int sqlite3_shutdown(void);
1440 SQLITE_API int sqlite3_os_init(void);
1441 SQLITE_API int sqlite3_os_end(void);
1442
1443 /*
1444 ** CAPI3REF: Configuring The SQLite Library
1445 ** EXPERIMENTAL
1446 **
1447 ** The sqlite3_config() interface is used to make global configuration
1448 ** changes to SQLite in order to tune SQLite to the specific needs of
1449 ** the application. The default configuration is recommended for most
@@ -1436,39 +1453,36 @@
1453 ** The sqlite3_config() interface is not threadsafe. The application
1454 ** must insure that no other SQLite interfaces are invoked by other
1455 ** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
1456 ** may only be invoked prior to library initialization using
1457 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
1458 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
1459 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
1460 ** Note, however, that ^sqlite3_config() can be called as part of the
1461 ** implementation of an application-defined [sqlite3_os_init()].
1462 **
1463 ** The first argument to sqlite3_config() is an integer
1464 ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
1465 ** what property of SQLite is to be configured. Subsequent arguments
1466 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
1467 ** in the first argument.
1468 **
1469 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1470 ** ^If the option is unknown or SQLite is unable to set the option
1471 ** then this routine returns a non-zero [error code].
 
 
 
 
 
1472 */
1473 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
1474
1475 /*
1476 ** CAPI3REF: Configure database connections
1477 ** EXPERIMENTAL
1478 **
1479 ** The sqlite3_db_config() interface is used to make configuration
1480 ** changes to a [database connection]. The interface is similar to
1481 ** [sqlite3_config()] except that the changes apply to a single
1482 ** [database connection] (specified in the first argument). The
1483 ** sqlite3_db_config() interface should only be used immediately after
1484 ** the database connection is created using [sqlite3_open()],
1485 ** [sqlite3_open16()], or [sqlite3_open_v2()].
1486 **
1487 ** The second argument to sqlite3_db_config(D,V,...) is the
1488 ** configuration verb - an integer code that indicates what
@@ -1475,17 +1489,17 @@
1489 ** aspect of the [database connection] is being configured.
1490 ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
1491 ** New verbs are likely to be added in future releases of SQLite.
1492 ** Additional arguments depend on the verb.
1493 **
1494 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1495 ** the call is considered successful.
1496 */
1497 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
1498
1499 /*
1500 ** CAPI3REF: Memory Allocation Routines
1501 ** EXPERIMENTAL
1502 **
1503 ** An instance of this object defines the interface between SQLite
1504 ** and low-level memory allocation routines.
1505 **
@@ -1511,11 +1525,11 @@
1525 ** The xMalloc and xFree methods must work like the
1526 ** malloc() and free() functions from the standard C library.
1527 ** The xRealloc method must work like realloc() from the standard C library
1528 ** with the exception that if the second argument to xRealloc is zero,
1529 ** xRealloc must be a no-op - it must not perform any allocation or
1530 ** deallocation. ^SQLite guarantees that the second argument to
1531 ** xRealloc is always a value returned by a prior call to xRoundup.
1532 ** And so in cases where xRoundup always returns a positive number,
1533 ** xRealloc can perform exactly as the standard library realloc() and
1534 ** still be in compliance with this specification.
1535 **
@@ -1563,11 +1577,11 @@
1577 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
1578 void *pAppData; /* Argument to xInit() and xShutdown() */
1579 };
1580
1581 /*
1582 ** CAPI3REF: Configuration Options
1583 ** EXPERIMENTAL
1584 **
1585 ** These constants are the available integer configuration options that
1586 ** can be passed as the first argument to the [sqlite3_config()] interface.
1587 **
@@ -1578,151 +1592,181 @@
1592 ** non-zero [error code] if a discontinued or unsupported configuration option
1593 ** is invoked.
1594 **
1595 ** <dl>
1596 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1597 ** <dd>There are no arguments to this option. ^This option sets the
1598 ** [threading mode] to Single-thread. In other words, it disables
1599 ** all mutexing and puts SQLite into a mode where it can only be used
1600 ** by a single thread. ^If SQLite is compiled with
1601 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1602 ** it is not possible to change the [threading mode] from its default
1603 ** value of Single-thread and so [sqlite3_config()] will return
1604 ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
1605 ** configuration option.</dd>
1606 **
1607 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1608 ** <dd>There are no arguments to this option. ^This option sets the
1609 ** [threading mode] to Multi-thread. In other words, it disables
1610 ** mutexing on [database connection] and [prepared statement] objects.
1611 ** The application is responsible for serializing access to
1612 ** [database connections] and [prepared statements]. But other mutexes
1613 ** are enabled so that SQLite will be safe to use in a multi-threaded
1614 ** environment as long as no two threads attempt to use the same
1615 ** [database connection] at the same time. ^If SQLite is compiled with
1616 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1617 ** it is not possible to set the Multi-thread [threading mode] and
1618 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1619 ** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
1620 **
1621 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1622 ** <dd>There are no arguments to this option. ^This option sets the
1623 ** [threading mode] to Serialized. In other words, this option enables
1624 ** all mutexes including the recursive
1625 ** mutexes on [database connection] and [prepared statement] objects.
1626 ** In this mode (which is the default when SQLite is compiled with
1627 ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
1628 ** to [database connections] and [prepared statements] so that the
1629 ** application is free to use the same [database connection] or the
1630 ** same [prepared statement] in different threads at the same time.
1631 ** ^If SQLite is compiled with
1632 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1633 ** it is not possible to set the Serialized [threading mode] and
1634 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1635 ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
1636 **
1637 ** <dt>SQLITE_CONFIG_MALLOC</dt>
1638 ** <dd> ^(This option takes a single argument which is a pointer to an
1639 ** instance of the [sqlite3_mem_methods] structure. The argument specifies
1640 ** alternative low-level memory allocation routines to be used in place of
1641 ** the memory allocation routines built into SQLite.)^ ^SQLite makes
1642 ** its own private copy of the content of the [sqlite3_mem_methods] structure
1643 ** before the [sqlite3_config()] call returns.</dd>
1644 **
1645 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1646 ** <dd> ^(This option takes a single argument which is a pointer to an
1647 ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1648 ** structure is filled with the currently defined memory allocation routines.)^
1649 ** This option can be used to overload the default memory allocation
1650 ** routines with a wrapper that simulations memory allocation failure or
1651 ** tracks memory usage, for example. </dd>
1652 **
1653 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1654 ** <dd> ^This option takes single argument of type int, interpreted as a
1655 ** boolean, which enables or disables the collection of memory allocation
1656 ** statistics. ^(When memory allocation statistics are disabled, the
1657 ** following SQLite interfaces become non-operational:
1658 ** <ul>
1659 ** <li> [sqlite3_memory_used()]
1660 ** <li> [sqlite3_memory_highwater()]
1661 ** <li> [sqlite3_soft_heap_limit()]
1662 ** <li> [sqlite3_status()]
1663 ** </ul>)^
1664 ** ^Memory allocation statistics are enabled by default unless SQLite is
1665 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1666 ** allocation statistics are disabled by default.
1667 ** </dd>
1668 **
1669 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
1670 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1671 ** scratch memory. There are three arguments: A pointer an 8-byte
1672 ** aligned memory buffer from which the scrach allocations will be
1673 ** drawn, the size of each scratch allocation (sz),
1674 ** and the maximum number of scratch allocations (N). The sz
1675 ** argument must be a multiple of 16. The sz parameter should be a few bytes
1676 ** larger than the actual scratch space required due to internal overhead.
1677 ** The first argument must be a pointer to an 8-byte aligned buffer
1678 ** of at least sz*N bytes of memory.
1679 ** ^SQLite will use no more than one scratch buffer per thread. So
1680 ** N should be set to the expected maximum number of threads. ^SQLite will
1681 ** never require a scratch buffer that is more than 6 times the database
1682 ** page size. ^If SQLite needs needs additional scratch memory beyond
1683 ** what is provided by this configuration option, then
1684 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 
1685 **
1686 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1687 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1688 ** the database page cache with the default page cache implemenation.
1689 ** This configuration should not be used if an application-define page
1690 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1691 ** There are three arguments to this option: A pointer to 8-byte aligned
1692 ** memory, the size of each page buffer (sz), and the number of pages (N).
1693 ** The sz argument should be the size of the largest database page
1694 ** (a power of two between 512 and 32768) plus a little extra for each
1695 ** page header. ^The page header size is 20 to 40 bytes depending on
1696 ** the host architecture. ^It is harmless, apart from the wasted memory,
1697 ** to make sz a little too large. The first
1698 ** argument should point to an allocation of at least sz*N bytes of memory.
1699 ** ^SQLite will use the memory provided by the first argument to satisfy its
1700 ** memory needs for the first N pages that it adds to cache. ^If additional
1701 ** page cache memory is needed beyond what is provided by this option, then
1702 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1703 ** ^The implementation might use one or more of the N buffers to hold
1704 ** memory accounting information. The pointer in the first argument must
1705 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1706 ** will be undefined.</dd>
1707 **
1708 ** <dt>SQLITE_CONFIG_HEAP</dt>
1709 ** <dd> ^This option specifies a static memory buffer that SQLite will use
1710 ** for all of its dynamic memory allocation needs beyond those provided
1711 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
1712 ** There are three arguments: An 8-byte aligned pointer to the memory,
1713 ** the number of bytes in the memory buffer, and the minimum allocation size.
1714 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
1715 ** to using its default memory allocator (the system malloc() implementation),
1716 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
1717 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
1718 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1719 ** allocator is engaged to handle all of SQLites memory allocation needs.
1720 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1721 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1722 **
1723 ** <dt>SQLITE_CONFIG_MUTEX</dt>
1724 ** <dd> ^(This option takes a single argument which is a pointer to an
1725 ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
1726 ** alternative low-level mutex routines to be used in place
1727 ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
1728 ** content of the [sqlite3_mutex_methods] structure before the call to
1729 ** [sqlite3_config()] returns. ^If SQLite is compiled with
1730 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1731 ** the entire mutexing subsystem is omitted from the build and hence calls to
1732 ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1733 ** return [SQLITE_ERROR].</dd>
1734 **
1735 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1736 ** <dd> ^(This option takes a single argument which is a pointer to an
1737 ** instance of the [sqlite3_mutex_methods] structure. The
1738 ** [sqlite3_mutex_methods]
1739 ** structure is filled with the currently defined mutex routines.)^
1740 ** This option can be used to overload the default mutex allocation
1741 ** routines with a wrapper used to track mutex usage for performance
1742 ** profiling or testing, for example. ^If SQLite is compiled with
1743 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1744 ** the entire mutexing subsystem is omitted from the build and hence calls to
1745 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1746 ** return [SQLITE_ERROR].</dd>
1747 **
1748 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1749 ** <dd> ^(This option takes two arguments that determine the default
1750 ** memory allocation for the lookaside memory allocator on each
1751 ** [database connection]. The first argument is the
1752 ** size of each lookaside buffer slot and the second is the number of
1753 ** slots allocated to each database connection.)^ ^(This option sets the
1754 ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1755 ** verb to [sqlite3_db_config()] can be used to change the lookaside
1756 ** configuration on individual connections.)^ </dd>
1757 **
1758 ** <dt>SQLITE_CONFIG_PCACHE</dt>
1759 ** <dd> ^(This option takes a single argument which is a pointer to
1760 ** an [sqlite3_pcache_methods] object. This object specifies the interface
1761 ** to a custom page cache implementation.)^ ^SQLite makes a copy of the
1762 ** object and uses it for page cache memory allocations.</dd>
1763 **
1764 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1765 ** <dd> ^(This option takes a single argument which is a pointer to an
1766 ** [sqlite3_pcache_methods] object. SQLite copies of the current
1767 ** page cache implementation into that object.)^ </dd>
1768 **
1769 ** </dl>
1770 */
1771 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1772 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1739,94 +1783,90 @@
1783 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1784 #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
1785 #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
1786
1787 /*
1788 ** CAPI3REF: Configuration Options
1789 ** EXPERIMENTAL
1790 **
1791 ** These constants are the available integer configuration options that
1792 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1793 **
1794 ** New configuration options may be added in future releases of SQLite.
1795 ** Existing configuration options might be discontinued. Applications
1796 ** should check the return code from [sqlite3_db_config()] to make sure that
1797 ** the call worked. ^The [sqlite3_db_config()] interface will return a
1798 ** non-zero [error code] if a discontinued or unsupported configuration option
1799 ** is invoked.
1800 **
1801 ** <dl>
1802 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1803 ** <dd> ^This option takes three additional arguments that determine the
1804 ** [lookaside memory allocator] configuration for the [database connection].
1805 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
1806 ** pointer to an memory buffer to use for lookaside memory.
1807 ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
1808 ** may be NULL in which case SQLite will allocate the
1809 ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
1810 ** size of each lookaside buffer slot. ^The third argument is the number of
1811 ** slots. The size of the buffer in the first argument must be greater than
1812 ** or equal to the product of the second and third arguments. The buffer
1813 ** must be aligned to an 8-byte boundary. ^If the second argument to
1814 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
1815 ** rounded down to the next smaller
1816 ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
1817 **
1818 ** </dl>
1819 */
1820 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1821
1822
1823 /*
1824 ** CAPI3REF: Enable Or Disable Extended Result Codes
1825 **
1826 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1827 ** [extended result codes] feature of SQLite. ^The extended result
1828 ** codes are disabled by default for historical compatibility.
 
 
 
1829 */
1830 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1831
1832 /*
1833 ** CAPI3REF: Last Insert Rowid
1834 **
1835 ** ^Each entry in an SQLite table has a unique 64-bit signed
1836 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1837 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1838 ** names are not also used by explicitly declared columns. ^If
1839 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1840 ** is another alias for the rowid.
1841 **
1842 ** ^This routine returns the [rowid] of the most recent
1843 ** successful [INSERT] into the database from the [database connection]
1844 ** in the first argument. ^If no successful [INSERT]s
1845 ** have ever occurred on that database connection, zero is returned.
1846 **
1847 ** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1848 ** row is returned by this routine as long as the trigger is running.
1849 ** But once the trigger terminates, the value returned by this routine
1850 ** reverts to the last value inserted before the trigger fired.)^
1851 **
1852 ** ^An [INSERT] that fails due to a constraint violation is not a
1853 ** successful [INSERT] and does not change the value returned by this
1854 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1855 ** and INSERT OR ABORT make no changes to the return value of this
1856 ** routine when their insertion fails. ^(When INSERT OR REPLACE
1857 ** encounters a constraint violation, it does not fail. The
1858 ** INSERT continues to completion after deleting rows that caused
1859 ** the constraint problem so INSERT OR REPLACE will always change
1860 ** the return value of this interface.)^
1861 **
1862 ** ^For the purposes of this routine, an [INSERT] is considered to
1863 ** be successful even if it is subsequently rolled back.
1864 **
1865 ** This function is accessible to SQL statements via the
1866 ** [last_insert_rowid() SQL function].
1867 **
 
 
 
1868 ** If a separate thread performs a new [INSERT] on the same
1869 ** database connection while the [sqlite3_last_insert_rowid()]
1870 ** function is running and thus changes the last insert [rowid],
1871 ** then the value returned by [sqlite3_last_insert_rowid()] is
1872 ** unpredictable and might not equal either the old or the new
@@ -1833,164 +1873,154 @@
1873 ** last insert [rowid].
1874 */
1875 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1876
1877 /*
1878 ** CAPI3REF: Count The Number Of Rows Modified
1879 **
1880 ** ^This function returns the number of database rows that were changed
1881 ** or inserted or deleted by the most recently completed SQL statement
1882 ** on the [database connection] specified by the first parameter.
1883 ** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
1884 ** or [DELETE] statement are counted. Auxiliary changes caused by
1885 ** triggers or [foreign key actions] are not counted.)^ Use the
1886 ** [sqlite3_total_changes()] function to find the total number of changes
1887 ** including changes caused by triggers and foreign key actions.
1888 **
1889 ** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
1890 ** are not counted. Only real table changes are counted.
1891 **
1892 ** ^(A "row change" is a change to a single row of a single table
1893 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
1894 ** are changed as side effects of [REPLACE] constraint resolution,
1895 ** rollback, ABORT processing, [DROP TABLE], or by any other
1896 ** mechanisms do not count as direct row changes.)^
1897 **
1898 ** A "trigger context" is a scope of execution that begins and
1899 ** ends with the script of a [CREATE TRIGGER | trigger].
1900 ** Most SQL statements are
1901 ** evaluated outside of any trigger. This is the "top level"
1902 ** trigger context. If a trigger fires from the top level, a
1903 ** new trigger context is entered for the duration of that one
1904 ** trigger. Subtriggers create subcontexts for their duration.
1905 **
1906 ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1907 ** not create a new trigger context.
1908 **
1909 ** ^This function returns the number of direct row changes in the
1910 ** most recent INSERT, UPDATE, or DELETE statement within the same
1911 ** trigger context.
1912 **
1913 ** ^Thus, when called from the top level, this function returns the
1914 ** number of changes in the most recent INSERT, UPDATE, or DELETE
1915 ** that also occurred at the top level. ^(Within the body of a trigger,
1916 ** the sqlite3_changes() interface can be called to find the number of
1917 ** changes in the most recently completed INSERT, UPDATE, or DELETE
1918 ** statement within the body of the same trigger.
1919 ** However, the number returned does not include changes
1920 ** caused by subtriggers since those have their own context.)^
1921 **
1922 ** See also the [sqlite3_total_changes()] interface, the
1923 ** [count_changes pragma], and the [changes() SQL function].
1924 **
 
 
 
1925 ** If a separate thread makes changes on the same database connection
1926 ** while [sqlite3_changes()] is running then the value returned
1927 ** is unpredictable and not meaningful.
1928 */
1929 SQLITE_API int sqlite3_changes(sqlite3*);
1930
1931 /*
1932 ** CAPI3REF: Total Number Of Rows Modified
1933 **
1934 ** ^This function returns the number of row changes caused by [INSERT],
1935 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1936 ** ^(The count returned by sqlite3_total_changes() includes all changes
1937 ** from all [CREATE TRIGGER | trigger] contexts and changes made by
1938 ** [foreign key actions]. However,
1939 ** the count does not include changes used to implement [REPLACE] constraints,
1940 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1941 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1942 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1943 ** are counted.)^
1944 ** ^The sqlite3_total_changes() function counts the changes as soon as
1945 ** the statement that makes them is completed (when the statement handle
1946 ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
1947 **
1948 ** See also the [sqlite3_changes()] interface, the
1949 ** [count_changes pragma], and the [total_changes() SQL function].
1950 **
 
 
 
1951 ** If a separate thread makes changes on the same database connection
1952 ** while [sqlite3_total_changes()] is running then the value
1953 ** returned is unpredictable and not meaningful.
1954 */
1955 SQLITE_API int sqlite3_total_changes(sqlite3*);
1956
1957 /*
1958 ** CAPI3REF: Interrupt A Long-Running Query
1959 **
1960 ** ^This function causes any pending database operation to abort and
1961 ** return at its earliest opportunity. This routine is typically
1962 ** called in response to a user action such as pressing "Cancel"
1963 ** or Ctrl-C where the user wants a long query operation to halt
1964 ** immediately.
1965 **
1966 ** ^It is safe to call this routine from a thread different from the
1967 ** thread that is currently running the database operation. But it
1968 ** is not safe to call this routine with a [database connection] that
1969 ** is closed or might close before sqlite3_interrupt() returns.
1970 **
1971 ** ^If an SQL operation is very nearly finished at the time when
1972 ** sqlite3_interrupt() is called, then it might not have an opportunity
1973 ** to be interrupted and might continue to completion.
1974 **
1975 ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1976 ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1977 ** that is inside an explicit transaction, then the entire transaction
1978 ** will be rolled back automatically.
1979 **
1980 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
1981 ** SQL statements on [database connection] D complete. ^Any new SQL statements
1982 ** that are started after the sqlite3_interrupt() call and before the
1983 ** running statements reaches zero are interrupted as if they had been
1984 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
1985 ** that are started after the running statement count reaches zero are
1986 ** not effected by the sqlite3_interrupt().
1987 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
1988 ** SQL statements is a no-op and has no effect on SQL statements
1989 ** that are started after the sqlite3_interrupt() call returns.
1990 **
 
 
 
1991 ** If the database connection closes while [sqlite3_interrupt()]
1992 ** is running then bad things will likely happen.
1993 */
1994 SQLITE_API void sqlite3_interrupt(sqlite3*);
1995
1996 /*
1997 ** CAPI3REF: Determine If An SQL Statement Is Complete
1998 **
1999 ** These routines are useful during command-line input to determine if the
2000 ** currently entered text seems to form a complete SQL statement or
2001 ** if additional input is needed before sending the text into
2002 ** SQLite for parsing. ^These routines return 1 if the input string
2003 ** appears to be a complete SQL statement. ^A statement is judged to be
2004 ** complete if it ends with a semicolon token and is not a prefix of a
2005 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
2006 ** string literals or quoted identifier names or comments are not
2007 ** independent tokens (they are part of the token in which they are
2008 ** embedded) and thus do not count as a statement terminator. ^Whitespace
2009 ** and comments that follow the final semicolon are ignored.
2010 **
2011 ** ^These routines return 0 if the statement is incomplete. ^If a
2012 ** memory allocation fails, then SQLITE_NOMEM is returned.
2013 **
2014 ** ^These routines do not parse the SQL statements thus
2015 ** will not detect syntactically incorrect SQL.
2016 **
2017 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
2018 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
2019 ** automatically by sqlite3_complete16(). If that initialization fails,
2020 ** then the return value from sqlite3_complete16() will be non-zero
2021 ** regardless of whether or not the input SQL is complete.)^
 
 
2022 **
2023 ** The input to [sqlite3_complete()] must be a zero-terminated
2024 ** UTF-8 string.
2025 **
2026 ** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1998,31 +2028,31 @@
2028 */
2029 SQLITE_API int sqlite3_complete(const char *sql);
2030 SQLITE_API int sqlite3_complete16(const void *sql);
2031
2032 /*
2033 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2034 **
2035 ** ^This routine sets a callback function that might be invoked whenever
2036 ** an attempt is made to open a database table that another thread
2037 ** or process has locked.
2038 **
2039 ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
2040 ** is returned immediately upon encountering the lock. ^If the busy callback
2041 ** is not NULL, then the callback might be invoked with two arguments.
2042 **
2043 ** ^The first argument to the busy handler is a copy of the void* pointer which
2044 ** is the third argument to sqlite3_busy_handler(). ^The second argument to
2045 ** the busy handler callback is the number of times that the busy handler has
2046 ** been invoked for this locking event. ^If the
2047 ** busy callback returns 0, then no additional attempts are made to
2048 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
2049 ** ^If the callback returns non-zero, then another attempt
2050 ** is made to open the database for reading and the cycle repeats.
2051 **
2052 ** The presence of a busy handler does not guarantee that it will be invoked
2053 ** when there is lock contention. ^If SQLite determines that invoking the busy
2054 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
2055 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
2056 ** Consider a scenario where one process is holding a read lock that
2057 ** it is trying to promote to a reserved lock and
2058 ** a second process is holding a reserved lock that it is trying
@@ -2032,69 +2062,63 @@
2062 ** invoke the busy handlers, neither will make any progress. Therefore,
2063 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
2064 ** will induce the first process to release its read lock and allow
2065 ** the second process to proceed.
2066 **
2067 ** ^The default busy callback is NULL.
2068 **
2069 ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
2070 ** when SQLite is in the middle of a large transaction where all the
2071 ** changes will not fit into the in-memory cache. SQLite will
2072 ** already hold a RESERVED lock on the database file, but it needs
2073 ** to promote this lock to EXCLUSIVE so that it can spill cache
2074 ** pages into the database file without harm to concurrent
2075 ** readers. ^If it is unable to promote the lock, then the in-memory
2076 ** cache will be left in an inconsistent state and so the error
2077 ** code is promoted from the relatively benign [SQLITE_BUSY] to
2078 ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion
2079 ** forces an automatic rollback of the changes. See the
2080 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
2081 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
2082 ** this is important.
2083 **
2084 ** ^(There can only be a single busy handler defined for each
2085 ** [database connection]. Setting a new busy handler clears any
2086 ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()]
2087 ** will also set or clear the busy handler.
2088 **
2089 ** The busy callback should not take any actions which modify the
2090 ** database connection that invoked the busy handler. Any such actions
2091 ** result in undefined behavior.
2092 **
 
 
 
2093 ** A busy handler must not close the database connection
2094 ** or [prepared statement] that invoked the busy handler.
2095 */
2096 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2097
2098 /*
2099 ** CAPI3REF: Set A Busy Timeout
2100 **
2101 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2102 ** for a specified amount of time when a table is locked. ^The handler
2103 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2104 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
2105 ** the handler returns 0 which causes [sqlite3_step()] to return
2106 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
2107 **
2108 ** ^Calling this routine with an argument less than or equal to zero
2109 ** turns off all busy handlers.
2110 **
2111 ** ^(There can only be a single busy handler for a particular
2112 ** [database connection] any any given moment. If another busy handler
2113 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2114 ** this routine, that other busy handler is cleared.)^
 
 
 
2115 */
2116 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2117
2118 /*
2119 ** CAPI3REF: Convenience Routines For Running Queries
2120 **
2121 ** Definition: A <b>result table</b> is memory data structure created by the
2122 ** [sqlite3_get_table()] interface. A result table records the
2123 ** complete query results from one or more queries.
2124 **
@@ -2138,31 +2162,29 @@
2162 ** azResult&#91;5] = "28";
2163 ** azResult&#91;6] = "Cindy";
2164 ** azResult&#91;7] = "21";
2165 ** </pre></blockquote>
2166 **
2167 ** ^The sqlite3_get_table() function evaluates one or more
2168 ** semicolon-separated SQL statements in the zero-terminated UTF-8
2169 ** string of its 2nd parameter and returns a result table to the
2170 ** pointer given in its 3rd parameter.
2171 **
2172 ** After the application has finished with the result from sqlite3_get_table(),
2173 ** it should pass the result table pointer to sqlite3_free_table() in order to
2174 ** release the memory that was malloced. Because of the way the
2175 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
2176 ** function must not try to call [sqlite3_free()] directly. Only
2177 ** [sqlite3_free_table()] is able to release the memory properly and safely.
2178 **
2179 ** ^(The sqlite3_get_table() interface is implemented as a wrapper around
2180 ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
2181 ** to any internal data structures of SQLite. It uses only the public
2182 ** interface defined here. As a consequence, errors that occur in the
2183 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2184 ** reflected in subsequent calls to [sqlite3_errcode()] or
2185 ** [sqlite3_errmsg()].)^
 
 
2186 */
2187 SQLITE_API int sqlite3_get_table(
2188 sqlite3 *db, /* An open database */
2189 const char *zSql, /* SQL to be evaluated */
2190 char ***pazResult, /* Results of the query */
@@ -2171,49 +2193,49 @@
2193 char **pzErrmsg /* Error msg written here */
2194 );
2195 SQLITE_API void sqlite3_free_table(char **result);
2196
2197 /*
2198 ** CAPI3REF: Formatted String Printing Functions
2199 **
2200 ** These routines are work-alikes of the "printf()" family of functions
2201 ** from the standard C library.
2202 **
2203 ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
2204 ** results into memory obtained from [sqlite3_malloc()].
2205 ** The strings returned by these two routines should be
2206 ** released by [sqlite3_free()]. ^Both routines return a
2207 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
2208 ** memory to hold the resulting string.
2209 **
2210 ** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
2211 ** the standard C library. The result is written into the
2212 ** buffer supplied as the second parameter whose size is given by
2213 ** the first parameter. Note that the order of the
2214 ** first two parameters is reversed from snprintf().)^ This is an
2215 ** historical accident that cannot be fixed without breaking
2216 ** backwards compatibility. ^(Note also that sqlite3_snprintf()
2217 ** returns a pointer to its buffer instead of the number of
2218 ** characters actually written into the buffer.)^ We admit that
2219 ** the number of characters written would be a more useful return
2220 ** value but we cannot change the implementation of sqlite3_snprintf()
2221 ** now without breaking compatibility.
2222 **
2223 ** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
2224 ** guarantees that the buffer is always zero-terminated. ^The first
2225 ** parameter "n" is the total size of the buffer, including space for
2226 ** the zero terminator. So the longest string that can be completely
2227 ** written will be n-1 characters.
2228 **
2229 ** These routines all implement some additional formatting
2230 ** options that are useful for constructing SQL statements.
2231 ** All of the usual printf() formatting options apply. In addition, there
2232 ** is are "%q", "%Q", and "%z" options.
2233 **
2234 ** ^(The %q option works like %s in that it substitutes a null-terminated
2235 ** string from the argument list. But %q also doubles every '\'' character.
2236 ** %q is designed for use inside a string literal.)^ By doubling each '\''
2237 ** character it escapes that character and allows it to be inserted into
2238 ** the string.
2239 **
2240 ** For example, assume the string variable zText contains text as follows:
2241 **
@@ -2244,14 +2266,14 @@
2266 ** </pre></blockquote>
2267 **
2268 ** This second example is an SQL syntax error. As a general rule you should
2269 ** always use %q instead of %s when inserting text into a string literal.
2270 **
2271 ** ^(The %Q option works like %q except it also adds single quotes around
2272 ** the outside of the total string. Additionally, if the parameter in the
2273 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
2274 ** single quotes).)^ So, for example, one could say:
2275 **
2276 ** <blockquote><pre>
2277 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
2278 ** sqlite3_exec(db, zSQL, 0, 0, 0);
2279 ** sqlite3_free(zSQL);
@@ -2258,75 +2280,63 @@
2280 ** </pre></blockquote>
2281 **
2282 ** The code above will render a correct SQL statement in the zSQL
2283 ** variable even if the zText variable is a NULL pointer.
2284 **
2285 ** ^(The "%z" formatting option works like "%s" but with the
2286 ** addition that after the string has been read and copied into
2287 ** the result, [sqlite3_free()] is called on the input string.)^
 
 
 
2288 */
2289 SQLITE_API char *sqlite3_mprintf(const char*,...);
2290 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2291 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2292
2293 /*
2294 ** CAPI3REF: Memory Allocation Subsystem
2295 **
2296 ** The SQLite core uses these three routines for all of its own
2297 ** internal memory allocation needs. "Core" in the previous sentence
2298 ** does not include operating-system specific VFS implementation. The
2299 ** Windows VFS uses native malloc() and free() for some operations.
2300 **
2301 ** ^The sqlite3_malloc() routine returns a pointer to a block
2302 ** of memory at least N bytes in length, where N is the parameter.
2303 ** ^If sqlite3_malloc() is unable to obtain sufficient free
2304 ** memory, it returns a NULL pointer. ^If the parameter N to
2305 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
2306 ** a NULL pointer.
2307 **
2308 ** ^Calling sqlite3_free() with a pointer previously returned
2309 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
2310 ** that it might be reused. ^The sqlite3_free() routine is
2311 ** a no-op if is called with a NULL pointer. Passing a NULL pointer
2312 ** to sqlite3_free() is harmless. After being freed, memory
2313 ** should neither be read nor written. Even reading previously freed
2314 ** memory might result in a segmentation fault or other severe error.
2315 ** Memory corruption, a segmentation fault, or other severe error
2316 ** might result if sqlite3_free() is called with a non-NULL pointer that
2317 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
2318 **
2319 ** ^(The sqlite3_realloc() interface attempts to resize a
2320 ** prior memory allocation to be at least N bytes, where N is the
2321 ** second parameter. The memory allocation to be resized is the first
2322 ** parameter.)^ ^ If the first parameter to sqlite3_realloc()
2323 ** is a NULL pointer then its behavior is identical to calling
2324 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
2325 ** ^If the second parameter to sqlite3_realloc() is zero or
2326 ** negative then the behavior is exactly the same as calling
2327 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
2328 ** ^sqlite3_realloc() returns a pointer to a memory allocation
2329 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
2330 ** ^If M is the size of the prior allocation, then min(N,M) bytes
2331 ** of the prior allocation are copied into the beginning of buffer returned
2332 ** by sqlite3_realloc() and the prior allocation is freed.
2333 ** ^If sqlite3_realloc() returns NULL, then the prior allocation
2334 ** is not freed.
2335 **
2336 ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
2337 ** is always aligned to at least an 8 byte boundary.
 
 
 
 
 
 
 
 
 
2338 **
2339 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
2340 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
2341 ** implementation of these routines to be omitted. That capability
2342 ** is no longer provided. Only built-in memory allocators can be used.
@@ -2337,14 +2347,10 @@
2347 ** and whatever filename encoding is used by the particular Windows
2348 ** installation. Memory allocation errors are detected, but
2349 ** they are reported back as [SQLITE_CANTOPEN] or
2350 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
2351 **
 
 
 
 
2352 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
2353 ** must be either NULL or else pointers obtained from a prior
2354 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
2355 ** not yet been released.
2356 **
@@ -2355,85 +2361,95 @@
2361 SQLITE_API void *sqlite3_malloc(int);
2362 SQLITE_API void *sqlite3_realloc(void*, int);
2363 SQLITE_API void sqlite3_free(void*);
2364
2365 /*
2366 ** CAPI3REF: Memory Allocator Statistics
2367 **
2368 ** SQLite provides these two interfaces for reporting on the status
2369 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
2370 ** routines, which form the built-in memory allocation subsystem.
2371 **
2372 ** ^The [sqlite3_memory_used()] routine returns the number of bytes
2373 ** of memory currently outstanding (malloced but not freed).
2374 ** ^The [sqlite3_memory_highwater()] routine returns the maximum
2375 ** value of [sqlite3_memory_used()] since the high-water mark
2376 ** was last reset. ^The values returned by [sqlite3_memory_used()] and
2377 ** [sqlite3_memory_highwater()] include any overhead
2378 ** added by SQLite in its implementation of [sqlite3_malloc()],
2379 ** but not overhead added by the any underlying system library
2380 ** routines that [sqlite3_malloc()] may call.
2381 **
2382 ** ^The memory high-water mark is reset to the current value of
2383 ** [sqlite3_memory_used()] if and only if the parameter to
2384 ** [sqlite3_memory_highwater()] is true. ^The value returned
2385 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2386 ** prior to the reset.
2387 */
2388 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2389 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2390
2391 /*
2392 ** CAPI3REF: Pseudo-Random Number Generator
2393 **
2394 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
2395 ** select random [ROWID | ROWIDs] when inserting new records into a table that
2396 ** already uses the largest possible [ROWID]. The PRNG is also used for
2397 ** the build-in random() and randomblob() SQL functions. This interface allows
2398 ** applications to access the same PRNG for other purposes.
2399 **
2400 ** ^A call to this routine stores N bytes of randomness into buffer P.
2401 **
2402 ** ^The first time this routine is invoked (either internally or by
2403 ** the application) the PRNG is seeded using randomness obtained
2404 ** from the xRandomness method of the default [sqlite3_vfs] object.
2405 ** ^On all subsequent invocations, the pseudo-randomness is generated
2406 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2407 ** method.
 
 
 
2408 */
2409 SQLITE_API void sqlite3_randomness(int N, void *P);
2410
2411 /*
2412 ** CAPI3REF: Compile-Time Authorization Callbacks
2413 **
2414 ** ^This routine registers a authorizer callback with a particular
2415 ** [database connection], supplied in the first argument.
2416 ** ^The authorizer callback is invoked as SQL statements are being compiled
2417 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
2418 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
2419 ** points during the compilation process, as logic is being created
2420 ** to perform various actions, the authorizer callback is invoked to
2421 ** see if those actions are allowed. ^The authorizer callback should
2422 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
2423 ** specific action but allow the SQL statement to continue to be
2424 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
2425 ** rejected with an error. ^If the authorizer callback returns
2426 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
2427 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
2428 ** the authorizer will fail with an error message.
2429 **
2430 ** When the callback returns [SQLITE_OK], that means the operation
2431 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
2432 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
2433 ** authorizer will fail with an error message explaining that
2434 ** access is denied.
2435 **
2436 ** ^The first parameter to the authorizer callback is a copy of the third
2437 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
2438 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
2439 ** the particular action to be authorized. ^The third through sixth parameters
2440 ** to the callback are zero-terminated strings that contain additional
2441 ** details about the action to be authorized.
2442 **
2443 ** ^If the action code is [SQLITE_READ]
2444 ** and the callback returns [SQLITE_IGNORE] then the
2445 ** [prepared statement] statement is constructed to substitute
2446 ** a NULL value in place of the table column that would have
2447 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
2448 ** return can be used to deny an untrusted user access to individual
2449 ** columns of a table.
2450 ** ^If the action code is [SQLITE_DELETE] and the callback returns
2451 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
2452 ** [truncate optimization] is disabled and all rows are deleted individually.
2453 **
2454 ** An authorizer is used when [sqlite3_prepare | preparing]
2455 ** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -2449,43 +2465,39 @@
2465 ** Applications that need to process SQL from untrusted sources
2466 ** might also consider lowering resource limits using [sqlite3_limit()]
2467 ** and limiting database size using the [max_page_count] [PRAGMA]
2468 ** in addition to using an authorizer.
2469 **
2470 ** ^(Only a single authorizer can be in place on a database connection
2471 ** at a time. Each call to sqlite3_set_authorizer overrides the
2472 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
2473 ** The authorizer is disabled by default.
2474 **
2475 ** The authorizer callback must not do anything that will modify
2476 ** the database connection that invoked the authorizer callback.
2477 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2478 ** database connections for the meaning of "modify" in this paragraph.
2479 **
2480 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
2481 ** statement might be re-prepared during [sqlite3_step()] due to a
2482 ** schema change. Hence, the application should ensure that the
2483 ** correct authorizer callback remains in place during the [sqlite3_step()].
2484 **
2485 ** ^Note that the authorizer callback is invoked only during
2486 ** [sqlite3_prepare()] or its variants. Authorization is not
2487 ** performed during statement evaluation in [sqlite3_step()], unless
2488 ** as stated in the previous paragraph, sqlite3_step() invokes
2489 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
 
 
 
 
2490 */
2491 SQLITE_API int sqlite3_set_authorizer(
2492 sqlite3*,
2493 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2494 void *pUserData
2495 );
2496
2497 /*
2498 ** CAPI3REF: Authorizer Return Codes
2499 **
2500 ** The [sqlite3_set_authorizer | authorizer callback function] must
2501 ** return either [SQLITE_OK] or one of these two constants in order
2502 ** to signal SQLite whether or not the action is permitted. See the
2503 ** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -2493,11 +2505,11 @@
2505 */
2506 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
2507 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
2508
2509 /*
2510 ** CAPI3REF: Authorizer Action Codes
2511 **
2512 ** The [sqlite3_set_authorizer()] interface registers a callback function
2513 ** that is invoked to authorize certain SQL statement actions. The
2514 ** second parameter to the callback is an integer code that specifies
2515 ** what action is being authorized. These are the integer action codes that
@@ -2504,19 +2516,16 @@
2516 ** the authorizer callback may be passed.
2517 **
2518 ** These action code values signify what kind of operation is to be
2519 ** authorized. The 3rd and 4th parameters to the authorization
2520 ** callback function will be parameters or NULL depending on which of these
2521 ** codes is used as the second parameter. ^(The 5th parameter to the
2522 ** authorizer callback is the name of the database ("main", "temp",
2523 ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback
2524 ** is the name of the inner-most trigger or view that is responsible for
2525 ** the access attempt or NULL if this access attempt is directly from
2526 ** top-level SQL code.
 
 
 
2527 */
2528 /******************************************* 3rd ************ 4th ***********/
2529 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
2530 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
2531 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2550,150 +2559,142 @@
2559 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2560 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2561 #define SQLITE_COPY 0 /* No longer used */
2562
2563 /*
2564 ** CAPI3REF: Tracing And Profiling Functions
2565 ** EXPERIMENTAL
2566 **
2567 ** These routines register callback functions that can be used for
2568 ** tracing and profiling the execution of SQL statements.
2569 **
2570 ** ^The callback function registered by sqlite3_trace() is invoked at
2571 ** various times when an SQL statement is being run by [sqlite3_step()].
2572 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2573 ** SQL statement text as the statement first begins executing.
2574 ** ^(Additional sqlite3_trace() callbacks might occur
2575 ** as each triggered subprogram is entered. The callbacks for triggers
2576 ** contain a UTF-8 SQL comment that identifies the trigger.)^
2577 **
2578 ** ^The callback function registered by sqlite3_profile() is invoked
2579 ** as each SQL statement finishes. ^The profile callback contains
2580 ** the original statement text and an estimate of wall-clock time
2581 ** of how long that statement took to run.
 
 
 
 
2582 */
2583 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2584 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2585 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2586
2587 /*
2588 ** CAPI3REF: Query Progress Callbacks
2589 **
2590 ** ^This routine configures a callback function - the
2591 ** progress callback - that is invoked periodically during long
2592 ** running calls to [sqlite3_exec()], [sqlite3_step()] and
2593 ** [sqlite3_get_table()]. An example use for this
2594 ** interface is to keep a GUI updated during a large query.
2595 **
2596 ** ^If the progress callback returns non-zero, the operation is
2597 ** interrupted. This feature can be used to implement a
2598 ** "Cancel" button on a GUI progress dialog box.
2599 **
2600 ** The progress handler must not do anything that will modify
2601 ** the database connection that invoked the progress handler.
2602 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2603 ** database connections for the meaning of "modify" in this paragraph.
2604 **
 
 
 
2605 */
2606 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2607
2608 /*
2609 ** CAPI3REF: Opening A New Database Connection
2610 **
2611 ** ^These routines open an SQLite database file whose name is given by the
2612 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2613 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2614 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
2615 ** returned in *ppDb, even if an error occurs. The only exception is that
2616 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
2617 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2618 ** object.)^ ^(If the database is opened (and/or created) successfully, then
2619 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
2620 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2621 ** an English language description of the error following a failure of any
2622 ** of the sqlite3_open() routines.
2623 **
2624 ** ^The default encoding for the database will be UTF-8 if
2625 ** sqlite3_open() or sqlite3_open_v2() is called and
2626 ** UTF-16 in the native byte order if sqlite3_open16() is used.
2627 **
2628 ** Whether or not an error occurs when it is opened, resources
2629 ** associated with the [database connection] handle should be released by
2630 ** passing it to [sqlite3_close()] when it is no longer required.
2631 **
2632 ** The sqlite3_open_v2() interface works like sqlite3_open()
2633 ** except that it accepts two additional parameters for additional control
2634 ** over the new database connection. ^(The flags parameter to
2635 ** sqlite3_open_v2() can take one of
2636 ** the following three values, optionally combined with the
2637 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2638 ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
2639 **
2640 ** <dl>
2641 ** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
2642 ** <dd>The database is opened in read-only mode. If the database does not
2643 ** already exist, an error is returned.</dd>)^
2644 **
2645 ** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
2646 ** <dd>The database is opened for reading and writing if possible, or reading
2647 ** only if the file is write protected by the operating system. In either
2648 ** case the database must already exist, otherwise an error is returned.</dd>)^
2649 **
2650 ** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2651 ** <dd>The database is opened for reading and writing, and is creates it if
2652 ** it does not already exist. This is the behavior that is always used for
2653 ** sqlite3_open() and sqlite3_open16().</dd>)^
2654 ** </dl>
2655 **
2656 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
2657 ** combinations shown above or one of the combinations shown above combined
2658 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
2659 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
2660 ** then the behavior is undefined.
2661 **
2662 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2663 ** opens in the multi-thread [threading mode] as long as the single-thread
2664 ** mode has not been set at compile-time or start-time. ^If the
2665 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
2666 ** in the serialized [threading mode] unless single-thread was
2667 ** previously selected at compile-time or start-time.
2668 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2669 ** eligible to use [shared cache mode], regardless of whether or not shared
2670 ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The
2671 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2672 ** participate in [shared cache mode] even if it is enabled.
2673 **
2674 ** ^If the filename is ":memory:", then a private, temporary in-memory database
2675 ** is created for the connection. ^This in-memory database will vanish when
2676 ** the database connection is closed. Future versions of SQLite might
2677 ** make use of additional special filenames that begin with the ":" character.
2678 ** It is recommended that when a database filename actually does begin with
2679 ** a ":" character you should prefix the filename with a pathname such as
2680 ** "./" to avoid ambiguity.
2681 **
2682 ** ^If the filename is an empty string, then a private, temporary
2683 ** on-disk database will be created. ^This private database will be
2684 ** automatically deleted as soon as the database connection is closed.
2685 **
2686 ** ^The fourth parameter to sqlite3_open_v2() is the name of the
2687 ** [sqlite3_vfs] object that defines the operating system interface that
2688 ** the new database connection should use. ^If the fourth parameter is
2689 ** a NULL pointer then the default [sqlite3_vfs] object is used.
2690 **
2691 ** <b>Note to Windows users:</b> The encoding used for the filename argument
2692 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2693 ** codepage is currently defined. Filenames containing international
2694 ** characters must be converted to UTF-8 prior to passing them into
2695 ** sqlite3_open() or sqlite3_open_v2().
 
 
 
 
2696 */
2697 SQLITE_API int sqlite3_open(
2698 const char *filename, /* Database filename (UTF-8) */
2699 sqlite3 **ppDb /* OUT: SQLite db handle */
2700 );
@@ -2707,27 +2708,27 @@
2708 int flags, /* Flags */
2709 const char *zVfs /* Name of VFS module to use */
2710 );
2711
2712 /*
2713 ** CAPI3REF: Error Codes And Messages
2714 **
2715 ** ^The sqlite3_errcode() interface returns the numeric [result code] or
2716 ** [extended result code] for the most recent failed sqlite3_* API call
2717 ** associated with a [database connection]. If a prior API call failed
2718 ** but the most recent API call succeeded, the return value from
2719 ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
2720 ** interface is the same except that it always returns the
2721 ** [extended result code] even when extended result codes are
2722 ** disabled.
2723 **
2724 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2725 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
2726 ** ^(Memory to hold the error message string is managed internally.
2727 ** The application does not need to worry about freeing the result.
2728 ** However, the error string might be overwritten or deallocated by
2729 ** subsequent calls to other SQLite interface functions.)^
2730 **
2731 ** When the serialized [threading mode] is in use, it might be the
2732 ** case that a second error occurs on a separate thread in between
2733 ** the time of the first error and the call to these interfaces.
2734 ** When that happens, the second error will be reported since these
@@ -2738,21 +2739,18 @@
2739 ** all calls to the interfaces listed here are completed.
2740 **
2741 ** If an interface fails with SQLITE_MISUSE, that means the interface
2742 ** was invoked incorrectly by the application. In that case, the
2743 ** error code and message may or may not be set.
 
 
 
2744 */
2745 SQLITE_API int sqlite3_errcode(sqlite3 *db);
2746 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
2747 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
2748 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
2749
2750 /*
2751 ** CAPI3REF: SQL Statement Object
2752 ** KEYWORDS: {prepared statement} {prepared statements}
2753 **
2754 ** An instance of this object represents a single SQL statement.
2755 ** This object is variously known as a "prepared statement" or a
2756 ** "compiled SQL statement" or simply as a "statement".
@@ -2774,29 +2772,29 @@
2772 ** information.
2773 */
2774 typedef struct sqlite3_stmt sqlite3_stmt;
2775
2776 /*
2777 ** CAPI3REF: Run-time Limits
2778 **
2779 ** ^(This interface allows the size of various constructs to be limited
2780 ** on a connection by connection basis. The first parameter is the
2781 ** [database connection] whose limit is to be set or queried. The
2782 ** second parameter is one of the [limit categories] that define a
2783 ** class of constructs to be size limited. The third parameter is the
2784 ** new limit for that construct. The function returns the old limit.)^
2785 **
2786 ** ^If the new limit is a negative number, the limit is unchanged.
2787 ** ^(For the limit category of SQLITE_LIMIT_XYZ there is a
2788 ** [limits | hard upper bound]
2789 ** set by a compile-time C preprocessor macro named
2790 ** [limits | SQLITE_MAX_XYZ].
2791 ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
2792 ** ^Attempts to increase a limit above its hard upper bound are
2793 ** silently truncated to the hard upper bound.
2794 **
2795 ** Run-time limits are intended for use in applications that manage
2796 ** both their own internal database and also databases that are controlled
2797 ** by untrusted external sources. An example application might be a
2798 ** web browser that has its own databases for storing history and
2799 ** separate databases controlled by JavaScript applications downloaded
2800 ** off the Internet. The internal databases can be given the
@@ -2806,63 +2804,60 @@
2804 ** interface to further control untrusted SQL. The size of the database
2805 ** created by an untrusted script can be contained using the
2806 ** [max_page_count] [PRAGMA].
2807 **
2808 ** New run-time limit categories may be added in future releases.
 
 
 
2809 */
2810 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2811
2812 /*
2813 ** CAPI3REF: Run-Time Limit Categories
2814 ** KEYWORDS: {limit category} {*limit categories}
2815 **
2816 ** These constants define various performance limits
2817 ** that can be lowered at run-time using [sqlite3_limit()].
2818 ** The synopsis of the meanings of the various limits is shown below.
2819 ** Additional information is available at [limits | Limits in SQLite].
2820 **
2821 ** <dl>
2822 ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2823 ** <dd>The maximum size of any string or BLOB or table row.<dd>)^
2824 **
2825 ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2826 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
2827 **
2828 ** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
2829 ** <dd>The maximum number of columns in a table definition or in the
2830 ** result set of a [SELECT] or the maximum number of columns in an index
2831 ** or in an ORDER BY or GROUP BY clause.</dd>)^
2832 **
2833 ** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2834 ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
2835 **
2836 ** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2837 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
2838 **
2839 ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
2840 ** <dd>The maximum number of instructions in a virtual machine program
2841 ** used to implement an SQL statement.</dd>)^
2842 **
2843 ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2844 ** <dd>The maximum number of arguments on a function.</dd>)^
2845 **
2846 ** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2847 ** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
2848 **
2849 ** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2850 ** <dd>The maximum length of the pattern argument to the [LIKE] or
2851 ** [GLOB] operators.</dd>)^
2852 **
2853 ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2854 ** <dd>The maximum number of variables in an SQL statement that can
2855 ** be bound.</dd>)^
2856 **
2857 ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2858 ** <dd>The maximum depth of recursion for triggers.</dd>)^
2859 ** </dl>
2860 */
2861 #define SQLITE_LIMIT_LENGTH 0
2862 #define SQLITE_LIMIT_SQL_LENGTH 1
2863 #define SQLITE_LIMIT_COLUMN 2
@@ -2874,11 +2869,11 @@
2869 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
2870 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
2871 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
2872
2873 /*
2874 ** CAPI3REF: Compiling An SQL Statement
2875 ** KEYWORDS: {SQL statement compiler}
2876 **
2877 ** To execute an SQL query, it must first be compiled into a byte-code
2878 ** program using one of these routines.
2879 **
@@ -2889,61 +2884,62 @@
2884 ** The second argument, "zSql", is the statement to be compiled, encoded
2885 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2886 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2887 ** use UTF-16.
2888 **
2889 ** ^If the nByte argument is less than zero, then zSql is read up to the
2890 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
2891 ** number of bytes read from zSql. ^When nByte is non-negative, the
2892 ** zSql string ends at either the first '\000' or '\u0000' character or
2893 ** the nByte-th byte, whichever comes first. If the caller knows
2894 ** that the supplied string is nul-terminated, then there is a small
2895 ** performance advantage to be gained by passing an nByte parameter that
2896 ** is equal to the number of bytes in the input string <i>including</i>
2897 ** the nul-terminator bytes.
2898 **
2899 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
2900 ** past the end of the first SQL statement in zSql. These routines only
2901 ** compile the first statement in zSql, so *pzTail is left pointing to
2902 ** what remains uncompiled.
2903 **
2904 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
2905 ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
2906 ** to NULL. ^If the input text contains no SQL (if the input is an empty
2907 ** string or a comment) then *ppStmt is set to NULL.
2908 ** The calling procedure is responsible for deleting the compiled
2909 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2910 ** ppStmt may not be NULL.
2911 **
2912 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
2913 ** otherwise an [error code] is returned.
2914 **
2915 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2916 ** recommended for all new programs. The two older interfaces are retained
2917 ** for backwards compatibility, but their use is discouraged.
2918 ** ^In the "v2" interfaces, the prepared statement
2919 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
2920 ** original SQL text. This causes the [sqlite3_step()] interface to
2921 ** behave differently in three ways:
2922 **
2923 ** <ol>
2924 ** <li>
2925 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2926 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
2927 ** statement and try to run it again. ^If the schema has changed in
2928 ** a way that makes the statement no longer valid, [sqlite3_step()] will still
2929 ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
2930 ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
2931 ** error go away. Note: use [sqlite3_errmsg()] to find the text
2932 ** of the parsing error that results in an [SQLITE_SCHEMA] return.
2933 ** </li>
2934 **
2935 ** <li>
2936 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
2937 ** [error codes] or [extended error codes]. ^The legacy behavior was that
2938 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2939 ** and the application would have to make a second call to [sqlite3_reset()]
2940 ** in order to find the underlying cause of the problem. With the "v2" prepare
2941 ** interfaces, the underlying reason for the error is returned immediately.
2942 ** </li>
2943 **
2944 ** <li>
2945 ** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2951,14 +2947,10 @@
2947 ** automatically recompiled (as if there had been a schema change) on the first
2948 ** [sqlite3_step()] call following any change to the
2949 ** [sqlite3_bind_text | bindings] of the [parameter].
2950 ** </li>
2951 ** </ol>
 
 
 
 
2952 */
2953 SQLITE_API int sqlite3_prepare(
2954 sqlite3 *db, /* Database handle */
2955 const char *zSql, /* SQL statement, UTF-8 encoded */
2956 int nByte, /* Maximum length of zSql in bytes. */
@@ -2986,28 +2978,25 @@
2978 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
2979 const void **pzTail /* OUT: Pointer to unused portion of zSql */
2980 );
2981
2982 /*
2983 ** CAPI3REF: Retrieving Statement SQL
2984 **
2985 ** ^This interface can be used to retrieve a saved copy of the original
2986 ** SQL text used to create a [prepared statement] if that statement was
2987 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
 
 
2988 */
2989 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
2990
2991 /*
2992 ** CAPI3REF: Dynamically Typed Value Object
2993 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
2994 **
2995 ** SQLite uses the sqlite3_value object to represent all values
2996 ** that can be stored in a database table. SQLite uses dynamic typing
2997 ** for the values it stores. ^Values stored in sqlite3_value objects
2998 ** can be integers, floating point values, strings, BLOBs, or NULL.
2999 **
3000 ** An sqlite3_value object may be either "protected" or "unprotected".
3001 ** Some interfaces require a protected sqlite3_value. Other interfaces
3002 ** will accept either a protected or an unprotected sqlite3_value.
@@ -3025,26 +3014,26 @@
3014 ** sqlite3_value objects and they can be used interchangeably. However,
3015 ** for maximum code portability it is recommended that applications
3016 ** still make the distinction between between protected and unprotected
3017 ** sqlite3_value objects even when not strictly required.
3018 **
3019 ** ^The sqlite3_value objects that are passed as parameters into the
3020 ** implementation of [application-defined SQL functions] are protected.
3021 ** ^The sqlite3_value object returned by
3022 ** [sqlite3_column_value()] is unprotected.
3023 ** Unprotected sqlite3_value objects may only be used with
3024 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
3025 ** The [sqlite3_value_blob | sqlite3_value_type()] family of
3026 ** interfaces require protected sqlite3_value objects.
3027 */
3028 typedef struct Mem sqlite3_value;
3029
3030 /*
3031 ** CAPI3REF: SQL Function Context Object
3032 **
3033 ** The context in which an SQL function executes is stored in an
3034 ** sqlite3_context object. ^A pointer to an sqlite3_context object
3035 ** is always first parameter to [application-defined SQL functions].
3036 ** The application-defined SQL function implementation will pass this
3037 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
3038 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
3039 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -3051,15 +3040,15 @@
3040 ** and/or [sqlite3_set_auxdata()].
3041 */
3042 typedef struct sqlite3_context sqlite3_context;
3043
3044 /*
3045 ** CAPI3REF: Binding Values To Prepared Statements
3046 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3047 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3048 **
3049 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3050 ** literals may be replaced by a [parameter] that matches one of following
3051 ** templates:
3052 **
3053 ** <ul>
3054 ** <li> ?
@@ -3068,76 +3057,70 @@
3057 ** <li> @VVV
3058 ** <li> $VVV
3059 ** </ul>
3060 **
3061 ** In the templates above, NNN represents an integer literal,
3062 ** and VVV represents an alphanumeric identifer.)^ ^The values of these
3063 ** parameters (also called "host parameter names" or "SQL parameters")
3064 ** can be set using the sqlite3_bind_*() routines defined here.
3065 **
3066 ** ^The first argument to the sqlite3_bind_*() routines is always
3067 ** a pointer to the [sqlite3_stmt] object returned from
3068 ** [sqlite3_prepare_v2()] or its variants.
3069 **
3070 ** ^The second argument is the index of the SQL parameter to be set.
3071 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
3072 ** SQL parameter is used more than once, second and subsequent
3073 ** occurrences have the same index as the first occurrence.
3074 ** ^The index for named parameters can be looked up using the
3075 ** [sqlite3_bind_parameter_index()] API if desired. ^The index
3076 ** for "?NNN" parameters is the value of NNN.
3077 ** ^The NNN value must be between 1 and the [sqlite3_limit()]
3078 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
3079 **
3080 ** ^The third argument is the value to bind to the parameter.
3081 **
3082 ** ^(In those routines that have a fourth argument, its value is the
3083 ** number of bytes in the parameter. To be clear: the value is the
3084 ** number of <u>bytes</u> in the value, not the number of characters.)^
3085 ** ^If the fourth parameter is negative, the length of the string is
3086 ** the number of bytes up to the first zero terminator.
3087 **
3088 ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
3089 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
3090 ** string after SQLite has finished with it. ^If the fifth argument is
3091 ** the special value [SQLITE_STATIC], then SQLite assumes that the
3092 ** information is in static, unmanaged space and does not need to be freed.
3093 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
3094 ** SQLite makes its own private copy of the data immediately, before
3095 ** the sqlite3_bind_*() routine returns.
3096 **
3097 ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
3098 ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
3099 ** (just an integer to hold its size) while it is being processed.
3100 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
3101 ** content is later written using
3102 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
3103 ** ^A negative value for the zeroblob results in a zero-length BLOB.
3104 **
3105 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
3106 ** for the [prepared statement] or with a prepared statement for which
3107 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
3108 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
3109 ** routine is passed a [prepared statement] that has been finalized, the
3110 ** result is undefined and probably harmful.
3111 **
3112 ** ^Bindings are not cleared by the [sqlite3_reset()] routine.
3113 ** ^Unbound parameters are interpreted as NULL.
3114 **
3115 ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
3116 ** [error code] if anything goes wrong.
3117 ** ^[SQLITE_RANGE] is returned if the parameter
3118 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
 
3119 **
3120 ** See also: [sqlite3_bind_parameter_count()],
3121 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
 
 
 
 
 
3122 */
3123 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3124 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3125 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3126 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -3146,175 +3129,155 @@
3129 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3130 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3131 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3132
3133 /*
3134 ** CAPI3REF: Number Of SQL Parameters
3135 **
3136 ** ^This routine can be used to find the number of [SQL parameters]
3137 ** in a [prepared statement]. SQL parameters are tokens of the
3138 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3139 ** placeholders for values that are [sqlite3_bind_blob | bound]
3140 ** to the parameters at a later time.
3141 **
3142 ** ^(This routine actually returns the index of the largest (rightmost)
3143 ** parameter. For all forms except ?NNN, this will correspond to the
3144 ** number of unique parameters. If parameters of the ?NNN form are used,
3145 ** there may be gaps in the list.)^
3146 **
3147 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3148 ** [sqlite3_bind_parameter_name()], and
3149 ** [sqlite3_bind_parameter_index()].
 
 
 
3150 */
3151 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3152
3153 /*
3154 ** CAPI3REF: Name Of A Host Parameter
3155 **
3156 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3157 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3158 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3159 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
3160 ** respectively.
3161 ** In other words, the initial ":" or "$" or "@" or "?"
3162 ** is included as part of the name.)^
3163 ** ^Parameters of the form "?" without a following integer have no name
3164 ** and are referred to as "nameless" or "anonymous parameters".
3165 **
3166 ** ^The first host parameter has an index of 1, not 0.
3167 **
3168 ** ^If the value N is out of range or if the N-th parameter is
3169 ** nameless, then NULL is returned. ^The returned string is
3170 ** always in UTF-8 encoding even if the named parameter was
3171 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
3172 ** [sqlite3_prepare16_v2()].
3173 **
3174 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3175 ** [sqlite3_bind_parameter_count()], and
3176 ** [sqlite3_bind_parameter_index()].
 
 
 
3177 */
3178 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3179
3180 /*
3181 ** CAPI3REF: Index Of A Parameter With A Given Name
3182 **
3183 ** ^Return the index of an SQL parameter given its name. ^The
3184 ** index value returned is suitable for use as the second
3185 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3186 ** is returned if no matching parameter is found. ^The parameter
3187 ** name must be given in UTF-8 even if the original statement
3188 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
3189 **
3190 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3191 ** [sqlite3_bind_parameter_count()], and
3192 ** [sqlite3_bind_parameter_index()].
 
 
 
3193 */
3194 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3195
3196 /*
3197 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3198 **
3199 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3200 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3201 ** ^Use this routine to reset all host parameters to NULL.
 
 
 
3202 */
3203 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3204
3205 /*
3206 ** CAPI3REF: Number Of Columns In A Result Set
3207 **
3208 ** ^Return the number of columns in the result set returned by the
3209 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3210 ** statement that does not return data (for example an [UPDATE]).
 
 
 
3211 */
3212 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3213
3214 /*
3215 ** CAPI3REF: Column Names In A Result Set
3216 **
3217 ** ^These routines return the name assigned to a particular column
3218 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3219 ** interface returns a pointer to a zero-terminated UTF-8 string
3220 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
3221 ** UTF-16 string. ^The first parameter is the [prepared statement]
3222 ** that implements the [SELECT] statement. ^The second parameter is the
3223 ** column number. ^The leftmost column is number 0.
3224 **
3225 ** ^The returned string pointer is valid until either the [prepared statement]
3226 ** is destroyed by [sqlite3_finalize()] or until the next call to
3227 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
3228 **
3229 ** ^If sqlite3_malloc() fails during the processing of either routine
3230 ** (for example during a conversion from UTF-8 to UTF-16) then a
3231 ** NULL pointer is returned.
3232 **
3233 ** ^The name of a result column is the value of the "AS" clause for
3234 ** that column, if there is an AS clause. If there is no AS clause
3235 ** then the name of the column is unspecified and may change from
3236 ** one release of SQLite to the next.
 
 
 
3237 */
3238 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3239 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3240
3241 /*
3242 ** CAPI3REF: Source Of Data In A Query Result
3243 **
3244 ** ^These routines provide a means to determine the database, table, and
3245 ** table column that is the origin of a particular result column in
3246 ** [SELECT] statement.
3247 ** ^The name of the database or table or column can be returned as
3248 ** either a UTF-8 or UTF-16 string. ^The _database_ routines return
3249 ** the database name, the _table_ routines return the table name, and
3250 ** the origin_ routines return the column name.
3251 ** ^The returned string is valid until the [prepared statement] is destroyed
3252 ** using [sqlite3_finalize()] or until the same information is requested
3253 ** again in a different encoding.
3254 **
3255 ** ^The names returned are the original un-aliased names of the
3256 ** database, table, and column.
3257 **
3258 ** ^The first argument to these interfaces is a [prepared statement].
3259 ** ^These functions return information about the Nth result column returned by
3260 ** the statement, where N is the second function argument.
3261 ** ^The left-most column is column 0 for these routines.
3262 **
3263 ** ^If the Nth column returned by the statement is an expression or
3264 ** subquery and is not a column value, then all of these functions return
3265 ** NULL. ^These routine might also return NULL if a memory allocation error
3266 ** occurs. ^Otherwise, they return the name of the attached database, table,
3267 ** or column that query result column was extracted from.
3268 **
3269 ** ^As with all other SQLite APIs, those whose names end with "16" return
3270 ** UTF-16 encoded strings and the other functions return UTF-8.
3271 **
3272 ** ^These APIs are only available if the library was compiled with the
3273 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
3274 **
 
3275 ** If two or more threads call one or more of these routines against the same
3276 ** prepared statement and column at the same time then the results are
3277 ** undefined.
3278 **
 
 
 
3279 ** If two or more threads call one or more
3280 ** [sqlite3_column_database_name | column metadata interfaces]
3281 ** for the same [prepared statement] and result column
3282 ** at the same time then the results are undefined.
3283 */
@@ -3324,46 +3287,43 @@
3287 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3288 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3289 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3290
3291 /*
3292 ** CAPI3REF: Declared Datatype Of A Query Result
3293 **
3294 ** ^(The first parameter is a [prepared statement].
3295 ** If this statement is a [SELECT] statement and the Nth column of the
3296 ** returned result set of that [SELECT] is a table column (not an
3297 ** expression or subquery) then the declared type of the table
3298 ** column is returned.)^ ^If the Nth column of the result set is an
3299 ** expression or subquery, then a NULL pointer is returned.
3300 ** ^The returned string is always UTF-8 encoded.
3301 **
3302 ** ^(For example, given the database schema:
3303 **
3304 ** CREATE TABLE t1(c1 VARIANT);
3305 **
3306 ** and the following statement to be compiled:
3307 **
3308 ** SELECT c1 + 1, c1 FROM t1;
3309 **
3310 ** this routine would return the string "VARIANT" for the second result
3311 ** column (i==1), and a NULL pointer for the first result column (i==0).)^
3312 **
3313 ** ^SQLite uses dynamic run-time typing. ^So just because a column
3314 ** is declared to contain a particular type does not mean that the
3315 ** data stored in that column is of the declared type. SQLite is
3316 ** strongly typed, but the typing is dynamic not static. ^Type
3317 ** is associated with individual values, not with the containers
3318 ** used to hold those values.
 
 
 
3319 */
3320 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3321 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3322
3323 /*
3324 ** CAPI3REF: Evaluate An SQL Statement
3325 **
3326 ** After a [prepared statement] has been prepared using either
3327 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3328 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3329 ** must be called one or more times to evaluate the statement.
@@ -3373,39 +3333,39 @@
3333 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
3334 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
3335 ** new "v2" interface is recommended for new applications but the legacy
3336 ** interface will continue to be supported.
3337 **
3338 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
3339 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
3340 ** ^With the "v2" interface, any of the other [result codes] or
3341 ** [extended result codes] might be returned as well.
3342 **
3343 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
3344 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
3345 ** or occurs outside of an explicit transaction, then you can retry the
3346 ** statement. If the statement is not a [COMMIT] and occurs within a
3347 ** explicit transaction then you should rollback the transaction before
3348 ** continuing.
3349 **
3350 ** ^[SQLITE_DONE] means that the statement has finished executing
3351 ** successfully. sqlite3_step() should not be called again on this virtual
3352 ** machine without first calling [sqlite3_reset()] to reset the virtual
3353 ** machine back to its initial state.
3354 **
3355 ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
3356 ** is returned each time a new row of data is ready for processing by the
3357 ** caller. The values may be accessed using the [column access functions].
3358 ** sqlite3_step() is called again to retrieve the next row of data.
3359 **
3360 ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
3361 ** violation) has occurred. sqlite3_step() should not be called again on
3362 ** the VM. More information may be found by calling [sqlite3_errmsg()].
3363 ** ^With the legacy interface, a more specific error code (for example,
3364 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
3365 ** can be obtained by calling [sqlite3_reset()] on the
3366 ** [prepared statement]. ^In the "v2" interface,
3367 ** the more specific error code is returned directly by sqlite3_step().
3368 **
3369 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
3370 ** Perhaps it was called on a [prepared statement] that has
3371 ** already been [sqlite3_finalize | finalized] or on one that had
@@ -3422,39 +3382,34 @@
3382 ** with the "v2" interface. If you prepare all of your SQL statements
3383 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3384 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3385 ** then the more specific [error codes] are returned directly
3386 ** by sqlite3_step(). The use of the "v2" interface is recommended.
 
 
 
3387 */
3388 SQLITE_API int sqlite3_step(sqlite3_stmt*);
3389
3390 /*
3391 ** CAPI3REF: Number of columns in a result set
3392 **
3393 ** ^The sqlite3_data_count(P) the number of columns in the
3394 ** of the result set of [prepared statement] P.
 
 
3395 */
3396 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3397
3398 /*
3399 ** CAPI3REF: Fundamental Datatypes
3400 ** KEYWORDS: SQLITE_TEXT
3401 **
3402 ** ^(Every value in SQLite has one of five fundamental datatypes:
3403 **
3404 ** <ul>
3405 ** <li> 64-bit signed integer
3406 ** <li> 64-bit IEEE floating point number
3407 ** <li> string
3408 ** <li> BLOB
3409 ** <li> NULL
3410 ** </ul>)^
3411 **
3412 ** These constants are codes for each of those types.
3413 **
3414 ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
3415 ** for a completely different meaning. Software that links against both
@@ -3471,22 +3426,22 @@
3426 # define SQLITE_TEXT 3
3427 #endif
3428 #define SQLITE3_TEXT 3
3429
3430 /*
3431 ** CAPI3REF: Result Values From A Query
3432 ** KEYWORDS: {column access functions}
3433 **
3434 ** These routines form the "result set" interface.
3435 **
3436 ** ^These routines return information about a single column of the current
3437 ** result row of a query. ^In every case the first argument is a pointer
3438 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
3439 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
3440 ** and the second argument is the index of the column for which information
3441 ** should be returned. ^The leftmost column of the result set has the index 0.
3442 ** ^The number of columns in the result can be determined using
3443 ** [sqlite3_column_count()].
3444 **
3445 ** If the SQL statement does not currently point to a valid row, or if the
3446 ** column index is out of range, the result is undefined.
3447 ** These routines may only be called when the most recent call to
@@ -3497,52 +3452,52 @@
3452 ** something other than [SQLITE_ROW], the results are undefined.
3453 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
3454 ** are called from a different thread while any of these routines
3455 ** are pending, then the results are undefined.
3456 **
3457 ** ^The sqlite3_column_type() routine returns the
3458 ** [SQLITE_INTEGER | datatype code] for the initial data type
3459 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
3460 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
3461 ** returned by sqlite3_column_type() is only meaningful if no type
3462 ** conversions have occurred as described below. After a type conversion,
3463 ** the value returned by sqlite3_column_type() is undefined. Future
3464 ** versions of SQLite may change the behavior of sqlite3_column_type()
3465 ** following a type conversion.
3466 **
3467 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
3468 ** routine returns the number of bytes in that BLOB or string.
3469 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
3470 ** the string to UTF-8 and then returns the number of bytes.
3471 ** ^If the result is a numeric value then sqlite3_column_bytes() uses
3472 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
3473 ** the number of bytes in that string.
3474 ** ^The value returned does not include the zero terminator at the end
3475 ** of the string. ^For clarity: the value returned is the number of
3476 ** bytes in the string, not the number of characters.
3477 **
3478 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3479 ** even empty strings, are always zero terminated. ^The return
3480 ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
3481 ** pointer, possibly even a NULL pointer.
3482 **
3483 ** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
3484 ** but leaves the result in UTF-16 in native byte order instead of UTF-8.
3485 ** ^The zero terminator is not included in this count.
3486 **
3487 ** ^The object returned by [sqlite3_column_value()] is an
3488 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
3489 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
3490 ** If the [unprotected sqlite3_value] object returned by
3491 ** [sqlite3_column_value()] is used in any other way, including calls
3492 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
3493 ** or [sqlite3_value_bytes()], then the behavior is undefined.
3494 **
3495 ** These routines attempt to convert the value where appropriate. ^For
3496 ** example, if the internal representation is FLOAT and a text result
3497 ** is requested, [sqlite3_snprintf()] is used internally to perform the
3498 ** conversion automatically. ^(The following table details the conversions
3499 ** that are applied:
3500 **
3501 ** <blockquote>
3502 ** <table border="1">
3503 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3562,22 +3517,22 @@
3517 ** <tr><td> TEXT <td> BLOB <td> No change
3518 ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
3519 ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
3520 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
3521 ** </table>
3522 ** </blockquote>)^
3523 **
3524 ** The table above makes reference to standard C library functions atoi()
3525 ** and atof(). SQLite does not really use these functions. It has its
3526 ** own equivalent internal routines. The atoi() and atof() names are
3527 ** used in the table for brevity and because they are familiar to most
3528 ** C programmers.
3529 **
3530 ** ^Note that when type conversions occur, pointers returned by prior
3531 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
3532 ** sqlite3_column_text16() may be invalidated.
3533 ** ^(Type conversions and pointer invalidations might occur
3534 ** in the following cases:
3535 **
3536 ** <ul>
3537 ** <li> The initial content is a BLOB and sqlite3_column_text() or
3538 ** sqlite3_column_text16() is called. A zero-terminator might
@@ -3586,51 +3541,47 @@
3541 ** sqlite3_column_text16() is called. The content must be converted
3542 ** to UTF-16.</li>
3543 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
3544 ** sqlite3_column_text() is called. The content must be converted
3545 ** to UTF-8.</li>
3546 ** </ul>)^
3547 **
3548 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
3549 ** not invalidate a prior pointer, though of course the content of the buffer
3550 ** that the prior pointer points to will have been modified. Other kinds
3551 ** of conversion are done in place when it is possible, but sometimes they
3552 ** are not possible and in those cases prior pointers are invalidated.
3553 **
3554 ** ^(The safest and easiest to remember policy is to invoke these routines
3555 ** in one of the following ways:
3556 **
3557 ** <ul>
3558 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
3559 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
3560 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3561 ** </ul>)^
3562 **
3563 ** In other words, you should call sqlite3_column_text(),
3564 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
3565 ** into the desired format, then invoke sqlite3_column_bytes() or
3566 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
3567 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
3568 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
3569 ** with calls to sqlite3_column_bytes().
3570 **
3571 ** ^The pointers returned are valid until a type conversion occurs as
3572 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3573 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
3574 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
3575 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3576 ** [sqlite3_free()].
3577 **
3578 ** ^(If a memory allocation error occurs during the evaluation of any
3579 ** of these routines, a default value is returned. The default value
3580 ** is either the integer 0, the floating point number 0.0, or a NULL
3581 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
3582 ** [SQLITE_NOMEM].)^
 
 
 
 
3583 */
3584 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
3585 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
3586 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
3587 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3640,139 +3591,132 @@
3591 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
3592 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
3593 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3594
3595 /*
3596 ** CAPI3REF: Destroy A Prepared Statement Object
3597 **
3598 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3599 ** ^If the statement was executed successfully or not executed at all, then
3600 ** SQLITE_OK is returned. ^If execution of the statement failed then an
3601 ** [error code] or [extended error code] is returned.
3602 **
3603 ** ^This routine can be called at any point during the execution of the
3604 ** [prepared statement]. ^If the virtual machine has not
3605 ** completed execution when this routine is called, that is like
3606 ** encountering an error or an [sqlite3_interrupt | interrupt].
3607 ** ^Incomplete updates may be rolled back and transactions canceled,
3608 ** depending on the circumstances, and the
3609 ** [error code] returned will be [SQLITE_ABORT].
 
 
 
3610 */
3611 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
3612
3613 /*
3614 ** CAPI3REF: Reset A Prepared Statement Object
3615 **
3616 ** The sqlite3_reset() function is called to reset a [prepared statement]
3617 ** object back to its initial state, ready to be re-executed.
3618 ** ^Any SQL statement variables that had values bound to them using
3619 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
3620 ** Use [sqlite3_clear_bindings()] to reset the bindings.
3621 **
3622 ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
3623 ** back to the beginning of its program.
3624 **
3625 ** ^If the most recent call to [sqlite3_step(S)] for the
3626 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3627 ** or if [sqlite3_step(S)] has never before been called on S,
3628 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
3629 **
3630 ** ^If the most recent call to [sqlite3_step(S)] for the
3631 ** [prepared statement] S indicated an error, then
3632 ** [sqlite3_reset(S)] returns an appropriate [error code].
3633 **
3634 ** ^The [sqlite3_reset(S)] interface does not change the values
3635 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3636 */
3637 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3638
3639 /*
3640 ** CAPI3REF: Create Or Redefine SQL Functions
3641 ** KEYWORDS: {function creation routines}
3642 ** KEYWORDS: {application-defined SQL function}
3643 ** KEYWORDS: {application-defined SQL functions}
3644 **
3645 ** ^These two functions (collectively known as "function creation routines")
3646 ** are used to add SQL functions or aggregates or to redefine the behavior
3647 ** of existing SQL functions or aggregates. The only difference between the
3648 ** two is that the second parameter, the name of the (scalar) function or
3649 ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
3650 ** for sqlite3_create_function16().
3651 **
3652 ** ^The first parameter is the [database connection] to which the SQL
3653 ** function is to be added. ^If an application uses more than one database
3654 ** connection then application-defined SQL functions must be added
3655 ** to each database connection separately.
3656 **
3657 ** The second parameter is the name of the SQL function to be created or
3658 ** redefined. ^The length of the name is limited to 255 bytes, exclusive of
3659 ** the zero-terminator. Note that the name length limit is in bytes, not
3660 ** characters. ^Any attempt to create a function with a longer name
3661 ** will result in [SQLITE_ERROR] being returned.
3662 **
3663 ** ^The third parameter (nArg)
3664 ** is the number of arguments that the SQL function or
3665 ** aggregate takes. ^If this parameter is -1, then the SQL function or
3666 ** aggregate may take any number of arguments between 0 and the limit
3667 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
3668 ** parameter is less than -1 or greater than 127 then the behavior is
3669 ** undefined.
3670 **
3671 ** The fourth parameter, eTextRep, specifies what
3672 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
3673 ** its parameters. Any SQL function implementation should be able to work
3674 ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3675 ** more efficient with one encoding than another. ^An application may
3676 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
3677 ** times with the same function but with different values of eTextRep.
3678 ** ^When multiple implementations of the same function are available, SQLite
3679 ** will pick the one that involves the least amount of data conversion.
3680 ** If there is only a single implementation which does not care what text
3681 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
3682 **
3683 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
3684 ** function can gain access to this pointer using [sqlite3_user_data()].)^
3685 **
3686 ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
3687 ** pointers to C-language functions that implement the SQL function or
3688 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
3689 ** callback only; NULL pointers should be passed as the xStep and xFinal
3690 ** parameters. ^An aggregate SQL function requires an implementation of xStep
3691 ** and xFinal and NULL should be passed for xFunc. ^To delete an existing
3692 ** SQL function or aggregate, pass NULL for all three function callbacks.
3693 **
3694 ** ^It is permitted to register multiple implementations of the same
3695 ** functions with the same name but with either differing numbers of
3696 ** arguments or differing preferred text encodings. ^SQLite will use
3697 ** the implementation that most closely matches the way in which the
3698 ** SQL function is used. ^A function implementation with a non-negative
3699 ** nArg parameter is a better match than a function implementation with
3700 ** a negative nArg. ^A function where the preferred text encoding
3701 ** matches the database encoding is a better
3702 ** match than a function where the encoding is different.
3703 ** ^A function where the encoding difference is between UTF16le and UTF16be
3704 ** is a closer match than a function where the encoding difference is
3705 ** between UTF8 and UTF16.
3706 **
3707 ** ^Built-in functions may be overloaded by new application-defined functions.
3708 ** ^The first application-defined function with a given name overrides all
3709 ** built-in functions in the same [database connection] with the same name.
3710 ** ^Subsequent application-defined functions of the same name only override
3711 ** prior application-defined functions that are an exact match for the
3712 ** number of parameters and preferred encoding.
3713 **
3714 ** ^An application-defined function is permitted to call other
3715 ** SQLite interfaces. However, such calls must not
3716 ** close the database connection nor finalize or reset the prepared
3717 ** statement in which the function is running.
 
 
 
 
3718 */
3719 SQLITE_API int sqlite3_create_function(
3720 sqlite3 *db,
3721 const char *zFunctionName,
3722 int nArg,
@@ -3792,11 +3736,11 @@
3736 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
3737 void (*xFinal)(sqlite3_context*)
3738 );
3739
3740 /*
3741 ** CAPI3REF: Text Encodings
3742 **
3743 ** These constant define integer codes that represent the various
3744 ** text encodings supported by SQLite.
3745 */
3746 #define SQLITE_UTF8 1
@@ -3824,11 +3768,11 @@
3768 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
3769 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
3770 #endif
3771
3772 /*
3773 ** CAPI3REF: Obtaining SQL Function Parameter Values
3774 **
3775 ** The C-language implementation of SQL functions and aggregates uses
3776 ** this set of interface routines to access the parameter values on
3777 ** the function or aggregate.
3778 **
@@ -3842,39 +3786,35 @@
3786 **
3787 ** These routines work only with [protected sqlite3_value] objects.
3788 ** Any attempt to use these routines on an [unprotected sqlite3_value]
3789 ** object results in undefined behavior.
3790 **
3791 ** ^These routines work just like the corresponding [column access functions]
3792 ** except that these routines take a single [protected sqlite3_value] object
3793 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
3794 **
3795 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
3796 ** in the native byte-order of the host machine. ^The
3797 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
3798 ** extract UTF-16 strings as big-endian and little-endian respectively.
3799 **
3800 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
3801 ** numeric affinity to the value. This means that an attempt is
3802 ** made to convert the value to an integer or floating point. If
3803 ** such a conversion is possible without loss of information (in other
3804 ** words, if the value is a string that looks like a number)
3805 ** then the conversion is performed. Otherwise no conversion occurs.
3806 ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
3807 **
3808 ** Please pay particular attention to the fact that the pointer returned
3809 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
3810 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
3811 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
3812 ** or [sqlite3_value_text16()].
3813 **
3814 ** These routines must be called from the same thread as
3815 ** the SQL function that supplied the [sqlite3_value*] parameters.
 
 
 
 
3816 */
3817 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
3818 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
3819 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
3820 SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3886,70 +3826,77 @@
3826 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
3827 SQLITE_API int sqlite3_value_type(sqlite3_value*);
3828 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
3829
3830 /*
3831 ** CAPI3REF: Obtain Aggregate Function Context
3832 **
3833 ** Implementions of aggregate SQL functions use this
3834 ** routine to allocate memory for storing their state.
3835 **
3836 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
3837 ** for a particular aggregate function, SQLite
3838 ** allocates N of memory, zeroes out that memory, and returns a pointer
3839 ** to the new memory. ^On second and subsequent calls to
3840 ** sqlite3_aggregate_context() for the same aggregate function instance,
3841 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
3842 ** called once for each invocation of the xStep callback and then one
3843 ** last time when the xFinal callback is invoked. ^(When no rows match
3844 ** an aggregate query, the xStep() callback of the aggregate function
3845 ** implementation is never called and xFinal() is called exactly once.
3846 ** In those cases, sqlite3_aggregate_context() might be called for the
3847 ** first time from within xFinal().)^
3848 **
3849 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
3850 ** less than or equal to zero or if a memory allocate error occurs.
3851 **
3852 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
3853 ** determined by the N parameter on first successful call. Changing the
3854 ** value of N in subsequent call to sqlite3_aggregate_context() within
3855 ** the same aggregate function instance will not resize the memory
3856 ** allocation.)^
3857 **
3858 ** ^SQLite automatically frees the memory allocated by
3859 ** sqlite3_aggregate_context() when the aggregate query concludes.
3860 **
3861 ** The first parameter must be a copy of the
3862 ** [sqlite3_context | SQL function context] that is the first parameter
3863 ** to the xStep or xFinal callback routine that implements the aggregate
3864 ** function.
3865 **
3866 ** This routine must be called from the same thread in which
3867 ** the aggregate SQL function is running.
 
 
 
3868 */
3869 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
3870
3871 /*
3872 ** CAPI3REF: User Data For Functions
3873 **
3874 ** ^The sqlite3_user_data() interface returns a copy of
3875 ** the pointer that was the pUserData parameter (the 5th parameter)
3876 ** of the [sqlite3_create_function()]
3877 ** and [sqlite3_create_function16()] routines that originally
3878 ** registered the application defined function.
3879 **
3880 ** This routine must be called from the same thread in which
3881 ** the application-defined function is running.
 
 
 
3882 */
3883 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
3884
3885 /*
3886 ** CAPI3REF: Database Connection For Functions
3887 **
3888 ** ^The sqlite3_context_db_handle() interface returns a copy of
3889 ** the pointer to the [database connection] (the 1st parameter)
3890 ** of the [sqlite3_create_function()]
3891 ** and [sqlite3_create_function16()] routines that originally
3892 ** registered the application defined function.
 
 
 
3893 */
3894 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
3895
3896 /*
3897 ** CAPI3REF: Function Auxiliary Data
3898 **
3899 ** The following two functions may be used by scalar SQL functions to
3900 ** associate metadata with argument values. If the same value is passed to
3901 ** multiple invocations of the same SQL function during query execution, under
3902 ** some circumstances the associated metadata may be preserved. This may
@@ -3958,52 +3905,49 @@
3905 ** metadata associated with the SQL value passed as the regular expression
3906 ** pattern. The compiled regular expression can be reused on multiple
3907 ** invocations of the same function so that the original pattern string
3908 ** does not need to be recompiled on each invocation.
3909 **
3910 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
3911 ** associated by the sqlite3_set_auxdata() function with the Nth argument
3912 ** value to the application-defined function. ^If no metadata has been ever
3913 ** been set for the Nth argument of the function, or if the corresponding
3914 ** function parameter has changed since the meta-data was set,
3915 ** then sqlite3_get_auxdata() returns a NULL pointer.
3916 **
3917 ** ^The sqlite3_set_auxdata() interface saves the metadata
3918 ** pointed to by its 3rd parameter as the metadata for the N-th
3919 ** argument of the application-defined function. Subsequent
3920 ** calls to sqlite3_get_auxdata() might return this data, if it has
3921 ** not been destroyed.
3922 ** ^If it is not NULL, SQLite will invoke the destructor
3923 ** function given by the 4th parameter to sqlite3_set_auxdata() on
3924 ** the metadata when the corresponding function parameter changes
3925 ** or when the SQL statement completes, whichever comes first.
3926 **
3927 ** SQLite is free to call the destructor and drop metadata on any
3928 ** parameter of any function at any time. ^The only guarantee is that
3929 ** the destructor will be called before the metadata is dropped.
3930 **
3931 ** ^(In practice, metadata is preserved between function calls for
3932 ** expressions that are constant at compile time. This includes literal
3933 ** values and [parameters].)^
3934 **
3935 ** These routines must be called from the same thread in which
3936 ** the SQL function is running.
 
 
 
3937 */
3938 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
3939 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
3940
3941
3942 /*
3943 ** CAPI3REF: Constants Defining Special Destructor Behavior
3944 **
3945 ** These are special values for the destructor that is passed in as the
3946 ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor
3947 ** argument is SQLITE_STATIC, it means that the content pointer is constant
3948 ** and will never change. It does not need to be destroyed. ^The
3949 ** SQLITE_TRANSIENT value means that the content will likely change in
3950 ** the near future and that SQLite should make its own private copy of
3951 ** the content before returning.
3952 **
3953 ** The typedef is necessary to work around problems in certain
@@ -4012,11 +3956,11 @@
3956 typedef void (*sqlite3_destructor_type)(void*);
3957 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
3958 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
3959
3960 /*
3961 ** CAPI3REF: Setting The Result Of An SQL Function
3962 **
3963 ** These routines are used by the xFunc or xFinal callbacks that
3964 ** implement SQL functions and aggregates. See
3965 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
3966 ** for additional information.
@@ -4023,107 +3967,102 @@
3967 **
3968 ** These functions work very much like the [parameter binding] family of
3969 ** functions used to bind values to host parameters in prepared statements.
3970 ** Refer to the [SQL parameter] documentation for additional information.
3971 **
3972 ** ^The sqlite3_result_blob() interface sets the result from
3973 ** an application-defined function to be the BLOB whose content is pointed
3974 ** to by the second parameter and which is N bytes long where N is the
3975 ** third parameter.
3976 **
3977 ** ^The sqlite3_result_zeroblob() interfaces set the result of
3978 ** the application-defined function to be a BLOB containing all zero
3979 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
3980 **
3981 ** ^The sqlite3_result_double() interface sets the result from
3982 ** an application-defined function to be a floating point value specified
3983 ** by its 2nd argument.
3984 **
3985 ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
3986 ** cause the implemented SQL function to throw an exception.
3987 ** ^SQLite uses the string pointed to by the
3988 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
3989 ** as the text of an error message. ^SQLite interprets the error
3990 ** message string from sqlite3_result_error() as UTF-8. ^SQLite
3991 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
3992 ** byte order. ^If the third parameter to sqlite3_result_error()
3993 ** or sqlite3_result_error16() is negative then SQLite takes as the error
3994 ** message all text up through the first zero character.
3995 ** ^If the third parameter to sqlite3_result_error() or
3996 ** sqlite3_result_error16() is non-negative then SQLite takes that many
3997 ** bytes (not characters) from the 2nd parameter as the error message.
3998 ** ^The sqlite3_result_error() and sqlite3_result_error16()
3999 ** routines make a private copy of the error message text before
4000 ** they return. Hence, the calling function can deallocate or
4001 ** modify the text after they return without harm.
4002 ** ^The sqlite3_result_error_code() function changes the error code
4003 ** returned by SQLite as a result of an error in a function. ^By default,
4004 ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
4005 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
4006 **
4007 ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
4008 ** indicating that a string or BLOB is too long to represent.
4009 **
4010 ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
4011 ** indicating that a memory allocation failed.
4012 **
4013 ** ^The sqlite3_result_int() interface sets the return value
4014 ** of the application-defined function to be the 32-bit signed integer
4015 ** value given in the 2nd argument.
4016 ** ^The sqlite3_result_int64() interface sets the return value
4017 ** of the application-defined function to be the 64-bit signed integer
4018 ** value given in the 2nd argument.
4019 **
4020 ** ^The sqlite3_result_null() interface sets the return value
4021 ** of the application-defined function to be NULL.
4022 **
4023 ** ^The sqlite3_result_text(), sqlite3_result_text16(),
4024 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
4025 ** set the return value of the application-defined function to be
4026 ** a text string which is represented as UTF-8, UTF-16 native byte order,
4027 ** UTF-16 little endian, or UTF-16 big endian, respectively.
4028 ** ^SQLite takes the text result from the application from
4029 ** the 2nd parameter of the sqlite3_result_text* interfaces.
4030 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
4031 ** is negative, then SQLite takes result text from the 2nd parameter
4032 ** through the first zero character.
4033 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
4034 ** is non-negative, then as many bytes (not characters) of the text
4035 ** pointed to by the 2nd parameter are taken as the application-defined
4036 ** function result.
4037 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
4038 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
4039 ** function as the destructor on the text or BLOB result when it has
4040 ** finished using that result.
4041 ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
4042 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
4043 ** assumes that the text or BLOB result is in constant space and does not
4044 ** copy the content of the parameter nor call a destructor on the content
4045 ** when it has finished using that result.
4046 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
4047 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
4048 ** then SQLite makes a copy of the result into space obtained from
4049 ** from [sqlite3_malloc()] before it returns.
4050 **
4051 ** ^The sqlite3_result_value() interface sets the result of
4052 ** the application-defined function to be a copy the
4053 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
4054 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
4055 ** so that the [sqlite3_value] specified in the parameter may change or
4056 ** be deallocated after sqlite3_result_value() returns without harm.
4057 ** ^A [protected sqlite3_value] object may always be used where an
4058 ** [unprotected sqlite3_value] object is required, so either
4059 ** kind of [sqlite3_value] object can be used with this interface.
4060 **
4061 ** If these routines are called from within the different thread
4062 ** than the one containing the application-defined function that received
4063 ** the [sqlite3_context] pointer, the results are undefined.
 
 
 
 
 
4064 */
4065 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4066 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4067 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4068 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -4139,58 +4078,54 @@
4078 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4079 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4080 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4081
4082 /*
4083 ** CAPI3REF: Define New Collating Sequences
4084 **
4085 ** These functions are used to add new collation sequences to the
4086 ** [database connection] specified as the first argument.
4087 **
4088 ** ^The name of the new collation sequence is specified as a UTF-8 string
4089 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
4090 ** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
4091 ** the name is passed as the second function argument.
4092 **
4093 ** ^The third argument may be one of the constants [SQLITE_UTF8],
4094 ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
4095 ** routine expects to be passed pointers to strings encoded using UTF-8,
4096 ** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
4097 ** third argument might also be [SQLITE_UTF16] to indicate that the routine
4098 ** expects pointers to be UTF-16 strings in the native byte order, or the
4099 ** argument can be [SQLITE_UTF16_ALIGNED] if the
4100 ** the routine expects pointers to 16-bit word aligned strings
4101 ** of UTF-16 in the native byte order.
4102 **
4103 ** A pointer to the user supplied routine must be passed as the fifth
4104 ** argument. ^If it is NULL, this is the same as deleting the collation
4105 ** sequence (so that SQLite cannot call it anymore).
4106 ** ^Each time the application supplied function is invoked, it is passed
4107 ** as its first parameter a copy of the void* passed as the fourth argument
4108 ** to sqlite3_create_collation() or sqlite3_create_collation16().
4109 **
4110 ** ^The remaining arguments to the application-supplied routine are two strings,
4111 ** each represented by a (length, data) pair and encoded in the encoding
4112 ** that was passed as the third argument when the collation sequence was
4113 ** registered. The application defined collation routine should
4114 ** return negative, zero or positive if the first string is less than,
4115 ** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
4116 **
4117 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
4118 ** except that it takes an extra argument which is a destructor for
4119 ** the collation. ^The destructor is called when the collation is
4120 ** destroyed and is passed a copy of the fourth parameter void* pointer
4121 ** of the sqlite3_create_collation_v2().
4122 ** ^Collations are destroyed when they are overridden by later calls to the
4123 ** collation creation functions or when the [database connection] is closed
4124 ** using [sqlite3_close()].
4125 **
4126 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
 
 
 
 
4127 */
4128 SQLITE_API int sqlite3_create_collation(
4129 sqlite3*,
4130 const char *zName,
4131 int eTextRep,
@@ -4212,37 +4147,34 @@
4147 void*,
4148 int(*xCompare)(void*,int,const void*,int,const void*)
4149 );
4150
4151 /*
4152 ** CAPI3REF: Collation Needed Callbacks
4153 **
4154 ** ^To avoid having to register all collation sequences before a database
4155 ** can be used, a single callback function may be registered with the
4156 ** [database connection] to be invoked whenever an undefined collation
4157 ** sequence is required.
4158 **
4159 ** ^If the function is registered using the sqlite3_collation_needed() API,
4160 ** then it is passed the names of undefined collation sequences as strings
4161 ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
4162 ** the names are passed as UTF-16 in machine native byte order.
4163 ** ^A call to either function replaces the existing collation-needed callback.
4164 **
4165 ** ^(When the callback is invoked, the first argument passed is a copy
4166 ** of the second argument to sqlite3_collation_needed() or
4167 ** sqlite3_collation_needed16(). The second argument is the database
4168 ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
4169 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
4170 ** sequence function required. The fourth parameter is the name of the
4171 ** required collation sequence.)^
4172 **
4173 ** The callback function should register the desired collation using
4174 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4175 ** [sqlite3_create_collation_v2()].
 
 
 
4176 */
4177 SQLITE_API int sqlite3_collation_needed(
4178 sqlite3*,
4179 void*,
4180 void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -4277,33 +4209,32 @@
4209 sqlite3 *db, /* Database to be rekeyed */
4210 const void *pKey, int nKey /* The new key */
4211 );
4212
4213 /*
4214 ** CAPI3REF: Suspend Execution For A Short Time
4215 **
4216 ** ^The sqlite3_sleep() function causes the current thread to suspend execution
4217 ** for at least a number of milliseconds specified in its parameter.
4218 **
4219 ** ^If the operating system does not support sleep requests with
4220 ** millisecond time resolution, then the time will be rounded up to
4221 ** the nearest second. ^The number of milliseconds of sleep actually
4222 ** requested from the operating system is returned.
4223 **
4224 ** ^SQLite implements this interface by calling the xSleep()
4225 ** method of the default [sqlite3_vfs] object.
 
 
4226 */
4227 SQLITE_API int sqlite3_sleep(int);
4228
4229 /*
4230 ** CAPI3REF: Name Of The Folder Holding Temporary Files
4231 **
4232 ** ^(If this global variable is made to point to a string which is
4233 ** the name of a folder (a.k.a. directory), then all temporary files
4234 ** created by SQLite when using a built-in [sqlite3_vfs | VFS]
4235 ** will be placed in that directory.)^ ^If this variable
4236 ** is a NULL pointer, then SQLite performs a search for an appropriate
4237 ** temporary file directory.
4238 **
4239 ** It is not safe to read or modify this variable in more than one
4240 ** thread at a time. It is not safe to read or modify this variable
@@ -4312,12 +4243,12 @@
4243 ** It is intended that this variable be set once
4244 ** as part of process initialization and before any SQLite interface
4245 ** routines have been called and that this variable remain unchanged
4246 ** thereafter.
4247 **
4248 ** ^The [temp_store_directory pragma] may modify this variable and cause
4249 ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
4250 ** the [temp_store_directory pragma] always assumes that any string
4251 ** that this variable points to is held in memory obtained from
4252 ** [sqlite3_malloc] and the pragma may attempt to free that memory
4253 ** using [sqlite3_free].
4254 ** Hence, if this variable is modified directly, either it should be
@@ -4325,18 +4256,18 @@
4256 ** or else the use of the [temp_store_directory pragma] should be avoided.
4257 */
4258 SQLITE_API char *sqlite3_temp_directory;
4259
4260 /*
4261 ** CAPI3REF: Test For Auto-Commit Mode
4262 ** KEYWORDS: {autocommit mode}
4263 **
4264 ** ^The sqlite3_get_autocommit() interface returns non-zero or
4265 ** zero if the given database connection is or is not in autocommit mode,
4266 ** respectively. ^Autocommit mode is on by default.
4267 ** ^Autocommit mode is disabled by a [BEGIN] statement.
4268 ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
4269 **
4270 ** If certain kinds of errors occur on a statement within a multi-statement
4271 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
4272 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
4273 ** transaction might be rolled back automatically. The only way to
@@ -4344,124 +4275,116 @@
4275 ** an error is to use this function.
4276 **
4277 ** If another thread changes the autocommit status of the database
4278 ** connection while this routine is running, then the return value
4279 ** is undefined.
 
 
4280 */
4281 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4282
4283 /*
4284 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
4285 **
4286 ** ^The sqlite3_db_handle interface returns the [database connection] handle
4287 ** to which a [prepared statement] belongs. ^The [database connection]
4288 ** returned by sqlite3_db_handle is the same [database connection]
4289 ** that was the first argument
4290 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4291 ** create the statement in the first place.
 
 
4292 */
4293 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4294
4295 /*
4296 ** CAPI3REF: Find the next prepared statement
4297 **
4298 ** ^This interface returns a pointer to the next [prepared statement] after
4299 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
4300 ** then this interface returns a pointer to the first prepared statement
4301 ** associated with the database connection pDb. ^If no prepared statement
4302 ** satisfies the conditions of this routine, it returns NULL.
4303 **
4304 ** The [database connection] pointer D in a call to
4305 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4306 ** connection and in particular must not be a NULL pointer.
 
 
4307 */
4308 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4309
4310 /*
4311 ** CAPI3REF: Commit And Rollback Notification Callbacks
4312 **
4313 ** ^The sqlite3_commit_hook() interface registers a callback
4314 ** function to be invoked whenever a transaction is [COMMIT | committed].
4315 ** ^Any callback set by a previous call to sqlite3_commit_hook()
4316 ** for the same database connection is overridden.
4317 ** ^The sqlite3_rollback_hook() interface registers a callback
4318 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
4319 ** ^Any callback set by a previous call to sqlite3_rollback_hook()
4320 ** for the same database connection is overridden.
4321 ** ^The pArg argument is passed through to the callback.
4322 ** ^If the callback on a commit hook function returns non-zero,
4323 ** then the commit is converted into a rollback.
4324 **
4325 ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
4326 ** return the P argument from the previous call of the same function
4327 ** on the same [database connection] D, or NULL for
4328 ** the first call for each function on D.
4329 **
4330 ** The callback implementation must not do anything that will modify
4331 ** the database connection that invoked the callback. Any actions
4332 ** to modify the database connection must be deferred until after the
4333 ** completion of the [sqlite3_step()] call that triggered the commit
4334 ** or rollback hook in the first place.
4335 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4336 ** database connections for the meaning of "modify" in this paragraph.
4337 **
4338 ** ^Registering a NULL function disables the callback.
4339 **
4340 ** ^When the commit hook callback routine returns zero, the [COMMIT]
4341 ** operation is allowed to continue normally. ^If the commit hook
4342 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
4343 ** ^The rollback hook is invoked on a rollback that results from a commit
4344 ** hook returning non-zero, just as it would be with any other rollback.
4345 **
4346 ** ^For the purposes of this API, a transaction is said to have been
4347 ** rolled back if an explicit "ROLLBACK" statement is executed, or
4348 ** an error or constraint causes an implicit rollback to occur.
4349 ** ^The rollback callback is not invoked if a transaction is
4350 ** automatically rolled back because the database connection is closed.
4351 ** ^The rollback callback is not invoked if a transaction is
4352 ** rolled back because a commit callback returned non-zero.
 
4353 **
4354 ** See also the [sqlite3_update_hook()] interface.
 
 
 
 
4355 */
4356 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
4357 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
4358
4359 /*
4360 ** CAPI3REF: Data Change Notification Callbacks
4361 **
4362 ** ^The sqlite3_update_hook() interface registers a callback function
4363 ** with the [database connection] identified by the first argument
4364 ** to be invoked whenever a row is updated, inserted or deleted.
4365 ** ^Any callback set by a previous call to this function
4366 ** for the same database connection is overridden.
4367 **
4368 ** ^The second argument is a pointer to the function to invoke when a
4369 ** row is updated, inserted or deleted.
4370 ** ^The first argument to the callback is a copy of the third argument
4371 ** to sqlite3_update_hook().
4372 ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
4373 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
4374 ** to be invoked.
4375 ** ^The third and fourth arguments to the callback contain pointers to the
4376 ** database and table name containing the affected row.
4377 ** ^The final callback parameter is the [rowid] of the row.
4378 ** ^In the case of an update, this is the [rowid] after the update takes place.
4379 **
4380 ** ^(The update hook is not invoked when internal system tables are
4381 ** modified (i.e. sqlite_master and sqlite_sequence).)^
4382 **
4383 ** ^In the current implementation, the update hook
4384 ** is not invoked when duplication rows are deleted because of an
4385 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
4386 ** invoked when rows are deleted using the [truncate optimization].
4387 ** The exceptions defined in this paragraph might change in a future
4388 ** release of SQLite.
4389 **
4390 ** The update hook implementation must not do anything that will modify
@@ -4469,169 +4392,157 @@
4392 ** to modify the database connection must be deferred until after the
4393 ** completion of the [sqlite3_step()] call that triggered the update hook.
4394 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
4395 ** database connections for the meaning of "modify" in this paragraph.
4396 **
4397 ** ^The sqlite3_update_hook(D,C,P) function
4398 ** returns the P argument from the previous call
4399 ** on the same [database connection] D, or NULL for
4400 ** the first call on D.
4401 **
4402 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
4403 ** interfaces.
 
 
 
4404 */
4405 SQLITE_API void *sqlite3_update_hook(
4406 sqlite3*,
4407 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
4408 void*
4409 );
4410
4411 /*
4412 ** CAPI3REF: Enable Or Disable Shared Pager Cache
4413 ** KEYWORDS: {shared cache}
4414 **
4415 ** ^(This routine enables or disables the sharing of the database cache
4416 ** and schema data structures between [database connection | connections]
4417 ** to the same database. Sharing is enabled if the argument is true
4418 ** and disabled if the argument is false.)^
4419 **
4420 ** ^Cache sharing is enabled and disabled for an entire process.
4421 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
4422 ** sharing was enabled or disabled for each thread separately.
4423 **
4424 ** ^(The cache sharing mode set by this interface effects all subsequent
4425 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
4426 ** Existing database connections continue use the sharing mode
4427 ** that was in effect at the time they were opened.)^
4428 **
4429 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
4430 ** successfully. An [error code] is returned otherwise.)^
4431 **
4432 ** ^Shared cache is disabled by default. But this might change in
 
 
 
 
4433 ** future releases of SQLite. Applications that care about shared
4434 ** cache setting should set it explicitly.
4435 **
4436 ** See Also: [SQLite Shared-Cache Mode]
 
 
4437 */
4438 SQLITE_API int sqlite3_enable_shared_cache(int);
4439
4440 /*
4441 ** CAPI3REF: Attempt To Free Heap Memory
4442 **
4443 ** ^The sqlite3_release_memory() interface attempts to free N bytes
4444 ** of heap memory by deallocating non-essential memory allocations
4445 ** held by the database library. Memory used to cache database
4446 ** pages to improve performance is an example of non-essential memory.
4447 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
4448 ** which might be more or less than the amount requested.
 
 
4449 */
4450 SQLITE_API int sqlite3_release_memory(int);
4451
4452 /*
4453 ** CAPI3REF: Impose A Limit On Heap Size
4454 **
4455 ** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
4456 ** on the amount of heap memory that may be allocated by SQLite.
4457 ** ^If an internal allocation is requested that would exceed the
4458 ** soft heap limit, [sqlite3_release_memory()] is invoked one or
4459 ** more times to free up some space before the allocation is performed.
4460 **
4461 ** ^The limit is called "soft" because if [sqlite3_release_memory()]
4462 ** cannot free sufficient memory to prevent the limit from being exceeded,
4463 ** the memory is allocated anyway and the current operation proceeds.
4464 **
4465 ** ^A negative or zero value for N means that there is no soft heap limit and
4466 ** [sqlite3_release_memory()] will only be called when memory is exhausted.
4467 ** ^The default value for the soft heap limit is zero.
4468 **
4469 ** ^(SQLite makes a best effort to honor the soft heap limit.
4470 ** But if the soft heap limit cannot be honored, execution will
4471 ** continue without error or notification.)^ This is why the limit is
4472 ** called a "soft" limit. It is advisory only.
4473 **
4474 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
4475 ** allocated by a single thread - the same thread in which this routine
4476 ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
4477 ** applied to all threads. The value specified for the soft heap limit
4478 ** is an upper bound on the total memory allocation for all threads. In
4479 ** version 3.5.0 there is no mechanism for limiting the heap usage for
4480 ** individual threads.
 
 
 
4481 */
4482 SQLITE_API void sqlite3_soft_heap_limit(int);
4483
4484 /*
4485 ** CAPI3REF: Extract Metadata About A Column Of A Table
4486 **
4487 ** ^This routine returns metadata about a specific column of a specific
4488 ** database table accessible using the [database connection] handle
4489 ** passed as the first function argument.
4490 **
4491 ** ^The column is identified by the second, third and fourth parameters to
4492 ** this function. ^The second parameter is either the name of the database
4493 ** (i.e. "main", "temp", or an attached database) containing the specified
4494 ** table or NULL. ^If it is NULL, then all attached databases are searched
4495 ** for the table using the same algorithm used by the database engine to
4496 ** resolve unqualified table references.
4497 **
4498 ** ^The third and fourth parameters to this function are the table and column
4499 ** name of the desired column, respectively. Neither of these parameters
4500 ** may be NULL.
4501 **
4502 ** ^Metadata is returned by writing to the memory locations passed as the 5th
4503 ** and subsequent parameters to this function. ^Any of these arguments may be
4504 ** NULL, in which case the corresponding element of metadata is omitted.
4505 **
4506 ** ^(<blockquote>
4507 ** <table border="1">
4508 ** <tr><th> Parameter <th> Output<br>Type <th> Description
4509 **
4510 ** <tr><td> 5th <td> const char* <td> Data type
4511 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
4512 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
4513 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
4514 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
4515 ** </table>
4516 ** </blockquote>)^
4517 **
4518 ** ^The memory pointed to by the character pointers returned for the
4519 ** declaration type and collation sequence is valid only until the next
4520 ** call to any SQLite API function.
4521 **
4522 ** ^If the specified table is actually a view, an [error code] is returned.
4523 **
4524 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
4525 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4526 ** parameters are set for the explicitly declared column. ^(If there is no
4527 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
4528 ** parameters are set as follows:
4529 **
4530 ** <pre>
4531 ** data type: "INTEGER"
4532 ** collation sequence: "BINARY"
4533 ** not null: 0
4534 ** primary key: 1
4535 ** auto increment: 0
4536 ** </pre>)^
4537 **
4538 ** ^(This function may load one or more schemas from database files. If an
4539 ** error occurs during this process, or if the requested table or column
4540 ** cannot be found, an [error code] is returned and an error message left
4541 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
4542 **
4543 ** ^This API is only available if the library was compiled with the
4544 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
4545 */
4546 SQLITE_API int sqlite3_table_column_metadata(
4547 sqlite3 *db, /* Connection handle */
4548 const char *zDbName, /* Database name or NULL */
@@ -4643,34 +4554,31 @@
4554 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
4555 int *pAutoinc /* OUTPUT: True if column is auto-increment */
4556 );
4557
4558 /*
4559 ** CAPI3REF: Load An Extension
4560 **
4561 ** ^This interface loads an SQLite extension library from the named file.
4562 **
4563 ** ^The sqlite3_load_extension() interface attempts to load an
4564 ** SQLite extension library contained in the file zFile.
4565 **
4566 ** ^The entry point is zProc.
4567 ** ^zProc may be 0, in which case the name of the entry point
4568 ** defaults to "sqlite3_extension_init".
4569 ** ^The sqlite3_load_extension() interface returns
4570 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4571 ** ^If an error occurs and pzErrMsg is not 0, then the
4572 ** [sqlite3_load_extension()] interface shall attempt to
4573 ** fill *pzErrMsg with error message text stored in memory
4574 ** obtained from [sqlite3_malloc()]. The calling function
4575 ** should free this memory by calling [sqlite3_free()].
4576 **
4577 ** ^Extension loading must be enabled using
4578 ** [sqlite3_enable_load_extension()] prior to calling this API,
4579 ** otherwise an error will be returned.
 
 
 
4580 **
4581 ** See also the [load_extension() SQL function].
4582 */
4583 SQLITE_API int sqlite3_load_extension(
4584 sqlite3 *db, /* Load the extension into this database connection */
@@ -4678,65 +4586,53 @@
4586 const char *zProc, /* Entry point. Derived from zFile if 0 */
4587 char **pzErrMsg /* Put error message here if not 0 */
4588 );
4589
4590 /*
4591 ** CAPI3REF: Enable Or Disable Extension Loading
4592 **
4593 ** ^So as not to open security holes in older applications that are
4594 ** unprepared to deal with extension loading, and as a means of disabling
4595 ** extension loading while evaluating user-entered SQL, the following API
4596 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
4597 **
4598 ** ^Extension loading is off by default. See ticket #1863.
4599 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
4600 ** to turn extension loading on and call it with onoff==0 to turn
4601 ** it back off again.
 
 
 
4602 */
4603 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
4604
4605 /*
4606 ** CAPI3REF: Automatically Load An Extensions
4607 **
4608 ** ^This API can be invoked at program startup in order to register
4609 ** one or more statically linked extensions that will be available
4610 ** to all new [database connections].
4611 **
4612 ** ^(This routine stores a pointer to the extension entry point
4613 ** in an array that is obtained from [sqlite3_malloc()]. That memory
4614 ** is deallocated by [sqlite3_reset_auto_extension()].)^
4615 **
4616 ** ^This function registers an extension entry point that is
4617 ** automatically invoked whenever a new [database connection]
4618 ** is opened using [sqlite3_open()], [sqlite3_open16()],
4619 ** or [sqlite3_open_v2()].
4620 ** ^Duplicate extensions are detected so calling this routine
4621 ** multiple times with the same extension is harmless.
4622 ** ^Automatic extensions apply across all threads.
 
 
 
 
 
 
4623 */
4624 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
4625
4626 /*
4627 ** CAPI3REF: Reset Automatic Extension Loading
4628 **
4629 ** ^(This function disables all previously registered automatic
4630 ** extensions. It undoes the effect of all prior
4631 ** [sqlite3_auto_extension()] calls.)^
4632 **
4633 ** ^This function disables automatic extensions in all threads.
 
 
 
4634 */
4635 SQLITE_API void sqlite3_reset_auto_extension(void);
4636
4637 /*
4638 ****** EXPERIMENTAL - subject to change without notice **************
@@ -4756,22 +4652,22 @@
4652 typedef struct sqlite3_index_info sqlite3_index_info;
4653 typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
4654 typedef struct sqlite3_module sqlite3_module;
4655
4656 /*
4657 ** CAPI3REF: Virtual Table Object
4658 ** KEYWORDS: sqlite3_module {virtual table module}
4659 ** EXPERIMENTAL
4660 **
4661 ** This structure, sometimes called a a "virtual table module",
4662 ** defines the implementation of a [virtual tables].
4663 ** This structure consists mostly of methods for the module.
4664 **
4665 ** ^A virtual table module is created by filling in a persistent
4666 ** instance of this structure and passing a pointer to that instance
4667 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4668 ** ^The registration remains valid until it is replaced by a different
4669 ** module or until the [database connection] closes. The content
4670 ** of this structure must not change while it is registered with
4671 ** any database connection.
4672 */
4673 struct sqlite3_module {
@@ -4803,56 +4699,56 @@
4699 void **ppArg);
4700 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
4701 };
4702
4703 /*
4704 ** CAPI3REF: Virtual Table Indexing Information
4705 ** KEYWORDS: sqlite3_index_info
4706 ** EXPERIMENTAL
4707 **
4708 ** The sqlite3_index_info structure and its substructures is used to
4709 ** pass information into and receive the reply from the [xBestIndex]
4710 ** method of a [virtual table module]. The fields under **Inputs** are the
4711 ** inputs to xBestIndex and are read-only. xBestIndex inserts its
4712 ** results into the **Outputs** fields.
4713 **
4714 ** ^(The aConstraint[] array records WHERE clause constraints of the form:
4715 **
4716 ** <pre>column OP expr</pre>
4717 **
4718 ** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^ ^(The particular operator is
4719 ** stored in aConstraint[].op.)^ ^(The index of the column is stored in
4720 ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the
4721 ** expr on the right-hand side can be evaluated (and thus the constraint
4722 ** is usable) and false if it cannot.)^
4723 **
4724 ** ^The optimizer automatically inverts terms of the form "expr OP column"
4725 ** and makes other simplifications to the WHERE clause in an attempt to
4726 ** get as many WHERE clause terms into the form shown above as possible.
4727 ** ^The aConstraint[] array only reports WHERE clause terms that are
4728 ** relevant to the particular virtual table being queried.
4729 **
4730 ** ^Information about the ORDER BY clause is stored in aOrderBy[].
4731 ** ^Each term of aOrderBy records a column of the ORDER BY clause.
4732 **
4733 ** The [xBestIndex] method must fill aConstraintUsage[] with information
4734 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
4735 ** the right-hand side of the corresponding aConstraint[] is evaluated
4736 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
4737 ** is true, then the constraint is assumed to be fully handled by the
4738 ** virtual table and is not checked again by SQLite.)^
4739 **
4740 ** ^The idxNum and idxPtr values are recorded and passed into the
4741 ** [xFilter] method.
4742 ** ^[sqlite3_free()] is used to free idxPtr if and only if
4743 ** needToFreeIdxPtr is true.
4744 **
4745 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4746 ** the correct order to satisfy the ORDER BY clause so that no separate
4747 ** sorting step is required.
4748 **
4749 ** ^The estimatedCost value is an estimate of the cost of doing the
4750 ** particular lookup. A full scan of a table with N entries should have
4751 ** a cost of N. A binary search of a table of N entries should have a
4752 ** cost of approximately log(N).
4753 */
4754 struct sqlite3_index_info {
@@ -4886,70 +4782,63 @@
4782 #define SQLITE_INDEX_CONSTRAINT_LT 16
4783 #define SQLITE_INDEX_CONSTRAINT_GE 32
4784 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
4785
4786 /*
4787 ** CAPI3REF: Register A Virtual Table Implementation
4788 ** EXPERIMENTAL
4789 **
4790 ** ^These routines are used to register a new [virtual table module] name.
4791 ** ^Module names must be registered before
4792 ** creating a new [virtual table] using the module and before using a
4793 ** preexisting [virtual table] for the module.
4794 **
4795 ** ^The module name is registered on the [database connection] specified
4796 ** by the first parameter. ^The name of the module is given by the
4797 ** second parameter. ^The third parameter is a pointer to
4798 ** the implementation of the [virtual table module]. ^The fourth
4799 ** parameter is an arbitrary client data pointer that is passed through
4800 ** into the [xCreate] and [xConnect] methods of the virtual table module
4801 ** when a new virtual table is be being created or reinitialized.
4802 **
4803 ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
4804 ** is a pointer to a destructor for the pClientData. ^SQLite will
4805 ** invoke the destructor function (if it is not NULL) when SQLite
4806 ** no longer needs the pClientData pointer. ^The sqlite3_create_module()
4807 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
4808 ** destructor.
4809 */
4810 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
4811 sqlite3 *db, /* SQLite connection to register module with */
4812 const char *zName, /* Name of the module */
4813 const sqlite3_module *p, /* Methods for the module */
4814 void *pClientData /* Client data for xCreate/xConnect */
4815 );
 
 
 
 
 
 
 
 
 
 
 
4816 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
4817 sqlite3 *db, /* SQLite connection to register module with */
4818 const char *zName, /* Name of the module */
4819 const sqlite3_module *p, /* Methods for the module */
4820 void *pClientData, /* Client data for xCreate/xConnect */
4821 void(*xDestroy)(void*) /* Module destructor function */
4822 );
4823
4824 /*
4825 ** CAPI3REF: Virtual Table Instance Object
4826 ** KEYWORDS: sqlite3_vtab
4827 ** EXPERIMENTAL
4828 **
4829 ** Every [virtual table module] implementation uses a subclass
4830 ** of this object to describe a particular instance
4831 ** of the [virtual table]. Each subclass will
4832 ** be tailored to the specific needs of the module implementation.
4833 ** The purpose of this superclass is to define certain fields that are
4834 ** common to all module implementations.
4835 **
4836 ** ^Virtual tables methods can set an error message by assigning a
4837 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
4838 ** take care that any prior string is freed by a call to [sqlite3_free()]
4839 ** prior to assigning a new string to zErrMsg. ^After the error message
4840 ** is delivered up to the client application, the string will be automatically
4841 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
4842 */
4843 struct sqlite3_vtab {
4844 const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4957,20 +4846,20 @@
4846 char *zErrMsg; /* Error message from sqlite3_mprintf() */
4847 /* Virtual table implementations will typically add additional fields */
4848 };
4849
4850 /*
4851 ** CAPI3REF: Virtual Table Cursor Object
4852 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
4853 ** EXPERIMENTAL
4854 **
4855 ** Every [virtual table module] implementation uses a subclass of the
4856 ** following structure to describe cursors that point into the
4857 ** [virtual table] and are used
4858 ** to loop through the virtual table. Cursors are created using the
4859 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4860 ** by the [sqlite3_module.xClose | xClose] method. Cursors are used
4861 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
4862 ** of the module. Each module implementation will define
4863 ** the content of a cursor structure to suit its own needs.
4864 **
4865 ** This superclass exists in order to define fields of the cursor that
@@ -4980,32 +4869,32 @@
4869 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
4870 /* Virtual table implementations will typically add additional fields */
4871 };
4872
4873 /*
4874 ** CAPI3REF: Declare The Schema Of A Virtual Table
4875 ** EXPERIMENTAL
4876 **
4877 ** ^The [xCreate] and [xConnect] methods of a
4878 ** [virtual table module] call this interface
4879 ** to declare the format (the names and datatypes of the columns) of
4880 ** the virtual tables they implement.
4881 */
4882 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
4883
4884 /*
4885 ** CAPI3REF: Overload A Function For A Virtual Table
4886 ** EXPERIMENTAL
4887 **
4888 ** ^(Virtual tables can provide alternative implementations of functions
4889 ** using the [xFindFunction] method of the [virtual table module].
4890 ** But global versions of those functions
4891 ** must exist in order to be overloaded.)^
4892 **
4893 ** ^(This API makes sure a global version of a function with a particular
4894 ** name and number of parameters exists. If no such function exists
4895 ** before this API is called, a new function is created.)^ ^The implementation
4896 ** of the new function always causes an exception to be thrown. So
4897 ** the new function is not good for anything by itself. Its only
4898 ** purpose is to be a placeholder function that can be overloaded
4899 ** by a [virtual table].
4900 */
@@ -5022,81 +4911,78 @@
4911 **
4912 ****** EXPERIMENTAL - subject to change without notice **************
4913 */
4914
4915 /*
4916 ** CAPI3REF: A Handle To An Open BLOB
4917 ** KEYWORDS: {BLOB handle} {BLOB handles}
4918 **
4919 ** An instance of this object represents an open BLOB on which
4920 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
4921 ** ^Objects of this type are created by [sqlite3_blob_open()]
4922 ** and destroyed by [sqlite3_blob_close()].
4923 ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
4924 ** can be used to read or write small subsections of the BLOB.
4925 ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
4926 */
4927 typedef struct sqlite3_blob sqlite3_blob;
4928
4929 /*
4930 ** CAPI3REF: Open A BLOB For Incremental I/O
4931 **
4932 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
4933 ** in row iRow, column zColumn, table zTable in database zDb;
4934 ** in other words, the same BLOB that would be selected by:
4935 **
4936 ** <pre>
4937 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4938 ** </pre>)^
4939 **
4940 ** ^If the flags parameter is non-zero, then the BLOB is opened for read
4941 ** and write access. ^If it is zero, the BLOB is opened for read access.
4942 ** ^It is not possible to open a column that is part of an index or primary
4943 ** key for writing. ^If [foreign key constraints] are enabled, it is
4944 ** not possible to open a column that is part of a [child key] for writing.
4945 **
4946 ** ^Note that the database name is not the filename that contains
4947 ** the database but rather the symbolic name of the database that
4948 ** appears after the AS keyword when the database is connected using [ATTACH].
4949 ** ^For the main database file, the database name is "main".
4950 ** ^For TEMP tables, the database name is "temp".
4951 **
4952 ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
4953 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
4954 ** to be a null pointer.)^
4955 ** ^This function sets the [database connection] error code and message
4956 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
4957 ** functions. ^Note that the *ppBlob variable is always initialized in a
4958 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
4959 ** regardless of the success or failure of this routine.
4960 **
4961 ** ^(If the row that a BLOB handle points to is modified by an
4962 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
4963 ** then the BLOB handle is marked as "expired".
4964 ** This is true if any column of the row is changed, even a column
4965 ** other than the one the BLOB handle is open on.)^
4966 ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4967 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
4968 ** ^(Changes written into a BLOB prior to the BLOB expiring are not
4969 ** rolled back by the expiration of the BLOB. Such changes will eventually
4970 ** commit if the transaction continues to completion.)^
4971 **
4972 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
4973 ** the opened blob. ^The size of a blob may not be changed by this
4974 ** interface. Use the [UPDATE] SQL command to change the size of a
4975 ** blob.
4976 **
4977 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
4978 ** and the built-in [zeroblob] SQL function can be used, if desired,
4979 ** to create an empty, zero-filled blob in which to read or write using
4980 ** this interface.
4981 **
4982 ** To avoid a resource leak, every open [BLOB handle] should eventually
4983 ** be released by a call to [sqlite3_blob_close()].
 
 
 
4984 */
4985 SQLITE_API int sqlite3_blob_open(
4986 sqlite3*,
4987 const char *zDb,
4988 const char *zTable,
@@ -5105,201 +4991,185 @@
4991 int flags,
4992 sqlite3_blob **ppBlob
4993 );
4994
4995 /*
4996 ** CAPI3REF: Close A BLOB Handle
4997 **
4998 ** ^Closes an open [BLOB handle].
4999 **
5000 ** ^Closing a BLOB shall cause the current transaction to commit
5001 ** if there are no other BLOBs, no pending prepared statements, and the
5002 ** database connection is in [autocommit mode].
5003 ** ^If any writes were made to the BLOB, they might be held in cache
5004 ** until the close operation if they will fit.
5005 **
5006 ** ^(Closing the BLOB often forces the changes
5007 ** out to disk and so if any I/O errors occur, they will likely occur
5008 ** at the time when the BLOB is closed. Any errors that occur during
5009 ** closing are reported as a non-zero return value.)^
5010 **
5011 ** ^(The BLOB is closed unconditionally. Even if this routine returns
5012 ** an error code, the BLOB is still closed.)^
5013 **
5014 ** ^Calling this routine with a null pointer (such as would be returned
5015 ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
 
 
 
5016 */
5017 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5018
5019 /*
5020 ** CAPI3REF: Return The Size Of An Open BLOB
5021 **
5022 ** ^Returns the size in bytes of the BLOB accessible via the
5023 ** successfully opened [BLOB handle] in its only argument. ^The
5024 ** incremental blob I/O routines can only read or overwriting existing
5025 ** blob content; they cannot change the size of a blob.
5026 **
5027 ** This routine only works on a [BLOB handle] which has been created
5028 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5029 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5030 ** to this routine results in undefined and probably undesirable behavior.
 
 
 
5031 */
5032 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5033
5034 /*
5035 ** CAPI3REF: Read Data From A BLOB Incrementally
5036 **
5037 ** ^(This function is used to read data from an open [BLOB handle] into a
5038 ** caller-supplied buffer. N bytes of data are copied into buffer Z
5039 ** from the open BLOB, starting at offset iOffset.)^
5040 **
5041 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
5042 ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
5043 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
5044 ** ^The size of the blob (and hence the maximum value of N+iOffset)
5045 ** can be determined using the [sqlite3_blob_bytes()] interface.
5046 **
5047 ** ^An attempt to read from an expired [BLOB handle] fails with an
5048 ** error code of [SQLITE_ABORT].
5049 **
5050 ** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
5051 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5052 **
5053 ** This routine only works on a [BLOB handle] which has been created
5054 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5055 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5056 ** to this routine results in undefined and probably undesirable behavior.
5057 **
5058 ** See also: [sqlite3_blob_write()].
 
 
 
5059 */
5060 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5061
5062 /*
5063 ** CAPI3REF: Write Data Into A BLOB Incrementally
5064 **
5065 ** ^This function is used to write data into an open [BLOB handle] from a
5066 ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
5067 ** into the open BLOB, starting at offset iOffset.
5068 **
5069 ** ^If the [BLOB handle] passed as the first argument was not opened for
5070 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
5071 ** this function returns [SQLITE_READONLY].
5072 **
5073 ** ^This function may only modify the contents of the BLOB; it is
5074 ** not possible to increase the size of a BLOB using this API.
5075 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
5076 ** [SQLITE_ERROR] is returned and no data is written. ^If N is
5077 ** less than zero [SQLITE_ERROR] is returned and no data is written.
5078 ** The size of the BLOB (and hence the maximum value of N+iOffset)
5079 ** can be determined using the [sqlite3_blob_bytes()] interface.
5080 **
5081 ** ^An attempt to write to an expired [BLOB handle] fails with an
5082 ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
5083 ** before the [BLOB handle] expired are not rolled back by the
5084 ** expiration of the handle, though of course those changes might
5085 ** have been overwritten by the statement that expired the BLOB handle
5086 ** or by other independent statements.
5087 **
5088 ** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
5089 ** Otherwise, an [error code] or an [extended error code] is returned.)^
5090 **
5091 ** This routine only works on a [BLOB handle] which has been created
5092 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5093 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5094 ** to this routine results in undefined and probably undesirable behavior.
5095 **
5096 ** See also: [sqlite3_blob_read()].
 
 
 
 
5097 */
5098 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5099
5100 /*
5101 ** CAPI3REF: Virtual File System Objects
5102 **
5103 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
5104 ** that SQLite uses to interact
5105 ** with the underlying operating system. Most SQLite builds come with a
5106 ** single default VFS that is appropriate for the host computer.
5107 ** New VFSes can be registered and existing VFSes can be unregistered.
5108 ** The following interfaces are provided.
5109 **
5110 ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
5111 ** ^Names are case sensitive.
5112 ** ^Names are zero-terminated UTF-8 strings.
5113 ** ^If there is no match, a NULL pointer is returned.
5114 ** ^If zVfsName is NULL then the default VFS is returned.
5115 **
5116 ** ^New VFSes are registered with sqlite3_vfs_register().
5117 ** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
5118 ** ^The same VFS can be registered multiple times without injury.
5119 ** ^To make an existing VFS into the default VFS, register it again
5120 ** with the makeDflt flag set. If two different VFSes with the
5121 ** same name are registered, the behavior is undefined. If a
5122 ** VFS is registered with a name that is NULL or an empty string,
5123 ** then the behavior is undefined.
5124 **
5125 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
5126 ** ^(If the default VFS is unregistered, another VFS is chosen as
5127 ** the default. The choice for the new VFS is arbitrary.)^
 
 
 
5128 */
5129 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5130 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5131 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5132
5133 /*
5134 ** CAPI3REF: Mutexes
5135 **
5136 ** The SQLite core uses these routines for thread
5137 ** synchronization. Though they are intended for internal
5138 ** use by SQLite, code that links against SQLite is
5139 ** permitted to use any of these routines.
5140 **
5141 ** The SQLite source code contains multiple implementations
5142 ** of these mutex routines. An appropriate implementation
5143 ** is selected automatically at compile-time. ^(The following
5144 ** implementations are available in the SQLite core:
5145 **
5146 ** <ul>
5147 ** <li> SQLITE_MUTEX_OS2
5148 ** <li> SQLITE_MUTEX_PTHREAD
5149 ** <li> SQLITE_MUTEX_W32
5150 ** <li> SQLITE_MUTEX_NOOP
5151 ** </ul>)^
5152 **
5153 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
5154 ** that does no real locking and is appropriate for use in
5155 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
5156 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
5157 ** are appropriate for use on OS/2, Unix, and Windows.
5158 **
5159 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
5160 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
5161 ** implementation is included with the library. In this case the
5162 ** application must supply a custom mutex implementation using the
5163 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
5164 ** before calling sqlite3_initialize() or any other public sqlite3_
5165 ** function that calls sqlite3_initialize().)^
5166 **
5167 ** ^The sqlite3_mutex_alloc() routine allocates a new
5168 ** mutex and returns a pointer to it. ^If it returns NULL
5169 ** that means that a mutex could not be allocated. ^SQLite
5170 ** will unwind its stack and return an error. ^(The argument
5171 ** to sqlite3_mutex_alloc() is one of these integer constants:
5172 **
5173 ** <ul>
5174 ** <li> SQLITE_MUTEX_FAST
5175 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -5307,68 +5177,70 @@
5177 ** <li> SQLITE_MUTEX_STATIC_MEM
5178 ** <li> SQLITE_MUTEX_STATIC_MEM2
5179 ** <li> SQLITE_MUTEX_STATIC_PRNG
5180 ** <li> SQLITE_MUTEX_STATIC_LRU
5181 ** <li> SQLITE_MUTEX_STATIC_LRU2
5182 ** </ul>)^
5183 **
5184 ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
5185 ** cause sqlite3_mutex_alloc() to create
5186 ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
5187 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
5188 ** The mutex implementation does not need to make a distinction
5189 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
5190 ** not want to. ^SQLite will only request a recursive mutex in
5191 ** cases where it really needs one. ^If a faster non-recursive mutex
5192 ** implementation is available on the host platform, the mutex subsystem
5193 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
5194 **
5195 ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
5196 ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
5197 ** a pointer to a static preexisting mutex. ^Six static mutexes are
5198 ** used by the current version of SQLite. Future versions of SQLite
5199 ** may add additional static mutexes. Static mutexes are for internal
5200 ** use by SQLite only. Applications that use SQLite mutexes should
5201 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
5202 ** SQLITE_MUTEX_RECURSIVE.
5203 **
5204 ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
5205 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
5206 ** returns a different mutex on every call. ^But for the static
5207 ** mutex types, the same mutex is returned on every call that has
5208 ** the same type number.
5209 **
5210 ** ^The sqlite3_mutex_free() routine deallocates a previously
5211 ** allocated dynamic mutex. ^SQLite is careful to deallocate every
5212 ** dynamic mutex that it allocates. The dynamic mutexes must not be in
5213 ** use when they are deallocated. Attempting to deallocate a static
5214 ** mutex results in undefined behavior. ^SQLite never deallocates
5215 ** a static mutex.
5216 **
5217 ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
5218 ** to enter a mutex. ^If another thread is already within the mutex,
5219 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
5220 ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
5221 ** upon successful entry. ^(Mutexes created using
5222 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
5223 ** In such cases the,
5224 ** mutex must be exited an equal number of times before another thread
5225 ** can enter.)^ ^(If the same thread tries to enter any other
5226 ** kind of mutex more than once, the behavior is undefined.
5227 ** SQLite will never exhibit
5228 ** such behavior in its own use of mutexes.)^
5229 **
5230 ** ^(Some systems (for example, Windows 95) do not support the operation
5231 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
5232 ** will always return SQLITE_BUSY. The SQLite core only ever uses
5233 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
5234 **
5235 ** ^The sqlite3_mutex_leave() routine exits a mutex that was
5236 ** previously entered by the same thread. ^(The behavior
5237 ** is undefined if the mutex is not currently entered by the
5238 ** calling thread or is not currently allocated. SQLite will
5239 ** never do either.)^
5240 **
5241 ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
5242 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
5243 ** behave as no-ops.
5244 **
5245 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
5246 */
@@ -5377,11 +5249,11 @@
5249 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
5250 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
5251 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
5252
5253 /*
5254 ** CAPI3REF: Mutex Methods Object
5255 ** EXPERIMENTAL
5256 **
5257 ** An instance of this structure defines the low-level routines
5258 ** used to allocate and use mutexes.
5259 **
@@ -5393,23 +5265,23 @@
5265 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
5266 ** Additionally, an instance of this structure can be used as an
5267 ** output variable when querying the system for the current mutex
5268 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
5269 **
5270 ** ^The xMutexInit method defined by this structure is invoked as
5271 ** part of system initialization by the sqlite3_initialize() function.
5272 ** ^The xMutexInit routine is calle by SQLite exactly once for each
5273 ** effective call to [sqlite3_initialize()].
5274 **
5275 ** ^The xMutexEnd method defined by this structure is invoked as
5276 ** part of system shutdown by the sqlite3_shutdown() function. The
5277 ** implementation of this method is expected to release all outstanding
5278 ** resources obtained by the mutex methods implementation, especially
5279 ** those obtained by the xMutexInit method. ^The xMutexEnd()
5280 ** interface is invoked exactly once for each call to [sqlite3_shutdown()].
5281 **
5282 ** ^(The remaining seven methods defined by this structure (xMutexAlloc,
5283 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
5284 ** xMutexNotheld) implement the following interfaces (respectively):
5285 **
5286 ** <ul>
5287 ** <li> [sqlite3_mutex_alloc()] </li>
@@ -5417,31 +5289,31 @@
5289 ** <li> [sqlite3_mutex_enter()] </li>
5290 ** <li> [sqlite3_mutex_try()] </li>
5291 ** <li> [sqlite3_mutex_leave()] </li>
5292 ** <li> [sqlite3_mutex_held()] </li>
5293 ** <li> [sqlite3_mutex_notheld()] </li>
5294 ** </ul>)^
5295 **
5296 ** The only difference is that the public sqlite3_XXX functions enumerated
5297 ** above silently ignore any invocations that pass a NULL pointer instead
5298 ** of a valid mutex handle. The implementations of the methods defined
5299 ** by this structure are not required to handle this case, the results
5300 ** of passing a NULL pointer instead of a valid mutex handle are undefined
5301 ** (i.e. it is acceptable to provide an implementation that segfaults if
5302 ** it is passed a NULL pointer).
5303 **
5304 ** The xMutexInit() method must be threadsafe. ^It must be harmless to
5305 ** invoke xMutexInit() mutiple times within the same process and without
5306 ** intervening calls to xMutexEnd(). Second and subsequent calls to
5307 ** xMutexInit() must be no-ops.
5308 **
5309 ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
5310 ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
5311 ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
5312 ** memory allocation for a fast or recursive mutex.
5313 **
5314 ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
5315 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
5316 ** If xMutexInit fails in any way, it is expected to clean up after itself
5317 ** prior to returning.
5318 */
5319 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -5456,43 +5328,45 @@
5328 int (*xMutexHeld)(sqlite3_mutex *);
5329 int (*xMutexNotheld)(sqlite3_mutex *);
5330 };
5331
5332 /*
5333 ** CAPI3REF: Mutex Verification Routines
5334 **
5335 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
5336 ** are intended for use inside assert() statements. ^The SQLite core
5337 ** never uses these routines except inside an assert() and applications
5338 ** are advised to follow the lead of the core. ^The SQLite core only
5339 ** provides implementations for these routines when it is compiled
5340 ** with the SQLITE_DEBUG flag. ^External mutex implementations
5341 ** are only required to provide these routines if SQLITE_DEBUG is
5342 ** defined and if NDEBUG is not defined.
5343 **
5344 ** ^These routines should return true if the mutex in their argument
5345 ** is held or not held, respectively, by the calling thread.
5346 **
5347 ** ^The implementation is not required to provided versions of these
5348 ** routines that actually work. If the implementation does not provide working
5349 ** versions of these routines, it should at least provide stubs that always
5350 ** return true so that one does not get spurious assertion failures.
5351 **
5352 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
5353 ** the routine should return 1. This seems counter-intuitive since
5354 ** clearly the mutex cannot be held if it does not exist. But the
5355 ** the reason the mutex does not exist is because the build is not
5356 ** using mutexes. And we do not want the assert() containing the
5357 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
5358 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
5359 ** interface should also return 1 when given a NULL pointer.
5360 */
5361 #ifndef NDEBUG
5362 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
5363 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
5364 #endif
5365
5366 /*
5367 ** CAPI3REF: Mutex Types
5368 **
5369 ** The [sqlite3_mutex_alloc()] interface takes a single argument
5370 ** which is one of these integer constants.
5371 **
5372 ** The set of static mutexes may change from one SQLite release to the
@@ -5508,52 +5382,54 @@
5382 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
5383 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
5384 #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
5385
5386 /*
5387 ** CAPI3REF: Retrieve the mutex for a database connection
5388 **
5389 ** ^This interface returns a pointer the [sqlite3_mutex] object that
5390 ** serializes access to the [database connection] given in the argument
5391 ** when the [threading mode] is Serialized.
5392 ** ^If the [threading mode] is Single-thread or Multi-thread then this
5393 ** routine returns a NULL pointer.
5394 */
5395 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
5396
5397 /*
5398 ** CAPI3REF: Low-Level Control Of Database Files
5399 **
5400 ** ^The [sqlite3_file_control()] interface makes a direct call to the
5401 ** xFileControl method for the [sqlite3_io_methods] object associated
5402 ** with a particular database identified by the second argument. ^The
5403 ** name of the database "main" for the main database or "temp" for the
5404 ** TEMP database, or the name that appears after the AS keyword for
5405 ** databases that are added using the [ATTACH] SQL command.
5406 ** ^A NULL pointer can be used in place of "main" to refer to the
5407 ** main database file.
5408 ** ^The third and fourth parameters to this routine
5409 ** are passed directly through to the second and third parameters of
5410 ** the xFileControl method. ^The return value of the xFileControl
5411 ** method becomes the return value of this routine.
5412 **
5413 ** ^If the second parameter (zDbName) does not match the name of any
5414 ** open database file, then SQLITE_ERROR is returned. ^This error
5415 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
5416 ** or [sqlite3_errmsg()]. The underlying xFileControl method might
5417 ** also return SQLITE_ERROR. There is no way to distinguish between
5418 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
5419 ** xFileControl method.
5420 **
5421 ** See also: [SQLITE_FCNTL_LOCKSTATE]
5422 */
5423 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
5424
5425 /*
5426 ** CAPI3REF: Testing Interface
5427 **
5428 ** ^The sqlite3_test_control() interface is used to read out internal
5429 ** state of SQLite and to inject faults into SQLite for testing
5430 ** purposes. ^The first parameter is an operation code that determines
5431 ** the number, meaning, and operation of all subsequent parameters.
5432 **
5433 ** This interface is not for use by applications. It exists solely
5434 ** for verifying the correct operation of the SQLite library. Depending
5435 ** on how the SQLite library is compiled, this interface might not exist.
@@ -5564,20 +5440,21 @@
5440 ** operate consistently from one release to the next.
5441 */
5442 SQLITE_API int sqlite3_test_control(int op, ...);
5443
5444 /*
5445 ** CAPI3REF: Testing Interface Operation Codes
5446 **
5447 ** These constants are the valid operation code parameters used
5448 ** as the first argument to [sqlite3_test_control()].
5449 **
5450 ** These parameters and their meanings are subject to change
5451 ** without notice. These values are for testing purposes only.
5452 ** Applications should not use any of these parameters or the
5453 ** [sqlite3_test_control()] interface.
5454 */
5455 #define SQLITE_TESTCTRL_FIRST 5
5456 #define SQLITE_TESTCTRL_PRNG_SAVE 5
5457 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
5458 #define SQLITE_TESTCTRL_PRNG_RESET 7
5459 #define SQLITE_TESTCTRL_BITVEC_TEST 8
5460 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5584,31 +5461,34 @@
5461 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
5462 #define SQLITE_TESTCTRL_PENDING_BYTE 11
5463 #define SQLITE_TESTCTRL_ASSERT 12
5464 #define SQLITE_TESTCTRL_ALWAYS 13
5465 #define SQLITE_TESTCTRL_RESERVE 14
5466 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
5467 #define SQLITE_TESTCTRL_ISKEYWORD 16
5468 #define SQLITE_TESTCTRL_LAST 16
5469
5470 /*
5471 ** CAPI3REF: SQLite Runtime Status
5472 ** EXPERIMENTAL
5473 **
5474 ** ^This interface is used to retrieve runtime status information
5475 ** about the preformance of SQLite, and optionally to reset various
5476 ** highwater marks. ^The first argument is an integer code for
5477 ** the specific parameter to measure. ^(Recognized integer codes
5478 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
5479 ** ^The current value of the parameter is returned into *pCurrent.
5480 ** ^The highest recorded value is returned in *pHighwater. ^If the
5481 ** resetFlag is true, then the highest record value is reset after
5482 ** *pHighwater is written. ^(Some parameters do not record the highest
5483 ** value. For those parameters
5484 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
5485 ** ^(Other parameters record only the highwater mark and not the current
5486 ** value. For these latter parameters nothing is written into *pCurrent.)^
5487 **
5488 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
5489 ** non-zero [error code] on failure.
5490 **
5491 ** This routine is threadsafe but is not atomic. This routine can be
5492 ** called while other threads are running the same or different SQLite
5493 ** interfaces. However the values returned in *pCurrent and
5494 ** *pHighwater reflect the status of SQLite at different points in time
@@ -5619,82 +5499,82 @@
5499 */
5500 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
5501
5502
5503 /*
5504 ** CAPI3REF: Status Parameters
5505 ** EXPERIMENTAL
5506 **
5507 ** These integer constants designate various run-time status parameters
5508 ** that can be returned by [sqlite3_status()].
5509 **
5510 ** <dl>
5511 ** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
5512 ** <dd>This parameter is the current amount of memory checked out
5513 ** using [sqlite3_malloc()], either directly or indirectly. The
5514 ** figure includes calls made to [sqlite3_malloc()] by the application
5515 ** and internal memory usage by the SQLite library. Scratch memory
5516 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
5517 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
5518 ** this parameter. The amount returned is the sum of the allocation
5519 ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
5520 **
5521 ** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5522 ** <dd>This parameter records the largest memory allocation request
5523 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
5524 ** internal equivalents). Only the value returned in the
5525 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5526 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5527 **
5528 ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5529 ** <dd>This parameter returns the number of pages used out of the
5530 ** [pagecache memory allocator] that was configured using
5531 ** [SQLITE_CONFIG_PAGECACHE]. The
5532 ** value returned is in pages, not in bytes.</dd>)^
5533 **
5534 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5535 ** <dd>This parameter returns the number of bytes of page cache
5536 ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
5537 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
5538 ** returned value includes allocations that overflowed because they
5539 ** where too large (they were larger than the "sz" parameter to
5540 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5541 ** no space was left in the page cache.</dd>)^
5542 **
5543 ** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5544 ** <dd>This parameter records the largest memory allocation request
5545 ** handed to [pagecache memory allocator]. Only the value returned in the
5546 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5547 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5548 **
5549 ** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
5550 ** <dd>This parameter returns the number of allocations used out of the
5551 ** [scratch memory allocator] configured using
5552 ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
5553 ** in bytes. Since a single thread may only have one scratch allocation
5554 ** outstanding at time, this parameter also reports the number of threads
5555 ** using scratch memory at the same time.</dd>)^
5556 **
5557 ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5558 ** <dd>This parameter returns the number of bytes of scratch memory
5559 ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
5560 ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
5561 ** returned include overflows because the requested allocation was too
5562 ** larger (that is, because the requested allocation was larger than the
5563 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
5564 ** slots were available.
5565 ** </dd>)^
5566 **
5567 ** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5568 ** <dd>This parameter records the largest memory allocation request
5569 ** handed to [scratch memory allocator]. Only the value returned in the
5570 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5571 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5572 **
5573 ** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
5574 ** <dd>This parameter records the deepest parser stack. It is only
5575 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
5576 ** </dl>
5577 **
5578 ** New status parameters may be added from time to time.
5579 */
5580 #define SQLITE_STATUS_MEMORY_USED 0
@@ -5706,31 +5586,31 @@
5586 #define SQLITE_STATUS_PARSER_STACK 6
5587 #define SQLITE_STATUS_PAGECACHE_SIZE 7
5588 #define SQLITE_STATUS_SCRATCH_SIZE 8
5589
5590 /*
5591 ** CAPI3REF: Database Connection Status
5592 ** EXPERIMENTAL
5593 **
5594 ** ^This interface is used to retrieve runtime status information
5595 ** about a single [database connection]. ^The first argument is the
5596 ** database connection object to be interrogated. ^The second argument
5597 ** is the parameter to interrogate. ^Currently, the only allowed value
5598 ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
5599 ** Additional options will likely appear in future releases of SQLite.
5600 **
5601 ** ^The current value of the requested parameter is written into *pCur
5602 ** and the highest instantaneous value is written into *pHiwtr. ^If
5603 ** the resetFlg is true, then the highest instantaneous value is
5604 ** reset back down to the current value.
5605 **
5606 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
5607 */
5608 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
5609
5610 /*
5611 ** CAPI3REF: Status Parameters for database connections
5612 ** EXPERIMENTAL
5613 **
5614 ** These constants are the available integer "verbs" that can be passed as
5615 ** the second argument to the [sqlite3_db_status()] interface.
5616 **
@@ -5739,61 +5619,61 @@
5619 ** [sqlite3_db_status()] to make sure that the call worked.
5620 ** The [sqlite3_db_status()] interface will return a non-zero error code
5621 ** if a discontinued or unsupported verb is invoked.
5622 **
5623 ** <dl>
5624 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5625 ** <dd>This parameter returns the number of lookaside memory slots currently
5626 ** checked out.</dd>)^
5627 ** </dl>
5628 */
5629 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
5630
5631
5632 /*
5633 ** CAPI3REF: Prepared Statement Status
5634 ** EXPERIMENTAL
5635 **
5636 ** ^(Each prepared statement maintains various
5637 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5638 ** of times it has performed specific operations.)^ These counters can
5639 ** be used to monitor the performance characteristics of the prepared
5640 ** statements. For example, if the number of table steps greatly exceeds
5641 ** the number of table searches or result rows, that would tend to indicate
5642 ** that the prepared statement is using a full table scan rather than
5643 ** an index.
5644 **
5645 ** ^(This interface is used to retrieve and reset counter values from
5646 ** a [prepared statement]. The first argument is the prepared statement
5647 ** object to be interrogated. The second argument
5648 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5649 ** to be interrogated.)^
5650 ** ^The current value of the requested counter is returned.
5651 ** ^If the resetFlg is true, then the counter is reset to zero after this
5652 ** interface call returns.
5653 **
5654 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
5655 */
5656 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5657
5658 /*
5659 ** CAPI3REF: Status Parameters for prepared statements
5660 ** EXPERIMENTAL
5661 **
5662 ** These preprocessor macros define integer codes that name counter
5663 ** values associated with the [sqlite3_stmt_status()] interface.
5664 ** The meanings of the various counters are as follows:
5665 **
5666 ** <dl>
5667 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5668 ** <dd>^This is the number of times that SQLite has stepped forward in
5669 ** a table as part of a full table scan. Large numbers for this counter
5670 ** may indicate opportunities for performance improvement through
5671 ** careful use of indices.</dd>
5672 **
5673 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
5674 ** <dd>^This is the number of sort operations that have occurred.
5675 ** A non-zero value in this counter may indicate an opportunity to
5676 ** improvement performance through careful use of indices.</dd>
5677 **
5678 ** </dl>
5679 */
@@ -5817,84 +5697,84 @@
5697 /*
5698 ** CAPI3REF: Application Defined Page Cache.
5699 ** KEYWORDS: {page cache}
5700 ** EXPERIMENTAL
5701 **
5702 ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5703 ** register an alternative page cache implementation by passing in an
5704 ** instance of the sqlite3_pcache_methods structure.)^ The majority of the
5705 ** heap memory used by SQLite is used by the page cache to cache data read
5706 ** from, or ready to be written to, the database file. By implementing a
5707 ** custom page cache using this API, an application can control more
5708 ** precisely the amount of memory consumed by SQLite, the way in which
5709 ** that memory is allocated and released, and the policies used to
5710 ** determine exactly which parts of a database file are cached and for
5711 ** how long.
5712 **
5713 ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
5714 ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
5715 ** the application may discard the parameter after the call to
5716 ** [sqlite3_config()] returns.)^
5717 **
5718 ** ^The xInit() method is called once for each call to [sqlite3_initialize()]
5719 ** (usually only once during the lifetime of the process). ^(The xInit()
5720 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
5721 ** ^The xInit() method can set up up global structures and/or any mutexes
5722 ** required by the custom page cache implementation.
5723 **
5724 ** ^The xShutdown() method is called from within [sqlite3_shutdown()],
5725 ** if the application invokes this API. It can be used to clean up
5726 ** any outstanding resources before process shutdown, if required.
5727 **
5728 ** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5729 ** the xInit method, so the xInit method need not be threadsafe. ^The
5730 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
5731 ** not need to be threadsafe either. All other methods must be threadsafe
5732 ** in multithreaded applications.
5733 **
5734 ** ^SQLite will never invoke xInit() more than once without an intervening
5735 ** call to xShutdown().
5736 **
5737 ** ^The xCreate() method is used to construct a new cache instance. SQLite
5738 ** will typically create one cache instance for each open database file,
5739 ** though this is not guaranteed. ^The
5740 ** first parameter, szPage, is the size in bytes of the pages that must
5741 ** be allocated by the cache. ^szPage will not be a power of two. ^szPage
5742 ** will the page size of the database file that is to be cached plus an
5743 ** increment (here called "R") of about 100 or 200. ^SQLite will use the
5744 ** extra R bytes on each page to store metadata about the underlying
5745 ** database page on disk. The value of R depends
5746 ** on the SQLite version, the target platform, and how SQLite was compiled.
5747 ** ^R is constant for a particular build of SQLite. ^The second argument to
5748 ** xCreate(), bPurgeable, is true if the cache being created will
5749 ** be used to cache database pages of a file stored on disk, or
5750 ** false if it is used for an in-memory database. ^The cache implementation
5751 ** does not have to do anything special based with the value of bPurgeable;
5752 ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
5753 ** never invoke xUnpin() except to deliberately delete a page.
5754 ** ^In other words, a cache created with bPurgeable set to false will
5755 ** never contain any unpinned pages.
5756 **
5757 ** ^(The xCachesize() method may be called at any time by SQLite to set the
5758 ** suggested maximum cache-size (number of pages stored by) the cache
5759 ** instance passed as the first argument. This is the value configured using
5760 ** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable
5761 ** parameter, the implementation is not required to do anything with this
5762 ** value; it is advisory only.
5763 **
5764 ** ^The xPagecount() method should return the number of pages currently
5765 ** stored in the cache.
5766 **
5767 ** ^The xFetch() method is used to fetch a page and return a pointer to it.
5768 ** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
5769 ** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
5770 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5771 ** is considered to be "pinned".
5772 **
5773 ** ^If the requested page is already in the page cache, then the page cache
5774 ** implementation must return a pointer to the page buffer with its content
5775 ** intact. ^(If the requested page is not already in the cache, then the
5776 ** behavior of the cache implementation is determined by the value of the
5777 ** createFlag parameter passed to xFetch, according to the following table:
5778 **
5779 ** <table border=1 width=85% align=center>
5780 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5901,45 +5781,45 @@
5781 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
5782 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
5783 ** Otherwise return NULL.
5784 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
5785 ** NULL if allocating a new page is effectively impossible.
5786 ** </table>)^
5787 **
5788 ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
5789 ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
5790 ** attempt to unpin one or more cache pages by spilling the content of
5791 ** pinned pages to disk and synching the operating system disk cache. After
5792 ** attempting to unpin pages, the xFetch() method will be invoked again with
5793 ** a createFlag of 2.
5794 **
5795 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
5796 ** as its second argument. ^(If the third parameter, discard, is non-zero,
5797 ** then the page should be evicted from the cache. In this case SQLite
5798 ** assumes that the next time the page is retrieved from the cache using
5799 ** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
5800 ** zero, then the page is considered to be unpinned. ^The cache implementation
5801 ** may choose to evict unpinned pages at any time.
5802 **
5803 ** ^(The cache is not required to perform any reference counting. A single
5804 ** call to xUnpin() unpins the page regardless of the number of prior calls
5805 ** to xFetch().)^
5806 **
5807 ** ^The xRekey() method is used to change the key value associated with the
5808 ** page passed as the second argument from oldKey to newKey. ^If the cache
5809 ** previously contains an entry associated with newKey, it should be
5810 ** discarded. ^Any prior cache entry associated with newKey is guaranteed not
5811 ** to be pinned.
5812 **
5813 ** ^When SQLite calls the xTruncate() method, the cache must discard all
5814 ** existing cache entries with page numbers (keys) greater than or equal
5815 ** to the value of the iLimit parameter passed to xTruncate(). ^If any
5816 ** of these pages are pinned, they are implicitly unpinned, meaning that
5817 ** they can be safely discarded.
5818 **
5819 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
5820 ** All resources associated with the specified cache should be freed. ^After
5821 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
5822 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
5823 ** functions.
5824 */
5825 typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5960,11 +5840,11 @@
5840 /*
5841 ** CAPI3REF: Online Backup Object
5842 ** EXPERIMENTAL
5843 **
5844 ** The sqlite3_backup object records state information about an ongoing
5845 ** online backup operation. ^The sqlite3_backup object is created by
5846 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
5847 ** [sqlite3_backup_finish()].
5848 **
5849 ** See Also: [Using the SQLite Online Backup API]
5850 */
@@ -5972,168 +5852,173 @@
5852
5853 /*
5854 ** CAPI3REF: Online Backup API.
5855 ** EXPERIMENTAL
5856 **
5857 ** The backup API copies the content of one database into another.
5858 ** It is useful either for creating backups of databases or
5859 ** for copying in-memory databases to or from persistent files.
5860 **
5861 ** See Also: [Using the SQLite Online Backup API]
5862 **
5863 ** ^Exclusive access is required to the destination database for the
5864 ** duration of the operation. ^However the source database is only
5865 ** read-locked while it is actually being read; it is not locked
5866 ** continuously for the entire backup operation. ^Thus, the backup may be
5867 ** performed on a live source database without preventing other users from
5868 ** reading or writing to the source database while the backup is underway.
5869 **
5870 ** ^(To perform a backup operation:
5871 ** <ol>
5872 ** <li><b>sqlite3_backup_init()</b> is called once to initialize the
5873 ** backup,
5874 ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
5875 ** the data between the two databases, and finally
5876 ** <li><b>sqlite3_backup_finish()</b> is called to release all resources
5877 ** associated with the backup operation.
5878 ** </ol>)^
5879 ** There should be exactly one call to sqlite3_backup_finish() for each
5880 ** successful call to sqlite3_backup_init().
5881 **
5882 ** <b>sqlite3_backup_init()</b>
5883 **
5884 ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
5885 ** [database connection] associated with the destination database
5886 ** and the database name, respectively.
5887 ** ^The database name is "main" for the main database, "temp" for the
5888 ** temporary database, or the name specified after the AS keyword in
5889 ** an [ATTACH] statement for an attached database.
5890 ** ^The S and M arguments passed to
5891 ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
5892 ** and database name of the source database, respectively.
5893 ** ^The source and destination [database connections] (parameters S and D)
5894 ** must be different or else sqlite3_backup_init(D,N,S,M) will file with
5895 ** an error.
5896 **
5897 ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
5898 ** returned and an error code and error message are store3d in the
5899 ** destination [database connection] D.
5900 ** ^The error code and message for the failed call to sqlite3_backup_init()
5901 ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
5902 ** [sqlite3_errmsg16()] functions.
5903 ** ^A successful call to sqlite3_backup_init() returns a pointer to an
5904 ** [sqlite3_backup] object.
5905 ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
5906 ** sqlite3_backup_finish() functions to perform the specified backup
5907 ** operation.
5908 **
5909 ** <b>sqlite3_backup_step()</b>
5910 **
5911 ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
5912 ** the source and destination databases specified by [sqlite3_backup] object B.
5913 ** ^If N is negative, all remaining source pages are copied.
5914 ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
5915 ** are still more pages to be copied, then the function resturns [SQLITE_OK].
5916 ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
5917 ** from source to destination, then it returns [SQLITE_DONE].
5918 ** ^If an error occurs while running sqlite3_backup_step(B,N),
5919 ** then an [error code] is returned. ^As well as [SQLITE_OK] and
5920 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
5921 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
5922 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
5923 **
5924 ** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
5925 ** database was opened read-only or if
5926 ** the destination is an in-memory database with a different page size
5927 ** from the source database.
5928 **
5929 ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
5930 ** the [sqlite3_busy_handler | busy-handler function]
5931 ** is invoked (if one is specified). ^If the
5932 ** busy-handler returns non-zero before the lock is available, then
5933 ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
5934 ** sqlite3_backup_step() can be retried later. ^If the source
5935 ** [database connection]
5936 ** is being used to write to the source database when sqlite3_backup_step()
5937 ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
5938 ** case the call to sqlite3_backup_step() can be retried later on. ^(If
5939 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
5940 ** [SQLITE_READONLY] is returned, then
5941 ** there is no point in retrying the call to sqlite3_backup_step(). These
5942 ** errors are considered fatal.)^ The application must accept
5943 ** that the backup operation has failed and pass the backup operation handle
5944 ** to the sqlite3_backup_finish() to release associated resources.
5945 **
5946 ** ^The first call to sqlite3_backup_step() obtains an exclusive lock
5947 ** on the destination file. ^The exclusive lock is not released until either
5948 ** sqlite3_backup_finish() is called or the backup operation is complete
5949 ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to
5950 ** sqlite3_backup_step() obtains a [shared lock] on the source database that
5951 ** lasts for the duration of the sqlite3_backup_step() call.
5952 ** ^Because the source database is not locked between calls to
5953 ** sqlite3_backup_step(), the source database may be modified mid-way
5954 ** through the backup process. ^If the source database is modified by an
5955 ** external process or via a database connection other than the one being
5956 ** used by the backup operation, then the backup will be automatically
5957 ** restarted by the next call to sqlite3_backup_step(). ^If the source
5958 ** database is modified by the using the same database connection as is used
5959 ** by the backup operation, then the backup database is automatically
5960 ** updated at the same time.
5961 **
5962 ** <b>sqlite3_backup_finish()</b>
5963 **
5964 ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5965 ** application wishes to abandon the backup operation, the application
5966 ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
5967 ** ^The sqlite3_backup_finish() interfaces releases all
5968 ** resources associated with the [sqlite3_backup] object.
5969 ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
5970 ** active write-transaction on the destination database is rolled back.
5971 ** The [sqlite3_backup] object is invalid
5972 ** and may not be used following a call to sqlite3_backup_finish().
5973 **
5974 ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
5975 ** sqlite3_backup_step() errors occurred, regardless or whether or not
5976 ** sqlite3_backup_step() completed.
5977 ** ^If an out-of-memory condition or IO error occurred during any prior
5978 ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
5979 ** sqlite3_backup_finish() returns the corresponding [error code].
 
 
5980 **
5981 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
5982 ** is not a permanent error and does not affect the return value of
5983 ** sqlite3_backup_finish().
5984 **
5985 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
5986 **
5987 ** ^Each call to sqlite3_backup_step() sets two values inside
5988 ** the [sqlite3_backup] object: the number of pages still to be backed
5989 ** up and the total number of pages in the source databae file.
5990 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
5991 ** retrieve these two values, respectively.
5992 **
5993 ** ^The values returned by these functions are only updated by
5994 ** sqlite3_backup_step(). ^If the source database is modified during a backup
5995 ** operation, then the values are not updated to account for any extra
5996 ** pages that need to be updated or the size of the source database file
5997 ** changing.
5998 **
5999 ** <b>Concurrent Usage of Database Handles</b>
6000 **
6001 ** ^The source [database connection] may be used by the application for other
6002 ** purposes while a backup operation is underway or being initialized.
6003 ** ^If SQLite is compiled and configured to support threadsafe database
6004 ** connections, then the source database connection may be used concurrently
6005 ** from within other threads.
6006 **
6007 ** However, the application must guarantee that the destination
6008 ** [database connection] is not passed to any other API (by any thread) after
6009 ** sqlite3_backup_init() is called and before the corresponding call to
6010 ** sqlite3_backup_finish(). SQLite does not currently check to see
6011 ** if the application incorrectly accesses the destination [database connection]
6012 ** and so no error code is reported, but the operations may malfunction
6013 ** nevertheless. Use of the destination database connection while a
6014 ** backup is in progress might also also cause a mutex deadlock.
 
6015 **
6016 ** If running in [shared cache mode], the application must
6017 ** guarantee that the shared cache used by the destination database
6018 ** is not accessed while the backup is running. In practice this means
6019 ** that the application must guarantee that the disk file being
6020 ** backed up to is not accessed by any connection within the process,
6021 ** not just the specific connection that was passed to sqlite3_backup_init().
6022 **
6023 ** The [sqlite3_backup] object itself is partially threadsafe. Multiple
6024 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -6155,60 +6040,60 @@
6040
6041 /*
6042 ** CAPI3REF: Unlock Notification
6043 ** EXPERIMENTAL
6044 **
6045 ** ^When running in shared-cache mode, a database operation may fail with
6046 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
6047 ** individual tables within the shared-cache cannot be obtained. See
6048 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
6049 ** ^This API may be used to register a callback that SQLite will invoke
6050 ** when the connection currently holding the required lock relinquishes it.
6051 ** ^This API is only available if the library was compiled with the
6052 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
6053 **
6054 ** See Also: [Using the SQLite Unlock Notification Feature].
6055 **
6056 ** ^Shared-cache locks are released when a database connection concludes
6057 ** its current transaction, either by committing it or rolling it back.
6058 **
6059 ** ^When a connection (known as the blocked connection) fails to obtain a
6060 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
6061 ** identity of the database connection (the blocking connection) that
6062 ** has locked the required resource is stored internally. ^After an
6063 ** application receives an SQLITE_LOCKED error, it may call the
6064 ** sqlite3_unlock_notify() method with the blocked connection handle as
6065 ** the first argument to register for a callback that will be invoked
6066 ** when the blocking connections current transaction is concluded. ^The
6067 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
6068 ** call that concludes the blocking connections transaction.
6069 **
6070 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
6071 ** there is a chance that the blocking connection will have already
6072 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
6073 ** If this happens, then the specified callback is invoked immediately,
6074 ** from within the call to sqlite3_unlock_notify().)^
6075 **
6076 ** ^If the blocked connection is attempting to obtain a write-lock on a
6077 ** shared-cache table, and more than one other connection currently holds
6078 ** a read-lock on the same table, then SQLite arbitrarily selects one of
6079 ** the other connections to use as the blocking connection.
6080 **
6081 ** ^(There may be at most one unlock-notify callback registered by a
6082 ** blocked connection. If sqlite3_unlock_notify() is called when the
6083 ** blocked connection already has a registered unlock-notify callback,
6084 ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
6085 ** called with a NULL pointer as its second argument, then any existing
6086 ** unlock-notify callback is cancelled. ^The blocked connections
6087 ** unlock-notify callback may also be canceled by closing the blocked
6088 ** connection using [sqlite3_close()].
6089 **
6090 ** The unlock-notify callback is not reentrant. If an application invokes
6091 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
6092 ** crash or deadlock may be the result.
6093 **
6094 ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
6095 ** returns SQLITE_OK.
6096 **
6097 ** <b>Callback Invocation Details</b>
6098 **
6099 ** When an unlock-notify callback is registered, the application provides a
@@ -6218,11 +6103,11 @@
6103 ** an unlock-notify callback is a pointer to an array of void* pointers,
6104 ** and the second is the number of entries in the array.
6105 **
6106 ** When a blocking connections transaction is concluded, there may be
6107 ** more than one blocked connection that has registered for an unlock-notify
6108 ** callback. ^If two or more such blocked connections have specified the
6109 ** same callback function, then instead of invoking the callback function
6110 ** multiple times, it is invoked once with the set of void* context pointers
6111 ** specified by the blocked connections bundled together into an array.
6112 ** This gives the application an opportunity to prioritize any actions
6113 ** related to the set of unblocked database connections.
@@ -6236,20 +6121,20 @@
6121 ** connection Y's transaction to be concluded, and similarly connection
6122 ** Y is waiting on connection X's transaction, then neither connection
6123 ** will proceed and the system may remain deadlocked indefinitely.
6124 **
6125 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
6126 ** detection. ^If a given call to sqlite3_unlock_notify() would put the
6127 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
6128 ** unlock-notify callback is registered. The system is said to be in
6129 ** a deadlocked state if connection A has registered for an unlock-notify
6130 ** callback on the conclusion of connection B's transaction, and connection
6131 ** B has itself registered for an unlock-notify callback when connection
6132 ** A's transaction is concluded. ^Indirect deadlock is also detected, so
6133 ** the system is also considered to be deadlocked if connection B has
6134 ** registered for an unlock-notify callback on the conclusion of connection
6135 ** C's transaction, where connection C is waiting on connection A. ^Any
6136 ** number of levels of indirection are allowed.
6137 **
6138 ** <b>The "DROP TABLE" Exception</b>
6139 **
6140 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -6261,14 +6146,14 @@
6146 ** sqlite3_unlock_notify() results in the unlock-notify callback being
6147 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
6148 ** or "DROP INDEX" query, an infinite loop might be the result.
6149 **
6150 ** One way around this problem is to check the extended error code returned
6151 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
6152 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
6153 ** the special "DROP TABLE/INDEX" case, the extended error code is just
6154 ** SQLITE_LOCKED.)^
6155 */
6156 SQLITE_API int sqlite3_unlock_notify(
6157 sqlite3 *pBlocked, /* Waiting connection */
6158 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
6159 void *pNotifyArg /* Argument to pass to xNotify */
@@ -6277,11 +6162,11 @@
6162
6163 /*
6164 ** CAPI3REF: String Comparison
6165 ** EXPERIMENTAL
6166 **
6167 ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
6168 ** compare the contents of two buffers containing UTF-8 strings in a
6169 ** case-indendent fashion, using the same definition of case independence
6170 ** that SQLite uses internally when comparing identifiers.
6171 */
6172 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
@@ -6507,34 +6392,34 @@
6392 #define TK_UNIQUE 100
6393 #define TK_CHECK 101
6394 #define TK_REFERENCES 102
6395 #define TK_AUTOINCR 103
6396 #define TK_ON 104
6397 #define TK_INSERT 105
6398 #define TK_DELETE 106
6399 #define TK_UPDATE 107
6400 #define TK_SET 108
6401 #define TK_DEFERRABLE 109
6402 #define TK_FOREIGN 110
6403 #define TK_DROP 111
6404 #define TK_UNION 112
6405 #define TK_ALL 113
6406 #define TK_EXCEPT 114
6407 #define TK_INTERSECT 115
6408 #define TK_SELECT 116
6409 #define TK_DISTINCT 117
6410 #define TK_DOT 118
6411 #define TK_FROM 119
6412 #define TK_JOIN 120
6413 #define TK_USING 121
6414 #define TK_ORDER 122
6415 #define TK_GROUP 123
6416 #define TK_HAVING 124
6417 #define TK_LIMIT 125
6418 #define TK_WHERE 126
6419 #define TK_INTO 127
6420 #define TK_VALUES 128
6421 #define TK_INTEGER 129
6422 #define TK_FLOAT 130
6423 #define TK_BLOB 131
6424 #define TK_REGISTER 132
6425 #define TK_VARIABLE 133
@@ -8506,41 +8391,47 @@
8391 ** A macro to discover the encoding of a database.
8392 */
8393 #define ENC(db) ((db)->aDb[0].pSchema->enc)
8394
8395 /*
8396 ** Possible values for the sqlite3.flags.
 
 
 
 
8397 */
8398 #define SQLITE_VdbeTrace 0x00000100 /* True to trace VDBE execution */
8399 #define SQLITE_InternChanges 0x00000200 /* Uncommitted Hash table changes */
8400 #define SQLITE_FullColNames 0x00000400 /* Show full column names on SELECT */
8401 #define SQLITE_ShortColNames 0x00000800 /* Show short columns names */
8402 #define SQLITE_CountRows 0x00001000 /* Count rows changed by INSERT, */
 
8403 /* DELETE, or UPDATE and return */
8404 /* the count using a callback. */
8405 #define SQLITE_NullCallback 0x00002000 /* Invoke the callback once if the */
8406 /* result set is empty */
8407 #define SQLITE_SqlTrace 0x00004000 /* Debug print SQL as it executes */
8408 #define SQLITE_VdbeListing 0x00008000 /* Debug listings of VDBE programs */
8409 #define SQLITE_WriteSchema 0x00010000 /* OK to update SQLITE_MASTER */
8410 #define SQLITE_NoReadlock 0x00020000 /* Readlocks are omitted when
8411 ** accessing read-only databases */
8412 #define SQLITE_IgnoreChecks 0x00040000 /* Do not enforce check constraints */
8413 #define SQLITE_ReadUncommitted 0x0080000 /* For shared-cache mode */
8414 #define SQLITE_LegacyFileFmt 0x00100000 /* Create new databases in format 1 */
8415 #define SQLITE_FullFSync 0x00200000 /* Use full fsync on the backend */
8416 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
8417 #define SQLITE_RecoveryMode 0x00800000 /* Ignore schema errors */
8418 #define SQLITE_ReverseOrder 0x01000000 /* Reverse unordered SELECTs */
8419 #define SQLITE_RecTriggers 0x02000000 /* Enable recursive triggers */
8420 #define SQLITE_ForeignKeys 0x04000000 /* Enforce foreign key constraints */
8421
8422 /*
8423 ** Bits of the sqlite3.flags field that are used by the
8424 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface.
8425 ** These must be the low-order bits of the flags field.
8426 */
8427 #define SQLITE_QueryFlattener 0x01 /* Disable query flattening */
8428 #define SQLITE_ColumnCache 0x02 /* Disable the column cache */
8429 #define SQLITE_IndexSort 0x04 /* Disable indexes for sorting */
8430 #define SQLITE_IndexSearch 0x08 /* Disable indexes for searching */
8431 #define SQLITE_IndexCover 0x10 /* Disable index covering table */
8432 #define SQLITE_OptMask 0x1f /* Mask of all disablable opts */
8433
8434 /*
8435 ** Possible values for the sqlite.magic field.
8436 ** The numbers are obtained at random and have no special meaning, other
8437 ** than being distinct from one another.
@@ -9250,18 +9141,17 @@
9141 #define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */
9142 #define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */
9143 #define EP_DblQuoted 0x0040 /* token.z was originally in "..." */
9144 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
9145 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
9146 #define EP_FixedDest 0x0200 /* Result needed in a specific register */
9147 #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
9148 #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
9149
9150 #define EP_Reduced 0x1000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
9151 #define EP_TokenOnly 0x2000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
9152 #define EP_Static 0x4000 /* Held in memory not obtained from malloc() */
 
9153
9154 /*
9155 ** The following are the meanings of bits in the Expr.flags2 field.
9156 */
9157 #define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */
@@ -9502,10 +9392,11 @@
9392 #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */
9393 #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */
9394 #define WHERE_OMIT_OPEN 0x0010 /* Table cursor are already open */
9395 #define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */
9396 #define WHERE_FORCE_TABLE 0x0040 /* Do not use an index-only search */
9397 #define WHERE_ONETABLE_ONLY 0x0080 /* Only code the 1st table in pTabList */
9398
9399 /*
9400 ** The WHERE clause processing routine has two halves. The
9401 ** first part does the start of the WHERE loop and the second
9402 ** half does the tail of the WHERE loop. An instance of
@@ -9514,10 +9405,11 @@
9405 */
9406 struct WhereInfo {
9407 Parse *pParse; /* Parsing and code generating context */
9408 u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */
9409 u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */
9410 u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */
9411 SrcList *pTabList; /* List of tables in the join */
9412 int iTop; /* The very beginning of the WHERE loop */
9413 int iContinue; /* Jump here to continue with next record */
9414 int iBreak; /* Jump here to break out of the loop */
9415 int nLevel; /* Number of nested loop */
@@ -9733,11 +9625,10 @@
9625 u8 nColCache; /* Number of entries in the column cache */
9626 u8 iColCache; /* Next entry of the cache to replace */
9627 struct yColCache {
9628 int iTable; /* Table cursor number */
9629 int iColumn; /* Table column number */
 
9630 u8 tempReg; /* iReg is a temp register that needs to be freed */
9631 int iLevel; /* Nesting level */
9632 int iReg; /* Reg with value of this column. 0 means none. */
9633 int lru; /* Least recently used entry has the smallest value */
9634 } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */
@@ -10252,17 +10143,17 @@
10143 #endif
10144 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
10145 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
10146 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16);
10147 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
10148 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
10149 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
10150 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
10151 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
10152 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
10153 SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int);
10154 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int);
10155 SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*);
10156 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int);
10157 SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse*,int,int);
10158 SQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int);
10159 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
@@ -48266,22 +48157,25 @@
48157 **
48158 ** When p->explain==1, each instruction is listed. When
48159 ** p->explain==2, only OP_Explain instructions are listed and these
48160 ** are shown in a different format. p->explain==2 is used to implement
48161 ** EXPLAIN QUERY PLAN.
48162 **
48163 ** When p->explain==1, first the main program is listed, then each of
48164 ** the trigger subprograms are listed one by one.
48165 */
48166 SQLITE_PRIVATE int sqlite3VdbeList(
48167 Vdbe *p /* The VDBE */
48168 ){
48169 int nRow; /* Stop when row count reaches this */
48170 int nSub = 0; /* Number of sub-vdbes seen so far */
48171 SubProgram **apSub = 0; /* Array of sub-vdbes */
48172 Mem *pSub = 0; /* Memory cell hold array of subprogs */
48173 sqlite3 *db = p->db; /* The database connection */
48174 int i; /* Loop counter */
48175 int rc = SQLITE_OK; /* Return code */
48176 Mem *pMem = p->pResultSet = &p->aMem[1]; /* First Mem of result set */
48177
48178 assert( p->explain );
48179 assert( p->magic==VDBE_MAGIC_RUN );
48180 assert( db->magic==SQLITE_MAGIC_BUSY );
48181 assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM );
@@ -48297,16 +48191,28 @@
48191 ** sqlite3_column_text16() failed. */
48192 db->mallocFailed = 1;
48193 return SQLITE_ERROR;
48194 }
48195
48196 /* When the number of output rows reaches nRow, that means the
48197 ** listing has finished and sqlite3_step() should return SQLITE_DONE.
48198 ** nRow is the sum of the number of rows in the main program, plus
48199 ** the sum of the number of rows in all trigger subprograms encountered
48200 ** so far. The nRow value will increase as new trigger subprograms are
48201 ** encountered, but p->pc will eventually catch up to nRow.
48202 */
48203 nRow = p->nOp;
48204 if( p->explain==1 ){
48205 /* The first 8 memory cells are used for the result set. So we will
48206 ** commandeer the 9th cell to use as storage for an array of pointers
48207 ** to trigger subprograms. The VDBE is guaranteed to have at least 9
48208 ** cells. */
48209 assert( p->nMem>9 );
48210 pSub = &p->aMem[9];
48211 if( pSub->flags&MEM_Blob ){
48212 /* On the first call to sqlite3_step(), pSub will hold a NULL. It is
48213 ** initialized to a BLOB by the P4_SUBPROGRAM processing logic below */
48214 nSub = pSub->n/sizeof(Vdbe*);
48215 apSub = (SubProgram **)pSub->z;
48216 }
48217 for(i=0; i<nSub; i++){
48218 nRow += apSub[i]->nOp;
@@ -48325,12 +48231,16 @@
48231 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc));
48232 }else{
48233 char *z;
48234 Op *pOp;
48235 if( i<p->nOp ){
48236 /* The output line number is small enough that we are still in the
48237 ** main program. */
48238 pOp = &p->aOp[i];
48239 }else{
48240 /* We are currently listing subprograms. Figure out which one and
48241 ** pick up the appropriate opcode. */
48242 int j;
48243 i -= p->nOp;
48244 for(j=0; i>=apSub[j]->nOp; j++){
48245 i -= apSub[j]->nOp;
48246 }
@@ -48348,10 +48258,15 @@
48258 pMem->n = sqlite3Strlen30(pMem->z);
48259 pMem->type = SQLITE_TEXT;
48260 pMem->enc = SQLITE_UTF8;
48261 pMem++;
48262
48263 /* When an OP_Program opcode is encounter (the only opcode that has
48264 ** a P4_SUBPROGRAM argument), expand the size of the array of subprograms
48265 ** kept in p->aMem[9].z to hold the new program - assuming this subprogram
48266 ** has not already been seen.
48267 */
48268 if( pOp->p4type==P4_SUBPROGRAM ){
48269 int nByte = (nSub+1)*sizeof(SubProgram*);
48270 int j;
48271 for(j=0; j<nSub; j++){
48272 if( apSub[j]==pOp->p4.pProgram ) break;
@@ -48479,42 +48394,47 @@
48394 }
48395 }
48396 #endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */
48397
48398 /*
48399 ** Allocate space from a fixed size buffer and return a pointer to
48400 ** that space. If insufficient space is available, return NULL.
48401 **
48402 ** The pBuf parameter is the initial value of a pointer which will
48403 ** receive the new memory. pBuf is normally NULL. If pBuf is not
48404 ** NULL, it means that memory space has already been allocated and that
48405 ** this routine should not allocate any new memory. When pBuf is not
48406 ** NULL simply return pBuf. Only allocate new memory space when pBuf
48407 ** is NULL.
48408 **
48409 ** nByte is the number of bytes of space needed.
48410 **
48411 ** *ppFrom points to available space and pEnd points to the end of the
48412 ** available space. When space is allocated, *ppFrom is advanced past
48413 ** the end of the allocated space.
48414 **
48415 ** *pnByte is a counter of the number of bytes of space that have failed
48416 ** to allocate. If there is insufficient space in *ppFrom to satisfy the
48417 ** request, then increment *pnByte by the amount of the request.
48418 */
48419 static void *allocSpace(
48420 void *pBuf, /* Where return pointer will be stored */
48421 int nByte, /* Number of bytes to allocate */
48422 u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */
48423 u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */
48424 int *pnByte /* If allocation cannot be made, increment *pnByte */
48425 ){
48426 assert( EIGHT_BYTE_ALIGNMENT(*ppFrom) );
48427 if( pBuf ) return pBuf;
48428 nByte = ROUND8(nByte);
48429 if( &(*ppFrom)[nByte] <= pEnd ){
48430 pBuf = (void*)*ppFrom;
48431 *ppFrom += nByte;
48432 }else{
48433 *pnByte += nByte;
48434 }
48435 return pBuf;
48436 }
48437
48438 /*
48439 ** Prepare a virtual machine for execution. This involves things such
48440 ** as allocating stack space and initializing the program counter.
@@ -48569,31 +48489,41 @@
48489 ** an array to marshal SQL function arguments in. This is only done the
48490 ** first time this function is called for a given VDBE, not when it is
48491 ** being called from sqlite3_reset() to reset the virtual machine.
48492 */
48493 if( nVar>=0 && ALWAYS(db->mallocFailed==0) ){
48494 u8 *zCsr = (u8 *)&p->aOp[p->nOp]; /* Memory avaliable for alloation */
48495 u8 *zEnd = (u8 *)&p->aOp[p->nOpAlloc]; /* First byte past available mem */
48496 int nByte; /* How much extra memory needed */
48497
48498 resolveP2Values(p, &nArg);
48499 p->usesStmtJournal = (u8)usesStmtJournal;
48500 if( isExplain && nMem<10 ){
48501 nMem = 10;
48502 }
48503 memset(zCsr, 0, zEnd-zCsr);
48504 zCsr += (zCsr - (u8*)0)&7;
48505 assert( EIGHT_BYTE_ALIGNMENT(zCsr) );
48506
48507 /* Memory for registers, parameters, cursor, etc, is allocated in two
48508 ** passes. On the first pass, we try to reuse unused space at the
48509 ** end of the opcode array. If we are unable to satisfy all memory
48510 ** requirements by reusing the opcode array tail, then the second
48511 ** pass will fill in the rest using a fresh allocation.
48512 **
48513 ** This two-pass approach that reuses as much memory as possible from
48514 ** the leftover space at the end of the opcode array can significantly
48515 ** reduce the amount of memory held by a prepared statement.
48516 */
48517 do {
48518 nByte = 0;
48519 p->aMem = allocSpace(p->aMem, nMem*sizeof(Mem), &zCsr, zEnd, &nByte);
48520 p->aVar = allocSpace(p->aVar, nVar*sizeof(Mem), &zCsr, zEnd, &nByte);
48521 p->apArg = allocSpace(p->apArg, nArg*sizeof(Mem*), &zCsr, zEnd, &nByte);
48522 p->azVar = allocSpace(p->azVar, nVar*sizeof(char*), &zCsr, zEnd, &nByte);
48523 p->apCsr = allocSpace(p->apCsr, nCursor*sizeof(VdbeCursor*),
48524 &zCsr, zEnd, &nByte);
 
48525 if( nByte ){
48526 p->pFree = sqlite3DbMallocZero(db, nByte);
48527 }
48528 zCsr = p->pFree;
48529 zEnd = &zCsr[nByte];
@@ -48931,14 +48861,15 @@
48861 ** still have 'null' as the master journal pointer, so they will roll
48862 ** back independently if a failure occurs.
48863 */
48864 for(i=0; i<db->nDb; i++){
48865 Btree *pBt = db->aDb[i].pBt;
 
48866 if( sqlite3BtreeIsInTrans(pBt) ){
48867 char const *zFile = sqlite3BtreeGetJournalname(pBt);
48868 if( zFile==0 || zFile[0]==0 ){
48869 continue; /* Ignore TEMP and :memory: databases */
48870 }
48871 if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){
48872 needSync = 1;
48873 }
48874 rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset);
48875 offset += sqlite3Strlen30(zFile)+1;
@@ -50780,12 +50711,13 @@
50711 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
50712 Mem *pMem;
50713 assert( p && p->pFunc && p->pFunc->xStep );
50714 assert( sqlite3_mutex_held(p->s.db->mutex) );
50715 pMem = p->pMem;
50716 testcase( nByte<0 );
50717 if( (pMem->flags & MEM_Agg)==0 ){
50718 if( nByte<=0 ){
50719 sqlite3VdbeMemReleaseExternal(pMem);
50720 pMem->flags = MEM_Null;
50721 pMem->z = 0;
50722 }else{
50723 sqlite3VdbeMemGrow(pMem, nByte, 0);
@@ -55878,19 +55810,19 @@
55810 rc = sqlite3BtreeLast(u.be.pC->pCursor, &u.be.res);
55811 if( rc!=SQLITE_OK ){
55812 goto abort_due_to_error;
55813 }
55814 if( u.be.res ){
55815 u.be.v = 1; /* IMP: R-61914-48074 */
55816 }else{
55817 assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) );
55818 rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v);
55819 assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */
55820 if( u.be.v==MAX_ROWID ){
55821 u.be.pC->useRandomRowid = 1;
55822 }else{
55823 u.be.v++; /* IMP: R-29538-34987 */
55824 }
55825 }
55826 }
55827
55828 #ifndef SQLITE_OMIT_AUTOINCREMENT
@@ -55910,11 +55842,11 @@
55842
55843 REGISTER_TRACE(pOp->p3, u.be.pMem);
55844 sqlite3VdbeMemIntegerify(u.be.pMem);
55845 assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */
55846 if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){
55847 rc = SQLITE_FULL; /* IMP: R-12275-61338 */
55848 goto abort_due_to_error;
55849 }
55850 if( u.be.v<u.be.pMem->u.i+1 ){
55851 u.be.v = u.be.pMem->u.i + 1;
55852 }
@@ -55923,10 +55855,15 @@
55855 #endif
55856
55857 sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0);
55858 }
55859 if( u.be.pC->useRandomRowid ){
55860 /* IMPLEMENTATION-OF: R-48598-02938 If the largest ROWID is equal to the
55861 ** largest possible integer (9223372036854775807) then the database
55862 ** engine starts picking candidate ROWIDs at random until it finds one
55863 ** that is not previously used.
55864 */
55865 assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
55866 ** an AUTOINCREMENT table. */
55867 u.be.v = db->lastRowid;
55868 u.be.cnt = 0;
55869 do{
@@ -55938,11 +55875,11 @@
55875 }
55876 rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res);
55877 u.be.cnt++;
55878 }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 );
55879 if( rc==SQLITE_OK && u.be.res==0 ){
55880 rc = SQLITE_FULL; /* IMP: R-38219-53002 */
55881 goto abort_due_to_error;
55882 }
55883 }
55884 u.be.pC->rowidIsValid = 0;
55885 u.be.pC->deferredMoveto = 0;
@@ -59317,22 +59254,21 @@
59254
59255 if( pTab ){
59256 int iCol;
59257 pSchema = pTab->pSchema;
59258 cntTab++;
59259 for(iCol=0; iCol<pTab->nCol; iCol++){
59260 Column *pCol = &pTab->aCol[iCol];
59261 if( sqlite3StrICmp(pCol->zName, zCol)==0 ){
59262 if( iCol==pTab->iPKey ){
59263 iCol = -1;
59264 }
59265 break;
59266 }
59267 }
59268 if( iCol>=pTab->nCol && sqlite3IsRowid(zCol) ){
59269 iCol = -1; /* IMP: R-44911-55124 */
 
59270 }
59271 if( iCol<pTab->nCol ){
59272 cnt++;
59273 if( iCol<0 ){
59274 pExpr->affinity = SQLITE_AFF_INTEGER;
@@ -59356,11 +59292,11 @@
59292 /*
59293 ** Perhaps the name is a reference to the ROWID
59294 */
59295 if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){
59296 cnt = 1;
59297 pExpr->iColumn = -1; /* IMP: R-44911-55124 */
59298 pExpr->affinity = SQLITE_AFF_INTEGER;
59299 }
59300
59301 /*
59302 ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z
@@ -60500,34 +60436,10 @@
60436 }
60437 }
60438 return pColl;
60439 }
60440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60441 /*
60442 ** Generate code for a comparison operator.
60443 */
60444 static int codeCompare(
60445 Parse *pParse, /* The parsing (and code generating) context */
@@ -62255,30 +62167,43 @@
62167 struct yColCache *p;
62168
62169 assert( iReg>0 ); /* Register numbers are always positive */
62170 assert( iCol>=-1 && iCol<32768 ); /* Finite column numbers */
62171
62172 /* The SQLITE_ColumnCache flag disables the column cache. This is used
62173 ** for testing only - to verify that SQLite always gets the same answer
62174 ** with and without the column cache.
62175 */
62176 if( pParse->db->flags & SQLITE_ColumnCache ) return;
62177
62178 /* First replace any existing entry.
62179 **
62180 ** Actually, the way the column cache is currently used, we are guaranteed
62181 ** that the object will never already be in cache. Verify this guarantee.
62182 */
62183 #ifndef NDEBUG
62184 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62185 #if 0 /* This code wold remove the entry from the cache if it existed */
62186 if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
62187 cacheEntryClear(pParse, p);
62188 p->iLevel = pParse->iCacheLevel;
62189 p->iReg = iReg;
 
62190 p->lru = pParse->iCacheCnt++;
62191 return;
62192 }
62193 #endif
62194 assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
62195 }
62196 #endif
62197
62198 /* Find an empty slot and replace it */
62199 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62200 if( p->iReg==0 ){
62201 p->iLevel = pParse->iCacheLevel;
62202 p->iTable = iTab;
62203 p->iColumn = iCol;
62204 p->iReg = iReg;
 
62205 p->tempReg = 0;
62206 p->lru = pParse->iCacheCnt++;
62207 return;
62208 }
62209 }
@@ -62296,26 +62221,27 @@
62221 p = &pParse->aColCache[idxLru];
62222 p->iLevel = pParse->iCacheLevel;
62223 p->iTable = iTab;
62224 p->iColumn = iCol;
62225 p->iReg = iReg;
 
62226 p->tempReg = 0;
62227 p->lru = pParse->iCacheCnt++;
62228 return;
62229 }
62230 }
62231
62232 /*
62233 ** Indicate that registers between iReg..iReg+nReg-1 are being overwritten.
62234 ** Purge the range of registers from the column cache.
62235 */
62236 SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){
62237 int i;
62238 int iLast = iReg + nReg - 1;
62239 struct yColCache *p;
62240 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62241 int r = p->iReg;
62242 if( r>=iReg && r<=iLast ){
62243 cacheEntryClear(pParse, p);
62244 p->iReg = 0;
62245 }
62246 }
62247 }
@@ -62370,32 +62296,24 @@
62296 ** is made to store the column value in register iReg, but this is
62297 ** not guaranteed. The location of the column value is returned.
62298 **
62299 ** There must be an open cursor to pTab in iTable when this routine
62300 ** is called. If iColumn<0 then code is generated that extracts the rowid.
 
 
 
 
 
 
62301 */
62302 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
62303 Parse *pParse, /* Parsing and code generating context */
62304 Table *pTab, /* Description of the table we are reading from */
62305 int iColumn, /* Index of the table column */
62306 int iTable, /* The cursor pointing to the table */
62307 int iReg /* Store results here */
 
62308 ){
62309 Vdbe *v = pParse->pVdbe;
62310 int i;
62311 struct yColCache *p;
62312
62313 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62314 if( p->iReg>0 && p->iTable==iTable && p->iColumn==iColumn ){
 
62315 p->lru = pParse->iCacheCnt++;
62316 sqlite3ExprCachePinRegister(pParse, p->iReg);
62317 return p->iReg;
62318 }
62319 }
@@ -62429,19 +62347,11 @@
62347 /*
62348 ** Record the fact that an affinity change has occurred on iCount
62349 ** registers starting with iStart.
62350 */
62351 SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse *pParse, int iStart, int iCount){
62352 sqlite3ExprCacheRemove(pParse, iStart, iCount);
 
 
 
 
 
 
 
 
62353 }
62354
62355 /*
62356 ** Generate code to move content from registers iFrom...iFrom+nReg-1
62357 ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date.
@@ -62469,23 +62379,28 @@
62379 for(i=0; i<nReg; i++){
62380 sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, iFrom+i, iTo+i);
62381 }
62382 }
62383
62384 #if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST)
62385 /*
62386 ** Return true if any register in the range iFrom..iTo (inclusive)
62387 ** is used as part of the column cache.
62388 **
62389 ** This routine is used within assert() and testcase() macros only
62390 ** and does not appear in a normal build.
62391 */
62392 static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){
62393 int i;
62394 struct yColCache *p;
62395 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
62396 int r = p->iReg;
62397 if( r>=iFrom && r<=iTo ) return 1; /*NO_TEST*/
62398 }
62399 return 0;
62400 }
62401 #endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */
62402
62403 /*
62404 ** If the last instruction coded is an ephemeral copy of any of
62405 ** the registers in the nReg registers beginning with iReg, then
62406 ** convert the last instruction from OP_SCopy to OP_Copy.
@@ -62602,14 +62517,12 @@
62517 if( pExpr->iTable<0 ){
62518 /* This only happens when coding check constraints */
62519 assert( pParse->ckBase>0 );
62520 inReg = pExpr->iColumn + pParse->ckBase;
62521 }else{
 
62522 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
62523 pExpr->iColumn, pExpr->iTable, target);
 
62524 }
62525 break;
62526 }
62527 case TK_INTEGER: {
62528 codeInteger(v, pExpr, 0, target);
@@ -62722,12 +62635,12 @@
62635 testcase( op==TK_LE );
62636 testcase( op==TK_GT );
62637 testcase( op==TK_GE );
62638 testcase( op==TK_EQ );
62639 testcase( op==TK_NE );
62640 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
62641 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
62642 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62643 r1, r2, inReg, SQLITE_STOREP2);
62644 testcase( regFree1==0 );
62645 testcase( regFree2==0 );
62646 break;
@@ -62734,12 +62647,12 @@
62647 }
62648 case TK_IS:
62649 case TK_ISNOT: {
62650 testcase( op==TK_IS );
62651 testcase( op==TK_ISNOT );
62652 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
62653 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
62654 op = (op==TK_IS) ? TK_EQ : TK_NE;
62655 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
62656 r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ);
62657 testcase( regFree1==0 );
62658 testcase( regFree2==0 );
@@ -62879,11 +62792,11 @@
62792 int endCoalesce = sqlite3VdbeMakeLabel(v);
62793 assert( nFarg>=2 );
62794 sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target);
62795 for(i=1; i<nFarg; i++){
62796 sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce);
62797 sqlite3ExprCacheRemove(pParse, target, 1);
62798 sqlite3ExprCachePush(pParse);
62799 sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target);
62800 sqlite3ExprCachePop(pParse, 1);
62801 }
62802 sqlite3VdbeResolveLabel(v, endCoalesce);
@@ -62934,11 +62847,10 @@
62847 (char*)pDef, P4_FUNCDEF);
62848 sqlite3VdbeChangeP5(v, (u8)nFarg);
62849 if( nFarg ){
62850 sqlite3ReleaseTempRange(pParse, r1, nFarg);
62851 }
 
62852 break;
62853 }
62854 #ifndef SQLITE_OMIT_SUBQUERY
62855 case TK_EXISTS:
62856 case TK_SELECT: {
@@ -62975,12 +62887,12 @@
62887 case TK_BETWEEN: {
62888 Expr *pLeft = pExpr->pLeft;
62889 struct ExprList_item *pLItem = pExpr->x.pList->a;
62890 Expr *pRight = pLItem->pExpr;
62891
62892 r1 = sqlite3ExprCodeTemp(pParse, pLeft, &regFree1);
62893 r2 = sqlite3ExprCodeTemp(pParse, pRight, &regFree2);
62894 testcase( regFree1==0 );
62895 testcase( regFree2==0 );
62896 r3 = sqlite3GetTempReg(pParse);
62897 r4 = sqlite3GetTempReg(pParse);
62898 codeCompare(pParse, pLeft, pRight, OP_Ge,
@@ -63511,12 +63423,12 @@
63423 testcase( op==TK_GT );
63424 testcase( op==TK_GE );
63425 testcase( op==TK_EQ );
63426 testcase( op==TK_NE );
63427 testcase( jumpIfNull==0 );
63428 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63429 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
63430 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63431 r1, r2, dest, jumpIfNull);
63432 testcase( regFree1==0 );
63433 testcase( regFree2==0 );
63434 break;
@@ -63523,12 +63435,12 @@
63435 }
63436 case TK_IS:
63437 case TK_ISNOT: {
63438 testcase( op==TK_IS );
63439 testcase( op==TK_ISNOT );
63440 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63441 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
63442 op = (op==TK_IS) ? TK_EQ : TK_NE;
63443 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63444 r1, r2, dest, SQLITE_NULLEQ);
63445 testcase( regFree1==0 );
63446 testcase( regFree2==0 );
@@ -63654,12 +63566,12 @@
63566 testcase( op==TK_GT );
63567 testcase( op==TK_GE );
63568 testcase( op==TK_EQ );
63569 testcase( op==TK_NE );
63570 testcase( jumpIfNull==0 );
63571 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63572 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
63573 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63574 r1, r2, dest, jumpIfNull);
63575 testcase( regFree1==0 );
63576 testcase( regFree2==0 );
63577 break;
@@ -63666,12 +63578,12 @@
63578 }
63579 case TK_IS:
63580 case TK_ISNOT: {
63581 testcase( pExpr->op==TK_IS );
63582 testcase( pExpr->op==TK_ISNOT );
63583 r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, &regFree1);
63584 r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, &regFree2);
63585 op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ;
63586 codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op,
63587 r1, r2, dest, SQLITE_NULLEQ);
63588 testcase( regFree1==0 );
63589 testcase( regFree2==0 );
@@ -64014,20 +63926,22 @@
63926 */
63927 SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){
63928 int i, n;
63929 i = pParse->iRangeReg;
63930 n = pParse->nRangeReg;
63931 if( nReg<=n ){
63932 assert( !usedAsColumnCache(pParse, i, i+n-1) );
63933 pParse->iRangeReg += nReg;
63934 pParse->nRangeReg -= nReg;
63935 }else{
63936 i = pParse->nMem+1;
63937 pParse->nMem += nReg;
63938 }
63939 return i;
63940 }
63941 SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){
63942 sqlite3ExprCacheRemove(pParse, iReg, nReg);
63943 if( nReg>pParse->nRangeReg ){
63944 pParse->nRangeReg = nReg;
63945 pParse->iRangeReg = iReg;
63946 }
63947 }
@@ -66818,11 +66732,12 @@
66732 Table *p;
66733 Db *pDb;
66734
66735 assert( db!=0 );
66736 assert( iDb>=0 && iDb<db->nDb );
66737 assert( zTabName );
66738 testcase( zTabName[0]==0 ); /* Zero-length table names are allowed */
66739 pDb = &db->aDb[iDb];
66740 p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName,
66741 sqlite3Strlen30(zTabName),0);
66742 sqlite3DeleteTable(p);
66743 db->flags |= SQLITE_InternChanges;
@@ -69685,11 +69600,10 @@
69600 sqlite3ErrorMsg(pParse, "unable to open a temporary database "
69601 "file for storing temporary tables");
69602 pParse->rc = rc;
69603 return 1;
69604 }
 
69605 assert( db->aDb[1].pSchema );
69606 sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt),
69607 db->dfltJournalMode);
69608 }
69609 return 0;
@@ -70791,11 +70705,11 @@
70705 /* Collect rowids of every row to be deleted.
70706 */
70707 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
70708 pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,WHERE_DUPLICATES_OK);
70709 if( pWInfo==0 ) goto delete_from_cleanup;
70710 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
70711 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
70712 if( db->flags & SQLITE_CountRows ){
70713 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
70714 }
70715 sqlite3WhereEnd(pWInfo);
@@ -71057,11 +70971,10 @@
70971 }
70972 }
70973 if( doMakeRec ){
70974 sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut);
70975 sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0);
 
70976 }
70977 sqlite3ReleaseTempRange(pParse, regBase, nCol+1);
70978 return regBase;
70979 }
70980
@@ -71180,33 +71093,45 @@
71093 }
71094 }
71095 }
71096
71097 /*
71098 ** Implementation of the abs() function.
71099 **
71100 ** IMP: R-23979-26855 The abs(X) function returns the absolute value of
71101 ** the numeric argument X.
71102 */
71103 static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
71104 assert( argc==1 );
71105 UNUSED_PARAMETER(argc);
71106 switch( sqlite3_value_type(argv[0]) ){
71107 case SQLITE_INTEGER: {
71108 i64 iVal = sqlite3_value_int64(argv[0]);
71109 if( iVal<0 ){
71110 if( (iVal<<1)==0 ){
71111 /* IMP: R-35460-15084 If X is the integer -9223372036854775807 then
71112 ** abs(X) throws an integer overflow error since there is no
71113 ** equivalent positive 64-bit two complement value. */
71114 sqlite3_result_error(context, "integer overflow", -1);
71115 return;
71116 }
71117 iVal = -iVal;
71118 }
71119 sqlite3_result_int64(context, iVal);
71120 break;
71121 }
71122 case SQLITE_NULL: {
71123 /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */
71124 sqlite3_result_null(context);
71125 break;
71126 }
71127 default: {
71128 /* Because sqlite3_value_double() returns 0.0 if the argument is not
71129 ** something that can be converted into a number, we have:
71130 ** IMP: R-57326-31541 Abs(X) return 0.0 if X is a string or blob that
71131 ** cannot be converted to a numeric value.
71132 */
71133 double rVal = sqlite3_value_double(argv[0]);
71134 if( rVal<0 ) rVal = -rVal;
71135 sqlite3_result_double(context, rVal);
71136 break;
71137 }
@@ -72104,13 +72029,20 @@
72029 }
72030 sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT);
72031 }
72032
72033
72034 /* IMP: R-25361-16150 This function is omitted from SQLite by default. It
72035 ** is only available if the SQLITE_SOUNDEX compile-time option is used
72036 ** when SQLite is built.
72037 */
72038 #ifdef SQLITE_SOUNDEX
72039 /*
72040 ** Compute the soundex encoding of a word.
72041 **
72042 ** IMP: R-59782-00072 The soundex(X) function returns a string that is the
72043 ** soundex encoding of the string X.
72044 */
72045 static void soundexFunc(
72046 sqlite3_context *context,
72047 int argc,
72048 sqlite3_value **argv
@@ -72150,14 +72082,16 @@
72082 zResult[j++] = '0';
72083 }
72084 zResult[j] = 0;
72085 sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT);
72086 }else{
72087 /* IMP: R-64894-50321 The string "?000" is returned if the argument
72088 ** is NULL or contains no ASCII alphabetic characters. */
72089 sqlite3_result_text(context, "?000", 4, SQLITE_STATIC);
72090 }
72091 }
72092 #endif /* SQLITE_SOUNDEX */
72093
72094 #ifndef SQLITE_OMIT_LOAD_EXTENSION
72095 /*
72096 ** A function that loads a shared-library extension then returns NULL.
72097 */
@@ -78623,11 +78557,11 @@
78557 if( rc!=SQLITE_OK ) return;
78558 openedTransaction = 1;
78559 }
78560
78561 /* Read the schema cookie from the database. If it does not match the
78562 ** value stored as part of the in-memory schema representation,
78563 ** set Parse.rc to SQLITE_SCHEMA. */
78564 sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie);
78565 if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){
78566 pParse->rc = SQLITE_SCHEMA;
78567 }
@@ -79215,10 +79149,43 @@
79149 for(i=0; i<pTab->nCol; i++){
79150 if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i;
79151 }
79152 return -1;
79153 }
79154
79155 /*
79156 ** Search the first N tables in pSrc, from left to right, looking for a
79157 ** table that has a column named zCol.
79158 **
79159 ** When found, set *piTab and *piCol to the table index and column index
79160 ** of the matching column and return TRUE.
79161 **
79162 ** If not found, return FALSE.
79163 */
79164 static int tableAndColumnIndex(
79165 SrcList *pSrc, /* Array of tables to search */
79166 int N, /* Number of tables in pSrc->a[] to search */
79167 const char *zCol, /* Name of the column we are looking for */
79168 int *piTab, /* Write index of pSrc->a[] here */
79169 int *piCol /* Write index of pSrc->a[*piTab].pTab->aCol[] here */
79170 ){
79171 int i; /* For looping over tables in pSrc */
79172 int iCol; /* Index of column matching zCol */
79173
79174 assert( (piTab==0)==(piCol==0) ); /* Both or neither are NULL */
79175 for(i=0; i<N; i++){
79176 iCol = columnIndex(pSrc->a[i].pTab, zCol);
79177 if( iCol>=0 ){
79178 if( piTab ){
79179 *piTab = i;
79180 *piCol = iCol;
79181 }
79182 return 1;
79183 }
79184 }
79185 return 0;
79186 }
79187
79188 /*
79189 ** This function is used to add terms implied by JOIN syntax to the
79190 ** WHERE clause expression of a SELECT statement. The new term, which
79191 ** is ANDed with the existing WHERE clause, is of the form:
@@ -79230,27 +79197,29 @@
79197 ** column iColRight of tab2.
79198 */
79199 static void addWhereTerm(
79200 Parse *pParse, /* Parsing context */
79201 SrcList *pSrc, /* List of tables in FROM clause */
79202 int iLeft, /* Index of first table to join in pSrc */
79203 int iColLeft, /* Index of column in first table */
79204 int iRight, /* Index of second table in pSrc */
79205 int iColRight, /* Index of column in second table */
79206 int isOuterJoin, /* True if this is an OUTER join */
79207 Expr **ppWhere /* IN/OUT: The WHERE clause to add to */
79208 ){
79209 sqlite3 *db = pParse->db;
79210 Expr *pE1;
79211 Expr *pE2;
79212 Expr *pEq;
79213
79214 assert( iLeft<iRight );
79215 assert( pSrc->nSrc>iRight );
79216 assert( pSrc->a[iLeft].pTab );
79217 assert( pSrc->a[iRight].pTab );
79218
79219 pE1 = sqlite3CreateColumnExpr(db, pSrc, iLeft, iColLeft);
79220 pE2 = sqlite3CreateColumnExpr(db, pSrc, iRight, iColRight);
79221
79222 pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0);
79223 if( pEq && isOuterJoin ){
79224 ExprSetProperty(pEq, EP_FromJoin);
79225 assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) );
@@ -79335,15 +79304,19 @@
79304 if( pRight->pOn || pRight->pUsing ){
79305 sqlite3ErrorMsg(pParse, "a NATURAL join may not have "
79306 "an ON or USING clause", 0);
79307 return 1;
79308 }
79309 for(j=0; j<pRightTab->nCol; j++){
79310 char *zName; /* Name of column in the right table */
79311 int iLeft; /* Matching left table */
79312 int iLeftCol; /* Matching column in the left table */
79313
79314 zName = pRightTab->aCol[j].zName;
79315 if( tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol) ){
79316 addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, j,
79317 isOuter, &p->pWhere);
79318 }
79319 }
79320 }
79321
79322 /* Disallow both ON and USING clauses in the same join
@@ -79371,19 +79344,26 @@
79344 ** not contained in both tables to be joined.
79345 */
79346 if( pRight->pUsing ){
79347 IdList *pList = pRight->pUsing;
79348 for(j=0; j<pList->nId; j++){
79349 char *zName; /* Name of the term in the USING clause */
79350 int iLeft; /* Table on the left with matching column name */
79351 int iLeftCol; /* Column number of matching column on the left */
79352 int iRightCol; /* Column number of matching column on the right */
79353
79354 zName = pList->a[j].zName;
79355 iRightCol = columnIndex(pRightTab, zName);
79356 if( iRightCol<0
79357 || !tableAndColumnIndex(pSrc, i+1, zName, &iLeft, &iLeftCol)
79358 ){
79359 sqlite3ErrorMsg(pParse, "cannot join using column %s - column "
79360 "not present in both tables", zName);
79361 return 1;
79362 }
79363 addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol,
79364 isOuter, &p->pWhere);
79365 }
79366 }
79367 }
79368 return 0;
79369 }
@@ -79938,11 +79918,11 @@
79918 if( pS ){
79919 /* The "table" is actually a sub-select or a view in the FROM clause
79920 ** of the SELECT statement. Return the declaration type and origin
79921 ** data for the result-set column of the sub-select.
79922 */
79923 if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
79924 /* If iCol is less than zero, then the expression requests the
79925 ** rowid of the sub-select or view. This expression is legal (see
79926 ** test case misc2.2.2) - it always evaluates to NULL.
79927 */
79928 NameContext sNC;
@@ -81499,11 +81479,11 @@
81479 ** (10) The subquery does not use aggregates or the outer query does not
81480 ** use LIMIT.
81481 **
81482 ** (11) The subquery and the outer query do not both have ORDER BY clauses.
81483 **
81484 ** (**) Not implemented. Subsumed into restriction (3). Was previously
81485 ** a separate restriction deriving from ticket #350.
81486 **
81487 ** (13) The subquery and outer query do not both use LIMIT
81488 **
81489 ** (14) The subquery does not use OFFSET
@@ -81573,10 +81553,11 @@
81553
81554 /* Check to see if flattening is permitted. Return 0 if not.
81555 */
81556 assert( p!=0 );
81557 assert( p->pPrior==0 ); /* Unable to flatten compound queries */
81558 if( db->flags & SQLITE_QueryFlattener ) return 0;
81559 pSrc = p->pSrc;
81560 assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc );
81561 pSubitem = &pSrc->a[iFrom];
81562 iParent = pSubitem->iCursor;
81563 pSub = pSubitem->pSelect;
@@ -82196,18 +82177,18 @@
82177 assert(IsVirtual(pTab));
82178 continue;
82179 }
82180
82181 if( i>0 && zTName==0 ){
82182 if( (pFrom->jointype & JT_NATURAL)!=0
82183 && tableAndColumnIndex(pTabList, i, zName, 0, 0)
82184 ){
82185 /* In a NATURAL join, omit the join columns from the
82186 ** table to the right of the join */
82187 continue;
82188 }
82189 if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){
82190 /* In a join with a USING clause, omit columns in the
82191 ** using clause from the table on the right. */
82192 continue;
82193 }
82194 }
@@ -82470,12 +82451,12 @@
82451 sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ);
82452 }
82453 sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem,
82454 (void*)pF->pFunc, P4_FUNCDEF);
82455 sqlite3VdbeChangeP5(v, (u8)nArg);
 
82456 sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg);
82457 sqlite3ReleaseTempRange(pParse, regAgg, nArg);
82458 if( addrNext ){
82459 sqlite3VdbeResolveLabel(v, addrNext);
82460 sqlite3ExprCacheClear(pParse);
82461 }
82462 }
@@ -82897,11 +82878,11 @@
82878 if( pCol->iSorterColumn>=j ){
82879 int r1 = j + regBase;
82880 int r2;
82881
82882 r2 = sqlite3ExprCodeGetColumn(pParse,
82883 pCol->pTab, pCol->iColumn, pCol->iTable, r1);
82884 if( r1!=r2 ){
82885 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
82886 }
82887 j++;
82888 }
@@ -85309,10 +85290,11 @@
85290 Btree *pTemp; /* The temporary database we vacuum into */
85291 char *zSql = 0; /* SQL statements */
85292 int saved_flags; /* Saved value of the db->flags */
85293 int saved_nChange; /* Saved value of db->nChange */
85294 int saved_nTotalChange; /* Saved value of db->nTotalChange */
85295 void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */
85296 Db *pDb = 0; /* Database to detach at end of vacuum */
85297 int isMemDb; /* True if vacuuming a :memory: database */
85298 int nRes;
85299
85300 if( !db->autoCommit ){
@@ -85324,12 +85306,14 @@
85306 ** restored before returning. Then set the writable-schema flag, and
85307 ** disable CHECK and foreign key constraints. */
85308 saved_flags = db->flags;
85309 saved_nChange = db->nChange;
85310 saved_nTotalChange = db->nTotalChange;
85311 saved_xTrace = db->xTrace;
85312 db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks;
85313 db->flags &= ~SQLITE_ForeignKeys;
85314 db->xTrace = 0;
85315
85316 pMain = db->aDb[0].pBt;
85317 isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain));
85318
85319 /* Attach the temporary database as 'vacuum_db'. The synchronous pragma
@@ -85506,10 +85490,11 @@
85490 end_of_vacuum:
85491 /* Restore the original value of db->flags */
85492 db->flags = saved_flags;
85493 db->nChange = saved_nChange;
85494 db->nTotalChange = saved_nTotalChange;
85495 db->xTrace = saved_xTrace;
85496
85497 /* Currently there is an SQL level transaction open on the vacuum
85498 ** database. No locks are held on any other files (since the main file
85499 ** was committed at the btree level). So it safe to end the transaction
85500 ** by manually setting the autoCommit flag to true and detaching the
@@ -86200,24 +86185,24 @@
86185 rc = SQLITE_NOMEM;
86186 }else{
86187 pParse->declareVtab = 1;
86188 pParse->db = db;
86189
86190 if( SQLITE_OK==sqlite3RunParser(pParse, zCreateTable, &zErr)
86191 && pParse->pNewTable
86192 && !db->mallocFailed
86193 && !pParse->pNewTable->pSelect
86194 && (pParse->pNewTable->tabFlags & TF_Virtual)==0
86195 ){
86196 if( !pTab->aCol ){
86197 pTab->aCol = pParse->pNewTable->aCol;
86198 pTab->nCol = pParse->pNewTable->nCol;
86199 pParse->pNewTable->nCol = 0;
86200 pParse->pNewTable->aCol = 0;
86201 }
86202 db->pVTab = 0;
86203 }else{
86204 sqlite3Error(db, SQLITE_ERROR, zErr);
86205 sqlite3DbFree(db, zErr);
86206 rc = SQLITE_ERROR;
86207 }
86208 pParse->declareVtab = 0;
@@ -89653,11 +89638,11 @@
89638 ** range (if any).
89639 */
89640 nConstraint = nEq;
89641 if( pRangeEnd ){
89642 Expr *pRight = pRangeEnd->pExpr->pRight;
89643 sqlite3ExprCacheRemove(pParse, regBase+nEq, 1);
89644 sqlite3ExprCode(pParse, pRight, regBase+nEq);
89645 sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt);
89646 if( zAff ){
89647 if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){
89648 /* Since the comparison is to be performed with no conversions
@@ -89758,30 +89743,50 @@
89743 ** B: <after the loop>
89744 **
89745 */
89746 WhereClause *pOrWc; /* The OR-clause broken out into subterms */
89747 WhereTerm *pFinal; /* Final subterm within the OR-clause. */
89748 SrcList *pOrTab; /* Shortened table list or OR-clause generation */
89749
89750 int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */
89751 int regRowset = 0; /* Register for RowSet object */
89752 int regRowid = 0; /* Register holding rowid */
89753 int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */
89754 int iRetInit; /* Address of regReturn init */
89755 int untestedTerms = 0; /* Some terms not completely tested */
89756 int ii;
89757
89758 pTerm = pLevel->plan.u.pTerm;
89759 assert( pTerm!=0 );
89760 assert( pTerm->eOperator==WO_OR );
89761 assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
89762 pOrWc = &pTerm->u.pOrInfo->wc;
89763 pFinal = &pOrWc->a[pOrWc->nTerm-1];
89764 pLevel->op = OP_Return;
89765 pLevel->p1 = regReturn;
89766
89767 /* Set up a new SrcList ni pOrTab containing the table being scanned
89768 ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
89769 ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
89770 */
89771 if( pWInfo->nLevel>1 ){
89772 int nNotReady; /* The number of notReady tables */
89773 struct SrcList_item *origSrc; /* Original list of tables */
89774 nNotReady = pWInfo->nLevel - iLevel - 1;
89775 pOrTab = sqlite3StackAllocRaw(pParse->db,
89776 sizeof(*pOrTab)+ nNotReady*sizeof(pOrTab->a[0]));
89777 if( pOrTab==0 ) return notReady;
89778 pOrTab->nAlloc = (i16)(nNotReady + 1);
89779 pOrTab->nSrc = pOrTab->nAlloc;
89780 memcpy(pOrTab->a, pTabItem, sizeof(*pTabItem));
89781 origSrc = pWInfo->pTabList->a;
89782 for(k=1; k<=nNotReady; k++){
89783 memcpy(&pOrTab->a[k], &origSrc[pLevel[k].iFrom], sizeof(pOrTab->a[k]));
89784 }
89785 }else{
89786 pOrTab = pWInfo->pTabList;
89787 }
89788
89789 /* Initialize the rowset register to contain NULL. An SQL NULL is
89790 ** equivalent to an empty rowset.
89791 **
89792 ** Also initialize regReturn to contain the address of the instruction
@@ -89802,36 +89807,42 @@
89807 for(ii=0; ii<pOrWc->nTerm; ii++){
89808 WhereTerm *pOrTerm = &pOrWc->a[ii];
89809 if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){
89810 WhereInfo *pSubWInfo; /* Info for single OR-term scan */
89811 /* Loop through table entries that match term pOrTerm. */
89812 pSubWInfo = sqlite3WhereBegin(pParse, pOrTab, pOrTerm->pExpr, 0,
89813 WHERE_OMIT_OPEN | WHERE_OMIT_CLOSE |
89814 WHERE_FORCE_TABLE | WHERE_ONETABLE_ONLY);
89815 if( pSubWInfo ){
89816 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
89817 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
89818 int r;
89819 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
89820 regRowid);
89821 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
89822 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
89823 }
89824 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
89825
89826 /* The pSubWInfo->untestedTerms flag means that this OR term
89827 ** contained one or more AND term from a notReady table. The
89828 ** terms from the notReady table could not be tested and will
89829 ** need to be tested later.
89830 */
89831 if( pSubWInfo->untestedTerms ) untestedTerms = 1;
89832
89833 /* Finish the loop through table entries that match term pOrTerm. */
89834 sqlite3WhereEnd(pSubWInfo);
89835 }
89836 }
89837 }
89838 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
 
89839 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk);
89840 sqlite3VdbeResolveLabel(v, iLoopBody);
89841
89842 if( pWInfo->nLevel>1 ) sqlite3StackFree(pParse->db, pOrTab);
89843 if( !untestedTerms ) disableTerm(pLevel, pTerm);
 
89844 }else
89845 #endif /* SQLITE_OMIT_OR_OPTIMIZATION */
89846
89847 {
89848 /* Case 5: There is no usable index. We must do a complete
@@ -89855,11 +89866,16 @@
89866 for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
89867 Expr *pE;
89868 testcase( pTerm->wtFlags & TERM_VIRTUAL );
89869 testcase( pTerm->wtFlags & TERM_CODED );
89870 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89871 if( (pTerm->prereqAll & notReady)!=0 ){
89872 testcase( pWInfo->untestedTerms==0
89873 && (pWInfo->wctrlFlags & WHERE_ONETABLE_ONLY)!=0 );
89874 pWInfo->untestedTerms = 1;
89875 continue;
89876 }
89877 pE = pTerm->pExpr;
89878 assert( pE!=0 );
89879 if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
89880 continue;
89881 }
@@ -89878,11 +89894,14 @@
89894 sqlite3ExprCacheClear(pParse);
89895 for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){
89896 testcase( pTerm->wtFlags & TERM_VIRTUAL );
89897 testcase( pTerm->wtFlags & TERM_CODED );
89898 if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
89899 if( (pTerm->prereqAll & notReady)!=0 ){
89900 assert( pWInfo->untestedTerms );
89901 continue;
89902 }
89903 assert( pTerm->pExpr );
89904 sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL);
89905 pTerm->wtFlags |= TERM_CODED;
89906 }
89907 }
@@ -90021,10 +90040,11 @@
90040 ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */
90041 u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */
90042 ){
90043 int i; /* Loop counter */
90044 int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */
90045 int nTabList; /* Number of elements in pTabList */
90046 WhereInfo *pWInfo; /* Will become the return value of this function */
90047 Vdbe *v = pParse->pVdbe; /* The virtual database engine */
90048 Bitmask notReady; /* Cursors that are not yet positioned */
90049 WhereMaskSet *pMaskSet; /* The expression mask set */
90050 WhereClause *pWC; /* Decomposition of the WHERE clause */
@@ -90039,29 +90059,36 @@
90059 */
90060 if( pTabList->nSrc>BMS ){
90061 sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS);
90062 return 0;
90063 }
90064
90065 /* This function normally generates a nested loop for all tables in
90066 ** pTabList. But if the WHERE_ONETABLE_ONLY flag is set, then we should
90067 ** only generate code for the first table in pTabList and assume that
90068 ** any cursors associated with subsequent tables are uninitialized.
90069 */
90070 nTabList = (wctrlFlags & WHERE_ONETABLE_ONLY) ? 1 : pTabList->nSrc;
90071
90072 /* Allocate and initialize the WhereInfo structure that will become the
90073 ** return value. A single allocation is used to store the WhereInfo
90074 ** struct, the contents of WhereInfo.a[], the WhereClause structure
90075 ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte
90076 ** field (type Bitmask) it must be aligned on an 8-byte boundary on
90077 ** some architectures. Hence the ROUND8() below.
90078 */
90079 db = pParse->db;
90080 nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel));
90081 pWInfo = sqlite3DbMallocZero(db,
90082 nByteWInfo +
90083 sizeof(WhereClause) +
90084 sizeof(WhereMaskSet)
90085 );
90086 if( db->mallocFailed ){
90087 goto whereBeginError;
90088 }
90089 pWInfo->nLevel = nTabList;
90090 pWInfo->pParse = pParse;
90091 pWInfo->pTabList = pTabList;
90092 pWInfo->iBreak = sqlite3VdbeMakeLabel(v);
90093 pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo];
90094 pWInfo->wctrlFlags = wctrlFlags;
@@ -90076,11 +90103,11 @@
90103 whereSplit(pWC, pWhere, TK_AND);
90104
90105 /* Special case: a WHERE clause that is constant. Evaluate the
90106 ** expression and either jump over all of the code or fall thru.
90107 */
90108 if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){
90109 sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL);
90110 pWhere = 0;
90111 }
90112
90113 /* Assign a bit from the bitmask to every term in the FROM clause.
@@ -90096,10 +90123,15 @@
90123 **
90124 ** Configure the WhereClause.vmask variable so that bits that correspond
90125 ** to virtual table cursors are set. This is used to selectively disable
90126 ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful
90127 ** with virtual tables.
90128 **
90129 ** Note that bitmasks are created for all pTabList->nSrc tables in
90130 ** pTabList, not just the first nTabList tables. nTabList is normally
90131 ** equal to pTabList->nSrc but might be shortened to 1 if the
90132 ** WHERE_ONETABLE_ONLY flag is set.
90133 */
90134 assert( pWC->vmask==0 && pMaskSet->n==0 );
90135 for(i=0; i<pTabList->nSrc; i++){
90136 createMask(pMaskSet, pTabList->a[i].iCursor);
90137 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -90147,11 +90179,11 @@
90179 notReady = ~(Bitmask)0;
90180 pTabItem = pTabList->a;
90181 pLevel = pWInfo->a;
90182 andFlags = ~0;
90183 WHERETRACE(("*** Optimizer Start ***\n"));
90184 for(i=iFrom=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
90185 WhereCost bestPlan; /* Most efficient plan seen so far */
90186 Index *pIdx; /* Index for FROM table at pTabItem */
90187 int j; /* For looping over FROM tables */
90188 int bestJ = -1; /* The value of j */
90189 Bitmask m; /* Bitmask value for j or bestJ */
@@ -90192,12 +90224,12 @@
90224 ** algorithm may choose to use t2 for the outer loop, which is a much
90225 ** costlier approach.
90226 */
90227 for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){
90228 Bitmask mask = (isOptimal ? 0 : notReady);
90229 assert( (nTabList-iFrom)>1 || isOptimal );
90230 for(j=iFrom, pTabItem=&pTabList->a[j]; j<nTabList; j++, pTabItem++){
90231 int doNotReorder; /* True if this table should not be reordered */
90232 WhereCost sCost; /* Cost information from best[Virtual]Index() */
90233 ExprList *pOrderBy; /* ORDER BY clause for index to optimize */
90234
90235 doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0;
@@ -90290,11 +90322,11 @@
90322
90323 /* Open all tables in the pTabList and any indices selected for
90324 ** searching those tables.
90325 */
90326 sqlite3CodeVerifySchema(pParse, -1); /* Insert the cookie verifier Goto */
90327 for(i=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
90328 Table *pTab; /* Table to open */
90329 int iDb; /* Index of database containing table/index */
90330
90331 #ifndef SQLITE_OMIT_EXPLAIN
90332 if( pParse->explain==2 ){
@@ -90369,11 +90401,11 @@
90401 /* Generate the code to do the search. Each iteration of the for
90402 ** loop below generates code for a single nested loop of the VM
90403 ** program.
90404 */
90405 notReady = ~(Bitmask)0;
90406 for(i=0; i<nTabList; i++){
90407 notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady);
90408 pWInfo->iContinue = pWInfo->a[i].addrCont;
90409 }
90410
90411 #ifdef SQLITE_TEST /* For testing and debugging use only */
@@ -90381,11 +90413,11 @@
90413 ** and the index used to access it (if any). If the table itself
90414 ** is not used, its name is just '{}'. If no index is used
90415 ** the index is listed as "{}". If the primary key is used the
90416 ** index name is '*'.
90417 */
90418 for(i=0; i<nTabList; i++){
90419 char *z;
90420 int n;
90421 pLevel = &pWInfo->a[i];
90422 pTabItem = &pTabList->a[pLevel->iFrom];
90423 z = pTabItem->zAlias;
@@ -90449,11 +90481,11 @@
90481 sqlite3 *db = pParse->db;
90482
90483 /* Generate loop termination code.
90484 */
90485 sqlite3ExprCacheClear(pParse);
90486 for(i=pWInfo->nLevel-1; i>=0; i--){
90487 pLevel = &pWInfo->a[i];
90488 sqlite3VdbeResolveLabel(v, pLevel->addrCont);
90489 if( pLevel->op!=OP_Noop ){
90490 sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2);
90491 sqlite3VdbeChangeP5(v, pLevel->p5);
@@ -90495,11 +90527,12 @@
90527 */
90528 sqlite3VdbeResolveLabel(v, pWInfo->iBreak);
90529
90530 /* Close all of the cursors that were opened by sqlite3WhereBegin.
90531 */
90532 assert( pWInfo->nLevel==1 || pWInfo->nLevel==pTabList->nSrc );
90533 for(i=0, pLevel=pWInfo->a; i<pWInfo->nLevel; i++, pLevel++){
90534 struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom];
90535 Table *pTab = pTabItem->pTab;
90536 assert( pTab!=0 );
90537 if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue;
90538 if( (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 ){
@@ -90767,12 +90800,12 @@
90800 #endif
90801 #define sqlite3ParserARG_SDECL Parse *pParse;
90802 #define sqlite3ParserARG_PDECL ,Parse *pParse
90803 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
90804 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
90805 #define YYNSTATE 631
90806 #define YYNRULE 330
90807 #define YYFALLBACK 1
90808 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
90809 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
90810 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
90811
@@ -90840,473 +90873,474 @@
90873 ** shifting non-terminals after a reduce.
90874 ** yy_default[] Default action for each state.
90875 */
90876 #define YY_ACTTAB_COUNT (1543)
90877 static const YYACTIONTYPE yy_action[] = {
90878 /* 0 */ 313, 49, 556, 46, 147, 172, 628, 598, 55, 55,
90879 /* 10 */ 55, 55, 302, 53, 53, 53, 53, 52, 52, 51,
90880 /* 20 */ 51, 51, 50, 238, 603, 66, 624, 623, 604, 598,
90881 /* 30 */ 591, 585, 48, 53, 53, 53, 53, 52, 52, 51,
90882 /* 40 */ 51, 51, 50, 238, 51, 51, 51, 50, 238, 56,
90883 /* 50 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90884 /* 60 */ 55, 55, 609, 53, 53, 53, 53, 52, 52, 51,
90885 /* 70 */ 51, 51, 50, 238, 313, 598, 672, 330, 411, 217,
90886 /* 80 */ 32, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90887 /* 90 */ 50, 238, 330, 414, 621, 620, 166, 598, 673, 382,
90888 /* 100 */ 379, 378, 602, 73, 591, 585, 307, 424, 166, 58,
90889 /* 110 */ 377, 382, 379, 378, 516, 515, 624, 623, 254, 200,
90890 /* 120 */ 199, 198, 377, 56, 57, 47, 583, 582, 584, 584,
90891 /* 130 */ 54, 54, 55, 55, 55, 55, 581, 53, 53, 53,
90892 /* 140 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 270,
90893 /* 150 */ 226, 422, 283, 133, 177, 139, 284, 385, 279, 384,
90894 /* 160 */ 169, 197, 251, 282, 253, 226, 411, 275, 440, 167,
90895 /* 170 */ 139, 284, 385, 279, 384, 169, 571, 236, 591, 585,
90896 /* 180 */ 240, 414, 275, 622, 621, 620, 674, 437, 441, 442,
90897 /* 190 */ 602, 88, 352, 266, 439, 268, 438, 56, 57, 47,
90898 /* 200 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90899 /* 210 */ 465, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90900 /* 220 */ 50, 238, 313, 471, 52, 52, 51, 51, 51, 50,
90901 /* 230 */ 238, 234, 166, 491, 567, 382, 379, 378, 1, 440,
90902 /* 240 */ 252, 176, 624, 623, 608, 67, 377, 513, 622, 443,
90903 /* 250 */ 237, 577, 591, 585, 622, 172, 466, 598, 554, 441,
90904 /* 260 */ 340, 409, 526, 580, 580, 349, 596, 553, 194, 482,
90905 /* 270 */ 175, 56, 57, 47, 583, 582, 584, 584, 54, 54,
90906 /* 280 */ 55, 55, 55, 55, 562, 53, 53, 53, 53, 52,
90907 /* 290 */ 52, 51, 51, 51, 50, 238, 313, 594, 594, 594,
90908 /* 300 */ 561, 578, 469, 65, 259, 351, 258, 411, 624, 623,
90909 /* 310 */ 621, 620, 332, 576, 575, 240, 560, 568, 520, 411,
90910 /* 320 */ 341, 237, 414, 624, 623, 598, 591, 585, 542, 519,
90911 /* 330 */ 171, 602, 95, 68, 414, 624, 623, 624, 623, 38,
90912 /* 340 */ 877, 506, 507, 602, 88, 56, 57, 47, 583, 582,
90913 /* 350 */ 584, 584, 54, 54, 55, 55, 55, 55, 532, 53,
90914 /* 360 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90915 /* 370 */ 313, 411, 579, 398, 531, 237, 621, 620, 388, 625,
90916 /* 380 */ 500, 206, 167, 396, 233, 312, 414, 387, 569, 492,
90917 /* 390 */ 216, 621, 620, 566, 622, 602, 74, 533, 210, 491,
90918 /* 400 */ 591, 585, 548, 621, 620, 621, 620, 300, 598, 466,
90919 /* 410 */ 481, 67, 603, 35, 622, 601, 604, 547, 6, 56,
90920 /* 420 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90921 /* 430 */ 55, 55, 601, 53, 53, 53, 53, 52, 52, 51,
90922 /* 440 */ 51, 51, 50, 238, 313, 411, 184, 409, 528, 580,
90923 /* 450 */ 580, 551, 962, 186, 419, 2, 353, 259, 351, 258,
90924 /* 460 */ 414, 409, 411, 580, 580, 44, 411, 544, 240, 602,
90925 /* 470 */ 94, 190, 7, 62, 591, 585, 598, 414, 350, 607,
90926 /* 480 */ 493, 414, 409, 317, 580, 580, 602, 95, 496, 565,
90927 /* 490 */ 602, 80, 203, 56, 57, 47, 583, 582, 584, 584,
90928 /* 500 */ 54, 54, 55, 55, 55, 55, 535, 53, 53, 53,
90929 /* 510 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 202,
90930 /* 520 */ 564, 293, 511, 49, 562, 46, 147, 411, 394, 183,
90931 /* 530 */ 563, 549, 505, 549, 174, 409, 322, 580, 580, 39,
90932 /* 540 */ 561, 37, 414, 624, 623, 192, 473, 383, 591, 585,
90933 /* 550 */ 474, 602, 80, 601, 504, 544, 560, 364, 402, 210,
90934 /* 560 */ 421, 952, 361, 952, 365, 201, 144, 56, 57, 47,
90935 /* 570 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90936 /* 580 */ 559, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90937 /* 590 */ 50, 238, 313, 601, 232, 264, 272, 321, 374, 484,
90938 /* 600 */ 510, 146, 342, 146, 328, 425, 485, 407, 576, 575,
90939 /* 610 */ 622, 621, 620, 49, 168, 46, 147, 353, 546, 491,
90940 /* 620 */ 204, 240, 591, 585, 421, 951, 549, 951, 549, 168,
90941 /* 630 */ 429, 67, 390, 343, 622, 434, 307, 423, 338, 360,
90942 /* 640 */ 391, 56, 57, 47, 583, 582, 584, 584, 54, 54,
90943 /* 650 */ 55, 55, 55, 55, 601, 53, 53, 53, 53, 52,
90944 /* 660 */ 52, 51, 51, 51, 50, 238, 313, 34, 318, 425,
90945 /* 670 */ 237, 21, 359, 273, 411, 167, 411, 276, 411, 540,
90946 /* 680 */ 411, 422, 13, 318, 619, 618, 617, 622, 275, 414,
90947 /* 690 */ 336, 414, 622, 414, 622, 414, 591, 585, 602, 69,
90948 /* 700 */ 602, 97, 602, 100, 602, 98, 631, 629, 334, 475,
90949 /* 710 */ 475, 367, 319, 148, 327, 56, 57, 47, 583, 582,
90950 /* 720 */ 584, 584, 54, 54, 55, 55, 55, 55, 411, 53,
90951 /* 730 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90952 /* 740 */ 313, 411, 331, 414, 411, 49, 276, 46, 147, 569,
90953 /* 750 */ 406, 216, 602, 106, 573, 573, 414, 354, 524, 414,
90954 /* 760 */ 411, 622, 411, 224, 4, 602, 104, 605, 602, 108,
90955 /* 770 */ 591, 585, 622, 20, 375, 414, 167, 414, 215, 144,
90956 /* 780 */ 470, 239, 167, 225, 602, 109, 602, 134, 18, 56,
90957 /* 790 */ 57, 47, 583, 582, 584, 584, 54, 54, 55, 55,
90958 /* 800 */ 55, 55, 411, 53, 53, 53, 53, 52, 52, 51,
90959 /* 810 */ 51, 51, 50, 238, 313, 411, 276, 414, 12, 459,
90960 /* 820 */ 276, 171, 411, 16, 223, 189, 602, 135, 354, 170,
90961 /* 830 */ 414, 622, 630, 2, 411, 622, 540, 414, 143, 602,
90962 /* 840 */ 61, 359, 132, 622, 591, 585, 602, 105, 458, 414,
90963 /* 850 */ 23, 622, 446, 326, 23, 538, 622, 325, 602, 103,
90964 /* 860 */ 427, 530, 309, 56, 57, 47, 583, 582, 584, 584,
90965 /* 870 */ 54, 54, 55, 55, 55, 55, 411, 53, 53, 53,
90966 /* 880 */ 53, 52, 52, 51, 51, 51, 50, 238, 313, 411,
90967 /* 890 */ 264, 414, 411, 276, 359, 219, 157, 214, 357, 366,
90968 /* 900 */ 602, 96, 522, 521, 414, 622, 358, 414, 622, 622,
90969 /* 910 */ 411, 613, 612, 602, 102, 142, 602, 77, 591, 585,
90970 /* 920 */ 529, 540, 231, 426, 308, 414, 622, 622, 468, 521,
90971 /* 930 */ 324, 601, 257, 263, 602, 99, 622, 56, 45, 47,
90972 /* 940 */ 583, 582, 584, 584, 54, 54, 55, 55, 55, 55,
90973 /* 950 */ 411, 53, 53, 53, 53, 52, 52, 51, 51, 51,
90974 /* 960 */ 50, 238, 313, 264, 264, 414, 411, 213, 209, 544,
90975 /* 970 */ 544, 207, 611, 28, 602, 138, 50, 238, 622, 622,
90976 /* 980 */ 381, 414, 503, 140, 323, 222, 274, 622, 590, 589,
90977 /* 990 */ 602, 137, 591, 585, 629, 334, 606, 30, 622, 571,
90978 /* 1000 */ 236, 601, 601, 130, 496, 601, 453, 451, 288, 286,
90979 /* 1010 */ 587, 586, 57, 47, 583, 582, 584, 584, 54, 54,
90980 /* 1020 */ 55, 55, 55, 55, 411, 53, 53, 53, 53, 52,
90981 /* 1030 */ 52, 51, 51, 51, 50, 238, 313, 588, 411, 414,
90982 /* 1040 */ 411, 264, 410, 129, 595, 400, 27, 376, 602, 136,
90983 /* 1050 */ 128, 165, 479, 414, 282, 414, 622, 622, 411, 622,
90984 /* 1060 */ 622, 411, 602, 76, 602, 93, 591, 585, 188, 372,
90985 /* 1070 */ 368, 125, 476, 414, 261, 160, 414, 171, 124, 472,
90986 /* 1080 */ 123, 15, 602, 92, 450, 602, 75, 47, 583, 582,
90987 /* 1090 */ 584, 584, 54, 54, 55, 55, 55, 55, 464, 53,
90988 /* 1100 */ 53, 53, 53, 52, 52, 51, 51, 51, 50, 238,
90989 /* 1110 */ 43, 405, 264, 3, 558, 264, 545, 415, 623, 159,
90990 /* 1120 */ 541, 158, 539, 278, 25, 461, 121, 622, 408, 622,
90991 /* 1130 */ 622, 622, 24, 43, 405, 622, 3, 622, 622, 120,
90992 /* 1140 */ 415, 623, 11, 456, 411, 156, 452, 403, 509, 277,
90993 /* 1150 */ 118, 408, 489, 113, 205, 449, 271, 567, 221, 414,
90994 /* 1160 */ 269, 267, 155, 622, 622, 111, 411, 622, 602, 95,
90995 /* 1170 */ 403, 622, 411, 110, 10, 622, 622, 40, 41, 534,
90996 /* 1180 */ 567, 414, 64, 264, 42, 413, 412, 414, 601, 596,
90997 /* 1190 */ 602, 91, 445, 436, 150, 435, 602, 90, 622, 265,
90998 /* 1200 */ 40, 41, 337, 242, 411, 191, 333, 42, 413, 412,
90999 /* 1210 */ 398, 420, 596, 316, 622, 399, 260, 107, 230, 414,
91000 /* 1220 */ 594, 594, 594, 593, 592, 14, 220, 411, 602, 101,
91001 /* 1230 */ 240, 622, 43, 405, 362, 3, 149, 315, 626, 415,
91002 /* 1240 */ 623, 127, 414, 594, 594, 594, 593, 592, 14, 622,
91003 /* 1250 */ 408, 602, 89, 411, 181, 33, 405, 463, 3, 411,
91004 /* 1260 */ 264, 462, 415, 623, 616, 615, 614, 355, 414, 403,
91005 /* 1270 */ 417, 416, 622, 408, 414, 622, 622, 602, 87, 567,
91006 /* 1280 */ 418, 627, 622, 602, 86, 8, 241, 180, 126, 255,
91007 /* 1290 */ 600, 178, 403, 240, 208, 455, 395, 294, 444, 40,
91008 /* 1300 */ 41, 297, 567, 248, 622, 296, 42, 413, 412, 247,
91009 /* 1310 */ 622, 596, 244, 622, 30, 60, 31, 243, 430, 624,
91010 /* 1320 */ 623, 292, 40, 41, 622, 295, 145, 622, 601, 42,
91011 /* 1330 */ 413, 412, 622, 622, 596, 393, 622, 397, 599, 59,
91012 /* 1340 */ 235, 622, 594, 594, 594, 593, 592, 14, 218, 291,
91013 /* 1350 */ 622, 36, 344, 305, 304, 303, 179, 301, 411, 567,
91014 /* 1360 */ 454, 557, 173, 185, 622, 594, 594, 594, 593, 592,
91015 /* 1370 */ 14, 411, 29, 414, 151, 289, 246, 523, 411, 196,
91016 /* 1380 */ 195, 335, 602, 85, 411, 245, 414, 526, 392, 543,
91017 /* 1390 */ 411, 596, 287, 414, 285, 602, 72, 537, 153, 414,
91018 /* 1400 */ 466, 411, 602, 71, 154, 414, 411, 152, 602, 84,
91019 /* 1410 */ 386, 536, 329, 411, 602, 83, 414, 518, 280, 411,
91020 /* 1420 */ 513, 414, 594, 594, 594, 602, 82, 517, 414, 311,
91021 /* 1430 */ 602, 81, 411, 514, 414, 512, 131, 602, 70, 229,
91022 /* 1440 */ 228, 227, 494, 602, 17, 411, 488, 414, 259, 346,
91023 /* 1450 */ 249, 389, 487, 486, 314, 164, 602, 79, 310, 240,
91024 /* 1460 */ 414, 373, 480, 163, 262, 371, 414, 162, 369, 602,
91025 /* 1470 */ 78, 212, 478, 26, 477, 602, 9, 161, 467, 363,
91026 /* 1480 */ 141, 122, 339, 187, 119, 457, 348, 117, 347, 116,
91027 /* 1490 */ 115, 114, 448, 112, 182, 320, 22, 433, 19, 432,
91028 /* 1500 */ 431, 63, 428, 610, 193, 298, 597, 574, 572, 404,
91029 /* 1510 */ 555, 552, 290, 281, 510, 499, 498, 497, 495, 380,
91030 /* 1520 */ 356, 460, 256, 250, 345, 447, 306, 5, 570, 550,
91031 /* 1530 */ 299, 211, 370, 401, 550, 508, 502, 501, 490, 527,
91032 /* 1540 */ 525, 483, 238,
91033 };
91034 static const YYCODETYPE yy_lookahead[] = {
91035 /* 0 */ 19, 222, 223, 224, 225, 24, 1, 26, 77, 78,
91036 /* 10 */ 79, 80, 15, 82, 83, 84, 85, 86, 87, 88,
91037 /* 20 */ 89, 90, 91, 92, 113, 22, 26, 27, 117, 26,
91038 /* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88,
91039 /* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68,
91040 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91041 /* 60 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
91042 /* 70 */ 89, 90, 91, 92, 19, 94, 118, 19, 150, 22,
91043 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91044 /* 90 */ 91, 92, 19, 165, 94, 95, 96, 94, 118, 99,
91045 /* 100 */ 100, 101, 174, 175, 49, 50, 22, 23, 96, 54,
91046 /* 110 */ 110, 99, 100, 101, 7, 8, 26, 27, 16, 105,
91047 /* 120 */ 106, 107, 110, 68, 69, 70, 71, 72, 73, 74,
91048 /* 130 */ 75, 76, 77, 78, 79, 80, 113, 82, 83, 84,
91049 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 16,
91050 /* 150 */ 92, 67, 98, 24, 96, 97, 98, 99, 100, 101,
91051 /* 160 */ 102, 25, 60, 109, 62, 92, 150, 109, 150, 25,
91052 /* 170 */ 97, 98, 99, 100, 101, 102, 86, 87, 49, 50,
91053 /* 180 */ 116, 165, 109, 165, 94, 95, 118, 97, 170, 171,
91054 /* 190 */ 174, 175, 128, 60, 104, 62, 106, 68, 69, 70,
91055 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91056 /* 210 */ 11, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91057 /* 220 */ 91, 92, 19, 21, 86, 87, 88, 89, 90, 91,
91058 /* 230 */ 92, 215, 96, 150, 66, 99, 100, 101, 22, 150,
91059 /* 240 */ 138, 118, 26, 27, 161, 162, 110, 103, 165, 231,
91060 /* 250 */ 232, 23, 49, 50, 165, 24, 57, 26, 32, 170,
91061 /* 260 */ 171, 112, 94, 114, 115, 63, 98, 41, 185, 186,
91062 /* 270 */ 118, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91063 /* 280 */ 77, 78, 79, 80, 12, 82, 83, 84, 85, 86,
91064 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
91065 /* 300 */ 28, 23, 100, 25, 105, 106, 107, 150, 26, 27,
91066 /* 310 */ 94, 95, 169, 170, 171, 116, 44, 23, 46, 150,
91067 /* 320 */ 231, 232, 165, 26, 27, 94, 49, 50, 23, 57,
91068 /* 330 */ 25, 174, 175, 22, 165, 26, 27, 26, 27, 136,
91069 /* 340 */ 138, 97, 98, 174, 175, 68, 69, 70, 71, 72,
91070 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 23, 82,
91071 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91072 /* 370 */ 19, 150, 23, 216, 23, 232, 94, 95, 221, 150,
91073 /* 380 */ 23, 160, 25, 214, 215, 163, 165, 88, 166, 167,
91074 /* 390 */ 168, 94, 95, 23, 165, 174, 175, 88, 160, 150,
91075 /* 400 */ 49, 50, 120, 94, 95, 94, 95, 158, 26, 57,
91076 /* 410 */ 161, 162, 113, 136, 165, 194, 117, 120, 22, 68,
91077 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91078 /* 430 */ 79, 80, 194, 82, 83, 84, 85, 86, 87, 88,
91079 /* 440 */ 89, 90, 91, 92, 19, 150, 23, 112, 23, 114,
91080 /* 450 */ 115, 25, 142, 143, 144, 145, 218, 105, 106, 107,
91081 /* 460 */ 165, 112, 150, 114, 115, 22, 150, 166, 116, 174,
91082 /* 470 */ 175, 22, 76, 235, 49, 50, 94, 165, 240, 172,
91083 /* 480 */ 173, 165, 112, 155, 114, 115, 174, 175, 181, 11,
91084 /* 490 */ 174, 175, 22, 68, 69, 70, 71, 72, 73, 74,
91085 /* 500 */ 75, 76, 77, 78, 79, 80, 205, 82, 83, 84,
91086 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 160,
91087 /* 520 */ 23, 226, 23, 222, 12, 224, 225, 150, 216, 23,
91088 /* 530 */ 23, 25, 36, 25, 25, 112, 220, 114, 115, 135,
91089 /* 540 */ 28, 137, 165, 26, 27, 119, 30, 51, 49, 50,
91090 /* 550 */ 34, 174, 175, 194, 58, 166, 44, 229, 46, 160,
91091 /* 560 */ 22, 23, 234, 25, 48, 206, 207, 68, 69, 70,
91092 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91093 /* 580 */ 23, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91094 /* 590 */ 91, 92, 19, 194, 205, 150, 23, 220, 19, 181,
91095 /* 600 */ 182, 95, 97, 95, 108, 67, 188, 169, 170, 171,
91096 /* 610 */ 165, 94, 95, 222, 50, 224, 225, 218, 120, 150,
91097 /* 620 */ 160, 116, 49, 50, 22, 23, 120, 25, 120, 50,
91098 /* 630 */ 161, 162, 19, 128, 165, 244, 22, 23, 193, 240,
91099 /* 640 */ 27, 68, 69, 70, 71, 72, 73, 74, 75, 76,
91100 /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
91101 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 25, 104, 67,
91102 /* 670 */ 232, 24, 150, 23, 150, 25, 150, 150, 150, 150,
91103 /* 680 */ 150, 67, 25, 104, 7, 8, 9, 165, 109, 165,
91104 /* 690 */ 245, 165, 165, 165, 165, 165, 49, 50, 174, 175,
91105 /* 700 */ 174, 175, 174, 175, 174, 175, 0, 1, 2, 105,
91106 /* 710 */ 106, 107, 248, 249, 187, 68, 69, 70, 71, 72,
91107 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
91108 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91109 /* 740 */ 19, 150, 213, 165, 150, 222, 150, 224, 225, 166,
91110 /* 750 */ 167, 168, 174, 175, 129, 130, 165, 150, 165, 165,
91111 /* 760 */ 150, 165, 150, 241, 35, 174, 175, 174, 174, 175,
91112 /* 770 */ 49, 50, 165, 52, 23, 165, 25, 165, 206, 207,
91113 /* 780 */ 23, 197, 25, 187, 174, 175, 174, 175, 204, 68,
91114 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
91115 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
91116 /* 810 */ 89, 90, 91, 92, 19, 150, 150, 165, 35, 23,
91117 /* 820 */ 150, 25, 150, 22, 217, 24, 174, 175, 150, 35,
91118 /* 830 */ 165, 165, 144, 145, 150, 165, 150, 165, 118, 174,
91119 /* 840 */ 175, 150, 22, 165, 49, 50, 174, 175, 23, 165,
91120 /* 850 */ 25, 165, 23, 187, 25, 27, 165, 187, 174, 175,
91121 /* 860 */ 23, 23, 25, 68, 69, 70, 71, 72, 73, 74,
91122 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
91123 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
91124 /* 890 */ 150, 165, 150, 150, 150, 217, 25, 160, 19, 213,
91125 /* 900 */ 174, 175, 190, 191, 165, 165, 27, 165, 165, 165,
91126 /* 910 */ 150, 150, 150, 174, 175, 39, 174, 175, 49, 50,
91127 /* 920 */ 23, 150, 52, 250, 251, 165, 165, 165, 190, 191,
91128 /* 930 */ 187, 194, 241, 193, 174, 175, 165, 68, 69, 70,
91129 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
91130 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
91131 /* 960 */ 91, 92, 19, 150, 150, 165, 150, 160, 160, 166,
91132 /* 970 */ 166, 160, 150, 22, 174, 175, 91, 92, 165, 165,
91133 /* 980 */ 52, 165, 29, 150, 213, 241, 23, 165, 49, 50,
91134 /* 990 */ 174, 175, 49, 50, 1, 2, 173, 126, 165, 86,
91135 /* 1000 */ 87, 194, 194, 22, 181, 194, 193, 193, 205, 205,
91136 /* 1010 */ 71, 72, 69, 70, 71, 72, 73, 74, 75, 76,
91137 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
91138 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 98, 150, 165,
91139 /* 1040 */ 150, 150, 150, 22, 150, 150, 22, 52, 174, 175,
91140 /* 1050 */ 22, 102, 20, 165, 109, 165, 165, 165, 150, 165,
91141 /* 1060 */ 165, 150, 174, 175, 174, 175, 49, 50, 24, 19,
91142 /* 1070 */ 43, 104, 59, 165, 138, 104, 165, 25, 53, 53,
91143 /* 1080 */ 22, 5, 174, 175, 193, 174, 175, 70, 71, 72,
91144 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 1, 82,
91145 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
91146 /* 1110 */ 19, 20, 150, 22, 150, 150, 150, 26, 27, 118,
91147 /* 1120 */ 150, 35, 150, 150, 76, 27, 108, 165, 37, 165,
91148 /* 1130 */ 165, 165, 76, 19, 20, 165, 22, 165, 165, 127,
91149 /* 1140 */ 26, 27, 22, 1, 150, 16, 20, 56, 150, 150,
91150 /* 1150 */ 119, 37, 150, 119, 160, 193, 150, 66, 193, 165,
91151 /* 1160 */ 150, 150, 121, 165, 165, 108, 150, 165, 174, 175,
91152 /* 1170 */ 56, 165, 150, 127, 22, 165, 165, 86, 87, 88,
91153 /* 1180 */ 66, 165, 16, 150, 93, 94, 95, 165, 194, 98,
91154 /* 1190 */ 174, 175, 128, 23, 15, 23, 174, 175, 165, 150,
91155 /* 1200 */ 86, 87, 65, 140, 150, 22, 3, 93, 94, 95,
91156 /* 1210 */ 216, 4, 98, 252, 165, 221, 150, 164, 180, 165,
91157 /* 1220 */ 129, 130, 131, 132, 133, 134, 193, 150, 174, 175,
91158 /* 1230 */ 116, 165, 19, 20, 150, 22, 249, 252, 149, 26,
91159 /* 1240 */ 27, 180, 165, 129, 130, 131, 132, 133, 134, 165,
91160 /* 1250 */ 37, 174, 175, 150, 6, 19, 20, 150, 22, 150,
91161 /* 1260 */ 150, 150, 26, 27, 149, 149, 13, 150, 165, 56,
91162 /* 1270 */ 149, 159, 165, 37, 165, 165, 165, 174, 175, 66,
91163 /* 1280 */ 146, 147, 165, 174, 175, 25, 152, 151, 154, 150,
91164 /* 1290 */ 194, 151, 56, 116, 160, 150, 123, 202, 150, 86,
91165 /* 1300 */ 87, 199, 66, 193, 165, 200, 93, 94, 95, 150,
91166 /* 1310 */ 165, 98, 150, 165, 126, 22, 124, 150, 150, 26,
91167 /* 1320 */ 27, 150, 86, 87, 165, 201, 150, 165, 194, 93,
91168 /* 1330 */ 94, 95, 165, 165, 98, 150, 165, 122, 203, 125,
91169 /* 1340 */ 227, 165, 129, 130, 131, 132, 133, 134, 5, 150,
91170 /* 1350 */ 165, 135, 218, 10, 11, 12, 13, 14, 150, 66,
91171 /* 1360 */ 17, 157, 118, 157, 165, 129, 130, 131, 132, 133,
91172 /* 1370 */ 134, 150, 104, 165, 31, 210, 33, 176, 150, 86,
91173 /* 1380 */ 87, 247, 174, 175, 150, 42, 165, 94, 121, 211,
91174 /* 1390 */ 150, 98, 210, 165, 210, 174, 175, 211, 55, 165,
91175 /* 1400 */ 57, 150, 174, 175, 61, 165, 150, 64, 174, 175,
91176 /* 1410 */ 104, 211, 47, 150, 174, 175, 165, 176, 176, 150,
91177 /* 1420 */ 103, 165, 129, 130, 131, 174, 175, 184, 165, 179,
91178 /* 1430 */ 174, 175, 150, 178, 165, 176, 22, 174, 175, 230,
91179 /* 1440 */ 92, 230, 184, 174, 175, 150, 176, 165, 105, 106,
91180 /* 1450 */ 107, 150, 176, 176, 111, 156, 174, 175, 179, 116,
91181 /* 1460 */ 165, 18, 157, 156, 238, 157, 165, 156, 45, 174,
91182 /* 1470 */ 175, 157, 157, 135, 239, 174, 175, 156, 189, 157,
91183 /* 1480 */ 68, 189, 139, 219, 22, 199, 157, 192, 18, 192,
91184 /* 1490 */ 192, 192, 199, 189, 219, 157, 243, 40, 243, 157,
91185 /* 1500 */ 157, 246, 38, 153, 196, 198, 166, 233, 233, 228,
91186 /* 1510 */ 177, 177, 209, 177, 182, 177, 166, 177, 166, 178,
91187 /* 1520 */ 242, 199, 242, 209, 209, 199, 148, 196, 166, 208,
91188 /* 1530 */ 195, 236, 237, 191, 208, 183, 183, 183, 186, 174,
91189 /* 1540 */ 174, 186, 92,
91190 };
91191 #define YY_SHIFT_USE_DFLT (-90)
91192 #define YY_SHIFT_COUNT (418)
91193 #define YY_SHIFT_MIN (-89)
91194 #define YY_SHIFT_MAX (1470)
91195 static const short yy_shift_ofst[] = {
91196 /* 0 */ 993, 1114, 1343, 1114, 1213, 1213, 90, 90, 0, -19,
91197 /* 10 */ 1213, 1213, 1213, 1213, 1213, 352, 517, 721, 1091, 1213,
91198 /* 20 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91199 /* 30 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91200 /* 40 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1236, 1213, 1213,
91201 /* 50 */ 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213, 1213,
91202 /* 60 */ 1213, -49, 199, 517, 517, 913, 913, 382, 1177, 55,
91203 /* 70 */ 647, 573, 499, 425, 351, 277, 203, 129, 795, 795,
91204 /* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795,
91205 /* 90 */ 795, 795, 795, 795, 795, 795, 869, 795, 943, 1017,
91206 /* 100 */ 1017, -69, -69, -69, -69, -1, -1, 58, 138, -44,
91207 /* 110 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91208 /* 120 */ 517, 517, 517, 517, 517, 517, 202, 579, 517, 517,
91209 /* 130 */ 517, 517, 517, 382, 885, 1450, -90, -90, -90, 1293,
91210 /* 140 */ 73, 272, 272, 309, 311, 297, 282, 216, 602, 538,
91211 /* 150 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91212 /* 160 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91213 /* 170 */ 517, 517, 517, 517, 517, 517, 517, 517, 517, 517,
91214 /* 180 */ 517, 517, 505, 231, 231, 231, 706, 64, 1177, 1177,
91215 /* 190 */ 1177, -90, -90, -90, 136, 168, 168, 12, 496, 496,
91216 /* 200 */ 496, 506, 423, 512, 370, 349, 335, 149, 149, 149,
91217 /* 210 */ 149, 604, 516, 149, 149, 508, 3, 299, 677, 871,
91218 /* 220 */ 613, 613, 879, 871, 879, 144, 382, 226, 382, 226,
91219 /* 230 */ 564, 226, 613, 226, 226, 404, 625, 625, 382, 426,
91220 /* 240 */ -89, 801, 1464, 1244, 1244, 1457, 1457, 1244, 1462, 1412,
91221 /* 250 */ 1188, 1470, 1470, 1470, 1470, 1244, 1188, 1462, 1412, 1412,
91222 /* 260 */ 1244, 1443, 1338, 1423, 1244, 1244, 1443, 1244, 1443, 1244,
91223 /* 270 */ 1443, 1414, 1306, 1306, 1306, 1365, 1348, 1348, 1414, 1306,
91224 /* 280 */ 1317, 1306, 1365, 1306, 1306, 1267, 1268, 1267, 1268, 1267,
91225 /* 290 */ 1268, 1244, 1244, 1216, 1214, 1215, 1192, 1173, 1188, 1177,
91226 /* 300 */ 1260, 1253, 1253, 1248, 1248, 1248, 1248, -90, -90, -90,
91227 /* 310 */ -90, -90, -90, 939, 102, 614, 84, 133, 14, 837,
91228 /* 320 */ 396, 829, 825, 796, 757, 751, 650, 357, 244, 107,
91229 /* 330 */ 54, 305, 278, 1207, 1203, 1183, 1063, 1179, 1137, 1166,
91230 /* 340 */ 1172, 1170, 1064, 1152, 1046, 1057, 1034, 1126, 1041, 1129,
91231 /* 350 */ 1142, 1031, 1120, 1012, 1056, 1048, 1018, 1098, 1086, 1001,
91232 /* 360 */ 1097, 1076, 1058, 971, 936, 1026, 1052, 1025, 1013, 1027,
91233 /* 370 */ 967, 1044, 1032, 1050, 945, 949, 1028, 995, 1024, 1021,
91234 /* 380 */ 963, 981, 928, 953, 951, 870, 876, 897, 838, 720,
91235 /* 390 */ 828, 794, 820, 498, 642, 783, 657, 729, 642, 557,
91236 /* 400 */ 507, 509, 497, 470, 478, 449, 294, 228, 443, 23,
91237 /* 410 */ 152, 123, 68, -20, -42, 57, 39, -3, 5,
91238 };
91239 #define YY_REDUCE_USE_DFLT (-222)
91240 #define YY_REDUCE_COUNT (312)
91241 #define YY_REDUCE_MIN (-221)
91242 #define YY_REDUCE_MAX (1378)
91243 static const short yy_reduce_ofst[] = {
91244 /* 0 */ 310, 994, 1134, 221, 169, 157, 89, 18, 83, 301,
91245 /* 10 */ 377, 316, 312, 16, 295, 238, 249, 391, 1301, 1295,
91246 /* 20 */ 1282, 1269, 1263, 1256, 1251, 1240, 1234, 1228, 1221, 1208,
91247 /* 30 */ 1109, 1103, 1077, 1054, 1022, 1016, 911, 908, 890, 888,
91248 /* 40 */ 874, 816, 800, 760, 742, 739, 726, 684, 672, 665,
91249 /* 50 */ 652, 612, 610, 594, 591, 578, 530, 528, 526, 524,
91250 /* 60 */ -72, -221, 399, 469, 445, 438, 143, 222, 359, 523,
91251 /* 70 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91252 /* 80 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91253 /* 90 */ 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
91254 /* 100 */ 523, 523, 523, 523, 523, 523, 523, 307, 523, 523,
91255 /* 110 */ 1110, 678, 1033, 965, 962, 891, 814, 813, 744, 771,
91256 /* 120 */ 691, 607, 522, 743, 686, 740, 328, 418, 670, 666,
91257 /* 130 */ 596, 527, 529, 583, 523, 523, 523, 523, 523, 593,
91258 /* 140 */ 823, 738, 712, 892, 1199, 1185, 1176, 1171, 673, 673,
91259 /* 150 */ 1168, 1167, 1162, 1159, 1148, 1145, 1139, 1117, 1111, 1107,
91260 /* 160 */ 1084, 1066, 1049, 1011, 1010, 1006, 1002, 999, 998, 973,
91261 /* 170 */ 972, 970, 966, 964, 895, 894, 892, 833, 822, 762,
91262 /* 180 */ 761, 229, 811, 804, 803, 389, 688, 808, 807, 737,
91263 /* 190 */ 460, 464, 572, 584, 1355, 1366, 1365, 1352, 1354, 1353,
91264 /* 200 */ 1352, 1326, 1335, 1342, 1335, 1335, 1335, 1335, 1335, 1335,
91265 /* 210 */ 1335, 1295, 1295, 1335, 1335, 1321, 1362, 1331, 1378, 1326,
91266 /* 220 */ 1315, 1314, 1280, 1322, 1278, 1341, 1352, 1340, 1350, 1338,
91267 /* 230 */ 1332, 1336, 1303, 1334, 1333, 1281, 1275, 1274, 1340, 1307,
91268 /* 240 */ 1308, 1350, 1255, 1343, 1342, 1255, 1253, 1338, 1275, 1304,
91269 /* 250 */ 1293, 1299, 1298, 1297, 1295, 1329, 1286, 1264, 1292, 1289,
91270 /* 260 */ 1322, 1321, 1235, 1226, 1315, 1314, 1311, 1308, 1307, 1305,
91271 /* 270 */ 1299, 1279, 1277, 1276, 1270, 1258, 1211, 1209, 1250, 1259,
91272 /* 280 */ 1255, 1242, 1243, 1241, 1201, 1200, 1184, 1186, 1182, 1178,
91273 /* 290 */ 1165, 1206, 1204, 1113, 1135, 1095, 1124, 1105, 1102, 1096,
91274 /* 300 */ 1112, 1140, 1136, 1121, 1116, 1115, 1089, 985, 961, 987,
91275 /* 310 */ 1061, 1038, 1053,
91276 };
91277 static const YYACTIONTYPE yy_default[] = {
91278 /* 0 */ 636, 872, 961, 961, 961, 872, 901, 901, 961, 760,
91279 /* 10 */ 961, 961, 961, 961, 870, 961, 961, 935, 961, 961,
91280 /* 20 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91281 /* 30 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91282 /* 40 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91283 /* 50 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91284 /* 60 */ 961, 844, 961, 961, 961, 901, 901, 675, 764, 795,
91285 /* 70 */ 961, 961, 961, 961, 961, 961, 961, 961, 934, 936,
91286 /* 80 */ 810, 809, 803, 802, 914, 775, 800, 793, 786, 797,
91287 /* 90 */ 873, 866, 867, 865, 869, 874, 961, 796, 832, 850,
91288 /* 100 */ 831, 849, 856, 848, 834, 843, 833, 667, 835, 836,
91289 /* 110 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91290 /* 120 */ 961, 961, 961, 961, 961, 961, 662, 729, 961, 961,
91291 /* 130 */ 961, 961, 961, 961, 837, 838, 853, 852, 851, 961,
91292 /* 140 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91293 /* 150 */ 961, 941, 939, 961, 885, 961, 961, 961, 961, 961,
91294 /* 160 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91295 /* 170 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91296 /* 180 */ 961, 642, 961, 760, 760, 760, 636, 961, 961, 961,
91297 /* 190 */ 961, 953, 764, 754, 720, 961, 961, 961, 961, 961,
91298 /* 200 */ 961, 961, 961, 961, 961, 961, 961, 805, 743, 924,
91299 /* 210 */ 926, 961, 907, 741, 664, 762, 677, 752, 644, 799,
91300 /* 220 */ 777, 777, 919, 799, 919, 701, 961, 789, 961, 789,
91301 /* 230 */ 698, 789, 777, 789, 789, 868, 961, 961, 961, 761,
91302 /* 240 */ 752, 961, 946, 768, 768, 938, 938, 768, 811, 733,
91303 /* 250 */ 799, 740, 740, 740, 740, 768, 799, 811, 733, 733,
91304 /* 260 */ 768, 659, 913, 911, 768, 768, 659, 768, 659, 768,
91305 /* 270 */ 659, 878, 731, 731, 731, 716, 882, 882, 878, 731,
91306 /* 280 */ 701, 731, 716, 731, 731, 781, 776, 781, 776, 781,
91307 /* 290 */ 776, 768, 768, 961, 794, 782, 792, 790, 799, 961,
91308 /* 300 */ 719, 652, 652, 641, 641, 641, 641, 958, 958, 953,
91309 /* 310 */ 703, 703, 685, 961, 961, 961, 961, 961, 961, 961,
91310 /* 320 */ 887, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91311 /* 330 */ 961, 961, 961, 961, 637, 948, 961, 961, 945, 961,
91312 /* 340 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91313 /* 350 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 917,
91314 /* 360 */ 961, 961, 961, 961, 961, 961, 910, 909, 961, 961,
91315 /* 370 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91316 /* 380 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 961,
91317 /* 390 */ 961, 961, 961, 961, 791, 961, 783, 961, 871, 961,
91318 /* 400 */ 961, 961, 961, 961, 961, 961, 961, 961, 961, 746,
91319 /* 410 */ 820, 961, 819, 823, 818, 669, 961, 650, 961, 633,
91320 /* 420 */ 638, 957, 960, 959, 956, 955, 954, 949, 947, 944,
91321 /* 430 */ 943, 942, 940, 937, 933, 891, 889, 896, 895, 894,
91322 /* 440 */ 893, 892, 890, 888, 886, 806, 804, 801, 798, 932,
91323 /* 450 */ 884, 742, 739, 738, 658, 950, 916, 925, 923, 812,
91324 /* 460 */ 922, 921, 920, 918, 915, 902, 808, 807, 734, 876,
91325 /* 470 */ 875, 661, 906, 905, 904, 908, 912, 903, 770, 660,
91326 /* 480 */ 657, 666, 723, 722, 730, 728, 727, 726, 725, 724,
91327 /* 490 */ 721, 668, 676, 687, 715, 700, 699, 881, 883, 880,
91328 /* 500 */ 879, 708, 707, 713, 712, 711, 710, 709, 706, 705,
91329 /* 510 */ 704, 697, 696, 702, 695, 718, 717, 714, 694, 737,
91330 /* 520 */ 736, 735, 732, 693, 692, 691, 823, 690, 689, 829,
91331 /* 530 */ 828, 816, 860, 757, 756, 755, 767, 766, 779, 778,
91332 /* 540 */ 814, 813, 780, 765, 759, 758, 774, 773, 772, 771,
91333 /* 550 */ 763, 753, 785, 788, 787, 784, 845, 862, 769, 859,
91334 /* 560 */ 931, 930, 929, 928, 927, 864, 863, 830, 827, 680,
91335 /* 570 */ 681, 900, 898, 899, 897, 683, 682, 679, 678, 861,
91336 /* 580 */ 748, 747, 857, 854, 846, 841, 858, 855, 847, 842,
91337 /* 590 */ 840, 839, 825, 824, 822, 821, 817, 826, 671, 749,
91338 /* 600 */ 745, 744, 815, 751, 750, 688, 686, 684, 665, 663,
91339 /* 610 */ 656, 654, 653, 655, 651, 649, 648, 647, 646, 645,
91340 /* 620 */ 674, 673, 672, 670, 669, 643, 640, 639, 635, 634,
91341 /* 630 */ 632,
91342 };
91343
91344 /* The next table maps tokens into fallback tokens. If a construct
91345 ** like the following:
91346 **
@@ -91487,17 +91521,17 @@
91521 "LSHIFT", "RSHIFT", "PLUS", "MINUS",
91522 "STAR", "SLASH", "REM", "CONCAT",
91523 "COLLATE", "BITNOT", "STRING", "JOIN_KW",
91524 "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY",
91525 "UNIQUE", "CHECK", "REFERENCES", "AUTOINCR",
91526 "ON", "INSERT", "DELETE", "UPDATE",
91527 "SET", "DEFERRABLE", "FOREIGN", "DROP",
91528 "UNION", "ALL", "EXCEPT", "INTERSECT",
91529 "SELECT", "DISTINCT", "DOT", "FROM",
91530 "JOIN", "USING", "ORDER", "GROUP",
91531 "HAVING", "LIMIT", "WHERE", "INTO",
91532 "VALUES", "INTEGER", "FLOAT", "BLOB",
91533 "REGISTER", "VARIABLE", "CASE", "WHEN",
91534 "THEN", "ELSE", "INDEX", "ALTER",
91535 "ADD", "error", "input", "cmdlist",
91536 "ecmd", "explain", "cmdx", "cmd",
91537 "transtype", "trans_opt", "nm", "savepoint_opt",
@@ -91607,264 +91641,265 @@
91641 /* 70 */ "autoinc ::=",
91642 /* 71 */ "autoinc ::= AUTOINCR",
91643 /* 72 */ "refargs ::=",
91644 /* 73 */ "refargs ::= refargs refarg",
91645 /* 74 */ "refarg ::= MATCH nm",
91646 /* 75 */ "refarg ::= ON INSERT refact",
91647 /* 76 */ "refarg ::= ON DELETE refact",
91648 /* 77 */ "refarg ::= ON UPDATE refact",
91649 /* 78 */ "refact ::= SET NULL",
91650 /* 79 */ "refact ::= SET DEFAULT",
91651 /* 80 */ "refact ::= CASCADE",
91652 /* 81 */ "refact ::= RESTRICT",
91653 /* 82 */ "refact ::= NO ACTION",
91654 /* 83 */ "defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt",
91655 /* 84 */ "defer_subclause ::= DEFERRABLE init_deferred_pred_opt",
91656 /* 85 */ "init_deferred_pred_opt ::=",
91657 /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
91658 /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
91659 /* 88 */ "conslist_opt ::=",
91660 /* 89 */ "conslist_opt ::= COMMA conslist",
91661 /* 90 */ "conslist ::= conslist COMMA tcons",
91662 /* 91 */ "conslist ::= conslist tcons",
91663 /* 92 */ "conslist ::= tcons",
91664 /* 93 */ "tcons ::= CONSTRAINT nm",
91665 /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
91666 /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
91667 /* 96 */ "tcons ::= CHECK LP expr RP onconf",
91668 /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
91669 /* 98 */ "defer_subclause_opt ::=",
91670 /* 99 */ "defer_subclause_opt ::= defer_subclause",
91671 /* 100 */ "onconf ::=",
91672 /* 101 */ "onconf ::= ON CONFLICT resolvetype",
91673 /* 102 */ "orconf ::=",
91674 /* 103 */ "orconf ::= OR resolvetype",
91675 /* 104 */ "resolvetype ::= raisetype",
91676 /* 105 */ "resolvetype ::= IGNORE",
91677 /* 106 */ "resolvetype ::= REPLACE",
91678 /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
91679 /* 108 */ "ifexists ::= IF EXISTS",
91680 /* 109 */ "ifexists ::=",
91681 /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
91682 /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
91683 /* 112 */ "cmd ::= select",
91684 /* 113 */ "select ::= oneselect",
91685 /* 114 */ "select ::= select multiselect_op oneselect",
91686 /* 115 */ "multiselect_op ::= UNION",
91687 /* 116 */ "multiselect_op ::= UNION ALL",
91688 /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
91689 /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
91690 /* 119 */ "distinct ::= DISTINCT",
91691 /* 120 */ "distinct ::= ALL",
91692 /* 121 */ "distinct ::=",
91693 /* 122 */ "sclp ::= selcollist COMMA",
91694 /* 123 */ "sclp ::=",
91695 /* 124 */ "selcollist ::= sclp expr as",
91696 /* 125 */ "selcollist ::= sclp STAR",
91697 /* 126 */ "selcollist ::= sclp nm DOT STAR",
91698 /* 127 */ "as ::= AS nm",
91699 /* 128 */ "as ::= ids",
91700 /* 129 */ "as ::=",
91701 /* 130 */ "from ::=",
91702 /* 131 */ "from ::= FROM seltablist",
91703 /* 132 */ "stl_prefix ::= seltablist joinop",
91704 /* 133 */ "stl_prefix ::=",
91705 /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
91706 /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
91707 /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
91708 /* 137 */ "dbnm ::=",
91709 /* 138 */ "dbnm ::= DOT nm",
91710 /* 139 */ "fullname ::= nm dbnm",
91711 /* 140 */ "joinop ::= COMMA|JOIN",
91712 /* 141 */ "joinop ::= JOIN_KW JOIN",
91713 /* 142 */ "joinop ::= JOIN_KW nm JOIN",
91714 /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
91715 /* 144 */ "on_opt ::= ON expr",
91716 /* 145 */ "on_opt ::=",
91717 /* 146 */ "indexed_opt ::=",
91718 /* 147 */ "indexed_opt ::= INDEXED BY nm",
91719 /* 148 */ "indexed_opt ::= NOT INDEXED",
91720 /* 149 */ "using_opt ::= USING LP inscollist RP",
91721 /* 150 */ "using_opt ::=",
91722 /* 151 */ "orderby_opt ::=",
91723 /* 152 */ "orderby_opt ::= ORDER BY sortlist",
91724 /* 153 */ "sortlist ::= sortlist COMMA sortitem sortorder",
91725 /* 154 */ "sortlist ::= sortitem sortorder",
91726 /* 155 */ "sortitem ::= expr",
91727 /* 156 */ "sortorder ::= ASC",
91728 /* 157 */ "sortorder ::= DESC",
91729 /* 158 */ "sortorder ::=",
91730 /* 159 */ "groupby_opt ::=",
91731 /* 160 */ "groupby_opt ::= GROUP BY nexprlist",
91732 /* 161 */ "having_opt ::=",
91733 /* 162 */ "having_opt ::= HAVING expr",
91734 /* 163 */ "limit_opt ::=",
91735 /* 164 */ "limit_opt ::= LIMIT expr",
91736 /* 165 */ "limit_opt ::= LIMIT expr OFFSET expr",
91737 /* 166 */ "limit_opt ::= LIMIT expr COMMA expr",
91738 /* 167 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
91739 /* 168 */ "where_opt ::=",
91740 /* 169 */ "where_opt ::= WHERE expr",
91741 /* 170 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
91742 /* 171 */ "setlist ::= setlist COMMA nm EQ expr",
91743 /* 172 */ "setlist ::= nm EQ expr",
91744 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP",
91745 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
91746 /* 175 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
91747 /* 176 */ "insert_cmd ::= INSERT orconf",
91748 /* 177 */ "insert_cmd ::= REPLACE",
91749 /* 178 */ "itemlist ::= itemlist COMMA expr",
91750 /* 179 */ "itemlist ::= expr",
91751 /* 180 */ "inscollist_opt ::=",
91752 /* 181 */ "inscollist_opt ::= LP inscollist RP",
91753 /* 182 */ "inscollist ::= inscollist COMMA nm",
91754 /* 183 */ "inscollist ::= nm",
91755 /* 184 */ "expr ::= term",
91756 /* 185 */ "expr ::= LP expr RP",
91757 /* 186 */ "term ::= NULL",
91758 /* 187 */ "expr ::= id",
91759 /* 188 */ "expr ::= JOIN_KW",
91760 /* 189 */ "expr ::= nm DOT nm",
91761 /* 190 */ "expr ::= nm DOT nm DOT nm",
91762 /* 191 */ "term ::= INTEGER|FLOAT|BLOB",
91763 /* 192 */ "term ::= STRING",
91764 /* 193 */ "expr ::= REGISTER",
91765 /* 194 */ "expr ::= VARIABLE",
91766 /* 195 */ "expr ::= expr COLLATE ids",
91767 /* 196 */ "expr ::= CAST LP expr AS typetoken RP",
91768 /* 197 */ "expr ::= ID LP distinct exprlist RP",
91769 /* 198 */ "expr ::= ID LP STAR RP",
91770 /* 199 */ "term ::= CTIME_KW",
91771 /* 200 */ "expr ::= expr AND expr",
91772 /* 201 */ "expr ::= expr OR expr",
91773 /* 202 */ "expr ::= expr LT|GT|GE|LE expr",
91774 /* 203 */ "expr ::= expr EQ|NE expr",
91775 /* 204 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
91776 /* 205 */ "expr ::= expr PLUS|MINUS expr",
91777 /* 206 */ "expr ::= expr STAR|SLASH|REM expr",
91778 /* 207 */ "expr ::= expr CONCAT expr",
91779 /* 208 */ "likeop ::= LIKE_KW",
91780 /* 209 */ "likeop ::= NOT LIKE_KW",
91781 /* 210 */ "likeop ::= MATCH",
91782 /* 211 */ "likeop ::= NOT MATCH",
91783 /* 212 */ "escape ::= ESCAPE expr",
91784 /* 213 */ "escape ::=",
91785 /* 214 */ "expr ::= expr likeop expr escape",
91786 /* 215 */ "expr ::= expr ISNULL|NOTNULL",
91787 /* 216 */ "expr ::= expr NOT NULL",
91788 /* 217 */ "expr ::= expr IS expr",
91789 /* 218 */ "expr ::= expr IS NOT expr",
91790 /* 219 */ "expr ::= NOT expr",
91791 /* 220 */ "expr ::= BITNOT expr",
91792 /* 221 */ "expr ::= MINUS expr",
91793 /* 222 */ "expr ::= PLUS expr",
91794 /* 223 */ "between_op ::= BETWEEN",
91795 /* 224 */ "between_op ::= NOT BETWEEN",
91796 /* 225 */ "expr ::= expr between_op expr AND expr",
91797 /* 226 */ "in_op ::= IN",
91798 /* 227 */ "in_op ::= NOT IN",
91799 /* 228 */ "expr ::= expr in_op LP exprlist RP",
91800 /* 229 */ "expr ::= LP select RP",
91801 /* 230 */ "expr ::= expr in_op LP select RP",
91802 /* 231 */ "expr ::= expr in_op nm dbnm",
91803 /* 232 */ "expr ::= EXISTS LP select RP",
91804 /* 233 */ "expr ::= CASE case_operand case_exprlist case_else END",
91805 /* 234 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
91806 /* 235 */ "case_exprlist ::= WHEN expr THEN expr",
91807 /* 236 */ "case_else ::= ELSE expr",
91808 /* 237 */ "case_else ::=",
91809 /* 238 */ "case_operand ::= expr",
91810 /* 239 */ "case_operand ::=",
91811 /* 240 */ "exprlist ::= nexprlist",
91812 /* 241 */ "exprlist ::=",
91813 /* 242 */ "nexprlist ::= nexprlist COMMA expr",
91814 /* 243 */ "nexprlist ::= expr",
91815 /* 244 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
91816 /* 245 */ "uniqueflag ::= UNIQUE",
91817 /* 246 */ "uniqueflag ::=",
91818 /* 247 */ "idxlist_opt ::=",
91819 /* 248 */ "idxlist_opt ::= LP idxlist RP",
91820 /* 249 */ "idxlist ::= idxlist COMMA nm collate sortorder",
91821 /* 250 */ "idxlist ::= nm collate sortorder",
91822 /* 251 */ "collate ::=",
91823 /* 252 */ "collate ::= COLLATE ids",
91824 /* 253 */ "cmd ::= DROP INDEX ifexists fullname",
91825 /* 254 */ "cmd ::= VACUUM",
91826 /* 255 */ "cmd ::= VACUUM nm",
91827 /* 256 */ "cmd ::= PRAGMA nm dbnm",
91828 /* 257 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
91829 /* 258 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
91830 /* 259 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
91831 /* 260 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
91832 /* 261 */ "nmnum ::= plus_num",
91833 /* 262 */ "nmnum ::= nm",
91834 /* 263 */ "nmnum ::= ON",
91835 /* 264 */ "nmnum ::= DELETE",
91836 /* 265 */ "nmnum ::= DEFAULT",
91837 /* 266 */ "plus_num ::= plus_opt number",
91838 /* 267 */ "minus_num ::= MINUS number",
91839 /* 268 */ "number ::= INTEGER|FLOAT",
91840 /* 269 */ "plus_opt ::= PLUS",
91841 /* 270 */ "plus_opt ::=",
91842 /* 271 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
91843 /* 272 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
91844 /* 273 */ "trigger_time ::= BEFORE",
91845 /* 274 */ "trigger_time ::= AFTER",
91846 /* 275 */ "trigger_time ::= INSTEAD OF",
91847 /* 276 */ "trigger_time ::=",
91848 /* 277 */ "trigger_event ::= DELETE|INSERT",
91849 /* 278 */ "trigger_event ::= UPDATE",
91850 /* 279 */ "trigger_event ::= UPDATE OF inscollist",
91851 /* 280 */ "foreach_clause ::=",
91852 /* 281 */ "foreach_clause ::= FOR EACH ROW",
91853 /* 282 */ "when_clause ::=",
91854 /* 283 */ "when_clause ::= WHEN expr",
91855 /* 284 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
91856 /* 285 */ "trigger_cmd_list ::= trigger_cmd SEMI",
91857 /* 286 */ "trnm ::= nm",
91858 /* 287 */ "trnm ::= nm DOT nm",
91859 /* 288 */ "tridxby ::=",
91860 /* 289 */ "tridxby ::= INDEXED BY nm",
91861 /* 290 */ "tridxby ::= NOT INDEXED",
91862 /* 291 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
91863 /* 292 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP",
91864 /* 293 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
91865 /* 294 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
91866 /* 295 */ "trigger_cmd ::= select",
91867 /* 296 */ "expr ::= RAISE LP IGNORE RP",
91868 /* 297 */ "expr ::= RAISE LP raisetype COMMA nm RP",
91869 /* 298 */ "raisetype ::= ROLLBACK",
91870 /* 299 */ "raisetype ::= ABORT",
91871 /* 300 */ "raisetype ::= FAIL",
91872 /* 301 */ "cmd ::= DROP TRIGGER ifexists fullname",
91873 /* 302 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
91874 /* 303 */ "cmd ::= DETACH database_kw_opt expr",
91875 /* 304 */ "key_opt ::=",
91876 /* 305 */ "key_opt ::= KEY expr",
91877 /* 306 */ "database_kw_opt ::= DATABASE",
91878 /* 307 */ "database_kw_opt ::=",
91879 /* 308 */ "cmd ::= REINDEX",
91880 /* 309 */ "cmd ::= REINDEX nm dbnm",
91881 /* 310 */ "cmd ::= ANALYZE",
91882 /* 311 */ "cmd ::= ANALYZE nm dbnm",
91883 /* 312 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
91884 /* 313 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
91885 /* 314 */ "add_column_fullname ::= fullname",
91886 /* 315 */ "kwcolumn_opt ::=",
91887 /* 316 */ "kwcolumn_opt ::= COLUMNKW",
91888 /* 317 */ "cmd ::= create_vtab",
91889 /* 318 */ "cmd ::= create_vtab LP vtabarglist RP",
91890 /* 319 */ "create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm",
91891 /* 320 */ "vtabarglist ::= vtabarg",
91892 /* 321 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
91893 /* 322 */ "vtabarg ::=",
91894 /* 323 */ "vtabarg ::= vtabarg vtabargtoken",
91895 /* 324 */ "vtabargtoken ::= ANY",
91896 /* 325 */ "vtabargtoken ::= lp anylist RP",
91897 /* 326 */ "lp ::= LP",
91898 /* 327 */ "anylist ::=",
91899 /* 328 */ "anylist ::= anylist LP anylist RP",
91900 /* 329 */ "anylist ::= anylist ANY",
91901 };
91902 #endif /* NDEBUG */
91903
91904
91905 #if YYSTACKDEPTH<=0
@@ -92326,10 +92361,11 @@
92361 { 180, 0 },
92362 { 180, 2 },
92363 { 182, 2 },
92364 { 182, 3 },
92365 { 182, 3 },
92366 { 182, 3 },
92367 { 183, 2 },
92368 { 183, 2 },
92369 { 183, 1 },
92370 { 183, 1 },
92371 { 183, 2 },
@@ -92653,12 +92689,12 @@
92689 {yygotominor.yy328 = TK_DEFERRED;}
92690 break;
92691 case 14: /* transtype ::= DEFERRED */
92692 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
92693 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
92694 case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
92695 case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
92696 {yygotominor.yy328 = yymsp[0].major;}
92697 break;
92698 case 17: /* cmd ::= COMMIT trans_opt */
92699 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
92700 {sqlite3CommitTransaction(pParse);}
@@ -92693,29 +92729,29 @@
92729 }
92730 break;
92731 case 28: /* ifnotexists ::= */
92732 case 31: /* temp ::= */ yytestcase(yyruleno==31);
92733 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
92734 case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
92735 case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
92736 case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
92737 case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
92738 case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
92739 case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
92740 case 121: /* distinct ::= */ yytestcase(yyruleno==121);
92741 case 223: /* between_op ::= BETWEEN */ yytestcase(yyruleno==223);
92742 case 226: /* in_op ::= IN */ yytestcase(yyruleno==226);
92743 {yygotominor.yy328 = 0;}
92744 break;
92745 case 29: /* ifnotexists ::= IF NOT EXISTS */
92746 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
92747 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
92748 case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
92749 case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
92750 case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
92751 case 224: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==224);
92752 case 227: /* in_op ::= NOT IN */ yytestcase(yyruleno==227);
92753 {yygotominor.yy328 = 1;}
92754 break;
92755 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
92756 {
92757 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -92745,24 +92781,24 @@
92781 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
92782 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
92783 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
92784 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
92785 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
92786 case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
92787 case 128: /* as ::= ids */ yytestcase(yyruleno==128);
92788 case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
92789 case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
92790 case 252: /* collate ::= COLLATE ids */ yytestcase(yyruleno==252);
92791 case 261: /* nmnum ::= plus_num */ yytestcase(yyruleno==261);
92792 case 262: /* nmnum ::= nm */ yytestcase(yyruleno==262);
92793 case 263: /* nmnum ::= ON */ yytestcase(yyruleno==263);
92794 case 264: /* nmnum ::= DELETE */ yytestcase(yyruleno==264);
92795 case 265: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==265);
92796 case 266: /* plus_num ::= plus_opt number */ yytestcase(yyruleno==266);
92797 case 267: /* minus_num ::= MINUS number */ yytestcase(yyruleno==267);
92798 case 268: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==268);
92799 case 286: /* trnm ::= nm */ yytestcase(yyruleno==286);
92800 {yygotominor.yy0 = yymsp[0].minor.yy0;}
92801 break;
92802 case 45: /* type ::= typetoken */
92803 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
92804 break;
@@ -92830,101 +92866,102 @@
92866 break;
92867 case 73: /* refargs ::= refargs refarg */
92868 { yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; }
92869 break;
92870 case 74: /* refarg ::= MATCH nm */
92871 case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75);
92872 { yygotominor.yy429.value = 0; yygotominor.yy429.mask = 0x000000; }
92873 break;
92874 case 76: /* refarg ::= ON DELETE refact */
92875 { yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; }
92876 break;
92877 case 77: /* refarg ::= ON UPDATE refact */
92878 { yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; }
92879 break;
92880 case 78: /* refact ::= SET NULL */
92881 { yygotominor.yy328 = OE_SetNull; /* EV: R-33326-45252 */}
92882 break;
92883 case 79: /* refact ::= SET DEFAULT */
92884 { yygotominor.yy328 = OE_SetDflt; /* EV: R-33326-45252 */}
92885 break;
92886 case 80: /* refact ::= CASCADE */
92887 { yygotominor.yy328 = OE_Cascade; /* EV: R-33326-45252 */}
92888 break;
92889 case 81: /* refact ::= RESTRICT */
92890 { yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */}
92891 break;
92892 case 82: /* refact ::= NO ACTION */
92893 { yygotominor.yy328 = OE_None; /* EV: R-33326-45252 */}
92894 break;
92895 case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
92896 case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
92897 case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
92898 case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
92899 {yygotominor.yy328 = yymsp[0].minor.yy328;}
92900 break;
92901 case 88: /* conslist_opt ::= */
92902 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
92903 break;
92904 case 89: /* conslist_opt ::= COMMA conslist */
92905 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
92906 break;
92907 case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
92908 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);}
92909 break;
92910 case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
92911 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);}
92912 break;
92913 case 96: /* tcons ::= CHECK LP expr RP onconf */
92914 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);}
92915 break;
92916 case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
92917 {
92918 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328);
92919 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328);
92920 }
92921 break;
92922 case 100: /* onconf ::= */
92923 {yygotominor.yy328 = OE_Default;}
92924 break;
92925 case 102: /* orconf ::= */
92926 {yygotominor.yy186 = OE_Default;}
92927 break;
92928 case 103: /* orconf ::= OR resolvetype */
92929 {yygotominor.yy186 = (u8)yymsp[0].minor.yy328;}
92930 break;
92931 case 105: /* resolvetype ::= IGNORE */
92932 {yygotominor.yy328 = OE_Ignore;}
92933 break;
92934 case 106: /* resolvetype ::= REPLACE */
92935 {yygotominor.yy328 = OE_Replace;}
92936 break;
92937 case 107: /* cmd ::= DROP TABLE ifexists fullname */
92938 {
92939 sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328);
92940 }
92941 break;
92942 case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
92943 {
92944 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy3, yymsp[-6].minor.yy328, yymsp[-4].minor.yy328);
92945 }
92946 break;
92947 case 111: /* cmd ::= DROP VIEW ifexists fullname */
92948 {
92949 sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328);
92950 }
92951 break;
92952 case 112: /* cmd ::= select */
92953 {
92954 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
92955 sqlite3Select(pParse, yymsp[0].minor.yy3, &dest);
92956 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
92957 }
92958 break;
92959 case 113: /* select ::= oneselect */
92960 {yygotominor.yy3 = yymsp[0].minor.yy3;}
92961 break;
92962 case 114: /* select ::= select multiselect_op oneselect */
92963 {
92964 if( yymsp[0].minor.yy3 ){
92965 yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328;
92966 yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3;
92967 }else{
@@ -92931,83 +92968,83 @@
92968 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
92969 }
92970 yygotominor.yy3 = yymsp[0].minor.yy3;
92971 }
92972 break;
92973 case 116: /* multiselect_op ::= UNION ALL */
92974 {yygotominor.yy328 = TK_ALL;}
92975 break;
92976 case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
92977 {
92978 yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy14,yymsp[-5].minor.yy65,yymsp[-4].minor.yy132,yymsp[-3].minor.yy14,yymsp[-2].minor.yy132,yymsp[-1].minor.yy14,yymsp[-7].minor.yy328,yymsp[0].minor.yy476.pLimit,yymsp[0].minor.yy476.pOffset);
92979 }
92980 break;
92981 case 122: /* sclp ::= selcollist COMMA */
92982 case 248: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==248);
92983 {yygotominor.yy14 = yymsp[-1].minor.yy14;}
92984 break;
92985 case 123: /* sclp ::= */
92986 case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
92987 case 159: /* groupby_opt ::= */ yytestcase(yyruleno==159);
92988 case 241: /* exprlist ::= */ yytestcase(yyruleno==241);
92989 case 247: /* idxlist_opt ::= */ yytestcase(yyruleno==247);
92990 {yygotominor.yy14 = 0;}
92991 break;
92992 case 124: /* selcollist ::= sclp expr as */
92993 {
92994 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr);
92995 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1);
92996 sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346);
92997 }
92998 break;
92999 case 125: /* selcollist ::= sclp STAR */
93000 {
93001 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
93002 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p);
93003 }
93004 break;
93005 case 126: /* selcollist ::= sclp nm DOT STAR */
93006 {
93007 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
93008 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
93009 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
93010 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot);
93011 }
93012 break;
93013 case 129: /* as ::= */
93014 {yygotominor.yy0.n = 0;}
93015 break;
93016 case 130: /* from ::= */
93017 {yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));}
93018 break;
93019 case 131: /* from ::= FROM seltablist */
93020 {
93021 yygotominor.yy65 = yymsp[0].minor.yy65;
93022 sqlite3SrcListShiftJoinType(yygotominor.yy65);
93023 }
93024 break;
93025 case 132: /* stl_prefix ::= seltablist joinop */
93026 {
93027 yygotominor.yy65 = yymsp[-1].minor.yy65;
93028 if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328;
93029 }
93030 break;
93031 case 133: /* stl_prefix ::= */
93032 {yygotominor.yy65 = 0;}
93033 break;
93034 case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
93035 {
93036 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93037 sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0);
93038 }
93039 break;
93040 case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
93041 {
93042 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy3,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93043 }
93044 break;
93045 case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
93046 {
93047 if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){
93048 yygotominor.yy65 = yymsp[-4].minor.yy65;
93049 }else{
93050 Select *pSubquery;
@@ -93015,180 +93052,180 @@
93052 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,0,0,0);
93053 yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408);
93054 }
93055 }
93056 break;
93057 case 137: /* dbnm ::= */
93058 case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
93059 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
93060 break;
93061 case 139: /* fullname ::= nm dbnm */
93062 {yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
93063 break;
93064 case 140: /* joinop ::= COMMA|JOIN */
93065 { yygotominor.yy328 = JT_INNER; }
93066 break;
93067 case 141: /* joinop ::= JOIN_KW JOIN */
93068 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
93069 break;
93070 case 142: /* joinop ::= JOIN_KW nm JOIN */
93071 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
93072 break;
93073 case 143: /* joinop ::= JOIN_KW nm nm JOIN */
93074 { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
93075 break;
93076 case 144: /* on_opt ::= ON expr */
93077 case 155: /* sortitem ::= expr */ yytestcase(yyruleno==155);
93078 case 162: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==162);
93079 case 169: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==169);
93080 case 236: /* case_else ::= ELSE expr */ yytestcase(yyruleno==236);
93081 case 238: /* case_operand ::= expr */ yytestcase(yyruleno==238);
93082 {yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;}
93083 break;
93084 case 145: /* on_opt ::= */
93085 case 161: /* having_opt ::= */ yytestcase(yyruleno==161);
93086 case 168: /* where_opt ::= */ yytestcase(yyruleno==168);
93087 case 237: /* case_else ::= */ yytestcase(yyruleno==237);
93088 case 239: /* case_operand ::= */ yytestcase(yyruleno==239);
93089 {yygotominor.yy132 = 0;}
93090 break;
93091 case 148: /* indexed_opt ::= NOT INDEXED */
93092 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
93093 break;
93094 case 149: /* using_opt ::= USING LP inscollist RP */
93095 case 181: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==181);
93096 {yygotominor.yy408 = yymsp[-1].minor.yy408;}
93097 break;
93098 case 150: /* using_opt ::= */
93099 case 180: /* inscollist_opt ::= */ yytestcase(yyruleno==180);
93100 {yygotominor.yy408 = 0;}
93101 break;
93102 case 152: /* orderby_opt ::= ORDER BY sortlist */
93103 case 160: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==160);
93104 case 240: /* exprlist ::= nexprlist */ yytestcase(yyruleno==240);
93105 {yygotominor.yy14 = yymsp[0].minor.yy14;}
93106 break;
93107 case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */
93108 {
93109 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy132);
93110 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93111 }
93112 break;
93113 case 154: /* sortlist ::= sortitem sortorder */
93114 {
93115 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy132);
93116 if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328;
93117 }
93118 break;
93119 case 156: /* sortorder ::= ASC */
93120 case 158: /* sortorder ::= */ yytestcase(yyruleno==158);
93121 {yygotominor.yy328 = SQLITE_SO_ASC;}
93122 break;
93123 case 157: /* sortorder ::= DESC */
93124 {yygotominor.yy328 = SQLITE_SO_DESC;}
93125 break;
93126 case 163: /* limit_opt ::= */
93127 {yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;}
93128 break;
93129 case 164: /* limit_opt ::= LIMIT expr */
93130 {yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;}
93131 break;
93132 case 165: /* limit_opt ::= LIMIT expr OFFSET expr */
93133 {yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;}
93134 break;
93135 case 166: /* limit_opt ::= LIMIT expr COMMA expr */
93136 {yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;}
93137 break;
93138 case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
93139 {
93140 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0);
93141 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132);
93142 }
93143 break;
93144 case 170: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
93145 {
93146 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0);
93147 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list");
93148 sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186);
93149 }
93150 break;
93151 case 171: /* setlist ::= setlist COMMA nm EQ expr */
93152 {
93153 yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr);
93154 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93155 }
93156 break;
93157 case 172: /* setlist ::= nm EQ expr */
93158 {
93159 yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr);
93160 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93161 }
93162 break;
93163 case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt VALUES LP itemlist RP */
93164 {sqlite3Insert(pParse, yymsp[-5].minor.yy65, yymsp[-1].minor.yy14, 0, yymsp[-4].minor.yy408, yymsp[-7].minor.yy186);}
93165 break;
93166 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
93167 {sqlite3Insert(pParse, yymsp[-2].minor.yy65, 0, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);}
93168 break;
93169 case 175: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
93170 {sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);}
93171 break;
93172 case 176: /* insert_cmd ::= INSERT orconf */
93173 {yygotominor.yy186 = yymsp[0].minor.yy186;}
93174 break;
93175 case 177: /* insert_cmd ::= REPLACE */
93176 {yygotominor.yy186 = OE_Replace;}
93177 break;
93178 case 178: /* itemlist ::= itemlist COMMA expr */
93179 case 242: /* nexprlist ::= nexprlist COMMA expr */ yytestcase(yyruleno==242);
93180 {yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);}
93181 break;
93182 case 179: /* itemlist ::= expr */
93183 case 243: /* nexprlist ::= expr */ yytestcase(yyruleno==243);
93184 {yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);}
93185 break;
93186 case 182: /* inscollist ::= inscollist COMMA nm */
93187 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);}
93188 break;
93189 case 183: /* inscollist ::= nm */
93190 {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
93191 break;
93192 case 184: /* expr ::= term */
93193 case 212: /* escape ::= ESCAPE expr */ yytestcase(yyruleno==212);
93194 {yygotominor.yy346 = yymsp[0].minor.yy346;}
93195 break;
93196 case 185: /* expr ::= LP expr RP */
93197 {yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
93198 break;
93199 case 186: /* term ::= NULL */
93200 case 191: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==191);
93201 case 192: /* term ::= STRING */ yytestcase(yyruleno==192);
93202 {spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
93203 break;
93204 case 187: /* expr ::= id */
93205 case 188: /* expr ::= JOIN_KW */ yytestcase(yyruleno==188);
93206 {spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);}
93207 break;
93208 case 189: /* expr ::= nm DOT nm */
93209 {
93210 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
93211 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
93212 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
93213 spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
93214 }
93215 break;
93216 case 190: /* expr ::= nm DOT nm DOT nm */
93217 {
93218 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
93219 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
93220 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
93221 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
93222 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
93223 spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
93224 }
93225 break;
93226 case 193: /* expr ::= REGISTER */
93227 {
93228 /* When doing a nested parse, one can include terms in an expression
93229 ** that look like this: #1 #2 ... These terms refer to registers
93230 ** in the virtual machine. #N is the N-th register. */
93231 if( pParse->nested==0 ){
@@ -93199,31 +93236,31 @@
93236 if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable);
93237 }
93238 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93239 }
93240 break;
93241 case 194: /* expr ::= VARIABLE */
93242 {
93243 spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
93244 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr);
93245 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93246 }
93247 break;
93248 case 195: /* expr ::= expr COLLATE ids */
93249 {
93250 yygotominor.yy346.pExpr = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0);
93251 yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart;
93252 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93253 }
93254 break;
93255 case 196: /* expr ::= CAST LP expr AS typetoken RP */
93256 {
93257 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0);
93258 spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
93259 }
93260 break;
93261 case 197: /* expr ::= ID LP distinct exprlist RP */
93262 {
93263 if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
93264 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
93265 }
93266 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0);
@@ -93231,17 +93268,17 @@
93268 if( yymsp[-2].minor.yy328 && yygotominor.yy346.pExpr ){
93269 yygotominor.yy346.pExpr->flags |= EP_Distinct;
93270 }
93271 }
93272 break;
93273 case 198: /* expr ::= ID LP STAR RP */
93274 {
93275 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
93276 spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
93277 }
93278 break;
93279 case 199: /* term ::= CTIME_KW */
93280 {
93281 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
93282 ** treated as functions that return constants */
93283 yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
93284 if( yygotominor.yy346.pExpr ){
@@ -93248,32 +93285,32 @@
93285 yygotominor.yy346.pExpr->op = TK_CONST_FUNC;
93286 }
93287 spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
93288 }
93289 break;
93290 case 200: /* expr ::= expr AND expr */
93291 case 201: /* expr ::= expr OR expr */ yytestcase(yyruleno==201);
93292 case 202: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==202);
93293 case 203: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==203);
93294 case 204: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==204);
93295 case 205: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==205);
93296 case 206: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==206);
93297 case 207: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==207);
93298 {spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);}
93299 break;
93300 case 208: /* likeop ::= LIKE_KW */
93301 case 210: /* likeop ::= MATCH */ yytestcase(yyruleno==210);
93302 {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;}
93303 break;
93304 case 209: /* likeop ::= NOT LIKE_KW */
93305 case 211: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==211);
93306 {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 1;}
93307 break;
93308 case 213: /* escape ::= */
93309 {memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));}
93310 break;
93311 case 214: /* expr ::= expr likeop expr escape */
93312 {
93313 ExprList *pList;
93314 pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr);
93315 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy346.pExpr);
93316 if( yymsp[0].minor.yy346.pExpr ){
@@ -93284,39 +93321,39 @@
93321 yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
93322 yygotominor.yy346.zEnd = yymsp[-1].minor.yy346.zEnd;
93323 if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc;
93324 }
93325 break;
93326 case 215: /* expr ::= expr ISNULL|NOTNULL */
93327 {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);}
93328 break;
93329 case 216: /* expr ::= expr NOT NULL */
93330 {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);}
93331 break;
93332 case 217: /* expr ::= expr IS expr */
93333 {
93334 spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);
93335 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL);
93336 }
93337 break;
93338 case 218: /* expr ::= expr IS NOT expr */
93339 {
93340 spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346);
93341 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL);
93342 }
93343 break;
93344 case 219: /* expr ::= NOT expr */
93345 case 220: /* expr ::= BITNOT expr */ yytestcase(yyruleno==220);
93346 {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93347 break;
93348 case 221: /* expr ::= MINUS expr */
93349 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93350 break;
93351 case 222: /* expr ::= PLUS expr */
93352 {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);}
93353 break;
93354 case 225: /* expr ::= expr between_op expr AND expr */
93355 {
93356 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
93357 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr);
93358 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93359 if( yygotominor.yy346.pExpr ){
@@ -93327,11 +93364,11 @@
93364 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93365 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93366 yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd;
93367 }
93368 break;
93369 case 228: /* expr ::= expr in_op LP exprlist RP */
93370 {
93371 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93372 if( yygotominor.yy346.pExpr ){
93373 yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14;
93374 sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93341,11 +93378,11 @@
93378 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93379 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93380 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93381 }
93382 break;
93383 case 229: /* expr ::= LP select RP */
93384 {
93385 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
93386 if( yygotominor.yy346.pExpr ){
93387 yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
93388 ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93355,11 +93392,11 @@
93392 }
93393 yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z;
93394 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93395 }
93396 break;
93397 case 230: /* expr ::= expr in_op LP select RP */
93398 {
93399 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0);
93400 if( yygotominor.yy346.pExpr ){
93401 yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3;
93402 ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect);
@@ -93370,11 +93407,11 @@
93407 if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93408 yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart;
93409 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93410 }
93411 break;
93412 case 231: /* expr ::= expr in_op nm dbnm */
93413 {
93414 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
93415 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0);
93416 if( yygotominor.yy346.pExpr ){
93417 yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -93386,11 +93423,11 @@
93423 if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0);
93424 yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart;
93425 yygotominor.yy346.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
93426 }
93427 break;
93428 case 232: /* expr ::= EXISTS LP select RP */
93429 {
93430 Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
93431 if( p ){
93432 p->x.pSelect = yymsp[-1].minor.yy3;
93433 ExprSetProperty(p, EP_xIsSelect);
@@ -93400,11 +93437,11 @@
93437 }
93438 yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
93439 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93440 }
93441 break;
93442 case 233: /* expr ::= CASE case_operand case_exprlist case_else END */
93443 {
93444 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, yymsp[-1].minor.yy132, 0);
93445 if( yygotominor.yy346.pExpr ){
93446 yygotominor.yy346.pExpr->x.pList = yymsp[-2].minor.yy14;
93447 sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr);
@@ -93413,37 +93450,37 @@
93450 }
93451 yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z;
93452 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93453 }
93454 break;
93455 case 234: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
93456 {
93457 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr);
93458 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
93459 }
93460 break;
93461 case 235: /* case_exprlist ::= WHEN expr THEN expr */
93462 {
93463 yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr);
93464 yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr);
93465 }
93466 break;
93467 case 244: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
93468 {
93469 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
93470 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy14, yymsp[-9].minor.yy328,
93471 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy328);
93472 }
93473 break;
93474 case 245: /* uniqueflag ::= UNIQUE */
93475 case 299: /* raisetype ::= ABORT */ yytestcase(yyruleno==299);
93476 {yygotominor.yy328 = OE_Abort;}
93477 break;
93478 case 246: /* uniqueflag ::= */
93479 {yygotominor.yy328 = OE_None;}
93480 break;
93481 case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */
93482 {
93483 Expr *p = 0;
93484 if( yymsp[-1].minor.yy0.n>0 ){
93485 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
93486 sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93452,11 +93489,11 @@
93489 sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1);
93490 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
93491 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93492 }
93493 break;
93494 case 250: /* idxlist ::= nm collate sortorder */
93495 {
93496 Expr *p = 0;
93497 if( yymsp[-1].minor.yy0.n>0 ){
93498 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
93499 sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0);
@@ -93465,212 +93502,212 @@
93502 sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1);
93503 sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index");
93504 if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328;
93505 }
93506 break;
93507 case 251: /* collate ::= */
93508 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
93509 break;
93510 case 253: /* cmd ::= DROP INDEX ifexists fullname */
93511 {sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);}
93512 break;
93513 case 254: /* cmd ::= VACUUM */
93514 case 255: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==255);
93515 {sqlite3Vacuum(pParse);}
93516 break;
93517 case 256: /* cmd ::= PRAGMA nm dbnm */
93518 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
93519 break;
93520 case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
93521 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
93522 break;
93523 case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
93524 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
93525 break;
93526 case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
93527 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
93528 break;
93529 case 260: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
93530 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
93531 break;
93532 case 271: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
93533 {
93534 Token all;
93535 all.z = yymsp[-3].minor.yy0.z;
93536 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
93537 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all);
93538 }
93539 break;
93540 case 272: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
93541 {
93542 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy328, yymsp[-4].minor.yy378.a, yymsp[-4].minor.yy378.b, yymsp[-2].minor.yy65, yymsp[0].minor.yy132, yymsp[-10].minor.yy328, yymsp[-8].minor.yy328);
93543 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
93544 }
93545 break;
93546 case 273: /* trigger_time ::= BEFORE */
93547 case 276: /* trigger_time ::= */ yytestcase(yyruleno==276);
93548 { yygotominor.yy328 = TK_BEFORE; }
93549 break;
93550 case 274: /* trigger_time ::= AFTER */
93551 { yygotominor.yy328 = TK_AFTER; }
93552 break;
93553 case 275: /* trigger_time ::= INSTEAD OF */
93554 { yygotominor.yy328 = TK_INSTEAD;}
93555 break;
93556 case 277: /* trigger_event ::= DELETE|INSERT */
93557 case 278: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==278);
93558 {yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;}
93559 break;
93560 case 279: /* trigger_event ::= UPDATE OF inscollist */
93561 {yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;}
93562 break;
93563 case 282: /* when_clause ::= */
93564 case 304: /* key_opt ::= */ yytestcase(yyruleno==304);
93565 { yygotominor.yy132 = 0; }
93566 break;
93567 case 283: /* when_clause ::= WHEN expr */
93568 case 305: /* key_opt ::= KEY expr */ yytestcase(yyruleno==305);
93569 { yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; }
93570 break;
93571 case 284: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
93572 {
93573 assert( yymsp[-2].minor.yy473!=0 );
93574 yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473;
93575 yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473;
93576 yygotominor.yy473 = yymsp[-2].minor.yy473;
93577 }
93578 break;
93579 case 285: /* trigger_cmd_list ::= trigger_cmd SEMI */
93580 {
93581 assert( yymsp[-1].minor.yy473!=0 );
93582 yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473;
93583 yygotominor.yy473 = yymsp[-1].minor.yy473;
93584 }
93585 break;
93586 case 287: /* trnm ::= nm DOT nm */
93587 {
93588 yygotominor.yy0 = yymsp[0].minor.yy0;
93589 sqlite3ErrorMsg(pParse,
93590 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
93591 "statements within triggers");
93592 }
93593 break;
93594 case 289: /* tridxby ::= INDEXED BY nm */
93595 {
93596 sqlite3ErrorMsg(pParse,
93597 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
93598 "within triggers");
93599 }
93600 break;
93601 case 290: /* tridxby ::= NOT INDEXED */
93602 {
93603 sqlite3ErrorMsg(pParse,
93604 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
93605 "within triggers");
93606 }
93607 break;
93608 case 291: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
93609 { yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); }
93610 break;
93611 case 292: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt VALUES LP itemlist RP */
93612 {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy408, yymsp[-1].minor.yy14, 0, yymsp[-7].minor.yy186);}
93613 break;
93614 case 293: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
93615 {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, 0, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);}
93616 break;
93617 case 294: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
93618 {yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);}
93619 break;
93620 case 295: /* trigger_cmd ::= select */
93621 {yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); }
93622 break;
93623 case 296: /* expr ::= RAISE LP IGNORE RP */
93624 {
93625 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
93626 if( yygotominor.yy346.pExpr ){
93627 yygotominor.yy346.pExpr->affinity = OE_Ignore;
93628 }
93629 yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z;
93630 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93631 }
93632 break;
93633 case 297: /* expr ::= RAISE LP raisetype COMMA nm RP */
93634 {
93635 yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
93636 if( yygotominor.yy346.pExpr ) {
93637 yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328;
93638 }
93639 yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z;
93640 yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
93641 }
93642 break;
93643 case 298: /* raisetype ::= ROLLBACK */
93644 {yygotominor.yy328 = OE_Rollback;}
93645 break;
93646 case 300: /* raisetype ::= FAIL */
93647 {yygotominor.yy328 = OE_Fail;}
93648 break;
93649 case 301: /* cmd ::= DROP TRIGGER ifexists fullname */
93650 {
93651 sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328);
93652 }
93653 break;
93654 case 302: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
93655 {
93656 sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132);
93657 }
93658 break;
93659 case 303: /* cmd ::= DETACH database_kw_opt expr */
93660 {
93661 sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr);
93662 }
93663 break;
93664 case 308: /* cmd ::= REINDEX */
93665 {sqlite3Reindex(pParse, 0, 0);}
93666 break;
93667 case 309: /* cmd ::= REINDEX nm dbnm */
93668 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
93669 break;
93670 case 310: /* cmd ::= ANALYZE */
93671 {sqlite3Analyze(pParse, 0, 0);}
93672 break;
93673 case 311: /* cmd ::= ANALYZE nm dbnm */
93674 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
93675 break;
93676 case 312: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
93677 {
93678 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0);
93679 }
93680 break;
93681 case 313: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
93682 {
93683 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
93684 }
93685 break;
93686 case 314: /* add_column_fullname ::= fullname */
93687 {
93688 pParse->db->lookaside.bEnabled = 0;
93689 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65);
93690 }
93691 break;
93692 case 317: /* cmd ::= create_vtab */
93693 {sqlite3VtabFinishParse(pParse,0);}
93694 break;
93695 case 318: /* cmd ::= create_vtab LP vtabarglist RP */
93696 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
93697 break;
93698 case 319: /* create_vtab ::= createkw VIRTUAL TABLE nm dbnm USING nm */
93699 {
93700 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0);
93701 }
93702 break;
93703 case 322: /* vtabarg ::= */
93704 {sqlite3VtabArgInit(pParse);}
93705 break;
93706 case 324: /* vtabargtoken ::= ANY */
93707 case 325: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==325);
93708 case 326: /* lp ::= LP */ yytestcase(yyruleno==326);
93709 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
93710 break;
93711 default:
93712 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
93713 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -93691,29 +93728,29 @@
93728 /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
93729 /* (54) carglist ::= */ yytestcase(yyruleno==54);
93730 /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
93731 /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
93732 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
93733 /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
93734 /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
93735 /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
93736 /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
93737 /* (269) plus_opt ::= PLUS */ yytestcase(yyruleno==269);
93738 /* (270) plus_opt ::= */ yytestcase(yyruleno==270);
93739 /* (280) foreach_clause ::= */ yytestcase(yyruleno==280);
93740 /* (281) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==281);
93741 /* (288) tridxby ::= */ yytestcase(yyruleno==288);
93742 /* (306) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==306);
93743 /* (307) database_kw_opt ::= */ yytestcase(yyruleno==307);
93744 /* (315) kwcolumn_opt ::= */ yytestcase(yyruleno==315);
93745 /* (316) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==316);
93746 /* (320) vtabarglist ::= vtabarg */ yytestcase(yyruleno==320);
93747 /* (321) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==321);
93748 /* (323) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==323);
93749 /* (327) anylist ::= */ yytestcase(yyruleno==327);
93750 /* (328) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==328);
93751 /* (329) anylist ::= anylist ANY */ yytestcase(yyruleno==329);
93752 break;
93753 };
93754 yygoto = yyRuleInfo[yyruleno].lhs;
93755 yysize = yyRuleInfo[yyruleno].nrhs;
93756 yypParser->yyidx -= yysize;
@@ -94300,10 +94337,11 @@
94337 return TK_ID;
94338 }
94339 SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){
94340 return keywordCode((char*)z, n);
94341 }
94342 #define SQLITE_N_KEYWORD 121
94343
94344 /************** End of keywordhash.h *****************************************/
94345 /************** Continuing where we left off in tokenize.c *******************/
94346
94347
@@ -94363,12 +94401,13 @@
94401 *tokenType = TK_SPACE;
94402 return i;
94403 }
94404 case '-': {
94405 if( z[1]=='-' ){
94406 /* IMP: R-15891-05542 -- syntax diagram for comments */
94407 for(i=2; (c=z[i])!=0 && c!='\n'; i++){}
94408 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
94409 return i;
94410 }
94411 *tokenType = TK_MINUS;
94412 return 1;
94413 }
@@ -94395,13 +94434,14 @@
94434 case '/': {
94435 if( z[1]!='*' || z[2]==0 ){
94436 *tokenType = TK_SLASH;
94437 return 1;
94438 }
94439 /* IMP: R-15891-05542 -- syntax diagram for comments */
94440 for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){}
94441 if( c ) i++;
94442 *tokenType = TK_SPACE; /* IMP: R-22934-25134 */
94443 return i;
94444 }
94445 case '%': {
94446 *tokenType = TK_REM;
94447 return 1;
@@ -94806,61 +94846,66 @@
94846 ** comments on that procedure for additional information.
94847 */
94848 #define tkSEMI 0
94849 #define tkWS 1
94850 #define tkOTHER 2
94851 #ifndef SQLITE_OMIT_TRIGGER
94852 #define tkEXPLAIN 3
94853 #define tkCREATE 4
94854 #define tkTEMP 5
94855 #define tkTRIGGER 6
94856 #define tkEND 7
94857 #endif
94858
94859 /*
94860 ** Return TRUE if the given SQL string ends in a semicolon.
94861 **
94862 ** Special handling is require for CREATE TRIGGER statements.
94863 ** Whenever the CREATE TRIGGER keywords are seen, the statement
94864 ** must end with ";END;".
94865 **
94866 ** This implementation uses a state machine with 8 states:
94867 **
94868 ** (0) INVALID We have not yet seen a non-whitespace character.
94869 **
94870 ** (1) START At the beginning or end of an SQL statement. This routine
94871 ** returns 1 if it ends in the START state and 0 if it ends
94872 ** in any other state.
94873 **
94874 ** (2) NORMAL We are in the middle of statement which ends with a single
94875 ** semicolon.
94876 **
94877 ** (3) EXPLAIN The keyword EXPLAIN has been seen at the beginning of
94878 ** a statement.
94879 **
94880 ** (4) CREATE The keyword CREATE has been seen at the beginning of a
94881 ** statement, possibly preceeded by EXPLAIN and/or followed by
94882 ** TEMP or TEMPORARY
94883 **
94884 ** (5) TRIGGER We are in the middle of a trigger definition that must be
94885 ** ended by a semicolon, the keyword END, and another semicolon.
94886 **
94887 ** (6) SEMI We've seen the first semicolon in the ";END;" that occurs at
94888 ** the end of a trigger definition.
94889 **
94890 ** (7) END We've seen the ";END" of the ";END;" that occurs at the end
94891 ** of a trigger difinition.
94892 **
94893 ** Transitions between states above are determined by tokens extracted
94894 ** from the input. The following tokens are significant:
94895 **
94896 ** (0) tkSEMI A semicolon.
94897 ** (1) tkWS Whitespace.
94898 ** (2) tkOTHER Any other SQL token.
94899 ** (3) tkEXPLAIN The "explain" keyword.
94900 ** (4) tkCREATE The "create" keyword.
94901 ** (5) tkTEMP The "temp" or "temporary" keyword.
94902 ** (6) tkTRIGGER The "trigger" keyword.
94903 ** (7) tkEND The "end" keyword.
94904 **
94905 ** Whitespace never causes a state transition and is always ignored.
94906 ** This means that a SQL string of all whitespace is invalid.
94907 **
94908 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
94909 ** to recognize the end of a trigger can be omitted. All we have to do
94910 ** is look for a semicolon that is not part of an string or comment.
94911 */
@@ -94870,30 +94915,32 @@
94915
94916 #ifndef SQLITE_OMIT_TRIGGER
94917 /* A complex statement machine used to detect the end of a CREATE TRIGGER
94918 ** statement. This is the normal case.
94919 */
94920 static const u8 trans[8][8] = {
94921 /* Token: */
94922 /* State: ** SEMI WS OTHER EXPLAIN CREATE TEMP TRIGGER END */
94923 /* 0 INVALID: */ { 1, 0, 2, 3, 4, 2, 2, 2, },
94924 /* 1 START: */ { 1, 1, 2, 3, 4, 2, 2, 2, },
94925 /* 2 NORMAL: */ { 1, 2, 2, 2, 2, 2, 2, 2, },
94926 /* 3 EXPLAIN: */ { 1, 3, 3, 2, 4, 2, 2, 2, },
94927 /* 4 CREATE: */ { 1, 4, 2, 2, 2, 4, 5, 2, },
94928 /* 5 TRIGGER: */ { 6, 5, 5, 5, 5, 5, 5, 5, },
94929 /* 6 SEMI: */ { 6, 6, 5, 5, 5, 5, 5, 7, },
94930 /* 7 END: */ { 1, 7, 5, 5, 5, 5, 5, 5, },
94931 };
94932 #else
94933 /* If triggers are not supported by this compile then the statement machine
94934 ** used to detect the end of a statement is much simplier
94935 */
94936 static const u8 trans[3][3] = {
94937 /* Token: */
94938 /* State: ** SEMI WS OTHER */
94939 /* 0 INVALID: */ { 1, 0, 2, },
94940 /* 1 START: */ { 1, 1, 2, },
94941 /* 2 NORMAL: */ { 1, 2, 2, },
94942 };
94943 #endif /* SQLITE_OMIT_TRIGGER */
94944
94945 while( *zSql ){
94946 switch( *zSql ){
@@ -94925,11 +94972,11 @@
94972 if( zSql[1]!='-' ){
94973 token = tkOTHER;
94974 break;
94975 }
94976 while( *zSql && *zSql!='\n' ){ zSql++; }
94977 if( *zSql==0 ) return state==1;
94978 token = tkWS;
94979 break;
94980 }
94981 case '[': { /* Microsoft-style identifiers in [...] */
94982 zSql++;
@@ -95009,11 +95056,11 @@
95056 }
95057 }
95058 state = trans[state][token];
95059 zSql++;
95060 }
95061 return state==1;
95062 }
95063
95064 #ifndef SQLITE_OMIT_UTF16
95065 /*
95066 ** This routine is the same as the sqlite3_complete() routine described
@@ -95397,11 +95444,11 @@
95444 switch( op ){
95445
95446 /* Mutex configuration options are only available in a threadsafe
95447 ** compile.
95448 */
95449 #if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0
95450 case SQLITE_CONFIG_SINGLETHREAD: {
95451 /* Disable all mutexing */
95452 sqlite3GlobalConfig.bCoreMutex = 0;
95453 sqlite3GlobalConfig.bFullMutex = 0;
95454 break;
@@ -97413,10 +97460,44 @@
97460 sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0);
97461 sqlite3_mutex_leave(db->mutex);
97462 break;
97463 }
97464
97465 /* sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS, sqlite3 *db, int N)
97466 **
97467 ** Enable or disable various optimizations for testing purposes. The
97468 ** argument N is a bitmask of optimizations to be disabled. For normal
97469 ** operation N should be 0. The idea is that a test program (like the
97470 ** SQL Logic Test or SLT test module) can run the same SQL multiple times
97471 ** with various optimizations disabled to verify that the same answer
97472 ** is obtained in every case.
97473 */
97474 case SQLITE_TESTCTRL_OPTIMIZATIONS: {
97475 sqlite3 *db = va_arg(ap, sqlite3*);
97476 int x = va_arg(ap,int);
97477 db->flags = (x & SQLITE_OptMask) | (db->flags & ~SQLITE_OptMask);
97478 break;
97479 }
97480
97481 #ifdef SQLITE_N_KEYWORD
97482 /* sqlite3_test_control(SQLITE_TESTCTRL_ISKEYWORD, const char *zWord)
97483 **
97484 ** If zWord is a keyword recognized by the parser, then return the
97485 ** number of keywords. Or if zWord is not a keyword, return 0.
97486 **
97487 ** This test feature is only available in the amalgamation since
97488 ** the SQLITE_N_KEYWORD macro is not defined in this file if SQLite
97489 ** is built using separate source files.
97490 */
97491 case SQLITE_TESTCTRL_ISKEYWORD: {
97492 const char *zWord = va_arg(ap, const char*);
97493 int n = sqlite3Strlen30(zWord);
97494 rc = (sqlite3KeywordCode((u8*)zWord, n)!=TK_ID) ? SQLITE_N_KEYWORD : 0;
97495 break;
97496 }
97497 #endif
97498
97499 }
97500 va_end(ap);
97501 #endif /* SQLITE_OMIT_BUILTIN_TEST */
97502 return rc;
97503 }
@@ -98203,10 +98284,14 @@
98284
98285 struct sqlite3_tokenizer_cursor {
98286 sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */
98287 /* Tokenizer implementations will typically add additional fields */
98288 };
98289
98290 int fts3_global_term_cnt(int iTerm, int iCol);
98291 int fts3_term_cnt(int iTerm, int iCol);
98292
98293
98294 #endif /* _FTS3_TOKENIZER_H_ */
98295
98296 /************** End of fts3_tokenizer.h **************************************/
98297 /************** Continuing where we left off in fts3Int.h ********************/
@@ -98287,18 +98372,20 @@
98372 */
98373 SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey);
98374 SQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData);
98375 SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey);
98376 SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*);
98377 SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int);
98378
98379 /*
98380 ** Shorthand for the functions above
98381 */
98382 #define fts3HashInit sqlite3Fts3HashInit
98383 #define fts3HashInsert sqlite3Fts3HashInsert
98384 #define fts3HashFind sqlite3Fts3HashFind
98385 #define fts3HashClear sqlite3Fts3HashClear
98386 #define fts3HashFindElem sqlite3Fts3HashFindElem
98387
98388 /*
98389 ** Macros for looping over all elements of a hash table. The idiom is
98390 ** like this:
98391 **
@@ -98371,10 +98458,12 @@
98458 /*
98459 ** Internal types used by SQLite.
98460 */
98461 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
98462 typedef short int i16; /* 2-byte (or larger) signed integer */
98463 typedef unsigned int u32; /* 4-byte unsigned integer */
98464 typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
98465 /*
98466 ** Macro used to suppress compiler warnings for unused parameters.
98467 */
98468 #define UNUSED_PARAMETER(x) (void)(x)
98469 #endif
@@ -98421,14 +98510,15 @@
98510 int nNodeSize; /* Soft limit for node size */
98511
98512 /* The following hash table is used to buffer pending index updates during
98513 ** transactions. Variable nPendingData estimates the memory size of the
98514 ** pending data, including hash table overhead, but not malloc overhead.
98515 ** When nPendingData exceeds nMaxPendingData, the buffer is flushed
98516 ** automatically. Variable iPrevDocid is the docid of the most recently
98517 ** inserted record.
98518 */
98519 int nMaxPendingData;
98520 int nPendingData;
98521 sqlite_int64 iPrevDocid;
98522 Fts3Hash pendingTerms;
98523 };
98524
@@ -98446,10 +98536,12 @@
98536 Fts3Expr *pExpr; /* Parsed MATCH query string */
98537 sqlite3_int64 iPrevId; /* Previous id read from aDoclist */
98538 char *pNextId; /* Pointer into the body of aDoclist */
98539 char *aDoclist; /* List of docids for full-text queries */
98540 int nDoclist; /* Size of buffer at aDoclist */
98541 int isMatchinfoOk; /* True when aMatchinfo[] matches iPrevId */
98542 u32 *aMatchinfo;
98543 };
98544
98545 /*
98546 ** The Fts3Cursor.eSearch member is always set to one of the following.
98547 ** Actualy, Fts3Cursor.eSearch can be greater than or equal to
@@ -98486,18 +98578,35 @@
98578 } aToken[1]; /* One entry for each token in the phrase */
98579 };
98580
98581 /*
98582 ** A tree of these objects forms the RHS of a MATCH operator.
98583 **
98584 ** If Fts3Expr.eType is either FTSQUERY_NEAR or FTSQUERY_PHRASE and isLoaded
98585 ** is true, then aDoclist points to a malloced buffer, size nDoclist bytes,
98586 ** containing the results of the NEAR or phrase query in FTS3 doclist
98587 ** format. As usual, the initial "Length" field found in doclists stored
98588 ** on disk is omitted from this buffer.
98589 **
98590 ** Variable pCurrent always points to the start of a docid field within
98591 ** aDoclist. Since the doclist is usually scanned in docid order, this can
98592 ** be used to accelerate seeking to the required docid within the doclist.
98593 */
98594 struct Fts3Expr {
98595 int eType; /* One of the FTSQUERY_XXX values defined below */
98596 int nNear; /* Valid if eType==FTSQUERY_NEAR */
98597 Fts3Expr *pParent; /* pParent->pLeft==this or pParent->pRight==this */
98598 Fts3Expr *pLeft; /* Left operand */
98599 Fts3Expr *pRight; /* Right operand */
98600 Fts3Phrase *pPhrase; /* Valid if eType==FTSQUERY_PHRASE */
98601
98602 int isLoaded; /* True if aDoclist/nDoclist are initialized. */
98603 char *aDoclist; /* Buffer containing doclist */
98604 int nDoclist; /* Size of aDoclist in bytes */
98605
98606 sqlite3_int64 iCurrent;
98607 char *pCurrent;
98608 };
98609
98610 /*
98611 ** Candidate values for Fts3Query.eType. Note that the order of the first
98612 ** four values is in order of precedence when parsing expressions. For
@@ -98526,10 +98635,11 @@
98635 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *);
98636 SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *);
98637 SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *);
98638 SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(Fts3Table *,int, sqlite3_int64,
98639 sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**);
98640 SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(Fts3Table*,const char*,int,int,Fts3SegReader**);
98641 SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *, Fts3SegReader *);
98642 SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate(
98643 Fts3Table *, Fts3SegReader **, int, Fts3SegFilter *,
98644 int (*)(Fts3Table *, void *, char *, int, char *, int), void *
98645 );
@@ -98555,10 +98665,13 @@
98665 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
98666 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
98667 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
98668 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
98669
98670 SQLITE_PRIVATE char *sqlite3Fts3FindPositions(Fts3Expr *, sqlite3_int64, int);
98671 SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *, Fts3Expr *);
98672
98673 /* fts3_tokenizer.c */
98674 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
98675 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
98676 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash,
98677 const char *, sqlite3_tokenizer **, const char **, char **
@@ -98567,18 +98680,22 @@
98680 /* fts3_snippet.c */
98681 SQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*);
98682 SQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context*, Fts3Cursor*,
98683 const char *, const char *, const char *
98684 );
98685 SQLITE_PRIVATE void sqlite3Fts3Snippet2(sqlite3_context *, Fts3Cursor *, const char *,
98686 const char *, const char *, int, int
98687 );
98688 SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *, Fts3Cursor *);
98689
98690 /* fts3_expr.c */
98691 SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *,
98692 char **, int, int, const char *, int, Fts3Expr **
98693 );
98694 SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *);
98695 #ifdef SQLITE_TEST
98696 SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db);
98697 #endif
98698
98699 #endif /* _FTSINT_H */
98700
98701 /************** End of fts3Int.h *********************************************/
@@ -98587,74 +98704,10 @@
98704
98705 #ifndef SQLITE_CORE
98706 SQLITE_EXTENSION_INIT1
98707 #endif
98708
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98709 /*
98710 ** Write a 64-bit variable-length integer to memory starting at p[0].
98711 ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
98712 ** The number of bytes written is returned.
98713 */
@@ -98676,17 +98729,13 @@
98729 ** The value is stored in *v.
98730 */
98731 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){
98732 const unsigned char *q = (const unsigned char *) p;
98733 sqlite_uint64 x = 0, y = 1;
98734 while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){
98735 x += y * (*q++ & 0x7f);
98736 y <<= 7;
 
 
 
 
98737 }
98738 x += y * (*q++);
98739 *v = (sqlite_int64) x;
98740 return (int) (q - (unsigned char *)p);
98741 }
@@ -98697,11 +98746,10 @@
98746 */
98747 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){
98748 sqlite_int64 i;
98749 int ret = sqlite3Fts3GetVarint(p, &i);
98750 *pi = (int) i;
 
98751 return ret;
98752 }
98753
98754 /*
98755 ** Return the number of bytes required to store the value passed as the
@@ -98726,35 +98774,33 @@
98774 **
98775 ** "abc" becomes abc
98776 ** 'xyz' becomes xyz
98777 ** [pqr] becomes pqr
98778 ** `mno` becomes mno
98779 **
98780 */
98781 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){
98782 char quote; /* Quote character (if any ) */
 
98783
98784 quote = z[0];
98785 if( quote=='[' || quote=='\'' || quote=='"' || quote=='`' ){
98786 int iIn = 1; /* Index of next byte to read from input */
98787 int iOut = 0; /* Index of next byte to write to output */
98788
98789 /* If the first byte was a '[', then the close-quote character is a ']' */
98790 if( quote=='[' ) quote = ']';
98791
98792 while( ALWAYS(z[iIn]) ){
98793 if( z[iIn]==quote ){
98794 if( z[iIn+1]!=quote ) break;
98795 z[iOut++] = quote;
98796 iIn += 2;
98797 }else{
98798 z[iOut++] = z[iIn++];
98799 }
98800 }
98801 z[iOut] = '\0';
 
 
98802 }
98803 }
98804
98805 static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){
98806 sqlite3_int64 iVal;
@@ -98919,11 +98965,11 @@
98965 ** argv[0] -> module name
98966 ** argv[1] -> database name
98967 ** argv[2] -> table name
98968 ** argv[...] -> "column name" and other module argument fields.
98969 */
98970 static int fts3InitVtab(
98971 int isCreate, /* True for xCreate, false for xConnect */
98972 sqlite3 *db, /* The SQLite database connection */
98973 void *pAux, /* Hash table containing tokenizers */
98974 int argc, /* Number of elements in argv array */
98975 const char * const *argv, /* xCreate/xConnect argument array */
@@ -98943,18 +98989,10 @@
98989 int nName;
98990
98991 const char *zTokenizer = 0; /* Name of tokenizer to use */
98992 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
98993
 
 
 
 
 
 
 
 
98994 nDb = (int)strlen(argv[1]) + 1;
98995 nName = (int)strlen(argv[2]) + 1;
98996 for(i=3; i<argc; i++){
98997 char const *z = argv[i];
98998 rc = sqlite3Fts3InitTokenizer(pHash, z, &pTokenizer, &zTokenizer, pzErr);
@@ -98995,10 +99033,11 @@
99033 p->nColumn = nCol;
99034 p->nPendingData = 0;
99035 p->azColumn = (char **)&p[1];
99036 p->pTokenizer = pTokenizer;
99037 p->nNodeSize = 1000;
99038 p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
99039 zCsr = (char *)&p->azColumn[nCol];
99040
99041 fts3HashInit(&p->pendingTerms, FTS3_HASH_STRING, 1);
99042
99043 /* Fill in the zName and zDb fields of the vtab structure. */
@@ -99038,15 +99077,10 @@
99077 }
99078
99079 rc = fts3DeclareVtab(p);
99080 if( rc!=SQLITE_OK ) goto fts3_init_out;
99081
 
 
 
 
 
99082 *ppVTab = &p->base;
99083
99084 fts3_init_out:
99085 assert( p || (pTokenizer && rc!=SQLITE_OK) );
99086 if( rc!=SQLITE_OK ){
@@ -99105,35 +99139,35 @@
99139 pInfo->estimatedCost = 500000;
99140 for(i=0; i<pInfo->nConstraint; i++){
99141 struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i];
99142 if( pCons->usable==0 ) continue;
99143
99144 /* A direct lookup on the rowid or docid column. Assign a cost of 1.0. */
 
 
99145 if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ
99146 && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 )
99147 ){
99148 pInfo->idxNum = FTS3_DOCID_SEARCH;
99149 pInfo->estimatedCost = 1.0;
99150 iCons = i;
 
99151 }
99152
99153 /* A MATCH constraint. Use a full-text search.
99154 **
99155 ** If there is more than one MATCH constraint available, use the first
99156 ** one encountered. If there is both a MATCH constraint and a direct
99157 ** rowid/docid lookup, prefer the MATCH strategy. This is done even
99158 ** though the rowid/docid lookup is faster than a MATCH query, selecting
99159 ** it would lead to an "unable to use function MATCH in the requested
99160 ** context" error.
99161 */
99162 if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH
 
99163 && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn
99164 ){
99165 pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn;
99166 pInfo->estimatedCost = 2.0;
99167 iCons = i;
99168 break;
99169 }
99170 }
99171
99172 if( iCons>=0 ){
99173 pInfo->aConstraintUsage[iCons].argvIndex = 1;
@@ -99175,25 +99209,33 @@
99209 static int fulltextClose(sqlite3_vtab_cursor *pCursor){
99210 Fts3Cursor *pCsr = (Fts3Cursor *)pCursor;
99211 sqlite3_finalize(pCsr->pStmt);
99212 sqlite3Fts3ExprFree(pCsr->pExpr);
99213 sqlite3_free(pCsr->aDoclist);
99214 sqlite3_free(pCsr->aMatchinfo);
99215 sqlite3_free(pCsr);
99216 return SQLITE_OK;
99217 }
99218
99219 static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){
99220 if( pCsr->isRequireSeek ){
99221 pCsr->isRequireSeek = 0;
99222 sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId);
99223 if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){
99224 return SQLITE_OK;
99225 }else{
99226 int rc = sqlite3_reset(pCsr->pStmt);
99227 if( rc==SQLITE_OK ){
99228 /* If no row was found and no error has occured, then the %_content
99229 ** table is missing a row that is present in the full-text index.
99230 ** The data structures are corrupt.
99231 */
99232 rc = SQLITE_CORRUPT;
99233 }
99234 pCsr->isEof = 1;
99235 if( pContext ){
99236 sqlite3_result_error_code(pContext, rc);
99237 }
99238 return rc;
99239 }
99240 }else{
99241 return SQLITE_OK;
@@ -99213,10 +99255,11 @@
99255 pCsr->isEof = 1;
99256 }else{
99257 sqlite3_reset(pCsr->pStmt);
99258 fts3GetDeltaVarint(&pCsr->pNextId, &pCsr->iPrevId);
99259 pCsr->isRequireSeek = 1;
99260 pCsr->isMatchinfoOk = 1;
99261 }
99262 return rc;
99263 }
99264
99265
@@ -99328,15 +99371,31 @@
99371 assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) );
99372 *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev);
99373 *piPrev = iVal;
99374 }
99375
99376 /*
99377 ** When this function is called, *ppPoslist is assumed to point to the
99378 ** start of a position-list.
99379 */
99380 static void fts3PoslistCopy(char **pp, char **ppPoslist){
99381 char *pEnd = *ppPoslist;
99382 char c = 0;
99383
99384 /* The end of a position list is marked by a zero encoded as an FTS3
99385 ** varint. A single 0x00 byte. Except, if the 0x00 byte is preceded by
99386 ** a byte with the 0x80 bit set, then it is not a varint 0, but the tail
99387 ** of some other, multi-byte, value.
99388 **
99389 ** The following block moves pEnd to point to the first byte that is not
99390 ** immediately preceded by a byte with the 0x80 bit set. Then increments
99391 ** pEnd once more so that it points to the byte immediately following the
99392 ** last byte in the position-list.
99393 */
99394 while( *pEnd | c ) c = *pEnd++ & 0x80;
99395 pEnd++;
99396
99397 if( pp ){
99398 int n = (int)(pEnd - *ppPoslist);
99399 char *p = *pp;
99400 memcpy(p, *ppPoslist, n);
99401 p += n;
@@ -99539,13 +99598,14 @@
99598 fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2;
99599 }else{
99600 if( (*p1&0xFE)==0 ) break;
99601 fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2;
99602 }
99603 }
99604
99605 if( pSave ){
99606 assert( pp && p );
99607 p = pSave;
99608 }
99609
99610 fts3ColumnlistCopy(0, &p1);
99611 fts3ColumnlistCopy(0, &p2);
@@ -99680,15 +99740,12 @@
99740 || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE
99741 || mergetype==MERGE_NEAR || mergetype==MERGE_POS_NEAR
99742 );
99743
99744 if( !aBuffer ){
 
 
 
99745 *pnBuffer = 0;
99746 return SQLITE_NOMEM;
99747 }
99748
99749 /* Read the first docid from each doclist */
99750 fts3GetDeltaVarint2(&p1, pEnd1, &i1);
99751 fts3GetDeltaVarint2(&p2, pEnd2, &i2);
@@ -99770,11 +99827,11 @@
99827 default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); {
99828 char *aTmp = 0;
99829 char **ppPos = 0;
99830 if( mergetype==MERGE_POS_NEAR ){
99831 ppPos = &p;
99832 aTmp = sqlite3_malloc(2*(n1+n2+1));
99833 if( !aTmp ){
99834 return SQLITE_NOMEM;
99835 }
99836 }
99837
@@ -99890,16 +99947,24 @@
99947 char **ppOut /* OUT: Malloced result buffer */
99948 ){
99949 int i;
99950 TermSelect tsc;
99951 Fts3SegFilter filter; /* Segment term filter configuration */
99952 Fts3SegReader **apSegment; /* Array of segments to read data from */
99953 int nSegment = 0; /* Size of apSegment array */
99954 int nAlloc = 16; /* Allocated size of segment array */
99955 int rc; /* Return code */
99956 sqlite3_stmt *pStmt = 0; /* SQL statement to scan %_segdir table */
99957 int iAge = 0; /* Used to assign ages to segments */
99958
99959 apSegment = (Fts3SegReader **)sqlite3_malloc(sizeof(Fts3SegReader*)*nAlloc);
99960 if( !apSegment ) return SQLITE_NOMEM;
99961 rc = sqlite3Fts3SegReaderPending(p, zTerm, nTerm, isPrefix, &apSegment[0]);
99962 if( rc!=SQLITE_OK ) goto finished;
99963 if( apSegment[0] ){
99964 nSegment = 1;
99965 }
99966
99967 /* Loop through the entire %_segdir table. For each segment, create a
99968 ** Fts3SegReader to iterate through the subset of the segment leaves
99969 ** that may contain a term that matches zTerm/nTerm. For non-prefix
99970 ** searches, this is always a single leaf. For prefix searches, this
@@ -100013,12 +100078,10 @@
100078 int rc = SQLITE_OK;
100079 int ii;
100080 int iCol = pPhrase->iColumn;
100081 int isTermPos = (pPhrase->nToken>1 || isReqPos);
100082
 
 
100083 for(ii=0; ii<pPhrase->nToken; ii++){
100084 struct PhraseToken *pTok = &pPhrase->aToken[ii];
100085 char *z = pTok->z; /* Next token of the phrase */
100086 int n = pTok->n; /* Size of z in bytes */
100087 int isPrefix = pTok->isPrefix;/* True if token is a prefix */
@@ -100046,10 +100109,11 @@
100109 }
100110 fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList);
100111 sqlite3_free(pOut);
100112 pOut = pList;
100113 }
100114 assert( nOut==0 || pOut!=0 );
100115 }
100116
100117 if( rc==SQLITE_OK ){
100118 *paOut = pOut;
100119 *pnOut = nOut;
@@ -100065,39 +100129,46 @@
100129 */
100130 static int evalFts3Expr(
100131 Fts3Table *p, /* Virtual table handle */
100132 Fts3Expr *pExpr, /* Parsed fts3 expression */
100133 char **paOut, /* OUT: Pointer to malloc'd result buffer */
100134 int *pnOut, /* OUT: Size of buffer at *paOut */
100135 int isReqPos /* Require positions in output buffer */
100136 ){
100137 int rc = SQLITE_OK; /* Return code */
100138
100139 /* Zero the output parameters. */
100140 *paOut = 0;
100141 *pnOut = 0;
100142
100143 if( pExpr ){
100144 assert( pExpr->eType==FTSQUERY_PHRASE
100145 || pExpr->eType==FTSQUERY_NEAR
100146 || isReqPos==0
100147 );
100148 if( pExpr->eType==FTSQUERY_PHRASE ){
100149 rc = fts3PhraseSelect(p, pExpr->pPhrase,
100150 isReqPos || (pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR),
100151 paOut, pnOut
100152 );
100153 }else{
100154 char *aLeft;
100155 char *aRight;
100156 int nLeft;
100157 int nRight;
100158
100159 if( 0==(rc = evalFts3Expr(p, pExpr->pRight, &aRight, &nRight, isReqPos))
100160 && 0==(rc = evalFts3Expr(p, pExpr->pLeft, &aLeft, &nLeft, isReqPos))
100161 ){
100162 assert( pExpr->eType==FTSQUERY_NEAR || pExpr->eType==FTSQUERY_OR
100163 || pExpr->eType==FTSQUERY_AND || pExpr->eType==FTSQUERY_NOT
100164 );
100165 switch( pExpr->eType ){
100166 case FTSQUERY_NEAR: {
100167 Fts3Expr *pLeft;
100168 Fts3Expr *pRight;
100169 int mergetype = isReqPos ? MERGE_POS_NEAR : MERGE_NEAR;
100170 int nParam1;
100171 int nParam2;
100172 char *aBuffer;
100173
100174 if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){
@@ -100203,10 +100274,11 @@
100274 assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) );
100275
100276 /* In case the cursor has been used before, clear it now. */
100277 sqlite3_finalize(pCsr->pStmt);
100278 sqlite3_free(pCsr->aDoclist);
100279 sqlite3Fts3ExprFree(pCsr->pExpr);
100280 memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor));
100281
100282 /* Compile a SELECT statement for this cursor. For a full-table-scan, the
100283 ** statement loops through all rows of the %_content table. For a
100284 ** full-text query or docid lookup, the statement retrieves a single
@@ -100229,19 +100301,17 @@
100301 const char *zQuery = (const char *)sqlite3_value_text(apVal[0]);
100302
100303 if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
100304 return SQLITE_NOMEM;
100305 }
 
 
100306
100307 rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn,
100308 iCol, zQuery, -1, &pCsr->pExpr
100309 );
100310 if( rc!=SQLITE_OK ) return rc;
100311
100312 rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0);
100313 pCsr->pNextId = pCsr->aDoclist;
100314 pCsr->iPrevId = 0;
100315 }
100316
100317 if( rc!=SQLITE_OK ) return rc;
@@ -100286,25 +100356,26 @@
100356 Fts3Table *p = (Fts3Table *)pCursor->pVtab;
100357
100358 /* The column value supplied by SQLite must be in range. */
100359 assert( iCol>=0 && iCol<=p->nColumn+1 );
100360
100361 if( iCol==p->nColumn+1 ){
100362 /* This call is a request for the "docid" column. Since "docid" is an
100363 ** alias for "rowid", use the xRowid() method to obtain the value.
100364 */
100365 sqlite3_int64 iRowid;
100366 rc = fts3RowidMethod(pCursor, &iRowid);
100367 sqlite3_result_int64(pContext, iRowid);
100368 }else if( iCol==p->nColumn ){
100369 /* The extra column whose name is the same as the table.
100370 ** Return a blob which is a pointer to the cursor.
100371 */
100372 sqlite3_result_blob(pContext, &pCsr, sizeof(pCsr), SQLITE_TRANSIENT);
100373 rc = SQLITE_OK;
100374 }else{
100375 rc = fts3CursorSeek(0, pCsr);
100376 if( rc==SQLITE_OK ){
100377 sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1));
100378 }
100379 }
100380 return rc;
100381 }
@@ -100357,10 +100428,67 @@
100428 */
100429 static int fts3RollbackMethod(sqlite3_vtab *pVtab){
100430 sqlite3Fts3PendingTermsClear((Fts3Table *)pVtab);
100431 return SQLITE_OK;
100432 }
100433
100434 /*
100435 ** Load the doclist associated with expression pExpr to pExpr->aDoclist.
100436 ** The loaded doclist contains positions as well as the document ids.
100437 ** This is used by the matchinfo(), snippet() and offsets() auxillary
100438 ** functions.
100439 */
100440 SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *pTab, Fts3Expr *pExpr){
100441 return evalFts3Expr(pTab, pExpr, &pExpr->aDoclist, &pExpr->nDoclist, 1);
100442 }
100443
100444 /*
100445 ** After ExprLoadDoclist() (see above) has been called, this function is
100446 ** used to iterate through the position lists that make up the doclist
100447 ** stored in pExpr->aDoclist.
100448 */
100449 SQLITE_PRIVATE char *sqlite3Fts3FindPositions(
100450 Fts3Expr *pExpr, /* Access this expressions doclist */
100451 sqlite3_int64 iDocid, /* Docid associated with requested pos-list */
100452 int iCol /* Column of requested pos-list */
100453 ){
100454 assert( pExpr->isLoaded );
100455 if( pExpr->aDoclist ){
100456 char *pEnd = &pExpr->aDoclist[pExpr->nDoclist];
100457 char *pCsr = pExpr->pCurrent;
100458
100459 assert( pCsr );
100460 while( pCsr<pEnd ){
100461 if( pExpr->iCurrent<iDocid ){
100462 fts3PoslistCopy(0, &pCsr);
100463 fts3GetDeltaVarint(&pCsr, &pExpr->iCurrent);
100464 pExpr->pCurrent = pCsr;
100465 }else{
100466 if( pExpr->iCurrent==iDocid ){
100467 int iThis = 0;
100468 if( iCol<0 ){
100469 /* If iCol is negative, return a pointer to the start of the
100470 ** position-list (instead of a pointer to the start of a list
100471 ** of offsets associated with a specific column).
100472 */
100473 return pCsr;
100474 }
100475 while( iThis<iCol ){
100476 fts3ColumnlistCopy(0, &pCsr);
100477 if( *pCsr==0x00 ) return 0;
100478 pCsr++;
100479 pCsr += sqlite3Fts3GetVarint32(pCsr, &iThis);
100480 }
100481 if( iCol==iThis ) return pCsr;
100482 }
100483 return 0;
100484 }
100485 }
100486 }
100487
100488 return 0;
100489 }
100490
100491 /*
100492 ** Helper function used by the implementation of the overloaded snippet(),
100493 ** offsets() and optimize() SQL functions.
100494 **
@@ -100418,12 +100546,56 @@
100546 switch( nVal ){
100547 case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
100548 case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
100549 case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
100550 }
100551 if( !zEllipsis || !zEnd || !zStart ){
100552 sqlite3_result_error_nomem(pContext);
100553 }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100554 sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis);
100555 }
100556 }
100557
100558 /*
100559 ** Implementation of the snippet2() function for FTS3
100560 */
100561 static void fts3Snippet2Func(
100562 sqlite3_context *pContext, /* SQLite function call context */
100563 int nVal, /* Size of apVal[] array */
100564 sqlite3_value **apVal /* Array of arguments */
100565 ){
100566 Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
100567 const char *zStart = "<b>";
100568 const char *zEnd = "</b>";
100569 const char *zEllipsis = "<b>...</b>";
100570 int iCol = -1;
100571 int nToken = 10;
100572
100573 /* There must be at least one argument passed to this function (otherwise
100574 ** the non-overloaded version would have been called instead of this one).
100575 */
100576 assert( nVal>=1 );
100577
100578 if( nVal>6 ){
100579 sqlite3_result_error(pContext,
100580 "wrong number of arguments to function snippet()", -1);
100581 return;
100582 }
100583 if( fts3FunctionArg(pContext, "snippet", apVal[0], &pCsr) ) return;
100584
100585 switch( nVal ){
100586 case 6: nToken = sqlite3_value_int(apVal[5]);
100587 case 5: iCol = sqlite3_value_int(apVal[4]);
100588 case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]);
100589 case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
100590 case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
100591 }
100592 if( !zEllipsis || !zEnd || !zStart ){
100593 sqlite3_result_error_nomem(pContext);
100594 }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100595 sqlite3Fts3Snippet2(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
100596 }
100597 }
100598
100599 /*
100600 ** Implementation of the offsets() function for FTS3
100601 */
@@ -100437,11 +100609,13 @@
100609 UNUSED_PARAMETER(nVal);
100610
100611 assert( nVal==1 );
100612 if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return;
100613 assert( pCsr );
100614 if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
100615 sqlite3Fts3Offsets(pContext, pCsr);
100616 }
100617 }
100618
100619 /*
100620 ** Implementation of the special optimize() function for FTS3. This
100621 ** function merges all segments in the database to a single segment.
@@ -100479,10 +100653,31 @@
100653 default:
100654 sqlite3_result_error_code(pContext, rc);
100655 break;
100656 }
100657 }
100658
100659 /*
100660 ** Implementation of the matchinfo() function for FTS3
100661 */
100662 static void fts3MatchinfoFunc(
100663 sqlite3_context *pContext, /* SQLite function call context */
100664 int nVal, /* Size of argument array */
100665 sqlite3_value **apVal /* Array of arguments */
100666 ){
100667 Fts3Cursor *pCsr; /* Cursor handle passed through apVal[0] */
100668
100669 if( nVal!=1 ){
100670 sqlite3_result_error(pContext,
100671 "wrong number of arguments to function matchinfo()", -1);
100672 return;
100673 }
100674
100675 if( SQLITE_OK==fts3FunctionArg(pContext, "matchinfo", apVal[0], &pCsr) ){
100676 sqlite3Fts3Matchinfo(pContext, pCsr);
100677 }
100678 }
100679
100680 /*
100681 ** This routine implements the xFindFunction method for the FTS3
100682 ** virtual table.
100683 */
@@ -100496,12 +100691,14 @@
100691 struct Overloaded {
100692 const char *zName;
100693 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
100694 } aOverload[] = {
100695 { "snippet", fts3SnippetFunc },
100696 { "snippet2", fts3Snippet2Func },
100697 { "offsets", fts3OffsetsFunc },
100698 { "optimize", fts3OptimizeFunc },
100699 { "matchinfo", fts3MatchinfoFunc },
100700 };
100701 int i; /* Iterator variable */
100702
100703 UNUSED_PARAMETER(pVtab);
100704 UNUSED_PARAMETER(nArg);
@@ -100602,17 +100799,18 @@
100799 SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){
100800 int rc = SQLITE_OK;
100801 Fts3Hash *pHash = 0;
100802 const sqlite3_tokenizer_module *pSimple = 0;
100803 const sqlite3_tokenizer_module *pPorter = 0;
100804
100805 #ifdef SQLITE_ENABLE_ICU
100806 const sqlite3_tokenizer_module *pIcu = 0;
100807 sqlite3Fts3IcuTokenizerModule(&pIcu);
100808 #endif
100809
100810 sqlite3Fts3SimpleTokenizerModule(&pSimple);
100811 sqlite3Fts3PorterTokenizerModule(&pPorter);
 
 
 
100812
100813 /* Allocate and initialise the hash-table used to store tokenizers. */
100814 pHash = sqlite3_malloc(sizeof(Fts3Hash));
100815 if( !pHash ){
100816 rc = SQLITE_NOMEM;
@@ -100622,28 +100820,34 @@
100820
100821 /* Load the built-in tokenizers into the hash table */
100822 if( rc==SQLITE_OK ){
100823 if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple)
100824 || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter)
100825 #ifdef SQLITE_ENABLE_ICU
100826 || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu))
100827 #endif
100828 ){
100829 rc = SQLITE_NOMEM;
100830 }
100831 }
100832
100833 #ifdef SQLITE_TEST
100834 if( rc==SQLITE_OK ){
100835 rc = sqlite3Fts3ExprInitTestInterface(db);
100836 }
100837 #endif
100838
100839 /* Create the virtual table wrapper around the hash-table and overload
100840 ** the two scalar functions. If this is successful, register the
100841 ** module with sqlite.
100842 */
100843 if( SQLITE_OK==rc
100844 && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer"))
100845 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1))
100846 && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet2", -1))
100847 && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1))
100848 && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", -1))
100849 && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1))
100850 ){
100851 return sqlite3_create_module_v2(
100852 db, "fts3", &fts3Module, (void *)pHash, hashDestroy
100853 );
@@ -100850,11 +101054,11 @@
101054
101055 /*
101056 ** Enlarge a memory allocation. If an out-of-memory allocation occurs,
101057 ** then free the old allocation.
101058 */
101059 static void *fts3ReallocOrFree(void *pOrig, int nNew){
101060 void *pRet = sqlite3_realloc(pOrig, nNew);
101061 if( !pRet ){
101062 sqlite3_free(pOrig);
101063 }
101064 return pRet;
@@ -101404,10 +101608,11 @@
101608 */
101609 SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *p){
101610 if( p ){
101611 sqlite3Fts3ExprFree(p->pLeft);
101612 sqlite3Fts3ExprFree(p->pRight);
101613 sqlite3_free(p->aDoclist);
101614 sqlite3_free(p);
101615 }
101616 }
101617
101618 /****************************************************************************
@@ -101581,12 +101786,12 @@
101786
101787 /*
101788 ** Register the query expression parser test function fts3_exprtest()
101789 ** with database connection db.
101790 */
101791 SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){
101792 return sqlite3_create_function(
101793 db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0
101794 );
101795 }
101796
101797 #endif
@@ -101868,26 +102073,36 @@
102073 assert( pH->count==0 );
102074 fts3HashClear(pH);
102075 }
102076 }
102077
102078 SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(
102079 const Fts3Hash *pH,
102080 const void *pKey,
102081 int nKey
102082 ){
102083 int h; /* A hash on key */
 
102084 int (*xHash)(const void*,int); /* The hash function */
102085
102086 if( pH==0 || pH->ht==0 ) return 0;
102087 xHash = ftsHashFunction(pH->keyClass);
102088 assert( xHash!=0 );
102089 h = (*xHash)(pKey,nKey);
102090 assert( (pH->htsize & (pH->htsize-1))==0 );
102091 return fts3FindElementByHash(pH,pKey,nKey, h & (pH->htsize-1));
102092 }
102093
102094 /*
102095 ** Attempt to locate an element of the hash table pH with a key
102096 ** that matches pKey,nKey. Return the data for this element if it is
102097 ** found, or NULL if there is no match.
102098 */
102099 SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash *pH, const void *pKey, int nKey){
102100 Fts3HashElem *pElem; /* The element that matches key (if any) */
102101
102102 pElem = sqlite3Fts3HashFindElem(pH, pKey, nKey);
102103 return pElem ? pElem->data : 0;
102104 }
102105
102106 /* Insert an element into the hash table pH. The key is pKey,nKey
102107 ** and the data is "data".
102108 **
@@ -102720,18 +102935,18 @@
102935 const char *z2 = 0;
102936
102937 /* Find the start of the next token. */
102938 z1 = zStr;
102939 while( z2==0 ){
102940 char c = *z1;
102941 switch( c ){
102942 case '\0': return 0; /* No more tokens here */
102943 case '\'':
102944 case '"':
102945 case '`': {
102946 z2 = z1;
102947 while( *++z2 && (*z2!=c || *++z2==c) );
 
102948 break;
102949 }
102950 case '[':
102951 z2 = &z1[1];
102952 while( *z2 && z2[0]!=']' ) z2++;
@@ -103065,14 +103280,14 @@
103280 const char *zName
103281 ){
103282 int rc = SQLITE_OK;
103283 void *p = (void *)pHash;
103284 const int any = SQLITE_ANY;
103285
103286 #ifdef SQLITE_TEST
103287 char *zTest = 0;
103288 char *zTest2 = 0;
 
 
103289 void *pdb = (void *)db;
103290 zTest = sqlite3_mprintf("%s_test", zName);
103291 zTest2 = sqlite3_mprintf("%s_internal_test", zName);
103292 if( !zTest || !zTest2 ){
103293 rc = SQLITE_NOMEM;
@@ -103085,14 +103300,17 @@
103300 #ifdef SQLITE_TEST
103301 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0))
103302 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0))
103303 || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0))
103304 #endif
103305 );
103306
103307 #ifdef SQLITE_TEST
103308 sqlite3_free(zTest);
103309 sqlite3_free(zTest2);
103310 #endif
103311
103312 return rc;
103313 }
103314
103315 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
103316
@@ -103350,11 +103568,11 @@
103568 typedef struct SegmentNode SegmentNode;
103569 typedef struct SegmentWriter SegmentWriter;
103570
103571 /*
103572 ** Data structure used while accumulating terms in the pending-terms hash
103573 ** table. The hash table entry maps from term (a string) to a malloc'd
103574 ** instance of this structure.
103575 */
103576 struct PendingList {
103577 int nData;
103578 char *aData;
@@ -103372,19 +103590,26 @@
103590 ** terms when querying the full-text index. See functions:
103591 **
103592 ** sqlite3Fts3SegReaderNew()
103593 ** sqlite3Fts3SegReaderFree()
103594 ** sqlite3Fts3SegReaderIterate()
103595 **
103596 ** Methods used to manipulate Fts3SegReader structures:
103597 **
103598 ** fts3SegReaderNext()
103599 ** fts3SegReaderFirstDocid()
103600 ** fts3SegReaderNextDocid()
103601 */
103602 struct Fts3SegReader {
103603 int iIdx; /* Index within level, or 0x7FFFFFFF for PT */
103604 sqlite3_int64 iStartBlock;
103605 sqlite3_int64 iEndBlock;
103606 sqlite3_stmt *pStmt; /* SQL Statement to access leaf nodes */
103607 char *aNode; /* Pointer to node data (or NULL) */
103608 int nNode; /* Size of buffer at aNode (or 0) */
103609 int nTermAlloc; /* Allocated size of zTerm buffer */
103610 Fts3HashElem **ppNextElem;
103611
103612 /* Variables set by fts3SegReaderNext(). These may be read directly
103613 ** by the caller. They are valid from the time SegmentReaderNew() returns
103614 ** until SegmentReaderNext() returns something other than SQLITE_OK
103615 ** (i.e. SQLITE_DONE).
@@ -103396,10 +103621,12 @@
103621
103622 /* The following variables are used to iterate through the current doclist */
103623 char *pOffsetList;
103624 sqlite3_int64 iDocid;
103625 };
103626
103627 #define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0)
103628
103629 /*
103630 ** An instance of this structure is used to create a segment b-tree in the
103631 ** database. The internal details of this type are only accessed by the
103632 ** following functions:
@@ -103600,17 +103827,17 @@
103827
103828 if( pzBlock ){
103829 sqlite3_bind_int64(pStmt, 1, iBlock);
103830 rc = sqlite3_step(pStmt);
103831 if( rc!=SQLITE_ROW ){
103832 return (rc==SQLITE_DONE ? SQLITE_CORRUPT : rc);
103833 }
103834
103835 *pnBlock = sqlite3_column_bytes(pStmt, 0);
103836 *pzBlock = (char *)sqlite3_column_blob(pStmt, 0);
103837 if( sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
103838 return SQLITE_CORRUPT;
103839 }
103840 }
103841 return SQLITE_OK;
103842 }
103843
@@ -103821,11 +104048,11 @@
104048 ** forced-flush would provide better performance. I suspect that if
104049 ** we ordered the doclists by size and flushed the largest until the
104050 ** buffer was half empty, that would let the less frequent terms
104051 ** generate longer doclists.
104052 */
104053 if( iDocid<=p->iPrevDocid || p->nPendingData>p->nMaxPendingData ){
104054 int rc = sqlite3Fts3PendingTermsFlush(p);
104055 if( rc!=SQLITE_OK ) return rc;
104056 }
104057 p->iPrevDocid = iDocid;
104058 return SQLITE_OK;
@@ -104048,10 +104275,25 @@
104275 pNext = &pReader->aDoclist[pReader->nDoclist];
104276 }
104277
104278 if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){
104279 int rc;
104280 if( fts3SegReaderIsPending(pReader) ){
104281 Fts3HashElem *pElem = *(pReader->ppNextElem);
104282 if( pElem==0 ){
104283 pReader->aNode = 0;
104284 }else{
104285 PendingList *pList = (PendingList *)fts3HashData(pElem);
104286 pReader->zTerm = (char *)fts3HashKey(pElem);
104287 pReader->nTerm = fts3HashKeysize(pElem);
104288 pReader->nNode = pReader->nDoclist = pList->nData + 1;
104289 pReader->aNode = pReader->aDoclist = pList->aData;
104290 pReader->ppNextElem++;
104291 assert( pReader->aNode );
104292 }
104293 return SQLITE_OK;
104294 }
104295 if( !pReader->pStmt ){
104296 pReader->aNode = 0;
104297 return SQLITE_OK;
104298 }
104299 rc = sqlite3_step(pReader->pStmt);
@@ -104157,11 +104399,13 @@
104399 */
104400 assert( p->nLeavesStmt<p->nLeavesTotal );
104401 sqlite3_reset(pReader->pStmt);
104402 p->aLeavesStmt[p->nLeavesStmt++] = pReader->pStmt;
104403 }
104404 if( !fts3SegReaderIsPending(pReader) ){
104405 sqlite3_free(pReader->zTerm);
104406 }
104407 sqlite3_free(pReader);
104408 }
104409 }
104410
104411 /*
@@ -104254,10 +104498,107 @@
104498 sqlite3Fts3SegReaderFree(p, pReader);
104499 }
104500 return rc;
104501 }
104502
104503 /*
104504 ** This is a comparison function used as a qsort() callback when sorting
104505 ** an array of pending terms by term. This occurs as part of flushing
104506 ** the contents of the pending-terms hash table to the database.
104507 */
104508 static int fts3CompareElemByTerm(const void *lhs, const void *rhs){
104509 char *z1 = fts3HashKey(*(Fts3HashElem **)lhs);
104510 char *z2 = fts3HashKey(*(Fts3HashElem **)rhs);
104511 int n1 = fts3HashKeysize(*(Fts3HashElem **)lhs);
104512 int n2 = fts3HashKeysize(*(Fts3HashElem **)rhs);
104513
104514 int n = (n1<n2 ? n1 : n2);
104515 int c = memcmp(z1, z2, n);
104516 if( c==0 ){
104517 c = n1 - n2;
104518 }
104519 return c;
104520 }
104521
104522 /*
104523 ** This function is used to allocate an Fts3SegReader that iterates through
104524 ** a subset of the terms stored in the Fts3Table.pendingTerms array.
104525 */
104526 SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(
104527 Fts3Table *p, /* Virtual table handle */
104528 const char *zTerm, /* Term to search for */
104529 int nTerm, /* Size of buffer zTerm */
104530 int isPrefix, /* True for a term-prefix query */
104531 Fts3SegReader **ppReader /* OUT: SegReader for pending-terms */
104532 ){
104533 Fts3SegReader *pReader = 0; /* Fts3SegReader object to return */
104534 Fts3HashElem **aElem = 0; /* Array of term hash entries to scan */
104535 int nElem = 0; /* Size of array at aElem */
104536 int rc = SQLITE_OK; /* Return Code */
104537
104538 if( isPrefix ){
104539 int nAlloc = 0; /* Size of allocated array at aElem */
104540 Fts3HashElem *pE = 0; /* Iterator variable */
104541
104542 for(pE=fts3HashFirst(&p->pendingTerms); pE; pE=fts3HashNext(pE)){
104543 char *zKey = (char *)fts3HashKey(pE);
104544 int nKey = fts3HashKeysize(pE);
104545 if( nTerm==0 || (nKey>=nTerm && 0==memcmp(zKey, zTerm, nTerm)) ){
104546 if( nElem==nAlloc ){
104547 Fts3HashElem **aElem2;
104548 nAlloc += 16;
104549 aElem2 = (Fts3HashElem **)sqlite3_realloc(
104550 aElem, nAlloc*sizeof(Fts3HashElem *)
104551 );
104552 if( !aElem2 ){
104553 rc = SQLITE_NOMEM;
104554 nElem = 0;
104555 break;
104556 }
104557 aElem = aElem2;
104558 }
104559 aElem[nElem++] = pE;
104560 }
104561 }
104562
104563 /* If more than one term matches the prefix, sort the Fts3HashElem
104564 ** objects in term order using qsort(). This uses the same comparison
104565 ** callback as is used when flushing terms to disk.
104566 */
104567 if( nElem>1 ){
104568 qsort(aElem, nElem, sizeof(Fts3HashElem *), fts3CompareElemByTerm);
104569 }
104570
104571 }else{
104572 Fts3HashElem *pE = fts3HashFindElem(&p->pendingTerms, zTerm, nTerm);
104573 if( pE ){
104574 aElem = &pE;
104575 nElem = 1;
104576 }
104577 }
104578
104579 if( nElem>0 ){
104580 int nByte = sizeof(Fts3SegReader) + (nElem+1)*sizeof(Fts3HashElem *);
104581 pReader = (Fts3SegReader *)sqlite3_malloc(nByte);
104582 if( !pReader ){
104583 rc = SQLITE_NOMEM;
104584 }else{
104585 memset(pReader, 0, nByte);
104586 pReader->iIdx = 0x7FFFFFFF;
104587 pReader->ppNextElem = (Fts3HashElem **)&pReader[1];
104588 memcpy(pReader->ppNextElem, aElem, nElem*sizeof(Fts3HashElem *));
104589 fts3SegReaderNext(pReader);
104590 }
104591 }
104592
104593 if( isPrefix ){
104594 sqlite3_free(aElem);
104595 }
104596 *ppReader = pReader;
104597 return rc;
104598 }
104599
104600
104601 /*
104602 ** The second argument to this function is expected to be a statement of
104603 ** the form:
104604 **
@@ -104297,11 +104638,11 @@
104638 ** Compare the entries pointed to by two Fts3SegReader structures.
104639 ** Comparison is as follows:
104640 **
104641 ** 1) EOF is greater than not EOF.
104642 **
104643 ** 2) The current terms (if any) are compared using memcmp(). If one
104644 ** term is a prefix of another, the longer term is considered the
104645 ** larger.
104646 **
104647 ** 3) By segment age. An older segment is considered larger.
104648 */
@@ -104425,15 +104766,13 @@
104766 ){
104767 sqlite3_stmt *pStmt;
104768 int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0);
104769 if( rc==SQLITE_OK ){
104770 sqlite3_bind_int64(pStmt, 1, iBlock);
104771 sqlite3_bind_blob(pStmt, 2, z, n, SQLITE_STATIC);
104772 sqlite3_step(pStmt);
104773 rc = sqlite3_reset(pStmt);
 
 
104774 }
104775 return rc;
104776 }
104777
104778 /*
@@ -104455,15 +104794,13 @@
104794 sqlite3_bind_int(pStmt, 1, iLevel);
104795 sqlite3_bind_int(pStmt, 2, iIdx);
104796 sqlite3_bind_int64(pStmt, 3, iStartBlock);
104797 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
104798 sqlite3_bind_int64(pStmt, 5, iEndBlock);
104799 sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
104800 sqlite3_step(pStmt);
104801 rc = sqlite3_reset(pStmt);
 
 
104802 }
104803 return rc;
104804 }
104805
104806 /*
@@ -105038,20 +105375,36 @@
105375 /*
105376 ** sqlite3Fts3SegReaderIterate() callback used when merging multiple
105377 ** segments to create a single, larger segment.
105378 */
105379 static int fts3MergeCallback(
105380 Fts3Table *p, /* FTS3 Virtual table handle */
105381 void *pContext, /* Pointer to SegmentWriter* to write with */
105382 char *zTerm, /* Term to write to the db */
105383 int nTerm, /* Number of bytes in zTerm */
105384 char *aDoclist, /* Doclist associated with zTerm */
105385 int nDoclist /* Number of bytes in doclist */
105386 ){
105387 SegmentWriter **ppW = (SegmentWriter **)pContext;
105388 return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist);
105389 }
105390
105391 /*
105392 ** sqlite3Fts3SegReaderIterate() callback used when flushing the contents
105393 ** of the pending-terms hash table to the database.
105394 */
105395 static int fts3FlushCallback(
105396 Fts3Table *p, /* FTS3 Virtual table handle */
105397 void *pContext, /* Pointer to SegmentWriter* to write with */
105398 char *zTerm, /* Term to write to the db */
105399 int nTerm, /* Number of bytes in zTerm */
105400 char *aDoclist, /* Doclist associated with zTerm */
105401 int nDoclist /* Number of bytes in doclist */
105402 ){
105403 SegmentWriter **ppW = (SegmentWriter **)pContext;
105404 return fts3SegWriterAdd(p, ppW, 0, zTerm, nTerm, aDoclist, nDoclist);
105405 }
105406
105407 /*
105408 ** This function is used to iterate through a contiguous set of terms
105409 ** stored in the full-text index. It merges data contained in one or
105410 ** more segments to support this.
@@ -105110,12 +105463,11 @@
105463 const char *zTerm = pFilter->zTerm;
105464 for(i=0; i<nSegment; i++){
105465 Fts3SegReader *pSeg = apSegment[i];
105466 while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ){
105467 rc = fts3SegReaderNext(pSeg);
105468 if( rc!=SQLITE_OK ) goto finished; }
 
105469 }
105470 }
105471
105472 fts3SegReaderSort(apSegment, nSegment, nSegment, fts3SegReaderCmp);
105473 while( apSegment[0]->aNode ){
@@ -105145,11 +105497,12 @@
105497 && 0==memcmp(zTerm, apSegment[nMerge]->zTerm, nTerm)
105498 ){
105499 nMerge++;
105500 }
105501
105502 assert( isIgnoreEmpty || (isRequirePos && !isColFilter) );
105503 if( nMerge==1 && !isIgnoreEmpty ){
105504 Fts3SegReader *p0 = apSegment[0];
105505 rc = xFunc(p, pContext, zTerm, nTerm, p0->aDoclist, p0->nDoclist);
105506 if( rc!=SQLITE_OK ) goto finished;
105507 }else{
105508 int nDoclist = 0; /* Size of doclist */
@@ -105169,13 +105522,13 @@
105522 int nList;
105523 int nByte;
105524 sqlite3_int64 iDocid = apSegment[0]->iDocid;
105525 fts3SegReaderNextDocid(apSegment[0], &pList, &nList);
105526 j = 1;
105527 while( j<nMerge
105528 && apSegment[j]->pOffsetList
105529 && apSegment[j]->iDocid==iDocid
105530 ){
105531 fts3SegReaderNextDocid(apSegment[j], 0, 0);
105532 j++;
105533 }
105534
@@ -105247,25 +105600,30 @@
105600 static int fts3SegmentMerge(Fts3Table *p, int iLevel){
105601 int i; /* Iterator variable */
105602 int rc; /* Return code */
105603 int iIdx; /* Index of new segment */
105604 int iNewLevel; /* Level to create new segment at */
105605 sqlite3_stmt *pStmt = 0;
105606 SegmentWriter *pWriter = 0;
105607 int nSegment = 0; /* Number of segments being merged */
105608 Fts3SegReader **apSegment = 0; /* Array of Segment iterators */
105609 Fts3SegReader *pPending = 0; /* Iterator for pending-terms */
105610 Fts3SegFilter filter; /* Segment term filter condition */
105611
105612 if( iLevel<0 ){
105613 /* This call is to merge all segments in the database to a single
105614 ** segment. The level of the new segment is equal to the the numerically
105615 ** greatest segment level currently present in the database. The index
105616 ** of the new segment is always 0.
105617 */
105618 iIdx = 0;
105619 rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pPending);
105620 if( rc!=SQLITE_OK ) goto finished;
105621 rc = fts3SegmentCountMax(p, &nSegment, &iNewLevel);
105622 if( rc!=SQLITE_OK ) goto finished;
105623 nSegment += (pPending!=0);
105624 if( nSegment<=1 ){
105625 return SQLITE_DONE;
105626 }
105627 }else{
105628 /* This call is to merge all segments at level iLevel. Find the next
105629 ** available segment index at level iLevel+1. The call to
@@ -105272,21 +105630,22 @@
105630 ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to
105631 ** a single iLevel+2 segment if necessary.
105632 */
105633 iNewLevel = iLevel+1;
105634 rc = fts3AllocateSegdirIdx(p, iNewLevel, &iIdx);
105635 if( rc!=SQLITE_OK ) goto finished;
105636 rc = fts3SegmentCount(p, iLevel, &nSegment);
105637 if( rc!=SQLITE_OK ) goto finished;
105638 }
 
105639 assert( nSegment>0 );
105640 assert( iNewLevel>=0 );
105641
105642 /* Allocate space for an array of pointers to segment iterators. */
105643 apSegment = (Fts3SegReader**)sqlite3_malloc(sizeof(Fts3SegReader *)*nSegment);
105644 if( !apSegment ){
105645 rc = SQLITE_NOMEM;
105646 goto finished;
105647 }
105648 memset(apSegment, 0, sizeof(Fts3SegReader *)*nSegment);
105649
105650 /* Allocate a Fts3SegReader structure for each segment being merged. A
105651 ** Fts3SegReader stores the state data required to iterate through all
@@ -105301,10 +105660,14 @@
105660 if( rc!=SQLITE_OK ){
105661 goto finished;
105662 }
105663 }
105664 rc = sqlite3_reset(pStmt);
105665 if( pPending ){
105666 apSegment[i] = pPending;
105667 pPending = 0;
105668 }
105669 pStmt = 0;
105670 if( rc!=SQLITE_OK ) goto finished;
105671
105672 memset(&filter, 0, sizeof(Fts3SegFilter));
105673 filter.flags = FTS3_SEGMENT_REQUIRE_POS;
@@ -105325,94 +105688,105 @@
105688 for(i=0; i<nSegment; i++){
105689 sqlite3Fts3SegReaderFree(p, apSegment[i]);
105690 }
105691 sqlite3_free(apSegment);
105692 }
105693 sqlite3Fts3SegReaderFree(p, pPending);
105694 sqlite3_reset(pStmt);
105695 return rc;
105696 }
105697
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105698
105699 /*
105700 ** Flush the contents of pendingTerms to a level 0 segment.
105701 */
105702 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
105703 int rc; /* Return Code */
105704 int idx; /* Index of new segment created */
 
 
105705 SegmentWriter *pWriter = 0; /* Used to write the segment */
105706 Fts3SegReader *pReader = 0; /* Used to iterate through the hash table */
105707
105708 /* Allocate a SegReader object to iterate through the contents of the
105709 ** pending-terms table. If an error occurs, or if there are no terms
105710 ** in the pending-terms table, return immediately.
105711 */
105712 rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pReader);
105713 if( rc!=SQLITE_OK || pReader==0 ){
105714 return rc;
 
105715 }
105716
105717 /* Determine the next index at level 0. If level 0 is already full, this
105718 ** call may merge all existing level 0 segments into a single level 1
105719 ** segment.
105720 */
105721 rc = fts3AllocateSegdirIdx(p, 0, &idx);
105722
105723 /* If no errors have occured, iterate through the contents of the
105724 ** pending-terms hash table using the Fts3SegReader iterator. The callback
105725 ** writes each term (along with its doclist) to the database via the
105726 ** SegmentWriter handle pWriter.
 
 
 
 
 
 
 
 
 
 
 
 
 
105727 */
105728 if( rc==SQLITE_OK ){
105729 void *c = (void *)&pWriter; /* SegReaderIterate() callback context */
105730 Fts3SegFilter f; /* SegReaderIterate() parameters */
105731
105732 memset(&f, 0, sizeof(Fts3SegFilter));
105733 f.flags = FTS3_SEGMENT_REQUIRE_POS;
105734 rc = sqlite3Fts3SegReaderIterate(p, &pReader, 1, &f, fts3FlushCallback, c);
105735 }
105736 assert( pWriter || rc!=SQLITE_OK );
105737
105738 /* If no errors have occured, flush the SegmentWriter object to the
105739 ** database. Then delete the SegmentWriter and Fts3SegReader objects
105740 ** allocated by this function.
105741 */
105742 if( rc==SQLITE_OK ){
105743 rc = fts3SegWriterFlush(p, pWriter, 0, idx);
105744 }
 
 
105745 fts3SegWriterFree(pWriter);
105746 sqlite3Fts3SegReaderFree(p, pReader);
105747
105748 if( rc==SQLITE_OK ){
105749 sqlite3Fts3PendingTermsClear(p);
105750 }
105751 return rc;
105752 }
105753
105754 /*
105755 ** Handle a 'special' INSERT of the form:
105756 **
105757 ** "INSERT INTO tbl(tbl) VALUES(<expr>)"
105758 **
105759 ** Argument pVal contains the result of <expr>. Currently the only
105760 ** meaningful value to insert is the text 'optimize'.
105761 */
105762 static int fts3SpecialInsert(Fts3Table *p, sqlite3_value *pVal){
105763 int rc; /* Return Code */
105764 const char *zVal = (const char *)sqlite3_value_text(pVal);
105765 int nVal = sqlite3_value_bytes(pVal);
105766
105767 if( !zVal ){
105768 return SQLITE_NOMEM;
105769 }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
105770 rc = fts3SegmentMerge(p, -1);
105771 if( rc==SQLITE_DONE ){
105772 rc = SQLITE_OK;
105773 }else{
105774 sqlite3Fts3PendingTermsClear(p);
105775 }
105776 #ifdef SQLITE_TEST
105777 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
105778 p->nNodeSize = atoi(&zVal[9]);
105779 rc = SQLITE_OK;
105780 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
105781 p->nMaxPendingData = atoi(&zVal[11]);
105782 rc = SQLITE_OK;
105783 #endif
105784 }else{
105785 rc = SQLITE_ERROR;
105786 }
105787
105788 return rc;
105789 }
105790
105791 /*
105792 ** This function does the work for the xUpdate method of FTS3 virtual
@@ -105426,10 +105800,11 @@
105800 ){
105801 Fts3Table *p = (Fts3Table *)pVtab;
105802 int rc = SQLITE_OK; /* Return Code */
105803 int isRemove = 0; /* True for an UPDATE or DELETE */
105804 sqlite3_int64 iRemove = 0; /* Rowid removed by UPDATE or DELETE */
105805
105806
105807 /* If this is a DELETE or UPDATE operation, remove the old record. */
105808 if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){
105809 int isEmpty;
105810 rc = fts3IsEmpty(p, apVal, &isEmpty);
@@ -105450,10 +105825,12 @@
105825 rc = fts3SqlExec(p, SQL_DELETE_CONTENT, apVal);
105826 }
105827 }
105828 }
105829 }
105830 }else if( sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL ){
105831 return fts3SpecialInsert(p, apVal[p->nColumn+2]);
105832 }
105833
105834 /* If this is an INSERT or UPDATE operation, insert the new record. */
105835 if( nArg>1 && rc==SQLITE_OK ){
105836 rc = fts3InsertData(p, apVal, pRowid);
@@ -105475,18 +105852,19 @@
105852 */
105853 SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){
105854 int rc;
105855 rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0);
105856 if( rc==SQLITE_OK ){
105857 rc = fts3SegmentMerge(p, -1);
 
 
 
105858 if( rc==SQLITE_OK ){
105859 rc = sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
105860 if( rc==SQLITE_OK ){
105861 sqlite3Fts3PendingTermsClear(p);
105862 }
105863 }else{
105864 sqlite3_exec(p->db, "ROLLBACK TO fts3", 0, 0, 0);
105865 sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0);
105866 }
105867 }
105868 return rc;
105869 }
105870
@@ -106220,10 +106598,620 @@
106598 }else{
106599 sqlite3_result_error_nomem(pCtx);
106600 }
106601 fts3SnippetFree(p);
106602 }
106603
106604 /*************************************************************************
106605 ** Below this point is the alternative, experimental snippet() implementation.
106606 */
106607
106608 #define SNIPPET_BUFFER_CHUNK 64
106609 #define SNIPPET_BUFFER_SIZE SNIPPET_BUFFER_CHUNK*4
106610 #define SNIPPET_BUFFER_MASK (SNIPPET_BUFFER_SIZE-1)
106611
106612 static void fts3GetDeltaPosition(char **pp, int *piPos){
106613 int iVal;
106614 *pp += sqlite3Fts3GetVarint32(*pp, &iVal);
106615 *piPos += (iVal-2);
106616 }
106617
106618 /*
106619 ** Iterate through all phrase nodes in an FTS3 query, except those that
106620 ** are part of a sub-tree that is the right-hand-side of a NOT operator.
106621 ** For each phrase node found, the supplied callback function is invoked.
106622 **
106623 ** If the callback function returns anything other than SQLITE_OK,
106624 ** the iteration is abandoned and the error code returned immediately.
106625 ** Otherwise, SQLITE_OK is returned after a callback has been made for
106626 ** all eligible phrase nodes.
106627 */
106628 static int fts3ExprIterate(
106629 Fts3Expr *pExpr, /* Expression to iterate phrases of */
106630 int (*x)(Fts3Expr *, void *), /* Callback function to invoke for phrases */
106631 void *pCtx /* Second argument to pass to callback */
106632 ){
106633 int rc;
106634 int eType = pExpr->eType;
106635 if( eType==FTSQUERY_NOT ){
106636 rc = SQLITE_OK;
106637 }else if( eType!=FTSQUERY_PHRASE ){
106638 assert( pExpr->pLeft && pExpr->pRight );
106639 rc = fts3ExprIterate(pExpr->pLeft, x, pCtx);
106640 if( rc==SQLITE_OK ){
106641 rc = fts3ExprIterate(pExpr->pRight, x, pCtx);
106642 }
106643 }else{
106644 rc = x(pExpr, pCtx);
106645 }
106646 return rc;
106647 }
106648
106649 typedef struct LoadDoclistCtx LoadDoclistCtx;
106650 struct LoadDoclistCtx {
106651 Fts3Table *pTab; /* FTS3 Table */
106652 int nPhrase; /* Number of phrases so far */
106653 };
106654
106655 static int fts3ExprLoadDoclistsCb(Fts3Expr *pExpr, void *ctx){
106656 int rc = SQLITE_OK;
106657 LoadDoclistCtx *p = (LoadDoclistCtx *)ctx;
106658 p->nPhrase++;
106659 if( pExpr->isLoaded==0 ){
106660 rc = sqlite3Fts3ExprLoadDoclist(p->pTab, pExpr);
106661 pExpr->isLoaded = 1;
106662 if( rc==SQLITE_OK && pExpr->aDoclist ){
106663 pExpr->pCurrent = pExpr->aDoclist;
106664 pExpr->pCurrent += sqlite3Fts3GetVarint(pExpr->pCurrent,&pExpr->iCurrent);
106665 }
106666 }
106667 return rc;
106668 }
106669
106670 static int fts3ExprLoadDoclists(Fts3Cursor *pCsr, int *pnPhrase){
106671 int rc;
106672 LoadDoclistCtx sCtx = {0, 0};
106673 sCtx.pTab = (Fts3Table *)pCsr->base.pVtab;
106674 rc = fts3ExprIterate(pCsr->pExpr, fts3ExprLoadDoclistsCb, (void *)&sCtx);
106675 *pnPhrase = sCtx.nPhrase;
106676 return rc;
106677 }
106678
106679 /*
106680 ** Each call to this function populates a chunk of a snippet-buffer
106681 ** SNIPPET_BUFFER_CHUNK bytes in size.
106682 **
106683 ** Return true if the end of the data has been reached (and all subsequent
106684 ** calls to fts3LoadSnippetBuffer() with the same arguments will be no-ops),
106685 ** or false otherwise.
106686 */
106687 static int fts3LoadSnippetBuffer(
106688 int iPos, /* Document token offset to load data for */
106689 u8 *aBuffer, /* Circular snippet buffer to populate */
106690 int nList, /* Number of position lists in appList */
106691 char **apList, /* IN/OUT: nList position list pointers */
106692 int *aiPrev /* IN/OUT: Previous positions read */
106693 ){
106694 int i;
106695 int nFin = 0;
106696
106697 assert( (iPos&(SNIPPET_BUFFER_CHUNK-1))==0 );
106698
106699 memset(&aBuffer[iPos&SNIPPET_BUFFER_MASK], 0, SNIPPET_BUFFER_CHUNK);
106700
106701 for(i=0; i<nList; i++){
106702 int iPrev = aiPrev[i];
106703 char *pList = apList[i];
106704
106705 if( !pList ){
106706 nFin++;
106707 continue;
106708 }
106709
106710 while( iPrev<(iPos+SNIPPET_BUFFER_CHUNK) ){
106711 if( iPrev>=iPos ){
106712 aBuffer[iPrev&SNIPPET_BUFFER_MASK] = i+1;
106713 }
106714 if( 0==((*pList)&0xFE) ){
106715 nFin++;
106716 break;
106717 }
106718 fts3GetDeltaPosition(&pList, &iPrev);
106719 }
106720
106721 aiPrev[i] = iPrev;
106722 apList[i] = pList;
106723 }
106724
106725 return (nFin==nList);
106726 }
106727
106728 typedef struct SnippetCtx SnippetCtx;
106729 struct SnippetCtx {
106730 Fts3Cursor *pCsr;
106731 int iCol;
106732 int iPhrase;
106733 int *aiPrev;
106734 int *anToken;
106735 char **apList;
106736 };
106737
106738 static int fts3SnippetFindPositions(Fts3Expr *pExpr, void *ctx){
106739 SnippetCtx *p = (SnippetCtx *)ctx;
106740 int iPhrase = p->iPhrase++;
106741 char *pCsr;
106742
106743 p->anToken[iPhrase] = pExpr->pPhrase->nToken;
106744 pCsr = sqlite3Fts3FindPositions(pExpr, p->pCsr->iPrevId, p->iCol);
106745
106746 if( pCsr ){
106747 int iVal;
106748 pCsr += sqlite3Fts3GetVarint32(pCsr, &iVal);
106749 p->apList[iPhrase] = pCsr;
106750 p->aiPrev[iPhrase] = iVal-2;
106751 }
106752 return SQLITE_OK;
106753 }
106754
106755 static void fts3SnippetCnt(
106756 int iIdx,
106757 int nSnippet,
106758 int *anCnt,
106759 u8 *aBuffer,
106760 int *anToken,
106761 u64 *pHlmask
106762 ){
106763 int iSub = (iIdx-1)&SNIPPET_BUFFER_MASK;
106764 int iAdd = (iIdx+nSnippet-1)&SNIPPET_BUFFER_MASK;
106765 int iSub2 = (iIdx+(nSnippet/3)-1)&SNIPPET_BUFFER_MASK;
106766 int iAdd2 = (iIdx+(nSnippet*2/3)-1)&SNIPPET_BUFFER_MASK;
106767
106768 u64 h = *pHlmask;
106769
106770 anCnt[ aBuffer[iSub] ]--;
106771 anCnt[ aBuffer[iSub2] ]--;
106772 anCnt[ aBuffer[iAdd] ]++;
106773 anCnt[ aBuffer[iAdd2] ]++;
106774
106775 h = h >> 1;
106776 if( aBuffer[iAdd] ){
106777 int j;
106778 for(j=anToken[aBuffer[iAdd]-1]; j>=1; j--){
106779 h |= (u64)1 << (nSnippet-j);
106780 }
106781 }
106782 *pHlmask = h;
106783 }
106784
106785 static int fts3SnippetScore(int n, int *anCnt){
106786 int j;
106787 int iScore = 0;
106788 for(j=1; j<=n; j++){
106789 int nCnt = anCnt[j];
106790 iScore += nCnt + (nCnt ? 1000 : 0);
106791 }
106792 return iScore;
106793 }
106794
106795 static int fts3BestSnippet(
106796 int nSnippet, /* Desired snippet length */
106797 Fts3Cursor *pCsr, /* Cursor to create snippet for */
106798 int iCol, /* Index of column to create snippet from */
106799 int *piPos, /* OUT: Starting token for best snippet */
106800 u64 *pHlmask /* OUT: Highlight mask for best snippet */
106801 ){
106802 int rc; /* Return Code */
106803 u8 aBuffer[SNIPPET_BUFFER_SIZE];/* Circular snippet buffer */
106804 int *aiPrev; /* Used by fts3LoadSnippetBuffer() */
106805 int *anToken; /* Number of tokens in each phrase */
106806 char **apList; /* Array of position lists */
106807 int *anCnt; /* Running totals of phrase occurences */
106808 int nList;
106809
106810 int i;
106811
106812 u64 hlmask = 0; /* Current mask of highlighted terms */
106813 u64 besthlmask = 0; /* Mask of highlighted terms for iBestPos */
106814 int iBestPos = 0; /* Starting position of 'best' snippet */
106815 int iBestScore = 0; /* Score of best snippet higher->better */
106816 SnippetCtx sCtx;
106817
106818 /* Iterate through the phrases in the expression to count them. The same
106819 ** callback makes sure the doclists are loaded for each phrase.
106820 */
106821 rc = fts3ExprLoadDoclists(pCsr, &nList);
106822 if( rc!=SQLITE_OK ){
106823 return rc;
106824 }
106825
106826 /* Now that it is known how many phrases there are, allocate and zero
106827 ** the required arrays using malloc().
106828 */
106829 apList = sqlite3_malloc(
106830 sizeof(u8*)*nList + /* apList */
106831 sizeof(int)*(nList) + /* anToken */
106832 sizeof(int)*nList + /* aiPrev */
106833 sizeof(int)*(nList+1) /* anCnt */
106834 );
106835 if( !apList ){
106836 return SQLITE_NOMEM;
106837 }
106838 memset(apList, 0, sizeof(u8*)*nList+sizeof(int)*nList+sizeof(int)*nList);
106839 anToken = (int *)&apList[nList];
106840 aiPrev = &anToken[nList];
106841 anCnt = &aiPrev[nList];
106842
106843 /* Initialize the contents of the aiPrev and aiList arrays. */
106844 sCtx.pCsr = pCsr;
106845 sCtx.iCol = iCol;
106846 sCtx.apList = apList;
106847 sCtx.aiPrev = aiPrev;
106848 sCtx.anToken = anToken;
106849 sCtx.iPhrase = 0;
106850 (void)fts3ExprIterate(pCsr->pExpr, fts3SnippetFindPositions, (void *)&sCtx);
106851
106852 /* Load the first two chunks of data into the buffer. */
106853 memset(aBuffer, 0, SNIPPET_BUFFER_SIZE);
106854 fts3LoadSnippetBuffer(0, aBuffer, nList, apList, aiPrev);
106855 fts3LoadSnippetBuffer(SNIPPET_BUFFER_CHUNK, aBuffer, nList, apList, aiPrev);
106856
106857 /* Set the initial contents of the highlight-mask and anCnt[] array. */
106858 for(i=1-nSnippet; i<=0; i++){
106859 fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
106860 }
106861 iBestScore = fts3SnippetScore(nList, anCnt);
106862 besthlmask = hlmask;
106863 iBestPos = 0;
106864
106865 for(i=1; 1; i++){
106866 int iScore;
106867
106868 if( 0==(i&(SNIPPET_BUFFER_CHUNK-1)) ){
106869 int iLoad = i + SNIPPET_BUFFER_CHUNK;
106870 if( fts3LoadSnippetBuffer(iLoad, aBuffer, nList, apList, aiPrev) ) break;
106871 }
106872
106873 /* Figure out how highly a snippet starting at token offset i scores
106874 ** according to fts3SnippetScore(). If it is higher than any previously
106875 ** considered position, save the current position, score and hlmask as
106876 ** the best snippet candidate found so far.
106877 */
106878 fts3SnippetCnt(i, nSnippet, anCnt, aBuffer, anToken, &hlmask);
106879 iScore = fts3SnippetScore(nList, anCnt);
106880 if( iScore>iBestScore ){
106881 iBestPos = i;
106882 iBestScore = iScore;
106883 besthlmask = hlmask;
106884 }
106885 }
106886
106887 sqlite3_free(apList);
106888 *piPos = iBestPos;
106889 *pHlmask = besthlmask;
106890 return SQLITE_OK;
106891 }
106892
106893 typedef struct StrBuffer StrBuffer;
106894 struct StrBuffer {
106895 char *z;
106896 int n;
106897 int nAlloc;
106898 };
106899
106900 static int fts3StringAppend(
106901 StrBuffer *pStr,
106902 const char *zAppend,
106903 int nAppend
106904 ){
106905 if( nAppend<0 ){
106906 nAppend = strlen(zAppend);
106907 }
106908
106909 if( pStr->n+nAppend+1>=pStr->nAlloc ){
106910 int nAlloc = pStr->nAlloc+nAppend+100;
106911 char *zNew = sqlite3_realloc(pStr->z, nAlloc);
106912 if( !zNew ){
106913 return SQLITE_NOMEM;
106914 }
106915 pStr->z = zNew;
106916 pStr->nAlloc = nAlloc;
106917 }
106918
106919 memcpy(&pStr->z[pStr->n], zAppend, nAppend);
106920 pStr->n += nAppend;
106921 pStr->z[pStr->n] = '\0';
106922
106923 return SQLITE_OK;
106924 }
106925
106926 static int fts3SnippetText(
106927 Fts3Cursor *pCsr, /* FTS3 Cursor */
106928 const char *zDoc, /* Document to extract snippet from */
106929 int nDoc, /* Size of zDoc in bytes */
106930 int nSnippet, /* Number of tokens in extracted snippet */
106931 int iPos, /* Index of first document token in snippet */
106932 u64 hlmask, /* Bitmask of terms to highlight in snippet */
106933 const char *zOpen, /* String inserted before highlighted term */
106934 const char *zClose, /* String inserted after highlighted term */
106935 const char *zEllipsis,
106936 char **pzSnippet /* OUT: Snippet text */
106937 ){
106938 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
106939 int rc; /* Return code */
106940 int iCurrent = 0;
106941 int iStart = 0;
106942 int iEnd;
106943
106944 sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
106945 sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */
106946 const char *ZDUMMY; /* Dummy arguments used with tokenizer */
106947 int DUMMY1, DUMMY2, DUMMY3; /* Dummy arguments used with tokenizer */
106948
106949 StrBuffer res = {0, 0, 0}; /* Result string */
106950
106951 /* Open a token cursor on the document. Read all tokens up to and
106952 ** including token iPos (the first token of the snippet). Set variable
106953 ** iStart to the byte offset in zDoc of the start of token iPos.
106954 */
106955 pMod = (sqlite3_tokenizer_module *)pTab->pTokenizer->pModule;
106956 rc = pMod->xOpen(pTab->pTokenizer, zDoc, nDoc, &pC);
106957 while( rc==SQLITE_OK && iCurrent<iPos ){
106958 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iStart, &DUMMY2, &iCurrent);
106959 }
106960 iEnd = iStart;
106961
106962 if( rc==SQLITE_OK && iStart>0 ){
106963 rc = fts3StringAppend(&res, zEllipsis, -1);
106964 }
106965
106966 while( rc==SQLITE_OK ){
106967 int iBegin;
106968 int iFin;
106969 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
106970
106971 if( rc==SQLITE_OK ){
106972 if( iCurrent>=(iPos+nSnippet) ){
106973 rc = SQLITE_DONE;
106974 }else{
106975 iEnd = iFin;
106976 if( hlmask & ((u64)1 << (iCurrent-iPos)) ){
106977 if( fts3StringAppend(&res, &zDoc[iStart], iBegin-iStart)
106978 || fts3StringAppend(&res, zOpen, -1)
106979 || fts3StringAppend(&res, &zDoc[iBegin], iEnd-iBegin)
106980 || fts3StringAppend(&res, zClose, -1)
106981 ){
106982 rc = SQLITE_NOMEM;
106983 }
106984 iStart = iEnd;
106985 }
106986 }
106987 }
106988 }
106989 assert( rc!=SQLITE_OK );
106990 if( rc==SQLITE_DONE ){
106991 rc = fts3StringAppend(&res, &zDoc[iStart], iEnd-iStart);
106992 if( rc==SQLITE_OK ){
106993 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
106994 if( rc==SQLITE_OK ){
106995 rc = fts3StringAppend(&res, zEllipsis, -1);
106996 }else if( rc==SQLITE_DONE ){
106997 rc = fts3StringAppend(&res, &zDoc[iEnd], -1);
106998 }
106999 }
107000 }
107001
107002 pMod->xClose(pC);
107003 if( rc!=SQLITE_OK ){
107004 sqlite3_free(res.z);
107005 }else{
107006 *pzSnippet = res.z;
107007 }
107008 return rc;
107009 }
107010
107011
107012 /*
107013 ** An instance of this structure is used to collect the 'global' part of
107014 ** the matchinfo statistics. The 'global' part consists of the following:
107015 **
107016 ** 1. The number of phrases in the query (nPhrase).
107017 **
107018 ** 2. The number of columns in the FTS3 table (nCol).
107019 **
107020 ** 3. A matrix of (nPhrase*nCol) integers containing the sum of the
107021 ** number of hits for each phrase in each column across all rows
107022 ** of the table.
107023 **
107024 ** The total size of the global matchinfo array, assuming the number of
107025 ** columns is N and the number of phrases is P is:
107026 **
107027 ** 2 + P*(N+1)
107028 **
107029 ** The number of hits for the 3rd phrase in the second column is found
107030 ** using the expression:
107031 **
107032 ** aGlobal[2 + P*(1+2) + 1]
107033 */
107034 typedef struct MatchInfo MatchInfo;
107035 struct MatchInfo {
107036 Fts3Table *pTab; /* FTS3 Table */
107037 Fts3Cursor *pCursor; /* FTS3 Cursor */
107038 int iPhrase; /* Number of phrases so far */
107039 int nCol; /* Number of columns in table */
107040 u32 *aGlobal; /* Pre-allocated buffer */
107041 };
107042
107043 /*
107044 ** This function is used to count the entries in a column-list (delta-encoded
107045 ** list of term offsets within a single column of a single row).
107046 */
107047 static int fts3ColumnlistCount(char **ppCollist){
107048 char *pEnd = *ppCollist;
107049 char c = 0;
107050 int nEntry = 0;
107051
107052 /* A column-list is terminated by either a 0x01 or 0x00. */
107053 while( 0xFE & (*pEnd | c) ){
107054 c = *pEnd++ & 0x80;
107055 if( !c ) nEntry++;
107056 }
107057
107058 *ppCollist = pEnd;
107059 return nEntry;
107060 }
107061
107062 static void fts3LoadColumnlistCounts(char **pp, u32 *aOut){
107063 char *pCsr = *pp;
107064 while( *pCsr ){
107065 sqlite3_int64 iCol = 0;
107066 if( *pCsr==0x01 ){
107067 pCsr++;
107068 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
107069 }
107070 aOut[iCol] += fts3ColumnlistCount(&pCsr);
107071 }
107072 pCsr++;
107073 *pp = pCsr;
107074 }
107075
107076 /*
107077 ** fts3ExprIterate() callback used to collect the "global" matchinfo stats
107078 ** for a single query.
107079 */
107080 static int fts3ExprGlobalMatchinfoCb(
107081 Fts3Expr *pExpr, /* Phrase expression node */
107082 void *pCtx /* Pointer to MatchInfo structure */
107083 ){
107084 MatchInfo *p = (MatchInfo *)pCtx;
107085 char *pCsr;
107086 char *pEnd;
107087 const int iStart = 2 + p->nCol*p->iPhrase;
107088
107089 assert( pExpr->isLoaded );
107090
107091 /* Fill in the global hit count matrix row for this phrase. */
107092 pCsr = pExpr->aDoclist;
107093 pEnd = &pExpr->aDoclist[pExpr->nDoclist];
107094 while( pCsr<pEnd ){
107095 while( *pCsr++ & 0x80 );
107096 fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iStart]);
107097 }
107098
107099 p->iPhrase++;
107100 return SQLITE_OK;
107101 }
107102
107103 static int fts3ExprLocalMatchinfoCb(
107104 Fts3Expr *pExpr, /* Phrase expression node */
107105 void *pCtx /* Pointer to MatchInfo structure */
107106 ){
107107 MatchInfo *p = (MatchInfo *)pCtx;
107108 int iPhrase = p->iPhrase++;
107109
107110 if( pExpr->aDoclist ){
107111 char *pCsr;
107112 int iOffset = 2 + p->nCol*(p->aGlobal[0]+iPhrase);
107113
107114 memset(&p->aGlobal[iOffset], 0, p->nCol*sizeof(u32));
107115 pCsr = sqlite3Fts3FindPositions(pExpr, p->pCursor->iPrevId, -1);
107116 if( pCsr ) fts3LoadColumnlistCounts(&pCsr, &p->aGlobal[iOffset]);
107117 }
107118
107119 return SQLITE_OK;
107120 }
107121
107122 /*
107123 ** Populate pCsr->aMatchinfo[] with data for the current row. The 'matchinfo'
107124 ** data is an array of 32-bit unsigned integers (C type u32).
107125 */
107126 static int fts3GetMatchinfo(Fts3Cursor *pCsr){
107127 MatchInfo g;
107128 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
107129 if( pCsr->aMatchinfo==0 ){
107130 int rc;
107131 int nPhrase;
107132 int nMatchinfo;
107133
107134 g.pTab = pTab;
107135 g.nCol = pTab->nColumn;
107136 g.iPhrase = 0;
107137 rc = fts3ExprLoadDoclists(pCsr, &nPhrase);
107138 if( rc!=SQLITE_OK ){
107139 return rc;
107140 }
107141
107142 nMatchinfo = 2 + 2*g.nCol*nPhrase;
107143
107144 g.iPhrase = 0;
107145 g.aGlobal = (u32 *)sqlite3_malloc(sizeof(u32)*nMatchinfo);
107146 if( !g.aGlobal ){
107147 return SQLITE_NOMEM;
107148 }
107149 memset(g.aGlobal, 0, sizeof(u32)*nMatchinfo);
107150
107151 g.aGlobal[0] = nPhrase;
107152 g.aGlobal[1] = g.nCol;
107153 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprGlobalMatchinfoCb, (void *)&g);
107154
107155 pCsr->aMatchinfo = g.aGlobal;
107156 }
107157
107158 g.pTab = pTab;
107159 g.pCursor = pCsr;
107160 g.nCol = pTab->nColumn;
107161 g.iPhrase = 0;
107162 g.aGlobal = pCsr->aMatchinfo;
107163
107164 if( pCsr->isMatchinfoOk ){
107165 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLocalMatchinfoCb, (void *)&g);
107166 pCsr->isMatchinfoOk = 0;
107167 }
107168
107169 return SQLITE_OK;
107170 }
107171
107172 SQLITE_PRIVATE void sqlite3Fts3Snippet2(
107173 sqlite3_context *pCtx, /* SQLite function call context */
107174 Fts3Cursor *pCsr, /* Cursor object */
107175 const char *zStart, /* Snippet start text - "<b>" */
107176 const char *zEnd, /* Snippet end text - "</b>" */
107177 const char *zEllipsis, /* Snippet ellipsis text - "<b>...</b>" */
107178 int iCol, /* Extract snippet from this column */
107179 int nToken /* Approximate number of tokens in snippet */
107180 ){
107181 int rc;
107182 int iPos = 0;
107183 u64 hlmask = 0;
107184 char *z = 0;
107185 int nDoc;
107186 const char *zDoc;
107187
107188 rc = fts3BestSnippet(nToken, pCsr, iCol, &iPos, &hlmask);
107189
107190 nDoc = sqlite3_column_bytes(pCsr->pStmt, iCol+1);
107191 zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol+1);
107192
107193 if( rc==SQLITE_OK ){
107194 rc = fts3SnippetText(
107195 pCsr, zDoc, nDoc, nToken, iPos, hlmask, zStart, zEnd, zEllipsis, &z);
107196 }
107197 if( rc!=SQLITE_OK ){
107198 sqlite3_result_error_code(pCtx, rc);
107199 }else{
107200 sqlite3_result_text(pCtx, z, -1, sqlite3_free);
107201 }
107202 }
107203
107204 SQLITE_PRIVATE void sqlite3Fts3Matchinfo(sqlite3_context *pContext, Fts3Cursor *pCsr){
107205 int rc = fts3GetMatchinfo(pCsr);
107206 if( rc!=SQLITE_OK ){
107207 sqlite3_result_error_code(pContext, rc);
107208 }else{
107209 int n = sizeof(u32)*(2+pCsr->aMatchinfo[0]*pCsr->aMatchinfo[1]*2);
107210 sqlite3_result_blob(pContext, pCsr->aMatchinfo, n, SQLITE_TRANSIENT);
107211 }
107212 }
107213
107214 #endif
107215
107216 /************** End of fts3_snippet.c ****************************************/
107217 /************** Begin file rtree.c *******************************************/
@@ -109539,11 +110527,11 @@
110527 int nArg; /* Number of arguments */
110528 int enc; /* Optimal text encoding */
110529 void *pContext; /* sqlite3_user_data() context */
110530 void (*xFunc)(sqlite3_context*,int,sqlite3_value**);
110531 } scalars[] = {
110532 {"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc},
110533
110534 {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16},
110535 {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16},
110536 {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16},
110537 {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16},
110538
+1410 -1525
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -79,88 +79,81 @@
7979
#ifdef SQLITE_VERSION_NUMBER
8080
# undef SQLITE_VERSION_NUMBER
8181
#endif
8282
8383
/*
84
-** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
85
-**
86
-** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
87
-** the sqlite3.h file specify the version of SQLite with which
88
-** that header file is associated.
89
-**
90
-** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
91
-** The W value is major version number and is always 3 in SQLite3.
92
-** The W value only changes when backwards compatibility is
93
-** broken and we intend to never break backwards compatibility.
94
-** The X value is the minor version number and only changes when
95
-** there are major feature enhancements that are forwards compatible
96
-** but not backwards compatible.
97
-** The Y value is the release number and is incremented with
98
-** each release but resets back to 0 whenever X is incremented.
99
-** The Z value only appears on branch releases.
100
-**
101
-** The SQLITE_VERSION_NUMBER is an integer that is computed as
102
-** follows:
103
-**
104
-** <blockquote><pre>
105
-** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
106
-** </pre></blockquote>
84
+** CAPI3REF: Compile-Time Library Version Numbers
85
+**
86
+** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
87
+** evaluates to a string literal that is the SQLite version in the
88
+** format "X.Y.Z" where X is the major version number (always 3 for
89
+** SQLite3) and Y is the minor version number and Z is the release number.)^
90
+** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
91
+** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
92
+** numbers used in [SQLITE_VERSION].)^
93
+** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
94
+** be larger than the release from which it is derived. Either Y will
95
+** be held constant and Z will be incremented or else Y will be incremented
96
+** and Z will be reset to zero.
10797
**
10898
** Since version 3.6.18, SQLite source code has been stored in the
109
-** <a href="http://www.fossil-scm.org/">fossil configuration management
110
-** system</a>. The SQLITE_SOURCE_ID
111
-** macro is a string which identifies a particular check-in of SQLite
112
-** within its configuration management system. The string contains the
113
-** date and time of the check-in (UTC) and an SHA1 hash of the entire
114
-** source tree.
99
+** <a href="http://www.fossil-scm.org/">Fossil configuration management
100
+** system</a>. ^The SQLITE_SOURCE_ID macro evalutes to
101
+** a string which identifies a particular check-in of SQLite
102
+** within its configuration management system. ^The SQLITE_SOURCE_ID
103
+** string contains the date and time of the check-in (UTC) and an SHA1
104
+** hash of the entire source tree.
115105
**
116106
** See also: [sqlite3_libversion()],
117107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
118108
** [sqlite_version()] and [sqlite_source_id()].
119
-**
120
-** Requirements: [H10011] [H10014]
121109
*/
122
-#define SQLITE_VERSION "3.6.21"
123
-#define SQLITE_VERSION_NUMBER 3006021
124
-#define SQLITE_SOURCE_ID "2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c"
110
+#define SQLITE_VERSION "3.6.22"
111
+#define SQLITE_VERSION_NUMBER 3006022
112
+#define SQLITE_SOURCE_ID "2010-01-02 19:02:02 51f7ee844057086789dcfcdcba7daf45343cae62"
125113
126114
/*
127
-** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
115
+** CAPI3REF: Run-Time Library Version Numbers
128116
** KEYWORDS: sqlite3_version
129117
**
130118
** These interfaces provide the same information as the [SQLITE_VERSION],
131
-** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
132
-** but are associated with the library instead of the header file. Cautious
119
+** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
120
+** but are associated with the library instead of the header file. ^(Cautious
133121
** programmers might include assert() statements in their application to
134122
** verify that values returned by these interfaces match the macros in
135123
** the header, and thus insure that the application is
136124
** compiled with matching library and header files.
137125
**
138126
** <blockquote><pre>
139127
** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
140128
** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
141
-** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
142
-** </pre></blockquote>
129
+** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
130
+** </pre></blockquote>)^
143131
**
144
-** The sqlite3_libversion() function returns the same information as is
145
-** in the sqlite3_version[] string constant. The function is provided
146
-** for use in DLLs since DLL users usually do not have direct access to string
147
-** constants within the DLL. Similarly, the sqlite3_sourceid() function
148
-** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
149
-** the header file.
132
+** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
133
+** macro. ^The sqlite3_libversion() function returns a pointer to the
134
+** to the sqlite3_version[] string constant. The sqlite3_libversion()
135
+** function is provided for use in DLLs since DLL users usually do not have
136
+** direct access to string constants within the DLL. ^The
137
+** sqlite3_libversion_number() function returns an integer equal to
138
+** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer
139
+** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
140
+** C preprocessor macro.
150141
**
151142
** See also: [sqlite_version()] and [sqlite_source_id()].
152
-**
153
-** Requirements: [H10021] [H10022] [H10023]
154143
*/
155144
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
156145
SQLITE_API const char *sqlite3_libversion(void);
157146
SQLITE_API const char *sqlite3_sourceid(void);
158147
SQLITE_API int sqlite3_libversion_number(void);
159148
160149
/*
161
-** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
150
+** CAPI3REF: Test To See If The Library Is Threadsafe
151
+**
152
+** ^The sqlite3_threadsafe() function returns zero if and only if
153
+** SQLite was compiled mutexing code omitted due to the
154
+** [SQLITE_THREADSAFE] compile-time option being set to 0.
162155
**
163156
** SQLite can be compiled with or without mutexes. When
164157
** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
165158
** are enabled and SQLite is threadsafe. When the
166159
** [SQLITE_THREADSAFE] macro is 0,
@@ -168,33 +161,33 @@
168161
** to use SQLite concurrently from more than one thread.
169162
**
170163
** Enabling mutexes incurs a measurable performance penalty.
171164
** So if speed is of utmost importance, it makes sense to disable
172165
** the mutexes. But for maximum safety, mutexes should be enabled.
173
-** The default behavior is for mutexes to be enabled.
166
+** ^The default behavior is for mutexes to be enabled.
174167
**
175168
** This interface can be used by an application to make sure that the
176169
** version of SQLite that it is linking against was compiled with
177170
** the desired setting of the [SQLITE_THREADSAFE] macro.
178171
**
179172
** This interface only reports on the compile-time mutex setting
180173
** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
181
-** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
174
+** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
182175
** can be fully or partially disabled using a call to [sqlite3_config()]
183176
** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
184
-** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows
185
-** only the default compile-time setting, not any run-time changes
186
-** to that setting.
177
+** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
178
+** sqlite3_threadsafe() function shows only the compile-time setting of
179
+** thread safety, not any run-time changes to that setting made by
180
+** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
181
+** is unchanged by calls to sqlite3_config().)^
187182
**
188183
** See the [threading mode] documentation for additional information.
189
-**
190
-** Requirements: [H10101] [H10102]
191184
*/
192185
SQLITE_API int sqlite3_threadsafe(void);
193186
194187
/*
195
-** CAPI3REF: Database Connection Handle {H12000} <S40200>
188
+** CAPI3REF: Database Connection Handle
196189
** KEYWORDS: {database connection} {database connections}
197190
**
198191
** Each open SQLite database is represented by a pointer to an instance of
199192
** the opaque structure named "sqlite3". It is useful to think of an sqlite3
200193
** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -205,21 +198,24 @@
205198
** sqlite3 object.
206199
*/
207200
typedef struct sqlite3 sqlite3;
208201
209202
/*
210
-** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
203
+** CAPI3REF: 64-Bit Integer Types
211204
** KEYWORDS: sqlite_int64 sqlite_uint64
212205
**
213206
** Because there is no cross-platform way to specify 64-bit integer types
214207
** SQLite includes typedefs for 64-bit signed and unsigned integers.
215208
**
216209
** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
217210
** The sqlite_int64 and sqlite_uint64 types are supported for backwards
218211
** compatibility only.
219212
**
220
-** Requirements: [H10201] [H10202]
213
+** ^The sqlite3_int64 and sqlite_int64 types can store integer values
214
+** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
215
+** sqlite3_uint64 and sqlite_uint64 types can store integer values
216
+** between 0 and +18446744073709551615 inclusive.
221217
*/
222218
#ifdef SQLITE_INT64_TYPE
223219
typedef SQLITE_INT64_TYPE sqlite_int64;
224220
typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
225221
#elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -239,28 +235,32 @@
239235
#ifdef SQLITE_OMIT_FLOATING_POINT
240236
# define double sqlite3_int64
241237
#endif
242238
243239
/*
244
-** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
240
+** CAPI3REF: Closing A Database Connection
245241
**
246
-** This routine is the destructor for the [sqlite3] object.
242
+** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
243
+** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
244
+** successfullly destroyed and all associated resources are deallocated.
247245
**
248246
** Applications must [sqlite3_finalize | finalize] all [prepared statements]
249247
** and [sqlite3_blob_close | close] all [BLOB handles] associated with
250
-** the [sqlite3] object prior to attempting to close the object.
248
+** the [sqlite3] object prior to attempting to close the object. ^If
249
+** sqlite3_close() is called on a [database connection] that still has
250
+** outstanding [prepared statements] or [BLOB handles], then it returns
251
+** SQLITE_BUSY.
251252
**
252
-** If [sqlite3_close()] is invoked while a transaction is open,
253
+** ^If [sqlite3_close()] is invoked while a transaction is open,
253254
** the transaction is automatically rolled back.
254255
**
255256
** The C parameter to [sqlite3_close(C)] must be either a NULL
256257
** pointer or an [sqlite3] object pointer obtained
257258
** from [sqlite3_open()], [sqlite3_open16()], or
258259
** [sqlite3_open_v2()], and not previously closed.
259
-**
260
-** Requirements:
261
-** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
260
+** ^Calling sqlite3_close() with a NULL pointer argument is a
261
+** harmless no-op.
262262
*/
263263
SQLITE_API int sqlite3_close(sqlite3 *);
264264
265265
/*
266266
** The type for a callback function.
@@ -268,52 +268,69 @@
268268
** compatibility and is not documented.
269269
*/
270270
typedef int (*sqlite3_callback)(void*,int,char**, char**);
271271
272272
/*
273
-** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
274
-**
275
-** The sqlite3_exec() interface is a convenient way of running one or more
276
-** SQL statements without having to write a lot of C code. The UTF-8 encoded
277
-** SQL statements are passed in as the second parameter to sqlite3_exec().
278
-** The statements are evaluated one by one until either an error or
279
-** an interrupt is encountered, or until they are all done. The 3rd parameter
280
-** is an optional callback that is invoked once for each row of any query
281
-** results produced by the SQL statements. The 5th parameter tells where
282
-** to write any error messages.
283
-**
284
-** The error message passed back through the 5th parameter is held
285
-** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak,
286
-** the calling application should call [sqlite3_free()] on any error
287
-** message returned through the 5th parameter when it has finished using
288
-** the error message.
289
-**
290
-** If the SQL statement in the 2nd parameter is NULL or an empty string
291
-** or a string containing only whitespace and comments, then no SQL
292
-** statements are evaluated and the database is not changed.
293
-**
294
-** The sqlite3_exec() interface is implemented in terms of
295
-** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
296
-** The sqlite3_exec() routine does nothing to the database that cannot be done
297
-** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
298
-**
299
-** The first parameter to [sqlite3_exec()] must be an valid and open
300
-** [database connection].
301
-**
302
-** The database connection must not be closed while
303
-** [sqlite3_exec()] is running.
304
-**
305
-** The calling function should use [sqlite3_free()] to free
306
-** the memory that *errmsg is left pointing at once the error
307
-** message is no longer needed.
308
-**
309
-** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
310
-** must remain unchanged while [sqlite3_exec()] is running.
311
-**
312
-** Requirements:
313
-** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
314
-** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
273
+** CAPI3REF: One-Step Query Execution Interface
274
+**
275
+** The sqlite3_exec() interface is a convenience wrapper around
276
+** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
277
+** that allows an application to run multiple statements of SQL
278
+** without having to use a lot of C code.
279
+**
280
+** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
281
+** semicolon-separate SQL statements passed into its 2nd argument,
282
+** in the context of the [database connection] passed in as its 1st
283
+** argument. ^If the callback function of the 3rd argument to
284
+** sqlite3_exec() is not NULL, then it is invoked for each result row
285
+** coming out of the evaluated SQL statements. ^The 4th argument to
286
+** to sqlite3_exec() is relayed through to the 1st argument of each
287
+** callback invocation. ^If the callback pointer to sqlite3_exec()
288
+** is NULL, then no callback is ever invoked and result rows are
289
+** ignored.
290
+**
291
+** ^If an error occurs while evaluating the SQL statements passed into
292
+** sqlite3_exec(), then execution of the current statement stops and
293
+** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
294
+** is not NULL then any error message is written into memory obtained
295
+** from [sqlite3_malloc()] and passed back through the 5th parameter.
296
+** To avoid memory leaks, the application should invoke [sqlite3_free()]
297
+** on error message strings returned through the 5th parameter of
298
+** of sqlite3_exec() after the error message string is no longer needed.
299
+** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
300
+** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
301
+** NULL before returning.
302
+**
303
+** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
304
+** routine returns SQLITE_ABORT without invoking the callback again and
305
+** without running any subsequent SQL statements.
306
+**
307
+** ^The 2nd argument to the sqlite3_exec() callback function is the
308
+** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
309
+** callback is an array of pointers to strings obtained as if from
310
+** [sqlite3_column_text()], one for each column. ^If an element of a
311
+** result row is NULL then the corresponding string pointer for the
312
+** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
313
+** sqlite3_exec() callback is an array of pointers to strings where each
314
+** entry represents the name of corresponding result column as obtained
315
+** from [sqlite3_column_name()].
316
+**
317
+** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
318
+** to an empty string, or a pointer that contains only whitespace and/or
319
+** SQL comments, then no SQL statements are evaluated and the database
320
+** is not changed.
321
+**
322
+** Restrictions:
323
+**
324
+** <ul>
325
+** <li> The application must insure that the 1st parameter to sqlite3_exec()
326
+** is a valid and open [database connection].
327
+** <li> The application must not close [database connection] specified by
328
+** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
329
+** <li> The application must not modify the SQL statement text passed into
330
+** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
331
+** </ul>
315332
*/
316333
SQLITE_API int sqlite3_exec(
317334
sqlite3*, /* An open database */
318335
const char *sql, /* SQL to be evaluated */
319336
int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -320,11 +337,11 @@
320337
void *, /* 1st argument to callback */
321338
char **errmsg /* Error msg written here */
322339
);
323340
324341
/*
325
-** CAPI3REF: Result Codes {H10210} <S10700>
342
+** CAPI3REF: Result Codes
326343
** KEYWORDS: SQLITE_OK {error code} {error codes}
327344
** KEYWORDS: {result code} {result codes}
328345
**
329346
** Many SQLite functions return an integer result code from the set shown
330347
** here in order to indicates success or failure.
@@ -364,11 +381,11 @@
364381
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
365382
#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
366383
/* end-of-error-codes */
367384
368385
/*
369
-** CAPI3REF: Extended Result Codes {H10220} <S10700>
386
+** CAPI3REF: Extended Result Codes
370387
** KEYWORDS: {extended error code} {extended error codes}
371388
** KEYWORDS: {extended result code} {extended result codes}
372389
**
373390
** In its default configuration, SQLite API routines return one of 26 integer
374391
** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -406,11 +423,11 @@
406423
#define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
407424
#define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
408425
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
409426
410427
/*
411
-** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
428
+** CAPI3REF: Flags For File Open Operations
412429
**
413430
** These bit values are intended for use in the
414431
** 3rd parameter to the [sqlite3_open_v2()] interface and
415432
** in the 4th parameter to the xOpen method of the
416433
** [sqlite3_vfs] object.
@@ -431,11 +448,11 @@
431448
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
432449
#define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
433450
#define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
434451
435452
/*
436
-** CAPI3REF: Device Characteristics {H10240} <H11120>
453
+** CAPI3REF: Device Characteristics
437454
**
438455
** The xDeviceCapabilities method of the [sqlite3_io_methods]
439456
** object returns an integer which is a vector of the these
440457
** bit values expressing I/O characteristics of the mass storage
441458
** device that holds the file that the [sqlite3_io_methods]
@@ -463,11 +480,11 @@
463480
#define SQLITE_IOCAP_ATOMIC64K 0x00000100
464481
#define SQLITE_IOCAP_SAFE_APPEND 0x00000200
465482
#define SQLITE_IOCAP_SEQUENTIAL 0x00000400
466483
467484
/*
468
-** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
485
+** CAPI3REF: File Locking Levels
469486
**
470487
** SQLite uses one of these integer values as the second
471488
** argument to calls it makes to the xLock() and xUnlock() methods
472489
** of an [sqlite3_io_methods] object.
473490
*/
@@ -476,11 +493,11 @@
476493
#define SQLITE_LOCK_RESERVED 2
477494
#define SQLITE_LOCK_PENDING 3
478495
#define SQLITE_LOCK_EXCLUSIVE 4
479496
480497
/*
481
-** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
498
+** CAPI3REF: Synchronization Type Flags
482499
**
483500
** When SQLite invokes the xSync() method of an
484501
** [sqlite3_io_methods] object it uses a combination of
485502
** these integer values as the second argument.
486503
**
@@ -494,11 +511,11 @@
494511
#define SQLITE_SYNC_NORMAL 0x00002
495512
#define SQLITE_SYNC_FULL 0x00003
496513
#define SQLITE_SYNC_DATAONLY 0x00010
497514
498515
/*
499
-** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
516
+** CAPI3REF: OS Interface Open File Handle
500517
**
501518
** An [sqlite3_file] object represents an open file in the
502519
** [sqlite3_vfs | OS interface layer]. Individual OS interface
503520
** implementations will
504521
** want to subclass this object by appending additional fields
@@ -510,11 +527,11 @@
510527
struct sqlite3_file {
511528
const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
512529
};
513530
514531
/*
515
-** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
532
+** CAPI3REF: OS Interface File Virtual Methods Object
516533
**
517534
** Every file opened by the [sqlite3_vfs] xOpen method populates an
518535
** [sqlite3_file] object (or, more commonly, a subclass of the
519536
** [sqlite3_file] object) with a pointer to an instance of this object.
520537
** This object defines the methods used to perform various operations
@@ -615,11 +632,11 @@
615632
int (*xDeviceCharacteristics)(sqlite3_file*);
616633
/* Additional methods may be added in future releases */
617634
};
618635
619636
/*
620
-** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
637
+** CAPI3REF: Standard File Control Opcodes
621638
**
622639
** These integer constants are opcodes for the xFileControl method
623640
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
624641
** interface.
625642
**
@@ -635,11 +652,11 @@
635652
#define SQLITE_GET_LOCKPROXYFILE 2
636653
#define SQLITE_SET_LOCKPROXYFILE 3
637654
#define SQLITE_LAST_ERRNO 4
638655
639656
/*
640
-** CAPI3REF: Mutex Handle {H17110} <S20130>
657
+** CAPI3REF: Mutex Handle
641658
**
642659
** The mutex module within SQLite defines [sqlite3_mutex] to be an
643660
** abstract type for a mutex object. The SQLite core never looks
644661
** at the internal representation of an [sqlite3_mutex]. It only
645662
** deals with pointers to the [sqlite3_mutex] object.
@@ -647,11 +664,11 @@
647664
** Mutexes are created using [sqlite3_mutex_alloc()].
648665
*/
649666
typedef struct sqlite3_mutex sqlite3_mutex;
650667
651668
/*
652
-** CAPI3REF: OS Interface Object {H11140} <S20100>
669
+** CAPI3REF: OS Interface Object
653670
**
654671
** An instance of the sqlite3_vfs object defines the interface between
655672
** the SQLite core and the underlying operating system. The "vfs"
656673
** in the name of the object stands for "virtual file system".
657674
**
@@ -801,14 +818,14 @@
801818
/* New fields may be appended in figure versions. The iVersion
802819
** value will increment whenever this happens. */
803820
};
804821
805822
/*
806
-** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
823
+** CAPI3REF: Flags for the xAccess VFS method
807824
**
808825
** These integer constants can be used as the third parameter to
809
-** the xAccess method of an [sqlite3_vfs] object. {END} They determine
826
+** the xAccess method of an [sqlite3_vfs] object. They determine
810827
** what kind of permissions the xAccess method is looking for.
811828
** With SQLITE_ACCESS_EXISTS, the xAccess method
812829
** simply checks whether the file exists.
813830
** With SQLITE_ACCESS_READWRITE, the xAccess method
814831
** checks whether the file is both readable and writable.
@@ -818,52 +835,52 @@
818835
#define SQLITE_ACCESS_EXISTS 0
819836
#define SQLITE_ACCESS_READWRITE 1
820837
#define SQLITE_ACCESS_READ 2
821838
822839
/*
823
-** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
840
+** CAPI3REF: Initialize The SQLite Library
824841
**
825
-** The sqlite3_initialize() routine initializes the
826
-** SQLite library. The sqlite3_shutdown() routine
842
+** ^The sqlite3_initialize() routine initializes the
843
+** SQLite library. ^The sqlite3_shutdown() routine
827844
** deallocates any resources that were allocated by sqlite3_initialize().
828845
** These routines are designed to aid in process initialization and
829846
** shutdown on embedded systems. Workstation applications using
830847
** SQLite normally do not need to invoke either of these routines.
831848
**
832849
** A call to sqlite3_initialize() is an "effective" call if it is
833850
** the first time sqlite3_initialize() is invoked during the lifetime of
834851
** the process, or if it is the first time sqlite3_initialize() is invoked
835
-** following a call to sqlite3_shutdown(). Only an effective call
852
+** following a call to sqlite3_shutdown(). ^(Only an effective call
836853
** of sqlite3_initialize() does any initialization. All other calls
837
-** are harmless no-ops.
854
+** are harmless no-ops.)^
838855
**
839856
** A call to sqlite3_shutdown() is an "effective" call if it is the first
840
-** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only
857
+** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
841858
** an effective call to sqlite3_shutdown() does any deinitialization.
842
-** All other valid calls to sqlite3_shutdown() are harmless no-ops.
859
+** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
843860
**
844861
** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
845862
** is not. The sqlite3_shutdown() interface must only be called from a
846863
** single thread. All open [database connections] must be closed and all
847864
** other SQLite resources must be deallocated prior to invoking
848865
** sqlite3_shutdown().
849866
**
850
-** Among other things, sqlite3_initialize() will invoke
851
-** sqlite3_os_init(). Similarly, sqlite3_shutdown()
867
+** Among other things, ^sqlite3_initialize() will invoke
868
+** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
852869
** will invoke sqlite3_os_end().
853870
**
854
-** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
855
-** If for some reason, sqlite3_initialize() is unable to initialize
871
+** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
872
+** ^If for some reason, sqlite3_initialize() is unable to initialize
856873
** the library (perhaps it is unable to allocate a needed resource such
857874
** as a mutex) it returns an [error code] other than [SQLITE_OK].
858875
**
859
-** The sqlite3_initialize() routine is called internally by many other
876
+** ^The sqlite3_initialize() routine is called internally by many other
860877
** SQLite interfaces so that an application usually does not need to
861878
** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
862879
** calls sqlite3_initialize() so the SQLite library will be automatically
863880
** initialized when [sqlite3_open()] is called if it has not be initialized
864
-** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
881
+** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
865882
** compile-time option, then the automatic calls to sqlite3_initialize()
866883
** are omitted and the application must call sqlite3_initialize() directly
867884
** prior to using any other SQLite interface. For maximum portability,
868885
** it is recommended that applications always invoke sqlite3_initialize()
869886
** directly prior to using any other SQLite interface. Future releases
@@ -898,11 +915,11 @@
898915
SQLITE_API int sqlite3_shutdown(void);
899916
SQLITE_API int sqlite3_os_init(void);
900917
SQLITE_API int sqlite3_os_end(void);
901918
902919
/*
903
-** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
920
+** CAPI3REF: Configuring The SQLite Library
904921
** EXPERIMENTAL
905922
**
906923
** The sqlite3_config() interface is used to make global configuration
907924
** changes to SQLite in order to tune SQLite to the specific needs of
908925
** the application. The default configuration is recommended for most
@@ -912,39 +929,36 @@
912929
** The sqlite3_config() interface is not threadsafe. The application
913930
** must insure that no other SQLite interfaces are invoked by other
914931
** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
915932
** may only be invoked prior to library initialization using
916933
** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
917
-** Note, however, that sqlite3_config() can be called as part of the
934
+** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
935
+** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
936
+** Note, however, that ^sqlite3_config() can be called as part of the
918937
** implementation of an application-defined [sqlite3_os_init()].
919938
**
920939
** The first argument to sqlite3_config() is an integer
921940
** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
922941
** what property of SQLite is to be configured. Subsequent arguments
923942
** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
924943
** in the first argument.
925944
**
926
-** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
927
-** If the option is unknown or SQLite is unable to set the option
945
+** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
946
+** ^If the option is unknown or SQLite is unable to set the option
928947
** then this routine returns a non-zero [error code].
929
-**
930
-** Requirements:
931
-** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
932
-** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
933
-** [H14162] [H14165] [H14168]
934948
*/
935949
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
936950
937951
/*
938
-** CAPI3REF: Configure database connections {H14200} <S20000>
952
+** CAPI3REF: Configure database connections
939953
** EXPERIMENTAL
940954
**
941955
** The sqlite3_db_config() interface is used to make configuration
942956
** changes to a [database connection]. The interface is similar to
943957
** [sqlite3_config()] except that the changes apply to a single
944958
** [database connection] (specified in the first argument). The
945
-** sqlite3_db_config() interface can only be used immediately after
959
+** sqlite3_db_config() interface should only be used immediately after
946960
** the database connection is created using [sqlite3_open()],
947961
** [sqlite3_open16()], or [sqlite3_open_v2()].
948962
**
949963
** The second argument to sqlite3_db_config(D,V,...) is the
950964
** configuration verb - an integer code that indicates what
@@ -951,17 +965,17 @@
951965
** aspect of the [database connection] is being configured.
952966
** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
953967
** New verbs are likely to be added in future releases of SQLite.
954968
** Additional arguments depend on the verb.
955969
**
956
-** Requirements:
957
-** [H14203] [H14206] [H14209] [H14212] [H14215]
970
+** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
971
+** the call is considered successful.
958972
*/
959973
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
960974
961975
/*
962
-** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
976
+** CAPI3REF: Memory Allocation Routines
963977
** EXPERIMENTAL
964978
**
965979
** An instance of this object defines the interface between SQLite
966980
** and low-level memory allocation routines.
967981
**
@@ -987,11 +1001,11 @@
9871001
** The xMalloc and xFree methods must work like the
9881002
** malloc() and free() functions from the standard C library.
9891003
** The xRealloc method must work like realloc() from the standard C library
9901004
** with the exception that if the second argument to xRealloc is zero,
9911005
** xRealloc must be a no-op - it must not perform any allocation or
992
-** deallocation. SQLite guaranteeds that the second argument to
1006
+** deallocation. ^SQLite guarantees that the second argument to
9931007
** xRealloc is always a value returned by a prior call to xRoundup.
9941008
** And so in cases where xRoundup always returns a positive number,
9951009
** xRealloc can perform exactly as the standard library realloc() and
9961010
** still be in compliance with this specification.
9971011
**
@@ -1039,11 +1053,11 @@
10391053
void (*xShutdown)(void*); /* Deinitialize the memory allocator */
10401054
void *pAppData; /* Argument to xInit() and xShutdown() */
10411055
};
10421056
10431057
/*
1044
-** CAPI3REF: Configuration Options {H10160} <S20000>
1058
+** CAPI3REF: Configuration Options
10451059
** EXPERIMENTAL
10461060
**
10471061
** These constants are the available integer configuration options that
10481062
** can be passed as the first argument to the [sqlite3_config()] interface.
10491063
**
@@ -1054,151 +1068,181 @@
10541068
** non-zero [error code] if a discontinued or unsupported configuration option
10551069
** is invoked.
10561070
**
10571071
** <dl>
10581072
** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1059
-** <dd>There are no arguments to this option. This option disables
1073
+** <dd>There are no arguments to this option. ^This option sets the
1074
+** [threading mode] to Single-thread. In other words, it disables
10601075
** all mutexing and puts SQLite into a mode where it can only be used
1061
-** by a single thread.</dd>
1076
+** by a single thread. ^If SQLite is compiled with
1077
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1078
+** it is not possible to change the [threading mode] from its default
1079
+** value of Single-thread and so [sqlite3_config()] will return
1080
+** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
1081
+** configuration option.</dd>
10621082
**
10631083
** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1064
-** <dd>There are no arguments to this option. This option disables
1084
+** <dd>There are no arguments to this option. ^This option sets the
1085
+** [threading mode] to Multi-thread. In other words, it disables
10651086
** mutexing on [database connection] and [prepared statement] objects.
10661087
** The application is responsible for serializing access to
10671088
** [database connections] and [prepared statements]. But other mutexes
10681089
** are enabled so that SQLite will be safe to use in a multi-threaded
10691090
** environment as long as no two threads attempt to use the same
1070
-** [database connection] at the same time. See the [threading mode]
1071
-** documentation for additional information.</dd>
1091
+** [database connection] at the same time. ^If SQLite is compiled with
1092
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1093
+** it is not possible to set the Multi-thread [threading mode] and
1094
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1095
+** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
10721096
**
10731097
** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1074
-** <dd>There are no arguments to this option. This option enables
1098
+** <dd>There are no arguments to this option. ^This option sets the
1099
+** [threading mode] to Serialized. In other words, this option enables
10751100
** all mutexes including the recursive
10761101
** mutexes on [database connection] and [prepared statement] objects.
10771102
** In this mode (which is the default when SQLite is compiled with
10781103
** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
10791104
** to [database connections] and [prepared statements] so that the
10801105
** application is free to use the same [database connection] or the
10811106
** same [prepared statement] in different threads at the same time.
1082
-** See the [threading mode] documentation for additional information.</dd>
1107
+** ^If SQLite is compiled with
1108
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1109
+** it is not possible to set the Serialized [threading mode] and
1110
+** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1111
+** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
10831112
**
10841113
** <dt>SQLITE_CONFIG_MALLOC</dt>
1085
-** <dd>This option takes a single argument which is a pointer to an
1114
+** <dd> ^(This option takes a single argument which is a pointer to an
10861115
** instance of the [sqlite3_mem_methods] structure. The argument specifies
10871116
** alternative low-level memory allocation routines to be used in place of
1088
-** the memory allocation routines built into SQLite.</dd>
1117
+** the memory allocation routines built into SQLite.)^ ^SQLite makes
1118
+** its own private copy of the content of the [sqlite3_mem_methods] structure
1119
+** before the [sqlite3_config()] call returns.</dd>
10891120
**
10901121
** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1091
-** <dd>This option takes a single argument which is a pointer to an
1122
+** <dd> ^(This option takes a single argument which is a pointer to an
10921123
** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1093
-** structure is filled with the currently defined memory allocation routines.
1124
+** structure is filled with the currently defined memory allocation routines.)^
10941125
** This option can be used to overload the default memory allocation
10951126
** routines with a wrapper that simulations memory allocation failure or
1096
-** tracks memory usage, for example.</dd>
1127
+** tracks memory usage, for example. </dd>
10971128
**
10981129
** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1099
-** <dd>This option takes single argument of type int, interpreted as a
1130
+** <dd> ^This option takes single argument of type int, interpreted as a
11001131
** boolean, which enables or disables the collection of memory allocation
1101
-** statistics. When disabled, the following SQLite interfaces become
1102
-** non-operational:
1132
+** statistics. ^(When memory allocation statistics are disabled, the
1133
+** following SQLite interfaces become non-operational:
11031134
** <ul>
11041135
** <li> [sqlite3_memory_used()]
11051136
** <li> [sqlite3_memory_highwater()]
11061137
** <li> [sqlite3_soft_heap_limit()]
11071138
** <li> [sqlite3_status()]
1108
-** </ul>
1139
+** </ul>)^
1140
+** ^Memory allocation statistics are enabled by default unless SQLite is
1141
+** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1142
+** allocation statistics are disabled by default.
11091143
** </dd>
11101144
**
11111145
** <dt>SQLITE_CONFIG_SCRATCH</dt>
1112
-** <dd>This option specifies a static memory buffer that SQLite can use for
1146
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
11131147
** scratch memory. There are three arguments: A pointer an 8-byte
11141148
** aligned memory buffer from which the scrach allocations will be
11151149
** drawn, the size of each scratch allocation (sz),
11161150
** and the maximum number of scratch allocations (N). The sz
11171151
** argument must be a multiple of 16. The sz parameter should be a few bytes
11181152
** larger than the actual scratch space required due to internal overhead.
1119
-** The first argument should pointer to an 8-byte aligned buffer
1153
+** The first argument must be a pointer to an 8-byte aligned buffer
11201154
** of at least sz*N bytes of memory.
1121
-** SQLite will use no more than one scratch buffer at once per thread, so
1122
-** N should be set to the expected maximum number of threads. The sz
1123
-** parameter should be 6 times the size of the largest database page size.
1124
-** Scratch buffers are used as part of the btree balance operation. If
1125
-** The btree balancer needs additional memory beyond what is provided by
1126
-** scratch buffers or if no scratch buffer space is specified, then SQLite
1127
-** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
1155
+** ^SQLite will use no more than one scratch buffer per thread. So
1156
+** N should be set to the expected maximum number of threads. ^SQLite will
1157
+** never require a scratch buffer that is more than 6 times the database
1158
+** page size. ^If SQLite needs needs additional scratch memory beyond
1159
+** what is provided by this configuration option, then
1160
+** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
11281161
**
11291162
** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1130
-** <dd>This option specifies a static memory buffer that SQLite can use for
1163
+** <dd> ^This option specifies a static memory buffer that SQLite can use for
11311164
** the database page cache with the default page cache implemenation.
11321165
** This configuration should not be used if an application-define page
11331166
** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
11341167
** There are three arguments to this option: A pointer to 8-byte aligned
11351168
** memory, the size of each page buffer (sz), and the number of pages (N).
11361169
** The sz argument should be the size of the largest database page
11371170
** (a power of two between 512 and 32768) plus a little extra for each
1138
-** page header. The page header size is 20 to 40 bytes depending on
1139
-** the host architecture. It is harmless, apart from the wasted memory,
1171
+** page header. ^The page header size is 20 to 40 bytes depending on
1172
+** the host architecture. ^It is harmless, apart from the wasted memory,
11401173
** to make sz a little too large. The first
11411174
** argument should point to an allocation of at least sz*N bytes of memory.
1142
-** SQLite will use the memory provided by the first argument to satisfy its
1143
-** memory needs for the first N pages that it adds to cache. If additional
1175
+** ^SQLite will use the memory provided by the first argument to satisfy its
1176
+** memory needs for the first N pages that it adds to cache. ^If additional
11441177
** page cache memory is needed beyond what is provided by this option, then
11451178
** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1146
-** The implementation might use one or more of the N buffers to hold
1179
+** ^The implementation might use one or more of the N buffers to hold
11471180
** memory accounting information. The pointer in the first argument must
11481181
** be aligned to an 8-byte boundary or subsequent behavior of SQLite
11491182
** will be undefined.</dd>
11501183
**
11511184
** <dt>SQLITE_CONFIG_HEAP</dt>
1152
-** <dd>This option specifies a static memory buffer that SQLite will use
1185
+** <dd> ^This option specifies a static memory buffer that SQLite will use
11531186
** for all of its dynamic memory allocation needs beyond those provided
11541187
** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
11551188
** There are three arguments: An 8-byte aligned pointer to the memory,
11561189
** the number of bytes in the memory buffer, and the minimum allocation size.
1157
-** If the first pointer (the memory pointer) is NULL, then SQLite reverts
1190
+** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
11581191
** to using its default memory allocator (the system malloc() implementation),
1159
-** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the
1192
+** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
11601193
** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
11611194
** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
11621195
** allocator is engaged to handle all of SQLites memory allocation needs.
11631196
** The first pointer (the memory pointer) must be aligned to an 8-byte
11641197
** boundary or subsequent behavior of SQLite will be undefined.</dd>
11651198
**
11661199
** <dt>SQLITE_CONFIG_MUTEX</dt>
1167
-** <dd>This option takes a single argument which is a pointer to an
1200
+** <dd> ^(This option takes a single argument which is a pointer to an
11681201
** instance of the [sqlite3_mutex_methods] structure. The argument specifies
11691202
** alternative low-level mutex routines to be used in place
1170
-** the mutex routines built into SQLite.</dd>
1203
+** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
1204
+** content of the [sqlite3_mutex_methods] structure before the call to
1205
+** [sqlite3_config()] returns. ^If SQLite is compiled with
1206
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1207
+** the entire mutexing subsystem is omitted from the build and hence calls to
1208
+** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1209
+** return [SQLITE_ERROR].</dd>
11711210
**
11721211
** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1173
-** <dd>This option takes a single argument which is a pointer to an
1212
+** <dd> ^(This option takes a single argument which is a pointer to an
11741213
** instance of the [sqlite3_mutex_methods] structure. The
11751214
** [sqlite3_mutex_methods]
1176
-** structure is filled with the currently defined mutex routines.
1215
+** structure is filled with the currently defined mutex routines.)^
11771216
** This option can be used to overload the default mutex allocation
11781217
** routines with a wrapper used to track mutex usage for performance
1179
-** profiling or testing, for example.</dd>
1218
+** profiling or testing, for example. ^If SQLite is compiled with
1219
+** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1220
+** the entire mutexing subsystem is omitted from the build and hence calls to
1221
+** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1222
+** return [SQLITE_ERROR].</dd>
11801223
**
11811224
** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1182
-** <dd>This option takes two arguments that determine the default
1183
-** memory allocation lookaside optimization. The first argument is the
1225
+** <dd> ^(This option takes two arguments that determine the default
1226
+** memory allocation for the lookaside memory allocator on each
1227
+** [database connection]. The first argument is the
11841228
** size of each lookaside buffer slot and the second is the number of
1185
-** slots allocated to each database connection. This option sets the
1186
-** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1229
+** slots allocated to each database connection.)^ ^(This option sets the
1230
+** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
11871231
** verb to [sqlite3_db_config()] can be used to change the lookaside
1188
-** configuration on individual connections.</dd>
1232
+** configuration on individual connections.)^ </dd>
11891233
**
11901234
** <dt>SQLITE_CONFIG_PCACHE</dt>
1191
-** <dd>This option takes a single argument which is a pointer to
1235
+** <dd> ^(This option takes a single argument which is a pointer to
11921236
** an [sqlite3_pcache_methods] object. This object specifies the interface
1193
-** to a custom page cache implementation. SQLite makes a copy of the
1237
+** to a custom page cache implementation.)^ ^SQLite makes a copy of the
11941238
** object and uses it for page cache memory allocations.</dd>
11951239
**
11961240
** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1197
-** <dd>This option takes a single argument which is a pointer to an
1241
+** <dd> ^(This option takes a single argument which is a pointer to an
11981242
** [sqlite3_pcache_methods] object. SQLite copies of the current
1199
-** page cache implementation into that object.</dd>
1243
+** page cache implementation into that object.)^ </dd>
12001244
**
12011245
** </dl>
12021246
*/
12031247
#define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
12041248
#define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1215,94 +1259,90 @@
12151259
#define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
12161260
#define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
12171261
#define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
12181262
12191263
/*
1220
-** CAPI3REF: Configuration Options {H10170} <S20000>
1264
+** CAPI3REF: Configuration Options
12211265
** EXPERIMENTAL
12221266
**
12231267
** These constants are the available integer configuration options that
12241268
** can be passed as the second argument to the [sqlite3_db_config()] interface.
12251269
**
12261270
** New configuration options may be added in future releases of SQLite.
12271271
** Existing configuration options might be discontinued. Applications
12281272
** should check the return code from [sqlite3_db_config()] to make sure that
1229
-** the call worked. The [sqlite3_db_config()] interface will return a
1273
+** the call worked. ^The [sqlite3_db_config()] interface will return a
12301274
** non-zero [error code] if a discontinued or unsupported configuration option
12311275
** is invoked.
12321276
**
12331277
** <dl>
12341278
** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1235
-** <dd>This option takes three additional arguments that determine the
1279
+** <dd> ^This option takes three additional arguments that determine the
12361280
** [lookaside memory allocator] configuration for the [database connection].
1237
-** The first argument (the third parameter to [sqlite3_db_config()] is a
1281
+** ^The first argument (the third parameter to [sqlite3_db_config()] is a
12381282
** pointer to an memory buffer to use for lookaside memory.
1239
-** The first argument may be NULL in which case SQLite will allocate the
1240
-** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the
1241
-** size of each lookaside buffer slot and the third argument is the number of
1283
+** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
1284
+** may be NULL in which case SQLite will allocate the
1285
+** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
1286
+** size of each lookaside buffer slot. ^The third argument is the number of
12421287
** slots. The size of the buffer in the first argument must be greater than
12431288
** or equal to the product of the second and third arguments. The buffer
1244
-** must be aligned to an 8-byte boundary. If the second argument is not
1245
-** a multiple of 8, it is internally rounded down to the next smaller
1289
+** must be aligned to an 8-byte boundary. ^If the second argument to
1290
+** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
1291
+** rounded down to the next smaller
12461292
** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
12471293
**
12481294
** </dl>
12491295
*/
12501296
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
12511297
12521298
12531299
/*
1254
-** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
1255
-**
1256
-** The sqlite3_extended_result_codes() routine enables or disables the
1257
-** [extended result codes] feature of SQLite. The extended result
1258
-** codes are disabled by default for historical compatibility considerations.
1259
-**
1260
-** Requirements:
1261
-** [H12201] [H12202]
1300
+** CAPI3REF: Enable Or Disable Extended Result Codes
1301
+**
1302
+** ^The sqlite3_extended_result_codes() routine enables or disables the
1303
+** [extended result codes] feature of SQLite. ^The extended result
1304
+** codes are disabled by default for historical compatibility.
12621305
*/
12631306
SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
12641307
12651308
/*
1266
-** CAPI3REF: Last Insert Rowid {H12220} <S10700>
1309
+** CAPI3REF: Last Insert Rowid
12671310
**
1268
-** Each entry in an SQLite table has a unique 64-bit signed
1269
-** integer key called the [ROWID | "rowid"]. The rowid is always available
1311
+** ^Each entry in an SQLite table has a unique 64-bit signed
1312
+** integer key called the [ROWID | "rowid"]. ^The rowid is always available
12701313
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1271
-** names are not also used by explicitly declared columns. If
1314
+** names are not also used by explicitly declared columns. ^If
12721315
** the table has a column of type [INTEGER PRIMARY KEY] then that column
12731316
** is another alias for the rowid.
12741317
**
1275
-** This routine returns the [rowid] of the most recent
1318
+** ^This routine returns the [rowid] of the most recent
12761319
** successful [INSERT] into the database from the [database connection]
1277
-** in the first argument. If no successful [INSERT]s
1320
+** in the first argument. ^If no successful [INSERT]s
12781321
** have ever occurred on that database connection, zero is returned.
12791322
**
1280
-** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1323
+** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
12811324
** row is returned by this routine as long as the trigger is running.
12821325
** But once the trigger terminates, the value returned by this routine
1283
-** reverts to the last value inserted before the trigger fired.
1326
+** reverts to the last value inserted before the trigger fired.)^
12841327
**
1285
-** An [INSERT] that fails due to a constraint violation is not a
1328
+** ^An [INSERT] that fails due to a constraint violation is not a
12861329
** successful [INSERT] and does not change the value returned by this
1287
-** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1330
+** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
12881331
** and INSERT OR ABORT make no changes to the return value of this
1289
-** routine when their insertion fails. When INSERT OR REPLACE
1332
+** routine when their insertion fails. ^(When INSERT OR REPLACE
12901333
** encounters a constraint violation, it does not fail. The
12911334
** INSERT continues to completion after deleting rows that caused
12921335
** the constraint problem so INSERT OR REPLACE will always change
1293
-** the return value of this interface.
1336
+** the return value of this interface.)^
12941337
**
1295
-** For the purposes of this routine, an [INSERT] is considered to
1338
+** ^For the purposes of this routine, an [INSERT] is considered to
12961339
** be successful even if it is subsequently rolled back.
12971340
**
12981341
** This function is accessible to SQL statements via the
12991342
** [last_insert_rowid() SQL function].
13001343
**
1301
-** Requirements:
1302
-** [H12221] [H12223]
1303
-**
13041344
** If a separate thread performs a new [INSERT] on the same
13051345
** database connection while the [sqlite3_last_insert_rowid()]
13061346
** function is running and thus changes the last insert [rowid],
13071347
** then the value returned by [sqlite3_last_insert_rowid()] is
13081348
** unpredictable and might not equal either the old or the new
@@ -1309,164 +1349,154 @@
13091349
** last insert [rowid].
13101350
*/
13111351
SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
13121352
13131353
/*
1314
-** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
1354
+** CAPI3REF: Count The Number Of Rows Modified
13151355
**
1316
-** This function returns the number of database rows that were changed
1356
+** ^This function returns the number of database rows that were changed
13171357
** or inserted or deleted by the most recently completed SQL statement
13181358
** on the [database connection] specified by the first parameter.
1319
-** Only changes that are directly specified by the [INSERT], [UPDATE],
1359
+** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
13201360
** or [DELETE] statement are counted. Auxiliary changes caused by
1321
-** triggers or [foreign key actions] are not counted. Use the
1361
+** triggers or [foreign key actions] are not counted.)^ Use the
13221362
** [sqlite3_total_changes()] function to find the total number of changes
13231363
** including changes caused by triggers and foreign key actions.
13241364
**
1325
-** Changes to a view that are simulated by an [INSTEAD OF trigger]
1365
+** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
13261366
** are not counted. Only real table changes are counted.
13271367
**
1328
-** A "row change" is a change to a single row of a single table
1368
+** ^(A "row change" is a change to a single row of a single table
13291369
** caused by an INSERT, DELETE, or UPDATE statement. Rows that
13301370
** are changed as side effects of [REPLACE] constraint resolution,
13311371
** rollback, ABORT processing, [DROP TABLE], or by any other
1332
-** mechanisms do not count as direct row changes.
1372
+** mechanisms do not count as direct row changes.)^
13331373
**
13341374
** A "trigger context" is a scope of execution that begins and
13351375
** ends with the script of a [CREATE TRIGGER | trigger].
13361376
** Most SQL statements are
13371377
** evaluated outside of any trigger. This is the "top level"
13381378
** trigger context. If a trigger fires from the top level, a
13391379
** new trigger context is entered for the duration of that one
13401380
** trigger. Subtriggers create subcontexts for their duration.
13411381
**
1342
-** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1382
+** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
13431383
** not create a new trigger context.
13441384
**
1345
-** This function returns the number of direct row changes in the
1385
+** ^This function returns the number of direct row changes in the
13461386
** most recent INSERT, UPDATE, or DELETE statement within the same
13471387
** trigger context.
13481388
**
1349
-** Thus, when called from the top level, this function returns the
1389
+** ^Thus, when called from the top level, this function returns the
13501390
** number of changes in the most recent INSERT, UPDATE, or DELETE
1351
-** that also occurred at the top level. Within the body of a trigger,
1391
+** that also occurred at the top level. ^(Within the body of a trigger,
13521392
** the sqlite3_changes() interface can be called to find the number of
13531393
** changes in the most recently completed INSERT, UPDATE, or DELETE
13541394
** statement within the body of the same trigger.
13551395
** However, the number returned does not include changes
1356
-** caused by subtriggers since those have their own context.
1396
+** caused by subtriggers since those have their own context.)^
13571397
**
13581398
** See also the [sqlite3_total_changes()] interface, the
13591399
** [count_changes pragma], and the [changes() SQL function].
13601400
**
1361
-** Requirements:
1362
-** [H12241] [H12243]
1363
-**
13641401
** If a separate thread makes changes on the same database connection
13651402
** while [sqlite3_changes()] is running then the value returned
13661403
** is unpredictable and not meaningful.
13671404
*/
13681405
SQLITE_API int sqlite3_changes(sqlite3*);
13691406
13701407
/*
1371
-** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1408
+** CAPI3REF: Total Number Of Rows Modified
13721409
**
1373
-** This function returns the number of row changes caused by [INSERT],
1410
+** ^This function returns the number of row changes caused by [INSERT],
13741411
** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1375
-** The count includes all changes from all [CREATE TRIGGER | trigger]
1376
-** contexts and changes made by [foreign key actions]. However,
1412
+** ^(The count returned by sqlite3_total_changes() includes all changes
1413
+** from all [CREATE TRIGGER | trigger] contexts and changes made by
1414
+** [foreign key actions]. However,
13771415
** the count does not include changes used to implement [REPLACE] constraints,
13781416
** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
13791417
** count does not include rows of views that fire an [INSTEAD OF trigger],
13801418
** though if the INSTEAD OF trigger makes changes of its own, those changes
1381
-** are counted.
1382
-** The changes are counted as soon as the statement that makes them is
1383
-** completed (when the statement handle is passed to [sqlite3_reset()] or
1384
-** [sqlite3_finalize()]).
1419
+** are counted.)^
1420
+** ^The sqlite3_total_changes() function counts the changes as soon as
1421
+** the statement that makes them is completed (when the statement handle
1422
+** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
13851423
**
13861424
** See also the [sqlite3_changes()] interface, the
13871425
** [count_changes pragma], and the [total_changes() SQL function].
13881426
**
1389
-** Requirements:
1390
-** [H12261] [H12263]
1391
-**
13921427
** If a separate thread makes changes on the same database connection
13931428
** while [sqlite3_total_changes()] is running then the value
13941429
** returned is unpredictable and not meaningful.
13951430
*/
13961431
SQLITE_API int sqlite3_total_changes(sqlite3*);
13971432
13981433
/*
1399
-** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
1434
+** CAPI3REF: Interrupt A Long-Running Query
14001435
**
1401
-** This function causes any pending database operation to abort and
1436
+** ^This function causes any pending database operation to abort and
14021437
** return at its earliest opportunity. This routine is typically
14031438
** called in response to a user action such as pressing "Cancel"
14041439
** or Ctrl-C where the user wants a long query operation to halt
14051440
** immediately.
14061441
**
1407
-** It is safe to call this routine from a thread different from the
1442
+** ^It is safe to call this routine from a thread different from the
14081443
** thread that is currently running the database operation. But it
14091444
** is not safe to call this routine with a [database connection] that
14101445
** is closed or might close before sqlite3_interrupt() returns.
14111446
**
1412
-** If an SQL operation is very nearly finished at the time when
1447
+** ^If an SQL operation is very nearly finished at the time when
14131448
** sqlite3_interrupt() is called, then it might not have an opportunity
14141449
** to be interrupted and might continue to completion.
14151450
**
1416
-** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1417
-** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1451
+** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1452
+** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
14181453
** that is inside an explicit transaction, then the entire transaction
14191454
** will be rolled back automatically.
14201455
**
1421
-** The sqlite3_interrupt(D) call is in effect until all currently running
1422
-** SQL statements on [database connection] D complete. Any new SQL statements
1456
+** ^The sqlite3_interrupt(D) call is in effect until all currently running
1457
+** SQL statements on [database connection] D complete. ^Any new SQL statements
14231458
** that are started after the sqlite3_interrupt() call and before the
14241459
** running statements reaches zero are interrupted as if they had been
1425
-** running prior to the sqlite3_interrupt() call. New SQL statements
1460
+** running prior to the sqlite3_interrupt() call. ^New SQL statements
14261461
** that are started after the running statement count reaches zero are
14271462
** not effected by the sqlite3_interrupt().
1428
-** A call to sqlite3_interrupt(D) that occurs when there are no running
1463
+** ^A call to sqlite3_interrupt(D) that occurs when there are no running
14291464
** SQL statements is a no-op and has no effect on SQL statements
14301465
** that are started after the sqlite3_interrupt() call returns.
14311466
**
1432
-** Requirements:
1433
-** [H12271] [H12272]
1434
-**
14351467
** If the database connection closes while [sqlite3_interrupt()]
14361468
** is running then bad things will likely happen.
14371469
*/
14381470
SQLITE_API void sqlite3_interrupt(sqlite3*);
14391471
14401472
/*
1441
-** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
1473
+** CAPI3REF: Determine If An SQL Statement Is Complete
14421474
**
14431475
** These routines are useful during command-line input to determine if the
14441476
** currently entered text seems to form a complete SQL statement or
14451477
** if additional input is needed before sending the text into
1446
-** SQLite for parsing. These routines return 1 if the input string
1447
-** appears to be a complete SQL statement. A statement is judged to be
1478
+** SQLite for parsing. ^These routines return 1 if the input string
1479
+** appears to be a complete SQL statement. ^A statement is judged to be
14481480
** complete if it ends with a semicolon token and is not a prefix of a
1449
-** well-formed CREATE TRIGGER statement. Semicolons that are embedded within
1481
+** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
14501482
** string literals or quoted identifier names or comments are not
14511483
** independent tokens (they are part of the token in which they are
1452
-** embedded) and thus do not count as a statement terminator. Whitespace
1484
+** embedded) and thus do not count as a statement terminator. ^Whitespace
14531485
** and comments that follow the final semicolon are ignored.
14541486
**
1455
-** These routines return 0 if the statement is incomplete. If a
1487
+** ^These routines return 0 if the statement is incomplete. ^If a
14561488
** memory allocation fails, then SQLITE_NOMEM is returned.
14571489
**
1458
-** These routines do not parse the SQL statements thus
1490
+** ^These routines do not parse the SQL statements thus
14591491
** will not detect syntactically incorrect SQL.
14601492
**
1461
-** If SQLite has not been initialized using [sqlite3_initialize()] prior
1493
+** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
14621494
** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
14631495
** automatically by sqlite3_complete16(). If that initialization fails,
14641496
** then the return value from sqlite3_complete16() will be non-zero
1465
-** regardless of whether or not the input SQL is complete.
1466
-**
1467
-** Requirements: [H10511] [H10512]
1497
+** regardless of whether or not the input SQL is complete.)^
14681498
**
14691499
** The input to [sqlite3_complete()] must be a zero-terminated
14701500
** UTF-8 string.
14711501
**
14721502
** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1474,31 +1504,31 @@
14741504
*/
14751505
SQLITE_API int sqlite3_complete(const char *sql);
14761506
SQLITE_API int sqlite3_complete16(const void *sql);
14771507
14781508
/*
1479
-** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
1509
+** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
14801510
**
1481
-** This routine sets a callback function that might be invoked whenever
1511
+** ^This routine sets a callback function that might be invoked whenever
14821512
** an attempt is made to open a database table that another thread
14831513
** or process has locked.
14841514
**
1485
-** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
1486
-** is returned immediately upon encountering the lock. If the busy callback
1487
-** is not NULL, then the callback will be invoked with two arguments.
1515
+** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
1516
+** is returned immediately upon encountering the lock. ^If the busy callback
1517
+** is not NULL, then the callback might be invoked with two arguments.
14881518
**
1489
-** The first argument to the handler is a copy of the void* pointer which
1490
-** is the third argument to sqlite3_busy_handler(). The second argument to
1491
-** the handler callback is the number of times that the busy handler has
1492
-** been invoked for this locking event. If the
1519
+** ^The first argument to the busy handler is a copy of the void* pointer which
1520
+** is the third argument to sqlite3_busy_handler(). ^The second argument to
1521
+** the busy handler callback is the number of times that the busy handler has
1522
+** been invoked for this locking event. ^If the
14931523
** busy callback returns 0, then no additional attempts are made to
14941524
** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
1495
-** If the callback returns non-zero, then another attempt
1525
+** ^If the callback returns non-zero, then another attempt
14961526
** is made to open the database for reading and the cycle repeats.
14971527
**
14981528
** The presence of a busy handler does not guarantee that it will be invoked
1499
-** when there is lock contention. If SQLite determines that invoking the busy
1529
+** when there is lock contention. ^If SQLite determines that invoking the busy
15001530
** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
15011531
** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
15021532
** Consider a scenario where one process is holding a read lock that
15031533
** it is trying to promote to a reserved lock and
15041534
** a second process is holding a reserved lock that it is trying
@@ -1508,69 +1538,63 @@
15081538
** invoke the busy handlers, neither will make any progress. Therefore,
15091539
** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
15101540
** will induce the first process to release its read lock and allow
15111541
** the second process to proceed.
15121542
**
1513
-** The default busy callback is NULL.
1543
+** ^The default busy callback is NULL.
15141544
**
1515
-** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
1545
+** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
15161546
** when SQLite is in the middle of a large transaction where all the
15171547
** changes will not fit into the in-memory cache. SQLite will
15181548
** already hold a RESERVED lock on the database file, but it needs
15191549
** to promote this lock to EXCLUSIVE so that it can spill cache
15201550
** pages into the database file without harm to concurrent
1521
-** readers. If it is unable to promote the lock, then the in-memory
1551
+** readers. ^If it is unable to promote the lock, then the in-memory
15221552
** cache will be left in an inconsistent state and so the error
15231553
** code is promoted from the relatively benign [SQLITE_BUSY] to
1524
-** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion
1554
+** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion
15251555
** forces an automatic rollback of the changes. See the
15261556
** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
15271557
** CorruptionFollowingBusyError</a> wiki page for a discussion of why
15281558
** this is important.
15291559
**
1530
-** There can only be a single busy handler defined for each
1560
+** ^(There can only be a single busy handler defined for each
15311561
** [database connection]. Setting a new busy handler clears any
1532
-** previously set handler. Note that calling [sqlite3_busy_timeout()]
1562
+** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()]
15331563
** will also set or clear the busy handler.
15341564
**
15351565
** The busy callback should not take any actions which modify the
15361566
** database connection that invoked the busy handler. Any such actions
15371567
** result in undefined behavior.
15381568
**
1539
-** Requirements:
1540
-** [H12311] [H12312] [H12314] [H12316] [H12318]
1541
-**
15421569
** A busy handler must not close the database connection
15431570
** or [prepared statement] that invoked the busy handler.
15441571
*/
15451572
SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
15461573
15471574
/*
1548
-** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
1575
+** CAPI3REF: Set A Busy Timeout
15491576
**
1550
-** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
1551
-** for a specified amount of time when a table is locked. The handler
1577
+** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
1578
+** for a specified amount of time when a table is locked. ^The handler
15521579
** will sleep multiple times until at least "ms" milliseconds of sleeping
1553
-** have accumulated. {H12343} After "ms" milliseconds of sleeping,
1580
+** have accumulated. ^After at least "ms" milliseconds of sleeping,
15541581
** the handler returns 0 which causes [sqlite3_step()] to return
15551582
** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
15561583
**
1557
-** Calling this routine with an argument less than or equal to zero
1584
+** ^Calling this routine with an argument less than or equal to zero
15581585
** turns off all busy handlers.
15591586
**
1560
-** There can only be a single busy handler for a particular
1587
+** ^(There can only be a single busy handler for a particular
15611588
** [database connection] any any given moment. If another busy handler
15621589
** was defined (using [sqlite3_busy_handler()]) prior to calling
1563
-** this routine, that other busy handler is cleared.
1564
-**
1565
-** Requirements:
1566
-** [H12341] [H12343] [H12344]
1590
+** this routine, that other busy handler is cleared.)^
15671591
*/
15681592
SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
15691593
15701594
/*
1571
-** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
1595
+** CAPI3REF: Convenience Routines For Running Queries
15721596
**
15731597
** Definition: A <b>result table</b> is memory data structure created by the
15741598
** [sqlite3_get_table()] interface. A result table records the
15751599
** complete query results from one or more queries.
15761600
**
@@ -1614,31 +1638,29 @@
16141638
** azResult&#91;5] = "28";
16151639
** azResult&#91;6] = "Cindy";
16161640
** azResult&#91;7] = "21";
16171641
** </pre></blockquote>
16181642
**
1619
-** The sqlite3_get_table() function evaluates one or more
1643
+** ^The sqlite3_get_table() function evaluates one or more
16201644
** semicolon-separated SQL statements in the zero-terminated UTF-8
1621
-** string of its 2nd parameter. It returns a result table to the
1645
+** string of its 2nd parameter and returns a result table to the
16221646
** pointer given in its 3rd parameter.
16231647
**
1624
-** After the calling function has finished using the result, it should
1625
-** pass the pointer to the result table to sqlite3_free_table() in order to
1648
+** After the application has finished with the result from sqlite3_get_table(),
1649
+** it should pass the result table pointer to sqlite3_free_table() in order to
16261650
** release the memory that was malloced. Because of the way the
16271651
** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
16281652
** function must not try to call [sqlite3_free()] directly. Only
16291653
** [sqlite3_free_table()] is able to release the memory properly and safely.
16301654
**
1631
-** The sqlite3_get_table() interface is implemented as a wrapper around
1655
+** ^(The sqlite3_get_table() interface is implemented as a wrapper around
16321656
** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
16331657
** to any internal data structures of SQLite. It uses only the public
16341658
** interface defined here. As a consequence, errors that occur in the
16351659
** wrapper layer outside of the internal [sqlite3_exec()] call are not
1636
-** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()].
1637
-**
1638
-** Requirements:
1639
-** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
1660
+** reflected in subsequent calls to [sqlite3_errcode()] or
1661
+** [sqlite3_errmsg()].)^
16401662
*/
16411663
SQLITE_API int sqlite3_get_table(
16421664
sqlite3 *db, /* An open database */
16431665
const char *zSql, /* SQL to be evaluated */
16441666
char ***pazResult, /* Results of the query */
@@ -1647,49 +1669,49 @@
16471669
char **pzErrmsg /* Error msg written here */
16481670
);
16491671
SQLITE_API void sqlite3_free_table(char **result);
16501672
16511673
/*
1652
-** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
1674
+** CAPI3REF: Formatted String Printing Functions
16531675
**
16541676
** These routines are work-alikes of the "printf()" family of functions
16551677
** from the standard C library.
16561678
**
1657
-** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
1679
+** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
16581680
** results into memory obtained from [sqlite3_malloc()].
16591681
** The strings returned by these two routines should be
1660
-** released by [sqlite3_free()]. Both routines return a
1682
+** released by [sqlite3_free()]. ^Both routines return a
16611683
** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
16621684
** memory to hold the resulting string.
16631685
**
1664
-** In sqlite3_snprintf() routine is similar to "snprintf()" from
1686
+** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
16651687
** the standard C library. The result is written into the
16661688
** buffer supplied as the second parameter whose size is given by
16671689
** the first parameter. Note that the order of the
1668
-** first two parameters is reversed from snprintf(). This is an
1690
+** first two parameters is reversed from snprintf().)^ This is an
16691691
** historical accident that cannot be fixed without breaking
1670
-** backwards compatibility. Note also that sqlite3_snprintf()
1692
+** backwards compatibility. ^(Note also that sqlite3_snprintf()
16711693
** returns a pointer to its buffer instead of the number of
1672
-** characters actually written into the buffer. We admit that
1694
+** characters actually written into the buffer.)^ We admit that
16731695
** the number of characters written would be a more useful return
16741696
** value but we cannot change the implementation of sqlite3_snprintf()
16751697
** now without breaking compatibility.
16761698
**
1677
-** As long as the buffer size is greater than zero, sqlite3_snprintf()
1678
-** guarantees that the buffer is always zero-terminated. The first
1699
+** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
1700
+** guarantees that the buffer is always zero-terminated. ^The first
16791701
** parameter "n" is the total size of the buffer, including space for
16801702
** the zero terminator. So the longest string that can be completely
16811703
** written will be n-1 characters.
16821704
**
16831705
** These routines all implement some additional formatting
16841706
** options that are useful for constructing SQL statements.
16851707
** All of the usual printf() formatting options apply. In addition, there
16861708
** is are "%q", "%Q", and "%z" options.
16871709
**
1688
-** The %q option works like %s in that it substitutes a null-terminated
1710
+** ^(The %q option works like %s in that it substitutes a null-terminated
16891711
** string from the argument list. But %q also doubles every '\'' character.
1690
-** %q is designed for use inside a string literal. By doubling each '\''
1712
+** %q is designed for use inside a string literal.)^ By doubling each '\''
16911713
** character it escapes that character and allows it to be inserted into
16921714
** the string.
16931715
**
16941716
** For example, assume the string variable zText contains text as follows:
16951717
**
@@ -1720,14 +1742,14 @@
17201742
** </pre></blockquote>
17211743
**
17221744
** This second example is an SQL syntax error. As a general rule you should
17231745
** always use %q instead of %s when inserting text into a string literal.
17241746
**
1725
-** The %Q option works like %q except it also adds single quotes around
1747
+** ^(The %Q option works like %q except it also adds single quotes around
17261748
** the outside of the total string. Additionally, if the parameter in the
17271749
** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
1728
-** single quotes) in place of the %Q option. So, for example, one could say:
1750
+** single quotes).)^ So, for example, one could say:
17291751
**
17301752
** <blockquote><pre>
17311753
** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
17321754
** sqlite3_exec(db, zSQL, 0, 0, 0);
17331755
** sqlite3_free(zSQL);
@@ -1734,75 +1756,63 @@
17341756
** </pre></blockquote>
17351757
**
17361758
** The code above will render a correct SQL statement in the zSQL
17371759
** variable even if the zText variable is a NULL pointer.
17381760
**
1739
-** The "%z" formatting option works exactly like "%s" with the
1761
+** ^(The "%z" formatting option works like "%s" but with the
17401762
** addition that after the string has been read and copied into
1741
-** the result, [sqlite3_free()] is called on the input string. {END}
1742
-**
1743
-** Requirements:
1744
-** [H17403] [H17406] [H17407]
1763
+** the result, [sqlite3_free()] is called on the input string.)^
17451764
*/
17461765
SQLITE_API char *sqlite3_mprintf(const char*,...);
17471766
SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
17481767
SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
17491768
17501769
/*
1751
-** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
1770
+** CAPI3REF: Memory Allocation Subsystem
17521771
**
1753
-** The SQLite core uses these three routines for all of its own
1772
+** The SQLite core uses these three routines for all of its own
17541773
** internal memory allocation needs. "Core" in the previous sentence
17551774
** does not include operating-system specific VFS implementation. The
17561775
** Windows VFS uses native malloc() and free() for some operations.
17571776
**
1758
-** The sqlite3_malloc() routine returns a pointer to a block
1777
+** ^The sqlite3_malloc() routine returns a pointer to a block
17591778
** of memory at least N bytes in length, where N is the parameter.
1760
-** If sqlite3_malloc() is unable to obtain sufficient free
1761
-** memory, it returns a NULL pointer. If the parameter N to
1779
+** ^If sqlite3_malloc() is unable to obtain sufficient free
1780
+** memory, it returns a NULL pointer. ^If the parameter N to
17621781
** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
17631782
** a NULL pointer.
17641783
**
1765
-** Calling sqlite3_free() with a pointer previously returned
1784
+** ^Calling sqlite3_free() with a pointer previously returned
17661785
** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
1767
-** that it might be reused. The sqlite3_free() routine is
1786
+** that it might be reused. ^The sqlite3_free() routine is
17681787
** a no-op if is called with a NULL pointer. Passing a NULL pointer
17691788
** to sqlite3_free() is harmless. After being freed, memory
17701789
** should neither be read nor written. Even reading previously freed
17711790
** memory might result in a segmentation fault or other severe error.
17721791
** Memory corruption, a segmentation fault, or other severe error
17731792
** might result if sqlite3_free() is called with a non-NULL pointer that
17741793
** was not obtained from sqlite3_malloc() or sqlite3_realloc().
17751794
**
1776
-** The sqlite3_realloc() interface attempts to resize a
1795
+** ^(The sqlite3_realloc() interface attempts to resize a
17771796
** prior memory allocation to be at least N bytes, where N is the
17781797
** second parameter. The memory allocation to be resized is the first
1779
-** parameter. If the first parameter to sqlite3_realloc()
1798
+** parameter.)^ ^ If the first parameter to sqlite3_realloc()
17801799
** is a NULL pointer then its behavior is identical to calling
17811800
** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
1782
-** If the second parameter to sqlite3_realloc() is zero or
1801
+** ^If the second parameter to sqlite3_realloc() is zero or
17831802
** negative then the behavior is exactly the same as calling
17841803
** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
1785
-** sqlite3_realloc() returns a pointer to a memory allocation
1804
+** ^sqlite3_realloc() returns a pointer to a memory allocation
17861805
** of at least N bytes in size or NULL if sufficient memory is unavailable.
1787
-** If M is the size of the prior allocation, then min(N,M) bytes
1806
+** ^If M is the size of the prior allocation, then min(N,M) bytes
17881807
** of the prior allocation are copied into the beginning of buffer returned
17891808
** by sqlite3_realloc() and the prior allocation is freed.
1790
-** If sqlite3_realloc() returns NULL, then the prior allocation
1809
+** ^If sqlite3_realloc() returns NULL, then the prior allocation
17911810
** is not freed.
17921811
**
1793
-** The memory returned by sqlite3_malloc() and sqlite3_realloc()
1794
-** is always aligned to at least an 8 byte boundary. {END}
1795
-**
1796
-** The default implementation of the memory allocation subsystem uses
1797
-** the malloc(), realloc() and free() provided by the standard C library.
1798
-** {H17382} However, if SQLite is compiled with the
1799
-** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
1800
-** is an integer), then SQLite create a static array of at least
1801
-** <i>NNN</i> bytes in size and uses that array for all of its dynamic
1802
-** memory allocation needs. {END} Additional memory allocator options
1803
-** may be added in future releases.
1812
+** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
1813
+** is always aligned to at least an 8 byte boundary.
18041814
**
18051815
** In SQLite version 3.5.0 and 3.5.1, it was possible to define
18061816
** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
18071817
** implementation of these routines to be omitted. That capability
18081818
** is no longer provided. Only built-in memory allocators can be used.
@@ -1813,14 +1823,10 @@
18131823
** and whatever filename encoding is used by the particular Windows
18141824
** installation. Memory allocation errors are detected, but
18151825
** they are reported back as [SQLITE_CANTOPEN] or
18161826
** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
18171827
**
1818
-** Requirements:
1819
-** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
1820
-** [H17321] [H17322] [H17323]
1821
-**
18221828
** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
18231829
** must be either NULL or else pointers obtained from a prior
18241830
** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
18251831
** not yet been released.
18261832
**
@@ -1831,85 +1837,95 @@
18311837
SQLITE_API void *sqlite3_malloc(int);
18321838
SQLITE_API void *sqlite3_realloc(void*, int);
18331839
SQLITE_API void sqlite3_free(void*);
18341840
18351841
/*
1836
-** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
1842
+** CAPI3REF: Memory Allocator Statistics
18371843
**
18381844
** SQLite provides these two interfaces for reporting on the status
18391845
** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
18401846
** routines, which form the built-in memory allocation subsystem.
18411847
**
1842
-** Requirements:
1843
-** [H17371] [H17373] [H17374] [H17375]
1848
+** ^The [sqlite3_memory_used()] routine returns the number of bytes
1849
+** of memory currently outstanding (malloced but not freed).
1850
+** ^The [sqlite3_memory_highwater()] routine returns the maximum
1851
+** value of [sqlite3_memory_used()] since the high-water mark
1852
+** was last reset. ^The values returned by [sqlite3_memory_used()] and
1853
+** [sqlite3_memory_highwater()] include any overhead
1854
+** added by SQLite in its implementation of [sqlite3_malloc()],
1855
+** but not overhead added by the any underlying system library
1856
+** routines that [sqlite3_malloc()] may call.
1857
+**
1858
+** ^The memory high-water mark is reset to the current value of
1859
+** [sqlite3_memory_used()] if and only if the parameter to
1860
+** [sqlite3_memory_highwater()] is true. ^The value returned
1861
+** by [sqlite3_memory_highwater(1)] is the high-water mark
1862
+** prior to the reset.
18441863
*/
18451864
SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
18461865
SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
18471866
18481867
/*
1849
-** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
1868
+** CAPI3REF: Pseudo-Random Number Generator
18501869
**
18511870
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
18521871
** select random [ROWID | ROWIDs] when inserting new records into a table that
18531872
** already uses the largest possible [ROWID]. The PRNG is also used for
18541873
** the build-in random() and randomblob() SQL functions. This interface allows
18551874
** applications to access the same PRNG for other purposes.
18561875
**
1857
-** A call to this routine stores N bytes of randomness into buffer P.
1876
+** ^A call to this routine stores N bytes of randomness into buffer P.
18581877
**
1859
-** The first time this routine is invoked (either internally or by
1878
+** ^The first time this routine is invoked (either internally or by
18601879
** the application) the PRNG is seeded using randomness obtained
18611880
** from the xRandomness method of the default [sqlite3_vfs] object.
1862
-** On all subsequent invocations, the pseudo-randomness is generated
1881
+** ^On all subsequent invocations, the pseudo-randomness is generated
18631882
** internally and without recourse to the [sqlite3_vfs] xRandomness
18641883
** method.
1865
-**
1866
-** Requirements:
1867
-** [H17392]
18681884
*/
18691885
SQLITE_API void sqlite3_randomness(int N, void *P);
18701886
18711887
/*
1872
-** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
1888
+** CAPI3REF: Compile-Time Authorization Callbacks
18731889
**
1874
-** This routine registers a authorizer callback with a particular
1890
+** ^This routine registers a authorizer callback with a particular
18751891
** [database connection], supplied in the first argument.
1876
-** The authorizer callback is invoked as SQL statements are being compiled
1892
+** ^The authorizer callback is invoked as SQL statements are being compiled
18771893
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
1878
-** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various
1894
+** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
18791895
** points during the compilation process, as logic is being created
18801896
** to perform various actions, the authorizer callback is invoked to
1881
-** see if those actions are allowed. The authorizer callback should
1897
+** see if those actions are allowed. ^The authorizer callback should
18821898
** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
18831899
** specific action but allow the SQL statement to continue to be
18841900
** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
1885
-** rejected with an error. If the authorizer callback returns
1901
+** rejected with an error. ^If the authorizer callback returns
18861902
** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
18871903
** then the [sqlite3_prepare_v2()] or equivalent call that triggered
18881904
** the authorizer will fail with an error message.
18891905
**
18901906
** When the callback returns [SQLITE_OK], that means the operation
1891
-** requested is ok. When the callback returns [SQLITE_DENY], the
1907
+** requested is ok. ^When the callback returns [SQLITE_DENY], the
18921908
** [sqlite3_prepare_v2()] or equivalent call that triggered the
18931909
** authorizer will fail with an error message explaining that
18941910
** access is denied.
18951911
**
1896
-** The first parameter to the authorizer callback is a copy of the third
1897
-** parameter to the sqlite3_set_authorizer() interface. The second parameter
1912
+** ^The first parameter to the authorizer callback is a copy of the third
1913
+** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
18981914
** to the callback is an integer [SQLITE_COPY | action code] that specifies
1899
-** the particular action to be authorized. The third through sixth parameters
1915
+** the particular action to be authorized. ^The third through sixth parameters
19001916
** to the callback are zero-terminated strings that contain additional
19011917
** details about the action to be authorized.
19021918
**
1903
-** If the action code is [SQLITE_READ]
1919
+** ^If the action code is [SQLITE_READ]
19041920
** and the callback returns [SQLITE_IGNORE] then the
19051921
** [prepared statement] statement is constructed to substitute
19061922
** a NULL value in place of the table column that would have
19071923
** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
19081924
** return can be used to deny an untrusted user access to individual
19091925
** columns of a table.
1910
-** If the action code is [SQLITE_DELETE] and the callback returns
1926
+** ^If the action code is [SQLITE_DELETE] and the callback returns
19111927
** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
19121928
** [truncate optimization] is disabled and all rows are deleted individually.
19131929
**
19141930
** An authorizer is used when [sqlite3_prepare | preparing]
19151931
** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -1925,43 +1941,39 @@
19251941
** Applications that need to process SQL from untrusted sources
19261942
** might also consider lowering resource limits using [sqlite3_limit()]
19271943
** and limiting database size using the [max_page_count] [PRAGMA]
19281944
** in addition to using an authorizer.
19291945
**
1930
-** Only a single authorizer can be in place on a database connection
1946
+** ^(Only a single authorizer can be in place on a database connection
19311947
** at a time. Each call to sqlite3_set_authorizer overrides the
1932
-** previous call. Disable the authorizer by installing a NULL callback.
1948
+** previous call.)^ ^Disable the authorizer by installing a NULL callback.
19331949
** The authorizer is disabled by default.
19341950
**
19351951
** The authorizer callback must not do anything that will modify
19361952
** the database connection that invoked the authorizer callback.
19371953
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
19381954
** database connections for the meaning of "modify" in this paragraph.
19391955
**
1940
-** When [sqlite3_prepare_v2()] is used to prepare a statement, the
1956
+** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
19411957
** statement might be re-prepared during [sqlite3_step()] due to a
19421958
** schema change. Hence, the application should ensure that the
19431959
** correct authorizer callback remains in place during the [sqlite3_step()].
19441960
**
1945
-** Note that the authorizer callback is invoked only during
1961
+** ^Note that the authorizer callback is invoked only during
19461962
** [sqlite3_prepare()] or its variants. Authorization is not
19471963
** performed during statement evaluation in [sqlite3_step()], unless
19481964
** as stated in the previous paragraph, sqlite3_step() invokes
19491965
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
1950
-**
1951
-** Requirements:
1952
-** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
1953
-** [H12511] [H12512] [H12520] [H12521] [H12522]
19541966
*/
19551967
SQLITE_API int sqlite3_set_authorizer(
19561968
sqlite3*,
19571969
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
19581970
void *pUserData
19591971
);
19601972
19611973
/*
1962
-** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
1974
+** CAPI3REF: Authorizer Return Codes
19631975
**
19641976
** The [sqlite3_set_authorizer | authorizer callback function] must
19651977
** return either [SQLITE_OK] or one of these two constants in order
19661978
** to signal SQLite whether or not the action is permitted. See the
19671979
** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -1969,11 +1981,11 @@
19691981
*/
19701982
#define SQLITE_DENY 1 /* Abort the SQL statement with an error */
19711983
#define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
19721984
19731985
/*
1974
-** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
1986
+** CAPI3REF: Authorizer Action Codes
19751987
**
19761988
** The [sqlite3_set_authorizer()] interface registers a callback function
19771989
** that is invoked to authorize certain SQL statement actions. The
19781990
** second parameter to the callback is an integer code that specifies
19791991
** what action is being authorized. These are the integer action codes that
@@ -1980,19 +1992,16 @@
19801992
** the authorizer callback may be passed.
19811993
**
19821994
** These action code values signify what kind of operation is to be
19831995
** authorized. The 3rd and 4th parameters to the authorization
19841996
** callback function will be parameters or NULL depending on which of these
1985
-** codes is used as the second parameter. The 5th parameter to the
1997
+** codes is used as the second parameter. ^(The 5th parameter to the
19861998
** authorizer callback is the name of the database ("main", "temp",
1987
-** etc.) if applicable. The 6th parameter to the authorizer callback
1999
+** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback
19882000
** is the name of the inner-most trigger or view that is responsible for
19892001
** the access attempt or NULL if this access attempt is directly from
19902002
** top-level SQL code.
1991
-**
1992
-** Requirements:
1993
-** [H12551] [H12552] [H12553] [H12554]
19942003
*/
19952004
/******************************************* 3rd ************ 4th ***********/
19962005
#define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
19972006
#define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
19982007
#define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2026,150 +2035,142 @@
20262035
#define SQLITE_FUNCTION 31 /* NULL Function Name */
20272036
#define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
20282037
#define SQLITE_COPY 0 /* No longer used */
20292038
20302039
/*
2031
-** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
2040
+** CAPI3REF: Tracing And Profiling Functions
20322041
** EXPERIMENTAL
20332042
**
20342043
** These routines register callback functions that can be used for
20352044
** tracing and profiling the execution of SQL statements.
20362045
**
2037
-** The callback function registered by sqlite3_trace() is invoked at
2046
+** ^The callback function registered by sqlite3_trace() is invoked at
20382047
** various times when an SQL statement is being run by [sqlite3_step()].
2039
-** The callback returns a UTF-8 rendering of the SQL statement text
2040
-** as the statement first begins executing. Additional callbacks occur
2048
+** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2049
+** SQL statement text as the statement first begins executing.
2050
+** ^(Additional sqlite3_trace() callbacks might occur
20412051
** as each triggered subprogram is entered. The callbacks for triggers
2042
-** contain a UTF-8 SQL comment that identifies the trigger.
2052
+** contain a UTF-8 SQL comment that identifies the trigger.)^
20432053
**
2044
-** The callback function registered by sqlite3_profile() is invoked
2045
-** as each SQL statement finishes. The profile callback contains
2054
+** ^The callback function registered by sqlite3_profile() is invoked
2055
+** as each SQL statement finishes. ^The profile callback contains
20462056
** the original statement text and an estimate of wall-clock time
20472057
** of how long that statement took to run.
2048
-**
2049
-** Requirements:
2050
-** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
2051
-** [H12290]
20522058
*/
20532059
SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
20542060
SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
20552061
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
20562062
20572063
/*
2058
-** CAPI3REF: Query Progress Callbacks {H12910} <S60400>
2064
+** CAPI3REF: Query Progress Callbacks
20592065
**
2060
-** This routine configures a callback function - the
2066
+** ^This routine configures a callback function - the
20612067
** progress callback - that is invoked periodically during long
20622068
** running calls to [sqlite3_exec()], [sqlite3_step()] and
20632069
** [sqlite3_get_table()]. An example use for this
20642070
** interface is to keep a GUI updated during a large query.
20652071
**
2066
-** If the progress callback returns non-zero, the operation is
2072
+** ^If the progress callback returns non-zero, the operation is
20672073
** interrupted. This feature can be used to implement a
20682074
** "Cancel" button on a GUI progress dialog box.
20692075
**
20702076
** The progress handler must not do anything that will modify
20712077
** the database connection that invoked the progress handler.
20722078
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
20732079
** database connections for the meaning of "modify" in this paragraph.
20742080
**
2075
-** Requirements:
2076
-** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
2077
-**
20782081
*/
20792082
SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
20802083
20812084
/*
2082
-** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
2085
+** CAPI3REF: Opening A New Database Connection
20832086
**
2084
-** These routines open an SQLite database file whose name is given by the
2085
-** filename argument. The filename argument is interpreted as UTF-8 for
2087
+** ^These routines open an SQLite database file whose name is given by the
2088
+** filename argument. ^The filename argument is interpreted as UTF-8 for
20862089
** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2087
-** order for sqlite3_open16(). A [database connection] handle is usually
2090
+** order for sqlite3_open16(). ^(A [database connection] handle is usually
20882091
** returned in *ppDb, even if an error occurs. The only exception is that
20892092
** if SQLite is unable to allocate memory to hold the [sqlite3] object,
20902093
** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2091
-** object. If the database is opened (and/or created) successfully, then
2092
-** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The
2094
+** object.)^ ^(If the database is opened (and/or created) successfully, then
2095
+** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
20932096
** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2094
-** an English language description of the error.
2097
+** an English language description of the error following a failure of any
2098
+** of the sqlite3_open() routines.
20952099
**
2096
-** The default encoding for the database will be UTF-8 if
2100
+** ^The default encoding for the database will be UTF-8 if
20972101
** sqlite3_open() or sqlite3_open_v2() is called and
20982102
** UTF-16 in the native byte order if sqlite3_open16() is used.
20992103
**
21002104
** Whether or not an error occurs when it is opened, resources
21012105
** associated with the [database connection] handle should be released by
21022106
** passing it to [sqlite3_close()] when it is no longer required.
21032107
**
21042108
** The sqlite3_open_v2() interface works like sqlite3_open()
21052109
** except that it accepts two additional parameters for additional control
2106
-** over the new database connection. The flags parameter can take one of
2110
+** over the new database connection. ^(The flags parameter to
2111
+** sqlite3_open_v2() can take one of
21072112
** the following three values, optionally combined with the
21082113
** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2109
-** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
2114
+** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
21102115
**
21112116
** <dl>
2112
-** <dt>[SQLITE_OPEN_READONLY]</dt>
2117
+** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
21132118
** <dd>The database is opened in read-only mode. If the database does not
2114
-** already exist, an error is returned.</dd>
2119
+** already exist, an error is returned.</dd>)^
21152120
**
2116
-** <dt>[SQLITE_OPEN_READWRITE]</dt>
2121
+** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
21172122
** <dd>The database is opened for reading and writing if possible, or reading
21182123
** only if the file is write protected by the operating system. In either
2119
-** case the database must already exist, otherwise an error is returned.</dd>
2124
+** case the database must already exist, otherwise an error is returned.</dd>)^
21202125
**
2121
-** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2126
+** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
21222127
** <dd>The database is opened for reading and writing, and is creates it if
21232128
** it does not already exist. This is the behavior that is always used for
2124
-** sqlite3_open() and sqlite3_open16().</dd>
2129
+** sqlite3_open() and sqlite3_open16().</dd>)^
21252130
** </dl>
21262131
**
21272132
** If the 3rd parameter to sqlite3_open_v2() is not one of the
21282133
** combinations shown above or one of the combinations shown above combined
21292134
** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
21302135
** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
21312136
** then the behavior is undefined.
21322137
**
2133
-** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2138
+** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
21342139
** opens in the multi-thread [threading mode] as long as the single-thread
2135
-** mode has not been set at compile-time or start-time. If the
2140
+** mode has not been set at compile-time or start-time. ^If the
21362141
** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
21372142
** in the serialized [threading mode] unless single-thread was
21382143
** previously selected at compile-time or start-time.
2139
-** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2144
+** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
21402145
** eligible to use [shared cache mode], regardless of whether or not shared
2141
-** cache is enabled using [sqlite3_enable_shared_cache()]. The
2146
+** cache is enabled using [sqlite3_enable_shared_cache()]. ^The
21422147
** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
21432148
** participate in [shared cache mode] even if it is enabled.
21442149
**
2145
-** If the filename is ":memory:", then a private, temporary in-memory database
2146
-** is created for the connection. This in-memory database will vanish when
2150
+** ^If the filename is ":memory:", then a private, temporary in-memory database
2151
+** is created for the connection. ^This in-memory database will vanish when
21472152
** the database connection is closed. Future versions of SQLite might
21482153
** make use of additional special filenames that begin with the ":" character.
21492154
** It is recommended that when a database filename actually does begin with
21502155
** a ":" character you should prefix the filename with a pathname such as
21512156
** "./" to avoid ambiguity.
21522157
**
2153
-** If the filename is an empty string, then a private, temporary
2154
-** on-disk database will be created. This private database will be
2158
+** ^If the filename is an empty string, then a private, temporary
2159
+** on-disk database will be created. ^This private database will be
21552160
** automatically deleted as soon as the database connection is closed.
21562161
**
2157
-** The fourth parameter to sqlite3_open_v2() is the name of the
2162
+** ^The fourth parameter to sqlite3_open_v2() is the name of the
21582163
** [sqlite3_vfs] object that defines the operating system interface that
2159
-** the new database connection should use. If the fourth parameter is
2164
+** the new database connection should use. ^If the fourth parameter is
21602165
** a NULL pointer then the default [sqlite3_vfs] object is used.
21612166
**
21622167
** <b>Note to Windows users:</b> The encoding used for the filename argument
21632168
** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
21642169
** codepage is currently defined. Filenames containing international
21652170
** characters must be converted to UTF-8 prior to passing them into
21662171
** sqlite3_open() or sqlite3_open_v2().
2167
-**
2168
-** Requirements:
2169
-** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
2170
-** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
21712172
*/
21722173
SQLITE_API int sqlite3_open(
21732174
const char *filename, /* Database filename (UTF-8) */
21742175
sqlite3 **ppDb /* OUT: SQLite db handle */
21752176
);
@@ -2183,27 +2184,27 @@
21832184
int flags, /* Flags */
21842185
const char *zVfs /* Name of VFS module to use */
21852186
);
21862187
21872188
/*
2188
-** CAPI3REF: Error Codes And Messages {H12800} <S60200>
2189
+** CAPI3REF: Error Codes And Messages
21892190
**
2190
-** The sqlite3_errcode() interface returns the numeric [result code] or
2191
+** ^The sqlite3_errcode() interface returns the numeric [result code] or
21912192
** [extended result code] for the most recent failed sqlite3_* API call
21922193
** associated with a [database connection]. If a prior API call failed
21932194
** but the most recent API call succeeded, the return value from
2194
-** sqlite3_errcode() is undefined. The sqlite3_extended_errcode()
2195
+** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
21952196
** interface is the same except that it always returns the
21962197
** [extended result code] even when extended result codes are
21972198
** disabled.
21982199
**
2199
-** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2200
+** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
22002201
** text that describes the error, as either UTF-8 or UTF-16 respectively.
2201
-** Memory to hold the error message string is managed internally.
2202
+** ^(Memory to hold the error message string is managed internally.
22022203
** The application does not need to worry about freeing the result.
22032204
** However, the error string might be overwritten or deallocated by
2204
-** subsequent calls to other SQLite interface functions.
2205
+** subsequent calls to other SQLite interface functions.)^
22052206
**
22062207
** When the serialized [threading mode] is in use, it might be the
22072208
** case that a second error occurs on a separate thread in between
22082209
** the time of the first error and the call to these interfaces.
22092210
** When that happens, the second error will be reported since these
@@ -2214,21 +2215,18 @@
22142215
** all calls to the interfaces listed here are completed.
22152216
**
22162217
** If an interface fails with SQLITE_MISUSE, that means the interface
22172218
** was invoked incorrectly by the application. In that case, the
22182219
** error code and message may or may not be set.
2219
-**
2220
-** Requirements:
2221
-** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
22222220
*/
22232221
SQLITE_API int sqlite3_errcode(sqlite3 *db);
22242222
SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
22252223
SQLITE_API const char *sqlite3_errmsg(sqlite3*);
22262224
SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
22272225
22282226
/*
2229
-** CAPI3REF: SQL Statement Object {H13000} <H13010>
2227
+** CAPI3REF: SQL Statement Object
22302228
** KEYWORDS: {prepared statement} {prepared statements}
22312229
**
22322230
** An instance of this object represents a single SQL statement.
22332231
** This object is variously known as a "prepared statement" or a
22342232
** "compiled SQL statement" or simply as a "statement".
@@ -2250,29 +2248,29 @@
22502248
** information.
22512249
*/
22522250
typedef struct sqlite3_stmt sqlite3_stmt;
22532251
22542252
/*
2255
-** CAPI3REF: Run-time Limits {H12760} <S20600>
2253
+** CAPI3REF: Run-time Limits
22562254
**
2257
-** This interface allows the size of various constructs to be limited
2255
+** ^(This interface allows the size of various constructs to be limited
22582256
** on a connection by connection basis. The first parameter is the
22592257
** [database connection] whose limit is to be set or queried. The
22602258
** second parameter is one of the [limit categories] that define a
22612259
** class of constructs to be size limited. The third parameter is the
2262
-** new limit for that construct. The function returns the old limit.
2260
+** new limit for that construct. The function returns the old limit.)^
22632261
**
2264
-** If the new limit is a negative number, the limit is unchanged.
2265
-** For the limit category of SQLITE_LIMIT_XYZ there is a
2262
+** ^If the new limit is a negative number, the limit is unchanged.
2263
+** ^(For the limit category of SQLITE_LIMIT_XYZ there is a
22662264
** [limits | hard upper bound]
22672265
** set by a compile-time C preprocessor macro named
22682266
** [limits | SQLITE_MAX_XYZ].
2269
-** (The "_LIMIT_" in the name is changed to "_MAX_".)
2270
-** Attempts to increase a limit above its hard upper bound are
2271
-** silently truncated to the hard upper limit.
2267
+** (The "_LIMIT_" in the name is changed to "_MAX_".))^
2268
+** ^Attempts to increase a limit above its hard upper bound are
2269
+** silently truncated to the hard upper bound.
22722270
**
2273
-** Run time limits are intended for use in applications that manage
2271
+** Run-time limits are intended for use in applications that manage
22742272
** both their own internal database and also databases that are controlled
22752273
** by untrusted external sources. An example application might be a
22762274
** web browser that has its own databases for storing history and
22772275
** separate databases controlled by JavaScript applications downloaded
22782276
** off the Internet. The internal databases can be given the
@@ -2282,63 +2280,60 @@
22822280
** interface to further control untrusted SQL. The size of the database
22832281
** created by an untrusted script can be contained using the
22842282
** [max_page_count] [PRAGMA].
22852283
**
22862284
** New run-time limit categories may be added in future releases.
2287
-**
2288
-** Requirements:
2289
-** [H12762] [H12766] [H12769]
22902285
*/
22912286
SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
22922287
22932288
/*
2294
-** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
2289
+** CAPI3REF: Run-Time Limit Categories
22952290
** KEYWORDS: {limit category} {*limit categories}
22962291
**
22972292
** These constants define various performance limits
22982293
** that can be lowered at run-time using [sqlite3_limit()].
22992294
** The synopsis of the meanings of the various limits is shown below.
23002295
** Additional information is available at [limits | Limits in SQLite].
23012296
**
23022297
** <dl>
2303
-** <dt>SQLITE_LIMIT_LENGTH</dt>
2304
-** <dd>The maximum size of any string or BLOB or table row.<dd>
2298
+** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2299
+** <dd>The maximum size of any string or BLOB or table row.<dd>)^
23052300
**
2306
-** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2307
-** <dd>The maximum length of an SQL statement.</dd>
2301
+** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2302
+** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
23082303
**
2309
-** <dt>SQLITE_LIMIT_COLUMN</dt>
2304
+** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
23102305
** <dd>The maximum number of columns in a table definition or in the
23112306
** result set of a [SELECT] or the maximum number of columns in an index
2312
-** or in an ORDER BY or GROUP BY clause.</dd>
2313
-**
2314
-** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2315
-** <dd>The maximum depth of the parse tree on any expression.</dd>
2316
-**
2317
-** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2318
-** <dd>The maximum number of terms in a compound SELECT statement.</dd>
2319
-**
2320
-** <dt>SQLITE_LIMIT_VDBE_OP</dt>
2307
+** or in an ORDER BY or GROUP BY clause.</dd>)^
2308
+**
2309
+** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2310
+** <dd>The maximum depth of the parse tree on any expression.</dd>)^
2311
+**
2312
+** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2313
+** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
2314
+**
2315
+** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
23212316
** <dd>The maximum number of instructions in a virtual machine program
2322
-** used to implement an SQL statement.</dd>
2323
-**
2324
-** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2325
-** <dd>The maximum number of arguments on a function.</dd>
2326
-**
2327
-** <dt>SQLITE_LIMIT_ATTACHED</dt>
2328
-** <dd>The maximum number of [ATTACH | attached databases].</dd>
2329
-**
2330
-** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2317
+** used to implement an SQL statement.</dd>)^
2318
+**
2319
+** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2320
+** <dd>The maximum number of arguments on a function.</dd>)^
2321
+**
2322
+** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2323
+** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
2324
+**
2325
+** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
23312326
** <dd>The maximum length of the pattern argument to the [LIKE] or
2332
-** [GLOB] operators.</dd>
2327
+** [GLOB] operators.</dd>)^
23332328
**
2334
-** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2329
+** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
23352330
** <dd>The maximum number of variables in an SQL statement that can
2336
-** be bound.</dd>
2331
+** be bound.</dd>)^
23372332
**
2338
-** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2339
-** <dd>The maximum depth of recursion for triggers.</dd>
2333
+** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2334
+** <dd>The maximum depth of recursion for triggers.</dd>)^
23402335
** </dl>
23412336
*/
23422337
#define SQLITE_LIMIT_LENGTH 0
23432338
#define SQLITE_LIMIT_SQL_LENGTH 1
23442339
#define SQLITE_LIMIT_COLUMN 2
@@ -2350,11 +2345,11 @@
23502345
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
23512346
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
23522347
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
23532348
23542349
/*
2355
-** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
2350
+** CAPI3REF: Compiling An SQL Statement
23562351
** KEYWORDS: {SQL statement compiler}
23572352
**
23582353
** To execute an SQL query, it must first be compiled into a byte-code
23592354
** program using one of these routines.
23602355
**
@@ -2365,61 +2360,62 @@
23652360
** The second argument, "zSql", is the statement to be compiled, encoded
23662361
** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
23672362
** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
23682363
** use UTF-16.
23692364
**
2370
-** If the nByte argument is less than zero, then zSql is read up to the
2371
-** first zero terminator. If nByte is non-negative, then it is the maximum
2372
-** number of bytes read from zSql. When nByte is non-negative, the
2365
+** ^If the nByte argument is less than zero, then zSql is read up to the
2366
+** first zero terminator. ^If nByte is non-negative, then it is the maximum
2367
+** number of bytes read from zSql. ^When nByte is non-negative, the
23732368
** zSql string ends at either the first '\000' or '\u0000' character or
23742369
** the nByte-th byte, whichever comes first. If the caller knows
23752370
** that the supplied string is nul-terminated, then there is a small
23762371
** performance advantage to be gained by passing an nByte parameter that
23772372
** is equal to the number of bytes in the input string <i>including</i>
23782373
** the nul-terminator bytes.
23792374
**
2380
-** If pzTail is not NULL then *pzTail is made to point to the first byte
2375
+** ^If pzTail is not NULL then *pzTail is made to point to the first byte
23812376
** past the end of the first SQL statement in zSql. These routines only
23822377
** compile the first statement in zSql, so *pzTail is left pointing to
23832378
** what remains uncompiled.
23842379
**
2385
-** *ppStmt is left pointing to a compiled [prepared statement] that can be
2386
-** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2387
-** to NULL. If the input text contains no SQL (if the input is an empty
2380
+** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
2381
+** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
2382
+** to NULL. ^If the input text contains no SQL (if the input is an empty
23882383
** string or a comment) then *ppStmt is set to NULL.
23892384
** The calling procedure is responsible for deleting the compiled
23902385
** SQL statement using [sqlite3_finalize()] after it has finished with it.
23912386
** ppStmt may not be NULL.
23922387
**
2393
-** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
2388
+** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
2389
+** otherwise an [error code] is returned.
23942390
**
23952391
** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
23962392
** recommended for all new programs. The two older interfaces are retained
23972393
** for backwards compatibility, but their use is discouraged.
2398
-** In the "v2" interfaces, the prepared statement
2394
+** ^In the "v2" interfaces, the prepared statement
23992395
** that is returned (the [sqlite3_stmt] object) contains a copy of the
24002396
** original SQL text. This causes the [sqlite3_step()] interface to
24012397
** behave differently in three ways:
24022398
**
24032399
** <ol>
24042400
** <li>
2405
-** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2401
+** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
24062402
** always used to do, [sqlite3_step()] will automatically recompile the SQL
2407
-** statement and try to run it again. If the schema has changed in
2403
+** statement and try to run it again. ^If the schema has changed in
24082404
** a way that makes the statement no longer valid, [sqlite3_step()] will still
24092405
** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
24102406
** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
24112407
** error go away. Note: use [sqlite3_errmsg()] to find the text
24122408
** of the parsing error that results in an [SQLITE_SCHEMA] return.
24132409
** </li>
24142410
**
24152411
** <li>
2416
-** When an error occurs, [sqlite3_step()] will return one of the detailed
2417
-** [error codes] or [extended error codes]. The legacy behavior was that
2412
+** ^When an error occurs, [sqlite3_step()] will return one of the detailed
2413
+** [error codes] or [extended error codes]. ^The legacy behavior was that
24182414
** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2419
-** and you would have to make a second call to [sqlite3_reset()] in order
2420
-** to find the underlying cause of the problem. With the "v2" prepare
2415
+** and the application would have to make a second call to [sqlite3_reset()]
2416
+** in order to find the underlying cause of the problem. With the "v2" prepare
24212417
** interfaces, the underlying reason for the error is returned immediately.
24222418
** </li>
24232419
**
24242420
** <li>
24252421
** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2427,14 +2423,10 @@
24272423
** automatically recompiled (as if there had been a schema change) on the first
24282424
** [sqlite3_step()] call following any change to the
24292425
** [sqlite3_bind_text | bindings] of the [parameter].
24302426
** </li>
24312427
** </ol>
2432
-**
2433
-** Requirements:
2434
-** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
2435
-**
24362428
*/
24372429
SQLITE_API int sqlite3_prepare(
24382430
sqlite3 *db, /* Database handle */
24392431
const char *zSql, /* SQL statement, UTF-8 encoded */
24402432
int nByte, /* Maximum length of zSql in bytes. */
@@ -2462,28 +2454,25 @@
24622454
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
24632455
const void **pzTail /* OUT: Pointer to unused portion of zSql */
24642456
);
24652457
24662458
/*
2467
-** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
2459
+** CAPI3REF: Retrieving Statement SQL
24682460
**
2469
-** This interface can be used to retrieve a saved copy of the original
2461
+** ^This interface can be used to retrieve a saved copy of the original
24702462
** SQL text used to create a [prepared statement] if that statement was
24712463
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
2472
-**
2473
-** Requirements:
2474
-** [H13101] [H13102] [H13103]
24752464
*/
24762465
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
24772466
24782467
/*
2479
-** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
2468
+** CAPI3REF: Dynamically Typed Value Object
24802469
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
24812470
**
24822471
** SQLite uses the sqlite3_value object to represent all values
24832472
** that can be stored in a database table. SQLite uses dynamic typing
2484
-** for the values it stores. Values stored in sqlite3_value objects
2473
+** for the values it stores. ^Values stored in sqlite3_value objects
24852474
** can be integers, floating point values, strings, BLOBs, or NULL.
24862475
**
24872476
** An sqlite3_value object may be either "protected" or "unprotected".
24882477
** Some interfaces require a protected sqlite3_value. Other interfaces
24892478
** will accept either a protected or an unprotected sqlite3_value.
@@ -2501,26 +2490,26 @@
25012490
** sqlite3_value objects and they can be used interchangeably. However,
25022491
** for maximum code portability it is recommended that applications
25032492
** still make the distinction between between protected and unprotected
25042493
** sqlite3_value objects even when not strictly required.
25052494
**
2506
-** The sqlite3_value objects that are passed as parameters into the
2495
+** ^The sqlite3_value objects that are passed as parameters into the
25072496
** implementation of [application-defined SQL functions] are protected.
2508
-** The sqlite3_value object returned by
2497
+** ^The sqlite3_value object returned by
25092498
** [sqlite3_column_value()] is unprotected.
25102499
** Unprotected sqlite3_value objects may only be used with
25112500
** [sqlite3_result_value()] and [sqlite3_bind_value()].
25122501
** The [sqlite3_value_blob | sqlite3_value_type()] family of
25132502
** interfaces require protected sqlite3_value objects.
25142503
*/
25152504
typedef struct Mem sqlite3_value;
25162505
25172506
/*
2518
-** CAPI3REF: SQL Function Context Object {H16001} <S20200>
2507
+** CAPI3REF: SQL Function Context Object
25192508
**
25202509
** The context in which an SQL function executes is stored in an
2521
-** sqlite3_context object. A pointer to an sqlite3_context object
2510
+** sqlite3_context object. ^A pointer to an sqlite3_context object
25222511
** is always first parameter to [application-defined SQL functions].
25232512
** The application-defined SQL function implementation will pass this
25242513
** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
25252514
** [sqlite3_aggregate_context()], [sqlite3_user_data()],
25262515
** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -2527,15 +2516,15 @@
25272516
** and/or [sqlite3_set_auxdata()].
25282517
*/
25292518
typedef struct sqlite3_context sqlite3_context;
25302519
25312520
/*
2532
-** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
2521
+** CAPI3REF: Binding Values To Prepared Statements
25332522
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
25342523
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
25352524
**
2536
-** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
2525
+** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
25372526
** literals may be replaced by a [parameter] that matches one of following
25382527
** templates:
25392528
**
25402529
** <ul>
25412530
** <li> ?
@@ -2544,76 +2533,70 @@
25442533
** <li> @VVV
25452534
** <li> $VVV
25462535
** </ul>
25472536
**
25482537
** In the templates above, NNN represents an integer literal,
2549
-** and VVV represents an alphanumeric identifer. The values of these
2538
+** and VVV represents an alphanumeric identifer.)^ ^The values of these
25502539
** parameters (also called "host parameter names" or "SQL parameters")
25512540
** can be set using the sqlite3_bind_*() routines defined here.
25522541
**
2553
-** The first argument to the sqlite3_bind_*() routines is always
2542
+** ^The first argument to the sqlite3_bind_*() routines is always
25542543
** a pointer to the [sqlite3_stmt] object returned from
25552544
** [sqlite3_prepare_v2()] or its variants.
25562545
**
2557
-** The second argument is the index of the SQL parameter to be set.
2558
-** The leftmost SQL parameter has an index of 1. When the same named
2546
+** ^The second argument is the index of the SQL parameter to be set.
2547
+** ^The leftmost SQL parameter has an index of 1. ^When the same named
25592548
** SQL parameter is used more than once, second and subsequent
25602549
** occurrences have the same index as the first occurrence.
2561
-** The index for named parameters can be looked up using the
2562
-** [sqlite3_bind_parameter_index()] API if desired. The index
2550
+** ^The index for named parameters can be looked up using the
2551
+** [sqlite3_bind_parameter_index()] API if desired. ^The index
25632552
** for "?NNN" parameters is the value of NNN.
2564
-** The NNN value must be between 1 and the [sqlite3_limit()]
2553
+** ^The NNN value must be between 1 and the [sqlite3_limit()]
25652554
** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
25662555
**
2567
-** The third argument is the value to bind to the parameter.
2556
+** ^The third argument is the value to bind to the parameter.
25682557
**
2569
-** In those routines that have a fourth argument, its value is the
2558
+** ^(In those routines that have a fourth argument, its value is the
25702559
** number of bytes in the parameter. To be clear: the value is the
2571
-** number of <u>bytes</u> in the value, not the number of characters.
2572
-** If the fourth parameter is negative, the length of the string is
2560
+** number of <u>bytes</u> in the value, not the number of characters.)^
2561
+** ^If the fourth parameter is negative, the length of the string is
25732562
** the number of bytes up to the first zero terminator.
25742563
**
2575
-** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
2564
+** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
25762565
** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
2577
-** string after SQLite has finished with it. If the fifth argument is
2566
+** string after SQLite has finished with it. ^If the fifth argument is
25782567
** the special value [SQLITE_STATIC], then SQLite assumes that the
25792568
** information is in static, unmanaged space and does not need to be freed.
2580
-** If the fifth argument has the value [SQLITE_TRANSIENT], then
2569
+** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
25812570
** SQLite makes its own private copy of the data immediately, before
25822571
** the sqlite3_bind_*() routine returns.
25832572
**
2584
-** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
2585
-** is filled with zeroes. A zeroblob uses a fixed amount of memory
2573
+** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
2574
+** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
25862575
** (just an integer to hold its size) while it is being processed.
25872576
** Zeroblobs are intended to serve as placeholders for BLOBs whose
25882577
** content is later written using
25892578
** [sqlite3_blob_open | incremental BLOB I/O] routines.
2590
-** A negative value for the zeroblob results in a zero-length BLOB.
2591
-**
2592
-** The sqlite3_bind_*() routines must be called after
2593
-** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
2594
-** before [sqlite3_step()].
2595
-** Bindings are not cleared by the [sqlite3_reset()] routine.
2596
-** Unbound parameters are interpreted as NULL.
2597
-**
2598
-** These routines return [SQLITE_OK] on success or an error code if
2599
-** anything goes wrong. [SQLITE_RANGE] is returned if the parameter
2600
-** index is out of range. [SQLITE_NOMEM] is returned if malloc() fails.
2601
-** [SQLITE_MISUSE] might be returned if these routines are called on a
2602
-** virtual machine that is the wrong state or which has already been finalized.
2603
-** Detection of misuse is unreliable. Applications should not depend
2604
-** on SQLITE_MISUSE returns. SQLITE_MISUSE is intended to indicate a
2605
-** a logic error in the application. Future versions of SQLite might
2606
-** panic rather than return SQLITE_MISUSE.
2579
+** ^A negative value for the zeroblob results in a zero-length BLOB.
2580
+**
2581
+** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
2582
+** for the [prepared statement] or with a prepared statement for which
2583
+** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
2584
+** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
2585
+** routine is passed a [prepared statement] that has been finalized, the
2586
+** result is undefined and probably harmful.
2587
+**
2588
+** ^Bindings are not cleared by the [sqlite3_reset()] routine.
2589
+** ^Unbound parameters are interpreted as NULL.
2590
+**
2591
+** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
2592
+** [error code] if anything goes wrong.
2593
+** ^[SQLITE_RANGE] is returned if the parameter
2594
+** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
26072595
**
26082596
** See also: [sqlite3_bind_parameter_count()],
26092597
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
2610
-**
2611
-** Requirements:
2612
-** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
2613
-** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
2614
-**
26152598
*/
26162599
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
26172600
SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
26182601
SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
26192602
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -2622,175 +2605,155 @@
26222605
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
26232606
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
26242607
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
26252608
26262609
/*
2627
-** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
2610
+** CAPI3REF: Number Of SQL Parameters
26282611
**
2629
-** This routine can be used to find the number of [SQL parameters]
2612
+** ^This routine can be used to find the number of [SQL parameters]
26302613
** in a [prepared statement]. SQL parameters are tokens of the
26312614
** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
26322615
** placeholders for values that are [sqlite3_bind_blob | bound]
26332616
** to the parameters at a later time.
26342617
**
2635
-** This routine actually returns the index of the largest (rightmost)
2618
+** ^(This routine actually returns the index of the largest (rightmost)
26362619
** parameter. For all forms except ?NNN, this will correspond to the
2637
-** number of unique parameters. If parameters of the ?NNN are used,
2638
-** there may be gaps in the list.
2620
+** number of unique parameters. If parameters of the ?NNN form are used,
2621
+** there may be gaps in the list.)^
26392622
**
26402623
** See also: [sqlite3_bind_blob|sqlite3_bind()],
26412624
** [sqlite3_bind_parameter_name()], and
26422625
** [sqlite3_bind_parameter_index()].
2643
-**
2644
-** Requirements:
2645
-** [H13601]
26462626
*/
26472627
SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
26482628
26492629
/*
2650
-** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
2630
+** CAPI3REF: Name Of A Host Parameter
26512631
**
2652
-** This routine returns a pointer to the name of the n-th
2653
-** [SQL parameter] in a [prepared statement].
2654
-** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
2632
+** ^The sqlite3_bind_parameter_name(P,N) interface returns
2633
+** the name of the N-th [SQL parameter] in the [prepared statement] P.
2634
+** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
26552635
** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
26562636
** respectively.
26572637
** In other words, the initial ":" or "$" or "@" or "?"
2658
-** is included as part of the name.
2659
-** Parameters of the form "?" without a following integer have no name
2660
-** and are also referred to as "anonymous parameters".
2661
-**
2662
-** The first host parameter has an index of 1, not 0.
2663
-**
2664
-** If the value n is out of range or if the n-th parameter is
2665
-** nameless, then NULL is returned. The returned string is
2638
+** is included as part of the name.)^
2639
+** ^Parameters of the form "?" without a following integer have no name
2640
+** and are referred to as "nameless" or "anonymous parameters".
2641
+**
2642
+** ^The first host parameter has an index of 1, not 0.
2643
+**
2644
+** ^If the value N is out of range or if the N-th parameter is
2645
+** nameless, then NULL is returned. ^The returned string is
26662646
** always in UTF-8 encoding even if the named parameter was
26672647
** originally specified as UTF-16 in [sqlite3_prepare16()] or
26682648
** [sqlite3_prepare16_v2()].
26692649
**
26702650
** See also: [sqlite3_bind_blob|sqlite3_bind()],
26712651
** [sqlite3_bind_parameter_count()], and
26722652
** [sqlite3_bind_parameter_index()].
2673
-**
2674
-** Requirements:
2675
-** [H13621]
26762653
*/
26772654
SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
26782655
26792656
/*
2680
-** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
2657
+** CAPI3REF: Index Of A Parameter With A Given Name
26812658
**
2682
-** Return the index of an SQL parameter given its name. The
2659
+** ^Return the index of an SQL parameter given its name. ^The
26832660
** index value returned is suitable for use as the second
2684
-** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero
2685
-** is returned if no matching parameter is found. The parameter
2661
+** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
2662
+** is returned if no matching parameter is found. ^The parameter
26862663
** name must be given in UTF-8 even if the original statement
26872664
** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
26882665
**
26892666
** See also: [sqlite3_bind_blob|sqlite3_bind()],
26902667
** [sqlite3_bind_parameter_count()], and
26912668
** [sqlite3_bind_parameter_index()].
2692
-**
2693
-** Requirements:
2694
-** [H13641]
26952669
*/
26962670
SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
26972671
26982672
/*
2699
-** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
2673
+** CAPI3REF: Reset All Bindings On A Prepared Statement
27002674
**
2701
-** Contrary to the intuition of many, [sqlite3_reset()] does not reset
2675
+** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
27022676
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
2703
-** Use this routine to reset all host parameters to NULL.
2704
-**
2705
-** Requirements:
2706
-** [H13661]
2677
+** ^Use this routine to reset all host parameters to NULL.
27072678
*/
27082679
SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
27092680
27102681
/*
2711
-** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
2712
-**
2713
-** Return the number of columns in the result set returned by the
2714
-** [prepared statement]. This routine returns 0 if pStmt is an SQL
2715
-** statement that does not return data (for example an [UPDATE]).
2716
-**
2717
-** Requirements:
2718
-** [H13711]
2682
+** CAPI3REF: Number Of Columns In A Result Set
2683
+**
2684
+** ^Return the number of columns in the result set returned by the
2685
+** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
2686
+** statement that does not return data (for example an [UPDATE]).
27192687
*/
27202688
SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
27212689
27222690
/*
2723
-** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
2691
+** CAPI3REF: Column Names In A Result Set
27242692
**
2725
-** These routines return the name assigned to a particular column
2726
-** in the result set of a [SELECT] statement. The sqlite3_column_name()
2693
+** ^These routines return the name assigned to a particular column
2694
+** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
27272695
** interface returns a pointer to a zero-terminated UTF-8 string
27282696
** and sqlite3_column_name16() returns a pointer to a zero-terminated
2729
-** UTF-16 string. The first parameter is the [prepared statement]
2730
-** that implements the [SELECT] statement. The second parameter is the
2731
-** column number. The leftmost column is number 0.
2697
+** UTF-16 string. ^The first parameter is the [prepared statement]
2698
+** that implements the [SELECT] statement. ^The second parameter is the
2699
+** column number. ^The leftmost column is number 0.
27322700
**
2733
-** The returned string pointer is valid until either the [prepared statement]
2701
+** ^The returned string pointer is valid until either the [prepared statement]
27342702
** is destroyed by [sqlite3_finalize()] or until the next call to
27352703
** sqlite3_column_name() or sqlite3_column_name16() on the same column.
27362704
**
2737
-** If sqlite3_malloc() fails during the processing of either routine
2705
+** ^If sqlite3_malloc() fails during the processing of either routine
27382706
** (for example during a conversion from UTF-8 to UTF-16) then a
27392707
** NULL pointer is returned.
27402708
**
2741
-** The name of a result column is the value of the "AS" clause for
2709
+** ^The name of a result column is the value of the "AS" clause for
27422710
** that column, if there is an AS clause. If there is no AS clause
27432711
** then the name of the column is unspecified and may change from
27442712
** one release of SQLite to the next.
2745
-**
2746
-** Requirements:
2747
-** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
27482713
*/
27492714
SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
27502715
SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
27512716
27522717
/*
2753
-** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
2718
+** CAPI3REF: Source Of Data In A Query Result
27542719
**
2755
-** These routines provide a means to determine what column of what
2756
-** table in which database a result of a [SELECT] statement comes from.
2757
-** The name of the database or table or column can be returned as
2758
-** either a UTF-8 or UTF-16 string. The _database_ routines return
2720
+** ^These routines provide a means to determine the database, table, and
2721
+** table column that is the origin of a particular result column in
2722
+** [SELECT] statement.
2723
+** ^The name of the database or table or column can be returned as
2724
+** either a UTF-8 or UTF-16 string. ^The _database_ routines return
27592725
** the database name, the _table_ routines return the table name, and
27602726
** the origin_ routines return the column name.
2761
-** The returned string is valid until the [prepared statement] is destroyed
2727
+** ^The returned string is valid until the [prepared statement] is destroyed
27622728
** using [sqlite3_finalize()] or until the same information is requested
27632729
** again in a different encoding.
27642730
**
2765
-** The names returned are the original un-aliased names of the
2731
+** ^The names returned are the original un-aliased names of the
27662732
** database, table, and column.
27672733
**
2768
-** The first argument to the following calls is a [prepared statement].
2769
-** These functions return information about the Nth column returned by
2734
+** ^The first argument to these interfaces is a [prepared statement].
2735
+** ^These functions return information about the Nth result column returned by
27702736
** the statement, where N is the second function argument.
2737
+** ^The left-most column is column 0 for these routines.
27712738
**
2772
-** If the Nth column returned by the statement is an expression or
2739
+** ^If the Nth column returned by the statement is an expression or
27732740
** subquery and is not a column value, then all of these functions return
2774
-** NULL. These routine might also return NULL if a memory allocation error
2775
-** occurs. Otherwise, they return the name of the attached database, table
2776
-** and column that query result column was extracted from.
2777
-**
2778
-** As with all other SQLite APIs, those postfixed with "16" return
2779
-** UTF-16 encoded strings, the other functions return UTF-8. {END}
2780
-**
2781
-** These APIs are only available if the library was compiled with the
2782
-** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
2783
-**
2784
-** {A13751}
2741
+** NULL. ^These routine might also return NULL if a memory allocation error
2742
+** occurs. ^Otherwise, they return the name of the attached database, table,
2743
+** or column that query result column was extracted from.
2744
+**
2745
+** ^As with all other SQLite APIs, those whose names end with "16" return
2746
+** UTF-16 encoded strings and the other functions return UTF-8.
2747
+**
2748
+** ^These APIs are only available if the library was compiled with the
2749
+** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
2750
+**
27852751
** If two or more threads call one or more of these routines against the same
27862752
** prepared statement and column at the same time then the results are
27872753
** undefined.
27882754
**
2789
-** Requirements:
2790
-** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
2791
-**
27922755
** If two or more threads call one or more
27932756
** [sqlite3_column_database_name | column metadata interfaces]
27942757
** for the same [prepared statement] and result column
27952758
** at the same time then the results are undefined.
27962759
*/
@@ -2800,46 +2763,43 @@
28002763
SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
28012764
SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
28022765
SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
28032766
28042767
/*
2805
-** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
2768
+** CAPI3REF: Declared Datatype Of A Query Result
28062769
**
2807
-** The first parameter is a [prepared statement].
2770
+** ^(The first parameter is a [prepared statement].
28082771
** If this statement is a [SELECT] statement and the Nth column of the
28092772
** returned result set of that [SELECT] is a table column (not an
28102773
** expression or subquery) then the declared type of the table
2811
-** column is returned. If the Nth column of the result set is an
2774
+** column is returned.)^ ^If the Nth column of the result set is an
28122775
** expression or subquery, then a NULL pointer is returned.
2813
-** The returned string is always UTF-8 encoded. {END}
2776
+** ^The returned string is always UTF-8 encoded.
28142777
**
2815
-** For example, given the database schema:
2778
+** ^(For example, given the database schema:
28162779
**
28172780
** CREATE TABLE t1(c1 VARIANT);
28182781
**
28192782
** and the following statement to be compiled:
28202783
**
28212784
** SELECT c1 + 1, c1 FROM t1;
28222785
**
28232786
** this routine would return the string "VARIANT" for the second result
2824
-** column (i==1), and a NULL pointer for the first result column (i==0).
2787
+** column (i==1), and a NULL pointer for the first result column (i==0).)^
28252788
**
2826
-** SQLite uses dynamic run-time typing. So just because a column
2789
+** ^SQLite uses dynamic run-time typing. ^So just because a column
28272790
** is declared to contain a particular type does not mean that the
28282791
** data stored in that column is of the declared type. SQLite is
2829
-** strongly typed, but the typing is dynamic not static. Type
2792
+** strongly typed, but the typing is dynamic not static. ^Type
28302793
** is associated with individual values, not with the containers
28312794
** used to hold those values.
2832
-**
2833
-** Requirements:
2834
-** [H13761] [H13762] [H13763]
28352795
*/
28362796
SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
28372797
SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
28382798
28392799
/*
2840
-** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
2800
+** CAPI3REF: Evaluate An SQL Statement
28412801
**
28422802
** After a [prepared statement] has been prepared using either
28432803
** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
28442804
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
28452805
** must be called one or more times to evaluate the statement.
@@ -2849,39 +2809,39 @@
28492809
** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
28502810
** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
28512811
** new "v2" interface is recommended for new applications but the legacy
28522812
** interface will continue to be supported.
28532813
**
2854
-** In the legacy interface, the return value will be either [SQLITE_BUSY],
2814
+** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
28552815
** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
2856
-** With the "v2" interface, any of the other [result codes] or
2816
+** ^With the "v2" interface, any of the other [result codes] or
28572817
** [extended result codes] might be returned as well.
28582818
**
2859
-** [SQLITE_BUSY] means that the database engine was unable to acquire the
2860
-** database locks it needs to do its job. If the statement is a [COMMIT]
2819
+** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
2820
+** database locks it needs to do its job. ^If the statement is a [COMMIT]
28612821
** or occurs outside of an explicit transaction, then you can retry the
28622822
** statement. If the statement is not a [COMMIT] and occurs within a
28632823
** explicit transaction then you should rollback the transaction before
28642824
** continuing.
28652825
**
2866
-** [SQLITE_DONE] means that the statement has finished executing
2826
+** ^[SQLITE_DONE] means that the statement has finished executing
28672827
** successfully. sqlite3_step() should not be called again on this virtual
28682828
** machine without first calling [sqlite3_reset()] to reset the virtual
28692829
** machine back to its initial state.
28702830
**
2871
-** If the SQL statement being executed returns any data, then [SQLITE_ROW]
2831
+** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
28722832
** is returned each time a new row of data is ready for processing by the
28732833
** caller. The values may be accessed using the [column access functions].
28742834
** sqlite3_step() is called again to retrieve the next row of data.
28752835
**
2876
-** [SQLITE_ERROR] means that a run-time error (such as a constraint
2836
+** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
28772837
** violation) has occurred. sqlite3_step() should not be called again on
28782838
** the VM. More information may be found by calling [sqlite3_errmsg()].
2879
-** With the legacy interface, a more specific error code (for example,
2839
+** ^With the legacy interface, a more specific error code (for example,
28802840
** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
28812841
** can be obtained by calling [sqlite3_reset()] on the
2882
-** [prepared statement]. In the "v2" interface,
2842
+** [prepared statement]. ^In the "v2" interface,
28832843
** the more specific error code is returned directly by sqlite3_step().
28842844
**
28852845
** [SQLITE_MISUSE] means that the this routine was called inappropriately.
28862846
** Perhaps it was called on a [prepared statement] that has
28872847
** already been [sqlite3_finalize | finalized] or on one that had
@@ -2898,39 +2858,34 @@
28982858
** with the "v2" interface. If you prepare all of your SQL statements
28992859
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
29002860
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
29012861
** then the more specific [error codes] are returned directly
29022862
** by sqlite3_step(). The use of the "v2" interface is recommended.
2903
-**
2904
-** Requirements:
2905
-** [H13202] [H15304] [H15306] [H15308] [H15310]
29062863
*/
29072864
SQLITE_API int sqlite3_step(sqlite3_stmt*);
29082865
29092866
/*
2910
-** CAPI3REF: Number of columns in a result set {H13770} <S10700>
2867
+** CAPI3REF: Number of columns in a result set
29112868
**
2912
-** Returns the number of values in the current row of the result set.
2913
-**
2914
-** Requirements:
2915
-** [H13771] [H13772]
2869
+** ^The sqlite3_data_count(P) the number of columns in the
2870
+** of the result set of [prepared statement] P.
29162871
*/
29172872
SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
29182873
29192874
/*
2920
-** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
2875
+** CAPI3REF: Fundamental Datatypes
29212876
** KEYWORDS: SQLITE_TEXT
29222877
**
2923
-** {H10266} Every value in SQLite has one of five fundamental datatypes:
2878
+** ^(Every value in SQLite has one of five fundamental datatypes:
29242879
**
29252880
** <ul>
29262881
** <li> 64-bit signed integer
29272882
** <li> 64-bit IEEE floating point number
29282883
** <li> string
29292884
** <li> BLOB
29302885
** <li> NULL
2931
-** </ul> {END}
2886
+** </ul>)^
29322887
**
29332888
** These constants are codes for each of those types.
29342889
**
29352890
** Note that the SQLITE_TEXT constant was also used in SQLite version 2
29362891
** for a completely different meaning. Software that links against both
@@ -2947,22 +2902,22 @@
29472902
# define SQLITE_TEXT 3
29482903
#endif
29492904
#define SQLITE3_TEXT 3
29502905
29512906
/*
2952
-** CAPI3REF: Result Values From A Query {H13800} <S10700>
2907
+** CAPI3REF: Result Values From A Query
29532908
** KEYWORDS: {column access functions}
29542909
**
2955
-** These routines form the "result set query" interface.
2910
+** These routines form the "result set" interface.
29562911
**
2957
-** These routines return information about a single column of the current
2958
-** result row of a query. In every case the first argument is a pointer
2912
+** ^These routines return information about a single column of the current
2913
+** result row of a query. ^In every case the first argument is a pointer
29592914
** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
29602915
** that was returned from [sqlite3_prepare_v2()] or one of its variants)
29612916
** and the second argument is the index of the column for which information
2962
-** should be returned. The leftmost column of the result set has the index 0.
2963
-** The number of columns in the result can be determined using
2917
+** should be returned. ^The leftmost column of the result set has the index 0.
2918
+** ^The number of columns in the result can be determined using
29642919
** [sqlite3_column_count()].
29652920
**
29662921
** If the SQL statement does not currently point to a valid row, or if the
29672922
** column index is out of range, the result is undefined.
29682923
** These routines may only be called when the most recent call to
@@ -2973,52 +2928,52 @@
29732928
** something other than [SQLITE_ROW], the results are undefined.
29742929
** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
29752930
** are called from a different thread while any of these routines
29762931
** are pending, then the results are undefined.
29772932
**
2978
-** The sqlite3_column_type() routine returns the
2933
+** ^The sqlite3_column_type() routine returns the
29792934
** [SQLITE_INTEGER | datatype code] for the initial data type
2980
-** of the result column. The returned value is one of [SQLITE_INTEGER],
2935
+** of the result column. ^The returned value is one of [SQLITE_INTEGER],
29812936
** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
29822937
** returned by sqlite3_column_type() is only meaningful if no type
29832938
** conversions have occurred as described below. After a type conversion,
29842939
** the value returned by sqlite3_column_type() is undefined. Future
29852940
** versions of SQLite may change the behavior of sqlite3_column_type()
29862941
** following a type conversion.
29872942
**
2988
-** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
2943
+** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
29892944
** routine returns the number of bytes in that BLOB or string.
2990
-** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
2945
+** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
29912946
** the string to UTF-8 and then returns the number of bytes.
2992
-** If the result is a numeric value then sqlite3_column_bytes() uses
2947
+** ^If the result is a numeric value then sqlite3_column_bytes() uses
29932948
** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
29942949
** the number of bytes in that string.
2995
-** The value returned does not include the zero terminator at the end
2996
-** of the string. For clarity: the value returned is the number of
2950
+** ^The value returned does not include the zero terminator at the end
2951
+** of the string. ^For clarity: the value returned is the number of
29972952
** bytes in the string, not the number of characters.
29982953
**
2999
-** Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3000
-** even empty strings, are always zero terminated. The return
2954
+** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
2955
+** even empty strings, are always zero terminated. ^The return
30012956
** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
30022957
** pointer, possibly even a NULL pointer.
30032958
**
3004
-** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
2959
+** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
30052960
** but leaves the result in UTF-16 in native byte order instead of UTF-8.
3006
-** The zero terminator is not included in this count.
2961
+** ^The zero terminator is not included in this count.
30072962
**
3008
-** The object returned by [sqlite3_column_value()] is an
2963
+** ^The object returned by [sqlite3_column_value()] is an
30092964
** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
30102965
** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
30112966
** If the [unprotected sqlite3_value] object returned by
30122967
** [sqlite3_column_value()] is used in any other way, including calls
30132968
** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
30142969
** or [sqlite3_value_bytes()], then the behavior is undefined.
30152970
**
3016
-** These routines attempt to convert the value where appropriate. For
2971
+** These routines attempt to convert the value where appropriate. ^For
30172972
** example, if the internal representation is FLOAT and a text result
30182973
** is requested, [sqlite3_snprintf()] is used internally to perform the
3019
-** conversion automatically. The following table details the conversions
2974
+** conversion automatically. ^(The following table details the conversions
30202975
** that are applied:
30212976
**
30222977
** <blockquote>
30232978
** <table border="1">
30242979
** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3038,22 +2993,22 @@
30382993
** <tr><td> TEXT <td> BLOB <td> No change
30392994
** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
30402995
** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
30412996
** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
30422997
** </table>
3043
-** </blockquote>
2998
+** </blockquote>)^
30442999
**
30453000
** The table above makes reference to standard C library functions atoi()
30463001
** and atof(). SQLite does not really use these functions. It has its
30473002
** own equivalent internal routines. The atoi() and atof() names are
30483003
** used in the table for brevity and because they are familiar to most
30493004
** C programmers.
30503005
**
3051
-** Note that when type conversions occur, pointers returned by prior
3006
+** ^Note that when type conversions occur, pointers returned by prior
30523007
** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
30533008
** sqlite3_column_text16() may be invalidated.
3054
-** Type conversions and pointer invalidations might occur
3009
+** ^(Type conversions and pointer invalidations might occur
30553010
** in the following cases:
30563011
**
30573012
** <ul>
30583013
** <li> The initial content is a BLOB and sqlite3_column_text() or
30593014
** sqlite3_column_text16() is called. A zero-terminator might
@@ -3062,51 +3017,47 @@
30623017
** sqlite3_column_text16() is called. The content must be converted
30633018
** to UTF-16.</li>
30643019
** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
30653020
** sqlite3_column_text() is called. The content must be converted
30663021
** to UTF-8.</li>
3067
-** </ul>
3022
+** </ul>)^
30683023
**
3069
-** Conversions between UTF-16be and UTF-16le are always done in place and do
3024
+** ^Conversions between UTF-16be and UTF-16le are always done in place and do
30703025
** not invalidate a prior pointer, though of course the content of the buffer
30713026
** that the prior pointer points to will have been modified. Other kinds
30723027
** of conversion are done in place when it is possible, but sometimes they
30733028
** are not possible and in those cases prior pointers are invalidated.
30743029
**
3075
-** The safest and easiest to remember policy is to invoke these routines
3030
+** ^(The safest and easiest to remember policy is to invoke these routines
30763031
** in one of the following ways:
30773032
**
30783033
** <ul>
30793034
** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
30803035
** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
30813036
** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3082
-** </ul>
3037
+** </ul>)^
30833038
**
30843039
** In other words, you should call sqlite3_column_text(),
30853040
** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
30863041
** into the desired format, then invoke sqlite3_column_bytes() or
30873042
** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
30883043
** to sqlite3_column_text() or sqlite3_column_blob() with calls to
30893044
** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
30903045
** with calls to sqlite3_column_bytes().
30913046
**
3092
-** The pointers returned are valid until a type conversion occurs as
3047
+** ^The pointers returned are valid until a type conversion occurs as
30933048
** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3094
-** [sqlite3_finalize()] is called. The memory space used to hold strings
3049
+** [sqlite3_finalize()] is called. ^The memory space used to hold strings
30953050
** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
30963051
** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
30973052
** [sqlite3_free()].
30983053
**
3099
-** If a memory allocation error occurs during the evaluation of any
3054
+** ^(If a memory allocation error occurs during the evaluation of any
31003055
** of these routines, a default value is returned. The default value
31013056
** is either the integer 0, the floating point number 0.0, or a NULL
31023057
** pointer. Subsequent calls to [sqlite3_errcode()] will return
3103
-** [SQLITE_NOMEM].
3104
-**
3105
-** Requirements:
3106
-** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
3107
-** [H13827] [H13830]
3058
+** [SQLITE_NOMEM].)^
31083059
*/
31093060
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
31103061
SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
31113062
SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
31123063
SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3116,139 +3067,132 @@
31163067
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
31173068
SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
31183069
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
31193070
31203071
/*
3121
-** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
3072
+** CAPI3REF: Destroy A Prepared Statement Object
31223073
**
3123
-** The sqlite3_finalize() function is called to delete a [prepared statement].
3124
-** If the statement was executed successfully or not executed at all, then
3125
-** SQLITE_OK is returned. If execution of the statement failed then an
3074
+** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3075
+** ^If the statement was executed successfully or not executed at all, then
3076
+** SQLITE_OK is returned. ^If execution of the statement failed then an
31263077
** [error code] or [extended error code] is returned.
31273078
**
3128
-** This routine can be called at any point during the execution of the
3129
-** [prepared statement]. If the virtual machine has not
3079
+** ^This routine can be called at any point during the execution of the
3080
+** [prepared statement]. ^If the virtual machine has not
31303081
** completed execution when this routine is called, that is like
31313082
** encountering an error or an [sqlite3_interrupt | interrupt].
3132
-** Incomplete updates may be rolled back and transactions canceled,
3083
+** ^Incomplete updates may be rolled back and transactions canceled,
31333084
** depending on the circumstances, and the
31343085
** [error code] returned will be [SQLITE_ABORT].
3135
-**
3136
-** Requirements:
3137
-** [H11302] [H11304]
31383086
*/
31393087
SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
31403088
31413089
/*
3142
-** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
3090
+** CAPI3REF: Reset A Prepared Statement Object
31433091
**
31443092
** The sqlite3_reset() function is called to reset a [prepared statement]
31453093
** object back to its initial state, ready to be re-executed.
3146
-** Any SQL statement variables that had values bound to them using
3094
+** ^Any SQL statement variables that had values bound to them using
31473095
** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
31483096
** Use [sqlite3_clear_bindings()] to reset the bindings.
31493097
**
3150
-** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
3151
-** back to the beginning of its program.
3152
-**
3153
-** {H11334} If the most recent call to [sqlite3_step(S)] for the
3154
-** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3155
-** or if [sqlite3_step(S)] has never before been called on S,
3156
-** then [sqlite3_reset(S)] returns [SQLITE_OK].
3157
-**
3158
-** {H11336} If the most recent call to [sqlite3_step(S)] for the
3159
-** [prepared statement] S indicated an error, then
3160
-** [sqlite3_reset(S)] returns an appropriate [error code].
3161
-**
3162
-** {H11338} The [sqlite3_reset(S)] interface does not change the values
3163
-** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3098
+** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
3099
+** back to the beginning of its program.
3100
+**
3101
+** ^If the most recent call to [sqlite3_step(S)] for the
3102
+** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3103
+** or if [sqlite3_step(S)] has never before been called on S,
3104
+** then [sqlite3_reset(S)] returns [SQLITE_OK].
3105
+**
3106
+** ^If the most recent call to [sqlite3_step(S)] for the
3107
+** [prepared statement] S indicated an error, then
3108
+** [sqlite3_reset(S)] returns an appropriate [error code].
3109
+**
3110
+** ^The [sqlite3_reset(S)] interface does not change the values
3111
+** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
31643112
*/
31653113
SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
31663114
31673115
/*
3168
-** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
3116
+** CAPI3REF: Create Or Redefine SQL Functions
31693117
** KEYWORDS: {function creation routines}
31703118
** KEYWORDS: {application-defined SQL function}
31713119
** KEYWORDS: {application-defined SQL functions}
31723120
**
3173
-** These two functions (collectively known as "function creation routines")
3121
+** ^These two functions (collectively known as "function creation routines")
31743122
** are used to add SQL functions or aggregates or to redefine the behavior
31753123
** of existing SQL functions or aggregates. The only difference between the
31763124
** two is that the second parameter, the name of the (scalar) function or
31773125
** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
31783126
** for sqlite3_create_function16().
31793127
**
3180
-** The first parameter is the [database connection] to which the SQL
3181
-** function is to be added. If a single program uses more than one database
3182
-** connection internally, then SQL functions must be added individually to
3183
-** each database connection.
3128
+** ^The first parameter is the [database connection] to which the SQL
3129
+** function is to be added. ^If an application uses more than one database
3130
+** connection then application-defined SQL functions must be added
3131
+** to each database connection separately.
31843132
**
31853133
** The second parameter is the name of the SQL function to be created or
3186
-** redefined. The length of the name is limited to 255 bytes, exclusive of
3134
+** redefined. ^The length of the name is limited to 255 bytes, exclusive of
31873135
** the zero-terminator. Note that the name length limit is in bytes, not
3188
-** characters. Any attempt to create a function with a longer name
3136
+** characters. ^Any attempt to create a function with a longer name
31893137
** will result in [SQLITE_ERROR] being returned.
31903138
**
3191
-** The third parameter (nArg)
3139
+** ^The third parameter (nArg)
31923140
** is the number of arguments that the SQL function or
3193
-** aggregate takes. If this parameter is -1, then the SQL function or
3141
+** aggregate takes. ^If this parameter is -1, then the SQL function or
31943142
** aggregate may take any number of arguments between 0 and the limit
31953143
** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
31963144
** parameter is less than -1 or greater than 127 then the behavior is
31973145
** undefined.
31983146
**
31993147
** The fourth parameter, eTextRep, specifies what
32003148
** [SQLITE_UTF8 | text encoding] this SQL function prefers for
32013149
** its parameters. Any SQL function implementation should be able to work
32023150
** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3203
-** more efficient with one encoding than another. An application may
3151
+** more efficient with one encoding than another. ^An application may
32043152
** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
32053153
** times with the same function but with different values of eTextRep.
3206
-** When multiple implementations of the same function are available, SQLite
3154
+** ^When multiple implementations of the same function are available, SQLite
32073155
** will pick the one that involves the least amount of data conversion.
32083156
** If there is only a single implementation which does not care what text
32093157
** encoding is used, then the fourth argument should be [SQLITE_ANY].
32103158
**
3211
-** The fifth parameter is an arbitrary pointer. The implementation of the
3212
-** function can gain access to this pointer using [sqlite3_user_data()].
3159
+** ^(The fifth parameter is an arbitrary pointer. The implementation of the
3160
+** function can gain access to this pointer using [sqlite3_user_data()].)^
32133161
**
32143162
** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
32153163
** pointers to C-language functions that implement the SQL function or
3216
-** aggregate. A scalar SQL function requires an implementation of the xFunc
3217
-** callback only, NULL pointers should be passed as the xStep and xFinal
3218
-** parameters. An aggregate SQL function requires an implementation of xStep
3219
-** and xFinal and NULL should be passed for xFunc. To delete an existing
3164
+** aggregate. ^A scalar SQL function requires an implementation of the xFunc
3165
+** callback only; NULL pointers should be passed as the xStep and xFinal
3166
+** parameters. ^An aggregate SQL function requires an implementation of xStep
3167
+** and xFinal and NULL should be passed for xFunc. ^To delete an existing
32203168
** SQL function or aggregate, pass NULL for all three function callbacks.
32213169
**
3222
-** It is permitted to register multiple implementations of the same
3170
+** ^It is permitted to register multiple implementations of the same
32233171
** functions with the same name but with either differing numbers of
3224
-** arguments or differing preferred text encodings. SQLite will use
3172
+** arguments or differing preferred text encodings. ^SQLite will use
32253173
** the implementation that most closely matches the way in which the
3226
-** SQL function is used. A function implementation with a non-negative
3174
+** SQL function is used. ^A function implementation with a non-negative
32273175
** nArg parameter is a better match than a function implementation with
3228
-** a negative nArg. A function where the preferred text encoding
3176
+** a negative nArg. ^A function where the preferred text encoding
32293177
** matches the database encoding is a better
32303178
** match than a function where the encoding is different.
3231
-** A function where the encoding difference is between UTF16le and UTF16be
3179
+** ^A function where the encoding difference is between UTF16le and UTF16be
32323180
** is a closer match than a function where the encoding difference is
32333181
** between UTF8 and UTF16.
32343182
**
3235
-** Built-in functions may be overloaded by new application-defined functions.
3236
-** The first application-defined function with a given name overrides all
3183
+** ^Built-in functions may be overloaded by new application-defined functions.
3184
+** ^The first application-defined function with a given name overrides all
32373185
** built-in functions in the same [database connection] with the same name.
3238
-** Subsequent application-defined functions of the same name only override
3186
+** ^Subsequent application-defined functions of the same name only override
32393187
** prior application-defined functions that are an exact match for the
32403188
** number of parameters and preferred encoding.
32413189
**
3242
-** An application-defined function is permitted to call other
3190
+** ^An application-defined function is permitted to call other
32433191
** SQLite interfaces. However, such calls must not
32443192
** close the database connection nor finalize or reset the prepared
32453193
** statement in which the function is running.
3246
-**
3247
-** Requirements:
3248
-** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
3249
-** [H16130] [H16133] [H16136] [H16139] [H16142]
32503194
*/
32513195
SQLITE_API int sqlite3_create_function(
32523196
sqlite3 *db,
32533197
const char *zFunctionName,
32543198
int nArg,
@@ -3268,11 +3212,11 @@
32683212
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
32693213
void (*xFinal)(sqlite3_context*)
32703214
);
32713215
32723216
/*
3273
-** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
3217
+** CAPI3REF: Text Encodings
32743218
**
32753219
** These constant define integer codes that represent the various
32763220
** text encodings supported by SQLite.
32773221
*/
32783222
#define SQLITE_UTF8 1
@@ -3300,11 +3244,11 @@
33003244
SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
33013245
SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
33023246
#endif
33033247
33043248
/*
3305
-** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
3249
+** CAPI3REF: Obtaining SQL Function Parameter Values
33063250
**
33073251
** The C-language implementation of SQL functions and aggregates uses
33083252
** this set of interface routines to access the parameter values on
33093253
** the function or aggregate.
33103254
**
@@ -3318,39 +3262,35 @@
33183262
**
33193263
** These routines work only with [protected sqlite3_value] objects.
33203264
** Any attempt to use these routines on an [unprotected sqlite3_value]
33213265
** object results in undefined behavior.
33223266
**
3323
-** These routines work just like the corresponding [column access functions]
3267
+** ^These routines work just like the corresponding [column access functions]
33243268
** except that these routines take a single [protected sqlite3_value] object
33253269
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
33263270
**
3327
-** The sqlite3_value_text16() interface extracts a UTF-16 string
3328
-** in the native byte-order of the host machine. The
3271
+** ^The sqlite3_value_text16() interface extracts a UTF-16 string
3272
+** in the native byte-order of the host machine. ^The
33293273
** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
33303274
** extract UTF-16 strings as big-endian and little-endian respectively.
33313275
**
3332
-** The sqlite3_value_numeric_type() interface attempts to apply
3276
+** ^(The sqlite3_value_numeric_type() interface attempts to apply
33333277
** numeric affinity to the value. This means that an attempt is
33343278
** made to convert the value to an integer or floating point. If
33353279
** such a conversion is possible without loss of information (in other
33363280
** words, if the value is a string that looks like a number)
33373281
** then the conversion is performed. Otherwise no conversion occurs.
3338
-** The [SQLITE_INTEGER | datatype] after conversion is returned.
3282
+** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
33393283
**
33403284
** Please pay particular attention to the fact that the pointer returned
33413285
** from [sqlite3_value_blob()], [sqlite3_value_text()], or
33423286
** [sqlite3_value_text16()] can be invalidated by a subsequent call to
33433287
** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
33443288
** or [sqlite3_value_text16()].
33453289
**
33463290
** These routines must be called from the same thread as
33473291
** the SQL function that supplied the [sqlite3_value*] parameters.
3348
-**
3349
-** Requirements:
3350
-** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
3351
-** [H15127] [H15130] [H15133] [H15136]
33523292
*/
33533293
SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
33543294
SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
33553295
SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
33563296
SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3362,70 +3302,77 @@
33623302
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
33633303
SQLITE_API int sqlite3_value_type(sqlite3_value*);
33643304
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
33653305
33663306
/*
3367
-** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
3368
-**
3369
-** The implementation of aggregate SQL functions use this routine to allocate
3370
-** a structure for storing their state.
3371
-**
3372
-** The first time the sqlite3_aggregate_context() routine is called for a
3373
-** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
3374
-** memory, and returns a pointer to it. On second and subsequent calls to
3375
-** sqlite3_aggregate_context() for the same aggregate function index,
3376
-** the same buffer is returned. The implementation of the aggregate can use
3377
-** the returned buffer to accumulate data.
3378
-**
3379
-** SQLite automatically frees the allocated buffer when the aggregate
3380
-** query concludes.
3381
-**
3382
-** The first parameter should be a copy of the
3307
+** CAPI3REF: Obtain Aggregate Function Context
3308
+**
3309
+** Implementions of aggregate SQL functions use this
3310
+** routine to allocate memory for storing their state.
3311
+**
3312
+** ^The first time the sqlite3_aggregate_context(C,N) routine is called
3313
+** for a particular aggregate function, SQLite
3314
+** allocates N of memory, zeroes out that memory, and returns a pointer
3315
+** to the new memory. ^On second and subsequent calls to
3316
+** sqlite3_aggregate_context() for the same aggregate function instance,
3317
+** the same buffer is returned. Sqlite3_aggregate_context() is normally
3318
+** called once for each invocation of the xStep callback and then one
3319
+** last time when the xFinal callback is invoked. ^(When no rows match
3320
+** an aggregate query, the xStep() callback of the aggregate function
3321
+** implementation is never called and xFinal() is called exactly once.
3322
+** In those cases, sqlite3_aggregate_context() might be called for the
3323
+** first time from within xFinal().)^
3324
+**
3325
+** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
3326
+** less than or equal to zero or if a memory allocate error occurs.
3327
+**
3328
+** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
3329
+** determined by the N parameter on first successful call. Changing the
3330
+** value of N in subsequent call to sqlite3_aggregate_context() within
3331
+** the same aggregate function instance will not resize the memory
3332
+** allocation.)^
3333
+**
3334
+** ^SQLite automatically frees the memory allocated by
3335
+** sqlite3_aggregate_context() when the aggregate query concludes.
3336
+**
3337
+** The first parameter must be a copy of the
33833338
** [sqlite3_context | SQL function context] that is the first parameter
3384
-** to the callback routine that implements the aggregate function.
3339
+** to the xStep or xFinal callback routine that implements the aggregate
3340
+** function.
33853341
**
33863342
** This routine must be called from the same thread in which
33873343
** the aggregate SQL function is running.
3388
-**
3389
-** Requirements:
3390
-** [H16211] [H16213] [H16215] [H16217]
33913344
*/
33923345
SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
33933346
33943347
/*
3395
-** CAPI3REF: User Data For Functions {H16240} <S20200>
3348
+** CAPI3REF: User Data For Functions
33963349
**
3397
-** The sqlite3_user_data() interface returns a copy of
3350
+** ^The sqlite3_user_data() interface returns a copy of
33983351
** the pointer that was the pUserData parameter (the 5th parameter)
33993352
** of the [sqlite3_create_function()]
34003353
** and [sqlite3_create_function16()] routines that originally
3401
-** registered the application defined function. {END}
3354
+** registered the application defined function.
34023355
**
34033356
** This routine must be called from the same thread in which
34043357
** the application-defined function is running.
3405
-**
3406
-** Requirements:
3407
-** [H16243]
34083358
*/
34093359
SQLITE_API void *sqlite3_user_data(sqlite3_context*);
34103360
34113361
/*
3412
-** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
3362
+** CAPI3REF: Database Connection For Functions
34133363
**
3414
-** The sqlite3_context_db_handle() interface returns a copy of
3364
+** ^The sqlite3_context_db_handle() interface returns a copy of
34153365
** the pointer to the [database connection] (the 1st parameter)
34163366
** of the [sqlite3_create_function()]
34173367
** and [sqlite3_create_function16()] routines that originally
34183368
** registered the application defined function.
3419
-**
3420
-** Requirements:
3421
-** [H16253]
34223369
*/
34233370
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
34243371
34253372
/*
3426
-** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
3373
+** CAPI3REF: Function Auxiliary Data
34273374
**
34283375
** The following two functions may be used by scalar SQL functions to
34293376
** associate metadata with argument values. If the same value is passed to
34303377
** multiple invocations of the same SQL function during query execution, under
34313378
** some circumstances the associated metadata may be preserved. This may
@@ -3434,52 +3381,49 @@
34343381
** metadata associated with the SQL value passed as the regular expression
34353382
** pattern. The compiled regular expression can be reused on multiple
34363383
** invocations of the same function so that the original pattern string
34373384
** does not need to be recompiled on each invocation.
34383385
**
3439
-** The sqlite3_get_auxdata() interface returns a pointer to the metadata
3386
+** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
34403387
** associated by the sqlite3_set_auxdata() function with the Nth argument
3441
-** value to the application-defined function. If no metadata has been ever
3388
+** value to the application-defined function. ^If no metadata has been ever
34423389
** been set for the Nth argument of the function, or if the corresponding
34433390
** function parameter has changed since the meta-data was set,
34443391
** then sqlite3_get_auxdata() returns a NULL pointer.
34453392
**
3446
-** The sqlite3_set_auxdata() interface saves the metadata
3393
+** ^The sqlite3_set_auxdata() interface saves the metadata
34473394
** pointed to by its 3rd parameter as the metadata for the N-th
34483395
** argument of the application-defined function. Subsequent
34493396
** calls to sqlite3_get_auxdata() might return this data, if it has
34503397
** not been destroyed.
3451
-** If it is not NULL, SQLite will invoke the destructor
3398
+** ^If it is not NULL, SQLite will invoke the destructor
34523399
** function given by the 4th parameter to sqlite3_set_auxdata() on
34533400
** the metadata when the corresponding function parameter changes
34543401
** or when the SQL statement completes, whichever comes first.
34553402
**
34563403
** SQLite is free to call the destructor and drop metadata on any
3457
-** parameter of any function at any time. The only guarantee is that
3404
+** parameter of any function at any time. ^The only guarantee is that
34583405
** the destructor will be called before the metadata is dropped.
34593406
**
3460
-** In practice, metadata is preserved between function calls for
3407
+** ^(In practice, metadata is preserved between function calls for
34613408
** expressions that are constant at compile time. This includes literal
3462
-** values and SQL variables.
3409
+** values and [parameters].)^
34633410
**
34643411
** These routines must be called from the same thread in which
34653412
** the SQL function is running.
3466
-**
3467
-** Requirements:
3468
-** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
34693413
*/
34703414
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
34713415
SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
34723416
34733417
34743418
/*
3475
-** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
3419
+** CAPI3REF: Constants Defining Special Destructor Behavior
34763420
**
34773421
** These are special values for the destructor that is passed in as the
3478
-** final argument to routines like [sqlite3_result_blob()]. If the destructor
3422
+** final argument to routines like [sqlite3_result_blob()]. ^If the destructor
34793423
** argument is SQLITE_STATIC, it means that the content pointer is constant
3480
-** and will never change. It does not need to be destroyed. The
3424
+** and will never change. It does not need to be destroyed. ^The
34813425
** SQLITE_TRANSIENT value means that the content will likely change in
34823426
** the near future and that SQLite should make its own private copy of
34833427
** the content before returning.
34843428
**
34853429
** The typedef is necessary to work around problems in certain
@@ -3488,11 +3432,11 @@
34883432
typedef void (*sqlite3_destructor_type)(void*);
34893433
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
34903434
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
34913435
34923436
/*
3493
-** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
3437
+** CAPI3REF: Setting The Result Of An SQL Function
34943438
**
34953439
** These routines are used by the xFunc or xFinal callbacks that
34963440
** implement SQL functions and aggregates. See
34973441
** [sqlite3_create_function()] and [sqlite3_create_function16()]
34983442
** for additional information.
@@ -3499,107 +3443,102 @@
34993443
**
35003444
** These functions work very much like the [parameter binding] family of
35013445
** functions used to bind values to host parameters in prepared statements.
35023446
** Refer to the [SQL parameter] documentation for additional information.
35033447
**
3504
-** The sqlite3_result_blob() interface sets the result from
3448
+** ^The sqlite3_result_blob() interface sets the result from
35053449
** an application-defined function to be the BLOB whose content is pointed
35063450
** to by the second parameter and which is N bytes long where N is the
35073451
** third parameter.
35083452
**
3509
-** The sqlite3_result_zeroblob() interfaces set the result of
3453
+** ^The sqlite3_result_zeroblob() interfaces set the result of
35103454
** the application-defined function to be a BLOB containing all zero
35113455
** bytes and N bytes in size, where N is the value of the 2nd parameter.
35123456
**
3513
-** The sqlite3_result_double() interface sets the result from
3457
+** ^The sqlite3_result_double() interface sets the result from
35143458
** an application-defined function to be a floating point value specified
35153459
** by its 2nd argument.
35163460
**
3517
-** The sqlite3_result_error() and sqlite3_result_error16() functions
3461
+** ^The sqlite3_result_error() and sqlite3_result_error16() functions
35183462
** cause the implemented SQL function to throw an exception.
3519
-** SQLite uses the string pointed to by the
3463
+** ^SQLite uses the string pointed to by the
35203464
** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
3521
-** as the text of an error message. SQLite interprets the error
3522
-** message string from sqlite3_result_error() as UTF-8. SQLite
3465
+** as the text of an error message. ^SQLite interprets the error
3466
+** message string from sqlite3_result_error() as UTF-8. ^SQLite
35233467
** interprets the string from sqlite3_result_error16() as UTF-16 in native
3524
-** byte order. If the third parameter to sqlite3_result_error()
3468
+** byte order. ^If the third parameter to sqlite3_result_error()
35253469
** or sqlite3_result_error16() is negative then SQLite takes as the error
35263470
** message all text up through the first zero character.
3527
-** If the third parameter to sqlite3_result_error() or
3471
+** ^If the third parameter to sqlite3_result_error() or
35283472
** sqlite3_result_error16() is non-negative then SQLite takes that many
35293473
** bytes (not characters) from the 2nd parameter as the error message.
3530
-** The sqlite3_result_error() and sqlite3_result_error16()
3474
+** ^The sqlite3_result_error() and sqlite3_result_error16()
35313475
** routines make a private copy of the error message text before
35323476
** they return. Hence, the calling function can deallocate or
35333477
** modify the text after they return without harm.
3534
-** The sqlite3_result_error_code() function changes the error code
3535
-** returned by SQLite as a result of an error in a function. By default,
3536
-** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error()
3478
+** ^The sqlite3_result_error_code() function changes the error code
3479
+** returned by SQLite as a result of an error in a function. ^By default,
3480
+** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
35373481
** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
35383482
**
3539
-** The sqlite3_result_toobig() interface causes SQLite to throw an error
3540
-** indicating that a string or BLOB is to long to represent.
3483
+** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
3484
+** indicating that a string or BLOB is too long to represent.
35413485
**
3542
-** The sqlite3_result_nomem() interface causes SQLite to throw an error
3486
+** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
35433487
** indicating that a memory allocation failed.
35443488
**
3545
-** The sqlite3_result_int() interface sets the return value
3489
+** ^The sqlite3_result_int() interface sets the return value
35463490
** of the application-defined function to be the 32-bit signed integer
35473491
** value given in the 2nd argument.
3548
-** The sqlite3_result_int64() interface sets the return value
3492
+** ^The sqlite3_result_int64() interface sets the return value
35493493
** of the application-defined function to be the 64-bit signed integer
35503494
** value given in the 2nd argument.
35513495
**
3552
-** The sqlite3_result_null() interface sets the return value
3496
+** ^The sqlite3_result_null() interface sets the return value
35533497
** of the application-defined function to be NULL.
35543498
**
3555
-** The sqlite3_result_text(), sqlite3_result_text16(),
3499
+** ^The sqlite3_result_text(), sqlite3_result_text16(),
35563500
** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
35573501
** set the return value of the application-defined function to be
35583502
** a text string which is represented as UTF-8, UTF-16 native byte order,
35593503
** UTF-16 little endian, or UTF-16 big endian, respectively.
3560
-** SQLite takes the text result from the application from
3504
+** ^SQLite takes the text result from the application from
35613505
** the 2nd parameter of the sqlite3_result_text* interfaces.
3562
-** If the 3rd parameter to the sqlite3_result_text* interfaces
3506
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
35633507
** is negative, then SQLite takes result text from the 2nd parameter
35643508
** through the first zero character.
3565
-** If the 3rd parameter to the sqlite3_result_text* interfaces
3509
+** ^If the 3rd parameter to the sqlite3_result_text* interfaces
35663510
** is non-negative, then as many bytes (not characters) of the text
35673511
** pointed to by the 2nd parameter are taken as the application-defined
35683512
** function result.
3569
-** If the 4th parameter to the sqlite3_result_text* interfaces
3513
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
35703514
** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
35713515
** function as the destructor on the text or BLOB result when it has
35723516
** finished using that result.
3573
-** If the 4th parameter to the sqlite3_result_text* interfaces or to
3517
+** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
35743518
** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
35753519
** assumes that the text or BLOB result is in constant space and does not
35763520
** copy the content of the parameter nor call a destructor on the content
35773521
** when it has finished using that result.
3578
-** If the 4th parameter to the sqlite3_result_text* interfaces
3522
+** ^If the 4th parameter to the sqlite3_result_text* interfaces
35793523
** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
35803524
** then SQLite makes a copy of the result into space obtained from
35813525
** from [sqlite3_malloc()] before it returns.
35823526
**
3583
-** The sqlite3_result_value() interface sets the result of
3527
+** ^The sqlite3_result_value() interface sets the result of
35843528
** the application-defined function to be a copy the
3585
-** [unprotected sqlite3_value] object specified by the 2nd parameter. The
3529
+** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
35863530
** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
35873531
** so that the [sqlite3_value] specified in the parameter may change or
35883532
** be deallocated after sqlite3_result_value() returns without harm.
3589
-** A [protected sqlite3_value] object may always be used where an
3533
+** ^A [protected sqlite3_value] object may always be used where an
35903534
** [unprotected sqlite3_value] object is required, so either
35913535
** kind of [sqlite3_value] object can be used with this interface.
35923536
**
35933537
** If these routines are called from within the different thread
35943538
** than the one containing the application-defined function that received
35953539
** the [sqlite3_context] pointer, the results are undefined.
3596
-**
3597
-** Requirements:
3598
-** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
3599
-** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
3600
-** [H16451] [H16454] [H16457] [H16460] [H16463]
36013540
*/
36023541
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
36033542
SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
36043543
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
36053544
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -3615,58 +3554,54 @@
36153554
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
36163555
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
36173556
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
36183557
36193558
/*
3620
-** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
3559
+** CAPI3REF: Define New Collating Sequences
36213560
**
36223561
** These functions are used to add new collation sequences to the
36233562
** [database connection] specified as the first argument.
36243563
**
3625
-** The name of the new collation sequence is specified as a UTF-8 string
3564
+** ^The name of the new collation sequence is specified as a UTF-8 string
36263565
** for sqlite3_create_collation() and sqlite3_create_collation_v2()
3627
-** and a UTF-16 string for sqlite3_create_collation16(). In all cases
3566
+** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
36283567
** the name is passed as the second function argument.
36293568
**
3630
-** The third argument may be one of the constants [SQLITE_UTF8],
3569
+** ^The third argument may be one of the constants [SQLITE_UTF8],
36313570
** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
36323571
** routine expects to be passed pointers to strings encoded using UTF-8,
3633
-** UTF-16 little-endian, or UTF-16 big-endian, respectively. The
3572
+** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
36343573
** third argument might also be [SQLITE_UTF16] to indicate that the routine
36353574
** expects pointers to be UTF-16 strings in the native byte order, or the
36363575
** argument can be [SQLITE_UTF16_ALIGNED] if the
36373576
** the routine expects pointers to 16-bit word aligned strings
36383577
** of UTF-16 in the native byte order.
36393578
**
36403579
** A pointer to the user supplied routine must be passed as the fifth
3641
-** argument. If it is NULL, this is the same as deleting the collation
3580
+** argument. ^If it is NULL, this is the same as deleting the collation
36423581
** sequence (so that SQLite cannot call it anymore).
3643
-** Each time the application supplied function is invoked, it is passed
3582
+** ^Each time the application supplied function is invoked, it is passed
36443583
** as its first parameter a copy of the void* passed as the fourth argument
36453584
** to sqlite3_create_collation() or sqlite3_create_collation16().
36463585
**
3647
-** The remaining arguments to the application-supplied routine are two strings,
3586
+** ^The remaining arguments to the application-supplied routine are two strings,
36483587
** each represented by a (length, data) pair and encoded in the encoding
36493588
** that was passed as the third argument when the collation sequence was
3650
-** registered. {END} The application defined collation routine should
3589
+** registered. The application defined collation routine should
36513590
** return negative, zero or positive if the first string is less than,
36523591
** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
36533592
**
3654
-** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
3593
+** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
36553594
** except that it takes an extra argument which is a destructor for
3656
-** the collation. The destructor is called when the collation is
3595
+** the collation. ^The destructor is called when the collation is
36573596
** destroyed and is passed a copy of the fourth parameter void* pointer
36583597
** of the sqlite3_create_collation_v2().
3659
-** Collations are destroyed when they are overridden by later calls to the
3598
+** ^Collations are destroyed when they are overridden by later calls to the
36603599
** collation creation functions or when the [database connection] is closed
36613600
** using [sqlite3_close()].
36623601
**
36633602
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
3664
-**
3665
-** Requirements:
3666
-** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
3667
-** [H16624] [H16627] [H16630]
36683603
*/
36693604
SQLITE_API int sqlite3_create_collation(
36703605
sqlite3*,
36713606
const char *zName,
36723607
int eTextRep,
@@ -3688,37 +3623,34 @@
36883623
void*,
36893624
int(*xCompare)(void*,int,const void*,int,const void*)
36903625
);
36913626
36923627
/*
3693
-** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
3628
+** CAPI3REF: Collation Needed Callbacks
36943629
**
3695
-** To avoid having to register all collation sequences before a database
3630
+** ^To avoid having to register all collation sequences before a database
36963631
** can be used, a single callback function may be registered with the
3697
-** [database connection] to be called whenever an undefined collation
3632
+** [database connection] to be invoked whenever an undefined collation
36983633
** sequence is required.
36993634
**
3700
-** If the function is registered using the sqlite3_collation_needed() API,
3635
+** ^If the function is registered using the sqlite3_collation_needed() API,
37013636
** then it is passed the names of undefined collation sequences as strings
3702
-** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
3637
+** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
37033638
** the names are passed as UTF-16 in machine native byte order.
3704
-** A call to either function replaces any existing callback.
3639
+** ^A call to either function replaces the existing collation-needed callback.
37053640
**
3706
-** When the callback is invoked, the first argument passed is a copy
3641
+** ^(When the callback is invoked, the first argument passed is a copy
37073642
** of the second argument to sqlite3_collation_needed() or
37083643
** sqlite3_collation_needed16(). The second argument is the database
37093644
** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
37103645
** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
37113646
** sequence function required. The fourth parameter is the name of the
3712
-** required collation sequence.
3647
+** required collation sequence.)^
37133648
**
37143649
** The callback function should register the desired collation using
37153650
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
37163651
** [sqlite3_create_collation_v2()].
3717
-**
3718
-** Requirements:
3719
-** [H16702] [H16704] [H16706]
37203652
*/
37213653
SQLITE_API int sqlite3_collation_needed(
37223654
sqlite3*,
37233655
void*,
37243656
void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -3753,33 +3685,32 @@
37533685
sqlite3 *db, /* Database to be rekeyed */
37543686
const void *pKey, int nKey /* The new key */
37553687
);
37563688
37573689
/*
3758
-** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
3690
+** CAPI3REF: Suspend Execution For A Short Time
37593691
**
3760
-** The sqlite3_sleep() function causes the current thread to suspend execution
3692
+** ^The sqlite3_sleep() function causes the current thread to suspend execution
37613693
** for at least a number of milliseconds specified in its parameter.
37623694
**
3763
-** If the operating system does not support sleep requests with
3695
+** ^If the operating system does not support sleep requests with
37643696
** millisecond time resolution, then the time will be rounded up to
3765
-** the nearest second. The number of milliseconds of sleep actually
3697
+** the nearest second. ^The number of milliseconds of sleep actually
37663698
** requested from the operating system is returned.
37673699
**
3768
-** SQLite implements this interface by calling the xSleep()
3700
+** ^SQLite implements this interface by calling the xSleep()
37693701
** method of the default [sqlite3_vfs] object.
3770
-**
3771
-** Requirements: [H10533] [H10536]
37723702
*/
37733703
SQLITE_API int sqlite3_sleep(int);
37743704
37753705
/*
3776
-** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
3706
+** CAPI3REF: Name Of The Folder Holding Temporary Files
37773707
**
3778
-** If this global variable is made to point to a string which is
3708
+** ^(If this global variable is made to point to a string which is
37793709
** the name of a folder (a.k.a. directory), then all temporary files
3780
-** created by SQLite will be placed in that directory. If this variable
3710
+** created by SQLite when using a built-in [sqlite3_vfs | VFS]
3711
+** will be placed in that directory.)^ ^If this variable
37813712
** is a NULL pointer, then SQLite performs a search for an appropriate
37823713
** temporary file directory.
37833714
**
37843715
** It is not safe to read or modify this variable in more than one
37853716
** thread at a time. It is not safe to read or modify this variable
@@ -3788,12 +3719,12 @@
37883719
** It is intended that this variable be set once
37893720
** as part of process initialization and before any SQLite interface
37903721
** routines have been called and that this variable remain unchanged
37913722
** thereafter.
37923723
**
3793
-** The [temp_store_directory pragma] may modify this variable and cause
3794
-** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
3724
+** ^The [temp_store_directory pragma] may modify this variable and cause
3725
+** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
37953726
** the [temp_store_directory pragma] always assumes that any string
37963727
** that this variable points to is held in memory obtained from
37973728
** [sqlite3_malloc] and the pragma may attempt to free that memory
37983729
** using [sqlite3_free].
37993730
** Hence, if this variable is modified directly, either it should be
@@ -3801,18 +3732,18 @@
38013732
** or else the use of the [temp_store_directory pragma] should be avoided.
38023733
*/
38033734
SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
38043735
38053736
/*
3806
-** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
3737
+** CAPI3REF: Test For Auto-Commit Mode
38073738
** KEYWORDS: {autocommit mode}
38083739
**
3809
-** The sqlite3_get_autocommit() interface returns non-zero or
3740
+** ^The sqlite3_get_autocommit() interface returns non-zero or
38103741
** zero if the given database connection is or is not in autocommit mode,
3811
-** respectively. Autocommit mode is on by default.
3812
-** Autocommit mode is disabled by a [BEGIN] statement.
3813
-** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
3742
+** respectively. ^Autocommit mode is on by default.
3743
+** ^Autocommit mode is disabled by a [BEGIN] statement.
3744
+** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
38143745
**
38153746
** If certain kinds of errors occur on a statement within a multi-statement
38163747
** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
38173748
** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
38183749
** transaction might be rolled back automatically. The only way to
@@ -3820,124 +3751,116 @@
38203751
** an error is to use this function.
38213752
**
38223753
** If another thread changes the autocommit status of the database
38233754
** connection while this routine is running, then the return value
38243755
** is undefined.
3825
-**
3826
-** Requirements: [H12931] [H12932] [H12933] [H12934]
38273756
*/
38283757
SQLITE_API int sqlite3_get_autocommit(sqlite3*);
38293758
38303759
/*
3831
-** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
3760
+** CAPI3REF: Find The Database Handle Of A Prepared Statement
38323761
**
3833
-** The sqlite3_db_handle interface returns the [database connection] handle
3834
-** to which a [prepared statement] belongs. The [database connection]
3835
-** returned by sqlite3_db_handle is the same [database connection] that was the first argument
3762
+** ^The sqlite3_db_handle interface returns the [database connection] handle
3763
+** to which a [prepared statement] belongs. ^The [database connection]
3764
+** returned by sqlite3_db_handle is the same [database connection]
3765
+** that was the first argument
38363766
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
38373767
** create the statement in the first place.
3838
-**
3839
-** Requirements: [H13123]
38403768
*/
38413769
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
38423770
38433771
/*
3844
-** CAPI3REF: Find the next prepared statement {H13140} <S60600>
3772
+** CAPI3REF: Find the next prepared statement
38453773
**
3846
-** This interface returns a pointer to the next [prepared statement] after
3847
-** pStmt associated with the [database connection] pDb. If pStmt is NULL
3774
+** ^This interface returns a pointer to the next [prepared statement] after
3775
+** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
38483776
** then this interface returns a pointer to the first prepared statement
3849
-** associated with the database connection pDb. If no prepared statement
3777
+** associated with the database connection pDb. ^If no prepared statement
38503778
** satisfies the conditions of this routine, it returns NULL.
38513779
**
38523780
** The [database connection] pointer D in a call to
38533781
** [sqlite3_next_stmt(D,S)] must refer to an open database
38543782
** connection and in particular must not be a NULL pointer.
3855
-**
3856
-** Requirements: [H13143] [H13146] [H13149] [H13152]
38573783
*/
38583784
SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
38593785
38603786
/*
3861
-** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
3787
+** CAPI3REF: Commit And Rollback Notification Callbacks
38623788
**
3863
-** The sqlite3_commit_hook() interface registers a callback
3789
+** ^The sqlite3_commit_hook() interface registers a callback
38643790
** function to be invoked whenever a transaction is [COMMIT | committed].
3865
-** Any callback set by a previous call to sqlite3_commit_hook()
3791
+** ^Any callback set by a previous call to sqlite3_commit_hook()
38663792
** for the same database connection is overridden.
3867
-** The sqlite3_rollback_hook() interface registers a callback
3793
+** ^The sqlite3_rollback_hook() interface registers a callback
38683794
** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
3869
-** Any callback set by a previous call to sqlite3_commit_hook()
3795
+** ^Any callback set by a previous call to sqlite3_rollback_hook()
38703796
** for the same database connection is overridden.
3871
-** The pArg argument is passed through to the callback.
3872
-** If the callback on a commit hook function returns non-zero,
3797
+** ^The pArg argument is passed through to the callback.
3798
+** ^If the callback on a commit hook function returns non-zero,
38733799
** then the commit is converted into a rollback.
38743800
**
3875
-** If another function was previously registered, its
3876
-** pArg value is returned. Otherwise NULL is returned.
3801
+** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
3802
+** return the P argument from the previous call of the same function
3803
+** on the same [database connection] D, or NULL for
3804
+** the first call for each function on D.
38773805
**
38783806
** The callback implementation must not do anything that will modify
38793807
** the database connection that invoked the callback. Any actions
38803808
** to modify the database connection must be deferred until after the
38813809
** completion of the [sqlite3_step()] call that triggered the commit
38823810
** or rollback hook in the first place.
38833811
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
38843812
** database connections for the meaning of "modify" in this paragraph.
38853813
**
3886
-** Registering a NULL function disables the callback.
3814
+** ^Registering a NULL function disables the callback.
38873815
**
3888
-** When the commit hook callback routine returns zero, the [COMMIT]
3889
-** operation is allowed to continue normally. If the commit hook
3816
+** ^When the commit hook callback routine returns zero, the [COMMIT]
3817
+** operation is allowed to continue normally. ^If the commit hook
38903818
** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
3891
-** The rollback hook is invoked on a rollback that results from a commit
3819
+** ^The rollback hook is invoked on a rollback that results from a commit
38923820
** hook returning non-zero, just as it would be with any other rollback.
38933821
**
3894
-** For the purposes of this API, a transaction is said to have been
3822
+** ^For the purposes of this API, a transaction is said to have been
38953823
** rolled back if an explicit "ROLLBACK" statement is executed, or
38963824
** an error or constraint causes an implicit rollback to occur.
3897
-** The rollback callback is not invoked if a transaction is
3825
+** ^The rollback callback is not invoked if a transaction is
38983826
** automatically rolled back because the database connection is closed.
3899
-** The rollback callback is not invoked if a transaction is
3827
+** ^The rollback callback is not invoked if a transaction is
39003828
** rolled back because a commit callback returned non-zero.
3901
-** <todo> Check on this </todo>
39023829
**
39033830
** See also the [sqlite3_update_hook()] interface.
3904
-**
3905
-** Requirements:
3906
-** [H12951] [H12952] [H12953] [H12954] [H12955]
3907
-** [H12961] [H12962] [H12963] [H12964]
39083831
*/
39093832
SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
39103833
SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
39113834
39123835
/*
3913
-** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
3836
+** CAPI3REF: Data Change Notification Callbacks
39143837
**
3915
-** The sqlite3_update_hook() interface registers a callback function
3838
+** ^The sqlite3_update_hook() interface registers a callback function
39163839
** with the [database connection] identified by the first argument
39173840
** to be invoked whenever a row is updated, inserted or deleted.
3918
-** Any callback set by a previous call to this function
3841
+** ^Any callback set by a previous call to this function
39193842
** for the same database connection is overridden.
39203843
**
3921
-** The second argument is a pointer to the function to invoke when a
3844
+** ^The second argument is a pointer to the function to invoke when a
39223845
** row is updated, inserted or deleted.
3923
-** The first argument to the callback is a copy of the third argument
3846
+** ^The first argument to the callback is a copy of the third argument
39243847
** to sqlite3_update_hook().
3925
-** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
3848
+** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
39263849
** or [SQLITE_UPDATE], depending on the operation that caused the callback
39273850
** to be invoked.
3928
-** The third and fourth arguments to the callback contain pointers to the
3851
+** ^The third and fourth arguments to the callback contain pointers to the
39293852
** database and table name containing the affected row.
3930
-** The final callback parameter is the [rowid] of the row.
3931
-** In the case of an update, this is the [rowid] after the update takes place.
3853
+** ^The final callback parameter is the [rowid] of the row.
3854
+** ^In the case of an update, this is the [rowid] after the update takes place.
39323855
**
3933
-** The update hook is not invoked when internal system tables are
3934
-** modified (i.e. sqlite_master and sqlite_sequence).
3856
+** ^(The update hook is not invoked when internal system tables are
3857
+** modified (i.e. sqlite_master and sqlite_sequence).)^
39353858
**
3936
-** In the current implementation, the update hook
3859
+** ^In the current implementation, the update hook
39373860
** is not invoked when duplication rows are deleted because of an
3938
-** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook
3861
+** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
39393862
** invoked when rows are deleted using the [truncate optimization].
39403863
** The exceptions defined in this paragraph might change in a future
39413864
** release of SQLite.
39423865
**
39433866
** The update hook implementation must not do anything that will modify
@@ -3945,169 +3868,157 @@
39453868
** to modify the database connection must be deferred until after the
39463869
** completion of the [sqlite3_step()] call that triggered the update hook.
39473870
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
39483871
** database connections for the meaning of "modify" in this paragraph.
39493872
**
3950
-** If another function was previously registered, its pArg value
3951
-** is returned. Otherwise NULL is returned.
3873
+** ^The sqlite3_update_hook(D,C,P) function
3874
+** returns the P argument from the previous call
3875
+** on the same [database connection] D, or NULL for
3876
+** the first call on D.
39523877
**
39533878
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
39543879
** interfaces.
3955
-**
3956
-** Requirements:
3957
-** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
39583880
*/
39593881
SQLITE_API void *sqlite3_update_hook(
39603882
sqlite3*,
39613883
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
39623884
void*
39633885
);
39643886
39653887
/*
3966
-** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
3888
+** CAPI3REF: Enable Or Disable Shared Pager Cache
39673889
** KEYWORDS: {shared cache}
39683890
**
3969
-** This routine enables or disables the sharing of the database cache
3891
+** ^(This routine enables or disables the sharing of the database cache
39703892
** and schema data structures between [database connection | connections]
39713893
** to the same database. Sharing is enabled if the argument is true
3972
-** and disabled if the argument is false.
3894
+** and disabled if the argument is false.)^
39733895
**
3974
-** Cache sharing is enabled and disabled for an entire process.
3896
+** ^Cache sharing is enabled and disabled for an entire process.
39753897
** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
39763898
** sharing was enabled or disabled for each thread separately.
39773899
**
3978
-** The cache sharing mode set by this interface effects all subsequent
3900
+** ^(The cache sharing mode set by this interface effects all subsequent
39793901
** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
39803902
** Existing database connections continue use the sharing mode
3981
-** that was in effect at the time they were opened.
3982
-**
3983
-** Virtual tables cannot be used with a shared cache. When shared
3984
-** cache is enabled, the [sqlite3_create_module()] API used to register
3985
-** virtual tables will always return an error.
3986
-**
3987
-** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
3988
-** successfully. An [error code] is returned otherwise.
3989
-**
3990
-** Shared cache is disabled by default. But this might change in
3903
+** that was in effect at the time they were opened.)^
3904
+**
3905
+** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
3906
+** successfully. An [error code] is returned otherwise.)^
3907
+**
3908
+** ^Shared cache is disabled by default. But this might change in
39913909
** future releases of SQLite. Applications that care about shared
39923910
** cache setting should set it explicitly.
39933911
**
39943912
** See Also: [SQLite Shared-Cache Mode]
3995
-**
3996
-** Requirements: [H10331] [H10336] [H10337] [H10339]
39973913
*/
39983914
SQLITE_API int sqlite3_enable_shared_cache(int);
39993915
40003916
/*
4001
-** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
3917
+** CAPI3REF: Attempt To Free Heap Memory
40023918
**
4003
-** The sqlite3_release_memory() interface attempts to free N bytes
3919
+** ^The sqlite3_release_memory() interface attempts to free N bytes
40043920
** of heap memory by deallocating non-essential memory allocations
4005
-** held by the database library. {END} Memory used to cache database
3921
+** held by the database library. Memory used to cache database
40063922
** pages to improve performance is an example of non-essential memory.
4007
-** sqlite3_release_memory() returns the number of bytes actually freed,
3923
+** ^sqlite3_release_memory() returns the number of bytes actually freed,
40083924
** which might be more or less than the amount requested.
4009
-**
4010
-** Requirements: [H17341] [H17342]
40113925
*/
40123926
SQLITE_API int sqlite3_release_memory(int);
40133927
40143928
/*
4015
-** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
3929
+** CAPI3REF: Impose A Limit On Heap Size
40163930
**
4017
-** The sqlite3_soft_heap_limit() interface places a "soft" limit
3931
+** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
40183932
** on the amount of heap memory that may be allocated by SQLite.
4019
-** If an internal allocation is requested that would exceed the
3933
+** ^If an internal allocation is requested that would exceed the
40203934
** soft heap limit, [sqlite3_release_memory()] is invoked one or
40213935
** more times to free up some space before the allocation is performed.
40223936
**
4023
-** The limit is called "soft", because if [sqlite3_release_memory()]
3937
+** ^The limit is called "soft" because if [sqlite3_release_memory()]
40243938
** cannot free sufficient memory to prevent the limit from being exceeded,
40253939
** the memory is allocated anyway and the current operation proceeds.
40263940
**
4027
-** A negative or zero value for N means that there is no soft heap limit and
3941
+** ^A negative or zero value for N means that there is no soft heap limit and
40283942
** [sqlite3_release_memory()] will only be called when memory is exhausted.
4029
-** The default value for the soft heap limit is zero.
3943
+** ^The default value for the soft heap limit is zero.
40303944
**
4031
-** SQLite makes a best effort to honor the soft heap limit.
3945
+** ^(SQLite makes a best effort to honor the soft heap limit.
40323946
** But if the soft heap limit cannot be honored, execution will
4033
-** continue without error or notification. This is why the limit is
3947
+** continue without error or notification.)^ This is why the limit is
40343948
** called a "soft" limit. It is advisory only.
40353949
**
40363950
** Prior to SQLite version 3.5.0, this routine only constrained the memory
40373951
** allocated by a single thread - the same thread in which this routine
40383952
** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
40393953
** applied to all threads. The value specified for the soft heap limit
40403954
** is an upper bound on the total memory allocation for all threads. In
40413955
** version 3.5.0 there is no mechanism for limiting the heap usage for
40423956
** individual threads.
4043
-**
4044
-** Requirements:
4045
-** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
40463957
*/
40473958
SQLITE_API void sqlite3_soft_heap_limit(int);
40483959
40493960
/*
4050
-** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
3961
+** CAPI3REF: Extract Metadata About A Column Of A Table
40513962
**
4052
-** This routine returns metadata about a specific column of a specific
3963
+** ^This routine returns metadata about a specific column of a specific
40533964
** database table accessible using the [database connection] handle
40543965
** passed as the first function argument.
40553966
**
4056
-** The column is identified by the second, third and fourth parameters to
4057
-** this function. The second parameter is either the name of the database
4058
-** (i.e. "main", "temp" or an attached database) containing the specified
4059
-** table or NULL. If it is NULL, then all attached databases are searched
3967
+** ^The column is identified by the second, third and fourth parameters to
3968
+** this function. ^The second parameter is either the name of the database
3969
+** (i.e. "main", "temp", or an attached database) containing the specified
3970
+** table or NULL. ^If it is NULL, then all attached databases are searched
40603971
** for the table using the same algorithm used by the database engine to
40613972
** resolve unqualified table references.
40623973
**
4063
-** The third and fourth parameters to this function are the table and column
3974
+** ^The third and fourth parameters to this function are the table and column
40643975
** name of the desired column, respectively. Neither of these parameters
40653976
** may be NULL.
40663977
**
4067
-** Metadata is returned by writing to the memory locations passed as the 5th
4068
-** and subsequent parameters to this function. Any of these arguments may be
3978
+** ^Metadata is returned by writing to the memory locations passed as the 5th
3979
+** and subsequent parameters to this function. ^Any of these arguments may be
40693980
** NULL, in which case the corresponding element of metadata is omitted.
40703981
**
4071
-** <blockquote>
3982
+** ^(<blockquote>
40723983
** <table border="1">
40733984
** <tr><th> Parameter <th> Output<br>Type <th> Description
40743985
**
40753986
** <tr><td> 5th <td> const char* <td> Data type
40763987
** <tr><td> 6th <td> const char* <td> Name of default collation sequence
40773988
** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
40783989
** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
40793990
** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
40803991
** </table>
4081
-** </blockquote>
3992
+** </blockquote>)^
40823993
**
4083
-** The memory pointed to by the character pointers returned for the
3994
+** ^The memory pointed to by the character pointers returned for the
40843995
** declaration type and collation sequence is valid only until the next
40853996
** call to any SQLite API function.
40863997
**
4087
-** If the specified table is actually a view, an [error code] is returned.
3998
+** ^If the specified table is actually a view, an [error code] is returned.
40883999
**
4089
-** If the specified column is "rowid", "oid" or "_rowid_" and an
4000
+** ^If the specified column is "rowid", "oid" or "_rowid_" and an
40904001
** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4091
-** parameters are set for the explicitly declared column. If there is no
4002
+** parameters are set for the explicitly declared column. ^(If there is no
40924003
** explicitly declared [INTEGER PRIMARY KEY] column, then the output
40934004
** parameters are set as follows:
40944005
**
40954006
** <pre>
40964007
** data type: "INTEGER"
40974008
** collation sequence: "BINARY"
40984009
** not null: 0
40994010
** primary key: 1
41004011
** auto increment: 0
4101
-** </pre>
4012
+** </pre>)^
41024013
**
4103
-** This function may load one or more schemas from database files. If an
4014
+** ^(This function may load one or more schemas from database files. If an
41044015
** error occurs during this process, or if the requested table or column
41054016
** cannot be found, an [error code] is returned and an error message left
4106
-** in the [database connection] (to be retrieved using sqlite3_errmsg()).
4017
+** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
41074018
**
4108
-** This API is only available if the library was compiled with the
4019
+** ^This API is only available if the library was compiled with the
41094020
** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
41104021
*/
41114022
SQLITE_API int sqlite3_table_column_metadata(
41124023
sqlite3 *db, /* Connection handle */
41134024
const char *zDbName, /* Database name or NULL */
@@ -4119,34 +4030,31 @@
41194030
int *pPrimaryKey, /* OUTPUT: True if column part of PK */
41204031
int *pAutoinc /* OUTPUT: True if column is auto-increment */
41214032
);
41224033
41234034
/*
4124
-** CAPI3REF: Load An Extension {H12600} <S20500>
4125
-**
4126
-** This interface loads an SQLite extension library from the named file.
4127
-**
4128
-** {H12601} The sqlite3_load_extension() interface attempts to load an
4129
-** SQLite extension library contained in the file zFile.
4130
-**
4131
-** {H12602} The entry point is zProc.
4132
-**
4133
-** {H12603} zProc may be 0, in which case the name of the entry point
4134
-** defaults to "sqlite3_extension_init".
4135
-**
4136
-** {H12604} The sqlite3_load_extension() interface shall return
4137
-** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4138
-**
4139
-** {H12605} If an error occurs and pzErrMsg is not 0, then the
4140
-** [sqlite3_load_extension()] interface shall attempt to
4141
-** fill *pzErrMsg with error message text stored in memory
4142
-** obtained from [sqlite3_malloc()]. {END} The calling function
4143
-** should free this memory by calling [sqlite3_free()].
4144
-**
4145
-** {H12606} Extension loading must be enabled using
4146
-** [sqlite3_enable_load_extension()] prior to calling this API,
4147
-** otherwise an error will be returned.
4035
+** CAPI3REF: Load An Extension
4036
+**
4037
+** ^This interface loads an SQLite extension library from the named file.
4038
+**
4039
+** ^The sqlite3_load_extension() interface attempts to load an
4040
+** SQLite extension library contained in the file zFile.
4041
+**
4042
+** ^The entry point is zProc.
4043
+** ^zProc may be 0, in which case the name of the entry point
4044
+** defaults to "sqlite3_extension_init".
4045
+** ^The sqlite3_load_extension() interface returns
4046
+** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4047
+** ^If an error occurs and pzErrMsg is not 0, then the
4048
+** [sqlite3_load_extension()] interface shall attempt to
4049
+** fill *pzErrMsg with error message text stored in memory
4050
+** obtained from [sqlite3_malloc()]. The calling function
4051
+** should free this memory by calling [sqlite3_free()].
4052
+**
4053
+** ^Extension loading must be enabled using
4054
+** [sqlite3_enable_load_extension()] prior to calling this API,
4055
+** otherwise an error will be returned.
41484056
**
41494057
** See also the [load_extension() SQL function].
41504058
*/
41514059
SQLITE_API int sqlite3_load_extension(
41524060
sqlite3 *db, /* Load the extension into this database connection */
@@ -4154,65 +4062,53 @@
41544062
const char *zProc, /* Entry point. Derived from zFile if 0 */
41554063
char **pzErrMsg /* Put error message here if not 0 */
41564064
);
41574065
41584066
/*
4159
-** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
4067
+** CAPI3REF: Enable Or Disable Extension Loading
41604068
**
4161
-** So as not to open security holes in older applications that are
4069
+** ^So as not to open security holes in older applications that are
41624070
** unprepared to deal with extension loading, and as a means of disabling
41634071
** extension loading while evaluating user-entered SQL, the following API
41644072
** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
41654073
**
4166
-** Extension loading is off by default. See ticket #1863.
4167
-**
4168
-** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
4169
-** to turn extension loading on and call it with onoff==0 to turn
4170
-** it back off again.
4171
-**
4172
-** {H12622} Extension loading is off by default.
4074
+** ^Extension loading is off by default. See ticket #1863.
4075
+** ^Call the sqlite3_enable_load_extension() routine with onoff==1
4076
+** to turn extension loading on and call it with onoff==0 to turn
4077
+** it back off again.
41734078
*/
41744079
SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
41754080
41764081
/*
4177
-** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
4082
+** CAPI3REF: Automatically Load An Extensions
41784083
**
4179
-** This API can be invoked at program startup in order to register
4084
+** ^This API can be invoked at program startup in order to register
41804085
** one or more statically linked extensions that will be available
4181
-** to all new [database connections]. {END}
4182
-**
4183
-** This routine stores a pointer to the extension in an array that is
4184
-** obtained from [sqlite3_malloc()]. If you run a memory leak checker
4185
-** on your program and it reports a leak because of this array, invoke
4186
-** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
4187
-**
4188
-** {H12641} This function registers an extension entry point that is
4189
-** automatically invoked whenever a new [database connection]
4190
-** is opened using [sqlite3_open()], [sqlite3_open16()],
4191
-** or [sqlite3_open_v2()].
4192
-**
4193
-** {H12642} Duplicate extensions are detected so calling this routine
4194
-** multiple times with the same extension is harmless.
4195
-**
4196
-** {H12643} This routine stores a pointer to the extension in an array
4197
-** that is obtained from [sqlite3_malloc()].
4198
-**
4199
-** {H12644} Automatic extensions apply across all threads.
4086
+** to all new [database connections].
4087
+**
4088
+** ^(This routine stores a pointer to the extension entry point
4089
+** in an array that is obtained from [sqlite3_malloc()]. That memory
4090
+** is deallocated by [sqlite3_reset_auto_extension()].)^
4091
+**
4092
+** ^This function registers an extension entry point that is
4093
+** automatically invoked whenever a new [database connection]
4094
+** is opened using [sqlite3_open()], [sqlite3_open16()],
4095
+** or [sqlite3_open_v2()].
4096
+** ^Duplicate extensions are detected so calling this routine
4097
+** multiple times with the same extension is harmless.
4098
+** ^Automatic extensions apply across all threads.
42004099
*/
42014100
SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
42024101
42034102
/*
4204
-** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
4205
-**
4206
-** This function disables all previously registered automatic
4207
-** extensions. {END} It undoes the effect of all prior
4208
-** [sqlite3_auto_extension()] calls.
4209
-**
4210
-** {H12661} This function disables all previously registered
4211
-** automatic extensions.
4212
-**
4213
-** {H12662} This function disables automatic extensions in all threads.
4103
+** CAPI3REF: Reset Automatic Extension Loading
4104
+**
4105
+** ^(This function disables all previously registered automatic
4106
+** extensions. It undoes the effect of all prior
4107
+** [sqlite3_auto_extension()] calls.)^
4108
+**
4109
+** ^This function disables automatic extensions in all threads.
42144110
*/
42154111
SQLITE_API void sqlite3_reset_auto_extension(void);
42164112
42174113
/*
42184114
****** EXPERIMENTAL - subject to change without notice **************
@@ -4232,22 +4128,22 @@
42324128
typedef struct sqlite3_index_info sqlite3_index_info;
42334129
typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
42344130
typedef struct sqlite3_module sqlite3_module;
42354131
42364132
/*
4237
-** CAPI3REF: Virtual Table Object {H18000} <S20400>
4133
+** CAPI3REF: Virtual Table Object
42384134
** KEYWORDS: sqlite3_module {virtual table module}
42394135
** EXPERIMENTAL
42404136
**
42414137
** This structure, sometimes called a a "virtual table module",
42424138
** defines the implementation of a [virtual tables].
42434139
** This structure consists mostly of methods for the module.
42444140
**
4245
-** A virtual table module is created by filling in a persistent
4141
+** ^A virtual table module is created by filling in a persistent
42464142
** instance of this structure and passing a pointer to that instance
42474143
** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4248
-** The registration remains valid until it is replaced by a different
4144
+** ^The registration remains valid until it is replaced by a different
42494145
** module or until the [database connection] closes. The content
42504146
** of this structure must not change while it is registered with
42514147
** any database connection.
42524148
*/
42534149
struct sqlite3_module {
@@ -4279,56 +4175,56 @@
42794175
void **ppArg);
42804176
int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
42814177
};
42824178
42834179
/*
4284
-** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
4180
+** CAPI3REF: Virtual Table Indexing Information
42854181
** KEYWORDS: sqlite3_index_info
42864182
** EXPERIMENTAL
42874183
**
42884184
** The sqlite3_index_info structure and its substructures is used to
42894185
** pass information into and receive the reply from the [xBestIndex]
42904186
** method of a [virtual table module]. The fields under **Inputs** are the
42914187
** inputs to xBestIndex and are read-only. xBestIndex inserts its
42924188
** results into the **Outputs** fields.
42934189
**
4294
-** The aConstraint[] array records WHERE clause constraints of the form:
4190
+** ^(The aConstraint[] array records WHERE clause constraints of the form:
42954191
**
42964192
** <pre>column OP expr</pre>
42974193
**
4298
-** where OP is =, &lt;, &lt;=, &gt;, or &gt;=. The particular operator is
4299
-** stored in aConstraint[].op. The index of the column is stored in
4300
-** aConstraint[].iColumn. aConstraint[].usable is TRUE if the
4194
+** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^ ^(The particular operator is
4195
+** stored in aConstraint[].op.)^ ^(The index of the column is stored in
4196
+** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the
43014197
** expr on the right-hand side can be evaluated (and thus the constraint
4302
-** is usable) and false if it cannot.
4198
+** is usable) and false if it cannot.)^
43034199
**
4304
-** The optimizer automatically inverts terms of the form "expr OP column"
4200
+** ^The optimizer automatically inverts terms of the form "expr OP column"
43054201
** and makes other simplifications to the WHERE clause in an attempt to
43064202
** get as many WHERE clause terms into the form shown above as possible.
4307
-** The aConstraint[] array only reports WHERE clause terms in the correct
4308
-** form that refer to the particular virtual table being queried.
4203
+** ^The aConstraint[] array only reports WHERE clause terms that are
4204
+** relevant to the particular virtual table being queried.
43094205
**
4310
-** Information about the ORDER BY clause is stored in aOrderBy[].
4311
-** Each term of aOrderBy records a column of the ORDER BY clause.
4206
+** ^Information about the ORDER BY clause is stored in aOrderBy[].
4207
+** ^Each term of aOrderBy records a column of the ORDER BY clause.
43124208
**
43134209
** The [xBestIndex] method must fill aConstraintUsage[] with information
4314
-** about what parameters to pass to xFilter. If argvIndex>0 then
4210
+** about what parameters to pass to xFilter. ^If argvIndex>0 then
43154211
** the right-hand side of the corresponding aConstraint[] is evaluated
4316
-** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
4212
+** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
43174213
** is true, then the constraint is assumed to be fully handled by the
4318
-** virtual table and is not checked again by SQLite.
4214
+** virtual table and is not checked again by SQLite.)^
43194215
**
4320
-** The idxNum and idxPtr values are recorded and passed into the
4216
+** ^The idxNum and idxPtr values are recorded and passed into the
43214217
** [xFilter] method.
4322
-** [sqlite3_free()] is used to free idxPtr if and only iff
4218
+** ^[sqlite3_free()] is used to free idxPtr if and only if
43234219
** needToFreeIdxPtr is true.
43244220
**
4325
-** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4221
+** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
43264222
** the correct order to satisfy the ORDER BY clause so that no separate
43274223
** sorting step is required.
43284224
**
4329
-** The estimatedCost value is an estimate of the cost of doing the
4225
+** ^The estimatedCost value is an estimate of the cost of doing the
43304226
** particular lookup. A full scan of a table with N entries should have
43314227
** a cost of N. A binary search of a table of N entries should have a
43324228
** cost of approximately log(N).
43334229
*/
43344230
struct sqlite3_index_info {
@@ -4362,70 +4258,63 @@
43624258
#define SQLITE_INDEX_CONSTRAINT_LT 16
43634259
#define SQLITE_INDEX_CONSTRAINT_GE 32
43644260
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
43654261
43664262
/*
4367
-** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
4263
+** CAPI3REF: Register A Virtual Table Implementation
43684264
** EXPERIMENTAL
43694265
**
4370
-** This routine is used to register a new [virtual table module] name.
4371
-** Module names must be registered before
4372
-** creating a new [virtual table] using the module, or before using a
4266
+** ^These routines are used to register a new [virtual table module] name.
4267
+** ^Module names must be registered before
4268
+** creating a new [virtual table] using the module and before using a
43734269
** preexisting [virtual table] for the module.
43744270
**
4375
-** The module name is registered on the [database connection] specified
4376
-** by the first parameter. The name of the module is given by the
4377
-** second parameter. The third parameter is a pointer to
4378
-** the implementation of the [virtual table module]. The fourth
4271
+** ^The module name is registered on the [database connection] specified
4272
+** by the first parameter. ^The name of the module is given by the
4273
+** second parameter. ^The third parameter is a pointer to
4274
+** the implementation of the [virtual table module]. ^The fourth
43794275
** parameter is an arbitrary client data pointer that is passed through
43804276
** into the [xCreate] and [xConnect] methods of the virtual table module
43814277
** when a new virtual table is be being created or reinitialized.
43824278
**
4383
-** This interface has exactly the same effect as calling
4384
-** [sqlite3_create_module_v2()] with a NULL client data destructor.
4279
+** ^The sqlite3_create_module_v2() interface has a fifth parameter which
4280
+** is a pointer to a destructor for the pClientData. ^SQLite will
4281
+** invoke the destructor function (if it is not NULL) when SQLite
4282
+** no longer needs the pClientData pointer. ^The sqlite3_create_module()
4283
+** interface is equivalent to sqlite3_create_module_v2() with a NULL
4284
+** destructor.
43854285
*/
43864286
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
43874287
sqlite3 *db, /* SQLite connection to register module with */
43884288
const char *zName, /* Name of the module */
43894289
const sqlite3_module *p, /* Methods for the module */
43904290
void *pClientData /* Client data for xCreate/xConnect */
43914291
);
4392
-
4393
-/*
4394
-** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
4395
-** EXPERIMENTAL
4396
-**
4397
-** This routine is identical to the [sqlite3_create_module()] method,
4398
-** except that it has an extra parameter to specify
4399
-** a destructor function for the client data pointer. SQLite will
4400
-** invoke the destructor function (if it is not NULL) when SQLite
4401
-** no longer needs the pClientData pointer.
4402
-*/
44034292
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
44044293
sqlite3 *db, /* SQLite connection to register module with */
44054294
const char *zName, /* Name of the module */
44064295
const sqlite3_module *p, /* Methods for the module */
44074296
void *pClientData, /* Client data for xCreate/xConnect */
44084297
void(*xDestroy)(void*) /* Module destructor function */
44094298
);
44104299
44114300
/*
4412
-** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
4301
+** CAPI3REF: Virtual Table Instance Object
44134302
** KEYWORDS: sqlite3_vtab
44144303
** EXPERIMENTAL
44154304
**
44164305
** Every [virtual table module] implementation uses a subclass
4417
-** of the following structure to describe a particular instance
4306
+** of this object to describe a particular instance
44184307
** of the [virtual table]. Each subclass will
44194308
** be tailored to the specific needs of the module implementation.
44204309
** The purpose of this superclass is to define certain fields that are
44214310
** common to all module implementations.
44224311
**
4423
-** Virtual tables methods can set an error message by assigning a
4312
+** ^Virtual tables methods can set an error message by assigning a
44244313
** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
44254314
** take care that any prior string is freed by a call to [sqlite3_free()]
4426
-** prior to assigning a new string to zErrMsg. After the error message
4315
+** prior to assigning a new string to zErrMsg. ^After the error message
44274316
** is delivered up to the client application, the string will be automatically
44284317
** freed by sqlite3_free() and the zErrMsg field will be zeroed.
44294318
*/
44304319
struct sqlite3_vtab {
44314320
const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4433,20 +4322,20 @@
44334322
char *zErrMsg; /* Error message from sqlite3_mprintf() */
44344323
/* Virtual table implementations will typically add additional fields */
44354324
};
44364325
44374326
/*
4438
-** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400>
4327
+** CAPI3REF: Virtual Table Cursor Object
44394328
** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
44404329
** EXPERIMENTAL
44414330
**
44424331
** Every [virtual table module] implementation uses a subclass of the
44434332
** following structure to describe cursors that point into the
44444333
** [virtual table] and are used
44454334
** to loop through the virtual table. Cursors are created using the
44464335
** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4447
-** by the [sqlite3_module.xClose | xClose] method. Cussors are used
4336
+** by the [sqlite3_module.xClose | xClose] method. Cursors are used
44484337
** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
44494338
** of the module. Each module implementation will define
44504339
** the content of a cursor structure to suit its own needs.
44514340
**
44524341
** This superclass exists in order to define fields of the cursor that
@@ -4456,32 +4345,32 @@
44564345
sqlite3_vtab *pVtab; /* Virtual table of this cursor */
44574346
/* Virtual table implementations will typically add additional fields */
44584347
};
44594348
44604349
/*
4461
-** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
4350
+** CAPI3REF: Declare The Schema Of A Virtual Table
44624351
** EXPERIMENTAL
44634352
**
4464
-** The [xCreate] and [xConnect] methods of a
4353
+** ^The [xCreate] and [xConnect] methods of a
44654354
** [virtual table module] call this interface
44664355
** to declare the format (the names and datatypes of the columns) of
44674356
** the virtual tables they implement.
44684357
*/
44694358
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
44704359
44714360
/*
4472
-** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
4361
+** CAPI3REF: Overload A Function For A Virtual Table
44734362
** EXPERIMENTAL
44744363
**
4475
-** Virtual tables can provide alternative implementations of functions
4364
+** ^(Virtual tables can provide alternative implementations of functions
44764365
** using the [xFindFunction] method of the [virtual table module].
44774366
** But global versions of those functions
4478
-** must exist in order to be overloaded.
4367
+** must exist in order to be overloaded.)^
44794368
**
4480
-** This API makes sure a global version of a function with a particular
4369
+** ^(This API makes sure a global version of a function with a particular
44814370
** name and number of parameters exists. If no such function exists
4482
-** before this API is called, a new function is created. The implementation
4371
+** before this API is called, a new function is created.)^ ^The implementation
44834372
** of the new function always causes an exception to be thrown. So
44844373
** the new function is not good for anything by itself. Its only
44854374
** purpose is to be a placeholder function that can be overloaded
44864375
** by a [virtual table].
44874376
*/
@@ -4498,81 +4387,78 @@
44984387
**
44994388
****** EXPERIMENTAL - subject to change without notice **************
45004389
*/
45014390
45024391
/*
4503
-** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
4392
+** CAPI3REF: A Handle To An Open BLOB
45044393
** KEYWORDS: {BLOB handle} {BLOB handles}
45054394
**
45064395
** An instance of this object represents an open BLOB on which
45074396
** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
4508
-** Objects of this type are created by [sqlite3_blob_open()]
4397
+** ^Objects of this type are created by [sqlite3_blob_open()]
45094398
** and destroyed by [sqlite3_blob_close()].
4510
-** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
4399
+** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
45114400
** can be used to read or write small subsections of the BLOB.
4512
-** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
4401
+** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
45134402
*/
45144403
typedef struct sqlite3_blob sqlite3_blob;
45154404
45164405
/*
4517
-** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
4406
+** CAPI3REF: Open A BLOB For Incremental I/O
45184407
**
4519
-** This interfaces opens a [BLOB handle | handle] to the BLOB located
4408
+** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
45204409
** in row iRow, column zColumn, table zTable in database zDb;
45214410
** in other words, the same BLOB that would be selected by:
45224411
**
45234412
** <pre>
45244413
** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4525
-** </pre> {END}
4414
+** </pre>)^
45264415
**
4527
-** If the flags parameter is non-zero, then the BLOB is opened for read
4528
-** and write access. If it is zero, the BLOB is opened for read access.
4529
-** It is not possible to open a column that is part of an index or primary
4416
+** ^If the flags parameter is non-zero, then the BLOB is opened for read
4417
+** and write access. ^If it is zero, the BLOB is opened for read access.
4418
+** ^It is not possible to open a column that is part of an index or primary
45304419
** key for writing. ^If [foreign key constraints] are enabled, it is
45314420
** not possible to open a column that is part of a [child key] for writing.
45324421
**
4533
-** Note that the database name is not the filename that contains
4422
+** ^Note that the database name is not the filename that contains
45344423
** the database but rather the symbolic name of the database that
4535
-** is assigned when the database is connected using [ATTACH].
4536
-** For the main database file, the database name is "main".
4537
-** For TEMP tables, the database name is "temp".
4424
+** appears after the AS keyword when the database is connected using [ATTACH].
4425
+** ^For the main database file, the database name is "main".
4426
+** ^For TEMP tables, the database name is "temp".
45384427
**
4539
-** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
4428
+** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
45404429
** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
4541
-** to be a null pointer.
4542
-** This function sets the [database connection] error code and message
4430
+** to be a null pointer.)^
4431
+** ^This function sets the [database connection] error code and message
45434432
** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
4544
-** functions. Note that the *ppBlob variable is always initialized in a
4433
+** functions. ^Note that the *ppBlob variable is always initialized in a
45454434
** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
45464435
** regardless of the success or failure of this routine.
45474436
**
4548
-** If the row that a BLOB handle points to is modified by an
4437
+** ^(If the row that a BLOB handle points to is modified by an
45494438
** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
45504439
** then the BLOB handle is marked as "expired".
45514440
** This is true if any column of the row is changed, even a column
4552
-** other than the one the BLOB handle is open on.
4553
-** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4441
+** other than the one the BLOB handle is open on.)^
4442
+** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
45544443
** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
4555
-** Changes written into a BLOB prior to the BLOB expiring are not
4556
-** rollback by the expiration of the BLOB. Such changes will eventually
4557
-** commit if the transaction continues to completion.
4444
+** ^(Changes written into a BLOB prior to the BLOB expiring are not
4445
+** rolled back by the expiration of the BLOB. Such changes will eventually
4446
+** commit if the transaction continues to completion.)^
45584447
**
4559
-** Use the [sqlite3_blob_bytes()] interface to determine the size of
4560
-** the opened blob. The size of a blob may not be changed by this
4448
+** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
4449
+** the opened blob. ^The size of a blob may not be changed by this
45614450
** interface. Use the [UPDATE] SQL command to change the size of a
45624451
** blob.
45634452
**
4564
-** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
4453
+** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
45654454
** and the built-in [zeroblob] SQL function can be used, if desired,
45664455
** to create an empty, zero-filled blob in which to read or write using
45674456
** this interface.
45684457
**
45694458
** To avoid a resource leak, every open [BLOB handle] should eventually
45704459
** be released by a call to [sqlite3_blob_close()].
4571
-**
4572
-** Requirements:
4573
-** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
45744460
*/
45754461
SQLITE_API int sqlite3_blob_open(
45764462
sqlite3*,
45774463
const char *zDb,
45784464
const char *zTable,
@@ -4581,201 +4467,185 @@
45814467
int flags,
45824468
sqlite3_blob **ppBlob
45834469
);
45844470
45854471
/*
4586
-** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
4472
+** CAPI3REF: Close A BLOB Handle
45874473
**
4588
-** Closes an open [BLOB handle].
4474
+** ^Closes an open [BLOB handle].
45894475
**
4590
-** Closing a BLOB shall cause the current transaction to commit
4476
+** ^Closing a BLOB shall cause the current transaction to commit
45914477
** if there are no other BLOBs, no pending prepared statements, and the
45924478
** database connection is in [autocommit mode].
4593
-** If any writes were made to the BLOB, they might be held in cache
4479
+** ^If any writes were made to the BLOB, they might be held in cache
45944480
** until the close operation if they will fit.
45954481
**
4596
-** Closing the BLOB often forces the changes
4482
+** ^(Closing the BLOB often forces the changes
45974483
** out to disk and so if any I/O errors occur, they will likely occur
45984484
** at the time when the BLOB is closed. Any errors that occur during
4599
-** closing are reported as a non-zero return value.
4600
-**
4601
-** The BLOB is closed unconditionally. Even if this routine returns
4602
-** an error code, the BLOB is still closed.
4603
-**
4604
-** Calling this routine with a null pointer (which as would be returned
4605
-** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
4606
-**
4607
-** Requirements:
4608
-** [H17833] [H17836] [H17839]
4485
+** closing are reported as a non-zero return value.)^
4486
+**
4487
+** ^(The BLOB is closed unconditionally. Even if this routine returns
4488
+** an error code, the BLOB is still closed.)^
4489
+**
4490
+** ^Calling this routine with a null pointer (such as would be returned
4491
+** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
46094492
*/
46104493
SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
46114494
46124495
/*
4613
-** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
4496
+** CAPI3REF: Return The Size Of An Open BLOB
46144497
**
4615
-** Returns the size in bytes of the BLOB accessible via the
4616
-** successfully opened [BLOB handle] in its only argument. The
4498
+** ^Returns the size in bytes of the BLOB accessible via the
4499
+** successfully opened [BLOB handle] in its only argument. ^The
46174500
** incremental blob I/O routines can only read or overwriting existing
46184501
** blob content; they cannot change the size of a blob.
46194502
**
46204503
** This routine only works on a [BLOB handle] which has been created
46214504
** by a prior successful call to [sqlite3_blob_open()] and which has not
46224505
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
46234506
** to this routine results in undefined and probably undesirable behavior.
4624
-**
4625
-** Requirements:
4626
-** [H17843]
46274507
*/
46284508
SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
46294509
46304510
/*
4631
-** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
4511
+** CAPI3REF: Read Data From A BLOB Incrementally
46324512
**
4633
-** This function is used to read data from an open [BLOB handle] into a
4513
+** ^(This function is used to read data from an open [BLOB handle] into a
46344514
** caller-supplied buffer. N bytes of data are copied into buffer Z
4635
-** from the open BLOB, starting at offset iOffset.
4515
+** from the open BLOB, starting at offset iOffset.)^
46364516
**
4637
-** If offset iOffset is less than N bytes from the end of the BLOB,
4638
-** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is
4517
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
4518
+** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
46394519
** less than zero, [SQLITE_ERROR] is returned and no data is read.
4640
-** The size of the blob (and hence the maximum value of N+iOffset)
4520
+** ^The size of the blob (and hence the maximum value of N+iOffset)
46414521
** can be determined using the [sqlite3_blob_bytes()] interface.
46424522
**
4643
-** An attempt to read from an expired [BLOB handle] fails with an
4523
+** ^An attempt to read from an expired [BLOB handle] fails with an
46444524
** error code of [SQLITE_ABORT].
46454525
**
4646
-** On success, SQLITE_OK is returned.
4647
-** Otherwise, an [error code] or an [extended error code] is returned.
4526
+** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
4527
+** Otherwise, an [error code] or an [extended error code] is returned.)^
46484528
**
46494529
** This routine only works on a [BLOB handle] which has been created
46504530
** by a prior successful call to [sqlite3_blob_open()] and which has not
46514531
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
46524532
** to this routine results in undefined and probably undesirable behavior.
46534533
**
46544534
** See also: [sqlite3_blob_write()].
4655
-**
4656
-** Requirements:
4657
-** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
46584535
*/
46594536
SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
46604537
46614538
/*
4662
-** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
4539
+** CAPI3REF: Write Data Into A BLOB Incrementally
46634540
**
4664
-** This function is used to write data into an open [BLOB handle] from a
4665
-** caller-supplied buffer. N bytes of data are copied from the buffer Z
4541
+** ^This function is used to write data into an open [BLOB handle] from a
4542
+** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
46664543
** into the open BLOB, starting at offset iOffset.
46674544
**
4668
-** If the [BLOB handle] passed as the first argument was not opened for
4545
+** ^If the [BLOB handle] passed as the first argument was not opened for
46694546
** writing (the flags parameter to [sqlite3_blob_open()] was zero),
46704547
** this function returns [SQLITE_READONLY].
46714548
**
4672
-** This function may only modify the contents of the BLOB; it is
4549
+** ^This function may only modify the contents of the BLOB; it is
46734550
** not possible to increase the size of a BLOB using this API.
4674
-** If offset iOffset is less than N bytes from the end of the BLOB,
4675
-** [SQLITE_ERROR] is returned and no data is written. If N is
4551
+** ^If offset iOffset is less than N bytes from the end of the BLOB,
4552
+** [SQLITE_ERROR] is returned and no data is written. ^If N is
46764553
** less than zero [SQLITE_ERROR] is returned and no data is written.
46774554
** The size of the BLOB (and hence the maximum value of N+iOffset)
46784555
** can be determined using the [sqlite3_blob_bytes()] interface.
46794556
**
4680
-** An attempt to write to an expired [BLOB handle] fails with an
4681
-** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred
4557
+** ^An attempt to write to an expired [BLOB handle] fails with an
4558
+** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
46824559
** before the [BLOB handle] expired are not rolled back by the
46834560
** expiration of the handle, though of course those changes might
46844561
** have been overwritten by the statement that expired the BLOB handle
46854562
** or by other independent statements.
46864563
**
4687
-** On success, SQLITE_OK is returned.
4688
-** Otherwise, an [error code] or an [extended error code] is returned.
4564
+** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
4565
+** Otherwise, an [error code] or an [extended error code] is returned.)^
46894566
**
46904567
** This routine only works on a [BLOB handle] which has been created
46914568
** by a prior successful call to [sqlite3_blob_open()] and which has not
46924569
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
46934570
** to this routine results in undefined and probably undesirable behavior.
46944571
**
46954572
** See also: [sqlite3_blob_read()].
4696
-**
4697
-** Requirements:
4698
-** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
4699
-** [H17888]
47004573
*/
47014574
SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
47024575
47034576
/*
4704
-** CAPI3REF: Virtual File System Objects {H11200} <S20100>
4577
+** CAPI3REF: Virtual File System Objects
47054578
**
47064579
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
47074580
** that SQLite uses to interact
47084581
** with the underlying operating system. Most SQLite builds come with a
47094582
** single default VFS that is appropriate for the host computer.
47104583
** New VFSes can be registered and existing VFSes can be unregistered.
47114584
** The following interfaces are provided.
47124585
**
4713
-** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
4714
-** Names are case sensitive.
4715
-** Names are zero-terminated UTF-8 strings.
4716
-** If there is no match, a NULL pointer is returned.
4717
-** If zVfsName is NULL then the default VFS is returned.
4586
+** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
4587
+** ^Names are case sensitive.
4588
+** ^Names are zero-terminated UTF-8 strings.
4589
+** ^If there is no match, a NULL pointer is returned.
4590
+** ^If zVfsName is NULL then the default VFS is returned.
47184591
**
4719
-** New VFSes are registered with sqlite3_vfs_register().
4720
-** Each new VFS becomes the default VFS if the makeDflt flag is set.
4721
-** The same VFS can be registered multiple times without injury.
4722
-** To make an existing VFS into the default VFS, register it again
4592
+** ^New VFSes are registered with sqlite3_vfs_register().
4593
+** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
4594
+** ^The same VFS can be registered multiple times without injury.
4595
+** ^To make an existing VFS into the default VFS, register it again
47234596
** with the makeDflt flag set. If two different VFSes with the
47244597
** same name are registered, the behavior is undefined. If a
47254598
** VFS is registered with a name that is NULL or an empty string,
47264599
** then the behavior is undefined.
47274600
**
4728
-** Unregister a VFS with the sqlite3_vfs_unregister() interface.
4729
-** If the default VFS is unregistered, another VFS is chosen as
4730
-** the default. The choice for the new VFS is arbitrary.
4731
-**
4732
-** Requirements:
4733
-** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
4601
+** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
4602
+** ^(If the default VFS is unregistered, another VFS is chosen as
4603
+** the default. The choice for the new VFS is arbitrary.)^
47344604
*/
47354605
SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
47364606
SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
47374607
SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
47384608
47394609
/*
4740
-** CAPI3REF: Mutexes {H17000} <S20000>
4610
+** CAPI3REF: Mutexes
47414611
**
47424612
** The SQLite core uses these routines for thread
47434613
** synchronization. Though they are intended for internal
47444614
** use by SQLite, code that links against SQLite is
47454615
** permitted to use any of these routines.
47464616
**
47474617
** The SQLite source code contains multiple implementations
47484618
** of these mutex routines. An appropriate implementation
4749
-** is selected automatically at compile-time. The following
4619
+** is selected automatically at compile-time. ^(The following
47504620
** implementations are available in the SQLite core:
47514621
**
47524622
** <ul>
47534623
** <li> SQLITE_MUTEX_OS2
47544624
** <li> SQLITE_MUTEX_PTHREAD
47554625
** <li> SQLITE_MUTEX_W32
47564626
** <li> SQLITE_MUTEX_NOOP
4757
-** </ul>
4627
+** </ul>)^
47584628
**
4759
-** The SQLITE_MUTEX_NOOP implementation is a set of routines
4629
+** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
47604630
** that does no real locking and is appropriate for use in
4761
-** a single-threaded application. The SQLITE_MUTEX_OS2,
4631
+** a single-threaded application. ^The SQLITE_MUTEX_OS2,
47624632
** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
47634633
** are appropriate for use on OS/2, Unix, and Windows.
47644634
**
4765
-** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
4635
+** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
47664636
** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
47674637
** implementation is included with the library. In this case the
47684638
** application must supply a custom mutex implementation using the
47694639
** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
47704640
** before calling sqlite3_initialize() or any other public sqlite3_
4771
-** function that calls sqlite3_initialize().
4641
+** function that calls sqlite3_initialize().)^
47724642
**
4773
-** {H17011} The sqlite3_mutex_alloc() routine allocates a new
4774
-** mutex and returns a pointer to it. {H17012} If it returns NULL
4775
-** that means that a mutex could not be allocated. {H17013} SQLite
4776
-** will unwind its stack and return an error. {H17014} The argument
4643
+** ^The sqlite3_mutex_alloc() routine allocates a new
4644
+** mutex and returns a pointer to it. ^If it returns NULL
4645
+** that means that a mutex could not be allocated. ^SQLite
4646
+** will unwind its stack and return an error. ^(The argument
47774647
** to sqlite3_mutex_alloc() is one of these integer constants:
47784648
**
47794649
** <ul>
47804650
** <li> SQLITE_MUTEX_FAST
47814651
** <li> SQLITE_MUTEX_RECURSIVE
@@ -4783,68 +4653,70 @@
47834653
** <li> SQLITE_MUTEX_STATIC_MEM
47844654
** <li> SQLITE_MUTEX_STATIC_MEM2
47854655
** <li> SQLITE_MUTEX_STATIC_PRNG
47864656
** <li> SQLITE_MUTEX_STATIC_LRU
47874657
** <li> SQLITE_MUTEX_STATIC_LRU2
4788
-** </ul>
4658
+** </ul>)^
47894659
**
4790
-** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
4791
-** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
4792
-** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
4660
+** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
4661
+** cause sqlite3_mutex_alloc() to create
4662
+** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
4663
+** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
47934664
** The mutex implementation does not need to make a distinction
47944665
** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
4795
-** not want to. {H17016} But SQLite will only request a recursive mutex in
4796
-** cases where it really needs one. {END} If a faster non-recursive mutex
4666
+** not want to. ^SQLite will only request a recursive mutex in
4667
+** cases where it really needs one. ^If a faster non-recursive mutex
47974668
** implementation is available on the host platform, the mutex subsystem
47984669
** might return such a mutex in response to SQLITE_MUTEX_FAST.
47994670
**
4800
-** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
4801
-** a pointer to a static preexisting mutex. {END} Six static mutexes are
4671
+** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
4672
+** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
4673
+** a pointer to a static preexisting mutex. ^Six static mutexes are
48024674
** used by the current version of SQLite. Future versions of SQLite
48034675
** may add additional static mutexes. Static mutexes are for internal
48044676
** use by SQLite only. Applications that use SQLite mutexes should
48054677
** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
48064678
** SQLITE_MUTEX_RECURSIVE.
48074679
**
4808
-** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
4680
+** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
48094681
** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
4810
-** returns a different mutex on every call. {H17034} But for the static
4682
+** returns a different mutex on every call. ^But for the static
48114683
** mutex types, the same mutex is returned on every call that has
48124684
** the same type number.
48134685
**
4814
-** {H17019} The sqlite3_mutex_free() routine deallocates a previously
4815
-** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
4816
-** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
4817
-** use when they are deallocated. {A17022} Attempting to deallocate a static
4818
-** mutex results in undefined behavior. {H17023} SQLite never deallocates
4819
-** a static mutex. {END}
4686
+** ^The sqlite3_mutex_free() routine deallocates a previously
4687
+** allocated dynamic mutex. ^SQLite is careful to deallocate every
4688
+** dynamic mutex that it allocates. The dynamic mutexes must not be in
4689
+** use when they are deallocated. Attempting to deallocate a static
4690
+** mutex results in undefined behavior. ^SQLite never deallocates
4691
+** a static mutex.
48204692
**
4821
-** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
4822
-** to enter a mutex. {H17024} If another thread is already within the mutex,
4693
+** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
4694
+** to enter a mutex. ^If another thread is already within the mutex,
48234695
** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
4824
-** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK]
4825
-** upon successful entry. {H17026} Mutexes created using
4696
+** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
4697
+** upon successful entry. ^(Mutexes created using
48264698
** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
4827
-** {H17027} In such cases the,
4699
+** In such cases the,
48284700
** mutex must be exited an equal number of times before another thread
4829
-** can enter. {A17028} If the same thread tries to enter any other
4701
+** can enter.)^ ^(If the same thread tries to enter any other
48304702
** kind of mutex more than once, the behavior is undefined.
4831
-** {H17029} SQLite will never exhibit
4832
-** such behavior in its own use of mutexes.
4703
+** SQLite will never exhibit
4704
+** such behavior in its own use of mutexes.)^
48334705
**
4834
-** Some systems (for example, Windows 95) do not support the operation
4706
+** ^(Some systems (for example, Windows 95) do not support the operation
48354707
** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
4836
-** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses
4837
-** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
4708
+** will always return SQLITE_BUSY. The SQLite core only ever uses
4709
+** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
48384710
**
4839
-** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
4840
-** previously entered by the same thread. {A17032} The behavior
4711
+** ^The sqlite3_mutex_leave() routine exits a mutex that was
4712
+** previously entered by the same thread. ^(The behavior
48414713
** is undefined if the mutex is not currently entered by the
4842
-** calling thread or is not currently allocated. {H17033} SQLite will
4843
-** never do either. {END}
4714
+** calling thread or is not currently allocated. SQLite will
4715
+** never do either.)^
48444716
**
4845
-** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
4717
+** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
48464718
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
48474719
** behave as no-ops.
48484720
**
48494721
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
48504722
*/
@@ -4853,11 +4725,11 @@
48534725
SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
48544726
SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
48554727
SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
48564728
48574729
/*
4858
-** CAPI3REF: Mutex Methods Object {H17120} <S20130>
4730
+** CAPI3REF: Mutex Methods Object
48594731
** EXPERIMENTAL
48604732
**
48614733
** An instance of this structure defines the low-level routines
48624734
** used to allocate and use mutexes.
48634735
**
@@ -4869,23 +4741,23 @@
48694741
** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
48704742
** Additionally, an instance of this structure can be used as an
48714743
** output variable when querying the system for the current mutex
48724744
** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
48734745
**
4874
-** The xMutexInit method defined by this structure is invoked as
4746
+** ^The xMutexInit method defined by this structure is invoked as
48754747
** part of system initialization by the sqlite3_initialize() function.
4876
-** {H17001} The xMutexInit routine shall be called by SQLite once for each
4748
+** ^The xMutexInit routine is calle by SQLite exactly once for each
48774749
** effective call to [sqlite3_initialize()].
48784750
**
4879
-** The xMutexEnd method defined by this structure is invoked as
4751
+** ^The xMutexEnd method defined by this structure is invoked as
48804752
** part of system shutdown by the sqlite3_shutdown() function. The
48814753
** implementation of this method is expected to release all outstanding
48824754
** resources obtained by the mutex methods implementation, especially
4883
-** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
4884
-** interface shall be invoked once for each call to [sqlite3_shutdown()].
4755
+** those obtained by the xMutexInit method. ^The xMutexEnd()
4756
+** interface is invoked exactly once for each call to [sqlite3_shutdown()].
48854757
**
4886
-** The remaining seven methods defined by this structure (xMutexAlloc,
4758
+** ^(The remaining seven methods defined by this structure (xMutexAlloc,
48874759
** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
48884760
** xMutexNotheld) implement the following interfaces (respectively):
48894761
**
48904762
** <ul>
48914763
** <li> [sqlite3_mutex_alloc()] </li>
@@ -4893,31 +4765,31 @@
48934765
** <li> [sqlite3_mutex_enter()] </li>
48944766
** <li> [sqlite3_mutex_try()] </li>
48954767
** <li> [sqlite3_mutex_leave()] </li>
48964768
** <li> [sqlite3_mutex_held()] </li>
48974769
** <li> [sqlite3_mutex_notheld()] </li>
4898
-** </ul>
4770
+** </ul>)^
48994771
**
49004772
** The only difference is that the public sqlite3_XXX functions enumerated
49014773
** above silently ignore any invocations that pass a NULL pointer instead
49024774
** of a valid mutex handle. The implementations of the methods defined
49034775
** by this structure are not required to handle this case, the results
49044776
** of passing a NULL pointer instead of a valid mutex handle are undefined
49054777
** (i.e. it is acceptable to provide an implementation that segfaults if
49064778
** it is passed a NULL pointer).
49074779
**
4908
-** The xMutexInit() method must be threadsafe. It must be harmless to
4780
+** The xMutexInit() method must be threadsafe. ^It must be harmless to
49094781
** invoke xMutexInit() mutiple times within the same process and without
49104782
** intervening calls to xMutexEnd(). Second and subsequent calls to
49114783
** xMutexInit() must be no-ops.
49124784
**
4913
-** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
4914
-** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
4915
-** allocation for a static mutex. However xMutexAlloc() may use SQLite
4785
+** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
4786
+** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
4787
+** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
49164788
** memory allocation for a fast or recursive mutex.
49174789
**
4918
-** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
4790
+** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
49194791
** called, but only if the prior call to xMutexInit returned SQLITE_OK.
49204792
** If xMutexInit fails in any way, it is expected to clean up after itself
49214793
** prior to returning.
49224794
*/
49234795
typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -4932,43 +4804,45 @@
49324804
int (*xMutexHeld)(sqlite3_mutex *);
49334805
int (*xMutexNotheld)(sqlite3_mutex *);
49344806
};
49354807
49364808
/*
4937
-** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
4809
+** CAPI3REF: Mutex Verification Routines
49384810
**
49394811
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
4940
-** are intended for use inside assert() statements. {H17081} The SQLite core
4812
+** are intended for use inside assert() statements. ^The SQLite core
49414813
** never uses these routines except inside an assert() and applications
4942
-** are advised to follow the lead of the core. {H17082} The core only
4814
+** are advised to follow the lead of the core. ^The SQLite core only
49434815
** provides implementations for these routines when it is compiled
4944
-** with the SQLITE_DEBUG flag. {A17087} External mutex implementations
4816
+** with the SQLITE_DEBUG flag. ^External mutex implementations
49454817
** are only required to provide these routines if SQLITE_DEBUG is
49464818
** defined and if NDEBUG is not defined.
49474819
**
4948
-** {H17083} These routines should return true if the mutex in their argument
4820
+** ^These routines should return true if the mutex in their argument
49494821
** is held or not held, respectively, by the calling thread.
49504822
**
4951
-** {X17084} The implementation is not required to provided versions of these
4823
+** ^The implementation is not required to provided versions of these
49524824
** routines that actually work. If the implementation does not provide working
49534825
** versions of these routines, it should at least provide stubs that always
49544826
** return true so that one does not get spurious assertion failures.
49554827
**
4956
-** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
4957
-** the routine should return 1. {END} This seems counter-intuitive since
4828
+** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
4829
+** the routine should return 1. This seems counter-intuitive since
49584830
** clearly the mutex cannot be held if it does not exist. But the
49594831
** the reason the mutex does not exist is because the build is not
49604832
** using mutexes. And we do not want the assert() containing the
49614833
** call to sqlite3_mutex_held() to fail, so a non-zero return is
4962
-** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld()
4834
+** the appropriate thing to do. ^The sqlite3_mutex_notheld()
49634835
** interface should also return 1 when given a NULL pointer.
49644836
*/
4837
+#ifndef NDEBUG
49654838
SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
49664839
SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
4840
+#endif
49674841
49684842
/*
4969
-** CAPI3REF: Mutex Types {H17001} <H17000>
4843
+** CAPI3REF: Mutex Types
49704844
**
49714845
** The [sqlite3_mutex_alloc()] interface takes a single argument
49724846
** which is one of these integer constants.
49734847
**
49744848
** The set of static mutexes may change from one SQLite release to the
@@ -4984,52 +4858,54 @@
49844858
#define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
49854859
#define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
49864860
#define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
49874861
49884862
/*
4989
-** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
4863
+** CAPI3REF: Retrieve the mutex for a database connection
49904864
**
4991
-** This interface returns a pointer the [sqlite3_mutex] object that
4865
+** ^This interface returns a pointer the [sqlite3_mutex] object that
49924866
** serializes access to the [database connection] given in the argument
49934867
** when the [threading mode] is Serialized.
4994
-** If the [threading mode] is Single-thread or Multi-thread then this
4868
+** ^If the [threading mode] is Single-thread or Multi-thread then this
49954869
** routine returns a NULL pointer.
49964870
*/
49974871
SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
49984872
49994873
/*
5000
-** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
4874
+** CAPI3REF: Low-Level Control Of Database Files
50014875
**
5002
-** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
4876
+** ^The [sqlite3_file_control()] interface makes a direct call to the
50034877
** xFileControl method for the [sqlite3_io_methods] object associated
5004
-** with a particular database identified by the second argument. {H11302} The
5005
-** name of the database is the name assigned to the database by the
5006
-** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
5007
-** database. {H11303} To control the main database file, use the name "main"
5008
-** or a NULL pointer. {H11304} The third and fourth parameters to this routine
4878
+** with a particular database identified by the second argument. ^The
4879
+** name of the database "main" for the main database or "temp" for the
4880
+** TEMP database, or the name that appears after the AS keyword for
4881
+** databases that are added using the [ATTACH] SQL command.
4882
+** ^A NULL pointer can be used in place of "main" to refer to the
4883
+** main database file.
4884
+** ^The third and fourth parameters to this routine
50094885
** are passed directly through to the second and third parameters of
5010
-** the xFileControl method. {H11305} The return value of the xFileControl
4886
+** the xFileControl method. ^The return value of the xFileControl
50114887
** method becomes the return value of this routine.
50124888
**
5013
-** {H11306} If the second parameter (zDbName) does not match the name of any
5014
-** open database file, then SQLITE_ERROR is returned. {H11307} This error
4889
+** ^If the second parameter (zDbName) does not match the name of any
4890
+** open database file, then SQLITE_ERROR is returned. ^This error
50154891
** code is not remembered and will not be recalled by [sqlite3_errcode()]
5016
-** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
5017
-** also return SQLITE_ERROR. {A11309} There is no way to distinguish between
4892
+** or [sqlite3_errmsg()]. The underlying xFileControl method might
4893
+** also return SQLITE_ERROR. There is no way to distinguish between
50184894
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
5019
-** xFileControl method. {END}
4895
+** xFileControl method.
50204896
**
50214897
** See also: [SQLITE_FCNTL_LOCKSTATE]
50224898
*/
50234899
SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
50244900
50254901
/*
5026
-** CAPI3REF: Testing Interface {H11400} <S30800>
4902
+** CAPI3REF: Testing Interface
50274903
**
5028
-** The sqlite3_test_control() interface is used to read out internal
4904
+** ^The sqlite3_test_control() interface is used to read out internal
50294905
** state of SQLite and to inject faults into SQLite for testing
5030
-** purposes. The first parameter is an operation code that determines
4906
+** purposes. ^The first parameter is an operation code that determines
50314907
** the number, meaning, and operation of all subsequent parameters.
50324908
**
50334909
** This interface is not for use by applications. It exists solely
50344910
** for verifying the correct operation of the SQLite library. Depending
50354911
** on how the SQLite library is compiled, this interface might not exist.
@@ -5040,20 +4916,21 @@
50404916
** operate consistently from one release to the next.
50414917
*/
50424918
SQLITE_API int sqlite3_test_control(int op, ...);
50434919
50444920
/*
5045
-** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
4921
+** CAPI3REF: Testing Interface Operation Codes
50464922
**
50474923
** These constants are the valid operation code parameters used
50484924
** as the first argument to [sqlite3_test_control()].
50494925
**
50504926
** These parameters and their meanings are subject to change
50514927
** without notice. These values are for testing purposes only.
50524928
** Applications should not use any of these parameters or the
50534929
** [sqlite3_test_control()] interface.
50544930
*/
4931
+#define SQLITE_TESTCTRL_FIRST 5
50554932
#define SQLITE_TESTCTRL_PRNG_SAVE 5
50564933
#define SQLITE_TESTCTRL_PRNG_RESTORE 6
50574934
#define SQLITE_TESTCTRL_PRNG_RESET 7
50584935
#define SQLITE_TESTCTRL_BITVEC_TEST 8
50594936
#define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5060,31 +4937,34 @@
50604937
#define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
50614938
#define SQLITE_TESTCTRL_PENDING_BYTE 11
50624939
#define SQLITE_TESTCTRL_ASSERT 12
50634940
#define SQLITE_TESTCTRL_ALWAYS 13
50644941
#define SQLITE_TESTCTRL_RESERVE 14
4942
+#define SQLITE_TESTCTRL_OPTIMIZATIONS 15
4943
+#define SQLITE_TESTCTRL_ISKEYWORD 16
4944
+#define SQLITE_TESTCTRL_LAST 16
50654945
50664946
/*
5067
-** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
4947
+** CAPI3REF: SQLite Runtime Status
50684948
** EXPERIMENTAL
50694949
**
5070
-** This interface is used to retrieve runtime status information
4950
+** ^This interface is used to retrieve runtime status information
50714951
** about the preformance of SQLite, and optionally to reset various
5072
-** highwater marks. The first argument is an integer code for
5073
-** the specific parameter to measure. Recognized integer codes
5074
-** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].
5075
-** The current value of the parameter is returned into *pCurrent.
5076
-** The highest recorded value is returned in *pHighwater. If the
4952
+** highwater marks. ^The first argument is an integer code for
4953
+** the specific parameter to measure. ^(Recognized integer codes
4954
+** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
4955
+** ^The current value of the parameter is returned into *pCurrent.
4956
+** ^The highest recorded value is returned in *pHighwater. ^If the
50774957
** resetFlag is true, then the highest record value is reset after
5078
-** *pHighwater is written. Some parameters do not record the highest
4958
+** *pHighwater is written. ^(Some parameters do not record the highest
50794959
** value. For those parameters
5080
-** nothing is written into *pHighwater and the resetFlag is ignored.
5081
-** Other parameters record only the highwater mark and not the current
5082
-** value. For these latter parameters nothing is written into *pCurrent.
4960
+** nothing is written into *pHighwater and the resetFlag is ignored.)^
4961
+** ^(Other parameters record only the highwater mark and not the current
4962
+** value. For these latter parameters nothing is written into *pCurrent.)^
50834963
**
5084
-** This routine returns SQLITE_OK on success and a non-zero
5085
-** [error code] on failure.
4964
+** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
4965
+** non-zero [error code] on failure.
50864966
**
50874967
** This routine is threadsafe but is not atomic. This routine can be
50884968
** called while other threads are running the same or different SQLite
50894969
** interfaces. However the values returned in *pCurrent and
50904970
** *pHighwater reflect the status of SQLite at different points in time
@@ -5095,82 +4975,82 @@
50954975
*/
50964976
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
50974977
50984978
50994979
/*
5100
-** CAPI3REF: Status Parameters {H17250} <H17200>
4980
+** CAPI3REF: Status Parameters
51014981
** EXPERIMENTAL
51024982
**
51034983
** These integer constants designate various run-time status parameters
51044984
** that can be returned by [sqlite3_status()].
51054985
**
51064986
** <dl>
5107
-** <dt>SQLITE_STATUS_MEMORY_USED</dt>
4987
+** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
51084988
** <dd>This parameter is the current amount of memory checked out
51094989
** using [sqlite3_malloc()], either directly or indirectly. The
51104990
** figure includes calls made to [sqlite3_malloc()] by the application
51114991
** and internal memory usage by the SQLite library. Scratch memory
51124992
** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
51134993
** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
51144994
** this parameter. The amount returned is the sum of the allocation
5115
-** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
4995
+** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
51164996
**
5117
-** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
4997
+** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
51184998
** <dd>This parameter records the largest memory allocation request
51194999
** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
51205000
** internal equivalents). Only the value returned in the
51215001
** *pHighwater parameter to [sqlite3_status()] is of interest.
5122
-** The value written into the *pCurrent parameter is undefined.</dd>
5002
+** The value written into the *pCurrent parameter is undefined.</dd>)^
51235003
**
5124
-** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5004
+** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
51255005
** <dd>This parameter returns the number of pages used out of the
51265006
** [pagecache memory allocator] that was configured using
51275007
** [SQLITE_CONFIG_PAGECACHE]. The
5128
-** value returned is in pages, not in bytes.</dd>
5008
+** value returned is in pages, not in bytes.</dd>)^
51295009
**
5130
-** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5010
+** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
51315011
** <dd>This parameter returns the number of bytes of page cache
51325012
** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
51335013
** buffer and where forced to overflow to [sqlite3_malloc()]. The
51345014
** returned value includes allocations that overflowed because they
51355015
** where too large (they were larger than the "sz" parameter to
51365016
** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5137
-** no space was left in the page cache.</dd>
5017
+** no space was left in the page cache.</dd>)^
51385018
**
5139
-** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5019
+** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
51405020
** <dd>This parameter records the largest memory allocation request
51415021
** handed to [pagecache memory allocator]. Only the value returned in the
51425022
** *pHighwater parameter to [sqlite3_status()] is of interest.
5143
-** The value written into the *pCurrent parameter is undefined.</dd>
5023
+** The value written into the *pCurrent parameter is undefined.</dd>)^
51445024
**
5145
-** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
5025
+** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
51465026
** <dd>This parameter returns the number of allocations used out of the
51475027
** [scratch memory allocator] configured using
51485028
** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
51495029
** in bytes. Since a single thread may only have one scratch allocation
51505030
** outstanding at time, this parameter also reports the number of threads
5151
-** using scratch memory at the same time.</dd>
5031
+** using scratch memory at the same time.</dd>)^
51525032
**
5153
-** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5033
+** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
51545034
** <dd>This parameter returns the number of bytes of scratch memory
51555035
** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
51565036
** buffer and where forced to overflow to [sqlite3_malloc()]. The values
51575037
** returned include overflows because the requested allocation was too
51585038
** larger (that is, because the requested allocation was larger than the
51595039
** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
51605040
** slots were available.
5161
-** </dd>
5041
+** </dd>)^
51625042
**
5163
-** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5043
+** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
51645044
** <dd>This parameter records the largest memory allocation request
51655045
** handed to [scratch memory allocator]. Only the value returned in the
51665046
** *pHighwater parameter to [sqlite3_status()] is of interest.
5167
-** The value written into the *pCurrent parameter is undefined.</dd>
5047
+** The value written into the *pCurrent parameter is undefined.</dd>)^
51685048
**
5169
-** <dt>SQLITE_STATUS_PARSER_STACK</dt>
5049
+** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
51705050
** <dd>This parameter records the deepest parser stack. It is only
5171
-** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
5051
+** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
51725052
** </dl>
51735053
**
51745054
** New status parameters may be added from time to time.
51755055
*/
51765056
#define SQLITE_STATUS_MEMORY_USED 0
@@ -5182,31 +5062,31 @@
51825062
#define SQLITE_STATUS_PARSER_STACK 6
51835063
#define SQLITE_STATUS_PAGECACHE_SIZE 7
51845064
#define SQLITE_STATUS_SCRATCH_SIZE 8
51855065
51865066
/*
5187
-** CAPI3REF: Database Connection Status {H17500} <S60200>
5067
+** CAPI3REF: Database Connection Status
51885068
** EXPERIMENTAL
51895069
**
5190
-** This interface is used to retrieve runtime status information
5191
-** about a single [database connection]. The first argument is the
5192
-** database connection object to be interrogated. The second argument
5193
-** is the parameter to interrogate. Currently, the only allowed value
5070
+** ^This interface is used to retrieve runtime status information
5071
+** about a single [database connection]. ^The first argument is the
5072
+** database connection object to be interrogated. ^The second argument
5073
+** is the parameter to interrogate. ^Currently, the only allowed value
51945074
** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
51955075
** Additional options will likely appear in future releases of SQLite.
51965076
**
5197
-** The current value of the requested parameter is written into *pCur
5198
-** and the highest instantaneous value is written into *pHiwtr. If
5077
+** ^The current value of the requested parameter is written into *pCur
5078
+** and the highest instantaneous value is written into *pHiwtr. ^If
51995079
** the resetFlg is true, then the highest instantaneous value is
52005080
** reset back down to the current value.
52015081
**
52025082
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
52035083
*/
52045084
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
52055085
52065086
/*
5207
-** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
5087
+** CAPI3REF: Status Parameters for database connections
52085088
** EXPERIMENTAL
52095089
**
52105090
** These constants are the available integer "verbs" that can be passed as
52115091
** the second argument to the [sqlite3_db_status()] interface.
52125092
**
@@ -5215,61 +5095,61 @@
52155095
** [sqlite3_db_status()] to make sure that the call worked.
52165096
** The [sqlite3_db_status()] interface will return a non-zero error code
52175097
** if a discontinued or unsupported verb is invoked.
52185098
**
52195099
** <dl>
5220
-** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5100
+** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
52215101
** <dd>This parameter returns the number of lookaside memory slots currently
5222
-** checked out.</dd>
5102
+** checked out.</dd>)^
52235103
** </dl>
52245104
*/
52255105
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
52265106
52275107
52285108
/*
5229
-** CAPI3REF: Prepared Statement Status {H17550} <S60200>
5109
+** CAPI3REF: Prepared Statement Status
52305110
** EXPERIMENTAL
52315111
**
5232
-** Each prepared statement maintains various
5112
+** ^(Each prepared statement maintains various
52335113
** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5234
-** of times it has performed specific operations. These counters can
5114
+** of times it has performed specific operations.)^ These counters can
52355115
** be used to monitor the performance characteristics of the prepared
52365116
** statements. For example, if the number of table steps greatly exceeds
52375117
** the number of table searches or result rows, that would tend to indicate
52385118
** that the prepared statement is using a full table scan rather than
52395119
** an index.
52405120
**
5241
-** This interface is used to retrieve and reset counter values from
5121
+** ^(This interface is used to retrieve and reset counter values from
52425122
** a [prepared statement]. The first argument is the prepared statement
52435123
** object to be interrogated. The second argument
52445124
** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5245
-** to be interrogated.
5246
-** The current value of the requested counter is returned.
5247
-** If the resetFlg is true, then the counter is reset to zero after this
5125
+** to be interrogated.)^
5126
+** ^The current value of the requested counter is returned.
5127
+** ^If the resetFlg is true, then the counter is reset to zero after this
52485128
** interface call returns.
52495129
**
52505130
** See also: [sqlite3_status()] and [sqlite3_db_status()].
52515131
*/
52525132
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
52535133
52545134
/*
5255
-** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
5135
+** CAPI3REF: Status Parameters for prepared statements
52565136
** EXPERIMENTAL
52575137
**
52585138
** These preprocessor macros define integer codes that name counter
52595139
** values associated with the [sqlite3_stmt_status()] interface.
52605140
** The meanings of the various counters are as follows:
52615141
**
52625142
** <dl>
52635143
** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5264
-** <dd>This is the number of times that SQLite has stepped forward in
5144
+** <dd>^This is the number of times that SQLite has stepped forward in
52655145
** a table as part of a full table scan. Large numbers for this counter
52665146
** may indicate opportunities for performance improvement through
52675147
** careful use of indices.</dd>
52685148
**
52695149
** <dt>SQLITE_STMTSTATUS_SORT</dt>
5270
-** <dd>This is the number of sort operations that have occurred.
5150
+** <dd>^This is the number of sort operations that have occurred.
52715151
** A non-zero value in this counter may indicate an opportunity to
52725152
** improvement performance through careful use of indices.</dd>
52735153
**
52745154
** </dl>
52755155
*/
@@ -5293,84 +5173,84 @@
52935173
/*
52945174
** CAPI3REF: Application Defined Page Cache.
52955175
** KEYWORDS: {page cache}
52965176
** EXPERIMENTAL
52975177
**
5298
-** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5178
+** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
52995179
** register an alternative page cache implementation by passing in an
5300
-** instance of the sqlite3_pcache_methods structure. The majority of the
5180
+** instance of the sqlite3_pcache_methods structure.)^ The majority of the
53015181
** heap memory used by SQLite is used by the page cache to cache data read
53025182
** from, or ready to be written to, the database file. By implementing a
53035183
** custom page cache using this API, an application can control more
53045184
** precisely the amount of memory consumed by SQLite, the way in which
53055185
** that memory is allocated and released, and the policies used to
53065186
** determine exactly which parts of a database file are cached and for
53075187
** how long.
53085188
**
5309
-** The contents of the sqlite3_pcache_methods structure are copied to an
5189
+** ^(The contents of the sqlite3_pcache_methods structure are copied to an
53105190
** internal buffer by SQLite within the call to [sqlite3_config]. Hence
53115191
** the application may discard the parameter after the call to
5312
-** [sqlite3_config()] returns.
5313
-**
5314
-** The xInit() method is called once for each call to [sqlite3_initialize()]
5315
-** (usually only once during the lifetime of the process). It is passed
5316
-** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
5317
-** up global structures and mutexes required by the custom page cache
5318
-** implementation.
5319
-**
5320
-** The xShutdown() method is called from within [sqlite3_shutdown()],
5192
+** [sqlite3_config()] returns.)^
5193
+**
5194
+** ^The xInit() method is called once for each call to [sqlite3_initialize()]
5195
+** (usually only once during the lifetime of the process). ^(The xInit()
5196
+** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
5197
+** ^The xInit() method can set up up global structures and/or any mutexes
5198
+** required by the custom page cache implementation.
5199
+**
5200
+** ^The xShutdown() method is called from within [sqlite3_shutdown()],
53215201
** if the application invokes this API. It can be used to clean up
53225202
** any outstanding resources before process shutdown, if required.
53235203
**
5324
-** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5325
-** the xInit method, so the xInit method need not be threadsafe. The
5204
+** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5205
+** the xInit method, so the xInit method need not be threadsafe. ^The
53265206
** xShutdown method is only called from [sqlite3_shutdown()] so it does
53275207
** not need to be threadsafe either. All other methods must be threadsafe
53285208
** in multithreaded applications.
53295209
**
5330
-** SQLite will never invoke xInit() more than once without an intervening
5210
+** ^SQLite will never invoke xInit() more than once without an intervening
53315211
** call to xShutdown().
53325212
**
5333
-** The xCreate() method is used to construct a new cache instance. SQLite
5213
+** ^The xCreate() method is used to construct a new cache instance. SQLite
53345214
** will typically create one cache instance for each open database file,
5335
-** though this is not guaranteed. The
5215
+** though this is not guaranteed. ^The
53365216
** first parameter, szPage, is the size in bytes of the pages that must
5337
-** be allocated by the cache. szPage will not be a power of two. szPage
5217
+** be allocated by the cache. ^szPage will not be a power of two. ^szPage
53385218
** will the page size of the database file that is to be cached plus an
5339
-** increment (here called "R") of about 100 or 200. SQLite will use the
5219
+** increment (here called "R") of about 100 or 200. ^SQLite will use the
53405220
** extra R bytes on each page to store metadata about the underlying
53415221
** database page on disk. The value of R depends
53425222
** on the SQLite version, the target platform, and how SQLite was compiled.
5343
-** R is constant for a particular build of SQLite. The second argument to
5223
+** ^R is constant for a particular build of SQLite. ^The second argument to
53445224
** xCreate(), bPurgeable, is true if the cache being created will
53455225
** be used to cache database pages of a file stored on disk, or
5346
-** false if it is used for an in-memory database. The cache implementation
5226
+** false if it is used for an in-memory database. ^The cache implementation
53475227
** does not have to do anything special based with the value of bPurgeable;
5348
-** it is purely advisory. On a cache where bPurgeable is false, SQLite will
5228
+** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
53495229
** never invoke xUnpin() except to deliberately delete a page.
5350
-** In other words, a cache created with bPurgeable set to false will
5230
+** ^In other words, a cache created with bPurgeable set to false will
53515231
** never contain any unpinned pages.
53525232
**
5353
-** The xCachesize() method may be called at any time by SQLite to set the
5233
+** ^(The xCachesize() method may be called at any time by SQLite to set the
53545234
** suggested maximum cache-size (number of pages stored by) the cache
53555235
** instance passed as the first argument. This is the value configured using
5356
-** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter,
5357
-** the implementation is not required to do anything with this
5236
+** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable
5237
+** parameter, the implementation is not required to do anything with this
53585238
** value; it is advisory only.
53595239
**
5360
-** The xPagecount() method should return the number of pages currently
5240
+** ^The xPagecount() method should return the number of pages currently
53615241
** stored in the cache.
53625242
**
5363
-** The xFetch() method is used to fetch a page and return a pointer to it.
5364
-** A 'page', in this context, is a buffer of szPage bytes aligned at an
5365
-** 8-byte boundary. The page to be fetched is determined by the key. The
5243
+** ^The xFetch() method is used to fetch a page and return a pointer to it.
5244
+** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
5245
+** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
53665246
** mimimum key value is 1. After it has been retrieved using xFetch, the page
53675247
** is considered to be "pinned".
53685248
**
5369
-** If the requested page is already in the page cache, then the page cache
5249
+** ^If the requested page is already in the page cache, then the page cache
53705250
** implementation must return a pointer to the page buffer with its content
5371
-** intact. If the requested page is not already in the cache, then the
5251
+** intact. ^(If the requested page is not already in the cache, then the
53725252
** behavior of the cache implementation is determined by the value of the
53735253
** createFlag parameter passed to xFetch, according to the following table:
53745254
**
53755255
** <table border=1 width=85% align=center>
53765256
** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5377,45 +5257,45 @@
53775257
** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
53785258
** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
53795259
** Otherwise return NULL.
53805260
** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
53815261
** NULL if allocating a new page is effectively impossible.
5382
-** </table>
5262
+** </table>)^
53835263
**
53845264
** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
53855265
** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
53865266
** attempt to unpin one or more cache pages by spilling the content of
53875267
** pinned pages to disk and synching the operating system disk cache. After
53885268
** attempting to unpin pages, the xFetch() method will be invoked again with
53895269
** a createFlag of 2.
53905270
**
5391
-** xUnpin() is called by SQLite with a pointer to a currently pinned page
5392
-** as its second argument. If the third parameter, discard, is non-zero,
5271
+** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
5272
+** as its second argument. ^(If the third parameter, discard, is non-zero,
53935273
** then the page should be evicted from the cache. In this case SQLite
53945274
** assumes that the next time the page is retrieved from the cache using
5395
-** the xFetch() method, it will be zeroed. If the discard parameter is
5396
-** zero, then the page is considered to be unpinned. The cache implementation
5275
+** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
5276
+** zero, then the page is considered to be unpinned. ^The cache implementation
53975277
** may choose to evict unpinned pages at any time.
53985278
**
5399
-** The cache is not required to perform any reference counting. A single
5279
+** ^(The cache is not required to perform any reference counting. A single
54005280
** call to xUnpin() unpins the page regardless of the number of prior calls
5401
-** to xFetch().
5281
+** to xFetch().)^
54025282
**
5403
-** The xRekey() method is used to change the key value associated with the
5404
-** page passed as the second argument from oldKey to newKey. If the cache
5283
+** ^The xRekey() method is used to change the key value associated with the
5284
+** page passed as the second argument from oldKey to newKey. ^If the cache
54055285
** previously contains an entry associated with newKey, it should be
5406
-** discarded. Any prior cache entry associated with newKey is guaranteed not
5286
+** discarded. ^Any prior cache entry associated with newKey is guaranteed not
54075287
** to be pinned.
54085288
**
5409
-** When SQLite calls the xTruncate() method, the cache must discard all
5289
+** ^When SQLite calls the xTruncate() method, the cache must discard all
54105290
** existing cache entries with page numbers (keys) greater than or equal
5411
-** to the value of the iLimit parameter passed to xTruncate(). If any
5291
+** to the value of the iLimit parameter passed to xTruncate(). ^If any
54125292
** of these pages are pinned, they are implicitly unpinned, meaning that
54135293
** they can be safely discarded.
54145294
**
5415
-** The xDestroy() method is used to delete a cache allocated by xCreate().
5416
-** All resources associated with the specified cache should be freed. After
5295
+** ^The xDestroy() method is used to delete a cache allocated by xCreate().
5296
+** All resources associated with the specified cache should be freed. ^After
54175297
** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
54185298
** handle invalid, and will not use it with any other sqlite3_pcache_methods
54195299
** functions.
54205300
*/
54215301
typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5436,11 +5316,11 @@
54365316
/*
54375317
** CAPI3REF: Online Backup Object
54385318
** EXPERIMENTAL
54395319
**
54405320
** The sqlite3_backup object records state information about an ongoing
5441
-** online backup operation. The sqlite3_backup object is created by
5321
+** online backup operation. ^The sqlite3_backup object is created by
54425322
** a call to [sqlite3_backup_init()] and is destroyed by a call to
54435323
** [sqlite3_backup_finish()].
54445324
**
54455325
** See Also: [Using the SQLite Online Backup API]
54465326
*/
@@ -5448,168 +5328,173 @@
54485328
54495329
/*
54505330
** CAPI3REF: Online Backup API.
54515331
** EXPERIMENTAL
54525332
**
5453
-** This API is used to overwrite the contents of one database with that
5454
-** of another. It is useful either for creating backups of databases or
5333
+** The backup API copies the content of one database into another.
5334
+** It is useful either for creating backups of databases or
54555335
** for copying in-memory databases to or from persistent files.
54565336
**
54575337
** See Also: [Using the SQLite Online Backup API]
54585338
**
5459
-** Exclusive access is required to the destination database for the
5460
-** duration of the operation. However the source database is only
5461
-** read-locked while it is actually being read, it is not locked
5462
-** continuously for the entire operation. Thus, the backup may be
5463
-** performed on a live database without preventing other users from
5464
-** writing to the database for an extended period of time.
5339
+** ^Exclusive access is required to the destination database for the
5340
+** duration of the operation. ^However the source database is only
5341
+** read-locked while it is actually being read; it is not locked
5342
+** continuously for the entire backup operation. ^Thus, the backup may be
5343
+** performed on a live source database without preventing other users from
5344
+** reading or writing to the source database while the backup is underway.
54655345
**
5466
-** To perform a backup operation:
5346
+** ^(To perform a backup operation:
54675347
** <ol>
54685348
** <li><b>sqlite3_backup_init()</b> is called once to initialize the
54695349
** backup,
54705350
** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
54715351
** the data between the two databases, and finally
54725352
** <li><b>sqlite3_backup_finish()</b> is called to release all resources
54735353
** associated with the backup operation.
5474
-** </ol>
5354
+** </ol>)^
54755355
** There should be exactly one call to sqlite3_backup_finish() for each
54765356
** successful call to sqlite3_backup_init().
54775357
**
54785358
** <b>sqlite3_backup_init()</b>
54795359
**
5480
-** The first two arguments passed to [sqlite3_backup_init()] are the database
5481
-** handle associated with the destination database and the database name
5482
-** used to attach the destination database to the handle. The database name
5483
-** is "main" for the main database, "temp" for the temporary database, or
5484
-** the name specified as part of the [ATTACH] statement if the destination is
5485
-** an attached database. The third and fourth arguments passed to
5486
-** sqlite3_backup_init() identify the [database connection]
5487
-** and database name used
5488
-** to access the source database. The values passed for the source and
5489
-** destination [database connection] parameters must not be the same.
5360
+** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
5361
+** [database connection] associated with the destination database
5362
+** and the database name, respectively.
5363
+** ^The database name is "main" for the main database, "temp" for the
5364
+** temporary database, or the name specified after the AS keyword in
5365
+** an [ATTACH] statement for an attached database.
5366
+** ^The S and M arguments passed to
5367
+** sqlite3_backup_init(D,N,S,M) identify the [database connection]
5368
+** and database name of the source database, respectively.
5369
+** ^The source and destination [database connections] (parameters S and D)
5370
+** must be different or else sqlite3_backup_init(D,N,S,M) will file with
5371
+** an error.
54905372
**
5491
-** If an error occurs within sqlite3_backup_init(), then NULL is returned
5492
-** and an error code and error message written into the [database connection]
5493
-** passed as the first argument. They may be retrieved using the
5494
-** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
5495
-** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
5496
-** returned. This pointer may be used with the sqlite3_backup_step() and
5373
+** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
5374
+** returned and an error code and error message are store3d in the
5375
+** destination [database connection] D.
5376
+** ^The error code and message for the failed call to sqlite3_backup_init()
5377
+** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
5378
+** [sqlite3_errmsg16()] functions.
5379
+** ^A successful call to sqlite3_backup_init() returns a pointer to an
5380
+** [sqlite3_backup] object.
5381
+** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
54975382
** sqlite3_backup_finish() functions to perform the specified backup
54985383
** operation.
54995384
**
55005385
** <b>sqlite3_backup_step()</b>
55015386
**
5502
-** Function [sqlite3_backup_step()] is used to copy up to nPage pages between
5503
-** the source and destination databases, where nPage is the value of the
5504
-** second parameter passed to sqlite3_backup_step(). If nPage is a negative
5505
-** value, all remaining source pages are copied. If the required pages are
5506
-** succesfully copied, but there are still more pages to copy before the
5507
-** backup is complete, it returns [SQLITE_OK]. If no error occured and there
5508
-** are no more pages to copy, then [SQLITE_DONE] is returned. If an error
5509
-** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
5387
+** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
5388
+** the source and destination databases specified by [sqlite3_backup] object B.
5389
+** ^If N is negative, all remaining source pages are copied.
5390
+** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
5391
+** are still more pages to be copied, then the function resturns [SQLITE_OK].
5392
+** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
5393
+** from source to destination, then it returns [SQLITE_DONE].
5394
+** ^If an error occurs while running sqlite3_backup_step(B,N),
5395
+** then an [error code] is returned. ^As well as [SQLITE_OK] and
55105396
** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
55115397
** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
55125398
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
55135399
**
5514
-** As well as the case where the destination database file was opened for
5515
-** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
5400
+** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
5401
+** database was opened read-only or if
55165402
** the destination is an in-memory database with a different page size
55175403
** from the source database.
55185404
**
5519
-** If sqlite3_backup_step() cannot obtain a required file-system lock, then
5405
+** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
55205406
** the [sqlite3_busy_handler | busy-handler function]
5521
-** is invoked (if one is specified). If the
5407
+** is invoked (if one is specified). ^If the
55225408
** busy-handler returns non-zero before the lock is available, then
5523
-** [SQLITE_BUSY] is returned to the caller. In this case the call to
5524
-** sqlite3_backup_step() can be retried later. If the source
5409
+** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
5410
+** sqlite3_backup_step() can be retried later. ^If the source
55255411
** [database connection]
55265412
** is being used to write to the source database when sqlite3_backup_step()
5527
-** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
5528
-** case the call to sqlite3_backup_step() can be retried later on. If
5413
+** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
5414
+** case the call to sqlite3_backup_step() can be retried later on. ^(If
55295415
** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
55305416
** [SQLITE_READONLY] is returned, then
55315417
** there is no point in retrying the call to sqlite3_backup_step(). These
5532
-** errors are considered fatal. At this point the application must accept
5418
+** errors are considered fatal.)^ The application must accept
55335419
** that the backup operation has failed and pass the backup operation handle
55345420
** to the sqlite3_backup_finish() to release associated resources.
55355421
**
5536
-** Following the first call to sqlite3_backup_step(), an exclusive lock is
5537
-** obtained on the destination file. It is not released until either
5422
+** ^The first call to sqlite3_backup_step() obtains an exclusive lock
5423
+** on the destination file. ^The exclusive lock is not released until either
55385424
** sqlite3_backup_finish() is called or the backup operation is complete
5539
-** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time
5540
-** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
5541
-** the source database file. This lock is released before the
5542
-** sqlite3_backup_step() call returns. Because the source database is not
5543
-** locked between calls to sqlite3_backup_step(), it may be modified mid-way
5544
-** through the backup procedure. If the source database is modified by an
5425
+** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to
5426
+** sqlite3_backup_step() obtains a [shared lock] on the source database that
5427
+** lasts for the duration of the sqlite3_backup_step() call.
5428
+** ^Because the source database is not locked between calls to
5429
+** sqlite3_backup_step(), the source database may be modified mid-way
5430
+** through the backup process. ^If the source database is modified by an
55455431
** external process or via a database connection other than the one being
5546
-** used by the backup operation, then the backup will be transparently
5547
-** restarted by the next call to sqlite3_backup_step(). If the source
5432
+** used by the backup operation, then the backup will be automatically
5433
+** restarted by the next call to sqlite3_backup_step(). ^If the source
55485434
** database is modified by the using the same database connection as is used
5549
-** by the backup operation, then the backup database is transparently
5435
+** by the backup operation, then the backup database is automatically
55505436
** updated at the same time.
55515437
**
55525438
** <b>sqlite3_backup_finish()</b>
55535439
**
5554
-** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5555
-** application wishes to abandon the backup operation, the [sqlite3_backup]
5556
-** object should be passed to sqlite3_backup_finish(). This releases all
5557
-** resources associated with the backup operation. If sqlite3_backup_step()
5558
-** has not yet returned [SQLITE_DONE], then any active write-transaction on the
5559
-** destination database is rolled back. The [sqlite3_backup] object is invalid
5440
+** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5441
+** application wishes to abandon the backup operation, the application
5442
+** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
5443
+** ^The sqlite3_backup_finish() interfaces releases all
5444
+** resources associated with the [sqlite3_backup] object.
5445
+** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
5446
+** active write-transaction on the destination database is rolled back.
5447
+** The [sqlite3_backup] object is invalid
55605448
** and may not be used following a call to sqlite3_backup_finish().
55615449
**
5562
-** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
5563
-** occurred, regardless or whether or not sqlite3_backup_step() was called
5564
-** a sufficient number of times to complete the backup operation. Or, if
5565
-** an out-of-memory condition or IO error occured during a call to
5566
-** sqlite3_backup_step() then [SQLITE_NOMEM] or an
5567
-** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
5568
-** is returned. In this case the error code and an error message are
5569
-** written to the destination [database connection].
5450
+** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
5451
+** sqlite3_backup_step() errors occurred, regardless or whether or not
5452
+** sqlite3_backup_step() completed.
5453
+** ^If an out-of-memory condition or IO error occurred during any prior
5454
+** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
5455
+** sqlite3_backup_finish() returns the corresponding [error code].
55705456
**
5571
-** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
5572
-** not a permanent error and does not affect the return value of
5457
+** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
5458
+** is not a permanent error and does not affect the return value of
55735459
** sqlite3_backup_finish().
55745460
**
55755461
** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
55765462
**
5577
-** Each call to sqlite3_backup_step() sets two values stored internally
5578
-** by an [sqlite3_backup] object. The number of pages still to be backed
5579
-** up, which may be queried by sqlite3_backup_remaining(), and the total
5580
-** number of pages in the source database file, which may be queried by
5581
-** sqlite3_backup_pagecount().
5463
+** ^Each call to sqlite3_backup_step() sets two values inside
5464
+** the [sqlite3_backup] object: the number of pages still to be backed
5465
+** up and the total number of pages in the source databae file.
5466
+** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
5467
+** retrieve these two values, respectively.
55825468
**
5583
-** The values returned by these functions are only updated by
5584
-** sqlite3_backup_step(). If the source database is modified during a backup
5469
+** ^The values returned by these functions are only updated by
5470
+** sqlite3_backup_step(). ^If the source database is modified during a backup
55855471
** operation, then the values are not updated to account for any extra
55865472
** pages that need to be updated or the size of the source database file
55875473
** changing.
55885474
**
55895475
** <b>Concurrent Usage of Database Handles</b>
55905476
**
5591
-** The source [database connection] may be used by the application for other
5477
+** ^The source [database connection] may be used by the application for other
55925478
** purposes while a backup operation is underway or being initialized.
5593
-** If SQLite is compiled and configured to support threadsafe database
5479
+** ^If SQLite is compiled and configured to support threadsafe database
55945480
** connections, then the source database connection may be used concurrently
55955481
** from within other threads.
55965482
**
5597
-** However, the application must guarantee that the destination database
5598
-** connection handle is not passed to any other API (by any thread) after
5483
+** However, the application must guarantee that the destination
5484
+** [database connection] is not passed to any other API (by any thread) after
55995485
** sqlite3_backup_init() is called and before the corresponding call to
5600
-** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
5601
-** for this, if the application does use the destination [database connection]
5602
-** for some other purpose during a backup operation, things may appear to
5603
-** work correctly but in fact be subtly malfunctioning. Use of the
5604
-** destination database connection while a backup is in progress might
5605
-** also cause a mutex deadlock.
5486
+** sqlite3_backup_finish(). SQLite does not currently check to see
5487
+** if the application incorrectly accesses the destination [database connection]
5488
+** and so no error code is reported, but the operations may malfunction
5489
+** nevertheless. Use of the destination database connection while a
5490
+** backup is in progress might also also cause a mutex deadlock.
56065491
**
5607
-** Furthermore, if running in [shared cache mode], the application must
5492
+** If running in [shared cache mode], the application must
56085493
** guarantee that the shared cache used by the destination database
56095494
** is not accessed while the backup is running. In practice this means
5610
-** that the application must guarantee that the file-system file being
5495
+** that the application must guarantee that the disk file being
56115496
** backed up to is not accessed by any connection within the process,
56125497
** not just the specific connection that was passed to sqlite3_backup_init().
56135498
**
56145499
** The [sqlite3_backup] object itself is partially threadsafe. Multiple
56155500
** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -5631,60 +5516,60 @@
56315516
56325517
/*
56335518
** CAPI3REF: Unlock Notification
56345519
** EXPERIMENTAL
56355520
**
5636
-** When running in shared-cache mode, a database operation may fail with
5521
+** ^When running in shared-cache mode, a database operation may fail with
56375522
** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
56385523
** individual tables within the shared-cache cannot be obtained. See
56395524
** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
5640
-** This API may be used to register a callback that SQLite will invoke
5525
+** ^This API may be used to register a callback that SQLite will invoke
56415526
** when the connection currently holding the required lock relinquishes it.
5642
-** This API is only available if the library was compiled with the
5527
+** ^This API is only available if the library was compiled with the
56435528
** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
56445529
**
56455530
** See Also: [Using the SQLite Unlock Notification Feature].
56465531
**
5647
-** Shared-cache locks are released when a database connection concludes
5532
+** ^Shared-cache locks are released when a database connection concludes
56485533
** its current transaction, either by committing it or rolling it back.
56495534
**
5650
-** When a connection (known as the blocked connection) fails to obtain a
5535
+** ^When a connection (known as the blocked connection) fails to obtain a
56515536
** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
56525537
** identity of the database connection (the blocking connection) that
5653
-** has locked the required resource is stored internally. After an
5538
+** has locked the required resource is stored internally. ^After an
56545539
** application receives an SQLITE_LOCKED error, it may call the
56555540
** sqlite3_unlock_notify() method with the blocked connection handle as
56565541
** the first argument to register for a callback that will be invoked
5657
-** when the blocking connections current transaction is concluded. The
5542
+** when the blocking connections current transaction is concluded. ^The
56585543
** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
56595544
** call that concludes the blocking connections transaction.
56605545
**
5661
-** If sqlite3_unlock_notify() is called in a multi-threaded application,
5546
+** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
56625547
** there is a chance that the blocking connection will have already
56635548
** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
56645549
** If this happens, then the specified callback is invoked immediately,
5665
-** from within the call to sqlite3_unlock_notify().
5550
+** from within the call to sqlite3_unlock_notify().)^
56665551
**
5667
-** If the blocked connection is attempting to obtain a write-lock on a
5552
+** ^If the blocked connection is attempting to obtain a write-lock on a
56685553
** shared-cache table, and more than one other connection currently holds
56695554
** a read-lock on the same table, then SQLite arbitrarily selects one of
56705555
** the other connections to use as the blocking connection.
56715556
**
5672
-** There may be at most one unlock-notify callback registered by a
5557
+** ^(There may be at most one unlock-notify callback registered by a
56735558
** blocked connection. If sqlite3_unlock_notify() is called when the
56745559
** blocked connection already has a registered unlock-notify callback,
5675
-** then the new callback replaces the old. If sqlite3_unlock_notify() is
5560
+** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
56765561
** called with a NULL pointer as its second argument, then any existing
5677
-** unlock-notify callback is cancelled. The blocked connections
5562
+** unlock-notify callback is cancelled. ^The blocked connections
56785563
** unlock-notify callback may also be canceled by closing the blocked
56795564
** connection using [sqlite3_close()].
56805565
**
56815566
** The unlock-notify callback is not reentrant. If an application invokes
56825567
** any sqlite3_xxx API functions from within an unlock-notify callback, a
56835568
** crash or deadlock may be the result.
56845569
**
5685
-** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
5570
+** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
56865571
** returns SQLITE_OK.
56875572
**
56885573
** <b>Callback Invocation Details</b>
56895574
**
56905575
** When an unlock-notify callback is registered, the application provides a
@@ -5694,11 +5579,11 @@
56945579
** an unlock-notify callback is a pointer to an array of void* pointers,
56955580
** and the second is the number of entries in the array.
56965581
**
56975582
** When a blocking connections transaction is concluded, there may be
56985583
** more than one blocked connection that has registered for an unlock-notify
5699
-** callback. If two or more such blocked connections have specified the
5584
+** callback. ^If two or more such blocked connections have specified the
57005585
** same callback function, then instead of invoking the callback function
57015586
** multiple times, it is invoked once with the set of void* context pointers
57025587
** specified by the blocked connections bundled together into an array.
57035588
** This gives the application an opportunity to prioritize any actions
57045589
** related to the set of unblocked database connections.
@@ -5712,20 +5597,20 @@
57125597
** connection Y's transaction to be concluded, and similarly connection
57135598
** Y is waiting on connection X's transaction, then neither connection
57145599
** will proceed and the system may remain deadlocked indefinitely.
57155600
**
57165601
** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
5717
-** detection. If a given call to sqlite3_unlock_notify() would put the
5602
+** detection. ^If a given call to sqlite3_unlock_notify() would put the
57185603
** system in a deadlocked state, then SQLITE_LOCKED is returned and no
57195604
** unlock-notify callback is registered. The system is said to be in
57205605
** a deadlocked state if connection A has registered for an unlock-notify
57215606
** callback on the conclusion of connection B's transaction, and connection
57225607
** B has itself registered for an unlock-notify callback when connection
5723
-** A's transaction is concluded. Indirect deadlock is also detected, so
5608
+** A's transaction is concluded. ^Indirect deadlock is also detected, so
57245609
** the system is also considered to be deadlocked if connection B has
57255610
** registered for an unlock-notify callback on the conclusion of connection
5726
-** C's transaction, where connection C is waiting on connection A. Any
5611
+** C's transaction, where connection C is waiting on connection A. ^Any
57275612
** number of levels of indirection are allowed.
57285613
**
57295614
** <b>The "DROP TABLE" Exception</b>
57305615
**
57315616
** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -5737,14 +5622,14 @@
57375622
** sqlite3_unlock_notify() results in the unlock-notify callback being
57385623
** invoked immediately. If the application then re-attempts the "DROP TABLE"
57395624
** or "DROP INDEX" query, an infinite loop might be the result.
57405625
**
57415626
** One way around this problem is to check the extended error code returned
5742
-** by an sqlite3_step() call. If there is a blocking connection, then the
5627
+** by an sqlite3_step() call. ^(If there is a blocking connection, then the
57435628
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
57445629
** the special "DROP TABLE/INDEX" case, the extended error code is just
5745
-** SQLITE_LOCKED.
5630
+** SQLITE_LOCKED.)^
57465631
*/
57475632
SQLITE_API int sqlite3_unlock_notify(
57485633
sqlite3 *pBlocked, /* Waiting connection */
57495634
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
57505635
void *pNotifyArg /* Argument to pass to xNotify */
@@ -5753,11 +5638,11 @@
57535638
57545639
/*
57555640
** CAPI3REF: String Comparison
57565641
** EXPERIMENTAL
57575642
**
5758
-** The [sqlite3_strnicmp()] API allows applications and extensions to
5643
+** ^The [sqlite3_strnicmp()] API allows applications and extensions to
57595644
** compare the contents of two buffers containing UTF-8 strings in a
57605645
** case-indendent fashion, using the same definition of case independence
57615646
** that SQLite uses internally when comparing identifiers.
57625647
*/
57635648
SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
57645649
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -79,88 +79,81 @@
79 #ifdef SQLITE_VERSION_NUMBER
80 # undef SQLITE_VERSION_NUMBER
81 #endif
82
83 /*
84 ** CAPI3REF: Compile-Time Library Version Numbers {H10010} <S60100>
85 **
86 ** The SQLITE_VERSION and SQLITE_VERSION_NUMBER #defines in
87 ** the sqlite3.h file specify the version of SQLite with which
88 ** that header file is associated.
89 **
90 ** The "version" of SQLite is a string of the form "W.X.Y" or "W.X.Y.Z".
91 ** The W value is major version number and is always 3 in SQLite3.
92 ** The W value only changes when backwards compatibility is
93 ** broken and we intend to never break backwards compatibility.
94 ** The X value is the minor version number and only changes when
95 ** there are major feature enhancements that are forwards compatible
96 ** but not backwards compatible.
97 ** The Y value is the release number and is incremented with
98 ** each release but resets back to 0 whenever X is incremented.
99 ** The Z value only appears on branch releases.
100 **
101 ** The SQLITE_VERSION_NUMBER is an integer that is computed as
102 ** follows:
103 **
104 ** <blockquote><pre>
105 ** SQLITE_VERSION_NUMBER = W*1000000 + X*1000 + Y
106 ** </pre></blockquote>
107 **
108 ** Since version 3.6.18, SQLite source code has been stored in the
109 ** <a href="http://www.fossil-scm.org/">fossil configuration management
110 ** system</a>. The SQLITE_SOURCE_ID
111 ** macro is a string which identifies a particular check-in of SQLite
112 ** within its configuration management system. The string contains the
113 ** date and time of the check-in (UTC) and an SHA1 hash of the entire
114 ** source tree.
115 **
116 ** See also: [sqlite3_libversion()],
117 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
118 ** [sqlite_version()] and [sqlite_source_id()].
119 **
120 ** Requirements: [H10011] [H10014]
121 */
122 #define SQLITE_VERSION "3.6.21"
123 #define SQLITE_VERSION_NUMBER 3006021
124 #define SQLITE_SOURCE_ID "2009-12-07 16:39:13 1ed88e9d01e9eda5cbc622e7614277f29bcc551c"
125
126 /*
127 ** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100>
128 ** KEYWORDS: sqlite3_version
129 **
130 ** These interfaces provide the same information as the [SQLITE_VERSION],
131 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] #defines in the header,
132 ** but are associated with the library instead of the header file. Cautious
133 ** programmers might include assert() statements in their application to
134 ** verify that values returned by these interfaces match the macros in
135 ** the header, and thus insure that the application is
136 ** compiled with matching library and header files.
137 **
138 ** <blockquote><pre>
139 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
140 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
141 ** assert( strcmp(sqlite3_libversion,SQLITE_VERSION)==0 );
142 ** </pre></blockquote>
143 **
144 ** The sqlite3_libversion() function returns the same information as is
145 ** in the sqlite3_version[] string constant. The function is provided
146 ** for use in DLLs since DLL users usually do not have direct access to string
147 ** constants within the DLL. Similarly, the sqlite3_sourceid() function
148 ** returns the same information as is in the [SQLITE_SOURCE_ID] #define of
149 ** the header file.
 
 
 
150 **
151 ** See also: [sqlite_version()] and [sqlite_source_id()].
152 **
153 ** Requirements: [H10021] [H10022] [H10023]
154 */
155 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
156 SQLITE_API const char *sqlite3_libversion(void);
157 SQLITE_API const char *sqlite3_sourceid(void);
158 SQLITE_API int sqlite3_libversion_number(void);
159
160 /*
161 ** CAPI3REF: Test To See If The Library Is Threadsafe {H10100} <S60100>
 
 
 
 
162 **
163 ** SQLite can be compiled with or without mutexes. When
164 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
165 ** are enabled and SQLite is threadsafe. When the
166 ** [SQLITE_THREADSAFE] macro is 0,
@@ -168,33 +161,33 @@
168 ** to use SQLite concurrently from more than one thread.
169 **
170 ** Enabling mutexes incurs a measurable performance penalty.
171 ** So if speed is of utmost importance, it makes sense to disable
172 ** the mutexes. But for maximum safety, mutexes should be enabled.
173 ** The default behavior is for mutexes to be enabled.
174 **
175 ** This interface can be used by an application to make sure that the
176 ** version of SQLite that it is linking against was compiled with
177 ** the desired setting of the [SQLITE_THREADSAFE] macro.
178 **
179 ** This interface only reports on the compile-time mutex setting
180 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
181 ** SQLITE_THREADSAFE=1 then mutexes are enabled by default but
182 ** can be fully or partially disabled using a call to [sqlite3_config()]
183 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
184 ** or [SQLITE_CONFIG_MUTEX]. The return value of this function shows
185 ** only the default compile-time setting, not any run-time changes
186 ** to that setting.
 
 
187 **
188 ** See the [threading mode] documentation for additional information.
189 **
190 ** Requirements: [H10101] [H10102]
191 */
192 SQLITE_API int sqlite3_threadsafe(void);
193
194 /*
195 ** CAPI3REF: Database Connection Handle {H12000} <S40200>
196 ** KEYWORDS: {database connection} {database connections}
197 **
198 ** Each open SQLite database is represented by a pointer to an instance of
199 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
200 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -205,21 +198,24 @@
205 ** sqlite3 object.
206 */
207 typedef struct sqlite3 sqlite3;
208
209 /*
210 ** CAPI3REF: 64-Bit Integer Types {H10200} <S10110>
211 ** KEYWORDS: sqlite_int64 sqlite_uint64
212 **
213 ** Because there is no cross-platform way to specify 64-bit integer types
214 ** SQLite includes typedefs for 64-bit signed and unsigned integers.
215 **
216 ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
217 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
218 ** compatibility only.
219 **
220 ** Requirements: [H10201] [H10202]
 
 
 
221 */
222 #ifdef SQLITE_INT64_TYPE
223 typedef SQLITE_INT64_TYPE sqlite_int64;
224 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
225 #elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -239,28 +235,32 @@
239 #ifdef SQLITE_OMIT_FLOATING_POINT
240 # define double sqlite3_int64
241 #endif
242
243 /*
244 ** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200>
245 **
246 ** This routine is the destructor for the [sqlite3] object.
 
 
247 **
248 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
249 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
250 ** the [sqlite3] object prior to attempting to close the object.
 
 
 
251 **
252 ** If [sqlite3_close()] is invoked while a transaction is open,
253 ** the transaction is automatically rolled back.
254 **
255 ** The C parameter to [sqlite3_close(C)] must be either a NULL
256 ** pointer or an [sqlite3] object pointer obtained
257 ** from [sqlite3_open()], [sqlite3_open16()], or
258 ** [sqlite3_open_v2()], and not previously closed.
259 **
260 ** Requirements:
261 ** [H12011] [H12012] [H12013] [H12014] [H12015] [H12019]
262 */
263 SQLITE_API int sqlite3_close(sqlite3 *);
264
265 /*
266 ** The type for a callback function.
@@ -268,52 +268,69 @@
268 ** compatibility and is not documented.
269 */
270 typedef int (*sqlite3_callback)(void*,int,char**, char**);
271
272 /*
273 ** CAPI3REF: One-Step Query Execution Interface {H12100} <S10000>
274 **
275 ** The sqlite3_exec() interface is a convenient way of running one or more
276 ** SQL statements without having to write a lot of C code. The UTF-8 encoded
277 ** SQL statements are passed in as the second parameter to sqlite3_exec().
278 ** The statements are evaluated one by one until either an error or
279 ** an interrupt is encountered, or until they are all done. The 3rd parameter
280 ** is an optional callback that is invoked once for each row of any query
281 ** results produced by the SQL statements. The 5th parameter tells where
282 ** to write any error messages.
283 **
284 ** The error message passed back through the 5th parameter is held
285 ** in memory obtained from [sqlite3_malloc()]. To avoid a memory leak,
286 ** the calling application should call [sqlite3_free()] on any error
287 ** message returned through the 5th parameter when it has finished using
288 ** the error message.
289 **
290 ** If the SQL statement in the 2nd parameter is NULL or an empty string
291 ** or a string containing only whitespace and comments, then no SQL
292 ** statements are evaluated and the database is not changed.
293 **
294 ** The sqlite3_exec() interface is implemented in terms of
295 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
296 ** The sqlite3_exec() routine does nothing to the database that cannot be done
297 ** by [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()].
298 **
299 ** The first parameter to [sqlite3_exec()] must be an valid and open
300 ** [database connection].
301 **
302 ** The database connection must not be closed while
303 ** [sqlite3_exec()] is running.
304 **
305 ** The calling function should use [sqlite3_free()] to free
306 ** the memory that *errmsg is left pointing at once the error
307 ** message is no longer needed.
308 **
309 ** The SQL statement text in the 2nd parameter to [sqlite3_exec()]
310 ** must remain unchanged while [sqlite3_exec()] is running.
311 **
312 ** Requirements:
313 ** [H12101] [H12102] [H12104] [H12105] [H12107] [H12110] [H12113] [H12116]
314 ** [H12119] [H12122] [H12125] [H12131] [H12134] [H12137] [H12138]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
315 */
316 SQLITE_API int sqlite3_exec(
317 sqlite3*, /* An open database */
318 const char *sql, /* SQL to be evaluated */
319 int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -320,11 +337,11 @@
320 void *, /* 1st argument to callback */
321 char **errmsg /* Error msg written here */
322 );
323
324 /*
325 ** CAPI3REF: Result Codes {H10210} <S10700>
326 ** KEYWORDS: SQLITE_OK {error code} {error codes}
327 ** KEYWORDS: {result code} {result codes}
328 **
329 ** Many SQLite functions return an integer result code from the set shown
330 ** here in order to indicates success or failure.
@@ -364,11 +381,11 @@
364 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
365 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
366 /* end-of-error-codes */
367
368 /*
369 ** CAPI3REF: Extended Result Codes {H10220} <S10700>
370 ** KEYWORDS: {extended error code} {extended error codes}
371 ** KEYWORDS: {extended result code} {extended result codes}
372 **
373 ** In its default configuration, SQLite API routines return one of 26 integer
374 ** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -406,11 +423,11 @@
406 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
407 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
408 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
409
410 /*
411 ** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700>
412 **
413 ** These bit values are intended for use in the
414 ** 3rd parameter to the [sqlite3_open_v2()] interface and
415 ** in the 4th parameter to the xOpen method of the
416 ** [sqlite3_vfs] object.
@@ -431,11 +448,11 @@
431 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
432 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
433 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
434
435 /*
436 ** CAPI3REF: Device Characteristics {H10240} <H11120>
437 **
438 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
439 ** object returns an integer which is a vector of the these
440 ** bit values expressing I/O characteristics of the mass storage
441 ** device that holds the file that the [sqlite3_io_methods]
@@ -463,11 +480,11 @@
463 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
464 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
465 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
466
467 /*
468 ** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310>
469 **
470 ** SQLite uses one of these integer values as the second
471 ** argument to calls it makes to the xLock() and xUnlock() methods
472 ** of an [sqlite3_io_methods] object.
473 */
@@ -476,11 +493,11 @@
476 #define SQLITE_LOCK_RESERVED 2
477 #define SQLITE_LOCK_PENDING 3
478 #define SQLITE_LOCK_EXCLUSIVE 4
479
480 /*
481 ** CAPI3REF: Synchronization Type Flags {H10260} <H11120>
482 **
483 ** When SQLite invokes the xSync() method of an
484 ** [sqlite3_io_methods] object it uses a combination of
485 ** these integer values as the second argument.
486 **
@@ -494,11 +511,11 @@
494 #define SQLITE_SYNC_NORMAL 0x00002
495 #define SQLITE_SYNC_FULL 0x00003
496 #define SQLITE_SYNC_DATAONLY 0x00010
497
498 /*
499 ** CAPI3REF: OS Interface Open File Handle {H11110} <S20110>
500 **
501 ** An [sqlite3_file] object represents an open file in the
502 ** [sqlite3_vfs | OS interface layer]. Individual OS interface
503 ** implementations will
504 ** want to subclass this object by appending additional fields
@@ -510,11 +527,11 @@
510 struct sqlite3_file {
511 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
512 };
513
514 /*
515 ** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110>
516 **
517 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
518 ** [sqlite3_file] object (or, more commonly, a subclass of the
519 ** [sqlite3_file] object) with a pointer to an instance of this object.
520 ** This object defines the methods used to perform various operations
@@ -615,11 +632,11 @@
615 int (*xDeviceCharacteristics)(sqlite3_file*);
616 /* Additional methods may be added in future releases */
617 };
618
619 /*
620 ** CAPI3REF: Standard File Control Opcodes {H11310} <S30800>
621 **
622 ** These integer constants are opcodes for the xFileControl method
623 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
624 ** interface.
625 **
@@ -635,11 +652,11 @@
635 #define SQLITE_GET_LOCKPROXYFILE 2
636 #define SQLITE_SET_LOCKPROXYFILE 3
637 #define SQLITE_LAST_ERRNO 4
638
639 /*
640 ** CAPI3REF: Mutex Handle {H17110} <S20130>
641 **
642 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
643 ** abstract type for a mutex object. The SQLite core never looks
644 ** at the internal representation of an [sqlite3_mutex]. It only
645 ** deals with pointers to the [sqlite3_mutex] object.
@@ -647,11 +664,11 @@
647 ** Mutexes are created using [sqlite3_mutex_alloc()].
648 */
649 typedef struct sqlite3_mutex sqlite3_mutex;
650
651 /*
652 ** CAPI3REF: OS Interface Object {H11140} <S20100>
653 **
654 ** An instance of the sqlite3_vfs object defines the interface between
655 ** the SQLite core and the underlying operating system. The "vfs"
656 ** in the name of the object stands for "virtual file system".
657 **
@@ -801,14 +818,14 @@
801 /* New fields may be appended in figure versions. The iVersion
802 ** value will increment whenever this happens. */
803 };
804
805 /*
806 ** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140>
807 **
808 ** These integer constants can be used as the third parameter to
809 ** the xAccess method of an [sqlite3_vfs] object. {END} They determine
810 ** what kind of permissions the xAccess method is looking for.
811 ** With SQLITE_ACCESS_EXISTS, the xAccess method
812 ** simply checks whether the file exists.
813 ** With SQLITE_ACCESS_READWRITE, the xAccess method
814 ** checks whether the file is both readable and writable.
@@ -818,52 +835,52 @@
818 #define SQLITE_ACCESS_EXISTS 0
819 #define SQLITE_ACCESS_READWRITE 1
820 #define SQLITE_ACCESS_READ 2
821
822 /*
823 ** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100>
824 **
825 ** The sqlite3_initialize() routine initializes the
826 ** SQLite library. The sqlite3_shutdown() routine
827 ** deallocates any resources that were allocated by sqlite3_initialize().
828 ** These routines are designed to aid in process initialization and
829 ** shutdown on embedded systems. Workstation applications using
830 ** SQLite normally do not need to invoke either of these routines.
831 **
832 ** A call to sqlite3_initialize() is an "effective" call if it is
833 ** the first time sqlite3_initialize() is invoked during the lifetime of
834 ** the process, or if it is the first time sqlite3_initialize() is invoked
835 ** following a call to sqlite3_shutdown(). Only an effective call
836 ** of sqlite3_initialize() does any initialization. All other calls
837 ** are harmless no-ops.
838 **
839 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
840 ** call to sqlite3_shutdown() since the last sqlite3_initialize(). Only
841 ** an effective call to sqlite3_shutdown() does any deinitialization.
842 ** All other valid calls to sqlite3_shutdown() are harmless no-ops.
843 **
844 ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
845 ** is not. The sqlite3_shutdown() interface must only be called from a
846 ** single thread. All open [database connections] must be closed and all
847 ** other SQLite resources must be deallocated prior to invoking
848 ** sqlite3_shutdown().
849 **
850 ** Among other things, sqlite3_initialize() will invoke
851 ** sqlite3_os_init(). Similarly, sqlite3_shutdown()
852 ** will invoke sqlite3_os_end().
853 **
854 ** The sqlite3_initialize() routine returns [SQLITE_OK] on success.
855 ** If for some reason, sqlite3_initialize() is unable to initialize
856 ** the library (perhaps it is unable to allocate a needed resource such
857 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
858 **
859 ** The sqlite3_initialize() routine is called internally by many other
860 ** SQLite interfaces so that an application usually does not need to
861 ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
862 ** calls sqlite3_initialize() so the SQLite library will be automatically
863 ** initialized when [sqlite3_open()] is called if it has not be initialized
864 ** already. However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
865 ** compile-time option, then the automatic calls to sqlite3_initialize()
866 ** are omitted and the application must call sqlite3_initialize() directly
867 ** prior to using any other SQLite interface. For maximum portability,
868 ** it is recommended that applications always invoke sqlite3_initialize()
869 ** directly prior to using any other SQLite interface. Future releases
@@ -898,11 +915,11 @@
898 SQLITE_API int sqlite3_shutdown(void);
899 SQLITE_API int sqlite3_os_init(void);
900 SQLITE_API int sqlite3_os_end(void);
901
902 /*
903 ** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200>
904 ** EXPERIMENTAL
905 **
906 ** The sqlite3_config() interface is used to make global configuration
907 ** changes to SQLite in order to tune SQLite to the specific needs of
908 ** the application. The default configuration is recommended for most
@@ -912,39 +929,36 @@
912 ** The sqlite3_config() interface is not threadsafe. The application
913 ** must insure that no other SQLite interfaces are invoked by other
914 ** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
915 ** may only be invoked prior to library initialization using
916 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
917 ** Note, however, that sqlite3_config() can be called as part of the
 
 
918 ** implementation of an application-defined [sqlite3_os_init()].
919 **
920 ** The first argument to sqlite3_config() is an integer
921 ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
922 ** what property of SQLite is to be configured. Subsequent arguments
923 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
924 ** in the first argument.
925 **
926 ** When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
927 ** If the option is unknown or SQLite is unable to set the option
928 ** then this routine returns a non-zero [error code].
929 **
930 ** Requirements:
931 ** [H14103] [H14106] [H14120] [H14123] [H14126] [H14129] [H14132] [H14135]
932 ** [H14138] [H14141] [H14144] [H14147] [H14150] [H14153] [H14156] [H14159]
933 ** [H14162] [H14165] [H14168]
934 */
935 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
936
937 /*
938 ** CAPI3REF: Configure database connections {H14200} <S20000>
939 ** EXPERIMENTAL
940 **
941 ** The sqlite3_db_config() interface is used to make configuration
942 ** changes to a [database connection]. The interface is similar to
943 ** [sqlite3_config()] except that the changes apply to a single
944 ** [database connection] (specified in the first argument). The
945 ** sqlite3_db_config() interface can only be used immediately after
946 ** the database connection is created using [sqlite3_open()],
947 ** [sqlite3_open16()], or [sqlite3_open_v2()].
948 **
949 ** The second argument to sqlite3_db_config(D,V,...) is the
950 ** configuration verb - an integer code that indicates what
@@ -951,17 +965,17 @@
951 ** aspect of the [database connection] is being configured.
952 ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
953 ** New verbs are likely to be added in future releases of SQLite.
954 ** Additional arguments depend on the verb.
955 **
956 ** Requirements:
957 ** [H14203] [H14206] [H14209] [H14212] [H14215]
958 */
959 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
960
961 /*
962 ** CAPI3REF: Memory Allocation Routines {H10155} <S20120>
963 ** EXPERIMENTAL
964 **
965 ** An instance of this object defines the interface between SQLite
966 ** and low-level memory allocation routines.
967 **
@@ -987,11 +1001,11 @@
987 ** The xMalloc and xFree methods must work like the
988 ** malloc() and free() functions from the standard C library.
989 ** The xRealloc method must work like realloc() from the standard C library
990 ** with the exception that if the second argument to xRealloc is zero,
991 ** xRealloc must be a no-op - it must not perform any allocation or
992 ** deallocation. SQLite guaranteeds that the second argument to
993 ** xRealloc is always a value returned by a prior call to xRoundup.
994 ** And so in cases where xRoundup always returns a positive number,
995 ** xRealloc can perform exactly as the standard library realloc() and
996 ** still be in compliance with this specification.
997 **
@@ -1039,11 +1053,11 @@
1039 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
1040 void *pAppData; /* Argument to xInit() and xShutdown() */
1041 };
1042
1043 /*
1044 ** CAPI3REF: Configuration Options {H10160} <S20000>
1045 ** EXPERIMENTAL
1046 **
1047 ** These constants are the available integer configuration options that
1048 ** can be passed as the first argument to the [sqlite3_config()] interface.
1049 **
@@ -1054,151 +1068,181 @@
1054 ** non-zero [error code] if a discontinued or unsupported configuration option
1055 ** is invoked.
1056 **
1057 ** <dl>
1058 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1059 ** <dd>There are no arguments to this option. This option disables
 
1060 ** all mutexing and puts SQLite into a mode where it can only be used
1061 ** by a single thread.</dd>
 
 
 
 
 
1062 **
1063 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1064 ** <dd>There are no arguments to this option. This option disables
 
1065 ** mutexing on [database connection] and [prepared statement] objects.
1066 ** The application is responsible for serializing access to
1067 ** [database connections] and [prepared statements]. But other mutexes
1068 ** are enabled so that SQLite will be safe to use in a multi-threaded
1069 ** environment as long as no two threads attempt to use the same
1070 ** [database connection] at the same time. See the [threading mode]
1071 ** documentation for additional information.</dd>
 
 
 
1072 **
1073 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1074 ** <dd>There are no arguments to this option. This option enables
 
1075 ** all mutexes including the recursive
1076 ** mutexes on [database connection] and [prepared statement] objects.
1077 ** In this mode (which is the default when SQLite is compiled with
1078 ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
1079 ** to [database connections] and [prepared statements] so that the
1080 ** application is free to use the same [database connection] or the
1081 ** same [prepared statement] in different threads at the same time.
1082 ** See the [threading mode] documentation for additional information.</dd>
 
 
 
 
1083 **
1084 ** <dt>SQLITE_CONFIG_MALLOC</dt>
1085 ** <dd>This option takes a single argument which is a pointer to an
1086 ** instance of the [sqlite3_mem_methods] structure. The argument specifies
1087 ** alternative low-level memory allocation routines to be used in place of
1088 ** the memory allocation routines built into SQLite.</dd>
 
 
1089 **
1090 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1091 ** <dd>This option takes a single argument which is a pointer to an
1092 ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1093 ** structure is filled with the currently defined memory allocation routines.
1094 ** This option can be used to overload the default memory allocation
1095 ** routines with a wrapper that simulations memory allocation failure or
1096 ** tracks memory usage, for example.</dd>
1097 **
1098 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1099 ** <dd>This option takes single argument of type int, interpreted as a
1100 ** boolean, which enables or disables the collection of memory allocation
1101 ** statistics. When disabled, the following SQLite interfaces become
1102 ** non-operational:
1103 ** <ul>
1104 ** <li> [sqlite3_memory_used()]
1105 ** <li> [sqlite3_memory_highwater()]
1106 ** <li> [sqlite3_soft_heap_limit()]
1107 ** <li> [sqlite3_status()]
1108 ** </ul>
 
 
 
1109 ** </dd>
1110 **
1111 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
1112 ** <dd>This option specifies a static memory buffer that SQLite can use for
1113 ** scratch memory. There are three arguments: A pointer an 8-byte
1114 ** aligned memory buffer from which the scrach allocations will be
1115 ** drawn, the size of each scratch allocation (sz),
1116 ** and the maximum number of scratch allocations (N). The sz
1117 ** argument must be a multiple of 16. The sz parameter should be a few bytes
1118 ** larger than the actual scratch space required due to internal overhead.
1119 ** The first argument should pointer to an 8-byte aligned buffer
1120 ** of at least sz*N bytes of memory.
1121 ** SQLite will use no more than one scratch buffer at once per thread, so
1122 ** N should be set to the expected maximum number of threads. The sz
1123 ** parameter should be 6 times the size of the largest database page size.
1124 ** Scratch buffers are used as part of the btree balance operation. If
1125 ** The btree balancer needs additional memory beyond what is provided by
1126 ** scratch buffers or if no scratch buffer space is specified, then SQLite
1127 ** goes to [sqlite3_malloc()] to obtain the memory it needs.</dd>
1128 **
1129 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1130 ** <dd>This option specifies a static memory buffer that SQLite can use for
1131 ** the database page cache with the default page cache implemenation.
1132 ** This configuration should not be used if an application-define page
1133 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1134 ** There are three arguments to this option: A pointer to 8-byte aligned
1135 ** memory, the size of each page buffer (sz), and the number of pages (N).
1136 ** The sz argument should be the size of the largest database page
1137 ** (a power of two between 512 and 32768) plus a little extra for each
1138 ** page header. The page header size is 20 to 40 bytes depending on
1139 ** the host architecture. It is harmless, apart from the wasted memory,
1140 ** to make sz a little too large. The first
1141 ** argument should point to an allocation of at least sz*N bytes of memory.
1142 ** SQLite will use the memory provided by the first argument to satisfy its
1143 ** memory needs for the first N pages that it adds to cache. If additional
1144 ** page cache memory is needed beyond what is provided by this option, then
1145 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1146 ** The implementation might use one or more of the N buffers to hold
1147 ** memory accounting information. The pointer in the first argument must
1148 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1149 ** will be undefined.</dd>
1150 **
1151 ** <dt>SQLITE_CONFIG_HEAP</dt>
1152 ** <dd>This option specifies a static memory buffer that SQLite will use
1153 ** for all of its dynamic memory allocation needs beyond those provided
1154 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
1155 ** There are three arguments: An 8-byte aligned pointer to the memory,
1156 ** the number of bytes in the memory buffer, and the minimum allocation size.
1157 ** If the first pointer (the memory pointer) is NULL, then SQLite reverts
1158 ** to using its default memory allocator (the system malloc() implementation),
1159 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. If the
1160 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
1161 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1162 ** allocator is engaged to handle all of SQLites memory allocation needs.
1163 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1164 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1165 **
1166 ** <dt>SQLITE_CONFIG_MUTEX</dt>
1167 ** <dd>This option takes a single argument which is a pointer to an
1168 ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
1169 ** alternative low-level mutex routines to be used in place
1170 ** the mutex routines built into SQLite.</dd>
 
 
 
 
 
 
1171 **
1172 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1173 ** <dd>This option takes a single argument which is a pointer to an
1174 ** instance of the [sqlite3_mutex_methods] structure. The
1175 ** [sqlite3_mutex_methods]
1176 ** structure is filled with the currently defined mutex routines.
1177 ** This option can be used to overload the default mutex allocation
1178 ** routines with a wrapper used to track mutex usage for performance
1179 ** profiling or testing, for example.</dd>
 
 
 
 
1180 **
1181 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1182 ** <dd>This option takes two arguments that determine the default
1183 ** memory allocation lookaside optimization. The first argument is the
 
1184 ** size of each lookaside buffer slot and the second is the number of
1185 ** slots allocated to each database connection. This option sets the
1186 ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1187 ** verb to [sqlite3_db_config()] can be used to change the lookaside
1188 ** configuration on individual connections.</dd>
1189 **
1190 ** <dt>SQLITE_CONFIG_PCACHE</dt>
1191 ** <dd>This option takes a single argument which is a pointer to
1192 ** an [sqlite3_pcache_methods] object. This object specifies the interface
1193 ** to a custom page cache implementation. SQLite makes a copy of the
1194 ** object and uses it for page cache memory allocations.</dd>
1195 **
1196 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1197 ** <dd>This option takes a single argument which is a pointer to an
1198 ** [sqlite3_pcache_methods] object. SQLite copies of the current
1199 ** page cache implementation into that object.</dd>
1200 **
1201 ** </dl>
1202 */
1203 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1204 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1215,94 +1259,90 @@
1215 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1216 #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
1217 #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
1218
1219 /*
1220 ** CAPI3REF: Configuration Options {H10170} <S20000>
1221 ** EXPERIMENTAL
1222 **
1223 ** These constants are the available integer configuration options that
1224 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1225 **
1226 ** New configuration options may be added in future releases of SQLite.
1227 ** Existing configuration options might be discontinued. Applications
1228 ** should check the return code from [sqlite3_db_config()] to make sure that
1229 ** the call worked. The [sqlite3_db_config()] interface will return a
1230 ** non-zero [error code] if a discontinued or unsupported configuration option
1231 ** is invoked.
1232 **
1233 ** <dl>
1234 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1235 ** <dd>This option takes three additional arguments that determine the
1236 ** [lookaside memory allocator] configuration for the [database connection].
1237 ** The first argument (the third parameter to [sqlite3_db_config()] is a
1238 ** pointer to an memory buffer to use for lookaside memory.
1239 ** The first argument may be NULL in which case SQLite will allocate the
1240 ** lookaside buffer itself using [sqlite3_malloc()]. The second argument is the
1241 ** size of each lookaside buffer slot and the third argument is the number of
 
1242 ** slots. The size of the buffer in the first argument must be greater than
1243 ** or equal to the product of the second and third arguments. The buffer
1244 ** must be aligned to an 8-byte boundary. If the second argument is not
1245 ** a multiple of 8, it is internally rounded down to the next smaller
 
1246 ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
1247 **
1248 ** </dl>
1249 */
1250 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1251
1252
1253 /*
1254 ** CAPI3REF: Enable Or Disable Extended Result Codes {H12200} <S10700>
1255 **
1256 ** The sqlite3_extended_result_codes() routine enables or disables the
1257 ** [extended result codes] feature of SQLite. The extended result
1258 ** codes are disabled by default for historical compatibility considerations.
1259 **
1260 ** Requirements:
1261 ** [H12201] [H12202]
1262 */
1263 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1264
1265 /*
1266 ** CAPI3REF: Last Insert Rowid {H12220} <S10700>
1267 **
1268 ** Each entry in an SQLite table has a unique 64-bit signed
1269 ** integer key called the [ROWID | "rowid"]. The rowid is always available
1270 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1271 ** names are not also used by explicitly declared columns. If
1272 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1273 ** is another alias for the rowid.
1274 **
1275 ** This routine returns the [rowid] of the most recent
1276 ** successful [INSERT] into the database from the [database connection]
1277 ** in the first argument. If no successful [INSERT]s
1278 ** have ever occurred on that database connection, zero is returned.
1279 **
1280 ** If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1281 ** row is returned by this routine as long as the trigger is running.
1282 ** But once the trigger terminates, the value returned by this routine
1283 ** reverts to the last value inserted before the trigger fired.
1284 **
1285 ** An [INSERT] that fails due to a constraint violation is not a
1286 ** successful [INSERT] and does not change the value returned by this
1287 ** routine. Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1288 ** and INSERT OR ABORT make no changes to the return value of this
1289 ** routine when their insertion fails. When INSERT OR REPLACE
1290 ** encounters a constraint violation, it does not fail. The
1291 ** INSERT continues to completion after deleting rows that caused
1292 ** the constraint problem so INSERT OR REPLACE will always change
1293 ** the return value of this interface.
1294 **
1295 ** For the purposes of this routine, an [INSERT] is considered to
1296 ** be successful even if it is subsequently rolled back.
1297 **
1298 ** This function is accessible to SQL statements via the
1299 ** [last_insert_rowid() SQL function].
1300 **
1301 ** Requirements:
1302 ** [H12221] [H12223]
1303 **
1304 ** If a separate thread performs a new [INSERT] on the same
1305 ** database connection while the [sqlite3_last_insert_rowid()]
1306 ** function is running and thus changes the last insert [rowid],
1307 ** then the value returned by [sqlite3_last_insert_rowid()] is
1308 ** unpredictable and might not equal either the old or the new
@@ -1309,164 +1349,154 @@
1309 ** last insert [rowid].
1310 */
1311 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1312
1313 /*
1314 ** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600>
1315 **
1316 ** This function returns the number of database rows that were changed
1317 ** or inserted or deleted by the most recently completed SQL statement
1318 ** on the [database connection] specified by the first parameter.
1319 ** Only changes that are directly specified by the [INSERT], [UPDATE],
1320 ** or [DELETE] statement are counted. Auxiliary changes caused by
1321 ** triggers or [foreign key actions] are not counted. Use the
1322 ** [sqlite3_total_changes()] function to find the total number of changes
1323 ** including changes caused by triggers and foreign key actions.
1324 **
1325 ** Changes to a view that are simulated by an [INSTEAD OF trigger]
1326 ** are not counted. Only real table changes are counted.
1327 **
1328 ** A "row change" is a change to a single row of a single table
1329 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
1330 ** are changed as side effects of [REPLACE] constraint resolution,
1331 ** rollback, ABORT processing, [DROP TABLE], or by any other
1332 ** mechanisms do not count as direct row changes.
1333 **
1334 ** A "trigger context" is a scope of execution that begins and
1335 ** ends with the script of a [CREATE TRIGGER | trigger].
1336 ** Most SQL statements are
1337 ** evaluated outside of any trigger. This is the "top level"
1338 ** trigger context. If a trigger fires from the top level, a
1339 ** new trigger context is entered for the duration of that one
1340 ** trigger. Subtriggers create subcontexts for their duration.
1341 **
1342 ** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1343 ** not create a new trigger context.
1344 **
1345 ** This function returns the number of direct row changes in the
1346 ** most recent INSERT, UPDATE, or DELETE statement within the same
1347 ** trigger context.
1348 **
1349 ** Thus, when called from the top level, this function returns the
1350 ** number of changes in the most recent INSERT, UPDATE, or DELETE
1351 ** that also occurred at the top level. Within the body of a trigger,
1352 ** the sqlite3_changes() interface can be called to find the number of
1353 ** changes in the most recently completed INSERT, UPDATE, or DELETE
1354 ** statement within the body of the same trigger.
1355 ** However, the number returned does not include changes
1356 ** caused by subtriggers since those have their own context.
1357 **
1358 ** See also the [sqlite3_total_changes()] interface, the
1359 ** [count_changes pragma], and the [changes() SQL function].
1360 **
1361 ** Requirements:
1362 ** [H12241] [H12243]
1363 **
1364 ** If a separate thread makes changes on the same database connection
1365 ** while [sqlite3_changes()] is running then the value returned
1366 ** is unpredictable and not meaningful.
1367 */
1368 SQLITE_API int sqlite3_changes(sqlite3*);
1369
1370 /*
1371 ** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600>
1372 **
1373 ** This function returns the number of row changes caused by [INSERT],
1374 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1375 ** The count includes all changes from all [CREATE TRIGGER | trigger]
1376 ** contexts and changes made by [foreign key actions]. However,
 
1377 ** the count does not include changes used to implement [REPLACE] constraints,
1378 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1379 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1380 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1381 ** are counted.
1382 ** The changes are counted as soon as the statement that makes them is
1383 ** completed (when the statement handle is passed to [sqlite3_reset()] or
1384 ** [sqlite3_finalize()]).
1385 **
1386 ** See also the [sqlite3_changes()] interface, the
1387 ** [count_changes pragma], and the [total_changes() SQL function].
1388 **
1389 ** Requirements:
1390 ** [H12261] [H12263]
1391 **
1392 ** If a separate thread makes changes on the same database connection
1393 ** while [sqlite3_total_changes()] is running then the value
1394 ** returned is unpredictable and not meaningful.
1395 */
1396 SQLITE_API int sqlite3_total_changes(sqlite3*);
1397
1398 /*
1399 ** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500>
1400 **
1401 ** This function causes any pending database operation to abort and
1402 ** return at its earliest opportunity. This routine is typically
1403 ** called in response to a user action such as pressing "Cancel"
1404 ** or Ctrl-C where the user wants a long query operation to halt
1405 ** immediately.
1406 **
1407 ** It is safe to call this routine from a thread different from the
1408 ** thread that is currently running the database operation. But it
1409 ** is not safe to call this routine with a [database connection] that
1410 ** is closed or might close before sqlite3_interrupt() returns.
1411 **
1412 ** If an SQL operation is very nearly finished at the time when
1413 ** sqlite3_interrupt() is called, then it might not have an opportunity
1414 ** to be interrupted and might continue to completion.
1415 **
1416 ** An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1417 ** If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1418 ** that is inside an explicit transaction, then the entire transaction
1419 ** will be rolled back automatically.
1420 **
1421 ** The sqlite3_interrupt(D) call is in effect until all currently running
1422 ** SQL statements on [database connection] D complete. Any new SQL statements
1423 ** that are started after the sqlite3_interrupt() call and before the
1424 ** running statements reaches zero are interrupted as if they had been
1425 ** running prior to the sqlite3_interrupt() call. New SQL statements
1426 ** that are started after the running statement count reaches zero are
1427 ** not effected by the sqlite3_interrupt().
1428 ** A call to sqlite3_interrupt(D) that occurs when there are no running
1429 ** SQL statements is a no-op and has no effect on SQL statements
1430 ** that are started after the sqlite3_interrupt() call returns.
1431 **
1432 ** Requirements:
1433 ** [H12271] [H12272]
1434 **
1435 ** If the database connection closes while [sqlite3_interrupt()]
1436 ** is running then bad things will likely happen.
1437 */
1438 SQLITE_API void sqlite3_interrupt(sqlite3*);
1439
1440 /*
1441 ** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200>
1442 **
1443 ** These routines are useful during command-line input to determine if the
1444 ** currently entered text seems to form a complete SQL statement or
1445 ** if additional input is needed before sending the text into
1446 ** SQLite for parsing. These routines return 1 if the input string
1447 ** appears to be a complete SQL statement. A statement is judged to be
1448 ** complete if it ends with a semicolon token and is not a prefix of a
1449 ** well-formed CREATE TRIGGER statement. Semicolons that are embedded within
1450 ** string literals or quoted identifier names or comments are not
1451 ** independent tokens (they are part of the token in which they are
1452 ** embedded) and thus do not count as a statement terminator. Whitespace
1453 ** and comments that follow the final semicolon are ignored.
1454 **
1455 ** These routines return 0 if the statement is incomplete. If a
1456 ** memory allocation fails, then SQLITE_NOMEM is returned.
1457 **
1458 ** These routines do not parse the SQL statements thus
1459 ** will not detect syntactically incorrect SQL.
1460 **
1461 ** If SQLite has not been initialized using [sqlite3_initialize()] prior
1462 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
1463 ** automatically by sqlite3_complete16(). If that initialization fails,
1464 ** then the return value from sqlite3_complete16() will be non-zero
1465 ** regardless of whether or not the input SQL is complete.
1466 **
1467 ** Requirements: [H10511] [H10512]
1468 **
1469 ** The input to [sqlite3_complete()] must be a zero-terminated
1470 ** UTF-8 string.
1471 **
1472 ** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1474,31 +1504,31 @@
1474 */
1475 SQLITE_API int sqlite3_complete(const char *sql);
1476 SQLITE_API int sqlite3_complete16(const void *sql);
1477
1478 /*
1479 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400>
1480 **
1481 ** This routine sets a callback function that might be invoked whenever
1482 ** an attempt is made to open a database table that another thread
1483 ** or process has locked.
1484 **
1485 ** If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
1486 ** is returned immediately upon encountering the lock. If the busy callback
1487 ** is not NULL, then the callback will be invoked with two arguments.
1488 **
1489 ** The first argument to the handler is a copy of the void* pointer which
1490 ** is the third argument to sqlite3_busy_handler(). The second argument to
1491 ** the handler callback is the number of times that the busy handler has
1492 ** been invoked for this locking event. If the
1493 ** busy callback returns 0, then no additional attempts are made to
1494 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
1495 ** If the callback returns non-zero, then another attempt
1496 ** is made to open the database for reading and the cycle repeats.
1497 **
1498 ** The presence of a busy handler does not guarantee that it will be invoked
1499 ** when there is lock contention. If SQLite determines that invoking the busy
1500 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
1501 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
1502 ** Consider a scenario where one process is holding a read lock that
1503 ** it is trying to promote to a reserved lock and
1504 ** a second process is holding a reserved lock that it is trying
@@ -1508,69 +1538,63 @@
1508 ** invoke the busy handlers, neither will make any progress. Therefore,
1509 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
1510 ** will induce the first process to release its read lock and allow
1511 ** the second process to proceed.
1512 **
1513 ** The default busy callback is NULL.
1514 **
1515 ** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
1516 ** when SQLite is in the middle of a large transaction where all the
1517 ** changes will not fit into the in-memory cache. SQLite will
1518 ** already hold a RESERVED lock on the database file, but it needs
1519 ** to promote this lock to EXCLUSIVE so that it can spill cache
1520 ** pages into the database file without harm to concurrent
1521 ** readers. If it is unable to promote the lock, then the in-memory
1522 ** cache will be left in an inconsistent state and so the error
1523 ** code is promoted from the relatively benign [SQLITE_BUSY] to
1524 ** the more severe [SQLITE_IOERR_BLOCKED]. This error code promotion
1525 ** forces an automatic rollback of the changes. See the
1526 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
1527 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
1528 ** this is important.
1529 **
1530 ** There can only be a single busy handler defined for each
1531 ** [database connection]. Setting a new busy handler clears any
1532 ** previously set handler. Note that calling [sqlite3_busy_timeout()]
1533 ** will also set or clear the busy handler.
1534 **
1535 ** The busy callback should not take any actions which modify the
1536 ** database connection that invoked the busy handler. Any such actions
1537 ** result in undefined behavior.
1538 **
1539 ** Requirements:
1540 ** [H12311] [H12312] [H12314] [H12316] [H12318]
1541 **
1542 ** A busy handler must not close the database connection
1543 ** or [prepared statement] that invoked the busy handler.
1544 */
1545 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
1546
1547 /*
1548 ** CAPI3REF: Set A Busy Timeout {H12340} <S40410>
1549 **
1550 ** This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
1551 ** for a specified amount of time when a table is locked. The handler
1552 ** will sleep multiple times until at least "ms" milliseconds of sleeping
1553 ** have accumulated. {H12343} After "ms" milliseconds of sleeping,
1554 ** the handler returns 0 which causes [sqlite3_step()] to return
1555 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
1556 **
1557 ** Calling this routine with an argument less than or equal to zero
1558 ** turns off all busy handlers.
1559 **
1560 ** There can only be a single busy handler for a particular
1561 ** [database connection] any any given moment. If another busy handler
1562 ** was defined (using [sqlite3_busy_handler()]) prior to calling
1563 ** this routine, that other busy handler is cleared.
1564 **
1565 ** Requirements:
1566 ** [H12341] [H12343] [H12344]
1567 */
1568 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
1569
1570 /*
1571 ** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000>
1572 **
1573 ** Definition: A <b>result table</b> is memory data structure created by the
1574 ** [sqlite3_get_table()] interface. A result table records the
1575 ** complete query results from one or more queries.
1576 **
@@ -1614,31 +1638,29 @@
1614 ** azResult&#91;5] = "28";
1615 ** azResult&#91;6] = "Cindy";
1616 ** azResult&#91;7] = "21";
1617 ** </pre></blockquote>
1618 **
1619 ** The sqlite3_get_table() function evaluates one or more
1620 ** semicolon-separated SQL statements in the zero-terminated UTF-8
1621 ** string of its 2nd parameter. It returns a result table to the
1622 ** pointer given in its 3rd parameter.
1623 **
1624 ** After the calling function has finished using the result, it should
1625 ** pass the pointer to the result table to sqlite3_free_table() in order to
1626 ** release the memory that was malloced. Because of the way the
1627 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
1628 ** function must not try to call [sqlite3_free()] directly. Only
1629 ** [sqlite3_free_table()] is able to release the memory properly and safely.
1630 **
1631 ** The sqlite3_get_table() interface is implemented as a wrapper around
1632 ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
1633 ** to any internal data structures of SQLite. It uses only the public
1634 ** interface defined here. As a consequence, errors that occur in the
1635 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
1636 ** reflected in subsequent calls to [sqlite3_errcode()] or [sqlite3_errmsg()].
1637 **
1638 ** Requirements:
1639 ** [H12371] [H12373] [H12374] [H12376] [H12379] [H12382]
1640 */
1641 SQLITE_API int sqlite3_get_table(
1642 sqlite3 *db, /* An open database */
1643 const char *zSql, /* SQL to be evaluated */
1644 char ***pazResult, /* Results of the query */
@@ -1647,49 +1669,49 @@
1647 char **pzErrmsg /* Error msg written here */
1648 );
1649 SQLITE_API void sqlite3_free_table(char **result);
1650
1651 /*
1652 ** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000>
1653 **
1654 ** These routines are work-alikes of the "printf()" family of functions
1655 ** from the standard C library.
1656 **
1657 ** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
1658 ** results into memory obtained from [sqlite3_malloc()].
1659 ** The strings returned by these two routines should be
1660 ** released by [sqlite3_free()]. Both routines return a
1661 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
1662 ** memory to hold the resulting string.
1663 **
1664 ** In sqlite3_snprintf() routine is similar to "snprintf()" from
1665 ** the standard C library. The result is written into the
1666 ** buffer supplied as the second parameter whose size is given by
1667 ** the first parameter. Note that the order of the
1668 ** first two parameters is reversed from snprintf(). This is an
1669 ** historical accident that cannot be fixed without breaking
1670 ** backwards compatibility. Note also that sqlite3_snprintf()
1671 ** returns a pointer to its buffer instead of the number of
1672 ** characters actually written into the buffer. We admit that
1673 ** the number of characters written would be a more useful return
1674 ** value but we cannot change the implementation of sqlite3_snprintf()
1675 ** now without breaking compatibility.
1676 **
1677 ** As long as the buffer size is greater than zero, sqlite3_snprintf()
1678 ** guarantees that the buffer is always zero-terminated. The first
1679 ** parameter "n" is the total size of the buffer, including space for
1680 ** the zero terminator. So the longest string that can be completely
1681 ** written will be n-1 characters.
1682 **
1683 ** These routines all implement some additional formatting
1684 ** options that are useful for constructing SQL statements.
1685 ** All of the usual printf() formatting options apply. In addition, there
1686 ** is are "%q", "%Q", and "%z" options.
1687 **
1688 ** The %q option works like %s in that it substitutes a null-terminated
1689 ** string from the argument list. But %q also doubles every '\'' character.
1690 ** %q is designed for use inside a string literal. By doubling each '\''
1691 ** character it escapes that character and allows it to be inserted into
1692 ** the string.
1693 **
1694 ** For example, assume the string variable zText contains text as follows:
1695 **
@@ -1720,14 +1742,14 @@
1720 ** </pre></blockquote>
1721 **
1722 ** This second example is an SQL syntax error. As a general rule you should
1723 ** always use %q instead of %s when inserting text into a string literal.
1724 **
1725 ** The %Q option works like %q except it also adds single quotes around
1726 ** the outside of the total string. Additionally, if the parameter in the
1727 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
1728 ** single quotes) in place of the %Q option. So, for example, one could say:
1729 **
1730 ** <blockquote><pre>
1731 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
1732 ** sqlite3_exec(db, zSQL, 0, 0, 0);
1733 ** sqlite3_free(zSQL);
@@ -1734,75 +1756,63 @@
1734 ** </pre></blockquote>
1735 **
1736 ** The code above will render a correct SQL statement in the zSQL
1737 ** variable even if the zText variable is a NULL pointer.
1738 **
1739 ** The "%z" formatting option works exactly like "%s" with the
1740 ** addition that after the string has been read and copied into
1741 ** the result, [sqlite3_free()] is called on the input string. {END}
1742 **
1743 ** Requirements:
1744 ** [H17403] [H17406] [H17407]
1745 */
1746 SQLITE_API char *sqlite3_mprintf(const char*,...);
1747 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
1748 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
1749
1750 /*
1751 ** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000>
1752 **
1753 ** The SQLite core uses these three routines for all of its own
1754 ** internal memory allocation needs. "Core" in the previous sentence
1755 ** does not include operating-system specific VFS implementation. The
1756 ** Windows VFS uses native malloc() and free() for some operations.
1757 **
1758 ** The sqlite3_malloc() routine returns a pointer to a block
1759 ** of memory at least N bytes in length, where N is the parameter.
1760 ** If sqlite3_malloc() is unable to obtain sufficient free
1761 ** memory, it returns a NULL pointer. If the parameter N to
1762 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
1763 ** a NULL pointer.
1764 **
1765 ** Calling sqlite3_free() with a pointer previously returned
1766 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
1767 ** that it might be reused. The sqlite3_free() routine is
1768 ** a no-op if is called with a NULL pointer. Passing a NULL pointer
1769 ** to sqlite3_free() is harmless. After being freed, memory
1770 ** should neither be read nor written. Even reading previously freed
1771 ** memory might result in a segmentation fault or other severe error.
1772 ** Memory corruption, a segmentation fault, or other severe error
1773 ** might result if sqlite3_free() is called with a non-NULL pointer that
1774 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
1775 **
1776 ** The sqlite3_realloc() interface attempts to resize a
1777 ** prior memory allocation to be at least N bytes, where N is the
1778 ** second parameter. The memory allocation to be resized is the first
1779 ** parameter. If the first parameter to sqlite3_realloc()
1780 ** is a NULL pointer then its behavior is identical to calling
1781 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
1782 ** If the second parameter to sqlite3_realloc() is zero or
1783 ** negative then the behavior is exactly the same as calling
1784 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
1785 ** sqlite3_realloc() returns a pointer to a memory allocation
1786 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
1787 ** If M is the size of the prior allocation, then min(N,M) bytes
1788 ** of the prior allocation are copied into the beginning of buffer returned
1789 ** by sqlite3_realloc() and the prior allocation is freed.
1790 ** If sqlite3_realloc() returns NULL, then the prior allocation
1791 ** is not freed.
1792 **
1793 ** The memory returned by sqlite3_malloc() and sqlite3_realloc()
1794 ** is always aligned to at least an 8 byte boundary. {END}
1795 **
1796 ** The default implementation of the memory allocation subsystem uses
1797 ** the malloc(), realloc() and free() provided by the standard C library.
1798 ** {H17382} However, if SQLite is compiled with the
1799 ** SQLITE_MEMORY_SIZE=<i>NNN</i> C preprocessor macro (where <i>NNN</i>
1800 ** is an integer), then SQLite create a static array of at least
1801 ** <i>NNN</i> bytes in size and uses that array for all of its dynamic
1802 ** memory allocation needs. {END} Additional memory allocator options
1803 ** may be added in future releases.
1804 **
1805 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
1806 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
1807 ** implementation of these routines to be omitted. That capability
1808 ** is no longer provided. Only built-in memory allocators can be used.
@@ -1813,14 +1823,10 @@
1813 ** and whatever filename encoding is used by the particular Windows
1814 ** installation. Memory allocation errors are detected, but
1815 ** they are reported back as [SQLITE_CANTOPEN] or
1816 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
1817 **
1818 ** Requirements:
1819 ** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318]
1820 ** [H17321] [H17322] [H17323]
1821 **
1822 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
1823 ** must be either NULL or else pointers obtained from a prior
1824 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
1825 ** not yet been released.
1826 **
@@ -1831,85 +1837,95 @@
1831 SQLITE_API void *sqlite3_malloc(int);
1832 SQLITE_API void *sqlite3_realloc(void*, int);
1833 SQLITE_API void sqlite3_free(void*);
1834
1835 /*
1836 ** CAPI3REF: Memory Allocator Statistics {H17370} <S30210>
1837 **
1838 ** SQLite provides these two interfaces for reporting on the status
1839 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
1840 ** routines, which form the built-in memory allocation subsystem.
1841 **
1842 ** Requirements:
1843 ** [H17371] [H17373] [H17374] [H17375]
 
 
 
 
 
 
 
 
 
 
 
 
 
1844 */
1845 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
1846 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
1847
1848 /*
1849 ** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000>
1850 **
1851 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
1852 ** select random [ROWID | ROWIDs] when inserting new records into a table that
1853 ** already uses the largest possible [ROWID]. The PRNG is also used for
1854 ** the build-in random() and randomblob() SQL functions. This interface allows
1855 ** applications to access the same PRNG for other purposes.
1856 **
1857 ** A call to this routine stores N bytes of randomness into buffer P.
1858 **
1859 ** The first time this routine is invoked (either internally or by
1860 ** the application) the PRNG is seeded using randomness obtained
1861 ** from the xRandomness method of the default [sqlite3_vfs] object.
1862 ** On all subsequent invocations, the pseudo-randomness is generated
1863 ** internally and without recourse to the [sqlite3_vfs] xRandomness
1864 ** method.
1865 **
1866 ** Requirements:
1867 ** [H17392]
1868 */
1869 SQLITE_API void sqlite3_randomness(int N, void *P);
1870
1871 /*
1872 ** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100>
1873 **
1874 ** This routine registers a authorizer callback with a particular
1875 ** [database connection], supplied in the first argument.
1876 ** The authorizer callback is invoked as SQL statements are being compiled
1877 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
1878 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. At various
1879 ** points during the compilation process, as logic is being created
1880 ** to perform various actions, the authorizer callback is invoked to
1881 ** see if those actions are allowed. The authorizer callback should
1882 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
1883 ** specific action but allow the SQL statement to continue to be
1884 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
1885 ** rejected with an error. If the authorizer callback returns
1886 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
1887 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
1888 ** the authorizer will fail with an error message.
1889 **
1890 ** When the callback returns [SQLITE_OK], that means the operation
1891 ** requested is ok. When the callback returns [SQLITE_DENY], the
1892 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
1893 ** authorizer will fail with an error message explaining that
1894 ** access is denied.
1895 **
1896 ** The first parameter to the authorizer callback is a copy of the third
1897 ** parameter to the sqlite3_set_authorizer() interface. The second parameter
1898 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
1899 ** the particular action to be authorized. The third through sixth parameters
1900 ** to the callback are zero-terminated strings that contain additional
1901 ** details about the action to be authorized.
1902 **
1903 ** If the action code is [SQLITE_READ]
1904 ** and the callback returns [SQLITE_IGNORE] then the
1905 ** [prepared statement] statement is constructed to substitute
1906 ** a NULL value in place of the table column that would have
1907 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
1908 ** return can be used to deny an untrusted user access to individual
1909 ** columns of a table.
1910 ** If the action code is [SQLITE_DELETE] and the callback returns
1911 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
1912 ** [truncate optimization] is disabled and all rows are deleted individually.
1913 **
1914 ** An authorizer is used when [sqlite3_prepare | preparing]
1915 ** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -1925,43 +1941,39 @@
1925 ** Applications that need to process SQL from untrusted sources
1926 ** might also consider lowering resource limits using [sqlite3_limit()]
1927 ** and limiting database size using the [max_page_count] [PRAGMA]
1928 ** in addition to using an authorizer.
1929 **
1930 ** Only a single authorizer can be in place on a database connection
1931 ** at a time. Each call to sqlite3_set_authorizer overrides the
1932 ** previous call. Disable the authorizer by installing a NULL callback.
1933 ** The authorizer is disabled by default.
1934 **
1935 ** The authorizer callback must not do anything that will modify
1936 ** the database connection that invoked the authorizer callback.
1937 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
1938 ** database connections for the meaning of "modify" in this paragraph.
1939 **
1940 ** When [sqlite3_prepare_v2()] is used to prepare a statement, the
1941 ** statement might be re-prepared during [sqlite3_step()] due to a
1942 ** schema change. Hence, the application should ensure that the
1943 ** correct authorizer callback remains in place during the [sqlite3_step()].
1944 **
1945 ** Note that the authorizer callback is invoked only during
1946 ** [sqlite3_prepare()] or its variants. Authorization is not
1947 ** performed during statement evaluation in [sqlite3_step()], unless
1948 ** as stated in the previous paragraph, sqlite3_step() invokes
1949 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
1950 **
1951 ** Requirements:
1952 ** [H12501] [H12502] [H12503] [H12504] [H12505] [H12506] [H12507] [H12510]
1953 ** [H12511] [H12512] [H12520] [H12521] [H12522]
1954 */
1955 SQLITE_API int sqlite3_set_authorizer(
1956 sqlite3*,
1957 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
1958 void *pUserData
1959 );
1960
1961 /*
1962 ** CAPI3REF: Authorizer Return Codes {H12590} <H12500>
1963 **
1964 ** The [sqlite3_set_authorizer | authorizer callback function] must
1965 ** return either [SQLITE_OK] or one of these two constants in order
1966 ** to signal SQLite whether or not the action is permitted. See the
1967 ** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -1969,11 +1981,11 @@
1969 */
1970 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
1971 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
1972
1973 /*
1974 ** CAPI3REF: Authorizer Action Codes {H12550} <H12500>
1975 **
1976 ** The [sqlite3_set_authorizer()] interface registers a callback function
1977 ** that is invoked to authorize certain SQL statement actions. The
1978 ** second parameter to the callback is an integer code that specifies
1979 ** what action is being authorized. These are the integer action codes that
@@ -1980,19 +1992,16 @@
1980 ** the authorizer callback may be passed.
1981 **
1982 ** These action code values signify what kind of operation is to be
1983 ** authorized. The 3rd and 4th parameters to the authorization
1984 ** callback function will be parameters or NULL depending on which of these
1985 ** codes is used as the second parameter. The 5th parameter to the
1986 ** authorizer callback is the name of the database ("main", "temp",
1987 ** etc.) if applicable. The 6th parameter to the authorizer callback
1988 ** is the name of the inner-most trigger or view that is responsible for
1989 ** the access attempt or NULL if this access attempt is directly from
1990 ** top-level SQL code.
1991 **
1992 ** Requirements:
1993 ** [H12551] [H12552] [H12553] [H12554]
1994 */
1995 /******************************************* 3rd ************ 4th ***********/
1996 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
1997 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
1998 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2026,150 +2035,142 @@
2026 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2027 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2028 #define SQLITE_COPY 0 /* No longer used */
2029
2030 /*
2031 ** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400>
2032 ** EXPERIMENTAL
2033 **
2034 ** These routines register callback functions that can be used for
2035 ** tracing and profiling the execution of SQL statements.
2036 **
2037 ** The callback function registered by sqlite3_trace() is invoked at
2038 ** various times when an SQL statement is being run by [sqlite3_step()].
2039 ** The callback returns a UTF-8 rendering of the SQL statement text
2040 ** as the statement first begins executing. Additional callbacks occur
 
2041 ** as each triggered subprogram is entered. The callbacks for triggers
2042 ** contain a UTF-8 SQL comment that identifies the trigger.
2043 **
2044 ** The callback function registered by sqlite3_profile() is invoked
2045 ** as each SQL statement finishes. The profile callback contains
2046 ** the original statement text and an estimate of wall-clock time
2047 ** of how long that statement took to run.
2048 **
2049 ** Requirements:
2050 ** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289]
2051 ** [H12290]
2052 */
2053 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2054 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2055 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2056
2057 /*
2058 ** CAPI3REF: Query Progress Callbacks {H12910} <S60400>
2059 **
2060 ** This routine configures a callback function - the
2061 ** progress callback - that is invoked periodically during long
2062 ** running calls to [sqlite3_exec()], [sqlite3_step()] and
2063 ** [sqlite3_get_table()]. An example use for this
2064 ** interface is to keep a GUI updated during a large query.
2065 **
2066 ** If the progress callback returns non-zero, the operation is
2067 ** interrupted. This feature can be used to implement a
2068 ** "Cancel" button on a GUI progress dialog box.
2069 **
2070 ** The progress handler must not do anything that will modify
2071 ** the database connection that invoked the progress handler.
2072 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2073 ** database connections for the meaning of "modify" in this paragraph.
2074 **
2075 ** Requirements:
2076 ** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918]
2077 **
2078 */
2079 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2080
2081 /*
2082 ** CAPI3REF: Opening A New Database Connection {H12700} <S40200>
2083 **
2084 ** These routines open an SQLite database file whose name is given by the
2085 ** filename argument. The filename argument is interpreted as UTF-8 for
2086 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2087 ** order for sqlite3_open16(). A [database connection] handle is usually
2088 ** returned in *ppDb, even if an error occurs. The only exception is that
2089 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
2090 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2091 ** object. If the database is opened (and/or created) successfully, then
2092 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned. The
2093 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2094 ** an English language description of the error.
 
2095 **
2096 ** The default encoding for the database will be UTF-8 if
2097 ** sqlite3_open() or sqlite3_open_v2() is called and
2098 ** UTF-16 in the native byte order if sqlite3_open16() is used.
2099 **
2100 ** Whether or not an error occurs when it is opened, resources
2101 ** associated with the [database connection] handle should be released by
2102 ** passing it to [sqlite3_close()] when it is no longer required.
2103 **
2104 ** The sqlite3_open_v2() interface works like sqlite3_open()
2105 ** except that it accepts two additional parameters for additional control
2106 ** over the new database connection. The flags parameter can take one of
 
2107 ** the following three values, optionally combined with the
2108 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2109 ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:
2110 **
2111 ** <dl>
2112 ** <dt>[SQLITE_OPEN_READONLY]</dt>
2113 ** <dd>The database is opened in read-only mode. If the database does not
2114 ** already exist, an error is returned.</dd>
2115 **
2116 ** <dt>[SQLITE_OPEN_READWRITE]</dt>
2117 ** <dd>The database is opened for reading and writing if possible, or reading
2118 ** only if the file is write protected by the operating system. In either
2119 ** case the database must already exist, otherwise an error is returned.</dd>
2120 **
2121 ** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2122 ** <dd>The database is opened for reading and writing, and is creates it if
2123 ** it does not already exist. This is the behavior that is always used for
2124 ** sqlite3_open() and sqlite3_open16().</dd>
2125 ** </dl>
2126 **
2127 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
2128 ** combinations shown above or one of the combinations shown above combined
2129 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
2130 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
2131 ** then the behavior is undefined.
2132 **
2133 ** If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2134 ** opens in the multi-thread [threading mode] as long as the single-thread
2135 ** mode has not been set at compile-time or start-time. If the
2136 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
2137 ** in the serialized [threading mode] unless single-thread was
2138 ** previously selected at compile-time or start-time.
2139 ** The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2140 ** eligible to use [shared cache mode], regardless of whether or not shared
2141 ** cache is enabled using [sqlite3_enable_shared_cache()]. The
2142 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2143 ** participate in [shared cache mode] even if it is enabled.
2144 **
2145 ** If the filename is ":memory:", then a private, temporary in-memory database
2146 ** is created for the connection. This in-memory database will vanish when
2147 ** the database connection is closed. Future versions of SQLite might
2148 ** make use of additional special filenames that begin with the ":" character.
2149 ** It is recommended that when a database filename actually does begin with
2150 ** a ":" character you should prefix the filename with a pathname such as
2151 ** "./" to avoid ambiguity.
2152 **
2153 ** If the filename is an empty string, then a private, temporary
2154 ** on-disk database will be created. This private database will be
2155 ** automatically deleted as soon as the database connection is closed.
2156 **
2157 ** The fourth parameter to sqlite3_open_v2() is the name of the
2158 ** [sqlite3_vfs] object that defines the operating system interface that
2159 ** the new database connection should use. If the fourth parameter is
2160 ** a NULL pointer then the default [sqlite3_vfs] object is used.
2161 **
2162 ** <b>Note to Windows users:</b> The encoding used for the filename argument
2163 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2164 ** codepage is currently defined. Filenames containing international
2165 ** characters must be converted to UTF-8 prior to passing them into
2166 ** sqlite3_open() or sqlite3_open_v2().
2167 **
2168 ** Requirements:
2169 ** [H12701] [H12702] [H12703] [H12704] [H12706] [H12707] [H12709] [H12711]
2170 ** [H12712] [H12713] [H12714] [H12717] [H12719] [H12721] [H12723]
2171 */
2172 SQLITE_API int sqlite3_open(
2173 const char *filename, /* Database filename (UTF-8) */
2174 sqlite3 **ppDb /* OUT: SQLite db handle */
2175 );
@@ -2183,27 +2184,27 @@
2183 int flags, /* Flags */
2184 const char *zVfs /* Name of VFS module to use */
2185 );
2186
2187 /*
2188 ** CAPI3REF: Error Codes And Messages {H12800} <S60200>
2189 **
2190 ** The sqlite3_errcode() interface returns the numeric [result code] or
2191 ** [extended result code] for the most recent failed sqlite3_* API call
2192 ** associated with a [database connection]. If a prior API call failed
2193 ** but the most recent API call succeeded, the return value from
2194 ** sqlite3_errcode() is undefined. The sqlite3_extended_errcode()
2195 ** interface is the same except that it always returns the
2196 ** [extended result code] even when extended result codes are
2197 ** disabled.
2198 **
2199 ** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2200 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
2201 ** Memory to hold the error message string is managed internally.
2202 ** The application does not need to worry about freeing the result.
2203 ** However, the error string might be overwritten or deallocated by
2204 ** subsequent calls to other SQLite interface functions.
2205 **
2206 ** When the serialized [threading mode] is in use, it might be the
2207 ** case that a second error occurs on a separate thread in between
2208 ** the time of the first error and the call to these interfaces.
2209 ** When that happens, the second error will be reported since these
@@ -2214,21 +2215,18 @@
2214 ** all calls to the interfaces listed here are completed.
2215 **
2216 ** If an interface fails with SQLITE_MISUSE, that means the interface
2217 ** was invoked incorrectly by the application. In that case, the
2218 ** error code and message may or may not be set.
2219 **
2220 ** Requirements:
2221 ** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809]
2222 */
2223 SQLITE_API int sqlite3_errcode(sqlite3 *db);
2224 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
2225 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
2226 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
2227
2228 /*
2229 ** CAPI3REF: SQL Statement Object {H13000} <H13010>
2230 ** KEYWORDS: {prepared statement} {prepared statements}
2231 **
2232 ** An instance of this object represents a single SQL statement.
2233 ** This object is variously known as a "prepared statement" or a
2234 ** "compiled SQL statement" or simply as a "statement".
@@ -2250,29 +2248,29 @@
2250 ** information.
2251 */
2252 typedef struct sqlite3_stmt sqlite3_stmt;
2253
2254 /*
2255 ** CAPI3REF: Run-time Limits {H12760} <S20600>
2256 **
2257 ** This interface allows the size of various constructs to be limited
2258 ** on a connection by connection basis. The first parameter is the
2259 ** [database connection] whose limit is to be set or queried. The
2260 ** second parameter is one of the [limit categories] that define a
2261 ** class of constructs to be size limited. The third parameter is the
2262 ** new limit for that construct. The function returns the old limit.
2263 **
2264 ** If the new limit is a negative number, the limit is unchanged.
2265 ** For the limit category of SQLITE_LIMIT_XYZ there is a
2266 ** [limits | hard upper bound]
2267 ** set by a compile-time C preprocessor macro named
2268 ** [limits | SQLITE_MAX_XYZ].
2269 ** (The "_LIMIT_" in the name is changed to "_MAX_".)
2270 ** Attempts to increase a limit above its hard upper bound are
2271 ** silently truncated to the hard upper limit.
2272 **
2273 ** Run time limits are intended for use in applications that manage
2274 ** both their own internal database and also databases that are controlled
2275 ** by untrusted external sources. An example application might be a
2276 ** web browser that has its own databases for storing history and
2277 ** separate databases controlled by JavaScript applications downloaded
2278 ** off the Internet. The internal databases can be given the
@@ -2282,63 +2280,60 @@
2282 ** interface to further control untrusted SQL. The size of the database
2283 ** created by an untrusted script can be contained using the
2284 ** [max_page_count] [PRAGMA].
2285 **
2286 ** New run-time limit categories may be added in future releases.
2287 **
2288 ** Requirements:
2289 ** [H12762] [H12766] [H12769]
2290 */
2291 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2292
2293 /*
2294 ** CAPI3REF: Run-Time Limit Categories {H12790} <H12760>
2295 ** KEYWORDS: {limit category} {*limit categories}
2296 **
2297 ** These constants define various performance limits
2298 ** that can be lowered at run-time using [sqlite3_limit()].
2299 ** The synopsis of the meanings of the various limits is shown below.
2300 ** Additional information is available at [limits | Limits in SQLite].
2301 **
2302 ** <dl>
2303 ** <dt>SQLITE_LIMIT_LENGTH</dt>
2304 ** <dd>The maximum size of any string or BLOB or table row.<dd>
2305 **
2306 ** <dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2307 ** <dd>The maximum length of an SQL statement.</dd>
2308 **
2309 ** <dt>SQLITE_LIMIT_COLUMN</dt>
2310 ** <dd>The maximum number of columns in a table definition or in the
2311 ** result set of a [SELECT] or the maximum number of columns in an index
2312 ** or in an ORDER BY or GROUP BY clause.</dd>
2313 **
2314 ** <dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2315 ** <dd>The maximum depth of the parse tree on any expression.</dd>
2316 **
2317 ** <dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2318 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>
2319 **
2320 ** <dt>SQLITE_LIMIT_VDBE_OP</dt>
2321 ** <dd>The maximum number of instructions in a virtual machine program
2322 ** used to implement an SQL statement.</dd>
2323 **
2324 ** <dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2325 ** <dd>The maximum number of arguments on a function.</dd>
2326 **
2327 ** <dt>SQLITE_LIMIT_ATTACHED</dt>
2328 ** <dd>The maximum number of [ATTACH | attached databases].</dd>
2329 **
2330 ** <dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2331 ** <dd>The maximum length of the pattern argument to the [LIKE] or
2332 ** [GLOB] operators.</dd>
2333 **
2334 ** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2335 ** <dd>The maximum number of variables in an SQL statement that can
2336 ** be bound.</dd>
2337 **
2338 ** <dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2339 ** <dd>The maximum depth of recursion for triggers.</dd>
2340 ** </dl>
2341 */
2342 #define SQLITE_LIMIT_LENGTH 0
2343 #define SQLITE_LIMIT_SQL_LENGTH 1
2344 #define SQLITE_LIMIT_COLUMN 2
@@ -2350,11 +2345,11 @@
2350 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
2351 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
2352 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
2353
2354 /*
2355 ** CAPI3REF: Compiling An SQL Statement {H13010} <S10000>
2356 ** KEYWORDS: {SQL statement compiler}
2357 **
2358 ** To execute an SQL query, it must first be compiled into a byte-code
2359 ** program using one of these routines.
2360 **
@@ -2365,61 +2360,62 @@
2365 ** The second argument, "zSql", is the statement to be compiled, encoded
2366 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2367 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2368 ** use UTF-16.
2369 **
2370 ** If the nByte argument is less than zero, then zSql is read up to the
2371 ** first zero terminator. If nByte is non-negative, then it is the maximum
2372 ** number of bytes read from zSql. When nByte is non-negative, the
2373 ** zSql string ends at either the first '\000' or '\u0000' character or
2374 ** the nByte-th byte, whichever comes first. If the caller knows
2375 ** that the supplied string is nul-terminated, then there is a small
2376 ** performance advantage to be gained by passing an nByte parameter that
2377 ** is equal to the number of bytes in the input string <i>including</i>
2378 ** the nul-terminator bytes.
2379 **
2380 ** If pzTail is not NULL then *pzTail is made to point to the first byte
2381 ** past the end of the first SQL statement in zSql. These routines only
2382 ** compile the first statement in zSql, so *pzTail is left pointing to
2383 ** what remains uncompiled.
2384 **
2385 ** *ppStmt is left pointing to a compiled [prepared statement] that can be
2386 ** executed using [sqlite3_step()]. If there is an error, *ppStmt is set
2387 ** to NULL. If the input text contains no SQL (if the input is an empty
2388 ** string or a comment) then *ppStmt is set to NULL.
2389 ** The calling procedure is responsible for deleting the compiled
2390 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2391 ** ppStmt may not be NULL.
2392 **
2393 ** On success, [SQLITE_OK] is returned, otherwise an [error code] is returned.
 
2394 **
2395 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2396 ** recommended for all new programs. The two older interfaces are retained
2397 ** for backwards compatibility, but their use is discouraged.
2398 ** In the "v2" interfaces, the prepared statement
2399 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
2400 ** original SQL text. This causes the [sqlite3_step()] interface to
2401 ** behave differently in three ways:
2402 **
2403 ** <ol>
2404 ** <li>
2405 ** If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2406 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
2407 ** statement and try to run it again. If the schema has changed in
2408 ** a way that makes the statement no longer valid, [sqlite3_step()] will still
2409 ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
2410 ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
2411 ** error go away. Note: use [sqlite3_errmsg()] to find the text
2412 ** of the parsing error that results in an [SQLITE_SCHEMA] return.
2413 ** </li>
2414 **
2415 ** <li>
2416 ** When an error occurs, [sqlite3_step()] will return one of the detailed
2417 ** [error codes] or [extended error codes]. The legacy behavior was that
2418 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2419 ** and you would have to make a second call to [sqlite3_reset()] in order
2420 ** to find the underlying cause of the problem. With the "v2" prepare
2421 ** interfaces, the underlying reason for the error is returned immediately.
2422 ** </li>
2423 **
2424 ** <li>
2425 ** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2427,14 +2423,10 @@
2427 ** automatically recompiled (as if there had been a schema change) on the first
2428 ** [sqlite3_step()] call following any change to the
2429 ** [sqlite3_bind_text | bindings] of the [parameter].
2430 ** </li>
2431 ** </ol>
2432 **
2433 ** Requirements:
2434 ** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021]
2435 **
2436 */
2437 SQLITE_API int sqlite3_prepare(
2438 sqlite3 *db, /* Database handle */
2439 const char *zSql, /* SQL statement, UTF-8 encoded */
2440 int nByte, /* Maximum length of zSql in bytes. */
@@ -2462,28 +2454,25 @@
2462 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
2463 const void **pzTail /* OUT: Pointer to unused portion of zSql */
2464 );
2465
2466 /*
2467 ** CAPI3REF: Retrieving Statement SQL {H13100} <H13000>
2468 **
2469 ** This interface can be used to retrieve a saved copy of the original
2470 ** SQL text used to create a [prepared statement] if that statement was
2471 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
2472 **
2473 ** Requirements:
2474 ** [H13101] [H13102] [H13103]
2475 */
2476 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
2477
2478 /*
2479 ** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200>
2480 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
2481 **
2482 ** SQLite uses the sqlite3_value object to represent all values
2483 ** that can be stored in a database table. SQLite uses dynamic typing
2484 ** for the values it stores. Values stored in sqlite3_value objects
2485 ** can be integers, floating point values, strings, BLOBs, or NULL.
2486 **
2487 ** An sqlite3_value object may be either "protected" or "unprotected".
2488 ** Some interfaces require a protected sqlite3_value. Other interfaces
2489 ** will accept either a protected or an unprotected sqlite3_value.
@@ -2501,26 +2490,26 @@
2501 ** sqlite3_value objects and they can be used interchangeably. However,
2502 ** for maximum code portability it is recommended that applications
2503 ** still make the distinction between between protected and unprotected
2504 ** sqlite3_value objects even when not strictly required.
2505 **
2506 ** The sqlite3_value objects that are passed as parameters into the
2507 ** implementation of [application-defined SQL functions] are protected.
2508 ** The sqlite3_value object returned by
2509 ** [sqlite3_column_value()] is unprotected.
2510 ** Unprotected sqlite3_value objects may only be used with
2511 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
2512 ** The [sqlite3_value_blob | sqlite3_value_type()] family of
2513 ** interfaces require protected sqlite3_value objects.
2514 */
2515 typedef struct Mem sqlite3_value;
2516
2517 /*
2518 ** CAPI3REF: SQL Function Context Object {H16001} <S20200>
2519 **
2520 ** The context in which an SQL function executes is stored in an
2521 ** sqlite3_context object. A pointer to an sqlite3_context object
2522 ** is always first parameter to [application-defined SQL functions].
2523 ** The application-defined SQL function implementation will pass this
2524 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
2525 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
2526 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -2527,15 +2516,15 @@
2527 ** and/or [sqlite3_set_auxdata()].
2528 */
2529 typedef struct sqlite3_context sqlite3_context;
2530
2531 /*
2532 ** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300>
2533 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
2534 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
2535 **
2536 ** In the SQL strings input to [sqlite3_prepare_v2()] and its variants,
2537 ** literals may be replaced by a [parameter] that matches one of following
2538 ** templates:
2539 **
2540 ** <ul>
2541 ** <li> ?
@@ -2544,76 +2533,70 @@
2544 ** <li> @VVV
2545 ** <li> $VVV
2546 ** </ul>
2547 **
2548 ** In the templates above, NNN represents an integer literal,
2549 ** and VVV represents an alphanumeric identifer. The values of these
2550 ** parameters (also called "host parameter names" or "SQL parameters")
2551 ** can be set using the sqlite3_bind_*() routines defined here.
2552 **
2553 ** The first argument to the sqlite3_bind_*() routines is always
2554 ** a pointer to the [sqlite3_stmt] object returned from
2555 ** [sqlite3_prepare_v2()] or its variants.
2556 **
2557 ** The second argument is the index of the SQL parameter to be set.
2558 ** The leftmost SQL parameter has an index of 1. When the same named
2559 ** SQL parameter is used more than once, second and subsequent
2560 ** occurrences have the same index as the first occurrence.
2561 ** The index for named parameters can be looked up using the
2562 ** [sqlite3_bind_parameter_index()] API if desired. The index
2563 ** for "?NNN" parameters is the value of NNN.
2564 ** The NNN value must be between 1 and the [sqlite3_limit()]
2565 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
2566 **
2567 ** The third argument is the value to bind to the parameter.
2568 **
2569 ** In those routines that have a fourth argument, its value is the
2570 ** number of bytes in the parameter. To be clear: the value is the
2571 ** number of <u>bytes</u> in the value, not the number of characters.
2572 ** If the fourth parameter is negative, the length of the string is
2573 ** the number of bytes up to the first zero terminator.
2574 **
2575 ** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
2576 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
2577 ** string after SQLite has finished with it. If the fifth argument is
2578 ** the special value [SQLITE_STATIC], then SQLite assumes that the
2579 ** information is in static, unmanaged space and does not need to be freed.
2580 ** If the fifth argument has the value [SQLITE_TRANSIENT], then
2581 ** SQLite makes its own private copy of the data immediately, before
2582 ** the sqlite3_bind_*() routine returns.
2583 **
2584 ** The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
2585 ** is filled with zeroes. A zeroblob uses a fixed amount of memory
2586 ** (just an integer to hold its size) while it is being processed.
2587 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
2588 ** content is later written using
2589 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
2590 ** A negative value for the zeroblob results in a zero-length BLOB.
2591 **
2592 ** The sqlite3_bind_*() routines must be called after
2593 ** [sqlite3_prepare_v2()] (and its variants) or [sqlite3_reset()] and
2594 ** before [sqlite3_step()].
2595 ** Bindings are not cleared by the [sqlite3_reset()] routine.
2596 ** Unbound parameters are interpreted as NULL.
2597 **
2598 ** These routines return [SQLITE_OK] on success or an error code if
2599 ** anything goes wrong. [SQLITE_RANGE] is returned if the parameter
2600 ** index is out of range. [SQLITE_NOMEM] is returned if malloc() fails.
2601 ** [SQLITE_MISUSE] might be returned if these routines are called on a
2602 ** virtual machine that is the wrong state or which has already been finalized.
2603 ** Detection of misuse is unreliable. Applications should not depend
2604 ** on SQLITE_MISUSE returns. SQLITE_MISUSE is intended to indicate a
2605 ** a logic error in the application. Future versions of SQLite might
2606 ** panic rather than return SQLITE_MISUSE.
2607 **
2608 ** See also: [sqlite3_bind_parameter_count()],
2609 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
2610 **
2611 ** Requirements:
2612 ** [H13506] [H13509] [H13512] [H13515] [H13518] [H13521] [H13524] [H13527]
2613 ** [H13530] [H13533] [H13536] [H13539] [H13542] [H13545] [H13548] [H13551]
2614 **
2615 */
2616 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
2617 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
2618 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
2619 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -2622,175 +2605,155 @@
2622 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
2623 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
2624 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
2625
2626 /*
2627 ** CAPI3REF: Number Of SQL Parameters {H13600} <S70300>
2628 **
2629 ** This routine can be used to find the number of [SQL parameters]
2630 ** in a [prepared statement]. SQL parameters are tokens of the
2631 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
2632 ** placeholders for values that are [sqlite3_bind_blob | bound]
2633 ** to the parameters at a later time.
2634 **
2635 ** This routine actually returns the index of the largest (rightmost)
2636 ** parameter. For all forms except ?NNN, this will correspond to the
2637 ** number of unique parameters. If parameters of the ?NNN are used,
2638 ** there may be gaps in the list.
2639 **
2640 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2641 ** [sqlite3_bind_parameter_name()], and
2642 ** [sqlite3_bind_parameter_index()].
2643 **
2644 ** Requirements:
2645 ** [H13601]
2646 */
2647 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
2648
2649 /*
2650 ** CAPI3REF: Name Of A Host Parameter {H13620} <S70300>
2651 **
2652 ** This routine returns a pointer to the name of the n-th
2653 ** [SQL parameter] in a [prepared statement].
2654 ** SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
2655 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
2656 ** respectively.
2657 ** In other words, the initial ":" or "$" or "@" or "?"
2658 ** is included as part of the name.
2659 ** Parameters of the form "?" without a following integer have no name
2660 ** and are also referred to as "anonymous parameters".
2661 **
2662 ** The first host parameter has an index of 1, not 0.
2663 **
2664 ** If the value n is out of range or if the n-th parameter is
2665 ** nameless, then NULL is returned. The returned string is
2666 ** always in UTF-8 encoding even if the named parameter was
2667 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
2668 ** [sqlite3_prepare16_v2()].
2669 **
2670 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2671 ** [sqlite3_bind_parameter_count()], and
2672 ** [sqlite3_bind_parameter_index()].
2673 **
2674 ** Requirements:
2675 ** [H13621]
2676 */
2677 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
2678
2679 /*
2680 ** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300>
2681 **
2682 ** Return the index of an SQL parameter given its name. The
2683 ** index value returned is suitable for use as the second
2684 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. A zero
2685 ** is returned if no matching parameter is found. The parameter
2686 ** name must be given in UTF-8 even if the original statement
2687 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
2688 **
2689 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2690 ** [sqlite3_bind_parameter_count()], and
2691 ** [sqlite3_bind_parameter_index()].
2692 **
2693 ** Requirements:
2694 ** [H13641]
2695 */
2696 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
2697
2698 /*
2699 ** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300>
2700 **
2701 ** Contrary to the intuition of many, [sqlite3_reset()] does not reset
2702 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
2703 ** Use this routine to reset all host parameters to NULL.
2704 **
2705 ** Requirements:
2706 ** [H13661]
2707 */
2708 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
2709
2710 /*
2711 ** CAPI3REF: Number Of Columns In A Result Set {H13710} <S10700>
2712 **
2713 ** Return the number of columns in the result set returned by the
2714 ** [prepared statement]. This routine returns 0 if pStmt is an SQL
2715 ** statement that does not return data (for example an [UPDATE]).
2716 **
2717 ** Requirements:
2718 ** [H13711]
2719 */
2720 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
2721
2722 /*
2723 ** CAPI3REF: Column Names In A Result Set {H13720} <S10700>
2724 **
2725 ** These routines return the name assigned to a particular column
2726 ** in the result set of a [SELECT] statement. The sqlite3_column_name()
2727 ** interface returns a pointer to a zero-terminated UTF-8 string
2728 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
2729 ** UTF-16 string. The first parameter is the [prepared statement]
2730 ** that implements the [SELECT] statement. The second parameter is the
2731 ** column number. The leftmost column is number 0.
2732 **
2733 ** The returned string pointer is valid until either the [prepared statement]
2734 ** is destroyed by [sqlite3_finalize()] or until the next call to
2735 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
2736 **
2737 ** If sqlite3_malloc() fails during the processing of either routine
2738 ** (for example during a conversion from UTF-8 to UTF-16) then a
2739 ** NULL pointer is returned.
2740 **
2741 ** The name of a result column is the value of the "AS" clause for
2742 ** that column, if there is an AS clause. If there is no AS clause
2743 ** then the name of the column is unspecified and may change from
2744 ** one release of SQLite to the next.
2745 **
2746 ** Requirements:
2747 ** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727]
2748 */
2749 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
2750 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
2751
2752 /*
2753 ** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700>
2754 **
2755 ** These routines provide a means to determine what column of what
2756 ** table in which database a result of a [SELECT] statement comes from.
2757 ** The name of the database or table or column can be returned as
2758 ** either a UTF-8 or UTF-16 string. The _database_ routines return
 
2759 ** the database name, the _table_ routines return the table name, and
2760 ** the origin_ routines return the column name.
2761 ** The returned string is valid until the [prepared statement] is destroyed
2762 ** using [sqlite3_finalize()] or until the same information is requested
2763 ** again in a different encoding.
2764 **
2765 ** The names returned are the original un-aliased names of the
2766 ** database, table, and column.
2767 **
2768 ** The first argument to the following calls is a [prepared statement].
2769 ** These functions return information about the Nth column returned by
2770 ** the statement, where N is the second function argument.
 
2771 **
2772 ** If the Nth column returned by the statement is an expression or
2773 ** subquery and is not a column value, then all of these functions return
2774 ** NULL. These routine might also return NULL if a memory allocation error
2775 ** occurs. Otherwise, they return the name of the attached database, table
2776 ** and column that query result column was extracted from.
2777 **
2778 ** As with all other SQLite APIs, those postfixed with "16" return
2779 ** UTF-16 encoded strings, the other functions return UTF-8. {END}
2780 **
2781 ** These APIs are only available if the library was compiled with the
2782 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
2783 **
2784 ** {A13751}
2785 ** If two or more threads call one or more of these routines against the same
2786 ** prepared statement and column at the same time then the results are
2787 ** undefined.
2788 **
2789 ** Requirements:
2790 ** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748]
2791 **
2792 ** If two or more threads call one or more
2793 ** [sqlite3_column_database_name | column metadata interfaces]
2794 ** for the same [prepared statement] and result column
2795 ** at the same time then the results are undefined.
2796 */
@@ -2800,46 +2763,43 @@
2800 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
2801 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
2802 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
2803
2804 /*
2805 ** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700>
2806 **
2807 ** The first parameter is a [prepared statement].
2808 ** If this statement is a [SELECT] statement and the Nth column of the
2809 ** returned result set of that [SELECT] is a table column (not an
2810 ** expression or subquery) then the declared type of the table
2811 ** column is returned. If the Nth column of the result set is an
2812 ** expression or subquery, then a NULL pointer is returned.
2813 ** The returned string is always UTF-8 encoded. {END}
2814 **
2815 ** For example, given the database schema:
2816 **
2817 ** CREATE TABLE t1(c1 VARIANT);
2818 **
2819 ** and the following statement to be compiled:
2820 **
2821 ** SELECT c1 + 1, c1 FROM t1;
2822 **
2823 ** this routine would return the string "VARIANT" for the second result
2824 ** column (i==1), and a NULL pointer for the first result column (i==0).
2825 **
2826 ** SQLite uses dynamic run-time typing. So just because a column
2827 ** is declared to contain a particular type does not mean that the
2828 ** data stored in that column is of the declared type. SQLite is
2829 ** strongly typed, but the typing is dynamic not static. Type
2830 ** is associated with individual values, not with the containers
2831 ** used to hold those values.
2832 **
2833 ** Requirements:
2834 ** [H13761] [H13762] [H13763]
2835 */
2836 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
2837 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
2838
2839 /*
2840 ** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000>
2841 **
2842 ** After a [prepared statement] has been prepared using either
2843 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
2844 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
2845 ** must be called one or more times to evaluate the statement.
@@ -2849,39 +2809,39 @@
2849 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
2850 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
2851 ** new "v2" interface is recommended for new applications but the legacy
2852 ** interface will continue to be supported.
2853 **
2854 ** In the legacy interface, the return value will be either [SQLITE_BUSY],
2855 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
2856 ** With the "v2" interface, any of the other [result codes] or
2857 ** [extended result codes] might be returned as well.
2858 **
2859 ** [SQLITE_BUSY] means that the database engine was unable to acquire the
2860 ** database locks it needs to do its job. If the statement is a [COMMIT]
2861 ** or occurs outside of an explicit transaction, then you can retry the
2862 ** statement. If the statement is not a [COMMIT] and occurs within a
2863 ** explicit transaction then you should rollback the transaction before
2864 ** continuing.
2865 **
2866 ** [SQLITE_DONE] means that the statement has finished executing
2867 ** successfully. sqlite3_step() should not be called again on this virtual
2868 ** machine without first calling [sqlite3_reset()] to reset the virtual
2869 ** machine back to its initial state.
2870 **
2871 ** If the SQL statement being executed returns any data, then [SQLITE_ROW]
2872 ** is returned each time a new row of data is ready for processing by the
2873 ** caller. The values may be accessed using the [column access functions].
2874 ** sqlite3_step() is called again to retrieve the next row of data.
2875 **
2876 ** [SQLITE_ERROR] means that a run-time error (such as a constraint
2877 ** violation) has occurred. sqlite3_step() should not be called again on
2878 ** the VM. More information may be found by calling [sqlite3_errmsg()].
2879 ** With the legacy interface, a more specific error code (for example,
2880 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
2881 ** can be obtained by calling [sqlite3_reset()] on the
2882 ** [prepared statement]. In the "v2" interface,
2883 ** the more specific error code is returned directly by sqlite3_step().
2884 **
2885 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
2886 ** Perhaps it was called on a [prepared statement] that has
2887 ** already been [sqlite3_finalize | finalized] or on one that had
@@ -2898,39 +2858,34 @@
2898 ** with the "v2" interface. If you prepare all of your SQL statements
2899 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
2900 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
2901 ** then the more specific [error codes] are returned directly
2902 ** by sqlite3_step(). The use of the "v2" interface is recommended.
2903 **
2904 ** Requirements:
2905 ** [H13202] [H15304] [H15306] [H15308] [H15310]
2906 */
2907 SQLITE_API int sqlite3_step(sqlite3_stmt*);
2908
2909 /*
2910 ** CAPI3REF: Number of columns in a result set {H13770} <S10700>
2911 **
2912 ** Returns the number of values in the current row of the result set.
2913 **
2914 ** Requirements:
2915 ** [H13771] [H13772]
2916 */
2917 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
2918
2919 /*
2920 ** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120>
2921 ** KEYWORDS: SQLITE_TEXT
2922 **
2923 ** {H10266} Every value in SQLite has one of five fundamental datatypes:
2924 **
2925 ** <ul>
2926 ** <li> 64-bit signed integer
2927 ** <li> 64-bit IEEE floating point number
2928 ** <li> string
2929 ** <li> BLOB
2930 ** <li> NULL
2931 ** </ul> {END}
2932 **
2933 ** These constants are codes for each of those types.
2934 **
2935 ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
2936 ** for a completely different meaning. Software that links against both
@@ -2947,22 +2902,22 @@
2947 # define SQLITE_TEXT 3
2948 #endif
2949 #define SQLITE3_TEXT 3
2950
2951 /*
2952 ** CAPI3REF: Result Values From A Query {H13800} <S10700>
2953 ** KEYWORDS: {column access functions}
2954 **
2955 ** These routines form the "result set query" interface.
2956 **
2957 ** These routines return information about a single column of the current
2958 ** result row of a query. In every case the first argument is a pointer
2959 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
2960 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
2961 ** and the second argument is the index of the column for which information
2962 ** should be returned. The leftmost column of the result set has the index 0.
2963 ** The number of columns in the result can be determined using
2964 ** [sqlite3_column_count()].
2965 **
2966 ** If the SQL statement does not currently point to a valid row, or if the
2967 ** column index is out of range, the result is undefined.
2968 ** These routines may only be called when the most recent call to
@@ -2973,52 +2928,52 @@
2973 ** something other than [SQLITE_ROW], the results are undefined.
2974 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
2975 ** are called from a different thread while any of these routines
2976 ** are pending, then the results are undefined.
2977 **
2978 ** The sqlite3_column_type() routine returns the
2979 ** [SQLITE_INTEGER | datatype code] for the initial data type
2980 ** of the result column. The returned value is one of [SQLITE_INTEGER],
2981 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
2982 ** returned by sqlite3_column_type() is only meaningful if no type
2983 ** conversions have occurred as described below. After a type conversion,
2984 ** the value returned by sqlite3_column_type() is undefined. Future
2985 ** versions of SQLite may change the behavior of sqlite3_column_type()
2986 ** following a type conversion.
2987 **
2988 ** If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
2989 ** routine returns the number of bytes in that BLOB or string.
2990 ** If the result is a UTF-16 string, then sqlite3_column_bytes() converts
2991 ** the string to UTF-8 and then returns the number of bytes.
2992 ** If the result is a numeric value then sqlite3_column_bytes() uses
2993 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
2994 ** the number of bytes in that string.
2995 ** The value returned does not include the zero terminator at the end
2996 ** of the string. For clarity: the value returned is the number of
2997 ** bytes in the string, not the number of characters.
2998 **
2999 ** Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
3000 ** even empty strings, are always zero terminated. The return
3001 ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
3002 ** pointer, possibly even a NULL pointer.
3003 **
3004 ** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
3005 ** but leaves the result in UTF-16 in native byte order instead of UTF-8.
3006 ** The zero terminator is not included in this count.
3007 **
3008 ** The object returned by [sqlite3_column_value()] is an
3009 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
3010 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
3011 ** If the [unprotected sqlite3_value] object returned by
3012 ** [sqlite3_column_value()] is used in any other way, including calls
3013 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
3014 ** or [sqlite3_value_bytes()], then the behavior is undefined.
3015 **
3016 ** These routines attempt to convert the value where appropriate. For
3017 ** example, if the internal representation is FLOAT and a text result
3018 ** is requested, [sqlite3_snprintf()] is used internally to perform the
3019 ** conversion automatically. The following table details the conversions
3020 ** that are applied:
3021 **
3022 ** <blockquote>
3023 ** <table border="1">
3024 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3038,22 +2993,22 @@
3038 ** <tr><td> TEXT <td> BLOB <td> No change
3039 ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
3040 ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
3041 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
3042 ** </table>
3043 ** </blockquote>
3044 **
3045 ** The table above makes reference to standard C library functions atoi()
3046 ** and atof(). SQLite does not really use these functions. It has its
3047 ** own equivalent internal routines. The atoi() and atof() names are
3048 ** used in the table for brevity and because they are familiar to most
3049 ** C programmers.
3050 **
3051 ** Note that when type conversions occur, pointers returned by prior
3052 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
3053 ** sqlite3_column_text16() may be invalidated.
3054 ** Type conversions and pointer invalidations might occur
3055 ** in the following cases:
3056 **
3057 ** <ul>
3058 ** <li> The initial content is a BLOB and sqlite3_column_text() or
3059 ** sqlite3_column_text16() is called. A zero-terminator might
@@ -3062,51 +3017,47 @@
3062 ** sqlite3_column_text16() is called. The content must be converted
3063 ** to UTF-16.</li>
3064 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
3065 ** sqlite3_column_text() is called. The content must be converted
3066 ** to UTF-8.</li>
3067 ** </ul>
3068 **
3069 ** Conversions between UTF-16be and UTF-16le are always done in place and do
3070 ** not invalidate a prior pointer, though of course the content of the buffer
3071 ** that the prior pointer points to will have been modified. Other kinds
3072 ** of conversion are done in place when it is possible, but sometimes they
3073 ** are not possible and in those cases prior pointers are invalidated.
3074 **
3075 ** The safest and easiest to remember policy is to invoke these routines
3076 ** in one of the following ways:
3077 **
3078 ** <ul>
3079 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
3080 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
3081 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3082 ** </ul>
3083 **
3084 ** In other words, you should call sqlite3_column_text(),
3085 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
3086 ** into the desired format, then invoke sqlite3_column_bytes() or
3087 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
3088 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
3089 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
3090 ** with calls to sqlite3_column_bytes().
3091 **
3092 ** The pointers returned are valid until a type conversion occurs as
3093 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3094 ** [sqlite3_finalize()] is called. The memory space used to hold strings
3095 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
3096 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3097 ** [sqlite3_free()].
3098 **
3099 ** If a memory allocation error occurs during the evaluation of any
3100 ** of these routines, a default value is returned. The default value
3101 ** is either the integer 0, the floating point number 0.0, or a NULL
3102 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
3103 ** [SQLITE_NOMEM].
3104 **
3105 ** Requirements:
3106 ** [H13803] [H13806] [H13809] [H13812] [H13815] [H13818] [H13821] [H13824]
3107 ** [H13827] [H13830]
3108 */
3109 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
3110 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
3111 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
3112 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3116,139 +3067,132 @@
3116 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
3117 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
3118 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3119
3120 /*
3121 ** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100>
3122 **
3123 ** The sqlite3_finalize() function is called to delete a [prepared statement].
3124 ** If the statement was executed successfully or not executed at all, then
3125 ** SQLITE_OK is returned. If execution of the statement failed then an
3126 ** [error code] or [extended error code] is returned.
3127 **
3128 ** This routine can be called at any point during the execution of the
3129 ** [prepared statement]. If the virtual machine has not
3130 ** completed execution when this routine is called, that is like
3131 ** encountering an error or an [sqlite3_interrupt | interrupt].
3132 ** Incomplete updates may be rolled back and transactions canceled,
3133 ** depending on the circumstances, and the
3134 ** [error code] returned will be [SQLITE_ABORT].
3135 **
3136 ** Requirements:
3137 ** [H11302] [H11304]
3138 */
3139 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
3140
3141 /*
3142 ** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300>
3143 **
3144 ** The sqlite3_reset() function is called to reset a [prepared statement]
3145 ** object back to its initial state, ready to be re-executed.
3146 ** Any SQL statement variables that had values bound to them using
3147 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
3148 ** Use [sqlite3_clear_bindings()] to reset the bindings.
3149 **
3150 ** {H11332} The [sqlite3_reset(S)] interface resets the [prepared statement] S
3151 ** back to the beginning of its program.
3152 **
3153 ** {H11334} If the most recent call to [sqlite3_step(S)] for the
3154 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3155 ** or if [sqlite3_step(S)] has never before been called on S,
3156 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
3157 **
3158 ** {H11336} If the most recent call to [sqlite3_step(S)] for the
3159 ** [prepared statement] S indicated an error, then
3160 ** [sqlite3_reset(S)] returns an appropriate [error code].
3161 **
3162 ** {H11338} The [sqlite3_reset(S)] interface does not change the values
3163 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3164 */
3165 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3166
3167 /*
3168 ** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200>
3169 ** KEYWORDS: {function creation routines}
3170 ** KEYWORDS: {application-defined SQL function}
3171 ** KEYWORDS: {application-defined SQL functions}
3172 **
3173 ** These two functions (collectively known as "function creation routines")
3174 ** are used to add SQL functions or aggregates or to redefine the behavior
3175 ** of existing SQL functions or aggregates. The only difference between the
3176 ** two is that the second parameter, the name of the (scalar) function or
3177 ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
3178 ** for sqlite3_create_function16().
3179 **
3180 ** The first parameter is the [database connection] to which the SQL
3181 ** function is to be added. If a single program uses more than one database
3182 ** connection internally, then SQL functions must be added individually to
3183 ** each database connection.
3184 **
3185 ** The second parameter is the name of the SQL function to be created or
3186 ** redefined. The length of the name is limited to 255 bytes, exclusive of
3187 ** the zero-terminator. Note that the name length limit is in bytes, not
3188 ** characters. Any attempt to create a function with a longer name
3189 ** will result in [SQLITE_ERROR] being returned.
3190 **
3191 ** The third parameter (nArg)
3192 ** is the number of arguments that the SQL function or
3193 ** aggregate takes. If this parameter is -1, then the SQL function or
3194 ** aggregate may take any number of arguments between 0 and the limit
3195 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
3196 ** parameter is less than -1 or greater than 127 then the behavior is
3197 ** undefined.
3198 **
3199 ** The fourth parameter, eTextRep, specifies what
3200 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
3201 ** its parameters. Any SQL function implementation should be able to work
3202 ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3203 ** more efficient with one encoding than another. An application may
3204 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
3205 ** times with the same function but with different values of eTextRep.
3206 ** When multiple implementations of the same function are available, SQLite
3207 ** will pick the one that involves the least amount of data conversion.
3208 ** If there is only a single implementation which does not care what text
3209 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
3210 **
3211 ** The fifth parameter is an arbitrary pointer. The implementation of the
3212 ** function can gain access to this pointer using [sqlite3_user_data()].
3213 **
3214 ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
3215 ** pointers to C-language functions that implement the SQL function or
3216 ** aggregate. A scalar SQL function requires an implementation of the xFunc
3217 ** callback only, NULL pointers should be passed as the xStep and xFinal
3218 ** parameters. An aggregate SQL function requires an implementation of xStep
3219 ** and xFinal and NULL should be passed for xFunc. To delete an existing
3220 ** SQL function or aggregate, pass NULL for all three function callbacks.
3221 **
3222 ** It is permitted to register multiple implementations of the same
3223 ** functions with the same name but with either differing numbers of
3224 ** arguments or differing preferred text encodings. SQLite will use
3225 ** the implementation that most closely matches the way in which the
3226 ** SQL function is used. A function implementation with a non-negative
3227 ** nArg parameter is a better match than a function implementation with
3228 ** a negative nArg. A function where the preferred text encoding
3229 ** matches the database encoding is a better
3230 ** match than a function where the encoding is different.
3231 ** A function where the encoding difference is between UTF16le and UTF16be
3232 ** is a closer match than a function where the encoding difference is
3233 ** between UTF8 and UTF16.
3234 **
3235 ** Built-in functions may be overloaded by new application-defined functions.
3236 ** The first application-defined function with a given name overrides all
3237 ** built-in functions in the same [database connection] with the same name.
3238 ** Subsequent application-defined functions of the same name only override
3239 ** prior application-defined functions that are an exact match for the
3240 ** number of parameters and preferred encoding.
3241 **
3242 ** An application-defined function is permitted to call other
3243 ** SQLite interfaces. However, such calls must not
3244 ** close the database connection nor finalize or reset the prepared
3245 ** statement in which the function is running.
3246 **
3247 ** Requirements:
3248 ** [H16103] [H16106] [H16109] [H16112] [H16118] [H16121] [H16127]
3249 ** [H16130] [H16133] [H16136] [H16139] [H16142]
3250 */
3251 SQLITE_API int sqlite3_create_function(
3252 sqlite3 *db,
3253 const char *zFunctionName,
3254 int nArg,
@@ -3268,11 +3212,11 @@
3268 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
3269 void (*xFinal)(sqlite3_context*)
3270 );
3271
3272 /*
3273 ** CAPI3REF: Text Encodings {H10267} <S50200> <H16100>
3274 **
3275 ** These constant define integer codes that represent the various
3276 ** text encodings supported by SQLite.
3277 */
3278 #define SQLITE_UTF8 1
@@ -3300,11 +3244,11 @@
3300 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
3301 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
3302 #endif
3303
3304 /*
3305 ** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200>
3306 **
3307 ** The C-language implementation of SQL functions and aggregates uses
3308 ** this set of interface routines to access the parameter values on
3309 ** the function or aggregate.
3310 **
@@ -3318,39 +3262,35 @@
3318 **
3319 ** These routines work only with [protected sqlite3_value] objects.
3320 ** Any attempt to use these routines on an [unprotected sqlite3_value]
3321 ** object results in undefined behavior.
3322 **
3323 ** These routines work just like the corresponding [column access functions]
3324 ** except that these routines take a single [protected sqlite3_value] object
3325 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
3326 **
3327 ** The sqlite3_value_text16() interface extracts a UTF-16 string
3328 ** in the native byte-order of the host machine. The
3329 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
3330 ** extract UTF-16 strings as big-endian and little-endian respectively.
3331 **
3332 ** The sqlite3_value_numeric_type() interface attempts to apply
3333 ** numeric affinity to the value. This means that an attempt is
3334 ** made to convert the value to an integer or floating point. If
3335 ** such a conversion is possible without loss of information (in other
3336 ** words, if the value is a string that looks like a number)
3337 ** then the conversion is performed. Otherwise no conversion occurs.
3338 ** The [SQLITE_INTEGER | datatype] after conversion is returned.
3339 **
3340 ** Please pay particular attention to the fact that the pointer returned
3341 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
3342 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
3343 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
3344 ** or [sqlite3_value_text16()].
3345 **
3346 ** These routines must be called from the same thread as
3347 ** the SQL function that supplied the [sqlite3_value*] parameters.
3348 **
3349 ** Requirements:
3350 ** [H15103] [H15106] [H15109] [H15112] [H15115] [H15118] [H15121] [H15124]
3351 ** [H15127] [H15130] [H15133] [H15136]
3352 */
3353 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
3354 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
3355 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
3356 SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3362,70 +3302,77 @@
3362 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
3363 SQLITE_API int sqlite3_value_type(sqlite3_value*);
3364 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
3365
3366 /*
3367 ** CAPI3REF: Obtain Aggregate Function Context {H16210} <S20200>
3368 **
3369 ** The implementation of aggregate SQL functions use this routine to allocate
3370 ** a structure for storing their state.
3371 **
3372 ** The first time the sqlite3_aggregate_context() routine is called for a
3373 ** particular aggregate, SQLite allocates nBytes of memory, zeroes out that
3374 ** memory, and returns a pointer to it. On second and subsequent calls to
3375 ** sqlite3_aggregate_context() for the same aggregate function index,
3376 ** the same buffer is returned. The implementation of the aggregate can use
3377 ** the returned buffer to accumulate data.
3378 **
3379 ** SQLite automatically frees the allocated buffer when the aggregate
3380 ** query concludes.
3381 **
3382 ** The first parameter should be a copy of the
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3383 ** [sqlite3_context | SQL function context] that is the first parameter
3384 ** to the callback routine that implements the aggregate function.
 
3385 **
3386 ** This routine must be called from the same thread in which
3387 ** the aggregate SQL function is running.
3388 **
3389 ** Requirements:
3390 ** [H16211] [H16213] [H16215] [H16217]
3391 */
3392 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
3393
3394 /*
3395 ** CAPI3REF: User Data For Functions {H16240} <S20200>
3396 **
3397 ** The sqlite3_user_data() interface returns a copy of
3398 ** the pointer that was the pUserData parameter (the 5th parameter)
3399 ** of the [sqlite3_create_function()]
3400 ** and [sqlite3_create_function16()] routines that originally
3401 ** registered the application defined function. {END}
3402 **
3403 ** This routine must be called from the same thread in which
3404 ** the application-defined function is running.
3405 **
3406 ** Requirements:
3407 ** [H16243]
3408 */
3409 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
3410
3411 /*
3412 ** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200>
3413 **
3414 ** The sqlite3_context_db_handle() interface returns a copy of
3415 ** the pointer to the [database connection] (the 1st parameter)
3416 ** of the [sqlite3_create_function()]
3417 ** and [sqlite3_create_function16()] routines that originally
3418 ** registered the application defined function.
3419 **
3420 ** Requirements:
3421 ** [H16253]
3422 */
3423 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
3424
3425 /*
3426 ** CAPI3REF: Function Auxiliary Data {H16270} <S20200>
3427 **
3428 ** The following two functions may be used by scalar SQL functions to
3429 ** associate metadata with argument values. If the same value is passed to
3430 ** multiple invocations of the same SQL function during query execution, under
3431 ** some circumstances the associated metadata may be preserved. This may
@@ -3434,52 +3381,49 @@
3434 ** metadata associated with the SQL value passed as the regular expression
3435 ** pattern. The compiled regular expression can be reused on multiple
3436 ** invocations of the same function so that the original pattern string
3437 ** does not need to be recompiled on each invocation.
3438 **
3439 ** The sqlite3_get_auxdata() interface returns a pointer to the metadata
3440 ** associated by the sqlite3_set_auxdata() function with the Nth argument
3441 ** value to the application-defined function. If no metadata has been ever
3442 ** been set for the Nth argument of the function, or if the corresponding
3443 ** function parameter has changed since the meta-data was set,
3444 ** then sqlite3_get_auxdata() returns a NULL pointer.
3445 **
3446 ** The sqlite3_set_auxdata() interface saves the metadata
3447 ** pointed to by its 3rd parameter as the metadata for the N-th
3448 ** argument of the application-defined function. Subsequent
3449 ** calls to sqlite3_get_auxdata() might return this data, if it has
3450 ** not been destroyed.
3451 ** If it is not NULL, SQLite will invoke the destructor
3452 ** function given by the 4th parameter to sqlite3_set_auxdata() on
3453 ** the metadata when the corresponding function parameter changes
3454 ** or when the SQL statement completes, whichever comes first.
3455 **
3456 ** SQLite is free to call the destructor and drop metadata on any
3457 ** parameter of any function at any time. The only guarantee is that
3458 ** the destructor will be called before the metadata is dropped.
3459 **
3460 ** In practice, metadata is preserved between function calls for
3461 ** expressions that are constant at compile time. This includes literal
3462 ** values and SQL variables.
3463 **
3464 ** These routines must be called from the same thread in which
3465 ** the SQL function is running.
3466 **
3467 ** Requirements:
3468 ** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279]
3469 */
3470 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
3471 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
3472
3473
3474 /*
3475 ** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100>
3476 **
3477 ** These are special values for the destructor that is passed in as the
3478 ** final argument to routines like [sqlite3_result_blob()]. If the destructor
3479 ** argument is SQLITE_STATIC, it means that the content pointer is constant
3480 ** and will never change. It does not need to be destroyed. The
3481 ** SQLITE_TRANSIENT value means that the content will likely change in
3482 ** the near future and that SQLite should make its own private copy of
3483 ** the content before returning.
3484 **
3485 ** The typedef is necessary to work around problems in certain
@@ -3488,11 +3432,11 @@
3488 typedef void (*sqlite3_destructor_type)(void*);
3489 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
3490 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
3491
3492 /*
3493 ** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200>
3494 **
3495 ** These routines are used by the xFunc or xFinal callbacks that
3496 ** implement SQL functions and aggregates. See
3497 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
3498 ** for additional information.
@@ -3499,107 +3443,102 @@
3499 **
3500 ** These functions work very much like the [parameter binding] family of
3501 ** functions used to bind values to host parameters in prepared statements.
3502 ** Refer to the [SQL parameter] documentation for additional information.
3503 **
3504 ** The sqlite3_result_blob() interface sets the result from
3505 ** an application-defined function to be the BLOB whose content is pointed
3506 ** to by the second parameter and which is N bytes long where N is the
3507 ** third parameter.
3508 **
3509 ** The sqlite3_result_zeroblob() interfaces set the result of
3510 ** the application-defined function to be a BLOB containing all zero
3511 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
3512 **
3513 ** The sqlite3_result_double() interface sets the result from
3514 ** an application-defined function to be a floating point value specified
3515 ** by its 2nd argument.
3516 **
3517 ** The sqlite3_result_error() and sqlite3_result_error16() functions
3518 ** cause the implemented SQL function to throw an exception.
3519 ** SQLite uses the string pointed to by the
3520 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
3521 ** as the text of an error message. SQLite interprets the error
3522 ** message string from sqlite3_result_error() as UTF-8. SQLite
3523 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
3524 ** byte order. If the third parameter to sqlite3_result_error()
3525 ** or sqlite3_result_error16() is negative then SQLite takes as the error
3526 ** message all text up through the first zero character.
3527 ** If the third parameter to sqlite3_result_error() or
3528 ** sqlite3_result_error16() is non-negative then SQLite takes that many
3529 ** bytes (not characters) from the 2nd parameter as the error message.
3530 ** The sqlite3_result_error() and sqlite3_result_error16()
3531 ** routines make a private copy of the error message text before
3532 ** they return. Hence, the calling function can deallocate or
3533 ** modify the text after they return without harm.
3534 ** The sqlite3_result_error_code() function changes the error code
3535 ** returned by SQLite as a result of an error in a function. By default,
3536 ** the error code is SQLITE_ERROR. A subsequent call to sqlite3_result_error()
3537 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
3538 **
3539 ** The sqlite3_result_toobig() interface causes SQLite to throw an error
3540 ** indicating that a string or BLOB is to long to represent.
3541 **
3542 ** The sqlite3_result_nomem() interface causes SQLite to throw an error
3543 ** indicating that a memory allocation failed.
3544 **
3545 ** The sqlite3_result_int() interface sets the return value
3546 ** of the application-defined function to be the 32-bit signed integer
3547 ** value given in the 2nd argument.
3548 ** The sqlite3_result_int64() interface sets the return value
3549 ** of the application-defined function to be the 64-bit signed integer
3550 ** value given in the 2nd argument.
3551 **
3552 ** The sqlite3_result_null() interface sets the return value
3553 ** of the application-defined function to be NULL.
3554 **
3555 ** The sqlite3_result_text(), sqlite3_result_text16(),
3556 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
3557 ** set the return value of the application-defined function to be
3558 ** a text string which is represented as UTF-8, UTF-16 native byte order,
3559 ** UTF-16 little endian, or UTF-16 big endian, respectively.
3560 ** SQLite takes the text result from the application from
3561 ** the 2nd parameter of the sqlite3_result_text* interfaces.
3562 ** If the 3rd parameter to the sqlite3_result_text* interfaces
3563 ** is negative, then SQLite takes result text from the 2nd parameter
3564 ** through the first zero character.
3565 ** If the 3rd parameter to the sqlite3_result_text* interfaces
3566 ** is non-negative, then as many bytes (not characters) of the text
3567 ** pointed to by the 2nd parameter are taken as the application-defined
3568 ** function result.
3569 ** If the 4th parameter to the sqlite3_result_text* interfaces
3570 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
3571 ** function as the destructor on the text or BLOB result when it has
3572 ** finished using that result.
3573 ** If the 4th parameter to the sqlite3_result_text* interfaces or to
3574 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
3575 ** assumes that the text or BLOB result is in constant space and does not
3576 ** copy the content of the parameter nor call a destructor on the content
3577 ** when it has finished using that result.
3578 ** If the 4th parameter to the sqlite3_result_text* interfaces
3579 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
3580 ** then SQLite makes a copy of the result into space obtained from
3581 ** from [sqlite3_malloc()] before it returns.
3582 **
3583 ** The sqlite3_result_value() interface sets the result of
3584 ** the application-defined function to be a copy the
3585 ** [unprotected sqlite3_value] object specified by the 2nd parameter. The
3586 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
3587 ** so that the [sqlite3_value] specified in the parameter may change or
3588 ** be deallocated after sqlite3_result_value() returns without harm.
3589 ** A [protected sqlite3_value] object may always be used where an
3590 ** [unprotected sqlite3_value] object is required, so either
3591 ** kind of [sqlite3_value] object can be used with this interface.
3592 **
3593 ** If these routines are called from within the different thread
3594 ** than the one containing the application-defined function that received
3595 ** the [sqlite3_context] pointer, the results are undefined.
3596 **
3597 ** Requirements:
3598 ** [H16403] [H16406] [H16409] [H16412] [H16415] [H16418] [H16421] [H16424]
3599 ** [H16427] [H16430] [H16433] [H16436] [H16439] [H16442] [H16445] [H16448]
3600 ** [H16451] [H16454] [H16457] [H16460] [H16463]
3601 */
3602 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
3603 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
3604 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
3605 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -3615,58 +3554,54 @@
3615 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
3616 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
3617 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
3618
3619 /*
3620 ** CAPI3REF: Define New Collating Sequences {H16600} <S20300>
3621 **
3622 ** These functions are used to add new collation sequences to the
3623 ** [database connection] specified as the first argument.
3624 **
3625 ** The name of the new collation sequence is specified as a UTF-8 string
3626 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
3627 ** and a UTF-16 string for sqlite3_create_collation16(). In all cases
3628 ** the name is passed as the second function argument.
3629 **
3630 ** The third argument may be one of the constants [SQLITE_UTF8],
3631 ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
3632 ** routine expects to be passed pointers to strings encoded using UTF-8,
3633 ** UTF-16 little-endian, or UTF-16 big-endian, respectively. The
3634 ** third argument might also be [SQLITE_UTF16] to indicate that the routine
3635 ** expects pointers to be UTF-16 strings in the native byte order, or the
3636 ** argument can be [SQLITE_UTF16_ALIGNED] if the
3637 ** the routine expects pointers to 16-bit word aligned strings
3638 ** of UTF-16 in the native byte order.
3639 **
3640 ** A pointer to the user supplied routine must be passed as the fifth
3641 ** argument. If it is NULL, this is the same as deleting the collation
3642 ** sequence (so that SQLite cannot call it anymore).
3643 ** Each time the application supplied function is invoked, it is passed
3644 ** as its first parameter a copy of the void* passed as the fourth argument
3645 ** to sqlite3_create_collation() or sqlite3_create_collation16().
3646 **
3647 ** The remaining arguments to the application-supplied routine are two strings,
3648 ** each represented by a (length, data) pair and encoded in the encoding
3649 ** that was passed as the third argument when the collation sequence was
3650 ** registered. {END} The application defined collation routine should
3651 ** return negative, zero or positive if the first string is less than,
3652 ** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
3653 **
3654 ** The sqlite3_create_collation_v2() works like sqlite3_create_collation()
3655 ** except that it takes an extra argument which is a destructor for
3656 ** the collation. The destructor is called when the collation is
3657 ** destroyed and is passed a copy of the fourth parameter void* pointer
3658 ** of the sqlite3_create_collation_v2().
3659 ** Collations are destroyed when they are overridden by later calls to the
3660 ** collation creation functions or when the [database connection] is closed
3661 ** using [sqlite3_close()].
3662 **
3663 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
3664 **
3665 ** Requirements:
3666 ** [H16603] [H16604] [H16606] [H16609] [H16612] [H16615] [H16618] [H16621]
3667 ** [H16624] [H16627] [H16630]
3668 */
3669 SQLITE_API int sqlite3_create_collation(
3670 sqlite3*,
3671 const char *zName,
3672 int eTextRep,
@@ -3688,37 +3623,34 @@
3688 void*,
3689 int(*xCompare)(void*,int,const void*,int,const void*)
3690 );
3691
3692 /*
3693 ** CAPI3REF: Collation Needed Callbacks {H16700} <S20300>
3694 **
3695 ** To avoid having to register all collation sequences before a database
3696 ** can be used, a single callback function may be registered with the
3697 ** [database connection] to be called whenever an undefined collation
3698 ** sequence is required.
3699 **
3700 ** If the function is registered using the sqlite3_collation_needed() API,
3701 ** then it is passed the names of undefined collation sequences as strings
3702 ** encoded in UTF-8. {H16703} If sqlite3_collation_needed16() is used,
3703 ** the names are passed as UTF-16 in machine native byte order.
3704 ** A call to either function replaces any existing callback.
3705 **
3706 ** When the callback is invoked, the first argument passed is a copy
3707 ** of the second argument to sqlite3_collation_needed() or
3708 ** sqlite3_collation_needed16(). The second argument is the database
3709 ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
3710 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
3711 ** sequence function required. The fourth parameter is the name of the
3712 ** required collation sequence.
3713 **
3714 ** The callback function should register the desired collation using
3715 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
3716 ** [sqlite3_create_collation_v2()].
3717 **
3718 ** Requirements:
3719 ** [H16702] [H16704] [H16706]
3720 */
3721 SQLITE_API int sqlite3_collation_needed(
3722 sqlite3*,
3723 void*,
3724 void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -3753,33 +3685,32 @@
3753 sqlite3 *db, /* Database to be rekeyed */
3754 const void *pKey, int nKey /* The new key */
3755 );
3756
3757 /*
3758 ** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410>
3759 **
3760 ** The sqlite3_sleep() function causes the current thread to suspend execution
3761 ** for at least a number of milliseconds specified in its parameter.
3762 **
3763 ** If the operating system does not support sleep requests with
3764 ** millisecond time resolution, then the time will be rounded up to
3765 ** the nearest second. The number of milliseconds of sleep actually
3766 ** requested from the operating system is returned.
3767 **
3768 ** SQLite implements this interface by calling the xSleep()
3769 ** method of the default [sqlite3_vfs] object.
3770 **
3771 ** Requirements: [H10533] [H10536]
3772 */
3773 SQLITE_API int sqlite3_sleep(int);
3774
3775 /*
3776 ** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000>
3777 **
3778 ** If this global variable is made to point to a string which is
3779 ** the name of a folder (a.k.a. directory), then all temporary files
3780 ** created by SQLite will be placed in that directory. If this variable
 
3781 ** is a NULL pointer, then SQLite performs a search for an appropriate
3782 ** temporary file directory.
3783 **
3784 ** It is not safe to read or modify this variable in more than one
3785 ** thread at a time. It is not safe to read or modify this variable
@@ -3788,12 +3719,12 @@
3788 ** It is intended that this variable be set once
3789 ** as part of process initialization and before any SQLite interface
3790 ** routines have been called and that this variable remain unchanged
3791 ** thereafter.
3792 **
3793 ** The [temp_store_directory pragma] may modify this variable and cause
3794 ** it to point to memory obtained from [sqlite3_malloc]. Furthermore,
3795 ** the [temp_store_directory pragma] always assumes that any string
3796 ** that this variable points to is held in memory obtained from
3797 ** [sqlite3_malloc] and the pragma may attempt to free that memory
3798 ** using [sqlite3_free].
3799 ** Hence, if this variable is modified directly, either it should be
@@ -3801,18 +3732,18 @@
3801 ** or else the use of the [temp_store_directory pragma] should be avoided.
3802 */
3803 SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
3804
3805 /*
3806 ** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200>
3807 ** KEYWORDS: {autocommit mode}
3808 **
3809 ** The sqlite3_get_autocommit() interface returns non-zero or
3810 ** zero if the given database connection is or is not in autocommit mode,
3811 ** respectively. Autocommit mode is on by default.
3812 ** Autocommit mode is disabled by a [BEGIN] statement.
3813 ** Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
3814 **
3815 ** If certain kinds of errors occur on a statement within a multi-statement
3816 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
3817 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
3818 ** transaction might be rolled back automatically. The only way to
@@ -3820,124 +3751,116 @@
3820 ** an error is to use this function.
3821 **
3822 ** If another thread changes the autocommit status of the database
3823 ** connection while this routine is running, then the return value
3824 ** is undefined.
3825 **
3826 ** Requirements: [H12931] [H12932] [H12933] [H12934]
3827 */
3828 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
3829
3830 /*
3831 ** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600>
3832 **
3833 ** The sqlite3_db_handle interface returns the [database connection] handle
3834 ** to which a [prepared statement] belongs. The [database connection]
3835 ** returned by sqlite3_db_handle is the same [database connection] that was the first argument
 
3836 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
3837 ** create the statement in the first place.
3838 **
3839 ** Requirements: [H13123]
3840 */
3841 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
3842
3843 /*
3844 ** CAPI3REF: Find the next prepared statement {H13140} <S60600>
3845 **
3846 ** This interface returns a pointer to the next [prepared statement] after
3847 ** pStmt associated with the [database connection] pDb. If pStmt is NULL
3848 ** then this interface returns a pointer to the first prepared statement
3849 ** associated with the database connection pDb. If no prepared statement
3850 ** satisfies the conditions of this routine, it returns NULL.
3851 **
3852 ** The [database connection] pointer D in a call to
3853 ** [sqlite3_next_stmt(D,S)] must refer to an open database
3854 ** connection and in particular must not be a NULL pointer.
3855 **
3856 ** Requirements: [H13143] [H13146] [H13149] [H13152]
3857 */
3858 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
3859
3860 /*
3861 ** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400>
3862 **
3863 ** The sqlite3_commit_hook() interface registers a callback
3864 ** function to be invoked whenever a transaction is [COMMIT | committed].
3865 ** Any callback set by a previous call to sqlite3_commit_hook()
3866 ** for the same database connection is overridden.
3867 ** The sqlite3_rollback_hook() interface registers a callback
3868 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
3869 ** Any callback set by a previous call to sqlite3_commit_hook()
3870 ** for the same database connection is overridden.
3871 ** The pArg argument is passed through to the callback.
3872 ** If the callback on a commit hook function returns non-zero,
3873 ** then the commit is converted into a rollback.
3874 **
3875 ** If another function was previously registered, its
3876 ** pArg value is returned. Otherwise NULL is returned.
 
 
3877 **
3878 ** The callback implementation must not do anything that will modify
3879 ** the database connection that invoked the callback. Any actions
3880 ** to modify the database connection must be deferred until after the
3881 ** completion of the [sqlite3_step()] call that triggered the commit
3882 ** or rollback hook in the first place.
3883 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3884 ** database connections for the meaning of "modify" in this paragraph.
3885 **
3886 ** Registering a NULL function disables the callback.
3887 **
3888 ** When the commit hook callback routine returns zero, the [COMMIT]
3889 ** operation is allowed to continue normally. If the commit hook
3890 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
3891 ** The rollback hook is invoked on a rollback that results from a commit
3892 ** hook returning non-zero, just as it would be with any other rollback.
3893 **
3894 ** For the purposes of this API, a transaction is said to have been
3895 ** rolled back if an explicit "ROLLBACK" statement is executed, or
3896 ** an error or constraint causes an implicit rollback to occur.
3897 ** The rollback callback is not invoked if a transaction is
3898 ** automatically rolled back because the database connection is closed.
3899 ** The rollback callback is not invoked if a transaction is
3900 ** rolled back because a commit callback returned non-zero.
3901 ** <todo> Check on this </todo>
3902 **
3903 ** See also the [sqlite3_update_hook()] interface.
3904 **
3905 ** Requirements:
3906 ** [H12951] [H12952] [H12953] [H12954] [H12955]
3907 ** [H12961] [H12962] [H12963] [H12964]
3908 */
3909 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
3910 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
3911
3912 /*
3913 ** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400>
3914 **
3915 ** The sqlite3_update_hook() interface registers a callback function
3916 ** with the [database connection] identified by the first argument
3917 ** to be invoked whenever a row is updated, inserted or deleted.
3918 ** Any callback set by a previous call to this function
3919 ** for the same database connection is overridden.
3920 **
3921 ** The second argument is a pointer to the function to invoke when a
3922 ** row is updated, inserted or deleted.
3923 ** The first argument to the callback is a copy of the third argument
3924 ** to sqlite3_update_hook().
3925 ** The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
3926 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
3927 ** to be invoked.
3928 ** The third and fourth arguments to the callback contain pointers to the
3929 ** database and table name containing the affected row.
3930 ** The final callback parameter is the [rowid] of the row.
3931 ** In the case of an update, this is the [rowid] after the update takes place.
3932 **
3933 ** The update hook is not invoked when internal system tables are
3934 ** modified (i.e. sqlite_master and sqlite_sequence).
3935 **
3936 ** In the current implementation, the update hook
3937 ** is not invoked when duplication rows are deleted because of an
3938 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. Nor is the update hook
3939 ** invoked when rows are deleted using the [truncate optimization].
3940 ** The exceptions defined in this paragraph might change in a future
3941 ** release of SQLite.
3942 **
3943 ** The update hook implementation must not do anything that will modify
@@ -3945,169 +3868,157 @@
3945 ** to modify the database connection must be deferred until after the
3946 ** completion of the [sqlite3_step()] call that triggered the update hook.
3947 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3948 ** database connections for the meaning of "modify" in this paragraph.
3949 **
3950 ** If another function was previously registered, its pArg value
3951 ** is returned. Otherwise NULL is returned.
 
 
3952 **
3953 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
3954 ** interfaces.
3955 **
3956 ** Requirements:
3957 ** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986]
3958 */
3959 SQLITE_API void *sqlite3_update_hook(
3960 sqlite3*,
3961 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
3962 void*
3963 );
3964
3965 /*
3966 ** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900>
3967 ** KEYWORDS: {shared cache}
3968 **
3969 ** This routine enables or disables the sharing of the database cache
3970 ** and schema data structures between [database connection | connections]
3971 ** to the same database. Sharing is enabled if the argument is true
3972 ** and disabled if the argument is false.
3973 **
3974 ** Cache sharing is enabled and disabled for an entire process.
3975 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
3976 ** sharing was enabled or disabled for each thread separately.
3977 **
3978 ** The cache sharing mode set by this interface effects all subsequent
3979 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
3980 ** Existing database connections continue use the sharing mode
3981 ** that was in effect at the time they were opened.
3982 **
3983 ** Virtual tables cannot be used with a shared cache. When shared
3984 ** cache is enabled, the [sqlite3_create_module()] API used to register
3985 ** virtual tables will always return an error.
3986 **
3987 ** This routine returns [SQLITE_OK] if shared cache was enabled or disabled
3988 ** successfully. An [error code] is returned otherwise.
3989 **
3990 ** Shared cache is disabled by default. But this might change in
3991 ** future releases of SQLite. Applications that care about shared
3992 ** cache setting should set it explicitly.
3993 **
3994 ** See Also: [SQLite Shared-Cache Mode]
3995 **
3996 ** Requirements: [H10331] [H10336] [H10337] [H10339]
3997 */
3998 SQLITE_API int sqlite3_enable_shared_cache(int);
3999
4000 /*
4001 ** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220>
4002 **
4003 ** The sqlite3_release_memory() interface attempts to free N bytes
4004 ** of heap memory by deallocating non-essential memory allocations
4005 ** held by the database library. {END} Memory used to cache database
4006 ** pages to improve performance is an example of non-essential memory.
4007 ** sqlite3_release_memory() returns the number of bytes actually freed,
4008 ** which might be more or less than the amount requested.
4009 **
4010 ** Requirements: [H17341] [H17342]
4011 */
4012 SQLITE_API int sqlite3_release_memory(int);
4013
4014 /*
4015 ** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220>
4016 **
4017 ** The sqlite3_soft_heap_limit() interface places a "soft" limit
4018 ** on the amount of heap memory that may be allocated by SQLite.
4019 ** If an internal allocation is requested that would exceed the
4020 ** soft heap limit, [sqlite3_release_memory()] is invoked one or
4021 ** more times to free up some space before the allocation is performed.
4022 **
4023 ** The limit is called "soft", because if [sqlite3_release_memory()]
4024 ** cannot free sufficient memory to prevent the limit from being exceeded,
4025 ** the memory is allocated anyway and the current operation proceeds.
4026 **
4027 ** A negative or zero value for N means that there is no soft heap limit and
4028 ** [sqlite3_release_memory()] will only be called when memory is exhausted.
4029 ** The default value for the soft heap limit is zero.
4030 **
4031 ** SQLite makes a best effort to honor the soft heap limit.
4032 ** But if the soft heap limit cannot be honored, execution will
4033 ** continue without error or notification. This is why the limit is
4034 ** called a "soft" limit. It is advisory only.
4035 **
4036 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
4037 ** allocated by a single thread - the same thread in which this routine
4038 ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
4039 ** applied to all threads. The value specified for the soft heap limit
4040 ** is an upper bound on the total memory allocation for all threads. In
4041 ** version 3.5.0 there is no mechanism for limiting the heap usage for
4042 ** individual threads.
4043 **
4044 ** Requirements:
4045 ** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358]
4046 */
4047 SQLITE_API void sqlite3_soft_heap_limit(int);
4048
4049 /*
4050 ** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300>
4051 **
4052 ** This routine returns metadata about a specific column of a specific
4053 ** database table accessible using the [database connection] handle
4054 ** passed as the first function argument.
4055 **
4056 ** The column is identified by the second, third and fourth parameters to
4057 ** this function. The second parameter is either the name of the database
4058 ** (i.e. "main", "temp" or an attached database) containing the specified
4059 ** table or NULL. If it is NULL, then all attached databases are searched
4060 ** for the table using the same algorithm used by the database engine to
4061 ** resolve unqualified table references.
4062 **
4063 ** The third and fourth parameters to this function are the table and column
4064 ** name of the desired column, respectively. Neither of these parameters
4065 ** may be NULL.
4066 **
4067 ** Metadata is returned by writing to the memory locations passed as the 5th
4068 ** and subsequent parameters to this function. Any of these arguments may be
4069 ** NULL, in which case the corresponding element of metadata is omitted.
4070 **
4071 ** <blockquote>
4072 ** <table border="1">
4073 ** <tr><th> Parameter <th> Output<br>Type <th> Description
4074 **
4075 ** <tr><td> 5th <td> const char* <td> Data type
4076 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
4077 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
4078 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
4079 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
4080 ** </table>
4081 ** </blockquote>
4082 **
4083 ** The memory pointed to by the character pointers returned for the
4084 ** declaration type and collation sequence is valid only until the next
4085 ** call to any SQLite API function.
4086 **
4087 ** If the specified table is actually a view, an [error code] is returned.
4088 **
4089 ** If the specified column is "rowid", "oid" or "_rowid_" and an
4090 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4091 ** parameters are set for the explicitly declared column. If there is no
4092 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
4093 ** parameters are set as follows:
4094 **
4095 ** <pre>
4096 ** data type: "INTEGER"
4097 ** collation sequence: "BINARY"
4098 ** not null: 0
4099 ** primary key: 1
4100 ** auto increment: 0
4101 ** </pre>
4102 **
4103 ** This function may load one or more schemas from database files. If an
4104 ** error occurs during this process, or if the requested table or column
4105 ** cannot be found, an [error code] is returned and an error message left
4106 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).
4107 **
4108 ** This API is only available if the library was compiled with the
4109 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
4110 */
4111 SQLITE_API int sqlite3_table_column_metadata(
4112 sqlite3 *db, /* Connection handle */
4113 const char *zDbName, /* Database name or NULL */
@@ -4119,34 +4030,31 @@
4119 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
4120 int *pAutoinc /* OUTPUT: True if column is auto-increment */
4121 );
4122
4123 /*
4124 ** CAPI3REF: Load An Extension {H12600} <S20500>
4125 **
4126 ** This interface loads an SQLite extension library from the named file.
4127 **
4128 ** {H12601} The sqlite3_load_extension() interface attempts to load an
4129 ** SQLite extension library contained in the file zFile.
4130 **
4131 ** {H12602} The entry point is zProc.
4132 **
4133 ** {H12603} zProc may be 0, in which case the name of the entry point
4134 ** defaults to "sqlite3_extension_init".
4135 **
4136 ** {H12604} The sqlite3_load_extension() interface shall return
4137 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4138 **
4139 ** {H12605} If an error occurs and pzErrMsg is not 0, then the
4140 ** [sqlite3_load_extension()] interface shall attempt to
4141 ** fill *pzErrMsg with error message text stored in memory
4142 ** obtained from [sqlite3_malloc()]. {END} The calling function
4143 ** should free this memory by calling [sqlite3_free()].
4144 **
4145 ** {H12606} Extension loading must be enabled using
4146 ** [sqlite3_enable_load_extension()] prior to calling this API,
4147 ** otherwise an error will be returned.
4148 **
4149 ** See also the [load_extension() SQL function].
4150 */
4151 SQLITE_API int sqlite3_load_extension(
4152 sqlite3 *db, /* Load the extension into this database connection */
@@ -4154,65 +4062,53 @@
4154 const char *zProc, /* Entry point. Derived from zFile if 0 */
4155 char **pzErrMsg /* Put error message here if not 0 */
4156 );
4157
4158 /*
4159 ** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500>
4160 **
4161 ** So as not to open security holes in older applications that are
4162 ** unprepared to deal with extension loading, and as a means of disabling
4163 ** extension loading while evaluating user-entered SQL, the following API
4164 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
4165 **
4166 ** Extension loading is off by default. See ticket #1863.
4167 **
4168 ** {H12621} Call the sqlite3_enable_load_extension() routine with onoff==1
4169 ** to turn extension loading on and call it with onoff==0 to turn
4170 ** it back off again.
4171 **
4172 ** {H12622} Extension loading is off by default.
4173 */
4174 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
4175
4176 /*
4177 ** CAPI3REF: Automatically Load An Extensions {H12640} <S20500>
4178 **
4179 ** This API can be invoked at program startup in order to register
4180 ** one or more statically linked extensions that will be available
4181 ** to all new [database connections]. {END}
4182 **
4183 ** This routine stores a pointer to the extension in an array that is
4184 ** obtained from [sqlite3_malloc()]. If you run a memory leak checker
4185 ** on your program and it reports a leak because of this array, invoke
4186 ** [sqlite3_reset_auto_extension()] prior to shutdown to free the memory.
4187 **
4188 ** {H12641} This function registers an extension entry point that is
4189 ** automatically invoked whenever a new [database connection]
4190 ** is opened using [sqlite3_open()], [sqlite3_open16()],
4191 ** or [sqlite3_open_v2()].
4192 **
4193 ** {H12642} Duplicate extensions are detected so calling this routine
4194 ** multiple times with the same extension is harmless.
4195 **
4196 ** {H12643} This routine stores a pointer to the extension in an array
4197 ** that is obtained from [sqlite3_malloc()].
4198 **
4199 ** {H12644} Automatic extensions apply across all threads.
4200 */
4201 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
4202
4203 /*
4204 ** CAPI3REF: Reset Automatic Extension Loading {H12660} <S20500>
4205 **
4206 ** This function disables all previously registered automatic
4207 ** extensions. {END} It undoes the effect of all prior
4208 ** [sqlite3_auto_extension()] calls.
4209 **
4210 ** {H12661} This function disables all previously registered
4211 ** automatic extensions.
4212 **
4213 ** {H12662} This function disables automatic extensions in all threads.
4214 */
4215 SQLITE_API void sqlite3_reset_auto_extension(void);
4216
4217 /*
4218 ****** EXPERIMENTAL - subject to change without notice **************
@@ -4232,22 +4128,22 @@
4232 typedef struct sqlite3_index_info sqlite3_index_info;
4233 typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
4234 typedef struct sqlite3_module sqlite3_module;
4235
4236 /*
4237 ** CAPI3REF: Virtual Table Object {H18000} <S20400>
4238 ** KEYWORDS: sqlite3_module {virtual table module}
4239 ** EXPERIMENTAL
4240 **
4241 ** This structure, sometimes called a a "virtual table module",
4242 ** defines the implementation of a [virtual tables].
4243 ** This structure consists mostly of methods for the module.
4244 **
4245 ** A virtual table module is created by filling in a persistent
4246 ** instance of this structure and passing a pointer to that instance
4247 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4248 ** The registration remains valid until it is replaced by a different
4249 ** module or until the [database connection] closes. The content
4250 ** of this structure must not change while it is registered with
4251 ** any database connection.
4252 */
4253 struct sqlite3_module {
@@ -4279,56 +4175,56 @@
4279 void **ppArg);
4280 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
4281 };
4282
4283 /*
4284 ** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400>
4285 ** KEYWORDS: sqlite3_index_info
4286 ** EXPERIMENTAL
4287 **
4288 ** The sqlite3_index_info structure and its substructures is used to
4289 ** pass information into and receive the reply from the [xBestIndex]
4290 ** method of a [virtual table module]. The fields under **Inputs** are the
4291 ** inputs to xBestIndex and are read-only. xBestIndex inserts its
4292 ** results into the **Outputs** fields.
4293 **
4294 ** The aConstraint[] array records WHERE clause constraints of the form:
4295 **
4296 ** <pre>column OP expr</pre>
4297 **
4298 ** where OP is =, &lt;, &lt;=, &gt;, or &gt;=. The particular operator is
4299 ** stored in aConstraint[].op. The index of the column is stored in
4300 ** aConstraint[].iColumn. aConstraint[].usable is TRUE if the
4301 ** expr on the right-hand side can be evaluated (and thus the constraint
4302 ** is usable) and false if it cannot.
4303 **
4304 ** The optimizer automatically inverts terms of the form "expr OP column"
4305 ** and makes other simplifications to the WHERE clause in an attempt to
4306 ** get as many WHERE clause terms into the form shown above as possible.
4307 ** The aConstraint[] array only reports WHERE clause terms in the correct
4308 ** form that refer to the particular virtual table being queried.
4309 **
4310 ** Information about the ORDER BY clause is stored in aOrderBy[].
4311 ** Each term of aOrderBy records a column of the ORDER BY clause.
4312 **
4313 ** The [xBestIndex] method must fill aConstraintUsage[] with information
4314 ** about what parameters to pass to xFilter. If argvIndex>0 then
4315 ** the right-hand side of the corresponding aConstraint[] is evaluated
4316 ** and becomes the argvIndex-th entry in argv. If aConstraintUsage[].omit
4317 ** is true, then the constraint is assumed to be fully handled by the
4318 ** virtual table and is not checked again by SQLite.
4319 **
4320 ** The idxNum and idxPtr values are recorded and passed into the
4321 ** [xFilter] method.
4322 ** [sqlite3_free()] is used to free idxPtr if and only iff
4323 ** needToFreeIdxPtr is true.
4324 **
4325 ** The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4326 ** the correct order to satisfy the ORDER BY clause so that no separate
4327 ** sorting step is required.
4328 **
4329 ** The estimatedCost value is an estimate of the cost of doing the
4330 ** particular lookup. A full scan of a table with N entries should have
4331 ** a cost of N. A binary search of a table of N entries should have a
4332 ** cost of approximately log(N).
4333 */
4334 struct sqlite3_index_info {
@@ -4362,70 +4258,63 @@
4362 #define SQLITE_INDEX_CONSTRAINT_LT 16
4363 #define SQLITE_INDEX_CONSTRAINT_GE 32
4364 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
4365
4366 /*
4367 ** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400>
4368 ** EXPERIMENTAL
4369 **
4370 ** This routine is used to register a new [virtual table module] name.
4371 ** Module names must be registered before
4372 ** creating a new [virtual table] using the module, or before using a
4373 ** preexisting [virtual table] for the module.
4374 **
4375 ** The module name is registered on the [database connection] specified
4376 ** by the first parameter. The name of the module is given by the
4377 ** second parameter. The third parameter is a pointer to
4378 ** the implementation of the [virtual table module]. The fourth
4379 ** parameter is an arbitrary client data pointer that is passed through
4380 ** into the [xCreate] and [xConnect] methods of the virtual table module
4381 ** when a new virtual table is be being created or reinitialized.
4382 **
4383 ** This interface has exactly the same effect as calling
4384 ** [sqlite3_create_module_v2()] with a NULL client data destructor.
 
 
 
 
4385 */
4386 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
4387 sqlite3 *db, /* SQLite connection to register module with */
4388 const char *zName, /* Name of the module */
4389 const sqlite3_module *p, /* Methods for the module */
4390 void *pClientData /* Client data for xCreate/xConnect */
4391 );
4392
4393 /*
4394 ** CAPI3REF: Register A Virtual Table Implementation {H18210} <S20400>
4395 ** EXPERIMENTAL
4396 **
4397 ** This routine is identical to the [sqlite3_create_module()] method,
4398 ** except that it has an extra parameter to specify
4399 ** a destructor function for the client data pointer. SQLite will
4400 ** invoke the destructor function (if it is not NULL) when SQLite
4401 ** no longer needs the pClientData pointer.
4402 */
4403 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
4404 sqlite3 *db, /* SQLite connection to register module with */
4405 const char *zName, /* Name of the module */
4406 const sqlite3_module *p, /* Methods for the module */
4407 void *pClientData, /* Client data for xCreate/xConnect */
4408 void(*xDestroy)(void*) /* Module destructor function */
4409 );
4410
4411 /*
4412 ** CAPI3REF: Virtual Table Instance Object {H18010} <S20400>
4413 ** KEYWORDS: sqlite3_vtab
4414 ** EXPERIMENTAL
4415 **
4416 ** Every [virtual table module] implementation uses a subclass
4417 ** of the following structure to describe a particular instance
4418 ** of the [virtual table]. Each subclass will
4419 ** be tailored to the specific needs of the module implementation.
4420 ** The purpose of this superclass is to define certain fields that are
4421 ** common to all module implementations.
4422 **
4423 ** Virtual tables methods can set an error message by assigning a
4424 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
4425 ** take care that any prior string is freed by a call to [sqlite3_free()]
4426 ** prior to assigning a new string to zErrMsg. After the error message
4427 ** is delivered up to the client application, the string will be automatically
4428 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
4429 */
4430 struct sqlite3_vtab {
4431 const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4433,20 +4322,20 @@
4433 char *zErrMsg; /* Error message from sqlite3_mprintf() */
4434 /* Virtual table implementations will typically add additional fields */
4435 };
4436
4437 /*
4438 ** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400>
4439 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
4440 ** EXPERIMENTAL
4441 **
4442 ** Every [virtual table module] implementation uses a subclass of the
4443 ** following structure to describe cursors that point into the
4444 ** [virtual table] and are used
4445 ** to loop through the virtual table. Cursors are created using the
4446 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4447 ** by the [sqlite3_module.xClose | xClose] method. Cussors are used
4448 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
4449 ** of the module. Each module implementation will define
4450 ** the content of a cursor structure to suit its own needs.
4451 **
4452 ** This superclass exists in order to define fields of the cursor that
@@ -4456,32 +4345,32 @@
4456 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
4457 /* Virtual table implementations will typically add additional fields */
4458 };
4459
4460 /*
4461 ** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400>
4462 ** EXPERIMENTAL
4463 **
4464 ** The [xCreate] and [xConnect] methods of a
4465 ** [virtual table module] call this interface
4466 ** to declare the format (the names and datatypes of the columns) of
4467 ** the virtual tables they implement.
4468 */
4469 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
4470
4471 /*
4472 ** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400>
4473 ** EXPERIMENTAL
4474 **
4475 ** Virtual tables can provide alternative implementations of functions
4476 ** using the [xFindFunction] method of the [virtual table module].
4477 ** But global versions of those functions
4478 ** must exist in order to be overloaded.
4479 **
4480 ** This API makes sure a global version of a function with a particular
4481 ** name and number of parameters exists. If no such function exists
4482 ** before this API is called, a new function is created. The implementation
4483 ** of the new function always causes an exception to be thrown. So
4484 ** the new function is not good for anything by itself. Its only
4485 ** purpose is to be a placeholder function that can be overloaded
4486 ** by a [virtual table].
4487 */
@@ -4498,81 +4387,78 @@
4498 **
4499 ****** EXPERIMENTAL - subject to change without notice **************
4500 */
4501
4502 /*
4503 ** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230>
4504 ** KEYWORDS: {BLOB handle} {BLOB handles}
4505 **
4506 ** An instance of this object represents an open BLOB on which
4507 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
4508 ** Objects of this type are created by [sqlite3_blob_open()]
4509 ** and destroyed by [sqlite3_blob_close()].
4510 ** The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
4511 ** can be used to read or write small subsections of the BLOB.
4512 ** The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
4513 */
4514 typedef struct sqlite3_blob sqlite3_blob;
4515
4516 /*
4517 ** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230>
4518 **
4519 ** This interfaces opens a [BLOB handle | handle] to the BLOB located
4520 ** in row iRow, column zColumn, table zTable in database zDb;
4521 ** in other words, the same BLOB that would be selected by:
4522 **
4523 ** <pre>
4524 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4525 ** </pre> {END}
4526 **
4527 ** If the flags parameter is non-zero, then the BLOB is opened for read
4528 ** and write access. If it is zero, the BLOB is opened for read access.
4529 ** It is not possible to open a column that is part of an index or primary
4530 ** key for writing. ^If [foreign key constraints] are enabled, it is
4531 ** not possible to open a column that is part of a [child key] for writing.
4532 **
4533 ** Note that the database name is not the filename that contains
4534 ** the database but rather the symbolic name of the database that
4535 ** is assigned when the database is connected using [ATTACH].
4536 ** For the main database file, the database name is "main".
4537 ** For TEMP tables, the database name is "temp".
4538 **
4539 ** On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
4540 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
4541 ** to be a null pointer.
4542 ** This function sets the [database connection] error code and message
4543 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
4544 ** functions. Note that the *ppBlob variable is always initialized in a
4545 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
4546 ** regardless of the success or failure of this routine.
4547 **
4548 ** If the row that a BLOB handle points to is modified by an
4549 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
4550 ** then the BLOB handle is marked as "expired".
4551 ** This is true if any column of the row is changed, even a column
4552 ** other than the one the BLOB handle is open on.
4553 ** Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4554 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
4555 ** Changes written into a BLOB prior to the BLOB expiring are not
4556 ** rollback by the expiration of the BLOB. Such changes will eventually
4557 ** commit if the transaction continues to completion.
4558 **
4559 ** Use the [sqlite3_blob_bytes()] interface to determine the size of
4560 ** the opened blob. The size of a blob may not be changed by this
4561 ** interface. Use the [UPDATE] SQL command to change the size of a
4562 ** blob.
4563 **
4564 ** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
4565 ** and the built-in [zeroblob] SQL function can be used, if desired,
4566 ** to create an empty, zero-filled blob in which to read or write using
4567 ** this interface.
4568 **
4569 ** To avoid a resource leak, every open [BLOB handle] should eventually
4570 ** be released by a call to [sqlite3_blob_close()].
4571 **
4572 ** Requirements:
4573 ** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824]
4574 */
4575 SQLITE_API int sqlite3_blob_open(
4576 sqlite3*,
4577 const char *zDb,
4578 const char *zTable,
@@ -4581,201 +4467,185 @@
4581 int flags,
4582 sqlite3_blob **ppBlob
4583 );
4584
4585 /*
4586 ** CAPI3REF: Close A BLOB Handle {H17830} <S30230>
4587 **
4588 ** Closes an open [BLOB handle].
4589 **
4590 ** Closing a BLOB shall cause the current transaction to commit
4591 ** if there are no other BLOBs, no pending prepared statements, and the
4592 ** database connection is in [autocommit mode].
4593 ** If any writes were made to the BLOB, they might be held in cache
4594 ** until the close operation if they will fit.
4595 **
4596 ** Closing the BLOB often forces the changes
4597 ** out to disk and so if any I/O errors occur, they will likely occur
4598 ** at the time when the BLOB is closed. Any errors that occur during
4599 ** closing are reported as a non-zero return value.
4600 **
4601 ** The BLOB is closed unconditionally. Even if this routine returns
4602 ** an error code, the BLOB is still closed.
4603 **
4604 ** Calling this routine with a null pointer (which as would be returned
4605 ** by failed call to [sqlite3_blob_open()]) is a harmless no-op.
4606 **
4607 ** Requirements:
4608 ** [H17833] [H17836] [H17839]
4609 */
4610 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
4611
4612 /*
4613 ** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230>
4614 **
4615 ** Returns the size in bytes of the BLOB accessible via the
4616 ** successfully opened [BLOB handle] in its only argument. The
4617 ** incremental blob I/O routines can only read or overwriting existing
4618 ** blob content; they cannot change the size of a blob.
4619 **
4620 ** This routine only works on a [BLOB handle] which has been created
4621 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4622 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4623 ** to this routine results in undefined and probably undesirable behavior.
4624 **
4625 ** Requirements:
4626 ** [H17843]
4627 */
4628 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
4629
4630 /*
4631 ** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230>
4632 **
4633 ** This function is used to read data from an open [BLOB handle] into a
4634 ** caller-supplied buffer. N bytes of data are copied into buffer Z
4635 ** from the open BLOB, starting at offset iOffset.
4636 **
4637 ** If offset iOffset is less than N bytes from the end of the BLOB,
4638 ** [SQLITE_ERROR] is returned and no data is read. If N or iOffset is
4639 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
4640 ** The size of the blob (and hence the maximum value of N+iOffset)
4641 ** can be determined using the [sqlite3_blob_bytes()] interface.
4642 **
4643 ** An attempt to read from an expired [BLOB handle] fails with an
4644 ** error code of [SQLITE_ABORT].
4645 **
4646 ** On success, SQLITE_OK is returned.
4647 ** Otherwise, an [error code] or an [extended error code] is returned.
4648 **
4649 ** This routine only works on a [BLOB handle] which has been created
4650 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4651 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4652 ** to this routine results in undefined and probably undesirable behavior.
4653 **
4654 ** See also: [sqlite3_blob_write()].
4655 **
4656 ** Requirements:
4657 ** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868]
4658 */
4659 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
4660
4661 /*
4662 ** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230>
4663 **
4664 ** This function is used to write data into an open [BLOB handle] from a
4665 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
4666 ** into the open BLOB, starting at offset iOffset.
4667 **
4668 ** If the [BLOB handle] passed as the first argument was not opened for
4669 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
4670 ** this function returns [SQLITE_READONLY].
4671 **
4672 ** This function may only modify the contents of the BLOB; it is
4673 ** not possible to increase the size of a BLOB using this API.
4674 ** If offset iOffset is less than N bytes from the end of the BLOB,
4675 ** [SQLITE_ERROR] is returned and no data is written. If N is
4676 ** less than zero [SQLITE_ERROR] is returned and no data is written.
4677 ** The size of the BLOB (and hence the maximum value of N+iOffset)
4678 ** can be determined using the [sqlite3_blob_bytes()] interface.
4679 **
4680 ** An attempt to write to an expired [BLOB handle] fails with an
4681 ** error code of [SQLITE_ABORT]. Writes to the BLOB that occurred
4682 ** before the [BLOB handle] expired are not rolled back by the
4683 ** expiration of the handle, though of course those changes might
4684 ** have been overwritten by the statement that expired the BLOB handle
4685 ** or by other independent statements.
4686 **
4687 ** On success, SQLITE_OK is returned.
4688 ** Otherwise, an [error code] or an [extended error code] is returned.
4689 **
4690 ** This routine only works on a [BLOB handle] which has been created
4691 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4692 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4693 ** to this routine results in undefined and probably undesirable behavior.
4694 **
4695 ** See also: [sqlite3_blob_read()].
4696 **
4697 ** Requirements:
4698 ** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885]
4699 ** [H17888]
4700 */
4701 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
4702
4703 /*
4704 ** CAPI3REF: Virtual File System Objects {H11200} <S20100>
4705 **
4706 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
4707 ** that SQLite uses to interact
4708 ** with the underlying operating system. Most SQLite builds come with a
4709 ** single default VFS that is appropriate for the host computer.
4710 ** New VFSes can be registered and existing VFSes can be unregistered.
4711 ** The following interfaces are provided.
4712 **
4713 ** The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
4714 ** Names are case sensitive.
4715 ** Names are zero-terminated UTF-8 strings.
4716 ** If there is no match, a NULL pointer is returned.
4717 ** If zVfsName is NULL then the default VFS is returned.
4718 **
4719 ** New VFSes are registered with sqlite3_vfs_register().
4720 ** Each new VFS becomes the default VFS if the makeDflt flag is set.
4721 ** The same VFS can be registered multiple times without injury.
4722 ** To make an existing VFS into the default VFS, register it again
4723 ** with the makeDflt flag set. If two different VFSes with the
4724 ** same name are registered, the behavior is undefined. If a
4725 ** VFS is registered with a name that is NULL or an empty string,
4726 ** then the behavior is undefined.
4727 **
4728 ** Unregister a VFS with the sqlite3_vfs_unregister() interface.
4729 ** If the default VFS is unregistered, another VFS is chosen as
4730 ** the default. The choice for the new VFS is arbitrary.
4731 **
4732 ** Requirements:
4733 ** [H11203] [H11206] [H11209] [H11212] [H11215] [H11218]
4734 */
4735 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
4736 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
4737 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
4738
4739 /*
4740 ** CAPI3REF: Mutexes {H17000} <S20000>
4741 **
4742 ** The SQLite core uses these routines for thread
4743 ** synchronization. Though they are intended for internal
4744 ** use by SQLite, code that links against SQLite is
4745 ** permitted to use any of these routines.
4746 **
4747 ** The SQLite source code contains multiple implementations
4748 ** of these mutex routines. An appropriate implementation
4749 ** is selected automatically at compile-time. The following
4750 ** implementations are available in the SQLite core:
4751 **
4752 ** <ul>
4753 ** <li> SQLITE_MUTEX_OS2
4754 ** <li> SQLITE_MUTEX_PTHREAD
4755 ** <li> SQLITE_MUTEX_W32
4756 ** <li> SQLITE_MUTEX_NOOP
4757 ** </ul>
4758 **
4759 ** The SQLITE_MUTEX_NOOP implementation is a set of routines
4760 ** that does no real locking and is appropriate for use in
4761 ** a single-threaded application. The SQLITE_MUTEX_OS2,
4762 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
4763 ** are appropriate for use on OS/2, Unix, and Windows.
4764 **
4765 ** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
4766 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
4767 ** implementation is included with the library. In this case the
4768 ** application must supply a custom mutex implementation using the
4769 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
4770 ** before calling sqlite3_initialize() or any other public sqlite3_
4771 ** function that calls sqlite3_initialize().
4772 **
4773 ** {H17011} The sqlite3_mutex_alloc() routine allocates a new
4774 ** mutex and returns a pointer to it. {H17012} If it returns NULL
4775 ** that means that a mutex could not be allocated. {H17013} SQLite
4776 ** will unwind its stack and return an error. {H17014} The argument
4777 ** to sqlite3_mutex_alloc() is one of these integer constants:
4778 **
4779 ** <ul>
4780 ** <li> SQLITE_MUTEX_FAST
4781 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -4783,68 +4653,70 @@
4783 ** <li> SQLITE_MUTEX_STATIC_MEM
4784 ** <li> SQLITE_MUTEX_STATIC_MEM2
4785 ** <li> SQLITE_MUTEX_STATIC_PRNG
4786 ** <li> SQLITE_MUTEX_STATIC_LRU
4787 ** <li> SQLITE_MUTEX_STATIC_LRU2
4788 ** </ul>
4789 **
4790 ** {H17015} The first two constants cause sqlite3_mutex_alloc() to create
4791 ** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
4792 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. {END}
 
4793 ** The mutex implementation does not need to make a distinction
4794 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
4795 ** not want to. {H17016} But SQLite will only request a recursive mutex in
4796 ** cases where it really needs one. {END} If a faster non-recursive mutex
4797 ** implementation is available on the host platform, the mutex subsystem
4798 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
4799 **
4800 ** {H17017} The other allowed parameters to sqlite3_mutex_alloc() each return
4801 ** a pointer to a static preexisting mutex. {END} Six static mutexes are
 
4802 ** used by the current version of SQLite. Future versions of SQLite
4803 ** may add additional static mutexes. Static mutexes are for internal
4804 ** use by SQLite only. Applications that use SQLite mutexes should
4805 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
4806 ** SQLITE_MUTEX_RECURSIVE.
4807 **
4808 ** {H17018} Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
4809 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
4810 ** returns a different mutex on every call. {H17034} But for the static
4811 ** mutex types, the same mutex is returned on every call that has
4812 ** the same type number.
4813 **
4814 ** {H17019} The sqlite3_mutex_free() routine deallocates a previously
4815 ** allocated dynamic mutex. {H17020} SQLite is careful to deallocate every
4816 ** dynamic mutex that it allocates. {A17021} The dynamic mutexes must not be in
4817 ** use when they are deallocated. {A17022} Attempting to deallocate a static
4818 ** mutex results in undefined behavior. {H17023} SQLite never deallocates
4819 ** a static mutex. {END}
4820 **
4821 ** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
4822 ** to enter a mutex. {H17024} If another thread is already within the mutex,
4823 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
4824 ** SQLITE_BUSY. {H17025} The sqlite3_mutex_try() interface returns [SQLITE_OK]
4825 ** upon successful entry. {H17026} Mutexes created using
4826 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
4827 ** {H17027} In such cases the,
4828 ** mutex must be exited an equal number of times before another thread
4829 ** can enter. {A17028} If the same thread tries to enter any other
4830 ** kind of mutex more than once, the behavior is undefined.
4831 ** {H17029} SQLite will never exhibit
4832 ** such behavior in its own use of mutexes.
4833 **
4834 ** Some systems (for example, Windows 95) do not support the operation
4835 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
4836 ** will always return SQLITE_BUSY. {H17030} The SQLite core only ever uses
4837 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.
4838 **
4839 ** {H17031} The sqlite3_mutex_leave() routine exits a mutex that was
4840 ** previously entered by the same thread. {A17032} The behavior
4841 ** is undefined if the mutex is not currently entered by the
4842 ** calling thread or is not currently allocated. {H17033} SQLite will
4843 ** never do either. {END}
4844 **
4845 ** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
4846 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
4847 ** behave as no-ops.
4848 **
4849 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
4850 */
@@ -4853,11 +4725,11 @@
4853 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
4854 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
4855 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
4856
4857 /*
4858 ** CAPI3REF: Mutex Methods Object {H17120} <S20130>
4859 ** EXPERIMENTAL
4860 **
4861 ** An instance of this structure defines the low-level routines
4862 ** used to allocate and use mutexes.
4863 **
@@ -4869,23 +4741,23 @@
4869 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
4870 ** Additionally, an instance of this structure can be used as an
4871 ** output variable when querying the system for the current mutex
4872 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
4873 **
4874 ** The xMutexInit method defined by this structure is invoked as
4875 ** part of system initialization by the sqlite3_initialize() function.
4876 ** {H17001} The xMutexInit routine shall be called by SQLite once for each
4877 ** effective call to [sqlite3_initialize()].
4878 **
4879 ** The xMutexEnd method defined by this structure is invoked as
4880 ** part of system shutdown by the sqlite3_shutdown() function. The
4881 ** implementation of this method is expected to release all outstanding
4882 ** resources obtained by the mutex methods implementation, especially
4883 ** those obtained by the xMutexInit method. {H17003} The xMutexEnd()
4884 ** interface shall be invoked once for each call to [sqlite3_shutdown()].
4885 **
4886 ** The remaining seven methods defined by this structure (xMutexAlloc,
4887 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
4888 ** xMutexNotheld) implement the following interfaces (respectively):
4889 **
4890 ** <ul>
4891 ** <li> [sqlite3_mutex_alloc()] </li>
@@ -4893,31 +4765,31 @@
4893 ** <li> [sqlite3_mutex_enter()] </li>
4894 ** <li> [sqlite3_mutex_try()] </li>
4895 ** <li> [sqlite3_mutex_leave()] </li>
4896 ** <li> [sqlite3_mutex_held()] </li>
4897 ** <li> [sqlite3_mutex_notheld()] </li>
4898 ** </ul>
4899 **
4900 ** The only difference is that the public sqlite3_XXX functions enumerated
4901 ** above silently ignore any invocations that pass a NULL pointer instead
4902 ** of a valid mutex handle. The implementations of the methods defined
4903 ** by this structure are not required to handle this case, the results
4904 ** of passing a NULL pointer instead of a valid mutex handle are undefined
4905 ** (i.e. it is acceptable to provide an implementation that segfaults if
4906 ** it is passed a NULL pointer).
4907 **
4908 ** The xMutexInit() method must be threadsafe. It must be harmless to
4909 ** invoke xMutexInit() mutiple times within the same process and without
4910 ** intervening calls to xMutexEnd(). Second and subsequent calls to
4911 ** xMutexInit() must be no-ops.
4912 **
4913 ** xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
4914 ** and its associates). Similarly, xMutexAlloc() must not use SQLite memory
4915 ** allocation for a static mutex. However xMutexAlloc() may use SQLite
4916 ** memory allocation for a fast or recursive mutex.
4917 **
4918 ** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
4919 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
4920 ** If xMutexInit fails in any way, it is expected to clean up after itself
4921 ** prior to returning.
4922 */
4923 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -4932,43 +4804,45 @@
4932 int (*xMutexHeld)(sqlite3_mutex *);
4933 int (*xMutexNotheld)(sqlite3_mutex *);
4934 };
4935
4936 /*
4937 ** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800>
4938 **
4939 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
4940 ** are intended for use inside assert() statements. {H17081} The SQLite core
4941 ** never uses these routines except inside an assert() and applications
4942 ** are advised to follow the lead of the core. {H17082} The core only
4943 ** provides implementations for these routines when it is compiled
4944 ** with the SQLITE_DEBUG flag. {A17087} External mutex implementations
4945 ** are only required to provide these routines if SQLITE_DEBUG is
4946 ** defined and if NDEBUG is not defined.
4947 **
4948 ** {H17083} These routines should return true if the mutex in their argument
4949 ** is held or not held, respectively, by the calling thread.
4950 **
4951 ** {X17084} The implementation is not required to provided versions of these
4952 ** routines that actually work. If the implementation does not provide working
4953 ** versions of these routines, it should at least provide stubs that always
4954 ** return true so that one does not get spurious assertion failures.
4955 **
4956 ** {H17085} If the argument to sqlite3_mutex_held() is a NULL pointer then
4957 ** the routine should return 1. {END} This seems counter-intuitive since
4958 ** clearly the mutex cannot be held if it does not exist. But the
4959 ** the reason the mutex does not exist is because the build is not
4960 ** using mutexes. And we do not want the assert() containing the
4961 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
4962 ** the appropriate thing to do. {H17086} The sqlite3_mutex_notheld()
4963 ** interface should also return 1 when given a NULL pointer.
4964 */
 
4965 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
4966 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
 
4967
4968 /*
4969 ** CAPI3REF: Mutex Types {H17001} <H17000>
4970 **
4971 ** The [sqlite3_mutex_alloc()] interface takes a single argument
4972 ** which is one of these integer constants.
4973 **
4974 ** The set of static mutexes may change from one SQLite release to the
@@ -4984,52 +4858,54 @@
4984 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
4985 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
4986 #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
4987
4988 /*
4989 ** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000>
4990 **
4991 ** This interface returns a pointer the [sqlite3_mutex] object that
4992 ** serializes access to the [database connection] given in the argument
4993 ** when the [threading mode] is Serialized.
4994 ** If the [threading mode] is Single-thread or Multi-thread then this
4995 ** routine returns a NULL pointer.
4996 */
4997 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
4998
4999 /*
5000 ** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800>
5001 **
5002 ** {H11301} The [sqlite3_file_control()] interface makes a direct call to the
5003 ** xFileControl method for the [sqlite3_io_methods] object associated
5004 ** with a particular database identified by the second argument. {H11302} The
5005 ** name of the database is the name assigned to the database by the
5006 ** <a href="lang_attach.html">ATTACH</a> SQL command that opened the
5007 ** database. {H11303} To control the main database file, use the name "main"
5008 ** or a NULL pointer. {H11304} The third and fourth parameters to this routine
 
 
5009 ** are passed directly through to the second and third parameters of
5010 ** the xFileControl method. {H11305} The return value of the xFileControl
5011 ** method becomes the return value of this routine.
5012 **
5013 ** {H11306} If the second parameter (zDbName) does not match the name of any
5014 ** open database file, then SQLITE_ERROR is returned. {H11307} This error
5015 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
5016 ** or [sqlite3_errmsg()]. {A11308} The underlying xFileControl method might
5017 ** also return SQLITE_ERROR. {A11309} There is no way to distinguish between
5018 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
5019 ** xFileControl method. {END}
5020 **
5021 ** See also: [SQLITE_FCNTL_LOCKSTATE]
5022 */
5023 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
5024
5025 /*
5026 ** CAPI3REF: Testing Interface {H11400} <S30800>
5027 **
5028 ** The sqlite3_test_control() interface is used to read out internal
5029 ** state of SQLite and to inject faults into SQLite for testing
5030 ** purposes. The first parameter is an operation code that determines
5031 ** the number, meaning, and operation of all subsequent parameters.
5032 **
5033 ** This interface is not for use by applications. It exists solely
5034 ** for verifying the correct operation of the SQLite library. Depending
5035 ** on how the SQLite library is compiled, this interface might not exist.
@@ -5040,20 +4916,21 @@
5040 ** operate consistently from one release to the next.
5041 */
5042 SQLITE_API int sqlite3_test_control(int op, ...);
5043
5044 /*
5045 ** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400>
5046 **
5047 ** These constants are the valid operation code parameters used
5048 ** as the first argument to [sqlite3_test_control()].
5049 **
5050 ** These parameters and their meanings are subject to change
5051 ** without notice. These values are for testing purposes only.
5052 ** Applications should not use any of these parameters or the
5053 ** [sqlite3_test_control()] interface.
5054 */
 
5055 #define SQLITE_TESTCTRL_PRNG_SAVE 5
5056 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
5057 #define SQLITE_TESTCTRL_PRNG_RESET 7
5058 #define SQLITE_TESTCTRL_BITVEC_TEST 8
5059 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5060,31 +4937,34 @@
5060 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
5061 #define SQLITE_TESTCTRL_PENDING_BYTE 11
5062 #define SQLITE_TESTCTRL_ASSERT 12
5063 #define SQLITE_TESTCTRL_ALWAYS 13
5064 #define SQLITE_TESTCTRL_RESERVE 14
 
 
 
5065
5066 /*
5067 ** CAPI3REF: SQLite Runtime Status {H17200} <S60200>
5068 ** EXPERIMENTAL
5069 **
5070 ** This interface is used to retrieve runtime status information
5071 ** about the preformance of SQLite, and optionally to reset various
5072 ** highwater marks. The first argument is an integer code for
5073 ** the specific parameter to measure. Recognized integer codes
5074 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].
5075 ** The current value of the parameter is returned into *pCurrent.
5076 ** The highest recorded value is returned in *pHighwater. If the
5077 ** resetFlag is true, then the highest record value is reset after
5078 ** *pHighwater is written. Some parameters do not record the highest
5079 ** value. For those parameters
5080 ** nothing is written into *pHighwater and the resetFlag is ignored.
5081 ** Other parameters record only the highwater mark and not the current
5082 ** value. For these latter parameters nothing is written into *pCurrent.
5083 **
5084 ** This routine returns SQLITE_OK on success and a non-zero
5085 ** [error code] on failure.
5086 **
5087 ** This routine is threadsafe but is not atomic. This routine can be
5088 ** called while other threads are running the same or different SQLite
5089 ** interfaces. However the values returned in *pCurrent and
5090 ** *pHighwater reflect the status of SQLite at different points in time
@@ -5095,82 +4975,82 @@
5095 */
5096 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
5097
5098
5099 /*
5100 ** CAPI3REF: Status Parameters {H17250} <H17200>
5101 ** EXPERIMENTAL
5102 **
5103 ** These integer constants designate various run-time status parameters
5104 ** that can be returned by [sqlite3_status()].
5105 **
5106 ** <dl>
5107 ** <dt>SQLITE_STATUS_MEMORY_USED</dt>
5108 ** <dd>This parameter is the current amount of memory checked out
5109 ** using [sqlite3_malloc()], either directly or indirectly. The
5110 ** figure includes calls made to [sqlite3_malloc()] by the application
5111 ** and internal memory usage by the SQLite library. Scratch memory
5112 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
5113 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
5114 ** this parameter. The amount returned is the sum of the allocation
5115 ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>
5116 **
5117 ** <dt>SQLITE_STATUS_MALLOC_SIZE</dt>
5118 ** <dd>This parameter records the largest memory allocation request
5119 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
5120 ** internal equivalents). Only the value returned in the
5121 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5122 ** The value written into the *pCurrent parameter is undefined.</dd>
5123 **
5124 ** <dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5125 ** <dd>This parameter returns the number of pages used out of the
5126 ** [pagecache memory allocator] that was configured using
5127 ** [SQLITE_CONFIG_PAGECACHE]. The
5128 ** value returned is in pages, not in bytes.</dd>
5129 **
5130 ** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5131 ** <dd>This parameter returns the number of bytes of page cache
5132 ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
5133 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
5134 ** returned value includes allocations that overflowed because they
5135 ** where too large (they were larger than the "sz" parameter to
5136 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5137 ** no space was left in the page cache.</dd>
5138 **
5139 ** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5140 ** <dd>This parameter records the largest memory allocation request
5141 ** handed to [pagecache memory allocator]. Only the value returned in the
5142 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5143 ** The value written into the *pCurrent parameter is undefined.</dd>
5144 **
5145 ** <dt>SQLITE_STATUS_SCRATCH_USED</dt>
5146 ** <dd>This parameter returns the number of allocations used out of the
5147 ** [scratch memory allocator] configured using
5148 ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
5149 ** in bytes. Since a single thread may only have one scratch allocation
5150 ** outstanding at time, this parameter also reports the number of threads
5151 ** using scratch memory at the same time.</dd>
5152 **
5153 ** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5154 ** <dd>This parameter returns the number of bytes of scratch memory
5155 ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
5156 ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
5157 ** returned include overflows because the requested allocation was too
5158 ** larger (that is, because the requested allocation was larger than the
5159 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
5160 ** slots were available.
5161 ** </dd>
5162 **
5163 ** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5164 ** <dd>This parameter records the largest memory allocation request
5165 ** handed to [scratch memory allocator]. Only the value returned in the
5166 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5167 ** The value written into the *pCurrent parameter is undefined.</dd>
5168 **
5169 ** <dt>SQLITE_STATUS_PARSER_STACK</dt>
5170 ** <dd>This parameter records the deepest parser stack. It is only
5171 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>
5172 ** </dl>
5173 **
5174 ** New status parameters may be added from time to time.
5175 */
5176 #define SQLITE_STATUS_MEMORY_USED 0
@@ -5182,31 +5062,31 @@
5182 #define SQLITE_STATUS_PARSER_STACK 6
5183 #define SQLITE_STATUS_PAGECACHE_SIZE 7
5184 #define SQLITE_STATUS_SCRATCH_SIZE 8
5185
5186 /*
5187 ** CAPI3REF: Database Connection Status {H17500} <S60200>
5188 ** EXPERIMENTAL
5189 **
5190 ** This interface is used to retrieve runtime status information
5191 ** about a single [database connection]. The first argument is the
5192 ** database connection object to be interrogated. The second argument
5193 ** is the parameter to interrogate. Currently, the only allowed value
5194 ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
5195 ** Additional options will likely appear in future releases of SQLite.
5196 **
5197 ** The current value of the requested parameter is written into *pCur
5198 ** and the highest instantaneous value is written into *pHiwtr. If
5199 ** the resetFlg is true, then the highest instantaneous value is
5200 ** reset back down to the current value.
5201 **
5202 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
5203 */
5204 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
5205
5206 /*
5207 ** CAPI3REF: Status Parameters for database connections {H17520} <H17500>
5208 ** EXPERIMENTAL
5209 **
5210 ** These constants are the available integer "verbs" that can be passed as
5211 ** the second argument to the [sqlite3_db_status()] interface.
5212 **
@@ -5215,61 +5095,61 @@
5215 ** [sqlite3_db_status()] to make sure that the call worked.
5216 ** The [sqlite3_db_status()] interface will return a non-zero error code
5217 ** if a discontinued or unsupported verb is invoked.
5218 **
5219 ** <dl>
5220 ** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5221 ** <dd>This parameter returns the number of lookaside memory slots currently
5222 ** checked out.</dd>
5223 ** </dl>
5224 */
5225 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
5226
5227
5228 /*
5229 ** CAPI3REF: Prepared Statement Status {H17550} <S60200>
5230 ** EXPERIMENTAL
5231 **
5232 ** Each prepared statement maintains various
5233 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5234 ** of times it has performed specific operations. These counters can
5235 ** be used to monitor the performance characteristics of the prepared
5236 ** statements. For example, if the number of table steps greatly exceeds
5237 ** the number of table searches or result rows, that would tend to indicate
5238 ** that the prepared statement is using a full table scan rather than
5239 ** an index.
5240 **
5241 ** This interface is used to retrieve and reset counter values from
5242 ** a [prepared statement]. The first argument is the prepared statement
5243 ** object to be interrogated. The second argument
5244 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5245 ** to be interrogated.
5246 ** The current value of the requested counter is returned.
5247 ** If the resetFlg is true, then the counter is reset to zero after this
5248 ** interface call returns.
5249 **
5250 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
5251 */
5252 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5253
5254 /*
5255 ** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550>
5256 ** EXPERIMENTAL
5257 **
5258 ** These preprocessor macros define integer codes that name counter
5259 ** values associated with the [sqlite3_stmt_status()] interface.
5260 ** The meanings of the various counters are as follows:
5261 **
5262 ** <dl>
5263 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5264 ** <dd>This is the number of times that SQLite has stepped forward in
5265 ** a table as part of a full table scan. Large numbers for this counter
5266 ** may indicate opportunities for performance improvement through
5267 ** careful use of indices.</dd>
5268 **
5269 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
5270 ** <dd>This is the number of sort operations that have occurred.
5271 ** A non-zero value in this counter may indicate an opportunity to
5272 ** improvement performance through careful use of indices.</dd>
5273 **
5274 ** </dl>
5275 */
@@ -5293,84 +5173,84 @@
5293 /*
5294 ** CAPI3REF: Application Defined Page Cache.
5295 ** KEYWORDS: {page cache}
5296 ** EXPERIMENTAL
5297 **
5298 ** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5299 ** register an alternative page cache implementation by passing in an
5300 ** instance of the sqlite3_pcache_methods structure. The majority of the
5301 ** heap memory used by SQLite is used by the page cache to cache data read
5302 ** from, or ready to be written to, the database file. By implementing a
5303 ** custom page cache using this API, an application can control more
5304 ** precisely the amount of memory consumed by SQLite, the way in which
5305 ** that memory is allocated and released, and the policies used to
5306 ** determine exactly which parts of a database file are cached and for
5307 ** how long.
5308 **
5309 ** The contents of the sqlite3_pcache_methods structure are copied to an
5310 ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
5311 ** the application may discard the parameter after the call to
5312 ** [sqlite3_config()] returns.
5313 **
5314 ** The xInit() method is called once for each call to [sqlite3_initialize()]
5315 ** (usually only once during the lifetime of the process). It is passed
5316 ** a copy of the sqlite3_pcache_methods.pArg value. It can be used to set
5317 ** up global structures and mutexes required by the custom page cache
5318 ** implementation.
5319 **
5320 ** The xShutdown() method is called from within [sqlite3_shutdown()],
5321 ** if the application invokes this API. It can be used to clean up
5322 ** any outstanding resources before process shutdown, if required.
5323 **
5324 ** SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5325 ** the xInit method, so the xInit method need not be threadsafe. The
5326 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
5327 ** not need to be threadsafe either. All other methods must be threadsafe
5328 ** in multithreaded applications.
5329 **
5330 ** SQLite will never invoke xInit() more than once without an intervening
5331 ** call to xShutdown().
5332 **
5333 ** The xCreate() method is used to construct a new cache instance. SQLite
5334 ** will typically create one cache instance for each open database file,
5335 ** though this is not guaranteed. The
5336 ** first parameter, szPage, is the size in bytes of the pages that must
5337 ** be allocated by the cache. szPage will not be a power of two. szPage
5338 ** will the page size of the database file that is to be cached plus an
5339 ** increment (here called "R") of about 100 or 200. SQLite will use the
5340 ** extra R bytes on each page to store metadata about the underlying
5341 ** database page on disk. The value of R depends
5342 ** on the SQLite version, the target platform, and how SQLite was compiled.
5343 ** R is constant for a particular build of SQLite. The second argument to
5344 ** xCreate(), bPurgeable, is true if the cache being created will
5345 ** be used to cache database pages of a file stored on disk, or
5346 ** false if it is used for an in-memory database. The cache implementation
5347 ** does not have to do anything special based with the value of bPurgeable;
5348 ** it is purely advisory. On a cache where bPurgeable is false, SQLite will
5349 ** never invoke xUnpin() except to deliberately delete a page.
5350 ** In other words, a cache created with bPurgeable set to false will
5351 ** never contain any unpinned pages.
5352 **
5353 ** The xCachesize() method may be called at any time by SQLite to set the
5354 ** suggested maximum cache-size (number of pages stored by) the cache
5355 ** instance passed as the first argument. This is the value configured using
5356 ** the SQLite "[PRAGMA cache_size]" command. As with the bPurgeable parameter,
5357 ** the implementation is not required to do anything with this
5358 ** value; it is advisory only.
5359 **
5360 ** The xPagecount() method should return the number of pages currently
5361 ** stored in the cache.
5362 **
5363 ** The xFetch() method is used to fetch a page and return a pointer to it.
5364 ** A 'page', in this context, is a buffer of szPage bytes aligned at an
5365 ** 8-byte boundary. The page to be fetched is determined by the key. The
5366 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5367 ** is considered to be "pinned".
5368 **
5369 ** If the requested page is already in the page cache, then the page cache
5370 ** implementation must return a pointer to the page buffer with its content
5371 ** intact. If the requested page is not already in the cache, then the
5372 ** behavior of the cache implementation is determined by the value of the
5373 ** createFlag parameter passed to xFetch, according to the following table:
5374 **
5375 ** <table border=1 width=85% align=center>
5376 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5377,45 +5257,45 @@
5377 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
5378 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
5379 ** Otherwise return NULL.
5380 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
5381 ** NULL if allocating a new page is effectively impossible.
5382 ** </table>
5383 **
5384 ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
5385 ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
5386 ** attempt to unpin one or more cache pages by spilling the content of
5387 ** pinned pages to disk and synching the operating system disk cache. After
5388 ** attempting to unpin pages, the xFetch() method will be invoked again with
5389 ** a createFlag of 2.
5390 **
5391 ** xUnpin() is called by SQLite with a pointer to a currently pinned page
5392 ** as its second argument. If the third parameter, discard, is non-zero,
5393 ** then the page should be evicted from the cache. In this case SQLite
5394 ** assumes that the next time the page is retrieved from the cache using
5395 ** the xFetch() method, it will be zeroed. If the discard parameter is
5396 ** zero, then the page is considered to be unpinned. The cache implementation
5397 ** may choose to evict unpinned pages at any time.
5398 **
5399 ** The cache is not required to perform any reference counting. A single
5400 ** call to xUnpin() unpins the page regardless of the number of prior calls
5401 ** to xFetch().
5402 **
5403 ** The xRekey() method is used to change the key value associated with the
5404 ** page passed as the second argument from oldKey to newKey. If the cache
5405 ** previously contains an entry associated with newKey, it should be
5406 ** discarded. Any prior cache entry associated with newKey is guaranteed not
5407 ** to be pinned.
5408 **
5409 ** When SQLite calls the xTruncate() method, the cache must discard all
5410 ** existing cache entries with page numbers (keys) greater than or equal
5411 ** to the value of the iLimit parameter passed to xTruncate(). If any
5412 ** of these pages are pinned, they are implicitly unpinned, meaning that
5413 ** they can be safely discarded.
5414 **
5415 ** The xDestroy() method is used to delete a cache allocated by xCreate().
5416 ** All resources associated with the specified cache should be freed. After
5417 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
5418 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
5419 ** functions.
5420 */
5421 typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5436,11 +5316,11 @@
5436 /*
5437 ** CAPI3REF: Online Backup Object
5438 ** EXPERIMENTAL
5439 **
5440 ** The sqlite3_backup object records state information about an ongoing
5441 ** online backup operation. The sqlite3_backup object is created by
5442 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
5443 ** [sqlite3_backup_finish()].
5444 **
5445 ** See Also: [Using the SQLite Online Backup API]
5446 */
@@ -5448,168 +5328,173 @@
5448
5449 /*
5450 ** CAPI3REF: Online Backup API.
5451 ** EXPERIMENTAL
5452 **
5453 ** This API is used to overwrite the contents of one database with that
5454 ** of another. It is useful either for creating backups of databases or
5455 ** for copying in-memory databases to or from persistent files.
5456 **
5457 ** See Also: [Using the SQLite Online Backup API]
5458 **
5459 ** Exclusive access is required to the destination database for the
5460 ** duration of the operation. However the source database is only
5461 ** read-locked while it is actually being read, it is not locked
5462 ** continuously for the entire operation. Thus, the backup may be
5463 ** performed on a live database without preventing other users from
5464 ** writing to the database for an extended period of time.
5465 **
5466 ** To perform a backup operation:
5467 ** <ol>
5468 ** <li><b>sqlite3_backup_init()</b> is called once to initialize the
5469 ** backup,
5470 ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
5471 ** the data between the two databases, and finally
5472 ** <li><b>sqlite3_backup_finish()</b> is called to release all resources
5473 ** associated with the backup operation.
5474 ** </ol>
5475 ** There should be exactly one call to sqlite3_backup_finish() for each
5476 ** successful call to sqlite3_backup_init().
5477 **
5478 ** <b>sqlite3_backup_init()</b>
5479 **
5480 ** The first two arguments passed to [sqlite3_backup_init()] are the database
5481 ** handle associated with the destination database and the database name
5482 ** used to attach the destination database to the handle. The database name
5483 ** is "main" for the main database, "temp" for the temporary database, or
5484 ** the name specified as part of the [ATTACH] statement if the destination is
5485 ** an attached database. The third and fourth arguments passed to
5486 ** sqlite3_backup_init() identify the [database connection]
5487 ** and database name used
5488 ** to access the source database. The values passed for the source and
5489 ** destination [database connection] parameters must not be the same.
 
 
5490 **
5491 ** If an error occurs within sqlite3_backup_init(), then NULL is returned
5492 ** and an error code and error message written into the [database connection]
5493 ** passed as the first argument. They may be retrieved using the
5494 ** [sqlite3_errcode()], [sqlite3_errmsg()], and [sqlite3_errmsg16()] functions.
5495 ** Otherwise, if successful, a pointer to an [sqlite3_backup] object is
5496 ** returned. This pointer may be used with the sqlite3_backup_step() and
 
 
 
5497 ** sqlite3_backup_finish() functions to perform the specified backup
5498 ** operation.
5499 **
5500 ** <b>sqlite3_backup_step()</b>
5501 **
5502 ** Function [sqlite3_backup_step()] is used to copy up to nPage pages between
5503 ** the source and destination databases, where nPage is the value of the
5504 ** second parameter passed to sqlite3_backup_step(). If nPage is a negative
5505 ** value, all remaining source pages are copied. If the required pages are
5506 ** succesfully copied, but there are still more pages to copy before the
5507 ** backup is complete, it returns [SQLITE_OK]. If no error occured and there
5508 ** are no more pages to copy, then [SQLITE_DONE] is returned. If an error
5509 ** occurs, then an SQLite error code is returned. As well as [SQLITE_OK] and
 
5510 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
5511 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
5512 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
5513 **
5514 ** As well as the case where the destination database file was opened for
5515 ** read-only access, sqlite3_backup_step() may return [SQLITE_READONLY] if
5516 ** the destination is an in-memory database with a different page size
5517 ** from the source database.
5518 **
5519 ** If sqlite3_backup_step() cannot obtain a required file-system lock, then
5520 ** the [sqlite3_busy_handler | busy-handler function]
5521 ** is invoked (if one is specified). If the
5522 ** busy-handler returns non-zero before the lock is available, then
5523 ** [SQLITE_BUSY] is returned to the caller. In this case the call to
5524 ** sqlite3_backup_step() can be retried later. If the source
5525 ** [database connection]
5526 ** is being used to write to the source database when sqlite3_backup_step()
5527 ** is called, then [SQLITE_LOCKED] is returned immediately. Again, in this
5528 ** case the call to sqlite3_backup_step() can be retried later on. If
5529 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
5530 ** [SQLITE_READONLY] is returned, then
5531 ** there is no point in retrying the call to sqlite3_backup_step(). These
5532 ** errors are considered fatal. At this point the application must accept
5533 ** that the backup operation has failed and pass the backup operation handle
5534 ** to the sqlite3_backup_finish() to release associated resources.
5535 **
5536 ** Following the first call to sqlite3_backup_step(), an exclusive lock is
5537 ** obtained on the destination file. It is not released until either
5538 ** sqlite3_backup_finish() is called or the backup operation is complete
5539 ** and sqlite3_backup_step() returns [SQLITE_DONE]. Additionally, each time
5540 ** a call to sqlite3_backup_step() is made a [shared lock] is obtained on
5541 ** the source database file. This lock is released before the
5542 ** sqlite3_backup_step() call returns. Because the source database is not
5543 ** locked between calls to sqlite3_backup_step(), it may be modified mid-way
5544 ** through the backup procedure. If the source database is modified by an
5545 ** external process or via a database connection other than the one being
5546 ** used by the backup operation, then the backup will be transparently
5547 ** restarted by the next call to sqlite3_backup_step(). If the source
5548 ** database is modified by the using the same database connection as is used
5549 ** by the backup operation, then the backup database is transparently
5550 ** updated at the same time.
5551 **
5552 ** <b>sqlite3_backup_finish()</b>
5553 **
5554 ** Once sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5555 ** application wishes to abandon the backup operation, the [sqlite3_backup]
5556 ** object should be passed to sqlite3_backup_finish(). This releases all
5557 ** resources associated with the backup operation. If sqlite3_backup_step()
5558 ** has not yet returned [SQLITE_DONE], then any active write-transaction on the
5559 ** destination database is rolled back. The [sqlite3_backup] object is invalid
 
 
5560 ** and may not be used following a call to sqlite3_backup_finish().
5561 **
5562 ** The value returned by sqlite3_backup_finish is [SQLITE_OK] if no error
5563 ** occurred, regardless or whether or not sqlite3_backup_step() was called
5564 ** a sufficient number of times to complete the backup operation. Or, if
5565 ** an out-of-memory condition or IO error occured during a call to
5566 ** sqlite3_backup_step() then [SQLITE_NOMEM] or an
5567 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] error code
5568 ** is returned. In this case the error code and an error message are
5569 ** written to the destination [database connection].
5570 **
5571 ** A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step() is
5572 ** not a permanent error and does not affect the return value of
5573 ** sqlite3_backup_finish().
5574 **
5575 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
5576 **
5577 ** Each call to sqlite3_backup_step() sets two values stored internally
5578 ** by an [sqlite3_backup] object. The number of pages still to be backed
5579 ** up, which may be queried by sqlite3_backup_remaining(), and the total
5580 ** number of pages in the source database file, which may be queried by
5581 ** sqlite3_backup_pagecount().
5582 **
5583 ** The values returned by these functions are only updated by
5584 ** sqlite3_backup_step(). If the source database is modified during a backup
5585 ** operation, then the values are not updated to account for any extra
5586 ** pages that need to be updated or the size of the source database file
5587 ** changing.
5588 **
5589 ** <b>Concurrent Usage of Database Handles</b>
5590 **
5591 ** The source [database connection] may be used by the application for other
5592 ** purposes while a backup operation is underway or being initialized.
5593 ** If SQLite is compiled and configured to support threadsafe database
5594 ** connections, then the source database connection may be used concurrently
5595 ** from within other threads.
5596 **
5597 ** However, the application must guarantee that the destination database
5598 ** connection handle is not passed to any other API (by any thread) after
5599 ** sqlite3_backup_init() is called and before the corresponding call to
5600 ** sqlite3_backup_finish(). Unfortunately SQLite does not currently check
5601 ** for this, if the application does use the destination [database connection]
5602 ** for some other purpose during a backup operation, things may appear to
5603 ** work correctly but in fact be subtly malfunctioning. Use of the
5604 ** destination database connection while a backup is in progress might
5605 ** also cause a mutex deadlock.
5606 **
5607 ** Furthermore, if running in [shared cache mode], the application must
5608 ** guarantee that the shared cache used by the destination database
5609 ** is not accessed while the backup is running. In practice this means
5610 ** that the application must guarantee that the file-system file being
5611 ** backed up to is not accessed by any connection within the process,
5612 ** not just the specific connection that was passed to sqlite3_backup_init().
5613 **
5614 ** The [sqlite3_backup] object itself is partially threadsafe. Multiple
5615 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -5631,60 +5516,60 @@
5631
5632 /*
5633 ** CAPI3REF: Unlock Notification
5634 ** EXPERIMENTAL
5635 **
5636 ** When running in shared-cache mode, a database operation may fail with
5637 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
5638 ** individual tables within the shared-cache cannot be obtained. See
5639 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
5640 ** This API may be used to register a callback that SQLite will invoke
5641 ** when the connection currently holding the required lock relinquishes it.
5642 ** This API is only available if the library was compiled with the
5643 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
5644 **
5645 ** See Also: [Using the SQLite Unlock Notification Feature].
5646 **
5647 ** Shared-cache locks are released when a database connection concludes
5648 ** its current transaction, either by committing it or rolling it back.
5649 **
5650 ** When a connection (known as the blocked connection) fails to obtain a
5651 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
5652 ** identity of the database connection (the blocking connection) that
5653 ** has locked the required resource is stored internally. After an
5654 ** application receives an SQLITE_LOCKED error, it may call the
5655 ** sqlite3_unlock_notify() method with the blocked connection handle as
5656 ** the first argument to register for a callback that will be invoked
5657 ** when the blocking connections current transaction is concluded. The
5658 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
5659 ** call that concludes the blocking connections transaction.
5660 **
5661 ** If sqlite3_unlock_notify() is called in a multi-threaded application,
5662 ** there is a chance that the blocking connection will have already
5663 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
5664 ** If this happens, then the specified callback is invoked immediately,
5665 ** from within the call to sqlite3_unlock_notify().
5666 **
5667 ** If the blocked connection is attempting to obtain a write-lock on a
5668 ** shared-cache table, and more than one other connection currently holds
5669 ** a read-lock on the same table, then SQLite arbitrarily selects one of
5670 ** the other connections to use as the blocking connection.
5671 **
5672 ** There may be at most one unlock-notify callback registered by a
5673 ** blocked connection. If sqlite3_unlock_notify() is called when the
5674 ** blocked connection already has a registered unlock-notify callback,
5675 ** then the new callback replaces the old. If sqlite3_unlock_notify() is
5676 ** called with a NULL pointer as its second argument, then any existing
5677 ** unlock-notify callback is cancelled. The blocked connections
5678 ** unlock-notify callback may also be canceled by closing the blocked
5679 ** connection using [sqlite3_close()].
5680 **
5681 ** The unlock-notify callback is not reentrant. If an application invokes
5682 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
5683 ** crash or deadlock may be the result.
5684 **
5685 ** Unless deadlock is detected (see below), sqlite3_unlock_notify() always
5686 ** returns SQLITE_OK.
5687 **
5688 ** <b>Callback Invocation Details</b>
5689 **
5690 ** When an unlock-notify callback is registered, the application provides a
@@ -5694,11 +5579,11 @@
5694 ** an unlock-notify callback is a pointer to an array of void* pointers,
5695 ** and the second is the number of entries in the array.
5696 **
5697 ** When a blocking connections transaction is concluded, there may be
5698 ** more than one blocked connection that has registered for an unlock-notify
5699 ** callback. If two or more such blocked connections have specified the
5700 ** same callback function, then instead of invoking the callback function
5701 ** multiple times, it is invoked once with the set of void* context pointers
5702 ** specified by the blocked connections bundled together into an array.
5703 ** This gives the application an opportunity to prioritize any actions
5704 ** related to the set of unblocked database connections.
@@ -5712,20 +5597,20 @@
5712 ** connection Y's transaction to be concluded, and similarly connection
5713 ** Y is waiting on connection X's transaction, then neither connection
5714 ** will proceed and the system may remain deadlocked indefinitely.
5715 **
5716 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
5717 ** detection. If a given call to sqlite3_unlock_notify() would put the
5718 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
5719 ** unlock-notify callback is registered. The system is said to be in
5720 ** a deadlocked state if connection A has registered for an unlock-notify
5721 ** callback on the conclusion of connection B's transaction, and connection
5722 ** B has itself registered for an unlock-notify callback when connection
5723 ** A's transaction is concluded. Indirect deadlock is also detected, so
5724 ** the system is also considered to be deadlocked if connection B has
5725 ** registered for an unlock-notify callback on the conclusion of connection
5726 ** C's transaction, where connection C is waiting on connection A. Any
5727 ** number of levels of indirection are allowed.
5728 **
5729 ** <b>The "DROP TABLE" Exception</b>
5730 **
5731 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -5737,14 +5622,14 @@
5737 ** sqlite3_unlock_notify() results in the unlock-notify callback being
5738 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
5739 ** or "DROP INDEX" query, an infinite loop might be the result.
5740 **
5741 ** One way around this problem is to check the extended error code returned
5742 ** by an sqlite3_step() call. If there is a blocking connection, then the
5743 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
5744 ** the special "DROP TABLE/INDEX" case, the extended error code is just
5745 ** SQLITE_LOCKED.
5746 */
5747 SQLITE_API int sqlite3_unlock_notify(
5748 sqlite3 *pBlocked, /* Waiting connection */
5749 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
5750 void *pNotifyArg /* Argument to pass to xNotify */
@@ -5753,11 +5638,11 @@
5753
5754 /*
5755 ** CAPI3REF: String Comparison
5756 ** EXPERIMENTAL
5757 **
5758 ** The [sqlite3_strnicmp()] API allows applications and extensions to
5759 ** compare the contents of two buffers containing UTF-8 strings in a
5760 ** case-indendent fashion, using the same definition of case independence
5761 ** that SQLite uses internally when comparing identifiers.
5762 */
5763 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
5764
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -79,88 +79,81 @@
79 #ifdef SQLITE_VERSION_NUMBER
80 # undef SQLITE_VERSION_NUMBER
81 #endif
82
83 /*
84 ** CAPI3REF: Compile-Time Library Version Numbers
85 **
86 ** ^(The [SQLITE_VERSION] C preprocessor macro in the sqlite3.h header
87 ** evaluates to a string literal that is the SQLite version in the
88 ** format "X.Y.Z" where X is the major version number (always 3 for
89 ** SQLite3) and Y is the minor version number and Z is the release number.)^
90 ** ^(The [SQLITE_VERSION_NUMBER] C preprocessor macro resolves to an integer
91 ** with the value (X*1000000 + Y*1000 + Z) where X, Y, and Z are the same
92 ** numbers used in [SQLITE_VERSION].)^
93 ** The SQLITE_VERSION_NUMBER for any given release of SQLite will also
94 ** be larger than the release from which it is derived. Either Y will
95 ** be held constant and Z will be incremented or else Y will be incremented
96 ** and Z will be reset to zero.
 
 
 
 
 
 
 
 
 
 
97 **
98 ** Since version 3.6.18, SQLite source code has been stored in the
99 ** <a href="http://www.fossil-scm.org/">Fossil configuration management
100 ** system</a>. ^The SQLITE_SOURCE_ID macro evalutes to
101 ** a string which identifies a particular check-in of SQLite
102 ** within its configuration management system. ^The SQLITE_SOURCE_ID
103 ** string contains the date and time of the check-in (UTC) and an SHA1
104 ** hash of the entire source tree.
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
 
 
109 */
110 #define SQLITE_VERSION "3.6.22"
111 #define SQLITE_VERSION_NUMBER 3006022
112 #define SQLITE_SOURCE_ID "2010-01-02 19:02:02 51f7ee844057086789dcfcdcba7daf45343cae62"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version
117 **
118 ** These interfaces provide the same information as the [SQLITE_VERSION],
119 ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
120 ** but are associated with the library instead of the header file. ^(Cautious
121 ** programmers might include assert() statements in their application to
122 ** verify that values returned by these interfaces match the macros in
123 ** the header, and thus insure that the application is
124 ** compiled with matching library and header files.
125 **
126 ** <blockquote><pre>
127 ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER );
128 ** assert( strcmp(sqlite3_sourceid(),SQLITE_SOURCE_ID)==0 );
129 ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 );
130 ** </pre></blockquote>)^
131 **
132 ** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION]
133 ** macro. ^The sqlite3_libversion() function returns a pointer to the
134 ** to the sqlite3_version[] string constant. The sqlite3_libversion()
135 ** function is provided for use in DLLs since DLL users usually do not have
136 ** direct access to string constants within the DLL. ^The
137 ** sqlite3_libversion_number() function returns an integer equal to
138 ** [SQLITE_VERSION_NUMBER]. ^The sqlite3_sourceid() function a pointer
139 ** to a string constant whose value is the same as the [SQLITE_SOURCE_ID]
140 ** C preprocessor macro.
141 **
142 ** See also: [sqlite_version()] and [sqlite_source_id()].
 
 
143 */
144 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
145 SQLITE_API const char *sqlite3_libversion(void);
146 SQLITE_API const char *sqlite3_sourceid(void);
147 SQLITE_API int sqlite3_libversion_number(void);
148
149 /*
150 ** CAPI3REF: Test To See If The Library Is Threadsafe
151 **
152 ** ^The sqlite3_threadsafe() function returns zero if and only if
153 ** SQLite was compiled mutexing code omitted due to the
154 ** [SQLITE_THREADSAFE] compile-time option being set to 0.
155 **
156 ** SQLite can be compiled with or without mutexes. When
157 ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes
158 ** are enabled and SQLite is threadsafe. When the
159 ** [SQLITE_THREADSAFE] macro is 0,
@@ -168,33 +161,33 @@
161 ** to use SQLite concurrently from more than one thread.
162 **
163 ** Enabling mutexes incurs a measurable performance penalty.
164 ** So if speed is of utmost importance, it makes sense to disable
165 ** the mutexes. But for maximum safety, mutexes should be enabled.
166 ** ^The default behavior is for mutexes to be enabled.
167 **
168 ** This interface can be used by an application to make sure that the
169 ** version of SQLite that it is linking against was compiled with
170 ** the desired setting of the [SQLITE_THREADSAFE] macro.
171 **
172 ** This interface only reports on the compile-time mutex setting
173 ** of the [SQLITE_THREADSAFE] flag. If SQLite is compiled with
174 ** SQLITE_THREADSAFE=1 or =2 then mutexes are enabled by default but
175 ** can be fully or partially disabled using a call to [sqlite3_config()]
176 ** with the verbs [SQLITE_CONFIG_SINGLETHREAD], [SQLITE_CONFIG_MULTITHREAD],
177 ** or [SQLITE_CONFIG_MUTEX]. ^(The return value of the
178 ** sqlite3_threadsafe() function shows only the compile-time setting of
179 ** thread safety, not any run-time changes to that setting made by
180 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
181 ** is unchanged by calls to sqlite3_config().)^
182 **
183 ** See the [threading mode] documentation for additional information.
 
 
184 */
185 SQLITE_API int sqlite3_threadsafe(void);
186
187 /*
188 ** CAPI3REF: Database Connection Handle
189 ** KEYWORDS: {database connection} {database connections}
190 **
191 ** Each open SQLite database is represented by a pointer to an instance of
192 ** the opaque structure named "sqlite3". It is useful to think of an sqlite3
193 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and
@@ -205,21 +198,24 @@
198 ** sqlite3 object.
199 */
200 typedef struct sqlite3 sqlite3;
201
202 /*
203 ** CAPI3REF: 64-Bit Integer Types
204 ** KEYWORDS: sqlite_int64 sqlite_uint64
205 **
206 ** Because there is no cross-platform way to specify 64-bit integer types
207 ** SQLite includes typedefs for 64-bit signed and unsigned integers.
208 **
209 ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions.
210 ** The sqlite_int64 and sqlite_uint64 types are supported for backwards
211 ** compatibility only.
212 **
213 ** ^The sqlite3_int64 and sqlite_int64 types can store integer values
214 ** between -9223372036854775808 and +9223372036854775807 inclusive. ^The
215 ** sqlite3_uint64 and sqlite_uint64 types can store integer values
216 ** between 0 and +18446744073709551615 inclusive.
217 */
218 #ifdef SQLITE_INT64_TYPE
219 typedef SQLITE_INT64_TYPE sqlite_int64;
220 typedef unsigned SQLITE_INT64_TYPE sqlite_uint64;
221 #elif defined(_MSC_VER) || defined(__BORLANDC__)
@@ -239,28 +235,32 @@
235 #ifdef SQLITE_OMIT_FLOATING_POINT
236 # define double sqlite3_int64
237 #endif
238
239 /*
240 ** CAPI3REF: Closing A Database Connection
241 **
242 ** ^The sqlite3_close() routine is the destructor for the [sqlite3] object.
243 ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is
244 ** successfullly destroyed and all associated resources are deallocated.
245 **
246 ** Applications must [sqlite3_finalize | finalize] all [prepared statements]
247 ** and [sqlite3_blob_close | close] all [BLOB handles] associated with
248 ** the [sqlite3] object prior to attempting to close the object. ^If
249 ** sqlite3_close() is called on a [database connection] that still has
250 ** outstanding [prepared statements] or [BLOB handles], then it returns
251 ** SQLITE_BUSY.
252 **
253 ** ^If [sqlite3_close()] is invoked while a transaction is open,
254 ** the transaction is automatically rolled back.
255 **
256 ** The C parameter to [sqlite3_close(C)] must be either a NULL
257 ** pointer or an [sqlite3] object pointer obtained
258 ** from [sqlite3_open()], [sqlite3_open16()], or
259 ** [sqlite3_open_v2()], and not previously closed.
260 ** ^Calling sqlite3_close() with a NULL pointer argument is a
261 ** harmless no-op.
 
262 */
263 SQLITE_API int sqlite3_close(sqlite3 *);
264
265 /*
266 ** The type for a callback function.
@@ -268,52 +268,69 @@
268 ** compatibility and is not documented.
269 */
270 typedef int (*sqlite3_callback)(void*,int,char**, char**);
271
272 /*
273 ** CAPI3REF: One-Step Query Execution Interface
274 **
275 ** The sqlite3_exec() interface is a convenience wrapper around
276 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
277 ** that allows an application to run multiple statements of SQL
278 ** without having to use a lot of C code.
279 **
280 ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded,
281 ** semicolon-separate SQL statements passed into its 2nd argument,
282 ** in the context of the [database connection] passed in as its 1st
283 ** argument. ^If the callback function of the 3rd argument to
284 ** sqlite3_exec() is not NULL, then it is invoked for each result row
285 ** coming out of the evaluated SQL statements. ^The 4th argument to
286 ** to sqlite3_exec() is relayed through to the 1st argument of each
287 ** callback invocation. ^If the callback pointer to sqlite3_exec()
288 ** is NULL, then no callback is ever invoked and result rows are
289 ** ignored.
290 **
291 ** ^If an error occurs while evaluating the SQL statements passed into
292 ** sqlite3_exec(), then execution of the current statement stops and
293 ** subsequent statements are skipped. ^If the 5th parameter to sqlite3_exec()
294 ** is not NULL then any error message is written into memory obtained
295 ** from [sqlite3_malloc()] and passed back through the 5th parameter.
296 ** To avoid memory leaks, the application should invoke [sqlite3_free()]
297 ** on error message strings returned through the 5th parameter of
298 ** of sqlite3_exec() after the error message string is no longer needed.
299 ** ^If the 5th parameter to sqlite3_exec() is not NULL and no errors
300 ** occur, then sqlite3_exec() sets the pointer in its 5th parameter to
301 ** NULL before returning.
302 **
303 ** ^If an sqlite3_exec() callback returns non-zero, the sqlite3_exec()
304 ** routine returns SQLITE_ABORT without invoking the callback again and
305 ** without running any subsequent SQL statements.
306 **
307 ** ^The 2nd argument to the sqlite3_exec() callback function is the
308 ** number of columns in the result. ^The 3rd argument to the sqlite3_exec()
309 ** callback is an array of pointers to strings obtained as if from
310 ** [sqlite3_column_text()], one for each column. ^If an element of a
311 ** result row is NULL then the corresponding string pointer for the
312 ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the
313 ** sqlite3_exec() callback is an array of pointers to strings where each
314 ** entry represents the name of corresponding result column as obtained
315 ** from [sqlite3_column_name()].
316 **
317 ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer
318 ** to an empty string, or a pointer that contains only whitespace and/or
319 ** SQL comments, then no SQL statements are evaluated and the database
320 ** is not changed.
321 **
322 ** Restrictions:
323 **
324 ** <ul>
325 ** <li> The application must insure that the 1st parameter to sqlite3_exec()
326 ** is a valid and open [database connection].
327 ** <li> The application must not close [database connection] specified by
328 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
329 ** <li> The application must not modify the SQL statement text passed into
330 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
331 ** </ul>
332 */
333 SQLITE_API int sqlite3_exec(
334 sqlite3*, /* An open database */
335 const char *sql, /* SQL to be evaluated */
336 int (*callback)(void*,int,char**,char**), /* Callback function */
@@ -320,11 +337,11 @@
337 void *, /* 1st argument to callback */
338 char **errmsg /* Error msg written here */
339 );
340
341 /*
342 ** CAPI3REF: Result Codes
343 ** KEYWORDS: SQLITE_OK {error code} {error codes}
344 ** KEYWORDS: {result code} {result codes}
345 **
346 ** Many SQLite functions return an integer result code from the set shown
347 ** here in order to indicates success or failure.
@@ -364,11 +381,11 @@
381 #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
382 #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
383 /* end-of-error-codes */
384
385 /*
386 ** CAPI3REF: Extended Result Codes
387 ** KEYWORDS: {extended error code} {extended error codes}
388 ** KEYWORDS: {extended result code} {extended result codes}
389 **
390 ** In its default configuration, SQLite API routines return one of 26 integer
391 ** [SQLITE_OK | result codes]. However, experience has shown that many of
@@ -406,11 +423,11 @@
423 #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8))
424 #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8))
425 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) )
426
427 /*
428 ** CAPI3REF: Flags For File Open Operations
429 **
430 ** These bit values are intended for use in the
431 ** 3rd parameter to the [sqlite3_open_v2()] interface and
432 ** in the 4th parameter to the xOpen method of the
433 ** [sqlite3_vfs] object.
@@ -431,11 +448,11 @@
448 #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
449 #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */
450 #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */
451
452 /*
453 ** CAPI3REF: Device Characteristics
454 **
455 ** The xDeviceCapabilities method of the [sqlite3_io_methods]
456 ** object returns an integer which is a vector of the these
457 ** bit values expressing I/O characteristics of the mass storage
458 ** device that holds the file that the [sqlite3_io_methods]
@@ -463,11 +480,11 @@
480 #define SQLITE_IOCAP_ATOMIC64K 0x00000100
481 #define SQLITE_IOCAP_SAFE_APPEND 0x00000200
482 #define SQLITE_IOCAP_SEQUENTIAL 0x00000400
483
484 /*
485 ** CAPI3REF: File Locking Levels
486 **
487 ** SQLite uses one of these integer values as the second
488 ** argument to calls it makes to the xLock() and xUnlock() methods
489 ** of an [sqlite3_io_methods] object.
490 */
@@ -476,11 +493,11 @@
493 #define SQLITE_LOCK_RESERVED 2
494 #define SQLITE_LOCK_PENDING 3
495 #define SQLITE_LOCK_EXCLUSIVE 4
496
497 /*
498 ** CAPI3REF: Synchronization Type Flags
499 **
500 ** When SQLite invokes the xSync() method of an
501 ** [sqlite3_io_methods] object it uses a combination of
502 ** these integer values as the second argument.
503 **
@@ -494,11 +511,11 @@
511 #define SQLITE_SYNC_NORMAL 0x00002
512 #define SQLITE_SYNC_FULL 0x00003
513 #define SQLITE_SYNC_DATAONLY 0x00010
514
515 /*
516 ** CAPI3REF: OS Interface Open File Handle
517 **
518 ** An [sqlite3_file] object represents an open file in the
519 ** [sqlite3_vfs | OS interface layer]. Individual OS interface
520 ** implementations will
521 ** want to subclass this object by appending additional fields
@@ -510,11 +527,11 @@
527 struct sqlite3_file {
528 const struct sqlite3_io_methods *pMethods; /* Methods for an open file */
529 };
530
531 /*
532 ** CAPI3REF: OS Interface File Virtual Methods Object
533 **
534 ** Every file opened by the [sqlite3_vfs] xOpen method populates an
535 ** [sqlite3_file] object (or, more commonly, a subclass of the
536 ** [sqlite3_file] object) with a pointer to an instance of this object.
537 ** This object defines the methods used to perform various operations
@@ -615,11 +632,11 @@
632 int (*xDeviceCharacteristics)(sqlite3_file*);
633 /* Additional methods may be added in future releases */
634 };
635
636 /*
637 ** CAPI3REF: Standard File Control Opcodes
638 **
639 ** These integer constants are opcodes for the xFileControl method
640 ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
641 ** interface.
642 **
@@ -635,11 +652,11 @@
652 #define SQLITE_GET_LOCKPROXYFILE 2
653 #define SQLITE_SET_LOCKPROXYFILE 3
654 #define SQLITE_LAST_ERRNO 4
655
656 /*
657 ** CAPI3REF: Mutex Handle
658 **
659 ** The mutex module within SQLite defines [sqlite3_mutex] to be an
660 ** abstract type for a mutex object. The SQLite core never looks
661 ** at the internal representation of an [sqlite3_mutex]. It only
662 ** deals with pointers to the [sqlite3_mutex] object.
@@ -647,11 +664,11 @@
664 ** Mutexes are created using [sqlite3_mutex_alloc()].
665 */
666 typedef struct sqlite3_mutex sqlite3_mutex;
667
668 /*
669 ** CAPI3REF: OS Interface Object
670 **
671 ** An instance of the sqlite3_vfs object defines the interface between
672 ** the SQLite core and the underlying operating system. The "vfs"
673 ** in the name of the object stands for "virtual file system".
674 **
@@ -801,14 +818,14 @@
818 /* New fields may be appended in figure versions. The iVersion
819 ** value will increment whenever this happens. */
820 };
821
822 /*
823 ** CAPI3REF: Flags for the xAccess VFS method
824 **
825 ** These integer constants can be used as the third parameter to
826 ** the xAccess method of an [sqlite3_vfs] object. They determine
827 ** what kind of permissions the xAccess method is looking for.
828 ** With SQLITE_ACCESS_EXISTS, the xAccess method
829 ** simply checks whether the file exists.
830 ** With SQLITE_ACCESS_READWRITE, the xAccess method
831 ** checks whether the file is both readable and writable.
@@ -818,52 +835,52 @@
835 #define SQLITE_ACCESS_EXISTS 0
836 #define SQLITE_ACCESS_READWRITE 1
837 #define SQLITE_ACCESS_READ 2
838
839 /*
840 ** CAPI3REF: Initialize The SQLite Library
841 **
842 ** ^The sqlite3_initialize() routine initializes the
843 ** SQLite library. ^The sqlite3_shutdown() routine
844 ** deallocates any resources that were allocated by sqlite3_initialize().
845 ** These routines are designed to aid in process initialization and
846 ** shutdown on embedded systems. Workstation applications using
847 ** SQLite normally do not need to invoke either of these routines.
848 **
849 ** A call to sqlite3_initialize() is an "effective" call if it is
850 ** the first time sqlite3_initialize() is invoked during the lifetime of
851 ** the process, or if it is the first time sqlite3_initialize() is invoked
852 ** following a call to sqlite3_shutdown(). ^(Only an effective call
853 ** of sqlite3_initialize() does any initialization. All other calls
854 ** are harmless no-ops.)^
855 **
856 ** A call to sqlite3_shutdown() is an "effective" call if it is the first
857 ** call to sqlite3_shutdown() since the last sqlite3_initialize(). ^(Only
858 ** an effective call to sqlite3_shutdown() does any deinitialization.
859 ** All other valid calls to sqlite3_shutdown() are harmless no-ops.)^
860 **
861 ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown()
862 ** is not. The sqlite3_shutdown() interface must only be called from a
863 ** single thread. All open [database connections] must be closed and all
864 ** other SQLite resources must be deallocated prior to invoking
865 ** sqlite3_shutdown().
866 **
867 ** Among other things, ^sqlite3_initialize() will invoke
868 ** sqlite3_os_init(). Similarly, ^sqlite3_shutdown()
869 ** will invoke sqlite3_os_end().
870 **
871 ** ^The sqlite3_initialize() routine returns [SQLITE_OK] on success.
872 ** ^If for some reason, sqlite3_initialize() is unable to initialize
873 ** the library (perhaps it is unable to allocate a needed resource such
874 ** as a mutex) it returns an [error code] other than [SQLITE_OK].
875 **
876 ** ^The sqlite3_initialize() routine is called internally by many other
877 ** SQLite interfaces so that an application usually does not need to
878 ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()]
879 ** calls sqlite3_initialize() so the SQLite library will be automatically
880 ** initialized when [sqlite3_open()] is called if it has not be initialized
881 ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT]
882 ** compile-time option, then the automatic calls to sqlite3_initialize()
883 ** are omitted and the application must call sqlite3_initialize() directly
884 ** prior to using any other SQLite interface. For maximum portability,
885 ** it is recommended that applications always invoke sqlite3_initialize()
886 ** directly prior to using any other SQLite interface. Future releases
@@ -898,11 +915,11 @@
915 SQLITE_API int sqlite3_shutdown(void);
916 SQLITE_API int sqlite3_os_init(void);
917 SQLITE_API int sqlite3_os_end(void);
918
919 /*
920 ** CAPI3REF: Configuring The SQLite Library
921 ** EXPERIMENTAL
922 **
923 ** The sqlite3_config() interface is used to make global configuration
924 ** changes to SQLite in order to tune SQLite to the specific needs of
925 ** the application. The default configuration is recommended for most
@@ -912,39 +929,36 @@
929 ** The sqlite3_config() interface is not threadsafe. The application
930 ** must insure that no other SQLite interfaces are invoked by other
931 ** threads while sqlite3_config() is running. Furthermore, sqlite3_config()
932 ** may only be invoked prior to library initialization using
933 ** [sqlite3_initialize()] or after shutdown by [sqlite3_shutdown()].
934 ** ^If sqlite3_config() is called after [sqlite3_initialize()] and before
935 ** [sqlite3_shutdown()] then it will return SQLITE_MISUSE.
936 ** Note, however, that ^sqlite3_config() can be called as part of the
937 ** implementation of an application-defined [sqlite3_os_init()].
938 **
939 ** The first argument to sqlite3_config() is an integer
940 ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines
941 ** what property of SQLite is to be configured. Subsequent arguments
942 ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option]
943 ** in the first argument.
944 **
945 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
946 ** ^If the option is unknown or SQLite is unable to set the option
947 ** then this routine returns a non-zero [error code].
 
 
 
 
 
948 */
949 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...);
950
951 /*
952 ** CAPI3REF: Configure database connections
953 ** EXPERIMENTAL
954 **
955 ** The sqlite3_db_config() interface is used to make configuration
956 ** changes to a [database connection]. The interface is similar to
957 ** [sqlite3_config()] except that the changes apply to a single
958 ** [database connection] (specified in the first argument). The
959 ** sqlite3_db_config() interface should only be used immediately after
960 ** the database connection is created using [sqlite3_open()],
961 ** [sqlite3_open16()], or [sqlite3_open_v2()].
962 **
963 ** The second argument to sqlite3_db_config(D,V,...) is the
964 ** configuration verb - an integer code that indicates what
@@ -951,17 +965,17 @@
965 ** aspect of the [database connection] is being configured.
966 ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE].
967 ** New verbs are likely to be added in future releases of SQLite.
968 ** Additional arguments depend on the verb.
969 **
970 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
971 ** the call is considered successful.
972 */
973 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...);
974
975 /*
976 ** CAPI3REF: Memory Allocation Routines
977 ** EXPERIMENTAL
978 **
979 ** An instance of this object defines the interface between SQLite
980 ** and low-level memory allocation routines.
981 **
@@ -987,11 +1001,11 @@
1001 ** The xMalloc and xFree methods must work like the
1002 ** malloc() and free() functions from the standard C library.
1003 ** The xRealloc method must work like realloc() from the standard C library
1004 ** with the exception that if the second argument to xRealloc is zero,
1005 ** xRealloc must be a no-op - it must not perform any allocation or
1006 ** deallocation. ^SQLite guarantees that the second argument to
1007 ** xRealloc is always a value returned by a prior call to xRoundup.
1008 ** And so in cases where xRoundup always returns a positive number,
1009 ** xRealloc can perform exactly as the standard library realloc() and
1010 ** still be in compliance with this specification.
1011 **
@@ -1039,11 +1053,11 @@
1053 void (*xShutdown)(void*); /* Deinitialize the memory allocator */
1054 void *pAppData; /* Argument to xInit() and xShutdown() */
1055 };
1056
1057 /*
1058 ** CAPI3REF: Configuration Options
1059 ** EXPERIMENTAL
1060 **
1061 ** These constants are the available integer configuration options that
1062 ** can be passed as the first argument to the [sqlite3_config()] interface.
1063 **
@@ -1054,151 +1068,181 @@
1068 ** non-zero [error code] if a discontinued or unsupported configuration option
1069 ** is invoked.
1070 **
1071 ** <dl>
1072 ** <dt>SQLITE_CONFIG_SINGLETHREAD</dt>
1073 ** <dd>There are no arguments to this option. ^This option sets the
1074 ** [threading mode] to Single-thread. In other words, it disables
1075 ** all mutexing and puts SQLite into a mode where it can only be used
1076 ** by a single thread. ^If SQLite is compiled with
1077 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1078 ** it is not possible to change the [threading mode] from its default
1079 ** value of Single-thread and so [sqlite3_config()] will return
1080 ** [SQLITE_ERROR] if called with the SQLITE_CONFIG_SINGLETHREAD
1081 ** configuration option.</dd>
1082 **
1083 ** <dt>SQLITE_CONFIG_MULTITHREAD</dt>
1084 ** <dd>There are no arguments to this option. ^This option sets the
1085 ** [threading mode] to Multi-thread. In other words, it disables
1086 ** mutexing on [database connection] and [prepared statement] objects.
1087 ** The application is responsible for serializing access to
1088 ** [database connections] and [prepared statements]. But other mutexes
1089 ** are enabled so that SQLite will be safe to use in a multi-threaded
1090 ** environment as long as no two threads attempt to use the same
1091 ** [database connection] at the same time. ^If SQLite is compiled with
1092 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1093 ** it is not possible to set the Multi-thread [threading mode] and
1094 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1095 ** SQLITE_CONFIG_MULTITHREAD configuration option.</dd>
1096 **
1097 ** <dt>SQLITE_CONFIG_SERIALIZED</dt>
1098 ** <dd>There are no arguments to this option. ^This option sets the
1099 ** [threading mode] to Serialized. In other words, this option enables
1100 ** all mutexes including the recursive
1101 ** mutexes on [database connection] and [prepared statement] objects.
1102 ** In this mode (which is the default when SQLite is compiled with
1103 ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access
1104 ** to [database connections] and [prepared statements] so that the
1105 ** application is free to use the same [database connection] or the
1106 ** same [prepared statement] in different threads at the same time.
1107 ** ^If SQLite is compiled with
1108 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1109 ** it is not possible to set the Serialized [threading mode] and
1110 ** [sqlite3_config()] will return [SQLITE_ERROR] if called with the
1111 ** SQLITE_CONFIG_SERIALIZED configuration option.</dd>
1112 **
1113 ** <dt>SQLITE_CONFIG_MALLOC</dt>
1114 ** <dd> ^(This option takes a single argument which is a pointer to an
1115 ** instance of the [sqlite3_mem_methods] structure. The argument specifies
1116 ** alternative low-level memory allocation routines to be used in place of
1117 ** the memory allocation routines built into SQLite.)^ ^SQLite makes
1118 ** its own private copy of the content of the [sqlite3_mem_methods] structure
1119 ** before the [sqlite3_config()] call returns.</dd>
1120 **
1121 ** <dt>SQLITE_CONFIG_GETMALLOC</dt>
1122 ** <dd> ^(This option takes a single argument which is a pointer to an
1123 ** instance of the [sqlite3_mem_methods] structure. The [sqlite3_mem_methods]
1124 ** structure is filled with the currently defined memory allocation routines.)^
1125 ** This option can be used to overload the default memory allocation
1126 ** routines with a wrapper that simulations memory allocation failure or
1127 ** tracks memory usage, for example. </dd>
1128 **
1129 ** <dt>SQLITE_CONFIG_MEMSTATUS</dt>
1130 ** <dd> ^This option takes single argument of type int, interpreted as a
1131 ** boolean, which enables or disables the collection of memory allocation
1132 ** statistics. ^(When memory allocation statistics are disabled, the
1133 ** following SQLite interfaces become non-operational:
1134 ** <ul>
1135 ** <li> [sqlite3_memory_used()]
1136 ** <li> [sqlite3_memory_highwater()]
1137 ** <li> [sqlite3_soft_heap_limit()]
1138 ** <li> [sqlite3_status()]
1139 ** </ul>)^
1140 ** ^Memory allocation statistics are enabled by default unless SQLite is
1141 ** compiled with [SQLITE_DEFAULT_MEMSTATUS]=0 in which case memory
1142 ** allocation statistics are disabled by default.
1143 ** </dd>
1144 **
1145 ** <dt>SQLITE_CONFIG_SCRATCH</dt>
1146 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1147 ** scratch memory. There are three arguments: A pointer an 8-byte
1148 ** aligned memory buffer from which the scrach allocations will be
1149 ** drawn, the size of each scratch allocation (sz),
1150 ** and the maximum number of scratch allocations (N). The sz
1151 ** argument must be a multiple of 16. The sz parameter should be a few bytes
1152 ** larger than the actual scratch space required due to internal overhead.
1153 ** The first argument must be a pointer to an 8-byte aligned buffer
1154 ** of at least sz*N bytes of memory.
1155 ** ^SQLite will use no more than one scratch buffer per thread. So
1156 ** N should be set to the expected maximum number of threads. ^SQLite will
1157 ** never require a scratch buffer that is more than 6 times the database
1158 ** page size. ^If SQLite needs needs additional scratch memory beyond
1159 ** what is provided by this configuration option, then
1160 ** [sqlite3_malloc()] will be used to obtain the memory needed.</dd>
 
1161 **
1162 ** <dt>SQLITE_CONFIG_PAGECACHE</dt>
1163 ** <dd> ^This option specifies a static memory buffer that SQLite can use for
1164 ** the database page cache with the default page cache implemenation.
1165 ** This configuration should not be used if an application-define page
1166 ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option.
1167 ** There are three arguments to this option: A pointer to 8-byte aligned
1168 ** memory, the size of each page buffer (sz), and the number of pages (N).
1169 ** The sz argument should be the size of the largest database page
1170 ** (a power of two between 512 and 32768) plus a little extra for each
1171 ** page header. ^The page header size is 20 to 40 bytes depending on
1172 ** the host architecture. ^It is harmless, apart from the wasted memory,
1173 ** to make sz a little too large. The first
1174 ** argument should point to an allocation of at least sz*N bytes of memory.
1175 ** ^SQLite will use the memory provided by the first argument to satisfy its
1176 ** memory needs for the first N pages that it adds to cache. ^If additional
1177 ** page cache memory is needed beyond what is provided by this option, then
1178 ** SQLite goes to [sqlite3_malloc()] for the additional storage space.
1179 ** ^The implementation might use one or more of the N buffers to hold
1180 ** memory accounting information. The pointer in the first argument must
1181 ** be aligned to an 8-byte boundary or subsequent behavior of SQLite
1182 ** will be undefined.</dd>
1183 **
1184 ** <dt>SQLITE_CONFIG_HEAP</dt>
1185 ** <dd> ^This option specifies a static memory buffer that SQLite will use
1186 ** for all of its dynamic memory allocation needs beyond those provided
1187 ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE].
1188 ** There are three arguments: An 8-byte aligned pointer to the memory,
1189 ** the number of bytes in the memory buffer, and the minimum allocation size.
1190 ** ^If the first pointer (the memory pointer) is NULL, then SQLite reverts
1191 ** to using its default memory allocator (the system malloc() implementation),
1192 ** undoing any prior invocation of [SQLITE_CONFIG_MALLOC]. ^If the
1193 ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or
1194 ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory
1195 ** allocator is engaged to handle all of SQLites memory allocation needs.
1196 ** The first pointer (the memory pointer) must be aligned to an 8-byte
1197 ** boundary or subsequent behavior of SQLite will be undefined.</dd>
1198 **
1199 ** <dt>SQLITE_CONFIG_MUTEX</dt>
1200 ** <dd> ^(This option takes a single argument which is a pointer to an
1201 ** instance of the [sqlite3_mutex_methods] structure. The argument specifies
1202 ** alternative low-level mutex routines to be used in place
1203 ** the mutex routines built into SQLite.)^ ^SQLite makes a copy of the
1204 ** content of the [sqlite3_mutex_methods] structure before the call to
1205 ** [sqlite3_config()] returns. ^If SQLite is compiled with
1206 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1207 ** the entire mutexing subsystem is omitted from the build and hence calls to
1208 ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will
1209 ** return [SQLITE_ERROR].</dd>
1210 **
1211 ** <dt>SQLITE_CONFIG_GETMUTEX</dt>
1212 ** <dd> ^(This option takes a single argument which is a pointer to an
1213 ** instance of the [sqlite3_mutex_methods] structure. The
1214 ** [sqlite3_mutex_methods]
1215 ** structure is filled with the currently defined mutex routines.)^
1216 ** This option can be used to overload the default mutex allocation
1217 ** routines with a wrapper used to track mutex usage for performance
1218 ** profiling or testing, for example. ^If SQLite is compiled with
1219 ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then
1220 ** the entire mutexing subsystem is omitted from the build and hence calls to
1221 ** [sqlite3_config()] with the SQLITE_CONFIG_GETMUTEX configuration option will
1222 ** return [SQLITE_ERROR].</dd>
1223 **
1224 ** <dt>SQLITE_CONFIG_LOOKASIDE</dt>
1225 ** <dd> ^(This option takes two arguments that determine the default
1226 ** memory allocation for the lookaside memory allocator on each
1227 ** [database connection]. The first argument is the
1228 ** size of each lookaside buffer slot and the second is the number of
1229 ** slots allocated to each database connection.)^ ^(This option sets the
1230 ** <i>default</i> lookaside size. The [SQLITE_DBCONFIG_LOOKASIDE]
1231 ** verb to [sqlite3_db_config()] can be used to change the lookaside
1232 ** configuration on individual connections.)^ </dd>
1233 **
1234 ** <dt>SQLITE_CONFIG_PCACHE</dt>
1235 ** <dd> ^(This option takes a single argument which is a pointer to
1236 ** an [sqlite3_pcache_methods] object. This object specifies the interface
1237 ** to a custom page cache implementation.)^ ^SQLite makes a copy of the
1238 ** object and uses it for page cache memory allocations.</dd>
1239 **
1240 ** <dt>SQLITE_CONFIG_GETPCACHE</dt>
1241 ** <dd> ^(This option takes a single argument which is a pointer to an
1242 ** [sqlite3_pcache_methods] object. SQLite copies of the current
1243 ** page cache implementation into that object.)^ </dd>
1244 **
1245 ** </dl>
1246 */
1247 #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */
1248 #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */
@@ -1215,94 +1259,90 @@
1259 #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */
1260 #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */
1261 #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */
1262
1263 /*
1264 ** CAPI3REF: Configuration Options
1265 ** EXPERIMENTAL
1266 **
1267 ** These constants are the available integer configuration options that
1268 ** can be passed as the second argument to the [sqlite3_db_config()] interface.
1269 **
1270 ** New configuration options may be added in future releases of SQLite.
1271 ** Existing configuration options might be discontinued. Applications
1272 ** should check the return code from [sqlite3_db_config()] to make sure that
1273 ** the call worked. ^The [sqlite3_db_config()] interface will return a
1274 ** non-zero [error code] if a discontinued or unsupported configuration option
1275 ** is invoked.
1276 **
1277 ** <dl>
1278 ** <dt>SQLITE_DBCONFIG_LOOKASIDE</dt>
1279 ** <dd> ^This option takes three additional arguments that determine the
1280 ** [lookaside memory allocator] configuration for the [database connection].
1281 ** ^The first argument (the third parameter to [sqlite3_db_config()] is a
1282 ** pointer to an memory buffer to use for lookaside memory.
1283 ** ^The first argument after the SQLITE_DBCONFIG_LOOKASIDE verb
1284 ** may be NULL in which case SQLite will allocate the
1285 ** lookaside buffer itself using [sqlite3_malloc()]. ^The second argument is the
1286 ** size of each lookaside buffer slot. ^The third argument is the number of
1287 ** slots. The size of the buffer in the first argument must be greater than
1288 ** or equal to the product of the second and third arguments. The buffer
1289 ** must be aligned to an 8-byte boundary. ^If the second argument to
1290 ** SQLITE_DBCONFIG_LOOKASIDE is not a multiple of 8, it is internally
1291 ** rounded down to the next smaller
1292 ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd>
1293 **
1294 ** </dl>
1295 */
1296 #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
1297
1298
1299 /*
1300 ** CAPI3REF: Enable Or Disable Extended Result Codes
1301 **
1302 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1303 ** [extended result codes] feature of SQLite. ^The extended result
1304 ** codes are disabled by default for historical compatibility.
 
 
 
1305 */
1306 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1307
1308 /*
1309 ** CAPI3REF: Last Insert Rowid
1310 **
1311 ** ^Each entry in an SQLite table has a unique 64-bit signed
1312 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1313 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
1314 ** names are not also used by explicitly declared columns. ^If
1315 ** the table has a column of type [INTEGER PRIMARY KEY] then that column
1316 ** is another alias for the rowid.
1317 **
1318 ** ^This routine returns the [rowid] of the most recent
1319 ** successful [INSERT] into the database from the [database connection]
1320 ** in the first argument. ^If no successful [INSERT]s
1321 ** have ever occurred on that database connection, zero is returned.
1322 **
1323 ** ^(If an [INSERT] occurs within a trigger, then the [rowid] of the inserted
1324 ** row is returned by this routine as long as the trigger is running.
1325 ** But once the trigger terminates, the value returned by this routine
1326 ** reverts to the last value inserted before the trigger fired.)^
1327 **
1328 ** ^An [INSERT] that fails due to a constraint violation is not a
1329 ** successful [INSERT] and does not change the value returned by this
1330 ** routine. ^Thus INSERT OR FAIL, INSERT OR IGNORE, INSERT OR ROLLBACK,
1331 ** and INSERT OR ABORT make no changes to the return value of this
1332 ** routine when their insertion fails. ^(When INSERT OR REPLACE
1333 ** encounters a constraint violation, it does not fail. The
1334 ** INSERT continues to completion after deleting rows that caused
1335 ** the constraint problem so INSERT OR REPLACE will always change
1336 ** the return value of this interface.)^
1337 **
1338 ** ^For the purposes of this routine, an [INSERT] is considered to
1339 ** be successful even if it is subsequently rolled back.
1340 **
1341 ** This function is accessible to SQL statements via the
1342 ** [last_insert_rowid() SQL function].
1343 **
 
 
 
1344 ** If a separate thread performs a new [INSERT] on the same
1345 ** database connection while the [sqlite3_last_insert_rowid()]
1346 ** function is running and thus changes the last insert [rowid],
1347 ** then the value returned by [sqlite3_last_insert_rowid()] is
1348 ** unpredictable and might not equal either the old or the new
@@ -1309,164 +1349,154 @@
1349 ** last insert [rowid].
1350 */
1351 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1352
1353 /*
1354 ** CAPI3REF: Count The Number Of Rows Modified
1355 **
1356 ** ^This function returns the number of database rows that were changed
1357 ** or inserted or deleted by the most recently completed SQL statement
1358 ** on the [database connection] specified by the first parameter.
1359 ** ^(Only changes that are directly specified by the [INSERT], [UPDATE],
1360 ** or [DELETE] statement are counted. Auxiliary changes caused by
1361 ** triggers or [foreign key actions] are not counted.)^ Use the
1362 ** [sqlite3_total_changes()] function to find the total number of changes
1363 ** including changes caused by triggers and foreign key actions.
1364 **
1365 ** ^Changes to a view that are simulated by an [INSTEAD OF trigger]
1366 ** are not counted. Only real table changes are counted.
1367 **
1368 ** ^(A "row change" is a change to a single row of a single table
1369 ** caused by an INSERT, DELETE, or UPDATE statement. Rows that
1370 ** are changed as side effects of [REPLACE] constraint resolution,
1371 ** rollback, ABORT processing, [DROP TABLE], or by any other
1372 ** mechanisms do not count as direct row changes.)^
1373 **
1374 ** A "trigger context" is a scope of execution that begins and
1375 ** ends with the script of a [CREATE TRIGGER | trigger].
1376 ** Most SQL statements are
1377 ** evaluated outside of any trigger. This is the "top level"
1378 ** trigger context. If a trigger fires from the top level, a
1379 ** new trigger context is entered for the duration of that one
1380 ** trigger. Subtriggers create subcontexts for their duration.
1381 **
1382 ** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does
1383 ** not create a new trigger context.
1384 **
1385 ** ^This function returns the number of direct row changes in the
1386 ** most recent INSERT, UPDATE, or DELETE statement within the same
1387 ** trigger context.
1388 **
1389 ** ^Thus, when called from the top level, this function returns the
1390 ** number of changes in the most recent INSERT, UPDATE, or DELETE
1391 ** that also occurred at the top level. ^(Within the body of a trigger,
1392 ** the sqlite3_changes() interface can be called to find the number of
1393 ** changes in the most recently completed INSERT, UPDATE, or DELETE
1394 ** statement within the body of the same trigger.
1395 ** However, the number returned does not include changes
1396 ** caused by subtriggers since those have their own context.)^
1397 **
1398 ** See also the [sqlite3_total_changes()] interface, the
1399 ** [count_changes pragma], and the [changes() SQL function].
1400 **
 
 
 
1401 ** If a separate thread makes changes on the same database connection
1402 ** while [sqlite3_changes()] is running then the value returned
1403 ** is unpredictable and not meaningful.
1404 */
1405 SQLITE_API int sqlite3_changes(sqlite3*);
1406
1407 /*
1408 ** CAPI3REF: Total Number Of Rows Modified
1409 **
1410 ** ^This function returns the number of row changes caused by [INSERT],
1411 ** [UPDATE] or [DELETE] statements since the [database connection] was opened.
1412 ** ^(The count returned by sqlite3_total_changes() includes all changes
1413 ** from all [CREATE TRIGGER | trigger] contexts and changes made by
1414 ** [foreign key actions]. However,
1415 ** the count does not include changes used to implement [REPLACE] constraints,
1416 ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The
1417 ** count does not include rows of views that fire an [INSTEAD OF trigger],
1418 ** though if the INSTEAD OF trigger makes changes of its own, those changes
1419 ** are counted.)^
1420 ** ^The sqlite3_total_changes() function counts the changes as soon as
1421 ** the statement that makes them is completed (when the statement handle
1422 ** is passed to [sqlite3_reset()] or [sqlite3_finalize()]).
1423 **
1424 ** See also the [sqlite3_changes()] interface, the
1425 ** [count_changes pragma], and the [total_changes() SQL function].
1426 **
 
 
 
1427 ** If a separate thread makes changes on the same database connection
1428 ** while [sqlite3_total_changes()] is running then the value
1429 ** returned is unpredictable and not meaningful.
1430 */
1431 SQLITE_API int sqlite3_total_changes(sqlite3*);
1432
1433 /*
1434 ** CAPI3REF: Interrupt A Long-Running Query
1435 **
1436 ** ^This function causes any pending database operation to abort and
1437 ** return at its earliest opportunity. This routine is typically
1438 ** called in response to a user action such as pressing "Cancel"
1439 ** or Ctrl-C where the user wants a long query operation to halt
1440 ** immediately.
1441 **
1442 ** ^It is safe to call this routine from a thread different from the
1443 ** thread that is currently running the database operation. But it
1444 ** is not safe to call this routine with a [database connection] that
1445 ** is closed or might close before sqlite3_interrupt() returns.
1446 **
1447 ** ^If an SQL operation is very nearly finished at the time when
1448 ** sqlite3_interrupt() is called, then it might not have an opportunity
1449 ** to be interrupted and might continue to completion.
1450 **
1451 ** ^An SQL operation that is interrupted will return [SQLITE_INTERRUPT].
1452 ** ^If the interrupted SQL operation is an INSERT, UPDATE, or DELETE
1453 ** that is inside an explicit transaction, then the entire transaction
1454 ** will be rolled back automatically.
1455 **
1456 ** ^The sqlite3_interrupt(D) call is in effect until all currently running
1457 ** SQL statements on [database connection] D complete. ^Any new SQL statements
1458 ** that are started after the sqlite3_interrupt() call and before the
1459 ** running statements reaches zero are interrupted as if they had been
1460 ** running prior to the sqlite3_interrupt() call. ^New SQL statements
1461 ** that are started after the running statement count reaches zero are
1462 ** not effected by the sqlite3_interrupt().
1463 ** ^A call to sqlite3_interrupt(D) that occurs when there are no running
1464 ** SQL statements is a no-op and has no effect on SQL statements
1465 ** that are started after the sqlite3_interrupt() call returns.
1466 **
 
 
 
1467 ** If the database connection closes while [sqlite3_interrupt()]
1468 ** is running then bad things will likely happen.
1469 */
1470 SQLITE_API void sqlite3_interrupt(sqlite3*);
1471
1472 /*
1473 ** CAPI3REF: Determine If An SQL Statement Is Complete
1474 **
1475 ** These routines are useful during command-line input to determine if the
1476 ** currently entered text seems to form a complete SQL statement or
1477 ** if additional input is needed before sending the text into
1478 ** SQLite for parsing. ^These routines return 1 if the input string
1479 ** appears to be a complete SQL statement. ^A statement is judged to be
1480 ** complete if it ends with a semicolon token and is not a prefix of a
1481 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
1482 ** string literals or quoted identifier names or comments are not
1483 ** independent tokens (they are part of the token in which they are
1484 ** embedded) and thus do not count as a statement terminator. ^Whitespace
1485 ** and comments that follow the final semicolon are ignored.
1486 **
1487 ** ^These routines return 0 if the statement is incomplete. ^If a
1488 ** memory allocation fails, then SQLITE_NOMEM is returned.
1489 **
1490 ** ^These routines do not parse the SQL statements thus
1491 ** will not detect syntactically incorrect SQL.
1492 **
1493 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
1494 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
1495 ** automatically by sqlite3_complete16(). If that initialization fails,
1496 ** then the return value from sqlite3_complete16() will be non-zero
1497 ** regardless of whether or not the input SQL is complete.)^
 
 
1498 **
1499 ** The input to [sqlite3_complete()] must be a zero-terminated
1500 ** UTF-8 string.
1501 **
1502 ** The input to [sqlite3_complete16()] must be a zero-terminated
@@ -1474,31 +1504,31 @@
1504 */
1505 SQLITE_API int sqlite3_complete(const char *sql);
1506 SQLITE_API int sqlite3_complete16(const void *sql);
1507
1508 /*
1509 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
1510 **
1511 ** ^This routine sets a callback function that might be invoked whenever
1512 ** an attempt is made to open a database table that another thread
1513 ** or process has locked.
1514 **
1515 ** ^If the busy callback is NULL, then [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]
1516 ** is returned immediately upon encountering the lock. ^If the busy callback
1517 ** is not NULL, then the callback might be invoked with two arguments.
1518 **
1519 ** ^The first argument to the busy handler is a copy of the void* pointer which
1520 ** is the third argument to sqlite3_busy_handler(). ^The second argument to
1521 ** the busy handler callback is the number of times that the busy handler has
1522 ** been invoked for this locking event. ^If the
1523 ** busy callback returns 0, then no additional attempts are made to
1524 ** access the database and [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED] is returned.
1525 ** ^If the callback returns non-zero, then another attempt
1526 ** is made to open the database for reading and the cycle repeats.
1527 **
1528 ** The presence of a busy handler does not guarantee that it will be invoked
1529 ** when there is lock contention. ^If SQLite determines that invoking the busy
1530 ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY]
1531 ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler.
1532 ** Consider a scenario where one process is holding a read lock that
1533 ** it is trying to promote to a reserved lock and
1534 ** a second process is holding a reserved lock that it is trying
@@ -1508,69 +1538,63 @@
1538 ** invoke the busy handlers, neither will make any progress. Therefore,
1539 ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this
1540 ** will induce the first process to release its read lock and allow
1541 ** the second process to proceed.
1542 **
1543 ** ^The default busy callback is NULL.
1544 **
1545 ** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED]
1546 ** when SQLite is in the middle of a large transaction where all the
1547 ** changes will not fit into the in-memory cache. SQLite will
1548 ** already hold a RESERVED lock on the database file, but it needs
1549 ** to promote this lock to EXCLUSIVE so that it can spill cache
1550 ** pages into the database file without harm to concurrent
1551 ** readers. ^If it is unable to promote the lock, then the in-memory
1552 ** cache will be left in an inconsistent state and so the error
1553 ** code is promoted from the relatively benign [SQLITE_BUSY] to
1554 ** the more severe [SQLITE_IOERR_BLOCKED]. ^This error code promotion
1555 ** forces an automatic rollback of the changes. See the
1556 ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError">
1557 ** CorruptionFollowingBusyError</a> wiki page for a discussion of why
1558 ** this is important.
1559 **
1560 ** ^(There can only be a single busy handler defined for each
1561 ** [database connection]. Setting a new busy handler clears any
1562 ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()]
1563 ** will also set or clear the busy handler.
1564 **
1565 ** The busy callback should not take any actions which modify the
1566 ** database connection that invoked the busy handler. Any such actions
1567 ** result in undefined behavior.
1568 **
 
 
 
1569 ** A busy handler must not close the database connection
1570 ** or [prepared statement] that invoked the busy handler.
1571 */
1572 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
1573
1574 /*
1575 ** CAPI3REF: Set A Busy Timeout
1576 **
1577 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
1578 ** for a specified amount of time when a table is locked. ^The handler
1579 ** will sleep multiple times until at least "ms" milliseconds of sleeping
1580 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
1581 ** the handler returns 0 which causes [sqlite3_step()] to return
1582 ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED].
1583 **
1584 ** ^Calling this routine with an argument less than or equal to zero
1585 ** turns off all busy handlers.
1586 **
1587 ** ^(There can only be a single busy handler for a particular
1588 ** [database connection] any any given moment. If another busy handler
1589 ** was defined (using [sqlite3_busy_handler()]) prior to calling
1590 ** this routine, that other busy handler is cleared.)^
 
 
 
1591 */
1592 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
1593
1594 /*
1595 ** CAPI3REF: Convenience Routines For Running Queries
1596 **
1597 ** Definition: A <b>result table</b> is memory data structure created by the
1598 ** [sqlite3_get_table()] interface. A result table records the
1599 ** complete query results from one or more queries.
1600 **
@@ -1614,31 +1638,29 @@
1638 ** azResult&#91;5] = "28";
1639 ** azResult&#91;6] = "Cindy";
1640 ** azResult&#91;7] = "21";
1641 ** </pre></blockquote>
1642 **
1643 ** ^The sqlite3_get_table() function evaluates one or more
1644 ** semicolon-separated SQL statements in the zero-terminated UTF-8
1645 ** string of its 2nd parameter and returns a result table to the
1646 ** pointer given in its 3rd parameter.
1647 **
1648 ** After the application has finished with the result from sqlite3_get_table(),
1649 ** it should pass the result table pointer to sqlite3_free_table() in order to
1650 ** release the memory that was malloced. Because of the way the
1651 ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling
1652 ** function must not try to call [sqlite3_free()] directly. Only
1653 ** [sqlite3_free_table()] is able to release the memory properly and safely.
1654 **
1655 ** ^(The sqlite3_get_table() interface is implemented as a wrapper around
1656 ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access
1657 ** to any internal data structures of SQLite. It uses only the public
1658 ** interface defined here. As a consequence, errors that occur in the
1659 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
1660 ** reflected in subsequent calls to [sqlite3_errcode()] or
1661 ** [sqlite3_errmsg()].)^
 
 
1662 */
1663 SQLITE_API int sqlite3_get_table(
1664 sqlite3 *db, /* An open database */
1665 const char *zSql, /* SQL to be evaluated */
1666 char ***pazResult, /* Results of the query */
@@ -1647,49 +1669,49 @@
1669 char **pzErrmsg /* Error msg written here */
1670 );
1671 SQLITE_API void sqlite3_free_table(char **result);
1672
1673 /*
1674 ** CAPI3REF: Formatted String Printing Functions
1675 **
1676 ** These routines are work-alikes of the "printf()" family of functions
1677 ** from the standard C library.
1678 **
1679 ** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their
1680 ** results into memory obtained from [sqlite3_malloc()].
1681 ** The strings returned by these two routines should be
1682 ** released by [sqlite3_free()]. ^Both routines return a
1683 ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough
1684 ** memory to hold the resulting string.
1685 **
1686 ** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from
1687 ** the standard C library. The result is written into the
1688 ** buffer supplied as the second parameter whose size is given by
1689 ** the first parameter. Note that the order of the
1690 ** first two parameters is reversed from snprintf().)^ This is an
1691 ** historical accident that cannot be fixed without breaking
1692 ** backwards compatibility. ^(Note also that sqlite3_snprintf()
1693 ** returns a pointer to its buffer instead of the number of
1694 ** characters actually written into the buffer.)^ We admit that
1695 ** the number of characters written would be a more useful return
1696 ** value but we cannot change the implementation of sqlite3_snprintf()
1697 ** now without breaking compatibility.
1698 **
1699 ** ^As long as the buffer size is greater than zero, sqlite3_snprintf()
1700 ** guarantees that the buffer is always zero-terminated. ^The first
1701 ** parameter "n" is the total size of the buffer, including space for
1702 ** the zero terminator. So the longest string that can be completely
1703 ** written will be n-1 characters.
1704 **
1705 ** These routines all implement some additional formatting
1706 ** options that are useful for constructing SQL statements.
1707 ** All of the usual printf() formatting options apply. In addition, there
1708 ** is are "%q", "%Q", and "%z" options.
1709 **
1710 ** ^(The %q option works like %s in that it substitutes a null-terminated
1711 ** string from the argument list. But %q also doubles every '\'' character.
1712 ** %q is designed for use inside a string literal.)^ By doubling each '\''
1713 ** character it escapes that character and allows it to be inserted into
1714 ** the string.
1715 **
1716 ** For example, assume the string variable zText contains text as follows:
1717 **
@@ -1720,14 +1742,14 @@
1742 ** </pre></blockquote>
1743 **
1744 ** This second example is an SQL syntax error. As a general rule you should
1745 ** always use %q instead of %s when inserting text into a string literal.
1746 **
1747 ** ^(The %Q option works like %q except it also adds single quotes around
1748 ** the outside of the total string. Additionally, if the parameter in the
1749 ** argument list is a NULL pointer, %Q substitutes the text "NULL" (without
1750 ** single quotes).)^ So, for example, one could say:
1751 **
1752 ** <blockquote><pre>
1753 ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText);
1754 ** sqlite3_exec(db, zSQL, 0, 0, 0);
1755 ** sqlite3_free(zSQL);
@@ -1734,75 +1756,63 @@
1756 ** </pre></blockquote>
1757 **
1758 ** The code above will render a correct SQL statement in the zSQL
1759 ** variable even if the zText variable is a NULL pointer.
1760 **
1761 ** ^(The "%z" formatting option works like "%s" but with the
1762 ** addition that after the string has been read and copied into
1763 ** the result, [sqlite3_free()] is called on the input string.)^
 
 
 
1764 */
1765 SQLITE_API char *sqlite3_mprintf(const char*,...);
1766 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
1767 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
1768
1769 /*
1770 ** CAPI3REF: Memory Allocation Subsystem
1771 **
1772 ** The SQLite core uses these three routines for all of its own
1773 ** internal memory allocation needs. "Core" in the previous sentence
1774 ** does not include operating-system specific VFS implementation. The
1775 ** Windows VFS uses native malloc() and free() for some operations.
1776 **
1777 ** ^The sqlite3_malloc() routine returns a pointer to a block
1778 ** of memory at least N bytes in length, where N is the parameter.
1779 ** ^If sqlite3_malloc() is unable to obtain sufficient free
1780 ** memory, it returns a NULL pointer. ^If the parameter N to
1781 ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
1782 ** a NULL pointer.
1783 **
1784 ** ^Calling sqlite3_free() with a pointer previously returned
1785 ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
1786 ** that it might be reused. ^The sqlite3_free() routine is
1787 ** a no-op if is called with a NULL pointer. Passing a NULL pointer
1788 ** to sqlite3_free() is harmless. After being freed, memory
1789 ** should neither be read nor written. Even reading previously freed
1790 ** memory might result in a segmentation fault or other severe error.
1791 ** Memory corruption, a segmentation fault, or other severe error
1792 ** might result if sqlite3_free() is called with a non-NULL pointer that
1793 ** was not obtained from sqlite3_malloc() or sqlite3_realloc().
1794 **
1795 ** ^(The sqlite3_realloc() interface attempts to resize a
1796 ** prior memory allocation to be at least N bytes, where N is the
1797 ** second parameter. The memory allocation to be resized is the first
1798 ** parameter.)^ ^ If the first parameter to sqlite3_realloc()
1799 ** is a NULL pointer then its behavior is identical to calling
1800 ** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
1801 ** ^If the second parameter to sqlite3_realloc() is zero or
1802 ** negative then the behavior is exactly the same as calling
1803 ** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
1804 ** ^sqlite3_realloc() returns a pointer to a memory allocation
1805 ** of at least N bytes in size or NULL if sufficient memory is unavailable.
1806 ** ^If M is the size of the prior allocation, then min(N,M) bytes
1807 ** of the prior allocation are copied into the beginning of buffer returned
1808 ** by sqlite3_realloc() and the prior allocation is freed.
1809 ** ^If sqlite3_realloc() returns NULL, then the prior allocation
1810 ** is not freed.
1811 **
1812 ** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
1813 ** is always aligned to at least an 8 byte boundary.
 
 
 
 
 
 
 
 
 
1814 **
1815 ** In SQLite version 3.5.0 and 3.5.1, it was possible to define
1816 ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in
1817 ** implementation of these routines to be omitted. That capability
1818 ** is no longer provided. Only built-in memory allocators can be used.
@@ -1813,14 +1823,10 @@
1823 ** and whatever filename encoding is used by the particular Windows
1824 ** installation. Memory allocation errors are detected, but
1825 ** they are reported back as [SQLITE_CANTOPEN] or
1826 ** [SQLITE_IOERR] rather than [SQLITE_NOMEM].
1827 **
 
 
 
 
1828 ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()]
1829 ** must be either NULL or else pointers obtained from a prior
1830 ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have
1831 ** not yet been released.
1832 **
@@ -1831,85 +1837,95 @@
1837 SQLITE_API void *sqlite3_malloc(int);
1838 SQLITE_API void *sqlite3_realloc(void*, int);
1839 SQLITE_API void sqlite3_free(void*);
1840
1841 /*
1842 ** CAPI3REF: Memory Allocator Statistics
1843 **
1844 ** SQLite provides these two interfaces for reporting on the status
1845 ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()]
1846 ** routines, which form the built-in memory allocation subsystem.
1847 **
1848 ** ^The [sqlite3_memory_used()] routine returns the number of bytes
1849 ** of memory currently outstanding (malloced but not freed).
1850 ** ^The [sqlite3_memory_highwater()] routine returns the maximum
1851 ** value of [sqlite3_memory_used()] since the high-water mark
1852 ** was last reset. ^The values returned by [sqlite3_memory_used()] and
1853 ** [sqlite3_memory_highwater()] include any overhead
1854 ** added by SQLite in its implementation of [sqlite3_malloc()],
1855 ** but not overhead added by the any underlying system library
1856 ** routines that [sqlite3_malloc()] may call.
1857 **
1858 ** ^The memory high-water mark is reset to the current value of
1859 ** [sqlite3_memory_used()] if and only if the parameter to
1860 ** [sqlite3_memory_highwater()] is true. ^The value returned
1861 ** by [sqlite3_memory_highwater(1)] is the high-water mark
1862 ** prior to the reset.
1863 */
1864 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
1865 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
1866
1867 /*
1868 ** CAPI3REF: Pseudo-Random Number Generator
1869 **
1870 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
1871 ** select random [ROWID | ROWIDs] when inserting new records into a table that
1872 ** already uses the largest possible [ROWID]. The PRNG is also used for
1873 ** the build-in random() and randomblob() SQL functions. This interface allows
1874 ** applications to access the same PRNG for other purposes.
1875 **
1876 ** ^A call to this routine stores N bytes of randomness into buffer P.
1877 **
1878 ** ^The first time this routine is invoked (either internally or by
1879 ** the application) the PRNG is seeded using randomness obtained
1880 ** from the xRandomness method of the default [sqlite3_vfs] object.
1881 ** ^On all subsequent invocations, the pseudo-randomness is generated
1882 ** internally and without recourse to the [sqlite3_vfs] xRandomness
1883 ** method.
 
 
 
1884 */
1885 SQLITE_API void sqlite3_randomness(int N, void *P);
1886
1887 /*
1888 ** CAPI3REF: Compile-Time Authorization Callbacks
1889 **
1890 ** ^This routine registers a authorizer callback with a particular
1891 ** [database connection], supplied in the first argument.
1892 ** ^The authorizer callback is invoked as SQL statements are being compiled
1893 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
1894 ** [sqlite3_prepare16()] and [sqlite3_prepare16_v2()]. ^At various
1895 ** points during the compilation process, as logic is being created
1896 ** to perform various actions, the authorizer callback is invoked to
1897 ** see if those actions are allowed. ^The authorizer callback should
1898 ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the
1899 ** specific action but allow the SQL statement to continue to be
1900 ** compiled, or [SQLITE_DENY] to cause the entire SQL statement to be
1901 ** rejected with an error. ^If the authorizer callback returns
1902 ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY]
1903 ** then the [sqlite3_prepare_v2()] or equivalent call that triggered
1904 ** the authorizer will fail with an error message.
1905 **
1906 ** When the callback returns [SQLITE_OK], that means the operation
1907 ** requested is ok. ^When the callback returns [SQLITE_DENY], the
1908 ** [sqlite3_prepare_v2()] or equivalent call that triggered the
1909 ** authorizer will fail with an error message explaining that
1910 ** access is denied.
1911 **
1912 ** ^The first parameter to the authorizer callback is a copy of the third
1913 ** parameter to the sqlite3_set_authorizer() interface. ^The second parameter
1914 ** to the callback is an integer [SQLITE_COPY | action code] that specifies
1915 ** the particular action to be authorized. ^The third through sixth parameters
1916 ** to the callback are zero-terminated strings that contain additional
1917 ** details about the action to be authorized.
1918 **
1919 ** ^If the action code is [SQLITE_READ]
1920 ** and the callback returns [SQLITE_IGNORE] then the
1921 ** [prepared statement] statement is constructed to substitute
1922 ** a NULL value in place of the table column that would have
1923 ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE]
1924 ** return can be used to deny an untrusted user access to individual
1925 ** columns of a table.
1926 ** ^If the action code is [SQLITE_DELETE] and the callback returns
1927 ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the
1928 ** [truncate optimization] is disabled and all rows are deleted individually.
1929 **
1930 ** An authorizer is used when [sqlite3_prepare | preparing]
1931 ** SQL statements from an untrusted source, to ensure that the SQL statements
@@ -1925,43 +1941,39 @@
1941 ** Applications that need to process SQL from untrusted sources
1942 ** might also consider lowering resource limits using [sqlite3_limit()]
1943 ** and limiting database size using the [max_page_count] [PRAGMA]
1944 ** in addition to using an authorizer.
1945 **
1946 ** ^(Only a single authorizer can be in place on a database connection
1947 ** at a time. Each call to sqlite3_set_authorizer overrides the
1948 ** previous call.)^ ^Disable the authorizer by installing a NULL callback.
1949 ** The authorizer is disabled by default.
1950 **
1951 ** The authorizer callback must not do anything that will modify
1952 ** the database connection that invoked the authorizer callback.
1953 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
1954 ** database connections for the meaning of "modify" in this paragraph.
1955 **
1956 ** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the
1957 ** statement might be re-prepared during [sqlite3_step()] due to a
1958 ** schema change. Hence, the application should ensure that the
1959 ** correct authorizer callback remains in place during the [sqlite3_step()].
1960 **
1961 ** ^Note that the authorizer callback is invoked only during
1962 ** [sqlite3_prepare()] or its variants. Authorization is not
1963 ** performed during statement evaluation in [sqlite3_step()], unless
1964 ** as stated in the previous paragraph, sqlite3_step() invokes
1965 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
 
 
 
 
1966 */
1967 SQLITE_API int sqlite3_set_authorizer(
1968 sqlite3*,
1969 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
1970 void *pUserData
1971 );
1972
1973 /*
1974 ** CAPI3REF: Authorizer Return Codes
1975 **
1976 ** The [sqlite3_set_authorizer | authorizer callback function] must
1977 ** return either [SQLITE_OK] or one of these two constants in order
1978 ** to signal SQLite whether or not the action is permitted. See the
1979 ** [sqlite3_set_authorizer | authorizer documentation] for additional
@@ -1969,11 +1981,11 @@
1981 */
1982 #define SQLITE_DENY 1 /* Abort the SQL statement with an error */
1983 #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */
1984
1985 /*
1986 ** CAPI3REF: Authorizer Action Codes
1987 **
1988 ** The [sqlite3_set_authorizer()] interface registers a callback function
1989 ** that is invoked to authorize certain SQL statement actions. The
1990 ** second parameter to the callback is an integer code that specifies
1991 ** what action is being authorized. These are the integer action codes that
@@ -1980,19 +1992,16 @@
1992 ** the authorizer callback may be passed.
1993 **
1994 ** These action code values signify what kind of operation is to be
1995 ** authorized. The 3rd and 4th parameters to the authorization
1996 ** callback function will be parameters or NULL depending on which of these
1997 ** codes is used as the second parameter. ^(The 5th parameter to the
1998 ** authorizer callback is the name of the database ("main", "temp",
1999 ** etc.) if applicable.)^ ^The 6th parameter to the authorizer callback
2000 ** is the name of the inner-most trigger or view that is responsible for
2001 ** the access attempt or NULL if this access attempt is directly from
2002 ** top-level SQL code.
 
 
 
2003 */
2004 /******************************************* 3rd ************ 4th ***********/
2005 #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */
2006 #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */
2007 #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */
@@ -2026,150 +2035,142 @@
2035 #define SQLITE_FUNCTION 31 /* NULL Function Name */
2036 #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */
2037 #define SQLITE_COPY 0 /* No longer used */
2038
2039 /*
2040 ** CAPI3REF: Tracing And Profiling Functions
2041 ** EXPERIMENTAL
2042 **
2043 ** These routines register callback functions that can be used for
2044 ** tracing and profiling the execution of SQL statements.
2045 **
2046 ** ^The callback function registered by sqlite3_trace() is invoked at
2047 ** various times when an SQL statement is being run by [sqlite3_step()].
2048 ** ^The sqlite3_trace() callback is invoked with a UTF-8 rendering of the
2049 ** SQL statement text as the statement first begins executing.
2050 ** ^(Additional sqlite3_trace() callbacks might occur
2051 ** as each triggered subprogram is entered. The callbacks for triggers
2052 ** contain a UTF-8 SQL comment that identifies the trigger.)^
2053 **
2054 ** ^The callback function registered by sqlite3_profile() is invoked
2055 ** as each SQL statement finishes. ^The profile callback contains
2056 ** the original statement text and an estimate of wall-clock time
2057 ** of how long that statement took to run.
 
 
 
 
2058 */
2059 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2060 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2061 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2062
2063 /*
2064 ** CAPI3REF: Query Progress Callbacks
2065 **
2066 ** ^This routine configures a callback function - the
2067 ** progress callback - that is invoked periodically during long
2068 ** running calls to [sqlite3_exec()], [sqlite3_step()] and
2069 ** [sqlite3_get_table()]. An example use for this
2070 ** interface is to keep a GUI updated during a large query.
2071 **
2072 ** ^If the progress callback returns non-zero, the operation is
2073 ** interrupted. This feature can be used to implement a
2074 ** "Cancel" button on a GUI progress dialog box.
2075 **
2076 ** The progress handler must not do anything that will modify
2077 ** the database connection that invoked the progress handler.
2078 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2079 ** database connections for the meaning of "modify" in this paragraph.
2080 **
 
 
 
2081 */
2082 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2083
2084 /*
2085 ** CAPI3REF: Opening A New Database Connection
2086 **
2087 ** ^These routines open an SQLite database file whose name is given by the
2088 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2089 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2090 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
2091 ** returned in *ppDb, even if an error occurs. The only exception is that
2092 ** if SQLite is unable to allocate memory to hold the [sqlite3] object,
2093 ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3]
2094 ** object.)^ ^(If the database is opened (and/or created) successfully, then
2095 ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The
2096 ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain
2097 ** an English language description of the error following a failure of any
2098 ** of the sqlite3_open() routines.
2099 **
2100 ** ^The default encoding for the database will be UTF-8 if
2101 ** sqlite3_open() or sqlite3_open_v2() is called and
2102 ** UTF-16 in the native byte order if sqlite3_open16() is used.
2103 **
2104 ** Whether or not an error occurs when it is opened, resources
2105 ** associated with the [database connection] handle should be released by
2106 ** passing it to [sqlite3_close()] when it is no longer required.
2107 **
2108 ** The sqlite3_open_v2() interface works like sqlite3_open()
2109 ** except that it accepts two additional parameters for additional control
2110 ** over the new database connection. ^(The flags parameter to
2111 ** sqlite3_open_v2() can take one of
2112 ** the following three values, optionally combined with the
2113 ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE],
2114 ** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^
2115 **
2116 ** <dl>
2117 ** ^(<dt>[SQLITE_OPEN_READONLY]</dt>
2118 ** <dd>The database is opened in read-only mode. If the database does not
2119 ** already exist, an error is returned.</dd>)^
2120 **
2121 ** ^(<dt>[SQLITE_OPEN_READWRITE]</dt>
2122 ** <dd>The database is opened for reading and writing if possible, or reading
2123 ** only if the file is write protected by the operating system. In either
2124 ** case the database must already exist, otherwise an error is returned.</dd>)^
2125 **
2126 ** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt>
2127 ** <dd>The database is opened for reading and writing, and is creates it if
2128 ** it does not already exist. This is the behavior that is always used for
2129 ** sqlite3_open() and sqlite3_open16().</dd>)^
2130 ** </dl>
2131 **
2132 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
2133 ** combinations shown above or one of the combinations shown above combined
2134 ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX],
2135 ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags,
2136 ** then the behavior is undefined.
2137 **
2138 ** ^If the [SQLITE_OPEN_NOMUTEX] flag is set, then the database connection
2139 ** opens in the multi-thread [threading mode] as long as the single-thread
2140 ** mode has not been set at compile-time or start-time. ^If the
2141 ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens
2142 ** in the serialized [threading mode] unless single-thread was
2143 ** previously selected at compile-time or start-time.
2144 ** ^The [SQLITE_OPEN_SHAREDCACHE] flag causes the database connection to be
2145 ** eligible to use [shared cache mode], regardless of whether or not shared
2146 ** cache is enabled using [sqlite3_enable_shared_cache()]. ^The
2147 ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not
2148 ** participate in [shared cache mode] even if it is enabled.
2149 **
2150 ** ^If the filename is ":memory:", then a private, temporary in-memory database
2151 ** is created for the connection. ^This in-memory database will vanish when
2152 ** the database connection is closed. Future versions of SQLite might
2153 ** make use of additional special filenames that begin with the ":" character.
2154 ** It is recommended that when a database filename actually does begin with
2155 ** a ":" character you should prefix the filename with a pathname such as
2156 ** "./" to avoid ambiguity.
2157 **
2158 ** ^If the filename is an empty string, then a private, temporary
2159 ** on-disk database will be created. ^This private database will be
2160 ** automatically deleted as soon as the database connection is closed.
2161 **
2162 ** ^The fourth parameter to sqlite3_open_v2() is the name of the
2163 ** [sqlite3_vfs] object that defines the operating system interface that
2164 ** the new database connection should use. ^If the fourth parameter is
2165 ** a NULL pointer then the default [sqlite3_vfs] object is used.
2166 **
2167 ** <b>Note to Windows users:</b> The encoding used for the filename argument
2168 ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever
2169 ** codepage is currently defined. Filenames containing international
2170 ** characters must be converted to UTF-8 prior to passing them into
2171 ** sqlite3_open() or sqlite3_open_v2().
 
 
 
 
2172 */
2173 SQLITE_API int sqlite3_open(
2174 const char *filename, /* Database filename (UTF-8) */
2175 sqlite3 **ppDb /* OUT: SQLite db handle */
2176 );
@@ -2183,27 +2184,27 @@
2184 int flags, /* Flags */
2185 const char *zVfs /* Name of VFS module to use */
2186 );
2187
2188 /*
2189 ** CAPI3REF: Error Codes And Messages
2190 **
2191 ** ^The sqlite3_errcode() interface returns the numeric [result code] or
2192 ** [extended result code] for the most recent failed sqlite3_* API call
2193 ** associated with a [database connection]. If a prior API call failed
2194 ** but the most recent API call succeeded, the return value from
2195 ** sqlite3_errcode() is undefined. ^The sqlite3_extended_errcode()
2196 ** interface is the same except that it always returns the
2197 ** [extended result code] even when extended result codes are
2198 ** disabled.
2199 **
2200 ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
2201 ** text that describes the error, as either UTF-8 or UTF-16 respectively.
2202 ** ^(Memory to hold the error message string is managed internally.
2203 ** The application does not need to worry about freeing the result.
2204 ** However, the error string might be overwritten or deallocated by
2205 ** subsequent calls to other SQLite interface functions.)^
2206 **
2207 ** When the serialized [threading mode] is in use, it might be the
2208 ** case that a second error occurs on a separate thread in between
2209 ** the time of the first error and the call to these interfaces.
2210 ** When that happens, the second error will be reported since these
@@ -2214,21 +2215,18 @@
2215 ** all calls to the interfaces listed here are completed.
2216 **
2217 ** If an interface fails with SQLITE_MISUSE, that means the interface
2218 ** was invoked incorrectly by the application. In that case, the
2219 ** error code and message may or may not be set.
 
 
 
2220 */
2221 SQLITE_API int sqlite3_errcode(sqlite3 *db);
2222 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
2223 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
2224 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
2225
2226 /*
2227 ** CAPI3REF: SQL Statement Object
2228 ** KEYWORDS: {prepared statement} {prepared statements}
2229 **
2230 ** An instance of this object represents a single SQL statement.
2231 ** This object is variously known as a "prepared statement" or a
2232 ** "compiled SQL statement" or simply as a "statement".
@@ -2250,29 +2248,29 @@
2248 ** information.
2249 */
2250 typedef struct sqlite3_stmt sqlite3_stmt;
2251
2252 /*
2253 ** CAPI3REF: Run-time Limits
2254 **
2255 ** ^(This interface allows the size of various constructs to be limited
2256 ** on a connection by connection basis. The first parameter is the
2257 ** [database connection] whose limit is to be set or queried. The
2258 ** second parameter is one of the [limit categories] that define a
2259 ** class of constructs to be size limited. The third parameter is the
2260 ** new limit for that construct. The function returns the old limit.)^
2261 **
2262 ** ^If the new limit is a negative number, the limit is unchanged.
2263 ** ^(For the limit category of SQLITE_LIMIT_XYZ there is a
2264 ** [limits | hard upper bound]
2265 ** set by a compile-time C preprocessor macro named
2266 ** [limits | SQLITE_MAX_XYZ].
2267 ** (The "_LIMIT_" in the name is changed to "_MAX_".))^
2268 ** ^Attempts to increase a limit above its hard upper bound are
2269 ** silently truncated to the hard upper bound.
2270 **
2271 ** Run-time limits are intended for use in applications that manage
2272 ** both their own internal database and also databases that are controlled
2273 ** by untrusted external sources. An example application might be a
2274 ** web browser that has its own databases for storing history and
2275 ** separate databases controlled by JavaScript applications downloaded
2276 ** off the Internet. The internal databases can be given the
@@ -2282,63 +2280,60 @@
2280 ** interface to further control untrusted SQL. The size of the database
2281 ** created by an untrusted script can be contained using the
2282 ** [max_page_count] [PRAGMA].
2283 **
2284 ** New run-time limit categories may be added in future releases.
 
 
 
2285 */
2286 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
2287
2288 /*
2289 ** CAPI3REF: Run-Time Limit Categories
2290 ** KEYWORDS: {limit category} {*limit categories}
2291 **
2292 ** These constants define various performance limits
2293 ** that can be lowered at run-time using [sqlite3_limit()].
2294 ** The synopsis of the meanings of the various limits is shown below.
2295 ** Additional information is available at [limits | Limits in SQLite].
2296 **
2297 ** <dl>
2298 ** ^(<dt>SQLITE_LIMIT_LENGTH</dt>
2299 ** <dd>The maximum size of any string or BLOB or table row.<dd>)^
2300 **
2301 ** ^(<dt>SQLITE_LIMIT_SQL_LENGTH</dt>
2302 ** <dd>The maximum length of an SQL statement, in bytes.</dd>)^
2303 **
2304 ** ^(<dt>SQLITE_LIMIT_COLUMN</dt>
2305 ** <dd>The maximum number of columns in a table definition or in the
2306 ** result set of a [SELECT] or the maximum number of columns in an index
2307 ** or in an ORDER BY or GROUP BY clause.</dd>)^
2308 **
2309 ** ^(<dt>SQLITE_LIMIT_EXPR_DEPTH</dt>
2310 ** <dd>The maximum depth of the parse tree on any expression.</dd>)^
2311 **
2312 ** ^(<dt>SQLITE_LIMIT_COMPOUND_SELECT</dt>
2313 ** <dd>The maximum number of terms in a compound SELECT statement.</dd>)^
2314 **
2315 ** ^(<dt>SQLITE_LIMIT_VDBE_OP</dt>
2316 ** <dd>The maximum number of instructions in a virtual machine program
2317 ** used to implement an SQL statement.</dd>)^
2318 **
2319 ** ^(<dt>SQLITE_LIMIT_FUNCTION_ARG</dt>
2320 ** <dd>The maximum number of arguments on a function.</dd>)^
2321 **
2322 ** ^(<dt>SQLITE_LIMIT_ATTACHED</dt>
2323 ** <dd>The maximum number of [ATTACH | attached databases].)^</dd>
2324 **
2325 ** ^(<dt>SQLITE_LIMIT_LIKE_PATTERN_LENGTH</dt>
2326 ** <dd>The maximum length of the pattern argument to the [LIKE] or
2327 ** [GLOB] operators.</dd>)^
2328 **
2329 ** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
2330 ** <dd>The maximum number of variables in an SQL statement that can
2331 ** be bound.</dd>)^
2332 **
2333 ** ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
2334 ** <dd>The maximum depth of recursion for triggers.</dd>)^
2335 ** </dl>
2336 */
2337 #define SQLITE_LIMIT_LENGTH 0
2338 #define SQLITE_LIMIT_SQL_LENGTH 1
2339 #define SQLITE_LIMIT_COLUMN 2
@@ -2350,11 +2345,11 @@
2345 #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
2346 #define SQLITE_LIMIT_VARIABLE_NUMBER 9
2347 #define SQLITE_LIMIT_TRIGGER_DEPTH 10
2348
2349 /*
2350 ** CAPI3REF: Compiling An SQL Statement
2351 ** KEYWORDS: {SQL statement compiler}
2352 **
2353 ** To execute an SQL query, it must first be compiled into a byte-code
2354 ** program using one of these routines.
2355 **
@@ -2365,61 +2360,62 @@
2360 ** The second argument, "zSql", is the statement to be compiled, encoded
2361 ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2()
2362 ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2()
2363 ** use UTF-16.
2364 **
2365 ** ^If the nByte argument is less than zero, then zSql is read up to the
2366 ** first zero terminator. ^If nByte is non-negative, then it is the maximum
2367 ** number of bytes read from zSql. ^When nByte is non-negative, the
2368 ** zSql string ends at either the first '\000' or '\u0000' character or
2369 ** the nByte-th byte, whichever comes first. If the caller knows
2370 ** that the supplied string is nul-terminated, then there is a small
2371 ** performance advantage to be gained by passing an nByte parameter that
2372 ** is equal to the number of bytes in the input string <i>including</i>
2373 ** the nul-terminator bytes.
2374 **
2375 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
2376 ** past the end of the first SQL statement in zSql. These routines only
2377 ** compile the first statement in zSql, so *pzTail is left pointing to
2378 ** what remains uncompiled.
2379 **
2380 ** ^*ppStmt is left pointing to a compiled [prepared statement] that can be
2381 ** executed using [sqlite3_step()]. ^If there is an error, *ppStmt is set
2382 ** to NULL. ^If the input text contains no SQL (if the input is an empty
2383 ** string or a comment) then *ppStmt is set to NULL.
2384 ** The calling procedure is responsible for deleting the compiled
2385 ** SQL statement using [sqlite3_finalize()] after it has finished with it.
2386 ** ppStmt may not be NULL.
2387 **
2388 ** ^On success, the sqlite3_prepare() family of routines return [SQLITE_OK];
2389 ** otherwise an [error code] is returned.
2390 **
2391 ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are
2392 ** recommended for all new programs. The two older interfaces are retained
2393 ** for backwards compatibility, but their use is discouraged.
2394 ** ^In the "v2" interfaces, the prepared statement
2395 ** that is returned (the [sqlite3_stmt] object) contains a copy of the
2396 ** original SQL text. This causes the [sqlite3_step()] interface to
2397 ** behave differently in three ways:
2398 **
2399 ** <ol>
2400 ** <li>
2401 ** ^If the database schema changes, instead of returning [SQLITE_SCHEMA] as it
2402 ** always used to do, [sqlite3_step()] will automatically recompile the SQL
2403 ** statement and try to run it again. ^If the schema has changed in
2404 ** a way that makes the statement no longer valid, [sqlite3_step()] will still
2405 ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is
2406 ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the
2407 ** error go away. Note: use [sqlite3_errmsg()] to find the text
2408 ** of the parsing error that results in an [SQLITE_SCHEMA] return.
2409 ** </li>
2410 **
2411 ** <li>
2412 ** ^When an error occurs, [sqlite3_step()] will return one of the detailed
2413 ** [error codes] or [extended error codes]. ^The legacy behavior was that
2414 ** [sqlite3_step()] would only return a generic [SQLITE_ERROR] result code
2415 ** and the application would have to make a second call to [sqlite3_reset()]
2416 ** in order to find the underlying cause of the problem. With the "v2" prepare
2417 ** interfaces, the underlying reason for the error is returned immediately.
2418 ** </li>
2419 **
2420 ** <li>
2421 ** ^If the value of a [parameter | host parameter] in the WHERE clause might
@@ -2427,14 +2423,10 @@
2423 ** automatically recompiled (as if there had been a schema change) on the first
2424 ** [sqlite3_step()] call following any change to the
2425 ** [sqlite3_bind_text | bindings] of the [parameter].
2426 ** </li>
2427 ** </ol>
 
 
 
 
2428 */
2429 SQLITE_API int sqlite3_prepare(
2430 sqlite3 *db, /* Database handle */
2431 const char *zSql, /* SQL statement, UTF-8 encoded */
2432 int nByte, /* Maximum length of zSql in bytes. */
@@ -2462,28 +2454,25 @@
2454 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
2455 const void **pzTail /* OUT: Pointer to unused portion of zSql */
2456 );
2457
2458 /*
2459 ** CAPI3REF: Retrieving Statement SQL
2460 **
2461 ** ^This interface can be used to retrieve a saved copy of the original
2462 ** SQL text used to create a [prepared statement] if that statement was
2463 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
 
 
 
2464 */
2465 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
2466
2467 /*
2468 ** CAPI3REF: Dynamically Typed Value Object
2469 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
2470 **
2471 ** SQLite uses the sqlite3_value object to represent all values
2472 ** that can be stored in a database table. SQLite uses dynamic typing
2473 ** for the values it stores. ^Values stored in sqlite3_value objects
2474 ** can be integers, floating point values, strings, BLOBs, or NULL.
2475 **
2476 ** An sqlite3_value object may be either "protected" or "unprotected".
2477 ** Some interfaces require a protected sqlite3_value. Other interfaces
2478 ** will accept either a protected or an unprotected sqlite3_value.
@@ -2501,26 +2490,26 @@
2490 ** sqlite3_value objects and they can be used interchangeably. However,
2491 ** for maximum code portability it is recommended that applications
2492 ** still make the distinction between between protected and unprotected
2493 ** sqlite3_value objects even when not strictly required.
2494 **
2495 ** ^The sqlite3_value objects that are passed as parameters into the
2496 ** implementation of [application-defined SQL functions] are protected.
2497 ** ^The sqlite3_value object returned by
2498 ** [sqlite3_column_value()] is unprotected.
2499 ** Unprotected sqlite3_value objects may only be used with
2500 ** [sqlite3_result_value()] and [sqlite3_bind_value()].
2501 ** The [sqlite3_value_blob | sqlite3_value_type()] family of
2502 ** interfaces require protected sqlite3_value objects.
2503 */
2504 typedef struct Mem sqlite3_value;
2505
2506 /*
2507 ** CAPI3REF: SQL Function Context Object
2508 **
2509 ** The context in which an SQL function executes is stored in an
2510 ** sqlite3_context object. ^A pointer to an sqlite3_context object
2511 ** is always first parameter to [application-defined SQL functions].
2512 ** The application-defined SQL function implementation will pass this
2513 ** pointer through into calls to [sqlite3_result_int | sqlite3_result()],
2514 ** [sqlite3_aggregate_context()], [sqlite3_user_data()],
2515 ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()],
@@ -2527,15 +2516,15 @@
2516 ** and/or [sqlite3_set_auxdata()].
2517 */
2518 typedef struct sqlite3_context sqlite3_context;
2519
2520 /*
2521 ** CAPI3REF: Binding Values To Prepared Statements
2522 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
2523 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
2524 **
2525 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
2526 ** literals may be replaced by a [parameter] that matches one of following
2527 ** templates:
2528 **
2529 ** <ul>
2530 ** <li> ?
@@ -2544,76 +2533,70 @@
2533 ** <li> @VVV
2534 ** <li> $VVV
2535 ** </ul>
2536 **
2537 ** In the templates above, NNN represents an integer literal,
2538 ** and VVV represents an alphanumeric identifer.)^ ^The values of these
2539 ** parameters (also called "host parameter names" or "SQL parameters")
2540 ** can be set using the sqlite3_bind_*() routines defined here.
2541 **
2542 ** ^The first argument to the sqlite3_bind_*() routines is always
2543 ** a pointer to the [sqlite3_stmt] object returned from
2544 ** [sqlite3_prepare_v2()] or its variants.
2545 **
2546 ** ^The second argument is the index of the SQL parameter to be set.
2547 ** ^The leftmost SQL parameter has an index of 1. ^When the same named
2548 ** SQL parameter is used more than once, second and subsequent
2549 ** occurrences have the same index as the first occurrence.
2550 ** ^The index for named parameters can be looked up using the
2551 ** [sqlite3_bind_parameter_index()] API if desired. ^The index
2552 ** for "?NNN" parameters is the value of NNN.
2553 ** ^The NNN value must be between 1 and the [sqlite3_limit()]
2554 ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999).
2555 **
2556 ** ^The third argument is the value to bind to the parameter.
2557 **
2558 ** ^(In those routines that have a fourth argument, its value is the
2559 ** number of bytes in the parameter. To be clear: the value is the
2560 ** number of <u>bytes</u> in the value, not the number of characters.)^
2561 ** ^If the fourth parameter is negative, the length of the string is
2562 ** the number of bytes up to the first zero terminator.
2563 **
2564 ** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
2565 ** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
2566 ** string after SQLite has finished with it. ^If the fifth argument is
2567 ** the special value [SQLITE_STATIC], then SQLite assumes that the
2568 ** information is in static, unmanaged space and does not need to be freed.
2569 ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then
2570 ** SQLite makes its own private copy of the data immediately, before
2571 ** the sqlite3_bind_*() routine returns.
2572 **
2573 ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
2574 ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
2575 ** (just an integer to hold its size) while it is being processed.
2576 ** Zeroblobs are intended to serve as placeholders for BLOBs whose
2577 ** content is later written using
2578 ** [sqlite3_blob_open | incremental BLOB I/O] routines.
2579 ** ^A negative value for the zeroblob results in a zero-length BLOB.
2580 **
2581 ** ^If any of the sqlite3_bind_*() routines are called with a NULL pointer
2582 ** for the [prepared statement] or with a prepared statement for which
2583 ** [sqlite3_step()] has been called more recently than [sqlite3_reset()],
2584 ** then the call will return [SQLITE_MISUSE]. If any sqlite3_bind_()
2585 ** routine is passed a [prepared statement] that has been finalized, the
2586 ** result is undefined and probably harmful.
2587 **
2588 ** ^Bindings are not cleared by the [sqlite3_reset()] routine.
2589 ** ^Unbound parameters are interpreted as NULL.
2590 **
2591 ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
2592 ** [error code] if anything goes wrong.
2593 ** ^[SQLITE_RANGE] is returned if the parameter
2594 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
 
2595 **
2596 ** See also: [sqlite3_bind_parameter_count()],
2597 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
 
 
 
 
 
2598 */
2599 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
2600 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
2601 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
2602 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
@@ -2622,175 +2605,155 @@
2605 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
2606 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
2607 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
2608
2609 /*
2610 ** CAPI3REF: Number Of SQL Parameters
2611 **
2612 ** ^This routine can be used to find the number of [SQL parameters]
2613 ** in a [prepared statement]. SQL parameters are tokens of the
2614 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
2615 ** placeholders for values that are [sqlite3_bind_blob | bound]
2616 ** to the parameters at a later time.
2617 **
2618 ** ^(This routine actually returns the index of the largest (rightmost)
2619 ** parameter. For all forms except ?NNN, this will correspond to the
2620 ** number of unique parameters. If parameters of the ?NNN form are used,
2621 ** there may be gaps in the list.)^
2622 **
2623 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2624 ** [sqlite3_bind_parameter_name()], and
2625 ** [sqlite3_bind_parameter_index()].
 
 
 
2626 */
2627 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
2628
2629 /*
2630 ** CAPI3REF: Name Of A Host Parameter
2631 **
2632 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
2633 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
2634 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
2635 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
2636 ** respectively.
2637 ** In other words, the initial ":" or "$" or "@" or "?"
2638 ** is included as part of the name.)^
2639 ** ^Parameters of the form "?" without a following integer have no name
2640 ** and are referred to as "nameless" or "anonymous parameters".
2641 **
2642 ** ^The first host parameter has an index of 1, not 0.
2643 **
2644 ** ^If the value N is out of range or if the N-th parameter is
2645 ** nameless, then NULL is returned. ^The returned string is
2646 ** always in UTF-8 encoding even if the named parameter was
2647 ** originally specified as UTF-16 in [sqlite3_prepare16()] or
2648 ** [sqlite3_prepare16_v2()].
2649 **
2650 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2651 ** [sqlite3_bind_parameter_count()], and
2652 ** [sqlite3_bind_parameter_index()].
 
 
 
2653 */
2654 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
2655
2656 /*
2657 ** CAPI3REF: Index Of A Parameter With A Given Name
2658 **
2659 ** ^Return the index of an SQL parameter given its name. ^The
2660 ** index value returned is suitable for use as the second
2661 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
2662 ** is returned if no matching parameter is found. ^The parameter
2663 ** name must be given in UTF-8 even if the original statement
2664 ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()].
2665 **
2666 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
2667 ** [sqlite3_bind_parameter_count()], and
2668 ** [sqlite3_bind_parameter_index()].
 
 
 
2669 */
2670 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
2671
2672 /*
2673 ** CAPI3REF: Reset All Bindings On A Prepared Statement
2674 **
2675 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
2676 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
2677 ** ^Use this routine to reset all host parameters to NULL.
 
 
 
2678 */
2679 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
2680
2681 /*
2682 ** CAPI3REF: Number Of Columns In A Result Set
2683 **
2684 ** ^Return the number of columns in the result set returned by the
2685 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
2686 ** statement that does not return data (for example an [UPDATE]).
 
 
 
2687 */
2688 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
2689
2690 /*
2691 ** CAPI3REF: Column Names In A Result Set
2692 **
2693 ** ^These routines return the name assigned to a particular column
2694 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
2695 ** interface returns a pointer to a zero-terminated UTF-8 string
2696 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
2697 ** UTF-16 string. ^The first parameter is the [prepared statement]
2698 ** that implements the [SELECT] statement. ^The second parameter is the
2699 ** column number. ^The leftmost column is number 0.
2700 **
2701 ** ^The returned string pointer is valid until either the [prepared statement]
2702 ** is destroyed by [sqlite3_finalize()] or until the next call to
2703 ** sqlite3_column_name() or sqlite3_column_name16() on the same column.
2704 **
2705 ** ^If sqlite3_malloc() fails during the processing of either routine
2706 ** (for example during a conversion from UTF-8 to UTF-16) then a
2707 ** NULL pointer is returned.
2708 **
2709 ** ^The name of a result column is the value of the "AS" clause for
2710 ** that column, if there is an AS clause. If there is no AS clause
2711 ** then the name of the column is unspecified and may change from
2712 ** one release of SQLite to the next.
 
 
 
2713 */
2714 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
2715 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
2716
2717 /*
2718 ** CAPI3REF: Source Of Data In A Query Result
2719 **
2720 ** ^These routines provide a means to determine the database, table, and
2721 ** table column that is the origin of a particular result column in
2722 ** [SELECT] statement.
2723 ** ^The name of the database or table or column can be returned as
2724 ** either a UTF-8 or UTF-16 string. ^The _database_ routines return
2725 ** the database name, the _table_ routines return the table name, and
2726 ** the origin_ routines return the column name.
2727 ** ^The returned string is valid until the [prepared statement] is destroyed
2728 ** using [sqlite3_finalize()] or until the same information is requested
2729 ** again in a different encoding.
2730 **
2731 ** ^The names returned are the original un-aliased names of the
2732 ** database, table, and column.
2733 **
2734 ** ^The first argument to these interfaces is a [prepared statement].
2735 ** ^These functions return information about the Nth result column returned by
2736 ** the statement, where N is the second function argument.
2737 ** ^The left-most column is column 0 for these routines.
2738 **
2739 ** ^If the Nth column returned by the statement is an expression or
2740 ** subquery and is not a column value, then all of these functions return
2741 ** NULL. ^These routine might also return NULL if a memory allocation error
2742 ** occurs. ^Otherwise, they return the name of the attached database, table,
2743 ** or column that query result column was extracted from.
2744 **
2745 ** ^As with all other SQLite APIs, those whose names end with "16" return
2746 ** UTF-16 encoded strings and the other functions return UTF-8.
2747 **
2748 ** ^These APIs are only available if the library was compiled with the
2749 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol.
2750 **
 
2751 ** If two or more threads call one or more of these routines against the same
2752 ** prepared statement and column at the same time then the results are
2753 ** undefined.
2754 **
 
 
 
2755 ** If two or more threads call one or more
2756 ** [sqlite3_column_database_name | column metadata interfaces]
2757 ** for the same [prepared statement] and result column
2758 ** at the same time then the results are undefined.
2759 */
@@ -2800,46 +2763,43 @@
2763 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
2764 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
2765 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
2766
2767 /*
2768 ** CAPI3REF: Declared Datatype Of A Query Result
2769 **
2770 ** ^(The first parameter is a [prepared statement].
2771 ** If this statement is a [SELECT] statement and the Nth column of the
2772 ** returned result set of that [SELECT] is a table column (not an
2773 ** expression or subquery) then the declared type of the table
2774 ** column is returned.)^ ^If the Nth column of the result set is an
2775 ** expression or subquery, then a NULL pointer is returned.
2776 ** ^The returned string is always UTF-8 encoded.
2777 **
2778 ** ^(For example, given the database schema:
2779 **
2780 ** CREATE TABLE t1(c1 VARIANT);
2781 **
2782 ** and the following statement to be compiled:
2783 **
2784 ** SELECT c1 + 1, c1 FROM t1;
2785 **
2786 ** this routine would return the string "VARIANT" for the second result
2787 ** column (i==1), and a NULL pointer for the first result column (i==0).)^
2788 **
2789 ** ^SQLite uses dynamic run-time typing. ^So just because a column
2790 ** is declared to contain a particular type does not mean that the
2791 ** data stored in that column is of the declared type. SQLite is
2792 ** strongly typed, but the typing is dynamic not static. ^Type
2793 ** is associated with individual values, not with the containers
2794 ** used to hold those values.
 
 
 
2795 */
2796 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
2797 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
2798
2799 /*
2800 ** CAPI3REF: Evaluate An SQL Statement
2801 **
2802 ** After a [prepared statement] has been prepared using either
2803 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
2804 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
2805 ** must be called one or more times to evaluate the statement.
@@ -2849,39 +2809,39 @@
2809 ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy
2810 ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the
2811 ** new "v2" interface is recommended for new applications but the legacy
2812 ** interface will continue to be supported.
2813 **
2814 ** ^In the legacy interface, the return value will be either [SQLITE_BUSY],
2815 ** [SQLITE_DONE], [SQLITE_ROW], [SQLITE_ERROR], or [SQLITE_MISUSE].
2816 ** ^With the "v2" interface, any of the other [result codes] or
2817 ** [extended result codes] might be returned as well.
2818 **
2819 ** ^[SQLITE_BUSY] means that the database engine was unable to acquire the
2820 ** database locks it needs to do its job. ^If the statement is a [COMMIT]
2821 ** or occurs outside of an explicit transaction, then you can retry the
2822 ** statement. If the statement is not a [COMMIT] and occurs within a
2823 ** explicit transaction then you should rollback the transaction before
2824 ** continuing.
2825 **
2826 ** ^[SQLITE_DONE] means that the statement has finished executing
2827 ** successfully. sqlite3_step() should not be called again on this virtual
2828 ** machine without first calling [sqlite3_reset()] to reset the virtual
2829 ** machine back to its initial state.
2830 **
2831 ** ^If the SQL statement being executed returns any data, then [SQLITE_ROW]
2832 ** is returned each time a new row of data is ready for processing by the
2833 ** caller. The values may be accessed using the [column access functions].
2834 ** sqlite3_step() is called again to retrieve the next row of data.
2835 **
2836 ** ^[SQLITE_ERROR] means that a run-time error (such as a constraint
2837 ** violation) has occurred. sqlite3_step() should not be called again on
2838 ** the VM. More information may be found by calling [sqlite3_errmsg()].
2839 ** ^With the legacy interface, a more specific error code (for example,
2840 ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth)
2841 ** can be obtained by calling [sqlite3_reset()] on the
2842 ** [prepared statement]. ^In the "v2" interface,
2843 ** the more specific error code is returned directly by sqlite3_step().
2844 **
2845 ** [SQLITE_MISUSE] means that the this routine was called inappropriately.
2846 ** Perhaps it was called on a [prepared statement] that has
2847 ** already been [sqlite3_finalize | finalized] or on one that had
@@ -2898,39 +2858,34 @@
2858 ** with the "v2" interface. If you prepare all of your SQL statements
2859 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
2860 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
2861 ** then the more specific [error codes] are returned directly
2862 ** by sqlite3_step(). The use of the "v2" interface is recommended.
 
 
 
2863 */
2864 SQLITE_API int sqlite3_step(sqlite3_stmt*);
2865
2866 /*
2867 ** CAPI3REF: Number of columns in a result set
2868 **
2869 ** ^The sqlite3_data_count(P) the number of columns in the
2870 ** of the result set of [prepared statement] P.
 
 
2871 */
2872 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
2873
2874 /*
2875 ** CAPI3REF: Fundamental Datatypes
2876 ** KEYWORDS: SQLITE_TEXT
2877 **
2878 ** ^(Every value in SQLite has one of five fundamental datatypes:
2879 **
2880 ** <ul>
2881 ** <li> 64-bit signed integer
2882 ** <li> 64-bit IEEE floating point number
2883 ** <li> string
2884 ** <li> BLOB
2885 ** <li> NULL
2886 ** </ul>)^
2887 **
2888 ** These constants are codes for each of those types.
2889 **
2890 ** Note that the SQLITE_TEXT constant was also used in SQLite version 2
2891 ** for a completely different meaning. Software that links against both
@@ -2947,22 +2902,22 @@
2902 # define SQLITE_TEXT 3
2903 #endif
2904 #define SQLITE3_TEXT 3
2905
2906 /*
2907 ** CAPI3REF: Result Values From A Query
2908 ** KEYWORDS: {column access functions}
2909 **
2910 ** These routines form the "result set" interface.
2911 **
2912 ** ^These routines return information about a single column of the current
2913 ** result row of a query. ^In every case the first argument is a pointer
2914 ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*]
2915 ** that was returned from [sqlite3_prepare_v2()] or one of its variants)
2916 ** and the second argument is the index of the column for which information
2917 ** should be returned. ^The leftmost column of the result set has the index 0.
2918 ** ^The number of columns in the result can be determined using
2919 ** [sqlite3_column_count()].
2920 **
2921 ** If the SQL statement does not currently point to a valid row, or if the
2922 ** column index is out of range, the result is undefined.
2923 ** These routines may only be called when the most recent call to
@@ -2973,52 +2928,52 @@
2928 ** something other than [SQLITE_ROW], the results are undefined.
2929 ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()]
2930 ** are called from a different thread while any of these routines
2931 ** are pending, then the results are undefined.
2932 **
2933 ** ^The sqlite3_column_type() routine returns the
2934 ** [SQLITE_INTEGER | datatype code] for the initial data type
2935 ** of the result column. ^The returned value is one of [SQLITE_INTEGER],
2936 ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value
2937 ** returned by sqlite3_column_type() is only meaningful if no type
2938 ** conversions have occurred as described below. After a type conversion,
2939 ** the value returned by sqlite3_column_type() is undefined. Future
2940 ** versions of SQLite may change the behavior of sqlite3_column_type()
2941 ** following a type conversion.
2942 **
2943 ** ^If the result is a BLOB or UTF-8 string then the sqlite3_column_bytes()
2944 ** routine returns the number of bytes in that BLOB or string.
2945 ** ^If the result is a UTF-16 string, then sqlite3_column_bytes() converts
2946 ** the string to UTF-8 and then returns the number of bytes.
2947 ** ^If the result is a numeric value then sqlite3_column_bytes() uses
2948 ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns
2949 ** the number of bytes in that string.
2950 ** ^The value returned does not include the zero terminator at the end
2951 ** of the string. ^For clarity: the value returned is the number of
2952 ** bytes in the string, not the number of characters.
2953 **
2954 ** ^Strings returned by sqlite3_column_text() and sqlite3_column_text16(),
2955 ** even empty strings, are always zero terminated. ^The return
2956 ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary
2957 ** pointer, possibly even a NULL pointer.
2958 **
2959 ** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes()
2960 ** but leaves the result in UTF-16 in native byte order instead of UTF-8.
2961 ** ^The zero terminator is not included in this count.
2962 **
2963 ** ^The object returned by [sqlite3_column_value()] is an
2964 ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object
2965 ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()].
2966 ** If the [unprotected sqlite3_value] object returned by
2967 ** [sqlite3_column_value()] is used in any other way, including calls
2968 ** to routines like [sqlite3_value_int()], [sqlite3_value_text()],
2969 ** or [sqlite3_value_bytes()], then the behavior is undefined.
2970 **
2971 ** These routines attempt to convert the value where appropriate. ^For
2972 ** example, if the internal representation is FLOAT and a text result
2973 ** is requested, [sqlite3_snprintf()] is used internally to perform the
2974 ** conversion automatically. ^(The following table details the conversions
2975 ** that are applied:
2976 **
2977 ** <blockquote>
2978 ** <table border="1">
2979 ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion
@@ -3038,22 +2993,22 @@
2993 ** <tr><td> TEXT <td> BLOB <td> No change
2994 ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi()
2995 ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof()
2996 ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed
2997 ** </table>
2998 ** </blockquote>)^
2999 **
3000 ** The table above makes reference to standard C library functions atoi()
3001 ** and atof(). SQLite does not really use these functions. It has its
3002 ** own equivalent internal routines. The atoi() and atof() names are
3003 ** used in the table for brevity and because they are familiar to most
3004 ** C programmers.
3005 **
3006 ** ^Note that when type conversions occur, pointers returned by prior
3007 ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or
3008 ** sqlite3_column_text16() may be invalidated.
3009 ** ^(Type conversions and pointer invalidations might occur
3010 ** in the following cases:
3011 **
3012 ** <ul>
3013 ** <li> The initial content is a BLOB and sqlite3_column_text() or
3014 ** sqlite3_column_text16() is called. A zero-terminator might
@@ -3062,51 +3017,47 @@
3017 ** sqlite3_column_text16() is called. The content must be converted
3018 ** to UTF-16.</li>
3019 ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or
3020 ** sqlite3_column_text() is called. The content must be converted
3021 ** to UTF-8.</li>
3022 ** </ul>)^
3023 **
3024 ** ^Conversions between UTF-16be and UTF-16le are always done in place and do
3025 ** not invalidate a prior pointer, though of course the content of the buffer
3026 ** that the prior pointer points to will have been modified. Other kinds
3027 ** of conversion are done in place when it is possible, but sometimes they
3028 ** are not possible and in those cases prior pointers are invalidated.
3029 **
3030 ** ^(The safest and easiest to remember policy is to invoke these routines
3031 ** in one of the following ways:
3032 **
3033 ** <ul>
3034 ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li>
3035 ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li>
3036 ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li>
3037 ** </ul>)^
3038 **
3039 ** In other words, you should call sqlite3_column_text(),
3040 ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result
3041 ** into the desired format, then invoke sqlite3_column_bytes() or
3042 ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls
3043 ** to sqlite3_column_text() or sqlite3_column_blob() with calls to
3044 ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16()
3045 ** with calls to sqlite3_column_bytes().
3046 **
3047 ** ^The pointers returned are valid until a type conversion occurs as
3048 ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
3049 ** [sqlite3_finalize()] is called. ^The memory space used to hold strings
3050 ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned
3051 ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
3052 ** [sqlite3_free()].
3053 **
3054 ** ^(If a memory allocation error occurs during the evaluation of any
3055 ** of these routines, a default value is returned. The default value
3056 ** is either the integer 0, the floating point number 0.0, or a NULL
3057 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
3058 ** [SQLITE_NOMEM].)^
 
 
 
 
3059 */
3060 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
3061 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
3062 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
3063 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
@@ -3116,139 +3067,132 @@
3067 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
3068 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
3069 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
3070
3071 /*
3072 ** CAPI3REF: Destroy A Prepared Statement Object
3073 **
3074 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
3075 ** ^If the statement was executed successfully or not executed at all, then
3076 ** SQLITE_OK is returned. ^If execution of the statement failed then an
3077 ** [error code] or [extended error code] is returned.
3078 **
3079 ** ^This routine can be called at any point during the execution of the
3080 ** [prepared statement]. ^If the virtual machine has not
3081 ** completed execution when this routine is called, that is like
3082 ** encountering an error or an [sqlite3_interrupt | interrupt].
3083 ** ^Incomplete updates may be rolled back and transactions canceled,
3084 ** depending on the circumstances, and the
3085 ** [error code] returned will be [SQLITE_ABORT].
 
 
 
3086 */
3087 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
3088
3089 /*
3090 ** CAPI3REF: Reset A Prepared Statement Object
3091 **
3092 ** The sqlite3_reset() function is called to reset a [prepared statement]
3093 ** object back to its initial state, ready to be re-executed.
3094 ** ^Any SQL statement variables that had values bound to them using
3095 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
3096 ** Use [sqlite3_clear_bindings()] to reset the bindings.
3097 **
3098 ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
3099 ** back to the beginning of its program.
3100 **
3101 ** ^If the most recent call to [sqlite3_step(S)] for the
3102 ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
3103 ** or if [sqlite3_step(S)] has never before been called on S,
3104 ** then [sqlite3_reset(S)] returns [SQLITE_OK].
3105 **
3106 ** ^If the most recent call to [sqlite3_step(S)] for the
3107 ** [prepared statement] S indicated an error, then
3108 ** [sqlite3_reset(S)] returns an appropriate [error code].
3109 **
3110 ** ^The [sqlite3_reset(S)] interface does not change the values
3111 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
3112 */
3113 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
3114
3115 /*
3116 ** CAPI3REF: Create Or Redefine SQL Functions
3117 ** KEYWORDS: {function creation routines}
3118 ** KEYWORDS: {application-defined SQL function}
3119 ** KEYWORDS: {application-defined SQL functions}
3120 **
3121 ** ^These two functions (collectively known as "function creation routines")
3122 ** are used to add SQL functions or aggregates or to redefine the behavior
3123 ** of existing SQL functions or aggregates. The only difference between the
3124 ** two is that the second parameter, the name of the (scalar) function or
3125 ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16
3126 ** for sqlite3_create_function16().
3127 **
3128 ** ^The first parameter is the [database connection] to which the SQL
3129 ** function is to be added. ^If an application uses more than one database
3130 ** connection then application-defined SQL functions must be added
3131 ** to each database connection separately.
3132 **
3133 ** The second parameter is the name of the SQL function to be created or
3134 ** redefined. ^The length of the name is limited to 255 bytes, exclusive of
3135 ** the zero-terminator. Note that the name length limit is in bytes, not
3136 ** characters. ^Any attempt to create a function with a longer name
3137 ** will result in [SQLITE_ERROR] being returned.
3138 **
3139 ** ^The third parameter (nArg)
3140 ** is the number of arguments that the SQL function or
3141 ** aggregate takes. ^If this parameter is -1, then the SQL function or
3142 ** aggregate may take any number of arguments between 0 and the limit
3143 ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third
3144 ** parameter is less than -1 or greater than 127 then the behavior is
3145 ** undefined.
3146 **
3147 ** The fourth parameter, eTextRep, specifies what
3148 ** [SQLITE_UTF8 | text encoding] this SQL function prefers for
3149 ** its parameters. Any SQL function implementation should be able to work
3150 ** work with UTF-8, UTF-16le, or UTF-16be. But some implementations may be
3151 ** more efficient with one encoding than another. ^An application may
3152 ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple
3153 ** times with the same function but with different values of eTextRep.
3154 ** ^When multiple implementations of the same function are available, SQLite
3155 ** will pick the one that involves the least amount of data conversion.
3156 ** If there is only a single implementation which does not care what text
3157 ** encoding is used, then the fourth argument should be [SQLITE_ANY].
3158 **
3159 ** ^(The fifth parameter is an arbitrary pointer. The implementation of the
3160 ** function can gain access to this pointer using [sqlite3_user_data()].)^
3161 **
3162 ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are
3163 ** pointers to C-language functions that implement the SQL function or
3164 ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
3165 ** callback only; NULL pointers should be passed as the xStep and xFinal
3166 ** parameters. ^An aggregate SQL function requires an implementation of xStep
3167 ** and xFinal and NULL should be passed for xFunc. ^To delete an existing
3168 ** SQL function or aggregate, pass NULL for all three function callbacks.
3169 **
3170 ** ^It is permitted to register multiple implementations of the same
3171 ** functions with the same name but with either differing numbers of
3172 ** arguments or differing preferred text encodings. ^SQLite will use
3173 ** the implementation that most closely matches the way in which the
3174 ** SQL function is used. ^A function implementation with a non-negative
3175 ** nArg parameter is a better match than a function implementation with
3176 ** a negative nArg. ^A function where the preferred text encoding
3177 ** matches the database encoding is a better
3178 ** match than a function where the encoding is different.
3179 ** ^A function where the encoding difference is between UTF16le and UTF16be
3180 ** is a closer match than a function where the encoding difference is
3181 ** between UTF8 and UTF16.
3182 **
3183 ** ^Built-in functions may be overloaded by new application-defined functions.
3184 ** ^The first application-defined function with a given name overrides all
3185 ** built-in functions in the same [database connection] with the same name.
3186 ** ^Subsequent application-defined functions of the same name only override
3187 ** prior application-defined functions that are an exact match for the
3188 ** number of parameters and preferred encoding.
3189 **
3190 ** ^An application-defined function is permitted to call other
3191 ** SQLite interfaces. However, such calls must not
3192 ** close the database connection nor finalize or reset the prepared
3193 ** statement in which the function is running.
 
 
 
 
3194 */
3195 SQLITE_API int sqlite3_create_function(
3196 sqlite3 *db,
3197 const char *zFunctionName,
3198 int nArg,
@@ -3268,11 +3212,11 @@
3212 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
3213 void (*xFinal)(sqlite3_context*)
3214 );
3215
3216 /*
3217 ** CAPI3REF: Text Encodings
3218 **
3219 ** These constant define integer codes that represent the various
3220 ** text encodings supported by SQLite.
3221 */
3222 #define SQLITE_UTF8 1
@@ -3300,11 +3244,11 @@
3244 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
3245 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64);
3246 #endif
3247
3248 /*
3249 ** CAPI3REF: Obtaining SQL Function Parameter Values
3250 **
3251 ** The C-language implementation of SQL functions and aggregates uses
3252 ** this set of interface routines to access the parameter values on
3253 ** the function or aggregate.
3254 **
@@ -3318,39 +3262,35 @@
3262 **
3263 ** These routines work only with [protected sqlite3_value] objects.
3264 ** Any attempt to use these routines on an [unprotected sqlite3_value]
3265 ** object results in undefined behavior.
3266 **
3267 ** ^These routines work just like the corresponding [column access functions]
3268 ** except that these routines take a single [protected sqlite3_value] object
3269 ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
3270 **
3271 ** ^The sqlite3_value_text16() interface extracts a UTF-16 string
3272 ** in the native byte-order of the host machine. ^The
3273 ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces
3274 ** extract UTF-16 strings as big-endian and little-endian respectively.
3275 **
3276 ** ^(The sqlite3_value_numeric_type() interface attempts to apply
3277 ** numeric affinity to the value. This means that an attempt is
3278 ** made to convert the value to an integer or floating point. If
3279 ** such a conversion is possible without loss of information (in other
3280 ** words, if the value is a string that looks like a number)
3281 ** then the conversion is performed. Otherwise no conversion occurs.
3282 ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
3283 **
3284 ** Please pay particular attention to the fact that the pointer returned
3285 ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
3286 ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
3287 ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
3288 ** or [sqlite3_value_text16()].
3289 **
3290 ** These routines must be called from the same thread as
3291 ** the SQL function that supplied the [sqlite3_value*] parameters.
 
 
 
 
3292 */
3293 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
3294 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
3295 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
3296 SQLITE_API double sqlite3_value_double(sqlite3_value*);
@@ -3362,70 +3302,77 @@
3302 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
3303 SQLITE_API int sqlite3_value_type(sqlite3_value*);
3304 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
3305
3306 /*
3307 ** CAPI3REF: Obtain Aggregate Function Context
3308 **
3309 ** Implementions of aggregate SQL functions use this
3310 ** routine to allocate memory for storing their state.
3311 **
3312 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
3313 ** for a particular aggregate function, SQLite
3314 ** allocates N of memory, zeroes out that memory, and returns a pointer
3315 ** to the new memory. ^On second and subsequent calls to
3316 ** sqlite3_aggregate_context() for the same aggregate function instance,
3317 ** the same buffer is returned. Sqlite3_aggregate_context() is normally
3318 ** called once for each invocation of the xStep callback and then one
3319 ** last time when the xFinal callback is invoked. ^(When no rows match
3320 ** an aggregate query, the xStep() callback of the aggregate function
3321 ** implementation is never called and xFinal() is called exactly once.
3322 ** In those cases, sqlite3_aggregate_context() might be called for the
3323 ** first time from within xFinal().)^
3324 **
3325 ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer if N is
3326 ** less than or equal to zero or if a memory allocate error occurs.
3327 **
3328 ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
3329 ** determined by the N parameter on first successful call. Changing the
3330 ** value of N in subsequent call to sqlite3_aggregate_context() within
3331 ** the same aggregate function instance will not resize the memory
3332 ** allocation.)^
3333 **
3334 ** ^SQLite automatically frees the memory allocated by
3335 ** sqlite3_aggregate_context() when the aggregate query concludes.
3336 **
3337 ** The first parameter must be a copy of the
3338 ** [sqlite3_context | SQL function context] that is the first parameter
3339 ** to the xStep or xFinal callback routine that implements the aggregate
3340 ** function.
3341 **
3342 ** This routine must be called from the same thread in which
3343 ** the aggregate SQL function is running.
 
 
 
3344 */
3345 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
3346
3347 /*
3348 ** CAPI3REF: User Data For Functions
3349 **
3350 ** ^The sqlite3_user_data() interface returns a copy of
3351 ** the pointer that was the pUserData parameter (the 5th parameter)
3352 ** of the [sqlite3_create_function()]
3353 ** and [sqlite3_create_function16()] routines that originally
3354 ** registered the application defined function.
3355 **
3356 ** This routine must be called from the same thread in which
3357 ** the application-defined function is running.
 
 
 
3358 */
3359 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
3360
3361 /*
3362 ** CAPI3REF: Database Connection For Functions
3363 **
3364 ** ^The sqlite3_context_db_handle() interface returns a copy of
3365 ** the pointer to the [database connection] (the 1st parameter)
3366 ** of the [sqlite3_create_function()]
3367 ** and [sqlite3_create_function16()] routines that originally
3368 ** registered the application defined function.
 
 
 
3369 */
3370 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
3371
3372 /*
3373 ** CAPI3REF: Function Auxiliary Data
3374 **
3375 ** The following two functions may be used by scalar SQL functions to
3376 ** associate metadata with argument values. If the same value is passed to
3377 ** multiple invocations of the same SQL function during query execution, under
3378 ** some circumstances the associated metadata may be preserved. This may
@@ -3434,52 +3381,49 @@
3381 ** metadata associated with the SQL value passed as the regular expression
3382 ** pattern. The compiled regular expression can be reused on multiple
3383 ** invocations of the same function so that the original pattern string
3384 ** does not need to be recompiled on each invocation.
3385 **
3386 ** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata
3387 ** associated by the sqlite3_set_auxdata() function with the Nth argument
3388 ** value to the application-defined function. ^If no metadata has been ever
3389 ** been set for the Nth argument of the function, or if the corresponding
3390 ** function parameter has changed since the meta-data was set,
3391 ** then sqlite3_get_auxdata() returns a NULL pointer.
3392 **
3393 ** ^The sqlite3_set_auxdata() interface saves the metadata
3394 ** pointed to by its 3rd parameter as the metadata for the N-th
3395 ** argument of the application-defined function. Subsequent
3396 ** calls to sqlite3_get_auxdata() might return this data, if it has
3397 ** not been destroyed.
3398 ** ^If it is not NULL, SQLite will invoke the destructor
3399 ** function given by the 4th parameter to sqlite3_set_auxdata() on
3400 ** the metadata when the corresponding function parameter changes
3401 ** or when the SQL statement completes, whichever comes first.
3402 **
3403 ** SQLite is free to call the destructor and drop metadata on any
3404 ** parameter of any function at any time. ^The only guarantee is that
3405 ** the destructor will be called before the metadata is dropped.
3406 **
3407 ** ^(In practice, metadata is preserved between function calls for
3408 ** expressions that are constant at compile time. This includes literal
3409 ** values and [parameters].)^
3410 **
3411 ** These routines must be called from the same thread in which
3412 ** the SQL function is running.
 
 
 
3413 */
3414 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
3415 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
3416
3417
3418 /*
3419 ** CAPI3REF: Constants Defining Special Destructor Behavior
3420 **
3421 ** These are special values for the destructor that is passed in as the
3422 ** final argument to routines like [sqlite3_result_blob()]. ^If the destructor
3423 ** argument is SQLITE_STATIC, it means that the content pointer is constant
3424 ** and will never change. It does not need to be destroyed. ^The
3425 ** SQLITE_TRANSIENT value means that the content will likely change in
3426 ** the near future and that SQLite should make its own private copy of
3427 ** the content before returning.
3428 **
3429 ** The typedef is necessary to work around problems in certain
@@ -3488,11 +3432,11 @@
3432 typedef void (*sqlite3_destructor_type)(void*);
3433 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
3434 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
3435
3436 /*
3437 ** CAPI3REF: Setting The Result Of An SQL Function
3438 **
3439 ** These routines are used by the xFunc or xFinal callbacks that
3440 ** implement SQL functions and aggregates. See
3441 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
3442 ** for additional information.
@@ -3499,107 +3443,102 @@
3443 **
3444 ** These functions work very much like the [parameter binding] family of
3445 ** functions used to bind values to host parameters in prepared statements.
3446 ** Refer to the [SQL parameter] documentation for additional information.
3447 **
3448 ** ^The sqlite3_result_blob() interface sets the result from
3449 ** an application-defined function to be the BLOB whose content is pointed
3450 ** to by the second parameter and which is N bytes long where N is the
3451 ** third parameter.
3452 **
3453 ** ^The sqlite3_result_zeroblob() interfaces set the result of
3454 ** the application-defined function to be a BLOB containing all zero
3455 ** bytes and N bytes in size, where N is the value of the 2nd parameter.
3456 **
3457 ** ^The sqlite3_result_double() interface sets the result from
3458 ** an application-defined function to be a floating point value specified
3459 ** by its 2nd argument.
3460 **
3461 ** ^The sqlite3_result_error() and sqlite3_result_error16() functions
3462 ** cause the implemented SQL function to throw an exception.
3463 ** ^SQLite uses the string pointed to by the
3464 ** 2nd parameter of sqlite3_result_error() or sqlite3_result_error16()
3465 ** as the text of an error message. ^SQLite interprets the error
3466 ** message string from sqlite3_result_error() as UTF-8. ^SQLite
3467 ** interprets the string from sqlite3_result_error16() as UTF-16 in native
3468 ** byte order. ^If the third parameter to sqlite3_result_error()
3469 ** or sqlite3_result_error16() is negative then SQLite takes as the error
3470 ** message all text up through the first zero character.
3471 ** ^If the third parameter to sqlite3_result_error() or
3472 ** sqlite3_result_error16() is non-negative then SQLite takes that many
3473 ** bytes (not characters) from the 2nd parameter as the error message.
3474 ** ^The sqlite3_result_error() and sqlite3_result_error16()
3475 ** routines make a private copy of the error message text before
3476 ** they return. Hence, the calling function can deallocate or
3477 ** modify the text after they return without harm.
3478 ** ^The sqlite3_result_error_code() function changes the error code
3479 ** returned by SQLite as a result of an error in a function. ^By default,
3480 ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error()
3481 ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR.
3482 **
3483 ** ^The sqlite3_result_toobig() interface causes SQLite to throw an error
3484 ** indicating that a string or BLOB is too long to represent.
3485 **
3486 ** ^The sqlite3_result_nomem() interface causes SQLite to throw an error
3487 ** indicating that a memory allocation failed.
3488 **
3489 ** ^The sqlite3_result_int() interface sets the return value
3490 ** of the application-defined function to be the 32-bit signed integer
3491 ** value given in the 2nd argument.
3492 ** ^The sqlite3_result_int64() interface sets the return value
3493 ** of the application-defined function to be the 64-bit signed integer
3494 ** value given in the 2nd argument.
3495 **
3496 ** ^The sqlite3_result_null() interface sets the return value
3497 ** of the application-defined function to be NULL.
3498 **
3499 ** ^The sqlite3_result_text(), sqlite3_result_text16(),
3500 ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces
3501 ** set the return value of the application-defined function to be
3502 ** a text string which is represented as UTF-8, UTF-16 native byte order,
3503 ** UTF-16 little endian, or UTF-16 big endian, respectively.
3504 ** ^SQLite takes the text result from the application from
3505 ** the 2nd parameter of the sqlite3_result_text* interfaces.
3506 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
3507 ** is negative, then SQLite takes result text from the 2nd parameter
3508 ** through the first zero character.
3509 ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
3510 ** is non-negative, then as many bytes (not characters) of the text
3511 ** pointed to by the 2nd parameter are taken as the application-defined
3512 ** function result.
3513 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
3514 ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that
3515 ** function as the destructor on the text or BLOB result when it has
3516 ** finished using that result.
3517 ** ^If the 4th parameter to the sqlite3_result_text* interfaces or to
3518 ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite
3519 ** assumes that the text or BLOB result is in constant space and does not
3520 ** copy the content of the parameter nor call a destructor on the content
3521 ** when it has finished using that result.
3522 ** ^If the 4th parameter to the sqlite3_result_text* interfaces
3523 ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT
3524 ** then SQLite makes a copy of the result into space obtained from
3525 ** from [sqlite3_malloc()] before it returns.
3526 **
3527 ** ^The sqlite3_result_value() interface sets the result of
3528 ** the application-defined function to be a copy the
3529 ** [unprotected sqlite3_value] object specified by the 2nd parameter. ^The
3530 ** sqlite3_result_value() interface makes a copy of the [sqlite3_value]
3531 ** so that the [sqlite3_value] specified in the parameter may change or
3532 ** be deallocated after sqlite3_result_value() returns without harm.
3533 ** ^A [protected sqlite3_value] object may always be used where an
3534 ** [unprotected sqlite3_value] object is required, so either
3535 ** kind of [sqlite3_value] object can be used with this interface.
3536 **
3537 ** If these routines are called from within the different thread
3538 ** than the one containing the application-defined function that received
3539 ** the [sqlite3_context] pointer, the results are undefined.
 
 
 
 
 
3540 */
3541 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
3542 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
3543 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
3544 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
@@ -3615,58 +3554,54 @@
3554 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
3555 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
3556 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
3557
3558 /*
3559 ** CAPI3REF: Define New Collating Sequences
3560 **
3561 ** These functions are used to add new collation sequences to the
3562 ** [database connection] specified as the first argument.
3563 **
3564 ** ^The name of the new collation sequence is specified as a UTF-8 string
3565 ** for sqlite3_create_collation() and sqlite3_create_collation_v2()
3566 ** and a UTF-16 string for sqlite3_create_collation16(). ^In all cases
3567 ** the name is passed as the second function argument.
3568 **
3569 ** ^The third argument may be one of the constants [SQLITE_UTF8],
3570 ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied
3571 ** routine expects to be passed pointers to strings encoded using UTF-8,
3572 ** UTF-16 little-endian, or UTF-16 big-endian, respectively. ^The
3573 ** third argument might also be [SQLITE_UTF16] to indicate that the routine
3574 ** expects pointers to be UTF-16 strings in the native byte order, or the
3575 ** argument can be [SQLITE_UTF16_ALIGNED] if the
3576 ** the routine expects pointers to 16-bit word aligned strings
3577 ** of UTF-16 in the native byte order.
3578 **
3579 ** A pointer to the user supplied routine must be passed as the fifth
3580 ** argument. ^If it is NULL, this is the same as deleting the collation
3581 ** sequence (so that SQLite cannot call it anymore).
3582 ** ^Each time the application supplied function is invoked, it is passed
3583 ** as its first parameter a copy of the void* passed as the fourth argument
3584 ** to sqlite3_create_collation() or sqlite3_create_collation16().
3585 **
3586 ** ^The remaining arguments to the application-supplied routine are two strings,
3587 ** each represented by a (length, data) pair and encoded in the encoding
3588 ** that was passed as the third argument when the collation sequence was
3589 ** registered. The application defined collation routine should
3590 ** return negative, zero or positive if the first string is less than,
3591 ** equal to, or greater than the second string. i.e. (STRING1 - STRING2).
3592 **
3593 ** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation()
3594 ** except that it takes an extra argument which is a destructor for
3595 ** the collation. ^The destructor is called when the collation is
3596 ** destroyed and is passed a copy of the fourth parameter void* pointer
3597 ** of the sqlite3_create_collation_v2().
3598 ** ^Collations are destroyed when they are overridden by later calls to the
3599 ** collation creation functions or when the [database connection] is closed
3600 ** using [sqlite3_close()].
3601 **
3602 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
 
 
 
 
3603 */
3604 SQLITE_API int sqlite3_create_collation(
3605 sqlite3*,
3606 const char *zName,
3607 int eTextRep,
@@ -3688,37 +3623,34 @@
3623 void*,
3624 int(*xCompare)(void*,int,const void*,int,const void*)
3625 );
3626
3627 /*
3628 ** CAPI3REF: Collation Needed Callbacks
3629 **
3630 ** ^To avoid having to register all collation sequences before a database
3631 ** can be used, a single callback function may be registered with the
3632 ** [database connection] to be invoked whenever an undefined collation
3633 ** sequence is required.
3634 **
3635 ** ^If the function is registered using the sqlite3_collation_needed() API,
3636 ** then it is passed the names of undefined collation sequences as strings
3637 ** encoded in UTF-8. ^If sqlite3_collation_needed16() is used,
3638 ** the names are passed as UTF-16 in machine native byte order.
3639 ** ^A call to either function replaces the existing collation-needed callback.
3640 **
3641 ** ^(When the callback is invoked, the first argument passed is a copy
3642 ** of the second argument to sqlite3_collation_needed() or
3643 ** sqlite3_collation_needed16(). The second argument is the database
3644 ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE],
3645 ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation
3646 ** sequence function required. The fourth parameter is the name of the
3647 ** required collation sequence.)^
3648 **
3649 ** The callback function should register the desired collation using
3650 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
3651 ** [sqlite3_create_collation_v2()].
 
 
 
3652 */
3653 SQLITE_API int sqlite3_collation_needed(
3654 sqlite3*,
3655 void*,
3656 void(*)(void*,sqlite3*,int eTextRep,const char*)
@@ -3753,33 +3685,32 @@
3685 sqlite3 *db, /* Database to be rekeyed */
3686 const void *pKey, int nKey /* The new key */
3687 );
3688
3689 /*
3690 ** CAPI3REF: Suspend Execution For A Short Time
3691 **
3692 ** ^The sqlite3_sleep() function causes the current thread to suspend execution
3693 ** for at least a number of milliseconds specified in its parameter.
3694 **
3695 ** ^If the operating system does not support sleep requests with
3696 ** millisecond time resolution, then the time will be rounded up to
3697 ** the nearest second. ^The number of milliseconds of sleep actually
3698 ** requested from the operating system is returned.
3699 **
3700 ** ^SQLite implements this interface by calling the xSleep()
3701 ** method of the default [sqlite3_vfs] object.
 
 
3702 */
3703 SQLITE_API int sqlite3_sleep(int);
3704
3705 /*
3706 ** CAPI3REF: Name Of The Folder Holding Temporary Files
3707 **
3708 ** ^(If this global variable is made to point to a string which is
3709 ** the name of a folder (a.k.a. directory), then all temporary files
3710 ** created by SQLite when using a built-in [sqlite3_vfs | VFS]
3711 ** will be placed in that directory.)^ ^If this variable
3712 ** is a NULL pointer, then SQLite performs a search for an appropriate
3713 ** temporary file directory.
3714 **
3715 ** It is not safe to read or modify this variable in more than one
3716 ** thread at a time. It is not safe to read or modify this variable
@@ -3788,12 +3719,12 @@
3719 ** It is intended that this variable be set once
3720 ** as part of process initialization and before any SQLite interface
3721 ** routines have been called and that this variable remain unchanged
3722 ** thereafter.
3723 **
3724 ** ^The [temp_store_directory pragma] may modify this variable and cause
3725 ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore,
3726 ** the [temp_store_directory pragma] always assumes that any string
3727 ** that this variable points to is held in memory obtained from
3728 ** [sqlite3_malloc] and the pragma may attempt to free that memory
3729 ** using [sqlite3_free].
3730 ** Hence, if this variable is modified directly, either it should be
@@ -3801,18 +3732,18 @@
3732 ** or else the use of the [temp_store_directory pragma] should be avoided.
3733 */
3734 SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
3735
3736 /*
3737 ** CAPI3REF: Test For Auto-Commit Mode
3738 ** KEYWORDS: {autocommit mode}
3739 **
3740 ** ^The sqlite3_get_autocommit() interface returns non-zero or
3741 ** zero if the given database connection is or is not in autocommit mode,
3742 ** respectively. ^Autocommit mode is on by default.
3743 ** ^Autocommit mode is disabled by a [BEGIN] statement.
3744 ** ^Autocommit mode is re-enabled by a [COMMIT] or [ROLLBACK].
3745 **
3746 ** If certain kinds of errors occur on a statement within a multi-statement
3747 ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR],
3748 ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the
3749 ** transaction might be rolled back automatically. The only way to
@@ -3820,124 +3751,116 @@
3751 ** an error is to use this function.
3752 **
3753 ** If another thread changes the autocommit status of the database
3754 ** connection while this routine is running, then the return value
3755 ** is undefined.
 
 
3756 */
3757 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
3758
3759 /*
3760 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
3761 **
3762 ** ^The sqlite3_db_handle interface returns the [database connection] handle
3763 ** to which a [prepared statement] belongs. ^The [database connection]
3764 ** returned by sqlite3_db_handle is the same [database connection]
3765 ** that was the first argument
3766 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
3767 ** create the statement in the first place.
 
 
3768 */
3769 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
3770
3771 /*
3772 ** CAPI3REF: Find the next prepared statement
3773 **
3774 ** ^This interface returns a pointer to the next [prepared statement] after
3775 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
3776 ** then this interface returns a pointer to the first prepared statement
3777 ** associated with the database connection pDb. ^If no prepared statement
3778 ** satisfies the conditions of this routine, it returns NULL.
3779 **
3780 ** The [database connection] pointer D in a call to
3781 ** [sqlite3_next_stmt(D,S)] must refer to an open database
3782 ** connection and in particular must not be a NULL pointer.
 
 
3783 */
3784 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
3785
3786 /*
3787 ** CAPI3REF: Commit And Rollback Notification Callbacks
3788 **
3789 ** ^The sqlite3_commit_hook() interface registers a callback
3790 ** function to be invoked whenever a transaction is [COMMIT | committed].
3791 ** ^Any callback set by a previous call to sqlite3_commit_hook()
3792 ** for the same database connection is overridden.
3793 ** ^The sqlite3_rollback_hook() interface registers a callback
3794 ** function to be invoked whenever a transaction is [ROLLBACK | rolled back].
3795 ** ^Any callback set by a previous call to sqlite3_rollback_hook()
3796 ** for the same database connection is overridden.
3797 ** ^The pArg argument is passed through to the callback.
3798 ** ^If the callback on a commit hook function returns non-zero,
3799 ** then the commit is converted into a rollback.
3800 **
3801 ** ^The sqlite3_commit_hook(D,C,P) and sqlite3_rollback_hook(D,C,P) functions
3802 ** return the P argument from the previous call of the same function
3803 ** on the same [database connection] D, or NULL for
3804 ** the first call for each function on D.
3805 **
3806 ** The callback implementation must not do anything that will modify
3807 ** the database connection that invoked the callback. Any actions
3808 ** to modify the database connection must be deferred until after the
3809 ** completion of the [sqlite3_step()] call that triggered the commit
3810 ** or rollback hook in the first place.
3811 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3812 ** database connections for the meaning of "modify" in this paragraph.
3813 **
3814 ** ^Registering a NULL function disables the callback.
3815 **
3816 ** ^When the commit hook callback routine returns zero, the [COMMIT]
3817 ** operation is allowed to continue normally. ^If the commit hook
3818 ** returns non-zero, then the [COMMIT] is converted into a [ROLLBACK].
3819 ** ^The rollback hook is invoked on a rollback that results from a commit
3820 ** hook returning non-zero, just as it would be with any other rollback.
3821 **
3822 ** ^For the purposes of this API, a transaction is said to have been
3823 ** rolled back if an explicit "ROLLBACK" statement is executed, or
3824 ** an error or constraint causes an implicit rollback to occur.
3825 ** ^The rollback callback is not invoked if a transaction is
3826 ** automatically rolled back because the database connection is closed.
3827 ** ^The rollback callback is not invoked if a transaction is
3828 ** rolled back because a commit callback returned non-zero.
 
3829 **
3830 ** See also the [sqlite3_update_hook()] interface.
 
 
 
 
3831 */
3832 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
3833 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
3834
3835 /*
3836 ** CAPI3REF: Data Change Notification Callbacks
3837 **
3838 ** ^The sqlite3_update_hook() interface registers a callback function
3839 ** with the [database connection] identified by the first argument
3840 ** to be invoked whenever a row is updated, inserted or deleted.
3841 ** ^Any callback set by a previous call to this function
3842 ** for the same database connection is overridden.
3843 **
3844 ** ^The second argument is a pointer to the function to invoke when a
3845 ** row is updated, inserted or deleted.
3846 ** ^The first argument to the callback is a copy of the third argument
3847 ** to sqlite3_update_hook().
3848 ** ^The second callback argument is one of [SQLITE_INSERT], [SQLITE_DELETE],
3849 ** or [SQLITE_UPDATE], depending on the operation that caused the callback
3850 ** to be invoked.
3851 ** ^The third and fourth arguments to the callback contain pointers to the
3852 ** database and table name containing the affected row.
3853 ** ^The final callback parameter is the [rowid] of the row.
3854 ** ^In the case of an update, this is the [rowid] after the update takes place.
3855 **
3856 ** ^(The update hook is not invoked when internal system tables are
3857 ** modified (i.e. sqlite_master and sqlite_sequence).)^
3858 **
3859 ** ^In the current implementation, the update hook
3860 ** is not invoked when duplication rows are deleted because of an
3861 ** [ON CONFLICT | ON CONFLICT REPLACE] clause. ^Nor is the update hook
3862 ** invoked when rows are deleted using the [truncate optimization].
3863 ** The exceptions defined in this paragraph might change in a future
3864 ** release of SQLite.
3865 **
3866 ** The update hook implementation must not do anything that will modify
@@ -3945,169 +3868,157 @@
3868 ** to modify the database connection must be deferred until after the
3869 ** completion of the [sqlite3_step()] call that triggered the update hook.
3870 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
3871 ** database connections for the meaning of "modify" in this paragraph.
3872 **
3873 ** ^The sqlite3_update_hook(D,C,P) function
3874 ** returns the P argument from the previous call
3875 ** on the same [database connection] D, or NULL for
3876 ** the first call on D.
3877 **
3878 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
3879 ** interfaces.
 
 
 
3880 */
3881 SQLITE_API void *sqlite3_update_hook(
3882 sqlite3*,
3883 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
3884 void*
3885 );
3886
3887 /*
3888 ** CAPI3REF: Enable Or Disable Shared Pager Cache
3889 ** KEYWORDS: {shared cache}
3890 **
3891 ** ^(This routine enables or disables the sharing of the database cache
3892 ** and schema data structures between [database connection | connections]
3893 ** to the same database. Sharing is enabled if the argument is true
3894 ** and disabled if the argument is false.)^
3895 **
3896 ** ^Cache sharing is enabled and disabled for an entire process.
3897 ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite,
3898 ** sharing was enabled or disabled for each thread separately.
3899 **
3900 ** ^(The cache sharing mode set by this interface effects all subsequent
3901 ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()].
3902 ** Existing database connections continue use the sharing mode
3903 ** that was in effect at the time they were opened.)^
3904 **
3905 ** ^(This routine returns [SQLITE_OK] if shared cache was enabled or disabled
3906 ** successfully. An [error code] is returned otherwise.)^
3907 **
3908 ** ^Shared cache is disabled by default. But this might change in
 
 
 
 
3909 ** future releases of SQLite. Applications that care about shared
3910 ** cache setting should set it explicitly.
3911 **
3912 ** See Also: [SQLite Shared-Cache Mode]
 
 
3913 */
3914 SQLITE_API int sqlite3_enable_shared_cache(int);
3915
3916 /*
3917 ** CAPI3REF: Attempt To Free Heap Memory
3918 **
3919 ** ^The sqlite3_release_memory() interface attempts to free N bytes
3920 ** of heap memory by deallocating non-essential memory allocations
3921 ** held by the database library. Memory used to cache database
3922 ** pages to improve performance is an example of non-essential memory.
3923 ** ^sqlite3_release_memory() returns the number of bytes actually freed,
3924 ** which might be more or less than the amount requested.
 
 
3925 */
3926 SQLITE_API int sqlite3_release_memory(int);
3927
3928 /*
3929 ** CAPI3REF: Impose A Limit On Heap Size
3930 **
3931 ** ^The sqlite3_soft_heap_limit() interface places a "soft" limit
3932 ** on the amount of heap memory that may be allocated by SQLite.
3933 ** ^If an internal allocation is requested that would exceed the
3934 ** soft heap limit, [sqlite3_release_memory()] is invoked one or
3935 ** more times to free up some space before the allocation is performed.
3936 **
3937 ** ^The limit is called "soft" because if [sqlite3_release_memory()]
3938 ** cannot free sufficient memory to prevent the limit from being exceeded,
3939 ** the memory is allocated anyway and the current operation proceeds.
3940 **
3941 ** ^A negative or zero value for N means that there is no soft heap limit and
3942 ** [sqlite3_release_memory()] will only be called when memory is exhausted.
3943 ** ^The default value for the soft heap limit is zero.
3944 **
3945 ** ^(SQLite makes a best effort to honor the soft heap limit.
3946 ** But if the soft heap limit cannot be honored, execution will
3947 ** continue without error or notification.)^ This is why the limit is
3948 ** called a "soft" limit. It is advisory only.
3949 **
3950 ** Prior to SQLite version 3.5.0, this routine only constrained the memory
3951 ** allocated by a single thread - the same thread in which this routine
3952 ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is
3953 ** applied to all threads. The value specified for the soft heap limit
3954 ** is an upper bound on the total memory allocation for all threads. In
3955 ** version 3.5.0 there is no mechanism for limiting the heap usage for
3956 ** individual threads.
 
 
 
3957 */
3958 SQLITE_API void sqlite3_soft_heap_limit(int);
3959
3960 /*
3961 ** CAPI3REF: Extract Metadata About A Column Of A Table
3962 **
3963 ** ^This routine returns metadata about a specific column of a specific
3964 ** database table accessible using the [database connection] handle
3965 ** passed as the first function argument.
3966 **
3967 ** ^The column is identified by the second, third and fourth parameters to
3968 ** this function. ^The second parameter is either the name of the database
3969 ** (i.e. "main", "temp", or an attached database) containing the specified
3970 ** table or NULL. ^If it is NULL, then all attached databases are searched
3971 ** for the table using the same algorithm used by the database engine to
3972 ** resolve unqualified table references.
3973 **
3974 ** ^The third and fourth parameters to this function are the table and column
3975 ** name of the desired column, respectively. Neither of these parameters
3976 ** may be NULL.
3977 **
3978 ** ^Metadata is returned by writing to the memory locations passed as the 5th
3979 ** and subsequent parameters to this function. ^Any of these arguments may be
3980 ** NULL, in which case the corresponding element of metadata is omitted.
3981 **
3982 ** ^(<blockquote>
3983 ** <table border="1">
3984 ** <tr><th> Parameter <th> Output<br>Type <th> Description
3985 **
3986 ** <tr><td> 5th <td> const char* <td> Data type
3987 ** <tr><td> 6th <td> const char* <td> Name of default collation sequence
3988 ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint
3989 ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY
3990 ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT]
3991 ** </table>
3992 ** </blockquote>)^
3993 **
3994 ** ^The memory pointed to by the character pointers returned for the
3995 ** declaration type and collation sequence is valid only until the next
3996 ** call to any SQLite API function.
3997 **
3998 ** ^If the specified table is actually a view, an [error code] is returned.
3999 **
4000 ** ^If the specified column is "rowid", "oid" or "_rowid_" and an
4001 ** [INTEGER PRIMARY KEY] column has been explicitly declared, then the output
4002 ** parameters are set for the explicitly declared column. ^(If there is no
4003 ** explicitly declared [INTEGER PRIMARY KEY] column, then the output
4004 ** parameters are set as follows:
4005 **
4006 ** <pre>
4007 ** data type: "INTEGER"
4008 ** collation sequence: "BINARY"
4009 ** not null: 0
4010 ** primary key: 1
4011 ** auto increment: 0
4012 ** </pre>)^
4013 **
4014 ** ^(This function may load one or more schemas from database files. If an
4015 ** error occurs during this process, or if the requested table or column
4016 ** cannot be found, an [error code] is returned and an error message left
4017 ** in the [database connection] (to be retrieved using sqlite3_errmsg()).)^
4018 **
4019 ** ^This API is only available if the library was compiled with the
4020 ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined.
4021 */
4022 SQLITE_API int sqlite3_table_column_metadata(
4023 sqlite3 *db, /* Connection handle */
4024 const char *zDbName, /* Database name or NULL */
@@ -4119,34 +4030,31 @@
4030 int *pPrimaryKey, /* OUTPUT: True if column part of PK */
4031 int *pAutoinc /* OUTPUT: True if column is auto-increment */
4032 );
4033
4034 /*
4035 ** CAPI3REF: Load An Extension
4036 **
4037 ** ^This interface loads an SQLite extension library from the named file.
4038 **
4039 ** ^The sqlite3_load_extension() interface attempts to load an
4040 ** SQLite extension library contained in the file zFile.
4041 **
4042 ** ^The entry point is zProc.
4043 ** ^zProc may be 0, in which case the name of the entry point
4044 ** defaults to "sqlite3_extension_init".
4045 ** ^The sqlite3_load_extension() interface returns
4046 ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong.
4047 ** ^If an error occurs and pzErrMsg is not 0, then the
4048 ** [sqlite3_load_extension()] interface shall attempt to
4049 ** fill *pzErrMsg with error message text stored in memory
4050 ** obtained from [sqlite3_malloc()]. The calling function
4051 ** should free this memory by calling [sqlite3_free()].
4052 **
4053 ** ^Extension loading must be enabled using
4054 ** [sqlite3_enable_load_extension()] prior to calling this API,
4055 ** otherwise an error will be returned.
 
 
 
4056 **
4057 ** See also the [load_extension() SQL function].
4058 */
4059 SQLITE_API int sqlite3_load_extension(
4060 sqlite3 *db, /* Load the extension into this database connection */
@@ -4154,65 +4062,53 @@
4062 const char *zProc, /* Entry point. Derived from zFile if 0 */
4063 char **pzErrMsg /* Put error message here if not 0 */
4064 );
4065
4066 /*
4067 ** CAPI3REF: Enable Or Disable Extension Loading
4068 **
4069 ** ^So as not to open security holes in older applications that are
4070 ** unprepared to deal with extension loading, and as a means of disabling
4071 ** extension loading while evaluating user-entered SQL, the following API
4072 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
4073 **
4074 ** ^Extension loading is off by default. See ticket #1863.
4075 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
4076 ** to turn extension loading on and call it with onoff==0 to turn
4077 ** it back off again.
 
 
 
4078 */
4079 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
4080
4081 /*
4082 ** CAPI3REF: Automatically Load An Extensions
4083 **
4084 ** ^This API can be invoked at program startup in order to register
4085 ** one or more statically linked extensions that will be available
4086 ** to all new [database connections].
4087 **
4088 ** ^(This routine stores a pointer to the extension entry point
4089 ** in an array that is obtained from [sqlite3_malloc()]. That memory
4090 ** is deallocated by [sqlite3_reset_auto_extension()].)^
4091 **
4092 ** ^This function registers an extension entry point that is
4093 ** automatically invoked whenever a new [database connection]
4094 ** is opened using [sqlite3_open()], [sqlite3_open16()],
4095 ** or [sqlite3_open_v2()].
4096 ** ^Duplicate extensions are detected so calling this routine
4097 ** multiple times with the same extension is harmless.
4098 ** ^Automatic extensions apply across all threads.
 
 
 
 
 
 
4099 */
4100 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
4101
4102 /*
4103 ** CAPI3REF: Reset Automatic Extension Loading
4104 **
4105 ** ^(This function disables all previously registered automatic
4106 ** extensions. It undoes the effect of all prior
4107 ** [sqlite3_auto_extension()] calls.)^
4108 **
4109 ** ^This function disables automatic extensions in all threads.
 
 
 
4110 */
4111 SQLITE_API void sqlite3_reset_auto_extension(void);
4112
4113 /*
4114 ****** EXPERIMENTAL - subject to change without notice **************
@@ -4232,22 +4128,22 @@
4128 typedef struct sqlite3_index_info sqlite3_index_info;
4129 typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor;
4130 typedef struct sqlite3_module sqlite3_module;
4131
4132 /*
4133 ** CAPI3REF: Virtual Table Object
4134 ** KEYWORDS: sqlite3_module {virtual table module}
4135 ** EXPERIMENTAL
4136 **
4137 ** This structure, sometimes called a a "virtual table module",
4138 ** defines the implementation of a [virtual tables].
4139 ** This structure consists mostly of methods for the module.
4140 **
4141 ** ^A virtual table module is created by filling in a persistent
4142 ** instance of this structure and passing a pointer to that instance
4143 ** to [sqlite3_create_module()] or [sqlite3_create_module_v2()].
4144 ** ^The registration remains valid until it is replaced by a different
4145 ** module or until the [database connection] closes. The content
4146 ** of this structure must not change while it is registered with
4147 ** any database connection.
4148 */
4149 struct sqlite3_module {
@@ -4279,56 +4175,56 @@
4175 void **ppArg);
4176 int (*xRename)(sqlite3_vtab *pVtab, const char *zNew);
4177 };
4178
4179 /*
4180 ** CAPI3REF: Virtual Table Indexing Information
4181 ** KEYWORDS: sqlite3_index_info
4182 ** EXPERIMENTAL
4183 **
4184 ** The sqlite3_index_info structure and its substructures is used to
4185 ** pass information into and receive the reply from the [xBestIndex]
4186 ** method of a [virtual table module]. The fields under **Inputs** are the
4187 ** inputs to xBestIndex and are read-only. xBestIndex inserts its
4188 ** results into the **Outputs** fields.
4189 **
4190 ** ^(The aConstraint[] array records WHERE clause constraints of the form:
4191 **
4192 ** <pre>column OP expr</pre>
4193 **
4194 ** where OP is =, &lt;, &lt;=, &gt;, or &gt;=.)^ ^(The particular operator is
4195 ** stored in aConstraint[].op.)^ ^(The index of the column is stored in
4196 ** aConstraint[].iColumn.)^ ^(aConstraint[].usable is TRUE if the
4197 ** expr on the right-hand side can be evaluated (and thus the constraint
4198 ** is usable) and false if it cannot.)^
4199 **
4200 ** ^The optimizer automatically inverts terms of the form "expr OP column"
4201 ** and makes other simplifications to the WHERE clause in an attempt to
4202 ** get as many WHERE clause terms into the form shown above as possible.
4203 ** ^The aConstraint[] array only reports WHERE clause terms that are
4204 ** relevant to the particular virtual table being queried.
4205 **
4206 ** ^Information about the ORDER BY clause is stored in aOrderBy[].
4207 ** ^Each term of aOrderBy records a column of the ORDER BY clause.
4208 **
4209 ** The [xBestIndex] method must fill aConstraintUsage[] with information
4210 ** about what parameters to pass to xFilter. ^If argvIndex>0 then
4211 ** the right-hand side of the corresponding aConstraint[] is evaluated
4212 ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit
4213 ** is true, then the constraint is assumed to be fully handled by the
4214 ** virtual table and is not checked again by SQLite.)^
4215 **
4216 ** ^The idxNum and idxPtr values are recorded and passed into the
4217 ** [xFilter] method.
4218 ** ^[sqlite3_free()] is used to free idxPtr if and only if
4219 ** needToFreeIdxPtr is true.
4220 **
4221 ** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in
4222 ** the correct order to satisfy the ORDER BY clause so that no separate
4223 ** sorting step is required.
4224 **
4225 ** ^The estimatedCost value is an estimate of the cost of doing the
4226 ** particular lookup. A full scan of a table with N entries should have
4227 ** a cost of N. A binary search of a table of N entries should have a
4228 ** cost of approximately log(N).
4229 */
4230 struct sqlite3_index_info {
@@ -4362,70 +4258,63 @@
4258 #define SQLITE_INDEX_CONSTRAINT_LT 16
4259 #define SQLITE_INDEX_CONSTRAINT_GE 32
4260 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
4261
4262 /*
4263 ** CAPI3REF: Register A Virtual Table Implementation
4264 ** EXPERIMENTAL
4265 **
4266 ** ^These routines are used to register a new [virtual table module] name.
4267 ** ^Module names must be registered before
4268 ** creating a new [virtual table] using the module and before using a
4269 ** preexisting [virtual table] for the module.
4270 **
4271 ** ^The module name is registered on the [database connection] specified
4272 ** by the first parameter. ^The name of the module is given by the
4273 ** second parameter. ^The third parameter is a pointer to
4274 ** the implementation of the [virtual table module]. ^The fourth
4275 ** parameter is an arbitrary client data pointer that is passed through
4276 ** into the [xCreate] and [xConnect] methods of the virtual table module
4277 ** when a new virtual table is be being created or reinitialized.
4278 **
4279 ** ^The sqlite3_create_module_v2() interface has a fifth parameter which
4280 ** is a pointer to a destructor for the pClientData. ^SQLite will
4281 ** invoke the destructor function (if it is not NULL) when SQLite
4282 ** no longer needs the pClientData pointer. ^The sqlite3_create_module()
4283 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
4284 ** destructor.
4285 */
4286 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module(
4287 sqlite3 *db, /* SQLite connection to register module with */
4288 const char *zName, /* Name of the module */
4289 const sqlite3_module *p, /* Methods for the module */
4290 void *pClientData /* Client data for xCreate/xConnect */
4291 );
 
 
 
 
 
 
 
 
 
 
 
4292 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2(
4293 sqlite3 *db, /* SQLite connection to register module with */
4294 const char *zName, /* Name of the module */
4295 const sqlite3_module *p, /* Methods for the module */
4296 void *pClientData, /* Client data for xCreate/xConnect */
4297 void(*xDestroy)(void*) /* Module destructor function */
4298 );
4299
4300 /*
4301 ** CAPI3REF: Virtual Table Instance Object
4302 ** KEYWORDS: sqlite3_vtab
4303 ** EXPERIMENTAL
4304 **
4305 ** Every [virtual table module] implementation uses a subclass
4306 ** of this object to describe a particular instance
4307 ** of the [virtual table]. Each subclass will
4308 ** be tailored to the specific needs of the module implementation.
4309 ** The purpose of this superclass is to define certain fields that are
4310 ** common to all module implementations.
4311 **
4312 ** ^Virtual tables methods can set an error message by assigning a
4313 ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should
4314 ** take care that any prior string is freed by a call to [sqlite3_free()]
4315 ** prior to assigning a new string to zErrMsg. ^After the error message
4316 ** is delivered up to the client application, the string will be automatically
4317 ** freed by sqlite3_free() and the zErrMsg field will be zeroed.
4318 */
4319 struct sqlite3_vtab {
4320 const sqlite3_module *pModule; /* The module for this virtual table */
@@ -4433,20 +4322,20 @@
4322 char *zErrMsg; /* Error message from sqlite3_mprintf() */
4323 /* Virtual table implementations will typically add additional fields */
4324 };
4325
4326 /*
4327 ** CAPI3REF: Virtual Table Cursor Object
4328 ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor}
4329 ** EXPERIMENTAL
4330 **
4331 ** Every [virtual table module] implementation uses a subclass of the
4332 ** following structure to describe cursors that point into the
4333 ** [virtual table] and are used
4334 ** to loop through the virtual table. Cursors are created using the
4335 ** [sqlite3_module.xOpen | xOpen] method of the module and are destroyed
4336 ** by the [sqlite3_module.xClose | xClose] method. Cursors are used
4337 ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods
4338 ** of the module. Each module implementation will define
4339 ** the content of a cursor structure to suit its own needs.
4340 **
4341 ** This superclass exists in order to define fields of the cursor that
@@ -4456,32 +4345,32 @@
4345 sqlite3_vtab *pVtab; /* Virtual table of this cursor */
4346 /* Virtual table implementations will typically add additional fields */
4347 };
4348
4349 /*
4350 ** CAPI3REF: Declare The Schema Of A Virtual Table
4351 ** EXPERIMENTAL
4352 **
4353 ** ^The [xCreate] and [xConnect] methods of a
4354 ** [virtual table module] call this interface
4355 ** to declare the format (the names and datatypes of the columns) of
4356 ** the virtual tables they implement.
4357 */
4358 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
4359
4360 /*
4361 ** CAPI3REF: Overload A Function For A Virtual Table
4362 ** EXPERIMENTAL
4363 **
4364 ** ^(Virtual tables can provide alternative implementations of functions
4365 ** using the [xFindFunction] method of the [virtual table module].
4366 ** But global versions of those functions
4367 ** must exist in order to be overloaded.)^
4368 **
4369 ** ^(This API makes sure a global version of a function with a particular
4370 ** name and number of parameters exists. If no such function exists
4371 ** before this API is called, a new function is created.)^ ^The implementation
4372 ** of the new function always causes an exception to be thrown. So
4373 ** the new function is not good for anything by itself. Its only
4374 ** purpose is to be a placeholder function that can be overloaded
4375 ** by a [virtual table].
4376 */
@@ -4498,81 +4387,78 @@
4387 **
4388 ****** EXPERIMENTAL - subject to change without notice **************
4389 */
4390
4391 /*
4392 ** CAPI3REF: A Handle To An Open BLOB
4393 ** KEYWORDS: {BLOB handle} {BLOB handles}
4394 **
4395 ** An instance of this object represents an open BLOB on which
4396 ** [sqlite3_blob_open | incremental BLOB I/O] can be performed.
4397 ** ^Objects of this type are created by [sqlite3_blob_open()]
4398 ** and destroyed by [sqlite3_blob_close()].
4399 ** ^The [sqlite3_blob_read()] and [sqlite3_blob_write()] interfaces
4400 ** can be used to read or write small subsections of the BLOB.
4401 ** ^The [sqlite3_blob_bytes()] interface returns the size of the BLOB in bytes.
4402 */
4403 typedef struct sqlite3_blob sqlite3_blob;
4404
4405 /*
4406 ** CAPI3REF: Open A BLOB For Incremental I/O
4407 **
4408 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
4409 ** in row iRow, column zColumn, table zTable in database zDb;
4410 ** in other words, the same BLOB that would be selected by:
4411 **
4412 ** <pre>
4413 ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow;
4414 ** </pre>)^
4415 **
4416 ** ^If the flags parameter is non-zero, then the BLOB is opened for read
4417 ** and write access. ^If it is zero, the BLOB is opened for read access.
4418 ** ^It is not possible to open a column that is part of an index or primary
4419 ** key for writing. ^If [foreign key constraints] are enabled, it is
4420 ** not possible to open a column that is part of a [child key] for writing.
4421 **
4422 ** ^Note that the database name is not the filename that contains
4423 ** the database but rather the symbolic name of the database that
4424 ** appears after the AS keyword when the database is connected using [ATTACH].
4425 ** ^For the main database file, the database name is "main".
4426 ** ^For TEMP tables, the database name is "temp".
4427 **
4428 ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is written
4429 ** to *ppBlob. Otherwise an [error code] is returned and *ppBlob is set
4430 ** to be a null pointer.)^
4431 ** ^This function sets the [database connection] error code and message
4432 ** accessible via [sqlite3_errcode()] and [sqlite3_errmsg()] and related
4433 ** functions. ^Note that the *ppBlob variable is always initialized in a
4434 ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob
4435 ** regardless of the success or failure of this routine.
4436 **
4437 ** ^(If the row that a BLOB handle points to is modified by an
4438 ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects
4439 ** then the BLOB handle is marked as "expired".
4440 ** This is true if any column of the row is changed, even a column
4441 ** other than the one the BLOB handle is open on.)^
4442 ** ^Calls to [sqlite3_blob_read()] and [sqlite3_blob_write()] for
4443 ** a expired BLOB handle fail with an return code of [SQLITE_ABORT].
4444 ** ^(Changes written into a BLOB prior to the BLOB expiring are not
4445 ** rolled back by the expiration of the BLOB. Such changes will eventually
4446 ** commit if the transaction continues to completion.)^
4447 **
4448 ** ^Use the [sqlite3_blob_bytes()] interface to determine the size of
4449 ** the opened blob. ^The size of a blob may not be changed by this
4450 ** interface. Use the [UPDATE] SQL command to change the size of a
4451 ** blob.
4452 **
4453 ** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces
4454 ** and the built-in [zeroblob] SQL function can be used, if desired,
4455 ** to create an empty, zero-filled blob in which to read or write using
4456 ** this interface.
4457 **
4458 ** To avoid a resource leak, every open [BLOB handle] should eventually
4459 ** be released by a call to [sqlite3_blob_close()].
 
 
 
4460 */
4461 SQLITE_API int sqlite3_blob_open(
4462 sqlite3*,
4463 const char *zDb,
4464 const char *zTable,
@@ -4581,201 +4467,185 @@
4467 int flags,
4468 sqlite3_blob **ppBlob
4469 );
4470
4471 /*
4472 ** CAPI3REF: Close A BLOB Handle
4473 **
4474 ** ^Closes an open [BLOB handle].
4475 **
4476 ** ^Closing a BLOB shall cause the current transaction to commit
4477 ** if there are no other BLOBs, no pending prepared statements, and the
4478 ** database connection is in [autocommit mode].
4479 ** ^If any writes were made to the BLOB, they might be held in cache
4480 ** until the close operation if they will fit.
4481 **
4482 ** ^(Closing the BLOB often forces the changes
4483 ** out to disk and so if any I/O errors occur, they will likely occur
4484 ** at the time when the BLOB is closed. Any errors that occur during
4485 ** closing are reported as a non-zero return value.)^
4486 **
4487 ** ^(The BLOB is closed unconditionally. Even if this routine returns
4488 ** an error code, the BLOB is still closed.)^
4489 **
4490 ** ^Calling this routine with a null pointer (such as would be returned
4491 ** by a failed call to [sqlite3_blob_open()]) is a harmless no-op.
 
 
 
4492 */
4493 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
4494
4495 /*
4496 ** CAPI3REF: Return The Size Of An Open BLOB
4497 **
4498 ** ^Returns the size in bytes of the BLOB accessible via the
4499 ** successfully opened [BLOB handle] in its only argument. ^The
4500 ** incremental blob I/O routines can only read or overwriting existing
4501 ** blob content; they cannot change the size of a blob.
4502 **
4503 ** This routine only works on a [BLOB handle] which has been created
4504 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4505 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4506 ** to this routine results in undefined and probably undesirable behavior.
 
 
 
4507 */
4508 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
4509
4510 /*
4511 ** CAPI3REF: Read Data From A BLOB Incrementally
4512 **
4513 ** ^(This function is used to read data from an open [BLOB handle] into a
4514 ** caller-supplied buffer. N bytes of data are copied into buffer Z
4515 ** from the open BLOB, starting at offset iOffset.)^
4516 **
4517 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
4518 ** [SQLITE_ERROR] is returned and no data is read. ^If N or iOffset is
4519 ** less than zero, [SQLITE_ERROR] is returned and no data is read.
4520 ** ^The size of the blob (and hence the maximum value of N+iOffset)
4521 ** can be determined using the [sqlite3_blob_bytes()] interface.
4522 **
4523 ** ^An attempt to read from an expired [BLOB handle] fails with an
4524 ** error code of [SQLITE_ABORT].
4525 **
4526 ** ^(On success, sqlite3_blob_read() returns SQLITE_OK.
4527 ** Otherwise, an [error code] or an [extended error code] is returned.)^
4528 **
4529 ** This routine only works on a [BLOB handle] which has been created
4530 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4531 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4532 ** to this routine results in undefined and probably undesirable behavior.
4533 **
4534 ** See also: [sqlite3_blob_write()].
 
 
 
4535 */
4536 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
4537
4538 /*
4539 ** CAPI3REF: Write Data Into A BLOB Incrementally
4540 **
4541 ** ^This function is used to write data into an open [BLOB handle] from a
4542 ** caller-supplied buffer. ^N bytes of data are copied from the buffer Z
4543 ** into the open BLOB, starting at offset iOffset.
4544 **
4545 ** ^If the [BLOB handle] passed as the first argument was not opened for
4546 ** writing (the flags parameter to [sqlite3_blob_open()] was zero),
4547 ** this function returns [SQLITE_READONLY].
4548 **
4549 ** ^This function may only modify the contents of the BLOB; it is
4550 ** not possible to increase the size of a BLOB using this API.
4551 ** ^If offset iOffset is less than N bytes from the end of the BLOB,
4552 ** [SQLITE_ERROR] is returned and no data is written. ^If N is
4553 ** less than zero [SQLITE_ERROR] is returned and no data is written.
4554 ** The size of the BLOB (and hence the maximum value of N+iOffset)
4555 ** can be determined using the [sqlite3_blob_bytes()] interface.
4556 **
4557 ** ^An attempt to write to an expired [BLOB handle] fails with an
4558 ** error code of [SQLITE_ABORT]. ^Writes to the BLOB that occurred
4559 ** before the [BLOB handle] expired are not rolled back by the
4560 ** expiration of the handle, though of course those changes might
4561 ** have been overwritten by the statement that expired the BLOB handle
4562 ** or by other independent statements.
4563 **
4564 ** ^(On success, sqlite3_blob_write() returns SQLITE_OK.
4565 ** Otherwise, an [error code] or an [extended error code] is returned.)^
4566 **
4567 ** This routine only works on a [BLOB handle] which has been created
4568 ** by a prior successful call to [sqlite3_blob_open()] and which has not
4569 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
4570 ** to this routine results in undefined and probably undesirable behavior.
4571 **
4572 ** See also: [sqlite3_blob_read()].
 
 
 
 
4573 */
4574 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
4575
4576 /*
4577 ** CAPI3REF: Virtual File System Objects
4578 **
4579 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
4580 ** that SQLite uses to interact
4581 ** with the underlying operating system. Most SQLite builds come with a
4582 ** single default VFS that is appropriate for the host computer.
4583 ** New VFSes can be registered and existing VFSes can be unregistered.
4584 ** The following interfaces are provided.
4585 **
4586 ** ^The sqlite3_vfs_find() interface returns a pointer to a VFS given its name.
4587 ** ^Names are case sensitive.
4588 ** ^Names are zero-terminated UTF-8 strings.
4589 ** ^If there is no match, a NULL pointer is returned.
4590 ** ^If zVfsName is NULL then the default VFS is returned.
4591 **
4592 ** ^New VFSes are registered with sqlite3_vfs_register().
4593 ** ^Each new VFS becomes the default VFS if the makeDflt flag is set.
4594 ** ^The same VFS can be registered multiple times without injury.
4595 ** ^To make an existing VFS into the default VFS, register it again
4596 ** with the makeDflt flag set. If two different VFSes with the
4597 ** same name are registered, the behavior is undefined. If a
4598 ** VFS is registered with a name that is NULL or an empty string,
4599 ** then the behavior is undefined.
4600 **
4601 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
4602 ** ^(If the default VFS is unregistered, another VFS is chosen as
4603 ** the default. The choice for the new VFS is arbitrary.)^
 
 
 
4604 */
4605 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
4606 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
4607 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
4608
4609 /*
4610 ** CAPI3REF: Mutexes
4611 **
4612 ** The SQLite core uses these routines for thread
4613 ** synchronization. Though they are intended for internal
4614 ** use by SQLite, code that links against SQLite is
4615 ** permitted to use any of these routines.
4616 **
4617 ** The SQLite source code contains multiple implementations
4618 ** of these mutex routines. An appropriate implementation
4619 ** is selected automatically at compile-time. ^(The following
4620 ** implementations are available in the SQLite core:
4621 **
4622 ** <ul>
4623 ** <li> SQLITE_MUTEX_OS2
4624 ** <li> SQLITE_MUTEX_PTHREAD
4625 ** <li> SQLITE_MUTEX_W32
4626 ** <li> SQLITE_MUTEX_NOOP
4627 ** </ul>)^
4628 **
4629 ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines
4630 ** that does no real locking and is appropriate for use in
4631 ** a single-threaded application. ^The SQLITE_MUTEX_OS2,
4632 ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations
4633 ** are appropriate for use on OS/2, Unix, and Windows.
4634 **
4635 ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor
4636 ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex
4637 ** implementation is included with the library. In this case the
4638 ** application must supply a custom mutex implementation using the
4639 ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function
4640 ** before calling sqlite3_initialize() or any other public sqlite3_
4641 ** function that calls sqlite3_initialize().)^
4642 **
4643 ** ^The sqlite3_mutex_alloc() routine allocates a new
4644 ** mutex and returns a pointer to it. ^If it returns NULL
4645 ** that means that a mutex could not be allocated. ^SQLite
4646 ** will unwind its stack and return an error. ^(The argument
4647 ** to sqlite3_mutex_alloc() is one of these integer constants:
4648 **
4649 ** <ul>
4650 ** <li> SQLITE_MUTEX_FAST
4651 ** <li> SQLITE_MUTEX_RECURSIVE
@@ -4783,68 +4653,70 @@
4653 ** <li> SQLITE_MUTEX_STATIC_MEM
4654 ** <li> SQLITE_MUTEX_STATIC_MEM2
4655 ** <li> SQLITE_MUTEX_STATIC_PRNG
4656 ** <li> SQLITE_MUTEX_STATIC_LRU
4657 ** <li> SQLITE_MUTEX_STATIC_LRU2
4658 ** </ul>)^
4659 **
4660 ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE)
4661 ** cause sqlite3_mutex_alloc() to create
4662 ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE
4663 ** is used but not necessarily so when SQLITE_MUTEX_FAST is used.
4664 ** The mutex implementation does not need to make a distinction
4665 ** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does
4666 ** not want to. ^SQLite will only request a recursive mutex in
4667 ** cases where it really needs one. ^If a faster non-recursive mutex
4668 ** implementation is available on the host platform, the mutex subsystem
4669 ** might return such a mutex in response to SQLITE_MUTEX_FAST.
4670 **
4671 ** ^The other allowed parameters to sqlite3_mutex_alloc() (anything other
4672 ** than SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) each return
4673 ** a pointer to a static preexisting mutex. ^Six static mutexes are
4674 ** used by the current version of SQLite. Future versions of SQLite
4675 ** may add additional static mutexes. Static mutexes are for internal
4676 ** use by SQLite only. Applications that use SQLite mutexes should
4677 ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or
4678 ** SQLITE_MUTEX_RECURSIVE.
4679 **
4680 ** ^Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST
4681 ** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc()
4682 ** returns a different mutex on every call. ^But for the static
4683 ** mutex types, the same mutex is returned on every call that has
4684 ** the same type number.
4685 **
4686 ** ^The sqlite3_mutex_free() routine deallocates a previously
4687 ** allocated dynamic mutex. ^SQLite is careful to deallocate every
4688 ** dynamic mutex that it allocates. The dynamic mutexes must not be in
4689 ** use when they are deallocated. Attempting to deallocate a static
4690 ** mutex results in undefined behavior. ^SQLite never deallocates
4691 ** a static mutex.
4692 **
4693 ** ^The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
4694 ** to enter a mutex. ^If another thread is already within the mutex,
4695 ** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
4696 ** SQLITE_BUSY. ^The sqlite3_mutex_try() interface returns [SQLITE_OK]
4697 ** upon successful entry. ^(Mutexes created using
4698 ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread.
4699 ** In such cases the,
4700 ** mutex must be exited an equal number of times before another thread
4701 ** can enter.)^ ^(If the same thread tries to enter any other
4702 ** kind of mutex more than once, the behavior is undefined.
4703 ** SQLite will never exhibit
4704 ** such behavior in its own use of mutexes.)^
4705 **
4706 ** ^(Some systems (for example, Windows 95) do not support the operation
4707 ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
4708 ** will always return SQLITE_BUSY. The SQLite core only ever uses
4709 ** sqlite3_mutex_try() as an optimization so this is acceptable behavior.)^
4710 **
4711 ** ^The sqlite3_mutex_leave() routine exits a mutex that was
4712 ** previously entered by the same thread. ^(The behavior
4713 ** is undefined if the mutex is not currently entered by the
4714 ** calling thread or is not currently allocated. SQLite will
4715 ** never do either.)^
4716 **
4717 ** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or
4718 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
4719 ** behave as no-ops.
4720 **
4721 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
4722 */
@@ -4853,11 +4725,11 @@
4725 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
4726 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
4727 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
4728
4729 /*
4730 ** CAPI3REF: Mutex Methods Object
4731 ** EXPERIMENTAL
4732 **
4733 ** An instance of this structure defines the low-level routines
4734 ** used to allocate and use mutexes.
4735 **
@@ -4869,23 +4741,23 @@
4741 ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option.
4742 ** Additionally, an instance of this structure can be used as an
4743 ** output variable when querying the system for the current mutex
4744 ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option.
4745 **
4746 ** ^The xMutexInit method defined by this structure is invoked as
4747 ** part of system initialization by the sqlite3_initialize() function.
4748 ** ^The xMutexInit routine is calle by SQLite exactly once for each
4749 ** effective call to [sqlite3_initialize()].
4750 **
4751 ** ^The xMutexEnd method defined by this structure is invoked as
4752 ** part of system shutdown by the sqlite3_shutdown() function. The
4753 ** implementation of this method is expected to release all outstanding
4754 ** resources obtained by the mutex methods implementation, especially
4755 ** those obtained by the xMutexInit method. ^The xMutexEnd()
4756 ** interface is invoked exactly once for each call to [sqlite3_shutdown()].
4757 **
4758 ** ^(The remaining seven methods defined by this structure (xMutexAlloc,
4759 ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and
4760 ** xMutexNotheld) implement the following interfaces (respectively):
4761 **
4762 ** <ul>
4763 ** <li> [sqlite3_mutex_alloc()] </li>
@@ -4893,31 +4765,31 @@
4765 ** <li> [sqlite3_mutex_enter()] </li>
4766 ** <li> [sqlite3_mutex_try()] </li>
4767 ** <li> [sqlite3_mutex_leave()] </li>
4768 ** <li> [sqlite3_mutex_held()] </li>
4769 ** <li> [sqlite3_mutex_notheld()] </li>
4770 ** </ul>)^
4771 **
4772 ** The only difference is that the public sqlite3_XXX functions enumerated
4773 ** above silently ignore any invocations that pass a NULL pointer instead
4774 ** of a valid mutex handle. The implementations of the methods defined
4775 ** by this structure are not required to handle this case, the results
4776 ** of passing a NULL pointer instead of a valid mutex handle are undefined
4777 ** (i.e. it is acceptable to provide an implementation that segfaults if
4778 ** it is passed a NULL pointer).
4779 **
4780 ** The xMutexInit() method must be threadsafe. ^It must be harmless to
4781 ** invoke xMutexInit() mutiple times within the same process and without
4782 ** intervening calls to xMutexEnd(). Second and subsequent calls to
4783 ** xMutexInit() must be no-ops.
4784 **
4785 ** ^xMutexInit() must not use SQLite memory allocation ([sqlite3_malloc()]
4786 ** and its associates). ^Similarly, xMutexAlloc() must not use SQLite memory
4787 ** allocation for a static mutex. ^However xMutexAlloc() may use SQLite
4788 ** memory allocation for a fast or recursive mutex.
4789 **
4790 ** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is
4791 ** called, but only if the prior call to xMutexInit returned SQLITE_OK.
4792 ** If xMutexInit fails in any way, it is expected to clean up after itself
4793 ** prior to returning.
4794 */
4795 typedef struct sqlite3_mutex_methods sqlite3_mutex_methods;
@@ -4932,43 +4804,45 @@
4804 int (*xMutexHeld)(sqlite3_mutex *);
4805 int (*xMutexNotheld)(sqlite3_mutex *);
4806 };
4807
4808 /*
4809 ** CAPI3REF: Mutex Verification Routines
4810 **
4811 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routines
4812 ** are intended for use inside assert() statements. ^The SQLite core
4813 ** never uses these routines except inside an assert() and applications
4814 ** are advised to follow the lead of the core. ^The SQLite core only
4815 ** provides implementations for these routines when it is compiled
4816 ** with the SQLITE_DEBUG flag. ^External mutex implementations
4817 ** are only required to provide these routines if SQLITE_DEBUG is
4818 ** defined and if NDEBUG is not defined.
4819 **
4820 ** ^These routines should return true if the mutex in their argument
4821 ** is held or not held, respectively, by the calling thread.
4822 **
4823 ** ^The implementation is not required to provided versions of these
4824 ** routines that actually work. If the implementation does not provide working
4825 ** versions of these routines, it should at least provide stubs that always
4826 ** return true so that one does not get spurious assertion failures.
4827 **
4828 ** ^If the argument to sqlite3_mutex_held() is a NULL pointer then
4829 ** the routine should return 1. This seems counter-intuitive since
4830 ** clearly the mutex cannot be held if it does not exist. But the
4831 ** the reason the mutex does not exist is because the build is not
4832 ** using mutexes. And we do not want the assert() containing the
4833 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
4834 ** the appropriate thing to do. ^The sqlite3_mutex_notheld()
4835 ** interface should also return 1 when given a NULL pointer.
4836 */
4837 #ifndef NDEBUG
4838 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
4839 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
4840 #endif
4841
4842 /*
4843 ** CAPI3REF: Mutex Types
4844 **
4845 ** The [sqlite3_mutex_alloc()] interface takes a single argument
4846 ** which is one of these integer constants.
4847 **
4848 ** The set of static mutexes may change from one SQLite release to the
@@ -4984,52 +4858,54 @@
4858 #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */
4859 #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */
4860 #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */
4861
4862 /*
4863 ** CAPI3REF: Retrieve the mutex for a database connection
4864 **
4865 ** ^This interface returns a pointer the [sqlite3_mutex] object that
4866 ** serializes access to the [database connection] given in the argument
4867 ** when the [threading mode] is Serialized.
4868 ** ^If the [threading mode] is Single-thread or Multi-thread then this
4869 ** routine returns a NULL pointer.
4870 */
4871 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
4872
4873 /*
4874 ** CAPI3REF: Low-Level Control Of Database Files
4875 **
4876 ** ^The [sqlite3_file_control()] interface makes a direct call to the
4877 ** xFileControl method for the [sqlite3_io_methods] object associated
4878 ** with a particular database identified by the second argument. ^The
4879 ** name of the database "main" for the main database or "temp" for the
4880 ** TEMP database, or the name that appears after the AS keyword for
4881 ** databases that are added using the [ATTACH] SQL command.
4882 ** ^A NULL pointer can be used in place of "main" to refer to the
4883 ** main database file.
4884 ** ^The third and fourth parameters to this routine
4885 ** are passed directly through to the second and third parameters of
4886 ** the xFileControl method. ^The return value of the xFileControl
4887 ** method becomes the return value of this routine.
4888 **
4889 ** ^If the second parameter (zDbName) does not match the name of any
4890 ** open database file, then SQLITE_ERROR is returned. ^This error
4891 ** code is not remembered and will not be recalled by [sqlite3_errcode()]
4892 ** or [sqlite3_errmsg()]. The underlying xFileControl method might
4893 ** also return SQLITE_ERROR. There is no way to distinguish between
4894 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
4895 ** xFileControl method.
4896 **
4897 ** See also: [SQLITE_FCNTL_LOCKSTATE]
4898 */
4899 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
4900
4901 /*
4902 ** CAPI3REF: Testing Interface
4903 **
4904 ** ^The sqlite3_test_control() interface is used to read out internal
4905 ** state of SQLite and to inject faults into SQLite for testing
4906 ** purposes. ^The first parameter is an operation code that determines
4907 ** the number, meaning, and operation of all subsequent parameters.
4908 **
4909 ** This interface is not for use by applications. It exists solely
4910 ** for verifying the correct operation of the SQLite library. Depending
4911 ** on how the SQLite library is compiled, this interface might not exist.
@@ -5040,20 +4916,21 @@
4916 ** operate consistently from one release to the next.
4917 */
4918 SQLITE_API int sqlite3_test_control(int op, ...);
4919
4920 /*
4921 ** CAPI3REF: Testing Interface Operation Codes
4922 **
4923 ** These constants are the valid operation code parameters used
4924 ** as the first argument to [sqlite3_test_control()].
4925 **
4926 ** These parameters and their meanings are subject to change
4927 ** without notice. These values are for testing purposes only.
4928 ** Applications should not use any of these parameters or the
4929 ** [sqlite3_test_control()] interface.
4930 */
4931 #define SQLITE_TESTCTRL_FIRST 5
4932 #define SQLITE_TESTCTRL_PRNG_SAVE 5
4933 #define SQLITE_TESTCTRL_PRNG_RESTORE 6
4934 #define SQLITE_TESTCTRL_PRNG_RESET 7
4935 #define SQLITE_TESTCTRL_BITVEC_TEST 8
4936 #define SQLITE_TESTCTRL_FAULT_INSTALL 9
@@ -5060,31 +4937,34 @@
4937 #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
4938 #define SQLITE_TESTCTRL_PENDING_BYTE 11
4939 #define SQLITE_TESTCTRL_ASSERT 12
4940 #define SQLITE_TESTCTRL_ALWAYS 13
4941 #define SQLITE_TESTCTRL_RESERVE 14
4942 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
4943 #define SQLITE_TESTCTRL_ISKEYWORD 16
4944 #define SQLITE_TESTCTRL_LAST 16
4945
4946 /*
4947 ** CAPI3REF: SQLite Runtime Status
4948 ** EXPERIMENTAL
4949 **
4950 ** ^This interface is used to retrieve runtime status information
4951 ** about the preformance of SQLite, and optionally to reset various
4952 ** highwater marks. ^The first argument is an integer code for
4953 ** the specific parameter to measure. ^(Recognized integer codes
4954 ** are of the form [SQLITE_STATUS_MEMORY_USED | SQLITE_STATUS_...].)^
4955 ** ^The current value of the parameter is returned into *pCurrent.
4956 ** ^The highest recorded value is returned in *pHighwater. ^If the
4957 ** resetFlag is true, then the highest record value is reset after
4958 ** *pHighwater is written. ^(Some parameters do not record the highest
4959 ** value. For those parameters
4960 ** nothing is written into *pHighwater and the resetFlag is ignored.)^
4961 ** ^(Other parameters record only the highwater mark and not the current
4962 ** value. For these latter parameters nothing is written into *pCurrent.)^
4963 **
4964 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
4965 ** non-zero [error code] on failure.
4966 **
4967 ** This routine is threadsafe but is not atomic. This routine can be
4968 ** called while other threads are running the same or different SQLite
4969 ** interfaces. However the values returned in *pCurrent and
4970 ** *pHighwater reflect the status of SQLite at different points in time
@@ -5095,82 +4975,82 @@
4975 */
4976 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
4977
4978
4979 /*
4980 ** CAPI3REF: Status Parameters
4981 ** EXPERIMENTAL
4982 **
4983 ** These integer constants designate various run-time status parameters
4984 ** that can be returned by [sqlite3_status()].
4985 **
4986 ** <dl>
4987 ** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt>
4988 ** <dd>This parameter is the current amount of memory checked out
4989 ** using [sqlite3_malloc()], either directly or indirectly. The
4990 ** figure includes calls made to [sqlite3_malloc()] by the application
4991 ** and internal memory usage by the SQLite library. Scratch memory
4992 ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache
4993 ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in
4994 ** this parameter. The amount returned is the sum of the allocation
4995 ** sizes as reported by the xSize method in [sqlite3_mem_methods].</dd>)^
4996 **
4997 ** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt>
4998 ** <dd>This parameter records the largest memory allocation request
4999 ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their
5000 ** internal equivalents). Only the value returned in the
5001 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5002 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5003 **
5004 ** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt>
5005 ** <dd>This parameter returns the number of pages used out of the
5006 ** [pagecache memory allocator] that was configured using
5007 ** [SQLITE_CONFIG_PAGECACHE]. The
5008 ** value returned is in pages, not in bytes.</dd>)^
5009 **
5010 ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt>
5011 ** <dd>This parameter returns the number of bytes of page cache
5012 ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE]
5013 ** buffer and where forced to overflow to [sqlite3_malloc()]. The
5014 ** returned value includes allocations that overflowed because they
5015 ** where too large (they were larger than the "sz" parameter to
5016 ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because
5017 ** no space was left in the page cache.</dd>)^
5018 **
5019 ** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt>
5020 ** <dd>This parameter records the largest memory allocation request
5021 ** handed to [pagecache memory allocator]. Only the value returned in the
5022 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5023 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5024 **
5025 ** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt>
5026 ** <dd>This parameter returns the number of allocations used out of the
5027 ** [scratch memory allocator] configured using
5028 ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not
5029 ** in bytes. Since a single thread may only have one scratch allocation
5030 ** outstanding at time, this parameter also reports the number of threads
5031 ** using scratch memory at the same time.</dd>)^
5032 **
5033 ** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt>
5034 ** <dd>This parameter returns the number of bytes of scratch memory
5035 ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH]
5036 ** buffer and where forced to overflow to [sqlite3_malloc()]. The values
5037 ** returned include overflows because the requested allocation was too
5038 ** larger (that is, because the requested allocation was larger than the
5039 ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer
5040 ** slots were available.
5041 ** </dd>)^
5042 **
5043 ** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt>
5044 ** <dd>This parameter records the largest memory allocation request
5045 ** handed to [scratch memory allocator]. Only the value returned in the
5046 ** *pHighwater parameter to [sqlite3_status()] is of interest.
5047 ** The value written into the *pCurrent parameter is undefined.</dd>)^
5048 **
5049 ** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt>
5050 ** <dd>This parameter records the deepest parser stack. It is only
5051 ** meaningful if SQLite is compiled with [YYTRACKMAXSTACKDEPTH].</dd>)^
5052 ** </dl>
5053 **
5054 ** New status parameters may be added from time to time.
5055 */
5056 #define SQLITE_STATUS_MEMORY_USED 0
@@ -5182,31 +5062,31 @@
5062 #define SQLITE_STATUS_PARSER_STACK 6
5063 #define SQLITE_STATUS_PAGECACHE_SIZE 7
5064 #define SQLITE_STATUS_SCRATCH_SIZE 8
5065
5066 /*
5067 ** CAPI3REF: Database Connection Status
5068 ** EXPERIMENTAL
5069 **
5070 ** ^This interface is used to retrieve runtime status information
5071 ** about a single [database connection]. ^The first argument is the
5072 ** database connection object to be interrogated. ^The second argument
5073 ** is the parameter to interrogate. ^Currently, the only allowed value
5074 ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED].
5075 ** Additional options will likely appear in future releases of SQLite.
5076 **
5077 ** ^The current value of the requested parameter is written into *pCur
5078 ** and the highest instantaneous value is written into *pHiwtr. ^If
5079 ** the resetFlg is true, then the highest instantaneous value is
5080 ** reset back down to the current value.
5081 **
5082 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
5083 */
5084 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
5085
5086 /*
5087 ** CAPI3REF: Status Parameters for database connections
5088 ** EXPERIMENTAL
5089 **
5090 ** These constants are the available integer "verbs" that can be passed as
5091 ** the second argument to the [sqlite3_db_status()] interface.
5092 **
@@ -5215,61 +5095,61 @@
5095 ** [sqlite3_db_status()] to make sure that the call worked.
5096 ** The [sqlite3_db_status()] interface will return a non-zero error code
5097 ** if a discontinued or unsupported verb is invoked.
5098 **
5099 ** <dl>
5100 ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt>
5101 ** <dd>This parameter returns the number of lookaside memory slots currently
5102 ** checked out.</dd>)^
5103 ** </dl>
5104 */
5105 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
5106
5107
5108 /*
5109 ** CAPI3REF: Prepared Statement Status
5110 ** EXPERIMENTAL
5111 **
5112 ** ^(Each prepared statement maintains various
5113 ** [SQLITE_STMTSTATUS_SORT | counters] that measure the number
5114 ** of times it has performed specific operations.)^ These counters can
5115 ** be used to monitor the performance characteristics of the prepared
5116 ** statements. For example, if the number of table steps greatly exceeds
5117 ** the number of table searches or result rows, that would tend to indicate
5118 ** that the prepared statement is using a full table scan rather than
5119 ** an index.
5120 **
5121 ** ^(This interface is used to retrieve and reset counter values from
5122 ** a [prepared statement]. The first argument is the prepared statement
5123 ** object to be interrogated. The second argument
5124 ** is an integer code for a specific [SQLITE_STMTSTATUS_SORT | counter]
5125 ** to be interrogated.)^
5126 ** ^The current value of the requested counter is returned.
5127 ** ^If the resetFlg is true, then the counter is reset to zero after this
5128 ** interface call returns.
5129 **
5130 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
5131 */
5132 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
5133
5134 /*
5135 ** CAPI3REF: Status Parameters for prepared statements
5136 ** EXPERIMENTAL
5137 **
5138 ** These preprocessor macros define integer codes that name counter
5139 ** values associated with the [sqlite3_stmt_status()] interface.
5140 ** The meanings of the various counters are as follows:
5141 **
5142 ** <dl>
5143 ** <dt>SQLITE_STMTSTATUS_FULLSCAN_STEP</dt>
5144 ** <dd>^This is the number of times that SQLite has stepped forward in
5145 ** a table as part of a full table scan. Large numbers for this counter
5146 ** may indicate opportunities for performance improvement through
5147 ** careful use of indices.</dd>
5148 **
5149 ** <dt>SQLITE_STMTSTATUS_SORT</dt>
5150 ** <dd>^This is the number of sort operations that have occurred.
5151 ** A non-zero value in this counter may indicate an opportunity to
5152 ** improvement performance through careful use of indices.</dd>
5153 **
5154 ** </dl>
5155 */
@@ -5293,84 +5173,84 @@
5173 /*
5174 ** CAPI3REF: Application Defined Page Cache.
5175 ** KEYWORDS: {page cache}
5176 ** EXPERIMENTAL
5177 **
5178 ** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can
5179 ** register an alternative page cache implementation by passing in an
5180 ** instance of the sqlite3_pcache_methods structure.)^ The majority of the
5181 ** heap memory used by SQLite is used by the page cache to cache data read
5182 ** from, or ready to be written to, the database file. By implementing a
5183 ** custom page cache using this API, an application can control more
5184 ** precisely the amount of memory consumed by SQLite, the way in which
5185 ** that memory is allocated and released, and the policies used to
5186 ** determine exactly which parts of a database file are cached and for
5187 ** how long.
5188 **
5189 ** ^(The contents of the sqlite3_pcache_methods structure are copied to an
5190 ** internal buffer by SQLite within the call to [sqlite3_config]. Hence
5191 ** the application may discard the parameter after the call to
5192 ** [sqlite3_config()] returns.)^
5193 **
5194 ** ^The xInit() method is called once for each call to [sqlite3_initialize()]
5195 ** (usually only once during the lifetime of the process). ^(The xInit()
5196 ** method is passed a copy of the sqlite3_pcache_methods.pArg value.)^
5197 ** ^The xInit() method can set up up global structures and/or any mutexes
5198 ** required by the custom page cache implementation.
5199 **
5200 ** ^The xShutdown() method is called from within [sqlite3_shutdown()],
5201 ** if the application invokes this API. It can be used to clean up
5202 ** any outstanding resources before process shutdown, if required.
5203 **
5204 ** ^SQLite holds a [SQLITE_MUTEX_RECURSIVE] mutex when it invokes
5205 ** the xInit method, so the xInit method need not be threadsafe. ^The
5206 ** xShutdown method is only called from [sqlite3_shutdown()] so it does
5207 ** not need to be threadsafe either. All other methods must be threadsafe
5208 ** in multithreaded applications.
5209 **
5210 ** ^SQLite will never invoke xInit() more than once without an intervening
5211 ** call to xShutdown().
5212 **
5213 ** ^The xCreate() method is used to construct a new cache instance. SQLite
5214 ** will typically create one cache instance for each open database file,
5215 ** though this is not guaranteed. ^The
5216 ** first parameter, szPage, is the size in bytes of the pages that must
5217 ** be allocated by the cache. ^szPage will not be a power of two. ^szPage
5218 ** will the page size of the database file that is to be cached plus an
5219 ** increment (here called "R") of about 100 or 200. ^SQLite will use the
5220 ** extra R bytes on each page to store metadata about the underlying
5221 ** database page on disk. The value of R depends
5222 ** on the SQLite version, the target platform, and how SQLite was compiled.
5223 ** ^R is constant for a particular build of SQLite. ^The second argument to
5224 ** xCreate(), bPurgeable, is true if the cache being created will
5225 ** be used to cache database pages of a file stored on disk, or
5226 ** false if it is used for an in-memory database. ^The cache implementation
5227 ** does not have to do anything special based with the value of bPurgeable;
5228 ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will
5229 ** never invoke xUnpin() except to deliberately delete a page.
5230 ** ^In other words, a cache created with bPurgeable set to false will
5231 ** never contain any unpinned pages.
5232 **
5233 ** ^(The xCachesize() method may be called at any time by SQLite to set the
5234 ** suggested maximum cache-size (number of pages stored by) the cache
5235 ** instance passed as the first argument. This is the value configured using
5236 ** the SQLite "[PRAGMA cache_size]" command.)^ ^As with the bPurgeable
5237 ** parameter, the implementation is not required to do anything with this
5238 ** value; it is advisory only.
5239 **
5240 ** ^The xPagecount() method should return the number of pages currently
5241 ** stored in the cache.
5242 **
5243 ** ^The xFetch() method is used to fetch a page and return a pointer to it.
5244 ** ^A 'page', in this context, is a buffer of szPage bytes aligned at an
5245 ** 8-byte boundary. ^The page to be fetched is determined by the key. ^The
5246 ** mimimum key value is 1. After it has been retrieved using xFetch, the page
5247 ** is considered to be "pinned".
5248 **
5249 ** ^If the requested page is already in the page cache, then the page cache
5250 ** implementation must return a pointer to the page buffer with its content
5251 ** intact. ^(If the requested page is not already in the cache, then the
5252 ** behavior of the cache implementation is determined by the value of the
5253 ** createFlag parameter passed to xFetch, according to the following table:
5254 **
5255 ** <table border=1 width=85% align=center>
5256 ** <tr><th> createFlag <th> Behaviour when page is not already in cache
@@ -5377,45 +5257,45 @@
5257 ** <tr><td> 0 <td> Do not allocate a new page. Return NULL.
5258 ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so.
5259 ** Otherwise return NULL.
5260 ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return
5261 ** NULL if allocating a new page is effectively impossible.
5262 ** </table>)^
5263 **
5264 ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If
5265 ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will
5266 ** attempt to unpin one or more cache pages by spilling the content of
5267 ** pinned pages to disk and synching the operating system disk cache. After
5268 ** attempting to unpin pages, the xFetch() method will be invoked again with
5269 ** a createFlag of 2.
5270 **
5271 ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page
5272 ** as its second argument. ^(If the third parameter, discard, is non-zero,
5273 ** then the page should be evicted from the cache. In this case SQLite
5274 ** assumes that the next time the page is retrieved from the cache using
5275 ** the xFetch() method, it will be zeroed.)^ ^If the discard parameter is
5276 ** zero, then the page is considered to be unpinned. ^The cache implementation
5277 ** may choose to evict unpinned pages at any time.
5278 **
5279 ** ^(The cache is not required to perform any reference counting. A single
5280 ** call to xUnpin() unpins the page regardless of the number of prior calls
5281 ** to xFetch().)^
5282 **
5283 ** ^The xRekey() method is used to change the key value associated with the
5284 ** page passed as the second argument from oldKey to newKey. ^If the cache
5285 ** previously contains an entry associated with newKey, it should be
5286 ** discarded. ^Any prior cache entry associated with newKey is guaranteed not
5287 ** to be pinned.
5288 **
5289 ** ^When SQLite calls the xTruncate() method, the cache must discard all
5290 ** existing cache entries with page numbers (keys) greater than or equal
5291 ** to the value of the iLimit parameter passed to xTruncate(). ^If any
5292 ** of these pages are pinned, they are implicitly unpinned, meaning that
5293 ** they can be safely discarded.
5294 **
5295 ** ^The xDestroy() method is used to delete a cache allocated by xCreate().
5296 ** All resources associated with the specified cache should be freed. ^After
5297 ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*]
5298 ** handle invalid, and will not use it with any other sqlite3_pcache_methods
5299 ** functions.
5300 */
5301 typedef struct sqlite3_pcache_methods sqlite3_pcache_methods;
@@ -5436,11 +5316,11 @@
5316 /*
5317 ** CAPI3REF: Online Backup Object
5318 ** EXPERIMENTAL
5319 **
5320 ** The sqlite3_backup object records state information about an ongoing
5321 ** online backup operation. ^The sqlite3_backup object is created by
5322 ** a call to [sqlite3_backup_init()] and is destroyed by a call to
5323 ** [sqlite3_backup_finish()].
5324 **
5325 ** See Also: [Using the SQLite Online Backup API]
5326 */
@@ -5448,168 +5328,173 @@
5328
5329 /*
5330 ** CAPI3REF: Online Backup API.
5331 ** EXPERIMENTAL
5332 **
5333 ** The backup API copies the content of one database into another.
5334 ** It is useful either for creating backups of databases or
5335 ** for copying in-memory databases to or from persistent files.
5336 **
5337 ** See Also: [Using the SQLite Online Backup API]
5338 **
5339 ** ^Exclusive access is required to the destination database for the
5340 ** duration of the operation. ^However the source database is only
5341 ** read-locked while it is actually being read; it is not locked
5342 ** continuously for the entire backup operation. ^Thus, the backup may be
5343 ** performed on a live source database without preventing other users from
5344 ** reading or writing to the source database while the backup is underway.
5345 **
5346 ** ^(To perform a backup operation:
5347 ** <ol>
5348 ** <li><b>sqlite3_backup_init()</b> is called once to initialize the
5349 ** backup,
5350 ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer
5351 ** the data between the two databases, and finally
5352 ** <li><b>sqlite3_backup_finish()</b> is called to release all resources
5353 ** associated with the backup operation.
5354 ** </ol>)^
5355 ** There should be exactly one call to sqlite3_backup_finish() for each
5356 ** successful call to sqlite3_backup_init().
5357 **
5358 ** <b>sqlite3_backup_init()</b>
5359 **
5360 ** ^The D and N arguments to sqlite3_backup_init(D,N,S,M) are the
5361 ** [database connection] associated with the destination database
5362 ** and the database name, respectively.
5363 ** ^The database name is "main" for the main database, "temp" for the
5364 ** temporary database, or the name specified after the AS keyword in
5365 ** an [ATTACH] statement for an attached database.
5366 ** ^The S and M arguments passed to
5367 ** sqlite3_backup_init(D,N,S,M) identify the [database connection]
5368 ** and database name of the source database, respectively.
5369 ** ^The source and destination [database connections] (parameters S and D)
5370 ** must be different or else sqlite3_backup_init(D,N,S,M) will file with
5371 ** an error.
5372 **
5373 ** ^If an error occurs within sqlite3_backup_init(D,N,S,M), then NULL is
5374 ** returned and an error code and error message are store3d in the
5375 ** destination [database connection] D.
5376 ** ^The error code and message for the failed call to sqlite3_backup_init()
5377 ** can be retrieved using the [sqlite3_errcode()], [sqlite3_errmsg()], and/or
5378 ** [sqlite3_errmsg16()] functions.
5379 ** ^A successful call to sqlite3_backup_init() returns a pointer to an
5380 ** [sqlite3_backup] object.
5381 ** ^The [sqlite3_backup] object may be used with the sqlite3_backup_step() and
5382 ** sqlite3_backup_finish() functions to perform the specified backup
5383 ** operation.
5384 **
5385 ** <b>sqlite3_backup_step()</b>
5386 **
5387 ** ^Function sqlite3_backup_step(B,N) will copy up to N pages between
5388 ** the source and destination databases specified by [sqlite3_backup] object B.
5389 ** ^If N is negative, all remaining source pages are copied.
5390 ** ^If sqlite3_backup_step(B,N) successfully copies N pages and there
5391 ** are still more pages to be copied, then the function resturns [SQLITE_OK].
5392 ** ^If sqlite3_backup_step(B,N) successfully finishes copying all pages
5393 ** from source to destination, then it returns [SQLITE_DONE].
5394 ** ^If an error occurs while running sqlite3_backup_step(B,N),
5395 ** then an [error code] is returned. ^As well as [SQLITE_OK] and
5396 ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY],
5397 ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an
5398 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code.
5399 **
5400 ** ^The sqlite3_backup_step() might return [SQLITE_READONLY] if the destination
5401 ** database was opened read-only or if
5402 ** the destination is an in-memory database with a different page size
5403 ** from the source database.
5404 **
5405 ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
5406 ** the [sqlite3_busy_handler | busy-handler function]
5407 ** is invoked (if one is specified). ^If the
5408 ** busy-handler returns non-zero before the lock is available, then
5409 ** [SQLITE_BUSY] is returned to the caller. ^In this case the call to
5410 ** sqlite3_backup_step() can be retried later. ^If the source
5411 ** [database connection]
5412 ** is being used to write to the source database when sqlite3_backup_step()
5413 ** is called, then [SQLITE_LOCKED] is returned immediately. ^Again, in this
5414 ** case the call to sqlite3_backup_step() can be retried later on. ^(If
5415 ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or
5416 ** [SQLITE_READONLY] is returned, then
5417 ** there is no point in retrying the call to sqlite3_backup_step(). These
5418 ** errors are considered fatal.)^ The application must accept
5419 ** that the backup operation has failed and pass the backup operation handle
5420 ** to the sqlite3_backup_finish() to release associated resources.
5421 **
5422 ** ^The first call to sqlite3_backup_step() obtains an exclusive lock
5423 ** on the destination file. ^The exclusive lock is not released until either
5424 ** sqlite3_backup_finish() is called or the backup operation is complete
5425 ** and sqlite3_backup_step() returns [SQLITE_DONE]. ^Every call to
5426 ** sqlite3_backup_step() obtains a [shared lock] on the source database that
5427 ** lasts for the duration of the sqlite3_backup_step() call.
5428 ** ^Because the source database is not locked between calls to
5429 ** sqlite3_backup_step(), the source database may be modified mid-way
5430 ** through the backup process. ^If the source database is modified by an
5431 ** external process or via a database connection other than the one being
5432 ** used by the backup operation, then the backup will be automatically
5433 ** restarted by the next call to sqlite3_backup_step(). ^If the source
5434 ** database is modified by the using the same database connection as is used
5435 ** by the backup operation, then the backup database is automatically
5436 ** updated at the same time.
5437 **
5438 ** <b>sqlite3_backup_finish()</b>
5439 **
5440 ** When sqlite3_backup_step() has returned [SQLITE_DONE], or when the
5441 ** application wishes to abandon the backup operation, the application
5442 ** should destroy the [sqlite3_backup] by passing it to sqlite3_backup_finish().
5443 ** ^The sqlite3_backup_finish() interfaces releases all
5444 ** resources associated with the [sqlite3_backup] object.
5445 ** ^If sqlite3_backup_step() has not yet returned [SQLITE_DONE], then any
5446 ** active write-transaction on the destination database is rolled back.
5447 ** The [sqlite3_backup] object is invalid
5448 ** and may not be used following a call to sqlite3_backup_finish().
5449 **
5450 ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no
5451 ** sqlite3_backup_step() errors occurred, regardless or whether or not
5452 ** sqlite3_backup_step() completed.
5453 ** ^If an out-of-memory condition or IO error occurred during any prior
5454 ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then
5455 ** sqlite3_backup_finish() returns the corresponding [error code].
 
 
5456 **
5457 ** ^A return of [SQLITE_BUSY] or [SQLITE_LOCKED] from sqlite3_backup_step()
5458 ** is not a permanent error and does not affect the return value of
5459 ** sqlite3_backup_finish().
5460 **
5461 ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b>
5462 **
5463 ** ^Each call to sqlite3_backup_step() sets two values inside
5464 ** the [sqlite3_backup] object: the number of pages still to be backed
5465 ** up and the total number of pages in the source databae file.
5466 ** The sqlite3_backup_remaining() and sqlite3_backup_pagecount() interfaces
5467 ** retrieve these two values, respectively.
5468 **
5469 ** ^The values returned by these functions are only updated by
5470 ** sqlite3_backup_step(). ^If the source database is modified during a backup
5471 ** operation, then the values are not updated to account for any extra
5472 ** pages that need to be updated or the size of the source database file
5473 ** changing.
5474 **
5475 ** <b>Concurrent Usage of Database Handles</b>
5476 **
5477 ** ^The source [database connection] may be used by the application for other
5478 ** purposes while a backup operation is underway or being initialized.
5479 ** ^If SQLite is compiled and configured to support threadsafe database
5480 ** connections, then the source database connection may be used concurrently
5481 ** from within other threads.
5482 **
5483 ** However, the application must guarantee that the destination
5484 ** [database connection] is not passed to any other API (by any thread) after
5485 ** sqlite3_backup_init() is called and before the corresponding call to
5486 ** sqlite3_backup_finish(). SQLite does not currently check to see
5487 ** if the application incorrectly accesses the destination [database connection]
5488 ** and so no error code is reported, but the operations may malfunction
5489 ** nevertheless. Use of the destination database connection while a
5490 ** backup is in progress might also also cause a mutex deadlock.
 
5491 **
5492 ** If running in [shared cache mode], the application must
5493 ** guarantee that the shared cache used by the destination database
5494 ** is not accessed while the backup is running. In practice this means
5495 ** that the application must guarantee that the disk file being
5496 ** backed up to is not accessed by any connection within the process,
5497 ** not just the specific connection that was passed to sqlite3_backup_init().
5498 **
5499 ** The [sqlite3_backup] object itself is partially threadsafe. Multiple
5500 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
@@ -5631,60 +5516,60 @@
5516
5517 /*
5518 ** CAPI3REF: Unlock Notification
5519 ** EXPERIMENTAL
5520 **
5521 ** ^When running in shared-cache mode, a database operation may fail with
5522 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
5523 ** individual tables within the shared-cache cannot be obtained. See
5524 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
5525 ** ^This API may be used to register a callback that SQLite will invoke
5526 ** when the connection currently holding the required lock relinquishes it.
5527 ** ^This API is only available if the library was compiled with the
5528 ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined.
5529 **
5530 ** See Also: [Using the SQLite Unlock Notification Feature].
5531 **
5532 ** ^Shared-cache locks are released when a database connection concludes
5533 ** its current transaction, either by committing it or rolling it back.
5534 **
5535 ** ^When a connection (known as the blocked connection) fails to obtain a
5536 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
5537 ** identity of the database connection (the blocking connection) that
5538 ** has locked the required resource is stored internally. ^After an
5539 ** application receives an SQLITE_LOCKED error, it may call the
5540 ** sqlite3_unlock_notify() method with the blocked connection handle as
5541 ** the first argument to register for a callback that will be invoked
5542 ** when the blocking connections current transaction is concluded. ^The
5543 ** callback is invoked from within the [sqlite3_step] or [sqlite3_close]
5544 ** call that concludes the blocking connections transaction.
5545 **
5546 ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application,
5547 ** there is a chance that the blocking connection will have already
5548 ** concluded its transaction by the time sqlite3_unlock_notify() is invoked.
5549 ** If this happens, then the specified callback is invoked immediately,
5550 ** from within the call to sqlite3_unlock_notify().)^
5551 **
5552 ** ^If the blocked connection is attempting to obtain a write-lock on a
5553 ** shared-cache table, and more than one other connection currently holds
5554 ** a read-lock on the same table, then SQLite arbitrarily selects one of
5555 ** the other connections to use as the blocking connection.
5556 **
5557 ** ^(There may be at most one unlock-notify callback registered by a
5558 ** blocked connection. If sqlite3_unlock_notify() is called when the
5559 ** blocked connection already has a registered unlock-notify callback,
5560 ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is
5561 ** called with a NULL pointer as its second argument, then any existing
5562 ** unlock-notify callback is cancelled. ^The blocked connections
5563 ** unlock-notify callback may also be canceled by closing the blocked
5564 ** connection using [sqlite3_close()].
5565 **
5566 ** The unlock-notify callback is not reentrant. If an application invokes
5567 ** any sqlite3_xxx API functions from within an unlock-notify callback, a
5568 ** crash or deadlock may be the result.
5569 **
5570 ** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always
5571 ** returns SQLITE_OK.
5572 **
5573 ** <b>Callback Invocation Details</b>
5574 **
5575 ** When an unlock-notify callback is registered, the application provides a
@@ -5694,11 +5579,11 @@
5579 ** an unlock-notify callback is a pointer to an array of void* pointers,
5580 ** and the second is the number of entries in the array.
5581 **
5582 ** When a blocking connections transaction is concluded, there may be
5583 ** more than one blocked connection that has registered for an unlock-notify
5584 ** callback. ^If two or more such blocked connections have specified the
5585 ** same callback function, then instead of invoking the callback function
5586 ** multiple times, it is invoked once with the set of void* context pointers
5587 ** specified by the blocked connections bundled together into an array.
5588 ** This gives the application an opportunity to prioritize any actions
5589 ** related to the set of unblocked database connections.
@@ -5712,20 +5597,20 @@
5597 ** connection Y's transaction to be concluded, and similarly connection
5598 ** Y is waiting on connection X's transaction, then neither connection
5599 ** will proceed and the system may remain deadlocked indefinitely.
5600 **
5601 ** To avoid this scenario, the sqlite3_unlock_notify() performs deadlock
5602 ** detection. ^If a given call to sqlite3_unlock_notify() would put the
5603 ** system in a deadlocked state, then SQLITE_LOCKED is returned and no
5604 ** unlock-notify callback is registered. The system is said to be in
5605 ** a deadlocked state if connection A has registered for an unlock-notify
5606 ** callback on the conclusion of connection B's transaction, and connection
5607 ** B has itself registered for an unlock-notify callback when connection
5608 ** A's transaction is concluded. ^Indirect deadlock is also detected, so
5609 ** the system is also considered to be deadlocked if connection B has
5610 ** registered for an unlock-notify callback on the conclusion of connection
5611 ** C's transaction, where connection C is waiting on connection A. ^Any
5612 ** number of levels of indirection are allowed.
5613 **
5614 ** <b>The "DROP TABLE" Exception</b>
5615 **
5616 ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost
@@ -5737,14 +5622,14 @@
5622 ** sqlite3_unlock_notify() results in the unlock-notify callback being
5623 ** invoked immediately. If the application then re-attempts the "DROP TABLE"
5624 ** or "DROP INDEX" query, an infinite loop might be the result.
5625 **
5626 ** One way around this problem is to check the extended error code returned
5627 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
5628 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
5629 ** the special "DROP TABLE/INDEX" case, the extended error code is just
5630 ** SQLITE_LOCKED.)^
5631 */
5632 SQLITE_API int sqlite3_unlock_notify(
5633 sqlite3 *pBlocked, /* Waiting connection */
5634 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
5635 void *pNotifyArg /* Argument to pass to xNotify */
@@ -5753,11 +5638,11 @@
5638
5639 /*
5640 ** CAPI3REF: String Comparison
5641 ** EXPERIMENTAL
5642 **
5643 ** ^The [sqlite3_strnicmp()] API allows applications and extensions to
5644 ** compare the contents of two buffers containing UTF-8 strings in a
5645 ** case-indendent fashion, using the same definition of case independence
5646 ** that SQLite uses internally when comparing identifiers.
5647 */
5648 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
5649

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button