Fossil SCM
Update the built-in SQLite to version 3.6.22 RC 1.
Commit
57225017b09f9cd620963a0a0b35fc8f488afca5
Parent
5efb82a71a469e9…
2 files changed
+4026
-3038
+1410
-1525
+4026
-3038
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | /****************************************************************************** |
| 2 | 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 | |
| 3 | +** version 3.6.22. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a one translation |
| 5 | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | 6 | ** possible if the files were compiled separately. Performance improvements |
| 7 | 7 | ** of 5% are more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -603,88 +603,81 @@ | ||
| 603 | 603 | #ifdef SQLITE_VERSION_NUMBER |
| 604 | 604 | # undef SQLITE_VERSION_NUMBER |
| 605 | 605 | #endif |
| 606 | 606 | |
| 607 | 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> | |
| 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. | |
| 631 | 621 | ** |
| 632 | 622 | ** 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. | |
| 639 | 629 | ** |
| 640 | 630 | ** See also: [sqlite3_libversion()], |
| 641 | 631 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 642 | 632 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 643 | -** | |
| 644 | -** Requirements: [H10011] [H10014] | |
| 645 | 633 | */ |
| 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" | |
| 649 | 637 | |
| 650 | 638 | /* |
| 651 | -** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> | |
| 639 | +** CAPI3REF: Run-Time Library Version Numbers | |
| 652 | 640 | ** KEYWORDS: sqlite3_version |
| 653 | 641 | ** |
| 654 | 642 | ** 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 | |
| 657 | 645 | ** programmers might include assert() statements in their application to |
| 658 | 646 | ** verify that values returned by these interfaces match the macros in |
| 659 | 647 | ** the header, and thus insure that the application is |
| 660 | 648 | ** compiled with matching library and header files. |
| 661 | 649 | ** |
| 662 | 650 | ** <blockquote><pre> |
| 663 | 651 | ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); |
| 664 | 652 | ** 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>)^ | |
| 667 | 655 | ** |
| 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. | |
| 674 | 665 | ** |
| 675 | 666 | ** See also: [sqlite_version()] and [sqlite_source_id()]. |
| 676 | -** | |
| 677 | -** Requirements: [H10021] [H10022] [H10023] | |
| 678 | 667 | */ |
| 679 | 668 | SQLITE_API const char sqlite3_version[] = SQLITE_VERSION; |
| 680 | 669 | SQLITE_API const char *sqlite3_libversion(void); |
| 681 | 670 | SQLITE_API const char *sqlite3_sourceid(void); |
| 682 | 671 | SQLITE_API int sqlite3_libversion_number(void); |
| 683 | 672 | |
| 684 | 673 | /* |
| 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. | |
| 686 | 679 | ** |
| 687 | 680 | ** SQLite can be compiled with or without mutexes. When |
| 688 | 681 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 689 | 682 | ** are enabled and SQLite is threadsafe. When the |
| 690 | 683 | ** [SQLITE_THREADSAFE] macro is 0, |
| @@ -692,33 +685,33 @@ | ||
| 692 | 685 | ** to use SQLite concurrently from more than one thread. |
| 693 | 686 | ** |
| 694 | 687 | ** Enabling mutexes incurs a measurable performance penalty. |
| 695 | 688 | ** So if speed is of utmost importance, it makes sense to disable |
| 696 | 689 | ** 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. | |
| 698 | 691 | ** |
| 699 | 692 | ** This interface can be used by an application to make sure that the |
| 700 | 693 | ** version of SQLite that it is linking against was compiled with |
| 701 | 694 | ** the desired setting of the [SQLITE_THREADSAFE] macro. |
| 702 | 695 | ** |
| 703 | 696 | ** This interface only reports on the compile-time mutex setting |
| 704 | 697 | ** 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 | |
| 706 | 699 | ** can be fully or partially disabled using a call to [sqlite3_config()] |
| 707 | 700 | ** 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().)^ | |
| 711 | 706 | ** |
| 712 | 707 | ** See the [threading mode] documentation for additional information. |
| 713 | -** | |
| 714 | -** Requirements: [H10101] [H10102] | |
| 715 | 708 | */ |
| 716 | 709 | SQLITE_API int sqlite3_threadsafe(void); |
| 717 | 710 | |
| 718 | 711 | /* |
| 719 | -** CAPI3REF: Database Connection Handle {H12000} <S40200> | |
| 712 | +** CAPI3REF: Database Connection Handle | |
| 720 | 713 | ** KEYWORDS: {database connection} {database connections} |
| 721 | 714 | ** |
| 722 | 715 | ** Each open SQLite database is represented by a pointer to an instance of |
| 723 | 716 | ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 |
| 724 | 717 | ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and |
| @@ -729,21 +722,24 @@ | ||
| 729 | 722 | ** sqlite3 object. |
| 730 | 723 | */ |
| 731 | 724 | typedef struct sqlite3 sqlite3; |
| 732 | 725 | |
| 733 | 726 | /* |
| 734 | -** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> | |
| 727 | +** CAPI3REF: 64-Bit Integer Types | |
| 735 | 728 | ** KEYWORDS: sqlite_int64 sqlite_uint64 |
| 736 | 729 | ** |
| 737 | 730 | ** Because there is no cross-platform way to specify 64-bit integer types |
| 738 | 731 | ** SQLite includes typedefs for 64-bit signed and unsigned integers. |
| 739 | 732 | ** |
| 740 | 733 | ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. |
| 741 | 734 | ** The sqlite_int64 and sqlite_uint64 types are supported for backwards |
| 742 | 735 | ** compatibility only. |
| 743 | 736 | ** |
| 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. | |
| 745 | 741 | */ |
| 746 | 742 | #ifdef SQLITE_INT64_TYPE |
| 747 | 743 | typedef SQLITE_INT64_TYPE sqlite_int64; |
| 748 | 744 | typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; |
| 749 | 745 | #elif defined(_MSC_VER) || defined(__BORLANDC__) |
| @@ -763,28 +759,32 @@ | ||
| 763 | 759 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 764 | 760 | # define double sqlite3_int64 |
| 765 | 761 | #endif |
| 766 | 762 | |
| 767 | 763 | /* |
| 768 | -** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> | |
| 764 | +** CAPI3REF: Closing A Database Connection | |
| 769 | 765 | ** |
| 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. | |
| 771 | 769 | ** |
| 772 | 770 | ** Applications must [sqlite3_finalize | finalize] all [prepared statements] |
| 773 | 771 | ** 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. | |
| 775 | 776 | ** |
| 776 | -** If [sqlite3_close()] is invoked while a transaction is open, | |
| 777 | +** ^If [sqlite3_close()] is invoked while a transaction is open, | |
| 777 | 778 | ** the transaction is automatically rolled back. |
| 778 | 779 | ** |
| 779 | 780 | ** The C parameter to [sqlite3_close(C)] must be either a NULL |
| 780 | 781 | ** pointer or an [sqlite3] object pointer obtained |
| 781 | 782 | ** from [sqlite3_open()], [sqlite3_open16()], or |
| 782 | 783 | ** [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. | |
| 786 | 786 | */ |
| 787 | 787 | SQLITE_API int sqlite3_close(sqlite3 *); |
| 788 | 788 | |
| 789 | 789 | /* |
| 790 | 790 | ** The type for a callback function. |
| @@ -792,52 +792,69 @@ | ||
| 792 | 792 | ** compatibility and is not documented. |
| 793 | 793 | */ |
| 794 | 794 | typedef int (*sqlite3_callback)(void*,int,char**, char**); |
| 795 | 795 | |
| 796 | 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] | |
| 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> | |
| 839 | 856 | */ |
| 840 | 857 | SQLITE_API int sqlite3_exec( |
| 841 | 858 | sqlite3*, /* An open database */ |
| 842 | 859 | const char *sql, /* SQL to be evaluated */ |
| 843 | 860 | int (*callback)(void*,int,char**,char**), /* Callback function */ |
| @@ -844,11 +861,11 @@ | ||
| 844 | 861 | void *, /* 1st argument to callback */ |
| 845 | 862 | char **errmsg /* Error msg written here */ |
| 846 | 863 | ); |
| 847 | 864 | |
| 848 | 865 | /* |
| 849 | -** CAPI3REF: Result Codes {H10210} <S10700> | |
| 866 | +** CAPI3REF: Result Codes | |
| 850 | 867 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 851 | 868 | ** KEYWORDS: {result code} {result codes} |
| 852 | 869 | ** |
| 853 | 870 | ** Many SQLite functions return an integer result code from the set shown |
| 854 | 871 | ** here in order to indicates success or failure. |
| @@ -888,11 +905,11 @@ | ||
| 888 | 905 | #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ |
| 889 | 906 | #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ |
| 890 | 907 | /* end-of-error-codes */ |
| 891 | 908 | |
| 892 | 909 | /* |
| 893 | -** CAPI3REF: Extended Result Codes {H10220} <S10700> | |
| 910 | +** CAPI3REF: Extended Result Codes | |
| 894 | 911 | ** KEYWORDS: {extended error code} {extended error codes} |
| 895 | 912 | ** KEYWORDS: {extended result code} {extended result codes} |
| 896 | 913 | ** |
| 897 | 914 | ** In its default configuration, SQLite API routines return one of 26 integer |
| 898 | 915 | ** [SQLITE_OK | result codes]. However, experience has shown that many of |
| @@ -930,11 +947,11 @@ | ||
| 930 | 947 | #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) |
| 931 | 948 | #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) |
| 932 | 949 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) |
| 933 | 950 | |
| 934 | 951 | /* |
| 935 | -** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> | |
| 952 | +** CAPI3REF: Flags For File Open Operations | |
| 936 | 953 | ** |
| 937 | 954 | ** These bit values are intended for use in the |
| 938 | 955 | ** 3rd parameter to the [sqlite3_open_v2()] interface and |
| 939 | 956 | ** in the 4th parameter to the xOpen method of the |
| 940 | 957 | ** [sqlite3_vfs] object. |
| @@ -955,11 +972,11 @@ | ||
| 955 | 972 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 956 | 973 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 957 | 974 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 958 | 975 | |
| 959 | 976 | /* |
| 960 | -** CAPI3REF: Device Characteristics {H10240} <H11120> | |
| 977 | +** CAPI3REF: Device Characteristics | |
| 961 | 978 | ** |
| 962 | 979 | ** The xDeviceCapabilities method of the [sqlite3_io_methods] |
| 963 | 980 | ** object returns an integer which is a vector of the these |
| 964 | 981 | ** bit values expressing I/O characteristics of the mass storage |
| 965 | 982 | ** device that holds the file that the [sqlite3_io_methods] |
| @@ -987,11 +1004,11 @@ | ||
| 987 | 1004 | #define SQLITE_IOCAP_ATOMIC64K 0x00000100 |
| 988 | 1005 | #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 |
| 989 | 1006 | #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 |
| 990 | 1007 | |
| 991 | 1008 | /* |
| 992 | -** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> | |
| 1009 | +** CAPI3REF: File Locking Levels | |
| 993 | 1010 | ** |
| 994 | 1011 | ** SQLite uses one of these integer values as the second |
| 995 | 1012 | ** argument to calls it makes to the xLock() and xUnlock() methods |
| 996 | 1013 | ** of an [sqlite3_io_methods] object. |
| 997 | 1014 | */ |
| @@ -1000,11 +1017,11 @@ | ||
| 1000 | 1017 | #define SQLITE_LOCK_RESERVED 2 |
| 1001 | 1018 | #define SQLITE_LOCK_PENDING 3 |
| 1002 | 1019 | #define SQLITE_LOCK_EXCLUSIVE 4 |
| 1003 | 1020 | |
| 1004 | 1021 | /* |
| 1005 | -** CAPI3REF: Synchronization Type Flags {H10260} <H11120> | |
| 1022 | +** CAPI3REF: Synchronization Type Flags | |
| 1006 | 1023 | ** |
| 1007 | 1024 | ** When SQLite invokes the xSync() method of an |
| 1008 | 1025 | ** [sqlite3_io_methods] object it uses a combination of |
| 1009 | 1026 | ** these integer values as the second argument. |
| 1010 | 1027 | ** |
| @@ -1018,11 +1035,11 @@ | ||
| 1018 | 1035 | #define SQLITE_SYNC_NORMAL 0x00002 |
| 1019 | 1036 | #define SQLITE_SYNC_FULL 0x00003 |
| 1020 | 1037 | #define SQLITE_SYNC_DATAONLY 0x00010 |
| 1021 | 1038 | |
| 1022 | 1039 | /* |
| 1023 | -** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> | |
| 1040 | +** CAPI3REF: OS Interface Open File Handle | |
| 1024 | 1041 | ** |
| 1025 | 1042 | ** An [sqlite3_file] object represents an open file in the |
| 1026 | 1043 | ** [sqlite3_vfs | OS interface layer]. Individual OS interface |
| 1027 | 1044 | ** implementations will |
| 1028 | 1045 | ** want to subclass this object by appending additional fields |
| @@ -1034,11 +1051,11 @@ | ||
| 1034 | 1051 | struct sqlite3_file { |
| 1035 | 1052 | const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ |
| 1036 | 1053 | }; |
| 1037 | 1054 | |
| 1038 | 1055 | /* |
| 1039 | -** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> | |
| 1056 | +** CAPI3REF: OS Interface File Virtual Methods Object | |
| 1040 | 1057 | ** |
| 1041 | 1058 | ** Every file opened by the [sqlite3_vfs] xOpen method populates an |
| 1042 | 1059 | ** [sqlite3_file] object (or, more commonly, a subclass of the |
| 1043 | 1060 | ** [sqlite3_file] object) with a pointer to an instance of this object. |
| 1044 | 1061 | ** This object defines the methods used to perform various operations |
| @@ -1139,11 +1156,11 @@ | ||
| 1139 | 1156 | int (*xDeviceCharacteristics)(sqlite3_file*); |
| 1140 | 1157 | /* Additional methods may be added in future releases */ |
| 1141 | 1158 | }; |
| 1142 | 1159 | |
| 1143 | 1160 | /* |
| 1144 | -** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> | |
| 1161 | +** CAPI3REF: Standard File Control Opcodes | |
| 1145 | 1162 | ** |
| 1146 | 1163 | ** These integer constants are opcodes for the xFileControl method |
| 1147 | 1164 | ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] |
| 1148 | 1165 | ** interface. |
| 1149 | 1166 | ** |
| @@ -1159,11 +1176,11 @@ | ||
| 1159 | 1176 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 1160 | 1177 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 1161 | 1178 | #define SQLITE_LAST_ERRNO 4 |
| 1162 | 1179 | |
| 1163 | 1180 | /* |
| 1164 | -** CAPI3REF: Mutex Handle {H17110} <S20130> | |
| 1181 | +** CAPI3REF: Mutex Handle | |
| 1165 | 1182 | ** |
| 1166 | 1183 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| 1167 | 1184 | ** abstract type for a mutex object. The SQLite core never looks |
| 1168 | 1185 | ** at the internal representation of an [sqlite3_mutex]. It only |
| 1169 | 1186 | ** deals with pointers to the [sqlite3_mutex] object. |
| @@ -1171,11 +1188,11 @@ | ||
| 1171 | 1188 | ** Mutexes are created using [sqlite3_mutex_alloc()]. |
| 1172 | 1189 | */ |
| 1173 | 1190 | typedef struct sqlite3_mutex sqlite3_mutex; |
| 1174 | 1191 | |
| 1175 | 1192 | /* |
| 1176 | -** CAPI3REF: OS Interface Object {H11140} <S20100> | |
| 1193 | +** CAPI3REF: OS Interface Object | |
| 1177 | 1194 | ** |
| 1178 | 1195 | ** An instance of the sqlite3_vfs object defines the interface between |
| 1179 | 1196 | ** the SQLite core and the underlying operating system. The "vfs" |
| 1180 | 1197 | ** in the name of the object stands for "virtual file system". |
| 1181 | 1198 | ** |
| @@ -1325,14 +1342,14 @@ | ||
| 1325 | 1342 | /* New fields may be appended in figure versions. The iVersion |
| 1326 | 1343 | ** value will increment whenever this happens. */ |
| 1327 | 1344 | }; |
| 1328 | 1345 | |
| 1329 | 1346 | /* |
| 1330 | -** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> | |
| 1347 | +** CAPI3REF: Flags for the xAccess VFS method | |
| 1331 | 1348 | ** |
| 1332 | 1349 | ** 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 | |
| 1334 | 1351 | ** what kind of permissions the xAccess method is looking for. |
| 1335 | 1352 | ** With SQLITE_ACCESS_EXISTS, the xAccess method |
| 1336 | 1353 | ** simply checks whether the file exists. |
| 1337 | 1354 | ** With SQLITE_ACCESS_READWRITE, the xAccess method |
| 1338 | 1355 | ** checks whether the file is both readable and writable. |
| @@ -1342,52 +1359,52 @@ | ||
| 1342 | 1359 | #define SQLITE_ACCESS_EXISTS 0 |
| 1343 | 1360 | #define SQLITE_ACCESS_READWRITE 1 |
| 1344 | 1361 | #define SQLITE_ACCESS_READ 2 |
| 1345 | 1362 | |
| 1346 | 1363 | /* |
| 1347 | -** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> | |
| 1364 | +** CAPI3REF: Initialize The SQLite Library | |
| 1348 | 1365 | ** |
| 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 | |
| 1351 | 1368 | ** deallocates any resources that were allocated by sqlite3_initialize(). |
| 1352 | 1369 | ** These routines are designed to aid in process initialization and |
| 1353 | 1370 | ** shutdown on embedded systems. Workstation applications using |
| 1354 | 1371 | ** SQLite normally do not need to invoke either of these routines. |
| 1355 | 1372 | ** |
| 1356 | 1373 | ** A call to sqlite3_initialize() is an "effective" call if it is |
| 1357 | 1374 | ** the first time sqlite3_initialize() is invoked during the lifetime of |
| 1358 | 1375 | ** 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 | |
| 1360 | 1377 | ** of sqlite3_initialize() does any initialization. All other calls |
| 1361 | -** are harmless no-ops. | |
| 1378 | +** are harmless no-ops.)^ | |
| 1362 | 1379 | ** |
| 1363 | 1380 | ** 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 | |
| 1365 | 1382 | ** 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.)^ | |
| 1367 | 1384 | ** |
| 1368 | 1385 | ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() |
| 1369 | 1386 | ** is not. The sqlite3_shutdown() interface must only be called from a |
| 1370 | 1387 | ** single thread. All open [database connections] must be closed and all |
| 1371 | 1388 | ** other SQLite resources must be deallocated prior to invoking |
| 1372 | 1389 | ** sqlite3_shutdown(). |
| 1373 | 1390 | ** |
| 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() | |
| 1376 | 1393 | ** will invoke sqlite3_os_end(). |
| 1377 | 1394 | ** |
| 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 | |
| 1380 | 1397 | ** the library (perhaps it is unable to allocate a needed resource such |
| 1381 | 1398 | ** as a mutex) it returns an [error code] other than [SQLITE_OK]. |
| 1382 | 1399 | ** |
| 1383 | -** The sqlite3_initialize() routine is called internally by many other | |
| 1400 | +** ^The sqlite3_initialize() routine is called internally by many other | |
| 1384 | 1401 | ** SQLite interfaces so that an application usually does not need to |
| 1385 | 1402 | ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] |
| 1386 | 1403 | ** calls sqlite3_initialize() so the SQLite library will be automatically |
| 1387 | 1404 | ** 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] | |
| 1389 | 1406 | ** compile-time option, then the automatic calls to sqlite3_initialize() |
| 1390 | 1407 | ** are omitted and the application must call sqlite3_initialize() directly |
| 1391 | 1408 | ** prior to using any other SQLite interface. For maximum portability, |
| 1392 | 1409 | ** it is recommended that applications always invoke sqlite3_initialize() |
| 1393 | 1410 | ** directly prior to using any other SQLite interface. Future releases |
| @@ -1422,11 +1439,11 @@ | ||
| 1422 | 1439 | SQLITE_API int sqlite3_shutdown(void); |
| 1423 | 1440 | SQLITE_API int sqlite3_os_init(void); |
| 1424 | 1441 | SQLITE_API int sqlite3_os_end(void); |
| 1425 | 1442 | |
| 1426 | 1443 | /* |
| 1427 | -** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200> | |
| 1444 | +** CAPI3REF: Configuring The SQLite Library | |
| 1428 | 1445 | ** EXPERIMENTAL |
| 1429 | 1446 | ** |
| 1430 | 1447 | ** The sqlite3_config() interface is used to make global configuration |
| 1431 | 1448 | ** changes to SQLite in order to tune SQLite to the specific needs of |
| 1432 | 1449 | ** the application. The default configuration is recommended for most |
| @@ -1436,39 +1453,36 @@ | ||
| 1436 | 1453 | ** The sqlite3_config() interface is not threadsafe. The application |
| 1437 | 1454 | ** must insure that no other SQLite interfaces are invoked by other |
| 1438 | 1455 | ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() |
| 1439 | 1456 | ** may only be invoked prior to library initialization using |
| 1440 | 1457 | ** [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 | |
| 1442 | 1461 | ** implementation of an application-defined [sqlite3_os_init()]. |
| 1443 | 1462 | ** |
| 1444 | 1463 | ** The first argument to sqlite3_config() is an integer |
| 1445 | 1464 | ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines |
| 1446 | 1465 | ** what property of SQLite is to be configured. Subsequent arguments |
| 1447 | 1466 | ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] |
| 1448 | 1467 | ** in the first argument. |
| 1449 | 1468 | ** |
| 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 | |
| 1452 | 1471 | ** 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 | 1472 | */ |
| 1459 | 1473 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...); |
| 1460 | 1474 | |
| 1461 | 1475 | /* |
| 1462 | -** CAPI3REF: Configure database connections {H14200} <S20000> | |
| 1476 | +** CAPI3REF: Configure database connections | |
| 1463 | 1477 | ** EXPERIMENTAL |
| 1464 | 1478 | ** |
| 1465 | 1479 | ** The sqlite3_db_config() interface is used to make configuration |
| 1466 | 1480 | ** changes to a [database connection]. The interface is similar to |
| 1467 | 1481 | ** [sqlite3_config()] except that the changes apply to a single |
| 1468 | 1482 | ** [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 | |
| 1470 | 1484 | ** the database connection is created using [sqlite3_open()], |
| 1471 | 1485 | ** [sqlite3_open16()], or [sqlite3_open_v2()]. |
| 1472 | 1486 | ** |
| 1473 | 1487 | ** The second argument to sqlite3_db_config(D,V,...) is the |
| 1474 | 1488 | ** configuration verb - an integer code that indicates what |
| @@ -1475,17 +1489,17 @@ | ||
| 1475 | 1489 | ** aspect of the [database connection] is being configured. |
| 1476 | 1490 | ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. |
| 1477 | 1491 | ** New verbs are likely to be added in future releases of SQLite. |
| 1478 | 1492 | ** Additional arguments depend on the verb. |
| 1479 | 1493 | ** |
| 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. | |
| 1482 | 1496 | */ |
| 1483 | 1497 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...); |
| 1484 | 1498 | |
| 1485 | 1499 | /* |
| 1486 | -** CAPI3REF: Memory Allocation Routines {H10155} <S20120> | |
| 1500 | +** CAPI3REF: Memory Allocation Routines | |
| 1487 | 1501 | ** EXPERIMENTAL |
| 1488 | 1502 | ** |
| 1489 | 1503 | ** An instance of this object defines the interface between SQLite |
| 1490 | 1504 | ** and low-level memory allocation routines. |
| 1491 | 1505 | ** |
| @@ -1511,11 +1525,11 @@ | ||
| 1511 | 1525 | ** The xMalloc and xFree methods must work like the |
| 1512 | 1526 | ** malloc() and free() functions from the standard C library. |
| 1513 | 1527 | ** The xRealloc method must work like realloc() from the standard C library |
| 1514 | 1528 | ** with the exception that if the second argument to xRealloc is zero, |
| 1515 | 1529 | ** 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 | |
| 1517 | 1531 | ** xRealloc is always a value returned by a prior call to xRoundup. |
| 1518 | 1532 | ** And so in cases where xRoundup always returns a positive number, |
| 1519 | 1533 | ** xRealloc can perform exactly as the standard library realloc() and |
| 1520 | 1534 | ** still be in compliance with this specification. |
| 1521 | 1535 | ** |
| @@ -1563,11 +1577,11 @@ | ||
| 1563 | 1577 | void (*xShutdown)(void*); /* Deinitialize the memory allocator */ |
| 1564 | 1578 | void *pAppData; /* Argument to xInit() and xShutdown() */ |
| 1565 | 1579 | }; |
| 1566 | 1580 | |
| 1567 | 1581 | /* |
| 1568 | -** CAPI3REF: Configuration Options {H10160} <S20000> | |
| 1582 | +** CAPI3REF: Configuration Options | |
| 1569 | 1583 | ** EXPERIMENTAL |
| 1570 | 1584 | ** |
| 1571 | 1585 | ** These constants are the available integer configuration options that |
| 1572 | 1586 | ** can be passed as the first argument to the [sqlite3_config()] interface. |
| 1573 | 1587 | ** |
| @@ -1578,151 +1592,181 @@ | ||
| 1578 | 1592 | ** non-zero [error code] if a discontinued or unsupported configuration option |
| 1579 | 1593 | ** is invoked. |
| 1580 | 1594 | ** |
| 1581 | 1595 | ** <dl> |
| 1582 | 1596 | ** <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 | |
| 1584 | 1599 | ** 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> | |
| 1586 | 1606 | ** |
| 1587 | 1607 | ** <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 | |
| 1589 | 1610 | ** mutexing on [database connection] and [prepared statement] objects. |
| 1590 | 1611 | ** The application is responsible for serializing access to |
| 1591 | 1612 | ** [database connections] and [prepared statements]. But other mutexes |
| 1592 | 1613 | ** are enabled so that SQLite will be safe to use in a multi-threaded |
| 1593 | 1614 | ** 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> | |
| 1596 | 1620 | ** |
| 1597 | 1621 | ** <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 | |
| 1599 | 1624 | ** all mutexes including the recursive |
| 1600 | 1625 | ** mutexes on [database connection] and [prepared statement] objects. |
| 1601 | 1626 | ** In this mode (which is the default when SQLite is compiled with |
| 1602 | 1627 | ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access |
| 1603 | 1628 | ** to [database connections] and [prepared statements] so that the |
| 1604 | 1629 | ** application is free to use the same [database connection] or the |
| 1605 | 1630 | ** 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> | |
| 1607 | 1636 | ** |
| 1608 | 1637 | ** <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 | |
| 1610 | 1639 | ** instance of the [sqlite3_mem_methods] structure. The argument specifies |
| 1611 | 1640 | ** 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> | |
| 1613 | 1644 | ** |
| 1614 | 1645 | ** <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 | |
| 1616 | 1647 | ** 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.)^ | |
| 1618 | 1649 | ** This option can be used to overload the default memory allocation |
| 1619 | 1650 | ** routines with a wrapper that simulations memory allocation failure or |
| 1620 | -** tracks memory usage, for example.</dd> | |
| 1651 | +** tracks memory usage, for example. </dd> | |
| 1621 | 1652 | ** |
| 1622 | 1653 | ** <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 | |
| 1624 | 1655 | ** 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: | |
| 1627 | 1658 | ** <ul> |
| 1628 | 1659 | ** <li> [sqlite3_memory_used()] |
| 1629 | 1660 | ** <li> [sqlite3_memory_highwater()] |
| 1630 | 1661 | ** <li> [sqlite3_soft_heap_limit()] |
| 1631 | 1662 | ** <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. | |
| 1633 | 1667 | ** </dd> |
| 1634 | 1668 | ** |
| 1635 | 1669 | ** <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 | |
| 1637 | 1671 | ** scratch memory. There are three arguments: A pointer an 8-byte |
| 1638 | 1672 | ** aligned memory buffer from which the scrach allocations will be |
| 1639 | 1673 | ** drawn, the size of each scratch allocation (sz), |
| 1640 | 1674 | ** and the maximum number of scratch allocations (N). The sz |
| 1641 | 1675 | ** argument must be a multiple of 16. The sz parameter should be a few bytes |
| 1642 | 1676 | ** 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 | |
| 1644 | 1678 | ** 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> | |
| 1652 | 1685 | ** |
| 1653 | 1686 | ** <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 | |
| 1655 | 1688 | ** the database page cache with the default page cache implemenation. |
| 1656 | 1689 | ** This configuration should not be used if an application-define page |
| 1657 | 1690 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1658 | 1691 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1659 | 1692 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1660 | 1693 | ** The sz argument should be the size of the largest database page |
| 1661 | 1694 | ** (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, | |
| 1664 | 1697 | ** to make sz a little too large. The first |
| 1665 | 1698 | ** 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 | |
| 1668 | 1701 | ** page cache memory is needed beyond what is provided by this option, then |
| 1669 | 1702 | ** 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 | |
| 1671 | 1704 | ** memory accounting information. The pointer in the first argument must |
| 1672 | 1705 | ** be aligned to an 8-byte boundary or subsequent behavior of SQLite |
| 1673 | 1706 | ** will be undefined.</dd> |
| 1674 | 1707 | ** |
| 1675 | 1708 | ** <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 | |
| 1677 | 1710 | ** for all of its dynamic memory allocation needs beyond those provided |
| 1678 | 1711 | ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. |
| 1679 | 1712 | ** There are three arguments: An 8-byte aligned pointer to the memory, |
| 1680 | 1713 | ** 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 | |
| 1682 | 1715 | ** 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 | |
| 1684 | 1717 | ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or |
| 1685 | 1718 | ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory |
| 1686 | 1719 | ** allocator is engaged to handle all of SQLites memory allocation needs. |
| 1687 | 1720 | ** The first pointer (the memory pointer) must be aligned to an 8-byte |
| 1688 | 1721 | ** boundary or subsequent behavior of SQLite will be undefined.</dd> |
| 1689 | 1722 | ** |
| 1690 | 1723 | ** <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 | |
| 1692 | 1725 | ** instance of the [sqlite3_mutex_methods] structure. The argument specifies |
| 1693 | 1726 | ** 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> | |
| 1695 | 1734 | ** |
| 1696 | 1735 | ** <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 | |
| 1698 | 1737 | ** instance of the [sqlite3_mutex_methods] structure. The |
| 1699 | 1738 | ** [sqlite3_mutex_methods] |
| 1700 | -** structure is filled with the currently defined mutex routines. | |
| 1739 | +** structure is filled with the currently defined mutex routines.)^ | |
| 1701 | 1740 | ** This option can be used to overload the default mutex allocation |
| 1702 | 1741 | ** 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> | |
| 1704 | 1747 | ** |
| 1705 | 1748 | ** <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 | |
| 1708 | 1752 | ** 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] | |
| 1711 | 1755 | ** verb to [sqlite3_db_config()] can be used to change the lookaside |
| 1712 | -** configuration on individual connections.</dd> | |
| 1756 | +** configuration on individual connections.)^ </dd> | |
| 1713 | 1757 | ** |
| 1714 | 1758 | ** <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 | |
| 1716 | 1760 | ** 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 | |
| 1718 | 1762 | ** object and uses it for page cache memory allocations.</dd> |
| 1719 | 1763 | ** |
| 1720 | 1764 | ** <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 | |
| 1722 | 1766 | ** [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> | |
| 1724 | 1768 | ** |
| 1725 | 1769 | ** </dl> |
| 1726 | 1770 | */ |
| 1727 | 1771 | #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ |
| 1728 | 1772 | #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ |
| @@ -1739,94 +1783,90 @@ | ||
| 1739 | 1783 | #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ |
| 1740 | 1784 | #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ |
| 1741 | 1785 | #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ |
| 1742 | 1786 | |
| 1743 | 1787 | /* |
| 1744 | -** CAPI3REF: Configuration Options {H10170} <S20000> | |
| 1788 | +** CAPI3REF: Configuration Options | |
| 1745 | 1789 | ** EXPERIMENTAL |
| 1746 | 1790 | ** |
| 1747 | 1791 | ** These constants are the available integer configuration options that |
| 1748 | 1792 | ** can be passed as the second argument to the [sqlite3_db_config()] interface. |
| 1749 | 1793 | ** |
| 1750 | 1794 | ** New configuration options may be added in future releases of SQLite. |
| 1751 | 1795 | ** Existing configuration options might be discontinued. Applications |
| 1752 | 1796 | ** 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 | |
| 1754 | 1798 | ** non-zero [error code] if a discontinued or unsupported configuration option |
| 1755 | 1799 | ** is invoked. |
| 1756 | 1800 | ** |
| 1757 | 1801 | ** <dl> |
| 1758 | 1802 | ** <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 | |
| 1760 | 1804 | ** [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 | |
| 1762 | 1806 | ** 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 | |
| 1766 | 1811 | ** slots. The size of the buffer in the first argument must be greater than |
| 1767 | 1812 | ** 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 | |
| 1770 | 1816 | ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd> |
| 1771 | 1817 | ** |
| 1772 | 1818 | ** </dl> |
| 1773 | 1819 | */ |
| 1774 | 1820 | #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ |
| 1775 | 1821 | |
| 1776 | 1822 | |
| 1777 | 1823 | /* |
| 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. | |
| 1786 | 1829 | */ |
| 1787 | 1830 | SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
| 1788 | 1831 | |
| 1789 | 1832 | /* |
| 1790 | -** CAPI3REF: Last Insert Rowid {H12220} <S10700> | |
| 1833 | +** CAPI3REF: Last Insert Rowid | |
| 1791 | 1834 | ** |
| 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 | |
| 1794 | 1837 | ** 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 | |
| 1796 | 1839 | ** the table has a column of type [INTEGER PRIMARY KEY] then that column |
| 1797 | 1840 | ** is another alias for the rowid. |
| 1798 | 1841 | ** |
| 1799 | -** This routine returns the [rowid] of the most recent | |
| 1842 | +** ^This routine returns the [rowid] of the most recent | |
| 1800 | 1843 | ** 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 | |
| 1802 | 1845 | ** have ever occurred on that database connection, zero is returned. |
| 1803 | 1846 | ** |
| 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 | |
| 1805 | 1848 | ** row is returned by this routine as long as the trigger is running. |
| 1806 | 1849 | ** 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.)^ | |
| 1808 | 1851 | ** |
| 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 | |
| 1810 | 1853 | ** 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, | |
| 1812 | 1855 | ** 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 | |
| 1814 | 1857 | ** encounters a constraint violation, it does not fail. The |
| 1815 | 1858 | ** INSERT continues to completion after deleting rows that caused |
| 1816 | 1859 | ** the constraint problem so INSERT OR REPLACE will always change |
| 1817 | -** the return value of this interface. | |
| 1860 | +** the return value of this interface.)^ | |
| 1818 | 1861 | ** |
| 1819 | -** For the purposes of this routine, an [INSERT] is considered to | |
| 1862 | +** ^For the purposes of this routine, an [INSERT] is considered to | |
| 1820 | 1863 | ** be successful even if it is subsequently rolled back. |
| 1821 | 1864 | ** |
| 1822 | 1865 | ** This function is accessible to SQL statements via the |
| 1823 | 1866 | ** [last_insert_rowid() SQL function]. |
| 1824 | 1867 | ** |
| 1825 | -** Requirements: | |
| 1826 | -** [H12221] [H12223] | |
| 1827 | -** | |
| 1828 | 1868 | ** If a separate thread performs a new [INSERT] on the same |
| 1829 | 1869 | ** database connection while the [sqlite3_last_insert_rowid()] |
| 1830 | 1870 | ** function is running and thus changes the last insert [rowid], |
| 1831 | 1871 | ** then the value returned by [sqlite3_last_insert_rowid()] is |
| 1832 | 1872 | ** unpredictable and might not equal either the old or the new |
| @@ -1833,164 +1873,154 @@ | ||
| 1833 | 1873 | ** last insert [rowid]. |
| 1834 | 1874 | */ |
| 1835 | 1875 | SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); |
| 1836 | 1876 | |
| 1837 | 1877 | /* |
| 1838 | -** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> | |
| 1878 | +** CAPI3REF: Count The Number Of Rows Modified | |
| 1839 | 1879 | ** |
| 1840 | -** This function returns the number of database rows that were changed | |
| 1880 | +** ^This function returns the number of database rows that were changed | |
| 1841 | 1881 | ** or inserted or deleted by the most recently completed SQL statement |
| 1842 | 1882 | ** 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], | |
| 1844 | 1884 | ** 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 | |
| 1846 | 1886 | ** [sqlite3_total_changes()] function to find the total number of changes |
| 1847 | 1887 | ** including changes caused by triggers and foreign key actions. |
| 1848 | 1888 | ** |
| 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] | |
| 1850 | 1890 | ** are not counted. Only real table changes are counted. |
| 1851 | 1891 | ** |
| 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 | |
| 1853 | 1893 | ** caused by an INSERT, DELETE, or UPDATE statement. Rows that |
| 1854 | 1894 | ** are changed as side effects of [REPLACE] constraint resolution, |
| 1855 | 1895 | ** 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.)^ | |
| 1857 | 1897 | ** |
| 1858 | 1898 | ** A "trigger context" is a scope of execution that begins and |
| 1859 | 1899 | ** ends with the script of a [CREATE TRIGGER | trigger]. |
| 1860 | 1900 | ** Most SQL statements are |
| 1861 | 1901 | ** evaluated outside of any trigger. This is the "top level" |
| 1862 | 1902 | ** trigger context. If a trigger fires from the top level, a |
| 1863 | 1903 | ** new trigger context is entered for the duration of that one |
| 1864 | 1904 | ** trigger. Subtriggers create subcontexts for their duration. |
| 1865 | 1905 | ** |
| 1866 | -** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does | |
| 1906 | +** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does | |
| 1867 | 1907 | ** not create a new trigger context. |
| 1868 | 1908 | ** |
| 1869 | -** This function returns the number of direct row changes in the | |
| 1909 | +** ^This function returns the number of direct row changes in the | |
| 1870 | 1910 | ** most recent INSERT, UPDATE, or DELETE statement within the same |
| 1871 | 1911 | ** trigger context. |
| 1872 | 1912 | ** |
| 1873 | -** Thus, when called from the top level, this function returns the | |
| 1913 | +** ^Thus, when called from the top level, this function returns the | |
| 1874 | 1914 | ** 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, | |
| 1876 | 1916 | ** the sqlite3_changes() interface can be called to find the number of |
| 1877 | 1917 | ** changes in the most recently completed INSERT, UPDATE, or DELETE |
| 1878 | 1918 | ** statement within the body of the same trigger. |
| 1879 | 1919 | ** 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.)^ | |
| 1881 | 1921 | ** |
| 1882 | 1922 | ** See also the [sqlite3_total_changes()] interface, the |
| 1883 | 1923 | ** [count_changes pragma], and the [changes() SQL function]. |
| 1884 | 1924 | ** |
| 1885 | -** Requirements: | |
| 1886 | -** [H12241] [H12243] | |
| 1887 | -** | |
| 1888 | 1925 | ** If a separate thread makes changes on the same database connection |
| 1889 | 1926 | ** while [sqlite3_changes()] is running then the value returned |
| 1890 | 1927 | ** is unpredictable and not meaningful. |
| 1891 | 1928 | */ |
| 1892 | 1929 | SQLITE_API int sqlite3_changes(sqlite3*); |
| 1893 | 1930 | |
| 1894 | 1931 | /* |
| 1895 | -** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> | |
| 1932 | +** CAPI3REF: Total Number Of Rows Modified | |
| 1896 | 1933 | ** |
| 1897 | -** This function returns the number of row changes caused by [INSERT], | |
| 1934 | +** ^This function returns the number of row changes caused by [INSERT], | |
| 1898 | 1935 | ** [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, | |
| 1901 | 1939 | ** the count does not include changes used to implement [REPLACE] constraints, |
| 1902 | 1940 | ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The |
| 1903 | 1941 | ** count does not include rows of views that fire an [INSTEAD OF trigger], |
| 1904 | 1942 | ** 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()]). | |
| 1909 | 1947 | ** |
| 1910 | 1948 | ** See also the [sqlite3_changes()] interface, the |
| 1911 | 1949 | ** [count_changes pragma], and the [total_changes() SQL function]. |
| 1912 | 1950 | ** |
| 1913 | -** Requirements: | |
| 1914 | -** [H12261] [H12263] | |
| 1915 | -** | |
| 1916 | 1951 | ** If a separate thread makes changes on the same database connection |
| 1917 | 1952 | ** while [sqlite3_total_changes()] is running then the value |
| 1918 | 1953 | ** returned is unpredictable and not meaningful. |
| 1919 | 1954 | */ |
| 1920 | 1955 | SQLITE_API int sqlite3_total_changes(sqlite3*); |
| 1921 | 1956 | |
| 1922 | 1957 | /* |
| 1923 | -** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> | |
| 1958 | +** CAPI3REF: Interrupt A Long-Running Query | |
| 1924 | 1959 | ** |
| 1925 | -** This function causes any pending database operation to abort and | |
| 1960 | +** ^This function causes any pending database operation to abort and | |
| 1926 | 1961 | ** return at its earliest opportunity. This routine is typically |
| 1927 | 1962 | ** called in response to a user action such as pressing "Cancel" |
| 1928 | 1963 | ** or Ctrl-C where the user wants a long query operation to halt |
| 1929 | 1964 | ** immediately. |
| 1930 | 1965 | ** |
| 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 | |
| 1932 | 1967 | ** thread that is currently running the database operation. But it |
| 1933 | 1968 | ** is not safe to call this routine with a [database connection] that |
| 1934 | 1969 | ** is closed or might close before sqlite3_interrupt() returns. |
| 1935 | 1970 | ** |
| 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 | |
| 1937 | 1972 | ** sqlite3_interrupt() is called, then it might not have an opportunity |
| 1938 | 1973 | ** to be interrupted and might continue to completion. |
| 1939 | 1974 | ** |
| 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 | |
| 1942 | 1977 | ** that is inside an explicit transaction, then the entire transaction |
| 1943 | 1978 | ** will be rolled back automatically. |
| 1944 | 1979 | ** |
| 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 | |
| 1947 | 1982 | ** that are started after the sqlite3_interrupt() call and before the |
| 1948 | 1983 | ** 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 | |
| 1950 | 1985 | ** that are started after the running statement count reaches zero are |
| 1951 | 1986 | ** 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 | |
| 1953 | 1988 | ** SQL statements is a no-op and has no effect on SQL statements |
| 1954 | 1989 | ** that are started after the sqlite3_interrupt() call returns. |
| 1955 | 1990 | ** |
| 1956 | -** Requirements: | |
| 1957 | -** [H12271] [H12272] | |
| 1958 | -** | |
| 1959 | 1991 | ** If the database connection closes while [sqlite3_interrupt()] |
| 1960 | 1992 | ** is running then bad things will likely happen. |
| 1961 | 1993 | */ |
| 1962 | 1994 | SQLITE_API void sqlite3_interrupt(sqlite3*); |
| 1963 | 1995 | |
| 1964 | 1996 | /* |
| 1965 | -** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> | |
| 1997 | +** CAPI3REF: Determine If An SQL Statement Is Complete | |
| 1966 | 1998 | ** |
| 1967 | 1999 | ** These routines are useful during command-line input to determine if the |
| 1968 | 2000 | ** currently entered text seems to form a complete SQL statement or |
| 1969 | 2001 | ** 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 | |
| 1972 | 2004 | ** 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 | |
| 1974 | 2006 | ** string literals or quoted identifier names or comments are not |
| 1975 | 2007 | ** 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 | |
| 1977 | 2009 | ** and comments that follow the final semicolon are ignored. |
| 1978 | 2010 | ** |
| 1979 | -** These routines return 0 if the statement is incomplete. If a | |
| 2011 | +** ^These routines return 0 if the statement is incomplete. ^If a | |
| 1980 | 2012 | ** memory allocation fails, then SQLITE_NOMEM is returned. |
| 1981 | 2013 | ** |
| 1982 | -** These routines do not parse the SQL statements thus | |
| 2014 | +** ^These routines do not parse the SQL statements thus | |
| 1983 | 2015 | ** will not detect syntactically incorrect SQL. |
| 1984 | 2016 | ** |
| 1985 | -** If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 2017 | +** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 1986 | 2018 | ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked |
| 1987 | 2019 | ** automatically by sqlite3_complete16(). If that initialization fails, |
| 1988 | 2020 | ** 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.)^ | |
| 1992 | 2022 | ** |
| 1993 | 2023 | ** The input to [sqlite3_complete()] must be a zero-terminated |
| 1994 | 2024 | ** UTF-8 string. |
| 1995 | 2025 | ** |
| 1996 | 2026 | ** The input to [sqlite3_complete16()] must be a zero-terminated |
| @@ -1998,31 +2028,31 @@ | ||
| 1998 | 2028 | */ |
| 1999 | 2029 | SQLITE_API int sqlite3_complete(const char *sql); |
| 2000 | 2030 | SQLITE_API int sqlite3_complete16(const void *sql); |
| 2001 | 2031 | |
| 2002 | 2032 | /* |
| 2003 | -** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> | |
| 2033 | +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors | |
| 2004 | 2034 | ** |
| 2005 | -** This routine sets a callback function that might be invoked whenever | |
| 2035 | +** ^This routine sets a callback function that might be invoked whenever | |
| 2006 | 2036 | ** an attempt is made to open a database table that another thread |
| 2007 | 2037 | ** or process has locked. |
| 2008 | 2038 | ** |
| 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. | |
| 2012 | 2042 | ** |
| 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 | |
| 2017 | 2047 | ** busy callback returns 0, then no additional attempts are made to |
| 2018 | 2048 | ** 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 | |
| 2020 | 2050 | ** is made to open the database for reading and the cycle repeats. |
| 2021 | 2051 | ** |
| 2022 | 2052 | ** 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 | |
| 2024 | 2054 | ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] |
| 2025 | 2055 | ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. |
| 2026 | 2056 | ** Consider a scenario where one process is holding a read lock that |
| 2027 | 2057 | ** it is trying to promote to a reserved lock and |
| 2028 | 2058 | ** a second process is holding a reserved lock that it is trying |
| @@ -2032,69 +2062,63 @@ | ||
| 2032 | 2062 | ** invoke the busy handlers, neither will make any progress. Therefore, |
| 2033 | 2063 | ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this |
| 2034 | 2064 | ** will induce the first process to release its read lock and allow |
| 2035 | 2065 | ** the second process to proceed. |
| 2036 | 2066 | ** |
| 2037 | -** The default busy callback is NULL. | |
| 2067 | +** ^The default busy callback is NULL. | |
| 2038 | 2068 | ** |
| 2039 | -** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] | |
| 2069 | +** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] | |
| 2040 | 2070 | ** when SQLite is in the middle of a large transaction where all the |
| 2041 | 2071 | ** changes will not fit into the in-memory cache. SQLite will |
| 2042 | 2072 | ** already hold a RESERVED lock on the database file, but it needs |
| 2043 | 2073 | ** to promote this lock to EXCLUSIVE so that it can spill cache |
| 2044 | 2074 | ** 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 | |
| 2046 | 2076 | ** cache will be left in an inconsistent state and so the error |
| 2047 | 2077 | ** 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 | |
| 2049 | 2079 | ** forces an automatic rollback of the changes. See the |
| 2050 | 2080 | ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError"> |
| 2051 | 2081 | ** CorruptionFollowingBusyError</a> wiki page for a discussion of why |
| 2052 | 2082 | ** this is important. |
| 2053 | 2083 | ** |
| 2054 | -** There can only be a single busy handler defined for each | |
| 2084 | +** ^(There can only be a single busy handler defined for each | |
| 2055 | 2085 | ** [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()] | |
| 2057 | 2087 | ** will also set or clear the busy handler. |
| 2058 | 2088 | ** |
| 2059 | 2089 | ** The busy callback should not take any actions which modify the |
| 2060 | 2090 | ** database connection that invoked the busy handler. Any such actions |
| 2061 | 2091 | ** result in undefined behavior. |
| 2062 | 2092 | ** |
| 2063 | -** Requirements: | |
| 2064 | -** [H12311] [H12312] [H12314] [H12316] [H12318] | |
| 2065 | -** | |
| 2066 | 2093 | ** A busy handler must not close the database connection |
| 2067 | 2094 | ** or [prepared statement] that invoked the busy handler. |
| 2068 | 2095 | */ |
| 2069 | 2096 | SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
| 2070 | 2097 | |
| 2071 | 2098 | /* |
| 2072 | -** CAPI3REF: Set A Busy Timeout {H12340} <S40410> | |
| 2099 | +** CAPI3REF: Set A Busy Timeout | |
| 2073 | 2100 | ** |
| 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 | |
| 2076 | 2103 | ** 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, | |
| 2078 | 2105 | ** the handler returns 0 which causes [sqlite3_step()] to return |
| 2079 | 2106 | ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. |
| 2080 | 2107 | ** |
| 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 | |
| 2082 | 2109 | ** turns off all busy handlers. |
| 2083 | 2110 | ** |
| 2084 | -** There can only be a single busy handler for a particular | |
| 2111 | +** ^(There can only be a single busy handler for a particular | |
| 2085 | 2112 | ** [database connection] any any given moment. If another busy handler |
| 2086 | 2113 | ** 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.)^ | |
| 2091 | 2115 | */ |
| 2092 | 2116 | SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
| 2093 | 2117 | |
| 2094 | 2118 | /* |
| 2095 | -** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> | |
| 2119 | +** CAPI3REF: Convenience Routines For Running Queries | |
| 2096 | 2120 | ** |
| 2097 | 2121 | ** Definition: A <b>result table</b> is memory data structure created by the |
| 2098 | 2122 | ** [sqlite3_get_table()] interface. A result table records the |
| 2099 | 2123 | ** complete query results from one or more queries. |
| 2100 | 2124 | ** |
| @@ -2138,31 +2162,29 @@ | ||
| 2138 | 2162 | ** azResult[5] = "28"; |
| 2139 | 2163 | ** azResult[6] = "Cindy"; |
| 2140 | 2164 | ** azResult[7] = "21"; |
| 2141 | 2165 | ** </pre></blockquote> |
| 2142 | 2166 | ** |
| 2143 | -** The sqlite3_get_table() function evaluates one or more | |
| 2167 | +** ^The sqlite3_get_table() function evaluates one or more | |
| 2144 | 2168 | ** 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 | |
| 2146 | 2170 | ** pointer given in its 3rd parameter. |
| 2147 | 2171 | ** |
| 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 | |
| 2150 | 2174 | ** release the memory that was malloced. Because of the way the |
| 2151 | 2175 | ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling |
| 2152 | 2176 | ** function must not try to call [sqlite3_free()] directly. Only |
| 2153 | 2177 | ** [sqlite3_free_table()] is able to release the memory properly and safely. |
| 2154 | 2178 | ** |
| 2155 | -** The sqlite3_get_table() interface is implemented as a wrapper around | |
| 2179 | +** ^(The sqlite3_get_table() interface is implemented as a wrapper around | |
| 2156 | 2180 | ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access |
| 2157 | 2181 | ** to any internal data structures of SQLite. It uses only the public |
| 2158 | 2182 | ** interface defined here. As a consequence, errors that occur in the |
| 2159 | 2183 | ** 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()].)^ | |
| 2164 | 2186 | */ |
| 2165 | 2187 | SQLITE_API int sqlite3_get_table( |
| 2166 | 2188 | sqlite3 *db, /* An open database */ |
| 2167 | 2189 | const char *zSql, /* SQL to be evaluated */ |
| 2168 | 2190 | char ***pazResult, /* Results of the query */ |
| @@ -2171,49 +2193,49 @@ | ||
| 2171 | 2193 | char **pzErrmsg /* Error msg written here */ |
| 2172 | 2194 | ); |
| 2173 | 2195 | SQLITE_API void sqlite3_free_table(char **result); |
| 2174 | 2196 | |
| 2175 | 2197 | /* |
| 2176 | -** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> | |
| 2198 | +** CAPI3REF: Formatted String Printing Functions | |
| 2177 | 2199 | ** |
| 2178 | 2200 | ** These routines are work-alikes of the "printf()" family of functions |
| 2179 | 2201 | ** from the standard C library. |
| 2180 | 2202 | ** |
| 2181 | -** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their | |
| 2203 | +** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their | |
| 2182 | 2204 | ** results into memory obtained from [sqlite3_malloc()]. |
| 2183 | 2205 | ** 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 | |
| 2185 | 2207 | ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough |
| 2186 | 2208 | ** memory to hold the resulting string. |
| 2187 | 2209 | ** |
| 2188 | -** In sqlite3_snprintf() routine is similar to "snprintf()" from | |
| 2210 | +** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from | |
| 2189 | 2211 | ** the standard C library. The result is written into the |
| 2190 | 2212 | ** buffer supplied as the second parameter whose size is given by |
| 2191 | 2213 | ** 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 | |
| 2193 | 2215 | ** historical accident that cannot be fixed without breaking |
| 2194 | -** backwards compatibility. Note also that sqlite3_snprintf() | |
| 2216 | +** backwards compatibility. ^(Note also that sqlite3_snprintf() | |
| 2195 | 2217 | ** 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 | |
| 2197 | 2219 | ** the number of characters written would be a more useful return |
| 2198 | 2220 | ** value but we cannot change the implementation of sqlite3_snprintf() |
| 2199 | 2221 | ** now without breaking compatibility. |
| 2200 | 2222 | ** |
| 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 | |
| 2203 | 2225 | ** parameter "n" is the total size of the buffer, including space for |
| 2204 | 2226 | ** the zero terminator. So the longest string that can be completely |
| 2205 | 2227 | ** written will be n-1 characters. |
| 2206 | 2228 | ** |
| 2207 | 2229 | ** These routines all implement some additional formatting |
| 2208 | 2230 | ** options that are useful for constructing SQL statements. |
| 2209 | 2231 | ** All of the usual printf() formatting options apply. In addition, there |
| 2210 | 2232 | ** is are "%q", "%Q", and "%z" options. |
| 2211 | 2233 | ** |
| 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 | |
| 2213 | 2235 | ** 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 '\'' | |
| 2215 | 2237 | ** character it escapes that character and allows it to be inserted into |
| 2216 | 2238 | ** the string. |
| 2217 | 2239 | ** |
| 2218 | 2240 | ** For example, assume the string variable zText contains text as follows: |
| 2219 | 2241 | ** |
| @@ -2244,14 +2266,14 @@ | ||
| 2244 | 2266 | ** </pre></blockquote> |
| 2245 | 2267 | ** |
| 2246 | 2268 | ** This second example is an SQL syntax error. As a general rule you should |
| 2247 | 2269 | ** always use %q instead of %s when inserting text into a string literal. |
| 2248 | 2270 | ** |
| 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 | |
| 2250 | 2272 | ** the outside of the total string. Additionally, if the parameter in the |
| 2251 | 2273 | ** 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: | |
| 2253 | 2275 | ** |
| 2254 | 2276 | ** <blockquote><pre> |
| 2255 | 2277 | ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText); |
| 2256 | 2278 | ** sqlite3_exec(db, zSQL, 0, 0, 0); |
| 2257 | 2279 | ** sqlite3_free(zSQL); |
| @@ -2258,75 +2280,63 @@ | ||
| 2258 | 2280 | ** </pre></blockquote> |
| 2259 | 2281 | ** |
| 2260 | 2282 | ** The code above will render a correct SQL statement in the zSQL |
| 2261 | 2283 | ** variable even if the zText variable is a NULL pointer. |
| 2262 | 2284 | ** |
| 2263 | -** The "%z" formatting option works exactly like "%s" with the | |
| 2285 | +** ^(The "%z" formatting option works like "%s" but with the | |
| 2264 | 2286 | ** 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.)^ | |
| 2269 | 2288 | */ |
| 2270 | 2289 | SQLITE_API char *sqlite3_mprintf(const char*,...); |
| 2271 | 2290 | SQLITE_API char *sqlite3_vmprintf(const char*, va_list); |
| 2272 | 2291 | SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); |
| 2273 | 2292 | |
| 2274 | 2293 | /* |
| 2275 | -** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> | |
| 2294 | +** CAPI3REF: Memory Allocation Subsystem | |
| 2276 | 2295 | ** |
| 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 | |
| 2278 | 2297 | ** internal memory allocation needs. "Core" in the previous sentence |
| 2279 | 2298 | ** does not include operating-system specific VFS implementation. The |
| 2280 | 2299 | ** Windows VFS uses native malloc() and free() for some operations. |
| 2281 | 2300 | ** |
| 2282 | -** The sqlite3_malloc() routine returns a pointer to a block | |
| 2301 | +** ^The sqlite3_malloc() routine returns a pointer to a block | |
| 2283 | 2302 | ** 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 | |
| 2286 | 2305 | ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns |
| 2287 | 2306 | ** a NULL pointer. |
| 2288 | 2307 | ** |
| 2289 | -** Calling sqlite3_free() with a pointer previously returned | |
| 2308 | +** ^Calling sqlite3_free() with a pointer previously returned | |
| 2290 | 2309 | ** 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 | |
| 2292 | 2311 | ** a no-op if is called with a NULL pointer. Passing a NULL pointer |
| 2293 | 2312 | ** to sqlite3_free() is harmless. After being freed, memory |
| 2294 | 2313 | ** should neither be read nor written. Even reading previously freed |
| 2295 | 2314 | ** memory might result in a segmentation fault or other severe error. |
| 2296 | 2315 | ** Memory corruption, a segmentation fault, or other severe error |
| 2297 | 2316 | ** might result if sqlite3_free() is called with a non-NULL pointer that |
| 2298 | 2317 | ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). |
| 2299 | 2318 | ** |
| 2300 | -** The sqlite3_realloc() interface attempts to resize a | |
| 2319 | +** ^(The sqlite3_realloc() interface attempts to resize a | |
| 2301 | 2320 | ** prior memory allocation to be at least N bytes, where N is the |
| 2302 | 2321 | ** 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() | |
| 2304 | 2323 | ** is a NULL pointer then its behavior is identical to calling |
| 2305 | 2324 | ** 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 | |
| 2307 | 2326 | ** negative then the behavior is exactly the same as calling |
| 2308 | 2327 | ** 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 | |
| 2310 | 2329 | ** 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 | |
| 2312 | 2331 | ** of the prior allocation are copied into the beginning of buffer returned |
| 2313 | 2332 | ** 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 | |
| 2315 | 2334 | ** is not freed. |
| 2316 | 2335 | ** |
| 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. | |
| 2328 | 2338 | ** |
| 2329 | 2339 | ** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
| 2330 | 2340 | ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in |
| 2331 | 2341 | ** implementation of these routines to be omitted. That capability |
| 2332 | 2342 | ** is no longer provided. Only built-in memory allocators can be used. |
| @@ -2337,14 +2347,10 @@ | ||
| 2337 | 2347 | ** and whatever filename encoding is used by the particular Windows |
| 2338 | 2348 | ** installation. Memory allocation errors are detected, but |
| 2339 | 2349 | ** they are reported back as [SQLITE_CANTOPEN] or |
| 2340 | 2350 | ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
| 2341 | 2351 | ** |
| 2342 | -** Requirements: | |
| 2343 | -** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318] | |
| 2344 | -** [H17321] [H17322] [H17323] | |
| 2345 | -** | |
| 2346 | 2352 | ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
| 2347 | 2353 | ** must be either NULL or else pointers obtained from a prior |
| 2348 | 2354 | ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
| 2349 | 2355 | ** not yet been released. |
| 2350 | 2356 | ** |
| @@ -2355,85 +2361,95 @@ | ||
| 2355 | 2361 | SQLITE_API void *sqlite3_malloc(int); |
| 2356 | 2362 | SQLITE_API void *sqlite3_realloc(void*, int); |
| 2357 | 2363 | SQLITE_API void sqlite3_free(void*); |
| 2358 | 2364 | |
| 2359 | 2365 | /* |
| 2360 | -** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> | |
| 2366 | +** CAPI3REF: Memory Allocator Statistics | |
| 2361 | 2367 | ** |
| 2362 | 2368 | ** SQLite provides these two interfaces for reporting on the status |
| 2363 | 2369 | ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] |
| 2364 | 2370 | ** routines, which form the built-in memory allocation subsystem. |
| 2365 | 2371 | ** |
| 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. | |
| 2368 | 2387 | */ |
| 2369 | 2388 | SQLITE_API sqlite3_int64 sqlite3_memory_used(void); |
| 2370 | 2389 | SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); |
| 2371 | 2390 | |
| 2372 | 2391 | /* |
| 2373 | -** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> | |
| 2392 | +** CAPI3REF: Pseudo-Random Number Generator | |
| 2374 | 2393 | ** |
| 2375 | 2394 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| 2376 | 2395 | ** select random [ROWID | ROWIDs] when inserting new records into a table that |
| 2377 | 2396 | ** already uses the largest possible [ROWID]. The PRNG is also used for |
| 2378 | 2397 | ** the build-in random() and randomblob() SQL functions. This interface allows |
| 2379 | 2398 | ** applications to access the same PRNG for other purposes. |
| 2380 | 2399 | ** |
| 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. | |
| 2382 | 2401 | ** |
| 2383 | -** The first time this routine is invoked (either internally or by | |
| 2402 | +** ^The first time this routine is invoked (either internally or by | |
| 2384 | 2403 | ** the application) the PRNG is seeded using randomness obtained |
| 2385 | 2404 | ** 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 | |
| 2387 | 2406 | ** internally and without recourse to the [sqlite3_vfs] xRandomness |
| 2388 | 2407 | ** method. |
| 2389 | -** | |
| 2390 | -** Requirements: | |
| 2391 | -** [H17392] | |
| 2392 | 2408 | */ |
| 2393 | 2409 | SQLITE_API void sqlite3_randomness(int N, void *P); |
| 2394 | 2410 | |
| 2395 | 2411 | /* |
| 2396 | -** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> | |
| 2412 | +** CAPI3REF: Compile-Time Authorization Callbacks | |
| 2397 | 2413 | ** |
| 2398 | -** This routine registers a authorizer callback with a particular | |
| 2414 | +** ^This routine registers a authorizer callback with a particular | |
| 2399 | 2415 | ** [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 | |
| 2401 | 2417 | ** 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 | |
| 2403 | 2419 | ** points during the compilation process, as logic is being created |
| 2404 | 2420 | ** 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 | |
| 2406 | 2422 | ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the |
| 2407 | 2423 | ** specific action but allow the SQL statement to continue to be |
| 2408 | 2424 | ** 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 | |
| 2410 | 2426 | ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] |
| 2411 | 2427 | ** then the [sqlite3_prepare_v2()] or equivalent call that triggered |
| 2412 | 2428 | ** the authorizer will fail with an error message. |
| 2413 | 2429 | ** |
| 2414 | 2430 | ** 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 | |
| 2416 | 2432 | ** [sqlite3_prepare_v2()] or equivalent call that triggered the |
| 2417 | 2433 | ** authorizer will fail with an error message explaining that |
| 2418 | 2434 | ** access is denied. |
| 2419 | 2435 | ** |
| 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 | |
| 2422 | 2438 | ** 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 | |
| 2424 | 2440 | ** to the callback are zero-terminated strings that contain additional |
| 2425 | 2441 | ** details about the action to be authorized. |
| 2426 | 2442 | ** |
| 2427 | -** If the action code is [SQLITE_READ] | |
| 2443 | +** ^If the action code is [SQLITE_READ] | |
| 2428 | 2444 | ** and the callback returns [SQLITE_IGNORE] then the |
| 2429 | 2445 | ** [prepared statement] statement is constructed to substitute |
| 2430 | 2446 | ** a NULL value in place of the table column that would have |
| 2431 | 2447 | ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] |
| 2432 | 2448 | ** return can be used to deny an untrusted user access to individual |
| 2433 | 2449 | ** 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 | |
| 2435 | 2451 | ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the |
| 2436 | 2452 | ** [truncate optimization] is disabled and all rows are deleted individually. |
| 2437 | 2453 | ** |
| 2438 | 2454 | ** An authorizer is used when [sqlite3_prepare | preparing] |
| 2439 | 2455 | ** SQL statements from an untrusted source, to ensure that the SQL statements |
| @@ -2449,43 +2465,39 @@ | ||
| 2449 | 2465 | ** Applications that need to process SQL from untrusted sources |
| 2450 | 2466 | ** might also consider lowering resource limits using [sqlite3_limit()] |
| 2451 | 2467 | ** and limiting database size using the [max_page_count] [PRAGMA] |
| 2452 | 2468 | ** in addition to using an authorizer. |
| 2453 | 2469 | ** |
| 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 | |
| 2455 | 2471 | ** 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. | |
| 2457 | 2473 | ** The authorizer is disabled by default. |
| 2458 | 2474 | ** |
| 2459 | 2475 | ** The authorizer callback must not do anything that will modify |
| 2460 | 2476 | ** the database connection that invoked the authorizer callback. |
| 2461 | 2477 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 2462 | 2478 | ** database connections for the meaning of "modify" in this paragraph. |
| 2463 | 2479 | ** |
| 2464 | -** When [sqlite3_prepare_v2()] is used to prepare a statement, the | |
| 2480 | +** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the | |
| 2465 | 2481 | ** statement might be re-prepared during [sqlite3_step()] due to a |
| 2466 | 2482 | ** schema change. Hence, the application should ensure that the |
| 2467 | 2483 | ** correct authorizer callback remains in place during the [sqlite3_step()]. |
| 2468 | 2484 | ** |
| 2469 | -** Note that the authorizer callback is invoked only during | |
| 2485 | +** ^Note that the authorizer callback is invoked only during | |
| 2470 | 2486 | ** [sqlite3_prepare()] or its variants. Authorization is not |
| 2471 | 2487 | ** performed during statement evaluation in [sqlite3_step()], unless |
| 2472 | 2488 | ** as stated in the previous paragraph, sqlite3_step() invokes |
| 2473 | 2489 | ** 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 | 2490 | */ |
| 2479 | 2491 | SQLITE_API int sqlite3_set_authorizer( |
| 2480 | 2492 | sqlite3*, |
| 2481 | 2493 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
| 2482 | 2494 | void *pUserData |
| 2483 | 2495 | ); |
| 2484 | 2496 | |
| 2485 | 2497 | /* |
| 2486 | -** CAPI3REF: Authorizer Return Codes {H12590} <H12500> | |
| 2498 | +** CAPI3REF: Authorizer Return Codes | |
| 2487 | 2499 | ** |
| 2488 | 2500 | ** The [sqlite3_set_authorizer | authorizer callback function] must |
| 2489 | 2501 | ** return either [SQLITE_OK] or one of these two constants in order |
| 2490 | 2502 | ** to signal SQLite whether or not the action is permitted. See the |
| 2491 | 2503 | ** [sqlite3_set_authorizer | authorizer documentation] for additional |
| @@ -2493,11 +2505,11 @@ | ||
| 2493 | 2505 | */ |
| 2494 | 2506 | #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ |
| 2495 | 2507 | #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ |
| 2496 | 2508 | |
| 2497 | 2509 | /* |
| 2498 | -** CAPI3REF: Authorizer Action Codes {H12550} <H12500> | |
| 2510 | +** CAPI3REF: Authorizer Action Codes | |
| 2499 | 2511 | ** |
| 2500 | 2512 | ** The [sqlite3_set_authorizer()] interface registers a callback function |
| 2501 | 2513 | ** that is invoked to authorize certain SQL statement actions. The |
| 2502 | 2514 | ** second parameter to the callback is an integer code that specifies |
| 2503 | 2515 | ** what action is being authorized. These are the integer action codes that |
| @@ -2504,19 +2516,16 @@ | ||
| 2504 | 2516 | ** the authorizer callback may be passed. |
| 2505 | 2517 | ** |
| 2506 | 2518 | ** These action code values signify what kind of operation is to be |
| 2507 | 2519 | ** authorized. The 3rd and 4th parameters to the authorization |
| 2508 | 2520 | ** 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 | |
| 2510 | 2522 | ** 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 | |
| 2512 | 2524 | ** is the name of the inner-most trigger or view that is responsible for |
| 2513 | 2525 | ** the access attempt or NULL if this access attempt is directly from |
| 2514 | 2526 | ** top-level SQL code. |
| 2515 | -** | |
| 2516 | -** Requirements: | |
| 2517 | -** [H12551] [H12552] [H12553] [H12554] | |
| 2518 | 2527 | */ |
| 2519 | 2528 | /******************************************* 3rd ************ 4th ***********/ |
| 2520 | 2529 | #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ |
| 2521 | 2530 | #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ |
| 2522 | 2531 | #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ |
| @@ -2550,150 +2559,142 @@ | ||
| 2550 | 2559 | #define SQLITE_FUNCTION 31 /* NULL Function Name */ |
| 2551 | 2560 | #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ |
| 2552 | 2561 | #define SQLITE_COPY 0 /* No longer used */ |
| 2553 | 2562 | |
| 2554 | 2563 | /* |
| 2555 | -** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> | |
| 2564 | +** CAPI3REF: Tracing And Profiling Functions | |
| 2556 | 2565 | ** EXPERIMENTAL |
| 2557 | 2566 | ** |
| 2558 | 2567 | ** These routines register callback functions that can be used for |
| 2559 | 2568 | ** tracing and profiling the execution of SQL statements. |
| 2560 | 2569 | ** |
| 2561 | -** The callback function registered by sqlite3_trace() is invoked at | |
| 2570 | +** ^The callback function registered by sqlite3_trace() is invoked at | |
| 2562 | 2571 | ** 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 | |
| 2565 | 2575 | ** 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.)^ | |
| 2567 | 2577 | ** |
| 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 | |
| 2570 | 2580 | ** the original statement text and an estimate of wall-clock time |
| 2571 | 2581 | ** of how long that statement took to run. |
| 2572 | -** | |
| 2573 | -** Requirements: | |
| 2574 | -** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289] | |
| 2575 | -** [H12290] | |
| 2576 | 2582 | */ |
| 2577 | 2583 | SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 2578 | 2584 | SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
| 2579 | 2585 | void(*xProfile)(void*,const char*,sqlite3_uint64), void*); |
| 2580 | 2586 | |
| 2581 | 2587 | /* |
| 2582 | -** CAPI3REF: Query Progress Callbacks {H12910} <S60400> | |
| 2588 | +** CAPI3REF: Query Progress Callbacks | |
| 2583 | 2589 | ** |
| 2584 | -** This routine configures a callback function - the | |
| 2590 | +** ^This routine configures a callback function - the | |
| 2585 | 2591 | ** progress callback - that is invoked periodically during long |
| 2586 | 2592 | ** running calls to [sqlite3_exec()], [sqlite3_step()] and |
| 2587 | 2593 | ** [sqlite3_get_table()]. An example use for this |
| 2588 | 2594 | ** interface is to keep a GUI updated during a large query. |
| 2589 | 2595 | ** |
| 2590 | -** If the progress callback returns non-zero, the operation is | |
| 2596 | +** ^If the progress callback returns non-zero, the operation is | |
| 2591 | 2597 | ** interrupted. This feature can be used to implement a |
| 2592 | 2598 | ** "Cancel" button on a GUI progress dialog box. |
| 2593 | 2599 | ** |
| 2594 | 2600 | ** The progress handler must not do anything that will modify |
| 2595 | 2601 | ** the database connection that invoked the progress handler. |
| 2596 | 2602 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 2597 | 2603 | ** database connections for the meaning of "modify" in this paragraph. |
| 2598 | 2604 | ** |
| 2599 | -** Requirements: | |
| 2600 | -** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918] | |
| 2601 | -** | |
| 2602 | 2605 | */ |
| 2603 | 2606 | SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
| 2604 | 2607 | |
| 2605 | 2608 | /* |
| 2606 | -** CAPI3REF: Opening A New Database Connection {H12700} <S40200> | |
| 2609 | +** CAPI3REF: Opening A New Database Connection | |
| 2607 | 2610 | ** |
| 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 | |
| 2610 | 2613 | ** 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 | |
| 2612 | 2615 | ** returned in *ppDb, even if an error occurs. The only exception is that |
| 2613 | 2616 | ** if SQLite is unable to allocate memory to hold the [sqlite3] object, |
| 2614 | 2617 | ** 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 | |
| 2617 | 2620 | ** [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. | |
| 2619 | 2623 | ** |
| 2620 | -** The default encoding for the database will be UTF-8 if | |
| 2624 | +** ^The default encoding for the database will be UTF-8 if | |
| 2621 | 2625 | ** sqlite3_open() or sqlite3_open_v2() is called and |
| 2622 | 2626 | ** UTF-16 in the native byte order if sqlite3_open16() is used. |
| 2623 | 2627 | ** |
| 2624 | 2628 | ** Whether or not an error occurs when it is opened, resources |
| 2625 | 2629 | ** associated with the [database connection] handle should be released by |
| 2626 | 2630 | ** passing it to [sqlite3_close()] when it is no longer required. |
| 2627 | 2631 | ** |
| 2628 | 2632 | ** The sqlite3_open_v2() interface works like sqlite3_open() |
| 2629 | 2633 | ** 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 | |
| 2631 | 2636 | ** the following three values, optionally combined with the |
| 2632 | 2637 | ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
| 2633 | -** and/or [SQLITE_OPEN_PRIVATECACHE] flags: | |
| 2638 | +** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ | |
| 2634 | 2639 | ** |
| 2635 | 2640 | ** <dl> |
| 2636 | -** <dt>[SQLITE_OPEN_READONLY]</dt> | |
| 2641 | +** ^(<dt>[SQLITE_OPEN_READONLY]</dt> | |
| 2637 | 2642 | ** <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>)^ | |
| 2639 | 2644 | ** |
| 2640 | -** <dt>[SQLITE_OPEN_READWRITE]</dt> | |
| 2645 | +** ^(<dt>[SQLITE_OPEN_READWRITE]</dt> | |
| 2641 | 2646 | ** <dd>The database is opened for reading and writing if possible, or reading |
| 2642 | 2647 | ** 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>)^ | |
| 2644 | 2649 | ** |
| 2645 | -** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> | |
| 2650 | +** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> | |
| 2646 | 2651 | ** <dd>The database is opened for reading and writing, and is creates it if |
| 2647 | 2652 | ** 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>)^ | |
| 2649 | 2654 | ** </dl> |
| 2650 | 2655 | ** |
| 2651 | 2656 | ** If the 3rd parameter to sqlite3_open_v2() is not one of the |
| 2652 | 2657 | ** combinations shown above or one of the combinations shown above combined |
| 2653 | 2658 | ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], |
| 2654 | 2659 | ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, |
| 2655 | 2660 | ** then the behavior is undefined. |
| 2656 | 2661 | ** |
| 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 | |
| 2658 | 2663 | ** 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 | |
| 2660 | 2665 | ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens |
| 2661 | 2666 | ** in the serialized [threading mode] unless single-thread was |
| 2662 | 2667 | ** 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 | |
| 2664 | 2669 | ** 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 | |
| 2666 | 2671 | ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not |
| 2667 | 2672 | ** participate in [shared cache mode] even if it is enabled. |
| 2668 | 2673 | ** |
| 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 | |
| 2671 | 2676 | ** the database connection is closed. Future versions of SQLite might |
| 2672 | 2677 | ** make use of additional special filenames that begin with the ":" character. |
| 2673 | 2678 | ** It is recommended that when a database filename actually does begin with |
| 2674 | 2679 | ** a ":" character you should prefix the filename with a pathname such as |
| 2675 | 2680 | ** "./" to avoid ambiguity. |
| 2676 | 2681 | ** |
| 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 | |
| 2679 | 2684 | ** automatically deleted as soon as the database connection is closed. |
| 2680 | 2685 | ** |
| 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 | |
| 2682 | 2687 | ** [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 | |
| 2684 | 2689 | ** a NULL pointer then the default [sqlite3_vfs] object is used. |
| 2685 | 2690 | ** |
| 2686 | 2691 | ** <b>Note to Windows users:</b> The encoding used for the filename argument |
| 2687 | 2692 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever |
| 2688 | 2693 | ** codepage is currently defined. Filenames containing international |
| 2689 | 2694 | ** characters must be converted to UTF-8 prior to passing them into |
| 2690 | 2695 | ** 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 | */ |
| 2696 | 2697 | SQLITE_API int sqlite3_open( |
| 2697 | 2698 | const char *filename, /* Database filename (UTF-8) */ |
| 2698 | 2699 | sqlite3 **ppDb /* OUT: SQLite db handle */ |
| 2699 | 2700 | ); |
| @@ -2707,27 +2708,27 @@ | ||
| 2707 | 2708 | int flags, /* Flags */ |
| 2708 | 2709 | const char *zVfs /* Name of VFS module to use */ |
| 2709 | 2710 | ); |
| 2710 | 2711 | |
| 2711 | 2712 | /* |
| 2712 | -** CAPI3REF: Error Codes And Messages {H12800} <S60200> | |
| 2713 | +** CAPI3REF: Error Codes And Messages | |
| 2713 | 2714 | ** |
| 2714 | -** The sqlite3_errcode() interface returns the numeric [result code] or | |
| 2715 | +** ^The sqlite3_errcode() interface returns the numeric [result code] or | |
| 2715 | 2716 | ** [extended result code] for the most recent failed sqlite3_* API call |
| 2716 | 2717 | ** associated with a [database connection]. If a prior API call failed |
| 2717 | 2718 | ** 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() | |
| 2719 | 2720 | ** interface is the same except that it always returns the |
| 2720 | 2721 | ** [extended result code] even when extended result codes are |
| 2721 | 2722 | ** disabled. |
| 2722 | 2723 | ** |
| 2723 | -** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | |
| 2724 | +** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | |
| 2724 | 2725 | ** 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. | |
| 2726 | 2727 | ** The application does not need to worry about freeing the result. |
| 2727 | 2728 | ** 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.)^ | |
| 2729 | 2730 | ** |
| 2730 | 2731 | ** When the serialized [threading mode] is in use, it might be the |
| 2731 | 2732 | ** case that a second error occurs on a separate thread in between |
| 2732 | 2733 | ** the time of the first error and the call to these interfaces. |
| 2733 | 2734 | ** When that happens, the second error will be reported since these |
| @@ -2738,21 +2739,18 @@ | ||
| 2738 | 2739 | ** all calls to the interfaces listed here are completed. |
| 2739 | 2740 | ** |
| 2740 | 2741 | ** If an interface fails with SQLITE_MISUSE, that means the interface |
| 2741 | 2742 | ** was invoked incorrectly by the application. In that case, the |
| 2742 | 2743 | ** error code and message may or may not be set. |
| 2743 | -** | |
| 2744 | -** Requirements: | |
| 2745 | -** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809] | |
| 2746 | 2744 | */ |
| 2747 | 2745 | SQLITE_API int sqlite3_errcode(sqlite3 *db); |
| 2748 | 2746 | SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); |
| 2749 | 2747 | SQLITE_API const char *sqlite3_errmsg(sqlite3*); |
| 2750 | 2748 | SQLITE_API const void *sqlite3_errmsg16(sqlite3*); |
| 2751 | 2749 | |
| 2752 | 2750 | /* |
| 2753 | -** CAPI3REF: SQL Statement Object {H13000} <H13010> | |
| 2751 | +** CAPI3REF: SQL Statement Object | |
| 2754 | 2752 | ** KEYWORDS: {prepared statement} {prepared statements} |
| 2755 | 2753 | ** |
| 2756 | 2754 | ** An instance of this object represents a single SQL statement. |
| 2757 | 2755 | ** This object is variously known as a "prepared statement" or a |
| 2758 | 2756 | ** "compiled SQL statement" or simply as a "statement". |
| @@ -2774,29 +2772,29 @@ | ||
| 2774 | 2772 | ** information. |
| 2775 | 2773 | */ |
| 2776 | 2774 | typedef struct sqlite3_stmt sqlite3_stmt; |
| 2777 | 2775 | |
| 2778 | 2776 | /* |
| 2779 | -** CAPI3REF: Run-time Limits {H12760} <S20600> | |
| 2777 | +** CAPI3REF: Run-time Limits | |
| 2780 | 2778 | ** |
| 2781 | -** This interface allows the size of various constructs to be limited | |
| 2779 | +** ^(This interface allows the size of various constructs to be limited | |
| 2782 | 2780 | ** on a connection by connection basis. The first parameter is the |
| 2783 | 2781 | ** [database connection] whose limit is to be set or queried. The |
| 2784 | 2782 | ** second parameter is one of the [limit categories] that define a |
| 2785 | 2783 | ** 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.)^ | |
| 2787 | 2785 | ** |
| 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 | |
| 2790 | 2788 | ** [limits | hard upper bound] |
| 2791 | 2789 | ** set by a compile-time C preprocessor macro named |
| 2792 | 2790 | ** [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. | |
| 2796 | 2794 | ** |
| 2797 | -** Run time limits are intended for use in applications that manage | |
| 2795 | +** Run-time limits are intended for use in applications that manage | |
| 2798 | 2796 | ** both their own internal database and also databases that are controlled |
| 2799 | 2797 | ** by untrusted external sources. An example application might be a |
| 2800 | 2798 | ** web browser that has its own databases for storing history and |
| 2801 | 2799 | ** separate databases controlled by JavaScript applications downloaded |
| 2802 | 2800 | ** off the Internet. The internal databases can be given the |
| @@ -2806,63 +2804,60 @@ | ||
| 2806 | 2804 | ** interface to further control untrusted SQL. The size of the database |
| 2807 | 2805 | ** created by an untrusted script can be contained using the |
| 2808 | 2806 | ** [max_page_count] [PRAGMA]. |
| 2809 | 2807 | ** |
| 2810 | 2808 | ** New run-time limit categories may be added in future releases. |
| 2811 | -** | |
| 2812 | -** Requirements: | |
| 2813 | -** [H12762] [H12766] [H12769] | |
| 2814 | 2809 | */ |
| 2815 | 2810 | SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
| 2816 | 2811 | |
| 2817 | 2812 | /* |
| 2818 | -** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> | |
| 2813 | +** CAPI3REF: Run-Time Limit Categories | |
| 2819 | 2814 | ** KEYWORDS: {limit category} {*limit categories} |
| 2820 | 2815 | ** |
| 2821 | 2816 | ** These constants define various performance limits |
| 2822 | 2817 | ** that can be lowered at run-time using [sqlite3_limit()]. |
| 2823 | 2818 | ** The synopsis of the meanings of the various limits is shown below. |
| 2824 | 2819 | ** Additional information is available at [limits | Limits in SQLite]. |
| 2825 | 2820 | ** |
| 2826 | 2821 | ** <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>)^ | |
| 2829 | 2824 | ** |
| 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>)^ | |
| 2832 | 2827 | ** |
| 2833 | -** <dt>SQLITE_LIMIT_COLUMN</dt> | |
| 2828 | +** ^(<dt>SQLITE_LIMIT_COLUMN</dt> | |
| 2834 | 2829 | ** <dd>The maximum number of columns in a table definition or in the |
| 2835 | 2830 | ** 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> | |
| 2845 | 2840 | ** <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> | |
| 2855 | 2850 | ** <dd>The maximum length of the pattern argument to the [LIKE] or |
| 2856 | -** [GLOB] operators.</dd> | |
| 2851 | +** [GLOB] operators.</dd>)^ | |
| 2857 | 2852 | ** |
| 2858 | -** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> | |
| 2853 | +** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> | |
| 2859 | 2854 | ** <dd>The maximum number of variables in an SQL statement that can |
| 2860 | -** be bound.</dd> | |
| 2855 | +** be bound.</dd>)^ | |
| 2861 | 2856 | ** |
| 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>)^ | |
| 2864 | 2859 | ** </dl> |
| 2865 | 2860 | */ |
| 2866 | 2861 | #define SQLITE_LIMIT_LENGTH 0 |
| 2867 | 2862 | #define SQLITE_LIMIT_SQL_LENGTH 1 |
| 2868 | 2863 | #define SQLITE_LIMIT_COLUMN 2 |
| @@ -2874,11 +2869,11 @@ | ||
| 2874 | 2869 | #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 |
| 2875 | 2870 | #define SQLITE_LIMIT_VARIABLE_NUMBER 9 |
| 2876 | 2871 | #define SQLITE_LIMIT_TRIGGER_DEPTH 10 |
| 2877 | 2872 | |
| 2878 | 2873 | /* |
| 2879 | -** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> | |
| 2874 | +** CAPI3REF: Compiling An SQL Statement | |
| 2880 | 2875 | ** KEYWORDS: {SQL statement compiler} |
| 2881 | 2876 | ** |
| 2882 | 2877 | ** To execute an SQL query, it must first be compiled into a byte-code |
| 2883 | 2878 | ** program using one of these routines. |
| 2884 | 2879 | ** |
| @@ -2889,61 +2884,62 @@ | ||
| 2889 | 2884 | ** The second argument, "zSql", is the statement to be compiled, encoded |
| 2890 | 2885 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 2891 | 2886 | ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 2892 | 2887 | ** use UTF-16. |
| 2893 | 2888 | ** |
| 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 | |
| 2897 | 2892 | ** zSql string ends at either the first '\000' or '\u0000' character or |
| 2898 | 2893 | ** the nByte-th byte, whichever comes first. If the caller knows |
| 2899 | 2894 | ** that the supplied string is nul-terminated, then there is a small |
| 2900 | 2895 | ** performance advantage to be gained by passing an nByte parameter that |
| 2901 | 2896 | ** is equal to the number of bytes in the input string <i>including</i> |
| 2902 | 2897 | ** the nul-terminator bytes. |
| 2903 | 2898 | ** |
| 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 | |
| 2905 | 2900 | ** past the end of the first SQL statement in zSql. These routines only |
| 2906 | 2901 | ** compile the first statement in zSql, so *pzTail is left pointing to |
| 2907 | 2902 | ** what remains uncompiled. |
| 2908 | 2903 | ** |
| 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 | |
| 2912 | 2907 | ** string or a comment) then *ppStmt is set to NULL. |
| 2913 | 2908 | ** The calling procedure is responsible for deleting the compiled |
| 2914 | 2909 | ** SQL statement using [sqlite3_finalize()] after it has finished with it. |
| 2915 | 2910 | ** ppStmt may not be NULL. |
| 2916 | 2911 | ** |
| 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. | |
| 2918 | 2914 | ** |
| 2919 | 2915 | ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are |
| 2920 | 2916 | ** recommended for all new programs. The two older interfaces are retained |
| 2921 | 2917 | ** for backwards compatibility, but their use is discouraged. |
| 2922 | -** In the "v2" interfaces, the prepared statement | |
| 2918 | +** ^In the "v2" interfaces, the prepared statement | |
| 2923 | 2919 | ** that is returned (the [sqlite3_stmt] object) contains a copy of the |
| 2924 | 2920 | ** original SQL text. This causes the [sqlite3_step()] interface to |
| 2925 | 2921 | ** behave differently in three ways: |
| 2926 | 2922 | ** |
| 2927 | 2923 | ** <ol> |
| 2928 | 2924 | ** <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 | |
| 2930 | 2926 | ** 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 | |
| 2932 | 2928 | ** a way that makes the statement no longer valid, [sqlite3_step()] will still |
| 2933 | 2929 | ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is |
| 2934 | 2930 | ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the |
| 2935 | 2931 | ** error go away. Note: use [sqlite3_errmsg()] to find the text |
| 2936 | 2932 | ** of the parsing error that results in an [SQLITE_SCHEMA] return. |
| 2937 | 2933 | ** </li> |
| 2938 | 2934 | ** |
| 2939 | 2935 | ** <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 | |
| 2942 | 2938 | ** [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 | |
| 2945 | 2941 | ** interfaces, the underlying reason for the error is returned immediately. |
| 2946 | 2942 | ** </li> |
| 2947 | 2943 | ** |
| 2948 | 2944 | ** <li> |
| 2949 | 2945 | ** ^If the value of a [parameter | host parameter] in the WHERE clause might |
| @@ -2951,14 +2947,10 @@ | ||
| 2951 | 2947 | ** automatically recompiled (as if there had been a schema change) on the first |
| 2952 | 2948 | ** [sqlite3_step()] call following any change to the |
| 2953 | 2949 | ** [sqlite3_bind_text | bindings] of the [parameter]. |
| 2954 | 2950 | ** </li> |
| 2955 | 2951 | ** </ol> |
| 2956 | -** | |
| 2957 | -** Requirements: | |
| 2958 | -** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021] | |
| 2959 | -** | |
| 2960 | 2952 | */ |
| 2961 | 2953 | SQLITE_API int sqlite3_prepare( |
| 2962 | 2954 | sqlite3 *db, /* Database handle */ |
| 2963 | 2955 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 2964 | 2956 | int nByte, /* Maximum length of zSql in bytes. */ |
| @@ -2986,28 +2978,25 @@ | ||
| 2986 | 2978 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 2987 | 2979 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 2988 | 2980 | ); |
| 2989 | 2981 | |
| 2990 | 2982 | /* |
| 2991 | -** CAPI3REF: Retrieving Statement SQL {H13100} <H13000> | |
| 2983 | +** CAPI3REF: Retrieving Statement SQL | |
| 2992 | 2984 | ** |
| 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 | |
| 2994 | 2986 | ** SQL text used to create a [prepared statement] if that statement was |
| 2995 | 2987 | ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. |
| 2996 | -** | |
| 2997 | -** Requirements: | |
| 2998 | -** [H13101] [H13102] [H13103] | |
| 2999 | 2988 | */ |
| 3000 | 2989 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 3001 | 2990 | |
| 3002 | 2991 | /* |
| 3003 | -** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200> | |
| 2992 | +** CAPI3REF: Dynamically Typed Value Object | |
| 3004 | 2993 | ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} |
| 3005 | 2994 | ** |
| 3006 | 2995 | ** SQLite uses the sqlite3_value object to represent all values |
| 3007 | 2996 | ** 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 | |
| 3009 | 2998 | ** can be integers, floating point values, strings, BLOBs, or NULL. |
| 3010 | 2999 | ** |
| 3011 | 3000 | ** An sqlite3_value object may be either "protected" or "unprotected". |
| 3012 | 3001 | ** Some interfaces require a protected sqlite3_value. Other interfaces |
| 3013 | 3002 | ** will accept either a protected or an unprotected sqlite3_value. |
| @@ -3025,26 +3014,26 @@ | ||
| 3025 | 3014 | ** sqlite3_value objects and they can be used interchangeably. However, |
| 3026 | 3015 | ** for maximum code portability it is recommended that applications |
| 3027 | 3016 | ** still make the distinction between between protected and unprotected |
| 3028 | 3017 | ** sqlite3_value objects even when not strictly required. |
| 3029 | 3018 | ** |
| 3030 | -** The sqlite3_value objects that are passed as parameters into the | |
| 3019 | +** ^The sqlite3_value objects that are passed as parameters into the | |
| 3031 | 3020 | ** implementation of [application-defined SQL functions] are protected. |
| 3032 | -** The sqlite3_value object returned by | |
| 3021 | +** ^The sqlite3_value object returned by | |
| 3033 | 3022 | ** [sqlite3_column_value()] is unprotected. |
| 3034 | 3023 | ** Unprotected sqlite3_value objects may only be used with |
| 3035 | 3024 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. |
| 3036 | 3025 | ** The [sqlite3_value_blob | sqlite3_value_type()] family of |
| 3037 | 3026 | ** interfaces require protected sqlite3_value objects. |
| 3038 | 3027 | */ |
| 3039 | 3028 | typedef struct Mem sqlite3_value; |
| 3040 | 3029 | |
| 3041 | 3030 | /* |
| 3042 | -** CAPI3REF: SQL Function Context Object {H16001} <S20200> | |
| 3031 | +** CAPI3REF: SQL Function Context Object | |
| 3043 | 3032 | ** |
| 3044 | 3033 | ** 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 | |
| 3046 | 3035 | ** is always first parameter to [application-defined SQL functions]. |
| 3047 | 3036 | ** The application-defined SQL function implementation will pass this |
| 3048 | 3037 | ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], |
| 3049 | 3038 | ** [sqlite3_aggregate_context()], [sqlite3_user_data()], |
| 3050 | 3039 | ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], |
| @@ -3051,15 +3040,15 @@ | ||
| 3051 | 3040 | ** and/or [sqlite3_set_auxdata()]. |
| 3052 | 3041 | */ |
| 3053 | 3042 | typedef struct sqlite3_context sqlite3_context; |
| 3054 | 3043 | |
| 3055 | 3044 | /* |
| 3056 | -** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300> | |
| 3045 | +** CAPI3REF: Binding Values To Prepared Statements | |
| 3057 | 3046 | ** KEYWORDS: {host parameter} {host parameters} {host parameter name} |
| 3058 | 3047 | ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} |
| 3059 | 3048 | ** |
| 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, | |
| 3061 | 3050 | ** literals may be replaced by a [parameter] that matches one of following |
| 3062 | 3051 | ** templates: |
| 3063 | 3052 | ** |
| 3064 | 3053 | ** <ul> |
| 3065 | 3054 | ** <li> ? |
| @@ -3068,76 +3057,70 @@ | ||
| 3068 | 3057 | ** <li> @VVV |
| 3069 | 3058 | ** <li> $VVV |
| 3070 | 3059 | ** </ul> |
| 3071 | 3060 | ** |
| 3072 | 3061 | ** 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 | |
| 3074 | 3063 | ** parameters (also called "host parameter names" or "SQL parameters") |
| 3075 | 3064 | ** can be set using the sqlite3_bind_*() routines defined here. |
| 3076 | 3065 | ** |
| 3077 | -** The first argument to the sqlite3_bind_*() routines is always | |
| 3066 | +** ^The first argument to the sqlite3_bind_*() routines is always | |
| 3078 | 3067 | ** a pointer to the [sqlite3_stmt] object returned from |
| 3079 | 3068 | ** [sqlite3_prepare_v2()] or its variants. |
| 3080 | 3069 | ** |
| 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 | |
| 3083 | 3072 | ** SQL parameter is used more than once, second and subsequent |
| 3084 | 3073 | ** 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 | |
| 3087 | 3076 | ** 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()] | |
| 3089 | 3078 | ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). |
| 3090 | 3079 | ** |
| 3091 | -** The third argument is the value to bind to the parameter. | |
| 3080 | +** ^The third argument is the value to bind to the parameter. | |
| 3092 | 3081 | ** |
| 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 | |
| 3094 | 3083 | ** 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 | |
| 3097 | 3086 | ** the number of bytes up to the first zero terminator. |
| 3098 | 3087 | ** |
| 3099 | -** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and | |
| 3088 | +** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and | |
| 3100 | 3089 | ** 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 | |
| 3102 | 3091 | ** the special value [SQLITE_STATIC], then SQLite assumes that the |
| 3103 | 3092 | ** 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 | |
| 3105 | 3094 | ** SQLite makes its own private copy of the data immediately, before |
| 3106 | 3095 | ** the sqlite3_bind_*() routine returns. |
| 3107 | 3096 | ** |
| 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 | |
| 3110 | 3099 | ** (just an integer to hold its size) while it is being processed. |
| 3111 | 3100 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 3112 | 3101 | ** content is later written using |
| 3113 | 3102 | ** [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. | |
| 3131 | 3119 | ** |
| 3132 | 3120 | ** See also: [sqlite3_bind_parameter_count()], |
| 3133 | 3121 | ** [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 | 3122 | */ |
| 3140 | 3123 | SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); |
| 3141 | 3124 | SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); |
| 3142 | 3125 | SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); |
| 3143 | 3126 | SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); |
| @@ -3146,175 +3129,155 @@ | ||
| 3146 | 3129 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 3147 | 3130 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 3148 | 3131 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 3149 | 3132 | |
| 3150 | 3133 | /* |
| 3151 | -** CAPI3REF: Number Of SQL Parameters {H13600} <S70300> | |
| 3134 | +** CAPI3REF: Number Of SQL Parameters | |
| 3152 | 3135 | ** |
| 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] | |
| 3154 | 3137 | ** in a [prepared statement]. SQL parameters are tokens of the |
| 3155 | 3138 | ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as |
| 3156 | 3139 | ** placeholders for values that are [sqlite3_bind_blob | bound] |
| 3157 | 3140 | ** to the parameters at a later time. |
| 3158 | 3141 | ** |
| 3159 | -** This routine actually returns the index of the largest (rightmost) | |
| 3142 | +** ^(This routine actually returns the index of the largest (rightmost) | |
| 3160 | 3143 | ** 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.)^ | |
| 3163 | 3146 | ** |
| 3164 | 3147 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3165 | 3148 | ** [sqlite3_bind_parameter_name()], and |
| 3166 | 3149 | ** [sqlite3_bind_parameter_index()]. |
| 3167 | -** | |
| 3168 | -** Requirements: | |
| 3169 | -** [H13601] | |
| 3170 | 3150 | */ |
| 3171 | 3151 | SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); |
| 3172 | 3152 | |
| 3173 | 3153 | /* |
| 3174 | -** CAPI3REF: Name Of A Host Parameter {H13620} <S70300> | |
| 3154 | +** CAPI3REF: Name Of A Host Parameter | |
| 3175 | 3155 | ** |
| 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" | |
| 3179 | 3159 | ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" |
| 3180 | 3160 | ** respectively. |
| 3181 | 3161 | ** 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 | |
| 3190 | 3170 | ** always in UTF-8 encoding even if the named parameter was |
| 3191 | 3171 | ** originally specified as UTF-16 in [sqlite3_prepare16()] or |
| 3192 | 3172 | ** [sqlite3_prepare16_v2()]. |
| 3193 | 3173 | ** |
| 3194 | 3174 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3195 | 3175 | ** [sqlite3_bind_parameter_count()], and |
| 3196 | 3176 | ** [sqlite3_bind_parameter_index()]. |
| 3197 | -** | |
| 3198 | -** Requirements: | |
| 3199 | -** [H13621] | |
| 3200 | 3177 | */ |
| 3201 | 3178 | SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); |
| 3202 | 3179 | |
| 3203 | 3180 | /* |
| 3204 | -** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300> | |
| 3181 | +** CAPI3REF: Index Of A Parameter With A Given Name | |
| 3205 | 3182 | ** |
| 3206 | -** Return the index of an SQL parameter given its name. The | |
| 3183 | +** ^Return the index of an SQL parameter given its name. ^The | |
| 3207 | 3184 | ** 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 | |
| 3210 | 3187 | ** name must be given in UTF-8 even if the original statement |
| 3211 | 3188 | ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. |
| 3212 | 3189 | ** |
| 3213 | 3190 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 3214 | 3191 | ** [sqlite3_bind_parameter_count()], and |
| 3215 | 3192 | ** [sqlite3_bind_parameter_index()]. |
| 3216 | -** | |
| 3217 | -** Requirements: | |
| 3218 | -** [H13641] | |
| 3219 | 3193 | */ |
| 3220 | 3194 | SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); |
| 3221 | 3195 | |
| 3222 | 3196 | /* |
| 3223 | -** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300> | |
| 3197 | +** CAPI3REF: Reset All Bindings On A Prepared Statement | |
| 3224 | 3198 | ** |
| 3225 | -** Contrary to the intuition of many, [sqlite3_reset()] does not reset | |
| 3199 | +** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset | |
| 3226 | 3200 | ** 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. | |
| 3231 | 3202 | */ |
| 3232 | 3203 | SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); |
| 3233 | 3204 | |
| 3234 | 3205 | /* |
| 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]). | |
| 3243 | 3211 | */ |
| 3244 | 3212 | SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); |
| 3245 | 3213 | |
| 3246 | 3214 | /* |
| 3247 | -** CAPI3REF: Column Names In A Result Set {H13720} <S10700> | |
| 3215 | +** CAPI3REF: Column Names In A Result Set | |
| 3248 | 3216 | ** |
| 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() | |
| 3251 | 3219 | ** interface returns a pointer to a zero-terminated UTF-8 string |
| 3252 | 3220 | ** 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. | |
| 3256 | 3224 | ** |
| 3257 | -** The returned string pointer is valid until either the [prepared statement] | |
| 3225 | +** ^The returned string pointer is valid until either the [prepared statement] | |
| 3258 | 3226 | ** is destroyed by [sqlite3_finalize()] or until the next call to |
| 3259 | 3227 | ** sqlite3_column_name() or sqlite3_column_name16() on the same column. |
| 3260 | 3228 | ** |
| 3261 | -** If sqlite3_malloc() fails during the processing of either routine | |
| 3229 | +** ^If sqlite3_malloc() fails during the processing of either routine | |
| 3262 | 3230 | ** (for example during a conversion from UTF-8 to UTF-16) then a |
| 3263 | 3231 | ** NULL pointer is returned. |
| 3264 | 3232 | ** |
| 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 | |
| 3266 | 3234 | ** that column, if there is an AS clause. If there is no AS clause |
| 3267 | 3235 | ** then the name of the column is unspecified and may change from |
| 3268 | 3236 | ** one release of SQLite to the next. |
| 3269 | -** | |
| 3270 | -** Requirements: | |
| 3271 | -** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727] | |
| 3272 | 3237 | */ |
| 3273 | 3238 | SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); |
| 3274 | 3239 | SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); |
| 3275 | 3240 | |
| 3276 | 3241 | /* |
| 3277 | -** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700> | |
| 3242 | +** CAPI3REF: Source Of Data In A Query Result | |
| 3278 | 3243 | ** |
| 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 | |
| 3283 | 3249 | ** the database name, the _table_ routines return the table name, and |
| 3284 | 3250 | ** 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 | |
| 3286 | 3252 | ** using [sqlite3_finalize()] or until the same information is requested |
| 3287 | 3253 | ** again in a different encoding. |
| 3288 | 3254 | ** |
| 3289 | -** The names returned are the original un-aliased names of the | |
| 3255 | +** ^The names returned are the original un-aliased names of the | |
| 3290 | 3256 | ** database, table, and column. |
| 3291 | 3257 | ** |
| 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 | |
| 3294 | 3260 | ** the statement, where N is the second function argument. |
| 3261 | +** ^The left-most column is column 0 for these routines. | |
| 3295 | 3262 | ** |
| 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 | |
| 3297 | 3264 | ** 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 | +** | |
| 3309 | 3275 | ** If two or more threads call one or more of these routines against the same |
| 3310 | 3276 | ** prepared statement and column at the same time then the results are |
| 3311 | 3277 | ** undefined. |
| 3312 | 3278 | ** |
| 3313 | -** Requirements: | |
| 3314 | -** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748] | |
| 3315 | -** | |
| 3316 | 3279 | ** If two or more threads call one or more |
| 3317 | 3280 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 3318 | 3281 | ** for the same [prepared statement] and result column |
| 3319 | 3282 | ** at the same time then the results are undefined. |
| 3320 | 3283 | */ |
| @@ -3324,46 +3287,43 @@ | ||
| 3324 | 3287 | SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); |
| 3325 | 3288 | SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); |
| 3326 | 3289 | SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); |
| 3327 | 3290 | |
| 3328 | 3291 | /* |
| 3329 | -** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700> | |
| 3292 | +** CAPI3REF: Declared Datatype Of A Query Result | |
| 3330 | 3293 | ** |
| 3331 | -** The first parameter is a [prepared statement]. | |
| 3294 | +** ^(The first parameter is a [prepared statement]. | |
| 3332 | 3295 | ** If this statement is a [SELECT] statement and the Nth column of the |
| 3333 | 3296 | ** returned result set of that [SELECT] is a table column (not an |
| 3334 | 3297 | ** 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 | |
| 3336 | 3299 | ** 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. | |
| 3338 | 3301 | ** |
| 3339 | -** For example, given the database schema: | |
| 3302 | +** ^(For example, given the database schema: | |
| 3340 | 3303 | ** |
| 3341 | 3304 | ** CREATE TABLE t1(c1 VARIANT); |
| 3342 | 3305 | ** |
| 3343 | 3306 | ** and the following statement to be compiled: |
| 3344 | 3307 | ** |
| 3345 | 3308 | ** SELECT c1 + 1, c1 FROM t1; |
| 3346 | 3309 | ** |
| 3347 | 3310 | ** 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).)^ | |
| 3349 | 3312 | ** |
| 3350 | -** SQLite uses dynamic run-time typing. So just because a column | |
| 3313 | +** ^SQLite uses dynamic run-time typing. ^So just because a column | |
| 3351 | 3314 | ** is declared to contain a particular type does not mean that the |
| 3352 | 3315 | ** 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 | |
| 3354 | 3317 | ** is associated with individual values, not with the containers |
| 3355 | 3318 | ** used to hold those values. |
| 3356 | -** | |
| 3357 | -** Requirements: | |
| 3358 | -** [H13761] [H13762] [H13763] | |
| 3359 | 3319 | */ |
| 3360 | 3320 | SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); |
| 3361 | 3321 | SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); |
| 3362 | 3322 | |
| 3363 | 3323 | /* |
| 3364 | -** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000> | |
| 3324 | +** CAPI3REF: Evaluate An SQL Statement | |
| 3365 | 3325 | ** |
| 3366 | 3326 | ** After a [prepared statement] has been prepared using either |
| 3367 | 3327 | ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy |
| 3368 | 3328 | ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function |
| 3369 | 3329 | ** must be called one or more times to evaluate the statement. |
| @@ -3373,39 +3333,39 @@ | ||
| 3373 | 3333 | ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy |
| 3374 | 3334 | ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the |
| 3375 | 3335 | ** new "v2" interface is recommended for new applications but the legacy |
| 3376 | 3336 | ** interface will continue to be supported. |
| 3377 | 3337 | ** |
| 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], | |
| 3379 | 3339 | ** [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 | |
| 3381 | 3341 | ** [extended result codes] might be returned as well. |
| 3382 | 3342 | ** |
| 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] | |
| 3385 | 3345 | ** or occurs outside of an explicit transaction, then you can retry the |
| 3386 | 3346 | ** statement. If the statement is not a [COMMIT] and occurs within a |
| 3387 | 3347 | ** explicit transaction then you should rollback the transaction before |
| 3388 | 3348 | ** continuing. |
| 3389 | 3349 | ** |
| 3390 | -** [SQLITE_DONE] means that the statement has finished executing | |
| 3350 | +** ^[SQLITE_DONE] means that the statement has finished executing | |
| 3391 | 3351 | ** successfully. sqlite3_step() should not be called again on this virtual |
| 3392 | 3352 | ** machine without first calling [sqlite3_reset()] to reset the virtual |
| 3393 | 3353 | ** machine back to its initial state. |
| 3394 | 3354 | ** |
| 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] | |
| 3396 | 3356 | ** is returned each time a new row of data is ready for processing by the |
| 3397 | 3357 | ** caller. The values may be accessed using the [column access functions]. |
| 3398 | 3358 | ** sqlite3_step() is called again to retrieve the next row of data. |
| 3399 | 3359 | ** |
| 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 | |
| 3401 | 3361 | ** violation) has occurred. sqlite3_step() should not be called again on |
| 3402 | 3362 | ** 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, | |
| 3404 | 3364 | ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) |
| 3405 | 3365 | ** can be obtained by calling [sqlite3_reset()] on the |
| 3406 | -** [prepared statement]. In the "v2" interface, | |
| 3366 | +** [prepared statement]. ^In the "v2" interface, | |
| 3407 | 3367 | ** the more specific error code is returned directly by sqlite3_step(). |
| 3408 | 3368 | ** |
| 3409 | 3369 | ** [SQLITE_MISUSE] means that the this routine was called inappropriately. |
| 3410 | 3370 | ** Perhaps it was called on a [prepared statement] that has |
| 3411 | 3371 | ** already been [sqlite3_finalize | finalized] or on one that had |
| @@ -3422,39 +3382,34 @@ | ||
| 3422 | 3382 | ** with the "v2" interface. If you prepare all of your SQL statements |
| 3423 | 3383 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead |
| 3424 | 3384 | ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, |
| 3425 | 3385 | ** then the more specific [error codes] are returned directly |
| 3426 | 3386 | ** by sqlite3_step(). The use of the "v2" interface is recommended. |
| 3427 | -** | |
| 3428 | -** Requirements: | |
| 3429 | -** [H13202] [H15304] [H15306] [H15308] [H15310] | |
| 3430 | 3387 | */ |
| 3431 | 3388 | SQLITE_API int sqlite3_step(sqlite3_stmt*); |
| 3432 | 3389 | |
| 3433 | 3390 | /* |
| 3434 | -** CAPI3REF: Number of columns in a result set {H13770} <S10700> | |
| 3391 | +** CAPI3REF: Number of columns in a result set | |
| 3435 | 3392 | ** |
| 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. | |
| 3440 | 3395 | */ |
| 3441 | 3396 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 3442 | 3397 | |
| 3443 | 3398 | /* |
| 3444 | -** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120> | |
| 3399 | +** CAPI3REF: Fundamental Datatypes | |
| 3445 | 3400 | ** KEYWORDS: SQLITE_TEXT |
| 3446 | 3401 | ** |
| 3447 | -** {H10266} Every value in SQLite has one of five fundamental datatypes: | |
| 3402 | +** ^(Every value in SQLite has one of five fundamental datatypes: | |
| 3448 | 3403 | ** |
| 3449 | 3404 | ** <ul> |
| 3450 | 3405 | ** <li> 64-bit signed integer |
| 3451 | 3406 | ** <li> 64-bit IEEE floating point number |
| 3452 | 3407 | ** <li> string |
| 3453 | 3408 | ** <li> BLOB |
| 3454 | 3409 | ** <li> NULL |
| 3455 | -** </ul> {END} | |
| 3410 | +** </ul>)^ | |
| 3456 | 3411 | ** |
| 3457 | 3412 | ** These constants are codes for each of those types. |
| 3458 | 3413 | ** |
| 3459 | 3414 | ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 |
| 3460 | 3415 | ** for a completely different meaning. Software that links against both |
| @@ -3471,22 +3426,22 @@ | ||
| 3471 | 3426 | # define SQLITE_TEXT 3 |
| 3472 | 3427 | #endif |
| 3473 | 3428 | #define SQLITE3_TEXT 3 |
| 3474 | 3429 | |
| 3475 | 3430 | /* |
| 3476 | -** CAPI3REF: Result Values From A Query {H13800} <S10700> | |
| 3431 | +** CAPI3REF: Result Values From A Query | |
| 3477 | 3432 | ** KEYWORDS: {column access functions} |
| 3478 | 3433 | ** |
| 3479 | -** These routines form the "result set query" interface. | |
| 3434 | +** These routines form the "result set" interface. | |
| 3480 | 3435 | ** |
| 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 | |
| 3483 | 3438 | ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] |
| 3484 | 3439 | ** that was returned from [sqlite3_prepare_v2()] or one of its variants) |
| 3485 | 3440 | ** 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 | |
| 3488 | 3443 | ** [sqlite3_column_count()]. |
| 3489 | 3444 | ** |
| 3490 | 3445 | ** If the SQL statement does not currently point to a valid row, or if the |
| 3491 | 3446 | ** column index is out of range, the result is undefined. |
| 3492 | 3447 | ** These routines may only be called when the most recent call to |
| @@ -3497,52 +3452,52 @@ | ||
| 3497 | 3452 | ** something other than [SQLITE_ROW], the results are undefined. |
| 3498 | 3453 | ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] |
| 3499 | 3454 | ** are called from a different thread while any of these routines |
| 3500 | 3455 | ** are pending, then the results are undefined. |
| 3501 | 3456 | ** |
| 3502 | -** The sqlite3_column_type() routine returns the | |
| 3457 | +** ^The sqlite3_column_type() routine returns the | |
| 3503 | 3458 | ** [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], | |
| 3505 | 3460 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value |
| 3506 | 3461 | ** returned by sqlite3_column_type() is only meaningful if no type |
| 3507 | 3462 | ** conversions have occurred as described below. After a type conversion, |
| 3508 | 3463 | ** the value returned by sqlite3_column_type() is undefined. Future |
| 3509 | 3464 | ** versions of SQLite may change the behavior of sqlite3_column_type() |
| 3510 | 3465 | ** following a type conversion. |
| 3511 | 3466 | ** |
| 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() | |
| 3513 | 3468 | ** 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 | |
| 3515 | 3470 | ** 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 | |
| 3517 | 3472 | ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns |
| 3518 | 3473 | ** 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 | |
| 3521 | 3476 | ** bytes in the string, not the number of characters. |
| 3522 | 3477 | ** |
| 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 | |
| 3525 | 3480 | ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary |
| 3526 | 3481 | ** pointer, possibly even a NULL pointer. |
| 3527 | 3482 | ** |
| 3528 | -** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() | |
| 3483 | +** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() | |
| 3529 | 3484 | ** 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. | |
| 3531 | 3486 | ** |
| 3532 | -** The object returned by [sqlite3_column_value()] is an | |
| 3487 | +** ^The object returned by [sqlite3_column_value()] is an | |
| 3533 | 3488 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 3534 | 3489 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| 3535 | 3490 | ** If the [unprotected sqlite3_value] object returned by |
| 3536 | 3491 | ** [sqlite3_column_value()] is used in any other way, including calls |
| 3537 | 3492 | ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], |
| 3538 | 3493 | ** or [sqlite3_value_bytes()], then the behavior is undefined. |
| 3539 | 3494 | ** |
| 3540 | -** These routines attempt to convert the value where appropriate. For | |
| 3495 | +** These routines attempt to convert the value where appropriate. ^For | |
| 3541 | 3496 | ** example, if the internal representation is FLOAT and a text result |
| 3542 | 3497 | ** 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 | |
| 3544 | 3499 | ** that are applied: |
| 3545 | 3500 | ** |
| 3546 | 3501 | ** <blockquote> |
| 3547 | 3502 | ** <table border="1"> |
| 3548 | 3503 | ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion |
| @@ -3562,22 +3517,22 @@ | ||
| 3562 | 3517 | ** <tr><td> TEXT <td> BLOB <td> No change |
| 3563 | 3518 | ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi() |
| 3564 | 3519 | ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof() |
| 3565 | 3520 | ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed |
| 3566 | 3521 | ** </table> |
| 3567 | -** </blockquote> | |
| 3522 | +** </blockquote>)^ | |
| 3568 | 3523 | ** |
| 3569 | 3524 | ** The table above makes reference to standard C library functions atoi() |
| 3570 | 3525 | ** and atof(). SQLite does not really use these functions. It has its |
| 3571 | 3526 | ** own equivalent internal routines. The atoi() and atof() names are |
| 3572 | 3527 | ** used in the table for brevity and because they are familiar to most |
| 3573 | 3528 | ** C programmers. |
| 3574 | 3529 | ** |
| 3575 | -** Note that when type conversions occur, pointers returned by prior | |
| 3530 | +** ^Note that when type conversions occur, pointers returned by prior | |
| 3576 | 3531 | ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or |
| 3577 | 3532 | ** sqlite3_column_text16() may be invalidated. |
| 3578 | -** Type conversions and pointer invalidations might occur | |
| 3533 | +** ^(Type conversions and pointer invalidations might occur | |
| 3579 | 3534 | ** in the following cases: |
| 3580 | 3535 | ** |
| 3581 | 3536 | ** <ul> |
| 3582 | 3537 | ** <li> The initial content is a BLOB and sqlite3_column_text() or |
| 3583 | 3538 | ** sqlite3_column_text16() is called. A zero-terminator might |
| @@ -3586,51 +3541,47 @@ | ||
| 3586 | 3541 | ** sqlite3_column_text16() is called. The content must be converted |
| 3587 | 3542 | ** to UTF-16.</li> |
| 3588 | 3543 | ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or |
| 3589 | 3544 | ** sqlite3_column_text() is called. The content must be converted |
| 3590 | 3545 | ** to UTF-8.</li> |
| 3591 | -** </ul> | |
| 3546 | +** </ul>)^ | |
| 3592 | 3547 | ** |
| 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 | |
| 3594 | 3549 | ** not invalidate a prior pointer, though of course the content of the buffer |
| 3595 | 3550 | ** that the prior pointer points to will have been modified. Other kinds |
| 3596 | 3551 | ** of conversion are done in place when it is possible, but sometimes they |
| 3597 | 3552 | ** are not possible and in those cases prior pointers are invalidated. |
| 3598 | 3553 | ** |
| 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 | |
| 3600 | 3555 | ** in one of the following ways: |
| 3601 | 3556 | ** |
| 3602 | 3557 | ** <ul> |
| 3603 | 3558 | ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li> |
| 3604 | 3559 | ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li> |
| 3605 | 3560 | ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li> |
| 3606 | -** </ul> | |
| 3561 | +** </ul>)^ | |
| 3607 | 3562 | ** |
| 3608 | 3563 | ** In other words, you should call sqlite3_column_text(), |
| 3609 | 3564 | ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result |
| 3610 | 3565 | ** into the desired format, then invoke sqlite3_column_bytes() or |
| 3611 | 3566 | ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls |
| 3612 | 3567 | ** to sqlite3_column_text() or sqlite3_column_blob() with calls to |
| 3613 | 3568 | ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() |
| 3614 | 3569 | ** with calls to sqlite3_column_bytes(). |
| 3615 | 3570 | ** |
| 3616 | -** The pointers returned are valid until a type conversion occurs as | |
| 3571 | +** ^The pointers returned are valid until a type conversion occurs as | |
| 3617 | 3572 | ** 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 | |
| 3619 | 3574 | ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned |
| 3620 | 3575 | ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into |
| 3621 | 3576 | ** [sqlite3_free()]. |
| 3622 | 3577 | ** |
| 3623 | -** If a memory allocation error occurs during the evaluation of any | |
| 3578 | +** ^(If a memory allocation error occurs during the evaluation of any | |
| 3624 | 3579 | ** of these routines, a default value is returned. The default value |
| 3625 | 3580 | ** is either the integer 0, the floating point number 0.0, or a NULL |
| 3626 | 3581 | ** 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].)^ | |
| 3632 | 3583 | */ |
| 3633 | 3584 | SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); |
| 3634 | 3585 | SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); |
| 3635 | 3586 | SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); |
| 3636 | 3587 | SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); |
| @@ -3640,139 +3591,132 @@ | ||
| 3640 | 3591 | SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); |
| 3641 | 3592 | SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); |
| 3642 | 3593 | SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); |
| 3643 | 3594 | |
| 3644 | 3595 | /* |
| 3645 | -** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100> | |
| 3596 | +** CAPI3REF: Destroy A Prepared Statement Object | |
| 3646 | 3597 | ** |
| 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 | |
| 3650 | 3601 | ** [error code] or [extended error code] is returned. |
| 3651 | 3602 | ** |
| 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 | |
| 3654 | 3605 | ** completed execution when this routine is called, that is like |
| 3655 | 3606 | ** 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, | |
| 3657 | 3608 | ** depending on the circumstances, and the |
| 3658 | 3609 | ** [error code] returned will be [SQLITE_ABORT]. |
| 3659 | -** | |
| 3660 | -** Requirements: | |
| 3661 | -** [H11302] [H11304] | |
| 3662 | 3610 | */ |
| 3663 | 3611 | SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); |
| 3664 | 3612 | |
| 3665 | 3613 | /* |
| 3666 | -** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300> | |
| 3614 | +** CAPI3REF: Reset A Prepared Statement Object | |
| 3667 | 3615 | ** |
| 3668 | 3616 | ** The sqlite3_reset() function is called to reset a [prepared statement] |
| 3669 | 3617 | ** 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 | |
| 3671 | 3619 | ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. |
| 3672 | 3620 | ** Use [sqlite3_clear_bindings()] to reset the bindings. |
| 3673 | 3621 | ** |
| 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. | |
| 3688 | 3636 | */ |
| 3689 | 3637 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 3690 | 3638 | |
| 3691 | 3639 | /* |
| 3692 | -** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200> | |
| 3640 | +** CAPI3REF: Create Or Redefine SQL Functions | |
| 3693 | 3641 | ** KEYWORDS: {function creation routines} |
| 3694 | 3642 | ** KEYWORDS: {application-defined SQL function} |
| 3695 | 3643 | ** KEYWORDS: {application-defined SQL functions} |
| 3696 | 3644 | ** |
| 3697 | -** These two functions (collectively known as "function creation routines") | |
| 3645 | +** ^These two functions (collectively known as "function creation routines") | |
| 3698 | 3646 | ** are used to add SQL functions or aggregates or to redefine the behavior |
| 3699 | 3647 | ** of existing SQL functions or aggregates. The only difference between the |
| 3700 | 3648 | ** two is that the second parameter, the name of the (scalar) function or |
| 3701 | 3649 | ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16 |
| 3702 | 3650 | ** for sqlite3_create_function16(). |
| 3703 | 3651 | ** |
| 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. | |
| 3708 | 3656 | ** |
| 3709 | 3657 | ** 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 | |
| 3711 | 3659 | ** 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 | |
| 3713 | 3661 | ** will result in [SQLITE_ERROR] being returned. |
| 3714 | 3662 | ** |
| 3715 | -** The third parameter (nArg) | |
| 3663 | +** ^The third parameter (nArg) | |
| 3716 | 3664 | ** 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 | |
| 3718 | 3666 | ** aggregate may take any number of arguments between 0 and the limit |
| 3719 | 3667 | ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third |
| 3720 | 3668 | ** parameter is less than -1 or greater than 127 then the behavior is |
| 3721 | 3669 | ** undefined. |
| 3722 | 3670 | ** |
| 3723 | 3671 | ** The fourth parameter, eTextRep, specifies what |
| 3724 | 3672 | ** [SQLITE_UTF8 | text encoding] this SQL function prefers for |
| 3725 | 3673 | ** its parameters. Any SQL function implementation should be able to work |
| 3726 | 3674 | ** 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 | |
| 3728 | 3676 | ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple |
| 3729 | 3677 | ** 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 | |
| 3731 | 3679 | ** will pick the one that involves the least amount of data conversion. |
| 3732 | 3680 | ** If there is only a single implementation which does not care what text |
| 3733 | 3681 | ** encoding is used, then the fourth argument should be [SQLITE_ANY]. |
| 3734 | 3682 | ** |
| 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()].)^ | |
| 3737 | 3685 | ** |
| 3738 | 3686 | ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are |
| 3739 | 3687 | ** 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 | |
| 3744 | 3692 | ** SQL function or aggregate, pass NULL for all three function callbacks. |
| 3745 | 3693 | ** |
| 3746 | -** It is permitted to register multiple implementations of the same | |
| 3694 | +** ^It is permitted to register multiple implementations of the same | |
| 3747 | 3695 | ** 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 | |
| 3749 | 3697 | ** 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 | |
| 3751 | 3699 | ** 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 | |
| 3753 | 3701 | ** matches the database encoding is a better |
| 3754 | 3702 | ** 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 | |
| 3756 | 3704 | ** is a closer match than a function where the encoding difference is |
| 3757 | 3705 | ** between UTF8 and UTF16. |
| 3758 | 3706 | ** |
| 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 | |
| 3761 | 3709 | ** 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 | |
| 3763 | 3711 | ** prior application-defined functions that are an exact match for the |
| 3764 | 3712 | ** number of parameters and preferred encoding. |
| 3765 | 3713 | ** |
| 3766 | -** An application-defined function is permitted to call other | |
| 3714 | +** ^An application-defined function is permitted to call other | |
| 3767 | 3715 | ** SQLite interfaces. However, such calls must not |
| 3768 | 3716 | ** close the database connection nor finalize or reset the prepared |
| 3769 | 3717 | ** 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 | 3718 | */ |
| 3775 | 3719 | SQLITE_API int sqlite3_create_function( |
| 3776 | 3720 | sqlite3 *db, |
| 3777 | 3721 | const char *zFunctionName, |
| 3778 | 3722 | int nArg, |
| @@ -3792,11 +3736,11 @@ | ||
| 3792 | 3736 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), |
| 3793 | 3737 | void (*xFinal)(sqlite3_context*) |
| 3794 | 3738 | ); |
| 3795 | 3739 | |
| 3796 | 3740 | /* |
| 3797 | -** CAPI3REF: Text Encodings {H10267} <S50200> <H16100> | |
| 3741 | +** CAPI3REF: Text Encodings | |
| 3798 | 3742 | ** |
| 3799 | 3743 | ** These constant define integer codes that represent the various |
| 3800 | 3744 | ** text encodings supported by SQLite. |
| 3801 | 3745 | */ |
| 3802 | 3746 | #define SQLITE_UTF8 1 |
| @@ -3824,11 +3768,11 @@ | ||
| 3824 | 3768 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 3825 | 3769 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); |
| 3826 | 3770 | #endif |
| 3827 | 3771 | |
| 3828 | 3772 | /* |
| 3829 | -** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200> | |
| 3773 | +** CAPI3REF: Obtaining SQL Function Parameter Values | |
| 3830 | 3774 | ** |
| 3831 | 3775 | ** The C-language implementation of SQL functions and aggregates uses |
| 3832 | 3776 | ** this set of interface routines to access the parameter values on |
| 3833 | 3777 | ** the function or aggregate. |
| 3834 | 3778 | ** |
| @@ -3842,39 +3786,35 @@ | ||
| 3842 | 3786 | ** |
| 3843 | 3787 | ** These routines work only with [protected sqlite3_value] objects. |
| 3844 | 3788 | ** Any attempt to use these routines on an [unprotected sqlite3_value] |
| 3845 | 3789 | ** object results in undefined behavior. |
| 3846 | 3790 | ** |
| 3847 | -** These routines work just like the corresponding [column access functions] | |
| 3791 | +** ^These routines work just like the corresponding [column access functions] | |
| 3848 | 3792 | ** except that these routines take a single [protected sqlite3_value] object |
| 3849 | 3793 | ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. |
| 3850 | 3794 | ** |
| 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 | |
| 3853 | 3797 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 3854 | 3798 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 3855 | 3799 | ** |
| 3856 | -** The sqlite3_value_numeric_type() interface attempts to apply | |
| 3800 | +** ^(The sqlite3_value_numeric_type() interface attempts to apply | |
| 3857 | 3801 | ** numeric affinity to the value. This means that an attempt is |
| 3858 | 3802 | ** made to convert the value to an integer or floating point. If |
| 3859 | 3803 | ** such a conversion is possible without loss of information (in other |
| 3860 | 3804 | ** words, if the value is a string that looks like a number) |
| 3861 | 3805 | ** 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.)^ | |
| 3863 | 3807 | ** |
| 3864 | 3808 | ** Please pay particular attention to the fact that the pointer returned |
| 3865 | 3809 | ** from [sqlite3_value_blob()], [sqlite3_value_text()], or |
| 3866 | 3810 | ** [sqlite3_value_text16()] can be invalidated by a subsequent call to |
| 3867 | 3811 | ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], |
| 3868 | 3812 | ** or [sqlite3_value_text16()]. |
| 3869 | 3813 | ** |
| 3870 | 3814 | ** These routines must be called from the same thread as |
| 3871 | 3815 | ** 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 | 3816 | */ |
| 3877 | 3817 | SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); |
| 3878 | 3818 | SQLITE_API int sqlite3_value_bytes(sqlite3_value*); |
| 3879 | 3819 | SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); |
| 3880 | 3820 | SQLITE_API double sqlite3_value_double(sqlite3_value*); |
| @@ -3886,70 +3826,77 @@ | ||
| 3886 | 3826 | SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); |
| 3887 | 3827 | SQLITE_API int sqlite3_value_type(sqlite3_value*); |
| 3888 | 3828 | SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); |
| 3889 | 3829 | |
| 3890 | 3830 | /* |
| 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 | |
| 3907 | 3862 | ** [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. | |
| 3909 | 3865 | ** |
| 3910 | 3866 | ** This routine must be called from the same thread in which |
| 3911 | 3867 | ** the aggregate SQL function is running. |
| 3912 | -** | |
| 3913 | -** Requirements: | |
| 3914 | -** [H16211] [H16213] [H16215] [H16217] | |
| 3915 | 3868 | */ |
| 3916 | 3869 | SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); |
| 3917 | 3870 | |
| 3918 | 3871 | /* |
| 3919 | -** CAPI3REF: User Data For Functions {H16240} <S20200> | |
| 3872 | +** CAPI3REF: User Data For Functions | |
| 3920 | 3873 | ** |
| 3921 | -** The sqlite3_user_data() interface returns a copy of | |
| 3874 | +** ^The sqlite3_user_data() interface returns a copy of | |
| 3922 | 3875 | ** the pointer that was the pUserData parameter (the 5th parameter) |
| 3923 | 3876 | ** of the [sqlite3_create_function()] |
| 3924 | 3877 | ** and [sqlite3_create_function16()] routines that originally |
| 3925 | -** registered the application defined function. {END} | |
| 3878 | +** registered the application defined function. | |
| 3926 | 3879 | ** |
| 3927 | 3880 | ** This routine must be called from the same thread in which |
| 3928 | 3881 | ** the application-defined function is running. |
| 3929 | -** | |
| 3930 | -** Requirements: | |
| 3931 | -** [H16243] | |
| 3932 | 3882 | */ |
| 3933 | 3883 | SQLITE_API void *sqlite3_user_data(sqlite3_context*); |
| 3934 | 3884 | |
| 3935 | 3885 | /* |
| 3936 | -** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200> | |
| 3886 | +** CAPI3REF: Database Connection For Functions | |
| 3937 | 3887 | ** |
| 3938 | -** The sqlite3_context_db_handle() interface returns a copy of | |
| 3888 | +** ^The sqlite3_context_db_handle() interface returns a copy of | |
| 3939 | 3889 | ** the pointer to the [database connection] (the 1st parameter) |
| 3940 | 3890 | ** of the [sqlite3_create_function()] |
| 3941 | 3891 | ** and [sqlite3_create_function16()] routines that originally |
| 3942 | 3892 | ** registered the application defined function. |
| 3943 | -** | |
| 3944 | -** Requirements: | |
| 3945 | -** [H16253] | |
| 3946 | 3893 | */ |
| 3947 | 3894 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); |
| 3948 | 3895 | |
| 3949 | 3896 | /* |
| 3950 | -** CAPI3REF: Function Auxiliary Data {H16270} <S20200> | |
| 3897 | +** CAPI3REF: Function Auxiliary Data | |
| 3951 | 3898 | ** |
| 3952 | 3899 | ** The following two functions may be used by scalar SQL functions to |
| 3953 | 3900 | ** associate metadata with argument values. If the same value is passed to |
| 3954 | 3901 | ** multiple invocations of the same SQL function during query execution, under |
| 3955 | 3902 | ** some circumstances the associated metadata may be preserved. This may |
| @@ -3958,52 +3905,49 @@ | ||
| 3958 | 3905 | ** metadata associated with the SQL value passed as the regular expression |
| 3959 | 3906 | ** pattern. The compiled regular expression can be reused on multiple |
| 3960 | 3907 | ** invocations of the same function so that the original pattern string |
| 3961 | 3908 | ** does not need to be recompiled on each invocation. |
| 3962 | 3909 | ** |
| 3963 | -** The sqlite3_get_auxdata() interface returns a pointer to the metadata | |
| 3910 | +** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata | |
| 3964 | 3911 | ** 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 | |
| 3966 | 3913 | ** been set for the Nth argument of the function, or if the corresponding |
| 3967 | 3914 | ** function parameter has changed since the meta-data was set, |
| 3968 | 3915 | ** then sqlite3_get_auxdata() returns a NULL pointer. |
| 3969 | 3916 | ** |
| 3970 | -** The sqlite3_set_auxdata() interface saves the metadata | |
| 3917 | +** ^The sqlite3_set_auxdata() interface saves the metadata | |
| 3971 | 3918 | ** pointed to by its 3rd parameter as the metadata for the N-th |
| 3972 | 3919 | ** argument of the application-defined function. Subsequent |
| 3973 | 3920 | ** calls to sqlite3_get_auxdata() might return this data, if it has |
| 3974 | 3921 | ** 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 | |
| 3976 | 3923 | ** function given by the 4th parameter to sqlite3_set_auxdata() on |
| 3977 | 3924 | ** the metadata when the corresponding function parameter changes |
| 3978 | 3925 | ** or when the SQL statement completes, whichever comes first. |
| 3979 | 3926 | ** |
| 3980 | 3927 | ** 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 | |
| 3982 | 3929 | ** the destructor will be called before the metadata is dropped. |
| 3983 | 3930 | ** |
| 3984 | -** In practice, metadata is preserved between function calls for | |
| 3931 | +** ^(In practice, metadata is preserved between function calls for | |
| 3985 | 3932 | ** expressions that are constant at compile time. This includes literal |
| 3986 | -** values and SQL variables. | |
| 3933 | +** values and [parameters].)^ | |
| 3987 | 3934 | ** |
| 3988 | 3935 | ** These routines must be called from the same thread in which |
| 3989 | 3936 | ** the SQL function is running. |
| 3990 | -** | |
| 3991 | -** Requirements: | |
| 3992 | -** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279] | |
| 3993 | 3937 | */ |
| 3994 | 3938 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 3995 | 3939 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 3996 | 3940 | |
| 3997 | 3941 | |
| 3998 | 3942 | /* |
| 3999 | -** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100> | |
| 3943 | +** CAPI3REF: Constants Defining Special Destructor Behavior | |
| 4000 | 3944 | ** |
| 4001 | 3945 | ** 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 | |
| 4003 | 3947 | ** 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 | |
| 4005 | 3949 | ** SQLITE_TRANSIENT value means that the content will likely change in |
| 4006 | 3950 | ** the near future and that SQLite should make its own private copy of |
| 4007 | 3951 | ** the content before returning. |
| 4008 | 3952 | ** |
| 4009 | 3953 | ** The typedef is necessary to work around problems in certain |
| @@ -4012,11 +3956,11 @@ | ||
| 4012 | 3956 | typedef void (*sqlite3_destructor_type)(void*); |
| 4013 | 3957 | #define SQLITE_STATIC ((sqlite3_destructor_type)0) |
| 4014 | 3958 | #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) |
| 4015 | 3959 | |
| 4016 | 3960 | /* |
| 4017 | -** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200> | |
| 3961 | +** CAPI3REF: Setting The Result Of An SQL Function | |
| 4018 | 3962 | ** |
| 4019 | 3963 | ** These routines are used by the xFunc or xFinal callbacks that |
| 4020 | 3964 | ** implement SQL functions and aggregates. See |
| 4021 | 3965 | ** [sqlite3_create_function()] and [sqlite3_create_function16()] |
| 4022 | 3966 | ** for additional information. |
| @@ -4023,107 +3967,102 @@ | ||
| 4023 | 3967 | ** |
| 4024 | 3968 | ** These functions work very much like the [parameter binding] family of |
| 4025 | 3969 | ** functions used to bind values to host parameters in prepared statements. |
| 4026 | 3970 | ** Refer to the [SQL parameter] documentation for additional information. |
| 4027 | 3971 | ** |
| 4028 | -** The sqlite3_result_blob() interface sets the result from | |
| 3972 | +** ^The sqlite3_result_blob() interface sets the result from | |
| 4029 | 3973 | ** an application-defined function to be the BLOB whose content is pointed |
| 4030 | 3974 | ** to by the second parameter and which is N bytes long where N is the |
| 4031 | 3975 | ** third parameter. |
| 4032 | 3976 | ** |
| 4033 | -** The sqlite3_result_zeroblob() interfaces set the result of | |
| 3977 | +** ^The sqlite3_result_zeroblob() interfaces set the result of | |
| 4034 | 3978 | ** the application-defined function to be a BLOB containing all zero |
| 4035 | 3979 | ** bytes and N bytes in size, where N is the value of the 2nd parameter. |
| 4036 | 3980 | ** |
| 4037 | -** The sqlite3_result_double() interface sets the result from | |
| 3981 | +** ^The sqlite3_result_double() interface sets the result from | |
| 4038 | 3982 | ** an application-defined function to be a floating point value specified |
| 4039 | 3983 | ** by its 2nd argument. |
| 4040 | 3984 | ** |
| 4041 | -** The sqlite3_result_error() and sqlite3_result_error16() functions | |
| 3985 | +** ^The sqlite3_result_error() and sqlite3_result_error16() functions | |
| 4042 | 3986 | ** 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 | |
| 4044 | 3988 | ** 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 | |
| 4047 | 3991 | ** 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() | |
| 4049 | 3993 | ** or sqlite3_result_error16() is negative then SQLite takes as the error |
| 4050 | 3994 | ** 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 | |
| 4052 | 3996 | ** sqlite3_result_error16() is non-negative then SQLite takes that many |
| 4053 | 3997 | ** 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() | |
| 4055 | 3999 | ** routines make a private copy of the error message text before |
| 4056 | 4000 | ** they return. Hence, the calling function can deallocate or |
| 4057 | 4001 | ** 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() | |
| 4061 | 4005 | ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. |
| 4062 | 4006 | ** |
| 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. | |
| 4065 | 4009 | ** |
| 4066 | -** The sqlite3_result_nomem() interface causes SQLite to throw an error | |
| 4010 | +** ^The sqlite3_result_nomem() interface causes SQLite to throw an error | |
| 4067 | 4011 | ** indicating that a memory allocation failed. |
| 4068 | 4012 | ** |
| 4069 | -** The sqlite3_result_int() interface sets the return value | |
| 4013 | +** ^The sqlite3_result_int() interface sets the return value | |
| 4070 | 4014 | ** of the application-defined function to be the 32-bit signed integer |
| 4071 | 4015 | ** 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 | |
| 4073 | 4017 | ** of the application-defined function to be the 64-bit signed integer |
| 4074 | 4018 | ** value given in the 2nd argument. |
| 4075 | 4019 | ** |
| 4076 | -** The sqlite3_result_null() interface sets the return value | |
| 4020 | +** ^The sqlite3_result_null() interface sets the return value | |
| 4077 | 4021 | ** of the application-defined function to be NULL. |
| 4078 | 4022 | ** |
| 4079 | -** The sqlite3_result_text(), sqlite3_result_text16(), | |
| 4023 | +** ^The sqlite3_result_text(), sqlite3_result_text16(), | |
| 4080 | 4024 | ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces |
| 4081 | 4025 | ** set the return value of the application-defined function to be |
| 4082 | 4026 | ** a text string which is represented as UTF-8, UTF-16 native byte order, |
| 4083 | 4027 | ** 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 | |
| 4085 | 4029 | ** 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 | |
| 4087 | 4031 | ** is negative, then SQLite takes result text from the 2nd parameter |
| 4088 | 4032 | ** 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 | |
| 4090 | 4034 | ** is non-negative, then as many bytes (not characters) of the text |
| 4091 | 4035 | ** pointed to by the 2nd parameter are taken as the application-defined |
| 4092 | 4036 | ** function result. |
| 4093 | -** If the 4th parameter to the sqlite3_result_text* interfaces | |
| 4037 | +** ^If the 4th parameter to the sqlite3_result_text* interfaces | |
| 4094 | 4038 | ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that |
| 4095 | 4039 | ** function as the destructor on the text or BLOB result when it has |
| 4096 | 4040 | ** 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 | |
| 4098 | 4042 | ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite |
| 4099 | 4043 | ** assumes that the text or BLOB result is in constant space and does not |
| 4100 | 4044 | ** copy the content of the parameter nor call a destructor on the content |
| 4101 | 4045 | ** 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 | |
| 4103 | 4047 | ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT |
| 4104 | 4048 | ** then SQLite makes a copy of the result into space obtained from |
| 4105 | 4049 | ** from [sqlite3_malloc()] before it returns. |
| 4106 | 4050 | ** |
| 4107 | -** The sqlite3_result_value() interface sets the result of | |
| 4051 | +** ^The sqlite3_result_value() interface sets the result of | |
| 4108 | 4052 | ** 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 | |
| 4110 | 4054 | ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] |
| 4111 | 4055 | ** so that the [sqlite3_value] specified in the parameter may change or |
| 4112 | 4056 | ** 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 | |
| 4114 | 4058 | ** [unprotected sqlite3_value] object is required, so either |
| 4115 | 4059 | ** kind of [sqlite3_value] object can be used with this interface. |
| 4116 | 4060 | ** |
| 4117 | 4061 | ** If these routines are called from within the different thread |
| 4118 | 4062 | ** than the one containing the application-defined function that received |
| 4119 | 4063 | ** 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 | 4064 | */ |
| 4126 | 4065 | SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
| 4127 | 4066 | SQLITE_API void sqlite3_result_double(sqlite3_context*, double); |
| 4128 | 4067 | SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); |
| 4129 | 4068 | SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); |
| @@ -4139,58 +4078,54 @@ | ||
| 4139 | 4078 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 4140 | 4079 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 4141 | 4080 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 4142 | 4081 | |
| 4143 | 4082 | /* |
| 4144 | -** CAPI3REF: Define New Collating Sequences {H16600} <S20300> | |
| 4083 | +** CAPI3REF: Define New Collating Sequences | |
| 4145 | 4084 | ** |
| 4146 | 4085 | ** These functions are used to add new collation sequences to the |
| 4147 | 4086 | ** [database connection] specified as the first argument. |
| 4148 | 4087 | ** |
| 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 | |
| 4150 | 4089 | ** 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 | |
| 4152 | 4091 | ** the name is passed as the second function argument. |
| 4153 | 4092 | ** |
| 4154 | -** The third argument may be one of the constants [SQLITE_UTF8], | |
| 4093 | +** ^The third argument may be one of the constants [SQLITE_UTF8], | |
| 4155 | 4094 | ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied |
| 4156 | 4095 | ** 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 | |
| 4158 | 4097 | ** third argument might also be [SQLITE_UTF16] to indicate that the routine |
| 4159 | 4098 | ** expects pointers to be UTF-16 strings in the native byte order, or the |
| 4160 | 4099 | ** argument can be [SQLITE_UTF16_ALIGNED] if the |
| 4161 | 4100 | ** the routine expects pointers to 16-bit word aligned strings |
| 4162 | 4101 | ** of UTF-16 in the native byte order. |
| 4163 | 4102 | ** |
| 4164 | 4103 | ** 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 | |
| 4166 | 4105 | ** 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 | |
| 4168 | 4107 | ** as its first parameter a copy of the void* passed as the fourth argument |
| 4169 | 4108 | ** to sqlite3_create_collation() or sqlite3_create_collation16(). |
| 4170 | 4109 | ** |
| 4171 | -** The remaining arguments to the application-supplied routine are two strings, | |
| 4110 | +** ^The remaining arguments to the application-supplied routine are two strings, | |
| 4172 | 4111 | ** each represented by a (length, data) pair and encoded in the encoding |
| 4173 | 4112 | ** 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 | |
| 4175 | 4114 | ** return negative, zero or positive if the first string is less than, |
| 4176 | 4115 | ** equal to, or greater than the second string. i.e. (STRING1 - STRING2). |
| 4177 | 4116 | ** |
| 4178 | -** The sqlite3_create_collation_v2() works like sqlite3_create_collation() | |
| 4117 | +** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() | |
| 4179 | 4118 | ** 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 | |
| 4181 | 4120 | ** destroyed and is passed a copy of the fourth parameter void* pointer |
| 4182 | 4121 | ** 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 | |
| 4184 | 4123 | ** collation creation functions or when the [database connection] is closed |
| 4185 | 4124 | ** using [sqlite3_close()]. |
| 4186 | 4125 | ** |
| 4187 | 4126 | ** 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 | 4127 | */ |
| 4193 | 4128 | SQLITE_API int sqlite3_create_collation( |
| 4194 | 4129 | sqlite3*, |
| 4195 | 4130 | const char *zName, |
| 4196 | 4131 | int eTextRep, |
| @@ -4212,37 +4147,34 @@ | ||
| 4212 | 4147 | void*, |
| 4213 | 4148 | int(*xCompare)(void*,int,const void*,int,const void*) |
| 4214 | 4149 | ); |
| 4215 | 4150 | |
| 4216 | 4151 | /* |
| 4217 | -** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> | |
| 4152 | +** CAPI3REF: Collation Needed Callbacks | |
| 4218 | 4153 | ** |
| 4219 | -** To avoid having to register all collation sequences before a database | |
| 4154 | +** ^To avoid having to register all collation sequences before a database | |
| 4220 | 4155 | ** 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 | |
| 4222 | 4157 | ** sequence is required. |
| 4223 | 4158 | ** |
| 4224 | -** If the function is registered using the sqlite3_collation_needed() API, | |
| 4159 | +** ^If the function is registered using the sqlite3_collation_needed() API, | |
| 4225 | 4160 | ** 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, | |
| 4227 | 4162 | ** 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. | |
| 4229 | 4164 | ** |
| 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 | |
| 4231 | 4166 | ** of the second argument to sqlite3_collation_needed() or |
| 4232 | 4167 | ** sqlite3_collation_needed16(). The second argument is the database |
| 4233 | 4168 | ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], |
| 4234 | 4169 | ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation |
| 4235 | 4170 | ** sequence function required. The fourth parameter is the name of the |
| 4236 | -** required collation sequence. | |
| 4171 | +** required collation sequence.)^ | |
| 4237 | 4172 | ** |
| 4238 | 4173 | ** The callback function should register the desired collation using |
| 4239 | 4174 | ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or |
| 4240 | 4175 | ** [sqlite3_create_collation_v2()]. |
| 4241 | -** | |
| 4242 | -** Requirements: | |
| 4243 | -** [H16702] [H16704] [H16706] | |
| 4244 | 4176 | */ |
| 4245 | 4177 | SQLITE_API int sqlite3_collation_needed( |
| 4246 | 4178 | sqlite3*, |
| 4247 | 4179 | void*, |
| 4248 | 4180 | void(*)(void*,sqlite3*,int eTextRep,const char*) |
| @@ -4277,33 +4209,32 @@ | ||
| 4277 | 4209 | sqlite3 *db, /* Database to be rekeyed */ |
| 4278 | 4210 | const void *pKey, int nKey /* The new key */ |
| 4279 | 4211 | ); |
| 4280 | 4212 | |
| 4281 | 4213 | /* |
| 4282 | -** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> | |
| 4214 | +** CAPI3REF: Suspend Execution For A Short Time | |
| 4283 | 4215 | ** |
| 4284 | -** The sqlite3_sleep() function causes the current thread to suspend execution | |
| 4216 | +** ^The sqlite3_sleep() function causes the current thread to suspend execution | |
| 4285 | 4217 | ** for at least a number of milliseconds specified in its parameter. |
| 4286 | 4218 | ** |
| 4287 | -** If the operating system does not support sleep requests with | |
| 4219 | +** ^If the operating system does not support sleep requests with | |
| 4288 | 4220 | ** 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 | |
| 4290 | 4222 | ** requested from the operating system is returned. |
| 4291 | 4223 | ** |
| 4292 | -** SQLite implements this interface by calling the xSleep() | |
| 4224 | +** ^SQLite implements this interface by calling the xSleep() | |
| 4293 | 4225 | ** method of the default [sqlite3_vfs] object. |
| 4294 | -** | |
| 4295 | -** Requirements: [H10533] [H10536] | |
| 4296 | 4226 | */ |
| 4297 | 4227 | SQLITE_API int sqlite3_sleep(int); |
| 4298 | 4228 | |
| 4299 | 4229 | /* |
| 4300 | -** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> | |
| 4230 | +** CAPI3REF: Name Of The Folder Holding Temporary Files | |
| 4301 | 4231 | ** |
| 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 | |
| 4303 | 4233 | ** 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 | |
| 4305 | 4236 | ** is a NULL pointer, then SQLite performs a search for an appropriate |
| 4306 | 4237 | ** temporary file directory. |
| 4307 | 4238 | ** |
| 4308 | 4239 | ** It is not safe to read or modify this variable in more than one |
| 4309 | 4240 | ** thread at a time. It is not safe to read or modify this variable |
| @@ -4312,12 +4243,12 @@ | ||
| 4312 | 4243 | ** It is intended that this variable be set once |
| 4313 | 4244 | ** as part of process initialization and before any SQLite interface |
| 4314 | 4245 | ** routines have been called and that this variable remain unchanged |
| 4315 | 4246 | ** thereafter. |
| 4316 | 4247 | ** |
| 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, | |
| 4319 | 4250 | ** the [temp_store_directory pragma] always assumes that any string |
| 4320 | 4251 | ** that this variable points to is held in memory obtained from |
| 4321 | 4252 | ** [sqlite3_malloc] and the pragma may attempt to free that memory |
| 4322 | 4253 | ** using [sqlite3_free]. |
| 4323 | 4254 | ** Hence, if this variable is modified directly, either it should be |
| @@ -4325,18 +4256,18 @@ | ||
| 4325 | 4256 | ** or else the use of the [temp_store_directory pragma] should be avoided. |
| 4326 | 4257 | */ |
| 4327 | 4258 | SQLITE_API char *sqlite3_temp_directory; |
| 4328 | 4259 | |
| 4329 | 4260 | /* |
| 4330 | -** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> | |
| 4261 | +** CAPI3REF: Test For Auto-Commit Mode | |
| 4331 | 4262 | ** KEYWORDS: {autocommit mode} |
| 4332 | 4263 | ** |
| 4333 | -** The sqlite3_get_autocommit() interface returns non-zero or | |
| 4264 | +** ^The sqlite3_get_autocommit() interface returns non-zero or | |
| 4334 | 4265 | ** 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]. | |
| 4338 | 4269 | ** |
| 4339 | 4270 | ** If certain kinds of errors occur on a statement within a multi-statement |
| 4340 | 4271 | ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], |
| 4341 | 4272 | ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the |
| 4342 | 4273 | ** transaction might be rolled back automatically. The only way to |
| @@ -4344,124 +4275,116 @@ | ||
| 4344 | 4275 | ** an error is to use this function. |
| 4345 | 4276 | ** |
| 4346 | 4277 | ** If another thread changes the autocommit status of the database |
| 4347 | 4278 | ** connection while this routine is running, then the return value |
| 4348 | 4279 | ** is undefined. |
| 4349 | -** | |
| 4350 | -** Requirements: [H12931] [H12932] [H12933] [H12934] | |
| 4351 | 4280 | */ |
| 4352 | 4281 | SQLITE_API int sqlite3_get_autocommit(sqlite3*); |
| 4353 | 4282 | |
| 4354 | 4283 | /* |
| 4355 | -** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> | |
| 4284 | +** CAPI3REF: Find The Database Handle Of A Prepared Statement | |
| 4356 | 4285 | ** |
| 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 | |
| 4360 | 4290 | ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to |
| 4361 | 4291 | ** create the statement in the first place. |
| 4362 | -** | |
| 4363 | -** Requirements: [H13123] | |
| 4364 | 4292 | */ |
| 4365 | 4293 | SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
| 4366 | 4294 | |
| 4367 | 4295 | /* |
| 4368 | -** CAPI3REF: Find the next prepared statement {H13140} <S60600> | |
| 4296 | +** CAPI3REF: Find the next prepared statement | |
| 4369 | 4297 | ** |
| 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 | |
| 4372 | 4300 | ** 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 | |
| 4374 | 4302 | ** satisfies the conditions of this routine, it returns NULL. |
| 4375 | 4303 | ** |
| 4376 | 4304 | ** The [database connection] pointer D in a call to |
| 4377 | 4305 | ** [sqlite3_next_stmt(D,S)] must refer to an open database |
| 4378 | 4306 | ** connection and in particular must not be a NULL pointer. |
| 4379 | -** | |
| 4380 | -** Requirements: [H13143] [H13146] [H13149] [H13152] | |
| 4381 | 4307 | */ |
| 4382 | 4308 | SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
| 4383 | 4309 | |
| 4384 | 4310 | /* |
| 4385 | -** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> | |
| 4311 | +** CAPI3REF: Commit And Rollback Notification Callbacks | |
| 4386 | 4312 | ** |
| 4387 | -** The sqlite3_commit_hook() interface registers a callback | |
| 4313 | +** ^The sqlite3_commit_hook() interface registers a callback | |
| 4388 | 4314 | ** 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() | |
| 4390 | 4316 | ** 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 | |
| 4392 | 4318 | ** 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() | |
| 4394 | 4320 | ** 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, | |
| 4397 | 4323 | ** then the commit is converted into a rollback. |
| 4398 | 4324 | ** |
| 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. | |
| 4401 | 4329 | ** |
| 4402 | 4330 | ** The callback implementation must not do anything that will modify |
| 4403 | 4331 | ** the database connection that invoked the callback. Any actions |
| 4404 | 4332 | ** to modify the database connection must be deferred until after the |
| 4405 | 4333 | ** completion of the [sqlite3_step()] call that triggered the commit |
| 4406 | 4334 | ** or rollback hook in the first place. |
| 4407 | 4335 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 4408 | 4336 | ** database connections for the meaning of "modify" in this paragraph. |
| 4409 | 4337 | ** |
| 4410 | -** Registering a NULL function disables the callback. | |
| 4338 | +** ^Registering a NULL function disables the callback. | |
| 4411 | 4339 | ** |
| 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 | |
| 4414 | 4342 | ** 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 | |
| 4416 | 4344 | ** hook returning non-zero, just as it would be with any other rollback. |
| 4417 | 4345 | ** |
| 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 | |
| 4419 | 4347 | ** rolled back if an explicit "ROLLBACK" statement is executed, or |
| 4420 | 4348 | ** 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 | |
| 4422 | 4350 | ** 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 | |
| 4424 | 4352 | ** rolled back because a commit callback returned non-zero. |
| 4425 | -** <todo> Check on this </todo> | |
| 4426 | 4353 | ** |
| 4427 | 4354 | ** See also the [sqlite3_update_hook()] interface. |
| 4428 | -** | |
| 4429 | -** Requirements: | |
| 4430 | -** [H12951] [H12952] [H12953] [H12954] [H12955] | |
| 4431 | -** [H12961] [H12962] [H12963] [H12964] | |
| 4432 | 4355 | */ |
| 4433 | 4356 | SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); |
| 4434 | 4357 | SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
| 4435 | 4358 | |
| 4436 | 4359 | /* |
| 4437 | -** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> | |
| 4360 | +** CAPI3REF: Data Change Notification Callbacks | |
| 4438 | 4361 | ** |
| 4439 | -** The sqlite3_update_hook() interface registers a callback function | |
| 4362 | +** ^The sqlite3_update_hook() interface registers a callback function | |
| 4440 | 4363 | ** with the [database connection] identified by the first argument |
| 4441 | 4364 | ** 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 | |
| 4443 | 4366 | ** for the same database connection is overridden. |
| 4444 | 4367 | ** |
| 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 | |
| 4446 | 4369 | ** 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 | |
| 4448 | 4371 | ** 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], | |
| 4450 | 4373 | ** or [SQLITE_UPDATE], depending on the operation that caused the callback |
| 4451 | 4374 | ** 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 | |
| 4453 | 4376 | ** 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. | |
| 4456 | 4379 | ** |
| 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).)^ | |
| 4459 | 4382 | ** |
| 4460 | -** In the current implementation, the update hook | |
| 4383 | +** ^In the current implementation, the update hook | |
| 4461 | 4384 | ** 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 | |
| 4463 | 4386 | ** invoked when rows are deleted using the [truncate optimization]. |
| 4464 | 4387 | ** The exceptions defined in this paragraph might change in a future |
| 4465 | 4388 | ** release of SQLite. |
| 4466 | 4389 | ** |
| 4467 | 4390 | ** The update hook implementation must not do anything that will modify |
| @@ -4469,169 +4392,157 @@ | ||
| 4469 | 4392 | ** to modify the database connection must be deferred until after the |
| 4470 | 4393 | ** completion of the [sqlite3_step()] call that triggered the update hook. |
| 4471 | 4394 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 4472 | 4395 | ** database connections for the meaning of "modify" in this paragraph. |
| 4473 | 4396 | ** |
| 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. | |
| 4476 | 4401 | ** |
| 4477 | 4402 | ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] |
| 4478 | 4403 | ** interfaces. |
| 4479 | -** | |
| 4480 | -** Requirements: | |
| 4481 | -** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986] | |
| 4482 | 4404 | */ |
| 4483 | 4405 | SQLITE_API void *sqlite3_update_hook( |
| 4484 | 4406 | sqlite3*, |
| 4485 | 4407 | void(*)(void *,int ,char const *,char const *,sqlite3_int64), |
| 4486 | 4408 | void* |
| 4487 | 4409 | ); |
| 4488 | 4410 | |
| 4489 | 4411 | /* |
| 4490 | -** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> | |
| 4412 | +** CAPI3REF: Enable Or Disable Shared Pager Cache | |
| 4491 | 4413 | ** KEYWORDS: {shared cache} |
| 4492 | 4414 | ** |
| 4493 | -** This routine enables or disables the sharing of the database cache | |
| 4415 | +** ^(This routine enables or disables the sharing of the database cache | |
| 4494 | 4416 | ** and schema data structures between [database connection | connections] |
| 4495 | 4417 | ** 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.)^ | |
| 4497 | 4419 | ** |
| 4498 | -** Cache sharing is enabled and disabled for an entire process. | |
| 4420 | +** ^Cache sharing is enabled and disabled for an entire process. | |
| 4499 | 4421 | ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, |
| 4500 | 4422 | ** sharing was enabled or disabled for each thread separately. |
| 4501 | 4423 | ** |
| 4502 | -** The cache sharing mode set by this interface effects all subsequent | |
| 4424 | +** ^(The cache sharing mode set by this interface effects all subsequent | |
| 4503 | 4425 | ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
| 4504 | 4426 | ** 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 | |
| 4515 | 4433 | ** future releases of SQLite. Applications that care about shared |
| 4516 | 4434 | ** cache setting should set it explicitly. |
| 4517 | 4435 | ** |
| 4518 | 4436 | ** See Also: [SQLite Shared-Cache Mode] |
| 4519 | -** | |
| 4520 | -** Requirements: [H10331] [H10336] [H10337] [H10339] | |
| 4521 | 4437 | */ |
| 4522 | 4438 | SQLITE_API int sqlite3_enable_shared_cache(int); |
| 4523 | 4439 | |
| 4524 | 4440 | /* |
| 4525 | -** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> | |
| 4441 | +** CAPI3REF: Attempt To Free Heap Memory | |
| 4526 | 4442 | ** |
| 4527 | -** The sqlite3_release_memory() interface attempts to free N bytes | |
| 4443 | +** ^The sqlite3_release_memory() interface attempts to free N bytes | |
| 4528 | 4444 | ** 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 | |
| 4530 | 4446 | ** 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, | |
| 4532 | 4448 | ** which might be more or less than the amount requested. |
| 4533 | -** | |
| 4534 | -** Requirements: [H17341] [H17342] | |
| 4535 | 4449 | */ |
| 4536 | 4450 | SQLITE_API int sqlite3_release_memory(int); |
| 4537 | 4451 | |
| 4538 | 4452 | /* |
| 4539 | -** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> | |
| 4453 | +** CAPI3REF: Impose A Limit On Heap Size | |
| 4540 | 4454 | ** |
| 4541 | -** The sqlite3_soft_heap_limit() interface places a "soft" limit | |
| 4455 | +** ^The sqlite3_soft_heap_limit() interface places a "soft" limit | |
| 4542 | 4456 | ** 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 | |
| 4544 | 4458 | ** soft heap limit, [sqlite3_release_memory()] is invoked one or |
| 4545 | 4459 | ** more times to free up some space before the allocation is performed. |
| 4546 | 4460 | ** |
| 4547 | -** The limit is called "soft", because if [sqlite3_release_memory()] | |
| 4461 | +** ^The limit is called "soft" because if [sqlite3_release_memory()] | |
| 4548 | 4462 | ** cannot free sufficient memory to prevent the limit from being exceeded, |
| 4549 | 4463 | ** the memory is allocated anyway and the current operation proceeds. |
| 4550 | 4464 | ** |
| 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 | |
| 4552 | 4466 | ** [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. | |
| 4554 | 4468 | ** |
| 4555 | -** SQLite makes a best effort to honor the soft heap limit. | |
| 4469 | +** ^(SQLite makes a best effort to honor the soft heap limit. | |
| 4556 | 4470 | ** 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 | |
| 4558 | 4472 | ** called a "soft" limit. It is advisory only. |
| 4559 | 4473 | ** |
| 4560 | 4474 | ** Prior to SQLite version 3.5.0, this routine only constrained the memory |
| 4561 | 4475 | ** allocated by a single thread - the same thread in which this routine |
| 4562 | 4476 | ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is |
| 4563 | 4477 | ** applied to all threads. The value specified for the soft heap limit |
| 4564 | 4478 | ** is an upper bound on the total memory allocation for all threads. In |
| 4565 | 4479 | ** version 3.5.0 there is no mechanism for limiting the heap usage for |
| 4566 | 4480 | ** individual threads. |
| 4567 | -** | |
| 4568 | -** Requirements: | |
| 4569 | -** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358] | |
| 4570 | 4481 | */ |
| 4571 | 4482 | SQLITE_API void sqlite3_soft_heap_limit(int); |
| 4572 | 4483 | |
| 4573 | 4484 | /* |
| 4574 | -** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> | |
| 4485 | +** CAPI3REF: Extract Metadata About A Column Of A Table | |
| 4575 | 4486 | ** |
| 4576 | -** This routine returns metadata about a specific column of a specific | |
| 4487 | +** ^This routine returns metadata about a specific column of a specific | |
| 4577 | 4488 | ** database table accessible using the [database connection] handle |
| 4578 | 4489 | ** passed as the first function argument. |
| 4579 | 4490 | ** |
| 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 | |
| 4584 | 4495 | ** for the table using the same algorithm used by the database engine to |
| 4585 | 4496 | ** resolve unqualified table references. |
| 4586 | 4497 | ** |
| 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 | |
| 4588 | 4499 | ** name of the desired column, respectively. Neither of these parameters |
| 4589 | 4500 | ** may be NULL. |
| 4590 | 4501 | ** |
| 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 | |
| 4593 | 4504 | ** NULL, in which case the corresponding element of metadata is omitted. |
| 4594 | 4505 | ** |
| 4595 | -** <blockquote> | |
| 4506 | +** ^(<blockquote> | |
| 4596 | 4507 | ** <table border="1"> |
| 4597 | 4508 | ** <tr><th> Parameter <th> Output<br>Type <th> Description |
| 4598 | 4509 | ** |
| 4599 | 4510 | ** <tr><td> 5th <td> const char* <td> Data type |
| 4600 | 4511 | ** <tr><td> 6th <td> const char* <td> Name of default collation sequence |
| 4601 | 4512 | ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint |
| 4602 | 4513 | ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY |
| 4603 | 4514 | ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT] |
| 4604 | 4515 | ** </table> |
| 4605 | -** </blockquote> | |
| 4516 | +** </blockquote>)^ | |
| 4606 | 4517 | ** |
| 4607 | -** The memory pointed to by the character pointers returned for the | |
| 4518 | +** ^The memory pointed to by the character pointers returned for the | |
| 4608 | 4519 | ** declaration type and collation sequence is valid only until the next |
| 4609 | 4520 | ** call to any SQLite API function. |
| 4610 | 4521 | ** |
| 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. | |
| 4612 | 4523 | ** |
| 4613 | -** If the specified column is "rowid", "oid" or "_rowid_" and an | |
| 4524 | +** ^If the specified column is "rowid", "oid" or "_rowid_" and an | |
| 4614 | 4525 | ** [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 | |
| 4616 | 4527 | ** explicitly declared [INTEGER PRIMARY KEY] column, then the output |
| 4617 | 4528 | ** parameters are set as follows: |
| 4618 | 4529 | ** |
| 4619 | 4530 | ** <pre> |
| 4620 | 4531 | ** data type: "INTEGER" |
| 4621 | 4532 | ** collation sequence: "BINARY" |
| 4622 | 4533 | ** not null: 0 |
| 4623 | 4534 | ** primary key: 1 |
| 4624 | 4535 | ** auto increment: 0 |
| 4625 | -** </pre> | |
| 4536 | +** </pre>)^ | |
| 4626 | 4537 | ** |
| 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 | |
| 4628 | 4539 | ** error occurs during this process, or if the requested table or column |
| 4629 | 4540 | ** 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()).)^ | |
| 4631 | 4542 | ** |
| 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 | |
| 4633 | 4544 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. |
| 4634 | 4545 | */ |
| 4635 | 4546 | SQLITE_API int sqlite3_table_column_metadata( |
| 4636 | 4547 | sqlite3 *db, /* Connection handle */ |
| 4637 | 4548 | const char *zDbName, /* Database name or NULL */ |
| @@ -4643,34 +4554,31 @@ | ||
| 4643 | 4554 | int *pPrimaryKey, /* OUTPUT: True if column part of PK */ |
| 4644 | 4555 | int *pAutoinc /* OUTPUT: True if column is auto-increment */ |
| 4645 | 4556 | ); |
| 4646 | 4557 | |
| 4647 | 4558 | /* |
| 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. | |
| 4672 | 4580 | ** |
| 4673 | 4581 | ** See also the [load_extension() SQL function]. |
| 4674 | 4582 | */ |
| 4675 | 4583 | SQLITE_API int sqlite3_load_extension( |
| 4676 | 4584 | sqlite3 *db, /* Load the extension into this database connection */ |
| @@ -4678,65 +4586,53 @@ | ||
| 4678 | 4586 | const char *zProc, /* Entry point. Derived from zFile if 0 */ |
| 4679 | 4587 | char **pzErrMsg /* Put error message here if not 0 */ |
| 4680 | 4588 | ); |
| 4681 | 4589 | |
| 4682 | 4590 | /* |
| 4683 | -** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> | |
| 4591 | +** CAPI3REF: Enable Or Disable Extension Loading | |
| 4684 | 4592 | ** |
| 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 | |
| 4686 | 4594 | ** unprepared to deal with extension loading, and as a means of disabling |
| 4687 | 4595 | ** extension loading while evaluating user-entered SQL, the following API |
| 4688 | 4596 | ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. |
| 4689 | 4597 | ** |
| 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. | |
| 4697 | 4602 | */ |
| 4698 | 4603 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| 4699 | 4604 | |
| 4700 | 4605 | /* |
| 4701 | -** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> | |
| 4606 | +** CAPI3REF: Automatically Load An Extensions | |
| 4702 | 4607 | ** |
| 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 | |
| 4704 | 4609 | ** 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. | |
| 4724 | 4623 | */ |
| 4725 | 4624 | SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); |
| 4726 | 4625 | |
| 4727 | 4626 | /* |
| 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. | |
| 4738 | 4634 | */ |
| 4739 | 4635 | SQLITE_API void sqlite3_reset_auto_extension(void); |
| 4740 | 4636 | |
| 4741 | 4637 | /* |
| 4742 | 4638 | ****** EXPERIMENTAL - subject to change without notice ************** |
| @@ -4756,22 +4652,22 @@ | ||
| 4756 | 4652 | typedef struct sqlite3_index_info sqlite3_index_info; |
| 4757 | 4653 | typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; |
| 4758 | 4654 | typedef struct sqlite3_module sqlite3_module; |
| 4759 | 4655 | |
| 4760 | 4656 | /* |
| 4761 | -** CAPI3REF: Virtual Table Object {H18000} <S20400> | |
| 4657 | +** CAPI3REF: Virtual Table Object | |
| 4762 | 4658 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 4763 | 4659 | ** EXPERIMENTAL |
| 4764 | 4660 | ** |
| 4765 | 4661 | ** This structure, sometimes called a a "virtual table module", |
| 4766 | 4662 | ** defines the implementation of a [virtual tables]. |
| 4767 | 4663 | ** This structure consists mostly of methods for the module. |
| 4768 | 4664 | ** |
| 4769 | -** A virtual table module is created by filling in a persistent | |
| 4665 | +** ^A virtual table module is created by filling in a persistent | |
| 4770 | 4666 | ** instance of this structure and passing a pointer to that instance |
| 4771 | 4667 | ** 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 | |
| 4773 | 4669 | ** module or until the [database connection] closes. The content |
| 4774 | 4670 | ** of this structure must not change while it is registered with |
| 4775 | 4671 | ** any database connection. |
| 4776 | 4672 | */ |
| 4777 | 4673 | struct sqlite3_module { |
| @@ -4803,56 +4699,56 @@ | ||
| 4803 | 4699 | void **ppArg); |
| 4804 | 4700 | int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); |
| 4805 | 4701 | }; |
| 4806 | 4702 | |
| 4807 | 4703 | /* |
| 4808 | -** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> | |
| 4704 | +** CAPI3REF: Virtual Table Indexing Information | |
| 4809 | 4705 | ** KEYWORDS: sqlite3_index_info |
| 4810 | 4706 | ** EXPERIMENTAL |
| 4811 | 4707 | ** |
| 4812 | 4708 | ** The sqlite3_index_info structure and its substructures is used to |
| 4813 | 4709 | ** pass information into and receive the reply from the [xBestIndex] |
| 4814 | 4710 | ** method of a [virtual table module]. The fields under **Inputs** are the |
| 4815 | 4711 | ** inputs to xBestIndex and are read-only. xBestIndex inserts its |
| 4816 | 4712 | ** results into the **Outputs** fields. |
| 4817 | 4713 | ** |
| 4818 | -** The aConstraint[] array records WHERE clause constraints of the form: | |
| 4714 | +** ^(The aConstraint[] array records WHERE clause constraints of the form: | |
| 4819 | 4715 | ** |
| 4820 | 4716 | ** <pre>column OP expr</pre> |
| 4821 | 4717 | ** |
| 4822 | -** where OP is =, <, <=, >, or >=. 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 =, <, <=, >, or >=.)^ ^(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 | |
| 4825 | 4721 | ** 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.)^ | |
| 4827 | 4723 | ** |
| 4828 | -** The optimizer automatically inverts terms of the form "expr OP column" | |
| 4724 | +** ^The optimizer automatically inverts terms of the form "expr OP column" | |
| 4829 | 4725 | ** and makes other simplifications to the WHERE clause in an attempt to |
| 4830 | 4726 | ** 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. | |
| 4833 | 4729 | ** |
| 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. | |
| 4836 | 4732 | ** |
| 4837 | 4733 | ** 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 | |
| 4839 | 4735 | ** 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 | |
| 4841 | 4737 | ** 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.)^ | |
| 4843 | 4739 | ** |
| 4844 | -** The idxNum and idxPtr values are recorded and passed into the | |
| 4740 | +** ^The idxNum and idxPtr values are recorded and passed into the | |
| 4845 | 4741 | ** [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 | |
| 4847 | 4743 | ** needToFreeIdxPtr is true. |
| 4848 | 4744 | ** |
| 4849 | -** The orderByConsumed means that output from [xFilter]/[xNext] will occur in | |
| 4745 | +** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in | |
| 4850 | 4746 | ** the correct order to satisfy the ORDER BY clause so that no separate |
| 4851 | 4747 | ** sorting step is required. |
| 4852 | 4748 | ** |
| 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 | |
| 4854 | 4750 | ** particular lookup. A full scan of a table with N entries should have |
| 4855 | 4751 | ** a cost of N. A binary search of a table of N entries should have a |
| 4856 | 4752 | ** cost of approximately log(N). |
| 4857 | 4753 | */ |
| 4858 | 4754 | struct sqlite3_index_info { |
| @@ -4886,70 +4782,63 @@ | ||
| 4886 | 4782 | #define SQLITE_INDEX_CONSTRAINT_LT 16 |
| 4887 | 4783 | #define SQLITE_INDEX_CONSTRAINT_GE 32 |
| 4888 | 4784 | #define SQLITE_INDEX_CONSTRAINT_MATCH 64 |
| 4889 | 4785 | |
| 4890 | 4786 | /* |
| 4891 | -** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> | |
| 4787 | +** CAPI3REF: Register A Virtual Table Implementation | |
| 4892 | 4788 | ** EXPERIMENTAL |
| 4893 | 4789 | ** |
| 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 | |
| 4897 | 4793 | ** preexisting [virtual table] for the module. |
| 4898 | 4794 | ** |
| 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 | |
| 4903 | 4799 | ** parameter is an arbitrary client data pointer that is passed through |
| 4904 | 4800 | ** into the [xCreate] and [xConnect] methods of the virtual table module |
| 4905 | 4801 | ** when a new virtual table is be being created or reinitialized. |
| 4906 | 4802 | ** |
| 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. | |
| 4909 | 4809 | */ |
| 4910 | 4810 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module( |
| 4911 | 4811 | sqlite3 *db, /* SQLite connection to register module with */ |
| 4912 | 4812 | const char *zName, /* Name of the module */ |
| 4913 | 4813 | const sqlite3_module *p, /* Methods for the module */ |
| 4914 | 4814 | void *pClientData /* Client data for xCreate/xConnect */ |
| 4915 | 4815 | ); |
| 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 | 4816 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2( |
| 4928 | 4817 | sqlite3 *db, /* SQLite connection to register module with */ |
| 4929 | 4818 | const char *zName, /* Name of the module */ |
| 4930 | 4819 | const sqlite3_module *p, /* Methods for the module */ |
| 4931 | 4820 | void *pClientData, /* Client data for xCreate/xConnect */ |
| 4932 | 4821 | void(*xDestroy)(void*) /* Module destructor function */ |
| 4933 | 4822 | ); |
| 4934 | 4823 | |
| 4935 | 4824 | /* |
| 4936 | -** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> | |
| 4825 | +** CAPI3REF: Virtual Table Instance Object | |
| 4937 | 4826 | ** KEYWORDS: sqlite3_vtab |
| 4938 | 4827 | ** EXPERIMENTAL |
| 4939 | 4828 | ** |
| 4940 | 4829 | ** 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 | |
| 4942 | 4831 | ** of the [virtual table]. Each subclass will |
| 4943 | 4832 | ** be tailored to the specific needs of the module implementation. |
| 4944 | 4833 | ** The purpose of this superclass is to define certain fields that are |
| 4945 | 4834 | ** common to all module implementations. |
| 4946 | 4835 | ** |
| 4947 | -** Virtual tables methods can set an error message by assigning a | |
| 4836 | +** ^Virtual tables methods can set an error message by assigning a | |
| 4948 | 4837 | ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should |
| 4949 | 4838 | ** 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 | |
| 4951 | 4840 | ** is delivered up to the client application, the string will be automatically |
| 4952 | 4841 | ** freed by sqlite3_free() and the zErrMsg field will be zeroed. |
| 4953 | 4842 | */ |
| 4954 | 4843 | struct sqlite3_vtab { |
| 4955 | 4844 | const sqlite3_module *pModule; /* The module for this virtual table */ |
| @@ -4957,20 +4846,20 @@ | ||
| 4957 | 4846 | char *zErrMsg; /* Error message from sqlite3_mprintf() */ |
| 4958 | 4847 | /* Virtual table implementations will typically add additional fields */ |
| 4959 | 4848 | }; |
| 4960 | 4849 | |
| 4961 | 4850 | /* |
| 4962 | -** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> | |
| 4851 | +** CAPI3REF: Virtual Table Cursor Object | |
| 4963 | 4852 | ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} |
| 4964 | 4853 | ** EXPERIMENTAL |
| 4965 | 4854 | ** |
| 4966 | 4855 | ** Every [virtual table module] implementation uses a subclass of the |
| 4967 | 4856 | ** following structure to describe cursors that point into the |
| 4968 | 4857 | ** [virtual table] and are used |
| 4969 | 4858 | ** to loop through the virtual table. Cursors are created using the |
| 4970 | 4859 | ** [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 | |
| 4972 | 4861 | ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods |
| 4973 | 4862 | ** of the module. Each module implementation will define |
| 4974 | 4863 | ** the content of a cursor structure to suit its own needs. |
| 4975 | 4864 | ** |
| 4976 | 4865 | ** This superclass exists in order to define fields of the cursor that |
| @@ -4980,32 +4869,32 @@ | ||
| 4980 | 4869 | sqlite3_vtab *pVtab; /* Virtual table of this cursor */ |
| 4981 | 4870 | /* Virtual table implementations will typically add additional fields */ |
| 4982 | 4871 | }; |
| 4983 | 4872 | |
| 4984 | 4873 | /* |
| 4985 | -** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> | |
| 4874 | +** CAPI3REF: Declare The Schema Of A Virtual Table | |
| 4986 | 4875 | ** EXPERIMENTAL |
| 4987 | 4876 | ** |
| 4988 | -** The [xCreate] and [xConnect] methods of a | |
| 4877 | +** ^The [xCreate] and [xConnect] methods of a | |
| 4989 | 4878 | ** [virtual table module] call this interface |
| 4990 | 4879 | ** to declare the format (the names and datatypes of the columns) of |
| 4991 | 4880 | ** the virtual tables they implement. |
| 4992 | 4881 | */ |
| 4993 | 4882 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL); |
| 4994 | 4883 | |
| 4995 | 4884 | /* |
| 4996 | -** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> | |
| 4885 | +** CAPI3REF: Overload A Function For A Virtual Table | |
| 4997 | 4886 | ** EXPERIMENTAL |
| 4998 | 4887 | ** |
| 4999 | -** Virtual tables can provide alternative implementations of functions | |
| 4888 | +** ^(Virtual tables can provide alternative implementations of functions | |
| 5000 | 4889 | ** using the [xFindFunction] method of the [virtual table module]. |
| 5001 | 4890 | ** But global versions of those functions |
| 5002 | -** must exist in order to be overloaded. | |
| 4891 | +** must exist in order to be overloaded.)^ | |
| 5003 | 4892 | ** |
| 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 | |
| 5005 | 4894 | ** 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 | |
| 5007 | 4896 | ** of the new function always causes an exception to be thrown. So |
| 5008 | 4897 | ** the new function is not good for anything by itself. Its only |
| 5009 | 4898 | ** purpose is to be a placeholder function that can be overloaded |
| 5010 | 4899 | ** by a [virtual table]. |
| 5011 | 4900 | */ |
| @@ -5022,81 +4911,78 @@ | ||
| 5022 | 4911 | ** |
| 5023 | 4912 | ****** EXPERIMENTAL - subject to change without notice ************** |
| 5024 | 4913 | */ |
| 5025 | 4914 | |
| 5026 | 4915 | /* |
| 5027 | -** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> | |
| 4916 | +** CAPI3REF: A Handle To An Open BLOB | |
| 5028 | 4917 | ** KEYWORDS: {BLOB handle} {BLOB handles} |
| 5029 | 4918 | ** |
| 5030 | 4919 | ** An instance of this object represents an open BLOB on which |
| 5031 | 4920 | ** [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()] | |
| 5033 | 4922 | ** 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 | |
| 5035 | 4924 | ** 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. | |
| 5037 | 4926 | */ |
| 5038 | 4927 | typedef struct sqlite3_blob sqlite3_blob; |
| 5039 | 4928 | |
| 5040 | 4929 | /* |
| 5041 | -** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> | |
| 4930 | +** CAPI3REF: Open A BLOB For Incremental I/O | |
| 5042 | 4931 | ** |
| 5043 | -** This interfaces opens a [BLOB handle | handle] to the BLOB located | |
| 4932 | +** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located | |
| 5044 | 4933 | ** in row iRow, column zColumn, table zTable in database zDb; |
| 5045 | 4934 | ** in other words, the same BLOB that would be selected by: |
| 5046 | 4935 | ** |
| 5047 | 4936 | ** <pre> |
| 5048 | 4937 | ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; |
| 5049 | -** </pre> {END} | |
| 4938 | +** </pre>)^ | |
| 5050 | 4939 | ** |
| 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 | |
| 5054 | 4943 | ** key for writing. ^If [foreign key constraints] are enabled, it is |
| 5055 | 4944 | ** not possible to open a column that is part of a [child key] for writing. |
| 5056 | 4945 | ** |
| 5057 | -** Note that the database name is not the filename that contains | |
| 4946 | +** ^Note that the database name is not the filename that contains | |
| 5058 | 4947 | ** 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". | |
| 5062 | 4951 | ** |
| 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 | |
| 5064 | 4953 | ** 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 | |
| 5067 | 4956 | ** 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 | |
| 5069 | 4958 | ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob |
| 5070 | 4959 | ** regardless of the success or failure of this routine. |
| 5071 | 4960 | ** |
| 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 | |
| 5073 | 4962 | ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects |
| 5074 | 4963 | ** then the BLOB handle is marked as "expired". |
| 5075 | 4964 | ** 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 | |
| 5078 | 4967 | ** 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.)^ | |
| 5082 | 4971 | ** |
| 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 | |
| 5085 | 4974 | ** interface. Use the [UPDATE] SQL command to change the size of a |
| 5086 | 4975 | ** blob. |
| 5087 | 4976 | ** |
| 5088 | -** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces | |
| 4977 | +** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces | |
| 5089 | 4978 | ** and the built-in [zeroblob] SQL function can be used, if desired, |
| 5090 | 4979 | ** to create an empty, zero-filled blob in which to read or write using |
| 5091 | 4980 | ** this interface. |
| 5092 | 4981 | ** |
| 5093 | 4982 | ** To avoid a resource leak, every open [BLOB handle] should eventually |
| 5094 | 4983 | ** be released by a call to [sqlite3_blob_close()]. |
| 5095 | -** | |
| 5096 | -** Requirements: | |
| 5097 | -** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824] | |
| 5098 | 4984 | */ |
| 5099 | 4985 | SQLITE_API int sqlite3_blob_open( |
| 5100 | 4986 | sqlite3*, |
| 5101 | 4987 | const char *zDb, |
| 5102 | 4988 | const char *zTable, |
| @@ -5105,201 +4991,185 @@ | ||
| 5105 | 4991 | int flags, |
| 5106 | 4992 | sqlite3_blob **ppBlob |
| 5107 | 4993 | ); |
| 5108 | 4994 | |
| 5109 | 4995 | /* |
| 5110 | -** CAPI3REF: Close A BLOB Handle {H17830} <S30230> | |
| 4996 | +** CAPI3REF: Close A BLOB Handle | |
| 5111 | 4997 | ** |
| 5112 | -** Closes an open [BLOB handle]. | |
| 4998 | +** ^Closes an open [BLOB handle]. | |
| 5113 | 4999 | ** |
| 5114 | -** Closing a BLOB shall cause the current transaction to commit | |
| 5000 | +** ^Closing a BLOB shall cause the current transaction to commit | |
| 5115 | 5001 | ** if there are no other BLOBs, no pending prepared statements, and the |
| 5116 | 5002 | ** 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 | |
| 5118 | 5004 | ** until the close operation if they will fit. |
| 5119 | 5005 | ** |
| 5120 | -** Closing the BLOB often forces the changes | |
| 5006 | +** ^(Closing the BLOB often forces the changes | |
| 5121 | 5007 | ** out to disk and so if any I/O errors occur, they will likely occur |
| 5122 | 5008 | ** 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. | |
| 5133 | 5016 | */ |
| 5134 | 5017 | SQLITE_API int sqlite3_blob_close(sqlite3_blob *); |
| 5135 | 5018 | |
| 5136 | 5019 | /* |
| 5137 | -** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> | |
| 5020 | +** CAPI3REF: Return The Size Of An Open BLOB | |
| 5138 | 5021 | ** |
| 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 | |
| 5141 | 5024 | ** incremental blob I/O routines can only read or overwriting existing |
| 5142 | 5025 | ** blob content; they cannot change the size of a blob. |
| 5143 | 5026 | ** |
| 5144 | 5027 | ** This routine only works on a [BLOB handle] which has been created |
| 5145 | 5028 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 5146 | 5029 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 5147 | 5030 | ** to this routine results in undefined and probably undesirable behavior. |
| 5148 | -** | |
| 5149 | -** Requirements: | |
| 5150 | -** [H17843] | |
| 5151 | 5031 | */ |
| 5152 | 5032 | SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); |
| 5153 | 5033 | |
| 5154 | 5034 | /* |
| 5155 | -** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> | |
| 5035 | +** CAPI3REF: Read Data From A BLOB Incrementally | |
| 5156 | 5036 | ** |
| 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 | |
| 5158 | 5038 | ** 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.)^ | |
| 5160 | 5040 | ** |
| 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 | |
| 5163 | 5043 | ** 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) | |
| 5165 | 5045 | ** can be determined using the [sqlite3_blob_bytes()] interface. |
| 5166 | 5046 | ** |
| 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 | |
| 5168 | 5048 | ** error code of [SQLITE_ABORT]. |
| 5169 | 5049 | ** |
| 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.)^ | |
| 5172 | 5052 | ** |
| 5173 | 5053 | ** This routine only works on a [BLOB handle] which has been created |
| 5174 | 5054 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 5175 | 5055 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 5176 | 5056 | ** to this routine results in undefined and probably undesirable behavior. |
| 5177 | 5057 | ** |
| 5178 | 5058 | ** See also: [sqlite3_blob_write()]. |
| 5179 | -** | |
| 5180 | -** Requirements: | |
| 5181 | -** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868] | |
| 5182 | 5059 | */ |
| 5183 | 5060 | SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); |
| 5184 | 5061 | |
| 5185 | 5062 | /* |
| 5186 | -** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> | |
| 5063 | +** CAPI3REF: Write Data Into A BLOB Incrementally | |
| 5187 | 5064 | ** |
| 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 | |
| 5190 | 5067 | ** into the open BLOB, starting at offset iOffset. |
| 5191 | 5068 | ** |
| 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 | |
| 5193 | 5070 | ** writing (the flags parameter to [sqlite3_blob_open()] was zero), |
| 5194 | 5071 | ** this function returns [SQLITE_READONLY]. |
| 5195 | 5072 | ** |
| 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 | |
| 5197 | 5074 | ** 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 | |
| 5200 | 5077 | ** less than zero [SQLITE_ERROR] is returned and no data is written. |
| 5201 | 5078 | ** The size of the BLOB (and hence the maximum value of N+iOffset) |
| 5202 | 5079 | ** can be determined using the [sqlite3_blob_bytes()] interface. |
| 5203 | 5080 | ** |
| 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 | |
| 5206 | 5083 | ** before the [BLOB handle] expired are not rolled back by the |
| 5207 | 5084 | ** expiration of the handle, though of course those changes might |
| 5208 | 5085 | ** have been overwritten by the statement that expired the BLOB handle |
| 5209 | 5086 | ** or by other independent statements. |
| 5210 | 5087 | ** |
| 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.)^ | |
| 5213 | 5090 | ** |
| 5214 | 5091 | ** This routine only works on a [BLOB handle] which has been created |
| 5215 | 5092 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 5216 | 5093 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 5217 | 5094 | ** to this routine results in undefined and probably undesirable behavior. |
| 5218 | 5095 | ** |
| 5219 | 5096 | ** See also: [sqlite3_blob_read()]. |
| 5220 | -** | |
| 5221 | -** Requirements: | |
| 5222 | -** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885] | |
| 5223 | -** [H17888] | |
| 5224 | 5097 | */ |
| 5225 | 5098 | SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); |
| 5226 | 5099 | |
| 5227 | 5100 | /* |
| 5228 | -** CAPI3REF: Virtual File System Objects {H11200} <S20100> | |
| 5101 | +** CAPI3REF: Virtual File System Objects | |
| 5229 | 5102 | ** |
| 5230 | 5103 | ** A virtual filesystem (VFS) is an [sqlite3_vfs] object |
| 5231 | 5104 | ** that SQLite uses to interact |
| 5232 | 5105 | ** with the underlying operating system. Most SQLite builds come with a |
| 5233 | 5106 | ** single default VFS that is appropriate for the host computer. |
| 5234 | 5107 | ** New VFSes can be registered and existing VFSes can be unregistered. |
| 5235 | 5108 | ** The following interfaces are provided. |
| 5236 | 5109 | ** |
| 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. | |
| 5242 | 5115 | ** |
| 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 | |
| 5247 | 5120 | ** with the makeDflt flag set. If two different VFSes with the |
| 5248 | 5121 | ** same name are registered, the behavior is undefined. If a |
| 5249 | 5122 | ** VFS is registered with a name that is NULL or an empty string, |
| 5250 | 5123 | ** then the behavior is undefined. |
| 5251 | 5124 | ** |
| 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.)^ | |
| 5258 | 5128 | */ |
| 5259 | 5129 | SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); |
| 5260 | 5130 | SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); |
| 5261 | 5131 | SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
| 5262 | 5132 | |
| 5263 | 5133 | /* |
| 5264 | -** CAPI3REF: Mutexes {H17000} <S20000> | |
| 5134 | +** CAPI3REF: Mutexes | |
| 5265 | 5135 | ** |
| 5266 | 5136 | ** The SQLite core uses these routines for thread |
| 5267 | 5137 | ** synchronization. Though they are intended for internal |
| 5268 | 5138 | ** use by SQLite, code that links against SQLite is |
| 5269 | 5139 | ** permitted to use any of these routines. |
| 5270 | 5140 | ** |
| 5271 | 5141 | ** The SQLite source code contains multiple implementations |
| 5272 | 5142 | ** 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 | |
| 5274 | 5144 | ** implementations are available in the SQLite core: |
| 5275 | 5145 | ** |
| 5276 | 5146 | ** <ul> |
| 5277 | 5147 | ** <li> SQLITE_MUTEX_OS2 |
| 5278 | 5148 | ** <li> SQLITE_MUTEX_PTHREAD |
| 5279 | 5149 | ** <li> SQLITE_MUTEX_W32 |
| 5280 | 5150 | ** <li> SQLITE_MUTEX_NOOP |
| 5281 | -** </ul> | |
| 5151 | +** </ul>)^ | |
| 5282 | 5152 | ** |
| 5283 | -** The SQLITE_MUTEX_NOOP implementation is a set of routines | |
| 5153 | +** ^The SQLITE_MUTEX_NOOP implementation is a set of routines | |
| 5284 | 5154 | ** 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, | |
| 5286 | 5156 | ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
| 5287 | 5157 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 5288 | 5158 | ** |
| 5289 | -** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor | |
| 5159 | +** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor | |
| 5290 | 5160 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 5291 | 5161 | ** implementation is included with the library. In this case the |
| 5292 | 5162 | ** application must supply a custom mutex implementation using the |
| 5293 | 5163 | ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function |
| 5294 | 5164 | ** before calling sqlite3_initialize() or any other public sqlite3_ |
| 5295 | -** function that calls sqlite3_initialize(). | |
| 5165 | +** function that calls sqlite3_initialize().)^ | |
| 5296 | 5166 | ** |
| 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 | |
| 5301 | 5171 | ** to sqlite3_mutex_alloc() is one of these integer constants: |
| 5302 | 5172 | ** |
| 5303 | 5173 | ** <ul> |
| 5304 | 5174 | ** <li> SQLITE_MUTEX_FAST |
| 5305 | 5175 | ** <li> SQLITE_MUTEX_RECURSIVE |
| @@ -5307,68 +5177,70 @@ | ||
| 5307 | 5177 | ** <li> SQLITE_MUTEX_STATIC_MEM |
| 5308 | 5178 | ** <li> SQLITE_MUTEX_STATIC_MEM2 |
| 5309 | 5179 | ** <li> SQLITE_MUTEX_STATIC_PRNG |
| 5310 | 5180 | ** <li> SQLITE_MUTEX_STATIC_LRU |
| 5311 | 5181 | ** <li> SQLITE_MUTEX_STATIC_LRU2 |
| 5312 | -** </ul> | |
| 5182 | +** </ul>)^ | |
| 5313 | 5183 | ** |
| 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. | |
| 5317 | 5188 | ** The mutex implementation does not need to make a distinction |
| 5318 | 5189 | ** 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 | |
| 5321 | 5192 | ** implementation is available on the host platform, the mutex subsystem |
| 5322 | 5193 | ** might return such a mutex in response to SQLITE_MUTEX_FAST. |
| 5323 | 5194 | ** |
| 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 | |
| 5326 | 5198 | ** used by the current version of SQLite. Future versions of SQLite |
| 5327 | 5199 | ** may add additional static mutexes. Static mutexes are for internal |
| 5328 | 5200 | ** use by SQLite only. Applications that use SQLite mutexes should |
| 5329 | 5201 | ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or |
| 5330 | 5202 | ** SQLITE_MUTEX_RECURSIVE. |
| 5331 | 5203 | ** |
| 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 | |
| 5333 | 5205 | ** 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 | |
| 5335 | 5207 | ** mutex types, the same mutex is returned on every call that has |
| 5336 | 5208 | ** the same type number. |
| 5337 | 5209 | ** |
| 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. | |
| 5344 | 5216 | ** |
| 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, | |
| 5347 | 5219 | ** 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 | |
| 5350 | 5222 | ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. |
| 5351 | -** {H17027} In such cases the, | |
| 5223 | +** In such cases the, | |
| 5352 | 5224 | ** 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 | |
| 5354 | 5226 | ** 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.)^ | |
| 5357 | 5229 | ** |
| 5358 | -** Some systems (for example, Windows 95) do not support the operation | |
| 5230 | +** ^(Some systems (for example, Windows 95) do not support the operation | |
| 5359 | 5231 | ** 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.)^ | |
| 5362 | 5234 | ** |
| 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 | |
| 5365 | 5237 | ** 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.)^ | |
| 5368 | 5240 | ** |
| 5369 | -** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or | |
| 5241 | +** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or | |
| 5370 | 5242 | ** sqlite3_mutex_leave() is a NULL pointer, then all three routines |
| 5371 | 5243 | ** behave as no-ops. |
| 5372 | 5244 | ** |
| 5373 | 5245 | ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. |
| 5374 | 5246 | */ |
| @@ -5377,11 +5249,11 @@ | ||
| 5377 | 5249 | SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); |
| 5378 | 5250 | SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); |
| 5379 | 5251 | SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); |
| 5380 | 5252 | |
| 5381 | 5253 | /* |
| 5382 | -** CAPI3REF: Mutex Methods Object {H17120} <S20130> | |
| 5254 | +** CAPI3REF: Mutex Methods Object | |
| 5383 | 5255 | ** EXPERIMENTAL |
| 5384 | 5256 | ** |
| 5385 | 5257 | ** An instance of this structure defines the low-level routines |
| 5386 | 5258 | ** used to allocate and use mutexes. |
| 5387 | 5259 | ** |
| @@ -5393,23 +5265,23 @@ | ||
| 5393 | 5265 | ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. |
| 5394 | 5266 | ** Additionally, an instance of this structure can be used as an |
| 5395 | 5267 | ** output variable when querying the system for the current mutex |
| 5396 | 5268 | ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. |
| 5397 | 5269 | ** |
| 5398 | -** The xMutexInit method defined by this structure is invoked as | |
| 5270 | +** ^The xMutexInit method defined by this structure is invoked as | |
| 5399 | 5271 | ** 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 | |
| 5401 | 5273 | ** effective call to [sqlite3_initialize()]. |
| 5402 | 5274 | ** |
| 5403 | -** The xMutexEnd method defined by this structure is invoked as | |
| 5275 | +** ^The xMutexEnd method defined by this structure is invoked as | |
| 5404 | 5276 | ** part of system shutdown by the sqlite3_shutdown() function. The |
| 5405 | 5277 | ** implementation of this method is expected to release all outstanding |
| 5406 | 5278 | ** 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()]. | |
| 5409 | 5281 | ** |
| 5410 | -** The remaining seven methods defined by this structure (xMutexAlloc, | |
| 5282 | +** ^(The remaining seven methods defined by this structure (xMutexAlloc, | |
| 5411 | 5283 | ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and |
| 5412 | 5284 | ** xMutexNotheld) implement the following interfaces (respectively): |
| 5413 | 5285 | ** |
| 5414 | 5286 | ** <ul> |
| 5415 | 5287 | ** <li> [sqlite3_mutex_alloc()] </li> |
| @@ -5417,31 +5289,31 @@ | ||
| 5417 | 5289 | ** <li> [sqlite3_mutex_enter()] </li> |
| 5418 | 5290 | ** <li> [sqlite3_mutex_try()] </li> |
| 5419 | 5291 | ** <li> [sqlite3_mutex_leave()] </li> |
| 5420 | 5292 | ** <li> [sqlite3_mutex_held()] </li> |
| 5421 | 5293 | ** <li> [sqlite3_mutex_notheld()] </li> |
| 5422 | -** </ul> | |
| 5294 | +** </ul>)^ | |
| 5423 | 5295 | ** |
| 5424 | 5296 | ** The only difference is that the public sqlite3_XXX functions enumerated |
| 5425 | 5297 | ** above silently ignore any invocations that pass a NULL pointer instead |
| 5426 | 5298 | ** of a valid mutex handle. The implementations of the methods defined |
| 5427 | 5299 | ** by this structure are not required to handle this case, the results |
| 5428 | 5300 | ** of passing a NULL pointer instead of a valid mutex handle are undefined |
| 5429 | 5301 | ** (i.e. it is acceptable to provide an implementation that segfaults if |
| 5430 | 5302 | ** it is passed a NULL pointer). |
| 5431 | 5303 | ** |
| 5432 | -** The xMutexInit() method must be threadsafe. It must be harmless to | |
| 5304 | +** The xMutexInit() method must be threadsafe. ^It must be harmless to | |
| 5433 | 5305 | ** invoke xMutexInit() mutiple times within the same process and without |
| 5434 | 5306 | ** intervening calls to xMutexEnd(). Second and subsequent calls to |
| 5435 | 5307 | ** xMutexInit() must be no-ops. |
| 5436 | 5308 | ** |
| 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 | |
| 5440 | 5312 | ** memory allocation for a fast or recursive mutex. |
| 5441 | 5313 | ** |
| 5442 | -** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is | |
| 5314 | +** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is | |
| 5443 | 5315 | ** called, but only if the prior call to xMutexInit returned SQLITE_OK. |
| 5444 | 5316 | ** If xMutexInit fails in any way, it is expected to clean up after itself |
| 5445 | 5317 | ** prior to returning. |
| 5446 | 5318 | */ |
| 5447 | 5319 | typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; |
| @@ -5456,43 +5328,45 @@ | ||
| 5456 | 5328 | int (*xMutexHeld)(sqlite3_mutex *); |
| 5457 | 5329 | int (*xMutexNotheld)(sqlite3_mutex *); |
| 5458 | 5330 | }; |
| 5459 | 5331 | |
| 5460 | 5332 | /* |
| 5461 | -** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> | |
| 5333 | +** CAPI3REF: Mutex Verification Routines | |
| 5462 | 5334 | ** |
| 5463 | 5335 | ** 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 | |
| 5465 | 5337 | ** 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 | |
| 5467 | 5339 | ** 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 | |
| 5469 | 5341 | ** are only required to provide these routines if SQLITE_DEBUG is |
| 5470 | 5342 | ** defined and if NDEBUG is not defined. |
| 5471 | 5343 | ** |
| 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 | |
| 5473 | 5345 | ** is held or not held, respectively, by the calling thread. |
| 5474 | 5346 | ** |
| 5475 | -** {X17084} The implementation is not required to provided versions of these | |
| 5347 | +** ^The implementation is not required to provided versions of these | |
| 5476 | 5348 | ** routines that actually work. If the implementation does not provide working |
| 5477 | 5349 | ** versions of these routines, it should at least provide stubs that always |
| 5478 | 5350 | ** return true so that one does not get spurious assertion failures. |
| 5479 | 5351 | ** |
| 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 | |
| 5482 | 5354 | ** clearly the mutex cannot be held if it does not exist. But the |
| 5483 | 5355 | ** the reason the mutex does not exist is because the build is not |
| 5484 | 5356 | ** using mutexes. And we do not want the assert() containing the |
| 5485 | 5357 | ** 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() | |
| 5487 | 5359 | ** interface should also return 1 when given a NULL pointer. |
| 5488 | 5360 | */ |
| 5361 | +#ifndef NDEBUG | |
| 5489 | 5362 | SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); |
| 5490 | 5363 | SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); |
| 5364 | +#endif | |
| 5491 | 5365 | |
| 5492 | 5366 | /* |
| 5493 | -** CAPI3REF: Mutex Types {H17001} <H17000> | |
| 5367 | +** CAPI3REF: Mutex Types | |
| 5494 | 5368 | ** |
| 5495 | 5369 | ** The [sqlite3_mutex_alloc()] interface takes a single argument |
| 5496 | 5370 | ** which is one of these integer constants. |
| 5497 | 5371 | ** |
| 5498 | 5372 | ** The set of static mutexes may change from one SQLite release to the |
| @@ -5508,52 +5382,54 @@ | ||
| 5508 | 5382 | #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ |
| 5509 | 5383 | #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ |
| 5510 | 5384 | #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ |
| 5511 | 5385 | |
| 5512 | 5386 | /* |
| 5513 | -** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000> | |
| 5387 | +** CAPI3REF: Retrieve the mutex for a database connection | |
| 5514 | 5388 | ** |
| 5515 | -** This interface returns a pointer the [sqlite3_mutex] object that | |
| 5389 | +** ^This interface returns a pointer the [sqlite3_mutex] object that | |
| 5516 | 5390 | ** serializes access to the [database connection] given in the argument |
| 5517 | 5391 | ** 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 | |
| 5519 | 5393 | ** routine returns a NULL pointer. |
| 5520 | 5394 | */ |
| 5521 | 5395 | SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); |
| 5522 | 5396 | |
| 5523 | 5397 | /* |
| 5524 | -** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> | |
| 5398 | +** CAPI3REF: Low-Level Control Of Database Files | |
| 5525 | 5399 | ** |
| 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 | |
| 5527 | 5401 | ** 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 | |
| 5533 | 5409 | ** 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 | |
| 5535 | 5411 | ** method becomes the return value of this routine. |
| 5536 | 5412 | ** |
| 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 | |
| 5539 | 5415 | ** 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 | |
| 5542 | 5418 | ** an incorrect zDbName and an SQLITE_ERROR return from the underlying |
| 5543 | -** xFileControl method. {END} | |
| 5419 | +** xFileControl method. | |
| 5544 | 5420 | ** |
| 5545 | 5421 | ** See also: [SQLITE_FCNTL_LOCKSTATE] |
| 5546 | 5422 | */ |
| 5547 | 5423 | SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); |
| 5548 | 5424 | |
| 5549 | 5425 | /* |
| 5550 | -** CAPI3REF: Testing Interface {H11400} <S30800> | |
| 5426 | +** CAPI3REF: Testing Interface | |
| 5551 | 5427 | ** |
| 5552 | -** The sqlite3_test_control() interface is used to read out internal | |
| 5428 | +** ^The sqlite3_test_control() interface is used to read out internal | |
| 5553 | 5429 | ** 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 | |
| 5555 | 5431 | ** the number, meaning, and operation of all subsequent parameters. |
| 5556 | 5432 | ** |
| 5557 | 5433 | ** This interface is not for use by applications. It exists solely |
| 5558 | 5434 | ** for verifying the correct operation of the SQLite library. Depending |
| 5559 | 5435 | ** on how the SQLite library is compiled, this interface might not exist. |
| @@ -5564,20 +5440,21 @@ | ||
| 5564 | 5440 | ** operate consistently from one release to the next. |
| 5565 | 5441 | */ |
| 5566 | 5442 | SQLITE_API int sqlite3_test_control(int op, ...); |
| 5567 | 5443 | |
| 5568 | 5444 | /* |
| 5569 | -** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> | |
| 5445 | +** CAPI3REF: Testing Interface Operation Codes | |
| 5570 | 5446 | ** |
| 5571 | 5447 | ** These constants are the valid operation code parameters used |
| 5572 | 5448 | ** as the first argument to [sqlite3_test_control()]. |
| 5573 | 5449 | ** |
| 5574 | 5450 | ** These parameters and their meanings are subject to change |
| 5575 | 5451 | ** without notice. These values are for testing purposes only. |
| 5576 | 5452 | ** Applications should not use any of these parameters or the |
| 5577 | 5453 | ** [sqlite3_test_control()] interface. |
| 5578 | 5454 | */ |
| 5455 | +#define SQLITE_TESTCTRL_FIRST 5 | |
| 5579 | 5456 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 5580 | 5457 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 5581 | 5458 | #define SQLITE_TESTCTRL_PRNG_RESET 7 |
| 5582 | 5459 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 5583 | 5460 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| @@ -5584,31 +5461,34 @@ | ||
| 5584 | 5461 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 5585 | 5462 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 5586 | 5463 | #define SQLITE_TESTCTRL_ASSERT 12 |
| 5587 | 5464 | #define SQLITE_TESTCTRL_ALWAYS 13 |
| 5588 | 5465 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 5466 | +#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 | |
| 5467 | +#define SQLITE_TESTCTRL_ISKEYWORD 16 | |
| 5468 | +#define SQLITE_TESTCTRL_LAST 16 | |
| 5589 | 5469 | |
| 5590 | 5470 | /* |
| 5591 | -** CAPI3REF: SQLite Runtime Status {H17200} <S60200> | |
| 5471 | +** CAPI3REF: SQLite Runtime Status | |
| 5592 | 5472 | ** EXPERIMENTAL |
| 5593 | 5473 | ** |
| 5594 | -** This interface is used to retrieve runtime status information | |
| 5474 | +** ^This interface is used to retrieve runtime status information | |
| 5595 | 5475 | ** 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 | |
| 5601 | 5481 | ** 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 | |
| 5603 | 5483 | ** 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.)^ | |
| 5607 | 5487 | ** |
| 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. | |
| 5610 | 5490 | ** |
| 5611 | 5491 | ** This routine is threadsafe but is not atomic. This routine can be |
| 5612 | 5492 | ** called while other threads are running the same or different SQLite |
| 5613 | 5493 | ** interfaces. However the values returned in *pCurrent and |
| 5614 | 5494 | ** *pHighwater reflect the status of SQLite at different points in time |
| @@ -5619,82 +5499,82 @@ | ||
| 5619 | 5499 | */ |
| 5620 | 5500 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); |
| 5621 | 5501 | |
| 5622 | 5502 | |
| 5623 | 5503 | /* |
| 5624 | -** CAPI3REF: Status Parameters {H17250} <H17200> | |
| 5504 | +** CAPI3REF: Status Parameters | |
| 5625 | 5505 | ** EXPERIMENTAL |
| 5626 | 5506 | ** |
| 5627 | 5507 | ** These integer constants designate various run-time status parameters |
| 5628 | 5508 | ** that can be returned by [sqlite3_status()]. |
| 5629 | 5509 | ** |
| 5630 | 5510 | ** <dl> |
| 5631 | -** <dt>SQLITE_STATUS_MEMORY_USED</dt> | |
| 5511 | +** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> | |
| 5632 | 5512 | ** <dd>This parameter is the current amount of memory checked out |
| 5633 | 5513 | ** using [sqlite3_malloc()], either directly or indirectly. The |
| 5634 | 5514 | ** figure includes calls made to [sqlite3_malloc()] by the application |
| 5635 | 5515 | ** and internal memory usage by the SQLite library. Scratch memory |
| 5636 | 5516 | ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache |
| 5637 | 5517 | ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in |
| 5638 | 5518 | ** 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>)^ | |
| 5640 | 5520 | ** |
| 5641 | -** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> | |
| 5521 | +** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt> | |
| 5642 | 5522 | ** <dd>This parameter records the largest memory allocation request |
| 5643 | 5523 | ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
| 5644 | 5524 | ** internal equivalents). Only the value returned in the |
| 5645 | 5525 | ** *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>)^ | |
| 5647 | 5527 | ** |
| 5648 | -** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> | |
| 5528 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> | |
| 5649 | 5529 | ** <dd>This parameter returns the number of pages used out of the |
| 5650 | 5530 | ** [pagecache memory allocator] that was configured using |
| 5651 | 5531 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| 5652 | -** value returned is in pages, not in bytes.</dd> | |
| 5532 | +** value returned is in pages, not in bytes.</dd>)^ | |
| 5653 | 5533 | ** |
| 5654 | -** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> | |
| 5534 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> | |
| 5655 | 5535 | ** <dd>This parameter returns the number of bytes of page cache |
| 5656 | 5536 | ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] |
| 5657 | 5537 | ** buffer and where forced to overflow to [sqlite3_malloc()]. The |
| 5658 | 5538 | ** returned value includes allocations that overflowed because they |
| 5659 | 5539 | ** where too large (they were larger than the "sz" parameter to |
| 5660 | 5540 | ** [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>)^ | |
| 5662 | 5542 | ** |
| 5663 | -** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> | |
| 5543 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> | |
| 5664 | 5544 | ** <dd>This parameter records the largest memory allocation request |
| 5665 | 5545 | ** handed to [pagecache memory allocator]. Only the value returned in the |
| 5666 | 5546 | ** *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>)^ | |
| 5668 | 5548 | ** |
| 5669 | -** <dt>SQLITE_STATUS_SCRATCH_USED</dt> | |
| 5549 | +** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt> | |
| 5670 | 5550 | ** <dd>This parameter returns the number of allocations used out of the |
| 5671 | 5551 | ** [scratch memory allocator] configured using |
| 5672 | 5552 | ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not |
| 5673 | 5553 | ** in bytes. Since a single thread may only have one scratch allocation |
| 5674 | 5554 | ** 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>)^ | |
| 5676 | 5556 | ** |
| 5677 | -** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> | |
| 5557 | +** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> | |
| 5678 | 5558 | ** <dd>This parameter returns the number of bytes of scratch memory |
| 5679 | 5559 | ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] |
| 5680 | 5560 | ** buffer and where forced to overflow to [sqlite3_malloc()]. The values |
| 5681 | 5561 | ** returned include overflows because the requested allocation was too |
| 5682 | 5562 | ** larger (that is, because the requested allocation was larger than the |
| 5683 | 5563 | ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer |
| 5684 | 5564 | ** slots were available. |
| 5685 | -** </dd> | |
| 5565 | +** </dd>)^ | |
| 5686 | 5566 | ** |
| 5687 | -** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> | |
| 5567 | +** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> | |
| 5688 | 5568 | ** <dd>This parameter records the largest memory allocation request |
| 5689 | 5569 | ** handed to [scratch memory allocator]. Only the value returned in the |
| 5690 | 5570 | ** *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>)^ | |
| 5692 | 5572 | ** |
| 5693 | -** <dt>SQLITE_STATUS_PARSER_STACK</dt> | |
| 5573 | +** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> | |
| 5694 | 5574 | ** <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>)^ | |
| 5696 | 5576 | ** </dl> |
| 5697 | 5577 | ** |
| 5698 | 5578 | ** New status parameters may be added from time to time. |
| 5699 | 5579 | */ |
| 5700 | 5580 | #define SQLITE_STATUS_MEMORY_USED 0 |
| @@ -5706,31 +5586,31 @@ | ||
| 5706 | 5586 | #define SQLITE_STATUS_PARSER_STACK 6 |
| 5707 | 5587 | #define SQLITE_STATUS_PAGECACHE_SIZE 7 |
| 5708 | 5588 | #define SQLITE_STATUS_SCRATCH_SIZE 8 |
| 5709 | 5589 | |
| 5710 | 5590 | /* |
| 5711 | -** CAPI3REF: Database Connection Status {H17500} <S60200> | |
| 5591 | +** CAPI3REF: Database Connection Status | |
| 5712 | 5592 | ** EXPERIMENTAL |
| 5713 | 5593 | ** |
| 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 | |
| 5718 | 5598 | ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. |
| 5719 | 5599 | ** Additional options will likely appear in future releases of SQLite. |
| 5720 | 5600 | ** |
| 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 | |
| 5723 | 5603 | ** the resetFlg is true, then the highest instantaneous value is |
| 5724 | 5604 | ** reset back down to the current value. |
| 5725 | 5605 | ** |
| 5726 | 5606 | ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. |
| 5727 | 5607 | */ |
| 5728 | 5608 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); |
| 5729 | 5609 | |
| 5730 | 5610 | /* |
| 5731 | -** CAPI3REF: Status Parameters for database connections {H17520} <H17500> | |
| 5611 | +** CAPI3REF: Status Parameters for database connections | |
| 5732 | 5612 | ** EXPERIMENTAL |
| 5733 | 5613 | ** |
| 5734 | 5614 | ** These constants are the available integer "verbs" that can be passed as |
| 5735 | 5615 | ** the second argument to the [sqlite3_db_status()] interface. |
| 5736 | 5616 | ** |
| @@ -5739,61 +5619,61 @@ | ||
| 5739 | 5619 | ** [sqlite3_db_status()] to make sure that the call worked. |
| 5740 | 5620 | ** The [sqlite3_db_status()] interface will return a non-zero error code |
| 5741 | 5621 | ** if a discontinued or unsupported verb is invoked. |
| 5742 | 5622 | ** |
| 5743 | 5623 | ** <dl> |
| 5744 | -** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> | |
| 5624 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> | |
| 5745 | 5625 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5746 | -** checked out.</dd> | |
| 5626 | +** checked out.</dd>)^ | |
| 5747 | 5627 | ** </dl> |
| 5748 | 5628 | */ |
| 5749 | 5629 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5750 | 5630 | |
| 5751 | 5631 | |
| 5752 | 5632 | /* |
| 5753 | -** CAPI3REF: Prepared Statement Status {H17550} <S60200> | |
| 5633 | +** CAPI3REF: Prepared Statement Status | |
| 5754 | 5634 | ** EXPERIMENTAL |
| 5755 | 5635 | ** |
| 5756 | -** Each prepared statement maintains various | |
| 5636 | +** ^(Each prepared statement maintains various | |
| 5757 | 5637 | ** [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 | |
| 5759 | 5639 | ** be used to monitor the performance characteristics of the prepared |
| 5760 | 5640 | ** statements. For example, if the number of table steps greatly exceeds |
| 5761 | 5641 | ** the number of table searches or result rows, that would tend to indicate |
| 5762 | 5642 | ** that the prepared statement is using a full table scan rather than |
| 5763 | 5643 | ** an index. |
| 5764 | 5644 | ** |
| 5765 | -** This interface is used to retrieve and reset counter values from | |
| 5645 | +** ^(This interface is used to retrieve and reset counter values from | |
| 5766 | 5646 | ** a [prepared statement]. The first argument is the prepared statement |
| 5767 | 5647 | ** object to be interrogated. The second argument |
| 5768 | 5648 | ** 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 | |
| 5772 | 5652 | ** interface call returns. |
| 5773 | 5653 | ** |
| 5774 | 5654 | ** See also: [sqlite3_status()] and [sqlite3_db_status()]. |
| 5775 | 5655 | */ |
| 5776 | 5656 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
| 5777 | 5657 | |
| 5778 | 5658 | /* |
| 5779 | -** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550> | |
| 5659 | +** CAPI3REF: Status Parameters for prepared statements | |
| 5780 | 5660 | ** EXPERIMENTAL |
| 5781 | 5661 | ** |
| 5782 | 5662 | ** These preprocessor macros define integer codes that name counter |
| 5783 | 5663 | ** values associated with the [sqlite3_stmt_status()] interface. |
| 5784 | 5664 | ** The meanings of the various counters are as follows: |
| 5785 | 5665 | ** |
| 5786 | 5666 | ** <dl> |
| 5787 | 5667 | ** <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 | |
| 5789 | 5669 | ** a table as part of a full table scan. Large numbers for this counter |
| 5790 | 5670 | ** may indicate opportunities for performance improvement through |
| 5791 | 5671 | ** careful use of indices.</dd> |
| 5792 | 5672 | ** |
| 5793 | 5673 | ** <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. | |
| 5795 | 5675 | ** A non-zero value in this counter may indicate an opportunity to |
| 5796 | 5676 | ** improvement performance through careful use of indices.</dd> |
| 5797 | 5677 | ** |
| 5798 | 5678 | ** </dl> |
| 5799 | 5679 | */ |
| @@ -5817,84 +5697,84 @@ | ||
| 5817 | 5697 | /* |
| 5818 | 5698 | ** CAPI3REF: Application Defined Page Cache. |
| 5819 | 5699 | ** KEYWORDS: {page cache} |
| 5820 | 5700 | ** EXPERIMENTAL |
| 5821 | 5701 | ** |
| 5822 | -** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can | |
| 5702 | +** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can | |
| 5823 | 5703 | ** 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 | |
| 5825 | 5705 | ** heap memory used by SQLite is used by the page cache to cache data read |
| 5826 | 5706 | ** from, or ready to be written to, the database file. By implementing a |
| 5827 | 5707 | ** custom page cache using this API, an application can control more |
| 5828 | 5708 | ** precisely the amount of memory consumed by SQLite, the way in which |
| 5829 | 5709 | ** that memory is allocated and released, and the policies used to |
| 5830 | 5710 | ** determine exactly which parts of a database file are cached and for |
| 5831 | 5711 | ** how long. |
| 5832 | 5712 | ** |
| 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 | |
| 5834 | 5714 | ** internal buffer by SQLite within the call to [sqlite3_config]. Hence |
| 5835 | 5715 | ** 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()], | |
| 5845 | 5725 | ** if the application invokes this API. It can be used to clean up |
| 5846 | 5726 | ** any outstanding resources before process shutdown, if required. |
| 5847 | 5727 | ** |
| 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 | |
| 5850 | 5730 | ** xShutdown method is only called from [sqlite3_shutdown()] so it does |
| 5851 | 5731 | ** not need to be threadsafe either. All other methods must be threadsafe |
| 5852 | 5732 | ** in multithreaded applications. |
| 5853 | 5733 | ** |
| 5854 | -** SQLite will never invoke xInit() more than once without an intervening | |
| 5734 | +** ^SQLite will never invoke xInit() more than once without an intervening | |
| 5855 | 5735 | ** call to xShutdown(). |
| 5856 | 5736 | ** |
| 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 | |
| 5858 | 5738 | ** 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 | |
| 5860 | 5740 | ** 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 | |
| 5862 | 5742 | ** 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 | |
| 5864 | 5744 | ** extra R bytes on each page to store metadata about the underlying |
| 5865 | 5745 | ** database page on disk. The value of R depends |
| 5866 | 5746 | ** 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 | |
| 5868 | 5748 | ** xCreate(), bPurgeable, is true if the cache being created will |
| 5869 | 5749 | ** 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 | |
| 5871 | 5751 | ** 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 | |
| 5873 | 5753 | ** 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 | |
| 5875 | 5755 | ** never contain any unpinned pages. |
| 5876 | 5756 | ** |
| 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 | |
| 5878 | 5758 | ** suggested maximum cache-size (number of pages stored by) the cache |
| 5879 | 5759 | ** 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 | |
| 5882 | 5762 | ** value; it is advisory only. |
| 5883 | 5763 | ** |
| 5884 | -** The xPagecount() method should return the number of pages currently | |
| 5764 | +** ^The xPagecount() method should return the number of pages currently | |
| 5885 | 5765 | ** stored in the cache. |
| 5886 | 5766 | ** |
| 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 | |
| 5890 | 5770 | ** mimimum key value is 1. After it has been retrieved using xFetch, the page |
| 5891 | 5771 | ** is considered to be "pinned". |
| 5892 | 5772 | ** |
| 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 | |
| 5894 | 5774 | ** 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 | |
| 5896 | 5776 | ** behavior of the cache implementation is determined by the value of the |
| 5897 | 5777 | ** createFlag parameter passed to xFetch, according to the following table: |
| 5898 | 5778 | ** |
| 5899 | 5779 | ** <table border=1 width=85% align=center> |
| 5900 | 5780 | ** <tr><th> createFlag <th> Behaviour when page is not already in cache |
| @@ -5901,45 +5781,45 @@ | ||
| 5901 | 5781 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 5902 | 5782 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 5903 | 5783 | ** Otherwise return NULL. |
| 5904 | 5784 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 5905 | 5785 | ** NULL if allocating a new page is effectively impossible. |
| 5906 | -** </table> | |
| 5786 | +** </table>)^ | |
| 5907 | 5787 | ** |
| 5908 | 5788 | ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If |
| 5909 | 5789 | ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will |
| 5910 | 5790 | ** attempt to unpin one or more cache pages by spilling the content of |
| 5911 | 5791 | ** pinned pages to disk and synching the operating system disk cache. After |
| 5912 | 5792 | ** attempting to unpin pages, the xFetch() method will be invoked again with |
| 5913 | 5793 | ** a createFlag of 2. |
| 5914 | 5794 | ** |
| 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, | |
| 5917 | 5797 | ** then the page should be evicted from the cache. In this case SQLite |
| 5918 | 5798 | ** 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 | |
| 5921 | 5801 | ** may choose to evict unpinned pages at any time. |
| 5922 | 5802 | ** |
| 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 | |
| 5924 | 5804 | ** call to xUnpin() unpins the page regardless of the number of prior calls |
| 5925 | -** to xFetch(). | |
| 5805 | +** to xFetch().)^ | |
| 5926 | 5806 | ** |
| 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 | |
| 5929 | 5809 | ** 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 | |
| 5931 | 5811 | ** to be pinned. |
| 5932 | 5812 | ** |
| 5933 | -** When SQLite calls the xTruncate() method, the cache must discard all | |
| 5813 | +** ^When SQLite calls the xTruncate() method, the cache must discard all | |
| 5934 | 5814 | ** 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 | |
| 5936 | 5816 | ** of these pages are pinned, they are implicitly unpinned, meaning that |
| 5937 | 5817 | ** they can be safely discarded. |
| 5938 | 5818 | ** |
| 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 | |
| 5941 | 5821 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 5942 | 5822 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods |
| 5943 | 5823 | ** functions. |
| 5944 | 5824 | */ |
| 5945 | 5825 | typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; |
| @@ -5960,11 +5840,11 @@ | ||
| 5960 | 5840 | /* |
| 5961 | 5841 | ** CAPI3REF: Online Backup Object |
| 5962 | 5842 | ** EXPERIMENTAL |
| 5963 | 5843 | ** |
| 5964 | 5844 | ** 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 | |
| 5966 | 5846 | ** a call to [sqlite3_backup_init()] and is destroyed by a call to |
| 5967 | 5847 | ** [sqlite3_backup_finish()]. |
| 5968 | 5848 | ** |
| 5969 | 5849 | ** See Also: [Using the SQLite Online Backup API] |
| 5970 | 5850 | */ |
| @@ -5972,168 +5852,173 @@ | ||
| 5972 | 5852 | |
| 5973 | 5853 | /* |
| 5974 | 5854 | ** CAPI3REF: Online Backup API. |
| 5975 | 5855 | ** EXPERIMENTAL |
| 5976 | 5856 | ** |
| 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 | |
| 5979 | 5859 | ** for copying in-memory databases to or from persistent files. |
| 5980 | 5860 | ** |
| 5981 | 5861 | ** See Also: [Using the SQLite Online Backup API] |
| 5982 | 5862 | ** |
| 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. | |
| 5989 | 5869 | ** |
| 5990 | -** To perform a backup operation: | |
| 5870 | +** ^(To perform a backup operation: | |
| 5991 | 5871 | ** <ol> |
| 5992 | 5872 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| 5993 | 5873 | ** backup, |
| 5994 | 5874 | ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer |
| 5995 | 5875 | ** the data between the two databases, and finally |
| 5996 | 5876 | ** <li><b>sqlite3_backup_finish()</b> is called to release all resources |
| 5997 | 5877 | ** associated with the backup operation. |
| 5998 | -** </ol> | |
| 5878 | +** </ol>)^ | |
| 5999 | 5879 | ** There should be exactly one call to sqlite3_backup_finish() for each |
| 6000 | 5880 | ** successful call to sqlite3_backup_init(). |
| 6001 | 5881 | ** |
| 6002 | 5882 | ** <b>sqlite3_backup_init()</b> |
| 6003 | 5883 | ** |
| 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. | |
| 6014 | 5896 | ** |
| 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 | |
| 6021 | 5906 | ** sqlite3_backup_finish() functions to perform the specified backup |
| 6022 | 5907 | ** operation. |
| 6023 | 5908 | ** |
| 6024 | 5909 | ** <b>sqlite3_backup_step()</b> |
| 6025 | 5910 | ** |
| 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 | |
| 6034 | 5920 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| 6035 | 5921 | ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an |
| 6036 | 5922 | ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. |
| 6037 | 5923 | ** |
| 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 | |
| 6040 | 5926 | ** the destination is an in-memory database with a different page size |
| 6041 | 5927 | ** from the source database. |
| 6042 | 5928 | ** |
| 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 | |
| 6044 | 5930 | ** 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 | |
| 6046 | 5932 | ** 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 | |
| 6049 | 5935 | ** [database connection] |
| 6050 | 5936 | ** 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 | |
| 6053 | 5939 | ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or |
| 6054 | 5940 | ** [SQLITE_READONLY] is returned, then |
| 6055 | 5941 | ** 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 | |
| 6057 | 5943 | ** that the backup operation has failed and pass the backup operation handle |
| 6058 | 5944 | ** to the sqlite3_backup_finish() to release associated resources. |
| 6059 | 5945 | ** |
| 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 | |
| 6062 | 5948 | ** 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 | |
| 6069 | 5955 | ** 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 | |
| 6072 | 5958 | ** 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 | |
| 6074 | 5960 | ** updated at the same time. |
| 6075 | 5961 | ** |
| 6076 | 5962 | ** <b>sqlite3_backup_finish()</b> |
| 6077 | 5963 | ** |
| 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 | |
| 6084 | 5972 | ** and may not be used following a call to sqlite3_backup_finish(). |
| 6085 | 5973 | ** |
| 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]. | |
| 6094 | 5980 | ** |
| 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 | |
| 6097 | 5983 | ** sqlite3_backup_finish(). |
| 6098 | 5984 | ** |
| 6099 | 5985 | ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b> |
| 6100 | 5986 | ** |
| 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. | |
| 6106 | 5992 | ** |
| 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 | |
| 6109 | 5995 | ** operation, then the values are not updated to account for any extra |
| 6110 | 5996 | ** pages that need to be updated or the size of the source database file |
| 6111 | 5997 | ** changing. |
| 6112 | 5998 | ** |
| 6113 | 5999 | ** <b>Concurrent Usage of Database Handles</b> |
| 6114 | 6000 | ** |
| 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 | |
| 6116 | 6002 | ** 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 | |
| 6118 | 6004 | ** connections, then the source database connection may be used concurrently |
| 6119 | 6005 | ** from within other threads. |
| 6120 | 6006 | ** |
| 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 | |
| 6123 | 6009 | ** 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. | |
| 6130 | 6015 | ** |
| 6131 | -** Furthermore, if running in [shared cache mode], the application must | |
| 6016 | +** If running in [shared cache mode], the application must | |
| 6132 | 6017 | ** guarantee that the shared cache used by the destination database |
| 6133 | 6018 | ** 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 | |
| 6135 | 6020 | ** backed up to is not accessed by any connection within the process, |
| 6136 | 6021 | ** not just the specific connection that was passed to sqlite3_backup_init(). |
| 6137 | 6022 | ** |
| 6138 | 6023 | ** The [sqlite3_backup] object itself is partially threadsafe. Multiple |
| 6139 | 6024 | ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). |
| @@ -6155,60 +6040,60 @@ | ||
| 6155 | 6040 | |
| 6156 | 6041 | /* |
| 6157 | 6042 | ** CAPI3REF: Unlock Notification |
| 6158 | 6043 | ** EXPERIMENTAL |
| 6159 | 6044 | ** |
| 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 | |
| 6161 | 6046 | ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or |
| 6162 | 6047 | ** individual tables within the shared-cache cannot be obtained. See |
| 6163 | 6048 | ** [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 | |
| 6165 | 6050 | ** 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 | |
| 6167 | 6052 | ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. |
| 6168 | 6053 | ** |
| 6169 | 6054 | ** See Also: [Using the SQLite Unlock Notification Feature]. |
| 6170 | 6055 | ** |
| 6171 | -** Shared-cache locks are released when a database connection concludes | |
| 6056 | +** ^Shared-cache locks are released when a database connection concludes | |
| 6172 | 6057 | ** its current transaction, either by committing it or rolling it back. |
| 6173 | 6058 | ** |
| 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 | |
| 6175 | 6060 | ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the |
| 6176 | 6061 | ** 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 | |
| 6178 | 6063 | ** application receives an SQLITE_LOCKED error, it may call the |
| 6179 | 6064 | ** sqlite3_unlock_notify() method with the blocked connection handle as |
| 6180 | 6065 | ** 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 | |
| 6182 | 6067 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| 6183 | 6068 | ** call that concludes the blocking connections transaction. |
| 6184 | 6069 | ** |
| 6185 | -** If sqlite3_unlock_notify() is called in a multi-threaded application, | |
| 6070 | +** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, | |
| 6186 | 6071 | ** there is a chance that the blocking connection will have already |
| 6187 | 6072 | ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. |
| 6188 | 6073 | ** 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().)^ | |
| 6190 | 6075 | ** |
| 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 | |
| 6192 | 6077 | ** shared-cache table, and more than one other connection currently holds |
| 6193 | 6078 | ** a read-lock on the same table, then SQLite arbitrarily selects one of |
| 6194 | 6079 | ** the other connections to use as the blocking connection. |
| 6195 | 6080 | ** |
| 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 | |
| 6197 | 6082 | ** blocked connection. If sqlite3_unlock_notify() is called when the |
| 6198 | 6083 | ** 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 | |
| 6200 | 6085 | ** 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 | |
| 6202 | 6087 | ** unlock-notify callback may also be canceled by closing the blocked |
| 6203 | 6088 | ** connection using [sqlite3_close()]. |
| 6204 | 6089 | ** |
| 6205 | 6090 | ** The unlock-notify callback is not reentrant. If an application invokes |
| 6206 | 6091 | ** any sqlite3_xxx API functions from within an unlock-notify callback, a |
| 6207 | 6092 | ** crash or deadlock may be the result. |
| 6208 | 6093 | ** |
| 6209 | -** Unless deadlock is detected (see below), sqlite3_unlock_notify() always | |
| 6094 | +** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always | |
| 6210 | 6095 | ** returns SQLITE_OK. |
| 6211 | 6096 | ** |
| 6212 | 6097 | ** <b>Callback Invocation Details</b> |
| 6213 | 6098 | ** |
| 6214 | 6099 | ** When an unlock-notify callback is registered, the application provides a |
| @@ -6218,11 +6103,11 @@ | ||
| 6218 | 6103 | ** an unlock-notify callback is a pointer to an array of void* pointers, |
| 6219 | 6104 | ** and the second is the number of entries in the array. |
| 6220 | 6105 | ** |
| 6221 | 6106 | ** When a blocking connections transaction is concluded, there may be |
| 6222 | 6107 | ** 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 | |
| 6224 | 6109 | ** same callback function, then instead of invoking the callback function |
| 6225 | 6110 | ** multiple times, it is invoked once with the set of void* context pointers |
| 6226 | 6111 | ** specified by the blocked connections bundled together into an array. |
| 6227 | 6112 | ** This gives the application an opportunity to prioritize any actions |
| 6228 | 6113 | ** related to the set of unblocked database connections. |
| @@ -6236,20 +6121,20 @@ | ||
| 6236 | 6121 | ** connection Y's transaction to be concluded, and similarly connection |
| 6237 | 6122 | ** Y is waiting on connection X's transaction, then neither connection |
| 6238 | 6123 | ** will proceed and the system may remain deadlocked indefinitely. |
| 6239 | 6124 | ** |
| 6240 | 6125 | ** 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 | |
| 6242 | 6127 | ** system in a deadlocked state, then SQLITE_LOCKED is returned and no |
| 6243 | 6128 | ** unlock-notify callback is registered. The system is said to be in |
| 6244 | 6129 | ** a deadlocked state if connection A has registered for an unlock-notify |
| 6245 | 6130 | ** callback on the conclusion of connection B's transaction, and connection |
| 6246 | 6131 | ** 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 | |
| 6248 | 6133 | ** the system is also considered to be deadlocked if connection B has |
| 6249 | 6134 | ** 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 | |
| 6251 | 6136 | ** number of levels of indirection are allowed. |
| 6252 | 6137 | ** |
| 6253 | 6138 | ** <b>The "DROP TABLE" Exception</b> |
| 6254 | 6139 | ** |
| 6255 | 6140 | ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost |
| @@ -6261,14 +6146,14 @@ | ||
| 6261 | 6146 | ** sqlite3_unlock_notify() results in the unlock-notify callback being |
| 6262 | 6147 | ** invoked immediately. If the application then re-attempts the "DROP TABLE" |
| 6263 | 6148 | ** or "DROP INDEX" query, an infinite loop might be the result. |
| 6264 | 6149 | ** |
| 6265 | 6150 | ** 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 | |
| 6267 | 6152 | ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in |
| 6268 | 6153 | ** the special "DROP TABLE/INDEX" case, the extended error code is just |
| 6269 | -** SQLITE_LOCKED. | |
| 6154 | +** SQLITE_LOCKED.)^ | |
| 6270 | 6155 | */ |
| 6271 | 6156 | SQLITE_API int sqlite3_unlock_notify( |
| 6272 | 6157 | sqlite3 *pBlocked, /* Waiting connection */ |
| 6273 | 6158 | void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ |
| 6274 | 6159 | void *pNotifyArg /* Argument to pass to xNotify */ |
| @@ -6277,11 +6162,11 @@ | ||
| 6277 | 6162 | |
| 6278 | 6163 | /* |
| 6279 | 6164 | ** CAPI3REF: String Comparison |
| 6280 | 6165 | ** EXPERIMENTAL |
| 6281 | 6166 | ** |
| 6282 | -** The [sqlite3_strnicmp()] API allows applications and extensions to | |
| 6167 | +** ^The [sqlite3_strnicmp()] API allows applications and extensions to | |
| 6283 | 6168 | ** compare the contents of two buffers containing UTF-8 strings in a |
| 6284 | 6169 | ** case-indendent fashion, using the same definition of case independence |
| 6285 | 6170 | ** that SQLite uses internally when comparing identifiers. |
| 6286 | 6171 | */ |
| 6287 | 6172 | SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); |
| @@ -6507,34 +6392,34 @@ | ||
| 6507 | 6392 | #define TK_UNIQUE 100 |
| 6508 | 6393 | #define TK_CHECK 101 |
| 6509 | 6394 | #define TK_REFERENCES 102 |
| 6510 | 6395 | #define TK_AUTOINCR 103 |
| 6511 | 6396 | #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 | |
| 6536 | 6421 | #define TK_INTEGER 129 |
| 6537 | 6422 | #define TK_FLOAT 130 |
| 6538 | 6423 | #define TK_BLOB 131 |
| 6539 | 6424 | #define TK_REGISTER 132 |
| 6540 | 6425 | #define TK_VARIABLE 133 |
| @@ -8506,41 +8391,47 @@ | ||
| 8506 | 8391 | ** A macro to discover the encoding of a database. |
| 8507 | 8392 | */ |
| 8508 | 8393 | #define ENC(db) ((db)->aDb[0].pSchema->enc) |
| 8509 | 8394 | |
| 8510 | 8395 | /* |
| 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. | |
| 8516 | 8397 | */ |
| 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, */ | |
| 8523 | 8403 | /* DELETE, or UPDATE and return */ |
| 8524 | 8404 | /* 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 */ | |
| 8526 | 8406 | /* 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 | |
| 8531 | 8411 | ** 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 */ | |
| 8542 | 8433 | |
| 8543 | 8434 | /* |
| 8544 | 8435 | ** Possible values for the sqlite.magic field. |
| 8545 | 8436 | ** The numbers are obtained at random and have no special meaning, other |
| 8546 | 8437 | ** than being distinct from one another. |
| @@ -9250,18 +9141,17 @@ | ||
| 9250 | 9141 | #define EP_Distinct 0x0010 /* Aggregate function with DISTINCT keyword */ |
| 9251 | 9142 | #define EP_VarSelect 0x0020 /* pSelect is correlated, not constant */ |
| 9252 | 9143 | #define EP_DblQuoted 0x0040 /* token.z was originally in "..." */ |
| 9253 | 9144 | #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */ |
| 9254 | 9145 | #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() */ | |
| 9263 | 9153 | |
| 9264 | 9154 | /* |
| 9265 | 9155 | ** The following are the meanings of bits in the Expr.flags2 field. |
| 9266 | 9156 | */ |
| 9267 | 9157 | #define EP2_MallocedToken 0x0001 /* Need to sqlite3DbFree() Expr.zToken */ |
| @@ -9502,10 +9392,11 @@ | ||
| 9502 | 9392 | #define WHERE_ONEPASS_DESIRED 0x0004 /* Want to do one-pass UPDATE/DELETE */ |
| 9503 | 9393 | #define WHERE_DUPLICATES_OK 0x0008 /* Ok to return a row more than once */ |
| 9504 | 9394 | #define WHERE_OMIT_OPEN 0x0010 /* Table cursor are already open */ |
| 9505 | 9395 | #define WHERE_OMIT_CLOSE 0x0020 /* Omit close of table & index cursors */ |
| 9506 | 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 */ | |
| 9507 | 9398 | |
| 9508 | 9399 | /* |
| 9509 | 9400 | ** The WHERE clause processing routine has two halves. The |
| 9510 | 9401 | ** first part does the start of the WHERE loop and the second |
| 9511 | 9402 | ** half does the tail of the WHERE loop. An instance of |
| @@ -9514,10 +9405,11 @@ | ||
| 9514 | 9405 | */ |
| 9515 | 9406 | struct WhereInfo { |
| 9516 | 9407 | Parse *pParse; /* Parsing and code generating context */ |
| 9517 | 9408 | u16 wctrlFlags; /* Flags originally passed to sqlite3WhereBegin() */ |
| 9518 | 9409 | u8 okOnePass; /* Ok to use one-pass algorithm for UPDATE or DELETE */ |
| 9410 | + u8 untestedTerms; /* Not all WHERE terms resolved by outer loop */ | |
| 9519 | 9411 | SrcList *pTabList; /* List of tables in the join */ |
| 9520 | 9412 | int iTop; /* The very beginning of the WHERE loop */ |
| 9521 | 9413 | int iContinue; /* Jump here to continue with next record */ |
| 9522 | 9414 | int iBreak; /* Jump here to break out of the loop */ |
| 9523 | 9415 | int nLevel; /* Number of nested loop */ |
| @@ -9733,11 +9625,10 @@ | ||
| 9733 | 9625 | u8 nColCache; /* Number of entries in the column cache */ |
| 9734 | 9626 | u8 iColCache; /* Next entry of the cache to replace */ |
| 9735 | 9627 | struct yColCache { |
| 9736 | 9628 | int iTable; /* Table cursor number */ |
| 9737 | 9629 | int iColumn; /* Table column number */ |
| 9738 | - u8 affChange; /* True if this register has had an affinity change */ | |
| 9739 | 9630 | u8 tempReg; /* iReg is a temp register that needs to be freed */ |
| 9740 | 9631 | int iLevel; /* Nesting level */ |
| 9741 | 9632 | int iReg; /* Reg with value of this column. 0 means none. */ |
| 9742 | 9633 | int lru; /* Least recently used entry has the smallest value */ |
| 9743 | 9634 | } aColCache[SQLITE_N_COLCACHE]; /* One for each column cache entry */ |
| @@ -10252,17 +10143,17 @@ | ||
| 10252 | 10143 | #endif |
| 10253 | 10144 | SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*); |
| 10254 | 10145 | SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int); |
| 10255 | 10146 | SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**, u16); |
| 10256 | 10147 | 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); | |
| 10258 | 10149 | SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int); |
| 10259 | 10150 | SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int); |
| 10260 | 10151 | SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int); |
| 10261 | 10152 | SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*); |
| 10262 | 10153 | SQLITE_PRIVATE void sqlite3ExprCachePop(Parse*, int); |
| 10263 | -SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int); | |
| 10154 | +SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse*, int, int); | |
| 10264 | 10155 | SQLITE_PRIVATE void sqlite3ExprCacheClear(Parse*); |
| 10265 | 10156 | SQLITE_PRIVATE void sqlite3ExprCacheAffinityChange(Parse*, int, int); |
| 10266 | 10157 | SQLITE_PRIVATE void sqlite3ExprHardCopy(Parse*,int,int); |
| 10267 | 10158 | SQLITE_PRIVATE int sqlite3ExprCode(Parse*, Expr*, int); |
| 10268 | 10159 | SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*); |
| @@ -48266,22 +48157,25 @@ | ||
| 48266 | 48157 | ** |
| 48267 | 48158 | ** When p->explain==1, each instruction is listed. When |
| 48268 | 48159 | ** p->explain==2, only OP_Explain instructions are listed and these |
| 48269 | 48160 | ** are shown in a different format. p->explain==2 is used to implement |
| 48270 | 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. | |
| 48271 | 48165 | */ |
| 48272 | 48166 | SQLITE_PRIVATE int sqlite3VdbeList( |
| 48273 | 48167 | Vdbe *p /* The VDBE */ |
| 48274 | 48168 | ){ |
| 48275 | - int nRow; /* Total number of rows to return */ | |
| 48169 | + int nRow; /* Stop when row count reaches this */ | |
| 48276 | 48170 | int nSub = 0; /* Number of sub-vdbes seen so far */ |
| 48277 | 48171 | 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 */ | |
| 48283 | 48177 | |
| 48284 | 48178 | assert( p->explain ); |
| 48285 | 48179 | assert( p->magic==VDBE_MAGIC_RUN ); |
| 48286 | 48180 | assert( db->magic==SQLITE_MAGIC_BUSY ); |
| 48287 | 48181 | assert( p->rc==SQLITE_OK || p->rc==SQLITE_BUSY || p->rc==SQLITE_NOMEM ); |
| @@ -48297,16 +48191,28 @@ | ||
| 48297 | 48191 | ** sqlite3_column_text16() failed. */ |
| 48298 | 48192 | db->mallocFailed = 1; |
| 48299 | 48193 | return SQLITE_ERROR; |
| 48300 | 48194 | } |
| 48301 | 48195 | |
| 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 | + */ | |
| 48304 | 48203 | nRow = p->nOp; |
| 48305 | 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 ); | |
| 48306 | 48210 | pSub = &p->aMem[9]; |
| 48307 | 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 */ | |
| 48308 | 48214 | nSub = pSub->n/sizeof(Vdbe*); |
| 48309 | 48215 | apSub = (SubProgram **)pSub->z; |
| 48310 | 48216 | } |
| 48311 | 48217 | for(i=0; i<nSub; i++){ |
| 48312 | 48218 | nRow += apSub[i]->nOp; |
| @@ -48325,12 +48231,16 @@ | ||
| 48325 | 48231 | sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3ErrStr(p->rc)); |
| 48326 | 48232 | }else{ |
| 48327 | 48233 | char *z; |
| 48328 | 48234 | Op *pOp; |
| 48329 | 48235 | if( i<p->nOp ){ |
| 48236 | + /* The output line number is small enough that we are still in the | |
| 48237 | + ** main program. */ | |
| 48330 | 48238 | pOp = &p->aOp[i]; |
| 48331 | 48239 | }else{ |
| 48240 | + /* We are currently listing subprograms. Figure out which one and | |
| 48241 | + ** pick up the appropriate opcode. */ | |
| 48332 | 48242 | int j; |
| 48333 | 48243 | i -= p->nOp; |
| 48334 | 48244 | for(j=0; i>=apSub[j]->nOp; j++){ |
| 48335 | 48245 | i -= apSub[j]->nOp; |
| 48336 | 48246 | } |
| @@ -48348,10 +48258,15 @@ | ||
| 48348 | 48258 | pMem->n = sqlite3Strlen30(pMem->z); |
| 48349 | 48259 | pMem->type = SQLITE_TEXT; |
| 48350 | 48260 | pMem->enc = SQLITE_UTF8; |
| 48351 | 48261 | pMem++; |
| 48352 | 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 | + */ | |
| 48353 | 48268 | if( pOp->p4type==P4_SUBPROGRAM ){ |
| 48354 | 48269 | int nByte = (nSub+1)*sizeof(SubProgram*); |
| 48355 | 48270 | int j; |
| 48356 | 48271 | for(j=0; j<nSub; j++){ |
| 48357 | 48272 | if( apSub[j]==pOp->p4.pProgram ) break; |
| @@ -48479,42 +48394,47 @@ | ||
| 48479 | 48394 | } |
| 48480 | 48395 | } |
| 48481 | 48396 | #endif /* !SQLITE_OMIT_TRACE && SQLITE_ENABLE_IOTRACE */ |
| 48482 | 48397 | |
| 48483 | 48398 | /* |
| 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. | |
| 48489 | 48408 | ** |
| 48490 | 48409 | ** nByte is the number of bytes of space needed. |
| 48491 | 48410 | ** |
| 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. | |
| 48494 | 48414 | ** |
| 48495 | 48415 | ** *pnByte is a counter of the number of bytes of space that have failed |
| 48496 | 48416 | ** to allocate. If there is insufficient space in *ppFrom to satisfy the |
| 48497 | 48417 | ** request, then increment *pnByte by the amount of the request. |
| 48498 | 48418 | */ |
| 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 */ | |
| 48501 | 48421 | int nByte, /* Number of bytes to allocate */ |
| 48502 | 48422 | u8 **ppFrom, /* IN/OUT: Allocate from *ppFrom */ |
| 48503 | 48423 | u8 *pEnd, /* Pointer to 1 byte past the end of *ppFrom buffer */ |
| 48504 | 48424 | int *pnByte /* If allocation cannot be made, increment *pnByte */ |
| 48505 | 48425 | ){ |
| 48506 | 48426 | 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; | |
| 48516 | 48436 | } |
| 48517 | 48437 | |
| 48518 | 48438 | /* |
| 48519 | 48439 | ** Prepare a virtual machine for execution. This involves things such |
| 48520 | 48440 | ** as allocating stack space and initializing the program counter. |
| @@ -48569,31 +48489,41 @@ | ||
| 48569 | 48489 | ** an array to marshal SQL function arguments in. This is only done the |
| 48570 | 48490 | ** first time this function is called for a given VDBE, not when it is |
| 48571 | 48491 | ** being called from sqlite3_reset() to reset the virtual machine. |
| 48572 | 48492 | */ |
| 48573 | 48493 | 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 | + | |
| 48577 | 48498 | resolveP2Values(p, &nArg); |
| 48578 | 48499 | p->usesStmtJournal = (u8)usesStmtJournal; |
| 48579 | 48500 | if( isExplain && nMem<10 ){ |
| 48580 | 48501 | nMem = 10; |
| 48581 | 48502 | } |
| 48582 | 48503 | memset(zCsr, 0, zEnd-zCsr); |
| 48583 | 48504 | zCsr += (zCsr - (u8*)0)&7; |
| 48584 | 48505 | assert( EIGHT_BYTE_ALIGNMENT(zCsr) ); |
| 48585 | 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 | + */ | |
| 48586 | 48517 | do { |
| 48587 | 48518 | 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); | |
| 48595 | 48525 | if( nByte ){ |
| 48596 | 48526 | p->pFree = sqlite3DbMallocZero(db, nByte); |
| 48597 | 48527 | } |
| 48598 | 48528 | zCsr = p->pFree; |
| 48599 | 48529 | zEnd = &zCsr[nByte]; |
| @@ -48931,14 +48861,15 @@ | ||
| 48931 | 48861 | ** still have 'null' as the master journal pointer, so they will roll |
| 48932 | 48862 | ** back independently if a failure occurs. |
| 48933 | 48863 | */ |
| 48934 | 48864 | for(i=0; i<db->nDb; i++){ |
| 48935 | 48865 | Btree *pBt = db->aDb[i].pBt; |
| 48936 | - if( i==1 ) continue; /* Ignore the TEMP database */ | |
| 48937 | 48866 | if( sqlite3BtreeIsInTrans(pBt) ){ |
| 48938 | 48867 | 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 | + } | |
| 48940 | 48871 | if( !needSync && !sqlite3BtreeSyncDisabled(pBt) ){ |
| 48941 | 48872 | needSync = 1; |
| 48942 | 48873 | } |
| 48943 | 48874 | rc = sqlite3OsWrite(pMaster, zFile, sqlite3Strlen30(zFile)+1, offset); |
| 48944 | 48875 | offset += sqlite3Strlen30(zFile)+1; |
| @@ -50780,12 +50711,13 @@ | ||
| 50780 | 50711 | SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){ |
| 50781 | 50712 | Mem *pMem; |
| 50782 | 50713 | assert( p && p->pFunc && p->pFunc->xStep ); |
| 50783 | 50714 | assert( sqlite3_mutex_held(p->s.db->mutex) ); |
| 50784 | 50715 | pMem = p->pMem; |
| 50716 | + testcase( nByte<0 ); | |
| 50785 | 50717 | if( (pMem->flags & MEM_Agg)==0 ){ |
| 50786 | - if( nByte==0 ){ | |
| 50718 | + if( nByte<=0 ){ | |
| 50787 | 50719 | sqlite3VdbeMemReleaseExternal(pMem); |
| 50788 | 50720 | pMem->flags = MEM_Null; |
| 50789 | 50721 | pMem->z = 0; |
| 50790 | 50722 | }else{ |
| 50791 | 50723 | sqlite3VdbeMemGrow(pMem, nByte, 0); |
| @@ -55878,19 +55810,19 @@ | ||
| 55878 | 55810 | rc = sqlite3BtreeLast(u.be.pC->pCursor, &u.be.res); |
| 55879 | 55811 | if( rc!=SQLITE_OK ){ |
| 55880 | 55812 | goto abort_due_to_error; |
| 55881 | 55813 | } |
| 55882 | 55814 | if( u.be.res ){ |
| 55883 | - u.be.v = 1; | |
| 55815 | + u.be.v = 1; /* IMP: R-61914-48074 */ | |
| 55884 | 55816 | }else{ |
| 55885 | 55817 | assert( sqlite3BtreeCursorIsValid(u.be.pC->pCursor) ); |
| 55886 | 55818 | rc = sqlite3BtreeKeySize(u.be.pC->pCursor, &u.be.v); |
| 55887 | 55819 | assert( rc==SQLITE_OK ); /* Cannot fail following BtreeLast() */ |
| 55888 | 55820 | if( u.be.v==MAX_ROWID ){ |
| 55889 | 55821 | u.be.pC->useRandomRowid = 1; |
| 55890 | 55822 | }else{ |
| 55891 | - u.be.v++; | |
| 55823 | + u.be.v++; /* IMP: R-29538-34987 */ | |
| 55892 | 55824 | } |
| 55893 | 55825 | } |
| 55894 | 55826 | } |
| 55895 | 55827 | |
| 55896 | 55828 | #ifndef SQLITE_OMIT_AUTOINCREMENT |
| @@ -55910,11 +55842,11 @@ | ||
| 55910 | 55842 | |
| 55911 | 55843 | REGISTER_TRACE(pOp->p3, u.be.pMem); |
| 55912 | 55844 | sqlite3VdbeMemIntegerify(u.be.pMem); |
| 55913 | 55845 | assert( (u.be.pMem->flags & MEM_Int)!=0 ); /* mem(P3) holds an integer */ |
| 55914 | 55846 | if( u.be.pMem->u.i==MAX_ROWID || u.be.pC->useRandomRowid ){ |
| 55915 | - rc = SQLITE_FULL; | |
| 55847 | + rc = SQLITE_FULL; /* IMP: R-12275-61338 */ | |
| 55916 | 55848 | goto abort_due_to_error; |
| 55917 | 55849 | } |
| 55918 | 55850 | if( u.be.v<u.be.pMem->u.i+1 ){ |
| 55919 | 55851 | u.be.v = u.be.pMem->u.i + 1; |
| 55920 | 55852 | } |
| @@ -55923,10 +55855,15 @@ | ||
| 55923 | 55855 | #endif |
| 55924 | 55856 | |
| 55925 | 55857 | sqlite3BtreeSetCachedRowid(u.be.pC->pCursor, u.be.v<MAX_ROWID ? u.be.v+1 : 0); |
| 55926 | 55858 | } |
| 55927 | 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 | + */ | |
| 55928 | 55865 | assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is |
| 55929 | 55866 | ** an AUTOINCREMENT table. */ |
| 55930 | 55867 | u.be.v = db->lastRowid; |
| 55931 | 55868 | u.be.cnt = 0; |
| 55932 | 55869 | do{ |
| @@ -55938,11 +55875,11 @@ | ||
| 55938 | 55875 | } |
| 55939 | 55876 | rc = sqlite3BtreeMovetoUnpacked(u.be.pC->pCursor, 0, (u64)u.be.v, 0, &u.be.res); |
| 55940 | 55877 | u.be.cnt++; |
| 55941 | 55878 | }while( u.be.cnt<100 && rc==SQLITE_OK && u.be.res==0 ); |
| 55942 | 55879 | if( rc==SQLITE_OK && u.be.res==0 ){ |
| 55943 | - rc = SQLITE_FULL; | |
| 55880 | + rc = SQLITE_FULL; /* IMP: R-38219-53002 */ | |
| 55944 | 55881 | goto abort_due_to_error; |
| 55945 | 55882 | } |
| 55946 | 55883 | } |
| 55947 | 55884 | u.be.pC->rowidIsValid = 0; |
| 55948 | 55885 | u.be.pC->deferredMoveto = 0; |
| @@ -59317,22 +59254,21 @@ | ||
| 59317 | 59254 | |
| 59318 | 59255 | if( pTab ){ |
| 59319 | 59256 | int iCol; |
| 59320 | 59257 | pSchema = pTab->pSchema; |
| 59321 | 59258 | 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 */ | |
| 59334 | 59270 | } |
| 59335 | 59271 | if( iCol<pTab->nCol ){ |
| 59336 | 59272 | cnt++; |
| 59337 | 59273 | if( iCol<0 ){ |
| 59338 | 59274 | pExpr->affinity = SQLITE_AFF_INTEGER; |
| @@ -59356,11 +59292,11 @@ | ||
| 59356 | 59292 | /* |
| 59357 | 59293 | ** Perhaps the name is a reference to the ROWID |
| 59358 | 59294 | */ |
| 59359 | 59295 | if( cnt==0 && cntTab==1 && sqlite3IsRowid(zCol) ){ |
| 59360 | 59296 | cnt = 1; |
| 59361 | - pExpr->iColumn = -1; | |
| 59297 | + pExpr->iColumn = -1; /* IMP: R-44911-55124 */ | |
| 59362 | 59298 | pExpr->affinity = SQLITE_AFF_INTEGER; |
| 59363 | 59299 | } |
| 59364 | 59300 | |
| 59365 | 59301 | /* |
| 59366 | 59302 | ** If the input is of the form Z (not Y.Z or X.Y.Z) then the name Z |
| @@ -60500,34 +60436,10 @@ | ||
| 60500 | 60436 | } |
| 60501 | 60437 | } |
| 60502 | 60438 | return pColl; |
| 60503 | 60439 | } |
| 60504 | 60440 | |
| 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 | 60441 | /* |
| 60530 | 60442 | ** Generate code for a comparison operator. |
| 60531 | 60443 | */ |
| 60532 | 60444 | static int codeCompare( |
| 60533 | 60445 | Parse *pParse, /* The parsing (and code generating) context */ |
| @@ -62255,30 +62167,43 @@ | ||
| 62255 | 62167 | struct yColCache *p; |
| 62256 | 62168 | |
| 62257 | 62169 | assert( iReg>0 ); /* Register numbers are always positive */ |
| 62258 | 62170 | assert( iCol>=-1 && iCol<32768 ); /* Finite column numbers */ |
| 62259 | 62171 | |
| 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 | |
| 62261 | 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 */ | |
| 62262 | 62186 | if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){ |
| 62263 | 62187 | cacheEntryClear(pParse, p); |
| 62264 | 62188 | p->iLevel = pParse->iCacheLevel; |
| 62265 | 62189 | p->iReg = iReg; |
| 62266 | - p->affChange = 0; | |
| 62267 | 62190 | p->lru = pParse->iCacheCnt++; |
| 62268 | 62191 | return; |
| 62269 | 62192 | } |
| 62193 | +#endif | |
| 62194 | + assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol ); | |
| 62270 | 62195 | } |
| 62196 | +#endif | |
| 62271 | 62197 | |
| 62272 | 62198 | /* Find an empty slot and replace it */ |
| 62273 | 62199 | for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 62274 | 62200 | if( p->iReg==0 ){ |
| 62275 | 62201 | p->iLevel = pParse->iCacheLevel; |
| 62276 | 62202 | p->iTable = iTab; |
| 62277 | 62203 | p->iColumn = iCol; |
| 62278 | 62204 | p->iReg = iReg; |
| 62279 | - p->affChange = 0; | |
| 62280 | 62205 | p->tempReg = 0; |
| 62281 | 62206 | p->lru = pParse->iCacheCnt++; |
| 62282 | 62207 | return; |
| 62283 | 62208 | } |
| 62284 | 62209 | } |
| @@ -62296,26 +62221,27 @@ | ||
| 62296 | 62221 | p = &pParse->aColCache[idxLru]; |
| 62297 | 62222 | p->iLevel = pParse->iCacheLevel; |
| 62298 | 62223 | p->iTable = iTab; |
| 62299 | 62224 | p->iColumn = iCol; |
| 62300 | 62225 | p->iReg = iReg; |
| 62301 | - p->affChange = 0; | |
| 62302 | 62226 | p->tempReg = 0; |
| 62303 | 62227 | p->lru = pParse->iCacheCnt++; |
| 62304 | 62228 | return; |
| 62305 | 62229 | } |
| 62306 | 62230 | } |
| 62307 | 62231 | |
| 62308 | 62232 | /* |
| 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. | |
| 62311 | 62235 | */ |
| 62312 | -SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg){ | |
| 62236 | +SQLITE_PRIVATE void sqlite3ExprCacheRemove(Parse *pParse, int iReg, int nReg){ | |
| 62313 | 62237 | int i; |
| 62238 | + int iLast = iReg + nReg - 1; | |
| 62314 | 62239 | struct yColCache *p; |
| 62315 | 62240 | 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 ){ | |
| 62317 | 62243 | cacheEntryClear(pParse, p); |
| 62318 | 62244 | p->iReg = 0; |
| 62319 | 62245 | } |
| 62320 | 62246 | } |
| 62321 | 62247 | } |
| @@ -62370,32 +62296,24 @@ | ||
| 62370 | 62296 | ** is made to store the column value in register iReg, but this is |
| 62371 | 62297 | ** not guaranteed. The location of the column value is returned. |
| 62372 | 62298 | ** |
| 62373 | 62299 | ** There must be an open cursor to pTab in iTable when this routine |
| 62374 | 62300 | ** 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 | 62301 | */ |
| 62382 | 62302 | SQLITE_PRIVATE int sqlite3ExprCodeGetColumn( |
| 62383 | 62303 | Parse *pParse, /* Parsing and code generating context */ |
| 62384 | 62304 | Table *pTab, /* Description of the table we are reading from */ |
| 62385 | 62305 | int iColumn, /* Index of the table column */ |
| 62386 | 62306 | 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 */ | |
| 62389 | 62308 | ){ |
| 62390 | 62309 | Vdbe *v = pParse->pVdbe; |
| 62391 | 62310 | int i; |
| 62392 | 62311 | struct yColCache *p; |
| 62393 | 62312 | |
| 62394 | 62313 | 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 ){ | |
| 62397 | 62315 | p->lru = pParse->iCacheCnt++; |
| 62398 | 62316 | sqlite3ExprCachePinRegister(pParse, p->iReg); |
| 62399 | 62317 | return p->iReg; |
| 62400 | 62318 | } |
| 62401 | 62319 | } |
| @@ -62429,19 +62347,11 @@ | ||
| 62429 | 62347 | /* |
| 62430 | 62348 | ** Record the fact that an affinity change has occurred on iCount |
| 62431 | 62349 | ** registers starting with iStart. |
| 62432 | 62350 | */ |
| 62433 | 62351 | 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); | |
| 62443 | 62353 | } |
| 62444 | 62354 | |
| 62445 | 62355 | /* |
| 62446 | 62356 | ** Generate code to move content from registers iFrom...iFrom+nReg-1 |
| 62447 | 62357 | ** over to iTo..iTo+nReg-1. Keep the column cache up-to-date. |
| @@ -62469,23 +62379,28 @@ | ||
| 62469 | 62379 | for(i=0; i<nReg; i++){ |
| 62470 | 62380 | sqlite3VdbeAddOp2(pParse->pVdbe, OP_Copy, iFrom+i, iTo+i); |
| 62471 | 62381 | } |
| 62472 | 62382 | } |
| 62473 | 62383 | |
| 62384 | +#if defined(SQLITE_DEBUG) || defined(SQLITE_COVERAGE_TEST) | |
| 62474 | 62385 | /* |
| 62475 | 62386 | ** Return true if any register in the range iFrom..iTo (inclusive) |
| 62476 | 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. | |
| 62477 | 62391 | */ |
| 62478 | 62392 | static int usedAsColumnCache(Parse *pParse, int iFrom, int iTo){ |
| 62479 | 62393 | int i; |
| 62480 | 62394 | struct yColCache *p; |
| 62481 | 62395 | for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){ |
| 62482 | 62396 | int r = p->iReg; |
| 62483 | - if( r>=iFrom && r<=iTo ) return 1; | |
| 62397 | + if( r>=iFrom && r<=iTo ) return 1; /*NO_TEST*/ | |
| 62484 | 62398 | } |
| 62485 | 62399 | return 0; |
| 62486 | 62400 | } |
| 62401 | +#endif /* SQLITE_DEBUG || SQLITE_COVERAGE_TEST */ | |
| 62487 | 62402 | |
| 62488 | 62403 | /* |
| 62489 | 62404 | ** If the last instruction coded is an ephemeral copy of any of |
| 62490 | 62405 | ** the registers in the nReg registers beginning with iReg, then |
| 62491 | 62406 | ** convert the last instruction from OP_SCopy to OP_Copy. |
| @@ -62602,14 +62517,12 @@ | ||
| 62602 | 62517 | if( pExpr->iTable<0 ){ |
| 62603 | 62518 | /* This only happens when coding check constraints */ |
| 62604 | 62519 | assert( pParse->ckBase>0 ); |
| 62605 | 62520 | inReg = pExpr->iColumn + pParse->ckBase; |
| 62606 | 62521 | }else{ |
| 62607 | - testcase( (pExpr->flags & EP_AnyAff)!=0 ); | |
| 62608 | 62522 | inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab, |
| 62609 | - pExpr->iColumn, pExpr->iTable, target, | |
| 62610 | - pExpr->flags & EP_AnyAff); | |
| 62523 | + pExpr->iColumn, pExpr->iTable, target); | |
| 62611 | 62524 | } |
| 62612 | 62525 | break; |
| 62613 | 62526 | } |
| 62614 | 62527 | case TK_INTEGER: { |
| 62615 | 62528 | codeInteger(v, pExpr, 0, target); |
| @@ -62722,12 +62635,12 @@ | ||
| 62722 | 62635 | testcase( op==TK_LE ); |
| 62723 | 62636 | testcase( op==TK_GT ); |
| 62724 | 62637 | testcase( op==TK_GE ); |
| 62725 | 62638 | testcase( op==TK_EQ ); |
| 62726 | 62639 | testcase( op==TK_NE ); |
| 62727 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 62728 | - pExpr->pRight, &r2, ®Free2); | |
| 62640 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 62641 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 62729 | 62642 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 62730 | 62643 | r1, r2, inReg, SQLITE_STOREP2); |
| 62731 | 62644 | testcase( regFree1==0 ); |
| 62732 | 62645 | testcase( regFree2==0 ); |
| 62733 | 62646 | break; |
| @@ -62734,12 +62647,12 @@ | ||
| 62734 | 62647 | } |
| 62735 | 62648 | case TK_IS: |
| 62736 | 62649 | case TK_ISNOT: { |
| 62737 | 62650 | testcase( op==TK_IS ); |
| 62738 | 62651 | testcase( op==TK_ISNOT ); |
| 62739 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 62740 | - pExpr->pRight, &r2, ®Free2); | |
| 62652 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 62653 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 62741 | 62654 | op = (op==TK_IS) ? TK_EQ : TK_NE; |
| 62742 | 62655 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 62743 | 62656 | r1, r2, inReg, SQLITE_STOREP2 | SQLITE_NULLEQ); |
| 62744 | 62657 | testcase( regFree1==0 ); |
| 62745 | 62658 | testcase( regFree2==0 ); |
| @@ -62879,11 +62792,11 @@ | ||
| 62879 | 62792 | int endCoalesce = sqlite3VdbeMakeLabel(v); |
| 62880 | 62793 | assert( nFarg>=2 ); |
| 62881 | 62794 | sqlite3ExprCode(pParse, pFarg->a[0].pExpr, target); |
| 62882 | 62795 | for(i=1; i<nFarg; i++){ |
| 62883 | 62796 | sqlite3VdbeAddOp2(v, OP_NotNull, target, endCoalesce); |
| 62884 | - sqlite3ExprCacheRemove(pParse, target); | |
| 62797 | + sqlite3ExprCacheRemove(pParse, target, 1); | |
| 62885 | 62798 | sqlite3ExprCachePush(pParse); |
| 62886 | 62799 | sqlite3ExprCode(pParse, pFarg->a[i].pExpr, target); |
| 62887 | 62800 | sqlite3ExprCachePop(pParse, 1); |
| 62888 | 62801 | } |
| 62889 | 62802 | sqlite3VdbeResolveLabel(v, endCoalesce); |
| @@ -62934,11 +62847,10 @@ | ||
| 62934 | 62847 | (char*)pDef, P4_FUNCDEF); |
| 62935 | 62848 | sqlite3VdbeChangeP5(v, (u8)nFarg); |
| 62936 | 62849 | if( nFarg ){ |
| 62937 | 62850 | sqlite3ReleaseTempRange(pParse, r1, nFarg); |
| 62938 | 62851 | } |
| 62939 | - sqlite3ExprCacheAffinityChange(pParse, r1, nFarg); | |
| 62940 | 62852 | break; |
| 62941 | 62853 | } |
| 62942 | 62854 | #ifndef SQLITE_OMIT_SUBQUERY |
| 62943 | 62855 | case TK_EXISTS: |
| 62944 | 62856 | case TK_SELECT: { |
| @@ -62975,12 +62887,12 @@ | ||
| 62975 | 62887 | case TK_BETWEEN: { |
| 62976 | 62888 | Expr *pLeft = pExpr->pLeft; |
| 62977 | 62889 | struct ExprList_item *pLItem = pExpr->x.pList->a; |
| 62978 | 62890 | Expr *pRight = pLItem->pExpr; |
| 62979 | 62891 | |
| 62980 | - codeCompareOperands(pParse, pLeft, &r1, ®Free1, | |
| 62981 | - pRight, &r2, ®Free2); | |
| 62892 | + r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); | |
| 62893 | + r2 = sqlite3ExprCodeTemp(pParse, pRight, ®Free2); | |
| 62982 | 62894 | testcase( regFree1==0 ); |
| 62983 | 62895 | testcase( regFree2==0 ); |
| 62984 | 62896 | r3 = sqlite3GetTempReg(pParse); |
| 62985 | 62897 | r4 = sqlite3GetTempReg(pParse); |
| 62986 | 62898 | codeCompare(pParse, pLeft, pRight, OP_Ge, |
| @@ -63511,12 +63423,12 @@ | ||
| 63511 | 63423 | testcase( op==TK_GT ); |
| 63512 | 63424 | testcase( op==TK_GE ); |
| 63513 | 63425 | testcase( op==TK_EQ ); |
| 63514 | 63426 | testcase( op==TK_NE ); |
| 63515 | 63427 | testcase( jumpIfNull==0 ); |
| 63516 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 63517 | - pExpr->pRight, &r2, ®Free2); | |
| 63428 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 63429 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 63518 | 63430 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 63519 | 63431 | r1, r2, dest, jumpIfNull); |
| 63520 | 63432 | testcase( regFree1==0 ); |
| 63521 | 63433 | testcase( regFree2==0 ); |
| 63522 | 63434 | break; |
| @@ -63523,12 +63435,12 @@ | ||
| 63523 | 63435 | } |
| 63524 | 63436 | case TK_IS: |
| 63525 | 63437 | case TK_ISNOT: { |
| 63526 | 63438 | testcase( op==TK_IS ); |
| 63527 | 63439 | testcase( op==TK_ISNOT ); |
| 63528 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 63529 | - pExpr->pRight, &r2, ®Free2); | |
| 63440 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 63441 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 63530 | 63442 | op = (op==TK_IS) ? TK_EQ : TK_NE; |
| 63531 | 63443 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 63532 | 63444 | r1, r2, dest, SQLITE_NULLEQ); |
| 63533 | 63445 | testcase( regFree1==0 ); |
| 63534 | 63446 | testcase( regFree2==0 ); |
| @@ -63654,12 +63566,12 @@ | ||
| 63654 | 63566 | testcase( op==TK_GT ); |
| 63655 | 63567 | testcase( op==TK_GE ); |
| 63656 | 63568 | testcase( op==TK_EQ ); |
| 63657 | 63569 | testcase( op==TK_NE ); |
| 63658 | 63570 | testcase( jumpIfNull==0 ); |
| 63659 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 63660 | - pExpr->pRight, &r2, ®Free2); | |
| 63571 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 63572 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 63661 | 63573 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 63662 | 63574 | r1, r2, dest, jumpIfNull); |
| 63663 | 63575 | testcase( regFree1==0 ); |
| 63664 | 63576 | testcase( regFree2==0 ); |
| 63665 | 63577 | break; |
| @@ -63666,12 +63578,12 @@ | ||
| 63666 | 63578 | } |
| 63667 | 63579 | case TK_IS: |
| 63668 | 63580 | case TK_ISNOT: { |
| 63669 | 63581 | testcase( pExpr->op==TK_IS ); |
| 63670 | 63582 | testcase( pExpr->op==TK_ISNOT ); |
| 63671 | - codeCompareOperands(pParse, pExpr->pLeft, &r1, ®Free1, | |
| 63672 | - pExpr->pRight, &r2, ®Free2); | |
| 63583 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 63584 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 63673 | 63585 | op = (pExpr->op==TK_IS) ? TK_NE : TK_EQ; |
| 63674 | 63586 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 63675 | 63587 | r1, r2, dest, SQLITE_NULLEQ); |
| 63676 | 63588 | testcase( regFree1==0 ); |
| 63677 | 63589 | testcase( regFree2==0 ); |
| @@ -64014,20 +63926,22 @@ | ||
| 64014 | 63926 | */ |
| 64015 | 63927 | SQLITE_PRIVATE int sqlite3GetTempRange(Parse *pParse, int nReg){ |
| 64016 | 63928 | int i, n; |
| 64017 | 63929 | i = pParse->iRangeReg; |
| 64018 | 63930 | 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) ); | |
| 64020 | 63933 | pParse->iRangeReg += nReg; |
| 64021 | 63934 | pParse->nRangeReg -= nReg; |
| 64022 | 63935 | }else{ |
| 64023 | 63936 | i = pParse->nMem+1; |
| 64024 | 63937 | pParse->nMem += nReg; |
| 64025 | 63938 | } |
| 64026 | 63939 | return i; |
| 64027 | 63940 | } |
| 64028 | 63941 | SQLITE_PRIVATE void sqlite3ReleaseTempRange(Parse *pParse, int iReg, int nReg){ |
| 63942 | + sqlite3ExprCacheRemove(pParse, iReg, nReg); | |
| 64029 | 63943 | if( nReg>pParse->nRangeReg ){ |
| 64030 | 63944 | pParse->nRangeReg = nReg; |
| 64031 | 63945 | pParse->iRangeReg = iReg; |
| 64032 | 63946 | } |
| 64033 | 63947 | } |
| @@ -66818,11 +66732,12 @@ | ||
| 66818 | 66732 | Table *p; |
| 66819 | 66733 | Db *pDb; |
| 66820 | 66734 | |
| 66821 | 66735 | assert( db!=0 ); |
| 66822 | 66736 | 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 */ | |
| 66824 | 66739 | pDb = &db->aDb[iDb]; |
| 66825 | 66740 | p = sqlite3HashInsert(&pDb->pSchema->tblHash, zTabName, |
| 66826 | 66741 | sqlite3Strlen30(zTabName),0); |
| 66827 | 66742 | sqlite3DeleteTable(p); |
| 66828 | 66743 | db->flags |= SQLITE_InternChanges; |
| @@ -69685,11 +69600,10 @@ | ||
| 69685 | 69600 | sqlite3ErrorMsg(pParse, "unable to open a temporary database " |
| 69686 | 69601 | "file for storing temporary tables"); |
| 69687 | 69602 | pParse->rc = rc; |
| 69688 | 69603 | return 1; |
| 69689 | 69604 | } |
| 69690 | - assert( (db->flags & SQLITE_InTrans)==0 || db->autoCommit ); | |
| 69691 | 69605 | assert( db->aDb[1].pSchema ); |
| 69692 | 69606 | sqlite3PagerJournalMode(sqlite3BtreePager(db->aDb[1].pBt), |
| 69693 | 69607 | db->dfltJournalMode); |
| 69694 | 69608 | } |
| 69695 | 69609 | return 0; |
| @@ -70791,11 +70705,11 @@ | ||
| 70791 | 70705 | /* Collect rowids of every row to be deleted. |
| 70792 | 70706 | */ |
| 70793 | 70707 | sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet); |
| 70794 | 70708 | pWInfo = sqlite3WhereBegin(pParse, pTabList, pWhere,0,WHERE_DUPLICATES_OK); |
| 70795 | 70709 | if( pWInfo==0 ) goto delete_from_cleanup; |
| 70796 | - regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0); | |
| 70710 | + regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid); | |
| 70797 | 70711 | sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid); |
| 70798 | 70712 | if( db->flags & SQLITE_CountRows ){ |
| 70799 | 70713 | sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1); |
| 70800 | 70714 | } |
| 70801 | 70715 | sqlite3WhereEnd(pWInfo); |
| @@ -71057,11 +70971,10 @@ | ||
| 71057 | 70971 | } |
| 71058 | 70972 | } |
| 71059 | 70973 | if( doMakeRec ){ |
| 71060 | 70974 | sqlite3VdbeAddOp3(v, OP_MakeRecord, regBase, nCol+1, regOut); |
| 71061 | 70975 | sqlite3VdbeChangeP4(v, -1, sqlite3IndexAffinityStr(v, pIdx), 0); |
| 71062 | - sqlite3ExprCacheAffinityChange(pParse, regBase, nCol+1); | |
| 71063 | 70976 | } |
| 71064 | 70977 | sqlite3ReleaseTempRange(pParse, regBase, nCol+1); |
| 71065 | 70978 | return regBase; |
| 71066 | 70979 | } |
| 71067 | 70980 | |
| @@ -71180,33 +71093,45 @@ | ||
| 71180 | 71093 | } |
| 71181 | 71094 | } |
| 71182 | 71095 | } |
| 71183 | 71096 | |
| 71184 | 71097 | /* |
| 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. | |
| 71186 | 71102 | */ |
| 71187 | 71103 | static void absFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ |
| 71188 | 71104 | assert( argc==1 ); |
| 71189 | 71105 | UNUSED_PARAMETER(argc); |
| 71190 | 71106 | switch( sqlite3_value_type(argv[0]) ){ |
| 71191 | 71107 | case SQLITE_INTEGER: { |
| 71192 | 71108 | i64 iVal = sqlite3_value_int64(argv[0]); |
| 71193 | 71109 | if( iVal<0 ){ |
| 71194 | 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. */ | |
| 71195 | 71114 | sqlite3_result_error(context, "integer overflow", -1); |
| 71196 | 71115 | return; |
| 71197 | 71116 | } |
| 71198 | 71117 | iVal = -iVal; |
| 71199 | 71118 | } |
| 71200 | 71119 | sqlite3_result_int64(context, iVal); |
| 71201 | 71120 | break; |
| 71202 | 71121 | } |
| 71203 | 71122 | case SQLITE_NULL: { |
| 71123 | + /* IMP: R-37434-19929 Abs(X) returns NULL if X is NULL. */ | |
| 71204 | 71124 | sqlite3_result_null(context); |
| 71205 | 71125 | break; |
| 71206 | 71126 | } |
| 71207 | 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 | + */ | |
| 71208 | 71133 | double rVal = sqlite3_value_double(argv[0]); |
| 71209 | 71134 | if( rVal<0 ) rVal = -rVal; |
| 71210 | 71135 | sqlite3_result_double(context, rVal); |
| 71211 | 71136 | break; |
| 71212 | 71137 | } |
| @@ -72104,13 +72029,20 @@ | ||
| 72104 | 72029 | } |
| 72105 | 72030 | sqlite3_result_text(context, (char*)zIn, nIn, SQLITE_TRANSIENT); |
| 72106 | 72031 | } |
| 72107 | 72032 | |
| 72108 | 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 | +*/ | |
| 72109 | 72038 | #ifdef SQLITE_SOUNDEX |
| 72110 | 72039 | /* |
| 72111 | 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. | |
| 72112 | 72044 | */ |
| 72113 | 72045 | static void soundexFunc( |
| 72114 | 72046 | sqlite3_context *context, |
| 72115 | 72047 | int argc, |
| 72116 | 72048 | sqlite3_value **argv |
| @@ -72150,14 +72082,16 @@ | ||
| 72150 | 72082 | zResult[j++] = '0'; |
| 72151 | 72083 | } |
| 72152 | 72084 | zResult[j] = 0; |
| 72153 | 72085 | sqlite3_result_text(context, zResult, 4, SQLITE_TRANSIENT); |
| 72154 | 72086 | }else{ |
| 72087 | + /* IMP: R-64894-50321 The string "?000" is returned if the argument | |
| 72088 | + ** is NULL or contains no ASCII alphabetic characters. */ | |
| 72155 | 72089 | sqlite3_result_text(context, "?000", 4, SQLITE_STATIC); |
| 72156 | 72090 | } |
| 72157 | 72091 | } |
| 72158 | -#endif | |
| 72092 | +#endif /* SQLITE_SOUNDEX */ | |
| 72159 | 72093 | |
| 72160 | 72094 | #ifndef SQLITE_OMIT_LOAD_EXTENSION |
| 72161 | 72095 | /* |
| 72162 | 72096 | ** A function that loads a shared-library extension then returns NULL. |
| 72163 | 72097 | */ |
| @@ -78623,11 +78557,11 @@ | ||
| 78623 | 78557 | if( rc!=SQLITE_OK ) return; |
| 78624 | 78558 | openedTransaction = 1; |
| 78625 | 78559 | } |
| 78626 | 78560 | |
| 78627 | 78561 | /* 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, | |
| 78629 | 78563 | ** set Parse.rc to SQLITE_SCHEMA. */ |
| 78630 | 78564 | sqlite3BtreeGetMeta(pBt, BTREE_SCHEMA_VERSION, (u32 *)&cookie); |
| 78631 | 78565 | if( cookie!=db->aDb[iDb].pSchema->schema_cookie ){ |
| 78632 | 78566 | pParse->rc = SQLITE_SCHEMA; |
| 78633 | 78567 | } |
| @@ -79215,10 +79149,43 @@ | ||
| 79215 | 79149 | for(i=0; i<pTab->nCol; i++){ |
| 79216 | 79150 | if( sqlite3StrICmp(pTab->aCol[i].zName, zCol)==0 ) return i; |
| 79217 | 79151 | } |
| 79218 | 79152 | return -1; |
| 79219 | 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 | +} | |
| 79220 | 79187 | |
| 79221 | 79188 | /* |
| 79222 | 79189 | ** This function is used to add terms implied by JOIN syntax to the |
| 79223 | 79190 | ** WHERE clause expression of a SELECT statement. The new term, which |
| 79224 | 79191 | ** is ANDed with the existing WHERE clause, is of the form: |
| @@ -79230,27 +79197,29 @@ | ||
| 79230 | 79197 | ** column iColRight of tab2. |
| 79231 | 79198 | */ |
| 79232 | 79199 | static void addWhereTerm( |
| 79233 | 79200 | Parse *pParse, /* Parsing context */ |
| 79234 | 79201 | 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 */ | |
| 79236 | 79203 | int iColLeft, /* Index of column in first table */ |
| 79204 | + int iRight, /* Index of second table in pSrc */ | |
| 79237 | 79205 | int iColRight, /* Index of column in second table */ |
| 79238 | 79206 | int isOuterJoin, /* True if this is an OUTER join */ |
| 79239 | 79207 | Expr **ppWhere /* IN/OUT: The WHERE clause to add to */ |
| 79240 | 79208 | ){ |
| 79241 | 79209 | sqlite3 *db = pParse->db; |
| 79242 | 79210 | Expr *pE1; |
| 79243 | 79211 | Expr *pE2; |
| 79244 | 79212 | Expr *pEq; |
| 79245 | 79213 | |
| 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 ); | |
| 79249 | 79218 | |
| 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); | |
| 79252 | 79221 | |
| 79253 | 79222 | pEq = sqlite3PExpr(pParse, TK_EQ, pE1, pE2, 0); |
| 79254 | 79223 | if( pEq && isOuterJoin ){ |
| 79255 | 79224 | ExprSetProperty(pEq, EP_FromJoin); |
| 79256 | 79225 | assert( !ExprHasAnyProperty(pEq, EP_TokenOnly|EP_Reduced) ); |
| @@ -79335,15 +79304,19 @@ | ||
| 79335 | 79304 | if( pRight->pOn || pRight->pUsing ){ |
| 79336 | 79305 | sqlite3ErrorMsg(pParse, "a NATURAL join may not have " |
| 79337 | 79306 | "an ON or USING clause", 0); |
| 79338 | 79307 | return 1; |
| 79339 | 79308 | } |
| 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); | |
| 79345 | 79318 | } |
| 79346 | 79319 | } |
| 79347 | 79320 | } |
| 79348 | 79321 | |
| 79349 | 79322 | /* Disallow both ON and USING clauses in the same join |
| @@ -79371,19 +79344,26 @@ | ||
| 79371 | 79344 | ** not contained in both tables to be joined. |
| 79372 | 79345 | */ |
| 79373 | 79346 | if( pRight->pUsing ){ |
| 79374 | 79347 | IdList *pList = pRight->pUsing; |
| 79375 | 79348 | 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 | + ){ | |
| 79380 | 79359 | sqlite3ErrorMsg(pParse, "cannot join using column %s - column " |
| 79381 | 79360 | "not present in both tables", zName); |
| 79382 | 79361 | return 1; |
| 79383 | 79362 | } |
| 79384 | - addWhereTerm(pParse, pSrc, i, iLeftCol, iRightCol, isOuter, &p->pWhere); | |
| 79363 | + addWhereTerm(pParse, pSrc, iLeft, iLeftCol, i+1, iRightCol, | |
| 79364 | + isOuter, &p->pWhere); | |
| 79385 | 79365 | } |
| 79386 | 79366 | } |
| 79387 | 79367 | } |
| 79388 | 79368 | return 0; |
| 79389 | 79369 | } |
| @@ -79938,11 +79918,11 @@ | ||
| 79938 | 79918 | if( pS ){ |
| 79939 | 79919 | /* The "table" is actually a sub-select or a view in the FROM clause |
| 79940 | 79920 | ** of the SELECT statement. Return the declaration type and origin |
| 79941 | 79921 | ** data for the result-set column of the sub-select. |
| 79942 | 79922 | */ |
| 79943 | - if( ALWAYS(iCol>=0 && iCol<pS->pEList->nExpr) ){ | |
| 79923 | + if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){ | |
| 79944 | 79924 | /* If iCol is less than zero, then the expression requests the |
| 79945 | 79925 | ** rowid of the sub-select or view. This expression is legal (see |
| 79946 | 79926 | ** test case misc2.2.2) - it always evaluates to NULL. |
| 79947 | 79927 | */ |
| 79948 | 79928 | NameContext sNC; |
| @@ -81499,11 +81479,11 @@ | ||
| 81499 | 81479 | ** (10) The subquery does not use aggregates or the outer query does not |
| 81500 | 81480 | ** use LIMIT. |
| 81501 | 81481 | ** |
| 81502 | 81482 | ** (11) The subquery and the outer query do not both have ORDER BY clauses. |
| 81503 | 81483 | ** |
| 81504 | -** (12) Not implemented. Subsumed into restriction (3). Was previously | |
| 81484 | +** (**) Not implemented. Subsumed into restriction (3). Was previously | |
| 81505 | 81485 | ** a separate restriction deriving from ticket #350. |
| 81506 | 81486 | ** |
| 81507 | 81487 | ** (13) The subquery and outer query do not both use LIMIT |
| 81508 | 81488 | ** |
| 81509 | 81489 | ** (14) The subquery does not use OFFSET |
| @@ -81573,10 +81553,11 @@ | ||
| 81573 | 81553 | |
| 81574 | 81554 | /* Check to see if flattening is permitted. Return 0 if not. |
| 81575 | 81555 | */ |
| 81576 | 81556 | assert( p!=0 ); |
| 81577 | 81557 | assert( p->pPrior==0 ); /* Unable to flatten compound queries */ |
| 81558 | + if( db->flags & SQLITE_QueryFlattener ) return 0; | |
| 81578 | 81559 | pSrc = p->pSrc; |
| 81579 | 81560 | assert( pSrc && iFrom>=0 && iFrom<pSrc->nSrc ); |
| 81580 | 81561 | pSubitem = &pSrc->a[iFrom]; |
| 81581 | 81562 | iParent = pSubitem->iCursor; |
| 81582 | 81563 | pSub = pSubitem->pSelect; |
| @@ -82196,18 +82177,18 @@ | ||
| 82196 | 82177 | assert(IsVirtual(pTab)); |
| 82197 | 82178 | continue; |
| 82198 | 82179 | } |
| 82199 | 82180 | |
| 82200 | 82181 | 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 | + ){ | |
| 82204 | 82185 | /* In a NATURAL join, omit the join columns from the |
| 82205 | - ** table on the right */ | |
| 82186 | + ** table to the right of the join */ | |
| 82206 | 82187 | continue; |
| 82207 | 82188 | } |
| 82208 | - if( sqlite3IdListIndex(pLeft[1].pUsing, zName)>=0 ){ | |
| 82189 | + if( sqlite3IdListIndex(pFrom->pUsing, zName)>=0 ){ | |
| 82209 | 82190 | /* In a join with a USING clause, omit columns in the |
| 82210 | 82191 | ** using clause from the table on the right. */ |
| 82211 | 82192 | continue; |
| 82212 | 82193 | } |
| 82213 | 82194 | } |
| @@ -82470,12 +82451,12 @@ | ||
| 82470 | 82451 | sqlite3VdbeAddOp4(v, OP_CollSeq, 0, 0, 0, (char *)pColl, P4_COLLSEQ); |
| 82471 | 82452 | } |
| 82472 | 82453 | sqlite3VdbeAddOp4(v, OP_AggStep, 0, regAgg, pF->iMem, |
| 82473 | 82454 | (void*)pF->pFunc, P4_FUNCDEF); |
| 82474 | 82455 | sqlite3VdbeChangeP5(v, (u8)nArg); |
| 82475 | - sqlite3ReleaseTempRange(pParse, regAgg, nArg); | |
| 82476 | 82456 | sqlite3ExprCacheAffinityChange(pParse, regAgg, nArg); |
| 82457 | + sqlite3ReleaseTempRange(pParse, regAgg, nArg); | |
| 82477 | 82458 | if( addrNext ){ |
| 82478 | 82459 | sqlite3VdbeResolveLabel(v, addrNext); |
| 82479 | 82460 | sqlite3ExprCacheClear(pParse); |
| 82480 | 82461 | } |
| 82481 | 82462 | } |
| @@ -82897,11 +82878,11 @@ | ||
| 82897 | 82878 | if( pCol->iSorterColumn>=j ){ |
| 82898 | 82879 | int r1 = j + regBase; |
| 82899 | 82880 | int r2; |
| 82900 | 82881 | |
| 82901 | 82882 | r2 = sqlite3ExprCodeGetColumn(pParse, |
| 82902 | - pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0); | |
| 82883 | + pCol->pTab, pCol->iColumn, pCol->iTable, r1); | |
| 82903 | 82884 | if( r1!=r2 ){ |
| 82904 | 82885 | sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1); |
| 82905 | 82886 | } |
| 82906 | 82887 | j++; |
| 82907 | 82888 | } |
| @@ -85309,10 +85290,11 @@ | ||
| 85309 | 85290 | Btree *pTemp; /* The temporary database we vacuum into */ |
| 85310 | 85291 | char *zSql = 0; /* SQL statements */ |
| 85311 | 85292 | int saved_flags; /* Saved value of the db->flags */ |
| 85312 | 85293 | int saved_nChange; /* Saved value of db->nChange */ |
| 85313 | 85294 | int saved_nTotalChange; /* Saved value of db->nTotalChange */ |
| 85295 | + void (*saved_xTrace)(void*,const char*); /* Saved db->xTrace */ | |
| 85314 | 85296 | Db *pDb = 0; /* Database to detach at end of vacuum */ |
| 85315 | 85297 | int isMemDb; /* True if vacuuming a :memory: database */ |
| 85316 | 85298 | int nRes; |
| 85317 | 85299 | |
| 85318 | 85300 | if( !db->autoCommit ){ |
| @@ -85324,12 +85306,14 @@ | ||
| 85324 | 85306 | ** restored before returning. Then set the writable-schema flag, and |
| 85325 | 85307 | ** disable CHECK and foreign key constraints. */ |
| 85326 | 85308 | saved_flags = db->flags; |
| 85327 | 85309 | saved_nChange = db->nChange; |
| 85328 | 85310 | saved_nTotalChange = db->nTotalChange; |
| 85311 | + saved_xTrace = db->xTrace; | |
| 85329 | 85312 | db->flags |= SQLITE_WriteSchema | SQLITE_IgnoreChecks; |
| 85330 | 85313 | db->flags &= ~SQLITE_ForeignKeys; |
| 85314 | + db->xTrace = 0; | |
| 85331 | 85315 | |
| 85332 | 85316 | pMain = db->aDb[0].pBt; |
| 85333 | 85317 | isMemDb = sqlite3PagerIsMemdb(sqlite3BtreePager(pMain)); |
| 85334 | 85318 | |
| 85335 | 85319 | /* Attach the temporary database as 'vacuum_db'. The synchronous pragma |
| @@ -85506,10 +85490,11 @@ | ||
| 85506 | 85490 | end_of_vacuum: |
| 85507 | 85491 | /* Restore the original value of db->flags */ |
| 85508 | 85492 | db->flags = saved_flags; |
| 85509 | 85493 | db->nChange = saved_nChange; |
| 85510 | 85494 | db->nTotalChange = saved_nTotalChange; |
| 85495 | + db->xTrace = saved_xTrace; | |
| 85511 | 85496 | |
| 85512 | 85497 | /* Currently there is an SQL level transaction open on the vacuum |
| 85513 | 85498 | ** database. No locks are held on any other files (since the main file |
| 85514 | 85499 | ** was committed at the btree level). So it safe to end the transaction |
| 85515 | 85500 | ** by manually setting the autoCommit flag to true and detaching the |
| @@ -86200,24 +86185,24 @@ | ||
| 86200 | 86185 | rc = SQLITE_NOMEM; |
| 86201 | 86186 | }else{ |
| 86202 | 86187 | pParse->declareVtab = 1; |
| 86203 | 86188 | pParse->db = db; |
| 86204 | 86189 | |
| 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 | |
| 86210 | 86195 | ){ |
| 86211 | 86196 | if( !pTab->aCol ){ |
| 86212 | 86197 | pTab->aCol = pParse->pNewTable->aCol; |
| 86213 | 86198 | pTab->nCol = pParse->pNewTable->nCol; |
| 86214 | 86199 | pParse->pNewTable->nCol = 0; |
| 86215 | 86200 | pParse->pNewTable->aCol = 0; |
| 86216 | 86201 | } |
| 86217 | 86202 | db->pVTab = 0; |
| 86218 | - } else { | |
| 86203 | + }else{ | |
| 86219 | 86204 | sqlite3Error(db, SQLITE_ERROR, zErr); |
| 86220 | 86205 | sqlite3DbFree(db, zErr); |
| 86221 | 86206 | rc = SQLITE_ERROR; |
| 86222 | 86207 | } |
| 86223 | 86208 | pParse->declareVtab = 0; |
| @@ -89653,11 +89638,11 @@ | ||
| 89653 | 89638 | ** range (if any). |
| 89654 | 89639 | */ |
| 89655 | 89640 | nConstraint = nEq; |
| 89656 | 89641 | if( pRangeEnd ){ |
| 89657 | 89642 | Expr *pRight = pRangeEnd->pExpr->pRight; |
| 89658 | - sqlite3ExprCacheRemove(pParse, regBase+nEq); | |
| 89643 | + sqlite3ExprCacheRemove(pParse, regBase+nEq, 1); | |
| 89659 | 89644 | sqlite3ExprCode(pParse, pRight, regBase+nEq); |
| 89660 | 89645 | sqlite3ExprCodeIsNullJump(v, pRight, regBase+nEq, addrNxt); |
| 89661 | 89646 | if( zAff ){ |
| 89662 | 89647 | if( sqlite3CompareAffinity(pRight, zAff[nConstraint])==SQLITE_AFF_NONE){ |
| 89663 | 89648 | /* Since the comparison is to be performed with no conversions |
| @@ -89758,30 +89743,50 @@ | ||
| 89758 | 89743 | ** B: <after the loop> |
| 89759 | 89744 | ** |
| 89760 | 89745 | */ |
| 89761 | 89746 | WhereClause *pOrWc; /* The OR-clause broken out into subterms */ |
| 89762 | 89747 | WhereTerm *pFinal; /* Final subterm within the OR-clause. */ |
| 89763 | - SrcList oneTab; /* Shortened table list */ | |
| 89748 | + SrcList *pOrTab; /* Shortened table list or OR-clause generation */ | |
| 89764 | 89749 | |
| 89765 | 89750 | int regReturn = ++pParse->nMem; /* Register used with OP_Gosub */ |
| 89766 | 89751 | int regRowset = 0; /* Register for RowSet object */ |
| 89767 | 89752 | int regRowid = 0; /* Register holding rowid */ |
| 89768 | 89753 | int iLoopBody = sqlite3VdbeMakeLabel(v); /* Start of loop body */ |
| 89769 | 89754 | int iRetInit; /* Address of regReturn init */ |
| 89755 | + int untestedTerms = 0; /* Some terms not completely tested */ | |
| 89770 | 89756 | int ii; |
| 89771 | 89757 | |
| 89772 | 89758 | pTerm = pLevel->plan.u.pTerm; |
| 89773 | 89759 | assert( pTerm!=0 ); |
| 89774 | 89760 | assert( pTerm->eOperator==WO_OR ); |
| 89775 | 89761 | assert( (pTerm->wtFlags & TERM_ORINFO)!=0 ); |
| 89776 | 89762 | pOrWc = &pTerm->u.pOrInfo->wc; |
| 89777 | 89763 | pFinal = &pOrWc->a[pOrWc->nTerm-1]; |
| 89764 | + pLevel->op = OP_Return; | |
| 89765 | + pLevel->p1 = regReturn; | |
| 89778 | 89766 | |
| 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 | + } | |
| 89783 | 89788 | |
| 89784 | 89789 | /* Initialize the rowset register to contain NULL. An SQL NULL is |
| 89785 | 89790 | ** equivalent to an empty rowset. |
| 89786 | 89791 | ** |
| 89787 | 89792 | ** Also initialize regReturn to contain the address of the instruction |
| @@ -89802,36 +89807,42 @@ | ||
| 89802 | 89807 | for(ii=0; ii<pOrWc->nTerm; ii++){ |
| 89803 | 89808 | WhereTerm *pOrTerm = &pOrWc->a[ii]; |
| 89804 | 89809 | if( pOrTerm->leftCursor==iCur || pOrTerm->eOperator==WO_AND ){ |
| 89805 | 89810 | WhereInfo *pSubWInfo; /* Info for single OR-term scan */ |
| 89806 | 89811 | /* 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); | |
| 89809 | 89815 | if( pSubWInfo ){ |
| 89810 | 89816 | if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){ |
| 89811 | 89817 | int iSet = ((ii==pOrWc->nTerm-1)?-1:ii); |
| 89812 | 89818 | int r; |
| 89813 | 89819 | r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur, |
| 89814 | - regRowid, 0); | |
| 89820 | + regRowid); | |
| 89815 | 89821 | sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset, |
| 89816 | 89822 | sqlite3VdbeCurrentAddr(v)+2, r, iSet); |
| 89817 | 89823 | } |
| 89818 | 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; | |
| 89819 | 89832 | |
| 89820 | 89833 | /* Finish the loop through table entries that match term pOrTerm. */ |
| 89821 | 89834 | sqlite3WhereEnd(pSubWInfo); |
| 89822 | 89835 | } |
| 89823 | 89836 | } |
| 89824 | 89837 | } |
| 89825 | 89838 | sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v)); |
| 89826 | - /* sqlite3VdbeAddOp2(v, OP_Null, 0, regRowset); */ | |
| 89827 | 89839 | sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrBrk); |
| 89828 | 89840 | sqlite3VdbeResolveLabel(v, iLoopBody); |
| 89829 | 89841 | |
| 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); | |
| 89833 | 89844 | }else |
| 89834 | 89845 | #endif /* SQLITE_OMIT_OR_OPTIMIZATION */ |
| 89835 | 89846 | |
| 89836 | 89847 | { |
| 89837 | 89848 | /* Case 5: There is no usable index. We must do a complete |
| @@ -89855,11 +89866,16 @@ | ||
| 89855 | 89866 | for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){ |
| 89856 | 89867 | Expr *pE; |
| 89857 | 89868 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 89858 | 89869 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 89859 | 89870 | 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 | + } | |
| 89861 | 89877 | pE = pTerm->pExpr; |
| 89862 | 89878 | assert( pE!=0 ); |
| 89863 | 89879 | if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){ |
| 89864 | 89880 | continue; |
| 89865 | 89881 | } |
| @@ -89878,11 +89894,14 @@ | ||
| 89878 | 89894 | sqlite3ExprCacheClear(pParse); |
| 89879 | 89895 | for(pTerm=pWC->a, j=0; j<pWC->nTerm; j++, pTerm++){ |
| 89880 | 89896 | testcase( pTerm->wtFlags & TERM_VIRTUAL ); |
| 89881 | 89897 | testcase( pTerm->wtFlags & TERM_CODED ); |
| 89882 | 89898 | 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 | + } | |
| 89884 | 89903 | assert( pTerm->pExpr ); |
| 89885 | 89904 | sqlite3ExprIfFalse(pParse, pTerm->pExpr, addrCont, SQLITE_JUMPIFNULL); |
| 89886 | 89905 | pTerm->wtFlags |= TERM_CODED; |
| 89887 | 89906 | } |
| 89888 | 89907 | } |
| @@ -90021,10 +90040,11 @@ | ||
| 90021 | 90040 | ExprList **ppOrderBy, /* An ORDER BY clause, or NULL */ |
| 90022 | 90041 | u16 wctrlFlags /* One of the WHERE_* flags defined in sqliteInt.h */ |
| 90023 | 90042 | ){ |
| 90024 | 90043 | int i; /* Loop counter */ |
| 90025 | 90044 | int nByteWInfo; /* Num. bytes allocated for WhereInfo struct */ |
| 90045 | + int nTabList; /* Number of elements in pTabList */ | |
| 90026 | 90046 | WhereInfo *pWInfo; /* Will become the return value of this function */ |
| 90027 | 90047 | Vdbe *v = pParse->pVdbe; /* The virtual database engine */ |
| 90028 | 90048 | Bitmask notReady; /* Cursors that are not yet positioned */ |
| 90029 | 90049 | WhereMaskSet *pMaskSet; /* The expression mask set */ |
| 90030 | 90050 | WhereClause *pWC; /* Decomposition of the WHERE clause */ |
| @@ -90039,29 +90059,36 @@ | ||
| 90039 | 90059 | */ |
| 90040 | 90060 | if( pTabList->nSrc>BMS ){ |
| 90041 | 90061 | sqlite3ErrorMsg(pParse, "at most %d tables in a join", BMS); |
| 90042 | 90062 | return 0; |
| 90043 | 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; | |
| 90044 | 90071 | |
| 90045 | 90072 | /* Allocate and initialize the WhereInfo structure that will become the |
| 90046 | 90073 | ** return value. A single allocation is used to store the WhereInfo |
| 90047 | 90074 | ** struct, the contents of WhereInfo.a[], the WhereClause structure |
| 90048 | 90075 | ** and the WhereMaskSet structure. Since WhereClause contains an 8-byte |
| 90049 | 90076 | ** field (type Bitmask) it must be aligned on an 8-byte boundary on |
| 90050 | 90077 | ** some architectures. Hence the ROUND8() below. |
| 90051 | 90078 | */ |
| 90052 | 90079 | db = pParse->db; |
| 90053 | - nByteWInfo = ROUND8(sizeof(WhereInfo)+(pTabList->nSrc-1)*sizeof(WhereLevel)); | |
| 90080 | + nByteWInfo = ROUND8(sizeof(WhereInfo)+(nTabList-1)*sizeof(WhereLevel)); | |
| 90054 | 90081 | pWInfo = sqlite3DbMallocZero(db, |
| 90055 | 90082 | nByteWInfo + |
| 90056 | 90083 | sizeof(WhereClause) + |
| 90057 | 90084 | sizeof(WhereMaskSet) |
| 90058 | 90085 | ); |
| 90059 | 90086 | if( db->mallocFailed ){ |
| 90060 | 90087 | goto whereBeginError; |
| 90061 | 90088 | } |
| 90062 | - pWInfo->nLevel = pTabList->nSrc; | |
| 90089 | + pWInfo->nLevel = nTabList; | |
| 90063 | 90090 | pWInfo->pParse = pParse; |
| 90064 | 90091 | pWInfo->pTabList = pTabList; |
| 90065 | 90092 | pWInfo->iBreak = sqlite3VdbeMakeLabel(v); |
| 90066 | 90093 | pWInfo->pWC = pWC = (WhereClause *)&((u8 *)pWInfo)[nByteWInfo]; |
| 90067 | 90094 | pWInfo->wctrlFlags = wctrlFlags; |
| @@ -90076,11 +90103,11 @@ | ||
| 90076 | 90103 | whereSplit(pWC, pWhere, TK_AND); |
| 90077 | 90104 | |
| 90078 | 90105 | /* Special case: a WHERE clause that is constant. Evaluate the |
| 90079 | 90106 | ** expression and either jump over all of the code or fall thru. |
| 90080 | 90107 | */ |
| 90081 | - if( pWhere && (pTabList->nSrc==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){ | |
| 90108 | + if( pWhere && (nTabList==0 || sqlite3ExprIsConstantNotJoin(pWhere)) ){ | |
| 90082 | 90109 | sqlite3ExprIfFalse(pParse, pWhere, pWInfo->iBreak, SQLITE_JUMPIFNULL); |
| 90083 | 90110 | pWhere = 0; |
| 90084 | 90111 | } |
| 90085 | 90112 | |
| 90086 | 90113 | /* Assign a bit from the bitmask to every term in the FROM clause. |
| @@ -90096,10 +90123,15 @@ | ||
| 90096 | 90123 | ** |
| 90097 | 90124 | ** Configure the WhereClause.vmask variable so that bits that correspond |
| 90098 | 90125 | ** to virtual table cursors are set. This is used to selectively disable |
| 90099 | 90126 | ** the OR-to-IN transformation in exprAnalyzeOrTerm(). It is not helpful |
| 90100 | 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. | |
| 90101 | 90133 | */ |
| 90102 | 90134 | assert( pWC->vmask==0 && pMaskSet->n==0 ); |
| 90103 | 90135 | for(i=0; i<pTabList->nSrc; i++){ |
| 90104 | 90136 | createMask(pMaskSet, pTabList->a[i].iCursor); |
| 90105 | 90137 | #ifndef SQLITE_OMIT_VIRTUALTABLE |
| @@ -90147,11 +90179,11 @@ | ||
| 90147 | 90179 | notReady = ~(Bitmask)0; |
| 90148 | 90180 | pTabItem = pTabList->a; |
| 90149 | 90181 | pLevel = pWInfo->a; |
| 90150 | 90182 | andFlags = ~0; |
| 90151 | 90183 | 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++){ | |
| 90153 | 90185 | WhereCost bestPlan; /* Most efficient plan seen so far */ |
| 90154 | 90186 | Index *pIdx; /* Index for FROM table at pTabItem */ |
| 90155 | 90187 | int j; /* For looping over FROM tables */ |
| 90156 | 90188 | int bestJ = -1; /* The value of j */ |
| 90157 | 90189 | Bitmask m; /* Bitmask value for j or bestJ */ |
| @@ -90192,12 +90224,12 @@ | ||
| 90192 | 90224 | ** algorithm may choose to use t2 for the outer loop, which is a much |
| 90193 | 90225 | ** costlier approach. |
| 90194 | 90226 | */ |
| 90195 | 90227 | for(isOptimal=1; isOptimal>=0 && bestJ<0; isOptimal--){ |
| 90196 | 90228 | 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++){ | |
| 90199 | 90231 | int doNotReorder; /* True if this table should not be reordered */ |
| 90200 | 90232 | WhereCost sCost; /* Cost information from best[Virtual]Index() */ |
| 90201 | 90233 | ExprList *pOrderBy; /* ORDER BY clause for index to optimize */ |
| 90202 | 90234 | |
| 90203 | 90235 | doNotReorder = (pTabItem->jointype & (JT_LEFT|JT_CROSS))!=0; |
| @@ -90290,11 +90322,11 @@ | ||
| 90290 | 90322 | |
| 90291 | 90323 | /* Open all tables in the pTabList and any indices selected for |
| 90292 | 90324 | ** searching those tables. |
| 90293 | 90325 | */ |
| 90294 | 90326 | 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++){ | |
| 90296 | 90328 | Table *pTab; /* Table to open */ |
| 90297 | 90329 | int iDb; /* Index of database containing table/index */ |
| 90298 | 90330 | |
| 90299 | 90331 | #ifndef SQLITE_OMIT_EXPLAIN |
| 90300 | 90332 | if( pParse->explain==2 ){ |
| @@ -90369,11 +90401,11 @@ | ||
| 90369 | 90401 | /* Generate the code to do the search. Each iteration of the for |
| 90370 | 90402 | ** loop below generates code for a single nested loop of the VM |
| 90371 | 90403 | ** program. |
| 90372 | 90404 | */ |
| 90373 | 90405 | notReady = ~(Bitmask)0; |
| 90374 | - for(i=0; i<pTabList->nSrc; i++){ | |
| 90406 | + for(i=0; i<nTabList; i++){ | |
| 90375 | 90407 | notReady = codeOneLoopStart(pWInfo, i, wctrlFlags, notReady); |
| 90376 | 90408 | pWInfo->iContinue = pWInfo->a[i].addrCont; |
| 90377 | 90409 | } |
| 90378 | 90410 | |
| 90379 | 90411 | #ifdef SQLITE_TEST /* For testing and debugging use only */ |
| @@ -90381,11 +90413,11 @@ | ||
| 90381 | 90413 | ** and the index used to access it (if any). If the table itself |
| 90382 | 90414 | ** is not used, its name is just '{}'. If no index is used |
| 90383 | 90415 | ** the index is listed as "{}". If the primary key is used the |
| 90384 | 90416 | ** index name is '*'. |
| 90385 | 90417 | */ |
| 90386 | - for(i=0; i<pTabList->nSrc; i++){ | |
| 90418 | + for(i=0; i<nTabList; i++){ | |
| 90387 | 90419 | char *z; |
| 90388 | 90420 | int n; |
| 90389 | 90421 | pLevel = &pWInfo->a[i]; |
| 90390 | 90422 | pTabItem = &pTabList->a[pLevel->iFrom]; |
| 90391 | 90423 | z = pTabItem->zAlias; |
| @@ -90449,11 +90481,11 @@ | ||
| 90449 | 90481 | sqlite3 *db = pParse->db; |
| 90450 | 90482 | |
| 90451 | 90483 | /* Generate loop termination code. |
| 90452 | 90484 | */ |
| 90453 | 90485 | sqlite3ExprCacheClear(pParse); |
| 90454 | - for(i=pTabList->nSrc-1; i>=0; i--){ | |
| 90486 | + for(i=pWInfo->nLevel-1; i>=0; i--){ | |
| 90455 | 90487 | pLevel = &pWInfo->a[i]; |
| 90456 | 90488 | sqlite3VdbeResolveLabel(v, pLevel->addrCont); |
| 90457 | 90489 | if( pLevel->op!=OP_Noop ){ |
| 90458 | 90490 | sqlite3VdbeAddOp2(v, pLevel->op, pLevel->p1, pLevel->p2); |
| 90459 | 90491 | sqlite3VdbeChangeP5(v, pLevel->p5); |
| @@ -90495,11 +90527,12 @@ | ||
| 90495 | 90527 | */ |
| 90496 | 90528 | sqlite3VdbeResolveLabel(v, pWInfo->iBreak); |
| 90497 | 90529 | |
| 90498 | 90530 | /* Close all of the cursors that were opened by sqlite3WhereBegin. |
| 90499 | 90531 | */ |
| 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++){ | |
| 90501 | 90534 | struct SrcList_item *pTabItem = &pTabList->a[pLevel->iFrom]; |
| 90502 | 90535 | Table *pTab = pTabItem->pTab; |
| 90503 | 90536 | assert( pTab!=0 ); |
| 90504 | 90537 | if( (pTab->tabFlags & TF_Ephemeral)!=0 || pTab->pSelect ) continue; |
| 90505 | 90538 | if( (pWInfo->wctrlFlags & WHERE_OMIT_CLOSE)==0 ){ |
| @@ -90767,12 +90800,12 @@ | ||
| 90767 | 90800 | #endif |
| 90768 | 90801 | #define sqlite3ParserARG_SDECL Parse *pParse; |
| 90769 | 90802 | #define sqlite3ParserARG_PDECL ,Parse *pParse |
| 90770 | 90803 | #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse |
| 90771 | 90804 | #define sqlite3ParserARG_STORE yypParser->pParse = pParse |
| 90772 | -#define YYNSTATE 629 | |
| 90773 | -#define YYNRULE 329 | |
| 90805 | +#define YYNSTATE 631 | |
| 90806 | +#define YYNRULE 330 | |
| 90774 | 90807 | #define YYFALLBACK 1 |
| 90775 | 90808 | #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| 90776 | 90809 | #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| 90777 | 90810 | #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| 90778 | 90811 | |
| @@ -90840,473 +90873,474 @@ | ||
| 90840 | 90873 | ** shifting non-terminals after a reduce. |
| 90841 | 90874 | ** yy_default[] Default action for each state. |
| 90842 | 90875 | */ |
| 90843 | 90876 | #define YY_ACTTAB_COUNT (1543) |
| 90844 | 90877 | 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, | |
| 90853 | 90886 | /* 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, | |
| 91000 | 91033 | }; |
| 91001 | 91034 | static const YYCODETYPE yy_lookahead[] = { |
| 91002 | 91035 | /* 0 */ 19, 222, 223, 224, 225, 24, 1, 26, 77, 78, |
| 91003 | 91036 | /* 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, | |
| 91005 | 91038 | /* 30 */ 49, 50, 81, 82, 83, 84, 85, 86, 87, 88, |
| 91006 | 91039 | /* 40 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 68, |
| 91007 | 91040 | /* 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, | |
| 91010 | 91043 | /* 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, | |
| 91019 | 91052 | /* 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, | |
| 91022 | 91055 | /* 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, | |
| 91038 | 91071 | /* 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, | |
| 91044 | 91077 | /* 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, | |
| 91059 | 91092 | /* 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, | |
| 91074 | 91107 | /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82, |
| 91075 | 91108 | /* 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, | |
| 91081 | 91114 | /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, |
| 91082 | 91115 | /* 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, | |
| 91089 | 91122 | /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84, |
| 91090 | 91123 | /* 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, | |
| 91096 | 91129 | /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, |
| 91097 | 91130 | /* 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, | |
| 91104 | 91137 | /* 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, | |
| 91112 | 91145 | /* 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, | |
| 91157 | 91190 | }; |
| 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) | |
| 91162 | 91195 | 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, | |
| 91170 | 91203 | /* 70 */ 647, 573, 499, 425, 351, 277, 203, 129, 795, 795, |
| 91171 | 91204 | /* 80 */ 795, 795, 795, 795, 795, 795, 795, 795, 795, 795, |
| 91172 | 91205 | /* 90 */ 795, 795, 795, 795, 795, 795, 869, 795, 943, 1017, |
| 91173 | 91206 | /* 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, | |
| 91205 | 91238 | }; |
| 91206 | 91239 | #define YY_REDUCE_USE_DFLT (-222) |
| 91207 | -#define YY_REDUCE_COUNT (311) | |
| 91240 | +#define YY_REDUCE_COUNT (312) | |
| 91208 | 91241 | #define YY_REDUCE_MIN (-221) |
| 91209 | -#define YY_REDUCE_MAX (1377) | |
| 91242 | +#define YY_REDUCE_MAX (1378) | |
| 91210 | 91243 | 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, | |
| 91243 | 91276 | }; |
| 91244 | 91277 | 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, | |
| 91308 | 91342 | }; |
| 91309 | 91343 | |
| 91310 | 91344 | /* The next table maps tokens into fallback tokens. If a construct |
| 91311 | 91345 | ** like the following: |
| 91312 | 91346 | ** |
| @@ -91487,17 +91521,17 @@ | ||
| 91487 | 91521 | "LSHIFT", "RSHIFT", "PLUS", "MINUS", |
| 91488 | 91522 | "STAR", "SLASH", "REM", "CONCAT", |
| 91489 | 91523 | "COLLATE", "BITNOT", "STRING", "JOIN_KW", |
| 91490 | 91524 | "CONSTRAINT", "DEFAULT", "NULL", "PRIMARY", |
| 91491 | 91525 | "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", | |
| 91499 | 91533 | "REGISTER", "VARIABLE", "CASE", "WHEN", |
| 91500 | 91534 | "THEN", "ELSE", "INDEX", "ALTER", |
| 91501 | 91535 | "ADD", "error", "input", "cmdlist", |
| 91502 | 91536 | "ecmd", "explain", "cmdx", "cmd", |
| 91503 | 91537 | "transtype", "trans_opt", "nm", "savepoint_opt", |
| @@ -91607,264 +91641,265 @@ | ||
| 91607 | 91641 | /* 70 */ "autoinc ::=", |
| 91608 | 91642 | /* 71 */ "autoinc ::= AUTOINCR", |
| 91609 | 91643 | /* 72 */ "refargs ::=", |
| 91610 | 91644 | /* 73 */ "refargs ::= refargs refarg", |
| 91611 | 91645 | /* 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", | |
| 91866 | 91901 | }; |
| 91867 | 91902 | #endif /* NDEBUG */ |
| 91868 | 91903 | |
| 91869 | 91904 | |
| 91870 | 91905 | #if YYSTACKDEPTH<=0 |
| @@ -92326,10 +92361,11 @@ | ||
| 92326 | 92361 | { 180, 0 }, |
| 92327 | 92362 | { 180, 2 }, |
| 92328 | 92363 | { 182, 2 }, |
| 92329 | 92364 | { 182, 3 }, |
| 92330 | 92365 | { 182, 3 }, |
| 92366 | + { 182, 3 }, | |
| 92331 | 92367 | { 183, 2 }, |
| 92332 | 92368 | { 183, 2 }, |
| 92333 | 92369 | { 183, 1 }, |
| 92334 | 92370 | { 183, 1 }, |
| 92335 | 92371 | { 183, 2 }, |
| @@ -92653,12 +92689,12 @@ | ||
| 92653 | 92689 | {yygotominor.yy328 = TK_DEFERRED;} |
| 92654 | 92690 | break; |
| 92655 | 92691 | case 14: /* transtype ::= DEFERRED */ |
| 92656 | 92692 | case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15); |
| 92657 | 92693 | 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); | |
| 92660 | 92696 | {yygotominor.yy328 = yymsp[0].major;} |
| 92661 | 92697 | break; |
| 92662 | 92698 | case 17: /* cmd ::= COMMIT trans_opt */ |
| 92663 | 92699 | case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18); |
| 92664 | 92700 | {sqlite3CommitTransaction(pParse);} |
| @@ -92693,29 +92729,29 @@ | ||
| 92693 | 92729 | } |
| 92694 | 92730 | break; |
| 92695 | 92731 | case 28: /* ifnotexists ::= */ |
| 92696 | 92732 | case 31: /* temp ::= */ yytestcase(yyruleno==31); |
| 92697 | 92733 | 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); | |
| 92707 | 92743 | {yygotominor.yy328 = 0;} |
| 92708 | 92744 | break; |
| 92709 | 92745 | case 29: /* ifnotexists ::= IF NOT EXISTS */ |
| 92710 | 92746 | case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30); |
| 92711 | 92747 | 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); | |
| 92717 | 92753 | {yygotominor.yy328 = 1;} |
| 92718 | 92754 | break; |
| 92719 | 92755 | case 32: /* create_table_args ::= LP columnlist conslist_opt RP */ |
| 92720 | 92756 | { |
| 92721 | 92757 | sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0); |
| @@ -92745,24 +92781,24 @@ | ||
| 92745 | 92781 | case 41: /* nm ::= id */ yytestcase(yyruleno==41); |
| 92746 | 92782 | case 42: /* nm ::= STRING */ yytestcase(yyruleno==42); |
| 92747 | 92783 | case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43); |
| 92748 | 92784 | case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46); |
| 92749 | 92785 | 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); | |
| 92764 | 92800 | {yygotominor.yy0 = yymsp[0].minor.yy0;} |
| 92765 | 92801 | break; |
| 92766 | 92802 | case 45: /* type ::= typetoken */ |
| 92767 | 92803 | {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);} |
| 92768 | 92804 | break; |
| @@ -92830,101 +92866,102 @@ | ||
| 92830 | 92866 | break; |
| 92831 | 92867 | case 73: /* refargs ::= refargs refarg */ |
| 92832 | 92868 | { yygotominor.yy328 = (yymsp[-1].minor.yy328 & ~yymsp[0].minor.yy429.mask) | yymsp[0].minor.yy429.value; } |
| 92833 | 92869 | break; |
| 92834 | 92870 | case 74: /* refarg ::= MATCH nm */ |
| 92871 | + case 75: /* refarg ::= ON INSERT refact */ yytestcase(yyruleno==75); | |
| 92835 | 92872 | { yygotominor.yy429.value = 0; yygotominor.yy429.mask = 0x000000; } |
| 92836 | 92873 | break; |
| 92837 | - case 75: /* refarg ::= ON DELETE refact */ | |
| 92874 | + case 76: /* refarg ::= ON DELETE refact */ | |
| 92838 | 92875 | { yygotominor.yy429.value = yymsp[0].minor.yy328; yygotominor.yy429.mask = 0x0000ff; } |
| 92839 | 92876 | break; |
| 92840 | - case 76: /* refarg ::= ON UPDATE refact */ | |
| 92877 | + case 77: /* refarg ::= ON UPDATE refact */ | |
| 92841 | 92878 | { yygotominor.yy429.value = yymsp[0].minor.yy328<<8; yygotominor.yy429.mask = 0x00ff00; } |
| 92842 | 92879 | break; |
| 92843 | - case 77: /* refact ::= SET NULL */ | |
| 92880 | + case 78: /* refact ::= SET NULL */ | |
| 92844 | 92881 | { yygotominor.yy328 = OE_SetNull; /* EV: R-33326-45252 */} |
| 92845 | 92882 | break; |
| 92846 | - case 78: /* refact ::= SET DEFAULT */ | |
| 92883 | + case 79: /* refact ::= SET DEFAULT */ | |
| 92847 | 92884 | { yygotominor.yy328 = OE_SetDflt; /* EV: R-33326-45252 */} |
| 92848 | 92885 | break; |
| 92849 | - case 79: /* refact ::= CASCADE */ | |
| 92886 | + case 80: /* refact ::= CASCADE */ | |
| 92850 | 92887 | { yygotominor.yy328 = OE_Cascade; /* EV: R-33326-45252 */} |
| 92851 | 92888 | break; |
| 92852 | - case 80: /* refact ::= RESTRICT */ | |
| 92889 | + case 81: /* refact ::= RESTRICT */ | |
| 92853 | 92890 | { yygotominor.yy328 = OE_Restrict; /* EV: R-33326-45252 */} |
| 92854 | 92891 | break; |
| 92855 | - case 81: /* refact ::= NO ACTION */ | |
| 92892 | + case 82: /* refact ::= NO ACTION */ | |
| 92856 | 92893 | { yygotominor.yy328 = OE_None; /* EV: R-33326-45252 */} |
| 92857 | 92894 | 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); | |
| 92862 | 92899 | {yygotominor.yy328 = yymsp[0].minor.yy328;} |
| 92863 | 92900 | break; |
| 92864 | - case 87: /* conslist_opt ::= */ | |
| 92901 | + case 88: /* conslist_opt ::= */ | |
| 92865 | 92902 | {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;} |
| 92866 | 92903 | break; |
| 92867 | - case 88: /* conslist_opt ::= COMMA conslist */ | |
| 92904 | + case 89: /* conslist_opt ::= COMMA conslist */ | |
| 92868 | 92905 | {yygotominor.yy0 = yymsp[-1].minor.yy0;} |
| 92869 | 92906 | break; |
| 92870 | - case 93: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ | |
| 92907 | + case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */ | |
| 92871 | 92908 | {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy14,yymsp[0].minor.yy328,yymsp[-2].minor.yy328,0);} |
| 92872 | 92909 | break; |
| 92873 | - case 94: /* tcons ::= UNIQUE LP idxlist RP onconf */ | |
| 92910 | + case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */ | |
| 92874 | 92911 | {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy14,yymsp[0].minor.yy328,0,0,0,0);} |
| 92875 | 92912 | break; |
| 92876 | - case 95: /* tcons ::= CHECK LP expr RP onconf */ | |
| 92913 | + case 96: /* tcons ::= CHECK LP expr RP onconf */ | |
| 92877 | 92914 | {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy346.pExpr);} |
| 92878 | 92915 | 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 */ | |
| 92880 | 92917 | { |
| 92881 | 92918 | sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy14, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy14, yymsp[-1].minor.yy328); |
| 92882 | 92919 | sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy328); |
| 92883 | 92920 | } |
| 92884 | 92921 | break; |
| 92885 | - case 99: /* onconf ::= */ | |
| 92922 | + case 100: /* onconf ::= */ | |
| 92886 | 92923 | {yygotominor.yy328 = OE_Default;} |
| 92887 | 92924 | break; |
| 92888 | - case 101: /* orconf ::= */ | |
| 92925 | + case 102: /* orconf ::= */ | |
| 92889 | 92926 | {yygotominor.yy186 = OE_Default;} |
| 92890 | 92927 | break; |
| 92891 | - case 102: /* orconf ::= OR resolvetype */ | |
| 92928 | + case 103: /* orconf ::= OR resolvetype */ | |
| 92892 | 92929 | {yygotominor.yy186 = (u8)yymsp[0].minor.yy328;} |
| 92893 | 92930 | break; |
| 92894 | - case 104: /* resolvetype ::= IGNORE */ | |
| 92931 | + case 105: /* resolvetype ::= IGNORE */ | |
| 92895 | 92932 | {yygotominor.yy328 = OE_Ignore;} |
| 92896 | 92933 | break; |
| 92897 | - case 105: /* resolvetype ::= REPLACE */ | |
| 92934 | + case 106: /* resolvetype ::= REPLACE */ | |
| 92898 | 92935 | {yygotominor.yy328 = OE_Replace;} |
| 92899 | 92936 | break; |
| 92900 | - case 106: /* cmd ::= DROP TABLE ifexists fullname */ | |
| 92937 | + case 107: /* cmd ::= DROP TABLE ifexists fullname */ | |
| 92901 | 92938 | { |
| 92902 | 92939 | sqlite3DropTable(pParse, yymsp[0].minor.yy65, 0, yymsp[-1].minor.yy328); |
| 92903 | 92940 | } |
| 92904 | 92941 | 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 */ | |
| 92906 | 92943 | { |
| 92907 | 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); |
| 92908 | 92945 | } |
| 92909 | 92946 | break; |
| 92910 | - case 110: /* cmd ::= DROP VIEW ifexists fullname */ | |
| 92947 | + case 111: /* cmd ::= DROP VIEW ifexists fullname */ | |
| 92911 | 92948 | { |
| 92912 | 92949 | sqlite3DropTable(pParse, yymsp[0].minor.yy65, 1, yymsp[-1].minor.yy328); |
| 92913 | 92950 | } |
| 92914 | 92951 | break; |
| 92915 | - case 111: /* cmd ::= select */ | |
| 92952 | + case 112: /* cmd ::= select */ | |
| 92916 | 92953 | { |
| 92917 | 92954 | SelectDest dest = {SRT_Output, 0, 0, 0, 0}; |
| 92918 | 92955 | sqlite3Select(pParse, yymsp[0].minor.yy3, &dest); |
| 92919 | 92956 | sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3); |
| 92920 | 92957 | } |
| 92921 | 92958 | break; |
| 92922 | - case 112: /* select ::= oneselect */ | |
| 92959 | + case 113: /* select ::= oneselect */ | |
| 92923 | 92960 | {yygotominor.yy3 = yymsp[0].minor.yy3;} |
| 92924 | 92961 | break; |
| 92925 | - case 113: /* select ::= select multiselect_op oneselect */ | |
| 92962 | + case 114: /* select ::= select multiselect_op oneselect */ | |
| 92926 | 92963 | { |
| 92927 | 92964 | if( yymsp[0].minor.yy3 ){ |
| 92928 | 92965 | yymsp[0].minor.yy3->op = (u8)yymsp[-1].minor.yy328; |
| 92929 | 92966 | yymsp[0].minor.yy3->pPrior = yymsp[-2].minor.yy3; |
| 92930 | 92967 | }else{ |
| @@ -92931,83 +92968,83 @@ | ||
| 92931 | 92968 | sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3); |
| 92932 | 92969 | } |
| 92933 | 92970 | yygotominor.yy3 = yymsp[0].minor.yy3; |
| 92934 | 92971 | } |
| 92935 | 92972 | break; |
| 92936 | - case 115: /* multiselect_op ::= UNION ALL */ | |
| 92973 | + case 116: /* multiselect_op ::= UNION ALL */ | |
| 92937 | 92974 | {yygotominor.yy328 = TK_ALL;} |
| 92938 | 92975 | 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 */ | |
| 92940 | 92977 | { |
| 92941 | 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); |
| 92942 | 92979 | } |
| 92943 | 92980 | 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); | |
| 92946 | 92983 | {yygotominor.yy14 = yymsp[-1].minor.yy14;} |
| 92947 | 92984 | 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); | |
| 92953 | 92990 | {yygotominor.yy14 = 0;} |
| 92954 | 92991 | break; |
| 92955 | - case 123: /* selcollist ::= sclp expr as */ | |
| 92992 | + case 124: /* selcollist ::= sclp expr as */ | |
| 92956 | 92993 | { |
| 92957 | 92994 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy14, yymsp[-1].minor.yy346.pExpr); |
| 92958 | 92995 | if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[0].minor.yy0, 1); |
| 92959 | 92996 | sqlite3ExprListSetSpan(pParse,yygotominor.yy14,&yymsp[-1].minor.yy346); |
| 92960 | 92997 | } |
| 92961 | 92998 | break; |
| 92962 | - case 124: /* selcollist ::= sclp STAR */ | |
| 92999 | + case 125: /* selcollist ::= sclp STAR */ | |
| 92963 | 93000 | { |
| 92964 | 93001 | Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0); |
| 92965 | 93002 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy14, p); |
| 92966 | 93003 | } |
| 92967 | 93004 | break; |
| 92968 | - case 125: /* selcollist ::= sclp nm DOT STAR */ | |
| 93005 | + case 126: /* selcollist ::= sclp nm DOT STAR */ | |
| 92969 | 93006 | { |
| 92970 | 93007 | Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0); |
| 92971 | 93008 | Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 92972 | 93009 | Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0); |
| 92973 | 93010 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14, pDot); |
| 92974 | 93011 | } |
| 92975 | 93012 | break; |
| 92976 | - case 128: /* as ::= */ | |
| 93013 | + case 129: /* as ::= */ | |
| 92977 | 93014 | {yygotominor.yy0.n = 0;} |
| 92978 | 93015 | break; |
| 92979 | - case 129: /* from ::= */ | |
| 93016 | + case 130: /* from ::= */ | |
| 92980 | 93017 | {yygotominor.yy65 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy65));} |
| 92981 | 93018 | break; |
| 92982 | - case 130: /* from ::= FROM seltablist */ | |
| 93019 | + case 131: /* from ::= FROM seltablist */ | |
| 92983 | 93020 | { |
| 92984 | 93021 | yygotominor.yy65 = yymsp[0].minor.yy65; |
| 92985 | 93022 | sqlite3SrcListShiftJoinType(yygotominor.yy65); |
| 92986 | 93023 | } |
| 92987 | 93024 | break; |
| 92988 | - case 131: /* stl_prefix ::= seltablist joinop */ | |
| 93025 | + case 132: /* stl_prefix ::= seltablist joinop */ | |
| 92989 | 93026 | { |
| 92990 | 93027 | yygotominor.yy65 = yymsp[-1].minor.yy65; |
| 92991 | 93028 | if( ALWAYS(yygotominor.yy65 && yygotominor.yy65->nSrc>0) ) yygotominor.yy65->a[yygotominor.yy65->nSrc-1].jointype = (u8)yymsp[0].minor.yy328; |
| 92992 | 93029 | } |
| 92993 | 93030 | break; |
| 92994 | - case 132: /* stl_prefix ::= */ | |
| 93031 | + case 133: /* stl_prefix ::= */ | |
| 92995 | 93032 | {yygotominor.yy65 = 0;} |
| 92996 | 93033 | 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 */ | |
| 92998 | 93035 | { |
| 92999 | 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); |
| 93000 | 93037 | sqlite3SrcListIndexedBy(pParse, yygotominor.yy65, &yymsp[-2].minor.yy0); |
| 93001 | 93038 | } |
| 93002 | 93039 | 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 */ | |
| 93004 | 93041 | { |
| 93005 | 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); |
| 93006 | 93043 | } |
| 93007 | 93044 | 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 */ | |
| 93009 | 93046 | { |
| 93010 | 93047 | if( yymsp[-6].minor.yy65==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy132==0 && yymsp[0].minor.yy408==0 ){ |
| 93011 | 93048 | yygotominor.yy65 = yymsp[-4].minor.yy65; |
| 93012 | 93049 | }else{ |
| 93013 | 93050 | Select *pSubquery; |
| @@ -93015,180 +93052,180 @@ | ||
| 93015 | 93052 | pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy65,0,0,0,0,0,0,0); |
| 93016 | 93053 | yygotominor.yy65 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy65,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy132,yymsp[0].minor.yy408); |
| 93017 | 93054 | } |
| 93018 | 93055 | } |
| 93019 | 93056 | 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); | |
| 93022 | 93059 | {yygotominor.yy0.z=0; yygotominor.yy0.n=0;} |
| 93023 | 93060 | break; |
| 93024 | - case 138: /* fullname ::= nm dbnm */ | |
| 93061 | + case 139: /* fullname ::= nm dbnm */ | |
| 93025 | 93062 | {yygotominor.yy65 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);} |
| 93026 | 93063 | break; |
| 93027 | - case 139: /* joinop ::= COMMA|JOIN */ | |
| 93064 | + case 140: /* joinop ::= COMMA|JOIN */ | |
| 93028 | 93065 | { yygotominor.yy328 = JT_INNER; } |
| 93029 | 93066 | break; |
| 93030 | - case 140: /* joinop ::= JOIN_KW JOIN */ | |
| 93067 | + case 141: /* joinop ::= JOIN_KW JOIN */ | |
| 93031 | 93068 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); } |
| 93032 | 93069 | break; |
| 93033 | - case 141: /* joinop ::= JOIN_KW nm JOIN */ | |
| 93070 | + case 142: /* joinop ::= JOIN_KW nm JOIN */ | |
| 93034 | 93071 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); } |
| 93035 | 93072 | break; |
| 93036 | - case 142: /* joinop ::= JOIN_KW nm nm JOIN */ | |
| 93073 | + case 143: /* joinop ::= JOIN_KW nm nm JOIN */ | |
| 93037 | 93074 | { yygotominor.yy328 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); } |
| 93038 | 93075 | 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); | |
| 93045 | 93082 | {yygotominor.yy132 = yymsp[0].minor.yy346.pExpr;} |
| 93046 | 93083 | 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); | |
| 93052 | 93089 | {yygotominor.yy132 = 0;} |
| 93053 | 93090 | break; |
| 93054 | - case 147: /* indexed_opt ::= NOT INDEXED */ | |
| 93091 | + case 148: /* indexed_opt ::= NOT INDEXED */ | |
| 93055 | 93092 | {yygotominor.yy0.z=0; yygotominor.yy0.n=1;} |
| 93056 | 93093 | 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); | |
| 93059 | 93096 | {yygotominor.yy408 = yymsp[-1].minor.yy408;} |
| 93060 | 93097 | 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); | |
| 93063 | 93100 | {yygotominor.yy408 = 0;} |
| 93064 | 93101 | 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); | |
| 93068 | 93105 | {yygotominor.yy14 = yymsp[0].minor.yy14;} |
| 93069 | 93106 | break; |
| 93070 | - case 152: /* sortlist ::= sortlist COMMA sortitem sortorder */ | |
| 93107 | + case 153: /* sortlist ::= sortlist COMMA sortitem sortorder */ | |
| 93071 | 93108 | { |
| 93072 | 93109 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy14,yymsp[-1].minor.yy132); |
| 93073 | 93110 | if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 93074 | 93111 | } |
| 93075 | 93112 | break; |
| 93076 | - case 153: /* sortlist ::= sortitem sortorder */ | |
| 93113 | + case 154: /* sortlist ::= sortitem sortorder */ | |
| 93077 | 93114 | { |
| 93078 | 93115 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy132); |
| 93079 | 93116 | if( yygotominor.yy14 && ALWAYS(yygotominor.yy14->a) ) yygotominor.yy14->a[0].sortOrder = (u8)yymsp[0].minor.yy328; |
| 93080 | 93117 | } |
| 93081 | 93118 | 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); | |
| 93084 | 93121 | {yygotominor.yy328 = SQLITE_SO_ASC;} |
| 93085 | 93122 | break; |
| 93086 | - case 156: /* sortorder ::= DESC */ | |
| 93123 | + case 157: /* sortorder ::= DESC */ | |
| 93087 | 93124 | {yygotominor.yy328 = SQLITE_SO_DESC;} |
| 93088 | 93125 | break; |
| 93089 | - case 162: /* limit_opt ::= */ | |
| 93126 | + case 163: /* limit_opt ::= */ | |
| 93090 | 93127 | {yygotominor.yy476.pLimit = 0; yygotominor.yy476.pOffset = 0;} |
| 93091 | 93128 | break; |
| 93092 | - case 163: /* limit_opt ::= LIMIT expr */ | |
| 93129 | + case 164: /* limit_opt ::= LIMIT expr */ | |
| 93093 | 93130 | {yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr; yygotominor.yy476.pOffset = 0;} |
| 93094 | 93131 | break; |
| 93095 | - case 164: /* limit_opt ::= LIMIT expr OFFSET expr */ | |
| 93132 | + case 165: /* limit_opt ::= LIMIT expr OFFSET expr */ | |
| 93096 | 93133 | {yygotominor.yy476.pLimit = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pOffset = yymsp[0].minor.yy346.pExpr;} |
| 93097 | 93134 | break; |
| 93098 | - case 165: /* limit_opt ::= LIMIT expr COMMA expr */ | |
| 93135 | + case 166: /* limit_opt ::= LIMIT expr COMMA expr */ | |
| 93099 | 93136 | {yygotominor.yy476.pOffset = yymsp[-2].minor.yy346.pExpr; yygotominor.yy476.pLimit = yymsp[0].minor.yy346.pExpr;} |
| 93100 | 93137 | break; |
| 93101 | - case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ | |
| 93138 | + case 167: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */ | |
| 93102 | 93139 | { |
| 93103 | 93140 | sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy65, &yymsp[-1].minor.yy0); |
| 93104 | 93141 | sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy65,yymsp[0].minor.yy132); |
| 93105 | 93142 | } |
| 93106 | 93143 | 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 */ | |
| 93108 | 93145 | { |
| 93109 | 93146 | sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy65, &yymsp[-3].minor.yy0); |
| 93110 | 93147 | sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy14,"set list"); |
| 93111 | 93148 | sqlite3Update(pParse,yymsp[-4].minor.yy65,yymsp[-1].minor.yy14,yymsp[0].minor.yy132,yymsp[-5].minor.yy186); |
| 93112 | 93149 | } |
| 93113 | 93150 | break; |
| 93114 | - case 170: /* setlist ::= setlist COMMA nm EQ expr */ | |
| 93151 | + case 171: /* setlist ::= setlist COMMA nm EQ expr */ | |
| 93115 | 93152 | { |
| 93116 | 93153 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy14, yymsp[0].minor.yy346.pExpr); |
| 93117 | 93154 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 93118 | 93155 | } |
| 93119 | 93156 | break; |
| 93120 | - case 171: /* setlist ::= nm EQ expr */ | |
| 93157 | + case 172: /* setlist ::= nm EQ expr */ | |
| 93121 | 93158 | { |
| 93122 | 93159 | yygotominor.yy14 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy346.pExpr); |
| 93123 | 93160 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 93124 | 93161 | } |
| 93125 | 93162 | 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 */ | |
| 93127 | 93164 | {sqlite3Insert(pParse, yymsp[-5].minor.yy65, yymsp[-1].minor.yy14, 0, yymsp[-4].minor.yy408, yymsp[-7].minor.yy186);} |
| 93128 | 93165 | break; |
| 93129 | - case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ | |
| 93166 | + case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */ | |
| 93130 | 93167 | {sqlite3Insert(pParse, yymsp[-2].minor.yy65, 0, yymsp[0].minor.yy3, yymsp[-1].minor.yy408, yymsp[-4].minor.yy186);} |
| 93131 | 93168 | 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 */ | |
| 93133 | 93170 | {sqlite3Insert(pParse, yymsp[-3].minor.yy65, 0, 0, yymsp[-2].minor.yy408, yymsp[-5].minor.yy186);} |
| 93134 | 93171 | break; |
| 93135 | - case 175: /* insert_cmd ::= INSERT orconf */ | |
| 93172 | + case 176: /* insert_cmd ::= INSERT orconf */ | |
| 93136 | 93173 | {yygotominor.yy186 = yymsp[0].minor.yy186;} |
| 93137 | 93174 | break; |
| 93138 | - case 176: /* insert_cmd ::= REPLACE */ | |
| 93175 | + case 177: /* insert_cmd ::= REPLACE */ | |
| 93139 | 93176 | {yygotominor.yy186 = OE_Replace;} |
| 93140 | 93177 | 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); | |
| 93143 | 93180 | {yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy14,yymsp[0].minor.yy346.pExpr);} |
| 93144 | 93181 | 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); | |
| 93147 | 93184 | {yygotominor.yy14 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy346.pExpr);} |
| 93148 | 93185 | break; |
| 93149 | - case 181: /* inscollist ::= inscollist COMMA nm */ | |
| 93186 | + case 182: /* inscollist ::= inscollist COMMA nm */ | |
| 93150 | 93187 | {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy408,&yymsp[0].minor.yy0);} |
| 93151 | 93188 | break; |
| 93152 | - case 182: /* inscollist ::= nm */ | |
| 93189 | + case 183: /* inscollist ::= nm */ | |
| 93153 | 93190 | {yygotominor.yy408 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);} |
| 93154 | 93191 | 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); | |
| 93157 | 93194 | {yygotominor.yy346 = yymsp[0].minor.yy346;} |
| 93158 | 93195 | break; |
| 93159 | - case 184: /* expr ::= LP expr RP */ | |
| 93196 | + case 185: /* expr ::= LP expr RP */ | |
| 93160 | 93197 | {yygotominor.yy346.pExpr = yymsp[-1].minor.yy346.pExpr; spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);} |
| 93161 | 93198 | 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); | |
| 93165 | 93202 | {spanExpr(&yygotominor.yy346, pParse, yymsp[0].major, &yymsp[0].minor.yy0);} |
| 93166 | 93203 | 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); | |
| 93169 | 93206 | {spanExpr(&yygotominor.yy346, pParse, TK_ID, &yymsp[0].minor.yy0);} |
| 93170 | 93207 | break; |
| 93171 | - case 188: /* expr ::= nm DOT nm */ | |
| 93208 | + case 189: /* expr ::= nm DOT nm */ | |
| 93172 | 93209 | { |
| 93173 | 93210 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 93174 | 93211 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 93175 | 93212 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0); |
| 93176 | 93213 | spanSet(&yygotominor.yy346,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0); |
| 93177 | 93214 | } |
| 93178 | 93215 | break; |
| 93179 | - case 189: /* expr ::= nm DOT nm DOT nm */ | |
| 93216 | + case 190: /* expr ::= nm DOT nm DOT nm */ | |
| 93180 | 93217 | { |
| 93181 | 93218 | Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0); |
| 93182 | 93219 | Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0); |
| 93183 | 93220 | Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0); |
| 93184 | 93221 | Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0); |
| 93185 | 93222 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0); |
| 93186 | 93223 | spanSet(&yygotominor.yy346,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0); |
| 93187 | 93224 | } |
| 93188 | 93225 | break; |
| 93189 | - case 192: /* expr ::= REGISTER */ | |
| 93226 | + case 193: /* expr ::= REGISTER */ | |
| 93190 | 93227 | { |
| 93191 | 93228 | /* When doing a nested parse, one can include terms in an expression |
| 93192 | 93229 | ** that look like this: #1 #2 ... These terms refer to registers |
| 93193 | 93230 | ** in the virtual machine. #N is the N-th register. */ |
| 93194 | 93231 | if( pParse->nested==0 ){ |
| @@ -93199,31 +93236,31 @@ | ||
| 93199 | 93236 | if( yygotominor.yy346.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy346.pExpr->iTable); |
| 93200 | 93237 | } |
| 93201 | 93238 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 93202 | 93239 | } |
| 93203 | 93240 | break; |
| 93204 | - case 193: /* expr ::= VARIABLE */ | |
| 93241 | + case 194: /* expr ::= VARIABLE */ | |
| 93205 | 93242 | { |
| 93206 | 93243 | spanExpr(&yygotominor.yy346, pParse, TK_VARIABLE, &yymsp[0].minor.yy0); |
| 93207 | 93244 | sqlite3ExprAssignVarNumber(pParse, yygotominor.yy346.pExpr); |
| 93208 | 93245 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 93209 | 93246 | } |
| 93210 | 93247 | break; |
| 93211 | - case 194: /* expr ::= expr COLLATE ids */ | |
| 93248 | + case 195: /* expr ::= expr COLLATE ids */ | |
| 93212 | 93249 | { |
| 93213 | 93250 | yygotominor.yy346.pExpr = sqlite3ExprSetColl(pParse, yymsp[-2].minor.yy346.pExpr, &yymsp[0].minor.yy0); |
| 93214 | 93251 | yygotominor.yy346.zStart = yymsp[-2].minor.yy346.zStart; |
| 93215 | 93252 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93216 | 93253 | } |
| 93217 | 93254 | break; |
| 93218 | - case 195: /* expr ::= CAST LP expr AS typetoken RP */ | |
| 93255 | + case 196: /* expr ::= CAST LP expr AS typetoken RP */ | |
| 93219 | 93256 | { |
| 93220 | 93257 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy346.pExpr, 0, &yymsp[-1].minor.yy0); |
| 93221 | 93258 | spanSet(&yygotominor.yy346,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0); |
| 93222 | 93259 | } |
| 93223 | 93260 | break; |
| 93224 | - case 196: /* expr ::= ID LP distinct exprlist RP */ | |
| 93261 | + case 197: /* expr ::= ID LP distinct exprlist RP */ | |
| 93225 | 93262 | { |
| 93226 | 93263 | if( yymsp[-1].minor.yy14 && yymsp[-1].minor.yy14->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){ |
| 93227 | 93264 | sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0); |
| 93228 | 93265 | } |
| 93229 | 93266 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy14, &yymsp[-4].minor.yy0); |
| @@ -93231,17 +93268,17 @@ | ||
| 93231 | 93268 | if( yymsp[-2].minor.yy328 && yygotominor.yy346.pExpr ){ |
| 93232 | 93269 | yygotominor.yy346.pExpr->flags |= EP_Distinct; |
| 93233 | 93270 | } |
| 93234 | 93271 | } |
| 93235 | 93272 | break; |
| 93236 | - case 197: /* expr ::= ID LP STAR RP */ | |
| 93273 | + case 198: /* expr ::= ID LP STAR RP */ | |
| 93237 | 93274 | { |
| 93238 | 93275 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0); |
| 93239 | 93276 | spanSet(&yygotominor.yy346,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0); |
| 93240 | 93277 | } |
| 93241 | 93278 | break; |
| 93242 | - case 198: /* term ::= CTIME_KW */ | |
| 93279 | + case 199: /* term ::= CTIME_KW */ | |
| 93243 | 93280 | { |
| 93244 | 93281 | /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are |
| 93245 | 93282 | ** treated as functions that return constants */ |
| 93246 | 93283 | yygotominor.yy346.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0); |
| 93247 | 93284 | if( yygotominor.yy346.pExpr ){ |
| @@ -93248,32 +93285,32 @@ | ||
| 93248 | 93285 | yygotominor.yy346.pExpr->op = TK_CONST_FUNC; |
| 93249 | 93286 | } |
| 93250 | 93287 | spanSet(&yygotominor.yy346, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0); |
| 93251 | 93288 | } |
| 93252 | 93289 | 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); | |
| 93261 | 93298 | {spanBinaryExpr(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346);} |
| 93262 | 93299 | 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); | |
| 93265 | 93302 | {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 0;} |
| 93266 | 93303 | 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); | |
| 93269 | 93306 | {yygotominor.yy96.eOperator = yymsp[0].minor.yy0; yygotominor.yy96.not = 1;} |
| 93270 | 93307 | break; |
| 93271 | - case 212: /* escape ::= */ | |
| 93308 | + case 213: /* escape ::= */ | |
| 93272 | 93309 | {memset(&yygotominor.yy346,0,sizeof(yygotominor.yy346));} |
| 93273 | 93310 | break; |
| 93274 | - case 213: /* expr ::= expr likeop expr escape */ | |
| 93311 | + case 214: /* expr ::= expr likeop expr escape */ | |
| 93275 | 93312 | { |
| 93276 | 93313 | ExprList *pList; |
| 93277 | 93314 | pList = sqlite3ExprListAppend(pParse,0, yymsp[-1].minor.yy346.pExpr); |
| 93278 | 93315 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[-3].minor.yy346.pExpr); |
| 93279 | 93316 | if( yymsp[0].minor.yy346.pExpr ){ |
| @@ -93284,39 +93321,39 @@ | ||
| 93284 | 93321 | yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart; |
| 93285 | 93322 | yygotominor.yy346.zEnd = yymsp[-1].minor.yy346.zEnd; |
| 93286 | 93323 | if( yygotominor.yy346.pExpr ) yygotominor.yy346.pExpr->flags |= EP_InfixFunc; |
| 93287 | 93324 | } |
| 93288 | 93325 | break; |
| 93289 | - case 214: /* expr ::= expr ISNULL|NOTNULL */ | |
| 93326 | + case 215: /* expr ::= expr ISNULL|NOTNULL */ | |
| 93290 | 93327 | {spanUnaryPostfix(&yygotominor.yy346,pParse,yymsp[0].major,&yymsp[-1].minor.yy346,&yymsp[0].minor.yy0);} |
| 93291 | 93328 | break; |
| 93292 | - case 215: /* expr ::= expr NOT NULL */ | |
| 93329 | + case 216: /* expr ::= expr NOT NULL */ | |
| 93293 | 93330 | {spanUnaryPostfix(&yygotominor.yy346,pParse,TK_NOTNULL,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy0);} |
| 93294 | 93331 | break; |
| 93295 | - case 216: /* expr ::= expr IS expr */ | |
| 93332 | + case 217: /* expr ::= expr IS expr */ | |
| 93296 | 93333 | { |
| 93297 | 93334 | spanBinaryExpr(&yygotominor.yy346,pParse,TK_IS,&yymsp[-2].minor.yy346,&yymsp[0].minor.yy346); |
| 93298 | 93335 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_ISNULL); |
| 93299 | 93336 | } |
| 93300 | 93337 | break; |
| 93301 | - case 217: /* expr ::= expr IS NOT expr */ | |
| 93338 | + case 218: /* expr ::= expr IS NOT expr */ | |
| 93302 | 93339 | { |
| 93303 | 93340 | spanBinaryExpr(&yygotominor.yy346,pParse,TK_ISNOT,&yymsp[-3].minor.yy346,&yymsp[0].minor.yy346); |
| 93304 | 93341 | binaryToUnaryIfNull(pParse, yymsp[0].minor.yy346.pExpr, yygotominor.yy346.pExpr, TK_NOTNULL); |
| 93305 | 93342 | } |
| 93306 | 93343 | 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); | |
| 93309 | 93346 | {spanUnaryPrefix(&yygotominor.yy346,pParse,yymsp[-1].major,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 93310 | 93347 | break; |
| 93311 | - case 220: /* expr ::= MINUS expr */ | |
| 93348 | + case 221: /* expr ::= MINUS expr */ | |
| 93312 | 93349 | {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UMINUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 93313 | 93350 | break; |
| 93314 | - case 221: /* expr ::= PLUS expr */ | |
| 93351 | + case 222: /* expr ::= PLUS expr */ | |
| 93315 | 93352 | {spanUnaryPrefix(&yygotominor.yy346,pParse,TK_UPLUS,&yymsp[0].minor.yy346,&yymsp[-1].minor.yy0);} |
| 93316 | 93353 | break; |
| 93317 | - case 224: /* expr ::= expr between_op expr AND expr */ | |
| 93354 | + case 225: /* expr ::= expr between_op expr AND expr */ | |
| 93318 | 93355 | { |
| 93319 | 93356 | ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr); |
| 93320 | 93357 | pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy346.pExpr); |
| 93321 | 93358 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy346.pExpr, 0, 0); |
| 93322 | 93359 | if( yygotominor.yy346.pExpr ){ |
| @@ -93327,11 +93364,11 @@ | ||
| 93327 | 93364 | if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 93328 | 93365 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 93329 | 93366 | yygotominor.yy346.zEnd = yymsp[0].minor.yy346.zEnd; |
| 93330 | 93367 | } |
| 93331 | 93368 | break; |
| 93332 | - case 227: /* expr ::= expr in_op LP exprlist RP */ | |
| 93369 | + case 228: /* expr ::= expr in_op LP exprlist RP */ | |
| 93333 | 93370 | { |
| 93334 | 93371 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0); |
| 93335 | 93372 | if( yygotominor.yy346.pExpr ){ |
| 93336 | 93373 | yygotominor.yy346.pExpr->x.pList = yymsp[-1].minor.yy14; |
| 93337 | 93374 | sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr); |
| @@ -93341,11 +93378,11 @@ | ||
| 93341 | 93378 | if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 93342 | 93379 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 93343 | 93380 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93344 | 93381 | } |
| 93345 | 93382 | break; |
| 93346 | - case 228: /* expr ::= LP select RP */ | |
| 93383 | + case 229: /* expr ::= LP select RP */ | |
| 93347 | 93384 | { |
| 93348 | 93385 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0); |
| 93349 | 93386 | if( yygotominor.yy346.pExpr ){ |
| 93350 | 93387 | yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3; |
| 93351 | 93388 | ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect); |
| @@ -93355,11 +93392,11 @@ | ||
| 93355 | 93392 | } |
| 93356 | 93393 | yygotominor.yy346.zStart = yymsp[-2].minor.yy0.z; |
| 93357 | 93394 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93358 | 93395 | } |
| 93359 | 93396 | break; |
| 93360 | - case 229: /* expr ::= expr in_op LP select RP */ | |
| 93397 | + case 230: /* expr ::= expr in_op LP select RP */ | |
| 93361 | 93398 | { |
| 93362 | 93399 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy346.pExpr, 0, 0); |
| 93363 | 93400 | if( yygotominor.yy346.pExpr ){ |
| 93364 | 93401 | yygotominor.yy346.pExpr->x.pSelect = yymsp[-1].minor.yy3; |
| 93365 | 93402 | ExprSetProperty(yygotominor.yy346.pExpr, EP_xIsSelect); |
| @@ -93370,11 +93407,11 @@ | ||
| 93370 | 93407 | if( yymsp[-3].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 93371 | 93408 | yygotominor.yy346.zStart = yymsp[-4].minor.yy346.zStart; |
| 93372 | 93409 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93373 | 93410 | } |
| 93374 | 93411 | break; |
| 93375 | - case 230: /* expr ::= expr in_op nm dbnm */ | |
| 93412 | + case 231: /* expr ::= expr in_op nm dbnm */ | |
| 93376 | 93413 | { |
| 93377 | 93414 | SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0); |
| 93378 | 93415 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy346.pExpr, 0, 0); |
| 93379 | 93416 | if( yygotominor.yy346.pExpr ){ |
| 93380 | 93417 | yygotominor.yy346.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0); |
| @@ -93386,11 +93423,11 @@ | ||
| 93386 | 93423 | if( yymsp[-2].minor.yy328 ) yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy346.pExpr, 0, 0); |
| 93387 | 93424 | yygotominor.yy346.zStart = yymsp[-3].minor.yy346.zStart; |
| 93388 | 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]; |
| 93389 | 93426 | } |
| 93390 | 93427 | break; |
| 93391 | - case 231: /* expr ::= EXISTS LP select RP */ | |
| 93428 | + case 232: /* expr ::= EXISTS LP select RP */ | |
| 93392 | 93429 | { |
| 93393 | 93430 | Expr *p = yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0); |
| 93394 | 93431 | if( p ){ |
| 93395 | 93432 | p->x.pSelect = yymsp[-1].minor.yy3; |
| 93396 | 93433 | ExprSetProperty(p, EP_xIsSelect); |
| @@ -93400,11 +93437,11 @@ | ||
| 93400 | 93437 | } |
| 93401 | 93438 | yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z; |
| 93402 | 93439 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93403 | 93440 | } |
| 93404 | 93441 | 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 */ | |
| 93406 | 93443 | { |
| 93407 | 93444 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy132, yymsp[-1].minor.yy132, 0); |
| 93408 | 93445 | if( yygotominor.yy346.pExpr ){ |
| 93409 | 93446 | yygotominor.yy346.pExpr->x.pList = yymsp[-2].minor.yy14; |
| 93410 | 93447 | sqlite3ExprSetHeight(pParse, yygotominor.yy346.pExpr); |
| @@ -93413,37 +93450,37 @@ | ||
| 93413 | 93450 | } |
| 93414 | 93451 | yygotominor.yy346.zStart = yymsp[-4].minor.yy0.z; |
| 93415 | 93452 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93416 | 93453 | } |
| 93417 | 93454 | break; |
| 93418 | - case 233: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 93455 | + case 234: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */ | |
| 93419 | 93456 | { |
| 93420 | 93457 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy14, yymsp[-2].minor.yy346.pExpr); |
| 93421 | 93458 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr); |
| 93422 | 93459 | } |
| 93423 | 93460 | break; |
| 93424 | - case 234: /* case_exprlist ::= WHEN expr THEN expr */ | |
| 93461 | + case 235: /* case_exprlist ::= WHEN expr THEN expr */ | |
| 93425 | 93462 | { |
| 93426 | 93463 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy346.pExpr); |
| 93427 | 93464 | yygotominor.yy14 = sqlite3ExprListAppend(pParse,yygotominor.yy14, yymsp[0].minor.yy346.pExpr); |
| 93428 | 93465 | } |
| 93429 | 93466 | 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 */ | |
| 93431 | 93468 | { |
| 93432 | 93469 | sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, |
| 93433 | 93470 | sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy14, yymsp[-9].minor.yy328, |
| 93434 | 93471 | &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy328); |
| 93435 | 93472 | } |
| 93436 | 93473 | 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); | |
| 93439 | 93476 | {yygotominor.yy328 = OE_Abort;} |
| 93440 | 93477 | break; |
| 93441 | - case 245: /* uniqueflag ::= */ | |
| 93478 | + case 246: /* uniqueflag ::= */ | |
| 93442 | 93479 | {yygotominor.yy328 = OE_None;} |
| 93443 | 93480 | break; |
| 93444 | - case 248: /* idxlist ::= idxlist COMMA nm collate sortorder */ | |
| 93481 | + case 249: /* idxlist ::= idxlist COMMA nm collate sortorder */ | |
| 93445 | 93482 | { |
| 93446 | 93483 | Expr *p = 0; |
| 93447 | 93484 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 93448 | 93485 | p = sqlite3Expr(pParse->db, TK_COLUMN, 0); |
| 93449 | 93486 | sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -93452,11 +93489,11 @@ | ||
| 93452 | 93489 | sqlite3ExprListSetName(pParse,yygotominor.yy14,&yymsp[-2].minor.yy0,1); |
| 93453 | 93490 | sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 93454 | 93491 | if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 93455 | 93492 | } |
| 93456 | 93493 | break; |
| 93457 | - case 249: /* idxlist ::= nm collate sortorder */ | |
| 93494 | + case 250: /* idxlist ::= nm collate sortorder */ | |
| 93458 | 93495 | { |
| 93459 | 93496 | Expr *p = 0; |
| 93460 | 93497 | if( yymsp[-1].minor.yy0.n>0 ){ |
| 93461 | 93498 | p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0); |
| 93462 | 93499 | sqlite3ExprSetColl(pParse, p, &yymsp[-1].minor.yy0); |
| @@ -93465,212 +93502,212 @@ | ||
| 93465 | 93502 | sqlite3ExprListSetName(pParse, yygotominor.yy14, &yymsp[-2].minor.yy0, 1); |
| 93466 | 93503 | sqlite3ExprListCheckLength(pParse, yygotominor.yy14, "index"); |
| 93467 | 93504 | if( yygotominor.yy14 ) yygotominor.yy14->a[yygotominor.yy14->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy328; |
| 93468 | 93505 | } |
| 93469 | 93506 | break; |
| 93470 | - case 250: /* collate ::= */ | |
| 93507 | + case 251: /* collate ::= */ | |
| 93471 | 93508 | {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;} |
| 93472 | 93509 | break; |
| 93473 | - case 252: /* cmd ::= DROP INDEX ifexists fullname */ | |
| 93510 | + case 253: /* cmd ::= DROP INDEX ifexists fullname */ | |
| 93474 | 93511 | {sqlite3DropIndex(pParse, yymsp[0].minor.yy65, yymsp[-1].minor.yy328);} |
| 93475 | 93512 | 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); | |
| 93478 | 93515 | {sqlite3Vacuum(pParse);} |
| 93479 | 93516 | break; |
| 93480 | - case 255: /* cmd ::= PRAGMA nm dbnm */ | |
| 93517 | + case 256: /* cmd ::= PRAGMA nm dbnm */ | |
| 93481 | 93518 | {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);} |
| 93482 | 93519 | break; |
| 93483 | - case 256: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 93520 | + case 257: /* cmd ::= PRAGMA nm dbnm EQ nmnum */ | |
| 93484 | 93521 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);} |
| 93485 | 93522 | break; |
| 93486 | - case 257: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 93523 | + case 258: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */ | |
| 93487 | 93524 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);} |
| 93488 | 93525 | break; |
| 93489 | - case 258: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 93526 | + case 259: /* cmd ::= PRAGMA nm dbnm EQ minus_num */ | |
| 93490 | 93527 | {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);} |
| 93491 | 93528 | break; |
| 93492 | - case 259: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 93529 | + case 260: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */ | |
| 93493 | 93530 | {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);} |
| 93494 | 93531 | 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 */ | |
| 93496 | 93533 | { |
| 93497 | 93534 | Token all; |
| 93498 | 93535 | all.z = yymsp[-3].minor.yy0.z; |
| 93499 | 93536 | all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n; |
| 93500 | 93537 | sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy473, &all); |
| 93501 | 93538 | } |
| 93502 | 93539 | 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 */ | |
| 93504 | 93541 | { |
| 93505 | 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); |
| 93506 | 93543 | yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0); |
| 93507 | 93544 | } |
| 93508 | 93545 | 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); | |
| 93511 | 93548 | { yygotominor.yy328 = TK_BEFORE; } |
| 93512 | 93549 | break; |
| 93513 | - case 273: /* trigger_time ::= AFTER */ | |
| 93550 | + case 274: /* trigger_time ::= AFTER */ | |
| 93514 | 93551 | { yygotominor.yy328 = TK_AFTER; } |
| 93515 | 93552 | break; |
| 93516 | - case 274: /* trigger_time ::= INSTEAD OF */ | |
| 93553 | + case 275: /* trigger_time ::= INSTEAD OF */ | |
| 93517 | 93554 | { yygotominor.yy328 = TK_INSTEAD;} |
| 93518 | 93555 | 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); | |
| 93521 | 93558 | {yygotominor.yy378.a = yymsp[0].major; yygotominor.yy378.b = 0;} |
| 93522 | 93559 | break; |
| 93523 | - case 278: /* trigger_event ::= UPDATE OF inscollist */ | |
| 93560 | + case 279: /* trigger_event ::= UPDATE OF inscollist */ | |
| 93524 | 93561 | {yygotominor.yy378.a = TK_UPDATE; yygotominor.yy378.b = yymsp[0].minor.yy408;} |
| 93525 | 93562 | 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); | |
| 93528 | 93565 | { yygotominor.yy132 = 0; } |
| 93529 | 93566 | 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); | |
| 93532 | 93569 | { yygotominor.yy132 = yymsp[0].minor.yy346.pExpr; } |
| 93533 | 93570 | 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 */ | |
| 93535 | 93572 | { |
| 93536 | 93573 | assert( yymsp[-2].minor.yy473!=0 ); |
| 93537 | 93574 | yymsp[-2].minor.yy473->pLast->pNext = yymsp[-1].minor.yy473; |
| 93538 | 93575 | yymsp[-2].minor.yy473->pLast = yymsp[-1].minor.yy473; |
| 93539 | 93576 | yygotominor.yy473 = yymsp[-2].minor.yy473; |
| 93540 | 93577 | } |
| 93541 | 93578 | break; |
| 93542 | - case 284: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 93579 | + case 285: /* trigger_cmd_list ::= trigger_cmd SEMI */ | |
| 93543 | 93580 | { |
| 93544 | 93581 | assert( yymsp[-1].minor.yy473!=0 ); |
| 93545 | 93582 | yymsp[-1].minor.yy473->pLast = yymsp[-1].minor.yy473; |
| 93546 | 93583 | yygotominor.yy473 = yymsp[-1].minor.yy473; |
| 93547 | 93584 | } |
| 93548 | 93585 | break; |
| 93549 | - case 286: /* trnm ::= nm DOT nm */ | |
| 93586 | + case 287: /* trnm ::= nm DOT nm */ | |
| 93550 | 93587 | { |
| 93551 | 93588 | yygotominor.yy0 = yymsp[0].minor.yy0; |
| 93552 | 93589 | sqlite3ErrorMsg(pParse, |
| 93553 | 93590 | "qualified table names are not allowed on INSERT, UPDATE, and DELETE " |
| 93554 | 93591 | "statements within triggers"); |
| 93555 | 93592 | } |
| 93556 | 93593 | break; |
| 93557 | - case 288: /* tridxby ::= INDEXED BY nm */ | |
| 93594 | + case 289: /* tridxby ::= INDEXED BY nm */ | |
| 93558 | 93595 | { |
| 93559 | 93596 | sqlite3ErrorMsg(pParse, |
| 93560 | 93597 | "the INDEXED BY clause is not allowed on UPDATE or DELETE statements " |
| 93561 | 93598 | "within triggers"); |
| 93562 | 93599 | } |
| 93563 | 93600 | break; |
| 93564 | - case 289: /* tridxby ::= NOT INDEXED */ | |
| 93601 | + case 290: /* tridxby ::= NOT INDEXED */ | |
| 93565 | 93602 | { |
| 93566 | 93603 | sqlite3ErrorMsg(pParse, |
| 93567 | 93604 | "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements " |
| 93568 | 93605 | "within triggers"); |
| 93569 | 93606 | } |
| 93570 | 93607 | 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 */ | |
| 93572 | 93609 | { yygotominor.yy473 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy14, yymsp[0].minor.yy132, yymsp[-5].minor.yy186); } |
| 93573 | 93610 | 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 */ | |
| 93575 | 93612 | {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-5].minor.yy0, yymsp[-4].minor.yy408, yymsp[-1].minor.yy14, 0, yymsp[-7].minor.yy186);} |
| 93576 | 93613 | 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 */ | |
| 93578 | 93615 | {yygotominor.yy473 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy408, 0, yymsp[0].minor.yy3, yymsp[-4].minor.yy186);} |
| 93579 | 93616 | break; |
| 93580 | - case 293: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ | |
| 93617 | + case 294: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */ | |
| 93581 | 93618 | {yygotominor.yy473 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy132);} |
| 93582 | 93619 | break; |
| 93583 | - case 294: /* trigger_cmd ::= select */ | |
| 93620 | + case 295: /* trigger_cmd ::= select */ | |
| 93584 | 93621 | {yygotominor.yy473 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy3); } |
| 93585 | 93622 | break; |
| 93586 | - case 295: /* expr ::= RAISE LP IGNORE RP */ | |
| 93623 | + case 296: /* expr ::= RAISE LP IGNORE RP */ | |
| 93587 | 93624 | { |
| 93588 | 93625 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0); |
| 93589 | 93626 | if( yygotominor.yy346.pExpr ){ |
| 93590 | 93627 | yygotominor.yy346.pExpr->affinity = OE_Ignore; |
| 93591 | 93628 | } |
| 93592 | 93629 | yygotominor.yy346.zStart = yymsp[-3].minor.yy0.z; |
| 93593 | 93630 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93594 | 93631 | } |
| 93595 | 93632 | break; |
| 93596 | - case 296: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 93633 | + case 297: /* expr ::= RAISE LP raisetype COMMA nm RP */ | |
| 93597 | 93634 | { |
| 93598 | 93635 | yygotominor.yy346.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0); |
| 93599 | 93636 | if( yygotominor.yy346.pExpr ) { |
| 93600 | 93637 | yygotominor.yy346.pExpr->affinity = (char)yymsp[-3].minor.yy328; |
| 93601 | 93638 | } |
| 93602 | 93639 | yygotominor.yy346.zStart = yymsp[-5].minor.yy0.z; |
| 93603 | 93640 | yygotominor.yy346.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n]; |
| 93604 | 93641 | } |
| 93605 | 93642 | break; |
| 93606 | - case 297: /* raisetype ::= ROLLBACK */ | |
| 93643 | + case 298: /* raisetype ::= ROLLBACK */ | |
| 93607 | 93644 | {yygotominor.yy328 = OE_Rollback;} |
| 93608 | 93645 | break; |
| 93609 | - case 299: /* raisetype ::= FAIL */ | |
| 93646 | + case 300: /* raisetype ::= FAIL */ | |
| 93610 | 93647 | {yygotominor.yy328 = OE_Fail;} |
| 93611 | 93648 | break; |
| 93612 | - case 300: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 93649 | + case 301: /* cmd ::= DROP TRIGGER ifexists fullname */ | |
| 93613 | 93650 | { |
| 93614 | 93651 | sqlite3DropTrigger(pParse,yymsp[0].minor.yy65,yymsp[-1].minor.yy328); |
| 93615 | 93652 | } |
| 93616 | 93653 | 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 */ | |
| 93618 | 93655 | { |
| 93619 | 93656 | sqlite3Attach(pParse, yymsp[-3].minor.yy346.pExpr, yymsp[-1].minor.yy346.pExpr, yymsp[0].minor.yy132); |
| 93620 | 93657 | } |
| 93621 | 93658 | break; |
| 93622 | - case 302: /* cmd ::= DETACH database_kw_opt expr */ | |
| 93659 | + case 303: /* cmd ::= DETACH database_kw_opt expr */ | |
| 93623 | 93660 | { |
| 93624 | 93661 | sqlite3Detach(pParse, yymsp[0].minor.yy346.pExpr); |
| 93625 | 93662 | } |
| 93626 | 93663 | break; |
| 93627 | - case 307: /* cmd ::= REINDEX */ | |
| 93664 | + case 308: /* cmd ::= REINDEX */ | |
| 93628 | 93665 | {sqlite3Reindex(pParse, 0, 0);} |
| 93629 | 93666 | break; |
| 93630 | - case 308: /* cmd ::= REINDEX nm dbnm */ | |
| 93667 | + case 309: /* cmd ::= REINDEX nm dbnm */ | |
| 93631 | 93668 | {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 93632 | 93669 | break; |
| 93633 | - case 309: /* cmd ::= ANALYZE */ | |
| 93670 | + case 310: /* cmd ::= ANALYZE */ | |
| 93634 | 93671 | {sqlite3Analyze(pParse, 0, 0);} |
| 93635 | 93672 | break; |
| 93636 | - case 310: /* cmd ::= ANALYZE nm dbnm */ | |
| 93673 | + case 311: /* cmd ::= ANALYZE nm dbnm */ | |
| 93637 | 93674 | {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);} |
| 93638 | 93675 | break; |
| 93639 | - case 311: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 93676 | + case 312: /* cmd ::= ALTER TABLE fullname RENAME TO nm */ | |
| 93640 | 93677 | { |
| 93641 | 93678 | sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy65,&yymsp[0].minor.yy0); |
| 93642 | 93679 | } |
| 93643 | 93680 | 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 */ | |
| 93645 | 93682 | { |
| 93646 | 93683 | sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0); |
| 93647 | 93684 | } |
| 93648 | 93685 | break; |
| 93649 | - case 313: /* add_column_fullname ::= fullname */ | |
| 93686 | + case 314: /* add_column_fullname ::= fullname */ | |
| 93650 | 93687 | { |
| 93651 | 93688 | pParse->db->lookaside.bEnabled = 0; |
| 93652 | 93689 | sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy65); |
| 93653 | 93690 | } |
| 93654 | 93691 | break; |
| 93655 | - case 316: /* cmd ::= create_vtab */ | |
| 93692 | + case 317: /* cmd ::= create_vtab */ | |
| 93656 | 93693 | {sqlite3VtabFinishParse(pParse,0);} |
| 93657 | 93694 | break; |
| 93658 | - case 317: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 93695 | + case 318: /* cmd ::= create_vtab LP vtabarglist RP */ | |
| 93659 | 93696 | {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);} |
| 93660 | 93697 | 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 */ | |
| 93662 | 93699 | { |
| 93663 | 93700 | sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); |
| 93664 | 93701 | } |
| 93665 | 93702 | break; |
| 93666 | - case 321: /* vtabarg ::= */ | |
| 93703 | + case 322: /* vtabarg ::= */ | |
| 93667 | 93704 | {sqlite3VtabArgInit(pParse);} |
| 93668 | 93705 | 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); | |
| 93672 | 93709 | {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);} |
| 93673 | 93710 | break; |
| 93674 | 93711 | default: |
| 93675 | 93712 | /* (0) input ::= cmdlist */ yytestcase(yyruleno==0); |
| 93676 | 93713 | /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1); |
| @@ -93691,29 +93728,29 @@ | ||
| 93691 | 93728 | /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53); |
| 93692 | 93729 | /* (54) carglist ::= */ yytestcase(yyruleno==54); |
| 93693 | 93730 | /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55); |
| 93694 | 93731 | /* (56) carg ::= ccons */ yytestcase(yyruleno==56); |
| 93695 | 93732 | /* (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); | |
| 93715 | 93752 | break; |
| 93716 | 93753 | }; |
| 93717 | 93754 | yygoto = yyRuleInfo[yyruleno].lhs; |
| 93718 | 93755 | yysize = yyRuleInfo[yyruleno].nrhs; |
| 93719 | 93756 | yypParser->yyidx -= yysize; |
| @@ -94300,10 +94337,11 @@ | ||
| 94300 | 94337 | return TK_ID; |
| 94301 | 94338 | } |
| 94302 | 94339 | SQLITE_PRIVATE int sqlite3KeywordCode(const unsigned char *z, int n){ |
| 94303 | 94340 | return keywordCode((char*)z, n); |
| 94304 | 94341 | } |
| 94342 | +#define SQLITE_N_KEYWORD 121 | |
| 94305 | 94343 | |
| 94306 | 94344 | /************** End of keywordhash.h *****************************************/ |
| 94307 | 94345 | /************** Continuing where we left off in tokenize.c *******************/ |
| 94308 | 94346 | |
| 94309 | 94347 | |
| @@ -94363,12 +94401,13 @@ | ||
| 94363 | 94401 | *tokenType = TK_SPACE; |
| 94364 | 94402 | return i; |
| 94365 | 94403 | } |
| 94366 | 94404 | case '-': { |
| 94367 | 94405 | if( z[1]=='-' ){ |
| 94406 | + /* IMP: R-15891-05542 -- syntax diagram for comments */ | |
| 94368 | 94407 | for(i=2; (c=z[i])!=0 && c!='\n'; i++){} |
| 94369 | - *tokenType = TK_SPACE; | |
| 94408 | + *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ | |
| 94370 | 94409 | return i; |
| 94371 | 94410 | } |
| 94372 | 94411 | *tokenType = TK_MINUS; |
| 94373 | 94412 | return 1; |
| 94374 | 94413 | } |
| @@ -94395,13 +94434,14 @@ | ||
| 94395 | 94434 | case '/': { |
| 94396 | 94435 | if( z[1]!='*' || z[2]==0 ){ |
| 94397 | 94436 | *tokenType = TK_SLASH; |
| 94398 | 94437 | return 1; |
| 94399 | 94438 | } |
| 94439 | + /* IMP: R-15891-05542 -- syntax diagram for comments */ | |
| 94400 | 94440 | for(i=3, c=z[2]; (c!='*' || z[i]!='/') && (c=z[i])!=0; i++){} |
| 94401 | 94441 | if( c ) i++; |
| 94402 | - *tokenType = TK_SPACE; | |
| 94442 | + *tokenType = TK_SPACE; /* IMP: R-22934-25134 */ | |
| 94403 | 94443 | return i; |
| 94404 | 94444 | } |
| 94405 | 94445 | case '%': { |
| 94406 | 94446 | *tokenType = TK_REM; |
| 94407 | 94447 | return 1; |
| @@ -94806,61 +94846,66 @@ | ||
| 94806 | 94846 | ** comments on that procedure for additional information. |
| 94807 | 94847 | */ |
| 94808 | 94848 | #define tkSEMI 0 |
| 94809 | 94849 | #define tkWS 1 |
| 94810 | 94850 | #define tkOTHER 2 |
| 94851 | +#ifndef SQLITE_OMIT_TRIGGER | |
| 94811 | 94852 | #define tkEXPLAIN 3 |
| 94812 | 94853 | #define tkCREATE 4 |
| 94813 | 94854 | #define tkTEMP 5 |
| 94814 | 94855 | #define tkTRIGGER 6 |
| 94815 | 94856 | #define tkEND 7 |
| 94857 | +#endif | |
| 94816 | 94858 | |
| 94817 | 94859 | /* |
| 94818 | 94860 | ** Return TRUE if the given SQL string ends in a semicolon. |
| 94819 | 94861 | ** |
| 94820 | 94862 | ** Special handling is require for CREATE TRIGGER statements. |
| 94821 | 94863 | ** Whenever the CREATE TRIGGER keywords are seen, the statement |
| 94822 | 94864 | ** must end with ";END;". |
| 94823 | 94865 | ** |
| 94824 | -** This implementation uses a state machine with 7 states: | |
| 94866 | +** This implementation uses a state machine with 8 states: | |
| 94825 | 94867 | ** |
| 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 | |
| 94827 | 94871 | ** returns 1 if it ends in the START state and 0 if it ends |
| 94828 | 94872 | ** in any other state. |
| 94829 | 94873 | ** |
| 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 | |
| 94831 | 94875 | ** semicolon. |
| 94832 | 94876 | ** |
| 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 | |
| 94834 | 94878 | ** a statement. |
| 94835 | 94879 | ** |
| 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 | |
| 94837 | 94881 | ** statement, possibly preceeded by EXPLAIN and/or followed by |
| 94838 | 94882 | ** TEMP or TEMPORARY |
| 94839 | 94883 | ** |
| 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 | |
| 94841 | 94885 | ** ended by a semicolon, the keyword END, and another semicolon. |
| 94842 | 94886 | ** |
| 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 | |
| 94844 | 94888 | ** the end of a trigger definition. |
| 94845 | 94889 | ** |
| 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 | |
| 94847 | 94891 | ** of a trigger difinition. |
| 94848 | 94892 | ** |
| 94849 | 94893 | ** Transitions between states above are determined by tokens extracted |
| 94850 | 94894 | ** from the input. The following tokens are significant: |
| 94851 | 94895 | ** |
| 94852 | 94896 | ** (0) tkSEMI A semicolon. |
| 94853 | -** (1) tkWS Whitespace | |
| 94897 | +** (1) tkWS Whitespace. | |
| 94854 | 94898 | ** (2) tkOTHER Any other SQL token. |
| 94855 | 94899 | ** (3) tkEXPLAIN The "explain" keyword. |
| 94856 | 94900 | ** (4) tkCREATE The "create" keyword. |
| 94857 | 94901 | ** (5) tkTEMP The "temp" or "temporary" keyword. |
| 94858 | 94902 | ** (6) tkTRIGGER The "trigger" keyword. |
| 94859 | 94903 | ** (7) tkEND The "end" keyword. |
| 94860 | 94904 | ** |
| 94861 | 94905 | ** Whitespace never causes a state transition and is always ignored. |
| 94906 | +** This means that a SQL string of all whitespace is invalid. | |
| 94862 | 94907 | ** |
| 94863 | 94908 | ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed |
| 94864 | 94909 | ** to recognize the end of a trigger can be omitted. All we have to do |
| 94865 | 94910 | ** is look for a semicolon that is not part of an string or comment. |
| 94866 | 94911 | */ |
| @@ -94870,30 +94915,32 @@ | ||
| 94870 | 94915 | |
| 94871 | 94916 | #ifndef SQLITE_OMIT_TRIGGER |
| 94872 | 94917 | /* A complex statement machine used to detect the end of a CREATE TRIGGER |
| 94873 | 94918 | ** statement. This is the normal case. |
| 94874 | 94919 | */ |
| 94875 | - static const u8 trans[7][8] = { | |
| 94920 | + static const u8 trans[8][8] = { | |
| 94876 | 94921 | /* 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, }, | |
| 94885 | 94931 | }; |
| 94886 | 94932 | #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 | |
| 94888 | 94934 | ** used to detect the end of a statement is much simplier |
| 94889 | 94935 | */ |
| 94890 | - static const u8 trans[2][3] = { | |
| 94936 | + static const u8 trans[3][3] = { | |
| 94891 | 94937 | /* Token: */ |
| 94892 | 94938 | /* 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, }, | |
| 94895 | 94942 | }; |
| 94896 | 94943 | #endif /* SQLITE_OMIT_TRIGGER */ |
| 94897 | 94944 | |
| 94898 | 94945 | while( *zSql ){ |
| 94899 | 94946 | switch( *zSql ){ |
| @@ -94925,11 +94972,11 @@ | ||
| 94925 | 94972 | if( zSql[1]!='-' ){ |
| 94926 | 94973 | token = tkOTHER; |
| 94927 | 94974 | break; |
| 94928 | 94975 | } |
| 94929 | 94976 | while( *zSql && *zSql!='\n' ){ zSql++; } |
| 94930 | - if( *zSql==0 ) return state==0; | |
| 94977 | + if( *zSql==0 ) return state==1; | |
| 94931 | 94978 | token = tkWS; |
| 94932 | 94979 | break; |
| 94933 | 94980 | } |
| 94934 | 94981 | case '[': { /* Microsoft-style identifiers in [...] */ |
| 94935 | 94982 | zSql++; |
| @@ -95009,11 +95056,11 @@ | ||
| 95009 | 95056 | } |
| 95010 | 95057 | } |
| 95011 | 95058 | state = trans[state][token]; |
| 95012 | 95059 | zSql++; |
| 95013 | 95060 | } |
| 95014 | - return state==0; | |
| 95061 | + return state==1; | |
| 95015 | 95062 | } |
| 95016 | 95063 | |
| 95017 | 95064 | #ifndef SQLITE_OMIT_UTF16 |
| 95018 | 95065 | /* |
| 95019 | 95066 | ** This routine is the same as the sqlite3_complete() routine described |
| @@ -95397,11 +95444,11 @@ | ||
| 95397 | 95444 | switch( op ){ |
| 95398 | 95445 | |
| 95399 | 95446 | /* Mutex configuration options are only available in a threadsafe |
| 95400 | 95447 | ** compile. |
| 95401 | 95448 | */ |
| 95402 | -#if SQLITE_THREADSAFE | |
| 95449 | +#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE>0 | |
| 95403 | 95450 | case SQLITE_CONFIG_SINGLETHREAD: { |
| 95404 | 95451 | /* Disable all mutexing */ |
| 95405 | 95452 | sqlite3GlobalConfig.bCoreMutex = 0; |
| 95406 | 95453 | sqlite3GlobalConfig.bFullMutex = 0; |
| 95407 | 95454 | break; |
| @@ -97413,10 +97460,44 @@ | ||
| 97413 | 97460 | sqlite3BtreeSetPageSize(db->aDb[0].pBt, 0, x, 0); |
| 97414 | 97461 | sqlite3_mutex_leave(db->mutex); |
| 97415 | 97462 | break; |
| 97416 | 97463 | } |
| 97417 | 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 | + | |
| 97418 | 97499 | } |
| 97419 | 97500 | va_end(ap); |
| 97420 | 97501 | #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| 97421 | 97502 | return rc; |
| 97422 | 97503 | } |
| @@ -98203,10 +98284,14 @@ | ||
| 98203 | 98284 | |
| 98204 | 98285 | struct sqlite3_tokenizer_cursor { |
| 98205 | 98286 | sqlite3_tokenizer *pTokenizer; /* Tokenizer for this cursor. */ |
| 98206 | 98287 | /* Tokenizer implementations will typically add additional fields */ |
| 98207 | 98288 | }; |
| 98289 | + | |
| 98290 | +int fts3_global_term_cnt(int iTerm, int iCol); | |
| 98291 | +int fts3_term_cnt(int iTerm, int iCol); | |
| 98292 | + | |
| 98208 | 98293 | |
| 98209 | 98294 | #endif /* _FTS3_TOKENIZER_H_ */ |
| 98210 | 98295 | |
| 98211 | 98296 | /************** End of fts3_tokenizer.h **************************************/ |
| 98212 | 98297 | /************** Continuing where we left off in fts3Int.h ********************/ |
| @@ -98287,18 +98372,20 @@ | ||
| 98287 | 98372 | */ |
| 98288 | 98373 | SQLITE_PRIVATE void sqlite3Fts3HashInit(Fts3Hash *pNew, char keyClass, char copyKey); |
| 98289 | 98374 | SQLITE_PRIVATE void *sqlite3Fts3HashInsert(Fts3Hash*, const void *pKey, int nKey, void *pData); |
| 98290 | 98375 | SQLITE_PRIVATE void *sqlite3Fts3HashFind(const Fts3Hash*, const void *pKey, int nKey); |
| 98291 | 98376 | SQLITE_PRIVATE void sqlite3Fts3HashClear(Fts3Hash*); |
| 98377 | +SQLITE_PRIVATE Fts3HashElem *sqlite3Fts3HashFindElem(const Fts3Hash *, const void *, int); | |
| 98292 | 98378 | |
| 98293 | 98379 | /* |
| 98294 | 98380 | ** Shorthand for the functions above |
| 98295 | 98381 | */ |
| 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 | |
| 98300 | 98387 | |
| 98301 | 98388 | /* |
| 98302 | 98389 | ** Macros for looping over all elements of a hash table. The idiom is |
| 98303 | 98390 | ** like this: |
| 98304 | 98391 | ** |
| @@ -98371,10 +98458,12 @@ | ||
| 98371 | 98458 | /* |
| 98372 | 98459 | ** Internal types used by SQLite. |
| 98373 | 98460 | */ |
| 98374 | 98461 | typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */ |
| 98375 | 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 */ | |
| 98376 | 98465 | /* |
| 98377 | 98466 | ** Macro used to suppress compiler warnings for unused parameters. |
| 98378 | 98467 | */ |
| 98379 | 98468 | #define UNUSED_PARAMETER(x) (void)(x) |
| 98380 | 98469 | #endif |
| @@ -98421,14 +98510,15 @@ | ||
| 98421 | 98510 | int nNodeSize; /* Soft limit for node size */ |
| 98422 | 98511 | |
| 98423 | 98512 | /* The following hash table is used to buffer pending index updates during |
| 98424 | 98513 | ** transactions. Variable nPendingData estimates the memory size of the |
| 98425 | 98514 | ** 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 | |
| 98427 | 98516 | ** automatically. Variable iPrevDocid is the docid of the most recently |
| 98428 | 98517 | ** inserted record. |
| 98429 | 98518 | */ |
| 98519 | + int nMaxPendingData; | |
| 98430 | 98520 | int nPendingData; |
| 98431 | 98521 | sqlite_int64 iPrevDocid; |
| 98432 | 98522 | Fts3Hash pendingTerms; |
| 98433 | 98523 | }; |
| 98434 | 98524 | |
| @@ -98446,10 +98536,12 @@ | ||
| 98446 | 98536 | Fts3Expr *pExpr; /* Parsed MATCH query string */ |
| 98447 | 98537 | sqlite3_int64 iPrevId; /* Previous id read from aDoclist */ |
| 98448 | 98538 | char *pNextId; /* Pointer into the body of aDoclist */ |
| 98449 | 98539 | char *aDoclist; /* List of docids for full-text queries */ |
| 98450 | 98540 | int nDoclist; /* Size of buffer at aDoclist */ |
| 98541 | + int isMatchinfoOk; /* True when aMatchinfo[] matches iPrevId */ | |
| 98542 | + u32 *aMatchinfo; | |
| 98451 | 98543 | }; |
| 98452 | 98544 | |
| 98453 | 98545 | /* |
| 98454 | 98546 | ** The Fts3Cursor.eSearch member is always set to one of the following. |
| 98455 | 98547 | ** Actualy, Fts3Cursor.eSearch can be greater than or equal to |
| @@ -98486,18 +98578,35 @@ | ||
| 98486 | 98578 | } aToken[1]; /* One entry for each token in the phrase */ |
| 98487 | 98579 | }; |
| 98488 | 98580 | |
| 98489 | 98581 | /* |
| 98490 | 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. | |
| 98491 | 98593 | */ |
| 98492 | 98594 | struct Fts3Expr { |
| 98493 | 98595 | int eType; /* One of the FTSQUERY_XXX values defined below */ |
| 98494 | 98596 | int nNear; /* Valid if eType==FTSQUERY_NEAR */ |
| 98495 | 98597 | Fts3Expr *pParent; /* pParent->pLeft==this or pParent->pRight==this */ |
| 98496 | 98598 | Fts3Expr *pLeft; /* Left operand */ |
| 98497 | 98599 | Fts3Expr *pRight; /* Right operand */ |
| 98498 | 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; | |
| 98499 | 98608 | }; |
| 98500 | 98609 | |
| 98501 | 98610 | /* |
| 98502 | 98611 | ** Candidate values for Fts3Query.eType. Note that the order of the first |
| 98503 | 98612 | ** four values is in order of precedence when parsing expressions. For |
| @@ -98526,10 +98635,11 @@ | ||
| 98526 | 98635 | SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *); |
| 98527 | 98636 | SQLITE_PRIVATE void sqlite3Fts3PendingTermsClear(Fts3Table *); |
| 98528 | 98637 | SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *); |
| 98529 | 98638 | SQLITE_PRIVATE int sqlite3Fts3SegReaderNew(Fts3Table *,int, sqlite3_int64, |
| 98530 | 98639 | sqlite3_int64, sqlite3_int64, const char *, int, Fts3SegReader**); |
| 98640 | +SQLITE_PRIVATE int sqlite3Fts3SegReaderPending(Fts3Table*,const char*,int,int,Fts3SegReader**); | |
| 98531 | 98641 | SQLITE_PRIVATE void sqlite3Fts3SegReaderFree(Fts3Table *, Fts3SegReader *); |
| 98532 | 98642 | SQLITE_PRIVATE int sqlite3Fts3SegReaderIterate( |
| 98533 | 98643 | Fts3Table *, Fts3SegReader **, int, Fts3SegFilter *, |
| 98534 | 98644 | int (*)(Fts3Table *, void *, char *, int, char *, int), void * |
| 98535 | 98645 | ); |
| @@ -98555,10 +98665,13 @@ | ||
| 98555 | 98665 | SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *); |
| 98556 | 98666 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *); |
| 98557 | 98667 | SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64); |
| 98558 | 98668 | SQLITE_PRIVATE void sqlite3Fts3Dequote(char *); |
| 98559 | 98669 | |
| 98670 | +SQLITE_PRIVATE char *sqlite3Fts3FindPositions(Fts3Expr *, sqlite3_int64, int); | |
| 98671 | +SQLITE_PRIVATE int sqlite3Fts3ExprLoadDoclist(Fts3Table *, Fts3Expr *); | |
| 98672 | + | |
| 98560 | 98673 | /* fts3_tokenizer.c */ |
| 98561 | 98674 | SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *); |
| 98562 | 98675 | SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *); |
| 98563 | 98676 | SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, |
| 98564 | 98677 | const char *, sqlite3_tokenizer **, const char **, char ** |
| @@ -98567,18 +98680,22 @@ | ||
| 98567 | 98680 | /* fts3_snippet.c */ |
| 98568 | 98681 | SQLITE_PRIVATE void sqlite3Fts3Offsets(sqlite3_context*, Fts3Cursor*); |
| 98569 | 98682 | SQLITE_PRIVATE void sqlite3Fts3Snippet(sqlite3_context*, Fts3Cursor*, |
| 98570 | 98683 | const char *, const char *, const char * |
| 98571 | 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 *); | |
| 98572 | 98689 | |
| 98573 | 98690 | /* fts3_expr.c */ |
| 98574 | 98691 | SQLITE_PRIVATE int sqlite3Fts3ExprParse(sqlite3_tokenizer *, |
| 98575 | 98692 | char **, int, int, const char *, int, Fts3Expr ** |
| 98576 | 98693 | ); |
| 98577 | 98694 | SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *); |
| 98578 | 98695 | #ifdef SQLITE_TEST |
| 98579 | -SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3 *db); | |
| 98696 | +SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3 *db); | |
| 98580 | 98697 | #endif |
| 98581 | 98698 | |
| 98582 | 98699 | #endif /* _FTSINT_H */ |
| 98583 | 98700 | |
| 98584 | 98701 | /************** End of fts3Int.h *********************************************/ |
| @@ -98587,74 +98704,10 @@ | ||
| 98587 | 98704 | |
| 98588 | 98705 | #ifndef SQLITE_CORE |
| 98589 | 98706 | SQLITE_EXTENSION_INIT1 |
| 98590 | 98707 | #endif |
| 98591 | 98708 | |
| 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 | 98709 | /* |
| 98657 | 98710 | ** Write a 64-bit variable-length integer to memory starting at p[0]. |
| 98658 | 98711 | ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes. |
| 98659 | 98712 | ** The number of bytes written is returned. |
| 98660 | 98713 | */ |
| @@ -98676,17 +98729,13 @@ | ||
| 98676 | 98729 | ** The value is stored in *v. |
| 98677 | 98730 | */ |
| 98678 | 98731 | SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *p, sqlite_int64 *v){ |
| 98679 | 98732 | const unsigned char *q = (const unsigned char *) p; |
| 98680 | 98733 | sqlite_uint64 x = 0, y = 1; |
| 98681 | - while( (*q & 0x80) == 0x80 ){ | |
| 98734 | + while( (*q&0x80)==0x80 && q-(unsigned char *)p<FTS3_VARINT_MAX ){ | |
| 98682 | 98735 | x += y * (*q++ & 0x7f); |
| 98683 | 98736 | y <<= 7; |
| 98684 | - if( q - (unsigned char *)p >= FTS3_VARINT_MAX ){ /* bad data */ | |
| 98685 | - assert( 0 ); | |
| 98686 | - return 0; | |
| 98687 | - } | |
| 98688 | 98737 | } |
| 98689 | 98738 | x += y * (*q++); |
| 98690 | 98739 | *v = (sqlite_int64) x; |
| 98691 | 98740 | return (int) (q - (unsigned char *)p); |
| 98692 | 98741 | } |
| @@ -98697,11 +98746,10 @@ | ||
| 98697 | 98746 | */ |
| 98698 | 98747 | SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *p, int *pi){ |
| 98699 | 98748 | sqlite_int64 i; |
| 98700 | 98749 | int ret = sqlite3Fts3GetVarint(p, &i); |
| 98701 | 98750 | *pi = (int) i; |
| 98702 | - assert( *pi==i ); | |
| 98703 | 98751 | return ret; |
| 98704 | 98752 | } |
| 98705 | 98753 | |
| 98706 | 98754 | /* |
| 98707 | 98755 | ** Return the number of bytes required to store the value passed as the |
| @@ -98726,35 +98774,33 @@ | ||
| 98726 | 98774 | ** |
| 98727 | 98775 | ** "abc" becomes abc |
| 98728 | 98776 | ** 'xyz' becomes xyz |
| 98729 | 98777 | ** [pqr] becomes pqr |
| 98730 | 98778 | ** `mno` becomes mno |
| 98779 | +** | |
| 98731 | 98780 | */ |
| 98732 | 98781 | SQLITE_PRIVATE void sqlite3Fts3Dequote(char *z){ |
| 98733 | - int quote; | |
| 98734 | - int i, j; | |
| 98782 | + char quote; /* Quote character (if any ) */ | |
| 98735 | 98783 | |
| 98736 | 98784 | 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'; | |
| 98756 | 98802 | } |
| 98757 | 98803 | } |
| 98758 | 98804 | |
| 98759 | 98805 | static void fts3GetDeltaVarint(char **pp, sqlite3_int64 *pVal){ |
| 98760 | 98806 | sqlite3_int64 iVal; |
| @@ -98919,11 +98965,11 @@ | ||
| 98919 | 98965 | ** argv[0] -> module name |
| 98920 | 98966 | ** argv[1] -> database name |
| 98921 | 98967 | ** argv[2] -> table name |
| 98922 | 98968 | ** argv[...] -> "column name" and other module argument fields. |
| 98923 | 98969 | */ |
| 98924 | -int fts3InitVtab( | |
| 98970 | +static int fts3InitVtab( | |
| 98925 | 98971 | int isCreate, /* True for xCreate, false for xConnect */ |
| 98926 | 98972 | sqlite3 *db, /* The SQLite database connection */ |
| 98927 | 98973 | void *pAux, /* Hash table containing tokenizers */ |
| 98928 | 98974 | int argc, /* Number of elements in argv array */ |
| 98929 | 98975 | const char * const *argv, /* xCreate/xConnect argument array */ |
| @@ -98943,18 +98989,10 @@ | ||
| 98943 | 98989 | int nName; |
| 98944 | 98990 | |
| 98945 | 98991 | const char *zTokenizer = 0; /* Name of tokenizer to use */ |
| 98946 | 98992 | sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */ |
| 98947 | 98993 | |
| 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 | 98994 | nDb = (int)strlen(argv[1]) + 1; |
| 98957 | 98995 | nName = (int)strlen(argv[2]) + 1; |
| 98958 | 98996 | for(i=3; i<argc; i++){ |
| 98959 | 98997 | char const *z = argv[i]; |
| 98960 | 98998 | rc = sqlite3Fts3InitTokenizer(pHash, z, &pTokenizer, &zTokenizer, pzErr); |
| @@ -98995,10 +99033,11 @@ | ||
| 98995 | 99033 | p->nColumn = nCol; |
| 98996 | 99034 | p->nPendingData = 0; |
| 98997 | 99035 | p->azColumn = (char **)&p[1]; |
| 98998 | 99036 | p->pTokenizer = pTokenizer; |
| 98999 | 99037 | p->nNodeSize = 1000; |
| 99038 | + p->nMaxPendingData = FTS3_MAX_PENDING_DATA; | |
| 99000 | 99039 | zCsr = (char *)&p->azColumn[nCol]; |
| 99001 | 99040 | |
| 99002 | 99041 | fts3HashInit(&p->pendingTerms, FTS3_HASH_STRING, 1); |
| 99003 | 99042 | |
| 99004 | 99043 | /* Fill in the zName and zDb fields of the vtab structure. */ |
| @@ -99038,15 +99077,10 @@ | ||
| 99038 | 99077 | } |
| 99039 | 99078 | |
| 99040 | 99079 | rc = fts3DeclareVtab(p); |
| 99041 | 99080 | if( rc!=SQLITE_OK ) goto fts3_init_out; |
| 99042 | 99081 | |
| 99043 | -#ifdef SQLITE_TEST | |
| 99044 | - if( zTestParam ){ | |
| 99045 | - p->nNodeSize = atoi(&zTestParam[5]); | |
| 99046 | - } | |
| 99047 | -#endif | |
| 99048 | 99082 | *ppVTab = &p->base; |
| 99049 | 99083 | |
| 99050 | 99084 | fts3_init_out: |
| 99051 | 99085 | assert( p || (pTokenizer && rc!=SQLITE_OK) ); |
| 99052 | 99086 | if( rc!=SQLITE_OK ){ |
| @@ -99105,35 +99139,35 @@ | ||
| 99105 | 99139 | pInfo->estimatedCost = 500000; |
| 99106 | 99140 | for(i=0; i<pInfo->nConstraint; i++){ |
| 99107 | 99141 | struct sqlite3_index_constraint *pCons = &pInfo->aConstraint[i]; |
| 99108 | 99142 | if( pCons->usable==0 ) continue; |
| 99109 | 99143 | |
| 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. */ | |
| 99113 | 99145 | if( pCons->op==SQLITE_INDEX_CONSTRAINT_EQ |
| 99114 | 99146 | && (pCons->iColumn<0 || pCons->iColumn==p->nColumn+1 ) |
| 99115 | 99147 | ){ |
| 99116 | 99148 | pInfo->idxNum = FTS3_DOCID_SEARCH; |
| 99117 | 99149 | pInfo->estimatedCost = 1.0; |
| 99118 | 99150 | iCons = i; |
| 99119 | - break; | |
| 99120 | 99151 | } |
| 99121 | 99152 | |
| 99122 | 99153 | /* A MATCH constraint. Use a full-text search. |
| 99123 | 99154 | ** |
| 99124 | 99155 | ** If there is more than one MATCH constraint available, use the first |
| 99125 | 99156 | ** 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. | |
| 99127 | 99161 | */ |
| 99128 | - if( iCons<0 | |
| 99129 | - && pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH | |
| 99162 | + if( pCons->op==SQLITE_INDEX_CONSTRAINT_MATCH | |
| 99130 | 99163 | && pCons->iColumn>=0 && pCons->iColumn<=p->nColumn |
| 99131 | 99164 | ){ |
| 99132 | 99165 | pInfo->idxNum = FTS3_FULLTEXT_SEARCH + pCons->iColumn; |
| 99133 | 99166 | pInfo->estimatedCost = 2.0; |
| 99134 | 99167 | iCons = i; |
| 99168 | + break; | |
| 99135 | 99169 | } |
| 99136 | 99170 | } |
| 99137 | 99171 | |
| 99138 | 99172 | if( iCons>=0 ){ |
| 99139 | 99173 | pInfo->aConstraintUsage[iCons].argvIndex = 1; |
| @@ -99175,25 +99209,33 @@ | ||
| 99175 | 99209 | static int fulltextClose(sqlite3_vtab_cursor *pCursor){ |
| 99176 | 99210 | Fts3Cursor *pCsr = (Fts3Cursor *)pCursor; |
| 99177 | 99211 | sqlite3_finalize(pCsr->pStmt); |
| 99178 | 99212 | sqlite3Fts3ExprFree(pCsr->pExpr); |
| 99179 | 99213 | sqlite3_free(pCsr->aDoclist); |
| 99214 | + sqlite3_free(pCsr->aMatchinfo); | |
| 99180 | 99215 | sqlite3_free(pCsr); |
| 99181 | 99216 | return SQLITE_OK; |
| 99182 | 99217 | } |
| 99183 | 99218 | |
| 99184 | -static int fts3CursorSeek(Fts3Cursor *pCsr){ | |
| 99219 | +static int fts3CursorSeek(sqlite3_context *pContext, Fts3Cursor *pCsr){ | |
| 99185 | 99220 | if( pCsr->isRequireSeek ){ |
| 99186 | 99221 | pCsr->isRequireSeek = 0; |
| 99187 | 99222 | sqlite3_bind_int64(pCsr->pStmt, 1, pCsr->iPrevId); |
| 99188 | 99223 | if( SQLITE_ROW==sqlite3_step(pCsr->pStmt) ){ |
| 99189 | 99224 | return SQLITE_OK; |
| 99190 | 99225 | }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 | + } | |
| 99192 | 99234 | 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); | |
| 99195 | 99237 | } |
| 99196 | 99238 | return rc; |
| 99197 | 99239 | } |
| 99198 | 99240 | }else{ |
| 99199 | 99241 | return SQLITE_OK; |
| @@ -99213,10 +99255,11 @@ | ||
| 99213 | 99255 | pCsr->isEof = 1; |
| 99214 | 99256 | }else{ |
| 99215 | 99257 | sqlite3_reset(pCsr->pStmt); |
| 99216 | 99258 | fts3GetDeltaVarint(&pCsr->pNextId, &pCsr->iPrevId); |
| 99217 | 99259 | pCsr->isRequireSeek = 1; |
| 99260 | + pCsr->isMatchinfoOk = 1; | |
| 99218 | 99261 | } |
| 99219 | 99262 | return rc; |
| 99220 | 99263 | } |
| 99221 | 99264 | |
| 99222 | 99265 | |
| @@ -99328,15 +99371,31 @@ | ||
| 99328 | 99371 | assert( iVal-*piPrev > 0 || (*piPrev==0 && iVal==0) ); |
| 99329 | 99372 | *pp += sqlite3Fts3PutVarint(*pp, iVal-*piPrev); |
| 99330 | 99373 | *piPrev = iVal; |
| 99331 | 99374 | } |
| 99332 | 99375 | |
| 99376 | +/* | |
| 99377 | +** When this function is called, *ppPoslist is assumed to point to the | |
| 99378 | +** start of a position-list. | |
| 99379 | +*/ | |
| 99333 | 99380 | static void fts3PoslistCopy(char **pp, char **ppPoslist){ |
| 99334 | 99381 | char *pEnd = *ppPoslist; |
| 99335 | 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 | + */ | |
| 99336 | 99394 | while( *pEnd | c ) c = *pEnd++ & 0x80; |
| 99337 | 99395 | pEnd++; |
| 99396 | + | |
| 99338 | 99397 | if( pp ){ |
| 99339 | 99398 | int n = (int)(pEnd - *ppPoslist); |
| 99340 | 99399 | char *p = *pp; |
| 99341 | 99400 | memcpy(p, *ppPoslist, n); |
| 99342 | 99401 | p += n; |
| @@ -99539,13 +99598,14 @@ | ||
| 99539 | 99598 | fts3GetDeltaVarint(&p2, &iPos2); iPos2 -= 2; |
| 99540 | 99599 | }else{ |
| 99541 | 99600 | if( (*p1&0xFE)==0 ) break; |
| 99542 | 99601 | fts3GetDeltaVarint(&p1, &iPos1); iPos1 -= 2; |
| 99543 | 99602 | } |
| 99603 | + } | |
| 99544 | 99604 | |
| 99545 | - } | |
| 99546 | - if( pSave && pp ){ | |
| 99605 | + if( pSave ){ | |
| 99606 | + assert( pp && p ); | |
| 99547 | 99607 | p = pSave; |
| 99548 | 99608 | } |
| 99549 | 99609 | |
| 99550 | 99610 | fts3ColumnlistCopy(0, &p1); |
| 99551 | 99611 | fts3ColumnlistCopy(0, &p2); |
| @@ -99680,15 +99740,12 @@ | ||
| 99680 | 99740 | || mergetype==MERGE_PHRASE || mergetype==MERGE_POS_PHRASE |
| 99681 | 99741 | || mergetype==MERGE_NEAR || mergetype==MERGE_POS_NEAR |
| 99682 | 99742 | ); |
| 99683 | 99743 | |
| 99684 | 99744 | if( !aBuffer ){ |
| 99685 | - return SQLITE_NOMEM; | |
| 99686 | - } | |
| 99687 | - if( n1==0 && n2==0 ){ | |
| 99688 | 99745 | *pnBuffer = 0; |
| 99689 | - return SQLITE_OK; | |
| 99746 | + return SQLITE_NOMEM; | |
| 99690 | 99747 | } |
| 99691 | 99748 | |
| 99692 | 99749 | /* Read the first docid from each doclist */ |
| 99693 | 99750 | fts3GetDeltaVarint2(&p1, pEnd1, &i1); |
| 99694 | 99751 | fts3GetDeltaVarint2(&p2, pEnd2, &i2); |
| @@ -99770,11 +99827,11 @@ | ||
| 99770 | 99827 | default: assert( mergetype==MERGE_POS_NEAR || mergetype==MERGE_NEAR ); { |
| 99771 | 99828 | char *aTmp = 0; |
| 99772 | 99829 | char **ppPos = 0; |
| 99773 | 99830 | if( mergetype==MERGE_POS_NEAR ){ |
| 99774 | 99831 | ppPos = &p; |
| 99775 | - aTmp = sqlite3_malloc(2*(n1+n2)); | |
| 99832 | + aTmp = sqlite3_malloc(2*(n1+n2+1)); | |
| 99776 | 99833 | if( !aTmp ){ |
| 99777 | 99834 | return SQLITE_NOMEM; |
| 99778 | 99835 | } |
| 99779 | 99836 | } |
| 99780 | 99837 | |
| @@ -99890,16 +99947,24 @@ | ||
| 99890 | 99947 | char **ppOut /* OUT: Malloced result buffer */ |
| 99891 | 99948 | ){ |
| 99892 | 99949 | int i; |
| 99893 | 99950 | TermSelect tsc; |
| 99894 | 99951 | 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 */ | |
| 99896 | 99953 | 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 */ | |
| 99898 | 99955 | 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 */ | |
| 99900 | 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 | + } | |
| 99901 | 99966 | |
| 99902 | 99967 | /* Loop through the entire %_segdir table. For each segment, create a |
| 99903 | 99968 | ** Fts3SegReader to iterate through the subset of the segment leaves |
| 99904 | 99969 | ** that may contain a term that matches zTerm/nTerm. For non-prefix |
| 99905 | 99970 | ** searches, this is always a single leaf. For prefix searches, this |
| @@ -100013,12 +100078,10 @@ | ||
| 100013 | 100078 | int rc = SQLITE_OK; |
| 100014 | 100079 | int ii; |
| 100015 | 100080 | int iCol = pPhrase->iColumn; |
| 100016 | 100081 | int isTermPos = (pPhrase->nToken>1 || isReqPos); |
| 100017 | 100082 | |
| 100018 | - assert( p->nPendingData==0 ); | |
| 100019 | - | |
| 100020 | 100083 | for(ii=0; ii<pPhrase->nToken; ii++){ |
| 100021 | 100084 | struct PhraseToken *pTok = &pPhrase->aToken[ii]; |
| 100022 | 100085 | char *z = pTok->z; /* Next token of the phrase */ |
| 100023 | 100086 | int n = pTok->n; /* Size of z in bytes */ |
| 100024 | 100087 | int isPrefix = pTok->isPrefix;/* True if token is a prefix */ |
| @@ -100046,10 +100109,11 @@ | ||
| 100046 | 100109 | } |
| 100047 | 100110 | fts3DoclistMerge(mergetype, 0, 0, pList, &nOut, pOut, nOut, pList, nList); |
| 100048 | 100111 | sqlite3_free(pOut); |
| 100049 | 100112 | pOut = pList; |
| 100050 | 100113 | } |
| 100114 | + assert( nOut==0 || pOut!=0 ); | |
| 100051 | 100115 | } |
| 100052 | 100116 | |
| 100053 | 100117 | if( rc==SQLITE_OK ){ |
| 100054 | 100118 | *paOut = pOut; |
| 100055 | 100119 | *pnOut = nOut; |
| @@ -100065,39 +100129,46 @@ | ||
| 100065 | 100129 | */ |
| 100066 | 100130 | static int evalFts3Expr( |
| 100067 | 100131 | Fts3Table *p, /* Virtual table handle */ |
| 100068 | 100132 | Fts3Expr *pExpr, /* Parsed fts3 expression */ |
| 100069 | 100133 | 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 */ | |
| 100071 | 100136 | ){ |
| 100072 | 100137 | int rc = SQLITE_OK; /* Return code */ |
| 100073 | 100138 | |
| 100074 | 100139 | /* Zero the output parameters. */ |
| 100075 | 100140 | *paOut = 0; |
| 100076 | 100141 | *pnOut = 0; |
| 100077 | 100142 | |
| 100078 | 100143 | if( pExpr ){ |
| 100144 | + assert( pExpr->eType==FTSQUERY_PHRASE | |
| 100145 | + || pExpr->eType==FTSQUERY_NEAR | |
| 100146 | + || isReqPos==0 | |
| 100147 | + ); | |
| 100079 | 100148 | 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 | + ); | |
| 100082 | 100153 | }else{ |
| 100083 | 100154 | char *aLeft; |
| 100084 | 100155 | char *aRight; |
| 100085 | 100156 | int nLeft; |
| 100086 | 100157 | int nRight; |
| 100087 | 100158 | |
| 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)) | |
| 100090 | 100161 | ){ |
| 100091 | 100162 | assert( pExpr->eType==FTSQUERY_NEAR || pExpr->eType==FTSQUERY_OR |
| 100092 | 100163 | || pExpr->eType==FTSQUERY_AND || pExpr->eType==FTSQUERY_NOT |
| 100093 | 100164 | ); |
| 100094 | 100165 | switch( pExpr->eType ){ |
| 100095 | 100166 | case FTSQUERY_NEAR: { |
| 100096 | 100167 | Fts3Expr *pLeft; |
| 100097 | 100168 | Fts3Expr *pRight; |
| 100098 | - int mergetype = MERGE_NEAR; | |
| 100169 | + int mergetype = isReqPos ? MERGE_POS_NEAR : MERGE_NEAR; | |
| 100099 | 100170 | int nParam1; |
| 100100 | 100171 | int nParam2; |
| 100101 | 100172 | char *aBuffer; |
| 100102 | 100173 | |
| 100103 | 100174 | if( pExpr->pParent && pExpr->pParent->eType==FTSQUERY_NEAR ){ |
| @@ -100203,10 +100274,11 @@ | ||
| 100203 | 100274 | assert( (nVal==0)==(idxNum==FTS3_FULLSCAN_SEARCH) ); |
| 100204 | 100275 | |
| 100205 | 100276 | /* In case the cursor has been used before, clear it now. */ |
| 100206 | 100277 | sqlite3_finalize(pCsr->pStmt); |
| 100207 | 100278 | sqlite3_free(pCsr->aDoclist); |
| 100279 | + sqlite3Fts3ExprFree(pCsr->pExpr); | |
| 100208 | 100280 | memset(&pCursor[1], 0, sizeof(Fts3Cursor)-sizeof(sqlite3_vtab_cursor)); |
| 100209 | 100281 | |
| 100210 | 100282 | /* Compile a SELECT statement for this cursor. For a full-table-scan, the |
| 100211 | 100283 | ** statement loops through all rows of the %_content table. For a |
| 100212 | 100284 | ** full-text query or docid lookup, the statement retrieves a single |
| @@ -100229,19 +100301,17 @@ | ||
| 100229 | 100301 | const char *zQuery = (const char *)sqlite3_value_text(apVal[0]); |
| 100230 | 100302 | |
| 100231 | 100303 | if( zQuery==0 && sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ |
| 100232 | 100304 | return SQLITE_NOMEM; |
| 100233 | 100305 | } |
| 100234 | - rc = sqlite3Fts3PendingTermsFlush(p); | |
| 100235 | - if( rc!=SQLITE_OK ) return rc; | |
| 100236 | 100306 | |
| 100237 | 100307 | rc = sqlite3Fts3ExprParse(p->pTokenizer, p->azColumn, p->nColumn, |
| 100238 | 100308 | iCol, zQuery, -1, &pCsr->pExpr |
| 100239 | 100309 | ); |
| 100240 | 100310 | if( rc!=SQLITE_OK ) return rc; |
| 100241 | 100311 | |
| 100242 | - rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist); | |
| 100312 | + rc = evalFts3Expr(p, pCsr->pExpr, &pCsr->aDoclist, &pCsr->nDoclist, 0); | |
| 100243 | 100313 | pCsr->pNextId = pCsr->aDoclist; |
| 100244 | 100314 | pCsr->iPrevId = 0; |
| 100245 | 100315 | } |
| 100246 | 100316 | |
| 100247 | 100317 | if( rc!=SQLITE_OK ) return rc; |
| @@ -100286,25 +100356,26 @@ | ||
| 100286 | 100356 | Fts3Table *p = (Fts3Table *)pCursor->pVtab; |
| 100287 | 100357 | |
| 100288 | 100358 | /* The column value supplied by SQLite must be in range. */ |
| 100289 | 100359 | assert( iCol>=0 && iCol<=p->nColumn+1 ); |
| 100290 | 100360 | |
| 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 ){ | |
| 100306 | 100377 | sqlite3_result_value(pContext, sqlite3_column_value(pCsr->pStmt, iCol+1)); |
| 100307 | 100378 | } |
| 100308 | 100379 | } |
| 100309 | 100380 | return rc; |
| 100310 | 100381 | } |
| @@ -100357,10 +100428,67 @@ | ||
| 100357 | 100428 | */ |
| 100358 | 100429 | static int fts3RollbackMethod(sqlite3_vtab *pVtab){ |
| 100359 | 100430 | sqlite3Fts3PendingTermsClear((Fts3Table *)pVtab); |
| 100360 | 100431 | return SQLITE_OK; |
| 100361 | 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 | +} | |
| 100362 | 100490 | |
| 100363 | 100491 | /* |
| 100364 | 100492 | ** Helper function used by the implementation of the overloaded snippet(), |
| 100365 | 100493 | ** offsets() and optimize() SQL functions. |
| 100366 | 100494 | ** |
| @@ -100418,12 +100546,56 @@ | ||
| 100418 | 100546 | switch( nVal ){ |
| 100419 | 100547 | case 4: zEllipsis = (const char*)sqlite3_value_text(apVal[3]); |
| 100420 | 100548 | case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]); |
| 100421 | 100549 | case 2: zStart = (const char*)sqlite3_value_text(apVal[1]); |
| 100422 | 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 | +} | |
| 100423 | 100557 | |
| 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 | + } | |
| 100425 | 100597 | } |
| 100426 | 100598 | |
| 100427 | 100599 | /* |
| 100428 | 100600 | ** Implementation of the offsets() function for FTS3 |
| 100429 | 100601 | */ |
| @@ -100437,11 +100609,13 @@ | ||
| 100437 | 100609 | UNUSED_PARAMETER(nVal); |
| 100438 | 100610 | |
| 100439 | 100611 | assert( nVal==1 ); |
| 100440 | 100612 | if( fts3FunctionArg(pContext, "offsets", apVal[0], &pCsr) ) return; |
| 100441 | 100613 | assert( pCsr ); |
| 100442 | - sqlite3Fts3Offsets(pContext, pCsr); | |
| 100614 | + if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){ | |
| 100615 | + sqlite3Fts3Offsets(pContext, pCsr); | |
| 100616 | + } | |
| 100443 | 100617 | } |
| 100444 | 100618 | |
| 100445 | 100619 | /* |
| 100446 | 100620 | ** Implementation of the special optimize() function for FTS3. This |
| 100447 | 100621 | ** function merges all segments in the database to a single segment. |
| @@ -100479,10 +100653,31 @@ | ||
| 100479 | 100653 | default: |
| 100480 | 100654 | sqlite3_result_error_code(pContext, rc); |
| 100481 | 100655 | break; |
| 100482 | 100656 | } |
| 100483 | 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 | +} | |
| 100484 | 100679 | |
| 100485 | 100680 | /* |
| 100486 | 100681 | ** This routine implements the xFindFunction method for the FTS3 |
| 100487 | 100682 | ** virtual table. |
| 100488 | 100683 | */ |
| @@ -100496,12 +100691,14 @@ | ||
| 100496 | 100691 | struct Overloaded { |
| 100497 | 100692 | const char *zName; |
| 100498 | 100693 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**); |
| 100499 | 100694 | } aOverload[] = { |
| 100500 | 100695 | { "snippet", fts3SnippetFunc }, |
| 100696 | + { "snippet2", fts3Snippet2Func }, | |
| 100501 | 100697 | { "offsets", fts3OffsetsFunc }, |
| 100502 | 100698 | { "optimize", fts3OptimizeFunc }, |
| 100699 | + { "matchinfo", fts3MatchinfoFunc }, | |
| 100503 | 100700 | }; |
| 100504 | 100701 | int i; /* Iterator variable */ |
| 100505 | 100702 | |
| 100506 | 100703 | UNUSED_PARAMETER(pVtab); |
| 100507 | 100704 | UNUSED_PARAMETER(nArg); |
| @@ -100602,17 +100799,18 @@ | ||
| 100602 | 100799 | SQLITE_PRIVATE int sqlite3Fts3Init(sqlite3 *db){ |
| 100603 | 100800 | int rc = SQLITE_OK; |
| 100604 | 100801 | Fts3Hash *pHash = 0; |
| 100605 | 100802 | const sqlite3_tokenizer_module *pSimple = 0; |
| 100606 | 100803 | const sqlite3_tokenizer_module *pPorter = 0; |
| 100804 | + | |
| 100805 | +#ifdef SQLITE_ENABLE_ICU | |
| 100607 | 100806 | const sqlite3_tokenizer_module *pIcu = 0; |
| 100807 | + sqlite3Fts3IcuTokenizerModule(&pIcu); | |
| 100808 | +#endif | |
| 100608 | 100809 | |
| 100609 | 100810 | sqlite3Fts3SimpleTokenizerModule(&pSimple); |
| 100610 | 100811 | sqlite3Fts3PorterTokenizerModule(&pPorter); |
| 100611 | -#ifdef SQLITE_ENABLE_ICU | |
| 100612 | - sqlite3Fts3IcuTokenizerModule(&pIcu); | |
| 100613 | -#endif | |
| 100614 | 100812 | |
| 100615 | 100813 | /* Allocate and initialise the hash-table used to store tokenizers. */ |
| 100616 | 100814 | pHash = sqlite3_malloc(sizeof(Fts3Hash)); |
| 100617 | 100815 | if( !pHash ){ |
| 100618 | 100816 | rc = SQLITE_NOMEM; |
| @@ -100622,28 +100820,34 @@ | ||
| 100622 | 100820 | |
| 100623 | 100821 | /* Load the built-in tokenizers into the hash table */ |
| 100624 | 100822 | if( rc==SQLITE_OK ){ |
| 100625 | 100823 | if( sqlite3Fts3HashInsert(pHash, "simple", 7, (void *)pSimple) |
| 100626 | 100824 | || sqlite3Fts3HashInsert(pHash, "porter", 7, (void *)pPorter) |
| 100825 | +#ifdef SQLITE_ENABLE_ICU | |
| 100627 | 100826 | || (pIcu && sqlite3Fts3HashInsert(pHash, "icu", 4, (void *)pIcu)) |
| 100827 | +#endif | |
| 100628 | 100828 | ){ |
| 100629 | 100829 | rc = SQLITE_NOMEM; |
| 100630 | 100830 | } |
| 100631 | 100831 | } |
| 100632 | 100832 | |
| 100633 | 100833 | #ifdef SQLITE_TEST |
| 100634 | - sqlite3Fts3ExprInitTestInterface(db); | |
| 100834 | + if( rc==SQLITE_OK ){ | |
| 100835 | + rc = sqlite3Fts3ExprInitTestInterface(db); | |
| 100836 | + } | |
| 100635 | 100837 | #endif |
| 100636 | 100838 | |
| 100637 | 100839 | /* Create the virtual table wrapper around the hash-table and overload |
| 100638 | 100840 | ** the two scalar functions. If this is successful, register the |
| 100639 | 100841 | ** module with sqlite. |
| 100640 | 100842 | */ |
| 100641 | 100843 | if( SQLITE_OK==rc |
| 100642 | 100844 | && SQLITE_OK==(rc = sqlite3Fts3InitHashTable(db, pHash, "fts3_tokenizer")) |
| 100643 | 100845 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet", -1)) |
| 100846 | + && SQLITE_OK==(rc = sqlite3_overload_function(db, "snippet2", -1)) | |
| 100644 | 100847 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "offsets", 1)) |
| 100848 | + && SQLITE_OK==(rc = sqlite3_overload_function(db, "matchinfo", -1)) | |
| 100645 | 100849 | && SQLITE_OK==(rc = sqlite3_overload_function(db, "optimize", 1)) |
| 100646 | 100850 | ){ |
| 100647 | 100851 | return sqlite3_create_module_v2( |
| 100648 | 100852 | db, "fts3", &fts3Module, (void *)pHash, hashDestroy |
| 100649 | 100853 | ); |
| @@ -100850,11 +101054,11 @@ | ||
| 100850 | 101054 | |
| 100851 | 101055 | /* |
| 100852 | 101056 | ** Enlarge a memory allocation. If an out-of-memory allocation occurs, |
| 100853 | 101057 | ** then free the old allocation. |
| 100854 | 101058 | */ |
| 100855 | -void *fts3ReallocOrFree(void *pOrig, int nNew){ | |
| 101059 | +static void *fts3ReallocOrFree(void *pOrig, int nNew){ | |
| 100856 | 101060 | void *pRet = sqlite3_realloc(pOrig, nNew); |
| 100857 | 101061 | if( !pRet ){ |
| 100858 | 101062 | sqlite3_free(pOrig); |
| 100859 | 101063 | } |
| 100860 | 101064 | return pRet; |
| @@ -101404,10 +101608,11 @@ | ||
| 101404 | 101608 | */ |
| 101405 | 101609 | SQLITE_PRIVATE void sqlite3Fts3ExprFree(Fts3Expr *p){ |
| 101406 | 101610 | if( p ){ |
| 101407 | 101611 | sqlite3Fts3ExprFree(p->pLeft); |
| 101408 | 101612 | sqlite3Fts3ExprFree(p->pRight); |
| 101613 | + sqlite3_free(p->aDoclist); | |
| 101409 | 101614 | sqlite3_free(p); |
| 101410 | 101615 | } |
| 101411 | 101616 | } |
| 101412 | 101617 | |
| 101413 | 101618 | /**************************************************************************** |
| @@ -101581,12 +101786,12 @@ | ||
| 101581 | 101786 | |
| 101582 | 101787 | /* |
| 101583 | 101788 | ** Register the query expression parser test function fts3_exprtest() |
| 101584 | 101789 | ** with database connection db. |
| 101585 | 101790 | */ |
| 101586 | -SQLITE_PRIVATE void sqlite3Fts3ExprInitTestInterface(sqlite3* db){ | |
| 101587 | - sqlite3_create_function( | |
| 101791 | +SQLITE_PRIVATE int sqlite3Fts3ExprInitTestInterface(sqlite3* db){ | |
| 101792 | + return sqlite3_create_function( | |
| 101588 | 101793 | db, "fts3_exprtest", -1, SQLITE_UTF8, 0, fts3ExprTest, 0, 0 |
| 101589 | 101794 | ); |
| 101590 | 101795 | } |
| 101591 | 101796 | |
| 101592 | 101797 | #endif |
| @@ -101868,26 +102073,36 @@ | ||
| 101868 | 102073 | assert( pH->count==0 ); |
| 101869 | 102074 | fts3HashClear(pH); |
| 101870 | 102075 | } |
| 101871 | 102076 | } |
| 101872 | 102077 | |
| 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 */ | |
| 101880 | 102084 | int (*xHash)(const void*,int); /* The hash function */ |
| 101881 | 102085 | |
| 101882 | 102086 | if( pH==0 || pH->ht==0 ) return 0; |
| 101883 | 102087 | xHash = ftsHashFunction(pH->keyClass); |
| 101884 | 102088 | assert( xHash!=0 ); |
| 101885 | 102089 | h = (*xHash)(pKey,nKey); |
| 101886 | 102090 | 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; | |
| 101889 | 102104 | } |
| 101890 | 102105 | |
| 101891 | 102106 | /* Insert an element into the hash table pH. The key is pKey,nKey |
| 101892 | 102107 | ** and the data is "data". |
| 101893 | 102108 | ** |
| @@ -102720,18 +102935,18 @@ | ||
| 102720 | 102935 | const char *z2 = 0; |
| 102721 | 102936 | |
| 102722 | 102937 | /* Find the start of the next token. */ |
| 102723 | 102938 | z1 = zStr; |
| 102724 | 102939 | while( z2==0 ){ |
| 102725 | - switch( *z1 ){ | |
| 102940 | + char c = *z1; | |
| 102941 | + switch( c ){ | |
| 102726 | 102942 | case '\0': return 0; /* No more tokens here */ |
| 102727 | 102943 | case '\'': |
| 102728 | 102944 | case '"': |
| 102729 | 102945 | 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) ); | |
| 102733 | 102948 | break; |
| 102734 | 102949 | } |
| 102735 | 102950 | case '[': |
| 102736 | 102951 | z2 = &z1[1]; |
| 102737 | 102952 | while( *z2 && z2[0]!=']' ) z2++; |
| @@ -103065,14 +103280,14 @@ | ||
| 103065 | 103280 | const char *zName |
| 103066 | 103281 | ){ |
| 103067 | 103282 | int rc = SQLITE_OK; |
| 103068 | 103283 | void *p = (void *)pHash; |
| 103069 | 103284 | const int any = SQLITE_ANY; |
| 103285 | + | |
| 103286 | +#ifdef SQLITE_TEST | |
| 103070 | 103287 | char *zTest = 0; |
| 103071 | 103288 | char *zTest2 = 0; |
| 103072 | - | |
| 103073 | -#ifdef SQLITE_TEST | |
| 103074 | 103289 | void *pdb = (void *)db; |
| 103075 | 103290 | zTest = sqlite3_mprintf("%s_test", zName); |
| 103076 | 103291 | zTest2 = sqlite3_mprintf("%s_internal_test", zName); |
| 103077 | 103292 | if( !zTest || !zTest2 ){ |
| 103078 | 103293 | rc = SQLITE_NOMEM; |
| @@ -103085,14 +103300,17 @@ | ||
| 103085 | 103300 | #ifdef SQLITE_TEST |
| 103086 | 103301 | || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 2, any, p, testFunc, 0, 0)) |
| 103087 | 103302 | || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest, 3, any, p, testFunc, 0, 0)) |
| 103088 | 103303 | || SQLITE_OK!=(rc = sqlite3_create_function(db, zTest2, 0, any, pdb, intTestFunc, 0, 0)) |
| 103089 | 103304 | #endif |
| 103090 | - ); | |
| 103305 | + ); | |
| 103091 | 103306 | |
| 103307 | +#ifdef SQLITE_TEST | |
| 103092 | 103308 | sqlite3_free(zTest); |
| 103093 | 103309 | sqlite3_free(zTest2); |
| 103310 | +#endif | |
| 103311 | + | |
| 103094 | 103312 | return rc; |
| 103095 | 103313 | } |
| 103096 | 103314 | |
| 103097 | 103315 | #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */ |
| 103098 | 103316 | |
| @@ -103350,11 +103568,11 @@ | ||
| 103350 | 103568 | typedef struct SegmentNode SegmentNode; |
| 103351 | 103569 | typedef struct SegmentWriter SegmentWriter; |
| 103352 | 103570 | |
| 103353 | 103571 | /* |
| 103354 | 103572 | ** 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 | |
| 103356 | 103574 | ** instance of this structure. |
| 103357 | 103575 | */ |
| 103358 | 103576 | struct PendingList { |
| 103359 | 103577 | int nData; |
| 103360 | 103578 | char *aData; |
| @@ -103372,19 +103590,26 @@ | ||
| 103372 | 103590 | ** terms when querying the full-text index. See functions: |
| 103373 | 103591 | ** |
| 103374 | 103592 | ** sqlite3Fts3SegReaderNew() |
| 103375 | 103593 | ** sqlite3Fts3SegReaderFree() |
| 103376 | 103594 | ** sqlite3Fts3SegReaderIterate() |
| 103595 | +** | |
| 103596 | +** Methods used to manipulate Fts3SegReader structures: | |
| 103597 | +** | |
| 103598 | +** fts3SegReaderNext() | |
| 103599 | +** fts3SegReaderFirstDocid() | |
| 103600 | +** fts3SegReaderNextDocid() | |
| 103377 | 103601 | */ |
| 103378 | 103602 | struct Fts3SegReader { |
| 103379 | - int iIdx; /* Index within level */ | |
| 103603 | + int iIdx; /* Index within level, or 0x7FFFFFFF for PT */ | |
| 103380 | 103604 | sqlite3_int64 iStartBlock; |
| 103381 | 103605 | sqlite3_int64 iEndBlock; |
| 103382 | 103606 | sqlite3_stmt *pStmt; /* SQL Statement to access leaf nodes */ |
| 103383 | 103607 | char *aNode; /* Pointer to node data (or NULL) */ |
| 103384 | 103608 | int nNode; /* Size of buffer at aNode (or 0) */ |
| 103385 | 103609 | int nTermAlloc; /* Allocated size of zTerm buffer */ |
| 103610 | + Fts3HashElem **ppNextElem; | |
| 103386 | 103611 | |
| 103387 | 103612 | /* Variables set by fts3SegReaderNext(). These may be read directly |
| 103388 | 103613 | ** by the caller. They are valid from the time SegmentReaderNew() returns |
| 103389 | 103614 | ** until SegmentReaderNext() returns something other than SQLITE_OK |
| 103390 | 103615 | ** (i.e. SQLITE_DONE). |
| @@ -103396,10 +103621,12 @@ | ||
| 103396 | 103621 | |
| 103397 | 103622 | /* The following variables are used to iterate through the current doclist */ |
| 103398 | 103623 | char *pOffsetList; |
| 103399 | 103624 | sqlite3_int64 iDocid; |
| 103400 | 103625 | }; |
| 103626 | + | |
| 103627 | +#define fts3SegReaderIsPending(p) ((p)->ppNextElem!=0) | |
| 103401 | 103628 | |
| 103402 | 103629 | /* |
| 103403 | 103630 | ** An instance of this structure is used to create a segment b-tree in the |
| 103404 | 103631 | ** database. The internal details of this type are only accessed by the |
| 103405 | 103632 | ** following functions: |
| @@ -103600,17 +103827,17 @@ | ||
| 103600 | 103827 | |
| 103601 | 103828 | if( pzBlock ){ |
| 103602 | 103829 | sqlite3_bind_int64(pStmt, 1, iBlock); |
| 103603 | 103830 | rc = sqlite3_step(pStmt); |
| 103604 | 103831 | if( rc!=SQLITE_ROW ){ |
| 103605 | - return SQLITE_CORRUPT; | |
| 103832 | + return (rc==SQLITE_DONE ? SQLITE_CORRUPT : rc); | |
| 103606 | 103833 | } |
| 103607 | 103834 | |
| 103608 | 103835 | *pnBlock = sqlite3_column_bytes(pStmt, 0); |
| 103609 | 103836 | *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; | |
| 103612 | 103839 | } |
| 103613 | 103840 | } |
| 103614 | 103841 | return SQLITE_OK; |
| 103615 | 103842 | } |
| 103616 | 103843 | |
| @@ -103821,11 +104048,11 @@ | ||
| 103821 | 104048 | ** forced-flush would provide better performance. I suspect that if |
| 103822 | 104049 | ** we ordered the doclists by size and flushed the largest until the |
| 103823 | 104050 | ** buffer was half empty, that would let the less frequent terms |
| 103824 | 104051 | ** generate longer doclists. |
| 103825 | 104052 | */ |
| 103826 | - if( iDocid<=p->iPrevDocid || p->nPendingData>FTS3_MAX_PENDING_DATA ){ | |
| 104053 | + if( iDocid<=p->iPrevDocid || p->nPendingData>p->nMaxPendingData ){ | |
| 103827 | 104054 | int rc = sqlite3Fts3PendingTermsFlush(p); |
| 103828 | 104055 | if( rc!=SQLITE_OK ) return rc; |
| 103829 | 104056 | } |
| 103830 | 104057 | p->iPrevDocid = iDocid; |
| 103831 | 104058 | return SQLITE_OK; |
| @@ -104048,10 +104275,25 @@ | ||
| 104048 | 104275 | pNext = &pReader->aDoclist[pReader->nDoclist]; |
| 104049 | 104276 | } |
| 104050 | 104277 | |
| 104051 | 104278 | if( !pNext || pNext>=&pReader->aNode[pReader->nNode] ){ |
| 104052 | 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 | + } | |
| 104053 | 104295 | if( !pReader->pStmt ){ |
| 104054 | 104296 | pReader->aNode = 0; |
| 104055 | 104297 | return SQLITE_OK; |
| 104056 | 104298 | } |
| 104057 | 104299 | rc = sqlite3_step(pReader->pStmt); |
| @@ -104157,11 +104399,13 @@ | ||
| 104157 | 104399 | */ |
| 104158 | 104400 | assert( p->nLeavesStmt<p->nLeavesTotal ); |
| 104159 | 104401 | sqlite3_reset(pReader->pStmt); |
| 104160 | 104402 | p->aLeavesStmt[p->nLeavesStmt++] = pReader->pStmt; |
| 104161 | 104403 | } |
| 104162 | - sqlite3_free(pReader->zTerm); | |
| 104404 | + if( !fts3SegReaderIsPending(pReader) ){ | |
| 104405 | + sqlite3_free(pReader->zTerm); | |
| 104406 | + } | |
| 104163 | 104407 | sqlite3_free(pReader); |
| 104164 | 104408 | } |
| 104165 | 104409 | } |
| 104166 | 104410 | |
| 104167 | 104411 | /* |
| @@ -104254,10 +104498,107 @@ | ||
| 104254 | 104498 | sqlite3Fts3SegReaderFree(p, pReader); |
| 104255 | 104499 | } |
| 104256 | 104500 | return rc; |
| 104257 | 104501 | } |
| 104258 | 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 | + | |
| 104259 | 104600 | |
| 104260 | 104601 | /* |
| 104261 | 104602 | ** The second argument to this function is expected to be a statement of |
| 104262 | 104603 | ** the form: |
| 104263 | 104604 | ** |
| @@ -104297,11 +104638,11 @@ | ||
| 104297 | 104638 | ** Compare the entries pointed to by two Fts3SegReader structures. |
| 104298 | 104639 | ** Comparison is as follows: |
| 104299 | 104640 | ** |
| 104300 | 104641 | ** 1) EOF is greater than not EOF. |
| 104301 | 104642 | ** |
| 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 | |
| 104303 | 104644 | ** term is a prefix of another, the longer term is considered the |
| 104304 | 104645 | ** larger. |
| 104305 | 104646 | ** |
| 104306 | 104647 | ** 3) By segment age. An older segment is considered larger. |
| 104307 | 104648 | */ |
| @@ -104425,15 +104766,13 @@ | ||
| 104425 | 104766 | ){ |
| 104426 | 104767 | sqlite3_stmt *pStmt; |
| 104427 | 104768 | int rc = fts3SqlStmt(p, SQL_INSERT_SEGMENTS, &pStmt, 0); |
| 104428 | 104769 | if( rc==SQLITE_OK ){ |
| 104429 | 104770 | 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); | |
| 104435 | 104774 | } |
| 104436 | 104775 | return rc; |
| 104437 | 104776 | } |
| 104438 | 104777 | |
| 104439 | 104778 | /* |
| @@ -104455,15 +104794,13 @@ | ||
| 104455 | 104794 | sqlite3_bind_int(pStmt, 1, iLevel); |
| 104456 | 104795 | sqlite3_bind_int(pStmt, 2, iIdx); |
| 104457 | 104796 | sqlite3_bind_int64(pStmt, 3, iStartBlock); |
| 104458 | 104797 | sqlite3_bind_int64(pStmt, 4, iLeafEndBlock); |
| 104459 | 104798 | 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); | |
| 104465 | 104802 | } |
| 104466 | 104803 | return rc; |
| 104467 | 104804 | } |
| 104468 | 104805 | |
| 104469 | 104806 | /* |
| @@ -105038,20 +105375,36 @@ | ||
| 105038 | 105375 | /* |
| 105039 | 105376 | ** sqlite3Fts3SegReaderIterate() callback used when merging multiple |
| 105040 | 105377 | ** segments to create a single, larger segment. |
| 105041 | 105378 | */ |
| 105042 | 105379 | 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 */ | |
| 105049 | 105386 | ){ |
| 105050 | 105387 | SegmentWriter **ppW = (SegmentWriter **)pContext; |
| 105051 | 105388 | return fts3SegWriterAdd(p, ppW, 1, zTerm, nTerm, aDoclist, nDoclist); |
| 105052 | 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 | +} | |
| 105053 | 105406 | |
| 105054 | 105407 | /* |
| 105055 | 105408 | ** This function is used to iterate through a contiguous set of terms |
| 105056 | 105409 | ** stored in the full-text index. It merges data contained in one or |
| 105057 | 105410 | ** more segments to support this. |
| @@ -105110,12 +105463,11 @@ | ||
| 105110 | 105463 | const char *zTerm = pFilter->zTerm; |
| 105111 | 105464 | for(i=0; i<nSegment; i++){ |
| 105112 | 105465 | Fts3SegReader *pSeg = apSegment[i]; |
| 105113 | 105466 | while( fts3SegReaderTermCmp(pSeg, zTerm, nTerm)<0 ){ |
| 105114 | 105467 | rc = fts3SegReaderNext(pSeg); |
| 105115 | - if( rc!=SQLITE_OK ) goto finished; | |
| 105116 | - } | |
| 105468 | + if( rc!=SQLITE_OK ) goto finished; } | |
| 105117 | 105469 | } |
| 105118 | 105470 | } |
| 105119 | 105471 | |
| 105120 | 105472 | fts3SegReaderSort(apSegment, nSegment, nSegment, fts3SegReaderCmp); |
| 105121 | 105473 | while( apSegment[0]->aNode ){ |
| @@ -105145,11 +105497,12 @@ | ||
| 105145 | 105497 | && 0==memcmp(zTerm, apSegment[nMerge]->zTerm, nTerm) |
| 105146 | 105498 | ){ |
| 105147 | 105499 | nMerge++; |
| 105148 | 105500 | } |
| 105149 | 105501 | |
| 105150 | - if( nMerge==1 && !isIgnoreEmpty && !isColFilter && isRequirePos ){ | |
| 105502 | + assert( isIgnoreEmpty || (isRequirePos && !isColFilter) ); | |
| 105503 | + if( nMerge==1 && !isIgnoreEmpty ){ | |
| 105151 | 105504 | Fts3SegReader *p0 = apSegment[0]; |
| 105152 | 105505 | rc = xFunc(p, pContext, zTerm, nTerm, p0->aDoclist, p0->nDoclist); |
| 105153 | 105506 | if( rc!=SQLITE_OK ) goto finished; |
| 105154 | 105507 | }else{ |
| 105155 | 105508 | int nDoclist = 0; /* Size of doclist */ |
| @@ -105169,13 +105522,13 @@ | ||
| 105169 | 105522 | int nList; |
| 105170 | 105523 | int nByte; |
| 105171 | 105524 | sqlite3_int64 iDocid = apSegment[0]->iDocid; |
| 105172 | 105525 | fts3SegReaderNextDocid(apSegment[0], &pList, &nList); |
| 105173 | 105526 | 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 | |
| 105177 | 105530 | ){ |
| 105178 | 105531 | fts3SegReaderNextDocid(apSegment[j], 0, 0); |
| 105179 | 105532 | j++; |
| 105180 | 105533 | } |
| 105181 | 105534 | |
| @@ -105247,25 +105600,30 @@ | ||
| 105247 | 105600 | static int fts3SegmentMerge(Fts3Table *p, int iLevel){ |
| 105248 | 105601 | int i; /* Iterator variable */ |
| 105249 | 105602 | int rc; /* Return code */ |
| 105250 | 105603 | int iIdx; /* Index of new segment */ |
| 105251 | 105604 | int iNewLevel; /* Level to create new segment at */ |
| 105252 | - sqlite3_stmt *pStmt; | |
| 105605 | + sqlite3_stmt *pStmt = 0; | |
| 105253 | 105606 | SegmentWriter *pWriter = 0; |
| 105254 | 105607 | int nSegment = 0; /* Number of segments being merged */ |
| 105255 | 105608 | Fts3SegReader **apSegment = 0; /* Array of Segment iterators */ |
| 105609 | + Fts3SegReader *pPending = 0; /* Iterator for pending-terms */ | |
| 105256 | 105610 | Fts3SegFilter filter; /* Segment term filter condition */ |
| 105257 | 105611 | |
| 105258 | 105612 | if( iLevel<0 ){ |
| 105259 | 105613 | /* This call is to merge all segments in the database to a single |
| 105260 | 105614 | ** segment. The level of the new segment is equal to the the numerically |
| 105261 | 105615 | ** greatest segment level currently present in the database. The index |
| 105262 | 105616 | ** of the new segment is always 0. |
| 105263 | 105617 | */ |
| 105264 | 105618 | iIdx = 0; |
| 105619 | + rc = sqlite3Fts3SegReaderPending(p, 0, 0, 1, &pPending); | |
| 105620 | + if( rc!=SQLITE_OK ) goto finished; | |
| 105265 | 105621 | rc = fts3SegmentCountMax(p, &nSegment, &iNewLevel); |
| 105266 | - if( nSegment==1 ){ | |
| 105622 | + if( rc!=SQLITE_OK ) goto finished; | |
| 105623 | + nSegment += (pPending!=0); | |
| 105624 | + if( nSegment<=1 ){ | |
| 105267 | 105625 | return SQLITE_DONE; |
| 105268 | 105626 | } |
| 105269 | 105627 | }else{ |
| 105270 | 105628 | /* This call is to merge all segments at level iLevel. Find the next |
| 105271 | 105629 | ** available segment index at level iLevel+1. The call to |
| @@ -105272,21 +105630,22 @@ | ||
| 105272 | 105630 | ** fts3AllocateSegdirIdx() will merge the segments at level iLevel+1 to |
| 105273 | 105631 | ** a single iLevel+2 segment if necessary. |
| 105274 | 105632 | */ |
| 105275 | 105633 | iNewLevel = iLevel+1; |
| 105276 | 105634 | rc = fts3AllocateSegdirIdx(p, iNewLevel, &iIdx); |
| 105277 | - if( rc!=SQLITE_OK ) return rc; | |
| 105635 | + if( rc!=SQLITE_OK ) goto finished; | |
| 105278 | 105636 | rc = fts3SegmentCount(p, iLevel, &nSegment); |
| 105637 | + if( rc!=SQLITE_OK ) goto finished; | |
| 105279 | 105638 | } |
| 105280 | - if( rc!=SQLITE_OK ) return rc; | |
| 105281 | 105639 | assert( nSegment>0 ); |
| 105282 | 105640 | assert( iNewLevel>=0 ); |
| 105283 | 105641 | |
| 105284 | 105642 | /* Allocate space for an array of pointers to segment iterators. */ |
| 105285 | 105643 | apSegment = (Fts3SegReader**)sqlite3_malloc(sizeof(Fts3SegReader *)*nSegment); |
| 105286 | 105644 | if( !apSegment ){ |
| 105287 | - return SQLITE_NOMEM; | |
| 105645 | + rc = SQLITE_NOMEM; | |
| 105646 | + goto finished; | |
| 105288 | 105647 | } |
| 105289 | 105648 | memset(apSegment, 0, sizeof(Fts3SegReader *)*nSegment); |
| 105290 | 105649 | |
| 105291 | 105650 | /* Allocate a Fts3SegReader structure for each segment being merged. A |
| 105292 | 105651 | ** Fts3SegReader stores the state data required to iterate through all |
| @@ -105301,10 +105660,14 @@ | ||
| 105301 | 105660 | if( rc!=SQLITE_OK ){ |
| 105302 | 105661 | goto finished; |
| 105303 | 105662 | } |
| 105304 | 105663 | } |
| 105305 | 105664 | rc = sqlite3_reset(pStmt); |
| 105665 | + if( pPending ){ | |
| 105666 | + apSegment[i] = pPending; | |
| 105667 | + pPending = 0; | |
| 105668 | + } | |
| 105306 | 105669 | pStmt = 0; |
| 105307 | 105670 | if( rc!=SQLITE_OK ) goto finished; |
| 105308 | 105671 | |
| 105309 | 105672 | memset(&filter, 0, sizeof(Fts3SegFilter)); |
| 105310 | 105673 | filter.flags = FTS3_SEGMENT_REQUIRE_POS; |
| @@ -105325,94 +105688,105 @@ | ||
| 105325 | 105688 | for(i=0; i<nSegment; i++){ |
| 105326 | 105689 | sqlite3Fts3SegReaderFree(p, apSegment[i]); |
| 105327 | 105690 | } |
| 105328 | 105691 | sqlite3_free(apSegment); |
| 105329 | 105692 | } |
| 105693 | + sqlite3Fts3SegReaderFree(p, pPending); | |
| 105330 | 105694 | sqlite3_reset(pStmt); |
| 105331 | 105695 | return rc; |
| 105332 | 105696 | } |
| 105333 | 105697 | |
| 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 | 105698 | |
| 105354 | 105699 | /* |
| 105355 | 105700 | ** Flush the contents of pendingTerms to a level 0 segment. |
| 105356 | 105701 | */ |
| 105357 | 105702 | 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 */ | |
| 105362 | 105705 | SegmentWriter *pWriter = 0; /* Used to write the segment */ |
| 105706 | + Fts3SegReader *pReader = 0; /* Used to iterate through the hash table */ | |
| 105363 | 105707 | |
| 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. | |
| 105366 | 105711 | */ |
| 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; | |
| 105371 | 105715 | } |
| 105372 | 105716 | |
| 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 | + */ | |
| 105374 | 105721 | 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. | |
| 105393 | 105727 | */ |
| 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 | + */ | |
| 105406 | 105742 | if( rc==SQLITE_OK ){ |
| 105407 | 105743 | rc = fts3SegWriterFlush(p, pWriter, 0, idx); |
| 105408 | 105744 | } |
| 105409 | - | |
| 105410 | - /* Free all allocated resources before returning */ | |
| 105411 | 105745 | 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 | + | |
| 105414 | 105788 | return rc; |
| 105415 | 105789 | } |
| 105416 | 105790 | |
| 105417 | 105791 | /* |
| 105418 | 105792 | ** This function does the work for the xUpdate method of FTS3 virtual |
| @@ -105426,10 +105800,11 @@ | ||
| 105426 | 105800 | ){ |
| 105427 | 105801 | Fts3Table *p = (Fts3Table *)pVtab; |
| 105428 | 105802 | int rc = SQLITE_OK; /* Return Code */ |
| 105429 | 105803 | int isRemove = 0; /* True for an UPDATE or DELETE */ |
| 105430 | 105804 | sqlite3_int64 iRemove = 0; /* Rowid removed by UPDATE or DELETE */ |
| 105805 | + | |
| 105431 | 105806 | |
| 105432 | 105807 | /* If this is a DELETE or UPDATE operation, remove the old record. */ |
| 105433 | 105808 | if( sqlite3_value_type(apVal[0])!=SQLITE_NULL ){ |
| 105434 | 105809 | int isEmpty; |
| 105435 | 105810 | rc = fts3IsEmpty(p, apVal, &isEmpty); |
| @@ -105450,10 +105825,12 @@ | ||
| 105450 | 105825 | rc = fts3SqlExec(p, SQL_DELETE_CONTENT, apVal); |
| 105451 | 105826 | } |
| 105452 | 105827 | } |
| 105453 | 105828 | } |
| 105454 | 105829 | } |
| 105830 | + }else if( sqlite3_value_type(apVal[p->nColumn+2])!=SQLITE_NULL ){ | |
| 105831 | + return fts3SpecialInsert(p, apVal[p->nColumn+2]); | |
| 105455 | 105832 | } |
| 105456 | 105833 | |
| 105457 | 105834 | /* If this is an INSERT or UPDATE operation, insert the new record. */ |
| 105458 | 105835 | if( nArg>1 && rc==SQLITE_OK ){ |
| 105459 | 105836 | rc = fts3InsertData(p, apVal, pRowid); |
| @@ -105475,18 +105852,19 @@ | ||
| 105475 | 105852 | */ |
| 105476 | 105853 | SQLITE_PRIVATE int sqlite3Fts3Optimize(Fts3Table *p){ |
| 105477 | 105854 | int rc; |
| 105478 | 105855 | rc = sqlite3_exec(p->db, "SAVEPOINT fts3", 0, 0, 0); |
| 105479 | 105856 | if( rc==SQLITE_OK ){ |
| 105480 | - rc = sqlite3Fts3PendingTermsFlush(p); | |
| 105481 | - if( rc==SQLITE_OK ){ | |
| 105482 | - rc = fts3SegmentMerge(p, -1); | |
| 105483 | - } | |
| 105857 | + rc = fts3SegmentMerge(p, -1); | |
| 105484 | 105858 | if( rc==SQLITE_OK ){ |
| 105485 | 105859 | rc = sqlite3_exec(p->db, "RELEASE fts3", 0, 0, 0); |
| 105860 | + if( rc==SQLITE_OK ){ | |
| 105861 | + sqlite3Fts3PendingTermsClear(p); | |
| 105862 | + } | |
| 105486 | 105863 | }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); | |
| 105488 | 105866 | } |
| 105489 | 105867 | } |
| 105490 | 105868 | return rc; |
| 105491 | 105869 | } |
| 105492 | 105870 | |
| @@ -106220,10 +106598,620 @@ | ||
| 106220 | 106598 | }else{ |
| 106221 | 106599 | sqlite3_result_error_nomem(pCtx); |
| 106222 | 106600 | } |
| 106223 | 106601 | fts3SnippetFree(p); |
| 106224 | 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 | +} | |
| 106225 | 107213 | |
| 106226 | 107214 | #endif |
| 106227 | 107215 | |
| 106228 | 107216 | /************** End of fts3_snippet.c ****************************************/ |
| 106229 | 107217 | /************** Begin file rtree.c *******************************************/ |
| @@ -109539,11 +110527,11 @@ | ||
| 109539 | 110527 | int nArg; /* Number of arguments */ |
| 109540 | 110528 | int enc; /* Optimal text encoding */ |
| 109541 | 110529 | void *pContext; /* sqlite3_user_data() context */ |
| 109542 | 110530 | void (*xFunc)(sqlite3_context*,int,sqlite3_value**); |
| 109543 | 110531 | } scalars[] = { |
| 109544 | - {"regexp",-1, SQLITE_ANY, 0, icuRegexpFunc}, | |
| 110532 | + {"regexp", 2, SQLITE_ANY, 0, icuRegexpFunc}, | |
| 109545 | 110533 | |
| 109546 | 110534 | {"lower", 1, SQLITE_UTF16, 0, icuCaseFunc16}, |
| 109547 | 110535 | {"lower", 2, SQLITE_UTF16, 0, icuCaseFunc16}, |
| 109548 | 110536 | {"upper", 1, SQLITE_UTF16, (void*)1, icuCaseFunc16}, |
| 109549 | 110537 | {"upper", 2, SQLITE_UTF16, (void*)1, icuCaseFunc16}, |
| 109550 | 110538 |
| --- 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[5] = "28"; |
| 2139 | ** azResult[6] = "Cindy"; |
| 2140 | ** azResult[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 =, <, <=, >, or >=. 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, ®Free1, |
| 62728 | pExpr->pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 62740 | pExpr->pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 62981 | pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 63517 | pExpr->pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 63529 | pExpr->pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 63660 | pExpr->pRight, &r2, ®Free2); |
| 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, ®Free1, |
| 63672 | pExpr->pRight, &r2, ®Free2); |
| 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[5] = "28"; |
| 2163 | ** azResult[6] = "Cindy"; |
| 2164 | ** azResult[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 =, <, <=, >, or >=.)^ ^(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, ®Free1); |
| 62641 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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, ®Free1); |
| 62653 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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, ®Free1); |
| 62893 | r2 = sqlite3ExprCodeTemp(pParse, pRight, ®Free2); |
| 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, ®Free1); |
| 63429 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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, ®Free1); |
| 63441 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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, ®Free1); |
| 63572 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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, ®Free1); |
| 63584 | r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); |
| 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 @@ | ||
| 79 | 79 | #ifdef SQLITE_VERSION_NUMBER |
| 80 | 80 | # undef SQLITE_VERSION_NUMBER |
| 81 | 81 | #endif |
| 82 | 82 | |
| 83 | 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> | |
| 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. | |
| 107 | 97 | ** |
| 108 | 98 | ** 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. | |
| 115 | 105 | ** |
| 116 | 106 | ** See also: [sqlite3_libversion()], |
| 117 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 118 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 119 | -** | |
| 120 | -** Requirements: [H10011] [H10014] | |
| 121 | 109 | */ |
| 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" | |
| 125 | 113 | |
| 126 | 114 | /* |
| 127 | -** CAPI3REF: Run-Time Library Version Numbers {H10020} <S60100> | |
| 115 | +** CAPI3REF: Run-Time Library Version Numbers | |
| 128 | 116 | ** KEYWORDS: sqlite3_version |
| 129 | 117 | ** |
| 130 | 118 | ** 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 | |
| 133 | 121 | ** programmers might include assert() statements in their application to |
| 134 | 122 | ** verify that values returned by these interfaces match the macros in |
| 135 | 123 | ** the header, and thus insure that the application is |
| 136 | 124 | ** compiled with matching library and header files. |
| 137 | 125 | ** |
| 138 | 126 | ** <blockquote><pre> |
| 139 | 127 | ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); |
| 140 | 128 | ** 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>)^ | |
| 143 | 131 | ** |
| 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. | |
| 150 | 141 | ** |
| 151 | 142 | ** See also: [sqlite_version()] and [sqlite_source_id()]. |
| 152 | -** | |
| 153 | -** Requirements: [H10021] [H10022] [H10023] | |
| 154 | 143 | */ |
| 155 | 144 | SQLITE_API SQLITE_EXTERN const char sqlite3_version[]; |
| 156 | 145 | SQLITE_API const char *sqlite3_libversion(void); |
| 157 | 146 | SQLITE_API const char *sqlite3_sourceid(void); |
| 158 | 147 | SQLITE_API int sqlite3_libversion_number(void); |
| 159 | 148 | |
| 160 | 149 | /* |
| 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. | |
| 162 | 155 | ** |
| 163 | 156 | ** SQLite can be compiled with or without mutexes. When |
| 164 | 157 | ** the [SQLITE_THREADSAFE] C preprocessor macro is 1 or 2, mutexes |
| 165 | 158 | ** are enabled and SQLite is threadsafe. When the |
| 166 | 159 | ** [SQLITE_THREADSAFE] macro is 0, |
| @@ -168,33 +161,33 @@ | ||
| 168 | 161 | ** to use SQLite concurrently from more than one thread. |
| 169 | 162 | ** |
| 170 | 163 | ** Enabling mutexes incurs a measurable performance penalty. |
| 171 | 164 | ** So if speed is of utmost importance, it makes sense to disable |
| 172 | 165 | ** 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. | |
| 174 | 167 | ** |
| 175 | 168 | ** This interface can be used by an application to make sure that the |
| 176 | 169 | ** version of SQLite that it is linking against was compiled with |
| 177 | 170 | ** the desired setting of the [SQLITE_THREADSAFE] macro. |
| 178 | 171 | ** |
| 179 | 172 | ** This interface only reports on the compile-time mutex setting |
| 180 | 173 | ** 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 | |
| 182 | 175 | ** can be fully or partially disabled using a call to [sqlite3_config()] |
| 183 | 176 | ** 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().)^ | |
| 187 | 182 | ** |
| 188 | 183 | ** See the [threading mode] documentation for additional information. |
| 189 | -** | |
| 190 | -** Requirements: [H10101] [H10102] | |
| 191 | 184 | */ |
| 192 | 185 | SQLITE_API int sqlite3_threadsafe(void); |
| 193 | 186 | |
| 194 | 187 | /* |
| 195 | -** CAPI3REF: Database Connection Handle {H12000} <S40200> | |
| 188 | +** CAPI3REF: Database Connection Handle | |
| 196 | 189 | ** KEYWORDS: {database connection} {database connections} |
| 197 | 190 | ** |
| 198 | 191 | ** Each open SQLite database is represented by a pointer to an instance of |
| 199 | 192 | ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 |
| 200 | 193 | ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and |
| @@ -205,21 +198,24 @@ | ||
| 205 | 198 | ** sqlite3 object. |
| 206 | 199 | */ |
| 207 | 200 | typedef struct sqlite3 sqlite3; |
| 208 | 201 | |
| 209 | 202 | /* |
| 210 | -** CAPI3REF: 64-Bit Integer Types {H10200} <S10110> | |
| 203 | +** CAPI3REF: 64-Bit Integer Types | |
| 211 | 204 | ** KEYWORDS: sqlite_int64 sqlite_uint64 |
| 212 | 205 | ** |
| 213 | 206 | ** Because there is no cross-platform way to specify 64-bit integer types |
| 214 | 207 | ** SQLite includes typedefs for 64-bit signed and unsigned integers. |
| 215 | 208 | ** |
| 216 | 209 | ** The sqlite3_int64 and sqlite3_uint64 are the preferred type definitions. |
| 217 | 210 | ** The sqlite_int64 and sqlite_uint64 types are supported for backwards |
| 218 | 211 | ** compatibility only. |
| 219 | 212 | ** |
| 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. | |
| 221 | 217 | */ |
| 222 | 218 | #ifdef SQLITE_INT64_TYPE |
| 223 | 219 | typedef SQLITE_INT64_TYPE sqlite_int64; |
| 224 | 220 | typedef unsigned SQLITE_INT64_TYPE sqlite_uint64; |
| 225 | 221 | #elif defined(_MSC_VER) || defined(__BORLANDC__) |
| @@ -239,28 +235,32 @@ | ||
| 239 | 235 | #ifdef SQLITE_OMIT_FLOATING_POINT |
| 240 | 236 | # define double sqlite3_int64 |
| 241 | 237 | #endif |
| 242 | 238 | |
| 243 | 239 | /* |
| 244 | -** CAPI3REF: Closing A Database Connection {H12010} <S30100><S40200> | |
| 240 | +** CAPI3REF: Closing A Database Connection | |
| 245 | 241 | ** |
| 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. | |
| 247 | 245 | ** |
| 248 | 246 | ** Applications must [sqlite3_finalize | finalize] all [prepared statements] |
| 249 | 247 | ** 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. | |
| 251 | 252 | ** |
| 252 | -** If [sqlite3_close()] is invoked while a transaction is open, | |
| 253 | +** ^If [sqlite3_close()] is invoked while a transaction is open, | |
| 253 | 254 | ** the transaction is automatically rolled back. |
| 254 | 255 | ** |
| 255 | 256 | ** The C parameter to [sqlite3_close(C)] must be either a NULL |
| 256 | 257 | ** pointer or an [sqlite3] object pointer obtained |
| 257 | 258 | ** from [sqlite3_open()], [sqlite3_open16()], or |
| 258 | 259 | ** [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. | |
| 262 | 262 | */ |
| 263 | 263 | SQLITE_API int sqlite3_close(sqlite3 *); |
| 264 | 264 | |
| 265 | 265 | /* |
| 266 | 266 | ** The type for a callback function. |
| @@ -268,52 +268,69 @@ | ||
| 268 | 268 | ** compatibility and is not documented. |
| 269 | 269 | */ |
| 270 | 270 | typedef int (*sqlite3_callback)(void*,int,char**, char**); |
| 271 | 271 | |
| 272 | 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] | |
| 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> | |
| 315 | 332 | */ |
| 316 | 333 | SQLITE_API int sqlite3_exec( |
| 317 | 334 | sqlite3*, /* An open database */ |
| 318 | 335 | const char *sql, /* SQL to be evaluated */ |
| 319 | 336 | int (*callback)(void*,int,char**,char**), /* Callback function */ |
| @@ -320,11 +337,11 @@ | ||
| 320 | 337 | void *, /* 1st argument to callback */ |
| 321 | 338 | char **errmsg /* Error msg written here */ |
| 322 | 339 | ); |
| 323 | 340 | |
| 324 | 341 | /* |
| 325 | -** CAPI3REF: Result Codes {H10210} <S10700> | |
| 342 | +** CAPI3REF: Result Codes | |
| 326 | 343 | ** KEYWORDS: SQLITE_OK {error code} {error codes} |
| 327 | 344 | ** KEYWORDS: {result code} {result codes} |
| 328 | 345 | ** |
| 329 | 346 | ** Many SQLite functions return an integer result code from the set shown |
| 330 | 347 | ** here in order to indicates success or failure. |
| @@ -364,11 +381,11 @@ | ||
| 364 | 381 | #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ |
| 365 | 382 | #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ |
| 366 | 383 | /* end-of-error-codes */ |
| 367 | 384 | |
| 368 | 385 | /* |
| 369 | -** CAPI3REF: Extended Result Codes {H10220} <S10700> | |
| 386 | +** CAPI3REF: Extended Result Codes | |
| 370 | 387 | ** KEYWORDS: {extended error code} {extended error codes} |
| 371 | 388 | ** KEYWORDS: {extended result code} {extended result codes} |
| 372 | 389 | ** |
| 373 | 390 | ** In its default configuration, SQLite API routines return one of 26 integer |
| 374 | 391 | ** [SQLITE_OK | result codes]. However, experience has shown that many of |
| @@ -406,11 +423,11 @@ | ||
| 406 | 423 | #define SQLITE_IOERR_CLOSE (SQLITE_IOERR | (16<<8)) |
| 407 | 424 | #define SQLITE_IOERR_DIR_CLOSE (SQLITE_IOERR | (17<<8)) |
| 408 | 425 | #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8) ) |
| 409 | 426 | |
| 410 | 427 | /* |
| 411 | -** CAPI3REF: Flags For File Open Operations {H10230} <H11120> <H12700> | |
| 428 | +** CAPI3REF: Flags For File Open Operations | |
| 412 | 429 | ** |
| 413 | 430 | ** These bit values are intended for use in the |
| 414 | 431 | ** 3rd parameter to the [sqlite3_open_v2()] interface and |
| 415 | 432 | ** in the 4th parameter to the xOpen method of the |
| 416 | 433 | ** [sqlite3_vfs] object. |
| @@ -431,11 +448,11 @@ | ||
| 431 | 448 | #define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */ |
| 432 | 449 | #define SQLITE_OPEN_SHAREDCACHE 0x00020000 /* Ok for sqlite3_open_v2() */ |
| 433 | 450 | #define SQLITE_OPEN_PRIVATECACHE 0x00040000 /* Ok for sqlite3_open_v2() */ |
| 434 | 451 | |
| 435 | 452 | /* |
| 436 | -** CAPI3REF: Device Characteristics {H10240} <H11120> | |
| 453 | +** CAPI3REF: Device Characteristics | |
| 437 | 454 | ** |
| 438 | 455 | ** The xDeviceCapabilities method of the [sqlite3_io_methods] |
| 439 | 456 | ** object returns an integer which is a vector of the these |
| 440 | 457 | ** bit values expressing I/O characteristics of the mass storage |
| 441 | 458 | ** device that holds the file that the [sqlite3_io_methods] |
| @@ -463,11 +480,11 @@ | ||
| 463 | 480 | #define SQLITE_IOCAP_ATOMIC64K 0x00000100 |
| 464 | 481 | #define SQLITE_IOCAP_SAFE_APPEND 0x00000200 |
| 465 | 482 | #define SQLITE_IOCAP_SEQUENTIAL 0x00000400 |
| 466 | 483 | |
| 467 | 484 | /* |
| 468 | -** CAPI3REF: File Locking Levels {H10250} <H11120> <H11310> | |
| 485 | +** CAPI3REF: File Locking Levels | |
| 469 | 486 | ** |
| 470 | 487 | ** SQLite uses one of these integer values as the second |
| 471 | 488 | ** argument to calls it makes to the xLock() and xUnlock() methods |
| 472 | 489 | ** of an [sqlite3_io_methods] object. |
| 473 | 490 | */ |
| @@ -476,11 +493,11 @@ | ||
| 476 | 493 | #define SQLITE_LOCK_RESERVED 2 |
| 477 | 494 | #define SQLITE_LOCK_PENDING 3 |
| 478 | 495 | #define SQLITE_LOCK_EXCLUSIVE 4 |
| 479 | 496 | |
| 480 | 497 | /* |
| 481 | -** CAPI3REF: Synchronization Type Flags {H10260} <H11120> | |
| 498 | +** CAPI3REF: Synchronization Type Flags | |
| 482 | 499 | ** |
| 483 | 500 | ** When SQLite invokes the xSync() method of an |
| 484 | 501 | ** [sqlite3_io_methods] object it uses a combination of |
| 485 | 502 | ** these integer values as the second argument. |
| 486 | 503 | ** |
| @@ -494,11 +511,11 @@ | ||
| 494 | 511 | #define SQLITE_SYNC_NORMAL 0x00002 |
| 495 | 512 | #define SQLITE_SYNC_FULL 0x00003 |
| 496 | 513 | #define SQLITE_SYNC_DATAONLY 0x00010 |
| 497 | 514 | |
| 498 | 515 | /* |
| 499 | -** CAPI3REF: OS Interface Open File Handle {H11110} <S20110> | |
| 516 | +** CAPI3REF: OS Interface Open File Handle | |
| 500 | 517 | ** |
| 501 | 518 | ** An [sqlite3_file] object represents an open file in the |
| 502 | 519 | ** [sqlite3_vfs | OS interface layer]. Individual OS interface |
| 503 | 520 | ** implementations will |
| 504 | 521 | ** want to subclass this object by appending additional fields |
| @@ -510,11 +527,11 @@ | ||
| 510 | 527 | struct sqlite3_file { |
| 511 | 528 | const struct sqlite3_io_methods *pMethods; /* Methods for an open file */ |
| 512 | 529 | }; |
| 513 | 530 | |
| 514 | 531 | /* |
| 515 | -** CAPI3REF: OS Interface File Virtual Methods Object {H11120} <S20110> | |
| 532 | +** CAPI3REF: OS Interface File Virtual Methods Object | |
| 516 | 533 | ** |
| 517 | 534 | ** Every file opened by the [sqlite3_vfs] xOpen method populates an |
| 518 | 535 | ** [sqlite3_file] object (or, more commonly, a subclass of the |
| 519 | 536 | ** [sqlite3_file] object) with a pointer to an instance of this object. |
| 520 | 537 | ** This object defines the methods used to perform various operations |
| @@ -615,11 +632,11 @@ | ||
| 615 | 632 | int (*xDeviceCharacteristics)(sqlite3_file*); |
| 616 | 633 | /* Additional methods may be added in future releases */ |
| 617 | 634 | }; |
| 618 | 635 | |
| 619 | 636 | /* |
| 620 | -** CAPI3REF: Standard File Control Opcodes {H11310} <S30800> | |
| 637 | +** CAPI3REF: Standard File Control Opcodes | |
| 621 | 638 | ** |
| 622 | 639 | ** These integer constants are opcodes for the xFileControl method |
| 623 | 640 | ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] |
| 624 | 641 | ** interface. |
| 625 | 642 | ** |
| @@ -635,11 +652,11 @@ | ||
| 635 | 652 | #define SQLITE_GET_LOCKPROXYFILE 2 |
| 636 | 653 | #define SQLITE_SET_LOCKPROXYFILE 3 |
| 637 | 654 | #define SQLITE_LAST_ERRNO 4 |
| 638 | 655 | |
| 639 | 656 | /* |
| 640 | -** CAPI3REF: Mutex Handle {H17110} <S20130> | |
| 657 | +** CAPI3REF: Mutex Handle | |
| 641 | 658 | ** |
| 642 | 659 | ** The mutex module within SQLite defines [sqlite3_mutex] to be an |
| 643 | 660 | ** abstract type for a mutex object. The SQLite core never looks |
| 644 | 661 | ** at the internal representation of an [sqlite3_mutex]. It only |
| 645 | 662 | ** deals with pointers to the [sqlite3_mutex] object. |
| @@ -647,11 +664,11 @@ | ||
| 647 | 664 | ** Mutexes are created using [sqlite3_mutex_alloc()]. |
| 648 | 665 | */ |
| 649 | 666 | typedef struct sqlite3_mutex sqlite3_mutex; |
| 650 | 667 | |
| 651 | 668 | /* |
| 652 | -** CAPI3REF: OS Interface Object {H11140} <S20100> | |
| 669 | +** CAPI3REF: OS Interface Object | |
| 653 | 670 | ** |
| 654 | 671 | ** An instance of the sqlite3_vfs object defines the interface between |
| 655 | 672 | ** the SQLite core and the underlying operating system. The "vfs" |
| 656 | 673 | ** in the name of the object stands for "virtual file system". |
| 657 | 674 | ** |
| @@ -801,14 +818,14 @@ | ||
| 801 | 818 | /* New fields may be appended in figure versions. The iVersion |
| 802 | 819 | ** value will increment whenever this happens. */ |
| 803 | 820 | }; |
| 804 | 821 | |
| 805 | 822 | /* |
| 806 | -** CAPI3REF: Flags for the xAccess VFS method {H11190} <H11140> | |
| 823 | +** CAPI3REF: Flags for the xAccess VFS method | |
| 807 | 824 | ** |
| 808 | 825 | ** 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 | |
| 810 | 827 | ** what kind of permissions the xAccess method is looking for. |
| 811 | 828 | ** With SQLITE_ACCESS_EXISTS, the xAccess method |
| 812 | 829 | ** simply checks whether the file exists. |
| 813 | 830 | ** With SQLITE_ACCESS_READWRITE, the xAccess method |
| 814 | 831 | ** checks whether the file is both readable and writable. |
| @@ -818,52 +835,52 @@ | ||
| 818 | 835 | #define SQLITE_ACCESS_EXISTS 0 |
| 819 | 836 | #define SQLITE_ACCESS_READWRITE 1 |
| 820 | 837 | #define SQLITE_ACCESS_READ 2 |
| 821 | 838 | |
| 822 | 839 | /* |
| 823 | -** CAPI3REF: Initialize The SQLite Library {H10130} <S20000><S30100> | |
| 840 | +** CAPI3REF: Initialize The SQLite Library | |
| 824 | 841 | ** |
| 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 | |
| 827 | 844 | ** deallocates any resources that were allocated by sqlite3_initialize(). |
| 828 | 845 | ** These routines are designed to aid in process initialization and |
| 829 | 846 | ** shutdown on embedded systems. Workstation applications using |
| 830 | 847 | ** SQLite normally do not need to invoke either of these routines. |
| 831 | 848 | ** |
| 832 | 849 | ** A call to sqlite3_initialize() is an "effective" call if it is |
| 833 | 850 | ** the first time sqlite3_initialize() is invoked during the lifetime of |
| 834 | 851 | ** 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 | |
| 836 | 853 | ** of sqlite3_initialize() does any initialization. All other calls |
| 837 | -** are harmless no-ops. | |
| 854 | +** are harmless no-ops.)^ | |
| 838 | 855 | ** |
| 839 | 856 | ** 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 | |
| 841 | 858 | ** 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.)^ | |
| 843 | 860 | ** |
| 844 | 861 | ** The sqlite3_initialize() interface is threadsafe, but sqlite3_shutdown() |
| 845 | 862 | ** is not. The sqlite3_shutdown() interface must only be called from a |
| 846 | 863 | ** single thread. All open [database connections] must be closed and all |
| 847 | 864 | ** other SQLite resources must be deallocated prior to invoking |
| 848 | 865 | ** sqlite3_shutdown(). |
| 849 | 866 | ** |
| 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() | |
| 852 | 869 | ** will invoke sqlite3_os_end(). |
| 853 | 870 | ** |
| 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 | |
| 856 | 873 | ** the library (perhaps it is unable to allocate a needed resource such |
| 857 | 874 | ** as a mutex) it returns an [error code] other than [SQLITE_OK]. |
| 858 | 875 | ** |
| 859 | -** The sqlite3_initialize() routine is called internally by many other | |
| 876 | +** ^The sqlite3_initialize() routine is called internally by many other | |
| 860 | 877 | ** SQLite interfaces so that an application usually does not need to |
| 861 | 878 | ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] |
| 862 | 879 | ** calls sqlite3_initialize() so the SQLite library will be automatically |
| 863 | 880 | ** 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] | |
| 865 | 882 | ** compile-time option, then the automatic calls to sqlite3_initialize() |
| 866 | 883 | ** are omitted and the application must call sqlite3_initialize() directly |
| 867 | 884 | ** prior to using any other SQLite interface. For maximum portability, |
| 868 | 885 | ** it is recommended that applications always invoke sqlite3_initialize() |
| 869 | 886 | ** directly prior to using any other SQLite interface. Future releases |
| @@ -898,11 +915,11 @@ | ||
| 898 | 915 | SQLITE_API int sqlite3_shutdown(void); |
| 899 | 916 | SQLITE_API int sqlite3_os_init(void); |
| 900 | 917 | SQLITE_API int sqlite3_os_end(void); |
| 901 | 918 | |
| 902 | 919 | /* |
| 903 | -** CAPI3REF: Configuring The SQLite Library {H14100} <S20000><S30200> | |
| 920 | +** CAPI3REF: Configuring The SQLite Library | |
| 904 | 921 | ** EXPERIMENTAL |
| 905 | 922 | ** |
| 906 | 923 | ** The sqlite3_config() interface is used to make global configuration |
| 907 | 924 | ** changes to SQLite in order to tune SQLite to the specific needs of |
| 908 | 925 | ** the application. The default configuration is recommended for most |
| @@ -912,39 +929,36 @@ | ||
| 912 | 929 | ** The sqlite3_config() interface is not threadsafe. The application |
| 913 | 930 | ** must insure that no other SQLite interfaces are invoked by other |
| 914 | 931 | ** threads while sqlite3_config() is running. Furthermore, sqlite3_config() |
| 915 | 932 | ** may only be invoked prior to library initialization using |
| 916 | 933 | ** [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 | |
| 918 | 937 | ** implementation of an application-defined [sqlite3_os_init()]. |
| 919 | 938 | ** |
| 920 | 939 | ** The first argument to sqlite3_config() is an integer |
| 921 | 940 | ** [SQLITE_CONFIG_SINGLETHREAD | configuration option] that determines |
| 922 | 941 | ** what property of SQLite is to be configured. Subsequent arguments |
| 923 | 942 | ** vary depending on the [SQLITE_CONFIG_SINGLETHREAD | configuration option] |
| 924 | 943 | ** in the first argument. |
| 925 | 944 | ** |
| 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 | |
| 928 | 947 | ** 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 | 948 | */ |
| 935 | 949 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_config(int, ...); |
| 936 | 950 | |
| 937 | 951 | /* |
| 938 | -** CAPI3REF: Configure database connections {H14200} <S20000> | |
| 952 | +** CAPI3REF: Configure database connections | |
| 939 | 953 | ** EXPERIMENTAL |
| 940 | 954 | ** |
| 941 | 955 | ** The sqlite3_db_config() interface is used to make configuration |
| 942 | 956 | ** changes to a [database connection]. The interface is similar to |
| 943 | 957 | ** [sqlite3_config()] except that the changes apply to a single |
| 944 | 958 | ** [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 | |
| 946 | 960 | ** the database connection is created using [sqlite3_open()], |
| 947 | 961 | ** [sqlite3_open16()], or [sqlite3_open_v2()]. |
| 948 | 962 | ** |
| 949 | 963 | ** The second argument to sqlite3_db_config(D,V,...) is the |
| 950 | 964 | ** configuration verb - an integer code that indicates what |
| @@ -951,17 +965,17 @@ | ||
| 951 | 965 | ** aspect of the [database connection] is being configured. |
| 952 | 966 | ** The only choice for this value is [SQLITE_DBCONFIG_LOOKASIDE]. |
| 953 | 967 | ** New verbs are likely to be added in future releases of SQLite. |
| 954 | 968 | ** Additional arguments depend on the verb. |
| 955 | 969 | ** |
| 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. | |
| 958 | 972 | */ |
| 959 | 973 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_config(sqlite3*, int op, ...); |
| 960 | 974 | |
| 961 | 975 | /* |
| 962 | -** CAPI3REF: Memory Allocation Routines {H10155} <S20120> | |
| 976 | +** CAPI3REF: Memory Allocation Routines | |
| 963 | 977 | ** EXPERIMENTAL |
| 964 | 978 | ** |
| 965 | 979 | ** An instance of this object defines the interface between SQLite |
| 966 | 980 | ** and low-level memory allocation routines. |
| 967 | 981 | ** |
| @@ -987,11 +1001,11 @@ | ||
| 987 | 1001 | ** The xMalloc and xFree methods must work like the |
| 988 | 1002 | ** malloc() and free() functions from the standard C library. |
| 989 | 1003 | ** The xRealloc method must work like realloc() from the standard C library |
| 990 | 1004 | ** with the exception that if the second argument to xRealloc is zero, |
| 991 | 1005 | ** 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 | |
| 993 | 1007 | ** xRealloc is always a value returned by a prior call to xRoundup. |
| 994 | 1008 | ** And so in cases where xRoundup always returns a positive number, |
| 995 | 1009 | ** xRealloc can perform exactly as the standard library realloc() and |
| 996 | 1010 | ** still be in compliance with this specification. |
| 997 | 1011 | ** |
| @@ -1039,11 +1053,11 @@ | ||
| 1039 | 1053 | void (*xShutdown)(void*); /* Deinitialize the memory allocator */ |
| 1040 | 1054 | void *pAppData; /* Argument to xInit() and xShutdown() */ |
| 1041 | 1055 | }; |
| 1042 | 1056 | |
| 1043 | 1057 | /* |
| 1044 | -** CAPI3REF: Configuration Options {H10160} <S20000> | |
| 1058 | +** CAPI3REF: Configuration Options | |
| 1045 | 1059 | ** EXPERIMENTAL |
| 1046 | 1060 | ** |
| 1047 | 1061 | ** These constants are the available integer configuration options that |
| 1048 | 1062 | ** can be passed as the first argument to the [sqlite3_config()] interface. |
| 1049 | 1063 | ** |
| @@ -1054,151 +1068,181 @@ | ||
| 1054 | 1068 | ** non-zero [error code] if a discontinued or unsupported configuration option |
| 1055 | 1069 | ** is invoked. |
| 1056 | 1070 | ** |
| 1057 | 1071 | ** <dl> |
| 1058 | 1072 | ** <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 | |
| 1060 | 1075 | ** 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> | |
| 1062 | 1082 | ** |
| 1063 | 1083 | ** <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 | |
| 1065 | 1086 | ** mutexing on [database connection] and [prepared statement] objects. |
| 1066 | 1087 | ** The application is responsible for serializing access to |
| 1067 | 1088 | ** [database connections] and [prepared statements]. But other mutexes |
| 1068 | 1089 | ** are enabled so that SQLite will be safe to use in a multi-threaded |
| 1069 | 1090 | ** 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> | |
| 1072 | 1096 | ** |
| 1073 | 1097 | ** <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 | |
| 1075 | 1100 | ** all mutexes including the recursive |
| 1076 | 1101 | ** mutexes on [database connection] and [prepared statement] objects. |
| 1077 | 1102 | ** In this mode (which is the default when SQLite is compiled with |
| 1078 | 1103 | ** [SQLITE_THREADSAFE=1]) the SQLite library will itself serialize access |
| 1079 | 1104 | ** to [database connections] and [prepared statements] so that the |
| 1080 | 1105 | ** application is free to use the same [database connection] or the |
| 1081 | 1106 | ** 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> | |
| 1083 | 1112 | ** |
| 1084 | 1113 | ** <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 | |
| 1086 | 1115 | ** instance of the [sqlite3_mem_methods] structure. The argument specifies |
| 1087 | 1116 | ** 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> | |
| 1089 | 1120 | ** |
| 1090 | 1121 | ** <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 | |
| 1092 | 1123 | ** 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.)^ | |
| 1094 | 1125 | ** This option can be used to overload the default memory allocation |
| 1095 | 1126 | ** routines with a wrapper that simulations memory allocation failure or |
| 1096 | -** tracks memory usage, for example.</dd> | |
| 1127 | +** tracks memory usage, for example. </dd> | |
| 1097 | 1128 | ** |
| 1098 | 1129 | ** <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 | |
| 1100 | 1131 | ** 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: | |
| 1103 | 1134 | ** <ul> |
| 1104 | 1135 | ** <li> [sqlite3_memory_used()] |
| 1105 | 1136 | ** <li> [sqlite3_memory_highwater()] |
| 1106 | 1137 | ** <li> [sqlite3_soft_heap_limit()] |
| 1107 | 1138 | ** <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. | |
| 1109 | 1143 | ** </dd> |
| 1110 | 1144 | ** |
| 1111 | 1145 | ** <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 | |
| 1113 | 1147 | ** scratch memory. There are three arguments: A pointer an 8-byte |
| 1114 | 1148 | ** aligned memory buffer from which the scrach allocations will be |
| 1115 | 1149 | ** drawn, the size of each scratch allocation (sz), |
| 1116 | 1150 | ** and the maximum number of scratch allocations (N). The sz |
| 1117 | 1151 | ** argument must be a multiple of 16. The sz parameter should be a few bytes |
| 1118 | 1152 | ** 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 | |
| 1120 | 1154 | ** 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> | |
| 1128 | 1161 | ** |
| 1129 | 1162 | ** <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 | |
| 1131 | 1164 | ** the database page cache with the default page cache implemenation. |
| 1132 | 1165 | ** This configuration should not be used if an application-define page |
| 1133 | 1166 | ** cache implementation is loaded using the SQLITE_CONFIG_PCACHE option. |
| 1134 | 1167 | ** There are three arguments to this option: A pointer to 8-byte aligned |
| 1135 | 1168 | ** memory, the size of each page buffer (sz), and the number of pages (N). |
| 1136 | 1169 | ** The sz argument should be the size of the largest database page |
| 1137 | 1170 | ** (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, | |
| 1140 | 1173 | ** to make sz a little too large. The first |
| 1141 | 1174 | ** 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 | |
| 1144 | 1177 | ** page cache memory is needed beyond what is provided by this option, then |
| 1145 | 1178 | ** 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 | |
| 1147 | 1180 | ** memory accounting information. The pointer in the first argument must |
| 1148 | 1181 | ** be aligned to an 8-byte boundary or subsequent behavior of SQLite |
| 1149 | 1182 | ** will be undefined.</dd> |
| 1150 | 1183 | ** |
| 1151 | 1184 | ** <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 | |
| 1153 | 1186 | ** for all of its dynamic memory allocation needs beyond those provided |
| 1154 | 1187 | ** for by [SQLITE_CONFIG_SCRATCH] and [SQLITE_CONFIG_PAGECACHE]. |
| 1155 | 1188 | ** There are three arguments: An 8-byte aligned pointer to the memory, |
| 1156 | 1189 | ** 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 | |
| 1158 | 1191 | ** 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 | |
| 1160 | 1193 | ** memory pointer is not NULL and either [SQLITE_ENABLE_MEMSYS3] or |
| 1161 | 1194 | ** [SQLITE_ENABLE_MEMSYS5] are defined, then the alternative memory |
| 1162 | 1195 | ** allocator is engaged to handle all of SQLites memory allocation needs. |
| 1163 | 1196 | ** The first pointer (the memory pointer) must be aligned to an 8-byte |
| 1164 | 1197 | ** boundary or subsequent behavior of SQLite will be undefined.</dd> |
| 1165 | 1198 | ** |
| 1166 | 1199 | ** <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 | |
| 1168 | 1201 | ** instance of the [sqlite3_mutex_methods] structure. The argument specifies |
| 1169 | 1202 | ** 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> | |
| 1171 | 1210 | ** |
| 1172 | 1211 | ** <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 | |
| 1174 | 1213 | ** instance of the [sqlite3_mutex_methods] structure. The |
| 1175 | 1214 | ** [sqlite3_mutex_methods] |
| 1176 | -** structure is filled with the currently defined mutex routines. | |
| 1215 | +** structure is filled with the currently defined mutex routines.)^ | |
| 1177 | 1216 | ** This option can be used to overload the default mutex allocation |
| 1178 | 1217 | ** 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> | |
| 1180 | 1223 | ** |
| 1181 | 1224 | ** <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 | |
| 1184 | 1228 | ** 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] | |
| 1187 | 1231 | ** verb to [sqlite3_db_config()] can be used to change the lookaside |
| 1188 | -** configuration on individual connections.</dd> | |
| 1232 | +** configuration on individual connections.)^ </dd> | |
| 1189 | 1233 | ** |
| 1190 | 1234 | ** <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 | |
| 1192 | 1236 | ** 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 | |
| 1194 | 1238 | ** object and uses it for page cache memory allocations.</dd> |
| 1195 | 1239 | ** |
| 1196 | 1240 | ** <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 | |
| 1198 | 1242 | ** [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> | |
| 1200 | 1244 | ** |
| 1201 | 1245 | ** </dl> |
| 1202 | 1246 | */ |
| 1203 | 1247 | #define SQLITE_CONFIG_SINGLETHREAD 1 /* nil */ |
| 1204 | 1248 | #define SQLITE_CONFIG_MULTITHREAD 2 /* nil */ |
| @@ -1215,94 +1259,90 @@ | ||
| 1215 | 1259 | #define SQLITE_CONFIG_LOOKASIDE 13 /* int int */ |
| 1216 | 1260 | #define SQLITE_CONFIG_PCACHE 14 /* sqlite3_pcache_methods* */ |
| 1217 | 1261 | #define SQLITE_CONFIG_GETPCACHE 15 /* sqlite3_pcache_methods* */ |
| 1218 | 1262 | |
| 1219 | 1263 | /* |
| 1220 | -** CAPI3REF: Configuration Options {H10170} <S20000> | |
| 1264 | +** CAPI3REF: Configuration Options | |
| 1221 | 1265 | ** EXPERIMENTAL |
| 1222 | 1266 | ** |
| 1223 | 1267 | ** These constants are the available integer configuration options that |
| 1224 | 1268 | ** can be passed as the second argument to the [sqlite3_db_config()] interface. |
| 1225 | 1269 | ** |
| 1226 | 1270 | ** New configuration options may be added in future releases of SQLite. |
| 1227 | 1271 | ** Existing configuration options might be discontinued. Applications |
| 1228 | 1272 | ** 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 | |
| 1230 | 1274 | ** non-zero [error code] if a discontinued or unsupported configuration option |
| 1231 | 1275 | ** is invoked. |
| 1232 | 1276 | ** |
| 1233 | 1277 | ** <dl> |
| 1234 | 1278 | ** <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 | |
| 1236 | 1280 | ** [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 | |
| 1238 | 1282 | ** 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 | |
| 1242 | 1287 | ** slots. The size of the buffer in the first argument must be greater than |
| 1243 | 1288 | ** 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 | |
| 1246 | 1292 | ** multiple of 8. See also: [SQLITE_CONFIG_LOOKASIDE]</dd> |
| 1247 | 1293 | ** |
| 1248 | 1294 | ** </dl> |
| 1249 | 1295 | */ |
| 1250 | 1296 | #define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */ |
| 1251 | 1297 | |
| 1252 | 1298 | |
| 1253 | 1299 | /* |
| 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. | |
| 1262 | 1305 | */ |
| 1263 | 1306 | SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff); |
| 1264 | 1307 | |
| 1265 | 1308 | /* |
| 1266 | -** CAPI3REF: Last Insert Rowid {H12220} <S10700> | |
| 1309 | +** CAPI3REF: Last Insert Rowid | |
| 1267 | 1310 | ** |
| 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 | |
| 1270 | 1313 | ** 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 | |
| 1272 | 1315 | ** the table has a column of type [INTEGER PRIMARY KEY] then that column |
| 1273 | 1316 | ** is another alias for the rowid. |
| 1274 | 1317 | ** |
| 1275 | -** This routine returns the [rowid] of the most recent | |
| 1318 | +** ^This routine returns the [rowid] of the most recent | |
| 1276 | 1319 | ** 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 | |
| 1278 | 1321 | ** have ever occurred on that database connection, zero is returned. |
| 1279 | 1322 | ** |
| 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 | |
| 1281 | 1324 | ** row is returned by this routine as long as the trigger is running. |
| 1282 | 1325 | ** 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.)^ | |
| 1284 | 1327 | ** |
| 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 | |
| 1286 | 1329 | ** 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, | |
| 1288 | 1331 | ** 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 | |
| 1290 | 1333 | ** encounters a constraint violation, it does not fail. The |
| 1291 | 1334 | ** INSERT continues to completion after deleting rows that caused |
| 1292 | 1335 | ** the constraint problem so INSERT OR REPLACE will always change |
| 1293 | -** the return value of this interface. | |
| 1336 | +** the return value of this interface.)^ | |
| 1294 | 1337 | ** |
| 1295 | -** For the purposes of this routine, an [INSERT] is considered to | |
| 1338 | +** ^For the purposes of this routine, an [INSERT] is considered to | |
| 1296 | 1339 | ** be successful even if it is subsequently rolled back. |
| 1297 | 1340 | ** |
| 1298 | 1341 | ** This function is accessible to SQL statements via the |
| 1299 | 1342 | ** [last_insert_rowid() SQL function]. |
| 1300 | 1343 | ** |
| 1301 | -** Requirements: | |
| 1302 | -** [H12221] [H12223] | |
| 1303 | -** | |
| 1304 | 1344 | ** If a separate thread performs a new [INSERT] on the same |
| 1305 | 1345 | ** database connection while the [sqlite3_last_insert_rowid()] |
| 1306 | 1346 | ** function is running and thus changes the last insert [rowid], |
| 1307 | 1347 | ** then the value returned by [sqlite3_last_insert_rowid()] is |
| 1308 | 1348 | ** unpredictable and might not equal either the old or the new |
| @@ -1309,164 +1349,154 @@ | ||
| 1309 | 1349 | ** last insert [rowid]. |
| 1310 | 1350 | */ |
| 1311 | 1351 | SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*); |
| 1312 | 1352 | |
| 1313 | 1353 | /* |
| 1314 | -** CAPI3REF: Count The Number Of Rows Modified {H12240} <S10600> | |
| 1354 | +** CAPI3REF: Count The Number Of Rows Modified | |
| 1315 | 1355 | ** |
| 1316 | -** This function returns the number of database rows that were changed | |
| 1356 | +** ^This function returns the number of database rows that were changed | |
| 1317 | 1357 | ** or inserted or deleted by the most recently completed SQL statement |
| 1318 | 1358 | ** 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], | |
| 1320 | 1360 | ** 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 | |
| 1322 | 1362 | ** [sqlite3_total_changes()] function to find the total number of changes |
| 1323 | 1363 | ** including changes caused by triggers and foreign key actions. |
| 1324 | 1364 | ** |
| 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] | |
| 1326 | 1366 | ** are not counted. Only real table changes are counted. |
| 1327 | 1367 | ** |
| 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 | |
| 1329 | 1369 | ** caused by an INSERT, DELETE, or UPDATE statement. Rows that |
| 1330 | 1370 | ** are changed as side effects of [REPLACE] constraint resolution, |
| 1331 | 1371 | ** 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.)^ | |
| 1333 | 1373 | ** |
| 1334 | 1374 | ** A "trigger context" is a scope of execution that begins and |
| 1335 | 1375 | ** ends with the script of a [CREATE TRIGGER | trigger]. |
| 1336 | 1376 | ** Most SQL statements are |
| 1337 | 1377 | ** evaluated outside of any trigger. This is the "top level" |
| 1338 | 1378 | ** trigger context. If a trigger fires from the top level, a |
| 1339 | 1379 | ** new trigger context is entered for the duration of that one |
| 1340 | 1380 | ** trigger. Subtriggers create subcontexts for their duration. |
| 1341 | 1381 | ** |
| 1342 | -** Calling [sqlite3_exec()] or [sqlite3_step()] recursively does | |
| 1382 | +** ^Calling [sqlite3_exec()] or [sqlite3_step()] recursively does | |
| 1343 | 1383 | ** not create a new trigger context. |
| 1344 | 1384 | ** |
| 1345 | -** This function returns the number of direct row changes in the | |
| 1385 | +** ^This function returns the number of direct row changes in the | |
| 1346 | 1386 | ** most recent INSERT, UPDATE, or DELETE statement within the same |
| 1347 | 1387 | ** trigger context. |
| 1348 | 1388 | ** |
| 1349 | -** Thus, when called from the top level, this function returns the | |
| 1389 | +** ^Thus, when called from the top level, this function returns the | |
| 1350 | 1390 | ** 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, | |
| 1352 | 1392 | ** the sqlite3_changes() interface can be called to find the number of |
| 1353 | 1393 | ** changes in the most recently completed INSERT, UPDATE, or DELETE |
| 1354 | 1394 | ** statement within the body of the same trigger. |
| 1355 | 1395 | ** 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.)^ | |
| 1357 | 1397 | ** |
| 1358 | 1398 | ** See also the [sqlite3_total_changes()] interface, the |
| 1359 | 1399 | ** [count_changes pragma], and the [changes() SQL function]. |
| 1360 | 1400 | ** |
| 1361 | -** Requirements: | |
| 1362 | -** [H12241] [H12243] | |
| 1363 | -** | |
| 1364 | 1401 | ** If a separate thread makes changes on the same database connection |
| 1365 | 1402 | ** while [sqlite3_changes()] is running then the value returned |
| 1366 | 1403 | ** is unpredictable and not meaningful. |
| 1367 | 1404 | */ |
| 1368 | 1405 | SQLITE_API int sqlite3_changes(sqlite3*); |
| 1369 | 1406 | |
| 1370 | 1407 | /* |
| 1371 | -** CAPI3REF: Total Number Of Rows Modified {H12260} <S10600> | |
| 1408 | +** CAPI3REF: Total Number Of Rows Modified | |
| 1372 | 1409 | ** |
| 1373 | -** This function returns the number of row changes caused by [INSERT], | |
| 1410 | +** ^This function returns the number of row changes caused by [INSERT], | |
| 1374 | 1411 | ** [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, | |
| 1377 | 1415 | ** the count does not include changes used to implement [REPLACE] constraints, |
| 1378 | 1416 | ** do rollbacks or ABORT processing, or [DROP TABLE] processing. The |
| 1379 | 1417 | ** count does not include rows of views that fire an [INSTEAD OF trigger], |
| 1380 | 1418 | ** 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()]). | |
| 1385 | 1423 | ** |
| 1386 | 1424 | ** See also the [sqlite3_changes()] interface, the |
| 1387 | 1425 | ** [count_changes pragma], and the [total_changes() SQL function]. |
| 1388 | 1426 | ** |
| 1389 | -** Requirements: | |
| 1390 | -** [H12261] [H12263] | |
| 1391 | -** | |
| 1392 | 1427 | ** If a separate thread makes changes on the same database connection |
| 1393 | 1428 | ** while [sqlite3_total_changes()] is running then the value |
| 1394 | 1429 | ** returned is unpredictable and not meaningful. |
| 1395 | 1430 | */ |
| 1396 | 1431 | SQLITE_API int sqlite3_total_changes(sqlite3*); |
| 1397 | 1432 | |
| 1398 | 1433 | /* |
| 1399 | -** CAPI3REF: Interrupt A Long-Running Query {H12270} <S30500> | |
| 1434 | +** CAPI3REF: Interrupt A Long-Running Query | |
| 1400 | 1435 | ** |
| 1401 | -** This function causes any pending database operation to abort and | |
| 1436 | +** ^This function causes any pending database operation to abort and | |
| 1402 | 1437 | ** return at its earliest opportunity. This routine is typically |
| 1403 | 1438 | ** called in response to a user action such as pressing "Cancel" |
| 1404 | 1439 | ** or Ctrl-C where the user wants a long query operation to halt |
| 1405 | 1440 | ** immediately. |
| 1406 | 1441 | ** |
| 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 | |
| 1408 | 1443 | ** thread that is currently running the database operation. But it |
| 1409 | 1444 | ** is not safe to call this routine with a [database connection] that |
| 1410 | 1445 | ** is closed or might close before sqlite3_interrupt() returns. |
| 1411 | 1446 | ** |
| 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 | |
| 1413 | 1448 | ** sqlite3_interrupt() is called, then it might not have an opportunity |
| 1414 | 1449 | ** to be interrupted and might continue to completion. |
| 1415 | 1450 | ** |
| 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 | |
| 1418 | 1453 | ** that is inside an explicit transaction, then the entire transaction |
| 1419 | 1454 | ** will be rolled back automatically. |
| 1420 | 1455 | ** |
| 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 | |
| 1423 | 1458 | ** that are started after the sqlite3_interrupt() call and before the |
| 1424 | 1459 | ** 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 | |
| 1426 | 1461 | ** that are started after the running statement count reaches zero are |
| 1427 | 1462 | ** 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 | |
| 1429 | 1464 | ** SQL statements is a no-op and has no effect on SQL statements |
| 1430 | 1465 | ** that are started after the sqlite3_interrupt() call returns. |
| 1431 | 1466 | ** |
| 1432 | -** Requirements: | |
| 1433 | -** [H12271] [H12272] | |
| 1434 | -** | |
| 1435 | 1467 | ** If the database connection closes while [sqlite3_interrupt()] |
| 1436 | 1468 | ** is running then bad things will likely happen. |
| 1437 | 1469 | */ |
| 1438 | 1470 | SQLITE_API void sqlite3_interrupt(sqlite3*); |
| 1439 | 1471 | |
| 1440 | 1472 | /* |
| 1441 | -** CAPI3REF: Determine If An SQL Statement Is Complete {H10510} <S70200> | |
| 1473 | +** CAPI3REF: Determine If An SQL Statement Is Complete | |
| 1442 | 1474 | ** |
| 1443 | 1475 | ** These routines are useful during command-line input to determine if the |
| 1444 | 1476 | ** currently entered text seems to form a complete SQL statement or |
| 1445 | 1477 | ** 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 | |
| 1448 | 1480 | ** 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 | |
| 1450 | 1482 | ** string literals or quoted identifier names or comments are not |
| 1451 | 1483 | ** 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 | |
| 1453 | 1485 | ** and comments that follow the final semicolon are ignored. |
| 1454 | 1486 | ** |
| 1455 | -** These routines return 0 if the statement is incomplete. If a | |
| 1487 | +** ^These routines return 0 if the statement is incomplete. ^If a | |
| 1456 | 1488 | ** memory allocation fails, then SQLITE_NOMEM is returned. |
| 1457 | 1489 | ** |
| 1458 | -** These routines do not parse the SQL statements thus | |
| 1490 | +** ^These routines do not parse the SQL statements thus | |
| 1459 | 1491 | ** will not detect syntactically incorrect SQL. |
| 1460 | 1492 | ** |
| 1461 | -** If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 1493 | +** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior | |
| 1462 | 1494 | ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked |
| 1463 | 1495 | ** automatically by sqlite3_complete16(). If that initialization fails, |
| 1464 | 1496 | ** 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.)^ | |
| 1468 | 1498 | ** |
| 1469 | 1499 | ** The input to [sqlite3_complete()] must be a zero-terminated |
| 1470 | 1500 | ** UTF-8 string. |
| 1471 | 1501 | ** |
| 1472 | 1502 | ** The input to [sqlite3_complete16()] must be a zero-terminated |
| @@ -1474,31 +1504,31 @@ | ||
| 1474 | 1504 | */ |
| 1475 | 1505 | SQLITE_API int sqlite3_complete(const char *sql); |
| 1476 | 1506 | SQLITE_API int sqlite3_complete16(const void *sql); |
| 1477 | 1507 | |
| 1478 | 1508 | /* |
| 1479 | -** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors {H12310} <S40400> | |
| 1509 | +** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors | |
| 1480 | 1510 | ** |
| 1481 | -** This routine sets a callback function that might be invoked whenever | |
| 1511 | +** ^This routine sets a callback function that might be invoked whenever | |
| 1482 | 1512 | ** an attempt is made to open a database table that another thread |
| 1483 | 1513 | ** or process has locked. |
| 1484 | 1514 | ** |
| 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. | |
| 1488 | 1518 | ** |
| 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 | |
| 1493 | 1523 | ** busy callback returns 0, then no additional attempts are made to |
| 1494 | 1524 | ** 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 | |
| 1496 | 1526 | ** is made to open the database for reading and the cycle repeats. |
| 1497 | 1527 | ** |
| 1498 | 1528 | ** 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 | |
| 1500 | 1530 | ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] |
| 1501 | 1531 | ** or [SQLITE_IOERR_BLOCKED] instead of invoking the busy handler. |
| 1502 | 1532 | ** Consider a scenario where one process is holding a read lock that |
| 1503 | 1533 | ** it is trying to promote to a reserved lock and |
| 1504 | 1534 | ** a second process is holding a reserved lock that it is trying |
| @@ -1508,69 +1538,63 @@ | ||
| 1508 | 1538 | ** invoke the busy handlers, neither will make any progress. Therefore, |
| 1509 | 1539 | ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this |
| 1510 | 1540 | ** will induce the first process to release its read lock and allow |
| 1511 | 1541 | ** the second process to proceed. |
| 1512 | 1542 | ** |
| 1513 | -** The default busy callback is NULL. | |
| 1543 | +** ^The default busy callback is NULL. | |
| 1514 | 1544 | ** |
| 1515 | -** The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] | |
| 1545 | +** ^The [SQLITE_BUSY] error is converted to [SQLITE_IOERR_BLOCKED] | |
| 1516 | 1546 | ** when SQLite is in the middle of a large transaction where all the |
| 1517 | 1547 | ** changes will not fit into the in-memory cache. SQLite will |
| 1518 | 1548 | ** already hold a RESERVED lock on the database file, but it needs |
| 1519 | 1549 | ** to promote this lock to EXCLUSIVE so that it can spill cache |
| 1520 | 1550 | ** 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 | |
| 1522 | 1552 | ** cache will be left in an inconsistent state and so the error |
| 1523 | 1553 | ** 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 | |
| 1525 | 1555 | ** forces an automatic rollback of the changes. See the |
| 1526 | 1556 | ** <a href="/cvstrac/wiki?p=CorruptionFollowingBusyError"> |
| 1527 | 1557 | ** CorruptionFollowingBusyError</a> wiki page for a discussion of why |
| 1528 | 1558 | ** this is important. |
| 1529 | 1559 | ** |
| 1530 | -** There can only be a single busy handler defined for each | |
| 1560 | +** ^(There can only be a single busy handler defined for each | |
| 1531 | 1561 | ** [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()] | |
| 1533 | 1563 | ** will also set or clear the busy handler. |
| 1534 | 1564 | ** |
| 1535 | 1565 | ** The busy callback should not take any actions which modify the |
| 1536 | 1566 | ** database connection that invoked the busy handler. Any such actions |
| 1537 | 1567 | ** result in undefined behavior. |
| 1538 | 1568 | ** |
| 1539 | -** Requirements: | |
| 1540 | -** [H12311] [H12312] [H12314] [H12316] [H12318] | |
| 1541 | -** | |
| 1542 | 1569 | ** A busy handler must not close the database connection |
| 1543 | 1570 | ** or [prepared statement] that invoked the busy handler. |
| 1544 | 1571 | */ |
| 1545 | 1572 | SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); |
| 1546 | 1573 | |
| 1547 | 1574 | /* |
| 1548 | -** CAPI3REF: Set A Busy Timeout {H12340} <S40410> | |
| 1575 | +** CAPI3REF: Set A Busy Timeout | |
| 1549 | 1576 | ** |
| 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 | |
| 1552 | 1579 | ** 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, | |
| 1554 | 1581 | ** the handler returns 0 which causes [sqlite3_step()] to return |
| 1555 | 1582 | ** [SQLITE_BUSY] or [SQLITE_IOERR_BLOCKED]. |
| 1556 | 1583 | ** |
| 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 | |
| 1558 | 1585 | ** turns off all busy handlers. |
| 1559 | 1586 | ** |
| 1560 | -** There can only be a single busy handler for a particular | |
| 1587 | +** ^(There can only be a single busy handler for a particular | |
| 1561 | 1588 | ** [database connection] any any given moment. If another busy handler |
| 1562 | 1589 | ** 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.)^ | |
| 1567 | 1591 | */ |
| 1568 | 1592 | SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); |
| 1569 | 1593 | |
| 1570 | 1594 | /* |
| 1571 | -** CAPI3REF: Convenience Routines For Running Queries {H12370} <S10000> | |
| 1595 | +** CAPI3REF: Convenience Routines For Running Queries | |
| 1572 | 1596 | ** |
| 1573 | 1597 | ** Definition: A <b>result table</b> is memory data structure created by the |
| 1574 | 1598 | ** [sqlite3_get_table()] interface. A result table records the |
| 1575 | 1599 | ** complete query results from one or more queries. |
| 1576 | 1600 | ** |
| @@ -1614,31 +1638,29 @@ | ||
| 1614 | 1638 | ** azResult[5] = "28"; |
| 1615 | 1639 | ** azResult[6] = "Cindy"; |
| 1616 | 1640 | ** azResult[7] = "21"; |
| 1617 | 1641 | ** </pre></blockquote> |
| 1618 | 1642 | ** |
| 1619 | -** The sqlite3_get_table() function evaluates one or more | |
| 1643 | +** ^The sqlite3_get_table() function evaluates one or more | |
| 1620 | 1644 | ** 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 | |
| 1622 | 1646 | ** pointer given in its 3rd parameter. |
| 1623 | 1647 | ** |
| 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 | |
| 1626 | 1650 | ** release the memory that was malloced. Because of the way the |
| 1627 | 1651 | ** [sqlite3_malloc()] happens within sqlite3_get_table(), the calling |
| 1628 | 1652 | ** function must not try to call [sqlite3_free()] directly. Only |
| 1629 | 1653 | ** [sqlite3_free_table()] is able to release the memory properly and safely. |
| 1630 | 1654 | ** |
| 1631 | -** The sqlite3_get_table() interface is implemented as a wrapper around | |
| 1655 | +** ^(The sqlite3_get_table() interface is implemented as a wrapper around | |
| 1632 | 1656 | ** [sqlite3_exec()]. The sqlite3_get_table() routine does not have access |
| 1633 | 1657 | ** to any internal data structures of SQLite. It uses only the public |
| 1634 | 1658 | ** interface defined here. As a consequence, errors that occur in the |
| 1635 | 1659 | ** 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()].)^ | |
| 1640 | 1662 | */ |
| 1641 | 1663 | SQLITE_API int sqlite3_get_table( |
| 1642 | 1664 | sqlite3 *db, /* An open database */ |
| 1643 | 1665 | const char *zSql, /* SQL to be evaluated */ |
| 1644 | 1666 | char ***pazResult, /* Results of the query */ |
| @@ -1647,49 +1669,49 @@ | ||
| 1647 | 1669 | char **pzErrmsg /* Error msg written here */ |
| 1648 | 1670 | ); |
| 1649 | 1671 | SQLITE_API void sqlite3_free_table(char **result); |
| 1650 | 1672 | |
| 1651 | 1673 | /* |
| 1652 | -** CAPI3REF: Formatted String Printing Functions {H17400} <S70000><S20000> | |
| 1674 | +** CAPI3REF: Formatted String Printing Functions | |
| 1653 | 1675 | ** |
| 1654 | 1676 | ** These routines are work-alikes of the "printf()" family of functions |
| 1655 | 1677 | ** from the standard C library. |
| 1656 | 1678 | ** |
| 1657 | -** The sqlite3_mprintf() and sqlite3_vmprintf() routines write their | |
| 1679 | +** ^The sqlite3_mprintf() and sqlite3_vmprintf() routines write their | |
| 1658 | 1680 | ** results into memory obtained from [sqlite3_malloc()]. |
| 1659 | 1681 | ** 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 | |
| 1661 | 1683 | ** NULL pointer if [sqlite3_malloc()] is unable to allocate enough |
| 1662 | 1684 | ** memory to hold the resulting string. |
| 1663 | 1685 | ** |
| 1664 | -** In sqlite3_snprintf() routine is similar to "snprintf()" from | |
| 1686 | +** ^(In sqlite3_snprintf() routine is similar to "snprintf()" from | |
| 1665 | 1687 | ** the standard C library. The result is written into the |
| 1666 | 1688 | ** buffer supplied as the second parameter whose size is given by |
| 1667 | 1689 | ** 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 | |
| 1669 | 1691 | ** historical accident that cannot be fixed without breaking |
| 1670 | -** backwards compatibility. Note also that sqlite3_snprintf() | |
| 1692 | +** backwards compatibility. ^(Note also that sqlite3_snprintf() | |
| 1671 | 1693 | ** 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 | |
| 1673 | 1695 | ** the number of characters written would be a more useful return |
| 1674 | 1696 | ** value but we cannot change the implementation of sqlite3_snprintf() |
| 1675 | 1697 | ** now without breaking compatibility. |
| 1676 | 1698 | ** |
| 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 | |
| 1679 | 1701 | ** parameter "n" is the total size of the buffer, including space for |
| 1680 | 1702 | ** the zero terminator. So the longest string that can be completely |
| 1681 | 1703 | ** written will be n-1 characters. |
| 1682 | 1704 | ** |
| 1683 | 1705 | ** These routines all implement some additional formatting |
| 1684 | 1706 | ** options that are useful for constructing SQL statements. |
| 1685 | 1707 | ** All of the usual printf() formatting options apply. In addition, there |
| 1686 | 1708 | ** is are "%q", "%Q", and "%z" options. |
| 1687 | 1709 | ** |
| 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 | |
| 1689 | 1711 | ** 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 '\'' | |
| 1691 | 1713 | ** character it escapes that character and allows it to be inserted into |
| 1692 | 1714 | ** the string. |
| 1693 | 1715 | ** |
| 1694 | 1716 | ** For example, assume the string variable zText contains text as follows: |
| 1695 | 1717 | ** |
| @@ -1720,14 +1742,14 @@ | ||
| 1720 | 1742 | ** </pre></blockquote> |
| 1721 | 1743 | ** |
| 1722 | 1744 | ** This second example is an SQL syntax error. As a general rule you should |
| 1723 | 1745 | ** always use %q instead of %s when inserting text into a string literal. |
| 1724 | 1746 | ** |
| 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 | |
| 1726 | 1748 | ** the outside of the total string. Additionally, if the parameter in the |
| 1727 | 1749 | ** 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: | |
| 1729 | 1751 | ** |
| 1730 | 1752 | ** <blockquote><pre> |
| 1731 | 1753 | ** char *zSQL = sqlite3_mprintf("INSERT INTO table VALUES(%Q)", zText); |
| 1732 | 1754 | ** sqlite3_exec(db, zSQL, 0, 0, 0); |
| 1733 | 1755 | ** sqlite3_free(zSQL); |
| @@ -1734,75 +1756,63 @@ | ||
| 1734 | 1756 | ** </pre></blockquote> |
| 1735 | 1757 | ** |
| 1736 | 1758 | ** The code above will render a correct SQL statement in the zSQL |
| 1737 | 1759 | ** variable even if the zText variable is a NULL pointer. |
| 1738 | 1760 | ** |
| 1739 | -** The "%z" formatting option works exactly like "%s" with the | |
| 1761 | +** ^(The "%z" formatting option works like "%s" but with the | |
| 1740 | 1762 | ** 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.)^ | |
| 1745 | 1764 | */ |
| 1746 | 1765 | SQLITE_API char *sqlite3_mprintf(const char*,...); |
| 1747 | 1766 | SQLITE_API char *sqlite3_vmprintf(const char*, va_list); |
| 1748 | 1767 | SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...); |
| 1749 | 1768 | |
| 1750 | 1769 | /* |
| 1751 | -** CAPI3REF: Memory Allocation Subsystem {H17300} <S20000> | |
| 1770 | +** CAPI3REF: Memory Allocation Subsystem | |
| 1752 | 1771 | ** |
| 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 | |
| 1754 | 1773 | ** internal memory allocation needs. "Core" in the previous sentence |
| 1755 | 1774 | ** does not include operating-system specific VFS implementation. The |
| 1756 | 1775 | ** Windows VFS uses native malloc() and free() for some operations. |
| 1757 | 1776 | ** |
| 1758 | -** The sqlite3_malloc() routine returns a pointer to a block | |
| 1777 | +** ^The sqlite3_malloc() routine returns a pointer to a block | |
| 1759 | 1778 | ** 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 | |
| 1762 | 1781 | ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns |
| 1763 | 1782 | ** a NULL pointer. |
| 1764 | 1783 | ** |
| 1765 | -** Calling sqlite3_free() with a pointer previously returned | |
| 1784 | +** ^Calling sqlite3_free() with a pointer previously returned | |
| 1766 | 1785 | ** 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 | |
| 1768 | 1787 | ** a no-op if is called with a NULL pointer. Passing a NULL pointer |
| 1769 | 1788 | ** to sqlite3_free() is harmless. After being freed, memory |
| 1770 | 1789 | ** should neither be read nor written. Even reading previously freed |
| 1771 | 1790 | ** memory might result in a segmentation fault or other severe error. |
| 1772 | 1791 | ** Memory corruption, a segmentation fault, or other severe error |
| 1773 | 1792 | ** might result if sqlite3_free() is called with a non-NULL pointer that |
| 1774 | 1793 | ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). |
| 1775 | 1794 | ** |
| 1776 | -** The sqlite3_realloc() interface attempts to resize a | |
| 1795 | +** ^(The sqlite3_realloc() interface attempts to resize a | |
| 1777 | 1796 | ** prior memory allocation to be at least N bytes, where N is the |
| 1778 | 1797 | ** 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() | |
| 1780 | 1799 | ** is a NULL pointer then its behavior is identical to calling |
| 1781 | 1800 | ** 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 | |
| 1783 | 1802 | ** negative then the behavior is exactly the same as calling |
| 1784 | 1803 | ** 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 | |
| 1786 | 1805 | ** 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 | |
| 1788 | 1807 | ** of the prior allocation are copied into the beginning of buffer returned |
| 1789 | 1808 | ** 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 | |
| 1791 | 1810 | ** is not freed. |
| 1792 | 1811 | ** |
| 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. | |
| 1804 | 1814 | ** |
| 1805 | 1815 | ** In SQLite version 3.5.0 and 3.5.1, it was possible to define |
| 1806 | 1816 | ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in |
| 1807 | 1817 | ** implementation of these routines to be omitted. That capability |
| 1808 | 1818 | ** is no longer provided. Only built-in memory allocators can be used. |
| @@ -1813,14 +1823,10 @@ | ||
| 1813 | 1823 | ** and whatever filename encoding is used by the particular Windows |
| 1814 | 1824 | ** installation. Memory allocation errors are detected, but |
| 1815 | 1825 | ** they are reported back as [SQLITE_CANTOPEN] or |
| 1816 | 1826 | ** [SQLITE_IOERR] rather than [SQLITE_NOMEM]. |
| 1817 | 1827 | ** |
| 1818 | -** Requirements: | |
| 1819 | -** [H17303] [H17304] [H17305] [H17306] [H17310] [H17312] [H17315] [H17318] | |
| 1820 | -** [H17321] [H17322] [H17323] | |
| 1821 | -** | |
| 1822 | 1828 | ** The pointer arguments to [sqlite3_free()] and [sqlite3_realloc()] |
| 1823 | 1829 | ** must be either NULL or else pointers obtained from a prior |
| 1824 | 1830 | ** invocation of [sqlite3_malloc()] or [sqlite3_realloc()] that have |
| 1825 | 1831 | ** not yet been released. |
| 1826 | 1832 | ** |
| @@ -1831,85 +1837,95 @@ | ||
| 1831 | 1837 | SQLITE_API void *sqlite3_malloc(int); |
| 1832 | 1838 | SQLITE_API void *sqlite3_realloc(void*, int); |
| 1833 | 1839 | SQLITE_API void sqlite3_free(void*); |
| 1834 | 1840 | |
| 1835 | 1841 | /* |
| 1836 | -** CAPI3REF: Memory Allocator Statistics {H17370} <S30210> | |
| 1842 | +** CAPI3REF: Memory Allocator Statistics | |
| 1837 | 1843 | ** |
| 1838 | 1844 | ** SQLite provides these two interfaces for reporting on the status |
| 1839 | 1845 | ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] |
| 1840 | 1846 | ** routines, which form the built-in memory allocation subsystem. |
| 1841 | 1847 | ** |
| 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. | |
| 1844 | 1863 | */ |
| 1845 | 1864 | SQLITE_API sqlite3_int64 sqlite3_memory_used(void); |
| 1846 | 1865 | SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag); |
| 1847 | 1866 | |
| 1848 | 1867 | /* |
| 1849 | -** CAPI3REF: Pseudo-Random Number Generator {H17390} <S20000> | |
| 1868 | +** CAPI3REF: Pseudo-Random Number Generator | |
| 1850 | 1869 | ** |
| 1851 | 1870 | ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to |
| 1852 | 1871 | ** select random [ROWID | ROWIDs] when inserting new records into a table that |
| 1853 | 1872 | ** already uses the largest possible [ROWID]. The PRNG is also used for |
| 1854 | 1873 | ** the build-in random() and randomblob() SQL functions. This interface allows |
| 1855 | 1874 | ** applications to access the same PRNG for other purposes. |
| 1856 | 1875 | ** |
| 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. | |
| 1858 | 1877 | ** |
| 1859 | -** The first time this routine is invoked (either internally or by | |
| 1878 | +** ^The first time this routine is invoked (either internally or by | |
| 1860 | 1879 | ** the application) the PRNG is seeded using randomness obtained |
| 1861 | 1880 | ** 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 | |
| 1863 | 1882 | ** internally and without recourse to the [sqlite3_vfs] xRandomness |
| 1864 | 1883 | ** method. |
| 1865 | -** | |
| 1866 | -** Requirements: | |
| 1867 | -** [H17392] | |
| 1868 | 1884 | */ |
| 1869 | 1885 | SQLITE_API void sqlite3_randomness(int N, void *P); |
| 1870 | 1886 | |
| 1871 | 1887 | /* |
| 1872 | -** CAPI3REF: Compile-Time Authorization Callbacks {H12500} <S70100> | |
| 1888 | +** CAPI3REF: Compile-Time Authorization Callbacks | |
| 1873 | 1889 | ** |
| 1874 | -** This routine registers a authorizer callback with a particular | |
| 1890 | +** ^This routine registers a authorizer callback with a particular | |
| 1875 | 1891 | ** [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 | |
| 1877 | 1893 | ** 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 | |
| 1879 | 1895 | ** points during the compilation process, as logic is being created |
| 1880 | 1896 | ** 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 | |
| 1882 | 1898 | ** return [SQLITE_OK] to allow the action, [SQLITE_IGNORE] to disallow the |
| 1883 | 1899 | ** specific action but allow the SQL statement to continue to be |
| 1884 | 1900 | ** 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 | |
| 1886 | 1902 | ** any value other than [SQLITE_IGNORE], [SQLITE_OK], or [SQLITE_DENY] |
| 1887 | 1903 | ** then the [sqlite3_prepare_v2()] or equivalent call that triggered |
| 1888 | 1904 | ** the authorizer will fail with an error message. |
| 1889 | 1905 | ** |
| 1890 | 1906 | ** 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 | |
| 1892 | 1908 | ** [sqlite3_prepare_v2()] or equivalent call that triggered the |
| 1893 | 1909 | ** authorizer will fail with an error message explaining that |
| 1894 | 1910 | ** access is denied. |
| 1895 | 1911 | ** |
| 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 | |
| 1898 | 1914 | ** 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 | |
| 1900 | 1916 | ** to the callback are zero-terminated strings that contain additional |
| 1901 | 1917 | ** details about the action to be authorized. |
| 1902 | 1918 | ** |
| 1903 | -** If the action code is [SQLITE_READ] | |
| 1919 | +** ^If the action code is [SQLITE_READ] | |
| 1904 | 1920 | ** and the callback returns [SQLITE_IGNORE] then the |
| 1905 | 1921 | ** [prepared statement] statement is constructed to substitute |
| 1906 | 1922 | ** a NULL value in place of the table column that would have |
| 1907 | 1923 | ** been read if [SQLITE_OK] had been returned. The [SQLITE_IGNORE] |
| 1908 | 1924 | ** return can be used to deny an untrusted user access to individual |
| 1909 | 1925 | ** 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 | |
| 1911 | 1927 | ** [SQLITE_IGNORE] then the [DELETE] operation proceeds but the |
| 1912 | 1928 | ** [truncate optimization] is disabled and all rows are deleted individually. |
| 1913 | 1929 | ** |
| 1914 | 1930 | ** An authorizer is used when [sqlite3_prepare | preparing] |
| 1915 | 1931 | ** SQL statements from an untrusted source, to ensure that the SQL statements |
| @@ -1925,43 +1941,39 @@ | ||
| 1925 | 1941 | ** Applications that need to process SQL from untrusted sources |
| 1926 | 1942 | ** might also consider lowering resource limits using [sqlite3_limit()] |
| 1927 | 1943 | ** and limiting database size using the [max_page_count] [PRAGMA] |
| 1928 | 1944 | ** in addition to using an authorizer. |
| 1929 | 1945 | ** |
| 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 | |
| 1931 | 1947 | ** 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. | |
| 1933 | 1949 | ** The authorizer is disabled by default. |
| 1934 | 1950 | ** |
| 1935 | 1951 | ** The authorizer callback must not do anything that will modify |
| 1936 | 1952 | ** the database connection that invoked the authorizer callback. |
| 1937 | 1953 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 1938 | 1954 | ** database connections for the meaning of "modify" in this paragraph. |
| 1939 | 1955 | ** |
| 1940 | -** When [sqlite3_prepare_v2()] is used to prepare a statement, the | |
| 1956 | +** ^When [sqlite3_prepare_v2()] is used to prepare a statement, the | |
| 1941 | 1957 | ** statement might be re-prepared during [sqlite3_step()] due to a |
| 1942 | 1958 | ** schema change. Hence, the application should ensure that the |
| 1943 | 1959 | ** correct authorizer callback remains in place during the [sqlite3_step()]. |
| 1944 | 1960 | ** |
| 1945 | -** Note that the authorizer callback is invoked only during | |
| 1961 | +** ^Note that the authorizer callback is invoked only during | |
| 1946 | 1962 | ** [sqlite3_prepare()] or its variants. Authorization is not |
| 1947 | 1963 | ** performed during statement evaluation in [sqlite3_step()], unless |
| 1948 | 1964 | ** as stated in the previous paragraph, sqlite3_step() invokes |
| 1949 | 1965 | ** 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 | 1966 | */ |
| 1955 | 1967 | SQLITE_API int sqlite3_set_authorizer( |
| 1956 | 1968 | sqlite3*, |
| 1957 | 1969 | int (*xAuth)(void*,int,const char*,const char*,const char*,const char*), |
| 1958 | 1970 | void *pUserData |
| 1959 | 1971 | ); |
| 1960 | 1972 | |
| 1961 | 1973 | /* |
| 1962 | -** CAPI3REF: Authorizer Return Codes {H12590} <H12500> | |
| 1974 | +** CAPI3REF: Authorizer Return Codes | |
| 1963 | 1975 | ** |
| 1964 | 1976 | ** The [sqlite3_set_authorizer | authorizer callback function] must |
| 1965 | 1977 | ** return either [SQLITE_OK] or one of these two constants in order |
| 1966 | 1978 | ** to signal SQLite whether or not the action is permitted. See the |
| 1967 | 1979 | ** [sqlite3_set_authorizer | authorizer documentation] for additional |
| @@ -1969,11 +1981,11 @@ | ||
| 1969 | 1981 | */ |
| 1970 | 1982 | #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ |
| 1971 | 1983 | #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ |
| 1972 | 1984 | |
| 1973 | 1985 | /* |
| 1974 | -** CAPI3REF: Authorizer Action Codes {H12550} <H12500> | |
| 1986 | +** CAPI3REF: Authorizer Action Codes | |
| 1975 | 1987 | ** |
| 1976 | 1988 | ** The [sqlite3_set_authorizer()] interface registers a callback function |
| 1977 | 1989 | ** that is invoked to authorize certain SQL statement actions. The |
| 1978 | 1990 | ** second parameter to the callback is an integer code that specifies |
| 1979 | 1991 | ** what action is being authorized. These are the integer action codes that |
| @@ -1980,19 +1992,16 @@ | ||
| 1980 | 1992 | ** the authorizer callback may be passed. |
| 1981 | 1993 | ** |
| 1982 | 1994 | ** These action code values signify what kind of operation is to be |
| 1983 | 1995 | ** authorized. The 3rd and 4th parameters to the authorization |
| 1984 | 1996 | ** 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 | |
| 1986 | 1998 | ** 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 | |
| 1988 | 2000 | ** is the name of the inner-most trigger or view that is responsible for |
| 1989 | 2001 | ** the access attempt or NULL if this access attempt is directly from |
| 1990 | 2002 | ** top-level SQL code. |
| 1991 | -** | |
| 1992 | -** Requirements: | |
| 1993 | -** [H12551] [H12552] [H12553] [H12554] | |
| 1994 | 2003 | */ |
| 1995 | 2004 | /******************************************* 3rd ************ 4th ***********/ |
| 1996 | 2005 | #define SQLITE_CREATE_INDEX 1 /* Index Name Table Name */ |
| 1997 | 2006 | #define SQLITE_CREATE_TABLE 2 /* Table Name NULL */ |
| 1998 | 2007 | #define SQLITE_CREATE_TEMP_INDEX 3 /* Index Name Table Name */ |
| @@ -2026,150 +2035,142 @@ | ||
| 2026 | 2035 | #define SQLITE_FUNCTION 31 /* NULL Function Name */ |
| 2027 | 2036 | #define SQLITE_SAVEPOINT 32 /* Operation Savepoint Name */ |
| 2028 | 2037 | #define SQLITE_COPY 0 /* No longer used */ |
| 2029 | 2038 | |
| 2030 | 2039 | /* |
| 2031 | -** CAPI3REF: Tracing And Profiling Functions {H12280} <S60400> | |
| 2040 | +** CAPI3REF: Tracing And Profiling Functions | |
| 2032 | 2041 | ** EXPERIMENTAL |
| 2033 | 2042 | ** |
| 2034 | 2043 | ** These routines register callback functions that can be used for |
| 2035 | 2044 | ** tracing and profiling the execution of SQL statements. |
| 2036 | 2045 | ** |
| 2037 | -** The callback function registered by sqlite3_trace() is invoked at | |
| 2046 | +** ^The callback function registered by sqlite3_trace() is invoked at | |
| 2038 | 2047 | ** 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 | |
| 2041 | 2051 | ** 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.)^ | |
| 2043 | 2053 | ** |
| 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 | |
| 2046 | 2056 | ** the original statement text and an estimate of wall-clock time |
| 2047 | 2057 | ** of how long that statement took to run. |
| 2048 | -** | |
| 2049 | -** Requirements: | |
| 2050 | -** [H12281] [H12282] [H12283] [H12284] [H12285] [H12287] [H12288] [H12289] | |
| 2051 | -** [H12290] | |
| 2052 | 2058 | */ |
| 2053 | 2059 | SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*); |
| 2054 | 2060 | SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*, |
| 2055 | 2061 | void(*xProfile)(void*,const char*,sqlite3_uint64), void*); |
| 2056 | 2062 | |
| 2057 | 2063 | /* |
| 2058 | -** CAPI3REF: Query Progress Callbacks {H12910} <S60400> | |
| 2064 | +** CAPI3REF: Query Progress Callbacks | |
| 2059 | 2065 | ** |
| 2060 | -** This routine configures a callback function - the | |
| 2066 | +** ^This routine configures a callback function - the | |
| 2061 | 2067 | ** progress callback - that is invoked periodically during long |
| 2062 | 2068 | ** running calls to [sqlite3_exec()], [sqlite3_step()] and |
| 2063 | 2069 | ** [sqlite3_get_table()]. An example use for this |
| 2064 | 2070 | ** interface is to keep a GUI updated during a large query. |
| 2065 | 2071 | ** |
| 2066 | -** If the progress callback returns non-zero, the operation is | |
| 2072 | +** ^If the progress callback returns non-zero, the operation is | |
| 2067 | 2073 | ** interrupted. This feature can be used to implement a |
| 2068 | 2074 | ** "Cancel" button on a GUI progress dialog box. |
| 2069 | 2075 | ** |
| 2070 | 2076 | ** The progress handler must not do anything that will modify |
| 2071 | 2077 | ** the database connection that invoked the progress handler. |
| 2072 | 2078 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 2073 | 2079 | ** database connections for the meaning of "modify" in this paragraph. |
| 2074 | 2080 | ** |
| 2075 | -** Requirements: | |
| 2076 | -** [H12911] [H12912] [H12913] [H12914] [H12915] [H12916] [H12917] [H12918] | |
| 2077 | -** | |
| 2078 | 2081 | */ |
| 2079 | 2082 | SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*); |
| 2080 | 2083 | |
| 2081 | 2084 | /* |
| 2082 | -** CAPI3REF: Opening A New Database Connection {H12700} <S40200> | |
| 2085 | +** CAPI3REF: Opening A New Database Connection | |
| 2083 | 2086 | ** |
| 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 | |
| 2086 | 2089 | ** 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 | |
| 2088 | 2091 | ** returned in *ppDb, even if an error occurs. The only exception is that |
| 2089 | 2092 | ** if SQLite is unable to allocate memory to hold the [sqlite3] object, |
| 2090 | 2093 | ** 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 | |
| 2093 | 2096 | ** [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. | |
| 2095 | 2099 | ** |
| 2096 | -** The default encoding for the database will be UTF-8 if | |
| 2100 | +** ^The default encoding for the database will be UTF-8 if | |
| 2097 | 2101 | ** sqlite3_open() or sqlite3_open_v2() is called and |
| 2098 | 2102 | ** UTF-16 in the native byte order if sqlite3_open16() is used. |
| 2099 | 2103 | ** |
| 2100 | 2104 | ** Whether or not an error occurs when it is opened, resources |
| 2101 | 2105 | ** associated with the [database connection] handle should be released by |
| 2102 | 2106 | ** passing it to [sqlite3_close()] when it is no longer required. |
| 2103 | 2107 | ** |
| 2104 | 2108 | ** The sqlite3_open_v2() interface works like sqlite3_open() |
| 2105 | 2109 | ** 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 | |
| 2107 | 2112 | ** the following three values, optionally combined with the |
| 2108 | 2113 | ** [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], [SQLITE_OPEN_SHAREDCACHE], |
| 2109 | -** and/or [SQLITE_OPEN_PRIVATECACHE] flags: | |
| 2114 | +** and/or [SQLITE_OPEN_PRIVATECACHE] flags:)^ | |
| 2110 | 2115 | ** |
| 2111 | 2116 | ** <dl> |
| 2112 | -** <dt>[SQLITE_OPEN_READONLY]</dt> | |
| 2117 | +** ^(<dt>[SQLITE_OPEN_READONLY]</dt> | |
| 2113 | 2118 | ** <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>)^ | |
| 2115 | 2120 | ** |
| 2116 | -** <dt>[SQLITE_OPEN_READWRITE]</dt> | |
| 2121 | +** ^(<dt>[SQLITE_OPEN_READWRITE]</dt> | |
| 2117 | 2122 | ** <dd>The database is opened for reading and writing if possible, or reading |
| 2118 | 2123 | ** 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>)^ | |
| 2120 | 2125 | ** |
| 2121 | -** <dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> | |
| 2126 | +** ^(<dt>[SQLITE_OPEN_READWRITE] | [SQLITE_OPEN_CREATE]</dt> | |
| 2122 | 2127 | ** <dd>The database is opened for reading and writing, and is creates it if |
| 2123 | 2128 | ** 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>)^ | |
| 2125 | 2130 | ** </dl> |
| 2126 | 2131 | ** |
| 2127 | 2132 | ** If the 3rd parameter to sqlite3_open_v2() is not one of the |
| 2128 | 2133 | ** combinations shown above or one of the combinations shown above combined |
| 2129 | 2134 | ** with the [SQLITE_OPEN_NOMUTEX], [SQLITE_OPEN_FULLMUTEX], |
| 2130 | 2135 | ** [SQLITE_OPEN_SHAREDCACHE] and/or [SQLITE_OPEN_SHAREDCACHE] flags, |
| 2131 | 2136 | ** then the behavior is undefined. |
| 2132 | 2137 | ** |
| 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 | |
| 2134 | 2139 | ** 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 | |
| 2136 | 2141 | ** [SQLITE_OPEN_FULLMUTEX] flag is set then the database connection opens |
| 2137 | 2142 | ** in the serialized [threading mode] unless single-thread was |
| 2138 | 2143 | ** 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 | |
| 2140 | 2145 | ** 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 | |
| 2142 | 2147 | ** [SQLITE_OPEN_PRIVATECACHE] flag causes the database connection to not |
| 2143 | 2148 | ** participate in [shared cache mode] even if it is enabled. |
| 2144 | 2149 | ** |
| 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 | |
| 2147 | 2152 | ** the database connection is closed. Future versions of SQLite might |
| 2148 | 2153 | ** make use of additional special filenames that begin with the ":" character. |
| 2149 | 2154 | ** It is recommended that when a database filename actually does begin with |
| 2150 | 2155 | ** a ":" character you should prefix the filename with a pathname such as |
| 2151 | 2156 | ** "./" to avoid ambiguity. |
| 2152 | 2157 | ** |
| 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 | |
| 2155 | 2160 | ** automatically deleted as soon as the database connection is closed. |
| 2156 | 2161 | ** |
| 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 | |
| 2158 | 2163 | ** [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 | |
| 2160 | 2165 | ** a NULL pointer then the default [sqlite3_vfs] object is used. |
| 2161 | 2166 | ** |
| 2162 | 2167 | ** <b>Note to Windows users:</b> The encoding used for the filename argument |
| 2163 | 2168 | ** of sqlite3_open() and sqlite3_open_v2() must be UTF-8, not whatever |
| 2164 | 2169 | ** codepage is currently defined. Filenames containing international |
| 2165 | 2170 | ** characters must be converted to UTF-8 prior to passing them into |
| 2166 | 2171 | ** 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 | */ |
| 2172 | 2173 | SQLITE_API int sqlite3_open( |
| 2173 | 2174 | const char *filename, /* Database filename (UTF-8) */ |
| 2174 | 2175 | sqlite3 **ppDb /* OUT: SQLite db handle */ |
| 2175 | 2176 | ); |
| @@ -2183,27 +2184,27 @@ | ||
| 2183 | 2184 | int flags, /* Flags */ |
| 2184 | 2185 | const char *zVfs /* Name of VFS module to use */ |
| 2185 | 2186 | ); |
| 2186 | 2187 | |
| 2187 | 2188 | /* |
| 2188 | -** CAPI3REF: Error Codes And Messages {H12800} <S60200> | |
| 2189 | +** CAPI3REF: Error Codes And Messages | |
| 2189 | 2190 | ** |
| 2190 | -** The sqlite3_errcode() interface returns the numeric [result code] or | |
| 2191 | +** ^The sqlite3_errcode() interface returns the numeric [result code] or | |
| 2191 | 2192 | ** [extended result code] for the most recent failed sqlite3_* API call |
| 2192 | 2193 | ** associated with a [database connection]. If a prior API call failed |
| 2193 | 2194 | ** 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() | |
| 2195 | 2196 | ** interface is the same except that it always returns the |
| 2196 | 2197 | ** [extended result code] even when extended result codes are |
| 2197 | 2198 | ** disabled. |
| 2198 | 2199 | ** |
| 2199 | -** The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | |
| 2200 | +** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language | |
| 2200 | 2201 | ** 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. | |
| 2202 | 2203 | ** The application does not need to worry about freeing the result. |
| 2203 | 2204 | ** 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.)^ | |
| 2205 | 2206 | ** |
| 2206 | 2207 | ** When the serialized [threading mode] is in use, it might be the |
| 2207 | 2208 | ** case that a second error occurs on a separate thread in between |
| 2208 | 2209 | ** the time of the first error and the call to these interfaces. |
| 2209 | 2210 | ** When that happens, the second error will be reported since these |
| @@ -2214,21 +2215,18 @@ | ||
| 2214 | 2215 | ** all calls to the interfaces listed here are completed. |
| 2215 | 2216 | ** |
| 2216 | 2217 | ** If an interface fails with SQLITE_MISUSE, that means the interface |
| 2217 | 2218 | ** was invoked incorrectly by the application. In that case, the |
| 2218 | 2219 | ** error code and message may or may not be set. |
| 2219 | -** | |
| 2220 | -** Requirements: | |
| 2221 | -** [H12801] [H12802] [H12803] [H12807] [H12808] [H12809] | |
| 2222 | 2220 | */ |
| 2223 | 2221 | SQLITE_API int sqlite3_errcode(sqlite3 *db); |
| 2224 | 2222 | SQLITE_API int sqlite3_extended_errcode(sqlite3 *db); |
| 2225 | 2223 | SQLITE_API const char *sqlite3_errmsg(sqlite3*); |
| 2226 | 2224 | SQLITE_API const void *sqlite3_errmsg16(sqlite3*); |
| 2227 | 2225 | |
| 2228 | 2226 | /* |
| 2229 | -** CAPI3REF: SQL Statement Object {H13000} <H13010> | |
| 2227 | +** CAPI3REF: SQL Statement Object | |
| 2230 | 2228 | ** KEYWORDS: {prepared statement} {prepared statements} |
| 2231 | 2229 | ** |
| 2232 | 2230 | ** An instance of this object represents a single SQL statement. |
| 2233 | 2231 | ** This object is variously known as a "prepared statement" or a |
| 2234 | 2232 | ** "compiled SQL statement" or simply as a "statement". |
| @@ -2250,29 +2248,29 @@ | ||
| 2250 | 2248 | ** information. |
| 2251 | 2249 | */ |
| 2252 | 2250 | typedef struct sqlite3_stmt sqlite3_stmt; |
| 2253 | 2251 | |
| 2254 | 2252 | /* |
| 2255 | -** CAPI3REF: Run-time Limits {H12760} <S20600> | |
| 2253 | +** CAPI3REF: Run-time Limits | |
| 2256 | 2254 | ** |
| 2257 | -** This interface allows the size of various constructs to be limited | |
| 2255 | +** ^(This interface allows the size of various constructs to be limited | |
| 2258 | 2256 | ** on a connection by connection basis. The first parameter is the |
| 2259 | 2257 | ** [database connection] whose limit is to be set or queried. The |
| 2260 | 2258 | ** second parameter is one of the [limit categories] that define a |
| 2261 | 2259 | ** 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.)^ | |
| 2263 | 2261 | ** |
| 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 | |
| 2266 | 2264 | ** [limits | hard upper bound] |
| 2267 | 2265 | ** set by a compile-time C preprocessor macro named |
| 2268 | 2266 | ** [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. | |
| 2272 | 2270 | ** |
| 2273 | -** Run time limits are intended for use in applications that manage | |
| 2271 | +** Run-time limits are intended for use in applications that manage | |
| 2274 | 2272 | ** both their own internal database and also databases that are controlled |
| 2275 | 2273 | ** by untrusted external sources. An example application might be a |
| 2276 | 2274 | ** web browser that has its own databases for storing history and |
| 2277 | 2275 | ** separate databases controlled by JavaScript applications downloaded |
| 2278 | 2276 | ** off the Internet. The internal databases can be given the |
| @@ -2282,63 +2280,60 @@ | ||
| 2282 | 2280 | ** interface to further control untrusted SQL. The size of the database |
| 2283 | 2281 | ** created by an untrusted script can be contained using the |
| 2284 | 2282 | ** [max_page_count] [PRAGMA]. |
| 2285 | 2283 | ** |
| 2286 | 2284 | ** New run-time limit categories may be added in future releases. |
| 2287 | -** | |
| 2288 | -** Requirements: | |
| 2289 | -** [H12762] [H12766] [H12769] | |
| 2290 | 2285 | */ |
| 2291 | 2286 | SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal); |
| 2292 | 2287 | |
| 2293 | 2288 | /* |
| 2294 | -** CAPI3REF: Run-Time Limit Categories {H12790} <H12760> | |
| 2289 | +** CAPI3REF: Run-Time Limit Categories | |
| 2295 | 2290 | ** KEYWORDS: {limit category} {*limit categories} |
| 2296 | 2291 | ** |
| 2297 | 2292 | ** These constants define various performance limits |
| 2298 | 2293 | ** that can be lowered at run-time using [sqlite3_limit()]. |
| 2299 | 2294 | ** The synopsis of the meanings of the various limits is shown below. |
| 2300 | 2295 | ** Additional information is available at [limits | Limits in SQLite]. |
| 2301 | 2296 | ** |
| 2302 | 2297 | ** <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>)^ | |
| 2305 | 2300 | ** |
| 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>)^ | |
| 2308 | 2303 | ** |
| 2309 | -** <dt>SQLITE_LIMIT_COLUMN</dt> | |
| 2304 | +** ^(<dt>SQLITE_LIMIT_COLUMN</dt> | |
| 2310 | 2305 | ** <dd>The maximum number of columns in a table definition or in the |
| 2311 | 2306 | ** 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> | |
| 2321 | 2316 | ** <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> | |
| 2331 | 2326 | ** <dd>The maximum length of the pattern argument to the [LIKE] or |
| 2332 | -** [GLOB] operators.</dd> | |
| 2327 | +** [GLOB] operators.</dd>)^ | |
| 2333 | 2328 | ** |
| 2334 | -** <dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> | |
| 2329 | +** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt> | |
| 2335 | 2330 | ** <dd>The maximum number of variables in an SQL statement that can |
| 2336 | -** be bound.</dd> | |
| 2331 | +** be bound.</dd>)^ | |
| 2337 | 2332 | ** |
| 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>)^ | |
| 2340 | 2335 | ** </dl> |
| 2341 | 2336 | */ |
| 2342 | 2337 | #define SQLITE_LIMIT_LENGTH 0 |
| 2343 | 2338 | #define SQLITE_LIMIT_SQL_LENGTH 1 |
| 2344 | 2339 | #define SQLITE_LIMIT_COLUMN 2 |
| @@ -2350,11 +2345,11 @@ | ||
| 2350 | 2345 | #define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8 |
| 2351 | 2346 | #define SQLITE_LIMIT_VARIABLE_NUMBER 9 |
| 2352 | 2347 | #define SQLITE_LIMIT_TRIGGER_DEPTH 10 |
| 2353 | 2348 | |
| 2354 | 2349 | /* |
| 2355 | -** CAPI3REF: Compiling An SQL Statement {H13010} <S10000> | |
| 2350 | +** CAPI3REF: Compiling An SQL Statement | |
| 2356 | 2351 | ** KEYWORDS: {SQL statement compiler} |
| 2357 | 2352 | ** |
| 2358 | 2353 | ** To execute an SQL query, it must first be compiled into a byte-code |
| 2359 | 2354 | ** program using one of these routines. |
| 2360 | 2355 | ** |
| @@ -2365,61 +2360,62 @@ | ||
| 2365 | 2360 | ** The second argument, "zSql", is the statement to be compiled, encoded |
| 2366 | 2361 | ** as either UTF-8 or UTF-16. The sqlite3_prepare() and sqlite3_prepare_v2() |
| 2367 | 2362 | ** interfaces use UTF-8, and sqlite3_prepare16() and sqlite3_prepare16_v2() |
| 2368 | 2363 | ** use UTF-16. |
| 2369 | 2364 | ** |
| 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 | |
| 2373 | 2368 | ** zSql string ends at either the first '\000' or '\u0000' character or |
| 2374 | 2369 | ** the nByte-th byte, whichever comes first. If the caller knows |
| 2375 | 2370 | ** that the supplied string is nul-terminated, then there is a small |
| 2376 | 2371 | ** performance advantage to be gained by passing an nByte parameter that |
| 2377 | 2372 | ** is equal to the number of bytes in the input string <i>including</i> |
| 2378 | 2373 | ** the nul-terminator bytes. |
| 2379 | 2374 | ** |
| 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 | |
| 2381 | 2376 | ** past the end of the first SQL statement in zSql. These routines only |
| 2382 | 2377 | ** compile the first statement in zSql, so *pzTail is left pointing to |
| 2383 | 2378 | ** what remains uncompiled. |
| 2384 | 2379 | ** |
| 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 | |
| 2388 | 2383 | ** string or a comment) then *ppStmt is set to NULL. |
| 2389 | 2384 | ** The calling procedure is responsible for deleting the compiled |
| 2390 | 2385 | ** SQL statement using [sqlite3_finalize()] after it has finished with it. |
| 2391 | 2386 | ** ppStmt may not be NULL. |
| 2392 | 2387 | ** |
| 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. | |
| 2394 | 2390 | ** |
| 2395 | 2391 | ** The sqlite3_prepare_v2() and sqlite3_prepare16_v2() interfaces are |
| 2396 | 2392 | ** recommended for all new programs. The two older interfaces are retained |
| 2397 | 2393 | ** for backwards compatibility, but their use is discouraged. |
| 2398 | -** In the "v2" interfaces, the prepared statement | |
| 2394 | +** ^In the "v2" interfaces, the prepared statement | |
| 2399 | 2395 | ** that is returned (the [sqlite3_stmt] object) contains a copy of the |
| 2400 | 2396 | ** original SQL text. This causes the [sqlite3_step()] interface to |
| 2401 | 2397 | ** behave differently in three ways: |
| 2402 | 2398 | ** |
| 2403 | 2399 | ** <ol> |
| 2404 | 2400 | ** <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 | |
| 2406 | 2402 | ** 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 | |
| 2408 | 2404 | ** a way that makes the statement no longer valid, [sqlite3_step()] will still |
| 2409 | 2405 | ** return [SQLITE_SCHEMA]. But unlike the legacy behavior, [SQLITE_SCHEMA] is |
| 2410 | 2406 | ** now a fatal error. Calling [sqlite3_prepare_v2()] again will not make the |
| 2411 | 2407 | ** error go away. Note: use [sqlite3_errmsg()] to find the text |
| 2412 | 2408 | ** of the parsing error that results in an [SQLITE_SCHEMA] return. |
| 2413 | 2409 | ** </li> |
| 2414 | 2410 | ** |
| 2415 | 2411 | ** <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 | |
| 2418 | 2414 | ** [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 | |
| 2421 | 2417 | ** interfaces, the underlying reason for the error is returned immediately. |
| 2422 | 2418 | ** </li> |
| 2423 | 2419 | ** |
| 2424 | 2420 | ** <li> |
| 2425 | 2421 | ** ^If the value of a [parameter | host parameter] in the WHERE clause might |
| @@ -2427,14 +2423,10 @@ | ||
| 2427 | 2423 | ** automatically recompiled (as if there had been a schema change) on the first |
| 2428 | 2424 | ** [sqlite3_step()] call following any change to the |
| 2429 | 2425 | ** [sqlite3_bind_text | bindings] of the [parameter]. |
| 2430 | 2426 | ** </li> |
| 2431 | 2427 | ** </ol> |
| 2432 | -** | |
| 2433 | -** Requirements: | |
| 2434 | -** [H13011] [H13012] [H13013] [H13014] [H13015] [H13016] [H13019] [H13021] | |
| 2435 | -** | |
| 2436 | 2428 | */ |
| 2437 | 2429 | SQLITE_API int sqlite3_prepare( |
| 2438 | 2430 | sqlite3 *db, /* Database handle */ |
| 2439 | 2431 | const char *zSql, /* SQL statement, UTF-8 encoded */ |
| 2440 | 2432 | int nByte, /* Maximum length of zSql in bytes. */ |
| @@ -2462,28 +2454,25 @@ | ||
| 2462 | 2454 | sqlite3_stmt **ppStmt, /* OUT: Statement handle */ |
| 2463 | 2455 | const void **pzTail /* OUT: Pointer to unused portion of zSql */ |
| 2464 | 2456 | ); |
| 2465 | 2457 | |
| 2466 | 2458 | /* |
| 2467 | -** CAPI3REF: Retrieving Statement SQL {H13100} <H13000> | |
| 2459 | +** CAPI3REF: Retrieving Statement SQL | |
| 2468 | 2460 | ** |
| 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 | |
| 2470 | 2462 | ** SQL text used to create a [prepared statement] if that statement was |
| 2471 | 2463 | ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()]. |
| 2472 | -** | |
| 2473 | -** Requirements: | |
| 2474 | -** [H13101] [H13102] [H13103] | |
| 2475 | 2464 | */ |
| 2476 | 2465 | SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt); |
| 2477 | 2466 | |
| 2478 | 2467 | /* |
| 2479 | -** CAPI3REF: Dynamically Typed Value Object {H15000} <S20200> | |
| 2468 | +** CAPI3REF: Dynamically Typed Value Object | |
| 2480 | 2469 | ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value} |
| 2481 | 2470 | ** |
| 2482 | 2471 | ** SQLite uses the sqlite3_value object to represent all values |
| 2483 | 2472 | ** 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 | |
| 2485 | 2474 | ** can be integers, floating point values, strings, BLOBs, or NULL. |
| 2486 | 2475 | ** |
| 2487 | 2476 | ** An sqlite3_value object may be either "protected" or "unprotected". |
| 2488 | 2477 | ** Some interfaces require a protected sqlite3_value. Other interfaces |
| 2489 | 2478 | ** will accept either a protected or an unprotected sqlite3_value. |
| @@ -2501,26 +2490,26 @@ | ||
| 2501 | 2490 | ** sqlite3_value objects and they can be used interchangeably. However, |
| 2502 | 2491 | ** for maximum code portability it is recommended that applications |
| 2503 | 2492 | ** still make the distinction between between protected and unprotected |
| 2504 | 2493 | ** sqlite3_value objects even when not strictly required. |
| 2505 | 2494 | ** |
| 2506 | -** The sqlite3_value objects that are passed as parameters into the | |
| 2495 | +** ^The sqlite3_value objects that are passed as parameters into the | |
| 2507 | 2496 | ** implementation of [application-defined SQL functions] are protected. |
| 2508 | -** The sqlite3_value object returned by | |
| 2497 | +** ^The sqlite3_value object returned by | |
| 2509 | 2498 | ** [sqlite3_column_value()] is unprotected. |
| 2510 | 2499 | ** Unprotected sqlite3_value objects may only be used with |
| 2511 | 2500 | ** [sqlite3_result_value()] and [sqlite3_bind_value()]. |
| 2512 | 2501 | ** The [sqlite3_value_blob | sqlite3_value_type()] family of |
| 2513 | 2502 | ** interfaces require protected sqlite3_value objects. |
| 2514 | 2503 | */ |
| 2515 | 2504 | typedef struct Mem sqlite3_value; |
| 2516 | 2505 | |
| 2517 | 2506 | /* |
| 2518 | -** CAPI3REF: SQL Function Context Object {H16001} <S20200> | |
| 2507 | +** CAPI3REF: SQL Function Context Object | |
| 2519 | 2508 | ** |
| 2520 | 2509 | ** 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 | |
| 2522 | 2511 | ** is always first parameter to [application-defined SQL functions]. |
| 2523 | 2512 | ** The application-defined SQL function implementation will pass this |
| 2524 | 2513 | ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], |
| 2525 | 2514 | ** [sqlite3_aggregate_context()], [sqlite3_user_data()], |
| 2526 | 2515 | ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], |
| @@ -2527,15 +2516,15 @@ | ||
| 2527 | 2516 | ** and/or [sqlite3_set_auxdata()]. |
| 2528 | 2517 | */ |
| 2529 | 2518 | typedef struct sqlite3_context sqlite3_context; |
| 2530 | 2519 | |
| 2531 | 2520 | /* |
| 2532 | -** CAPI3REF: Binding Values To Prepared Statements {H13500} <S70300> | |
| 2521 | +** CAPI3REF: Binding Values To Prepared Statements | |
| 2533 | 2522 | ** KEYWORDS: {host parameter} {host parameters} {host parameter name} |
| 2534 | 2523 | ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} |
| 2535 | 2524 | ** |
| 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, | |
| 2537 | 2526 | ** literals may be replaced by a [parameter] that matches one of following |
| 2538 | 2527 | ** templates: |
| 2539 | 2528 | ** |
| 2540 | 2529 | ** <ul> |
| 2541 | 2530 | ** <li> ? |
| @@ -2544,76 +2533,70 @@ | ||
| 2544 | 2533 | ** <li> @VVV |
| 2545 | 2534 | ** <li> $VVV |
| 2546 | 2535 | ** </ul> |
| 2547 | 2536 | ** |
| 2548 | 2537 | ** 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 | |
| 2550 | 2539 | ** parameters (also called "host parameter names" or "SQL parameters") |
| 2551 | 2540 | ** can be set using the sqlite3_bind_*() routines defined here. |
| 2552 | 2541 | ** |
| 2553 | -** The first argument to the sqlite3_bind_*() routines is always | |
| 2542 | +** ^The first argument to the sqlite3_bind_*() routines is always | |
| 2554 | 2543 | ** a pointer to the [sqlite3_stmt] object returned from |
| 2555 | 2544 | ** [sqlite3_prepare_v2()] or its variants. |
| 2556 | 2545 | ** |
| 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 | |
| 2559 | 2548 | ** SQL parameter is used more than once, second and subsequent |
| 2560 | 2549 | ** 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 | |
| 2563 | 2552 | ** 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()] | |
| 2565 | 2554 | ** parameter [SQLITE_LIMIT_VARIABLE_NUMBER] (default value: 999). |
| 2566 | 2555 | ** |
| 2567 | -** The third argument is the value to bind to the parameter. | |
| 2556 | +** ^The third argument is the value to bind to the parameter. | |
| 2568 | 2557 | ** |
| 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 | |
| 2570 | 2559 | ** 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 | |
| 2573 | 2562 | ** the number of bytes up to the first zero terminator. |
| 2574 | 2563 | ** |
| 2575 | -** The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and | |
| 2564 | +** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and | |
| 2576 | 2565 | ** 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 | |
| 2578 | 2567 | ** the special value [SQLITE_STATIC], then SQLite assumes that the |
| 2579 | 2568 | ** 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 | |
| 2581 | 2570 | ** SQLite makes its own private copy of the data immediately, before |
| 2582 | 2571 | ** the sqlite3_bind_*() routine returns. |
| 2583 | 2572 | ** |
| 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 | |
| 2586 | 2575 | ** (just an integer to hold its size) while it is being processed. |
| 2587 | 2576 | ** Zeroblobs are intended to serve as placeholders for BLOBs whose |
| 2588 | 2577 | ** content is later written using |
| 2589 | 2578 | ** [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. | |
| 2607 | 2595 | ** |
| 2608 | 2596 | ** See also: [sqlite3_bind_parameter_count()], |
| 2609 | 2597 | ** [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 | 2598 | */ |
| 2616 | 2599 | SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); |
| 2617 | 2600 | SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); |
| 2618 | 2601 | SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); |
| 2619 | 2602 | SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); |
| @@ -2622,175 +2605,155 @@ | ||
| 2622 | 2605 | SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*)); |
| 2623 | 2606 | SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*); |
| 2624 | 2607 | SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n); |
| 2625 | 2608 | |
| 2626 | 2609 | /* |
| 2627 | -** CAPI3REF: Number Of SQL Parameters {H13600} <S70300> | |
| 2610 | +** CAPI3REF: Number Of SQL Parameters | |
| 2628 | 2611 | ** |
| 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] | |
| 2630 | 2613 | ** in a [prepared statement]. SQL parameters are tokens of the |
| 2631 | 2614 | ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as |
| 2632 | 2615 | ** placeholders for values that are [sqlite3_bind_blob | bound] |
| 2633 | 2616 | ** to the parameters at a later time. |
| 2634 | 2617 | ** |
| 2635 | -** This routine actually returns the index of the largest (rightmost) | |
| 2618 | +** ^(This routine actually returns the index of the largest (rightmost) | |
| 2636 | 2619 | ** 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.)^ | |
| 2639 | 2622 | ** |
| 2640 | 2623 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 2641 | 2624 | ** [sqlite3_bind_parameter_name()], and |
| 2642 | 2625 | ** [sqlite3_bind_parameter_index()]. |
| 2643 | -** | |
| 2644 | -** Requirements: | |
| 2645 | -** [H13601] | |
| 2646 | 2626 | */ |
| 2647 | 2627 | SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*); |
| 2648 | 2628 | |
| 2649 | 2629 | /* |
| 2650 | -** CAPI3REF: Name Of A Host Parameter {H13620} <S70300> | |
| 2630 | +** CAPI3REF: Name Of A Host Parameter | |
| 2651 | 2631 | ** |
| 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" | |
| 2655 | 2635 | ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA" |
| 2656 | 2636 | ** respectively. |
| 2657 | 2637 | ** 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 | |
| 2666 | 2646 | ** always in UTF-8 encoding even if the named parameter was |
| 2667 | 2647 | ** originally specified as UTF-16 in [sqlite3_prepare16()] or |
| 2668 | 2648 | ** [sqlite3_prepare16_v2()]. |
| 2669 | 2649 | ** |
| 2670 | 2650 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 2671 | 2651 | ** [sqlite3_bind_parameter_count()], and |
| 2672 | 2652 | ** [sqlite3_bind_parameter_index()]. |
| 2673 | -** | |
| 2674 | -** Requirements: | |
| 2675 | -** [H13621] | |
| 2676 | 2653 | */ |
| 2677 | 2654 | SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int); |
| 2678 | 2655 | |
| 2679 | 2656 | /* |
| 2680 | -** CAPI3REF: Index Of A Parameter With A Given Name {H13640} <S70300> | |
| 2657 | +** CAPI3REF: Index Of A Parameter With A Given Name | |
| 2681 | 2658 | ** |
| 2682 | -** Return the index of an SQL parameter given its name. The | |
| 2659 | +** ^Return the index of an SQL parameter given its name. ^The | |
| 2683 | 2660 | ** 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 | |
| 2686 | 2663 | ** name must be given in UTF-8 even if the original statement |
| 2687 | 2664 | ** was prepared from UTF-16 text using [sqlite3_prepare16_v2()]. |
| 2688 | 2665 | ** |
| 2689 | 2666 | ** See also: [sqlite3_bind_blob|sqlite3_bind()], |
| 2690 | 2667 | ** [sqlite3_bind_parameter_count()], and |
| 2691 | 2668 | ** [sqlite3_bind_parameter_index()]. |
| 2692 | -** | |
| 2693 | -** Requirements: | |
| 2694 | -** [H13641] | |
| 2695 | 2669 | */ |
| 2696 | 2670 | SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName); |
| 2697 | 2671 | |
| 2698 | 2672 | /* |
| 2699 | -** CAPI3REF: Reset All Bindings On A Prepared Statement {H13660} <S70300> | |
| 2673 | +** CAPI3REF: Reset All Bindings On A Prepared Statement | |
| 2700 | 2674 | ** |
| 2701 | -** Contrary to the intuition of many, [sqlite3_reset()] does not reset | |
| 2675 | +** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset | |
| 2702 | 2676 | ** 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. | |
| 2707 | 2678 | */ |
| 2708 | 2679 | SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*); |
| 2709 | 2680 | |
| 2710 | 2681 | /* |
| 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]). | |
| 2719 | 2687 | */ |
| 2720 | 2688 | SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt); |
| 2721 | 2689 | |
| 2722 | 2690 | /* |
| 2723 | -** CAPI3REF: Column Names In A Result Set {H13720} <S10700> | |
| 2691 | +** CAPI3REF: Column Names In A Result Set | |
| 2724 | 2692 | ** |
| 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() | |
| 2727 | 2695 | ** interface returns a pointer to a zero-terminated UTF-8 string |
| 2728 | 2696 | ** 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. | |
| 2732 | 2700 | ** |
| 2733 | -** The returned string pointer is valid until either the [prepared statement] | |
| 2701 | +** ^The returned string pointer is valid until either the [prepared statement] | |
| 2734 | 2702 | ** is destroyed by [sqlite3_finalize()] or until the next call to |
| 2735 | 2703 | ** sqlite3_column_name() or sqlite3_column_name16() on the same column. |
| 2736 | 2704 | ** |
| 2737 | -** If sqlite3_malloc() fails during the processing of either routine | |
| 2705 | +** ^If sqlite3_malloc() fails during the processing of either routine | |
| 2738 | 2706 | ** (for example during a conversion from UTF-8 to UTF-16) then a |
| 2739 | 2707 | ** NULL pointer is returned. |
| 2740 | 2708 | ** |
| 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 | |
| 2742 | 2710 | ** that column, if there is an AS clause. If there is no AS clause |
| 2743 | 2711 | ** then the name of the column is unspecified and may change from |
| 2744 | 2712 | ** one release of SQLite to the next. |
| 2745 | -** | |
| 2746 | -** Requirements: | |
| 2747 | -** [H13721] [H13723] [H13724] [H13725] [H13726] [H13727] | |
| 2748 | 2713 | */ |
| 2749 | 2714 | SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N); |
| 2750 | 2715 | SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N); |
| 2751 | 2716 | |
| 2752 | 2717 | /* |
| 2753 | -** CAPI3REF: Source Of Data In A Query Result {H13740} <S10700> | |
| 2718 | +** CAPI3REF: Source Of Data In A Query Result | |
| 2754 | 2719 | ** |
| 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 | |
| 2759 | 2725 | ** the database name, the _table_ routines return the table name, and |
| 2760 | 2726 | ** 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 | |
| 2762 | 2728 | ** using [sqlite3_finalize()] or until the same information is requested |
| 2763 | 2729 | ** again in a different encoding. |
| 2764 | 2730 | ** |
| 2765 | -** The names returned are the original un-aliased names of the | |
| 2731 | +** ^The names returned are the original un-aliased names of the | |
| 2766 | 2732 | ** database, table, and column. |
| 2767 | 2733 | ** |
| 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 | |
| 2770 | 2736 | ** the statement, where N is the second function argument. |
| 2737 | +** ^The left-most column is column 0 for these routines. | |
| 2771 | 2738 | ** |
| 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 | |
| 2773 | 2740 | ** 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 | +** | |
| 2785 | 2751 | ** If two or more threads call one or more of these routines against the same |
| 2786 | 2752 | ** prepared statement and column at the same time then the results are |
| 2787 | 2753 | ** undefined. |
| 2788 | 2754 | ** |
| 2789 | -** Requirements: | |
| 2790 | -** [H13741] [H13742] [H13743] [H13744] [H13745] [H13746] [H13748] | |
| 2791 | -** | |
| 2792 | 2755 | ** If two or more threads call one or more |
| 2793 | 2756 | ** [sqlite3_column_database_name | column metadata interfaces] |
| 2794 | 2757 | ** for the same [prepared statement] and result column |
| 2795 | 2758 | ** at the same time then the results are undefined. |
| 2796 | 2759 | */ |
| @@ -2800,46 +2763,43 @@ | ||
| 2800 | 2763 | SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int); |
| 2801 | 2764 | SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int); |
| 2802 | 2765 | SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int); |
| 2803 | 2766 | |
| 2804 | 2767 | /* |
| 2805 | -** CAPI3REF: Declared Datatype Of A Query Result {H13760} <S10700> | |
| 2768 | +** CAPI3REF: Declared Datatype Of A Query Result | |
| 2806 | 2769 | ** |
| 2807 | -** The first parameter is a [prepared statement]. | |
| 2770 | +** ^(The first parameter is a [prepared statement]. | |
| 2808 | 2771 | ** If this statement is a [SELECT] statement and the Nth column of the |
| 2809 | 2772 | ** returned result set of that [SELECT] is a table column (not an |
| 2810 | 2773 | ** 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 | |
| 2812 | 2775 | ** 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. | |
| 2814 | 2777 | ** |
| 2815 | -** For example, given the database schema: | |
| 2778 | +** ^(For example, given the database schema: | |
| 2816 | 2779 | ** |
| 2817 | 2780 | ** CREATE TABLE t1(c1 VARIANT); |
| 2818 | 2781 | ** |
| 2819 | 2782 | ** and the following statement to be compiled: |
| 2820 | 2783 | ** |
| 2821 | 2784 | ** SELECT c1 + 1, c1 FROM t1; |
| 2822 | 2785 | ** |
| 2823 | 2786 | ** 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).)^ | |
| 2825 | 2788 | ** |
| 2826 | -** SQLite uses dynamic run-time typing. So just because a column | |
| 2789 | +** ^SQLite uses dynamic run-time typing. ^So just because a column | |
| 2827 | 2790 | ** is declared to contain a particular type does not mean that the |
| 2828 | 2791 | ** 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 | |
| 2830 | 2793 | ** is associated with individual values, not with the containers |
| 2831 | 2794 | ** used to hold those values. |
| 2832 | -** | |
| 2833 | -** Requirements: | |
| 2834 | -** [H13761] [H13762] [H13763] | |
| 2835 | 2795 | */ |
| 2836 | 2796 | SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int); |
| 2837 | 2797 | SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int); |
| 2838 | 2798 | |
| 2839 | 2799 | /* |
| 2840 | -** CAPI3REF: Evaluate An SQL Statement {H13200} <S10000> | |
| 2800 | +** CAPI3REF: Evaluate An SQL Statement | |
| 2841 | 2801 | ** |
| 2842 | 2802 | ** After a [prepared statement] has been prepared using either |
| 2843 | 2803 | ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy |
| 2844 | 2804 | ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function |
| 2845 | 2805 | ** must be called one or more times to evaluate the statement. |
| @@ -2849,39 +2809,39 @@ | ||
| 2849 | 2809 | ** [sqlite3_prepare_v2()] and [sqlite3_prepare16_v2()] or the older legacy |
| 2850 | 2810 | ** interface [sqlite3_prepare()] and [sqlite3_prepare16()]. The use of the |
| 2851 | 2811 | ** new "v2" interface is recommended for new applications but the legacy |
| 2852 | 2812 | ** interface will continue to be supported. |
| 2853 | 2813 | ** |
| 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], | |
| 2855 | 2815 | ** [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 | |
| 2857 | 2817 | ** [extended result codes] might be returned as well. |
| 2858 | 2818 | ** |
| 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] | |
| 2861 | 2821 | ** or occurs outside of an explicit transaction, then you can retry the |
| 2862 | 2822 | ** statement. If the statement is not a [COMMIT] and occurs within a |
| 2863 | 2823 | ** explicit transaction then you should rollback the transaction before |
| 2864 | 2824 | ** continuing. |
| 2865 | 2825 | ** |
| 2866 | -** [SQLITE_DONE] means that the statement has finished executing | |
| 2826 | +** ^[SQLITE_DONE] means that the statement has finished executing | |
| 2867 | 2827 | ** successfully. sqlite3_step() should not be called again on this virtual |
| 2868 | 2828 | ** machine without first calling [sqlite3_reset()] to reset the virtual |
| 2869 | 2829 | ** machine back to its initial state. |
| 2870 | 2830 | ** |
| 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] | |
| 2872 | 2832 | ** is returned each time a new row of data is ready for processing by the |
| 2873 | 2833 | ** caller. The values may be accessed using the [column access functions]. |
| 2874 | 2834 | ** sqlite3_step() is called again to retrieve the next row of data. |
| 2875 | 2835 | ** |
| 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 | |
| 2877 | 2837 | ** violation) has occurred. sqlite3_step() should not be called again on |
| 2878 | 2838 | ** 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, | |
| 2880 | 2840 | ** [SQLITE_INTERRUPT], [SQLITE_SCHEMA], [SQLITE_CORRUPT], and so forth) |
| 2881 | 2841 | ** can be obtained by calling [sqlite3_reset()] on the |
| 2882 | -** [prepared statement]. In the "v2" interface, | |
| 2842 | +** [prepared statement]. ^In the "v2" interface, | |
| 2883 | 2843 | ** the more specific error code is returned directly by sqlite3_step(). |
| 2884 | 2844 | ** |
| 2885 | 2845 | ** [SQLITE_MISUSE] means that the this routine was called inappropriately. |
| 2886 | 2846 | ** Perhaps it was called on a [prepared statement] that has |
| 2887 | 2847 | ** already been [sqlite3_finalize | finalized] or on one that had |
| @@ -2898,39 +2858,34 @@ | ||
| 2898 | 2858 | ** with the "v2" interface. If you prepare all of your SQL statements |
| 2899 | 2859 | ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead |
| 2900 | 2860 | ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces, |
| 2901 | 2861 | ** then the more specific [error codes] are returned directly |
| 2902 | 2862 | ** by sqlite3_step(). The use of the "v2" interface is recommended. |
| 2903 | -** | |
| 2904 | -** Requirements: | |
| 2905 | -** [H13202] [H15304] [H15306] [H15308] [H15310] | |
| 2906 | 2863 | */ |
| 2907 | 2864 | SQLITE_API int sqlite3_step(sqlite3_stmt*); |
| 2908 | 2865 | |
| 2909 | 2866 | /* |
| 2910 | -** CAPI3REF: Number of columns in a result set {H13770} <S10700> | |
| 2867 | +** CAPI3REF: Number of columns in a result set | |
| 2911 | 2868 | ** |
| 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. | |
| 2916 | 2871 | */ |
| 2917 | 2872 | SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt); |
| 2918 | 2873 | |
| 2919 | 2874 | /* |
| 2920 | -** CAPI3REF: Fundamental Datatypes {H10265} <S10110><S10120> | |
| 2875 | +** CAPI3REF: Fundamental Datatypes | |
| 2921 | 2876 | ** KEYWORDS: SQLITE_TEXT |
| 2922 | 2877 | ** |
| 2923 | -** {H10266} Every value in SQLite has one of five fundamental datatypes: | |
| 2878 | +** ^(Every value in SQLite has one of five fundamental datatypes: | |
| 2924 | 2879 | ** |
| 2925 | 2880 | ** <ul> |
| 2926 | 2881 | ** <li> 64-bit signed integer |
| 2927 | 2882 | ** <li> 64-bit IEEE floating point number |
| 2928 | 2883 | ** <li> string |
| 2929 | 2884 | ** <li> BLOB |
| 2930 | 2885 | ** <li> NULL |
| 2931 | -** </ul> {END} | |
| 2886 | +** </ul>)^ | |
| 2932 | 2887 | ** |
| 2933 | 2888 | ** These constants are codes for each of those types. |
| 2934 | 2889 | ** |
| 2935 | 2890 | ** Note that the SQLITE_TEXT constant was also used in SQLite version 2 |
| 2936 | 2891 | ** for a completely different meaning. Software that links against both |
| @@ -2947,22 +2902,22 @@ | ||
| 2947 | 2902 | # define SQLITE_TEXT 3 |
| 2948 | 2903 | #endif |
| 2949 | 2904 | #define SQLITE3_TEXT 3 |
| 2950 | 2905 | |
| 2951 | 2906 | /* |
| 2952 | -** CAPI3REF: Result Values From A Query {H13800} <S10700> | |
| 2907 | +** CAPI3REF: Result Values From A Query | |
| 2953 | 2908 | ** KEYWORDS: {column access functions} |
| 2954 | 2909 | ** |
| 2955 | -** These routines form the "result set query" interface. | |
| 2910 | +** These routines form the "result set" interface. | |
| 2956 | 2911 | ** |
| 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 | |
| 2959 | 2914 | ** to the [prepared statement] that is being evaluated (the [sqlite3_stmt*] |
| 2960 | 2915 | ** that was returned from [sqlite3_prepare_v2()] or one of its variants) |
| 2961 | 2916 | ** 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 | |
| 2964 | 2919 | ** [sqlite3_column_count()]. |
| 2965 | 2920 | ** |
| 2966 | 2921 | ** If the SQL statement does not currently point to a valid row, or if the |
| 2967 | 2922 | ** column index is out of range, the result is undefined. |
| 2968 | 2923 | ** These routines may only be called when the most recent call to |
| @@ -2973,52 +2928,52 @@ | ||
| 2973 | 2928 | ** something other than [SQLITE_ROW], the results are undefined. |
| 2974 | 2929 | ** If [sqlite3_step()] or [sqlite3_reset()] or [sqlite3_finalize()] |
| 2975 | 2930 | ** are called from a different thread while any of these routines |
| 2976 | 2931 | ** are pending, then the results are undefined. |
| 2977 | 2932 | ** |
| 2978 | -** The sqlite3_column_type() routine returns the | |
| 2933 | +** ^The sqlite3_column_type() routine returns the | |
| 2979 | 2934 | ** [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], | |
| 2981 | 2936 | ** [SQLITE_FLOAT], [SQLITE_TEXT], [SQLITE_BLOB], or [SQLITE_NULL]. The value |
| 2982 | 2937 | ** returned by sqlite3_column_type() is only meaningful if no type |
| 2983 | 2938 | ** conversions have occurred as described below. After a type conversion, |
| 2984 | 2939 | ** the value returned by sqlite3_column_type() is undefined. Future |
| 2985 | 2940 | ** versions of SQLite may change the behavior of sqlite3_column_type() |
| 2986 | 2941 | ** following a type conversion. |
| 2987 | 2942 | ** |
| 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() | |
| 2989 | 2944 | ** 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 | |
| 2991 | 2946 | ** 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 | |
| 2993 | 2948 | ** [sqlite3_snprintf()] to convert that value to a UTF-8 string and returns |
| 2994 | 2949 | ** 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 | |
| 2997 | 2952 | ** bytes in the string, not the number of characters. |
| 2998 | 2953 | ** |
| 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 | |
| 3001 | 2956 | ** value from sqlite3_column_blob() for a zero-length BLOB is an arbitrary |
| 3002 | 2957 | ** pointer, possibly even a NULL pointer. |
| 3003 | 2958 | ** |
| 3004 | -** The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() | |
| 2959 | +** ^The sqlite3_column_bytes16() routine is similar to sqlite3_column_bytes() | |
| 3005 | 2960 | ** 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. | |
| 3007 | 2962 | ** |
| 3008 | -** The object returned by [sqlite3_column_value()] is an | |
| 2963 | +** ^The object returned by [sqlite3_column_value()] is an | |
| 3009 | 2964 | ** [unprotected sqlite3_value] object. An unprotected sqlite3_value object |
| 3010 | 2965 | ** may only be used with [sqlite3_bind_value()] and [sqlite3_result_value()]. |
| 3011 | 2966 | ** If the [unprotected sqlite3_value] object returned by |
| 3012 | 2967 | ** [sqlite3_column_value()] is used in any other way, including calls |
| 3013 | 2968 | ** to routines like [sqlite3_value_int()], [sqlite3_value_text()], |
| 3014 | 2969 | ** or [sqlite3_value_bytes()], then the behavior is undefined. |
| 3015 | 2970 | ** |
| 3016 | -** These routines attempt to convert the value where appropriate. For | |
| 2971 | +** These routines attempt to convert the value where appropriate. ^For | |
| 3017 | 2972 | ** example, if the internal representation is FLOAT and a text result |
| 3018 | 2973 | ** 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 | |
| 3020 | 2975 | ** that are applied: |
| 3021 | 2976 | ** |
| 3022 | 2977 | ** <blockquote> |
| 3023 | 2978 | ** <table border="1"> |
| 3024 | 2979 | ** <tr><th> Internal<br>Type <th> Requested<br>Type <th> Conversion |
| @@ -3038,22 +2993,22 @@ | ||
| 3038 | 2993 | ** <tr><td> TEXT <td> BLOB <td> No change |
| 3039 | 2994 | ** <tr><td> BLOB <td> INTEGER <td> Convert to TEXT then use atoi() |
| 3040 | 2995 | ** <tr><td> BLOB <td> FLOAT <td> Convert to TEXT then use atof() |
| 3041 | 2996 | ** <tr><td> BLOB <td> TEXT <td> Add a zero terminator if needed |
| 3042 | 2997 | ** </table> |
| 3043 | -** </blockquote> | |
| 2998 | +** </blockquote>)^ | |
| 3044 | 2999 | ** |
| 3045 | 3000 | ** The table above makes reference to standard C library functions atoi() |
| 3046 | 3001 | ** and atof(). SQLite does not really use these functions. It has its |
| 3047 | 3002 | ** own equivalent internal routines. The atoi() and atof() names are |
| 3048 | 3003 | ** used in the table for brevity and because they are familiar to most |
| 3049 | 3004 | ** C programmers. |
| 3050 | 3005 | ** |
| 3051 | -** Note that when type conversions occur, pointers returned by prior | |
| 3006 | +** ^Note that when type conversions occur, pointers returned by prior | |
| 3052 | 3007 | ** calls to sqlite3_column_blob(), sqlite3_column_text(), and/or |
| 3053 | 3008 | ** sqlite3_column_text16() may be invalidated. |
| 3054 | -** Type conversions and pointer invalidations might occur | |
| 3009 | +** ^(Type conversions and pointer invalidations might occur | |
| 3055 | 3010 | ** in the following cases: |
| 3056 | 3011 | ** |
| 3057 | 3012 | ** <ul> |
| 3058 | 3013 | ** <li> The initial content is a BLOB and sqlite3_column_text() or |
| 3059 | 3014 | ** sqlite3_column_text16() is called. A zero-terminator might |
| @@ -3062,51 +3017,47 @@ | ||
| 3062 | 3017 | ** sqlite3_column_text16() is called. The content must be converted |
| 3063 | 3018 | ** to UTF-16.</li> |
| 3064 | 3019 | ** <li> The initial content is UTF-16 text and sqlite3_column_bytes() or |
| 3065 | 3020 | ** sqlite3_column_text() is called. The content must be converted |
| 3066 | 3021 | ** to UTF-8.</li> |
| 3067 | -** </ul> | |
| 3022 | +** </ul>)^ | |
| 3068 | 3023 | ** |
| 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 | |
| 3070 | 3025 | ** not invalidate a prior pointer, though of course the content of the buffer |
| 3071 | 3026 | ** that the prior pointer points to will have been modified. Other kinds |
| 3072 | 3027 | ** of conversion are done in place when it is possible, but sometimes they |
| 3073 | 3028 | ** are not possible and in those cases prior pointers are invalidated. |
| 3074 | 3029 | ** |
| 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 | |
| 3076 | 3031 | ** in one of the following ways: |
| 3077 | 3032 | ** |
| 3078 | 3033 | ** <ul> |
| 3079 | 3034 | ** <li>sqlite3_column_text() followed by sqlite3_column_bytes()</li> |
| 3080 | 3035 | ** <li>sqlite3_column_blob() followed by sqlite3_column_bytes()</li> |
| 3081 | 3036 | ** <li>sqlite3_column_text16() followed by sqlite3_column_bytes16()</li> |
| 3082 | -** </ul> | |
| 3037 | +** </ul>)^ | |
| 3083 | 3038 | ** |
| 3084 | 3039 | ** In other words, you should call sqlite3_column_text(), |
| 3085 | 3040 | ** sqlite3_column_blob(), or sqlite3_column_text16() first to force the result |
| 3086 | 3041 | ** into the desired format, then invoke sqlite3_column_bytes() or |
| 3087 | 3042 | ** sqlite3_column_bytes16() to find the size of the result. Do not mix calls |
| 3088 | 3043 | ** to sqlite3_column_text() or sqlite3_column_blob() with calls to |
| 3089 | 3044 | ** sqlite3_column_bytes16(), and do not mix calls to sqlite3_column_text16() |
| 3090 | 3045 | ** with calls to sqlite3_column_bytes(). |
| 3091 | 3046 | ** |
| 3092 | -** The pointers returned are valid until a type conversion occurs as | |
| 3047 | +** ^The pointers returned are valid until a type conversion occurs as | |
| 3093 | 3048 | ** 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 | |
| 3095 | 3050 | ** and BLOBs is freed automatically. Do <b>not</b> pass the pointers returned |
| 3096 | 3051 | ** [sqlite3_column_blob()], [sqlite3_column_text()], etc. into |
| 3097 | 3052 | ** [sqlite3_free()]. |
| 3098 | 3053 | ** |
| 3099 | -** If a memory allocation error occurs during the evaluation of any | |
| 3054 | +** ^(If a memory allocation error occurs during the evaluation of any | |
| 3100 | 3055 | ** of these routines, a default value is returned. The default value |
| 3101 | 3056 | ** is either the integer 0, the floating point number 0.0, or a NULL |
| 3102 | 3057 | ** 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].)^ | |
| 3108 | 3059 | */ |
| 3109 | 3060 | SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol); |
| 3110 | 3061 | SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol); |
| 3111 | 3062 | SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol); |
| 3112 | 3063 | SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol); |
| @@ -3116,139 +3067,132 @@ | ||
| 3116 | 3067 | SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol); |
| 3117 | 3068 | SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol); |
| 3118 | 3069 | SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol); |
| 3119 | 3070 | |
| 3120 | 3071 | /* |
| 3121 | -** CAPI3REF: Destroy A Prepared Statement Object {H13300} <S70300><S30100> | |
| 3072 | +** CAPI3REF: Destroy A Prepared Statement Object | |
| 3122 | 3073 | ** |
| 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 | |
| 3126 | 3077 | ** [error code] or [extended error code] is returned. |
| 3127 | 3078 | ** |
| 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 | |
| 3130 | 3081 | ** completed execution when this routine is called, that is like |
| 3131 | 3082 | ** 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, | |
| 3133 | 3084 | ** depending on the circumstances, and the |
| 3134 | 3085 | ** [error code] returned will be [SQLITE_ABORT]. |
| 3135 | -** | |
| 3136 | -** Requirements: | |
| 3137 | -** [H11302] [H11304] | |
| 3138 | 3086 | */ |
| 3139 | 3087 | SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt); |
| 3140 | 3088 | |
| 3141 | 3089 | /* |
| 3142 | -** CAPI3REF: Reset A Prepared Statement Object {H13330} <S70300> | |
| 3090 | +** CAPI3REF: Reset A Prepared Statement Object | |
| 3143 | 3091 | ** |
| 3144 | 3092 | ** The sqlite3_reset() function is called to reset a [prepared statement] |
| 3145 | 3093 | ** 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 | |
| 3147 | 3095 | ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values. |
| 3148 | 3096 | ** Use [sqlite3_clear_bindings()] to reset the bindings. |
| 3149 | 3097 | ** |
| 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. | |
| 3164 | 3112 | */ |
| 3165 | 3113 | SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt); |
| 3166 | 3114 | |
| 3167 | 3115 | /* |
| 3168 | -** CAPI3REF: Create Or Redefine SQL Functions {H16100} <S20200> | |
| 3116 | +** CAPI3REF: Create Or Redefine SQL Functions | |
| 3169 | 3117 | ** KEYWORDS: {function creation routines} |
| 3170 | 3118 | ** KEYWORDS: {application-defined SQL function} |
| 3171 | 3119 | ** KEYWORDS: {application-defined SQL functions} |
| 3172 | 3120 | ** |
| 3173 | -** These two functions (collectively known as "function creation routines") | |
| 3121 | +** ^These two functions (collectively known as "function creation routines") | |
| 3174 | 3122 | ** are used to add SQL functions or aggregates or to redefine the behavior |
| 3175 | 3123 | ** of existing SQL functions or aggregates. The only difference between the |
| 3176 | 3124 | ** two is that the second parameter, the name of the (scalar) function or |
| 3177 | 3125 | ** aggregate, is encoded in UTF-8 for sqlite3_create_function() and UTF-16 |
| 3178 | 3126 | ** for sqlite3_create_function16(). |
| 3179 | 3127 | ** |
| 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. | |
| 3184 | 3132 | ** |
| 3185 | 3133 | ** 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 | |
| 3187 | 3135 | ** 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 | |
| 3189 | 3137 | ** will result in [SQLITE_ERROR] being returned. |
| 3190 | 3138 | ** |
| 3191 | -** The third parameter (nArg) | |
| 3139 | +** ^The third parameter (nArg) | |
| 3192 | 3140 | ** 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 | |
| 3194 | 3142 | ** aggregate may take any number of arguments between 0 and the limit |
| 3195 | 3143 | ** set by [sqlite3_limit]([SQLITE_LIMIT_FUNCTION_ARG]). If the third |
| 3196 | 3144 | ** parameter is less than -1 or greater than 127 then the behavior is |
| 3197 | 3145 | ** undefined. |
| 3198 | 3146 | ** |
| 3199 | 3147 | ** The fourth parameter, eTextRep, specifies what |
| 3200 | 3148 | ** [SQLITE_UTF8 | text encoding] this SQL function prefers for |
| 3201 | 3149 | ** its parameters. Any SQL function implementation should be able to work |
| 3202 | 3150 | ** 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 | |
| 3204 | 3152 | ** invoke sqlite3_create_function() or sqlite3_create_function16() multiple |
| 3205 | 3153 | ** 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 | |
| 3207 | 3155 | ** will pick the one that involves the least amount of data conversion. |
| 3208 | 3156 | ** If there is only a single implementation which does not care what text |
| 3209 | 3157 | ** encoding is used, then the fourth argument should be [SQLITE_ANY]. |
| 3210 | 3158 | ** |
| 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()].)^ | |
| 3213 | 3161 | ** |
| 3214 | 3162 | ** The seventh, eighth and ninth parameters, xFunc, xStep and xFinal, are |
| 3215 | 3163 | ** 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 | |
| 3220 | 3168 | ** SQL function or aggregate, pass NULL for all three function callbacks. |
| 3221 | 3169 | ** |
| 3222 | -** It is permitted to register multiple implementations of the same | |
| 3170 | +** ^It is permitted to register multiple implementations of the same | |
| 3223 | 3171 | ** 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 | |
| 3225 | 3173 | ** 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 | |
| 3227 | 3175 | ** 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 | |
| 3229 | 3177 | ** matches the database encoding is a better |
| 3230 | 3178 | ** 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 | |
| 3232 | 3180 | ** is a closer match than a function where the encoding difference is |
| 3233 | 3181 | ** between UTF8 and UTF16. |
| 3234 | 3182 | ** |
| 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 | |
| 3237 | 3185 | ** 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 | |
| 3239 | 3187 | ** prior application-defined functions that are an exact match for the |
| 3240 | 3188 | ** number of parameters and preferred encoding. |
| 3241 | 3189 | ** |
| 3242 | -** An application-defined function is permitted to call other | |
| 3190 | +** ^An application-defined function is permitted to call other | |
| 3243 | 3191 | ** SQLite interfaces. However, such calls must not |
| 3244 | 3192 | ** close the database connection nor finalize or reset the prepared |
| 3245 | 3193 | ** 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 | 3194 | */ |
| 3251 | 3195 | SQLITE_API int sqlite3_create_function( |
| 3252 | 3196 | sqlite3 *db, |
| 3253 | 3197 | const char *zFunctionName, |
| 3254 | 3198 | int nArg, |
| @@ -3268,11 +3212,11 @@ | ||
| 3268 | 3212 | void (*xStep)(sqlite3_context*,int,sqlite3_value**), |
| 3269 | 3213 | void (*xFinal)(sqlite3_context*) |
| 3270 | 3214 | ); |
| 3271 | 3215 | |
| 3272 | 3216 | /* |
| 3273 | -** CAPI3REF: Text Encodings {H10267} <S50200> <H16100> | |
| 3217 | +** CAPI3REF: Text Encodings | |
| 3274 | 3218 | ** |
| 3275 | 3219 | ** These constant define integer codes that represent the various |
| 3276 | 3220 | ** text encodings supported by SQLite. |
| 3277 | 3221 | */ |
| 3278 | 3222 | #define SQLITE_UTF8 1 |
| @@ -3300,11 +3244,11 @@ | ||
| 3300 | 3244 | SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void); |
| 3301 | 3245 | SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),void*,sqlite3_int64); |
| 3302 | 3246 | #endif |
| 3303 | 3247 | |
| 3304 | 3248 | /* |
| 3305 | -** CAPI3REF: Obtaining SQL Function Parameter Values {H15100} <S20200> | |
| 3249 | +** CAPI3REF: Obtaining SQL Function Parameter Values | |
| 3306 | 3250 | ** |
| 3307 | 3251 | ** The C-language implementation of SQL functions and aggregates uses |
| 3308 | 3252 | ** this set of interface routines to access the parameter values on |
| 3309 | 3253 | ** the function or aggregate. |
| 3310 | 3254 | ** |
| @@ -3318,39 +3262,35 @@ | ||
| 3318 | 3262 | ** |
| 3319 | 3263 | ** These routines work only with [protected sqlite3_value] objects. |
| 3320 | 3264 | ** Any attempt to use these routines on an [unprotected sqlite3_value] |
| 3321 | 3265 | ** object results in undefined behavior. |
| 3322 | 3266 | ** |
| 3323 | -** These routines work just like the corresponding [column access functions] | |
| 3267 | +** ^These routines work just like the corresponding [column access functions] | |
| 3324 | 3268 | ** except that these routines take a single [protected sqlite3_value] object |
| 3325 | 3269 | ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. |
| 3326 | 3270 | ** |
| 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 | |
| 3329 | 3273 | ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces |
| 3330 | 3274 | ** extract UTF-16 strings as big-endian and little-endian respectively. |
| 3331 | 3275 | ** |
| 3332 | -** The sqlite3_value_numeric_type() interface attempts to apply | |
| 3276 | +** ^(The sqlite3_value_numeric_type() interface attempts to apply | |
| 3333 | 3277 | ** numeric affinity to the value. This means that an attempt is |
| 3334 | 3278 | ** made to convert the value to an integer or floating point. If |
| 3335 | 3279 | ** such a conversion is possible without loss of information (in other |
| 3336 | 3280 | ** words, if the value is a string that looks like a number) |
| 3337 | 3281 | ** 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.)^ | |
| 3339 | 3283 | ** |
| 3340 | 3284 | ** Please pay particular attention to the fact that the pointer returned |
| 3341 | 3285 | ** from [sqlite3_value_blob()], [sqlite3_value_text()], or |
| 3342 | 3286 | ** [sqlite3_value_text16()] can be invalidated by a subsequent call to |
| 3343 | 3287 | ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()], |
| 3344 | 3288 | ** or [sqlite3_value_text16()]. |
| 3345 | 3289 | ** |
| 3346 | 3290 | ** These routines must be called from the same thread as |
| 3347 | 3291 | ** 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 | 3292 | */ |
| 3353 | 3293 | SQLITE_API const void *sqlite3_value_blob(sqlite3_value*); |
| 3354 | 3294 | SQLITE_API int sqlite3_value_bytes(sqlite3_value*); |
| 3355 | 3295 | SQLITE_API int sqlite3_value_bytes16(sqlite3_value*); |
| 3356 | 3296 | SQLITE_API double sqlite3_value_double(sqlite3_value*); |
| @@ -3362,70 +3302,77 @@ | ||
| 3362 | 3302 | SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*); |
| 3363 | 3303 | SQLITE_API int sqlite3_value_type(sqlite3_value*); |
| 3364 | 3304 | SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*); |
| 3365 | 3305 | |
| 3366 | 3306 | /* |
| 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 | |
| 3383 | 3338 | ** [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. | |
| 3385 | 3341 | ** |
| 3386 | 3342 | ** This routine must be called from the same thread in which |
| 3387 | 3343 | ** the aggregate SQL function is running. |
| 3388 | -** | |
| 3389 | -** Requirements: | |
| 3390 | -** [H16211] [H16213] [H16215] [H16217] | |
| 3391 | 3344 | */ |
| 3392 | 3345 | SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes); |
| 3393 | 3346 | |
| 3394 | 3347 | /* |
| 3395 | -** CAPI3REF: User Data For Functions {H16240} <S20200> | |
| 3348 | +** CAPI3REF: User Data For Functions | |
| 3396 | 3349 | ** |
| 3397 | -** The sqlite3_user_data() interface returns a copy of | |
| 3350 | +** ^The sqlite3_user_data() interface returns a copy of | |
| 3398 | 3351 | ** the pointer that was the pUserData parameter (the 5th parameter) |
| 3399 | 3352 | ** of the [sqlite3_create_function()] |
| 3400 | 3353 | ** and [sqlite3_create_function16()] routines that originally |
| 3401 | -** registered the application defined function. {END} | |
| 3354 | +** registered the application defined function. | |
| 3402 | 3355 | ** |
| 3403 | 3356 | ** This routine must be called from the same thread in which |
| 3404 | 3357 | ** the application-defined function is running. |
| 3405 | -** | |
| 3406 | -** Requirements: | |
| 3407 | -** [H16243] | |
| 3408 | 3358 | */ |
| 3409 | 3359 | SQLITE_API void *sqlite3_user_data(sqlite3_context*); |
| 3410 | 3360 | |
| 3411 | 3361 | /* |
| 3412 | -** CAPI3REF: Database Connection For Functions {H16250} <S60600><S20200> | |
| 3362 | +** CAPI3REF: Database Connection For Functions | |
| 3413 | 3363 | ** |
| 3414 | -** The sqlite3_context_db_handle() interface returns a copy of | |
| 3364 | +** ^The sqlite3_context_db_handle() interface returns a copy of | |
| 3415 | 3365 | ** the pointer to the [database connection] (the 1st parameter) |
| 3416 | 3366 | ** of the [sqlite3_create_function()] |
| 3417 | 3367 | ** and [sqlite3_create_function16()] routines that originally |
| 3418 | 3368 | ** registered the application defined function. |
| 3419 | -** | |
| 3420 | -** Requirements: | |
| 3421 | -** [H16253] | |
| 3422 | 3369 | */ |
| 3423 | 3370 | SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*); |
| 3424 | 3371 | |
| 3425 | 3372 | /* |
| 3426 | -** CAPI3REF: Function Auxiliary Data {H16270} <S20200> | |
| 3373 | +** CAPI3REF: Function Auxiliary Data | |
| 3427 | 3374 | ** |
| 3428 | 3375 | ** The following two functions may be used by scalar SQL functions to |
| 3429 | 3376 | ** associate metadata with argument values. If the same value is passed to |
| 3430 | 3377 | ** multiple invocations of the same SQL function during query execution, under |
| 3431 | 3378 | ** some circumstances the associated metadata may be preserved. This may |
| @@ -3434,52 +3381,49 @@ | ||
| 3434 | 3381 | ** metadata associated with the SQL value passed as the regular expression |
| 3435 | 3382 | ** pattern. The compiled regular expression can be reused on multiple |
| 3436 | 3383 | ** invocations of the same function so that the original pattern string |
| 3437 | 3384 | ** does not need to be recompiled on each invocation. |
| 3438 | 3385 | ** |
| 3439 | -** The sqlite3_get_auxdata() interface returns a pointer to the metadata | |
| 3386 | +** ^The sqlite3_get_auxdata() interface returns a pointer to the metadata | |
| 3440 | 3387 | ** 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 | |
| 3442 | 3389 | ** been set for the Nth argument of the function, or if the corresponding |
| 3443 | 3390 | ** function parameter has changed since the meta-data was set, |
| 3444 | 3391 | ** then sqlite3_get_auxdata() returns a NULL pointer. |
| 3445 | 3392 | ** |
| 3446 | -** The sqlite3_set_auxdata() interface saves the metadata | |
| 3393 | +** ^The sqlite3_set_auxdata() interface saves the metadata | |
| 3447 | 3394 | ** pointed to by its 3rd parameter as the metadata for the N-th |
| 3448 | 3395 | ** argument of the application-defined function. Subsequent |
| 3449 | 3396 | ** calls to sqlite3_get_auxdata() might return this data, if it has |
| 3450 | 3397 | ** 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 | |
| 3452 | 3399 | ** function given by the 4th parameter to sqlite3_set_auxdata() on |
| 3453 | 3400 | ** the metadata when the corresponding function parameter changes |
| 3454 | 3401 | ** or when the SQL statement completes, whichever comes first. |
| 3455 | 3402 | ** |
| 3456 | 3403 | ** 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 | |
| 3458 | 3405 | ** the destructor will be called before the metadata is dropped. |
| 3459 | 3406 | ** |
| 3460 | -** In practice, metadata is preserved between function calls for | |
| 3407 | +** ^(In practice, metadata is preserved between function calls for | |
| 3461 | 3408 | ** expressions that are constant at compile time. This includes literal |
| 3462 | -** values and SQL variables. | |
| 3409 | +** values and [parameters].)^ | |
| 3463 | 3410 | ** |
| 3464 | 3411 | ** These routines must be called from the same thread in which |
| 3465 | 3412 | ** the SQL function is running. |
| 3466 | -** | |
| 3467 | -** Requirements: | |
| 3468 | -** [H16272] [H16274] [H16276] [H16277] [H16278] [H16279] | |
| 3469 | 3413 | */ |
| 3470 | 3414 | SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N); |
| 3471 | 3415 | SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*)); |
| 3472 | 3416 | |
| 3473 | 3417 | |
| 3474 | 3418 | /* |
| 3475 | -** CAPI3REF: Constants Defining Special Destructor Behavior {H10280} <S30100> | |
| 3419 | +** CAPI3REF: Constants Defining Special Destructor Behavior | |
| 3476 | 3420 | ** |
| 3477 | 3421 | ** 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 | |
| 3479 | 3423 | ** 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 | |
| 3481 | 3425 | ** SQLITE_TRANSIENT value means that the content will likely change in |
| 3482 | 3426 | ** the near future and that SQLite should make its own private copy of |
| 3483 | 3427 | ** the content before returning. |
| 3484 | 3428 | ** |
| 3485 | 3429 | ** The typedef is necessary to work around problems in certain |
| @@ -3488,11 +3432,11 @@ | ||
| 3488 | 3432 | typedef void (*sqlite3_destructor_type)(void*); |
| 3489 | 3433 | #define SQLITE_STATIC ((sqlite3_destructor_type)0) |
| 3490 | 3434 | #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1) |
| 3491 | 3435 | |
| 3492 | 3436 | /* |
| 3493 | -** CAPI3REF: Setting The Result Of An SQL Function {H16400} <S20200> | |
| 3437 | +** CAPI3REF: Setting The Result Of An SQL Function | |
| 3494 | 3438 | ** |
| 3495 | 3439 | ** These routines are used by the xFunc or xFinal callbacks that |
| 3496 | 3440 | ** implement SQL functions and aggregates. See |
| 3497 | 3441 | ** [sqlite3_create_function()] and [sqlite3_create_function16()] |
| 3498 | 3442 | ** for additional information. |
| @@ -3499,107 +3443,102 @@ | ||
| 3499 | 3443 | ** |
| 3500 | 3444 | ** These functions work very much like the [parameter binding] family of |
| 3501 | 3445 | ** functions used to bind values to host parameters in prepared statements. |
| 3502 | 3446 | ** Refer to the [SQL parameter] documentation for additional information. |
| 3503 | 3447 | ** |
| 3504 | -** The sqlite3_result_blob() interface sets the result from | |
| 3448 | +** ^The sqlite3_result_blob() interface sets the result from | |
| 3505 | 3449 | ** an application-defined function to be the BLOB whose content is pointed |
| 3506 | 3450 | ** to by the second parameter and which is N bytes long where N is the |
| 3507 | 3451 | ** third parameter. |
| 3508 | 3452 | ** |
| 3509 | -** The sqlite3_result_zeroblob() interfaces set the result of | |
| 3453 | +** ^The sqlite3_result_zeroblob() interfaces set the result of | |
| 3510 | 3454 | ** the application-defined function to be a BLOB containing all zero |
| 3511 | 3455 | ** bytes and N bytes in size, where N is the value of the 2nd parameter. |
| 3512 | 3456 | ** |
| 3513 | -** The sqlite3_result_double() interface sets the result from | |
| 3457 | +** ^The sqlite3_result_double() interface sets the result from | |
| 3514 | 3458 | ** an application-defined function to be a floating point value specified |
| 3515 | 3459 | ** by its 2nd argument. |
| 3516 | 3460 | ** |
| 3517 | -** The sqlite3_result_error() and sqlite3_result_error16() functions | |
| 3461 | +** ^The sqlite3_result_error() and sqlite3_result_error16() functions | |
| 3518 | 3462 | ** 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 | |
| 3520 | 3464 | ** 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 | |
| 3523 | 3467 | ** 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() | |
| 3525 | 3469 | ** or sqlite3_result_error16() is negative then SQLite takes as the error |
| 3526 | 3470 | ** 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 | |
| 3528 | 3472 | ** sqlite3_result_error16() is non-negative then SQLite takes that many |
| 3529 | 3473 | ** 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() | |
| 3531 | 3475 | ** routines make a private copy of the error message text before |
| 3532 | 3476 | ** they return. Hence, the calling function can deallocate or |
| 3533 | 3477 | ** 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() | |
| 3537 | 3481 | ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. |
| 3538 | 3482 | ** |
| 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. | |
| 3541 | 3485 | ** |
| 3542 | -** The sqlite3_result_nomem() interface causes SQLite to throw an error | |
| 3486 | +** ^The sqlite3_result_nomem() interface causes SQLite to throw an error | |
| 3543 | 3487 | ** indicating that a memory allocation failed. |
| 3544 | 3488 | ** |
| 3545 | -** The sqlite3_result_int() interface sets the return value | |
| 3489 | +** ^The sqlite3_result_int() interface sets the return value | |
| 3546 | 3490 | ** of the application-defined function to be the 32-bit signed integer |
| 3547 | 3491 | ** 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 | |
| 3549 | 3493 | ** of the application-defined function to be the 64-bit signed integer |
| 3550 | 3494 | ** value given in the 2nd argument. |
| 3551 | 3495 | ** |
| 3552 | -** The sqlite3_result_null() interface sets the return value | |
| 3496 | +** ^The sqlite3_result_null() interface sets the return value | |
| 3553 | 3497 | ** of the application-defined function to be NULL. |
| 3554 | 3498 | ** |
| 3555 | -** The sqlite3_result_text(), sqlite3_result_text16(), | |
| 3499 | +** ^The sqlite3_result_text(), sqlite3_result_text16(), | |
| 3556 | 3500 | ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces |
| 3557 | 3501 | ** set the return value of the application-defined function to be |
| 3558 | 3502 | ** a text string which is represented as UTF-8, UTF-16 native byte order, |
| 3559 | 3503 | ** 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 | |
| 3561 | 3505 | ** 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 | |
| 3563 | 3507 | ** is negative, then SQLite takes result text from the 2nd parameter |
| 3564 | 3508 | ** 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 | |
| 3566 | 3510 | ** is non-negative, then as many bytes (not characters) of the text |
| 3567 | 3511 | ** pointed to by the 2nd parameter are taken as the application-defined |
| 3568 | 3512 | ** function result. |
| 3569 | -** If the 4th parameter to the sqlite3_result_text* interfaces | |
| 3513 | +** ^If the 4th parameter to the sqlite3_result_text* interfaces | |
| 3570 | 3514 | ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that |
| 3571 | 3515 | ** function as the destructor on the text or BLOB result when it has |
| 3572 | 3516 | ** 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 | |
| 3574 | 3518 | ** sqlite3_result_blob is the special constant SQLITE_STATIC, then SQLite |
| 3575 | 3519 | ** assumes that the text or BLOB result is in constant space and does not |
| 3576 | 3520 | ** copy the content of the parameter nor call a destructor on the content |
| 3577 | 3521 | ** 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 | |
| 3579 | 3523 | ** or sqlite3_result_blob is the special constant SQLITE_TRANSIENT |
| 3580 | 3524 | ** then SQLite makes a copy of the result into space obtained from |
| 3581 | 3525 | ** from [sqlite3_malloc()] before it returns. |
| 3582 | 3526 | ** |
| 3583 | -** The sqlite3_result_value() interface sets the result of | |
| 3527 | +** ^The sqlite3_result_value() interface sets the result of | |
| 3584 | 3528 | ** 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 | |
| 3586 | 3530 | ** sqlite3_result_value() interface makes a copy of the [sqlite3_value] |
| 3587 | 3531 | ** so that the [sqlite3_value] specified in the parameter may change or |
| 3588 | 3532 | ** 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 | |
| 3590 | 3534 | ** [unprotected sqlite3_value] object is required, so either |
| 3591 | 3535 | ** kind of [sqlite3_value] object can be used with this interface. |
| 3592 | 3536 | ** |
| 3593 | 3537 | ** If these routines are called from within the different thread |
| 3594 | 3538 | ** than the one containing the application-defined function that received |
| 3595 | 3539 | ** 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 | 3540 | */ |
| 3602 | 3541 | SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
| 3603 | 3542 | SQLITE_API void sqlite3_result_double(sqlite3_context*, double); |
| 3604 | 3543 | SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); |
| 3605 | 3544 | SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); |
| @@ -3615,58 +3554,54 @@ | ||
| 3615 | 3554 | SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); |
| 3616 | 3555 | SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); |
| 3617 | 3556 | SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); |
| 3618 | 3557 | |
| 3619 | 3558 | /* |
| 3620 | -** CAPI3REF: Define New Collating Sequences {H16600} <S20300> | |
| 3559 | +** CAPI3REF: Define New Collating Sequences | |
| 3621 | 3560 | ** |
| 3622 | 3561 | ** These functions are used to add new collation sequences to the |
| 3623 | 3562 | ** [database connection] specified as the first argument. |
| 3624 | 3563 | ** |
| 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 | |
| 3626 | 3565 | ** 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 | |
| 3628 | 3567 | ** the name is passed as the second function argument. |
| 3629 | 3568 | ** |
| 3630 | -** The third argument may be one of the constants [SQLITE_UTF8], | |
| 3569 | +** ^The third argument may be one of the constants [SQLITE_UTF8], | |
| 3631 | 3570 | ** [SQLITE_UTF16LE], or [SQLITE_UTF16BE], indicating that the user-supplied |
| 3632 | 3571 | ** 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 | |
| 3634 | 3573 | ** third argument might also be [SQLITE_UTF16] to indicate that the routine |
| 3635 | 3574 | ** expects pointers to be UTF-16 strings in the native byte order, or the |
| 3636 | 3575 | ** argument can be [SQLITE_UTF16_ALIGNED] if the |
| 3637 | 3576 | ** the routine expects pointers to 16-bit word aligned strings |
| 3638 | 3577 | ** of UTF-16 in the native byte order. |
| 3639 | 3578 | ** |
| 3640 | 3579 | ** 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 | |
| 3642 | 3581 | ** 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 | |
| 3644 | 3583 | ** as its first parameter a copy of the void* passed as the fourth argument |
| 3645 | 3584 | ** to sqlite3_create_collation() or sqlite3_create_collation16(). |
| 3646 | 3585 | ** |
| 3647 | -** The remaining arguments to the application-supplied routine are two strings, | |
| 3586 | +** ^The remaining arguments to the application-supplied routine are two strings, | |
| 3648 | 3587 | ** each represented by a (length, data) pair and encoded in the encoding |
| 3649 | 3588 | ** 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 | |
| 3651 | 3590 | ** return negative, zero or positive if the first string is less than, |
| 3652 | 3591 | ** equal to, or greater than the second string. i.e. (STRING1 - STRING2). |
| 3653 | 3592 | ** |
| 3654 | -** The sqlite3_create_collation_v2() works like sqlite3_create_collation() | |
| 3593 | +** ^The sqlite3_create_collation_v2() works like sqlite3_create_collation() | |
| 3655 | 3594 | ** 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 | |
| 3657 | 3596 | ** destroyed and is passed a copy of the fourth parameter void* pointer |
| 3658 | 3597 | ** 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 | |
| 3660 | 3599 | ** collation creation functions or when the [database connection] is closed |
| 3661 | 3600 | ** using [sqlite3_close()]. |
| 3662 | 3601 | ** |
| 3663 | 3602 | ** 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 | 3603 | */ |
| 3669 | 3604 | SQLITE_API int sqlite3_create_collation( |
| 3670 | 3605 | sqlite3*, |
| 3671 | 3606 | const char *zName, |
| 3672 | 3607 | int eTextRep, |
| @@ -3688,37 +3623,34 @@ | ||
| 3688 | 3623 | void*, |
| 3689 | 3624 | int(*xCompare)(void*,int,const void*,int,const void*) |
| 3690 | 3625 | ); |
| 3691 | 3626 | |
| 3692 | 3627 | /* |
| 3693 | -** CAPI3REF: Collation Needed Callbacks {H16700} <S20300> | |
| 3628 | +** CAPI3REF: Collation Needed Callbacks | |
| 3694 | 3629 | ** |
| 3695 | -** To avoid having to register all collation sequences before a database | |
| 3630 | +** ^To avoid having to register all collation sequences before a database | |
| 3696 | 3631 | ** 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 | |
| 3698 | 3633 | ** sequence is required. |
| 3699 | 3634 | ** |
| 3700 | -** If the function is registered using the sqlite3_collation_needed() API, | |
| 3635 | +** ^If the function is registered using the sqlite3_collation_needed() API, | |
| 3701 | 3636 | ** 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, | |
| 3703 | 3638 | ** 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. | |
| 3705 | 3640 | ** |
| 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 | |
| 3707 | 3642 | ** of the second argument to sqlite3_collation_needed() or |
| 3708 | 3643 | ** sqlite3_collation_needed16(). The second argument is the database |
| 3709 | 3644 | ** connection. The third argument is one of [SQLITE_UTF8], [SQLITE_UTF16BE], |
| 3710 | 3645 | ** or [SQLITE_UTF16LE], indicating the most desirable form of the collation |
| 3711 | 3646 | ** sequence function required. The fourth parameter is the name of the |
| 3712 | -** required collation sequence. | |
| 3647 | +** required collation sequence.)^ | |
| 3713 | 3648 | ** |
| 3714 | 3649 | ** The callback function should register the desired collation using |
| 3715 | 3650 | ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or |
| 3716 | 3651 | ** [sqlite3_create_collation_v2()]. |
| 3717 | -** | |
| 3718 | -** Requirements: | |
| 3719 | -** [H16702] [H16704] [H16706] | |
| 3720 | 3652 | */ |
| 3721 | 3653 | SQLITE_API int sqlite3_collation_needed( |
| 3722 | 3654 | sqlite3*, |
| 3723 | 3655 | void*, |
| 3724 | 3656 | void(*)(void*,sqlite3*,int eTextRep,const char*) |
| @@ -3753,33 +3685,32 @@ | ||
| 3753 | 3685 | sqlite3 *db, /* Database to be rekeyed */ |
| 3754 | 3686 | const void *pKey, int nKey /* The new key */ |
| 3755 | 3687 | ); |
| 3756 | 3688 | |
| 3757 | 3689 | /* |
| 3758 | -** CAPI3REF: Suspend Execution For A Short Time {H10530} <S40410> | |
| 3690 | +** CAPI3REF: Suspend Execution For A Short Time | |
| 3759 | 3691 | ** |
| 3760 | -** The sqlite3_sleep() function causes the current thread to suspend execution | |
| 3692 | +** ^The sqlite3_sleep() function causes the current thread to suspend execution | |
| 3761 | 3693 | ** for at least a number of milliseconds specified in its parameter. |
| 3762 | 3694 | ** |
| 3763 | -** If the operating system does not support sleep requests with | |
| 3695 | +** ^If the operating system does not support sleep requests with | |
| 3764 | 3696 | ** 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 | |
| 3766 | 3698 | ** requested from the operating system is returned. |
| 3767 | 3699 | ** |
| 3768 | -** SQLite implements this interface by calling the xSleep() | |
| 3700 | +** ^SQLite implements this interface by calling the xSleep() | |
| 3769 | 3701 | ** method of the default [sqlite3_vfs] object. |
| 3770 | -** | |
| 3771 | -** Requirements: [H10533] [H10536] | |
| 3772 | 3702 | */ |
| 3773 | 3703 | SQLITE_API int sqlite3_sleep(int); |
| 3774 | 3704 | |
| 3775 | 3705 | /* |
| 3776 | -** CAPI3REF: Name Of The Folder Holding Temporary Files {H10310} <S20000> | |
| 3706 | +** CAPI3REF: Name Of The Folder Holding Temporary Files | |
| 3777 | 3707 | ** |
| 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 | |
| 3779 | 3709 | ** 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 | |
| 3781 | 3712 | ** is a NULL pointer, then SQLite performs a search for an appropriate |
| 3782 | 3713 | ** temporary file directory. |
| 3783 | 3714 | ** |
| 3784 | 3715 | ** It is not safe to read or modify this variable in more than one |
| 3785 | 3716 | ** thread at a time. It is not safe to read or modify this variable |
| @@ -3788,12 +3719,12 @@ | ||
| 3788 | 3719 | ** It is intended that this variable be set once |
| 3789 | 3720 | ** as part of process initialization and before any SQLite interface |
| 3790 | 3721 | ** routines have been called and that this variable remain unchanged |
| 3791 | 3722 | ** thereafter. |
| 3792 | 3723 | ** |
| 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, | |
| 3795 | 3726 | ** the [temp_store_directory pragma] always assumes that any string |
| 3796 | 3727 | ** that this variable points to is held in memory obtained from |
| 3797 | 3728 | ** [sqlite3_malloc] and the pragma may attempt to free that memory |
| 3798 | 3729 | ** using [sqlite3_free]. |
| 3799 | 3730 | ** Hence, if this variable is modified directly, either it should be |
| @@ -3801,18 +3732,18 @@ | ||
| 3801 | 3732 | ** or else the use of the [temp_store_directory pragma] should be avoided. |
| 3802 | 3733 | */ |
| 3803 | 3734 | SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory; |
| 3804 | 3735 | |
| 3805 | 3736 | /* |
| 3806 | -** CAPI3REF: Test For Auto-Commit Mode {H12930} <S60200> | |
| 3737 | +** CAPI3REF: Test For Auto-Commit Mode | |
| 3807 | 3738 | ** KEYWORDS: {autocommit mode} |
| 3808 | 3739 | ** |
| 3809 | -** The sqlite3_get_autocommit() interface returns non-zero or | |
| 3740 | +** ^The sqlite3_get_autocommit() interface returns non-zero or | |
| 3810 | 3741 | ** 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]. | |
| 3814 | 3745 | ** |
| 3815 | 3746 | ** If certain kinds of errors occur on a statement within a multi-statement |
| 3816 | 3747 | ** transaction (errors including [SQLITE_FULL], [SQLITE_IOERR], |
| 3817 | 3748 | ** [SQLITE_NOMEM], [SQLITE_BUSY], and [SQLITE_INTERRUPT]) then the |
| 3818 | 3749 | ** transaction might be rolled back automatically. The only way to |
| @@ -3820,124 +3751,116 @@ | ||
| 3820 | 3751 | ** an error is to use this function. |
| 3821 | 3752 | ** |
| 3822 | 3753 | ** If another thread changes the autocommit status of the database |
| 3823 | 3754 | ** connection while this routine is running, then the return value |
| 3824 | 3755 | ** is undefined. |
| 3825 | -** | |
| 3826 | -** Requirements: [H12931] [H12932] [H12933] [H12934] | |
| 3827 | 3756 | */ |
| 3828 | 3757 | SQLITE_API int sqlite3_get_autocommit(sqlite3*); |
| 3829 | 3758 | |
| 3830 | 3759 | /* |
| 3831 | -** CAPI3REF: Find The Database Handle Of A Prepared Statement {H13120} <S60600> | |
| 3760 | +** CAPI3REF: Find The Database Handle Of A Prepared Statement | |
| 3832 | 3761 | ** |
| 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 | |
| 3836 | 3766 | ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to |
| 3837 | 3767 | ** create the statement in the first place. |
| 3838 | -** | |
| 3839 | -** Requirements: [H13123] | |
| 3840 | 3768 | */ |
| 3841 | 3769 | SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*); |
| 3842 | 3770 | |
| 3843 | 3771 | /* |
| 3844 | -** CAPI3REF: Find the next prepared statement {H13140} <S60600> | |
| 3772 | +** CAPI3REF: Find the next prepared statement | |
| 3845 | 3773 | ** |
| 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 | |
| 3848 | 3776 | ** 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 | |
| 3850 | 3778 | ** satisfies the conditions of this routine, it returns NULL. |
| 3851 | 3779 | ** |
| 3852 | 3780 | ** The [database connection] pointer D in a call to |
| 3853 | 3781 | ** [sqlite3_next_stmt(D,S)] must refer to an open database |
| 3854 | 3782 | ** connection and in particular must not be a NULL pointer. |
| 3855 | -** | |
| 3856 | -** Requirements: [H13143] [H13146] [H13149] [H13152] | |
| 3857 | 3783 | */ |
| 3858 | 3784 | SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt); |
| 3859 | 3785 | |
| 3860 | 3786 | /* |
| 3861 | -** CAPI3REF: Commit And Rollback Notification Callbacks {H12950} <S60400> | |
| 3787 | +** CAPI3REF: Commit And Rollback Notification Callbacks | |
| 3862 | 3788 | ** |
| 3863 | -** The sqlite3_commit_hook() interface registers a callback | |
| 3789 | +** ^The sqlite3_commit_hook() interface registers a callback | |
| 3864 | 3790 | ** 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() | |
| 3866 | 3792 | ** 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 | |
| 3868 | 3794 | ** 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() | |
| 3870 | 3796 | ** 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, | |
| 3873 | 3799 | ** then the commit is converted into a rollback. |
| 3874 | 3800 | ** |
| 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. | |
| 3877 | 3805 | ** |
| 3878 | 3806 | ** The callback implementation must not do anything that will modify |
| 3879 | 3807 | ** the database connection that invoked the callback. Any actions |
| 3880 | 3808 | ** to modify the database connection must be deferred until after the |
| 3881 | 3809 | ** completion of the [sqlite3_step()] call that triggered the commit |
| 3882 | 3810 | ** or rollback hook in the first place. |
| 3883 | 3811 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 3884 | 3812 | ** database connections for the meaning of "modify" in this paragraph. |
| 3885 | 3813 | ** |
| 3886 | -** Registering a NULL function disables the callback. | |
| 3814 | +** ^Registering a NULL function disables the callback. | |
| 3887 | 3815 | ** |
| 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 | |
| 3890 | 3818 | ** 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 | |
| 3892 | 3820 | ** hook returning non-zero, just as it would be with any other rollback. |
| 3893 | 3821 | ** |
| 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 | |
| 3895 | 3823 | ** rolled back if an explicit "ROLLBACK" statement is executed, or |
| 3896 | 3824 | ** 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 | |
| 3898 | 3826 | ** 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 | |
| 3900 | 3828 | ** rolled back because a commit callback returned non-zero. |
| 3901 | -** <todo> Check on this </todo> | |
| 3902 | 3829 | ** |
| 3903 | 3830 | ** See also the [sqlite3_update_hook()] interface. |
| 3904 | -** | |
| 3905 | -** Requirements: | |
| 3906 | -** [H12951] [H12952] [H12953] [H12954] [H12955] | |
| 3907 | -** [H12961] [H12962] [H12963] [H12964] | |
| 3908 | 3831 | */ |
| 3909 | 3832 | SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*); |
| 3910 | 3833 | SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*); |
| 3911 | 3834 | |
| 3912 | 3835 | /* |
| 3913 | -** CAPI3REF: Data Change Notification Callbacks {H12970} <S60400> | |
| 3836 | +** CAPI3REF: Data Change Notification Callbacks | |
| 3914 | 3837 | ** |
| 3915 | -** The sqlite3_update_hook() interface registers a callback function | |
| 3838 | +** ^The sqlite3_update_hook() interface registers a callback function | |
| 3916 | 3839 | ** with the [database connection] identified by the first argument |
| 3917 | 3840 | ** 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 | |
| 3919 | 3842 | ** for the same database connection is overridden. |
| 3920 | 3843 | ** |
| 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 | |
| 3922 | 3845 | ** 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 | |
| 3924 | 3847 | ** 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], | |
| 3926 | 3849 | ** or [SQLITE_UPDATE], depending on the operation that caused the callback |
| 3927 | 3850 | ** 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 | |
| 3929 | 3852 | ** 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. | |
| 3932 | 3855 | ** |
| 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).)^ | |
| 3935 | 3858 | ** |
| 3936 | -** In the current implementation, the update hook | |
| 3859 | +** ^In the current implementation, the update hook | |
| 3937 | 3860 | ** 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 | |
| 3939 | 3862 | ** invoked when rows are deleted using the [truncate optimization]. |
| 3940 | 3863 | ** The exceptions defined in this paragraph might change in a future |
| 3941 | 3864 | ** release of SQLite. |
| 3942 | 3865 | ** |
| 3943 | 3866 | ** The update hook implementation must not do anything that will modify |
| @@ -3945,169 +3868,157 @@ | ||
| 3945 | 3868 | ** to modify the database connection must be deferred until after the |
| 3946 | 3869 | ** completion of the [sqlite3_step()] call that triggered the update hook. |
| 3947 | 3870 | ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their |
| 3948 | 3871 | ** database connections for the meaning of "modify" in this paragraph. |
| 3949 | 3872 | ** |
| 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. | |
| 3952 | 3877 | ** |
| 3953 | 3878 | ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()] |
| 3954 | 3879 | ** interfaces. |
| 3955 | -** | |
| 3956 | -** Requirements: | |
| 3957 | -** [H12971] [H12973] [H12975] [H12977] [H12979] [H12981] [H12983] [H12986] | |
| 3958 | 3880 | */ |
| 3959 | 3881 | SQLITE_API void *sqlite3_update_hook( |
| 3960 | 3882 | sqlite3*, |
| 3961 | 3883 | void(*)(void *,int ,char const *,char const *,sqlite3_int64), |
| 3962 | 3884 | void* |
| 3963 | 3885 | ); |
| 3964 | 3886 | |
| 3965 | 3887 | /* |
| 3966 | -** CAPI3REF: Enable Or Disable Shared Pager Cache {H10330} <S30900> | |
| 3888 | +** CAPI3REF: Enable Or Disable Shared Pager Cache | |
| 3967 | 3889 | ** KEYWORDS: {shared cache} |
| 3968 | 3890 | ** |
| 3969 | -** This routine enables or disables the sharing of the database cache | |
| 3891 | +** ^(This routine enables or disables the sharing of the database cache | |
| 3970 | 3892 | ** and schema data structures between [database connection | connections] |
| 3971 | 3893 | ** 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.)^ | |
| 3973 | 3895 | ** |
| 3974 | -** Cache sharing is enabled and disabled for an entire process. | |
| 3896 | +** ^Cache sharing is enabled and disabled for an entire process. | |
| 3975 | 3897 | ** This is a change as of SQLite version 3.5.0. In prior versions of SQLite, |
| 3976 | 3898 | ** sharing was enabled or disabled for each thread separately. |
| 3977 | 3899 | ** |
| 3978 | -** The cache sharing mode set by this interface effects all subsequent | |
| 3900 | +** ^(The cache sharing mode set by this interface effects all subsequent | |
| 3979 | 3901 | ** calls to [sqlite3_open()], [sqlite3_open_v2()], and [sqlite3_open16()]. |
| 3980 | 3902 | ** 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 | |
| 3991 | 3909 | ** future releases of SQLite. Applications that care about shared |
| 3992 | 3910 | ** cache setting should set it explicitly. |
| 3993 | 3911 | ** |
| 3994 | 3912 | ** See Also: [SQLite Shared-Cache Mode] |
| 3995 | -** | |
| 3996 | -** Requirements: [H10331] [H10336] [H10337] [H10339] | |
| 3997 | 3913 | */ |
| 3998 | 3914 | SQLITE_API int sqlite3_enable_shared_cache(int); |
| 3999 | 3915 | |
| 4000 | 3916 | /* |
| 4001 | -** CAPI3REF: Attempt To Free Heap Memory {H17340} <S30220> | |
| 3917 | +** CAPI3REF: Attempt To Free Heap Memory | |
| 4002 | 3918 | ** |
| 4003 | -** The sqlite3_release_memory() interface attempts to free N bytes | |
| 3919 | +** ^The sqlite3_release_memory() interface attempts to free N bytes | |
| 4004 | 3920 | ** 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 | |
| 4006 | 3922 | ** 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, | |
| 4008 | 3924 | ** which might be more or less than the amount requested. |
| 4009 | -** | |
| 4010 | -** Requirements: [H17341] [H17342] | |
| 4011 | 3925 | */ |
| 4012 | 3926 | SQLITE_API int sqlite3_release_memory(int); |
| 4013 | 3927 | |
| 4014 | 3928 | /* |
| 4015 | -** CAPI3REF: Impose A Limit On Heap Size {H17350} <S30220> | |
| 3929 | +** CAPI3REF: Impose A Limit On Heap Size | |
| 4016 | 3930 | ** |
| 4017 | -** The sqlite3_soft_heap_limit() interface places a "soft" limit | |
| 3931 | +** ^The sqlite3_soft_heap_limit() interface places a "soft" limit | |
| 4018 | 3932 | ** 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 | |
| 4020 | 3934 | ** soft heap limit, [sqlite3_release_memory()] is invoked one or |
| 4021 | 3935 | ** more times to free up some space before the allocation is performed. |
| 4022 | 3936 | ** |
| 4023 | -** The limit is called "soft", because if [sqlite3_release_memory()] | |
| 3937 | +** ^The limit is called "soft" because if [sqlite3_release_memory()] | |
| 4024 | 3938 | ** cannot free sufficient memory to prevent the limit from being exceeded, |
| 4025 | 3939 | ** the memory is allocated anyway and the current operation proceeds. |
| 4026 | 3940 | ** |
| 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 | |
| 4028 | 3942 | ** [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. | |
| 4030 | 3944 | ** |
| 4031 | -** SQLite makes a best effort to honor the soft heap limit. | |
| 3945 | +** ^(SQLite makes a best effort to honor the soft heap limit. | |
| 4032 | 3946 | ** 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 | |
| 4034 | 3948 | ** called a "soft" limit. It is advisory only. |
| 4035 | 3949 | ** |
| 4036 | 3950 | ** Prior to SQLite version 3.5.0, this routine only constrained the memory |
| 4037 | 3951 | ** allocated by a single thread - the same thread in which this routine |
| 4038 | 3952 | ** runs. Beginning with SQLite version 3.5.0, the soft heap limit is |
| 4039 | 3953 | ** applied to all threads. The value specified for the soft heap limit |
| 4040 | 3954 | ** is an upper bound on the total memory allocation for all threads. In |
| 4041 | 3955 | ** version 3.5.0 there is no mechanism for limiting the heap usage for |
| 4042 | 3956 | ** individual threads. |
| 4043 | -** | |
| 4044 | -** Requirements: | |
| 4045 | -** [H16351] [H16352] [H16353] [H16354] [H16355] [H16358] | |
| 4046 | 3957 | */ |
| 4047 | 3958 | SQLITE_API void sqlite3_soft_heap_limit(int); |
| 4048 | 3959 | |
| 4049 | 3960 | /* |
| 4050 | -** CAPI3REF: Extract Metadata About A Column Of A Table {H12850} <S60300> | |
| 3961 | +** CAPI3REF: Extract Metadata About A Column Of A Table | |
| 4051 | 3962 | ** |
| 4052 | -** This routine returns metadata about a specific column of a specific | |
| 3963 | +** ^This routine returns metadata about a specific column of a specific | |
| 4053 | 3964 | ** database table accessible using the [database connection] handle |
| 4054 | 3965 | ** passed as the first function argument. |
| 4055 | 3966 | ** |
| 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 | |
| 4060 | 3971 | ** for the table using the same algorithm used by the database engine to |
| 4061 | 3972 | ** resolve unqualified table references. |
| 4062 | 3973 | ** |
| 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 | |
| 4064 | 3975 | ** name of the desired column, respectively. Neither of these parameters |
| 4065 | 3976 | ** may be NULL. |
| 4066 | 3977 | ** |
| 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 | |
| 4069 | 3980 | ** NULL, in which case the corresponding element of metadata is omitted. |
| 4070 | 3981 | ** |
| 4071 | -** <blockquote> | |
| 3982 | +** ^(<blockquote> | |
| 4072 | 3983 | ** <table border="1"> |
| 4073 | 3984 | ** <tr><th> Parameter <th> Output<br>Type <th> Description |
| 4074 | 3985 | ** |
| 4075 | 3986 | ** <tr><td> 5th <td> const char* <td> Data type |
| 4076 | 3987 | ** <tr><td> 6th <td> const char* <td> Name of default collation sequence |
| 4077 | 3988 | ** <tr><td> 7th <td> int <td> True if column has a NOT NULL constraint |
| 4078 | 3989 | ** <tr><td> 8th <td> int <td> True if column is part of the PRIMARY KEY |
| 4079 | 3990 | ** <tr><td> 9th <td> int <td> True if column is [AUTOINCREMENT] |
| 4080 | 3991 | ** </table> |
| 4081 | -** </blockquote> | |
| 3992 | +** </blockquote>)^ | |
| 4082 | 3993 | ** |
| 4083 | -** The memory pointed to by the character pointers returned for the | |
| 3994 | +** ^The memory pointed to by the character pointers returned for the | |
| 4084 | 3995 | ** declaration type and collation sequence is valid only until the next |
| 4085 | 3996 | ** call to any SQLite API function. |
| 4086 | 3997 | ** |
| 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. | |
| 4088 | 3999 | ** |
| 4089 | -** If the specified column is "rowid", "oid" or "_rowid_" and an | |
| 4000 | +** ^If the specified column is "rowid", "oid" or "_rowid_" and an | |
| 4090 | 4001 | ** [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 | |
| 4092 | 4003 | ** explicitly declared [INTEGER PRIMARY KEY] column, then the output |
| 4093 | 4004 | ** parameters are set as follows: |
| 4094 | 4005 | ** |
| 4095 | 4006 | ** <pre> |
| 4096 | 4007 | ** data type: "INTEGER" |
| 4097 | 4008 | ** collation sequence: "BINARY" |
| 4098 | 4009 | ** not null: 0 |
| 4099 | 4010 | ** primary key: 1 |
| 4100 | 4011 | ** auto increment: 0 |
| 4101 | -** </pre> | |
| 4012 | +** </pre>)^ | |
| 4102 | 4013 | ** |
| 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 | |
| 4104 | 4015 | ** error occurs during this process, or if the requested table or column |
| 4105 | 4016 | ** 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()).)^ | |
| 4107 | 4018 | ** |
| 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 | |
| 4109 | 4020 | ** [SQLITE_ENABLE_COLUMN_METADATA] C-preprocessor symbol defined. |
| 4110 | 4021 | */ |
| 4111 | 4022 | SQLITE_API int sqlite3_table_column_metadata( |
| 4112 | 4023 | sqlite3 *db, /* Connection handle */ |
| 4113 | 4024 | const char *zDbName, /* Database name or NULL */ |
| @@ -4119,34 +4030,31 @@ | ||
| 4119 | 4030 | int *pPrimaryKey, /* OUTPUT: True if column part of PK */ |
| 4120 | 4031 | int *pAutoinc /* OUTPUT: True if column is auto-increment */ |
| 4121 | 4032 | ); |
| 4122 | 4033 | |
| 4123 | 4034 | /* |
| 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. | |
| 4148 | 4056 | ** |
| 4149 | 4057 | ** See also the [load_extension() SQL function]. |
| 4150 | 4058 | */ |
| 4151 | 4059 | SQLITE_API int sqlite3_load_extension( |
| 4152 | 4060 | sqlite3 *db, /* Load the extension into this database connection */ |
| @@ -4154,65 +4062,53 @@ | ||
| 4154 | 4062 | const char *zProc, /* Entry point. Derived from zFile if 0 */ |
| 4155 | 4063 | char **pzErrMsg /* Put error message here if not 0 */ |
| 4156 | 4064 | ); |
| 4157 | 4065 | |
| 4158 | 4066 | /* |
| 4159 | -** CAPI3REF: Enable Or Disable Extension Loading {H12620} <S20500> | |
| 4067 | +** CAPI3REF: Enable Or Disable Extension Loading | |
| 4160 | 4068 | ** |
| 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 | |
| 4162 | 4070 | ** unprepared to deal with extension loading, and as a means of disabling |
| 4163 | 4071 | ** extension loading while evaluating user-entered SQL, the following API |
| 4164 | 4072 | ** is provided to turn the [sqlite3_load_extension()] mechanism on and off. |
| 4165 | 4073 | ** |
| 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. | |
| 4173 | 4078 | */ |
| 4174 | 4079 | SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff); |
| 4175 | 4080 | |
| 4176 | 4081 | /* |
| 4177 | -** CAPI3REF: Automatically Load An Extensions {H12640} <S20500> | |
| 4082 | +** CAPI3REF: Automatically Load An Extensions | |
| 4178 | 4083 | ** |
| 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 | |
| 4180 | 4085 | ** 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. | |
| 4200 | 4099 | */ |
| 4201 | 4100 | SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void)); |
| 4202 | 4101 | |
| 4203 | 4102 | /* |
| 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. | |
| 4214 | 4110 | */ |
| 4215 | 4111 | SQLITE_API void sqlite3_reset_auto_extension(void); |
| 4216 | 4112 | |
| 4217 | 4113 | /* |
| 4218 | 4114 | ****** EXPERIMENTAL - subject to change without notice ************** |
| @@ -4232,22 +4128,22 @@ | ||
| 4232 | 4128 | typedef struct sqlite3_index_info sqlite3_index_info; |
| 4233 | 4129 | typedef struct sqlite3_vtab_cursor sqlite3_vtab_cursor; |
| 4234 | 4130 | typedef struct sqlite3_module sqlite3_module; |
| 4235 | 4131 | |
| 4236 | 4132 | /* |
| 4237 | -** CAPI3REF: Virtual Table Object {H18000} <S20400> | |
| 4133 | +** CAPI3REF: Virtual Table Object | |
| 4238 | 4134 | ** KEYWORDS: sqlite3_module {virtual table module} |
| 4239 | 4135 | ** EXPERIMENTAL |
| 4240 | 4136 | ** |
| 4241 | 4137 | ** This structure, sometimes called a a "virtual table module", |
| 4242 | 4138 | ** defines the implementation of a [virtual tables]. |
| 4243 | 4139 | ** This structure consists mostly of methods for the module. |
| 4244 | 4140 | ** |
| 4245 | -** A virtual table module is created by filling in a persistent | |
| 4141 | +** ^A virtual table module is created by filling in a persistent | |
| 4246 | 4142 | ** instance of this structure and passing a pointer to that instance |
| 4247 | 4143 | ** 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 | |
| 4249 | 4145 | ** module or until the [database connection] closes. The content |
| 4250 | 4146 | ** of this structure must not change while it is registered with |
| 4251 | 4147 | ** any database connection. |
| 4252 | 4148 | */ |
| 4253 | 4149 | struct sqlite3_module { |
| @@ -4279,56 +4175,56 @@ | ||
| 4279 | 4175 | void **ppArg); |
| 4280 | 4176 | int (*xRename)(sqlite3_vtab *pVtab, const char *zNew); |
| 4281 | 4177 | }; |
| 4282 | 4178 | |
| 4283 | 4179 | /* |
| 4284 | -** CAPI3REF: Virtual Table Indexing Information {H18100} <S20400> | |
| 4180 | +** CAPI3REF: Virtual Table Indexing Information | |
| 4285 | 4181 | ** KEYWORDS: sqlite3_index_info |
| 4286 | 4182 | ** EXPERIMENTAL |
| 4287 | 4183 | ** |
| 4288 | 4184 | ** The sqlite3_index_info structure and its substructures is used to |
| 4289 | 4185 | ** pass information into and receive the reply from the [xBestIndex] |
| 4290 | 4186 | ** method of a [virtual table module]. The fields under **Inputs** are the |
| 4291 | 4187 | ** inputs to xBestIndex and are read-only. xBestIndex inserts its |
| 4292 | 4188 | ** results into the **Outputs** fields. |
| 4293 | 4189 | ** |
| 4294 | -** The aConstraint[] array records WHERE clause constraints of the form: | |
| 4190 | +** ^(The aConstraint[] array records WHERE clause constraints of the form: | |
| 4295 | 4191 | ** |
| 4296 | 4192 | ** <pre>column OP expr</pre> |
| 4297 | 4193 | ** |
| 4298 | -** where OP is =, <, <=, >, or >=. 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 =, <, <=, >, or >=.)^ ^(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 | |
| 4301 | 4197 | ** 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.)^ | |
| 4303 | 4199 | ** |
| 4304 | -** The optimizer automatically inverts terms of the form "expr OP column" | |
| 4200 | +** ^The optimizer automatically inverts terms of the form "expr OP column" | |
| 4305 | 4201 | ** and makes other simplifications to the WHERE clause in an attempt to |
| 4306 | 4202 | ** 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. | |
| 4309 | 4205 | ** |
| 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. | |
| 4312 | 4208 | ** |
| 4313 | 4209 | ** 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 | |
| 4315 | 4211 | ** 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 | |
| 4317 | 4213 | ** 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.)^ | |
| 4319 | 4215 | ** |
| 4320 | -** The idxNum and idxPtr values are recorded and passed into the | |
| 4216 | +** ^The idxNum and idxPtr values are recorded and passed into the | |
| 4321 | 4217 | ** [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 | |
| 4323 | 4219 | ** needToFreeIdxPtr is true. |
| 4324 | 4220 | ** |
| 4325 | -** The orderByConsumed means that output from [xFilter]/[xNext] will occur in | |
| 4221 | +** ^The orderByConsumed means that output from [xFilter]/[xNext] will occur in | |
| 4326 | 4222 | ** the correct order to satisfy the ORDER BY clause so that no separate |
| 4327 | 4223 | ** sorting step is required. |
| 4328 | 4224 | ** |
| 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 | |
| 4330 | 4226 | ** particular lookup. A full scan of a table with N entries should have |
| 4331 | 4227 | ** a cost of N. A binary search of a table of N entries should have a |
| 4332 | 4228 | ** cost of approximately log(N). |
| 4333 | 4229 | */ |
| 4334 | 4230 | struct sqlite3_index_info { |
| @@ -4362,70 +4258,63 @@ | ||
| 4362 | 4258 | #define SQLITE_INDEX_CONSTRAINT_LT 16 |
| 4363 | 4259 | #define SQLITE_INDEX_CONSTRAINT_GE 32 |
| 4364 | 4260 | #define SQLITE_INDEX_CONSTRAINT_MATCH 64 |
| 4365 | 4261 | |
| 4366 | 4262 | /* |
| 4367 | -** CAPI3REF: Register A Virtual Table Implementation {H18200} <S20400> | |
| 4263 | +** CAPI3REF: Register A Virtual Table Implementation | |
| 4368 | 4264 | ** EXPERIMENTAL |
| 4369 | 4265 | ** |
| 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 | |
| 4373 | 4269 | ** preexisting [virtual table] for the module. |
| 4374 | 4270 | ** |
| 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 | |
| 4379 | 4275 | ** parameter is an arbitrary client data pointer that is passed through |
| 4380 | 4276 | ** into the [xCreate] and [xConnect] methods of the virtual table module |
| 4381 | 4277 | ** when a new virtual table is be being created or reinitialized. |
| 4382 | 4278 | ** |
| 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. | |
| 4385 | 4285 | */ |
| 4386 | 4286 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module( |
| 4387 | 4287 | sqlite3 *db, /* SQLite connection to register module with */ |
| 4388 | 4288 | const char *zName, /* Name of the module */ |
| 4389 | 4289 | const sqlite3_module *p, /* Methods for the module */ |
| 4390 | 4290 | void *pClientData /* Client data for xCreate/xConnect */ |
| 4391 | 4291 | ); |
| 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 | 4292 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_create_module_v2( |
| 4404 | 4293 | sqlite3 *db, /* SQLite connection to register module with */ |
| 4405 | 4294 | const char *zName, /* Name of the module */ |
| 4406 | 4295 | const sqlite3_module *p, /* Methods for the module */ |
| 4407 | 4296 | void *pClientData, /* Client data for xCreate/xConnect */ |
| 4408 | 4297 | void(*xDestroy)(void*) /* Module destructor function */ |
| 4409 | 4298 | ); |
| 4410 | 4299 | |
| 4411 | 4300 | /* |
| 4412 | -** CAPI3REF: Virtual Table Instance Object {H18010} <S20400> | |
| 4301 | +** CAPI3REF: Virtual Table Instance Object | |
| 4413 | 4302 | ** KEYWORDS: sqlite3_vtab |
| 4414 | 4303 | ** EXPERIMENTAL |
| 4415 | 4304 | ** |
| 4416 | 4305 | ** 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 | |
| 4418 | 4307 | ** of the [virtual table]. Each subclass will |
| 4419 | 4308 | ** be tailored to the specific needs of the module implementation. |
| 4420 | 4309 | ** The purpose of this superclass is to define certain fields that are |
| 4421 | 4310 | ** common to all module implementations. |
| 4422 | 4311 | ** |
| 4423 | -** Virtual tables methods can set an error message by assigning a | |
| 4312 | +** ^Virtual tables methods can set an error message by assigning a | |
| 4424 | 4313 | ** string obtained from [sqlite3_mprintf()] to zErrMsg. The method should |
| 4425 | 4314 | ** 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 | |
| 4427 | 4316 | ** is delivered up to the client application, the string will be automatically |
| 4428 | 4317 | ** freed by sqlite3_free() and the zErrMsg field will be zeroed. |
| 4429 | 4318 | */ |
| 4430 | 4319 | struct sqlite3_vtab { |
| 4431 | 4320 | const sqlite3_module *pModule; /* The module for this virtual table */ |
| @@ -4433,20 +4322,20 @@ | ||
| 4433 | 4322 | char *zErrMsg; /* Error message from sqlite3_mprintf() */ |
| 4434 | 4323 | /* Virtual table implementations will typically add additional fields */ |
| 4435 | 4324 | }; |
| 4436 | 4325 | |
| 4437 | 4326 | /* |
| 4438 | -** CAPI3REF: Virtual Table Cursor Object {H18020} <S20400> | |
| 4327 | +** CAPI3REF: Virtual Table Cursor Object | |
| 4439 | 4328 | ** KEYWORDS: sqlite3_vtab_cursor {virtual table cursor} |
| 4440 | 4329 | ** EXPERIMENTAL |
| 4441 | 4330 | ** |
| 4442 | 4331 | ** Every [virtual table module] implementation uses a subclass of the |
| 4443 | 4332 | ** following structure to describe cursors that point into the |
| 4444 | 4333 | ** [virtual table] and are used |
| 4445 | 4334 | ** to loop through the virtual table. Cursors are created using the |
| 4446 | 4335 | ** [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 | |
| 4448 | 4337 | ** by the [xFilter], [xNext], [xEof], [xColumn], and [xRowid] methods |
| 4449 | 4338 | ** of the module. Each module implementation will define |
| 4450 | 4339 | ** the content of a cursor structure to suit its own needs. |
| 4451 | 4340 | ** |
| 4452 | 4341 | ** This superclass exists in order to define fields of the cursor that |
| @@ -4456,32 +4345,32 @@ | ||
| 4456 | 4345 | sqlite3_vtab *pVtab; /* Virtual table of this cursor */ |
| 4457 | 4346 | /* Virtual table implementations will typically add additional fields */ |
| 4458 | 4347 | }; |
| 4459 | 4348 | |
| 4460 | 4349 | /* |
| 4461 | -** CAPI3REF: Declare The Schema Of A Virtual Table {H18280} <S20400> | |
| 4350 | +** CAPI3REF: Declare The Schema Of A Virtual Table | |
| 4462 | 4351 | ** EXPERIMENTAL |
| 4463 | 4352 | ** |
| 4464 | -** The [xCreate] and [xConnect] methods of a | |
| 4353 | +** ^The [xCreate] and [xConnect] methods of a | |
| 4465 | 4354 | ** [virtual table module] call this interface |
| 4466 | 4355 | ** to declare the format (the names and datatypes of the columns) of |
| 4467 | 4356 | ** the virtual tables they implement. |
| 4468 | 4357 | */ |
| 4469 | 4358 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_declare_vtab(sqlite3*, const char *zSQL); |
| 4470 | 4359 | |
| 4471 | 4360 | /* |
| 4472 | -** CAPI3REF: Overload A Function For A Virtual Table {H18300} <S20400> | |
| 4361 | +** CAPI3REF: Overload A Function For A Virtual Table | |
| 4473 | 4362 | ** EXPERIMENTAL |
| 4474 | 4363 | ** |
| 4475 | -** Virtual tables can provide alternative implementations of functions | |
| 4364 | +** ^(Virtual tables can provide alternative implementations of functions | |
| 4476 | 4365 | ** using the [xFindFunction] method of the [virtual table module]. |
| 4477 | 4366 | ** But global versions of those functions |
| 4478 | -** must exist in order to be overloaded. | |
| 4367 | +** must exist in order to be overloaded.)^ | |
| 4479 | 4368 | ** |
| 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 | |
| 4481 | 4370 | ** 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 | |
| 4483 | 4372 | ** of the new function always causes an exception to be thrown. So |
| 4484 | 4373 | ** the new function is not good for anything by itself. Its only |
| 4485 | 4374 | ** purpose is to be a placeholder function that can be overloaded |
| 4486 | 4375 | ** by a [virtual table]. |
| 4487 | 4376 | */ |
| @@ -4498,81 +4387,78 @@ | ||
| 4498 | 4387 | ** |
| 4499 | 4388 | ****** EXPERIMENTAL - subject to change without notice ************** |
| 4500 | 4389 | */ |
| 4501 | 4390 | |
| 4502 | 4391 | /* |
| 4503 | -** CAPI3REF: A Handle To An Open BLOB {H17800} <S30230> | |
| 4392 | +** CAPI3REF: A Handle To An Open BLOB | |
| 4504 | 4393 | ** KEYWORDS: {BLOB handle} {BLOB handles} |
| 4505 | 4394 | ** |
| 4506 | 4395 | ** An instance of this object represents an open BLOB on which |
| 4507 | 4396 | ** [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()] | |
| 4509 | 4398 | ** 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 | |
| 4511 | 4400 | ** 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. | |
| 4513 | 4402 | */ |
| 4514 | 4403 | typedef struct sqlite3_blob sqlite3_blob; |
| 4515 | 4404 | |
| 4516 | 4405 | /* |
| 4517 | -** CAPI3REF: Open A BLOB For Incremental I/O {H17810} <S30230> | |
| 4406 | +** CAPI3REF: Open A BLOB For Incremental I/O | |
| 4518 | 4407 | ** |
| 4519 | -** This interfaces opens a [BLOB handle | handle] to the BLOB located | |
| 4408 | +** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located | |
| 4520 | 4409 | ** in row iRow, column zColumn, table zTable in database zDb; |
| 4521 | 4410 | ** in other words, the same BLOB that would be selected by: |
| 4522 | 4411 | ** |
| 4523 | 4412 | ** <pre> |
| 4524 | 4413 | ** SELECT zColumn FROM zDb.zTable WHERE [rowid] = iRow; |
| 4525 | -** </pre> {END} | |
| 4414 | +** </pre>)^ | |
| 4526 | 4415 | ** |
| 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 | |
| 4530 | 4419 | ** key for writing. ^If [foreign key constraints] are enabled, it is |
| 4531 | 4420 | ** not possible to open a column that is part of a [child key] for writing. |
| 4532 | 4421 | ** |
| 4533 | -** Note that the database name is not the filename that contains | |
| 4422 | +** ^Note that the database name is not the filename that contains | |
| 4534 | 4423 | ** 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". | |
| 4538 | 4427 | ** |
| 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 | |
| 4540 | 4429 | ** 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 | |
| 4543 | 4432 | ** 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 | |
| 4545 | 4434 | ** way that makes it safe to invoke [sqlite3_blob_close()] on *ppBlob |
| 4546 | 4435 | ** regardless of the success or failure of this routine. |
| 4547 | 4436 | ** |
| 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 | |
| 4549 | 4438 | ** [UPDATE], [DELETE], or by [ON CONFLICT] side-effects |
| 4550 | 4439 | ** then the BLOB handle is marked as "expired". |
| 4551 | 4440 | ** 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 | |
| 4554 | 4443 | ** 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.)^ | |
| 4558 | 4447 | ** |
| 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 | |
| 4561 | 4450 | ** interface. Use the [UPDATE] SQL command to change the size of a |
| 4562 | 4451 | ** blob. |
| 4563 | 4452 | ** |
| 4564 | -** The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces | |
| 4453 | +** ^The [sqlite3_bind_zeroblob()] and [sqlite3_result_zeroblob()] interfaces | |
| 4565 | 4454 | ** and the built-in [zeroblob] SQL function can be used, if desired, |
| 4566 | 4455 | ** to create an empty, zero-filled blob in which to read or write using |
| 4567 | 4456 | ** this interface. |
| 4568 | 4457 | ** |
| 4569 | 4458 | ** To avoid a resource leak, every open [BLOB handle] should eventually |
| 4570 | 4459 | ** be released by a call to [sqlite3_blob_close()]. |
| 4571 | -** | |
| 4572 | -** Requirements: | |
| 4573 | -** [H17813] [H17814] [H17816] [H17819] [H17821] [H17824] | |
| 4574 | 4460 | */ |
| 4575 | 4461 | SQLITE_API int sqlite3_blob_open( |
| 4576 | 4462 | sqlite3*, |
| 4577 | 4463 | const char *zDb, |
| 4578 | 4464 | const char *zTable, |
| @@ -4581,201 +4467,185 @@ | ||
| 4581 | 4467 | int flags, |
| 4582 | 4468 | sqlite3_blob **ppBlob |
| 4583 | 4469 | ); |
| 4584 | 4470 | |
| 4585 | 4471 | /* |
| 4586 | -** CAPI3REF: Close A BLOB Handle {H17830} <S30230> | |
| 4472 | +** CAPI3REF: Close A BLOB Handle | |
| 4587 | 4473 | ** |
| 4588 | -** Closes an open [BLOB handle]. | |
| 4474 | +** ^Closes an open [BLOB handle]. | |
| 4589 | 4475 | ** |
| 4590 | -** Closing a BLOB shall cause the current transaction to commit | |
| 4476 | +** ^Closing a BLOB shall cause the current transaction to commit | |
| 4591 | 4477 | ** if there are no other BLOBs, no pending prepared statements, and the |
| 4592 | 4478 | ** 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 | |
| 4594 | 4480 | ** until the close operation if they will fit. |
| 4595 | 4481 | ** |
| 4596 | -** Closing the BLOB often forces the changes | |
| 4482 | +** ^(Closing the BLOB often forces the changes | |
| 4597 | 4483 | ** out to disk and so if any I/O errors occur, they will likely occur |
| 4598 | 4484 | ** 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. | |
| 4609 | 4492 | */ |
| 4610 | 4493 | SQLITE_API int sqlite3_blob_close(sqlite3_blob *); |
| 4611 | 4494 | |
| 4612 | 4495 | /* |
| 4613 | -** CAPI3REF: Return The Size Of An Open BLOB {H17840} <S30230> | |
| 4496 | +** CAPI3REF: Return The Size Of An Open BLOB | |
| 4614 | 4497 | ** |
| 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 | |
| 4617 | 4500 | ** incremental blob I/O routines can only read or overwriting existing |
| 4618 | 4501 | ** blob content; they cannot change the size of a blob. |
| 4619 | 4502 | ** |
| 4620 | 4503 | ** This routine only works on a [BLOB handle] which has been created |
| 4621 | 4504 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 4622 | 4505 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 4623 | 4506 | ** to this routine results in undefined and probably undesirable behavior. |
| 4624 | -** | |
| 4625 | -** Requirements: | |
| 4626 | -** [H17843] | |
| 4627 | 4507 | */ |
| 4628 | 4508 | SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *); |
| 4629 | 4509 | |
| 4630 | 4510 | /* |
| 4631 | -** CAPI3REF: Read Data From A BLOB Incrementally {H17850} <S30230> | |
| 4511 | +** CAPI3REF: Read Data From A BLOB Incrementally | |
| 4632 | 4512 | ** |
| 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 | |
| 4634 | 4514 | ** 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.)^ | |
| 4636 | 4516 | ** |
| 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 | |
| 4639 | 4519 | ** 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) | |
| 4641 | 4521 | ** can be determined using the [sqlite3_blob_bytes()] interface. |
| 4642 | 4522 | ** |
| 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 | |
| 4644 | 4524 | ** error code of [SQLITE_ABORT]. |
| 4645 | 4525 | ** |
| 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.)^ | |
| 4648 | 4528 | ** |
| 4649 | 4529 | ** This routine only works on a [BLOB handle] which has been created |
| 4650 | 4530 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 4651 | 4531 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 4652 | 4532 | ** to this routine results in undefined and probably undesirable behavior. |
| 4653 | 4533 | ** |
| 4654 | 4534 | ** See also: [sqlite3_blob_write()]. |
| 4655 | -** | |
| 4656 | -** Requirements: | |
| 4657 | -** [H17853] [H17856] [H17859] [H17862] [H17863] [H17865] [H17868] | |
| 4658 | 4535 | */ |
| 4659 | 4536 | SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset); |
| 4660 | 4537 | |
| 4661 | 4538 | /* |
| 4662 | -** CAPI3REF: Write Data Into A BLOB Incrementally {H17870} <S30230> | |
| 4539 | +** CAPI3REF: Write Data Into A BLOB Incrementally | |
| 4663 | 4540 | ** |
| 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 | |
| 4666 | 4543 | ** into the open BLOB, starting at offset iOffset. |
| 4667 | 4544 | ** |
| 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 | |
| 4669 | 4546 | ** writing (the flags parameter to [sqlite3_blob_open()] was zero), |
| 4670 | 4547 | ** this function returns [SQLITE_READONLY]. |
| 4671 | 4548 | ** |
| 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 | |
| 4673 | 4550 | ** 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 | |
| 4676 | 4553 | ** less than zero [SQLITE_ERROR] is returned and no data is written. |
| 4677 | 4554 | ** The size of the BLOB (and hence the maximum value of N+iOffset) |
| 4678 | 4555 | ** can be determined using the [sqlite3_blob_bytes()] interface. |
| 4679 | 4556 | ** |
| 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 | |
| 4682 | 4559 | ** before the [BLOB handle] expired are not rolled back by the |
| 4683 | 4560 | ** expiration of the handle, though of course those changes might |
| 4684 | 4561 | ** have been overwritten by the statement that expired the BLOB handle |
| 4685 | 4562 | ** or by other independent statements. |
| 4686 | 4563 | ** |
| 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.)^ | |
| 4689 | 4566 | ** |
| 4690 | 4567 | ** This routine only works on a [BLOB handle] which has been created |
| 4691 | 4568 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 4692 | 4569 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| 4693 | 4570 | ** to this routine results in undefined and probably undesirable behavior. |
| 4694 | 4571 | ** |
| 4695 | 4572 | ** See also: [sqlite3_blob_read()]. |
| 4696 | -** | |
| 4697 | -** Requirements: | |
| 4698 | -** [H17873] [H17874] [H17875] [H17876] [H17877] [H17879] [H17882] [H17885] | |
| 4699 | -** [H17888] | |
| 4700 | 4573 | */ |
| 4701 | 4574 | SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset); |
| 4702 | 4575 | |
| 4703 | 4576 | /* |
| 4704 | -** CAPI3REF: Virtual File System Objects {H11200} <S20100> | |
| 4577 | +** CAPI3REF: Virtual File System Objects | |
| 4705 | 4578 | ** |
| 4706 | 4579 | ** A virtual filesystem (VFS) is an [sqlite3_vfs] object |
| 4707 | 4580 | ** that SQLite uses to interact |
| 4708 | 4581 | ** with the underlying operating system. Most SQLite builds come with a |
| 4709 | 4582 | ** single default VFS that is appropriate for the host computer. |
| 4710 | 4583 | ** New VFSes can be registered and existing VFSes can be unregistered. |
| 4711 | 4584 | ** The following interfaces are provided. |
| 4712 | 4585 | ** |
| 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. | |
| 4718 | 4591 | ** |
| 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 | |
| 4723 | 4596 | ** with the makeDflt flag set. If two different VFSes with the |
| 4724 | 4597 | ** same name are registered, the behavior is undefined. If a |
| 4725 | 4598 | ** VFS is registered with a name that is NULL or an empty string, |
| 4726 | 4599 | ** then the behavior is undefined. |
| 4727 | 4600 | ** |
| 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.)^ | |
| 4734 | 4604 | */ |
| 4735 | 4605 | SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName); |
| 4736 | 4606 | SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt); |
| 4737 | 4607 | SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*); |
| 4738 | 4608 | |
| 4739 | 4609 | /* |
| 4740 | -** CAPI3REF: Mutexes {H17000} <S20000> | |
| 4610 | +** CAPI3REF: Mutexes | |
| 4741 | 4611 | ** |
| 4742 | 4612 | ** The SQLite core uses these routines for thread |
| 4743 | 4613 | ** synchronization. Though they are intended for internal |
| 4744 | 4614 | ** use by SQLite, code that links against SQLite is |
| 4745 | 4615 | ** permitted to use any of these routines. |
| 4746 | 4616 | ** |
| 4747 | 4617 | ** The SQLite source code contains multiple implementations |
| 4748 | 4618 | ** 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 | |
| 4750 | 4620 | ** implementations are available in the SQLite core: |
| 4751 | 4621 | ** |
| 4752 | 4622 | ** <ul> |
| 4753 | 4623 | ** <li> SQLITE_MUTEX_OS2 |
| 4754 | 4624 | ** <li> SQLITE_MUTEX_PTHREAD |
| 4755 | 4625 | ** <li> SQLITE_MUTEX_W32 |
| 4756 | 4626 | ** <li> SQLITE_MUTEX_NOOP |
| 4757 | -** </ul> | |
| 4627 | +** </ul>)^ | |
| 4758 | 4628 | ** |
| 4759 | -** The SQLITE_MUTEX_NOOP implementation is a set of routines | |
| 4629 | +** ^The SQLITE_MUTEX_NOOP implementation is a set of routines | |
| 4760 | 4630 | ** 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, | |
| 4762 | 4632 | ** SQLITE_MUTEX_PTHREAD, and SQLITE_MUTEX_W32 implementations |
| 4763 | 4633 | ** are appropriate for use on OS/2, Unix, and Windows. |
| 4764 | 4634 | ** |
| 4765 | -** If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor | |
| 4635 | +** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor | |
| 4766 | 4636 | ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex |
| 4767 | 4637 | ** implementation is included with the library. In this case the |
| 4768 | 4638 | ** application must supply a custom mutex implementation using the |
| 4769 | 4639 | ** [SQLITE_CONFIG_MUTEX] option of the sqlite3_config() function |
| 4770 | 4640 | ** before calling sqlite3_initialize() or any other public sqlite3_ |
| 4771 | -** function that calls sqlite3_initialize(). | |
| 4641 | +** function that calls sqlite3_initialize().)^ | |
| 4772 | 4642 | ** |
| 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 | |
| 4777 | 4647 | ** to sqlite3_mutex_alloc() is one of these integer constants: |
| 4778 | 4648 | ** |
| 4779 | 4649 | ** <ul> |
| 4780 | 4650 | ** <li> SQLITE_MUTEX_FAST |
| 4781 | 4651 | ** <li> SQLITE_MUTEX_RECURSIVE |
| @@ -4783,68 +4653,70 @@ | ||
| 4783 | 4653 | ** <li> SQLITE_MUTEX_STATIC_MEM |
| 4784 | 4654 | ** <li> SQLITE_MUTEX_STATIC_MEM2 |
| 4785 | 4655 | ** <li> SQLITE_MUTEX_STATIC_PRNG |
| 4786 | 4656 | ** <li> SQLITE_MUTEX_STATIC_LRU |
| 4787 | 4657 | ** <li> SQLITE_MUTEX_STATIC_LRU2 |
| 4788 | -** </ul> | |
| 4658 | +** </ul>)^ | |
| 4789 | 4659 | ** |
| 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. | |
| 4793 | 4664 | ** The mutex implementation does not need to make a distinction |
| 4794 | 4665 | ** 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 | |
| 4797 | 4668 | ** implementation is available on the host platform, the mutex subsystem |
| 4798 | 4669 | ** might return such a mutex in response to SQLITE_MUTEX_FAST. |
| 4799 | 4670 | ** |
| 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 | |
| 4802 | 4674 | ** used by the current version of SQLite. Future versions of SQLite |
| 4803 | 4675 | ** may add additional static mutexes. Static mutexes are for internal |
| 4804 | 4676 | ** use by SQLite only. Applications that use SQLite mutexes should |
| 4805 | 4677 | ** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or |
| 4806 | 4678 | ** SQLITE_MUTEX_RECURSIVE. |
| 4807 | 4679 | ** |
| 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 | |
| 4809 | 4681 | ** 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 | |
| 4811 | 4683 | ** mutex types, the same mutex is returned on every call that has |
| 4812 | 4684 | ** the same type number. |
| 4813 | 4685 | ** |
| 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. | |
| 4820 | 4692 | ** |
| 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, | |
| 4823 | 4695 | ** 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 | |
| 4826 | 4698 | ** SQLITE_MUTEX_RECURSIVE can be entered multiple times by the same thread. |
| 4827 | -** {H17027} In such cases the, | |
| 4699 | +** In such cases the, | |
| 4828 | 4700 | ** 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 | |
| 4830 | 4702 | ** 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.)^ | |
| 4833 | 4705 | ** |
| 4834 | -** Some systems (for example, Windows 95) do not support the operation | |
| 4706 | +** ^(Some systems (for example, Windows 95) do not support the operation | |
| 4835 | 4707 | ** 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.)^ | |
| 4838 | 4710 | ** |
| 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 | |
| 4841 | 4713 | ** 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.)^ | |
| 4844 | 4716 | ** |
| 4845 | -** If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or | |
| 4717 | +** ^If the argument to sqlite3_mutex_enter(), sqlite3_mutex_try(), or | |
| 4846 | 4718 | ** sqlite3_mutex_leave() is a NULL pointer, then all three routines |
| 4847 | 4719 | ** behave as no-ops. |
| 4848 | 4720 | ** |
| 4849 | 4721 | ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()]. |
| 4850 | 4722 | */ |
| @@ -4853,11 +4725,11 @@ | ||
| 4853 | 4725 | SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*); |
| 4854 | 4726 | SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*); |
| 4855 | 4727 | SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*); |
| 4856 | 4728 | |
| 4857 | 4729 | /* |
| 4858 | -** CAPI3REF: Mutex Methods Object {H17120} <S20130> | |
| 4730 | +** CAPI3REF: Mutex Methods Object | |
| 4859 | 4731 | ** EXPERIMENTAL |
| 4860 | 4732 | ** |
| 4861 | 4733 | ** An instance of this structure defines the low-level routines |
| 4862 | 4734 | ** used to allocate and use mutexes. |
| 4863 | 4735 | ** |
| @@ -4869,23 +4741,23 @@ | ||
| 4869 | 4741 | ** to sqlite3_config() along with the [SQLITE_CONFIG_MUTEX] option. |
| 4870 | 4742 | ** Additionally, an instance of this structure can be used as an |
| 4871 | 4743 | ** output variable when querying the system for the current mutex |
| 4872 | 4744 | ** implementation, using the [SQLITE_CONFIG_GETMUTEX] option. |
| 4873 | 4745 | ** |
| 4874 | -** The xMutexInit method defined by this structure is invoked as | |
| 4746 | +** ^The xMutexInit method defined by this structure is invoked as | |
| 4875 | 4747 | ** 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 | |
| 4877 | 4749 | ** effective call to [sqlite3_initialize()]. |
| 4878 | 4750 | ** |
| 4879 | -** The xMutexEnd method defined by this structure is invoked as | |
| 4751 | +** ^The xMutexEnd method defined by this structure is invoked as | |
| 4880 | 4752 | ** part of system shutdown by the sqlite3_shutdown() function. The |
| 4881 | 4753 | ** implementation of this method is expected to release all outstanding |
| 4882 | 4754 | ** 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()]. | |
| 4885 | 4757 | ** |
| 4886 | -** The remaining seven methods defined by this structure (xMutexAlloc, | |
| 4758 | +** ^(The remaining seven methods defined by this structure (xMutexAlloc, | |
| 4887 | 4759 | ** xMutexFree, xMutexEnter, xMutexTry, xMutexLeave, xMutexHeld and |
| 4888 | 4760 | ** xMutexNotheld) implement the following interfaces (respectively): |
| 4889 | 4761 | ** |
| 4890 | 4762 | ** <ul> |
| 4891 | 4763 | ** <li> [sqlite3_mutex_alloc()] </li> |
| @@ -4893,31 +4765,31 @@ | ||
| 4893 | 4765 | ** <li> [sqlite3_mutex_enter()] </li> |
| 4894 | 4766 | ** <li> [sqlite3_mutex_try()] </li> |
| 4895 | 4767 | ** <li> [sqlite3_mutex_leave()] </li> |
| 4896 | 4768 | ** <li> [sqlite3_mutex_held()] </li> |
| 4897 | 4769 | ** <li> [sqlite3_mutex_notheld()] </li> |
| 4898 | -** </ul> | |
| 4770 | +** </ul>)^ | |
| 4899 | 4771 | ** |
| 4900 | 4772 | ** The only difference is that the public sqlite3_XXX functions enumerated |
| 4901 | 4773 | ** above silently ignore any invocations that pass a NULL pointer instead |
| 4902 | 4774 | ** of a valid mutex handle. The implementations of the methods defined |
| 4903 | 4775 | ** by this structure are not required to handle this case, the results |
| 4904 | 4776 | ** of passing a NULL pointer instead of a valid mutex handle are undefined |
| 4905 | 4777 | ** (i.e. it is acceptable to provide an implementation that segfaults if |
| 4906 | 4778 | ** it is passed a NULL pointer). |
| 4907 | 4779 | ** |
| 4908 | -** The xMutexInit() method must be threadsafe. It must be harmless to | |
| 4780 | +** The xMutexInit() method must be threadsafe. ^It must be harmless to | |
| 4909 | 4781 | ** invoke xMutexInit() mutiple times within the same process and without |
| 4910 | 4782 | ** intervening calls to xMutexEnd(). Second and subsequent calls to |
| 4911 | 4783 | ** xMutexInit() must be no-ops. |
| 4912 | 4784 | ** |
| 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 | |
| 4916 | 4788 | ** memory allocation for a fast or recursive mutex. |
| 4917 | 4789 | ** |
| 4918 | -** SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is | |
| 4790 | +** ^SQLite will invoke the xMutexEnd() method when [sqlite3_shutdown()] is | |
| 4919 | 4791 | ** called, but only if the prior call to xMutexInit returned SQLITE_OK. |
| 4920 | 4792 | ** If xMutexInit fails in any way, it is expected to clean up after itself |
| 4921 | 4793 | ** prior to returning. |
| 4922 | 4794 | */ |
| 4923 | 4795 | typedef struct sqlite3_mutex_methods sqlite3_mutex_methods; |
| @@ -4932,43 +4804,45 @@ | ||
| 4932 | 4804 | int (*xMutexHeld)(sqlite3_mutex *); |
| 4933 | 4805 | int (*xMutexNotheld)(sqlite3_mutex *); |
| 4934 | 4806 | }; |
| 4935 | 4807 | |
| 4936 | 4808 | /* |
| 4937 | -** CAPI3REF: Mutex Verification Routines {H17080} <S20130> <S30800> | |
| 4809 | +** CAPI3REF: Mutex Verification Routines | |
| 4938 | 4810 | ** |
| 4939 | 4811 | ** 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 | |
| 4941 | 4813 | ** 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 | |
| 4943 | 4815 | ** 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 | |
| 4945 | 4817 | ** are only required to provide these routines if SQLITE_DEBUG is |
| 4946 | 4818 | ** defined and if NDEBUG is not defined. |
| 4947 | 4819 | ** |
| 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 | |
| 4949 | 4821 | ** is held or not held, respectively, by the calling thread. |
| 4950 | 4822 | ** |
| 4951 | -** {X17084} The implementation is not required to provided versions of these | |
| 4823 | +** ^The implementation is not required to provided versions of these | |
| 4952 | 4824 | ** routines that actually work. If the implementation does not provide working |
| 4953 | 4825 | ** versions of these routines, it should at least provide stubs that always |
| 4954 | 4826 | ** return true so that one does not get spurious assertion failures. |
| 4955 | 4827 | ** |
| 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 | |
| 4958 | 4830 | ** clearly the mutex cannot be held if it does not exist. But the |
| 4959 | 4831 | ** the reason the mutex does not exist is because the build is not |
| 4960 | 4832 | ** using mutexes. And we do not want the assert() containing the |
| 4961 | 4833 | ** 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() | |
| 4963 | 4835 | ** interface should also return 1 when given a NULL pointer. |
| 4964 | 4836 | */ |
| 4837 | +#ifndef NDEBUG | |
| 4965 | 4838 | SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*); |
| 4966 | 4839 | SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*); |
| 4840 | +#endif | |
| 4967 | 4841 | |
| 4968 | 4842 | /* |
| 4969 | -** CAPI3REF: Mutex Types {H17001} <H17000> | |
| 4843 | +** CAPI3REF: Mutex Types | |
| 4970 | 4844 | ** |
| 4971 | 4845 | ** The [sqlite3_mutex_alloc()] interface takes a single argument |
| 4972 | 4846 | ** which is one of these integer constants. |
| 4973 | 4847 | ** |
| 4974 | 4848 | ** The set of static mutexes may change from one SQLite release to the |
| @@ -4984,52 +4858,54 @@ | ||
| 4984 | 4858 | #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ |
| 4985 | 4859 | #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ |
| 4986 | 4860 | #define SQLITE_MUTEX_STATIC_LRU2 7 /* lru page list */ |
| 4987 | 4861 | |
| 4988 | 4862 | /* |
| 4989 | -** CAPI3REF: Retrieve the mutex for a database connection {H17002} <H17000> | |
| 4863 | +** CAPI3REF: Retrieve the mutex for a database connection | |
| 4990 | 4864 | ** |
| 4991 | -** This interface returns a pointer the [sqlite3_mutex] object that | |
| 4865 | +** ^This interface returns a pointer the [sqlite3_mutex] object that | |
| 4992 | 4866 | ** serializes access to the [database connection] given in the argument |
| 4993 | 4867 | ** 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 | |
| 4995 | 4869 | ** routine returns a NULL pointer. |
| 4996 | 4870 | */ |
| 4997 | 4871 | SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*); |
| 4998 | 4872 | |
| 4999 | 4873 | /* |
| 5000 | -** CAPI3REF: Low-Level Control Of Database Files {H11300} <S30800> | |
| 4874 | +** CAPI3REF: Low-Level Control Of Database Files | |
| 5001 | 4875 | ** |
| 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 | |
| 5003 | 4877 | ** 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 | |
| 5009 | 4885 | ** 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 | |
| 5011 | 4887 | ** method becomes the return value of this routine. |
| 5012 | 4888 | ** |
| 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 | |
| 5015 | 4891 | ** 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 | |
| 5018 | 4894 | ** an incorrect zDbName and an SQLITE_ERROR return from the underlying |
| 5019 | -** xFileControl method. {END} | |
| 4895 | +** xFileControl method. | |
| 5020 | 4896 | ** |
| 5021 | 4897 | ** See also: [SQLITE_FCNTL_LOCKSTATE] |
| 5022 | 4898 | */ |
| 5023 | 4899 | SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*); |
| 5024 | 4900 | |
| 5025 | 4901 | /* |
| 5026 | -** CAPI3REF: Testing Interface {H11400} <S30800> | |
| 4902 | +** CAPI3REF: Testing Interface | |
| 5027 | 4903 | ** |
| 5028 | -** The sqlite3_test_control() interface is used to read out internal | |
| 4904 | +** ^The sqlite3_test_control() interface is used to read out internal | |
| 5029 | 4905 | ** 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 | |
| 5031 | 4907 | ** the number, meaning, and operation of all subsequent parameters. |
| 5032 | 4908 | ** |
| 5033 | 4909 | ** This interface is not for use by applications. It exists solely |
| 5034 | 4910 | ** for verifying the correct operation of the SQLite library. Depending |
| 5035 | 4911 | ** on how the SQLite library is compiled, this interface might not exist. |
| @@ -5040,20 +4916,21 @@ | ||
| 5040 | 4916 | ** operate consistently from one release to the next. |
| 5041 | 4917 | */ |
| 5042 | 4918 | SQLITE_API int sqlite3_test_control(int op, ...); |
| 5043 | 4919 | |
| 5044 | 4920 | /* |
| 5045 | -** CAPI3REF: Testing Interface Operation Codes {H11410} <H11400> | |
| 4921 | +** CAPI3REF: Testing Interface Operation Codes | |
| 5046 | 4922 | ** |
| 5047 | 4923 | ** These constants are the valid operation code parameters used |
| 5048 | 4924 | ** as the first argument to [sqlite3_test_control()]. |
| 5049 | 4925 | ** |
| 5050 | 4926 | ** These parameters and their meanings are subject to change |
| 5051 | 4927 | ** without notice. These values are for testing purposes only. |
| 5052 | 4928 | ** Applications should not use any of these parameters or the |
| 5053 | 4929 | ** [sqlite3_test_control()] interface. |
| 5054 | 4930 | */ |
| 4931 | +#define SQLITE_TESTCTRL_FIRST 5 | |
| 5055 | 4932 | #define SQLITE_TESTCTRL_PRNG_SAVE 5 |
| 5056 | 4933 | #define SQLITE_TESTCTRL_PRNG_RESTORE 6 |
| 5057 | 4934 | #define SQLITE_TESTCTRL_PRNG_RESET 7 |
| 5058 | 4935 | #define SQLITE_TESTCTRL_BITVEC_TEST 8 |
| 5059 | 4936 | #define SQLITE_TESTCTRL_FAULT_INSTALL 9 |
| @@ -5060,31 +4937,34 @@ | ||
| 5060 | 4937 | #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10 |
| 5061 | 4938 | #define SQLITE_TESTCTRL_PENDING_BYTE 11 |
| 5062 | 4939 | #define SQLITE_TESTCTRL_ASSERT 12 |
| 5063 | 4940 | #define SQLITE_TESTCTRL_ALWAYS 13 |
| 5064 | 4941 | #define SQLITE_TESTCTRL_RESERVE 14 |
| 4942 | +#define SQLITE_TESTCTRL_OPTIMIZATIONS 15 | |
| 4943 | +#define SQLITE_TESTCTRL_ISKEYWORD 16 | |
| 4944 | +#define SQLITE_TESTCTRL_LAST 16 | |
| 5065 | 4945 | |
| 5066 | 4946 | /* |
| 5067 | -** CAPI3REF: SQLite Runtime Status {H17200} <S60200> | |
| 4947 | +** CAPI3REF: SQLite Runtime Status | |
| 5068 | 4948 | ** EXPERIMENTAL |
| 5069 | 4949 | ** |
| 5070 | -** This interface is used to retrieve runtime status information | |
| 4950 | +** ^This interface is used to retrieve runtime status information | |
| 5071 | 4951 | ** 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 | |
| 5077 | 4957 | ** 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 | |
| 5079 | 4959 | ** 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.)^ | |
| 5083 | 4963 | ** |
| 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. | |
| 5086 | 4966 | ** |
| 5087 | 4967 | ** This routine is threadsafe but is not atomic. This routine can be |
| 5088 | 4968 | ** called while other threads are running the same or different SQLite |
| 5089 | 4969 | ** interfaces. However the values returned in *pCurrent and |
| 5090 | 4970 | ** *pHighwater reflect the status of SQLite at different points in time |
| @@ -5095,82 +4975,82 @@ | ||
| 5095 | 4975 | */ |
| 5096 | 4976 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag); |
| 5097 | 4977 | |
| 5098 | 4978 | |
| 5099 | 4979 | /* |
| 5100 | -** CAPI3REF: Status Parameters {H17250} <H17200> | |
| 4980 | +** CAPI3REF: Status Parameters | |
| 5101 | 4981 | ** EXPERIMENTAL |
| 5102 | 4982 | ** |
| 5103 | 4983 | ** These integer constants designate various run-time status parameters |
| 5104 | 4984 | ** that can be returned by [sqlite3_status()]. |
| 5105 | 4985 | ** |
| 5106 | 4986 | ** <dl> |
| 5107 | -** <dt>SQLITE_STATUS_MEMORY_USED</dt> | |
| 4987 | +** ^(<dt>SQLITE_STATUS_MEMORY_USED</dt> | |
| 5108 | 4988 | ** <dd>This parameter is the current amount of memory checked out |
| 5109 | 4989 | ** using [sqlite3_malloc()], either directly or indirectly. The |
| 5110 | 4990 | ** figure includes calls made to [sqlite3_malloc()] by the application |
| 5111 | 4991 | ** and internal memory usage by the SQLite library. Scratch memory |
| 5112 | 4992 | ** controlled by [SQLITE_CONFIG_SCRATCH] and auxiliary page-cache |
| 5113 | 4993 | ** memory controlled by [SQLITE_CONFIG_PAGECACHE] is not included in |
| 5114 | 4994 | ** 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>)^ | |
| 5116 | 4996 | ** |
| 5117 | -** <dt>SQLITE_STATUS_MALLOC_SIZE</dt> | |
| 4997 | +** ^(<dt>SQLITE_STATUS_MALLOC_SIZE</dt> | |
| 5118 | 4998 | ** <dd>This parameter records the largest memory allocation request |
| 5119 | 4999 | ** handed to [sqlite3_malloc()] or [sqlite3_realloc()] (or their |
| 5120 | 5000 | ** internal equivalents). Only the value returned in the |
| 5121 | 5001 | ** *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>)^ | |
| 5123 | 5003 | ** |
| 5124 | -** <dt>SQLITE_STATUS_PAGECACHE_USED</dt> | |
| 5004 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_USED</dt> | |
| 5125 | 5005 | ** <dd>This parameter returns the number of pages used out of the |
| 5126 | 5006 | ** [pagecache memory allocator] that was configured using |
| 5127 | 5007 | ** [SQLITE_CONFIG_PAGECACHE]. The |
| 5128 | -** value returned is in pages, not in bytes.</dd> | |
| 5008 | +** value returned is in pages, not in bytes.</dd>)^ | |
| 5129 | 5009 | ** |
| 5130 | -** <dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> | |
| 5010 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> | |
| 5131 | 5011 | ** <dd>This parameter returns the number of bytes of page cache |
| 5132 | 5012 | ** allocation which could not be statisfied by the [SQLITE_CONFIG_PAGECACHE] |
| 5133 | 5013 | ** buffer and where forced to overflow to [sqlite3_malloc()]. The |
| 5134 | 5014 | ** returned value includes allocations that overflowed because they |
| 5135 | 5015 | ** where too large (they were larger than the "sz" parameter to |
| 5136 | 5016 | ** [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>)^ | |
| 5138 | 5018 | ** |
| 5139 | -** <dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> | |
| 5019 | +** ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> | |
| 5140 | 5020 | ** <dd>This parameter records the largest memory allocation request |
| 5141 | 5021 | ** handed to [pagecache memory allocator]. Only the value returned in the |
| 5142 | 5022 | ** *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>)^ | |
| 5144 | 5024 | ** |
| 5145 | -** <dt>SQLITE_STATUS_SCRATCH_USED</dt> | |
| 5025 | +** ^(<dt>SQLITE_STATUS_SCRATCH_USED</dt> | |
| 5146 | 5026 | ** <dd>This parameter returns the number of allocations used out of the |
| 5147 | 5027 | ** [scratch memory allocator] configured using |
| 5148 | 5028 | ** [SQLITE_CONFIG_SCRATCH]. The value returned is in allocations, not |
| 5149 | 5029 | ** in bytes. Since a single thread may only have one scratch allocation |
| 5150 | 5030 | ** 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>)^ | |
| 5152 | 5032 | ** |
| 5153 | -** <dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> | |
| 5033 | +** ^(<dt>SQLITE_STATUS_SCRATCH_OVERFLOW</dt> | |
| 5154 | 5034 | ** <dd>This parameter returns the number of bytes of scratch memory |
| 5155 | 5035 | ** allocation which could not be statisfied by the [SQLITE_CONFIG_SCRATCH] |
| 5156 | 5036 | ** buffer and where forced to overflow to [sqlite3_malloc()]. The values |
| 5157 | 5037 | ** returned include overflows because the requested allocation was too |
| 5158 | 5038 | ** larger (that is, because the requested allocation was larger than the |
| 5159 | 5039 | ** "sz" parameter to [SQLITE_CONFIG_SCRATCH]) and because no scratch buffer |
| 5160 | 5040 | ** slots were available. |
| 5161 | -** </dd> | |
| 5041 | +** </dd>)^ | |
| 5162 | 5042 | ** |
| 5163 | -** <dt>SQLITE_STATUS_SCRATCH_SIZE</dt> | |
| 5043 | +** ^(<dt>SQLITE_STATUS_SCRATCH_SIZE</dt> | |
| 5164 | 5044 | ** <dd>This parameter records the largest memory allocation request |
| 5165 | 5045 | ** handed to [scratch memory allocator]. Only the value returned in the |
| 5166 | 5046 | ** *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>)^ | |
| 5168 | 5048 | ** |
| 5169 | -** <dt>SQLITE_STATUS_PARSER_STACK</dt> | |
| 5049 | +** ^(<dt>SQLITE_STATUS_PARSER_STACK</dt> | |
| 5170 | 5050 | ** <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>)^ | |
| 5172 | 5052 | ** </dl> |
| 5173 | 5053 | ** |
| 5174 | 5054 | ** New status parameters may be added from time to time. |
| 5175 | 5055 | */ |
| 5176 | 5056 | #define SQLITE_STATUS_MEMORY_USED 0 |
| @@ -5182,31 +5062,31 @@ | ||
| 5182 | 5062 | #define SQLITE_STATUS_PARSER_STACK 6 |
| 5183 | 5063 | #define SQLITE_STATUS_PAGECACHE_SIZE 7 |
| 5184 | 5064 | #define SQLITE_STATUS_SCRATCH_SIZE 8 |
| 5185 | 5065 | |
| 5186 | 5066 | /* |
| 5187 | -** CAPI3REF: Database Connection Status {H17500} <S60200> | |
| 5067 | +** CAPI3REF: Database Connection Status | |
| 5188 | 5068 | ** EXPERIMENTAL |
| 5189 | 5069 | ** |
| 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 | |
| 5194 | 5074 | ** for the second parameter is [SQLITE_DBSTATUS_LOOKASIDE_USED]. |
| 5195 | 5075 | ** Additional options will likely appear in future releases of SQLite. |
| 5196 | 5076 | ** |
| 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 | |
| 5199 | 5079 | ** the resetFlg is true, then the highest instantaneous value is |
| 5200 | 5080 | ** reset back down to the current value. |
| 5201 | 5081 | ** |
| 5202 | 5082 | ** See also: [sqlite3_status()] and [sqlite3_stmt_status()]. |
| 5203 | 5083 | */ |
| 5204 | 5084 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg); |
| 5205 | 5085 | |
| 5206 | 5086 | /* |
| 5207 | -** CAPI3REF: Status Parameters for database connections {H17520} <H17500> | |
| 5087 | +** CAPI3REF: Status Parameters for database connections | |
| 5208 | 5088 | ** EXPERIMENTAL |
| 5209 | 5089 | ** |
| 5210 | 5090 | ** These constants are the available integer "verbs" that can be passed as |
| 5211 | 5091 | ** the second argument to the [sqlite3_db_status()] interface. |
| 5212 | 5092 | ** |
| @@ -5215,61 +5095,61 @@ | ||
| 5215 | 5095 | ** [sqlite3_db_status()] to make sure that the call worked. |
| 5216 | 5096 | ** The [sqlite3_db_status()] interface will return a non-zero error code |
| 5217 | 5097 | ** if a discontinued or unsupported verb is invoked. |
| 5218 | 5098 | ** |
| 5219 | 5099 | ** <dl> |
| 5220 | -** <dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> | |
| 5100 | +** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_USED</dt> | |
| 5221 | 5101 | ** <dd>This parameter returns the number of lookaside memory slots currently |
| 5222 | -** checked out.</dd> | |
| 5102 | +** checked out.</dd>)^ | |
| 5223 | 5103 | ** </dl> |
| 5224 | 5104 | */ |
| 5225 | 5105 | #define SQLITE_DBSTATUS_LOOKASIDE_USED 0 |
| 5226 | 5106 | |
| 5227 | 5107 | |
| 5228 | 5108 | /* |
| 5229 | -** CAPI3REF: Prepared Statement Status {H17550} <S60200> | |
| 5109 | +** CAPI3REF: Prepared Statement Status | |
| 5230 | 5110 | ** EXPERIMENTAL |
| 5231 | 5111 | ** |
| 5232 | -** Each prepared statement maintains various | |
| 5112 | +** ^(Each prepared statement maintains various | |
| 5233 | 5113 | ** [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 | |
| 5235 | 5115 | ** be used to monitor the performance characteristics of the prepared |
| 5236 | 5116 | ** statements. For example, if the number of table steps greatly exceeds |
| 5237 | 5117 | ** the number of table searches or result rows, that would tend to indicate |
| 5238 | 5118 | ** that the prepared statement is using a full table scan rather than |
| 5239 | 5119 | ** an index. |
| 5240 | 5120 | ** |
| 5241 | -** This interface is used to retrieve and reset counter values from | |
| 5121 | +** ^(This interface is used to retrieve and reset counter values from | |
| 5242 | 5122 | ** a [prepared statement]. The first argument is the prepared statement |
| 5243 | 5123 | ** object to be interrogated. The second argument |
| 5244 | 5124 | ** 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 | |
| 5248 | 5128 | ** interface call returns. |
| 5249 | 5129 | ** |
| 5250 | 5130 | ** See also: [sqlite3_status()] and [sqlite3_db_status()]. |
| 5251 | 5131 | */ |
| 5252 | 5132 | SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg); |
| 5253 | 5133 | |
| 5254 | 5134 | /* |
| 5255 | -** CAPI3REF: Status Parameters for prepared statements {H17570} <H17550> | |
| 5135 | +** CAPI3REF: Status Parameters for prepared statements | |
| 5256 | 5136 | ** EXPERIMENTAL |
| 5257 | 5137 | ** |
| 5258 | 5138 | ** These preprocessor macros define integer codes that name counter |
| 5259 | 5139 | ** values associated with the [sqlite3_stmt_status()] interface. |
| 5260 | 5140 | ** The meanings of the various counters are as follows: |
| 5261 | 5141 | ** |
| 5262 | 5142 | ** <dl> |
| 5263 | 5143 | ** <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 | |
| 5265 | 5145 | ** a table as part of a full table scan. Large numbers for this counter |
| 5266 | 5146 | ** may indicate opportunities for performance improvement through |
| 5267 | 5147 | ** careful use of indices.</dd> |
| 5268 | 5148 | ** |
| 5269 | 5149 | ** <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. | |
| 5271 | 5151 | ** A non-zero value in this counter may indicate an opportunity to |
| 5272 | 5152 | ** improvement performance through careful use of indices.</dd> |
| 5273 | 5153 | ** |
| 5274 | 5154 | ** </dl> |
| 5275 | 5155 | */ |
| @@ -5293,84 +5173,84 @@ | ||
| 5293 | 5173 | /* |
| 5294 | 5174 | ** CAPI3REF: Application Defined Page Cache. |
| 5295 | 5175 | ** KEYWORDS: {page cache} |
| 5296 | 5176 | ** EXPERIMENTAL |
| 5297 | 5177 | ** |
| 5298 | -** The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can | |
| 5178 | +** ^(The [sqlite3_config]([SQLITE_CONFIG_PCACHE], ...) interface can | |
| 5299 | 5179 | ** 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 | |
| 5301 | 5181 | ** heap memory used by SQLite is used by the page cache to cache data read |
| 5302 | 5182 | ** from, or ready to be written to, the database file. By implementing a |
| 5303 | 5183 | ** custom page cache using this API, an application can control more |
| 5304 | 5184 | ** precisely the amount of memory consumed by SQLite, the way in which |
| 5305 | 5185 | ** that memory is allocated and released, and the policies used to |
| 5306 | 5186 | ** determine exactly which parts of a database file are cached and for |
| 5307 | 5187 | ** how long. |
| 5308 | 5188 | ** |
| 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 | |
| 5310 | 5190 | ** internal buffer by SQLite within the call to [sqlite3_config]. Hence |
| 5311 | 5191 | ** 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()], | |
| 5321 | 5201 | ** if the application invokes this API. It can be used to clean up |
| 5322 | 5202 | ** any outstanding resources before process shutdown, if required. |
| 5323 | 5203 | ** |
| 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 | |
| 5326 | 5206 | ** xShutdown method is only called from [sqlite3_shutdown()] so it does |
| 5327 | 5207 | ** not need to be threadsafe either. All other methods must be threadsafe |
| 5328 | 5208 | ** in multithreaded applications. |
| 5329 | 5209 | ** |
| 5330 | -** SQLite will never invoke xInit() more than once without an intervening | |
| 5210 | +** ^SQLite will never invoke xInit() more than once without an intervening | |
| 5331 | 5211 | ** call to xShutdown(). |
| 5332 | 5212 | ** |
| 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 | |
| 5334 | 5214 | ** 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 | |
| 5336 | 5216 | ** 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 | |
| 5338 | 5218 | ** 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 | |
| 5340 | 5220 | ** extra R bytes on each page to store metadata about the underlying |
| 5341 | 5221 | ** database page on disk. The value of R depends |
| 5342 | 5222 | ** 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 | |
| 5344 | 5224 | ** xCreate(), bPurgeable, is true if the cache being created will |
| 5345 | 5225 | ** 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 | |
| 5347 | 5227 | ** 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 | |
| 5349 | 5229 | ** 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 | |
| 5351 | 5231 | ** never contain any unpinned pages. |
| 5352 | 5232 | ** |
| 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 | |
| 5354 | 5234 | ** suggested maximum cache-size (number of pages stored by) the cache |
| 5355 | 5235 | ** 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 | |
| 5358 | 5238 | ** value; it is advisory only. |
| 5359 | 5239 | ** |
| 5360 | -** The xPagecount() method should return the number of pages currently | |
| 5240 | +** ^The xPagecount() method should return the number of pages currently | |
| 5361 | 5241 | ** stored in the cache. |
| 5362 | 5242 | ** |
| 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 | |
| 5366 | 5246 | ** mimimum key value is 1. After it has been retrieved using xFetch, the page |
| 5367 | 5247 | ** is considered to be "pinned". |
| 5368 | 5248 | ** |
| 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 | |
| 5370 | 5250 | ** 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 | |
| 5372 | 5252 | ** behavior of the cache implementation is determined by the value of the |
| 5373 | 5253 | ** createFlag parameter passed to xFetch, according to the following table: |
| 5374 | 5254 | ** |
| 5375 | 5255 | ** <table border=1 width=85% align=center> |
| 5376 | 5256 | ** <tr><th> createFlag <th> Behaviour when page is not already in cache |
| @@ -5377,45 +5257,45 @@ | ||
| 5377 | 5257 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 5378 | 5258 | ** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. |
| 5379 | 5259 | ** Otherwise return NULL. |
| 5380 | 5260 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 5381 | 5261 | ** NULL if allocating a new page is effectively impossible. |
| 5382 | -** </table> | |
| 5262 | +** </table>)^ | |
| 5383 | 5263 | ** |
| 5384 | 5264 | ** SQLite will normally invoke xFetch() with a createFlag of 0 or 1. If |
| 5385 | 5265 | ** a call to xFetch() with createFlag==1 returns NULL, then SQLite will |
| 5386 | 5266 | ** attempt to unpin one or more cache pages by spilling the content of |
| 5387 | 5267 | ** pinned pages to disk and synching the operating system disk cache. After |
| 5388 | 5268 | ** attempting to unpin pages, the xFetch() method will be invoked again with |
| 5389 | 5269 | ** a createFlag of 2. |
| 5390 | 5270 | ** |
| 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, | |
| 5393 | 5273 | ** then the page should be evicted from the cache. In this case SQLite |
| 5394 | 5274 | ** 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 | |
| 5397 | 5277 | ** may choose to evict unpinned pages at any time. |
| 5398 | 5278 | ** |
| 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 | |
| 5400 | 5280 | ** call to xUnpin() unpins the page regardless of the number of prior calls |
| 5401 | -** to xFetch(). | |
| 5281 | +** to xFetch().)^ | |
| 5402 | 5282 | ** |
| 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 | |
| 5405 | 5285 | ** 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 | |
| 5407 | 5287 | ** to be pinned. |
| 5408 | 5288 | ** |
| 5409 | -** When SQLite calls the xTruncate() method, the cache must discard all | |
| 5289 | +** ^When SQLite calls the xTruncate() method, the cache must discard all | |
| 5410 | 5290 | ** 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 | |
| 5412 | 5292 | ** of these pages are pinned, they are implicitly unpinned, meaning that |
| 5413 | 5293 | ** they can be safely discarded. |
| 5414 | 5294 | ** |
| 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 | |
| 5417 | 5297 | ** calling the xDestroy() method, SQLite considers the [sqlite3_pcache*] |
| 5418 | 5298 | ** handle invalid, and will not use it with any other sqlite3_pcache_methods |
| 5419 | 5299 | ** functions. |
| 5420 | 5300 | */ |
| 5421 | 5301 | typedef struct sqlite3_pcache_methods sqlite3_pcache_methods; |
| @@ -5436,11 +5316,11 @@ | ||
| 5436 | 5316 | /* |
| 5437 | 5317 | ** CAPI3REF: Online Backup Object |
| 5438 | 5318 | ** EXPERIMENTAL |
| 5439 | 5319 | ** |
| 5440 | 5320 | ** 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 | |
| 5442 | 5322 | ** a call to [sqlite3_backup_init()] and is destroyed by a call to |
| 5443 | 5323 | ** [sqlite3_backup_finish()]. |
| 5444 | 5324 | ** |
| 5445 | 5325 | ** See Also: [Using the SQLite Online Backup API] |
| 5446 | 5326 | */ |
| @@ -5448,168 +5328,173 @@ | ||
| 5448 | 5328 | |
| 5449 | 5329 | /* |
| 5450 | 5330 | ** CAPI3REF: Online Backup API. |
| 5451 | 5331 | ** EXPERIMENTAL |
| 5452 | 5332 | ** |
| 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 | |
| 5455 | 5335 | ** for copying in-memory databases to or from persistent files. |
| 5456 | 5336 | ** |
| 5457 | 5337 | ** See Also: [Using the SQLite Online Backup API] |
| 5458 | 5338 | ** |
| 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. | |
| 5465 | 5345 | ** |
| 5466 | -** To perform a backup operation: | |
| 5346 | +** ^(To perform a backup operation: | |
| 5467 | 5347 | ** <ol> |
| 5468 | 5348 | ** <li><b>sqlite3_backup_init()</b> is called once to initialize the |
| 5469 | 5349 | ** backup, |
| 5470 | 5350 | ** <li><b>sqlite3_backup_step()</b> is called one or more times to transfer |
| 5471 | 5351 | ** the data between the two databases, and finally |
| 5472 | 5352 | ** <li><b>sqlite3_backup_finish()</b> is called to release all resources |
| 5473 | 5353 | ** associated with the backup operation. |
| 5474 | -** </ol> | |
| 5354 | +** </ol>)^ | |
| 5475 | 5355 | ** There should be exactly one call to sqlite3_backup_finish() for each |
| 5476 | 5356 | ** successful call to sqlite3_backup_init(). |
| 5477 | 5357 | ** |
| 5478 | 5358 | ** <b>sqlite3_backup_init()</b> |
| 5479 | 5359 | ** |
| 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. | |
| 5490 | 5372 | ** |
| 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 | |
| 5497 | 5382 | ** sqlite3_backup_finish() functions to perform the specified backup |
| 5498 | 5383 | ** operation. |
| 5499 | 5384 | ** |
| 5500 | 5385 | ** <b>sqlite3_backup_step()</b> |
| 5501 | 5386 | ** |
| 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 | |
| 5510 | 5396 | ** [SQLITE_DONE], a call to sqlite3_backup_step() may return [SQLITE_READONLY], |
| 5511 | 5397 | ** [SQLITE_NOMEM], [SQLITE_BUSY], [SQLITE_LOCKED], or an |
| 5512 | 5398 | ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX] extended error code. |
| 5513 | 5399 | ** |
| 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 | |
| 5516 | 5402 | ** the destination is an in-memory database with a different page size |
| 5517 | 5403 | ** from the source database. |
| 5518 | 5404 | ** |
| 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 | |
| 5520 | 5406 | ** 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 | |
| 5522 | 5408 | ** 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 | |
| 5525 | 5411 | ** [database connection] |
| 5526 | 5412 | ** 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 | |
| 5529 | 5415 | ** [SQLITE_IOERR_ACCESS | SQLITE_IOERR_XXX], [SQLITE_NOMEM], or |
| 5530 | 5416 | ** [SQLITE_READONLY] is returned, then |
| 5531 | 5417 | ** 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 | |
| 5533 | 5419 | ** that the backup operation has failed and pass the backup operation handle |
| 5534 | 5420 | ** to the sqlite3_backup_finish() to release associated resources. |
| 5535 | 5421 | ** |
| 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 | |
| 5538 | 5424 | ** 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 | |
| 5545 | 5431 | ** 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 | |
| 5548 | 5434 | ** 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 | |
| 5550 | 5436 | ** updated at the same time. |
| 5551 | 5437 | ** |
| 5552 | 5438 | ** <b>sqlite3_backup_finish()</b> |
| 5553 | 5439 | ** |
| 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 | |
| 5560 | 5448 | ** and may not be used following a call to sqlite3_backup_finish(). |
| 5561 | 5449 | ** |
| 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]. | |
| 5570 | 5456 | ** |
| 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 | |
| 5573 | 5459 | ** sqlite3_backup_finish(). |
| 5574 | 5460 | ** |
| 5575 | 5461 | ** <b>sqlite3_backup_remaining(), sqlite3_backup_pagecount()</b> |
| 5576 | 5462 | ** |
| 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. | |
| 5582 | 5468 | ** |
| 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 | |
| 5585 | 5471 | ** operation, then the values are not updated to account for any extra |
| 5586 | 5472 | ** pages that need to be updated or the size of the source database file |
| 5587 | 5473 | ** changing. |
| 5588 | 5474 | ** |
| 5589 | 5475 | ** <b>Concurrent Usage of Database Handles</b> |
| 5590 | 5476 | ** |
| 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 | |
| 5592 | 5478 | ** 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 | |
| 5594 | 5480 | ** connections, then the source database connection may be used concurrently |
| 5595 | 5481 | ** from within other threads. |
| 5596 | 5482 | ** |
| 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 | |
| 5599 | 5485 | ** 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. | |
| 5606 | 5491 | ** |
| 5607 | -** Furthermore, if running in [shared cache mode], the application must | |
| 5492 | +** If running in [shared cache mode], the application must | |
| 5608 | 5493 | ** guarantee that the shared cache used by the destination database |
| 5609 | 5494 | ** 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 | |
| 5611 | 5496 | ** backed up to is not accessed by any connection within the process, |
| 5612 | 5497 | ** not just the specific connection that was passed to sqlite3_backup_init(). |
| 5613 | 5498 | ** |
| 5614 | 5499 | ** The [sqlite3_backup] object itself is partially threadsafe. Multiple |
| 5615 | 5500 | ** threads may safely make multiple concurrent calls to sqlite3_backup_step(). |
| @@ -5631,60 +5516,60 @@ | ||
| 5631 | 5516 | |
| 5632 | 5517 | /* |
| 5633 | 5518 | ** CAPI3REF: Unlock Notification |
| 5634 | 5519 | ** EXPERIMENTAL |
| 5635 | 5520 | ** |
| 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 | |
| 5637 | 5522 | ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or |
| 5638 | 5523 | ** individual tables within the shared-cache cannot be obtained. See |
| 5639 | 5524 | ** [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 | |
| 5641 | 5526 | ** 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 | |
| 5643 | 5528 | ** [SQLITE_ENABLE_UNLOCK_NOTIFY] C-preprocessor symbol defined. |
| 5644 | 5529 | ** |
| 5645 | 5530 | ** See Also: [Using the SQLite Unlock Notification Feature]. |
| 5646 | 5531 | ** |
| 5647 | -** Shared-cache locks are released when a database connection concludes | |
| 5532 | +** ^Shared-cache locks are released when a database connection concludes | |
| 5648 | 5533 | ** its current transaction, either by committing it or rolling it back. |
| 5649 | 5534 | ** |
| 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 | |
| 5651 | 5536 | ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the |
| 5652 | 5537 | ** 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 | |
| 5654 | 5539 | ** application receives an SQLITE_LOCKED error, it may call the |
| 5655 | 5540 | ** sqlite3_unlock_notify() method with the blocked connection handle as |
| 5656 | 5541 | ** 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 | |
| 5658 | 5543 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| 5659 | 5544 | ** call that concludes the blocking connections transaction. |
| 5660 | 5545 | ** |
| 5661 | -** If sqlite3_unlock_notify() is called in a multi-threaded application, | |
| 5546 | +** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, | |
| 5662 | 5547 | ** there is a chance that the blocking connection will have already |
| 5663 | 5548 | ** concluded its transaction by the time sqlite3_unlock_notify() is invoked. |
| 5664 | 5549 | ** 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().)^ | |
| 5666 | 5551 | ** |
| 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 | |
| 5668 | 5553 | ** shared-cache table, and more than one other connection currently holds |
| 5669 | 5554 | ** a read-lock on the same table, then SQLite arbitrarily selects one of |
| 5670 | 5555 | ** the other connections to use as the blocking connection. |
| 5671 | 5556 | ** |
| 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 | |
| 5673 | 5558 | ** blocked connection. If sqlite3_unlock_notify() is called when the |
| 5674 | 5559 | ** 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 | |
| 5676 | 5561 | ** 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 | |
| 5678 | 5563 | ** unlock-notify callback may also be canceled by closing the blocked |
| 5679 | 5564 | ** connection using [sqlite3_close()]. |
| 5680 | 5565 | ** |
| 5681 | 5566 | ** The unlock-notify callback is not reentrant. If an application invokes |
| 5682 | 5567 | ** any sqlite3_xxx API functions from within an unlock-notify callback, a |
| 5683 | 5568 | ** crash or deadlock may be the result. |
| 5684 | 5569 | ** |
| 5685 | -** Unless deadlock is detected (see below), sqlite3_unlock_notify() always | |
| 5570 | +** ^Unless deadlock is detected (see below), sqlite3_unlock_notify() always | |
| 5686 | 5571 | ** returns SQLITE_OK. |
| 5687 | 5572 | ** |
| 5688 | 5573 | ** <b>Callback Invocation Details</b> |
| 5689 | 5574 | ** |
| 5690 | 5575 | ** When an unlock-notify callback is registered, the application provides a |
| @@ -5694,11 +5579,11 @@ | ||
| 5694 | 5579 | ** an unlock-notify callback is a pointer to an array of void* pointers, |
| 5695 | 5580 | ** and the second is the number of entries in the array. |
| 5696 | 5581 | ** |
| 5697 | 5582 | ** When a blocking connections transaction is concluded, there may be |
| 5698 | 5583 | ** 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 | |
| 5700 | 5585 | ** same callback function, then instead of invoking the callback function |
| 5701 | 5586 | ** multiple times, it is invoked once with the set of void* context pointers |
| 5702 | 5587 | ** specified by the blocked connections bundled together into an array. |
| 5703 | 5588 | ** This gives the application an opportunity to prioritize any actions |
| 5704 | 5589 | ** related to the set of unblocked database connections. |
| @@ -5712,20 +5597,20 @@ | ||
| 5712 | 5597 | ** connection Y's transaction to be concluded, and similarly connection |
| 5713 | 5598 | ** Y is waiting on connection X's transaction, then neither connection |
| 5714 | 5599 | ** will proceed and the system may remain deadlocked indefinitely. |
| 5715 | 5600 | ** |
| 5716 | 5601 | ** 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 | |
| 5718 | 5603 | ** system in a deadlocked state, then SQLITE_LOCKED is returned and no |
| 5719 | 5604 | ** unlock-notify callback is registered. The system is said to be in |
| 5720 | 5605 | ** a deadlocked state if connection A has registered for an unlock-notify |
| 5721 | 5606 | ** callback on the conclusion of connection B's transaction, and connection |
| 5722 | 5607 | ** 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 | |
| 5724 | 5609 | ** the system is also considered to be deadlocked if connection B has |
| 5725 | 5610 | ** 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 | |
| 5727 | 5612 | ** number of levels of indirection are allowed. |
| 5728 | 5613 | ** |
| 5729 | 5614 | ** <b>The "DROP TABLE" Exception</b> |
| 5730 | 5615 | ** |
| 5731 | 5616 | ** When a call to [sqlite3_step()] returns SQLITE_LOCKED, it is almost |
| @@ -5737,14 +5622,14 @@ | ||
| 5737 | 5622 | ** sqlite3_unlock_notify() results in the unlock-notify callback being |
| 5738 | 5623 | ** invoked immediately. If the application then re-attempts the "DROP TABLE" |
| 5739 | 5624 | ** or "DROP INDEX" query, an infinite loop might be the result. |
| 5740 | 5625 | ** |
| 5741 | 5626 | ** 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 | |
| 5743 | 5628 | ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in |
| 5744 | 5629 | ** the special "DROP TABLE/INDEX" case, the extended error code is just |
| 5745 | -** SQLITE_LOCKED. | |
| 5630 | +** SQLITE_LOCKED.)^ | |
| 5746 | 5631 | */ |
| 5747 | 5632 | SQLITE_API int sqlite3_unlock_notify( |
| 5748 | 5633 | sqlite3 *pBlocked, /* Waiting connection */ |
| 5749 | 5634 | void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */ |
| 5750 | 5635 | void *pNotifyArg /* Argument to pass to xNotify */ |
| @@ -5753,11 +5638,11 @@ | ||
| 5753 | 5638 | |
| 5754 | 5639 | /* |
| 5755 | 5640 | ** CAPI3REF: String Comparison |
| 5756 | 5641 | ** EXPERIMENTAL |
| 5757 | 5642 | ** |
| 5758 | -** The [sqlite3_strnicmp()] API allows applications and extensions to | |
| 5643 | +** ^The [sqlite3_strnicmp()] API allows applications and extensions to | |
| 5759 | 5644 | ** compare the contents of two buffers containing UTF-8 strings in a |
| 5760 | 5645 | ** case-indendent fashion, using the same definition of case independence |
| 5761 | 5646 | ** that SQLite uses internally when comparing identifiers. |
| 5762 | 5647 | */ |
| 5763 | 5648 | SQLITE_API int sqlite3_strnicmp(const char *, const char *, int); |
| 5764 | 5649 |
| --- 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[5] = "28"; |
| 1615 | ** azResult[6] = "Cindy"; |
| 1616 | ** azResult[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 =, <, <=, >, or >=. 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[5] = "28"; |
| 1639 | ** azResult[6] = "Cindy"; |
| 1640 | ** azResult[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 =, <, <=, >, or >=.)^ ^(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 |