Fossil SCM
Sync with trunk.
Commit
e17d35e79627a0ab5294a5d69d9b0b2c1523bfd102b5ce9ba30e3df7c613230a
Parent
c5f1e0daea483f3…
56 files changed
+1
-1
+479
-519
+1984
-1070
+199
-153
+1
-1
+3
-3
+4
-2
+4
+1
-1
+1
-1
+7
-1
+2
-7
+11
-3
+4
-2
+1
-4
+11
+3
-2
+6
-2
+1
-1
+1
-1
+17
-7
+2
-2
+1
-1
+6
-3
+12
-4
+4
-1
+15
-2
+1
-1
+5
-3
+1
-1
+8
+53
-11
-4
+3
+4
-1
+34
-19
+4
-2
+112
-21
+82
+224
+68
+13
-7
+2
-2
+2
+2
+40
-14
+1
-1
+37
-1
+2
-2
+1
-1
+4
-4
+1
-1
+16
-18
+5
-1
+15
-11
+21
-6
~
VERSION
~
extsrc/shell.c
~
extsrc/sqlite3.c
~
extsrc/sqlite3.h
~
src/ajax.c
~
src/cgi.c
~
src/clone.c
~
src/configure.c
~
src/db.c
~
src/diff.c
~
src/diff.tcl
~
src/diffcmd.c
~
src/etag.c
~
src/forum.c
~
src/fossil.numbered-lines.js
~
src/fossil.page.forumpost.js
~
src/http.c
~
src/info.c
~
src/main.c
~
src/main.c
~
src/main.mk
~
src/manifest.c
~
src/markdown_html.c
~
src/name.c
~
src/printf.c
~
src/repolist.c
~
src/security_audit.c
~
src/setupuser.c
~
src/stat.c
~
src/tag.c
~
src/th_tcl.c
~
src/timeline.c
~
src/tkt.c
~
src/tktsetup.c
~
src/wiki.c
~
src/winfile.c
~
src/xfer.c
~
src/zip.c
~
test/link-tester.html
~
test/link-tester.js
~
test/link-tester.json
~
tools/makemake.tcl
~
win/Makefile.dmc
~
win/Makefile.mingw
~
win/Makefile.msc
~
www/changes.wiki
~
www/containers.md
~
www/customskin.md
~
www/fossil-v-git.wiki
~
www/gsoc-ideas.md
~
www/index.wiki
~
www/quickstart.wiki
~
www/reviews.wiki
~
www/signing.md
~
www/sync.wiki
~
www/th1.md
M
VERSION
+1
-1
| --- VERSION | ||
| +++ VERSION | ||
| @@ -1,1 +1,1 @@ | ||
| 1 | -2.26 | |
| 1 | +2.27 | |
| 2 | 2 |
| --- VERSION | |
| +++ VERSION | |
| @@ -1,1 +1,1 @@ | |
| 1 | 2.26 |
| 2 |
| --- VERSION | |
| +++ VERSION | |
| @@ -1,1 +1,1 @@ | |
| 1 | 2.27 |
| 2 |
+479
-519
| --- extsrc/shell.c | ||
| +++ extsrc/shell.c | ||
| @@ -1266,16 +1266,25 @@ | ||
| 1266 | 1266 | return 0x3fffffff & (int)(z2 - z); |
| 1267 | 1267 | } |
| 1268 | 1268 | |
| 1269 | 1269 | /* |
| 1270 | 1270 | ** Return the length of a string in characters. Multibyte UTF8 characters |
| 1271 | -** count as a single character. | |
| 1271 | +** count as a single character for single-width characters, or as two | |
| 1272 | +** characters for double-width characters. | |
| 1272 | 1273 | */ |
| 1273 | 1274 | static int strlenChar(const char *z){ |
| 1274 | 1275 | int n = 0; |
| 1275 | 1276 | while( *z ){ |
| 1276 | - if( (0xc0&*(z++))!=0x80 ) n++; | |
| 1277 | + if( (0x80&z[0])==0 ){ | |
| 1278 | + n++; | |
| 1279 | + z++; | |
| 1280 | + }else{ | |
| 1281 | + int u = 0; | |
| 1282 | + int len = decodeUtf8((const u8*)z, &u); | |
| 1283 | + z += len; | |
| 1284 | + n += cli_wcwidth(u); | |
| 1285 | + } | |
| 1277 | 1286 | } |
| 1278 | 1287 | return n; |
| 1279 | 1288 | } |
| 1280 | 1289 | |
| 1281 | 1290 | /* |
| @@ -1622,34 +1631,10 @@ | ||
| 1622 | 1631 | if( n>350 ) n = 350; |
| 1623 | 1632 | sqlite3_snprintf(sizeof(z), z, "%#+.*e", n, r); |
| 1624 | 1633 | sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); |
| 1625 | 1634 | } |
| 1626 | 1635 | |
| 1627 | - | |
| 1628 | -/* | |
| 1629 | -** SQL function: shell_module_schema(X) | |
| 1630 | -** | |
| 1631 | -** Return a fake schema for the table-valued function or eponymous virtual | |
| 1632 | -** table X. | |
| 1633 | -*/ | |
| 1634 | -static void shellModuleSchema( | |
| 1635 | - sqlite3_context *pCtx, | |
| 1636 | - int nVal, | |
| 1637 | - sqlite3_value **apVal | |
| 1638 | -){ | |
| 1639 | - const char *zName; | |
| 1640 | - char *zFake; | |
| 1641 | - UNUSED_PARAMETER(nVal); | |
| 1642 | - zName = (const char*)sqlite3_value_text(apVal[0]); | |
| 1643 | - zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0; | |
| 1644 | - if( zFake ){ | |
| 1645 | - sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), | |
| 1646 | - -1, sqlite3_free); | |
| 1647 | - free(zFake); | |
| 1648 | - } | |
| 1649 | -} | |
| 1650 | - | |
| 1651 | 1636 | /* |
| 1652 | 1637 | ** SQL function: shell_add_schema(S,X) |
| 1653 | 1638 | ** |
| 1654 | 1639 | ** Add the schema name X to the CREATE statement in S and return the result. |
| 1655 | 1640 | ** Examples: |
| @@ -1728,369 +1713,176 @@ | ||
| 1728 | 1713 | ** work here in the middle of this regular program. |
| 1729 | 1714 | */ |
| 1730 | 1715 | #define SQLITE_EXTENSION_INIT1 |
| 1731 | 1716 | #define SQLITE_EXTENSION_INIT2(X) (void)(X) |
| 1732 | 1717 | |
| 1733 | -#if defined(_WIN32) && defined(_MSC_VER) | |
| 1734 | -/************************* Begin test_windirent.h ******************/ | |
| 1718 | +/************************* Begin ../ext/misc/windirent.h ******************/ | |
| 1735 | 1719 | /* |
| 1736 | -** 2015 November 30 | |
| 1720 | +** 2025-06-05 | |
| 1737 | 1721 | ** |
| 1738 | 1722 | ** The author disclaims copyright to this source code. In place of |
| 1739 | 1723 | ** a legal notice, here is a blessing: |
| 1740 | 1724 | ** |
| 1741 | 1725 | ** May you do good and not evil. |
| 1742 | 1726 | ** May you find forgiveness for yourself and forgive others. |
| 1743 | 1727 | ** May you share freely, never taking more than you give. |
| 1744 | 1728 | ** |
| 1745 | 1729 | ************************************************************************* |
| 1746 | -** This file contains declarations for most of the opendir() family of | |
| 1747 | -** POSIX functions on Win32 using the MSVCRT. | |
| 1730 | +** | |
| 1731 | +** An implementation of opendir(), readdir(), and closedir() for Windows, | |
| 1732 | +** based on the FindFirstFile(), FindNextFile(), and FindClose() APIs | |
| 1733 | +** of Win32. | |
| 1734 | +** | |
| 1735 | +** #include this file inside any C-code module that needs to use | |
| 1736 | +** opendir()/readdir()/closedir(). This file is a no-op on non-Windows | |
| 1737 | +** machines. On Windows, static functions are defined that implement | |
| 1738 | +** those standard interfaces. | |
| 1748 | 1739 | */ |
| 1749 | - | |
| 1750 | 1740 | #if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H) |
| 1751 | 1741 | #define SQLITE_WINDIRENT_H |
| 1752 | 1742 | |
| 1753 | -/* | |
| 1754 | -** We need several data types from the Windows SDK header. | |
| 1755 | -*/ | |
| 1756 | - | |
| 1757 | 1743 | #ifndef WIN32_LEAN_AND_MEAN |
| 1758 | 1744 | #define WIN32_LEAN_AND_MEAN |
| 1759 | 1745 | #endif |
| 1760 | - | |
| 1761 | -#include "windows.h" | |
| 1762 | - | |
| 1763 | -/* | |
| 1764 | -** We need several support functions from the SQLite core. | |
| 1765 | -*/ | |
| 1766 | - | |
| 1767 | -/* #include "sqlite3.h" */ | |
| 1768 | - | |
| 1769 | -/* | |
| 1770 | -** We need several things from the ANSI and MSVCRT headers. | |
| 1771 | -*/ | |
| 1772 | - | |
| 1746 | +#include <windows.h> | |
| 1747 | +#include <io.h> | |
| 1773 | 1748 | #include <stdio.h> |
| 1774 | 1749 | #include <stdlib.h> |
| 1775 | 1750 | #include <errno.h> |
| 1776 | -#include <io.h> | |
| 1777 | 1751 | #include <limits.h> |
| 1778 | 1752 | #include <sys/types.h> |
| 1779 | 1753 | #include <sys/stat.h> |
| 1780 | - | |
| 1781 | -/* | |
| 1782 | -** We may need several defines that should have been in "sys/stat.h". | |
| 1783 | -*/ | |
| 1784 | - | |
| 1785 | -#ifndef S_ISREG | |
| 1786 | -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) | |
| 1787 | -#endif | |
| 1788 | - | |
| 1789 | -#ifndef S_ISDIR | |
| 1790 | -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) | |
| 1791 | -#endif | |
| 1792 | - | |
| 1793 | -#ifndef S_ISLNK | |
| 1794 | -#define S_ISLNK(mode) (0) | |
| 1795 | -#endif | |
| 1796 | - | |
| 1797 | -/* | |
| 1798 | -** We may need to provide the "mode_t" type. | |
| 1799 | -*/ | |
| 1800 | - | |
| 1801 | -#ifndef MODE_T_DEFINED | |
| 1802 | - #define MODE_T_DEFINED | |
| 1803 | - typedef unsigned short mode_t; | |
| 1804 | -#endif | |
| 1805 | - | |
| 1806 | -/* | |
| 1807 | -** We may need to provide the "ino_t" type. | |
| 1808 | -*/ | |
| 1809 | - | |
| 1810 | -#ifndef INO_T_DEFINED | |
| 1811 | - #define INO_T_DEFINED | |
| 1812 | - typedef unsigned short ino_t; | |
| 1813 | -#endif | |
| 1814 | - | |
| 1815 | -/* | |
| 1816 | -** We need to define "NAME_MAX" if it was not present in "limits.h". | |
| 1817 | -*/ | |
| 1818 | - | |
| 1819 | -#ifndef NAME_MAX | |
| 1820 | -# ifdef FILENAME_MAX | |
| 1821 | -# define NAME_MAX (FILENAME_MAX) | |
| 1822 | -# else | |
| 1823 | -# define NAME_MAX (260) | |
| 1824 | -# endif | |
| 1825 | -#endif | |
| 1826 | - | |
| 1827 | -/* | |
| 1828 | -** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T". | |
| 1829 | -*/ | |
| 1830 | - | |
| 1831 | -#ifndef NULL_INTPTR_T | |
| 1832 | -# define NULL_INTPTR_T ((intptr_t)(0)) | |
| 1833 | -#endif | |
| 1834 | - | |
| 1835 | -#ifndef BAD_INTPTR_T | |
| 1836 | -# define BAD_INTPTR_T ((intptr_t)(-1)) | |
| 1837 | -#endif | |
| 1838 | - | |
| 1839 | -/* | |
| 1840 | -** We need to provide the necessary structures and related types. | |
| 1841 | -*/ | |
| 1842 | - | |
| 1843 | -#ifndef DIRENT_DEFINED | |
| 1844 | -#define DIRENT_DEFINED | |
| 1845 | -typedef struct DIRENT DIRENT; | |
| 1846 | -typedef DIRENT *LPDIRENT; | |
| 1847 | -struct DIRENT { | |
| 1848 | - ino_t d_ino; /* Sequence number, do not use. */ | |
| 1849 | - unsigned d_attributes; /* Win32 file attributes. */ | |
| 1850 | - char d_name[NAME_MAX + 1]; /* Name within the directory. */ | |
| 1851 | -}; | |
| 1852 | -#endif | |
| 1853 | - | |
| 1854 | -#ifndef DIR_DEFINED | |
| 1855 | -#define DIR_DEFINED | |
| 1856 | -typedef struct DIR DIR; | |
| 1857 | -typedef DIR *LPDIR; | |
| 1858 | -struct DIR { | |
| 1859 | - intptr_t d_handle; /* Value returned by "_findfirst". */ | |
| 1860 | - DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ | |
| 1861 | - DIRENT d_next; /* DIRENT constructed based on "_findnext". */ | |
| 1862 | -}; | |
| 1863 | -#endif | |
| 1864 | - | |
| 1865 | -/* | |
| 1866 | -** Provide a macro, for use by the implementation, to determine if a | |
| 1867 | -** particular directory entry should be skipped over when searching for | |
| 1868 | -** the next directory entry that should be returned by the readdir() or | |
| 1869 | -** readdir_r() functions. | |
| 1870 | -*/ | |
| 1871 | - | |
| 1872 | -#ifndef is_filtered | |
| 1873 | -# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) | |
| 1874 | -#endif | |
| 1875 | - | |
| 1876 | -/* | |
| 1877 | -** Provide the function prototype for the POSIX compatible getenv() | |
| 1878 | -** function. This function is not thread-safe. | |
| 1879 | -*/ | |
| 1880 | - | |
| 1881 | -extern const char *windirent_getenv(const char *name); | |
| 1882 | - | |
| 1883 | -/* | |
| 1884 | -** Finally, we can provide the function prototypes for the opendir(), | |
| 1885 | -** readdir(), readdir_r(), and closedir() POSIX functions. | |
| 1886 | -*/ | |
| 1887 | - | |
| 1888 | -extern LPDIR opendir(const char *dirname); | |
| 1889 | -extern LPDIRENT readdir(LPDIR dirp); | |
| 1890 | -extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result); | |
| 1891 | -extern INT closedir(LPDIR dirp); | |
| 1892 | - | |
| 1893 | -#endif /* defined(WIN32) && defined(_MSC_VER) */ | |
| 1894 | - | |
| 1895 | -/************************* End test_windirent.h ********************/ | |
| 1896 | -/************************* Begin test_windirent.c ******************/ | |
| 1897 | -/* | |
| 1898 | -** 2015 November 30 | |
| 1899 | -** | |
| 1900 | -** The author disclaims copyright to this source code. In place of | |
| 1901 | -** a legal notice, here is a blessing: | |
| 1902 | -** | |
| 1903 | -** May you do good and not evil. | |
| 1904 | -** May you find forgiveness for yourself and forgive others. | |
| 1905 | -** May you share freely, never taking more than you give. | |
| 1906 | -** | |
| 1907 | -************************************************************************* | |
| 1908 | -** This file contains code to implement most of the opendir() family of | |
| 1909 | -** POSIX functions on Win32 using the MSVCRT. | |
| 1910 | -*/ | |
| 1911 | - | |
| 1912 | -#if defined(_WIN32) && defined(_MSC_VER) | |
| 1913 | -/* #include "test_windirent.h" */ | |
| 1914 | - | |
| 1915 | -/* | |
| 1916 | -** Implementation of the POSIX getenv() function using the Win32 API. | |
| 1917 | -** This function is not thread-safe. | |
| 1918 | -*/ | |
| 1919 | -const char *windirent_getenv( | |
| 1920 | - const char *name | |
| 1921 | -){ | |
| 1922 | - static char value[32768]; /* Maximum length, per MSDN */ | |
| 1923 | - DWORD dwSize = sizeof(value) / sizeof(char); /* Size in chars */ | |
| 1924 | - DWORD dwRet; /* Value returned by GetEnvironmentVariableA() */ | |
| 1925 | - | |
| 1926 | - memset(value, 0, sizeof(value)); | |
| 1927 | - dwRet = GetEnvironmentVariableA(name, value, dwSize); | |
| 1928 | - if( dwRet==0 || dwRet>dwSize ){ | |
| 1929 | - /* | |
| 1930 | - ** The function call to GetEnvironmentVariableA() failed -OR- | |
| 1931 | - ** the buffer is not large enough. Either way, return NULL. | |
| 1932 | - */ | |
| 1933 | - return 0; | |
| 1934 | - }else{ | |
| 1935 | - /* | |
| 1936 | - ** The function call to GetEnvironmentVariableA() succeeded | |
| 1937 | - ** -AND- the buffer contains the entire value. | |
| 1938 | - */ | |
| 1939 | - return value; | |
| 1940 | - } | |
| 1941 | -} | |
| 1942 | - | |
| 1943 | -/* | |
| 1944 | -** Implementation of the POSIX opendir() function using the MSVCRT. | |
| 1945 | -*/ | |
| 1946 | -LPDIR opendir( | |
| 1947 | - const char *dirname | |
| 1948 | -){ | |
| 1949 | - struct _finddata_t data; | |
| 1950 | - LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR)); | |
| 1951 | - SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]); | |
| 1952 | - | |
| 1953 | - if( dirp==NULL ) return NULL; | |
| 1954 | - memset(dirp, 0, sizeof(DIR)); | |
| 1955 | - | |
| 1956 | - /* TODO: Remove this if Unix-style root paths are not used. */ | |
| 1957 | - if( sqlite3_stricmp(dirname, "/")==0 ){ | |
| 1958 | - dirname = windirent_getenv("SystemDrive"); | |
| 1959 | - } | |
| 1960 | - | |
| 1961 | - memset(&data, 0, sizeof(struct _finddata_t)); | |
| 1962 | - _snprintf(data.name, namesize, "%s\\*", dirname); | |
| 1963 | - dirp->d_handle = _findfirst(data.name, &data); | |
| 1964 | - | |
| 1965 | - if( dirp->d_handle==BAD_INTPTR_T ){ | |
| 1966 | - closedir(dirp); | |
| 1967 | - return NULL; | |
| 1968 | - } | |
| 1969 | - | |
| 1970 | - /* TODO: Remove this block to allow hidden and/or system files. */ | |
| 1971 | - if( is_filtered(data) ){ | |
| 1972 | -next: | |
| 1973 | - | |
| 1974 | - memset(&data, 0, sizeof(struct _finddata_t)); | |
| 1975 | - if( _findnext(dirp->d_handle, &data)==-1 ){ | |
| 1976 | - closedir(dirp); | |
| 1977 | - return NULL; | |
| 1978 | - } | |
| 1979 | - | |
| 1980 | - /* TODO: Remove this block to allow hidden and/or system files. */ | |
| 1981 | - if( is_filtered(data) ) goto next; | |
| 1982 | - } | |
| 1983 | - | |
| 1984 | - dirp->d_first.d_attributes = data.attrib; | |
| 1985 | - strncpy(dirp->d_first.d_name, data.name, NAME_MAX); | |
| 1986 | - dirp->d_first.d_name[NAME_MAX] = '\0'; | |
| 1987 | - | |
| 1988 | - return dirp; | |
| 1989 | -} | |
| 1990 | - | |
| 1991 | -/* | |
| 1992 | -** Implementation of the POSIX readdir() function using the MSVCRT. | |
| 1993 | -*/ | |
| 1994 | -LPDIRENT readdir( | |
| 1995 | - LPDIR dirp | |
| 1996 | -){ | |
| 1997 | - struct _finddata_t data; | |
| 1998 | - | |
| 1999 | - if( dirp==NULL ) return NULL; | |
| 2000 | - | |
| 2001 | - if( dirp->d_first.d_ino==0 ){ | |
| 2002 | - dirp->d_first.d_ino++; | |
| 2003 | - dirp->d_next.d_ino++; | |
| 2004 | - | |
| 2005 | - return &dirp->d_first; | |
| 2006 | - } | |
| 2007 | - | |
| 2008 | -next: | |
| 2009 | - | |
| 2010 | - memset(&data, 0, sizeof(struct _finddata_t)); | |
| 2011 | - if( _findnext(dirp->d_handle, &data)==-1 ) return NULL; | |
| 2012 | - | |
| 2013 | - /* TODO: Remove this block to allow hidden and/or system files. */ | |
| 2014 | - if( is_filtered(data) ) goto next; | |
| 2015 | - | |
| 2016 | - dirp->d_next.d_ino++; | |
| 2017 | - dirp->d_next.d_attributes = data.attrib; | |
| 2018 | - strncpy(dirp->d_next.d_name, data.name, NAME_MAX); | |
| 2019 | - dirp->d_next.d_name[NAME_MAX] = '\0'; | |
| 2020 | - | |
| 2021 | - return &dirp->d_next; | |
| 2022 | -} | |
| 2023 | - | |
| 2024 | -/* | |
| 2025 | -** Implementation of the POSIX readdir_r() function using the MSVCRT. | |
| 2026 | -*/ | |
| 2027 | -INT readdir_r( | |
| 2028 | - LPDIR dirp, | |
| 2029 | - LPDIRENT entry, | |
| 2030 | - LPDIRENT *result | |
| 2031 | -){ | |
| 2032 | - struct _finddata_t data; | |
| 2033 | - | |
| 2034 | - if( dirp==NULL ) return EBADF; | |
| 2035 | - | |
| 2036 | - if( dirp->d_first.d_ino==0 ){ | |
| 2037 | - dirp->d_first.d_ino++; | |
| 2038 | - dirp->d_next.d_ino++; | |
| 2039 | - | |
| 2040 | - entry->d_ino = dirp->d_first.d_ino; | |
| 2041 | - entry->d_attributes = dirp->d_first.d_attributes; | |
| 2042 | - strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX); | |
| 2043 | - entry->d_name[NAME_MAX] = '\0'; | |
| 2044 | - | |
| 2045 | - *result = entry; | |
| 2046 | - return 0; | |
| 2047 | - } | |
| 2048 | - | |
| 2049 | -next: | |
| 2050 | - | |
| 2051 | - memset(&data, 0, sizeof(struct _finddata_t)); | |
| 2052 | - if( _findnext(dirp->d_handle, &data)==-1 ){ | |
| 2053 | - *result = NULL; | |
| 2054 | - return ENOENT; | |
| 2055 | - } | |
| 2056 | - | |
| 2057 | - /* TODO: Remove this block to allow hidden and/or system files. */ | |
| 2058 | - if( is_filtered(data) ) goto next; | |
| 2059 | - | |
| 2060 | - entry->d_ino = (ino_t)-1; /* not available */ | |
| 2061 | - entry->d_attributes = data.attrib; | |
| 2062 | - strncpy(entry->d_name, data.name, NAME_MAX); | |
| 2063 | - entry->d_name[NAME_MAX] = '\0'; | |
| 2064 | - | |
| 2065 | - *result = entry; | |
| 2066 | - return 0; | |
| 2067 | -} | |
| 2068 | - | |
| 2069 | -/* | |
| 2070 | -** Implementation of the POSIX closedir() function using the MSVCRT. | |
| 2071 | -*/ | |
| 2072 | -INT closedir( | |
| 2073 | - LPDIR dirp | |
| 2074 | -){ | |
| 2075 | - INT result = 0; | |
| 2076 | - | |
| 2077 | - if( dirp==NULL ) return EINVAL; | |
| 2078 | - | |
| 2079 | - if( dirp->d_handle!=NULL_INTPTR_T && dirp->d_handle!=BAD_INTPTR_T ){ | |
| 2080 | - result = _findclose(dirp->d_handle); | |
| 2081 | - } | |
| 2082 | - | |
| 2083 | - sqlite3_free(dirp); | |
| 2084 | - return result; | |
| 2085 | -} | |
| 2086 | - | |
| 2087 | -#endif /* defined(WIN32) && defined(_MSC_VER) */ | |
| 2088 | - | |
| 2089 | -/************************* End test_windirent.c ********************/ | |
| 2090 | -#define dirent DIRENT | |
| 2091 | -#endif | |
| 1754 | +#include <string.h> | |
| 1755 | +#ifndef FILENAME_MAX | |
| 1756 | +# define FILENAME_MAX (260) | |
| 1757 | +#endif | |
| 1758 | +#ifndef S_ISREG | |
| 1759 | +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) | |
| 1760 | +#endif | |
| 1761 | +#ifndef S_ISDIR | |
| 1762 | +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) | |
| 1763 | +#endif | |
| 1764 | +#ifndef S_ISLNK | |
| 1765 | +#define S_ISLNK(m) (0) | |
| 1766 | +#endif | |
| 1767 | +typedef unsigned short mode_t; | |
| 1768 | + | |
| 1769 | +/* The dirent object for Windows is abbreviated. The only field really | |
| 1770 | +** usable by applications is d_name[]. | |
| 1771 | +*/ | |
| 1772 | +struct dirent { | |
| 1773 | + int d_ino; /* Inode number (synthesized) */ | |
| 1774 | + unsigned d_attributes; /* File attributes */ | |
| 1775 | + char d_name[FILENAME_MAX]; /* Null-terminated filename */ | |
| 1776 | +}; | |
| 1777 | + | |
| 1778 | +/* The internals of DIR are opaque according to standards. So it | |
| 1779 | +** does not matter what we put here. */ | |
| 1780 | +typedef struct DIR DIR; | |
| 1781 | +struct DIR { | |
| 1782 | + intptr_t d_handle; /* Handle for findfirst()/findnext() */ | |
| 1783 | + struct dirent cur; /* Current entry */ | |
| 1784 | +}; | |
| 1785 | + | |
| 1786 | +/* Ignore hidden and system files */ | |
| 1787 | +#define WindowsFileToIgnore(a) \ | |
| 1788 | + ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) | |
| 1789 | + | |
| 1790 | +/* | |
| 1791 | +** Close a previously opened directory | |
| 1792 | +*/ | |
| 1793 | +static int closedir(DIR *pDir){ | |
| 1794 | + int rc = 0; | |
| 1795 | + if( pDir==0 ){ | |
| 1796 | + return EINVAL; | |
| 1797 | + } | |
| 1798 | + if( pDir->d_handle!=0 && pDir->d_handle!=(-1) ){ | |
| 1799 | + rc = _findclose(pDir->d_handle); | |
| 1800 | + } | |
| 1801 | + sqlite3_free(pDir); | |
| 1802 | + return rc; | |
| 1803 | +} | |
| 1804 | + | |
| 1805 | +/* | |
| 1806 | +** Open a new directory. The directory name should be UTF-8 encoded. | |
| 1807 | +** appropriate translations happen automatically. | |
| 1808 | +*/ | |
| 1809 | +static DIR *opendir(const char *zDirName){ | |
| 1810 | + DIR *pDir; | |
| 1811 | + wchar_t *b1; | |
| 1812 | + sqlite3_int64 sz; | |
| 1813 | + struct _wfinddata_t data; | |
| 1814 | + | |
| 1815 | + pDir = sqlite3_malloc64( sizeof(DIR) ); | |
| 1816 | + if( pDir==0 ) return 0; | |
| 1817 | + memset(pDir, 0, sizeof(DIR)); | |
| 1818 | + memset(&data, 0, sizeof(data)); | |
| 1819 | + sz = strlen(zDirName); | |
| 1820 | + b1 = sqlite3_malloc64( (sz+3)*sizeof(b1[0]) ); | |
| 1821 | + if( b1==0 ){ | |
| 1822 | + closedir(pDir); | |
| 1823 | + return NULL; | |
| 1824 | + } | |
| 1825 | + sz = MultiByteToWideChar(CP_UTF8, 0, zDirName, sz, b1, sz); | |
| 1826 | + b1[sz++] = '\\'; | |
| 1827 | + b1[sz++] = '*'; | |
| 1828 | + b1[sz] = 0; | |
| 1829 | + if( sz+1>sizeof(data.name)/sizeof(data.name[0]) ){ | |
| 1830 | + closedir(pDir); | |
| 1831 | + sqlite3_free(b1); | |
| 1832 | + return NULL; | |
| 1833 | + } | |
| 1834 | + memcpy(data.name, b1, (sz+1)*sizeof(b1[0])); | |
| 1835 | + sqlite3_free(b1); | |
| 1836 | + pDir->d_handle = _wfindfirst(data.name, &data); | |
| 1837 | + if( pDir->d_handle<0 ){ | |
| 1838 | + closedir(pDir); | |
| 1839 | + return NULL; | |
| 1840 | + } | |
| 1841 | + while( WindowsFileToIgnore(data) ){ | |
| 1842 | + memset(&data, 0, sizeof(data)); | |
| 1843 | + if( _wfindnext(pDir->d_handle, &data)==-1 ){ | |
| 1844 | + closedir(pDir); | |
| 1845 | + return NULL; | |
| 1846 | + } | |
| 1847 | + } | |
| 1848 | + pDir->cur.d_ino = 0; | |
| 1849 | + pDir->cur.d_attributes = data.attrib; | |
| 1850 | + WideCharToMultiByte(CP_UTF8, 0, data.name, -1, | |
| 1851 | + pDir->cur.d_name, FILENAME_MAX, 0, 0); | |
| 1852 | + return pDir; | |
| 1853 | +} | |
| 1854 | + | |
| 1855 | +/* | |
| 1856 | +** Read the next entry from a directory. | |
| 1857 | +** | |
| 1858 | +** The returned struct-dirent object is managed by DIR. It is only | |
| 1859 | +** valid until the next readdir() or closedir() call. Only the | |
| 1860 | +** d_name[] field is meaningful. The d_name[] value has been | |
| 1861 | +** translated into UTF8. | |
| 1862 | +*/ | |
| 1863 | +static struct dirent *readdir(DIR *pDir){ | |
| 1864 | + struct _wfinddata_t data; | |
| 1865 | + if( pDir==0 ) return 0; | |
| 1866 | + if( (pDir->cur.d_ino++)==0 ){ | |
| 1867 | + return &pDir->cur; | |
| 1868 | + } | |
| 1869 | + do{ | |
| 1870 | + memset(&data, 0, sizeof(data)); | |
| 1871 | + if( _wfindnext(pDir->d_handle, &data)==-1 ){ | |
| 1872 | + return NULL; | |
| 1873 | + } | |
| 1874 | + }while( WindowsFileToIgnore(data) ); | |
| 1875 | + pDir->cur.d_attributes = data.attrib; | |
| 1876 | + WideCharToMultiByte(CP_UTF8, 0, data.name, -1, | |
| 1877 | + pDir->cur.d_name, FILENAME_MAX, 0, 0); | |
| 1878 | + return &pDir->cur; | |
| 1879 | +} | |
| 1880 | + | |
| 1881 | +#endif /* defined(_WIN32) && defined(_MSC_VER) */ | |
| 1882 | + | |
| 1883 | +/************************* End ../ext/misc/windirent.h ********************/ | |
| 2092 | 1884 | /************************* Begin ../ext/misc/memtrace.c ******************/ |
| 2093 | 1885 | /* |
| 2094 | 1886 | ** 2019-01-21 |
| 2095 | 1887 | ** |
| 2096 | 1888 | ** The author disclaims copyright to this source code. In place of |
| @@ -8054,10 +7846,11 @@ | ||
| 8054 | 7846 | ** mode: Value of stat.st_mode for directory entry (an integer). |
| 8055 | 7847 | ** mtime: Value of stat.st_mtime for directory entry (an integer). |
| 8056 | 7848 | ** data: For a regular file, a blob containing the file data. For a |
| 8057 | 7849 | ** symlink, a text value containing the text of the link. For a |
| 8058 | 7850 | ** directory, NULL. |
| 7851 | +** level: Directory hierarchy level. Topmost is 1. | |
| 8059 | 7852 | ** |
| 8060 | 7853 | ** If a non-NULL value is specified for the optional $dir parameter and |
| 8061 | 7854 | ** $path is a relative path, then $path is interpreted relative to $dir. |
| 8062 | 7855 | ** And the paths returned in the "name" column of the table are also |
| 8063 | 7856 | ** relative to directory $dir. |
| @@ -8079,24 +7872,17 @@ | ||
| 8079 | 7872 | #if !defined(_WIN32) && !defined(WIN32) |
| 8080 | 7873 | # include <unistd.h> |
| 8081 | 7874 | # include <dirent.h> |
| 8082 | 7875 | # include <utime.h> |
| 8083 | 7876 | # include <sys/time.h> |
| 7877 | +# define STRUCT_STAT struct stat | |
| 8084 | 7878 | #else |
| 8085 | -# include "windows.h" | |
| 8086 | -# include <io.h> | |
| 7879 | +/* # include "windirent.h" */ | |
| 8087 | 7880 | # include <direct.h> |
| 8088 | -/* # include "test_windirent.h" */ | |
| 8089 | -# define dirent DIRENT | |
| 8090 | -# ifndef chmod | |
| 8091 | -# define chmod _chmod | |
| 8092 | -# endif | |
| 8093 | -# ifndef stat | |
| 8094 | -# define stat _stat | |
| 8095 | -# endif | |
| 8096 | -# define mkdir(path,mode) _mkdir(path) | |
| 8097 | -# define lstat(path,buf) stat(path,buf) | |
| 7881 | +# define STRUCT_STAT struct _stat | |
| 7882 | +# define chmod(path,mode) fileio_chmod(path,mode) | |
| 7883 | +# define mkdir(path,mode) fileio_mkdir(path) | |
| 8098 | 7884 | #endif |
| 8099 | 7885 | #include <time.h> |
| 8100 | 7886 | #include <errno.h> |
| 8101 | 7887 | |
| 8102 | 7888 | /* When used as part of the CLI, the sqlite3_stdio.h module will have |
| @@ -8108,18 +7894,54 @@ | ||
| 8108 | 7894 | #endif |
| 8109 | 7895 | |
| 8110 | 7896 | /* |
| 8111 | 7897 | ** Structure of the fsdir() table-valued function |
| 8112 | 7898 | */ |
| 8113 | - /* 0 1 2 3 4 5 */ | |
| 8114 | -#define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" | |
| 7899 | + /* 0 1 2 3 4 5 6 */ | |
| 7900 | +#define FSDIR_SCHEMA "(name,mode,mtime,data,level,path HIDDEN,dir HIDDEN)" | |
| 7901 | + | |
| 8115 | 7902 | #define FSDIR_COLUMN_NAME 0 /* Name of the file */ |
| 8116 | 7903 | #define FSDIR_COLUMN_MODE 1 /* Access mode */ |
| 8117 | 7904 | #define FSDIR_COLUMN_MTIME 2 /* Last modification time */ |
| 8118 | 7905 | #define FSDIR_COLUMN_DATA 3 /* File content */ |
| 8119 | -#define FSDIR_COLUMN_PATH 4 /* Path to top of search */ | |
| 8120 | -#define FSDIR_COLUMN_DIR 5 /* Path is relative to this directory */ | |
| 7906 | +#define FSDIR_COLUMN_LEVEL 4 /* Level. Topmost is 1 */ | |
| 7907 | +#define FSDIR_COLUMN_PATH 5 /* Path to top of search */ | |
| 7908 | +#define FSDIR_COLUMN_DIR 6 /* Path is relative to this directory */ | |
| 7909 | + | |
| 7910 | +/* | |
| 7911 | +** UTF8 chmod() function for Windows | |
| 7912 | +*/ | |
| 7913 | +#if defined(_WIN32) || defined(WIN32) | |
| 7914 | +static int fileio_chmod(const char *zPath, int pmode){ | |
| 7915 | + sqlite3_int64 sz = strlen(zPath); | |
| 7916 | + wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); | |
| 7917 | + int rc; | |
| 7918 | + if( b1==0 ) return -1; | |
| 7919 | + sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); | |
| 7920 | + b1[sz] = 0; | |
| 7921 | + rc = _wchmod(b1, pmode); | |
| 7922 | + sqlite3_free(b1); | |
| 7923 | + return rc; | |
| 7924 | +} | |
| 7925 | +#endif | |
| 7926 | + | |
| 7927 | +/* | |
| 7928 | +** UTF8 mkdir() function for Windows | |
| 7929 | +*/ | |
| 7930 | +#if defined(_WIN32) || defined(WIN32) | |
| 7931 | +static int fileio_mkdir(const char *zPath){ | |
| 7932 | + sqlite3_int64 sz = strlen(zPath); | |
| 7933 | + wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); | |
| 7934 | + int rc; | |
| 7935 | + if( b1==0 ) return -1; | |
| 7936 | + sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); | |
| 7937 | + b1[sz] = 0; | |
| 7938 | + rc = _wmkdir(b1); | |
| 7939 | + sqlite3_free(b1); | |
| 7940 | + return rc; | |
| 7941 | +} | |
| 7942 | +#endif | |
| 8121 | 7943 | |
| 8122 | 7944 | |
| 8123 | 7945 | /* |
| 8124 | 7946 | ** Set the result stored by context ctx to a blob containing the |
| 8125 | 7947 | ** contents of file zName. Or, leave the result unchanged (NULL) |
| @@ -8247,11 +8069,11 @@ | ||
| 8247 | 8069 | ** buffer to UTC. This is necessary on Win32, where the runtime library |
| 8248 | 8070 | ** appears to return these values as local times. |
| 8249 | 8071 | */ |
| 8250 | 8072 | static void statTimesToUtc( |
| 8251 | 8073 | const char *zPath, |
| 8252 | - struct stat *pStatBuf | |
| 8074 | + STRUCT_STAT *pStatBuf | |
| 8253 | 8075 | ){ |
| 8254 | 8076 | HANDLE hFindFile; |
| 8255 | 8077 | WIN32_FIND_DATAW fd; |
| 8256 | 8078 | LPWSTR zUnicodeName; |
| 8257 | 8079 | extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*); |
| @@ -8275,14 +8097,20 @@ | ||
| 8275 | 8097 | ** is required in order for the included time to be returned as UTC. On all |
| 8276 | 8098 | ** other systems, this function simply calls stat(). |
| 8277 | 8099 | */ |
| 8278 | 8100 | static int fileStat( |
| 8279 | 8101 | const char *zPath, |
| 8280 | - struct stat *pStatBuf | |
| 8102 | + STRUCT_STAT *pStatBuf | |
| 8281 | 8103 | ){ |
| 8282 | 8104 | #if defined(_WIN32) |
| 8283 | - int rc = stat(zPath, pStatBuf); | |
| 8105 | + sqlite3_int64 sz = strlen(zPath); | |
| 8106 | + wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); | |
| 8107 | + int rc; | |
| 8108 | + if( b1==0 ) return 1; | |
| 8109 | + sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); | |
| 8110 | + b1[sz] = 0; | |
| 8111 | + rc = _wstat(b1, pStatBuf); | |
| 8284 | 8112 | if( rc==0 ) statTimesToUtc(zPath, pStatBuf); |
| 8285 | 8113 | return rc; |
| 8286 | 8114 | #else |
| 8287 | 8115 | return stat(zPath, pStatBuf); |
| 8288 | 8116 | #endif |
| @@ -8293,16 +8121,14 @@ | ||
| 8293 | 8121 | ** is required in order for the included time to be returned as UTC. On all |
| 8294 | 8122 | ** other systems, this function simply calls lstat(). |
| 8295 | 8123 | */ |
| 8296 | 8124 | static int fileLinkStat( |
| 8297 | 8125 | const char *zPath, |
| 8298 | - struct stat *pStatBuf | |
| 8126 | + STRUCT_STAT *pStatBuf | |
| 8299 | 8127 | ){ |
| 8300 | 8128 | #if defined(_WIN32) |
| 8301 | - int rc = lstat(zPath, pStatBuf); | |
| 8302 | - if( rc==0 ) statTimesToUtc(zPath, pStatBuf); | |
| 8303 | - return rc; | |
| 8129 | + return fileStat(zPath, pStatBuf); | |
| 8304 | 8130 | #else |
| 8305 | 8131 | return lstat(zPath, pStatBuf); |
| 8306 | 8132 | #endif |
| 8307 | 8133 | } |
| 8308 | 8134 | |
| @@ -8328,11 +8154,11 @@ | ||
| 8328 | 8154 | }else{ |
| 8329 | 8155 | int nCopy = (int)strlen(zCopy); |
| 8330 | 8156 | int i = 1; |
| 8331 | 8157 | |
| 8332 | 8158 | while( rc==SQLITE_OK ){ |
| 8333 | - struct stat sStat; | |
| 8159 | + STRUCT_STAT sStat; | |
| 8334 | 8160 | int rc2; |
| 8335 | 8161 | |
| 8336 | 8162 | for(; zCopy[i]!='/' && i<nCopy; i++); |
| 8337 | 8163 | if( i==nCopy ) break; |
| 8338 | 8164 | zCopy[i] = '\0'; |
| @@ -8378,11 +8204,11 @@ | ||
| 8378 | 8204 | if( mkdir(zFile, mode) ){ |
| 8379 | 8205 | /* The mkdir() call to create the directory failed. This might not |
| 8380 | 8206 | ** be an error though - if there is already a directory at the same |
| 8381 | 8207 | ** path and either the permissions already match or can be changed |
| 8382 | 8208 | ** to do so using chmod(), it is not an error. */ |
| 8383 | - struct stat sStat; | |
| 8209 | + STRUCT_STAT sStat; | |
| 8384 | 8210 | if( errno!=EEXIST |
| 8385 | 8211 | || 0!=fileStat(zFile, &sStat) |
| 8386 | 8212 | || !S_ISDIR(sStat.st_mode) |
| 8387 | 8213 | || ((sStat.st_mode&0777)!=(mode&0777) && 0!=chmod(zFile, mode&0777)) |
| 8388 | 8214 | ){ |
| @@ -8574,17 +8400,18 @@ | ||
| 8574 | 8400 | |
| 8575 | 8401 | struct fsdir_cursor { |
| 8576 | 8402 | sqlite3_vtab_cursor base; /* Base class - must be first */ |
| 8577 | 8403 | |
| 8578 | 8404 | int nLvl; /* Number of entries in aLvl[] array */ |
| 8405 | + int mxLvl; /* Maximum level */ | |
| 8579 | 8406 | int iLvl; /* Index of current entry */ |
| 8580 | 8407 | FsdirLevel *aLvl; /* Hierarchy of directories being traversed */ |
| 8581 | 8408 | |
| 8582 | 8409 | const char *zBase; |
| 8583 | 8410 | int nBase; |
| 8584 | 8411 | |
| 8585 | - struct stat sStat; /* Current lstat() results */ | |
| 8412 | + STRUCT_STAT sStat; /* Current lstat() results */ | |
| 8586 | 8413 | char *zPath; /* Path to current entry */ |
| 8587 | 8414 | sqlite3_int64 iRowid; /* Current rowid */ |
| 8588 | 8415 | }; |
| 8589 | 8416 | |
| 8590 | 8417 | typedef struct fsdir_tab fsdir_tab; |
| @@ -8692,11 +8519,11 @@ | ||
| 8692 | 8519 | static int fsdirNext(sqlite3_vtab_cursor *cur){ |
| 8693 | 8520 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8694 | 8521 | mode_t m = pCur->sStat.st_mode; |
| 8695 | 8522 | |
| 8696 | 8523 | pCur->iRowid++; |
| 8697 | - if( S_ISDIR(m) ){ | |
| 8524 | + if( S_ISDIR(m) && pCur->iLvl+3<pCur->mxLvl ){ | |
| 8698 | 8525 | /* Descend into this directory */ |
| 8699 | 8526 | int iNew = pCur->iLvl + 1; |
| 8700 | 8527 | FsdirLevel *pLvl; |
| 8701 | 8528 | if( iNew>=pCur->nLvl ){ |
| 8702 | 8529 | int nNew = iNew+1; |
| @@ -8800,11 +8627,15 @@ | ||
| 8800 | 8627 | if( aBuf!=aStatic ) sqlite3_free(aBuf); |
| 8801 | 8628 | #endif |
| 8802 | 8629 | }else{ |
| 8803 | 8630 | readFileContents(ctx, pCur->zPath); |
| 8804 | 8631 | } |
| 8632 | + break; | |
| 8805 | 8633 | } |
| 8634 | + case FSDIR_COLUMN_LEVEL: | |
| 8635 | + sqlite3_result_int(ctx, pCur->iLvl+2); | |
| 8636 | + break; | |
| 8806 | 8637 | case FSDIR_COLUMN_PATH: |
| 8807 | 8638 | default: { |
| 8808 | 8639 | /* The FSDIR_COLUMN_PATH and FSDIR_COLUMN_DIR are input parameters. |
| 8809 | 8640 | ** always return their values as NULL */ |
| 8810 | 8641 | break; |
| @@ -8834,36 +8665,50 @@ | ||
| 8834 | 8665 | } |
| 8835 | 8666 | |
| 8836 | 8667 | /* |
| 8837 | 8668 | ** xFilter callback. |
| 8838 | 8669 | ** |
| 8839 | -** idxNum==1 PATH parameter only | |
| 8840 | -** idxNum==2 Both PATH and DIR supplied | |
| 8670 | +** idxNum bit Meaning | |
| 8671 | +** 0x01 PATH=N | |
| 8672 | +** 0x02 DIR=N | |
| 8673 | +** 0x04 LEVEL<N | |
| 8674 | +** 0x08 LEVEL<=N | |
| 8841 | 8675 | */ |
| 8842 | 8676 | static int fsdirFilter( |
| 8843 | 8677 | sqlite3_vtab_cursor *cur, |
| 8844 | 8678 | int idxNum, const char *idxStr, |
| 8845 | 8679 | int argc, sqlite3_value **argv |
| 8846 | 8680 | ){ |
| 8847 | 8681 | const char *zDir = 0; |
| 8848 | 8682 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8683 | + int i; | |
| 8849 | 8684 | (void)idxStr; |
| 8850 | 8685 | fsdirResetCursor(pCur); |
| 8851 | 8686 | |
| 8852 | 8687 | if( idxNum==0 ){ |
| 8853 | 8688 | fsdirSetErrmsg(pCur, "table function fsdir requires an argument"); |
| 8854 | 8689 | return SQLITE_ERROR; |
| 8855 | 8690 | } |
| 8856 | 8691 | |
| 8857 | - assert( argc==idxNum && (argc==1 || argc==2) ); | |
| 8692 | + assert( (idxNum & 0x01)!=0 && argc>0 ); | |
| 8858 | 8693 | zDir = (const char*)sqlite3_value_text(argv[0]); |
| 8859 | 8694 | if( zDir==0 ){ |
| 8860 | 8695 | fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument"); |
| 8861 | 8696 | return SQLITE_ERROR; |
| 8862 | 8697 | } |
| 8863 | - if( argc==2 ){ | |
| 8864 | - pCur->zBase = (const char*)sqlite3_value_text(argv[1]); | |
| 8698 | + i = 1; | |
| 8699 | + if( (idxNum & 0x02)!=0 ){ | |
| 8700 | + assert( argc>i ); | |
| 8701 | + pCur->zBase = (const char*)sqlite3_value_text(argv[i++]); | |
| 8702 | + } | |
| 8703 | + if( (idxNum & 0x0c)!=0 ){ | |
| 8704 | + assert( argc>i ); | |
| 8705 | + pCur->mxLvl = sqlite3_value_int(argv[i++]); | |
| 8706 | + if( idxNum & 0x08 ) pCur->mxLvl++; | |
| 8707 | + if( pCur->mxLvl<=0 ) pCur->mxLvl = 1000000000; | |
| 8708 | + }else{ | |
| 8709 | + pCur->mxLvl = 1000000000; | |
| 8865 | 8710 | } |
| 8866 | 8711 | if( pCur->zBase ){ |
| 8867 | 8712 | pCur->nBase = (int)strlen(pCur->zBase)+1; |
| 8868 | 8713 | pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir); |
| 8869 | 8714 | }else{ |
| @@ -8888,48 +8733,75 @@ | ||
| 8888 | 8733 | ** plan. |
| 8889 | 8734 | ** |
| 8890 | 8735 | ** In this implementation idxNum is used to represent the |
| 8891 | 8736 | ** query plan. idxStr is unused. |
| 8892 | 8737 | ** |
| 8893 | -** The query plan is represented by values of idxNum: | |
| 8738 | +** The query plan is represented by bits in idxNum: | |
| 8894 | 8739 | ** |
| 8895 | -** (1) The path value is supplied by argv[0] | |
| 8896 | -** (2) Path is in argv[0] and dir is in argv[1] | |
| 8740 | +** 0x01 The path value is supplied by argv[0] | |
| 8741 | +** 0x02 dir is in argv[1] | |
| 8742 | +** 0x04 maxdepth is in argv[1] or [2] | |
| 8897 | 8743 | */ |
| 8898 | 8744 | static int fsdirBestIndex( |
| 8899 | 8745 | sqlite3_vtab *tab, |
| 8900 | 8746 | sqlite3_index_info *pIdxInfo |
| 8901 | 8747 | ){ |
| 8902 | 8748 | int i; /* Loop over constraints */ |
| 8903 | 8749 | int idxPath = -1; /* Index in pIdxInfo->aConstraint of PATH= */ |
| 8904 | 8750 | int idxDir = -1; /* Index in pIdxInfo->aConstraint of DIR= */ |
| 8751 | + int idxLevel = -1; /* Index in pIdxInfo->aConstraint of LEVEL< or <= */ | |
| 8752 | + int idxLevelEQ = 0; /* 0x08 for LEVEL<= or LEVEL=. 0x04 for LEVEL< */ | |
| 8753 | + int omitLevel = 0; /* omit the LEVEL constraint */ | |
| 8905 | 8754 | int seenPath = 0; /* True if an unusable PATH= constraint is seen */ |
| 8906 | 8755 | int seenDir = 0; /* True if an unusable DIR= constraint is seen */ |
| 8907 | 8756 | const struct sqlite3_index_constraint *pConstraint; |
| 8908 | 8757 | |
| 8909 | 8758 | (void)tab; |
| 8910 | 8759 | pConstraint = pIdxInfo->aConstraint; |
| 8911 | 8760 | for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ |
| 8912 | - if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; | |
| 8913 | - switch( pConstraint->iColumn ){ | |
| 8914 | - case FSDIR_COLUMN_PATH: { | |
| 8915 | - if( pConstraint->usable ){ | |
| 8916 | - idxPath = i; | |
| 8917 | - seenPath = 0; | |
| 8918 | - }else if( idxPath<0 ){ | |
| 8919 | - seenPath = 1; | |
| 8920 | - } | |
| 8921 | - break; | |
| 8922 | - } | |
| 8923 | - case FSDIR_COLUMN_DIR: { | |
| 8924 | - if( pConstraint->usable ){ | |
| 8925 | - idxDir = i; | |
| 8926 | - seenDir = 0; | |
| 8927 | - }else if( idxDir<0 ){ | |
| 8928 | - seenDir = 1; | |
| 8929 | - } | |
| 8930 | - break; | |
| 8761 | + if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ | |
| 8762 | + switch( pConstraint->iColumn ){ | |
| 8763 | + case FSDIR_COLUMN_PATH: { | |
| 8764 | + if( pConstraint->usable ){ | |
| 8765 | + idxPath = i; | |
| 8766 | + seenPath = 0; | |
| 8767 | + }else if( idxPath<0 ){ | |
| 8768 | + seenPath = 1; | |
| 8769 | + } | |
| 8770 | + break; | |
| 8771 | + } | |
| 8772 | + case FSDIR_COLUMN_DIR: { | |
| 8773 | + if( pConstraint->usable ){ | |
| 8774 | + idxDir = i; | |
| 8775 | + seenDir = 0; | |
| 8776 | + }else if( idxDir<0 ){ | |
| 8777 | + seenDir = 1; | |
| 8778 | + } | |
| 8779 | + break; | |
| 8780 | + } | |
| 8781 | + case FSDIR_COLUMN_LEVEL: { | |
| 8782 | + if( pConstraint->usable && idxLevel<0 ){ | |
| 8783 | + idxLevel = i; | |
| 8784 | + idxLevelEQ = 0x08; | |
| 8785 | + omitLevel = 0; | |
| 8786 | + } | |
| 8787 | + break; | |
| 8788 | + } | |
| 8789 | + } | |
| 8790 | + }else | |
| 8791 | + if( pConstraint->iColumn==FSDIR_COLUMN_LEVEL | |
| 8792 | + && pConstraint->usable | |
| 8793 | + && idxLevel<0 | |
| 8794 | + ){ | |
| 8795 | + if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE ){ | |
| 8796 | + idxLevel = i; | |
| 8797 | + idxLevelEQ = 0x08; | |
| 8798 | + omitLevel = 1; | |
| 8799 | + }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ){ | |
| 8800 | + idxLevel = i; | |
| 8801 | + idxLevelEQ = 0x04; | |
| 8802 | + omitLevel = 1; | |
| 8931 | 8803 | } |
| 8932 | 8804 | } |
| 8933 | 8805 | } |
| 8934 | 8806 | if( seenPath || seenDir ){ |
| 8935 | 8807 | /* If input parameters are unusable, disallow this plan */ |
| @@ -8942,18 +8814,24 @@ | ||
| 8942 | 8814 | ** number. Leave it unchanged. */ |
| 8943 | 8815 | pIdxInfo->estimatedRows = 0x7fffffff; |
| 8944 | 8816 | }else{ |
| 8945 | 8817 | pIdxInfo->aConstraintUsage[idxPath].omit = 1; |
| 8946 | 8818 | pIdxInfo->aConstraintUsage[idxPath].argvIndex = 1; |
| 8819 | + pIdxInfo->idxNum = 0x01; | |
| 8820 | + pIdxInfo->estimatedCost = 1.0e9; | |
| 8821 | + i = 2; | |
| 8947 | 8822 | if( idxDir>=0 ){ |
| 8948 | 8823 | pIdxInfo->aConstraintUsage[idxDir].omit = 1; |
| 8949 | - pIdxInfo->aConstraintUsage[idxDir].argvIndex = 2; | |
| 8950 | - pIdxInfo->idxNum = 2; | |
| 8951 | - pIdxInfo->estimatedCost = 10.0; | |
| 8952 | - }else{ | |
| 8953 | - pIdxInfo->idxNum = 1; | |
| 8954 | - pIdxInfo->estimatedCost = 100.0; | |
| 8824 | + pIdxInfo->aConstraintUsage[idxDir].argvIndex = i++; | |
| 8825 | + pIdxInfo->idxNum |= 0x02; | |
| 8826 | + pIdxInfo->estimatedCost /= 1.0e4; | |
| 8827 | + } | |
| 8828 | + if( idxLevel>=0 ){ | |
| 8829 | + pIdxInfo->aConstraintUsage[idxLevel].omit = omitLevel; | |
| 8830 | + pIdxInfo->aConstraintUsage[idxLevel].argvIndex = i++; | |
| 8831 | + pIdxInfo->idxNum |= idxLevelEQ; | |
| 8832 | + pIdxInfo->estimatedCost /= 1.0e4; | |
| 8955 | 8833 | } |
| 8956 | 8834 | } |
| 8957 | 8835 | |
| 8958 | 8836 | return SQLITE_OK; |
| 8959 | 8837 | } |
| @@ -16808,11 +16686,11 @@ | ||
| 16808 | 16686 | case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break; |
| 16809 | 16687 | case SQLITE_FCNTL_PRAGMA: { |
| 16810 | 16688 | const char *const* a = (const char*const*)pArg; |
| 16811 | 16689 | if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){ |
| 16812 | 16690 | const u8 *zArg = (const u8*)a[2]; |
| 16813 | - if( zArg[0]>='0' && zArg[0]<=9 ){ | |
| 16691 | + if( zArg[0]>='0' && zArg[0]<='9' ){ | |
| 16814 | 16692 | pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0); |
| 16815 | 16693 | }else{ |
| 16816 | 16694 | static const struct { |
| 16817 | 16695 | const char *z; |
| 16818 | 16696 | unsigned int m; |
| @@ -18709,10 +18587,13 @@ | ||
| 18709 | 18587 | rc = sqlite3_create_module(db, "sqlite_dbptr", &dbdata_module, (void*)1); |
| 18710 | 18588 | } |
| 18711 | 18589 | return rc; |
| 18712 | 18590 | } |
| 18713 | 18591 | |
| 18592 | +#ifdef _WIN32 | |
| 18593 | + | |
| 18594 | +#endif | |
| 18714 | 18595 | int sqlite3_dbdata_init( |
| 18715 | 18596 | sqlite3 *db, |
| 18716 | 18597 | char **pzErrMsg, |
| 18717 | 18598 | const sqlite3_api_routines *pApi |
| 18718 | 18599 | ){ |
| @@ -25592,107 +25473,108 @@ | ||
| 25592 | 25473 | " --plain Show results as text/plain, not as HTML", |
| 25593 | 25474 | #endif |
| 25594 | 25475 | }; |
| 25595 | 25476 | |
| 25596 | 25477 | /* |
| 25597 | -** Output help text. | |
| 25478 | +** Output help text for commands that match zPattern. | |
| 25479 | +** | |
| 25480 | +** * If zPattern is NULL, then show all documented commands, but | |
| 25481 | +** only give a one-line summary of each. | |
| 25482 | +** | |
| 25483 | +** * If zPattern is "-a" or "-all" or "--all" then show all help text | |
| 25484 | +** for all commands except undocumented commands. | |
| 25485 | +** | |
| 25486 | +** * If zPattern is "0" then show all help for undocumented commands. | |
| 25487 | +** Undocumented commands begin with "," instead of "." in the azHelp[] | |
| 25488 | +** array. | |
| 25489 | +** | |
| 25490 | +** * If zPattern is a prefix for one or more documented commands, then | |
| 25491 | +** show help for those commands. If only a single command matches the | |
| 25492 | +** prefix, show the full text of the help. If multiple commands match, | |
| 25493 | +** Only show just the first line of each. | |
| 25598 | 25494 | ** |
| 25599 | -** zPattern describes the set of commands for which help text is provided. | |
| 25600 | -** If zPattern is NULL, then show all commands, but only give a one-line | |
| 25601 | -** description of each. | |
| 25495 | +** * Otherwise, show the complete text of any documented command for which | |
| 25496 | +** zPattern is a LIKE match for any text within that command help | |
| 25497 | +** text. | |
| 25602 | 25498 | ** |
| 25603 | -** Return the number of matches. | |
| 25499 | +** Return the number commands that match zPattern. | |
| 25604 | 25500 | */ |
| 25605 | 25501 | static int showHelp(FILE *out, const char *zPattern){ |
| 25606 | 25502 | int i = 0; |
| 25607 | 25503 | int j = 0; |
| 25608 | 25504 | int n = 0; |
| 25609 | 25505 | char *zPat; |
| 25610 | - if( zPattern==0 | |
| 25611 | - || zPattern[0]=='0' | |
| 25612 | - || cli_strcmp(zPattern,"-a")==0 | |
| 25613 | - || cli_strcmp(zPattern,"-all")==0 | |
| 25614 | - || cli_strcmp(zPattern,"--all")==0 | |
| 25615 | - ){ | |
| 25616 | - enum HelpWanted { HW_NoCull = 0, HW_SummaryOnly = 1, HW_Undoc = 2 }; | |
| 25617 | - enum HelpHave { HH_Undoc = 2, HH_Summary = 1, HH_More = 0 }; | |
| 25618 | - /* Show all or most commands | |
| 25619 | - ** *zPattern==0 => summary of documented commands only | |
| 25620 | - ** *zPattern=='0' => whole help for undocumented commands | |
| 25621 | - ** Otherwise => whole help for documented commands | |
| 25622 | - */ | |
| 25623 | - enum HelpWanted hw = HW_SummaryOnly; | |
| 25624 | - enum HelpHave hh = HH_More; | |
| 25625 | - if( zPattern!=0 ){ | |
| 25626 | - hw = (*zPattern=='0')? HW_NoCull|HW_Undoc : HW_NoCull; | |
| 25627 | - } | |
| 25628 | - for(i=0; i<ArraySize(azHelp); i++){ | |
| 25629 | - switch( azHelp[i][0] ){ | |
| 25630 | - case ',': | |
| 25631 | - hh = HH_Summary|HH_Undoc; | |
| 25632 | - break; | |
| 25633 | - case '.': | |
| 25634 | - hh = HH_Summary; | |
| 25635 | - break; | |
| 25636 | - default: | |
| 25637 | - hh &= ~HH_Summary; | |
| 25638 | - break; | |
| 25639 | - } | |
| 25640 | - if( ((hw^hh)&HH_Undoc)==0 ){ | |
| 25641 | - if( (hh&HH_Summary)!=0 ){ | |
| 25642 | - sqlite3_fprintf(out, ".%s\n", azHelp[i]+1); | |
| 25643 | - ++n; | |
| 25644 | - }else if( (hw&HW_SummaryOnly)==0 ){ | |
| 25645 | - sqlite3_fprintf(out, "%s\n", azHelp[i]); | |
| 25646 | - } | |
| 25647 | - } | |
| 25648 | - } | |
| 25649 | - }else{ | |
| 25650 | - /* Seek documented commands for which zPattern is an exact prefix */ | |
| 25651 | - zPat = sqlite3_mprintf(".%s*", zPattern); | |
| 25652 | - shell_check_oom(zPat); | |
| 25653 | - for(i=0; i<ArraySize(azHelp); i++){ | |
| 25654 | - if( sqlite3_strglob(zPat, azHelp[i])==0 ){ | |
| 25655 | - sqlite3_fprintf(out, "%s\n", azHelp[i]); | |
| 25656 | - j = i+1; | |
| 25657 | - n++; | |
| 25658 | - } | |
| 25659 | - } | |
| 25660 | - sqlite3_free(zPat); | |
| 25661 | - if( n ){ | |
| 25662 | - if( n==1 ){ | |
| 25663 | - /* when zPattern is a prefix of exactly one command, then include | |
| 25664 | - ** the details of that command, which should begin at offset j */ | |
| 25665 | - while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ | |
| 25666 | - sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25667 | - j++; | |
| 25668 | - } | |
| 25669 | - } | |
| 25670 | - return n; | |
| 25671 | - } | |
| 25672 | - /* Look for documented commands that contain zPattern anywhere. | |
| 25673 | - ** Show complete text of all documented commands that match. */ | |
| 25674 | - zPat = sqlite3_mprintf("%%%s%%", zPattern); | |
| 25675 | - shell_check_oom(zPat); | |
| 25676 | - for(i=0; i<ArraySize(azHelp); i++){ | |
| 25677 | - if( azHelp[i][0]==',' ){ | |
| 25678 | - while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; | |
| 25679 | - continue; | |
| 25680 | - } | |
| 25681 | - if( azHelp[i][0]=='.' ) j = i; | |
| 25682 | - if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ | |
| 25683 | - sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25684 | - while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ | |
| 25685 | - j++; | |
| 25686 | - sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25687 | - } | |
| 25688 | - i = j; | |
| 25689 | - n++; | |
| 25690 | - } | |
| 25691 | - } | |
| 25692 | - sqlite3_free(zPat); | |
| 25693 | - } | |
| 25506 | + if( zPattern==0 ){ | |
| 25507 | + /* Show just the first line for all help topics */ | |
| 25508 | + zPattern = "[a-z]"; | |
| 25509 | + }else if( cli_strcmp(zPattern,"-a")==0 | |
| 25510 | + || cli_strcmp(zPattern,"-all")==0 | |
| 25511 | + || cli_strcmp(zPattern,"--all")==0 | |
| 25512 | + ){ | |
| 25513 | + /* Show everything except undocumented commands */ | |
| 25514 | + zPattern = "."; | |
| 25515 | + }else if( cli_strcmp(zPattern,"0")==0 ){ | |
| 25516 | + /* Show complete help text of undocumented commands */ | |
| 25517 | + int show = 0; | |
| 25518 | + for(i=0; i<ArraySize(azHelp); i++){ | |
| 25519 | + if( azHelp[i][0]=='.' ){ | |
| 25520 | + show = 0; | |
| 25521 | + }else if( azHelp[i][0]==',' ){ | |
| 25522 | + show = 1; | |
| 25523 | + sqlite3_fprintf(out, ".%s\n", &azHelp[i][1]); | |
| 25524 | + n++; | |
| 25525 | + }else if( show ){ | |
| 25526 | + sqlite3_fprintf(out, "%s\n", azHelp[i]); | |
| 25527 | + } | |
| 25528 | + } | |
| 25529 | + return n; | |
| 25530 | + } | |
| 25531 | + | |
| 25532 | + /* Seek documented commands for which zPattern is an exact prefix */ | |
| 25533 | + zPat = sqlite3_mprintf(".%s*", zPattern); | |
| 25534 | + shell_check_oom(zPat); | |
| 25535 | + for(i=0; i<ArraySize(azHelp); i++){ | |
| 25536 | + if( sqlite3_strglob(zPat, azHelp[i])==0 ){ | |
| 25537 | + sqlite3_fprintf(out, "%s\n", azHelp[i]); | |
| 25538 | + j = i+1; | |
| 25539 | + n++; | |
| 25540 | + } | |
| 25541 | + } | |
| 25542 | + sqlite3_free(zPat); | |
| 25543 | + if( n ){ | |
| 25544 | + if( n==1 ){ | |
| 25545 | + /* when zPattern is a prefix of exactly one command, then include | |
| 25546 | + ** the details of that command, which should begin at offset j */ | |
| 25547 | + while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ | |
| 25548 | + sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25549 | + j++; | |
| 25550 | + } | |
| 25551 | + } | |
| 25552 | + return n; | |
| 25553 | + } | |
| 25554 | + | |
| 25555 | + /* Look for documented commands that contain zPattern anywhere. | |
| 25556 | + ** Show complete text of all documented commands that match. */ | |
| 25557 | + zPat = sqlite3_mprintf("%%%s%%", zPattern); | |
| 25558 | + shell_check_oom(zPat); | |
| 25559 | + for(i=0; i<ArraySize(azHelp); i++){ | |
| 25560 | + if( azHelp[i][0]==',' ){ | |
| 25561 | + while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; | |
| 25562 | + continue; | |
| 25563 | + } | |
| 25564 | + if( azHelp[i][0]=='.' ) j = i; | |
| 25565 | + if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ | |
| 25566 | + sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25567 | + while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ | |
| 25568 | + j++; | |
| 25569 | + sqlite3_fprintf(out, "%s\n", azHelp[j]); | |
| 25570 | + } | |
| 25571 | + i = j; | |
| 25572 | + n++; | |
| 25573 | + } | |
| 25574 | + } | |
| 25575 | + sqlite3_free(zPat); | |
| 25694 | 25576 | return n; |
| 25695 | 25577 | } |
| 25696 | 25578 | |
| 25697 | 25579 | /* Forward reference */ |
| 25698 | 25580 | static int process_input(ShellState *p); |
| @@ -25937,10 +25819,43 @@ | ||
| 25937 | 25819 | int sleep = sqlite3_value_int(argv[0]); |
| 25938 | 25820 | (void)argcUnused; |
| 25939 | 25821 | sqlite3_sleep(sleep/1000); |
| 25940 | 25822 | sqlite3_result_int(context, sleep); |
| 25941 | 25823 | } |
| 25824 | + | |
| 25825 | +/* | |
| 25826 | +** SQL function: shell_module_schema(X) | |
| 25827 | +** | |
| 25828 | +** Return a fake schema for the table-valued function or eponymous virtual | |
| 25829 | +** table X. | |
| 25830 | +*/ | |
| 25831 | +static void shellModuleSchema( | |
| 25832 | + sqlite3_context *pCtx, | |
| 25833 | + int nVal, | |
| 25834 | + sqlite3_value **apVal | |
| 25835 | +){ | |
| 25836 | + const char *zName; | |
| 25837 | + char *zFake; | |
| 25838 | + ShellState *p = (ShellState*)sqlite3_user_data(pCtx); | |
| 25839 | + FILE *pSavedLog = p->pLog; | |
| 25840 | + UNUSED_PARAMETER(nVal); | |
| 25841 | + zName = (const char*)sqlite3_value_text(apVal[0]); | |
| 25842 | + | |
| 25843 | + /* Temporarily disable the ".log" when calling shellFakeSchema() because | |
| 25844 | + ** shellFakeSchema() might generate failures for some ephemeral virtual | |
| 25845 | + ** tables due to missing arguments. Example: fts4aux. | |
| 25846 | + ** https://sqlite.org/forum/forumpost/42fe6520b803be51 */ | |
| 25847 | + p->pLog = 0; | |
| 25848 | + zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0; | |
| 25849 | + p->pLog = pSavedLog; | |
| 25850 | + | |
| 25851 | + if( zFake ){ | |
| 25852 | + sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), | |
| 25853 | + -1, sqlite3_free); | |
| 25854 | + free(zFake); | |
| 25855 | + } | |
| 25856 | +} | |
| 25942 | 25857 | |
| 25943 | 25858 | /* Flags for open_db(). |
| 25944 | 25859 | ** |
| 25945 | 25860 | ** The default behavior of open_db() is to exit(1) if the database fails to |
| 25946 | 25861 | ** open. The OPEN_DB_KEEPALIVE flag changes that so that it prints an error |
| @@ -26081,11 +25996,11 @@ | ||
| 26081 | 25996 | shellDtostr, 0, 0); |
| 26082 | 25997 | sqlite3_create_function(p->db, "dtostr", 2, SQLITE_UTF8, 0, |
| 26083 | 25998 | shellDtostr, 0, 0); |
| 26084 | 25999 | sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, |
| 26085 | 26000 | shellAddSchemaName, 0, 0); |
| 26086 | - sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0, | |
| 26001 | + sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, p, | |
| 26087 | 26002 | shellModuleSchema, 0, 0); |
| 26088 | 26003 | sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, |
| 26089 | 26004 | shellPutsFunc, 0, 0); |
| 26090 | 26005 | sqlite3_create_function(p->db, "usleep",1,SQLITE_UTF8,0, |
| 26091 | 26006 | shellUSleepFunc, 0, 0); |
| @@ -29541,11 +29456,12 @@ | ||
| 29541 | 29456 | rc = sqlite3_exec(p->db, |
| 29542 | 29457 | "SELECT sql FROM" |
| 29543 | 29458 | " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" |
| 29544 | 29459 | " FROM sqlite_schema UNION ALL" |
| 29545 | 29460 | " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) " |
| 29546 | - "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' " | |
| 29461 | + "WHERE type!='meta' AND sql NOTNULL" | |
| 29462 | + " AND name NOT LIKE 'sqlite__%' ESCAPE '_' " | |
| 29547 | 29463 | "ORDER BY x", |
| 29548 | 29464 | callback, &data, 0 |
| 29549 | 29465 | ); |
| 29550 | 29466 | if( rc==SQLITE_OK ){ |
| 29551 | 29467 | sqlite3_stmt *pStmt; |
| @@ -31017,11 +30933,11 @@ | ||
| 31017 | 30933 | } |
| 31018 | 30934 | appendText(&sSelect, " AND ", 0); |
| 31019 | 30935 | sqlite3_free(zQarg); |
| 31020 | 30936 | } |
| 31021 | 30937 | if( bNoSystemTabs ){ |
| 31022 | - appendText(&sSelect, "name NOT LIKE 'sqlite_%%' AND ", 0); | |
| 30938 | + appendText(&sSelect, "name NOT LIKE 'sqlite__%%' ESCAPE '_' AND ", 0); | |
| 31023 | 30939 | } |
| 31024 | 30940 | appendText(&sSelect, "sql IS NOT NULL" |
| 31025 | 30941 | " ORDER BY snum, rowid", 0); |
| 31026 | 30942 | if( bDebug ){ |
| 31027 | 30943 | sqlite3_fprintf(p->out, "SQL: %s;\n", sSelect.z); |
| @@ -31448,11 +31364,11 @@ | ||
| 31448 | 31364 | " UNION ALL SELECT 'sqlite_schema'" |
| 31449 | 31365 | " ORDER BY 1 collate nocase"; |
| 31450 | 31366 | }else{ |
| 31451 | 31367 | zSql = "SELECT lower(name) as tname FROM sqlite_schema" |
| 31452 | 31368 | " WHERE type='table' AND coalesce(rootpage,0)>1" |
| 31453 | - " AND name NOT LIKE 'sqlite_%'" | |
| 31369 | + " AND name NOT LIKE 'sqlite__%' ESCAPE '_'" | |
| 31454 | 31370 | " ORDER BY 1 collate nocase"; |
| 31455 | 31371 | } |
| 31456 | 31372 | sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 31457 | 31373 | initText(&sQuery); |
| 31458 | 31374 | initText(&sSql); |
| @@ -31513,11 +31429,11 @@ | ||
| 31513 | 31429 | { |
| 31514 | 31430 | int lrc; |
| 31515 | 31431 | char *zRevText = /* Query for reversible to-blob-to-text check */ |
| 31516 | 31432 | "SELECT lower(name) as tname FROM sqlite_schema\n" |
| 31517 | 31433 | "WHERE type='table' AND coalesce(rootpage,0)>1\n" |
| 31518 | - "AND name NOT LIKE 'sqlite_%%'%s\n" | |
| 31434 | + "AND name NOT LIKE 'sqlite__%%' ESCAPE '_'%s\n" | |
| 31519 | 31435 | "ORDER BY 1 collate nocase"; |
| 31520 | 31436 | zRevText = sqlite3_mprintf(zRevText, zLike? " AND name LIKE $tspec" : ""); |
| 31521 | 31437 | zRevText = sqlite3_mprintf( |
| 31522 | 31438 | /* lower-case query is first run, producing upper-case query. */ |
| 31523 | 31439 | "with tabcols as materialized(\n" |
| @@ -31709,11 +31625,11 @@ | ||
| 31709 | 31625 | } |
| 31710 | 31626 | appendText(&s, zDbName, '"'); |
| 31711 | 31627 | appendText(&s, ".sqlite_schema ", 0); |
| 31712 | 31628 | if( c=='t' ){ |
| 31713 | 31629 | appendText(&s," WHERE type IN ('table','view')" |
| 31714 | - " AND name NOT LIKE 'sqlite_%'" | |
| 31630 | + " AND name NOT LIKE 'sqlite__%' ESCAPE '_'" | |
| 31715 | 31631 | " AND name LIKE ?1", 0); |
| 31716 | 31632 | }else{ |
| 31717 | 31633 | appendText(&s," WHERE type='index'" |
| 31718 | 31634 | " AND tbl_name LIKE ?1", 0); |
| 31719 | 31635 | } |
| @@ -31803,11 +31719,11 @@ | ||
| 31803 | 31719 | const char *zUsage; /* Usage notes */ |
| 31804 | 31720 | } aCtrl[] = { |
| 31805 | 31721 | {"always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" }, |
| 31806 | 31722 | {"assert", SQLITE_TESTCTRL_ASSERT, 1, "BOOLEAN" }, |
| 31807 | 31723 | /*{"benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,1, "" },*/ |
| 31808 | - /*{"bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "" },*/ | |
| 31724 | + {"bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "SIZE INT-ARRAY"}, | |
| 31809 | 31725 | {"byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" }, |
| 31810 | 31726 | {"extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" }, |
| 31811 | 31727 | {"fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"args..." }, |
| 31812 | 31728 | {"fk_no_action", SQLITE_TESTCTRL_FK_NO_ACTION, 0, "BOOLEAN" }, |
| 31813 | 31729 | {"imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"}, |
| @@ -31922,10 +31838,11 @@ | ||
| 31922 | 31838 | { 0x02000000, 1, "Coroutines" }, |
| 31923 | 31839 | { 0x04000000, 1, "NullUnusedCols" }, |
| 31924 | 31840 | { 0x08000000, 1, "OnePass" }, |
| 31925 | 31841 | { 0x10000000, 1, "OrderBySubq" }, |
| 31926 | 31842 | { 0x20000000, 1, "StarQuery" }, |
| 31843 | + { 0x40000000, 1, "ExistsToJoin" }, | |
| 31927 | 31844 | { 0xffffffff, 0, "All" }, |
| 31928 | 31845 | }; |
| 31929 | 31846 | unsigned int curOpt; |
| 31930 | 31847 | unsigned int newOpt; |
| 31931 | 31848 | unsigned int m; |
| @@ -32141,10 +32058,53 @@ | ||
| 32141 | 32058 | rc2 = booleanValue(azArg[2]); |
| 32142 | 32059 | isOk = 3; |
| 32143 | 32060 | } |
| 32144 | 32061 | sqlite3_test_control(testctrl, &rc2); |
| 32145 | 32062 | break; |
| 32063 | + case SQLITE_TESTCTRL_BITVEC_TEST: { | |
| 32064 | + /* Examples: | |
| 32065 | + ** .testctrl bitvec_test 100 6,1 -- Show BITVEC constants | |
| 32066 | + ** .testctrl bitvec_test 1000 1,12,7,3 -- Simple test | |
| 32067 | + ** ---- -------- | |
| 32068 | + ** size of Bitvec -----^ ^--- aOp array. 0 added at end. | |
| 32069 | + ** | |
| 32070 | + ** See comments on sqlite3BitvecBuiltinTest() for more information | |
| 32071 | + ** about the aOp[] array. | |
| 32072 | + */ | |
| 32073 | + int iSize; | |
| 32074 | + const char *zTestArg; | |
| 32075 | + int nOp; | |
| 32076 | + int ii, jj, x; | |
| 32077 | + int *aOp; | |
| 32078 | + if( nArg!=4 ){ | |
| 32079 | + sqlite3_fprintf(stderr, | |
| 32080 | + "ERROR - should be: \".testctrl bitvec_test SIZE INT-ARRAY\"\n" | |
| 32081 | + ); | |
| 32082 | + rc = 1; | |
| 32083 | + goto meta_command_exit; | |
| 32084 | + } | |
| 32085 | + isOk = 3; | |
| 32086 | + iSize = (int)integerValue(azArg[2]); | |
| 32087 | + zTestArg = azArg[3]; | |
| 32088 | + nOp = (int)strlen(zTestArg)+1; | |
| 32089 | + aOp = malloc( sizeof(int)*(nOp+1) ); | |
| 32090 | + shell_check_oom(aOp); | |
| 32091 | + memset(aOp, 0, sizeof(int)*(nOp+1) ); | |
| 32092 | + for(ii = jj = x = 0; zTestArg[ii]!=0; ii++){ | |
| 32093 | + if( IsDigit(zTestArg[ii]) ){ | |
| 32094 | + x = x*10 + zTestArg[ii] - '0'; | |
| 32095 | + }else{ | |
| 32096 | + aOp[jj++] = x; | |
| 32097 | + x = 0; | |
| 32098 | + } | |
| 32099 | + } | |
| 32100 | + aOp[jj] = x; | |
| 32101 | + x = sqlite3_test_control(testctrl, iSize, aOp); | |
| 32102 | + sqlite3_fprintf(p->out, "result: %d\n", x); | |
| 32103 | + free(aOp); | |
| 32104 | + break; | |
| 32105 | + } | |
| 32146 | 32106 | case SQLITE_TESTCTRL_FAULT_INSTALL: { |
| 32147 | 32107 | int kk; |
| 32148 | 32108 | int bShowHelp = nArg<=2; |
| 32149 | 32109 | isOk = 3; |
| 32150 | 32110 | for(kk=2; kk<nArg; kk++){ |
| 32151 | 32111 |
| --- extsrc/shell.c | |
| +++ extsrc/shell.c | |
| @@ -1266,16 +1266,25 @@ | |
| 1266 | return 0x3fffffff & (int)(z2 - z); |
| 1267 | } |
| 1268 | |
| 1269 | /* |
| 1270 | ** Return the length of a string in characters. Multibyte UTF8 characters |
| 1271 | ** count as a single character. |
| 1272 | */ |
| 1273 | static int strlenChar(const char *z){ |
| 1274 | int n = 0; |
| 1275 | while( *z ){ |
| 1276 | if( (0xc0&*(z++))!=0x80 ) n++; |
| 1277 | } |
| 1278 | return n; |
| 1279 | } |
| 1280 | |
| 1281 | /* |
| @@ -1622,34 +1631,10 @@ | |
| 1622 | if( n>350 ) n = 350; |
| 1623 | sqlite3_snprintf(sizeof(z), z, "%#+.*e", n, r); |
| 1624 | sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); |
| 1625 | } |
| 1626 | |
| 1627 | |
| 1628 | /* |
| 1629 | ** SQL function: shell_module_schema(X) |
| 1630 | ** |
| 1631 | ** Return a fake schema for the table-valued function or eponymous virtual |
| 1632 | ** table X. |
| 1633 | */ |
| 1634 | static void shellModuleSchema( |
| 1635 | sqlite3_context *pCtx, |
| 1636 | int nVal, |
| 1637 | sqlite3_value **apVal |
| 1638 | ){ |
| 1639 | const char *zName; |
| 1640 | char *zFake; |
| 1641 | UNUSED_PARAMETER(nVal); |
| 1642 | zName = (const char*)sqlite3_value_text(apVal[0]); |
| 1643 | zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0; |
| 1644 | if( zFake ){ |
| 1645 | sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), |
| 1646 | -1, sqlite3_free); |
| 1647 | free(zFake); |
| 1648 | } |
| 1649 | } |
| 1650 | |
| 1651 | /* |
| 1652 | ** SQL function: shell_add_schema(S,X) |
| 1653 | ** |
| 1654 | ** Add the schema name X to the CREATE statement in S and return the result. |
| 1655 | ** Examples: |
| @@ -1728,369 +1713,176 @@ | |
| 1728 | ** work here in the middle of this regular program. |
| 1729 | */ |
| 1730 | #define SQLITE_EXTENSION_INIT1 |
| 1731 | #define SQLITE_EXTENSION_INIT2(X) (void)(X) |
| 1732 | |
| 1733 | #if defined(_WIN32) && defined(_MSC_VER) |
| 1734 | /************************* Begin test_windirent.h ******************/ |
| 1735 | /* |
| 1736 | ** 2015 November 30 |
| 1737 | ** |
| 1738 | ** The author disclaims copyright to this source code. In place of |
| 1739 | ** a legal notice, here is a blessing: |
| 1740 | ** |
| 1741 | ** May you do good and not evil. |
| 1742 | ** May you find forgiveness for yourself and forgive others. |
| 1743 | ** May you share freely, never taking more than you give. |
| 1744 | ** |
| 1745 | ************************************************************************* |
| 1746 | ** This file contains declarations for most of the opendir() family of |
| 1747 | ** POSIX functions on Win32 using the MSVCRT. |
| 1748 | */ |
| 1749 | |
| 1750 | #if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H) |
| 1751 | #define SQLITE_WINDIRENT_H |
| 1752 | |
| 1753 | /* |
| 1754 | ** We need several data types from the Windows SDK header. |
| 1755 | */ |
| 1756 | |
| 1757 | #ifndef WIN32_LEAN_AND_MEAN |
| 1758 | #define WIN32_LEAN_AND_MEAN |
| 1759 | #endif |
| 1760 | |
| 1761 | #include "windows.h" |
| 1762 | |
| 1763 | /* |
| 1764 | ** We need several support functions from the SQLite core. |
| 1765 | */ |
| 1766 | |
| 1767 | /* #include "sqlite3.h" */ |
| 1768 | |
| 1769 | /* |
| 1770 | ** We need several things from the ANSI and MSVCRT headers. |
| 1771 | */ |
| 1772 | |
| 1773 | #include <stdio.h> |
| 1774 | #include <stdlib.h> |
| 1775 | #include <errno.h> |
| 1776 | #include <io.h> |
| 1777 | #include <limits.h> |
| 1778 | #include <sys/types.h> |
| 1779 | #include <sys/stat.h> |
| 1780 | |
| 1781 | /* |
| 1782 | ** We may need several defines that should have been in "sys/stat.h". |
| 1783 | */ |
| 1784 | |
| 1785 | #ifndef S_ISREG |
| 1786 | #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) |
| 1787 | #endif |
| 1788 | |
| 1789 | #ifndef S_ISDIR |
| 1790 | #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) |
| 1791 | #endif |
| 1792 | |
| 1793 | #ifndef S_ISLNK |
| 1794 | #define S_ISLNK(mode) (0) |
| 1795 | #endif |
| 1796 | |
| 1797 | /* |
| 1798 | ** We may need to provide the "mode_t" type. |
| 1799 | */ |
| 1800 | |
| 1801 | #ifndef MODE_T_DEFINED |
| 1802 | #define MODE_T_DEFINED |
| 1803 | typedef unsigned short mode_t; |
| 1804 | #endif |
| 1805 | |
| 1806 | /* |
| 1807 | ** We may need to provide the "ino_t" type. |
| 1808 | */ |
| 1809 | |
| 1810 | #ifndef INO_T_DEFINED |
| 1811 | #define INO_T_DEFINED |
| 1812 | typedef unsigned short ino_t; |
| 1813 | #endif |
| 1814 | |
| 1815 | /* |
| 1816 | ** We need to define "NAME_MAX" if it was not present in "limits.h". |
| 1817 | */ |
| 1818 | |
| 1819 | #ifndef NAME_MAX |
| 1820 | # ifdef FILENAME_MAX |
| 1821 | # define NAME_MAX (FILENAME_MAX) |
| 1822 | # else |
| 1823 | # define NAME_MAX (260) |
| 1824 | # endif |
| 1825 | #endif |
| 1826 | |
| 1827 | /* |
| 1828 | ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T". |
| 1829 | */ |
| 1830 | |
| 1831 | #ifndef NULL_INTPTR_T |
| 1832 | # define NULL_INTPTR_T ((intptr_t)(0)) |
| 1833 | #endif |
| 1834 | |
| 1835 | #ifndef BAD_INTPTR_T |
| 1836 | # define BAD_INTPTR_T ((intptr_t)(-1)) |
| 1837 | #endif |
| 1838 | |
| 1839 | /* |
| 1840 | ** We need to provide the necessary structures and related types. |
| 1841 | */ |
| 1842 | |
| 1843 | #ifndef DIRENT_DEFINED |
| 1844 | #define DIRENT_DEFINED |
| 1845 | typedef struct DIRENT DIRENT; |
| 1846 | typedef DIRENT *LPDIRENT; |
| 1847 | struct DIRENT { |
| 1848 | ino_t d_ino; /* Sequence number, do not use. */ |
| 1849 | unsigned d_attributes; /* Win32 file attributes. */ |
| 1850 | char d_name[NAME_MAX + 1]; /* Name within the directory. */ |
| 1851 | }; |
| 1852 | #endif |
| 1853 | |
| 1854 | #ifndef DIR_DEFINED |
| 1855 | #define DIR_DEFINED |
| 1856 | typedef struct DIR DIR; |
| 1857 | typedef DIR *LPDIR; |
| 1858 | struct DIR { |
| 1859 | intptr_t d_handle; /* Value returned by "_findfirst". */ |
| 1860 | DIRENT d_first; /* DIRENT constructed based on "_findfirst". */ |
| 1861 | DIRENT d_next; /* DIRENT constructed based on "_findnext". */ |
| 1862 | }; |
| 1863 | #endif |
| 1864 | |
| 1865 | /* |
| 1866 | ** Provide a macro, for use by the implementation, to determine if a |
| 1867 | ** particular directory entry should be skipped over when searching for |
| 1868 | ** the next directory entry that should be returned by the readdir() or |
| 1869 | ** readdir_r() functions. |
| 1870 | */ |
| 1871 | |
| 1872 | #ifndef is_filtered |
| 1873 | # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) |
| 1874 | #endif |
| 1875 | |
| 1876 | /* |
| 1877 | ** Provide the function prototype for the POSIX compatible getenv() |
| 1878 | ** function. This function is not thread-safe. |
| 1879 | */ |
| 1880 | |
| 1881 | extern const char *windirent_getenv(const char *name); |
| 1882 | |
| 1883 | /* |
| 1884 | ** Finally, we can provide the function prototypes for the opendir(), |
| 1885 | ** readdir(), readdir_r(), and closedir() POSIX functions. |
| 1886 | */ |
| 1887 | |
| 1888 | extern LPDIR opendir(const char *dirname); |
| 1889 | extern LPDIRENT readdir(LPDIR dirp); |
| 1890 | extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result); |
| 1891 | extern INT closedir(LPDIR dirp); |
| 1892 | |
| 1893 | #endif /* defined(WIN32) && defined(_MSC_VER) */ |
| 1894 | |
| 1895 | /************************* End test_windirent.h ********************/ |
| 1896 | /************************* Begin test_windirent.c ******************/ |
| 1897 | /* |
| 1898 | ** 2015 November 30 |
| 1899 | ** |
| 1900 | ** The author disclaims copyright to this source code. In place of |
| 1901 | ** a legal notice, here is a blessing: |
| 1902 | ** |
| 1903 | ** May you do good and not evil. |
| 1904 | ** May you find forgiveness for yourself and forgive others. |
| 1905 | ** May you share freely, never taking more than you give. |
| 1906 | ** |
| 1907 | ************************************************************************* |
| 1908 | ** This file contains code to implement most of the opendir() family of |
| 1909 | ** POSIX functions on Win32 using the MSVCRT. |
| 1910 | */ |
| 1911 | |
| 1912 | #if defined(_WIN32) && defined(_MSC_VER) |
| 1913 | /* #include "test_windirent.h" */ |
| 1914 | |
| 1915 | /* |
| 1916 | ** Implementation of the POSIX getenv() function using the Win32 API. |
| 1917 | ** This function is not thread-safe. |
| 1918 | */ |
| 1919 | const char *windirent_getenv( |
| 1920 | const char *name |
| 1921 | ){ |
| 1922 | static char value[32768]; /* Maximum length, per MSDN */ |
| 1923 | DWORD dwSize = sizeof(value) / sizeof(char); /* Size in chars */ |
| 1924 | DWORD dwRet; /* Value returned by GetEnvironmentVariableA() */ |
| 1925 | |
| 1926 | memset(value, 0, sizeof(value)); |
| 1927 | dwRet = GetEnvironmentVariableA(name, value, dwSize); |
| 1928 | if( dwRet==0 || dwRet>dwSize ){ |
| 1929 | /* |
| 1930 | ** The function call to GetEnvironmentVariableA() failed -OR- |
| 1931 | ** the buffer is not large enough. Either way, return NULL. |
| 1932 | */ |
| 1933 | return 0; |
| 1934 | }else{ |
| 1935 | /* |
| 1936 | ** The function call to GetEnvironmentVariableA() succeeded |
| 1937 | ** -AND- the buffer contains the entire value. |
| 1938 | */ |
| 1939 | return value; |
| 1940 | } |
| 1941 | } |
| 1942 | |
| 1943 | /* |
| 1944 | ** Implementation of the POSIX opendir() function using the MSVCRT. |
| 1945 | */ |
| 1946 | LPDIR opendir( |
| 1947 | const char *dirname |
| 1948 | ){ |
| 1949 | struct _finddata_t data; |
| 1950 | LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR)); |
| 1951 | SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]); |
| 1952 | |
| 1953 | if( dirp==NULL ) return NULL; |
| 1954 | memset(dirp, 0, sizeof(DIR)); |
| 1955 | |
| 1956 | /* TODO: Remove this if Unix-style root paths are not used. */ |
| 1957 | if( sqlite3_stricmp(dirname, "/")==0 ){ |
| 1958 | dirname = windirent_getenv("SystemDrive"); |
| 1959 | } |
| 1960 | |
| 1961 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 1962 | _snprintf(data.name, namesize, "%s\\*", dirname); |
| 1963 | dirp->d_handle = _findfirst(data.name, &data); |
| 1964 | |
| 1965 | if( dirp->d_handle==BAD_INTPTR_T ){ |
| 1966 | closedir(dirp); |
| 1967 | return NULL; |
| 1968 | } |
| 1969 | |
| 1970 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 1971 | if( is_filtered(data) ){ |
| 1972 | next: |
| 1973 | |
| 1974 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 1975 | if( _findnext(dirp->d_handle, &data)==-1 ){ |
| 1976 | closedir(dirp); |
| 1977 | return NULL; |
| 1978 | } |
| 1979 | |
| 1980 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 1981 | if( is_filtered(data) ) goto next; |
| 1982 | } |
| 1983 | |
| 1984 | dirp->d_first.d_attributes = data.attrib; |
| 1985 | strncpy(dirp->d_first.d_name, data.name, NAME_MAX); |
| 1986 | dirp->d_first.d_name[NAME_MAX] = '\0'; |
| 1987 | |
| 1988 | return dirp; |
| 1989 | } |
| 1990 | |
| 1991 | /* |
| 1992 | ** Implementation of the POSIX readdir() function using the MSVCRT. |
| 1993 | */ |
| 1994 | LPDIRENT readdir( |
| 1995 | LPDIR dirp |
| 1996 | ){ |
| 1997 | struct _finddata_t data; |
| 1998 | |
| 1999 | if( dirp==NULL ) return NULL; |
| 2000 | |
| 2001 | if( dirp->d_first.d_ino==0 ){ |
| 2002 | dirp->d_first.d_ino++; |
| 2003 | dirp->d_next.d_ino++; |
| 2004 | |
| 2005 | return &dirp->d_first; |
| 2006 | } |
| 2007 | |
| 2008 | next: |
| 2009 | |
| 2010 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 2011 | if( _findnext(dirp->d_handle, &data)==-1 ) return NULL; |
| 2012 | |
| 2013 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 2014 | if( is_filtered(data) ) goto next; |
| 2015 | |
| 2016 | dirp->d_next.d_ino++; |
| 2017 | dirp->d_next.d_attributes = data.attrib; |
| 2018 | strncpy(dirp->d_next.d_name, data.name, NAME_MAX); |
| 2019 | dirp->d_next.d_name[NAME_MAX] = '\0'; |
| 2020 | |
| 2021 | return &dirp->d_next; |
| 2022 | } |
| 2023 | |
| 2024 | /* |
| 2025 | ** Implementation of the POSIX readdir_r() function using the MSVCRT. |
| 2026 | */ |
| 2027 | INT readdir_r( |
| 2028 | LPDIR dirp, |
| 2029 | LPDIRENT entry, |
| 2030 | LPDIRENT *result |
| 2031 | ){ |
| 2032 | struct _finddata_t data; |
| 2033 | |
| 2034 | if( dirp==NULL ) return EBADF; |
| 2035 | |
| 2036 | if( dirp->d_first.d_ino==0 ){ |
| 2037 | dirp->d_first.d_ino++; |
| 2038 | dirp->d_next.d_ino++; |
| 2039 | |
| 2040 | entry->d_ino = dirp->d_first.d_ino; |
| 2041 | entry->d_attributes = dirp->d_first.d_attributes; |
| 2042 | strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX); |
| 2043 | entry->d_name[NAME_MAX] = '\0'; |
| 2044 | |
| 2045 | *result = entry; |
| 2046 | return 0; |
| 2047 | } |
| 2048 | |
| 2049 | next: |
| 2050 | |
| 2051 | memset(&data, 0, sizeof(struct _finddata_t)); |
| 2052 | if( _findnext(dirp->d_handle, &data)==-1 ){ |
| 2053 | *result = NULL; |
| 2054 | return ENOENT; |
| 2055 | } |
| 2056 | |
| 2057 | /* TODO: Remove this block to allow hidden and/or system files. */ |
| 2058 | if( is_filtered(data) ) goto next; |
| 2059 | |
| 2060 | entry->d_ino = (ino_t)-1; /* not available */ |
| 2061 | entry->d_attributes = data.attrib; |
| 2062 | strncpy(entry->d_name, data.name, NAME_MAX); |
| 2063 | entry->d_name[NAME_MAX] = '\0'; |
| 2064 | |
| 2065 | *result = entry; |
| 2066 | return 0; |
| 2067 | } |
| 2068 | |
| 2069 | /* |
| 2070 | ** Implementation of the POSIX closedir() function using the MSVCRT. |
| 2071 | */ |
| 2072 | INT closedir( |
| 2073 | LPDIR dirp |
| 2074 | ){ |
| 2075 | INT result = 0; |
| 2076 | |
| 2077 | if( dirp==NULL ) return EINVAL; |
| 2078 | |
| 2079 | if( dirp->d_handle!=NULL_INTPTR_T && dirp->d_handle!=BAD_INTPTR_T ){ |
| 2080 | result = _findclose(dirp->d_handle); |
| 2081 | } |
| 2082 | |
| 2083 | sqlite3_free(dirp); |
| 2084 | return result; |
| 2085 | } |
| 2086 | |
| 2087 | #endif /* defined(WIN32) && defined(_MSC_VER) */ |
| 2088 | |
| 2089 | /************************* End test_windirent.c ********************/ |
| 2090 | #define dirent DIRENT |
| 2091 | #endif |
| 2092 | /************************* Begin ../ext/misc/memtrace.c ******************/ |
| 2093 | /* |
| 2094 | ** 2019-01-21 |
| 2095 | ** |
| 2096 | ** The author disclaims copyright to this source code. In place of |
| @@ -8054,10 +7846,11 @@ | |
| 8054 | ** mode: Value of stat.st_mode for directory entry (an integer). |
| 8055 | ** mtime: Value of stat.st_mtime for directory entry (an integer). |
| 8056 | ** data: For a regular file, a blob containing the file data. For a |
| 8057 | ** symlink, a text value containing the text of the link. For a |
| 8058 | ** directory, NULL. |
| 8059 | ** |
| 8060 | ** If a non-NULL value is specified for the optional $dir parameter and |
| 8061 | ** $path is a relative path, then $path is interpreted relative to $dir. |
| 8062 | ** And the paths returned in the "name" column of the table are also |
| 8063 | ** relative to directory $dir. |
| @@ -8079,24 +7872,17 @@ | |
| 8079 | #if !defined(_WIN32) && !defined(WIN32) |
| 8080 | # include <unistd.h> |
| 8081 | # include <dirent.h> |
| 8082 | # include <utime.h> |
| 8083 | # include <sys/time.h> |
| 8084 | #else |
| 8085 | # include "windows.h" |
| 8086 | # include <io.h> |
| 8087 | # include <direct.h> |
| 8088 | /* # include "test_windirent.h" */ |
| 8089 | # define dirent DIRENT |
| 8090 | # ifndef chmod |
| 8091 | # define chmod _chmod |
| 8092 | # endif |
| 8093 | # ifndef stat |
| 8094 | # define stat _stat |
| 8095 | # endif |
| 8096 | # define mkdir(path,mode) _mkdir(path) |
| 8097 | # define lstat(path,buf) stat(path,buf) |
| 8098 | #endif |
| 8099 | #include <time.h> |
| 8100 | #include <errno.h> |
| 8101 | |
| 8102 | /* When used as part of the CLI, the sqlite3_stdio.h module will have |
| @@ -8108,18 +7894,54 @@ | |
| 8108 | #endif |
| 8109 | |
| 8110 | /* |
| 8111 | ** Structure of the fsdir() table-valued function |
| 8112 | */ |
| 8113 | /* 0 1 2 3 4 5 */ |
| 8114 | #define FSDIR_SCHEMA "(name,mode,mtime,data,path HIDDEN,dir HIDDEN)" |
| 8115 | #define FSDIR_COLUMN_NAME 0 /* Name of the file */ |
| 8116 | #define FSDIR_COLUMN_MODE 1 /* Access mode */ |
| 8117 | #define FSDIR_COLUMN_MTIME 2 /* Last modification time */ |
| 8118 | #define FSDIR_COLUMN_DATA 3 /* File content */ |
| 8119 | #define FSDIR_COLUMN_PATH 4 /* Path to top of search */ |
| 8120 | #define FSDIR_COLUMN_DIR 5 /* Path is relative to this directory */ |
| 8121 | |
| 8122 | |
| 8123 | /* |
| 8124 | ** Set the result stored by context ctx to a blob containing the |
| 8125 | ** contents of file zName. Or, leave the result unchanged (NULL) |
| @@ -8247,11 +8069,11 @@ | |
| 8247 | ** buffer to UTC. This is necessary on Win32, where the runtime library |
| 8248 | ** appears to return these values as local times. |
| 8249 | */ |
| 8250 | static void statTimesToUtc( |
| 8251 | const char *zPath, |
| 8252 | struct stat *pStatBuf |
| 8253 | ){ |
| 8254 | HANDLE hFindFile; |
| 8255 | WIN32_FIND_DATAW fd; |
| 8256 | LPWSTR zUnicodeName; |
| 8257 | extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*); |
| @@ -8275,14 +8097,20 @@ | |
| 8275 | ** is required in order for the included time to be returned as UTC. On all |
| 8276 | ** other systems, this function simply calls stat(). |
| 8277 | */ |
| 8278 | static int fileStat( |
| 8279 | const char *zPath, |
| 8280 | struct stat *pStatBuf |
| 8281 | ){ |
| 8282 | #if defined(_WIN32) |
| 8283 | int rc = stat(zPath, pStatBuf); |
| 8284 | if( rc==0 ) statTimesToUtc(zPath, pStatBuf); |
| 8285 | return rc; |
| 8286 | #else |
| 8287 | return stat(zPath, pStatBuf); |
| 8288 | #endif |
| @@ -8293,16 +8121,14 @@ | |
| 8293 | ** is required in order for the included time to be returned as UTC. On all |
| 8294 | ** other systems, this function simply calls lstat(). |
| 8295 | */ |
| 8296 | static int fileLinkStat( |
| 8297 | const char *zPath, |
| 8298 | struct stat *pStatBuf |
| 8299 | ){ |
| 8300 | #if defined(_WIN32) |
| 8301 | int rc = lstat(zPath, pStatBuf); |
| 8302 | if( rc==0 ) statTimesToUtc(zPath, pStatBuf); |
| 8303 | return rc; |
| 8304 | #else |
| 8305 | return lstat(zPath, pStatBuf); |
| 8306 | #endif |
| 8307 | } |
| 8308 | |
| @@ -8328,11 +8154,11 @@ | |
| 8328 | }else{ |
| 8329 | int nCopy = (int)strlen(zCopy); |
| 8330 | int i = 1; |
| 8331 | |
| 8332 | while( rc==SQLITE_OK ){ |
| 8333 | struct stat sStat; |
| 8334 | int rc2; |
| 8335 | |
| 8336 | for(; zCopy[i]!='/' && i<nCopy; i++); |
| 8337 | if( i==nCopy ) break; |
| 8338 | zCopy[i] = '\0'; |
| @@ -8378,11 +8204,11 @@ | |
| 8378 | if( mkdir(zFile, mode) ){ |
| 8379 | /* The mkdir() call to create the directory failed. This might not |
| 8380 | ** be an error though - if there is already a directory at the same |
| 8381 | ** path and either the permissions already match or can be changed |
| 8382 | ** to do so using chmod(), it is not an error. */ |
| 8383 | struct stat sStat; |
| 8384 | if( errno!=EEXIST |
| 8385 | || 0!=fileStat(zFile, &sStat) |
| 8386 | || !S_ISDIR(sStat.st_mode) |
| 8387 | || ((sStat.st_mode&0777)!=(mode&0777) && 0!=chmod(zFile, mode&0777)) |
| 8388 | ){ |
| @@ -8574,17 +8400,18 @@ | |
| 8574 | |
| 8575 | struct fsdir_cursor { |
| 8576 | sqlite3_vtab_cursor base; /* Base class - must be first */ |
| 8577 | |
| 8578 | int nLvl; /* Number of entries in aLvl[] array */ |
| 8579 | int iLvl; /* Index of current entry */ |
| 8580 | FsdirLevel *aLvl; /* Hierarchy of directories being traversed */ |
| 8581 | |
| 8582 | const char *zBase; |
| 8583 | int nBase; |
| 8584 | |
| 8585 | struct stat sStat; /* Current lstat() results */ |
| 8586 | char *zPath; /* Path to current entry */ |
| 8587 | sqlite3_int64 iRowid; /* Current rowid */ |
| 8588 | }; |
| 8589 | |
| 8590 | typedef struct fsdir_tab fsdir_tab; |
| @@ -8692,11 +8519,11 @@ | |
| 8692 | static int fsdirNext(sqlite3_vtab_cursor *cur){ |
| 8693 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8694 | mode_t m = pCur->sStat.st_mode; |
| 8695 | |
| 8696 | pCur->iRowid++; |
| 8697 | if( S_ISDIR(m) ){ |
| 8698 | /* Descend into this directory */ |
| 8699 | int iNew = pCur->iLvl + 1; |
| 8700 | FsdirLevel *pLvl; |
| 8701 | if( iNew>=pCur->nLvl ){ |
| 8702 | int nNew = iNew+1; |
| @@ -8800,11 +8627,15 @@ | |
| 8800 | if( aBuf!=aStatic ) sqlite3_free(aBuf); |
| 8801 | #endif |
| 8802 | }else{ |
| 8803 | readFileContents(ctx, pCur->zPath); |
| 8804 | } |
| 8805 | } |
| 8806 | case FSDIR_COLUMN_PATH: |
| 8807 | default: { |
| 8808 | /* The FSDIR_COLUMN_PATH and FSDIR_COLUMN_DIR are input parameters. |
| 8809 | ** always return their values as NULL */ |
| 8810 | break; |
| @@ -8834,36 +8665,50 @@ | |
| 8834 | } |
| 8835 | |
| 8836 | /* |
| 8837 | ** xFilter callback. |
| 8838 | ** |
| 8839 | ** idxNum==1 PATH parameter only |
| 8840 | ** idxNum==2 Both PATH and DIR supplied |
| 8841 | */ |
| 8842 | static int fsdirFilter( |
| 8843 | sqlite3_vtab_cursor *cur, |
| 8844 | int idxNum, const char *idxStr, |
| 8845 | int argc, sqlite3_value **argv |
| 8846 | ){ |
| 8847 | const char *zDir = 0; |
| 8848 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8849 | (void)idxStr; |
| 8850 | fsdirResetCursor(pCur); |
| 8851 | |
| 8852 | if( idxNum==0 ){ |
| 8853 | fsdirSetErrmsg(pCur, "table function fsdir requires an argument"); |
| 8854 | return SQLITE_ERROR; |
| 8855 | } |
| 8856 | |
| 8857 | assert( argc==idxNum && (argc==1 || argc==2) ); |
| 8858 | zDir = (const char*)sqlite3_value_text(argv[0]); |
| 8859 | if( zDir==0 ){ |
| 8860 | fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument"); |
| 8861 | return SQLITE_ERROR; |
| 8862 | } |
| 8863 | if( argc==2 ){ |
| 8864 | pCur->zBase = (const char*)sqlite3_value_text(argv[1]); |
| 8865 | } |
| 8866 | if( pCur->zBase ){ |
| 8867 | pCur->nBase = (int)strlen(pCur->zBase)+1; |
| 8868 | pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir); |
| 8869 | }else{ |
| @@ -8888,48 +8733,75 @@ | |
| 8888 | ** plan. |
| 8889 | ** |
| 8890 | ** In this implementation idxNum is used to represent the |
| 8891 | ** query plan. idxStr is unused. |
| 8892 | ** |
| 8893 | ** The query plan is represented by values of idxNum: |
| 8894 | ** |
| 8895 | ** (1) The path value is supplied by argv[0] |
| 8896 | ** (2) Path is in argv[0] and dir is in argv[1] |
| 8897 | */ |
| 8898 | static int fsdirBestIndex( |
| 8899 | sqlite3_vtab *tab, |
| 8900 | sqlite3_index_info *pIdxInfo |
| 8901 | ){ |
| 8902 | int i; /* Loop over constraints */ |
| 8903 | int idxPath = -1; /* Index in pIdxInfo->aConstraint of PATH= */ |
| 8904 | int idxDir = -1; /* Index in pIdxInfo->aConstraint of DIR= */ |
| 8905 | int seenPath = 0; /* True if an unusable PATH= constraint is seen */ |
| 8906 | int seenDir = 0; /* True if an unusable DIR= constraint is seen */ |
| 8907 | const struct sqlite3_index_constraint *pConstraint; |
| 8908 | |
| 8909 | (void)tab; |
| 8910 | pConstraint = pIdxInfo->aConstraint; |
| 8911 | for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ |
| 8912 | if( pConstraint->op!=SQLITE_INDEX_CONSTRAINT_EQ ) continue; |
| 8913 | switch( pConstraint->iColumn ){ |
| 8914 | case FSDIR_COLUMN_PATH: { |
| 8915 | if( pConstraint->usable ){ |
| 8916 | idxPath = i; |
| 8917 | seenPath = 0; |
| 8918 | }else if( idxPath<0 ){ |
| 8919 | seenPath = 1; |
| 8920 | } |
| 8921 | break; |
| 8922 | } |
| 8923 | case FSDIR_COLUMN_DIR: { |
| 8924 | if( pConstraint->usable ){ |
| 8925 | idxDir = i; |
| 8926 | seenDir = 0; |
| 8927 | }else if( idxDir<0 ){ |
| 8928 | seenDir = 1; |
| 8929 | } |
| 8930 | break; |
| 8931 | } |
| 8932 | } |
| 8933 | } |
| 8934 | if( seenPath || seenDir ){ |
| 8935 | /* If input parameters are unusable, disallow this plan */ |
| @@ -8942,18 +8814,24 @@ | |
| 8942 | ** number. Leave it unchanged. */ |
| 8943 | pIdxInfo->estimatedRows = 0x7fffffff; |
| 8944 | }else{ |
| 8945 | pIdxInfo->aConstraintUsage[idxPath].omit = 1; |
| 8946 | pIdxInfo->aConstraintUsage[idxPath].argvIndex = 1; |
| 8947 | if( idxDir>=0 ){ |
| 8948 | pIdxInfo->aConstraintUsage[idxDir].omit = 1; |
| 8949 | pIdxInfo->aConstraintUsage[idxDir].argvIndex = 2; |
| 8950 | pIdxInfo->idxNum = 2; |
| 8951 | pIdxInfo->estimatedCost = 10.0; |
| 8952 | }else{ |
| 8953 | pIdxInfo->idxNum = 1; |
| 8954 | pIdxInfo->estimatedCost = 100.0; |
| 8955 | } |
| 8956 | } |
| 8957 | |
| 8958 | return SQLITE_OK; |
| 8959 | } |
| @@ -16808,11 +16686,11 @@ | |
| 16808 | case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break; |
| 16809 | case SQLITE_FCNTL_PRAGMA: { |
| 16810 | const char *const* a = (const char*const*)pArg; |
| 16811 | if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){ |
| 16812 | const u8 *zArg = (const u8*)a[2]; |
| 16813 | if( zArg[0]>='0' && zArg[0]<=9 ){ |
| 16814 | pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0); |
| 16815 | }else{ |
| 16816 | static const struct { |
| 16817 | const char *z; |
| 16818 | unsigned int m; |
| @@ -18709,10 +18587,13 @@ | |
| 18709 | rc = sqlite3_create_module(db, "sqlite_dbptr", &dbdata_module, (void*)1); |
| 18710 | } |
| 18711 | return rc; |
| 18712 | } |
| 18713 | |
| 18714 | int sqlite3_dbdata_init( |
| 18715 | sqlite3 *db, |
| 18716 | char **pzErrMsg, |
| 18717 | const sqlite3_api_routines *pApi |
| 18718 | ){ |
| @@ -25592,107 +25473,108 @@ | |
| 25592 | " --plain Show results as text/plain, not as HTML", |
| 25593 | #endif |
| 25594 | }; |
| 25595 | |
| 25596 | /* |
| 25597 | ** Output help text. |
| 25598 | ** |
| 25599 | ** zPattern describes the set of commands for which help text is provided. |
| 25600 | ** If zPattern is NULL, then show all commands, but only give a one-line |
| 25601 | ** description of each. |
| 25602 | ** |
| 25603 | ** Return the number of matches. |
| 25604 | */ |
| 25605 | static int showHelp(FILE *out, const char *zPattern){ |
| 25606 | int i = 0; |
| 25607 | int j = 0; |
| 25608 | int n = 0; |
| 25609 | char *zPat; |
| 25610 | if( zPattern==0 |
| 25611 | || zPattern[0]=='0' |
| 25612 | || cli_strcmp(zPattern,"-a")==0 |
| 25613 | || cli_strcmp(zPattern,"-all")==0 |
| 25614 | || cli_strcmp(zPattern,"--all")==0 |
| 25615 | ){ |
| 25616 | enum HelpWanted { HW_NoCull = 0, HW_SummaryOnly = 1, HW_Undoc = 2 }; |
| 25617 | enum HelpHave { HH_Undoc = 2, HH_Summary = 1, HH_More = 0 }; |
| 25618 | /* Show all or most commands |
| 25619 | ** *zPattern==0 => summary of documented commands only |
| 25620 | ** *zPattern=='0' => whole help for undocumented commands |
| 25621 | ** Otherwise => whole help for documented commands |
| 25622 | */ |
| 25623 | enum HelpWanted hw = HW_SummaryOnly; |
| 25624 | enum HelpHave hh = HH_More; |
| 25625 | if( zPattern!=0 ){ |
| 25626 | hw = (*zPattern=='0')? HW_NoCull|HW_Undoc : HW_NoCull; |
| 25627 | } |
| 25628 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25629 | switch( azHelp[i][0] ){ |
| 25630 | case ',': |
| 25631 | hh = HH_Summary|HH_Undoc; |
| 25632 | break; |
| 25633 | case '.': |
| 25634 | hh = HH_Summary; |
| 25635 | break; |
| 25636 | default: |
| 25637 | hh &= ~HH_Summary; |
| 25638 | break; |
| 25639 | } |
| 25640 | if( ((hw^hh)&HH_Undoc)==0 ){ |
| 25641 | if( (hh&HH_Summary)!=0 ){ |
| 25642 | sqlite3_fprintf(out, ".%s\n", azHelp[i]+1); |
| 25643 | ++n; |
| 25644 | }else if( (hw&HW_SummaryOnly)==0 ){ |
| 25645 | sqlite3_fprintf(out, "%s\n", azHelp[i]); |
| 25646 | } |
| 25647 | } |
| 25648 | } |
| 25649 | }else{ |
| 25650 | /* Seek documented commands for which zPattern is an exact prefix */ |
| 25651 | zPat = sqlite3_mprintf(".%s*", zPattern); |
| 25652 | shell_check_oom(zPat); |
| 25653 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25654 | if( sqlite3_strglob(zPat, azHelp[i])==0 ){ |
| 25655 | sqlite3_fprintf(out, "%s\n", azHelp[i]); |
| 25656 | j = i+1; |
| 25657 | n++; |
| 25658 | } |
| 25659 | } |
| 25660 | sqlite3_free(zPat); |
| 25661 | if( n ){ |
| 25662 | if( n==1 ){ |
| 25663 | /* when zPattern is a prefix of exactly one command, then include |
| 25664 | ** the details of that command, which should begin at offset j */ |
| 25665 | while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ |
| 25666 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25667 | j++; |
| 25668 | } |
| 25669 | } |
| 25670 | return n; |
| 25671 | } |
| 25672 | /* Look for documented commands that contain zPattern anywhere. |
| 25673 | ** Show complete text of all documented commands that match. */ |
| 25674 | zPat = sqlite3_mprintf("%%%s%%", zPattern); |
| 25675 | shell_check_oom(zPat); |
| 25676 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25677 | if( azHelp[i][0]==',' ){ |
| 25678 | while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; |
| 25679 | continue; |
| 25680 | } |
| 25681 | if( azHelp[i][0]=='.' ) j = i; |
| 25682 | if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ |
| 25683 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25684 | while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ |
| 25685 | j++; |
| 25686 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25687 | } |
| 25688 | i = j; |
| 25689 | n++; |
| 25690 | } |
| 25691 | } |
| 25692 | sqlite3_free(zPat); |
| 25693 | } |
| 25694 | return n; |
| 25695 | } |
| 25696 | |
| 25697 | /* Forward reference */ |
| 25698 | static int process_input(ShellState *p); |
| @@ -25937,10 +25819,43 @@ | |
| 25937 | int sleep = sqlite3_value_int(argv[0]); |
| 25938 | (void)argcUnused; |
| 25939 | sqlite3_sleep(sleep/1000); |
| 25940 | sqlite3_result_int(context, sleep); |
| 25941 | } |
| 25942 | |
| 25943 | /* Flags for open_db(). |
| 25944 | ** |
| 25945 | ** The default behavior of open_db() is to exit(1) if the database fails to |
| 25946 | ** open. The OPEN_DB_KEEPALIVE flag changes that so that it prints an error |
| @@ -26081,11 +25996,11 @@ | |
| 26081 | shellDtostr, 0, 0); |
| 26082 | sqlite3_create_function(p->db, "dtostr", 2, SQLITE_UTF8, 0, |
| 26083 | shellDtostr, 0, 0); |
| 26084 | sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, |
| 26085 | shellAddSchemaName, 0, 0); |
| 26086 | sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, 0, |
| 26087 | shellModuleSchema, 0, 0); |
| 26088 | sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, |
| 26089 | shellPutsFunc, 0, 0); |
| 26090 | sqlite3_create_function(p->db, "usleep",1,SQLITE_UTF8,0, |
| 26091 | shellUSleepFunc, 0, 0); |
| @@ -29541,11 +29456,12 @@ | |
| 29541 | rc = sqlite3_exec(p->db, |
| 29542 | "SELECT sql FROM" |
| 29543 | " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" |
| 29544 | " FROM sqlite_schema UNION ALL" |
| 29545 | " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) " |
| 29546 | "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' " |
| 29547 | "ORDER BY x", |
| 29548 | callback, &data, 0 |
| 29549 | ); |
| 29550 | if( rc==SQLITE_OK ){ |
| 29551 | sqlite3_stmt *pStmt; |
| @@ -31017,11 +30933,11 @@ | |
| 31017 | } |
| 31018 | appendText(&sSelect, " AND ", 0); |
| 31019 | sqlite3_free(zQarg); |
| 31020 | } |
| 31021 | if( bNoSystemTabs ){ |
| 31022 | appendText(&sSelect, "name NOT LIKE 'sqlite_%%' AND ", 0); |
| 31023 | } |
| 31024 | appendText(&sSelect, "sql IS NOT NULL" |
| 31025 | " ORDER BY snum, rowid", 0); |
| 31026 | if( bDebug ){ |
| 31027 | sqlite3_fprintf(p->out, "SQL: %s;\n", sSelect.z); |
| @@ -31448,11 +31364,11 @@ | |
| 31448 | " UNION ALL SELECT 'sqlite_schema'" |
| 31449 | " ORDER BY 1 collate nocase"; |
| 31450 | }else{ |
| 31451 | zSql = "SELECT lower(name) as tname FROM sqlite_schema" |
| 31452 | " WHERE type='table' AND coalesce(rootpage,0)>1" |
| 31453 | " AND name NOT LIKE 'sqlite_%'" |
| 31454 | " ORDER BY 1 collate nocase"; |
| 31455 | } |
| 31456 | sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 31457 | initText(&sQuery); |
| 31458 | initText(&sSql); |
| @@ -31513,11 +31429,11 @@ | |
| 31513 | { |
| 31514 | int lrc; |
| 31515 | char *zRevText = /* Query for reversible to-blob-to-text check */ |
| 31516 | "SELECT lower(name) as tname FROM sqlite_schema\n" |
| 31517 | "WHERE type='table' AND coalesce(rootpage,0)>1\n" |
| 31518 | "AND name NOT LIKE 'sqlite_%%'%s\n" |
| 31519 | "ORDER BY 1 collate nocase"; |
| 31520 | zRevText = sqlite3_mprintf(zRevText, zLike? " AND name LIKE $tspec" : ""); |
| 31521 | zRevText = sqlite3_mprintf( |
| 31522 | /* lower-case query is first run, producing upper-case query. */ |
| 31523 | "with tabcols as materialized(\n" |
| @@ -31709,11 +31625,11 @@ | |
| 31709 | } |
| 31710 | appendText(&s, zDbName, '"'); |
| 31711 | appendText(&s, ".sqlite_schema ", 0); |
| 31712 | if( c=='t' ){ |
| 31713 | appendText(&s," WHERE type IN ('table','view')" |
| 31714 | " AND name NOT LIKE 'sqlite_%'" |
| 31715 | " AND name LIKE ?1", 0); |
| 31716 | }else{ |
| 31717 | appendText(&s," WHERE type='index'" |
| 31718 | " AND tbl_name LIKE ?1", 0); |
| 31719 | } |
| @@ -31803,11 +31719,11 @@ | |
| 31803 | const char *zUsage; /* Usage notes */ |
| 31804 | } aCtrl[] = { |
| 31805 | {"always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" }, |
| 31806 | {"assert", SQLITE_TESTCTRL_ASSERT, 1, "BOOLEAN" }, |
| 31807 | /*{"benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,1, "" },*/ |
| 31808 | /*{"bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "" },*/ |
| 31809 | {"byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" }, |
| 31810 | {"extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" }, |
| 31811 | {"fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"args..." }, |
| 31812 | {"fk_no_action", SQLITE_TESTCTRL_FK_NO_ACTION, 0, "BOOLEAN" }, |
| 31813 | {"imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"}, |
| @@ -31922,10 +31838,11 @@ | |
| 31922 | { 0x02000000, 1, "Coroutines" }, |
| 31923 | { 0x04000000, 1, "NullUnusedCols" }, |
| 31924 | { 0x08000000, 1, "OnePass" }, |
| 31925 | { 0x10000000, 1, "OrderBySubq" }, |
| 31926 | { 0x20000000, 1, "StarQuery" }, |
| 31927 | { 0xffffffff, 0, "All" }, |
| 31928 | }; |
| 31929 | unsigned int curOpt; |
| 31930 | unsigned int newOpt; |
| 31931 | unsigned int m; |
| @@ -32141,10 +32058,53 @@ | |
| 32141 | rc2 = booleanValue(azArg[2]); |
| 32142 | isOk = 3; |
| 32143 | } |
| 32144 | sqlite3_test_control(testctrl, &rc2); |
| 32145 | break; |
| 32146 | case SQLITE_TESTCTRL_FAULT_INSTALL: { |
| 32147 | int kk; |
| 32148 | int bShowHelp = nArg<=2; |
| 32149 | isOk = 3; |
| 32150 | for(kk=2; kk<nArg; kk++){ |
| 32151 |
| --- extsrc/shell.c | |
| +++ extsrc/shell.c | |
| @@ -1266,16 +1266,25 @@ | |
| 1266 | return 0x3fffffff & (int)(z2 - z); |
| 1267 | } |
| 1268 | |
| 1269 | /* |
| 1270 | ** Return the length of a string in characters. Multibyte UTF8 characters |
| 1271 | ** count as a single character for single-width characters, or as two |
| 1272 | ** characters for double-width characters. |
| 1273 | */ |
| 1274 | static int strlenChar(const char *z){ |
| 1275 | int n = 0; |
| 1276 | while( *z ){ |
| 1277 | if( (0x80&z[0])==0 ){ |
| 1278 | n++; |
| 1279 | z++; |
| 1280 | }else{ |
| 1281 | int u = 0; |
| 1282 | int len = decodeUtf8((const u8*)z, &u); |
| 1283 | z += len; |
| 1284 | n += cli_wcwidth(u); |
| 1285 | } |
| 1286 | } |
| 1287 | return n; |
| 1288 | } |
| 1289 | |
| 1290 | /* |
| @@ -1622,34 +1631,10 @@ | |
| 1631 | if( n>350 ) n = 350; |
| 1632 | sqlite3_snprintf(sizeof(z), z, "%#+.*e", n, r); |
| 1633 | sqlite3_result_text(pCtx, z, -1, SQLITE_TRANSIENT); |
| 1634 | } |
| 1635 | |
| 1636 | /* |
| 1637 | ** SQL function: shell_add_schema(S,X) |
| 1638 | ** |
| 1639 | ** Add the schema name X to the CREATE statement in S and return the result. |
| 1640 | ** Examples: |
| @@ -1728,369 +1713,176 @@ | |
| 1713 | ** work here in the middle of this regular program. |
| 1714 | */ |
| 1715 | #define SQLITE_EXTENSION_INIT1 |
| 1716 | #define SQLITE_EXTENSION_INIT2(X) (void)(X) |
| 1717 | |
| 1718 | /************************* Begin ../ext/misc/windirent.h ******************/ |
| 1719 | /* |
| 1720 | ** 2025-06-05 |
| 1721 | ** |
| 1722 | ** The author disclaims copyright to this source code. In place of |
| 1723 | ** a legal notice, here is a blessing: |
| 1724 | ** |
| 1725 | ** May you do good and not evil. |
| 1726 | ** May you find forgiveness for yourself and forgive others. |
| 1727 | ** May you share freely, never taking more than you give. |
| 1728 | ** |
| 1729 | ************************************************************************* |
| 1730 | ** |
| 1731 | ** An implementation of opendir(), readdir(), and closedir() for Windows, |
| 1732 | ** based on the FindFirstFile(), FindNextFile(), and FindClose() APIs |
| 1733 | ** of Win32. |
| 1734 | ** |
| 1735 | ** #include this file inside any C-code module that needs to use |
| 1736 | ** opendir()/readdir()/closedir(). This file is a no-op on non-Windows |
| 1737 | ** machines. On Windows, static functions are defined that implement |
| 1738 | ** those standard interfaces. |
| 1739 | */ |
| 1740 | #if defined(_WIN32) && defined(_MSC_VER) && !defined(SQLITE_WINDIRENT_H) |
| 1741 | #define SQLITE_WINDIRENT_H |
| 1742 | |
| 1743 | #ifndef WIN32_LEAN_AND_MEAN |
| 1744 | #define WIN32_LEAN_AND_MEAN |
| 1745 | #endif |
| 1746 | #include <windows.h> |
| 1747 | #include <io.h> |
| 1748 | #include <stdio.h> |
| 1749 | #include <stdlib.h> |
| 1750 | #include <errno.h> |
| 1751 | #include <limits.h> |
| 1752 | #include <sys/types.h> |
| 1753 | #include <sys/stat.h> |
| 1754 | #include <string.h> |
| 1755 | #ifndef FILENAME_MAX |
| 1756 | # define FILENAME_MAX (260) |
| 1757 | #endif |
| 1758 | #ifndef S_ISREG |
| 1759 | #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) |
| 1760 | #endif |
| 1761 | #ifndef S_ISDIR |
| 1762 | #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
| 1763 | #endif |
| 1764 | #ifndef S_ISLNK |
| 1765 | #define S_ISLNK(m) (0) |
| 1766 | #endif |
| 1767 | typedef unsigned short mode_t; |
| 1768 | |
| 1769 | /* The dirent object for Windows is abbreviated. The only field really |
| 1770 | ** usable by applications is d_name[]. |
| 1771 | */ |
| 1772 | struct dirent { |
| 1773 | int d_ino; /* Inode number (synthesized) */ |
| 1774 | unsigned d_attributes; /* File attributes */ |
| 1775 | char d_name[FILENAME_MAX]; /* Null-terminated filename */ |
| 1776 | }; |
| 1777 | |
| 1778 | /* The internals of DIR are opaque according to standards. So it |
| 1779 | ** does not matter what we put here. */ |
| 1780 | typedef struct DIR DIR; |
| 1781 | struct DIR { |
| 1782 | intptr_t d_handle; /* Handle for findfirst()/findnext() */ |
| 1783 | struct dirent cur; /* Current entry */ |
| 1784 | }; |
| 1785 | |
| 1786 | /* Ignore hidden and system files */ |
| 1787 | #define WindowsFileToIgnore(a) \ |
| 1788 | ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM)) |
| 1789 | |
| 1790 | /* |
| 1791 | ** Close a previously opened directory |
| 1792 | */ |
| 1793 | static int closedir(DIR *pDir){ |
| 1794 | int rc = 0; |
| 1795 | if( pDir==0 ){ |
| 1796 | return EINVAL; |
| 1797 | } |
| 1798 | if( pDir->d_handle!=0 && pDir->d_handle!=(-1) ){ |
| 1799 | rc = _findclose(pDir->d_handle); |
| 1800 | } |
| 1801 | sqlite3_free(pDir); |
| 1802 | return rc; |
| 1803 | } |
| 1804 | |
| 1805 | /* |
| 1806 | ** Open a new directory. The directory name should be UTF-8 encoded. |
| 1807 | ** appropriate translations happen automatically. |
| 1808 | */ |
| 1809 | static DIR *opendir(const char *zDirName){ |
| 1810 | DIR *pDir; |
| 1811 | wchar_t *b1; |
| 1812 | sqlite3_int64 sz; |
| 1813 | struct _wfinddata_t data; |
| 1814 | |
| 1815 | pDir = sqlite3_malloc64( sizeof(DIR) ); |
| 1816 | if( pDir==0 ) return 0; |
| 1817 | memset(pDir, 0, sizeof(DIR)); |
| 1818 | memset(&data, 0, sizeof(data)); |
| 1819 | sz = strlen(zDirName); |
| 1820 | b1 = sqlite3_malloc64( (sz+3)*sizeof(b1[0]) ); |
| 1821 | if( b1==0 ){ |
| 1822 | closedir(pDir); |
| 1823 | return NULL; |
| 1824 | } |
| 1825 | sz = MultiByteToWideChar(CP_UTF8, 0, zDirName, sz, b1, sz); |
| 1826 | b1[sz++] = '\\'; |
| 1827 | b1[sz++] = '*'; |
| 1828 | b1[sz] = 0; |
| 1829 | if( sz+1>sizeof(data.name)/sizeof(data.name[0]) ){ |
| 1830 | closedir(pDir); |
| 1831 | sqlite3_free(b1); |
| 1832 | return NULL; |
| 1833 | } |
| 1834 | memcpy(data.name, b1, (sz+1)*sizeof(b1[0])); |
| 1835 | sqlite3_free(b1); |
| 1836 | pDir->d_handle = _wfindfirst(data.name, &data); |
| 1837 | if( pDir->d_handle<0 ){ |
| 1838 | closedir(pDir); |
| 1839 | return NULL; |
| 1840 | } |
| 1841 | while( WindowsFileToIgnore(data) ){ |
| 1842 | memset(&data, 0, sizeof(data)); |
| 1843 | if( _wfindnext(pDir->d_handle, &data)==-1 ){ |
| 1844 | closedir(pDir); |
| 1845 | return NULL; |
| 1846 | } |
| 1847 | } |
| 1848 | pDir->cur.d_ino = 0; |
| 1849 | pDir->cur.d_attributes = data.attrib; |
| 1850 | WideCharToMultiByte(CP_UTF8, 0, data.name, -1, |
| 1851 | pDir->cur.d_name, FILENAME_MAX, 0, 0); |
| 1852 | return pDir; |
| 1853 | } |
| 1854 | |
| 1855 | /* |
| 1856 | ** Read the next entry from a directory. |
| 1857 | ** |
| 1858 | ** The returned struct-dirent object is managed by DIR. It is only |
| 1859 | ** valid until the next readdir() or closedir() call. Only the |
| 1860 | ** d_name[] field is meaningful. The d_name[] value has been |
| 1861 | ** translated into UTF8. |
| 1862 | */ |
| 1863 | static struct dirent *readdir(DIR *pDir){ |
| 1864 | struct _wfinddata_t data; |
| 1865 | if( pDir==0 ) return 0; |
| 1866 | if( (pDir->cur.d_ino++)==0 ){ |
| 1867 | return &pDir->cur; |
| 1868 | } |
| 1869 | do{ |
| 1870 | memset(&data, 0, sizeof(data)); |
| 1871 | if( _wfindnext(pDir->d_handle, &data)==-1 ){ |
| 1872 | return NULL; |
| 1873 | } |
| 1874 | }while( WindowsFileToIgnore(data) ); |
| 1875 | pDir->cur.d_attributes = data.attrib; |
| 1876 | WideCharToMultiByte(CP_UTF8, 0, data.name, -1, |
| 1877 | pDir->cur.d_name, FILENAME_MAX, 0, 0); |
| 1878 | return &pDir->cur; |
| 1879 | } |
| 1880 | |
| 1881 | #endif /* defined(_WIN32) && defined(_MSC_VER) */ |
| 1882 | |
| 1883 | /************************* End ../ext/misc/windirent.h ********************/ |
| 1884 | /************************* Begin ../ext/misc/memtrace.c ******************/ |
| 1885 | /* |
| 1886 | ** 2019-01-21 |
| 1887 | ** |
| 1888 | ** The author disclaims copyright to this source code. In place of |
| @@ -8054,10 +7846,11 @@ | |
| 7846 | ** mode: Value of stat.st_mode for directory entry (an integer). |
| 7847 | ** mtime: Value of stat.st_mtime for directory entry (an integer). |
| 7848 | ** data: For a regular file, a blob containing the file data. For a |
| 7849 | ** symlink, a text value containing the text of the link. For a |
| 7850 | ** directory, NULL. |
| 7851 | ** level: Directory hierarchy level. Topmost is 1. |
| 7852 | ** |
| 7853 | ** If a non-NULL value is specified for the optional $dir parameter and |
| 7854 | ** $path is a relative path, then $path is interpreted relative to $dir. |
| 7855 | ** And the paths returned in the "name" column of the table are also |
| 7856 | ** relative to directory $dir. |
| @@ -8079,24 +7872,17 @@ | |
| 7872 | #if !defined(_WIN32) && !defined(WIN32) |
| 7873 | # include <unistd.h> |
| 7874 | # include <dirent.h> |
| 7875 | # include <utime.h> |
| 7876 | # include <sys/time.h> |
| 7877 | # define STRUCT_STAT struct stat |
| 7878 | #else |
| 7879 | /* # include "windirent.h" */ |
| 7880 | # include <direct.h> |
| 7881 | # define STRUCT_STAT struct _stat |
| 7882 | # define chmod(path,mode) fileio_chmod(path,mode) |
| 7883 | # define mkdir(path,mode) fileio_mkdir(path) |
| 7884 | #endif |
| 7885 | #include <time.h> |
| 7886 | #include <errno.h> |
| 7887 | |
| 7888 | /* When used as part of the CLI, the sqlite3_stdio.h module will have |
| @@ -8108,18 +7894,54 @@ | |
| 7894 | #endif |
| 7895 | |
| 7896 | /* |
| 7897 | ** Structure of the fsdir() table-valued function |
| 7898 | */ |
| 7899 | /* 0 1 2 3 4 5 6 */ |
| 7900 | #define FSDIR_SCHEMA "(name,mode,mtime,data,level,path HIDDEN,dir HIDDEN)" |
| 7901 | |
| 7902 | #define FSDIR_COLUMN_NAME 0 /* Name of the file */ |
| 7903 | #define FSDIR_COLUMN_MODE 1 /* Access mode */ |
| 7904 | #define FSDIR_COLUMN_MTIME 2 /* Last modification time */ |
| 7905 | #define FSDIR_COLUMN_DATA 3 /* File content */ |
| 7906 | #define FSDIR_COLUMN_LEVEL 4 /* Level. Topmost is 1 */ |
| 7907 | #define FSDIR_COLUMN_PATH 5 /* Path to top of search */ |
| 7908 | #define FSDIR_COLUMN_DIR 6 /* Path is relative to this directory */ |
| 7909 | |
| 7910 | /* |
| 7911 | ** UTF8 chmod() function for Windows |
| 7912 | */ |
| 7913 | #if defined(_WIN32) || defined(WIN32) |
| 7914 | static int fileio_chmod(const char *zPath, int pmode){ |
| 7915 | sqlite3_int64 sz = strlen(zPath); |
| 7916 | wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); |
| 7917 | int rc; |
| 7918 | if( b1==0 ) return -1; |
| 7919 | sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); |
| 7920 | b1[sz] = 0; |
| 7921 | rc = _wchmod(b1, pmode); |
| 7922 | sqlite3_free(b1); |
| 7923 | return rc; |
| 7924 | } |
| 7925 | #endif |
| 7926 | |
| 7927 | /* |
| 7928 | ** UTF8 mkdir() function for Windows |
| 7929 | */ |
| 7930 | #if defined(_WIN32) || defined(WIN32) |
| 7931 | static int fileio_mkdir(const char *zPath){ |
| 7932 | sqlite3_int64 sz = strlen(zPath); |
| 7933 | wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); |
| 7934 | int rc; |
| 7935 | if( b1==0 ) return -1; |
| 7936 | sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); |
| 7937 | b1[sz] = 0; |
| 7938 | rc = _wmkdir(b1); |
| 7939 | sqlite3_free(b1); |
| 7940 | return rc; |
| 7941 | } |
| 7942 | #endif |
| 7943 | |
| 7944 | |
| 7945 | /* |
| 7946 | ** Set the result stored by context ctx to a blob containing the |
| 7947 | ** contents of file zName. Or, leave the result unchanged (NULL) |
| @@ -8247,11 +8069,11 @@ | |
| 8069 | ** buffer to UTC. This is necessary on Win32, where the runtime library |
| 8070 | ** appears to return these values as local times. |
| 8071 | */ |
| 8072 | static void statTimesToUtc( |
| 8073 | const char *zPath, |
| 8074 | STRUCT_STAT *pStatBuf |
| 8075 | ){ |
| 8076 | HANDLE hFindFile; |
| 8077 | WIN32_FIND_DATAW fd; |
| 8078 | LPWSTR zUnicodeName; |
| 8079 | extern LPWSTR sqlite3_win32_utf8_to_unicode(const char*); |
| @@ -8275,14 +8097,20 @@ | |
| 8097 | ** is required in order for the included time to be returned as UTC. On all |
| 8098 | ** other systems, this function simply calls stat(). |
| 8099 | */ |
| 8100 | static int fileStat( |
| 8101 | const char *zPath, |
| 8102 | STRUCT_STAT *pStatBuf |
| 8103 | ){ |
| 8104 | #if defined(_WIN32) |
| 8105 | sqlite3_int64 sz = strlen(zPath); |
| 8106 | wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) ); |
| 8107 | int rc; |
| 8108 | if( b1==0 ) return 1; |
| 8109 | sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz); |
| 8110 | b1[sz] = 0; |
| 8111 | rc = _wstat(b1, pStatBuf); |
| 8112 | if( rc==0 ) statTimesToUtc(zPath, pStatBuf); |
| 8113 | return rc; |
| 8114 | #else |
| 8115 | return stat(zPath, pStatBuf); |
| 8116 | #endif |
| @@ -8293,16 +8121,14 @@ | |
| 8121 | ** is required in order for the included time to be returned as UTC. On all |
| 8122 | ** other systems, this function simply calls lstat(). |
| 8123 | */ |
| 8124 | static int fileLinkStat( |
| 8125 | const char *zPath, |
| 8126 | STRUCT_STAT *pStatBuf |
| 8127 | ){ |
| 8128 | #if defined(_WIN32) |
| 8129 | return fileStat(zPath, pStatBuf); |
| 8130 | #else |
| 8131 | return lstat(zPath, pStatBuf); |
| 8132 | #endif |
| 8133 | } |
| 8134 | |
| @@ -8328,11 +8154,11 @@ | |
| 8154 | }else{ |
| 8155 | int nCopy = (int)strlen(zCopy); |
| 8156 | int i = 1; |
| 8157 | |
| 8158 | while( rc==SQLITE_OK ){ |
| 8159 | STRUCT_STAT sStat; |
| 8160 | int rc2; |
| 8161 | |
| 8162 | for(; zCopy[i]!='/' && i<nCopy; i++); |
| 8163 | if( i==nCopy ) break; |
| 8164 | zCopy[i] = '\0'; |
| @@ -8378,11 +8204,11 @@ | |
| 8204 | if( mkdir(zFile, mode) ){ |
| 8205 | /* The mkdir() call to create the directory failed. This might not |
| 8206 | ** be an error though - if there is already a directory at the same |
| 8207 | ** path and either the permissions already match or can be changed |
| 8208 | ** to do so using chmod(), it is not an error. */ |
| 8209 | STRUCT_STAT sStat; |
| 8210 | if( errno!=EEXIST |
| 8211 | || 0!=fileStat(zFile, &sStat) |
| 8212 | || !S_ISDIR(sStat.st_mode) |
| 8213 | || ((sStat.st_mode&0777)!=(mode&0777) && 0!=chmod(zFile, mode&0777)) |
| 8214 | ){ |
| @@ -8574,17 +8400,18 @@ | |
| 8400 | |
| 8401 | struct fsdir_cursor { |
| 8402 | sqlite3_vtab_cursor base; /* Base class - must be first */ |
| 8403 | |
| 8404 | int nLvl; /* Number of entries in aLvl[] array */ |
| 8405 | int mxLvl; /* Maximum level */ |
| 8406 | int iLvl; /* Index of current entry */ |
| 8407 | FsdirLevel *aLvl; /* Hierarchy of directories being traversed */ |
| 8408 | |
| 8409 | const char *zBase; |
| 8410 | int nBase; |
| 8411 | |
| 8412 | STRUCT_STAT sStat; /* Current lstat() results */ |
| 8413 | char *zPath; /* Path to current entry */ |
| 8414 | sqlite3_int64 iRowid; /* Current rowid */ |
| 8415 | }; |
| 8416 | |
| 8417 | typedef struct fsdir_tab fsdir_tab; |
| @@ -8692,11 +8519,11 @@ | |
| 8519 | static int fsdirNext(sqlite3_vtab_cursor *cur){ |
| 8520 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8521 | mode_t m = pCur->sStat.st_mode; |
| 8522 | |
| 8523 | pCur->iRowid++; |
| 8524 | if( S_ISDIR(m) && pCur->iLvl+3<pCur->mxLvl ){ |
| 8525 | /* Descend into this directory */ |
| 8526 | int iNew = pCur->iLvl + 1; |
| 8527 | FsdirLevel *pLvl; |
| 8528 | if( iNew>=pCur->nLvl ){ |
| 8529 | int nNew = iNew+1; |
| @@ -8800,11 +8627,15 @@ | |
| 8627 | if( aBuf!=aStatic ) sqlite3_free(aBuf); |
| 8628 | #endif |
| 8629 | }else{ |
| 8630 | readFileContents(ctx, pCur->zPath); |
| 8631 | } |
| 8632 | break; |
| 8633 | } |
| 8634 | case FSDIR_COLUMN_LEVEL: |
| 8635 | sqlite3_result_int(ctx, pCur->iLvl+2); |
| 8636 | break; |
| 8637 | case FSDIR_COLUMN_PATH: |
| 8638 | default: { |
| 8639 | /* The FSDIR_COLUMN_PATH and FSDIR_COLUMN_DIR are input parameters. |
| 8640 | ** always return their values as NULL */ |
| 8641 | break; |
| @@ -8834,36 +8665,50 @@ | |
| 8665 | } |
| 8666 | |
| 8667 | /* |
| 8668 | ** xFilter callback. |
| 8669 | ** |
| 8670 | ** idxNum bit Meaning |
| 8671 | ** 0x01 PATH=N |
| 8672 | ** 0x02 DIR=N |
| 8673 | ** 0x04 LEVEL<N |
| 8674 | ** 0x08 LEVEL<=N |
| 8675 | */ |
| 8676 | static int fsdirFilter( |
| 8677 | sqlite3_vtab_cursor *cur, |
| 8678 | int idxNum, const char *idxStr, |
| 8679 | int argc, sqlite3_value **argv |
| 8680 | ){ |
| 8681 | const char *zDir = 0; |
| 8682 | fsdir_cursor *pCur = (fsdir_cursor*)cur; |
| 8683 | int i; |
| 8684 | (void)idxStr; |
| 8685 | fsdirResetCursor(pCur); |
| 8686 | |
| 8687 | if( idxNum==0 ){ |
| 8688 | fsdirSetErrmsg(pCur, "table function fsdir requires an argument"); |
| 8689 | return SQLITE_ERROR; |
| 8690 | } |
| 8691 | |
| 8692 | assert( (idxNum & 0x01)!=0 && argc>0 ); |
| 8693 | zDir = (const char*)sqlite3_value_text(argv[0]); |
| 8694 | if( zDir==0 ){ |
| 8695 | fsdirSetErrmsg(pCur, "table function fsdir requires a non-NULL argument"); |
| 8696 | return SQLITE_ERROR; |
| 8697 | } |
| 8698 | i = 1; |
| 8699 | if( (idxNum & 0x02)!=0 ){ |
| 8700 | assert( argc>i ); |
| 8701 | pCur->zBase = (const char*)sqlite3_value_text(argv[i++]); |
| 8702 | } |
| 8703 | if( (idxNum & 0x0c)!=0 ){ |
| 8704 | assert( argc>i ); |
| 8705 | pCur->mxLvl = sqlite3_value_int(argv[i++]); |
| 8706 | if( idxNum & 0x08 ) pCur->mxLvl++; |
| 8707 | if( pCur->mxLvl<=0 ) pCur->mxLvl = 1000000000; |
| 8708 | }else{ |
| 8709 | pCur->mxLvl = 1000000000; |
| 8710 | } |
| 8711 | if( pCur->zBase ){ |
| 8712 | pCur->nBase = (int)strlen(pCur->zBase)+1; |
| 8713 | pCur->zPath = sqlite3_mprintf("%s/%s", pCur->zBase, zDir); |
| 8714 | }else{ |
| @@ -8888,48 +8733,75 @@ | |
| 8733 | ** plan. |
| 8734 | ** |
| 8735 | ** In this implementation idxNum is used to represent the |
| 8736 | ** query plan. idxStr is unused. |
| 8737 | ** |
| 8738 | ** The query plan is represented by bits in idxNum: |
| 8739 | ** |
| 8740 | ** 0x01 The path value is supplied by argv[0] |
| 8741 | ** 0x02 dir is in argv[1] |
| 8742 | ** 0x04 maxdepth is in argv[1] or [2] |
| 8743 | */ |
| 8744 | static int fsdirBestIndex( |
| 8745 | sqlite3_vtab *tab, |
| 8746 | sqlite3_index_info *pIdxInfo |
| 8747 | ){ |
| 8748 | int i; /* Loop over constraints */ |
| 8749 | int idxPath = -1; /* Index in pIdxInfo->aConstraint of PATH= */ |
| 8750 | int idxDir = -1; /* Index in pIdxInfo->aConstraint of DIR= */ |
| 8751 | int idxLevel = -1; /* Index in pIdxInfo->aConstraint of LEVEL< or <= */ |
| 8752 | int idxLevelEQ = 0; /* 0x08 for LEVEL<= or LEVEL=. 0x04 for LEVEL< */ |
| 8753 | int omitLevel = 0; /* omit the LEVEL constraint */ |
| 8754 | int seenPath = 0; /* True if an unusable PATH= constraint is seen */ |
| 8755 | int seenDir = 0; /* True if an unusable DIR= constraint is seen */ |
| 8756 | const struct sqlite3_index_constraint *pConstraint; |
| 8757 | |
| 8758 | (void)tab; |
| 8759 | pConstraint = pIdxInfo->aConstraint; |
| 8760 | for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ |
| 8761 | if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ |
| 8762 | switch( pConstraint->iColumn ){ |
| 8763 | case FSDIR_COLUMN_PATH: { |
| 8764 | if( pConstraint->usable ){ |
| 8765 | idxPath = i; |
| 8766 | seenPath = 0; |
| 8767 | }else if( idxPath<0 ){ |
| 8768 | seenPath = 1; |
| 8769 | } |
| 8770 | break; |
| 8771 | } |
| 8772 | case FSDIR_COLUMN_DIR: { |
| 8773 | if( pConstraint->usable ){ |
| 8774 | idxDir = i; |
| 8775 | seenDir = 0; |
| 8776 | }else if( idxDir<0 ){ |
| 8777 | seenDir = 1; |
| 8778 | } |
| 8779 | break; |
| 8780 | } |
| 8781 | case FSDIR_COLUMN_LEVEL: { |
| 8782 | if( pConstraint->usable && idxLevel<0 ){ |
| 8783 | idxLevel = i; |
| 8784 | idxLevelEQ = 0x08; |
| 8785 | omitLevel = 0; |
| 8786 | } |
| 8787 | break; |
| 8788 | } |
| 8789 | } |
| 8790 | }else |
| 8791 | if( pConstraint->iColumn==FSDIR_COLUMN_LEVEL |
| 8792 | && pConstraint->usable |
| 8793 | && idxLevel<0 |
| 8794 | ){ |
| 8795 | if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LE ){ |
| 8796 | idxLevel = i; |
| 8797 | idxLevelEQ = 0x08; |
| 8798 | omitLevel = 1; |
| 8799 | }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_LT ){ |
| 8800 | idxLevel = i; |
| 8801 | idxLevelEQ = 0x04; |
| 8802 | omitLevel = 1; |
| 8803 | } |
| 8804 | } |
| 8805 | } |
| 8806 | if( seenPath || seenDir ){ |
| 8807 | /* If input parameters are unusable, disallow this plan */ |
| @@ -8942,18 +8814,24 @@ | |
| 8814 | ** number. Leave it unchanged. */ |
| 8815 | pIdxInfo->estimatedRows = 0x7fffffff; |
| 8816 | }else{ |
| 8817 | pIdxInfo->aConstraintUsage[idxPath].omit = 1; |
| 8818 | pIdxInfo->aConstraintUsage[idxPath].argvIndex = 1; |
| 8819 | pIdxInfo->idxNum = 0x01; |
| 8820 | pIdxInfo->estimatedCost = 1.0e9; |
| 8821 | i = 2; |
| 8822 | if( idxDir>=0 ){ |
| 8823 | pIdxInfo->aConstraintUsage[idxDir].omit = 1; |
| 8824 | pIdxInfo->aConstraintUsage[idxDir].argvIndex = i++; |
| 8825 | pIdxInfo->idxNum |= 0x02; |
| 8826 | pIdxInfo->estimatedCost /= 1.0e4; |
| 8827 | } |
| 8828 | if( idxLevel>=0 ){ |
| 8829 | pIdxInfo->aConstraintUsage[idxLevel].omit = omitLevel; |
| 8830 | pIdxInfo->aConstraintUsage[idxLevel].argvIndex = i++; |
| 8831 | pIdxInfo->idxNum |= idxLevelEQ; |
| 8832 | pIdxInfo->estimatedCost /= 1.0e4; |
| 8833 | } |
| 8834 | } |
| 8835 | |
| 8836 | return SQLITE_OK; |
| 8837 | } |
| @@ -16808,11 +16686,11 @@ | |
| 16686 | case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break; |
| 16687 | case SQLITE_FCNTL_PRAGMA: { |
| 16688 | const char *const* a = (const char*const*)pArg; |
| 16689 | if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){ |
| 16690 | const u8 *zArg = (const u8*)a[2]; |
| 16691 | if( zArg[0]>='0' && zArg[0]<='9' ){ |
| 16692 | pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0); |
| 16693 | }else{ |
| 16694 | static const struct { |
| 16695 | const char *z; |
| 16696 | unsigned int m; |
| @@ -18709,10 +18587,13 @@ | |
| 18587 | rc = sqlite3_create_module(db, "sqlite_dbptr", &dbdata_module, (void*)1); |
| 18588 | } |
| 18589 | return rc; |
| 18590 | } |
| 18591 | |
| 18592 | #ifdef _WIN32 |
| 18593 | |
| 18594 | #endif |
| 18595 | int sqlite3_dbdata_init( |
| 18596 | sqlite3 *db, |
| 18597 | char **pzErrMsg, |
| 18598 | const sqlite3_api_routines *pApi |
| 18599 | ){ |
| @@ -25592,107 +25473,108 @@ | |
| 25473 | " --plain Show results as text/plain, not as HTML", |
| 25474 | #endif |
| 25475 | }; |
| 25476 | |
| 25477 | /* |
| 25478 | ** Output help text for commands that match zPattern. |
| 25479 | ** |
| 25480 | ** * If zPattern is NULL, then show all documented commands, but |
| 25481 | ** only give a one-line summary of each. |
| 25482 | ** |
| 25483 | ** * If zPattern is "-a" or "-all" or "--all" then show all help text |
| 25484 | ** for all commands except undocumented commands. |
| 25485 | ** |
| 25486 | ** * If zPattern is "0" then show all help for undocumented commands. |
| 25487 | ** Undocumented commands begin with "," instead of "." in the azHelp[] |
| 25488 | ** array. |
| 25489 | ** |
| 25490 | ** * If zPattern is a prefix for one or more documented commands, then |
| 25491 | ** show help for those commands. If only a single command matches the |
| 25492 | ** prefix, show the full text of the help. If multiple commands match, |
| 25493 | ** Only show just the first line of each. |
| 25494 | ** |
| 25495 | ** * Otherwise, show the complete text of any documented command for which |
| 25496 | ** zPattern is a LIKE match for any text within that command help |
| 25497 | ** text. |
| 25498 | ** |
| 25499 | ** Return the number commands that match zPattern. |
| 25500 | */ |
| 25501 | static int showHelp(FILE *out, const char *zPattern){ |
| 25502 | int i = 0; |
| 25503 | int j = 0; |
| 25504 | int n = 0; |
| 25505 | char *zPat; |
| 25506 | if( zPattern==0 ){ |
| 25507 | /* Show just the first line for all help topics */ |
| 25508 | zPattern = "[a-z]"; |
| 25509 | }else if( cli_strcmp(zPattern,"-a")==0 |
| 25510 | || cli_strcmp(zPattern,"-all")==0 |
| 25511 | || cli_strcmp(zPattern,"--all")==0 |
| 25512 | ){ |
| 25513 | /* Show everything except undocumented commands */ |
| 25514 | zPattern = "."; |
| 25515 | }else if( cli_strcmp(zPattern,"0")==0 ){ |
| 25516 | /* Show complete help text of undocumented commands */ |
| 25517 | int show = 0; |
| 25518 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25519 | if( azHelp[i][0]=='.' ){ |
| 25520 | show = 0; |
| 25521 | }else if( azHelp[i][0]==',' ){ |
| 25522 | show = 1; |
| 25523 | sqlite3_fprintf(out, ".%s\n", &azHelp[i][1]); |
| 25524 | n++; |
| 25525 | }else if( show ){ |
| 25526 | sqlite3_fprintf(out, "%s\n", azHelp[i]); |
| 25527 | } |
| 25528 | } |
| 25529 | return n; |
| 25530 | } |
| 25531 | |
| 25532 | /* Seek documented commands for which zPattern is an exact prefix */ |
| 25533 | zPat = sqlite3_mprintf(".%s*", zPattern); |
| 25534 | shell_check_oom(zPat); |
| 25535 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25536 | if( sqlite3_strglob(zPat, azHelp[i])==0 ){ |
| 25537 | sqlite3_fprintf(out, "%s\n", azHelp[i]); |
| 25538 | j = i+1; |
| 25539 | n++; |
| 25540 | } |
| 25541 | } |
| 25542 | sqlite3_free(zPat); |
| 25543 | if( n ){ |
| 25544 | if( n==1 ){ |
| 25545 | /* when zPattern is a prefix of exactly one command, then include |
| 25546 | ** the details of that command, which should begin at offset j */ |
| 25547 | while( j<ArraySize(azHelp)-1 && azHelp[j][0]==' ' ){ |
| 25548 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25549 | j++; |
| 25550 | } |
| 25551 | } |
| 25552 | return n; |
| 25553 | } |
| 25554 | |
| 25555 | /* Look for documented commands that contain zPattern anywhere. |
| 25556 | ** Show complete text of all documented commands that match. */ |
| 25557 | zPat = sqlite3_mprintf("%%%s%%", zPattern); |
| 25558 | shell_check_oom(zPat); |
| 25559 | for(i=0; i<ArraySize(azHelp); i++){ |
| 25560 | if( azHelp[i][0]==',' ){ |
| 25561 | while( i<ArraySize(azHelp)-1 && azHelp[i+1][0]==' ' ) ++i; |
| 25562 | continue; |
| 25563 | } |
| 25564 | if( azHelp[i][0]=='.' ) j = i; |
| 25565 | if( sqlite3_strlike(zPat, azHelp[i], 0)==0 ){ |
| 25566 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25567 | while( j<ArraySize(azHelp)-1 && azHelp[j+1][0]==' ' ){ |
| 25568 | j++; |
| 25569 | sqlite3_fprintf(out, "%s\n", azHelp[j]); |
| 25570 | } |
| 25571 | i = j; |
| 25572 | n++; |
| 25573 | } |
| 25574 | } |
| 25575 | sqlite3_free(zPat); |
| 25576 | return n; |
| 25577 | } |
| 25578 | |
| 25579 | /* Forward reference */ |
| 25580 | static int process_input(ShellState *p); |
| @@ -25937,10 +25819,43 @@ | |
| 25819 | int sleep = sqlite3_value_int(argv[0]); |
| 25820 | (void)argcUnused; |
| 25821 | sqlite3_sleep(sleep/1000); |
| 25822 | sqlite3_result_int(context, sleep); |
| 25823 | } |
| 25824 | |
| 25825 | /* |
| 25826 | ** SQL function: shell_module_schema(X) |
| 25827 | ** |
| 25828 | ** Return a fake schema for the table-valued function or eponymous virtual |
| 25829 | ** table X. |
| 25830 | */ |
| 25831 | static void shellModuleSchema( |
| 25832 | sqlite3_context *pCtx, |
| 25833 | int nVal, |
| 25834 | sqlite3_value **apVal |
| 25835 | ){ |
| 25836 | const char *zName; |
| 25837 | char *zFake; |
| 25838 | ShellState *p = (ShellState*)sqlite3_user_data(pCtx); |
| 25839 | FILE *pSavedLog = p->pLog; |
| 25840 | UNUSED_PARAMETER(nVal); |
| 25841 | zName = (const char*)sqlite3_value_text(apVal[0]); |
| 25842 | |
| 25843 | /* Temporarily disable the ".log" when calling shellFakeSchema() because |
| 25844 | ** shellFakeSchema() might generate failures for some ephemeral virtual |
| 25845 | ** tables due to missing arguments. Example: fts4aux. |
| 25846 | ** https://sqlite.org/forum/forumpost/42fe6520b803be51 */ |
| 25847 | p->pLog = 0; |
| 25848 | zFake = zName? shellFakeSchema(sqlite3_context_db_handle(pCtx), 0, zName) : 0; |
| 25849 | p->pLog = pSavedLog; |
| 25850 | |
| 25851 | if( zFake ){ |
| 25852 | sqlite3_result_text(pCtx, sqlite3_mprintf("/* %s */", zFake), |
| 25853 | -1, sqlite3_free); |
| 25854 | free(zFake); |
| 25855 | } |
| 25856 | } |
| 25857 | |
| 25858 | /* Flags for open_db(). |
| 25859 | ** |
| 25860 | ** The default behavior of open_db() is to exit(1) if the database fails to |
| 25861 | ** open. The OPEN_DB_KEEPALIVE flag changes that so that it prints an error |
| @@ -26081,11 +25996,11 @@ | |
| 25996 | shellDtostr, 0, 0); |
| 25997 | sqlite3_create_function(p->db, "dtostr", 2, SQLITE_UTF8, 0, |
| 25998 | shellDtostr, 0, 0); |
| 25999 | sqlite3_create_function(p->db, "shell_add_schema", 3, SQLITE_UTF8, 0, |
| 26000 | shellAddSchemaName, 0, 0); |
| 26001 | sqlite3_create_function(p->db, "shell_module_schema", 1, SQLITE_UTF8, p, |
| 26002 | shellModuleSchema, 0, 0); |
| 26003 | sqlite3_create_function(p->db, "shell_putsnl", 1, SQLITE_UTF8, p, |
| 26004 | shellPutsFunc, 0, 0); |
| 26005 | sqlite3_create_function(p->db, "usleep",1,SQLITE_UTF8,0, |
| 26006 | shellUSleepFunc, 0, 0); |
| @@ -29541,11 +29456,12 @@ | |
| 29456 | rc = sqlite3_exec(p->db, |
| 29457 | "SELECT sql FROM" |
| 29458 | " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x" |
| 29459 | " FROM sqlite_schema UNION ALL" |
| 29460 | " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) " |
| 29461 | "WHERE type!='meta' AND sql NOTNULL" |
| 29462 | " AND name NOT LIKE 'sqlite__%' ESCAPE '_' " |
| 29463 | "ORDER BY x", |
| 29464 | callback, &data, 0 |
| 29465 | ); |
| 29466 | if( rc==SQLITE_OK ){ |
| 29467 | sqlite3_stmt *pStmt; |
| @@ -31017,11 +30933,11 @@ | |
| 30933 | } |
| 30934 | appendText(&sSelect, " AND ", 0); |
| 30935 | sqlite3_free(zQarg); |
| 30936 | } |
| 30937 | if( bNoSystemTabs ){ |
| 30938 | appendText(&sSelect, "name NOT LIKE 'sqlite__%%' ESCAPE '_' AND ", 0); |
| 30939 | } |
| 30940 | appendText(&sSelect, "sql IS NOT NULL" |
| 30941 | " ORDER BY snum, rowid", 0); |
| 30942 | if( bDebug ){ |
| 30943 | sqlite3_fprintf(p->out, "SQL: %s;\n", sSelect.z); |
| @@ -31448,11 +31364,11 @@ | |
| 31364 | " UNION ALL SELECT 'sqlite_schema'" |
| 31365 | " ORDER BY 1 collate nocase"; |
| 31366 | }else{ |
| 31367 | zSql = "SELECT lower(name) as tname FROM sqlite_schema" |
| 31368 | " WHERE type='table' AND coalesce(rootpage,0)>1" |
| 31369 | " AND name NOT LIKE 'sqlite__%' ESCAPE '_'" |
| 31370 | " ORDER BY 1 collate nocase"; |
| 31371 | } |
| 31372 | sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); |
| 31373 | initText(&sQuery); |
| 31374 | initText(&sSql); |
| @@ -31513,11 +31429,11 @@ | |
| 31429 | { |
| 31430 | int lrc; |
| 31431 | char *zRevText = /* Query for reversible to-blob-to-text check */ |
| 31432 | "SELECT lower(name) as tname FROM sqlite_schema\n" |
| 31433 | "WHERE type='table' AND coalesce(rootpage,0)>1\n" |
| 31434 | "AND name NOT LIKE 'sqlite__%%' ESCAPE '_'%s\n" |
| 31435 | "ORDER BY 1 collate nocase"; |
| 31436 | zRevText = sqlite3_mprintf(zRevText, zLike? " AND name LIKE $tspec" : ""); |
| 31437 | zRevText = sqlite3_mprintf( |
| 31438 | /* lower-case query is first run, producing upper-case query. */ |
| 31439 | "with tabcols as materialized(\n" |
| @@ -31709,11 +31625,11 @@ | |
| 31625 | } |
| 31626 | appendText(&s, zDbName, '"'); |
| 31627 | appendText(&s, ".sqlite_schema ", 0); |
| 31628 | if( c=='t' ){ |
| 31629 | appendText(&s," WHERE type IN ('table','view')" |
| 31630 | " AND name NOT LIKE 'sqlite__%' ESCAPE '_'" |
| 31631 | " AND name LIKE ?1", 0); |
| 31632 | }else{ |
| 31633 | appendText(&s," WHERE type='index'" |
| 31634 | " AND tbl_name LIKE ?1", 0); |
| 31635 | } |
| @@ -31803,11 +31719,11 @@ | |
| 31719 | const char *zUsage; /* Usage notes */ |
| 31720 | } aCtrl[] = { |
| 31721 | {"always", SQLITE_TESTCTRL_ALWAYS, 1, "BOOLEAN" }, |
| 31722 | {"assert", SQLITE_TESTCTRL_ASSERT, 1, "BOOLEAN" }, |
| 31723 | /*{"benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS,1, "" },*/ |
| 31724 | {"bitvec_test", SQLITE_TESTCTRL_BITVEC_TEST, 1, "SIZE INT-ARRAY"}, |
| 31725 | {"byteorder", SQLITE_TESTCTRL_BYTEORDER, 0, "" }, |
| 31726 | {"extra_schema_checks",SQLITE_TESTCTRL_EXTRA_SCHEMA_CHECKS,0,"BOOLEAN" }, |
| 31727 | {"fault_install", SQLITE_TESTCTRL_FAULT_INSTALL, 1,"args..." }, |
| 31728 | {"fk_no_action", SQLITE_TESTCTRL_FK_NO_ACTION, 0, "BOOLEAN" }, |
| 31729 | {"imposter", SQLITE_TESTCTRL_IMPOSTER,1,"SCHEMA ON/OFF ROOTPAGE"}, |
| @@ -31922,10 +31838,11 @@ | |
| 31838 | { 0x02000000, 1, "Coroutines" }, |
| 31839 | { 0x04000000, 1, "NullUnusedCols" }, |
| 31840 | { 0x08000000, 1, "OnePass" }, |
| 31841 | { 0x10000000, 1, "OrderBySubq" }, |
| 31842 | { 0x20000000, 1, "StarQuery" }, |
| 31843 | { 0x40000000, 1, "ExistsToJoin" }, |
| 31844 | { 0xffffffff, 0, "All" }, |
| 31845 | }; |
| 31846 | unsigned int curOpt; |
| 31847 | unsigned int newOpt; |
| 31848 | unsigned int m; |
| @@ -32141,10 +32058,53 @@ | |
| 32058 | rc2 = booleanValue(azArg[2]); |
| 32059 | isOk = 3; |
| 32060 | } |
| 32061 | sqlite3_test_control(testctrl, &rc2); |
| 32062 | break; |
| 32063 | case SQLITE_TESTCTRL_BITVEC_TEST: { |
| 32064 | /* Examples: |
| 32065 | ** .testctrl bitvec_test 100 6,1 -- Show BITVEC constants |
| 32066 | ** .testctrl bitvec_test 1000 1,12,7,3 -- Simple test |
| 32067 | ** ---- -------- |
| 32068 | ** size of Bitvec -----^ ^--- aOp array. 0 added at end. |
| 32069 | ** |
| 32070 | ** See comments on sqlite3BitvecBuiltinTest() for more information |
| 32071 | ** about the aOp[] array. |
| 32072 | */ |
| 32073 | int iSize; |
| 32074 | const char *zTestArg; |
| 32075 | int nOp; |
| 32076 | int ii, jj, x; |
| 32077 | int *aOp; |
| 32078 | if( nArg!=4 ){ |
| 32079 | sqlite3_fprintf(stderr, |
| 32080 | "ERROR - should be: \".testctrl bitvec_test SIZE INT-ARRAY\"\n" |
| 32081 | ); |
| 32082 | rc = 1; |
| 32083 | goto meta_command_exit; |
| 32084 | } |
| 32085 | isOk = 3; |
| 32086 | iSize = (int)integerValue(azArg[2]); |
| 32087 | zTestArg = azArg[3]; |
| 32088 | nOp = (int)strlen(zTestArg)+1; |
| 32089 | aOp = malloc( sizeof(int)*(nOp+1) ); |
| 32090 | shell_check_oom(aOp); |
| 32091 | memset(aOp, 0, sizeof(int)*(nOp+1) ); |
| 32092 | for(ii = jj = x = 0; zTestArg[ii]!=0; ii++){ |
| 32093 | if( IsDigit(zTestArg[ii]) ){ |
| 32094 | x = x*10 + zTestArg[ii] - '0'; |
| 32095 | }else{ |
| 32096 | aOp[jj++] = x; |
| 32097 | x = 0; |
| 32098 | } |
| 32099 | } |
| 32100 | aOp[jj] = x; |
| 32101 | x = sqlite3_test_control(testctrl, iSize, aOp); |
| 32102 | sqlite3_fprintf(p->out, "result: %d\n", x); |
| 32103 | free(aOp); |
| 32104 | break; |
| 32105 | } |
| 32106 | case SQLITE_TESTCTRL_FAULT_INSTALL: { |
| 32107 | int kk; |
| 32108 | int bShowHelp = nArg<=2; |
| 32109 | isOk = 3; |
| 32110 | for(kk=2; kk<nArg; kk++){ |
| 32111 |
+1984
-1070
| --- extsrc/sqlite3.c | ||
| +++ extsrc/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.50.0. By combining all the individual C code files into this | |
| 3 | +** version 3.51.0. By combining all the individual C code files into this | |
| 4 | 4 | ** single large file, the entire code can be compiled as a single 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% or more are commonly seen when SQLite is compiled as a single |
| 8 | 8 | ** translation unit. |
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | -** d22475b81c4e26ccc50f3b5626d43b32f7a2 with changes in files: | |
| 21 | +** 9f184f8dfa5ef6d57e10376adc30e0060ced with changes in files: | |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| @@ -463,13 +463,13 @@ | ||
| 463 | 463 | ** |
| 464 | 464 | ** See also: [sqlite3_libversion()], |
| 465 | 465 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 466 | 466 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 467 | 467 | */ |
| 468 | -#define SQLITE_VERSION "3.50.0" | |
| 469 | -#define SQLITE_VERSION_NUMBER 3050000 | |
| 470 | -#define SQLITE_SOURCE_ID "2025-04-15 21:59:38 d22475b81c4e26ccc50f3b5626d43b32f7a2de34e5a764539554665bdda735d5" | |
| 468 | +#define SQLITE_VERSION "3.51.0" | |
| 469 | +#define SQLITE_VERSION_NUMBER 3051000 | |
| 470 | +#define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839" | |
| 471 | 471 | |
| 472 | 472 | /* |
| 473 | 473 | ** CAPI3REF: Run-Time Library Version Numbers |
| 474 | 474 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 475 | 475 | ** |
| @@ -485,13 +485,13 @@ | ||
| 485 | 485 | ** assert( sqlite3_libversion_number()==SQLITE_VERSION_NUMBER ); |
| 486 | 486 | ** assert( strncmp(sqlite3_sourceid(),SQLITE_SOURCE_ID,80)==0 ); |
| 487 | 487 | ** assert( strcmp(sqlite3_libversion(),SQLITE_VERSION)==0 ); |
| 488 | 488 | ** </pre></blockquote>)^ |
| 489 | 489 | ** |
| 490 | -** ^The sqlite3_version[] string constant contains the text of [SQLITE_VERSION] | |
| 491 | -** macro. ^The sqlite3_libversion() function returns a pointer to the | |
| 492 | -** to the sqlite3_version[] string constant. The sqlite3_libversion() | |
| 490 | +** ^The sqlite3_version[] string constant contains the text of the | |
| 491 | +** [SQLITE_VERSION] macro. ^The sqlite3_libversion() function returns a | |
| 492 | +** pointer to the sqlite3_version[] string constant. The sqlite3_libversion() | |
| 493 | 493 | ** function is provided for use in DLLs since DLL users usually do not have |
| 494 | 494 | ** direct access to string constants within the DLL. ^The |
| 495 | 495 | ** sqlite3_libversion_number() function returns an integer equal to |
| 496 | 496 | ** [SQLITE_VERSION_NUMBER]. ^(The sqlite3_sourceid() function returns |
| 497 | 497 | ** a pointer to a string constant whose value is the same as the |
| @@ -687,11 +687,11 @@ | ||
| 687 | 687 | ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()], |
| 688 | 688 | ** that allows an application to run multiple statements of SQL |
| 689 | 689 | ** without having to use a lot of C code. |
| 690 | 690 | ** |
| 691 | 691 | ** ^The sqlite3_exec() interface runs zero or more UTF-8 encoded, |
| 692 | -** semicolon-separate SQL statements passed into its 2nd argument, | |
| 692 | +** semicolon-separated SQL statements passed into its 2nd argument, | |
| 693 | 693 | ** in the context of the [database connection] passed in as its 1st |
| 694 | 694 | ** argument. ^If the callback function of the 3rd argument to |
| 695 | 695 | ** sqlite3_exec() is not NULL, then it is invoked for each result row |
| 696 | 696 | ** coming out of the evaluated SQL statements. ^The 4th argument to |
| 697 | 697 | ** sqlite3_exec() is relayed through to the 1st argument of each |
| @@ -720,11 +720,11 @@ | ||
| 720 | 720 | ** callback is an array of pointers to strings obtained as if from |
| 721 | 721 | ** [sqlite3_column_text()], one for each column. ^If an element of a |
| 722 | 722 | ** result row is NULL then the corresponding string pointer for the |
| 723 | 723 | ** sqlite3_exec() callback is a NULL pointer. ^The 4th argument to the |
| 724 | 724 | ** sqlite3_exec() callback is an array of pointers to strings where each |
| 725 | -** entry represents the name of corresponding result column as obtained | |
| 725 | +** entry represents the name of a corresponding result column as obtained | |
| 726 | 726 | ** from [sqlite3_column_name()]. |
| 727 | 727 | ** |
| 728 | 728 | ** ^If the 2nd parameter to sqlite3_exec() is a NULL pointer, a pointer |
| 729 | 729 | ** to an empty string, or a pointer that contains only whitespace and/or |
| 730 | 730 | ** SQL comments, then no SQL statements are evaluated and the database |
| @@ -906,11 +906,11 @@ | ||
| 906 | 906 | ** Applications should not depend on the historical behavior. |
| 907 | 907 | ** |
| 908 | 908 | ** Note in particular that passing the SQLITE_OPEN_EXCLUSIVE flag into |
| 909 | 909 | ** [sqlite3_open_v2()] does *not* cause the underlying database file |
| 910 | 910 | ** to be opened using O_EXCL. Passing SQLITE_OPEN_EXCLUSIVE into |
| 911 | -** [sqlite3_open_v2()] has historically be a no-op and might become an | |
| 911 | +** [sqlite3_open_v2()] has historically been a no-op and might become an | |
| 912 | 912 | ** error in future versions of SQLite. |
| 913 | 913 | */ |
| 914 | 914 | #define SQLITE_OPEN_READONLY 0x00000001 /* Ok for sqlite3_open_v2() */ |
| 915 | 915 | #define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */ |
| 916 | 916 | #define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */ |
| @@ -1000,11 +1000,11 @@ | ||
| 1000 | 1000 | ** CAPI3REF: File Locking Levels |
| 1001 | 1001 | ** |
| 1002 | 1002 | ** SQLite uses one of these integer values as the second |
| 1003 | 1003 | ** argument to calls it makes to the xLock() and xUnlock() methods |
| 1004 | 1004 | ** of an [sqlite3_io_methods] object. These values are ordered from |
| 1005 | -** lest restrictive to most restrictive. | |
| 1005 | +** least restrictive to most restrictive. | |
| 1006 | 1006 | ** |
| 1007 | 1007 | ** The argument to xLock() is always SHARED or higher. The argument to |
| 1008 | 1008 | ** xUnlock is either SHARED or NONE. |
| 1009 | 1009 | */ |
| 1010 | 1010 | #define SQLITE_LOCK_NONE 0 /* xUnlock() only */ |
| @@ -1316,11 +1316,11 @@ | ||
| 1316 | 1316 | ** reason, the entire database file will be overwritten by the current |
| 1317 | 1317 | ** transaction. This is used by VACUUM operations. |
| 1318 | 1318 | ** |
| 1319 | 1319 | ** <li>[[SQLITE_FCNTL_VFSNAME]] |
| 1320 | 1320 | ** ^The [SQLITE_FCNTL_VFSNAME] opcode can be used to obtain the names of |
| 1321 | -** all [VFSes] in the VFS stack. The names are of all VFS shims and the | |
| 1321 | +** all [VFSes] in the VFS stack. The names of all VFS shims and the | |
| 1322 | 1322 | ** final bottom-level VFS are written into memory obtained from |
| 1323 | 1323 | ** [sqlite3_malloc()] and the result is stored in the char* variable |
| 1324 | 1324 | ** that the fourth parameter of [sqlite3_file_control()] points to. |
| 1325 | 1325 | ** The caller is responsible for freeing the memory when done. As with |
| 1326 | 1326 | ** all file-control actions, there is no guarantee that this will actually |
| @@ -1330,11 +1330,11 @@ | ||
| 1330 | 1330 | ** |
| 1331 | 1331 | ** <li>[[SQLITE_FCNTL_VFS_POINTER]] |
| 1332 | 1332 | ** ^The [SQLITE_FCNTL_VFS_POINTER] opcode finds a pointer to the top-level |
| 1333 | 1333 | ** [VFSes] currently in use. ^(The argument X in |
| 1334 | 1334 | ** sqlite3_file_control(db,SQLITE_FCNTL_VFS_POINTER,X) must be |
| 1335 | -** of type "[sqlite3_vfs] **". This opcodes will set *X | |
| 1335 | +** of type "[sqlite3_vfs] **". This opcode will set *X | |
| 1336 | 1336 | ** to a pointer to the top-level VFS.)^ |
| 1337 | 1337 | ** ^When there are multiple VFS shims in the stack, this opcode finds the |
| 1338 | 1338 | ** upper-most shim only. |
| 1339 | 1339 | ** |
| 1340 | 1340 | ** <li>[[SQLITE_FCNTL_PRAGMA]] |
| @@ -1520,11 +1520,11 @@ | ||
| 1520 | 1520 | ** record the fact that the pages have been checkpointed. |
| 1521 | 1521 | ** |
| 1522 | 1522 | ** <li>[[SQLITE_FCNTL_EXTERNAL_READER]] |
| 1523 | 1523 | ** The EXPERIMENTAL [SQLITE_FCNTL_EXTERNAL_READER] opcode is used to detect |
| 1524 | 1524 | ** whether or not there is a database client in another process with a wal-mode |
| 1525 | -** transaction open on the database or not. It is only available on unix.The | |
| 1525 | +** transaction open on the database or not. It is only available on unix. The | |
| 1526 | 1526 | ** (void*) argument passed with this file-control should be a pointer to a |
| 1527 | 1527 | ** value of type (int). The integer value is set to 1 if the database is a wal |
| 1528 | 1528 | ** mode database and there exists at least one client in another process that |
| 1529 | 1529 | ** currently has an SQL transaction open on the database. It is set to 0 if |
| 1530 | 1530 | ** the database is not a wal-mode db, or if there is no such connection in any |
| @@ -1945,11 +1945,11 @@ | ||
| 1945 | 1945 | ** |
| 1946 | 1946 | ** ^The sqlite3_initialize() routine is called internally by many other |
| 1947 | 1947 | ** SQLite interfaces so that an application usually does not need to |
| 1948 | 1948 | ** invoke sqlite3_initialize() directly. For example, [sqlite3_open()] |
| 1949 | 1949 | ** calls sqlite3_initialize() so the SQLite library will be automatically |
| 1950 | -** initialized when [sqlite3_open()] is called if it has not be initialized | |
| 1950 | +** initialized when [sqlite3_open()] is called if it has not been initialized | |
| 1951 | 1951 | ** already. ^However, if SQLite is compiled with the [SQLITE_OMIT_AUTOINIT] |
| 1952 | 1952 | ** compile-time option, then the automatic calls to sqlite3_initialize() |
| 1953 | 1953 | ** are omitted and the application must call sqlite3_initialize() directly |
| 1954 | 1954 | ** prior to using any other SQLite interface. For maximum portability, |
| 1955 | 1955 | ** it is recommended that applications always invoke sqlite3_initialize() |
| @@ -2202,25 +2202,25 @@ | ||
| 2202 | 2202 | ** <dd> ^(The SQLITE_CONFIG_GETMALLOC option takes a single argument which |
| 2203 | 2203 | ** is a pointer to an instance of the [sqlite3_mem_methods] structure. |
| 2204 | 2204 | ** The [sqlite3_mem_methods] |
| 2205 | 2205 | ** structure is filled with the currently defined memory allocation routines.)^ |
| 2206 | 2206 | ** This option can be used to overload the default memory allocation |
| 2207 | -** routines with a wrapper that simulations memory allocation failure or | |
| 2207 | +** routines with a wrapper that simulates memory allocation failure or | |
| 2208 | 2208 | ** tracks memory usage, for example. </dd> |
| 2209 | 2209 | ** |
| 2210 | 2210 | ** [[SQLITE_CONFIG_SMALL_MALLOC]] <dt>SQLITE_CONFIG_SMALL_MALLOC</dt> |
| 2211 | -** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes single argument of | |
| 2211 | +** <dd> ^The SQLITE_CONFIG_SMALL_MALLOC option takes a single argument of | |
| 2212 | 2212 | ** type int, interpreted as a boolean, which if true provides a hint to |
| 2213 | 2213 | ** SQLite that it should avoid large memory allocations if possible. |
| 2214 | 2214 | ** SQLite will run faster if it is free to make large memory allocations, |
| 2215 | -** but some application might prefer to run slower in exchange for | |
| 2215 | +** but some applications might prefer to run slower in exchange for | |
| 2216 | 2216 | ** guarantees about memory fragmentation that are possible if large |
| 2217 | 2217 | ** allocations are avoided. This hint is normally off. |
| 2218 | 2218 | ** </dd> |
| 2219 | 2219 | ** |
| 2220 | 2220 | ** [[SQLITE_CONFIG_MEMSTATUS]] <dt>SQLITE_CONFIG_MEMSTATUS</dt> |
| 2221 | -** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes single argument of type int, | |
| 2221 | +** <dd> ^The SQLITE_CONFIG_MEMSTATUS option takes a single argument of type int, | |
| 2222 | 2222 | ** interpreted as a boolean, which enables or disables the collection of |
| 2223 | 2223 | ** memory allocation statistics. ^(When memory allocation statistics are |
| 2224 | 2224 | ** disabled, the following SQLite interfaces become non-operational: |
| 2225 | 2225 | ** <ul> |
| 2226 | 2226 | ** <li> [sqlite3_hard_heap_limit64()] |
| @@ -2261,11 +2261,11 @@ | ||
| 2261 | 2261 | ** a page cache line is larger than sz bytes or if all of the pMem buffer |
| 2262 | 2262 | ** is exhausted. |
| 2263 | 2263 | ** ^If pMem is NULL and N is non-zero, then each database connection |
| 2264 | 2264 | ** does an initial bulk allocation for page cache memory |
| 2265 | 2265 | ** from [sqlite3_malloc()] sufficient for N cache lines if N is positive or |
| 2266 | -** of -1024*N bytes if N is negative, . ^If additional | |
| 2266 | +** of -1024*N bytes if N is negative. ^If additional | |
| 2267 | 2267 | ** page cache memory is needed beyond what is provided by the initial |
| 2268 | 2268 | ** allocation, then SQLite goes to [sqlite3_malloc()] separately for each |
| 2269 | 2269 | ** additional cache line. </dd> |
| 2270 | 2270 | ** |
| 2271 | 2271 | ** [[SQLITE_CONFIG_HEAP]] <dt>SQLITE_CONFIG_HEAP</dt> |
| @@ -2290,11 +2290,11 @@ | ||
| 2290 | 2290 | ** |
| 2291 | 2291 | ** [[SQLITE_CONFIG_MUTEX]] <dt>SQLITE_CONFIG_MUTEX</dt> |
| 2292 | 2292 | ** <dd> ^(The SQLITE_CONFIG_MUTEX option takes a single argument which is a |
| 2293 | 2293 | ** pointer to an instance of the [sqlite3_mutex_methods] structure. |
| 2294 | 2294 | ** The argument specifies alternative low-level mutex routines to be used |
| 2295 | -** in place the mutex routines built into SQLite.)^ ^SQLite makes a copy of | |
| 2295 | +** in place of the mutex routines built into SQLite.)^ ^SQLite makes a copy of | |
| 2296 | 2296 | ** the content of the [sqlite3_mutex_methods] structure before the call to |
| 2297 | 2297 | ** [sqlite3_config()] returns. ^If SQLite is compiled with |
| 2298 | 2298 | ** the [SQLITE_THREADSAFE | SQLITE_THREADSAFE=0] compile-time option then |
| 2299 | 2299 | ** the entire mutexing subsystem is omitted from the build and hence calls to |
| 2300 | 2300 | ** [sqlite3_config()] with the SQLITE_CONFIG_MUTEX configuration option will |
| @@ -2332,11 +2332,11 @@ | ||
| 2332 | 2332 | ** the interface to a custom page cache implementation.)^ |
| 2333 | 2333 | ** ^SQLite makes a copy of the [sqlite3_pcache_methods2] object.</dd> |
| 2334 | 2334 | ** |
| 2335 | 2335 | ** [[SQLITE_CONFIG_GETPCACHE2]] <dt>SQLITE_CONFIG_GETPCACHE2</dt> |
| 2336 | 2336 | ** <dd> ^(The SQLITE_CONFIG_GETPCACHE2 option takes a single argument which |
| 2337 | -** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies of | |
| 2337 | +** is a pointer to an [sqlite3_pcache_methods2] object. SQLite copies off | |
| 2338 | 2338 | ** the current page cache implementation into that object.)^ </dd> |
| 2339 | 2339 | ** |
| 2340 | 2340 | ** [[SQLITE_CONFIG_LOG]] <dt>SQLITE_CONFIG_LOG</dt> |
| 2341 | 2341 | ** <dd> The SQLITE_CONFIG_LOG option is used to configure the SQLite |
| 2342 | 2342 | ** global [error log]. |
| @@ -2349,11 +2349,11 @@ | ||
| 2349 | 2349 | ** passed through as the first parameter to the application-defined logger |
| 2350 | 2350 | ** function whenever that function is invoked. ^The second parameter to |
| 2351 | 2351 | ** the logger function is a copy of the first parameter to the corresponding |
| 2352 | 2352 | ** [sqlite3_log()] call and is intended to be a [result code] or an |
| 2353 | 2353 | ** [extended result code]. ^The third parameter passed to the logger is |
| 2354 | -** log message after formatting via [sqlite3_snprintf()]. | |
| 2354 | +** a log message after formatting via [sqlite3_snprintf()]. | |
| 2355 | 2355 | ** The SQLite logging interface is not reentrant; the logger function |
| 2356 | 2356 | ** supplied by the application must not invoke any SQLite interface. |
| 2357 | 2357 | ** In a multi-threaded application, the application-defined logger |
| 2358 | 2358 | ** function must be threadsafe. </dd> |
| 2359 | 2359 | ** |
| @@ -2540,11 +2540,11 @@ | ||
| 2540 | 2540 | ** CAPI3REF: Database Connection Configuration Options |
| 2541 | 2541 | ** |
| 2542 | 2542 | ** These constants are the available integer configuration options that |
| 2543 | 2543 | ** can be passed as the second parameter to the [sqlite3_db_config()] interface. |
| 2544 | 2544 | ** |
| 2545 | -** The [sqlite3_db_config()] interface is a var-args functions. It takes a | |
| 2545 | +** The [sqlite3_db_config()] interface is a var-args function. It takes a | |
| 2546 | 2546 | ** variable number of parameters, though always at least two. The number of |
| 2547 | 2547 | ** parameters passed into sqlite3_db_config() depends on which of these |
| 2548 | 2548 | ** constants is given as the second parameter. This documentation page |
| 2549 | 2549 | ** refers to parameters beyond the second as "arguments". Thus, when this |
| 2550 | 2550 | ** page says "the N-th argument" it means "the N-th parameter past the |
| @@ -2674,12 +2674,12 @@ | ||
| 2674 | 2674 | ** C-API [sqlite3_load_extension()] and the SQL function [load_extension()]. |
| 2675 | 2675 | ** There must be two additional arguments. |
| 2676 | 2676 | ** When the first argument to this interface is 1, then only the C-API is |
| 2677 | 2677 | ** enabled and the SQL function remains disabled. If the first argument to |
| 2678 | 2678 | ** this interface is 0, then both the C-API and the SQL function are disabled. |
| 2679 | -** If the first argument is -1, then no changes are made to state of either the | |
| 2680 | -** C-API or the SQL function. | |
| 2679 | +** If the first argument is -1, then no changes are made to the state of either | |
| 2680 | +** the C-API or the SQL function. | |
| 2681 | 2681 | ** The second parameter is a pointer to an integer into which |
| 2682 | 2682 | ** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface |
| 2683 | 2683 | ** is disabled or enabled following this call. The second parameter may |
| 2684 | 2684 | ** be a NULL pointer, in which case the new setting is not reported back. |
| 2685 | 2685 | ** </dd> |
| @@ -2793,11 +2793,11 @@ | ||
| 2793 | 2793 | ** </dd> |
| 2794 | 2794 | ** |
| 2795 | 2795 | ** [[SQLITE_DBCONFIG_LEGACY_ALTER_TABLE]] |
| 2796 | 2796 | ** <dt>SQLITE_DBCONFIG_LEGACY_ALTER_TABLE</dt> |
| 2797 | 2797 | ** <dd>The SQLITE_DBCONFIG_LEGACY_ALTER_TABLE option activates or deactivates |
| 2798 | -** the legacy behavior of the [ALTER TABLE RENAME] command such it | |
| 2798 | +** the legacy behavior of the [ALTER TABLE RENAME] command such that it | |
| 2799 | 2799 | ** behaves as it did prior to [version 3.24.0] (2018-06-04). See the |
| 2800 | 2800 | ** "Compatibility Notice" on the [ALTER TABLE RENAME documentation] for |
| 2801 | 2801 | ** additional information. This feature can also be turned on and off |
| 2802 | 2802 | ** using the [PRAGMA legacy_alter_table] statement. |
| 2803 | 2803 | ** </dd> |
| @@ -2842,11 +2842,11 @@ | ||
| 2842 | 2842 | ** |
| 2843 | 2843 | ** [[SQLITE_DBCONFIG_LEGACY_FILE_FORMAT]] |
| 2844 | 2844 | ** <dt>SQLITE_DBCONFIG_LEGACY_FILE_FORMAT</dt> |
| 2845 | 2845 | ** <dd>The SQLITE_DBCONFIG_LEGACY_FILE_FORMAT option activates or deactivates |
| 2846 | 2846 | ** the legacy file format flag. When activated, this flag causes all newly |
| 2847 | -** created database file to have a schema format version number (the 4-byte | |
| 2847 | +** created database files to have a schema format version number (the 4-byte | |
| 2848 | 2848 | ** integer found at offset 44 into the database header) of 1. This in turn |
| 2849 | 2849 | ** means that the resulting database file will be readable and writable by |
| 2850 | 2850 | ** any SQLite version back to 3.0.0 ([dateof:3.0.0]). Without this setting, |
| 2851 | 2851 | ** newly created databases are generally not understandable by SQLite versions |
| 2852 | 2852 | ** prior to 3.3.0 ([dateof:3.3.0]). As these words are written, there |
| @@ -2869,11 +2869,11 @@ | ||
| 2869 | 2869 | ** a flag that enables collection of the sqlite3_stmt_scanstatus_v2() |
| 2870 | 2870 | ** statistics. For statistics to be collected, the flag must be set on |
| 2871 | 2871 | ** the database handle both when the SQL statement is prepared and when it |
| 2872 | 2872 | ** is stepped. The flag is set (collection of statistics is enabled) |
| 2873 | 2873 | ** by default. <p>This option takes two arguments: an integer and a pointer to |
| 2874 | -** an integer.. The first argument is 1, 0, or -1 to enable, disable, or | |
| 2874 | +** an integer. The first argument is 1, 0, or -1 to enable, disable, or | |
| 2875 | 2875 | ** leave unchanged the statement scanstatus option. If the second argument |
| 2876 | 2876 | ** is not NULL, then the value of the statement scanstatus setting after |
| 2877 | 2877 | ** processing the first argument is written into the integer that the second |
| 2878 | 2878 | ** argument points to. |
| 2879 | 2879 | ** </dd> |
| @@ -2912,12 +2912,12 @@ | ||
| 2912 | 2912 | ** [[SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE]] |
| 2913 | 2913 | ** <dt>SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE</dt> |
| 2914 | 2914 | ** <dd>The SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE option enables or disables the |
| 2915 | 2915 | ** ability of the [ATTACH DATABASE] SQL command to open a database for writing. |
| 2916 | 2916 | ** This capability is enabled by default. Applications can disable or |
| 2917 | -** reenable this capability using the current DBCONFIG option. If the | |
| 2918 | -** the this capability is disabled, the [ATTACH] command will still work, | |
| 2917 | +** reenable this capability using the current DBCONFIG option. If | |
| 2918 | +** this capability is disabled, the [ATTACH] command will still work, | |
| 2919 | 2919 | ** but the database will be opened read-only. If this option is disabled, |
| 2920 | 2920 | ** then the ability to create a new database using [ATTACH] is also disabled, |
| 2921 | 2921 | ** regardless of the value of the [SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE] |
| 2922 | 2922 | ** option.<p> |
| 2923 | 2923 | ** This option takes two arguments which are an integer and a pointer |
| @@ -2947,11 +2947,11 @@ | ||
| 2947 | 2947 | ** |
| 2948 | 2948 | ** [[DBCONFIG arguments]] <h3>Arguments To SQLITE_DBCONFIG Options</h3> |
| 2949 | 2949 | ** |
| 2950 | 2950 | ** <p>Most of the SQLITE_DBCONFIG options take two arguments, so that the |
| 2951 | 2951 | ** overall call to [sqlite3_db_config()] has a total of four parameters. |
| 2952 | -** The first argument (the third parameter to sqlite3_db_config()) is a integer. | |
| 2952 | +** The first argument (the third parameter to sqlite3_db_config()) is an integer. | |
| 2953 | 2953 | ** The second argument is a pointer to an integer. If the first argument is 1, |
| 2954 | 2954 | ** then the option becomes enabled. If the first integer argument is 0, then the |
| 2955 | 2955 | ** option is disabled. If the first argument is -1, then the option setting |
| 2956 | 2956 | ** is unchanged. The second argument, the pointer to an integer, may be NULL. |
| 2957 | 2957 | ** If the second argument is not NULL, then a value of 0 or 1 is written into |
| @@ -3237,11 +3237,11 @@ | ||
| 3237 | 3237 | ** and comments that follow the final semicolon are ignored. |
| 3238 | 3238 | ** |
| 3239 | 3239 | ** ^These routines return 0 if the statement is incomplete. ^If a |
| 3240 | 3240 | ** memory allocation fails, then SQLITE_NOMEM is returned. |
| 3241 | 3241 | ** |
| 3242 | -** ^These routines do not parse the SQL statements thus | |
| 3242 | +** ^These routines do not parse the SQL statements and thus | |
| 3243 | 3243 | ** will not detect syntactically incorrect SQL. |
| 3244 | 3244 | ** |
| 3245 | 3245 | ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior |
| 3246 | 3246 | ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked |
| 3247 | 3247 | ** automatically by sqlite3_complete16(). If that initialization fails, |
| @@ -3354,11 +3354,11 @@ | ||
| 3354 | 3354 | ** Passing 0 to this function disables blocking locks altogether. Passing |
| 3355 | 3355 | ** -1 to this function requests that the VFS blocks for a long time - |
| 3356 | 3356 | ** indefinitely if possible. The results of passing any other negative value |
| 3357 | 3357 | ** are undefined. |
| 3358 | 3358 | ** |
| 3359 | -** Internally, each SQLite database handle store two timeout values - the | |
| 3359 | +** Internally, each SQLite database handle stores two timeout values - the | |
| 3360 | 3360 | ** busy-timeout (used for rollback mode databases, or if the VFS does not |
| 3361 | 3361 | ** support blocking locks) and the setlk-timeout (used for blocking locks |
| 3362 | 3362 | ** on wal-mode databases). The sqlite3_busy_timeout() method sets both |
| 3363 | 3363 | ** values, this function sets only the setlk-timeout value. Therefore, |
| 3364 | 3364 | ** to configure separate busy-timeout and setlk-timeout values for a single |
| @@ -3384,11 +3384,11 @@ | ||
| 3384 | 3384 | ** METHOD: sqlite3 |
| 3385 | 3385 | ** |
| 3386 | 3386 | ** This is a legacy interface that is preserved for backwards compatibility. |
| 3387 | 3387 | ** Use of this interface is not recommended. |
| 3388 | 3388 | ** |
| 3389 | -** Definition: A <b>result table</b> is memory data structure created by the | |
| 3389 | +** Definition: A <b>result table</b> is a memory data structure created by the | |
| 3390 | 3390 | ** [sqlite3_get_table()] interface. A result table records the |
| 3391 | 3391 | ** complete query results from one or more queries. |
| 3392 | 3392 | ** |
| 3393 | 3393 | ** The table conceptually has a number of rows and columns. But |
| 3394 | 3394 | ** these numbers are not part of the result table itself. These |
| @@ -3527,11 +3527,11 @@ | ||
| 3527 | 3527 | ** of a signed 32-bit integer. |
| 3528 | 3528 | ** |
| 3529 | 3529 | ** ^Calling sqlite3_free() with a pointer previously returned |
| 3530 | 3530 | ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so |
| 3531 | 3531 | ** that it might be reused. ^The sqlite3_free() routine is |
| 3532 | -** a no-op if is called with a NULL pointer. Passing a NULL pointer | |
| 3532 | +** a no-op if it is called with a NULL pointer. Passing a NULL pointer | |
| 3533 | 3533 | ** to sqlite3_free() is harmless. After being freed, memory |
| 3534 | 3534 | ** should neither be read nor written. Even reading previously freed |
| 3535 | 3535 | ** memory might result in a segmentation fault or other severe error. |
| 3536 | 3536 | ** Memory corruption, a segmentation fault, or other severe error |
| 3537 | 3537 | ** might result if sqlite3_free() is called with a non-NULL pointer that |
| @@ -3545,17 +3545,17 @@ | ||
| 3545 | 3545 | ** ^If the N parameter to sqlite3_realloc(X,N) is zero or |
| 3546 | 3546 | ** negative then the behavior is exactly the same as calling |
| 3547 | 3547 | ** sqlite3_free(X). |
| 3548 | 3548 | ** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation |
| 3549 | 3549 | ** of at least N bytes in size or NULL if insufficient memory is available. |
| 3550 | -** ^If M is the size of the prior allocation, then min(N,M) bytes | |
| 3551 | -** of the prior allocation are copied into the beginning of buffer returned | |
| 3550 | +** ^If M is the size of the prior allocation, then min(N,M) bytes of the | |
| 3551 | +** prior allocation are copied into the beginning of the buffer returned | |
| 3552 | 3552 | ** by sqlite3_realloc(X,N) and the prior allocation is freed. |
| 3553 | 3553 | ** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the |
| 3554 | 3554 | ** prior allocation is not freed. |
| 3555 | 3555 | ** |
| 3556 | -** ^The sqlite3_realloc64(X,N) interfaces works the same as | |
| 3556 | +** ^The sqlite3_realloc64(X,N) interface works the same as | |
| 3557 | 3557 | ** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead |
| 3558 | 3558 | ** of a 32-bit signed integer. |
| 3559 | 3559 | ** |
| 3560 | 3560 | ** ^If X is a memory allocation previously obtained from sqlite3_malloc(), |
| 3561 | 3561 | ** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then |
| @@ -3601,11 +3601,11 @@ | ||
| 3601 | 3601 | ** ^The [sqlite3_memory_highwater()] routine returns the maximum |
| 3602 | 3602 | ** value of [sqlite3_memory_used()] since the high-water mark |
| 3603 | 3603 | ** was last reset. ^The values returned by [sqlite3_memory_used()] and |
| 3604 | 3604 | ** [sqlite3_memory_highwater()] include any overhead |
| 3605 | 3605 | ** added by SQLite in its implementation of [sqlite3_malloc()], |
| 3606 | -** but not overhead added by the any underlying system library | |
| 3606 | +** but not overhead added by any underlying system library | |
| 3607 | 3607 | ** routines that [sqlite3_malloc()] may call. |
| 3608 | 3608 | ** |
| 3609 | 3609 | ** ^The memory high-water mark is reset to the current value of |
| 3610 | 3610 | ** [sqlite3_memory_used()] if and only if the parameter to |
| 3611 | 3611 | ** [sqlite3_memory_highwater()] is true. ^The value returned |
| @@ -4053,19 +4053,19 @@ | ||
| 4053 | 4053 | ** attempt to use the same database connection at the same time. |
| 4054 | 4054 | ** (Mutexes will block any actual concurrency, but in this mode |
| 4055 | 4055 | ** there is no harm in trying.) |
| 4056 | 4056 | ** |
| 4057 | 4057 | ** ^(<dt>[SQLITE_OPEN_SHAREDCACHE]</dt> |
| 4058 | -** <dd>The database is opened [shared cache] enabled, overriding | |
| 4058 | +** <dd>The database is opened with [shared cache] enabled, overriding | |
| 4059 | 4059 | ** the default shared cache setting provided by |
| 4060 | 4060 | ** [sqlite3_enable_shared_cache()].)^ |
| 4061 | 4061 | ** The [use of shared cache mode is discouraged] and hence shared cache |
| 4062 | 4062 | ** capabilities may be omitted from many builds of SQLite. In such cases, |
| 4063 | 4063 | ** this option is a no-op. |
| 4064 | 4064 | ** |
| 4065 | 4065 | ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt> |
| 4066 | -** <dd>The database is opened [shared cache] disabled, overriding | |
| 4066 | +** <dd>The database is opened with [shared cache] disabled, overriding | |
| 4067 | 4067 | ** the default shared cache setting provided by |
| 4068 | 4068 | ** [sqlite3_enable_shared_cache()].)^ |
| 4069 | 4069 | ** |
| 4070 | 4070 | ** [[OPEN_EXRESCODE]] ^(<dt>[SQLITE_OPEN_EXRESCODE]</dt> |
| 4071 | 4071 | ** <dd>The database connection comes up in "extended result code mode". |
| @@ -4396,11 +4396,11 @@ | ||
| 4396 | 4396 | ** These interfaces are provided for use by [VFS shim] implementations and |
| 4397 | 4397 | ** are not useful outside of that context. |
| 4398 | 4398 | ** |
| 4399 | 4399 | ** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of |
| 4400 | 4400 | ** database filename D with corresponding journal file J and WAL file W and |
| 4401 | -** with N URI parameters key/values pairs in the array P. The result from | |
| 4401 | +** an array P of N URI Key/Value pairs. The result from | |
| 4402 | 4402 | ** sqlite3_create_filename(D,J,W,N,P) is a pointer to a database filename that |
| 4403 | 4403 | ** is safe to pass to routines like: |
| 4404 | 4404 | ** <ul> |
| 4405 | 4405 | ** <li> [sqlite3_uri_parameter()], |
| 4406 | 4406 | ** <li> [sqlite3_uri_boolean()], |
| @@ -4479,19 +4479,19 @@ | ||
| 4479 | 4479 | ** The application does not need to worry about freeing the result. |
| 4480 | 4480 | ** However, the error string might be overwritten or deallocated by |
| 4481 | 4481 | ** subsequent calls to other SQLite interface functions.)^ |
| 4482 | 4482 | ** |
| 4483 | 4483 | ** ^The sqlite3_errstr(E) interface returns the English-language text |
| 4484 | -** that describes the [result code] E, as UTF-8, or NULL if E is not an | |
| 4484 | +** that describes the [result code] E, as UTF-8, or NULL if E is not a | |
| 4485 | 4485 | ** result code for which a text error message is available. |
| 4486 | 4486 | ** ^(Memory to hold the error message string is managed internally |
| 4487 | 4487 | ** and must not be freed by the application)^. |
| 4488 | 4488 | ** |
| 4489 | 4489 | ** ^If the most recent error references a specific token in the input |
| 4490 | 4490 | ** SQL, the sqlite3_error_offset() interface returns the byte offset |
| 4491 | 4491 | ** of the start of that token. ^The byte offset returned by |
| 4492 | -** sqlite3_error_offset() assumes that the input SQL is UTF8. | |
| 4492 | +** sqlite3_error_offset() assumes that the input SQL is UTF-8. | |
| 4493 | 4493 | ** ^If the most recent error does not reference a specific token in the input |
| 4494 | 4494 | ** SQL, then the sqlite3_error_offset() function returns -1. |
| 4495 | 4495 | ** |
| 4496 | 4496 | ** When the serialized [threading mode] is in use, it might be the |
| 4497 | 4497 | ** case that a second error occurs on a separate thread in between |
| @@ -4586,12 +4586,12 @@ | ||
| 4586 | 4586 | ** CAPI3REF: Run-Time Limit Categories |
| 4587 | 4587 | ** KEYWORDS: {limit category} {*limit categories} |
| 4588 | 4588 | ** |
| 4589 | 4589 | ** These constants define various performance limits |
| 4590 | 4590 | ** that can be lowered at run-time using [sqlite3_limit()]. |
| 4591 | -** The synopsis of the meanings of the various limits is shown below. | |
| 4592 | -** Additional information is available at [limits | Limits in SQLite]. | |
| 4591 | +** A concise description of these limits follows, and additional information | |
| 4592 | +** is available at [limits | Limits in SQLite]. | |
| 4593 | 4593 | ** |
| 4594 | 4594 | ** <dl> |
| 4595 | 4595 | ** [[SQLITE_LIMIT_LENGTH]] ^(<dt>SQLITE_LIMIT_LENGTH</dt> |
| 4596 | 4596 | ** <dd>The maximum size of any string or BLOB or table row, in bytes.<dd>)^ |
| 4597 | 4597 | ** |
| @@ -4652,11 +4652,11 @@ | ||
| 4652 | 4652 | #define SQLITE_LIMIT_WORKER_THREADS 11 |
| 4653 | 4653 | |
| 4654 | 4654 | /* |
| 4655 | 4655 | ** CAPI3REF: Prepare Flags |
| 4656 | 4656 | ** |
| 4657 | -** These constants define various flags that can be passed into | |
| 4657 | +** These constants define various flags that can be passed into the | |
| 4658 | 4658 | ** "prepFlags" parameter of the [sqlite3_prepare_v3()] and |
| 4659 | 4659 | ** [sqlite3_prepare16_v3()] interfaces. |
| 4660 | 4660 | ** |
| 4661 | 4661 | ** New flags may be added in future releases of SQLite. |
| 4662 | 4662 | ** |
| @@ -4739,11 +4739,11 @@ | ||
| 4739 | 4739 | ** statement is generated. |
| 4740 | 4740 | ** If the caller knows that the supplied string is nul-terminated, then |
| 4741 | 4741 | ** there is a small performance advantage to passing an nByte parameter that |
| 4742 | 4742 | ** is the number of bytes in the input string <i>including</i> |
| 4743 | 4743 | ** the nul-terminator. |
| 4744 | -** Note that nByte measure the length of the input in bytes, not | |
| 4744 | +** Note that nByte measures the length of the input in bytes, not | |
| 4745 | 4745 | ** characters, even for the UTF-16 interfaces. |
| 4746 | 4746 | ** |
| 4747 | 4747 | ** ^If pzTail is not NULL then *pzTail is made to point to the first byte |
| 4748 | 4748 | ** past the end of the first SQL statement in zSql. These routines only |
| 4749 | 4749 | ** compile the first statement in zSql, so *pzTail is left pointing to |
| @@ -4873,11 +4873,11 @@ | ||
| 4873 | 4873 | ** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql() |
| 4874 | 4874 | ** will return "SELECT 2345,NULL".)^ |
| 4875 | 4875 | ** |
| 4876 | 4876 | ** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory |
| 4877 | 4877 | ** is available to hold the result, or if the result would exceed the |
| 4878 | -** the maximum string length determined by the [SQLITE_LIMIT_LENGTH]. | |
| 4878 | +** maximum string length determined by the [SQLITE_LIMIT_LENGTH]. | |
| 4879 | 4879 | ** |
| 4880 | 4880 | ** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of |
| 4881 | 4881 | ** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time |
| 4882 | 4882 | ** option causes sqlite3_expanded_sql() to always return NULL. |
| 4883 | 4883 | ** |
| @@ -5061,11 +5061,11 @@ | ||
| 5061 | 5061 | /* |
| 5062 | 5062 | ** CAPI3REF: SQL Function Context Object |
| 5063 | 5063 | ** |
| 5064 | 5064 | ** The context in which an SQL function executes is stored in an |
| 5065 | 5065 | ** sqlite3_context object. ^A pointer to an sqlite3_context object |
| 5066 | -** is always first parameter to [application-defined SQL functions]. | |
| 5066 | +** is always the first parameter to [application-defined SQL functions]. | |
| 5067 | 5067 | ** The application-defined SQL function implementation will pass this |
| 5068 | 5068 | ** pointer through into calls to [sqlite3_result_int | sqlite3_result()], |
| 5069 | 5069 | ** [sqlite3_aggregate_context()], [sqlite3_user_data()], |
| 5070 | 5070 | ** [sqlite3_context_db_handle()], [sqlite3_get_auxdata()], |
| 5071 | 5071 | ** and/or [sqlite3_set_auxdata()]. |
| @@ -5077,11 +5077,11 @@ | ||
| 5077 | 5077 | ** KEYWORDS: {host parameter} {host parameters} {host parameter name} |
| 5078 | 5078 | ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding} |
| 5079 | 5079 | ** METHOD: sqlite3_stmt |
| 5080 | 5080 | ** |
| 5081 | 5081 | ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants, |
| 5082 | -** literals may be replaced by a [parameter] that matches one of following | |
| 5082 | +** literals may be replaced by a [parameter] that matches one of the following | |
| 5083 | 5083 | ** templates: |
| 5084 | 5084 | ** |
| 5085 | 5085 | ** <ul> |
| 5086 | 5086 | ** <li> ? |
| 5087 | 5087 | ** <li> ?NNN |
| @@ -5122,11 +5122,11 @@ | ||
| 5122 | 5122 | ** either UTF8 if the sixth parameter is SQLITE_UTF8, or UTF16 |
| 5123 | 5123 | ** otherwise. |
| 5124 | 5124 | ** |
| 5125 | 5125 | ** [[byte-order determination rules]] ^The byte-order of |
| 5126 | 5126 | ** UTF16 input text is determined by the byte-order mark (BOM, U+FEFF) |
| 5127 | -** found in first character, which is removed, or in the absence of a BOM | |
| 5127 | +** found in the first character, which is removed, or in the absence of a BOM | |
| 5128 | 5128 | ** the byte order is the native byte order of the host |
| 5129 | 5129 | ** machine for sqlite3_bind_text16() or the byte order specified in |
| 5130 | 5130 | ** the 6th parameter for sqlite3_bind_text64().)^ |
| 5131 | 5131 | ** ^If UTF16 input text contains invalid unicode |
| 5132 | 5132 | ** characters, then SQLite might change those invalid characters |
| @@ -5142,11 +5142,11 @@ | ||
| 5142 | 5142 | ** the behavior is undefined. |
| 5143 | 5143 | ** If a non-negative fourth parameter is provided to sqlite3_bind_text() |
| 5144 | 5144 | ** or sqlite3_bind_text16() or sqlite3_bind_text64() then |
| 5145 | 5145 | ** that parameter must be the byte offset |
| 5146 | 5146 | ** where the NUL terminator would occur assuming the string were NUL |
| 5147 | -** terminated. If any NUL characters occurs at byte offsets less than | |
| 5147 | +** terminated. If any NUL characters occur at byte offsets less than | |
| 5148 | 5148 | ** the value of the fourth parameter then the resulting string value will |
| 5149 | 5149 | ** contain embedded NULs. The result of expressions involving strings |
| 5150 | 5150 | ** with embedded NULs is undefined. |
| 5151 | 5151 | ** |
| 5152 | 5152 | ** ^The fifth argument to the BLOB and string binding interfaces controls |
| @@ -5354,11 +5354,11 @@ | ||
| 5354 | 5354 | /* |
| 5355 | 5355 | ** CAPI3REF: Source Of Data In A Query Result |
| 5356 | 5356 | ** METHOD: sqlite3_stmt |
| 5357 | 5357 | ** |
| 5358 | 5358 | ** ^These routines provide a means to determine the database, table, and |
| 5359 | -** table column that is the origin of a particular result column in | |
| 5359 | +** table column that is the origin of a particular result column in a | |
| 5360 | 5360 | ** [SELECT] statement. |
| 5361 | 5361 | ** ^The name of the database or table or column can be returned as |
| 5362 | 5362 | ** either a UTF-8 or UTF-16 string. ^The _database_ routines return |
| 5363 | 5363 | ** the database name, the _table_ routines return the table name, and |
| 5364 | 5364 | ** the origin_ routines return the column name. |
| @@ -5798,11 +5798,11 @@ | ||
| 5798 | 5798 | ** CAPI3REF: Destroy A Prepared Statement Object |
| 5799 | 5799 | ** DESTRUCTOR: sqlite3_stmt |
| 5800 | 5800 | ** |
| 5801 | 5801 | ** ^The sqlite3_finalize() function is called to delete a [prepared statement]. |
| 5802 | 5802 | ** ^If the most recent evaluation of the statement encountered no errors |
| 5803 | -** or if the statement is never been evaluated, then sqlite3_finalize() returns | |
| 5803 | +** or if the statement has never been evaluated, then sqlite3_finalize() returns | |
| 5804 | 5804 | ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then |
| 5805 | 5805 | ** sqlite3_finalize(S) returns the appropriate [error code] or |
| 5806 | 5806 | ** [extended error code]. |
| 5807 | 5807 | ** |
| 5808 | 5808 | ** ^The sqlite3_finalize(S) routine can be called at any point during |
| @@ -5923,12 +5923,12 @@ | ||
| 5923 | 5923 | ** within VIEWs, TRIGGERs, CHECK constraints, generated column expressions, |
| 5924 | 5924 | ** index expressions, or the WHERE clause of partial indexes. |
| 5925 | 5925 | ** |
| 5926 | 5926 | ** For best security, the [SQLITE_DIRECTONLY] flag is recommended for |
| 5927 | 5927 | ** all application-defined SQL functions that do not need to be |
| 5928 | -** used inside of triggers, view, CHECK constraints, or other elements of | |
| 5929 | -** the database schema. This flags is especially recommended for SQL | |
| 5928 | +** used inside of triggers, views, CHECK constraints, or other elements of | |
| 5929 | +** the database schema. This flag is especially recommended for SQL | |
| 5930 | 5930 | ** functions that have side effects or reveal internal application state. |
| 5931 | 5931 | ** Without this flag, an attacker might be able to modify the schema of |
| 5932 | 5932 | ** a database file to include invocations of the function with parameters |
| 5933 | 5933 | ** chosen by the attacker, which the application will then execute when |
| 5934 | 5934 | ** the database file is opened and read. |
| @@ -5955,11 +5955,11 @@ | ||
| 5955 | 5955 | ** or aggregate window function. More details regarding the implementation |
| 5956 | 5956 | ** of aggregate window functions are |
| 5957 | 5957 | ** [user-defined window functions|available here]. |
| 5958 | 5958 | ** |
| 5959 | 5959 | ** ^(If the final parameter to sqlite3_create_function_v2() or |
| 5960 | -** sqlite3_create_window_function() is not NULL, then it is destructor for | |
| 5960 | +** sqlite3_create_window_function() is not NULL, then it is the destructor for | |
| 5961 | 5961 | ** the application data pointer. The destructor is invoked when the function |
| 5962 | 5962 | ** is deleted, either by being overloaded or when the database connection |
| 5963 | 5963 | ** closes.)^ ^The destructor is also invoked if the call to |
| 5964 | 5964 | ** sqlite3_create_function_v2() fails. ^When the destructor callback is |
| 5965 | 5965 | ** invoked, it is passed a single argument which is a copy of the application |
| @@ -6030,11 +6030,11 @@ | ||
| 6030 | 6030 | ); |
| 6031 | 6031 | |
| 6032 | 6032 | /* |
| 6033 | 6033 | ** CAPI3REF: Text Encodings |
| 6034 | 6034 | ** |
| 6035 | -** These constant define integer codes that represent the various | |
| 6035 | +** These constants define integer codes that represent the various | |
| 6036 | 6036 | ** text encodings supported by SQLite. |
| 6037 | 6037 | */ |
| 6038 | 6038 | #define SQLITE_UTF8 1 /* IMP: R-37514-35566 */ |
| 6039 | 6039 | #define SQLITE_UTF16LE 2 /* IMP: R-03371-37637 */ |
| 6040 | 6040 | #define SQLITE_UTF16BE 3 /* IMP: R-51971-34154 */ |
| @@ -6122,11 +6122,11 @@ | ||
| 6122 | 6122 | ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call |
| 6123 | 6123 | ** [sqlite3_result_subtype()] to cause a sub-type to be associated with its |
| 6124 | 6124 | ** result. |
| 6125 | 6125 | ** Every function that invokes [sqlite3_result_subtype()] should have this |
| 6126 | 6126 | ** property. If it does not, then the call to [sqlite3_result_subtype()] |
| 6127 | -** might become a no-op if the function is used as term in an | |
| 6127 | +** might become a no-op if the function is used as a term in an | |
| 6128 | 6128 | ** [expression index]. On the other hand, SQL functions that never invoke |
| 6129 | 6129 | ** [sqlite3_result_subtype()] should avoid setting this property, as the |
| 6130 | 6130 | ** purpose of this property is to disable certain optimizations that are |
| 6131 | 6131 | ** incompatible with subtypes. |
| 6132 | 6132 | ** |
| @@ -6249,11 +6249,11 @@ | ||
| 6249 | 6249 | ** |
| 6250 | 6250 | ** ^Within the [xUpdate] method of a [virtual table], the |
| 6251 | 6251 | ** sqlite3_value_nochange(X) interface returns true if and only if |
| 6252 | 6252 | ** the column corresponding to X is unchanged by the UPDATE operation |
| 6253 | 6253 | ** that the xUpdate method call was invoked to implement and if |
| 6254 | -** and the prior [xColumn] method call that was invoked to extracted | |
| 6254 | +** the prior [xColumn] method call that was invoked to extract | |
| 6255 | 6255 | ** the value for that column returned without setting a result (probably |
| 6256 | 6256 | ** because it queried [sqlite3_vtab_nochange()] and found that the column |
| 6257 | 6257 | ** was unchanging). ^Within an [xUpdate] method, any value for which |
| 6258 | 6258 | ** sqlite3_value_nochange(X) is true will in all other respects appear |
| 6259 | 6259 | ** to be a NULL value. If sqlite3_value_nochange(X) is invoked anywhere other |
| @@ -6355,11 +6355,11 @@ | ||
| 6355 | 6355 | /* |
| 6356 | 6356 | ** CAPI3REF: Copy And Free SQL Values |
| 6357 | 6357 | ** METHOD: sqlite3_value |
| 6358 | 6358 | ** |
| 6359 | 6359 | ** ^The sqlite3_value_dup(V) interface makes a copy of the [sqlite3_value] |
| 6360 | -** object D and returns a pointer to that copy. ^The [sqlite3_value] returned | |
| 6360 | +** object V and returns a pointer to that copy. ^The [sqlite3_value] returned | |
| 6361 | 6361 | ** is a [protected sqlite3_value] object even if the input is not. |
| 6362 | 6362 | ** ^The sqlite3_value_dup(V) interface returns NULL if V is NULL or if a |
| 6363 | 6363 | ** memory allocation fails. ^If V is a [pointer value], then the result |
| 6364 | 6364 | ** of sqlite3_value_dup(V) is a NULL value. |
| 6365 | 6365 | ** |
| @@ -6393,11 +6393,11 @@ | ||
| 6393 | 6393 | ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer |
| 6394 | 6394 | ** when first called if N is less than or equal to zero or if a memory |
| 6395 | 6395 | ** allocation error occurs. |
| 6396 | 6396 | ** |
| 6397 | 6397 | ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is |
| 6398 | -** determined by the N parameter on first successful call. Changing the | |
| 6398 | +** determined by the N parameter on the first successful call. Changing the | |
| 6399 | 6399 | ** value of N in any subsequent call to sqlite3_aggregate_context() within |
| 6400 | 6400 | ** the same aggregate function instance will not resize the memory |
| 6401 | 6401 | ** allocation.)^ Within the xFinal callback, it is customary to set |
| 6402 | 6402 | ** N=0 in calls to sqlite3_aggregate_context(C,N) so that no |
| 6403 | 6403 | ** pointless memory allocations occur. |
| @@ -6555,11 +6555,11 @@ | ||
| 6555 | 6555 | ** of as a secret key such that only code that knows the secret key is able |
| 6556 | 6556 | ** to access the associated data. |
| 6557 | 6557 | ** |
| 6558 | 6558 | ** Security Warning: These interfaces should not be exposed in scripting |
| 6559 | 6559 | ** languages or in other circumstances where it might be possible for an |
| 6560 | -** an attacker to invoke them. Any agent that can invoke these interfaces | |
| 6560 | +** attacker to invoke them. Any agent that can invoke these interfaces | |
| 6561 | 6561 | ** can probably also take control of the process. |
| 6562 | 6562 | ** |
| 6563 | 6563 | ** Database connection client data is only available for SQLite |
| 6564 | 6564 | ** version 3.44.0 ([dateof:3.44.0]) and later. |
| 6565 | 6565 | ** |
| @@ -6669,11 +6669,11 @@ | ||
| 6669 | 6669 | ** ^If the 3rd parameter to the sqlite3_result_text* interfaces |
| 6670 | 6670 | ** is non-negative, then as many bytes (not characters) of the text |
| 6671 | 6671 | ** pointed to by the 2nd parameter are taken as the application-defined |
| 6672 | 6672 | ** function result. If the 3rd parameter is non-negative, then it |
| 6673 | 6673 | ** must be the byte offset into the string where the NUL terminator would |
| 6674 | -** appear if the string where NUL terminated. If any NUL characters occur | |
| 6674 | +** appear if the string were NUL terminated. If any NUL characters occur | |
| 6675 | 6675 | ** in the string at a byte offset that is less than the value of the 3rd |
| 6676 | 6676 | ** parameter, then the resulting string will contain embedded NULs and the |
| 6677 | 6677 | ** result of expressions operating on strings with embedded NULs is undefined. |
| 6678 | 6678 | ** ^If the 4th parameter to the sqlite3_result_text* interfaces |
| 6679 | 6679 | ** or sqlite3_result_blob is a non-NULL pointer, then SQLite calls that |
| @@ -6727,11 +6727,11 @@ | ||
| 6727 | 6727 | ** for the P parameter. ^SQLite invokes D with P as its only argument |
| 6728 | 6728 | ** when SQLite is finished with P. The T parameter should be a static |
| 6729 | 6729 | ** string and preferably a string literal. The sqlite3_result_pointer() |
| 6730 | 6730 | ** routine is part of the [pointer passing interface] added for SQLite 3.20.0. |
| 6731 | 6731 | ** |
| 6732 | -** If these routines are called from within the different thread | |
| 6732 | +** If these routines are called from within a different thread | |
| 6733 | 6733 | ** than the one containing the application-defined function that received |
| 6734 | 6734 | ** the [sqlite3_context] pointer, the results are undefined. |
| 6735 | 6735 | */ |
| 6736 | 6736 | SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); |
| 6737 | 6737 | SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*, |
| @@ -7133,11 +7133,11 @@ | ||
| 7133 | 7133 | /* |
| 7134 | 7134 | ** CAPI3REF: Return The Schema Name For A Database Connection |
| 7135 | 7135 | ** METHOD: sqlite3 |
| 7136 | 7136 | ** |
| 7137 | 7137 | ** ^The sqlite3_db_name(D,N) interface returns a pointer to the schema name |
| 7138 | -** for the N-th database on database connection D, or a NULL pointer of N is | |
| 7138 | +** for the N-th database on database connection D, or a NULL pointer if N is | |
| 7139 | 7139 | ** out of range. An N value of 0 means the main database file. An N of 1 is |
| 7140 | 7140 | ** the "temp" schema. Larger values of N correspond to various ATTACH-ed |
| 7141 | 7141 | ** databases. |
| 7142 | 7142 | ** |
| 7143 | 7143 | ** Space to hold the string that is returned by sqlite3_db_name() is managed |
| @@ -7228,20 +7228,20 @@ | ||
| 7228 | 7228 | ** |
| 7229 | 7229 | ** [[SQLITE_TXN_READ]] <dt>SQLITE_TXN_READ</dt> |
| 7230 | 7230 | ** <dd>The SQLITE_TXN_READ state means that the database is currently |
| 7231 | 7231 | ** in a read transaction. Content has been read from the database file |
| 7232 | 7232 | ** but nothing in the database file has changed. The transaction state |
| 7233 | -** will advanced to SQLITE_TXN_WRITE if any changes occur and there are | |
| 7233 | +** will be advanced to SQLITE_TXN_WRITE if any changes occur and there are | |
| 7234 | 7234 | ** no other conflicting concurrent write transactions. The transaction |
| 7235 | 7235 | ** state will revert to SQLITE_TXN_NONE following a [ROLLBACK] or |
| 7236 | 7236 | ** [COMMIT].</dd> |
| 7237 | 7237 | ** |
| 7238 | 7238 | ** [[SQLITE_TXN_WRITE]] <dt>SQLITE_TXN_WRITE</dt> |
| 7239 | 7239 | ** <dd>The SQLITE_TXN_WRITE state means that the database is currently |
| 7240 | 7240 | ** in a write transaction. Content has been written to the database file |
| 7241 | 7241 | ** but has not yet committed. The transaction state will change to |
| 7242 | -** to SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd> | |
| 7242 | +** SQLITE_TXN_NONE at the next [ROLLBACK] or [COMMIT].</dd> | |
| 7243 | 7243 | */ |
| 7244 | 7244 | #define SQLITE_TXN_NONE 0 |
| 7245 | 7245 | #define SQLITE_TXN_READ 1 |
| 7246 | 7246 | #define SQLITE_TXN_WRITE 2 |
| 7247 | 7247 | |
| @@ -7518,11 +7518,11 @@ | ||
| 7518 | 7518 | |
| 7519 | 7519 | /* |
| 7520 | 7520 | ** CAPI3REF: Impose A Limit On Heap Size |
| 7521 | 7521 | ** |
| 7522 | 7522 | ** These interfaces impose limits on the amount of heap memory that will be |
| 7523 | -** by all database connections within a single process. | |
| 7523 | +** used by all database connections within a single process. | |
| 7524 | 7524 | ** |
| 7525 | 7525 | ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the |
| 7526 | 7526 | ** soft limit on the amount of heap memory that may be allocated by SQLite. |
| 7527 | 7527 | ** ^SQLite strives to keep heap memory utilization below the soft heap |
| 7528 | 7528 | ** limit by reducing the number of pages held in the page cache |
| @@ -7576,11 +7576,11 @@ | ||
| 7576 | 7576 | ** by [sqlite3_config]([SQLITE_CONFIG_PAGECACHE],...) rather than |
| 7577 | 7577 | ** from the heap. |
| 7578 | 7578 | ** </ul>)^ |
| 7579 | 7579 | ** |
| 7580 | 7580 | ** The circumstances under which SQLite will enforce the heap limits may |
| 7581 | -** changes in future releases of SQLite. | |
| 7581 | +** change in future releases of SQLite. | |
| 7582 | 7582 | */ |
| 7583 | 7583 | SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N); |
| 7584 | 7584 | SQLITE_API sqlite3_int64 sqlite3_hard_heap_limit64(sqlite3_int64 N); |
| 7585 | 7585 | |
| 7586 | 7586 | /* |
| @@ -7691,12 +7691,12 @@ | ||
| 7691 | 7691 | ** be tried also. |
| 7692 | 7692 | ** |
| 7693 | 7693 | ** ^The entry point is zProc. |
| 7694 | 7694 | ** ^(zProc may be 0, in which case SQLite will try to come up with an |
| 7695 | 7695 | ** entry point name on its own. It first tries "sqlite3_extension_init". |
| 7696 | -** If that does not work, it constructs a name "sqlite3_X_init" where the | |
| 7697 | -** X is consists of the lower-case equivalent of all ASCII alphabetic | |
| 7696 | +** If that does not work, it constructs a name "sqlite3_X_init" where | |
| 7697 | +** X consists of the lower-case equivalent of all ASCII alphabetic | |
| 7698 | 7698 | ** characters in the filename from the last "/" to the first following |
| 7699 | 7699 | ** "." and omitting any initial "lib".)^ |
| 7700 | 7700 | ** ^The sqlite3_load_extension() interface returns |
| 7701 | 7701 | ** [SQLITE_OK] on success and [SQLITE_ERROR] if something goes wrong. |
| 7702 | 7702 | ** ^If an error occurs and pzErrMsg is not 0, then the |
| @@ -7763,11 +7763,11 @@ | ||
| 7763 | 7763 | ** that is to be automatically loaded into all new database connections. |
| 7764 | 7764 | ** |
| 7765 | 7765 | ** ^(Even though the function prototype shows that xEntryPoint() takes |
| 7766 | 7766 | ** no arguments and returns void, SQLite invokes xEntryPoint() with three |
| 7767 | 7767 | ** arguments and expects an integer result as if the signature of the |
| 7768 | -** entry point where as follows: | |
| 7768 | +** entry point were as follows: | |
| 7769 | 7769 | ** |
| 7770 | 7770 | ** <blockquote><pre> |
| 7771 | 7771 | ** int xEntryPoint( |
| 7772 | 7772 | ** sqlite3 *db, |
| 7773 | 7773 | ** const char **pzErrMsg, |
| @@ -7927,11 +7927,11 @@ | ||
| 7927 | 7927 | ** and becomes the argvIndex-th entry in argv. ^(If aConstraintUsage[].omit |
| 7928 | 7928 | ** is true, then the constraint is assumed to be fully handled by the |
| 7929 | 7929 | ** virtual table and might not be checked again by the byte code.)^ ^(The |
| 7930 | 7930 | ** aConstraintUsage[].omit flag is an optimization hint. When the omit flag |
| 7931 | 7931 | ** is left in its default setting of false, the constraint will always be |
| 7932 | -** checked separately in byte code. If the omit flag is change to true, then | |
| 7932 | +** checked separately in byte code. If the omit flag is changed to true, then | |
| 7933 | 7933 | ** the constraint may or may not be checked in byte code. In other words, |
| 7934 | 7934 | ** when the omit flag is true there is no guarantee that the constraint will |
| 7935 | 7935 | ** not be checked again using byte code.)^ |
| 7936 | 7936 | ** |
| 7937 | 7937 | ** ^The idxNum and idxStr values are recorded and passed into the |
| @@ -7953,11 +7953,11 @@ | ||
| 7953 | 7953 | ** will be returned by the strategy. |
| 7954 | 7954 | ** |
| 7955 | 7955 | ** The xBestIndex method may optionally populate the idxFlags field with a |
| 7956 | 7956 | ** mask of SQLITE_INDEX_SCAN_* flags. One such flag is |
| 7957 | 7957 | ** [SQLITE_INDEX_SCAN_HEX], which if set causes the [EXPLAIN QUERY PLAN] |
| 7958 | -** output to show the idxNum has hex instead of as decimal. Another flag is | |
| 7958 | +** output to show the idxNum as hex instead of as decimal. Another flag is | |
| 7959 | 7959 | ** SQLITE_INDEX_SCAN_UNIQUE, which if set indicates that the query plan will |
| 7960 | 7960 | ** return at most one row. |
| 7961 | 7961 | ** |
| 7962 | 7962 | ** Additionally, if xBestIndex sets the SQLITE_INDEX_SCAN_UNIQUE flag, then |
| 7963 | 7963 | ** SQLite also assumes that if a call to the xUpdate() method is made as |
| @@ -8094,11 +8094,11 @@ | ||
| 8094 | 8094 | ** by the first parameter. ^The name of the module is given by the |
| 8095 | 8095 | ** second parameter. ^The third parameter is a pointer to |
| 8096 | 8096 | ** the implementation of the [virtual table module]. ^The fourth |
| 8097 | 8097 | ** parameter is an arbitrary client data pointer that is passed through |
| 8098 | 8098 | ** into the [xCreate] and [xConnect] methods of the virtual table module |
| 8099 | -** when a new virtual table is be being created or reinitialized. | |
| 8099 | +** when a new virtual table is being created or reinitialized. | |
| 8100 | 8100 | ** |
| 8101 | 8101 | ** ^The sqlite3_create_module_v2() interface has a fifth parameter which |
| 8102 | 8102 | ** is a pointer to a destructor for the pClientData. ^SQLite will |
| 8103 | 8103 | ** invoke the destructor function (if it is not NULL) when SQLite |
| 8104 | 8104 | ** no longer needs the pClientData pointer. ^The destructor will also |
| @@ -8259,11 +8259,11 @@ | ||
| 8259 | 8259 | ** |
| 8260 | 8260 | ** ^(On success, [SQLITE_OK] is returned and the new [BLOB handle] is stored |
| 8261 | 8261 | ** in *ppBlob. Otherwise an [error code] is returned and, unless the error |
| 8262 | 8262 | ** code is SQLITE_MISUSE, *ppBlob is set to NULL.)^ ^This means that, provided |
| 8263 | 8263 | ** the API is not misused, it is always safe to call [sqlite3_blob_close()] |
| 8264 | -** on *ppBlob after this function it returns. | |
| 8264 | +** on *ppBlob after this function returns. | |
| 8265 | 8265 | ** |
| 8266 | 8266 | ** This function fails with SQLITE_ERROR if any of the following are true: |
| 8267 | 8267 | ** <ul> |
| 8268 | 8268 | ** <li> ^(Database zDb does not exist)^, |
| 8269 | 8269 | ** <li> ^(Table zTable does not exist within database zDb)^, |
| @@ -8379,11 +8379,11 @@ | ||
| 8379 | 8379 | ** CAPI3REF: Return The Size Of An Open BLOB |
| 8380 | 8380 | ** METHOD: sqlite3_blob |
| 8381 | 8381 | ** |
| 8382 | 8382 | ** ^Returns the size in bytes of the BLOB accessible via the |
| 8383 | 8383 | ** successfully opened [BLOB handle] in its only argument. ^The |
| 8384 | -** incremental blob I/O routines can only read or overwriting existing | |
| 8384 | +** incremental blob I/O routines can only read or overwrite existing | |
| 8385 | 8385 | ** blob content; they cannot change the size of a blob. |
| 8386 | 8386 | ** |
| 8387 | 8387 | ** This routine only works on a [BLOB handle] which has been created |
| 8388 | 8388 | ** by a prior successful call to [sqlite3_blob_open()] and which has not |
| 8389 | 8389 | ** been closed by [sqlite3_blob_close()]. Passing any other pointer in |
| @@ -8529,11 +8529,11 @@ | ||
| 8529 | 8529 | ** function that calls sqlite3_initialize(). |
| 8530 | 8530 | ** |
| 8531 | 8531 | ** ^The sqlite3_mutex_alloc() routine allocates a new |
| 8532 | 8532 | ** mutex and returns a pointer to it. ^The sqlite3_mutex_alloc() |
| 8533 | 8533 | ** routine returns NULL if it is unable to allocate the requested |
| 8534 | -** mutex. The argument to sqlite3_mutex_alloc() must one of these | |
| 8534 | +** mutex. The argument to sqlite3_mutex_alloc() must be one of these | |
| 8535 | 8535 | ** integer constants: |
| 8536 | 8536 | ** |
| 8537 | 8537 | ** <ul> |
| 8538 | 8538 | ** <li> SQLITE_MUTEX_FAST |
| 8539 | 8539 | ** <li> SQLITE_MUTEX_RECURSIVE |
| @@ -8762,11 +8762,11 @@ | ||
| 8762 | 8762 | |
| 8763 | 8763 | /* |
| 8764 | 8764 | ** CAPI3REF: Retrieve the mutex for a database connection |
| 8765 | 8765 | ** METHOD: sqlite3 |
| 8766 | 8766 | ** |
| 8767 | -** ^This interface returns a pointer the [sqlite3_mutex] object that | |
| 8767 | +** ^This interface returns a pointer to the [sqlite3_mutex] object that | |
| 8768 | 8768 | ** serializes access to the [database connection] given in the argument |
| 8769 | 8769 | ** when the [threading mode] is Serialized. |
| 8770 | 8770 | ** ^If the [threading mode] is Single-thread or Multi-thread then this |
| 8771 | 8771 | ** routine returns a NULL pointer. |
| 8772 | 8772 | */ |
| @@ -8885,11 +8885,11 @@ | ||
| 8885 | 8885 | |
| 8886 | 8886 | /* |
| 8887 | 8887 | ** CAPI3REF: SQL Keyword Checking |
| 8888 | 8888 | ** |
| 8889 | 8889 | ** These routines provide access to the set of SQL language keywords |
| 8890 | -** recognized by SQLite. Applications can uses these routines to determine | |
| 8890 | +** recognized by SQLite. Applications can use these routines to determine | |
| 8891 | 8891 | ** whether or not a specific identifier needs to be escaped (for example, |
| 8892 | 8892 | ** by enclosing in double-quotes) so as not to confuse the parser. |
| 8893 | 8893 | ** |
| 8894 | 8894 | ** The sqlite3_keyword_count() interface returns the number of distinct |
| 8895 | 8895 | ** keywords understood by SQLite. |
| @@ -9053,11 +9053,11 @@ | ||
| 9053 | 9053 | ** |
| 9054 | 9054 | ** ^The [sqlite3_str_value(X)] method returns a pointer to the current |
| 9055 | 9055 | ** content of the dynamic string under construction in X. The value |
| 9056 | 9056 | ** returned by [sqlite3_str_value(X)] is managed by the sqlite3_str object X |
| 9057 | 9057 | ** and might be freed or altered by any subsequent method on the same |
| 9058 | -** [sqlite3_str] object. Applications must not used the pointer returned | |
| 9058 | +** [sqlite3_str] object. Applications must not use the pointer returned by | |
| 9059 | 9059 | ** [sqlite3_str_value(X)] after any subsequent method call on the same |
| 9060 | 9060 | ** object. ^Applications may change the content of the string returned |
| 9061 | 9061 | ** by [sqlite3_str_value(X)] as long as they do not write into any bytes |
| 9062 | 9062 | ** outside the range of 0 to [sqlite3_str_length(X)] and do not read or |
| 9063 | 9063 | ** write any byte after any subsequent sqlite3_str method call. |
| @@ -9139,11 +9139,11 @@ | ||
| 9139 | 9139 | ** ^(<dt>SQLITE_STATUS_PAGECACHE_OVERFLOW</dt> |
| 9140 | 9140 | ** <dd>This parameter returns the number of bytes of page cache |
| 9141 | 9141 | ** allocation which could not be satisfied by the [SQLITE_CONFIG_PAGECACHE] |
| 9142 | 9142 | ** buffer and where forced to overflow to [sqlite3_malloc()]. The |
| 9143 | 9143 | ** returned value includes allocations that overflowed because they |
| 9144 | -** where too large (they were larger than the "sz" parameter to | |
| 9144 | +** were too large (they were larger than the "sz" parameter to | |
| 9145 | 9145 | ** [SQLITE_CONFIG_PAGECACHE]) and allocations that overflowed because |
| 9146 | 9146 | ** no space was left in the page cache.</dd>)^ |
| 9147 | 9147 | ** |
| 9148 | 9148 | ** [[SQLITE_STATUS_PAGECACHE_SIZE]] ^(<dt>SQLITE_STATUS_PAGECACHE_SIZE</dt> |
| 9149 | 9149 | ** <dd>This parameter records the largest memory allocation request |
| @@ -9223,53 +9223,55 @@ | ||
| 9223 | 9223 | ** checked out.</dd>)^ |
| 9224 | 9224 | ** |
| 9225 | 9225 | ** [[SQLITE_DBSTATUS_LOOKASIDE_HIT]] ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_HIT</dt> |
| 9226 | 9226 | ** <dd>This parameter returns the number of malloc attempts that were |
| 9227 | 9227 | ** satisfied using lookaside memory. Only the high-water value is meaningful; |
| 9228 | -** the current value is always zero.)^ | |
| 9228 | +** the current value is always zero.</dd>)^ | |
| 9229 | 9229 | ** |
| 9230 | 9230 | ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE]] |
| 9231 | 9231 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE</dt> |
| 9232 | -** <dd>This parameter returns the number malloc attempts that might have | |
| 9232 | +** <dd>This parameter returns the number of malloc attempts that might have | |
| 9233 | 9233 | ** been satisfied using lookaside memory but failed due to the amount of |
| 9234 | 9234 | ** memory requested being larger than the lookaside slot size. |
| 9235 | 9235 | ** Only the high-water value is meaningful; |
| 9236 | -** the current value is always zero.)^ | |
| 9236 | +** the current value is always zero.</dd>)^ | |
| 9237 | 9237 | ** |
| 9238 | 9238 | ** [[SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL]] |
| 9239 | 9239 | ** ^(<dt>SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL</dt> |
| 9240 | -** <dd>This parameter returns the number malloc attempts that might have | |
| 9240 | +** <dd>This parameter returns the number of malloc attempts that might have | |
| 9241 | 9241 | ** been satisfied using lookaside memory but failed due to all lookaside |
| 9242 | 9242 | ** memory already being in use. |
| 9243 | 9243 | ** Only the high-water value is meaningful; |
| 9244 | -** the current value is always zero.)^ | |
| 9244 | +** the current value is always zero.</dd>)^ | |
| 9245 | 9245 | ** |
| 9246 | 9246 | ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> |
| 9247 | 9247 | ** <dd>This parameter returns the approximate number of bytes of heap |
| 9248 | 9248 | ** memory used by all pager caches associated with the database connection.)^ |
| 9249 | 9249 | ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. |
| 9250 | +** </dd> | |
| 9250 | 9251 | ** |
| 9251 | 9252 | ** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]] |
| 9252 | 9253 | ** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt> |
| 9253 | 9254 | ** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a |
| 9254 | 9255 | ** pager cache is shared between two or more connections the bytes of heap |
| 9255 | 9256 | ** memory used by that pager cache is divided evenly between the attached |
| 9256 | 9257 | ** connections.)^ In other words, if none of the pager caches associated |
| 9257 | 9258 | ** with the database connection are shared, this request returns the same |
| 9258 | -** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are | |
| 9259 | +** value as DBSTATUS_CACHE_USED. Or, if one or more of the pager caches are | |
| 9259 | 9260 | ** shared, the value returned by this call will be smaller than that returned |
| 9260 | 9261 | ** by DBSTATUS_CACHE_USED. ^The highwater mark associated with |
| 9261 | -** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0. | |
| 9262 | +** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.</dd> | |
| 9262 | 9263 | ** |
| 9263 | 9264 | ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> |
| 9264 | 9265 | ** <dd>This parameter returns the approximate number of bytes of heap |
| 9265 | 9266 | ** memory used to store the schema for all databases associated |
| 9266 | 9267 | ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ |
| 9267 | 9268 | ** ^The full amount of memory used by the schemas is reported, even if the |
| 9268 | 9269 | ** schema memory is shared with other database connections due to |
| 9269 | 9270 | ** [shared cache mode] being enabled. |
| 9270 | 9271 | ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. |
| 9272 | +** </dd> | |
| 9271 | 9273 | ** |
| 9272 | 9274 | ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt> |
| 9273 | 9275 | ** <dd>This parameter returns the approximate number of bytes of heap |
| 9274 | 9276 | ** and lookaside memory used by all prepared statements associated with |
| 9275 | 9277 | ** the database connection.)^ |
| @@ -9302,11 +9304,11 @@ | ||
| 9302 | 9304 | ** [[SQLITE_DBSTATUS_CACHE_SPILL]] ^(<dt>SQLITE_DBSTATUS_CACHE_SPILL</dt> |
| 9303 | 9305 | ** <dd>This parameter returns the number of dirty cache entries that have |
| 9304 | 9306 | ** been written to disk in the middle of a transaction due to the page |
| 9305 | 9307 | ** cache overflowing. Transactions are more efficient if they are written |
| 9306 | 9308 | ** to disk all at once. When pages spill mid-transaction, that introduces |
| 9307 | -** additional overhead. This parameter can be used help identify | |
| 9309 | +** additional overhead. This parameter can be used to help identify | |
| 9308 | 9310 | ** inefficiencies that can be resolved by increasing the cache size. |
| 9309 | 9311 | ** </dd> |
| 9310 | 9312 | ** |
| 9311 | 9313 | ** [[SQLITE_DBSTATUS_DEFERRED_FKS]] ^(<dt>SQLITE_DBSTATUS_DEFERRED_FKS</dt> |
| 9312 | 9314 | ** <dd>This parameter returns zero for the current value if and only if |
| @@ -9373,48 +9375,48 @@ | ||
| 9373 | 9375 | ** careful use of indices.</dd> |
| 9374 | 9376 | ** |
| 9375 | 9377 | ** [[SQLITE_STMTSTATUS_SORT]] <dt>SQLITE_STMTSTATUS_SORT</dt> |
| 9376 | 9378 | ** <dd>^This is the number of sort operations that have occurred. |
| 9377 | 9379 | ** A non-zero value in this counter may indicate an opportunity to |
| 9378 | -** improvement performance through careful use of indices.</dd> | |
| 9380 | +** improve performance through careful use of indices.</dd> | |
| 9379 | 9381 | ** |
| 9380 | 9382 | ** [[SQLITE_STMTSTATUS_AUTOINDEX]] <dt>SQLITE_STMTSTATUS_AUTOINDEX</dt> |
| 9381 | 9383 | ** <dd>^This is the number of rows inserted into transient indices that |
| 9382 | 9384 | ** were created automatically in order to help joins run faster. |
| 9383 | 9385 | ** A non-zero value in this counter may indicate an opportunity to |
| 9384 | -** improvement performance by adding permanent indices that do not | |
| 9386 | +** improve performance by adding permanent indices that do not | |
| 9385 | 9387 | ** need to be reinitialized each time the statement is run.</dd> |
| 9386 | 9388 | ** |
| 9387 | 9389 | ** [[SQLITE_STMTSTATUS_VM_STEP]] <dt>SQLITE_STMTSTATUS_VM_STEP</dt> |
| 9388 | 9390 | ** <dd>^This is the number of virtual machine operations executed |
| 9389 | 9391 | ** by the prepared statement if that number is less than or equal |
| 9390 | 9392 | ** to 2147483647. The number of virtual machine operations can be |
| 9391 | 9393 | ** used as a proxy for the total work done by the prepared statement. |
| 9392 | 9394 | ** If the number of virtual machine operations exceeds 2147483647 |
| 9393 | -** then the value returned by this statement status code is undefined. | |
| 9395 | +** then the value returned by this statement status code is undefined.</dd> | |
| 9394 | 9396 | ** |
| 9395 | 9397 | ** [[SQLITE_STMTSTATUS_REPREPARE]] <dt>SQLITE_STMTSTATUS_REPREPARE</dt> |
| 9396 | 9398 | ** <dd>^This is the number of times that the prepare statement has been |
| 9397 | 9399 | ** automatically regenerated due to schema changes or changes to |
| 9398 | -** [bound parameters] that might affect the query plan. | |
| 9400 | +** [bound parameters] that might affect the query plan.</dd> | |
| 9399 | 9401 | ** |
| 9400 | 9402 | ** [[SQLITE_STMTSTATUS_RUN]] <dt>SQLITE_STMTSTATUS_RUN</dt> |
| 9401 | 9403 | ** <dd>^This is the number of times that the prepared statement has |
| 9402 | 9404 | ** been run. A single "run" for the purposes of this counter is one |
| 9403 | 9405 | ** or more calls to [sqlite3_step()] followed by a call to [sqlite3_reset()]. |
| 9404 | 9406 | ** The counter is incremented on the first [sqlite3_step()] call of each |
| 9405 | -** cycle. | |
| 9407 | +** cycle.</dd> | |
| 9406 | 9408 | ** |
| 9407 | 9409 | ** [[SQLITE_STMTSTATUS_FILTER_MISS]] |
| 9408 | 9410 | ** [[SQLITE_STMTSTATUS_FILTER HIT]] |
| 9409 | 9411 | ** <dt>SQLITE_STMTSTATUS_FILTER_HIT<br> |
| 9410 | 9412 | ** SQLITE_STMTSTATUS_FILTER_MISS</dt> |
| 9411 | 9413 | ** <dd>^SQLITE_STMTSTATUS_FILTER_HIT is the number of times that a join |
| 9412 | 9414 | ** step was bypassed because a Bloom filter returned not-found. The |
| 9413 | 9415 | ** corresponding SQLITE_STMTSTATUS_FILTER_MISS value is the number of |
| 9414 | 9416 | ** times that the Bloom filter returned a find, and thus the join step |
| 9415 | -** had to be processed as normal. | |
| 9417 | +** had to be processed as normal.</dd> | |
| 9416 | 9418 | ** |
| 9417 | 9419 | ** [[SQLITE_STMTSTATUS_MEMUSED]] <dt>SQLITE_STMTSTATUS_MEMUSED</dt> |
| 9418 | 9420 | ** <dd>^This is the approximate number of bytes of heap memory |
| 9419 | 9421 | ** used to store the prepared statement. ^This value is not actually |
| 9420 | 9422 | ** a counter, and so the resetFlg parameter to sqlite3_stmt_status() |
| @@ -9515,31 +9517,31 @@ | ||
| 9515 | 9517 | ** [[the xCreate() page cache methods]] |
| 9516 | 9518 | ** ^SQLite invokes the xCreate() method to construct a new cache instance. |
| 9517 | 9519 | ** SQLite will typically create one cache instance for each open database file, |
| 9518 | 9520 | ** though this is not guaranteed. ^The |
| 9519 | 9521 | ** first parameter, szPage, is the size in bytes of the pages that must |
| 9520 | -** be allocated by the cache. ^szPage will always a power of two. ^The | |
| 9522 | +** be allocated by the cache. ^szPage will always be a power of two. ^The | |
| 9521 | 9523 | ** second parameter szExtra is a number of bytes of extra storage |
| 9522 | -** associated with each page cache entry. ^The szExtra parameter will | |
| 9524 | +** associated with each page cache entry. ^The szExtra parameter will be | |
| 9523 | 9525 | ** a number less than 250. SQLite will use the |
| 9524 | 9526 | ** extra szExtra bytes on each page to store metadata about the underlying |
| 9525 | 9527 | ** database page on disk. The value passed into szExtra depends |
| 9526 | 9528 | ** on the SQLite version, the target platform, and how SQLite was compiled. |
| 9527 | 9529 | ** ^The third argument to xCreate(), bPurgeable, is true if the cache being |
| 9528 | 9530 | ** created will be used to cache database pages of a file stored on disk, or |
| 9529 | 9531 | ** false if it is used for an in-memory database. The cache implementation |
| 9530 | -** does not have to do anything special based with the value of bPurgeable; | |
| 9532 | +** does not have to do anything special based upon the value of bPurgeable; | |
| 9531 | 9533 | ** it is purely advisory. ^On a cache where bPurgeable is false, SQLite will |
| 9532 | 9534 | ** never invoke xUnpin() except to deliberately delete a page. |
| 9533 | 9535 | ** ^In other words, calls to xUnpin() on a cache with bPurgeable set to |
| 9534 | 9536 | ** false will always have the "discard" flag set to true. |
| 9535 | -** ^Hence, a cache created with bPurgeable false will | |
| 9537 | +** ^Hence, a cache created with bPurgeable set to false will | |
| 9536 | 9538 | ** never contain any unpinned pages. |
| 9537 | 9539 | ** |
| 9538 | 9540 | ** [[the xCachesize() page cache method]] |
| 9539 | 9541 | ** ^(The xCachesize() method may be called at any time by SQLite to set the |
| 9540 | -** suggested maximum cache-size (number of pages stored by) the cache | |
| 9542 | +** suggested maximum cache-size (number of pages stored) for the cache | |
| 9541 | 9543 | ** instance passed as the first argument. This is the value configured using |
| 9542 | 9544 | ** the SQLite "[PRAGMA cache_size]" command.)^ As with the bPurgeable |
| 9543 | 9545 | ** parameter, the implementation is not required to do anything with this |
| 9544 | 9546 | ** value; it is advisory only. |
| 9545 | 9547 | ** |
| @@ -9562,16 +9564,16 @@ | ||
| 9562 | 9564 | ** |
| 9563 | 9565 | ** If the requested page is already in the page cache, then the page cache |
| 9564 | 9566 | ** implementation must return a pointer to the page buffer with its content |
| 9565 | 9567 | ** intact. If the requested page is not already in the cache, then the |
| 9566 | 9568 | ** cache implementation should use the value of the createFlag |
| 9567 | -** parameter to help it determined what action to take: | |
| 9569 | +** parameter to help it determine what action to take: | |
| 9568 | 9570 | ** |
| 9569 | 9571 | ** <table border=1 width=85% align=center> |
| 9570 | 9572 | ** <tr><th> createFlag <th> Behavior when page is not already in cache |
| 9571 | 9573 | ** <tr><td> 0 <td> Do not allocate a new page. Return NULL. |
| 9572 | -** <tr><td> 1 <td> Allocate a new page if it easy and convenient to do so. | |
| 9574 | +** <tr><td> 1 <td> Allocate a new page if it is easy and convenient to do so. | |
| 9573 | 9575 | ** Otherwise return NULL. |
| 9574 | 9576 | ** <tr><td> 2 <td> Make every effort to allocate a new page. Only return |
| 9575 | 9577 | ** NULL if allocating a new page is effectively impossible. |
| 9576 | 9578 | ** </table> |
| 9577 | 9579 | ** |
| @@ -9584,11 +9586,11 @@ | ||
| 9584 | 9586 | ** [[the xUnpin() page cache method]] |
| 9585 | 9587 | ** ^xUnpin() is called by SQLite with a pointer to a currently pinned page |
| 9586 | 9588 | ** as its second argument. If the third parameter, discard, is non-zero, |
| 9587 | 9589 | ** then the page must be evicted from the cache. |
| 9588 | 9590 | ** ^If the discard parameter is |
| 9589 | -** zero, then the page may be discarded or retained at the discretion of | |
| 9591 | +** zero, then the page may be discarded or retained at the discretion of the | |
| 9590 | 9592 | ** page cache implementation. ^The page cache implementation |
| 9591 | 9593 | ** may choose to evict unpinned pages at any time. |
| 9592 | 9594 | ** |
| 9593 | 9595 | ** The cache must not perform any reference counting. A single |
| 9594 | 9596 | ** call to xUnpin() unpins the page regardless of the number of prior calls |
| @@ -9602,11 +9604,11 @@ | ||
| 9602 | 9604 | ** to be pinned. |
| 9603 | 9605 | ** |
| 9604 | 9606 | ** When SQLite calls the xTruncate() method, the cache must discard all |
| 9605 | 9607 | ** existing cache entries with page numbers (keys) greater than or equal |
| 9606 | 9608 | ** to the value of the iLimit parameter passed to xTruncate(). If any |
| 9607 | -** of these pages are pinned, they are implicitly unpinned, meaning that | |
| 9609 | +** of these pages are pinned, they become implicitly unpinned, meaning that | |
| 9608 | 9610 | ** they can be safely discarded. |
| 9609 | 9611 | ** |
| 9610 | 9612 | ** [[the xDestroy() page cache method]] |
| 9611 | 9613 | ** ^The xDestroy() method is used to delete a cache allocated by xCreate(). |
| 9612 | 9614 | ** All resources associated with the specified cache should be freed. ^After |
| @@ -9782,11 +9784,11 @@ | ||
| 9782 | 9784 | ** sqlite3_backup_step(), the source database may be modified mid-way |
| 9783 | 9785 | ** through the backup process. ^If the source database is modified by an |
| 9784 | 9786 | ** external process or via a database connection other than the one being |
| 9785 | 9787 | ** used by the backup operation, then the backup will be automatically |
| 9786 | 9788 | ** restarted by the next call to sqlite3_backup_step(). ^If the source |
| 9787 | -** database is modified by the using the same database connection as is used | |
| 9789 | +** database is modified by using the same database connection as is used | |
| 9788 | 9790 | ** by the backup operation, then the backup database is automatically |
| 9789 | 9791 | ** updated at the same time. |
| 9790 | 9792 | ** |
| 9791 | 9793 | ** [[sqlite3_backup_finish()]] <b>sqlite3_backup_finish()</b> |
| 9792 | 9794 | ** |
| @@ -9799,11 +9801,11 @@ | ||
| 9799 | 9801 | ** active write-transaction on the destination database is rolled back. |
| 9800 | 9802 | ** The [sqlite3_backup] object is invalid |
| 9801 | 9803 | ** and may not be used following a call to sqlite3_backup_finish(). |
| 9802 | 9804 | ** |
| 9803 | 9805 | ** ^The value returned by sqlite3_backup_finish is [SQLITE_OK] if no |
| 9804 | -** sqlite3_backup_step() errors occurred, regardless or whether or not | |
| 9806 | +** sqlite3_backup_step() errors occurred, regardless of whether or not | |
| 9805 | 9807 | ** sqlite3_backup_step() completed. |
| 9806 | 9808 | ** ^If an out-of-memory condition or IO error occurred during any prior |
| 9807 | 9809 | ** sqlite3_backup_step() call on the same [sqlite3_backup] object, then |
| 9808 | 9810 | ** sqlite3_backup_finish() returns the corresponding [error code]. |
| 9809 | 9811 | ** |
| @@ -9901,11 +9903,11 @@ | ||
| 9901 | 9903 | ** identity of the database connection (the blocking connection) that |
| 9902 | 9904 | ** has locked the required resource is stored internally. ^After an |
| 9903 | 9905 | ** application receives an SQLITE_LOCKED error, it may call the |
| 9904 | 9906 | ** sqlite3_unlock_notify() method with the blocked connection handle as |
| 9905 | 9907 | ** the first argument to register for a callback that will be invoked |
| 9906 | -** when the blocking connections current transaction is concluded. ^The | |
| 9908 | +** when the blocking connection's current transaction is concluded. ^The | |
| 9907 | 9909 | ** callback is invoked from within the [sqlite3_step] or [sqlite3_close] |
| 9908 | 9910 | ** call that concludes the blocking connection's transaction. |
| 9909 | 9911 | ** |
| 9910 | 9912 | ** ^(If sqlite3_unlock_notify() is called in a multi-threaded application, |
| 9911 | 9913 | ** there is a chance that the blocking connection will have already |
| @@ -9921,11 +9923,11 @@ | ||
| 9921 | 9923 | ** ^(There may be at most one unlock-notify callback registered by a |
| 9922 | 9924 | ** blocked connection. If sqlite3_unlock_notify() is called when the |
| 9923 | 9925 | ** blocked connection already has a registered unlock-notify callback, |
| 9924 | 9926 | ** then the new callback replaces the old.)^ ^If sqlite3_unlock_notify() is |
| 9925 | 9927 | ** called with a NULL pointer as its second argument, then any existing |
| 9926 | -** unlock-notify callback is canceled. ^The blocked connections | |
| 9928 | +** unlock-notify callback is canceled. ^The blocked connection's | |
| 9927 | 9929 | ** unlock-notify callback may also be canceled by closing the blocked |
| 9928 | 9930 | ** connection using [sqlite3_close()]. |
| 9929 | 9931 | ** |
| 9930 | 9932 | ** The unlock-notify callback is not reentrant. If an application invokes |
| 9931 | 9933 | ** any sqlite3_xxx API functions from within an unlock-notify callback, a |
| @@ -10319,11 +10321,11 @@ | ||
| 10319 | 10321 | ** where X is an integer. If X is zero, then the [virtual table] whose |
| 10320 | 10322 | ** [xCreate] or [xConnect] method invoked [sqlite3_vtab_config()] does not |
| 10321 | 10323 | ** support constraints. In this configuration (which is the default) if |
| 10322 | 10324 | ** a call to the [xUpdate] method returns [SQLITE_CONSTRAINT], then the entire |
| 10323 | 10325 | ** statement is rolled back as if [ON CONFLICT | OR ABORT] had been |
| 10324 | -** specified as part of the users SQL statement, regardless of the actual | |
| 10326 | +** specified as part of the user's SQL statement, regardless of the actual | |
| 10325 | 10327 | ** ON CONFLICT mode specified. |
| 10326 | 10328 | ** |
| 10327 | 10329 | ** If X is non-zero, then the virtual table implementation guarantees |
| 10328 | 10330 | ** that if [xUpdate] returns [SQLITE_CONSTRAINT], it will do so before |
| 10329 | 10331 | ** any modifications to internal or persistent data structures have been made. |
| @@ -10353,11 +10355,11 @@ | ||
| 10353 | 10355 | ** </dd> |
| 10354 | 10356 | ** |
| 10355 | 10357 | ** [[SQLITE_VTAB_INNOCUOUS]]<dt>SQLITE_VTAB_INNOCUOUS</dt> |
| 10356 | 10358 | ** <dd>Calls of the form |
| 10357 | 10359 | ** [sqlite3_vtab_config](db,SQLITE_VTAB_INNOCUOUS) from within the |
| 10358 | -** the [xConnect] or [xCreate] methods of a [virtual table] implementation | |
| 10360 | +** [xConnect] or [xCreate] methods of a [virtual table] implementation | |
| 10359 | 10361 | ** identify that virtual table as being safe to use from within triggers |
| 10360 | 10362 | ** and views. Conceptually, the SQLITE_VTAB_INNOCUOUS tag means that the |
| 10361 | 10363 | ** virtual table can do no serious harm even if it is controlled by a |
| 10362 | 10364 | ** malicious hacker. Developers should avoid setting the SQLITE_VTAB_INNOCUOUS |
| 10363 | 10365 | ** flag unless absolutely necessary. |
| @@ -10521,21 +10523,21 @@ | ||
| 10521 | 10523 | ** <tr><td>2<td>no<td>yes<td>yes |
| 10522 | 10524 | ** <tr><td>3<td>yes<td>yes<td>yes |
| 10523 | 10525 | ** </table> |
| 10524 | 10526 | ** |
| 10525 | 10527 | ** ^For the purposes of comparing virtual table output values to see if the |
| 10526 | -** values are same value for sorting purposes, two NULL values are considered | |
| 10528 | +** values are the same value for sorting purposes, two NULL values are considered | |
| 10527 | 10529 | ** to be the same. In other words, the comparison operator is "IS" |
| 10528 | 10530 | ** (or "IS NOT DISTINCT FROM") and not "==". |
| 10529 | 10531 | ** |
| 10530 | 10532 | ** If a virtual table implementation is unable to meet the requirements |
| 10531 | 10533 | ** specified above, then it must not set the "orderByConsumed" flag in the |
| 10532 | 10534 | ** [sqlite3_index_info] object or an incorrect answer may result. |
| 10533 | 10535 | ** |
| 10534 | 10536 | ** ^A virtual table implementation is always free to return rows in any order |
| 10535 | 10537 | ** it wants, as long as the "orderByConsumed" flag is not set. ^When the |
| 10536 | -** the "orderByConsumed" flag is unset, the query planner will add extra | |
| 10538 | +** "orderByConsumed" flag is unset, the query planner will add extra | |
| 10537 | 10539 | ** [bytecode] to ensure that the final results returned by the SQL query are |
| 10538 | 10540 | ** ordered correctly. The use of the "orderByConsumed" flag and the |
| 10539 | 10541 | ** sqlite3_vtab_distinct() interface is merely an optimization. ^Careful |
| 10540 | 10542 | ** use of the sqlite3_vtab_distinct() interface and the "orderByConsumed" |
| 10541 | 10543 | ** flag might help queries against a virtual table to run faster. Being |
| @@ -10628,11 +10630,11 @@ | ||
| 10628 | 10630 | ** |
| 10629 | 10631 | ** The X parameter in a call to sqlite3_vtab_in_first(X,P) or |
| 10630 | 10632 | ** sqlite3_vtab_in_next(X,P) should be one of the parameters to the |
| 10631 | 10633 | ** xFilter method which invokes these routines, and specifically |
| 10632 | 10634 | ** a parameter that was previously selected for all-at-once IN constraint |
| 10633 | -** processing use the [sqlite3_vtab_in()] interface in the | |
| 10635 | +** processing using the [sqlite3_vtab_in()] interface in the | |
| 10634 | 10636 | ** [xBestIndex|xBestIndex method]. ^(If the X parameter is not |
| 10635 | 10637 | ** an xFilter argument that was selected for all-at-once IN constraint |
| 10636 | 10638 | ** processing, then these routines return [SQLITE_ERROR].)^ |
| 10637 | 10639 | ** |
| 10638 | 10640 | ** ^(Use these routines to access all values on the right-hand side |
| @@ -10683,11 +10685,11 @@ | ||
| 10683 | 10685 | ** right-hand operand is not known, then *V is set to a NULL pointer. |
| 10684 | 10686 | ** ^The sqlite3_vtab_rhs_value(P,J,V) interface returns SQLITE_OK if |
| 10685 | 10687 | ** and only if *V is set to a value. ^The sqlite3_vtab_rhs_value(P,J,V) |
| 10686 | 10688 | ** inteface returns SQLITE_NOTFOUND if the right-hand side of the J-th |
| 10687 | 10689 | ** constraint is not available. ^The sqlite3_vtab_rhs_value() interface |
| 10688 | -** can return an result code other than SQLITE_OK or SQLITE_NOTFOUND if | |
| 10690 | +** can return a result code other than SQLITE_OK or SQLITE_NOTFOUND if | |
| 10689 | 10691 | ** something goes wrong. |
| 10690 | 10692 | ** |
| 10691 | 10693 | ** The sqlite3_vtab_rhs_value() interface is usually only successful if |
| 10692 | 10694 | ** the right-hand operand of a constraint is a literal value in the original |
| 10693 | 10695 | ** SQL statement. If the right-hand operand is an expression or a reference |
| @@ -10711,12 +10713,12 @@ | ||
| 10711 | 10713 | /* |
| 10712 | 10714 | ** CAPI3REF: Conflict resolution modes |
| 10713 | 10715 | ** KEYWORDS: {conflict resolution mode} |
| 10714 | 10716 | ** |
| 10715 | 10717 | ** These constants are returned by [sqlite3_vtab_on_conflict()] to |
| 10716 | -** inform a [virtual table] implementation what the [ON CONFLICT] mode | |
| 10717 | -** is for the SQL statement being evaluated. | |
| 10718 | +** inform a [virtual table] implementation of the [ON CONFLICT] mode | |
| 10719 | +** for the SQL statement being evaluated. | |
| 10718 | 10720 | ** |
| 10719 | 10721 | ** Note that the [SQLITE_IGNORE] constant is also used as a potential |
| 10720 | 10722 | ** return value from the [sqlite3_set_authorizer()] callback and that |
| 10721 | 10723 | ** [SQLITE_ABORT] is also a [result code]. |
| 10722 | 10724 | */ |
| @@ -10752,43 +10754,43 @@ | ||
| 10752 | 10754 | ** to the total number of rows examined by all iterations of the X-th loop.</dd> |
| 10753 | 10755 | ** |
| 10754 | 10756 | ** [[SQLITE_SCANSTAT_EST]] <dt>SQLITE_SCANSTAT_EST</dt> |
| 10755 | 10757 | ** <dd>^The "double" variable pointed to by the V parameter will be set to the |
| 10756 | 10758 | ** query planner's estimate for the average number of rows output from each |
| 10757 | -** iteration of the X-th loop. If the query planner's estimates was accurate, | |
| 10759 | +** iteration of the X-th loop. If the query planner's estimate was accurate, | |
| 10758 | 10760 | ** then this value will approximate the quotient NVISIT/NLOOP and the |
| 10759 | 10761 | ** product of this value for all prior loops with the same SELECTID will |
| 10760 | -** be the NLOOP value for the current loop. | |
| 10762 | +** be the NLOOP value for the current loop.</dd> | |
| 10761 | 10763 | ** |
| 10762 | 10764 | ** [[SQLITE_SCANSTAT_NAME]] <dt>SQLITE_SCANSTAT_NAME</dt> |
| 10763 | 10765 | ** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 10764 | 10766 | ** to a zero-terminated UTF-8 string containing the name of the index or table |
| 10765 | -** used for the X-th loop. | |
| 10767 | +** used for the X-th loop.</dd> | |
| 10766 | 10768 | ** |
| 10767 | 10769 | ** [[SQLITE_SCANSTAT_EXPLAIN]] <dt>SQLITE_SCANSTAT_EXPLAIN</dt> |
| 10768 | 10770 | ** <dd>^The "const char *" variable pointed to by the V parameter will be set |
| 10769 | 10771 | ** to a zero-terminated UTF-8 string containing the [EXPLAIN QUERY PLAN] |
| 10770 | -** description for the X-th loop. | |
| 10772 | +** description for the X-th loop.</dd> | |
| 10771 | 10773 | ** |
| 10772 | 10774 | ** [[SQLITE_SCANSTAT_SELECTID]] <dt>SQLITE_SCANSTAT_SELECTID</dt> |
| 10773 | 10775 | ** <dd>^The "int" variable pointed to by the V parameter will be set to the |
| 10774 | 10776 | ** id for the X-th query plan element. The id value is unique within the |
| 10775 | 10777 | ** statement. The select-id is the same value as is output in the first |
| 10776 | -** column of an [EXPLAIN QUERY PLAN] query. | |
| 10778 | +** column of an [EXPLAIN QUERY PLAN] query.</dd> | |
| 10777 | 10779 | ** |
| 10778 | 10780 | ** [[SQLITE_SCANSTAT_PARENTID]] <dt>SQLITE_SCANSTAT_PARENTID</dt> |
| 10779 | 10781 | ** <dd>The "int" variable pointed to by the V parameter will be set to the |
| 10780 | -** the id of the parent of the current query element, if applicable, or | |
| 10782 | +** id of the parent of the current query element, if applicable, or | |
| 10781 | 10783 | ** to zero if the query element has no parent. This is the same value as |
| 10782 | -** returned in the second column of an [EXPLAIN QUERY PLAN] query. | |
| 10784 | +** returned in the second column of an [EXPLAIN QUERY PLAN] query.</dd> | |
| 10783 | 10785 | ** |
| 10784 | 10786 | ** [[SQLITE_SCANSTAT_NCYCLE]] <dt>SQLITE_SCANSTAT_NCYCLE</dt> |
| 10785 | 10787 | ** <dd>The sqlite3_int64 output value is set to the number of cycles, |
| 10786 | 10788 | ** according to the processor time-stamp counter, that elapsed while the |
| 10787 | 10789 | ** query element was being processed. This value is not available for |
| 10788 | 10790 | ** all query elements - if it is unavailable the output variable is |
| 10789 | -** set to -1. | |
| 10791 | +** set to -1.</dd> | |
| 10790 | 10792 | ** </dl> |
| 10791 | 10793 | */ |
| 10792 | 10794 | #define SQLITE_SCANSTAT_NLOOP 0 |
| 10793 | 10795 | #define SQLITE_SCANSTAT_NVISIT 1 |
| 10794 | 10796 | #define SQLITE_SCANSTAT_EST 2 |
| @@ -10825,12 +10827,12 @@ | ||
| 10825 | 10827 | ** the EXPLAIN QUERY PLAN output) are available. Invoking API |
| 10826 | 10828 | ** sqlite3_stmt_scanstatus() is equivalent to calling |
| 10827 | 10829 | ** sqlite3_stmt_scanstatus_v2() with a zeroed flags parameter. |
| 10828 | 10830 | ** |
| 10829 | 10831 | ** Parameter "idx" identifies the specific query element to retrieve statistics |
| 10830 | -** for. Query elements are numbered starting from zero. A value of -1 may be | |
| 10831 | -** to query for statistics regarding the entire query. ^If idx is out of range | |
| 10832 | +** for. Query elements are numbered starting from zero. A value of -1 may | |
| 10833 | +** retrieve statistics for the entire query. ^If idx is out of range | |
| 10832 | 10834 | ** - less than -1 or greater than or equal to the total number of query |
| 10833 | 10835 | ** elements used to implement the statement - a non-zero value is returned and |
| 10834 | 10836 | ** the variable that pOut points to is unchanged. |
| 10835 | 10837 | ** |
| 10836 | 10838 | ** See also: [sqlite3_stmt_scanstatus_reset()] |
| @@ -10869,11 +10871,11 @@ | ||
| 10869 | 10871 | /* |
| 10870 | 10872 | ** CAPI3REF: Flush caches to disk mid-transaction |
| 10871 | 10873 | ** METHOD: sqlite3 |
| 10872 | 10874 | ** |
| 10873 | 10875 | ** ^If a write-transaction is open on [database connection] D when the |
| 10874 | -** [sqlite3_db_cacheflush(D)] interface invoked, any dirty | |
| 10876 | +** [sqlite3_db_cacheflush(D)] interface is invoked, any dirty | |
| 10875 | 10877 | ** pages in the pager-cache that are not currently in use are written out |
| 10876 | 10878 | ** to disk. A dirty page may be in use if a database cursor created by an |
| 10877 | 10879 | ** active SQL statement is reading from it, or if it is page 1 of a database |
| 10878 | 10880 | ** file (page 1 is always "in use"). ^The [sqlite3_db_cacheflush(D)] |
| 10879 | 10881 | ** interface flushes caches for all schemas - "main", "temp", and |
| @@ -10983,12 +10985,12 @@ | ||
| 10983 | 10985 | ** operation; or 1 for inserts, updates, or deletes invoked by top-level |
| 10984 | 10986 | ** triggers; or 2 for changes resulting from triggers called by top-level |
| 10985 | 10987 | ** triggers; and so forth. |
| 10986 | 10988 | ** |
| 10987 | 10989 | ** When the [sqlite3_blob_write()] API is used to update a blob column, |
| 10988 | -** the pre-update hook is invoked with SQLITE_DELETE. This is because the | |
| 10989 | -** in this case the new values are not available. In this case, when a | |
| 10990 | +** the pre-update hook is invoked with SQLITE_DELETE, because | |
| 10991 | +** the new values are not yet available. In this case, when a | |
| 10990 | 10992 | ** callback made with op==SQLITE_DELETE is actually a write using the |
| 10991 | 10993 | ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns |
| 10992 | 10994 | ** the index of the column being written. In other cases, where the |
| 10993 | 10995 | ** pre-update hook is being invoked for some other reason, including a |
| 10994 | 10996 | ** regular DELETE, sqlite3_preupdate_blobwrite() returns -1. |
| @@ -11237,20 +11239,20 @@ | ||
| 11237 | 11239 | ** is written into *P. |
| 11238 | 11240 | ** |
| 11239 | 11241 | ** For an ordinary on-disk database file, the serialization is just a |
| 11240 | 11242 | ** copy of the disk file. For an in-memory database or a "TEMP" database, |
| 11241 | 11243 | ** the serialization is the same sequence of bytes which would be written |
| 11242 | -** to disk if that database where backed up to disk. | |
| 11244 | +** to disk if that database were backed up to disk. | |
| 11243 | 11245 | ** |
| 11244 | 11246 | ** The usual case is that sqlite3_serialize() copies the serialization of |
| 11245 | 11247 | ** the database into memory obtained from [sqlite3_malloc64()] and returns |
| 11246 | 11248 | ** a pointer to that memory. The caller is responsible for freeing the |
| 11247 | 11249 | ** returned value to avoid a memory leak. However, if the F argument |
| 11248 | 11250 | ** contains the SQLITE_SERIALIZE_NOCOPY bit, then no memory allocations |
| 11249 | 11251 | ** are made, and the sqlite3_serialize() function will return a pointer |
| 11250 | 11252 | ** to the contiguous memory representation of the database that SQLite |
| 11251 | -** is currently using for that database, or NULL if the no such contiguous | |
| 11253 | +** is currently using for that database, or NULL if no such contiguous | |
| 11252 | 11254 | ** memory representation of the database exists. A contiguous memory |
| 11253 | 11255 | ** representation of the database will usually only exist if there has |
| 11254 | 11256 | ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same |
| 11255 | 11257 | ** values of D and S. |
| 11256 | 11258 | ** The size of the database is written into *P even if the |
| @@ -11317,11 +11319,11 @@ | ||
| 11317 | 11319 | ** |
| 11318 | 11320 | ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the |
| 11319 | 11321 | ** database is currently in a read transaction or is involved in a backup |
| 11320 | 11322 | ** operation. |
| 11321 | 11323 | ** |
| 11322 | -** It is not possible to deserialized into the TEMP database. If the | |
| 11324 | +** It is not possible to deserialize into the TEMP database. If the | |
| 11323 | 11325 | ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the |
| 11324 | 11326 | ** function returns SQLITE_ERROR. |
| 11325 | 11327 | ** |
| 11326 | 11328 | ** The deserialized database should not be in [WAL mode]. If the database |
| 11327 | 11329 | ** is in WAL mode, then any attempt to use the database file will result |
| @@ -11339,19 +11341,19 @@ | ||
| 11339 | 11341 | */ |
| 11340 | 11342 | SQLITE_API int sqlite3_deserialize( |
| 11341 | 11343 | sqlite3 *db, /* The database connection */ |
| 11342 | 11344 | const char *zSchema, /* Which DB to reopen with the deserialization */ |
| 11343 | 11345 | unsigned char *pData, /* The serialized database content */ |
| 11344 | - sqlite3_int64 szDb, /* Number bytes in the deserialization */ | |
| 11346 | + sqlite3_int64 szDb, /* Number of bytes in the deserialization */ | |
| 11345 | 11347 | sqlite3_int64 szBuf, /* Total size of buffer pData[] */ |
| 11346 | 11348 | unsigned mFlags /* Zero or more SQLITE_DESERIALIZE_* flags */ |
| 11347 | 11349 | ); |
| 11348 | 11350 | |
| 11349 | 11351 | /* |
| 11350 | 11352 | ** CAPI3REF: Flags for sqlite3_deserialize() |
| 11351 | 11353 | ** |
| 11352 | -** The following are allowed values for 6th argument (the F argument) to | |
| 11354 | +** The following are allowed values for the 6th argument (the F argument) to | |
| 11353 | 11355 | ** the [sqlite3_deserialize(D,S,P,N,M,F)] interface. |
| 11354 | 11356 | ** |
| 11355 | 11357 | ** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization |
| 11356 | 11358 | ** in the P argument is held in memory obtained from [sqlite3_malloc64()] |
| 11357 | 11359 | ** and that SQLite should take ownership of this memory and automatically |
| @@ -11872,13 +11874,14 @@ | ||
| 11872 | 11874 | ** This may appear to have some counter-intuitive effects if a single row |
| 11873 | 11875 | ** is written to more than once during a session. For example, if a row |
| 11874 | 11876 | ** is inserted while a session object is enabled, then later deleted while |
| 11875 | 11877 | ** the same session object is disabled, no INSERT record will appear in the |
| 11876 | 11878 | ** changeset, even though the delete took place while the session was disabled. |
| 11877 | -** Or, if one field of a row is updated while a session is disabled, and | |
| 11878 | -** another field of the same row is updated while the session is enabled, the | |
| 11879 | -** resulting changeset will contain an UPDATE change that updates both fields. | |
| 11879 | +** Or, if one field of a row is updated while a session is enabled, and | |
| 11880 | +** then another field of the same row is updated while the session is disabled, | |
| 11881 | +** the resulting changeset will contain an UPDATE change that updates both | |
| 11882 | +** fields. | |
| 11880 | 11883 | */ |
| 11881 | 11884 | SQLITE_API int sqlite3session_changeset( |
| 11882 | 11885 | sqlite3_session *pSession, /* Session object */ |
| 11883 | 11886 | int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */ |
| 11884 | 11887 | void **ppChangeset /* OUT: Buffer containing changeset */ |
| @@ -12083,11 +12086,11 @@ | ||
| 12083 | 12086 | ** CAPI3REF: Flags for sqlite3changeset_start_v2 |
| 12084 | 12087 | ** |
| 12085 | 12088 | ** The following flags may passed via the 4th parameter to |
| 12086 | 12089 | ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]: |
| 12087 | 12090 | ** |
| 12088 | -** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd> | |
| 12091 | +** <dt>SQLITE_CHANGESETSTART_INVERT <dd> | |
| 12089 | 12092 | ** Invert the changeset while iterating through it. This is equivalent to |
| 12090 | 12093 | ** inverting a changeset using sqlite3changeset_invert() before applying it. |
| 12091 | 12094 | ** It is an error to specify this flag with a patchset. |
| 12092 | 12095 | */ |
| 12093 | 12096 | #define SQLITE_CHANGESETSTART_INVERT 0x0002 |
| @@ -12628,17 +12631,26 @@ | ||
| 12628 | 12631 | ** Apply a changeset or patchset to a database. These functions attempt to |
| 12629 | 12632 | ** update the "main" database attached to handle db with the changes found in |
| 12630 | 12633 | ** the changeset passed via the second and third arguments. |
| 12631 | 12634 | ** |
| 12632 | 12635 | ** The fourth argument (xFilter) passed to these functions is the "filter |
| 12633 | -** callback". If it is not NULL, then for each table affected by at least one | |
| 12634 | -** change in the changeset, the filter callback is invoked with | |
| 12635 | -** the table name as the second argument, and a copy of the context pointer | |
| 12636 | -** passed as the sixth argument as the first. If the "filter callback" | |
| 12637 | -** returns zero, then no attempt is made to apply any changes to the table. | |
| 12638 | -** Otherwise, if the return value is non-zero or the xFilter argument to | |
| 12639 | -** is NULL, all changes related to the table are attempted. | |
| 12636 | +** callback". This may be passed NULL, in which case all changes in the | |
| 12637 | +** changeset are applied to the database. For sqlite3changeset_apply() and | |
| 12638 | +** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once | |
| 12639 | +** for each table affected by at least one change in the changeset. In this | |
| 12640 | +** case the table name is passed as the second argument, and a copy of | |
| 12641 | +** the context pointer passed as the sixth argument to apply() or apply_v2() | |
| 12642 | +** as the first. If the "filter callback" returns zero, then no attempt is | |
| 12643 | +** made to apply any changes to the table. Otherwise, if the return value is | |
| 12644 | +** non-zero, all changes related to the table are attempted. | |
| 12645 | +** | |
| 12646 | +** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once | |
| 12647 | +** per change. The second argument in this case is an sqlite3_changeset_iter | |
| 12648 | +** that may be queried using the usual APIs for the details of the current | |
| 12649 | +** change. If the "filter callback" returns zero in this case, then no attempt | |
| 12650 | +** is made to apply the current change. If it returns non-zero, the change | |
| 12651 | +** is applied. | |
| 12640 | 12652 | ** |
| 12641 | 12653 | ** For each table that is not excluded by the filter callback, this function |
| 12642 | 12654 | ** tests that the target database contains a compatible table. A table is |
| 12643 | 12655 | ** considered compatible if all of the following are true: |
| 12644 | 12656 | ** |
| @@ -12655,15 +12667,15 @@ | ||
| 12655 | 12667 | ** changes associated with the table are applied. A warning message is issued |
| 12656 | 12668 | ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most |
| 12657 | 12669 | ** one such warning is issued for each table in the changeset. |
| 12658 | 12670 | ** |
| 12659 | 12671 | ** For each change for which there is a compatible table, an attempt is made |
| 12660 | -** to modify the table contents according to the UPDATE, INSERT or DELETE | |
| 12661 | -** change. If a change cannot be applied cleanly, the conflict handler | |
| 12662 | -** function passed as the fifth argument to sqlite3changeset_apply() may be | |
| 12663 | -** invoked. A description of exactly when the conflict handler is invoked for | |
| 12664 | -** each type of change is below. | |
| 12672 | +** to modify the table contents according to each UPDATE, INSERT or DELETE | |
| 12673 | +** change that is not excluded by a filter callback. If a change cannot be | |
| 12674 | +** applied cleanly, the conflict handler function passed as the fifth argument | |
| 12675 | +** to sqlite3changeset_apply() may be invoked. A description of exactly when | |
| 12676 | +** the conflict handler is invoked for each type of change is below. | |
| 12665 | 12677 | ** |
| 12666 | 12678 | ** Unlike the xFilter argument, xConflict may not be passed NULL. The results |
| 12667 | 12679 | ** of passing anything other than a valid function pointer as the xConflict |
| 12668 | 12680 | ** argument are undefined. |
| 12669 | 12681 | ** |
| @@ -12801,10 +12813,27 @@ | ||
| 12801 | 12813 | void *pChangeset, /* Changeset blob */ |
| 12802 | 12814 | int(*xFilter)( |
| 12803 | 12815 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12804 | 12816 | const char *zTab /* Table name */ |
| 12805 | 12817 | ), |
| 12818 | + int(*xConflict)( | |
| 12819 | + void *pCtx, /* Copy of sixth arg to _apply() */ | |
| 12820 | + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ | |
| 12821 | + sqlite3_changeset_iter *p /* Handle describing change and conflict */ | |
| 12822 | + ), | |
| 12823 | + void *pCtx, /* First argument passed to xConflict */ | |
| 12824 | + void **ppRebase, int *pnRebase, /* OUT: Rebase data */ | |
| 12825 | + int flags /* SESSION_CHANGESETAPPLY_* flags */ | |
| 12826 | +); | |
| 12827 | +SQLITE_API int sqlite3changeset_apply_v3( | |
| 12828 | + sqlite3 *db, /* Apply change to "main" db of this handle */ | |
| 12829 | + int nChangeset, /* Size of changeset in bytes */ | |
| 12830 | + void *pChangeset, /* Changeset blob */ | |
| 12831 | + int(*xFilter)( | |
| 12832 | + void *pCtx, /* Copy of sixth arg to _apply() */ | |
| 12833 | + sqlite3_changeset_iter *p /* Handle describing change */ | |
| 12834 | + ), | |
| 12806 | 12835 | int(*xConflict)( |
| 12807 | 12836 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12808 | 12837 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 12809 | 12838 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 12810 | 12839 | ), |
| @@ -13220,10 +13249,27 @@ | ||
| 13220 | 13249 | void *pIn, /* First arg for xInput */ |
| 13221 | 13250 | int(*xFilter)( |
| 13222 | 13251 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 13223 | 13252 | const char *zTab /* Table name */ |
| 13224 | 13253 | ), |
| 13254 | + int(*xConflict)( | |
| 13255 | + void *pCtx, /* Copy of sixth arg to _apply() */ | |
| 13256 | + int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ | |
| 13257 | + sqlite3_changeset_iter *p /* Handle describing change and conflict */ | |
| 13258 | + ), | |
| 13259 | + void *pCtx, /* First argument passed to xConflict */ | |
| 13260 | + void **ppRebase, int *pnRebase, | |
| 13261 | + int flags | |
| 13262 | +); | |
| 13263 | +SQLITE_API int sqlite3changeset_apply_v3_strm( | |
| 13264 | + sqlite3 *db, /* Apply change to "main" db of this handle */ | |
| 13265 | + int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ | |
| 13266 | + void *pIn, /* First arg for xInput */ | |
| 13267 | + int(*xFilter)( | |
| 13268 | + void *pCtx, /* Copy of sixth arg to _apply() */ | |
| 13269 | + sqlite3_changeset_iter *p | |
| 13270 | + ), | |
| 13225 | 13271 | int(*xConflict)( |
| 13226 | 13272 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 13227 | 13273 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 13228 | 13274 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 13229 | 13275 | ), |
| @@ -15173,11 +15219,11 @@ | ||
| 15173 | 15219 | /* |
| 15174 | 15220 | ** GCC does not define the offsetof() macro so we'll have to do it |
| 15175 | 15221 | ** ourselves. |
| 15176 | 15222 | */ |
| 15177 | 15223 | #ifndef offsetof |
| 15178 | -#define offsetof(STRUCTURE,FIELD) ((size_t)((char*)&((STRUCTURE*)0)->FIELD)) | |
| 15224 | +# define offsetof(ST,M) ((size_t)((char*)&((ST*)0)->M - (char*)0)) | |
| 15179 | 15225 | #endif |
| 15180 | 15226 | |
| 15181 | 15227 | /* |
| 15182 | 15228 | ** Work around C99 "flex-array" syntax for pre-C99 compilers, so as |
| 15183 | 15229 | ** to avoid complaints from -fsanitize=strict-bounds. |
| @@ -15439,12 +15485,12 @@ | ||
| 15439 | 15485 | /* |
| 15440 | 15486 | ** Macro SMXV(n) return the maximum value that can be held in variable n, |
| 15441 | 15487 | ** assuming n is a signed integer type. UMXV(n) is similar for unsigned |
| 15442 | 15488 | ** integer types. |
| 15443 | 15489 | */ |
| 15444 | -#define SMXV(n) ((((i64)1)<<(sizeof(n)-1))-1) | |
| 15445 | -#define UMXV(n) ((((i64)1)<<(sizeof(n)))-1) | |
| 15490 | +#define SMXV(n) ((((i64)1)<<(sizeof(n)*8-1))-1) | |
| 15491 | +#define UMXV(n) ((((i64)1)<<(sizeof(n)*8))-1) | |
| 15446 | 15492 | |
| 15447 | 15493 | /* |
| 15448 | 15494 | ** Round up a number to the next larger multiple of 8. This is used |
| 15449 | 15495 | ** to force 8-byte alignment on 64-bit architectures. |
| 15450 | 15496 | ** |
| @@ -15561,10 +15607,12 @@ | ||
| 15561 | 15607 | ** 0x00008000 After all FROM-clause analysis |
| 15562 | 15608 | ** 0x00010000 Beginning of DELETE/INSERT/UPDATE processing |
| 15563 | 15609 | ** 0x00020000 Transform DISTINCT into GROUP BY |
| 15564 | 15610 | ** 0x00040000 SELECT tree dump after all code has been generated |
| 15565 | 15611 | ** 0x00080000 NOT NULL strength reduction |
| 15612 | +** 0x00100000 Pointers are all shown as zero | |
| 15613 | +** 0x00200000 EXISTS-to-JOIN optimization | |
| 15566 | 15614 | */ |
| 15567 | 15615 | |
| 15568 | 15616 | /* |
| 15569 | 15617 | ** Macros for "wheretrace" |
| 15570 | 15618 | */ |
| @@ -15605,10 +15653,11 @@ | ||
| 15605 | 15653 | ** |
| 15606 | 15654 | ** 0x00010000 Show more detail when printing WHERE terms |
| 15607 | 15655 | ** 0x00020000 Show WHERE terms returned from whereScanNext() |
| 15608 | 15656 | ** 0x00040000 Solver overview messages |
| 15609 | 15657 | ** 0x00080000 Star-query heuristic |
| 15658 | +** 0x00100000 Pointers are all shown as zero | |
| 15610 | 15659 | */ |
| 15611 | 15660 | |
| 15612 | 15661 | |
| 15613 | 15662 | /* |
| 15614 | 15663 | ** An instance of the following structure is used to store the busy-handler |
| @@ -15677,11 +15726,11 @@ | ||
| 15677 | 15726 | ** one parameter that destructors normally want. So we have to introduce |
| 15678 | 15727 | ** this magic value that the code knows to handle differently. Any |
| 15679 | 15728 | ** pointer will work here as long as it is distinct from SQLITE_STATIC |
| 15680 | 15729 | ** and SQLITE_TRANSIENT. |
| 15681 | 15730 | */ |
| 15682 | -#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3OomClear) | |
| 15731 | +#define SQLITE_DYNAMIC ((sqlite3_destructor_type)sqlite3RowSetClear) | |
| 15683 | 15732 | |
| 15684 | 15733 | /* |
| 15685 | 15734 | ** When SQLITE_OMIT_WSD is defined, it means that the target platform does |
| 15686 | 15735 | ** not support Writable Static Data (WSD) such as global and static variables. |
| 15687 | 15736 | ** All variables must either be on the stack or dynamically allocated from |
| @@ -16745,10 +16794,11 @@ | ||
| 16745 | 16794 | }; |
| 16746 | 16795 | |
| 16747 | 16796 | SQLITE_PRIVATE int sqlite3BtreeInsert(BtCursor*, const BtreePayload *pPayload, |
| 16748 | 16797 | int flags, int seekResult); |
| 16749 | 16798 | SQLITE_PRIVATE int sqlite3BtreeFirst(BtCursor*, int *pRes); |
| 16799 | +SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes); | |
| 16750 | 16800 | SQLITE_PRIVATE int sqlite3BtreeLast(BtCursor*, int *pRes); |
| 16751 | 16801 | SQLITE_PRIVATE int sqlite3BtreeNext(BtCursor*, int flags); |
| 16752 | 16802 | SQLITE_PRIVATE int sqlite3BtreeEof(BtCursor*); |
| 16753 | 16803 | SQLITE_PRIVATE int sqlite3BtreePrevious(BtCursor*, int flags); |
| 16754 | 16804 | SQLITE_PRIVATE i64 sqlite3BtreeIntegerKey(BtCursor*); |
| @@ -17078,76 +17128,76 @@ | ||
| 17078 | 17128 | #define OP_Last 32 /* jump0 */ |
| 17079 | 17129 | #define OP_IfSizeBetween 33 /* jump */ |
| 17080 | 17130 | #define OP_SorterSort 34 /* jump */ |
| 17081 | 17131 | #define OP_Sort 35 /* jump */ |
| 17082 | 17132 | #define OP_Rewind 36 /* jump0 */ |
| 17083 | -#define OP_SorterNext 37 /* jump */ | |
| 17084 | -#define OP_Prev 38 /* jump */ | |
| 17085 | -#define OP_Next 39 /* jump */ | |
| 17086 | -#define OP_IdxLE 40 /* jump, synopsis: key=r[P3@P4] */ | |
| 17087 | -#define OP_IdxGT 41 /* jump, synopsis: key=r[P3@P4] */ | |
| 17088 | -#define OP_IdxLT 42 /* jump, synopsis: key=r[P3@P4] */ | |
| 17133 | +#define OP_IfEmpty 37 /* jump, synopsis: if( empty(P1) ) goto P2 */ | |
| 17134 | +#define OP_SorterNext 38 /* jump */ | |
| 17135 | +#define OP_Prev 39 /* jump */ | |
| 17136 | +#define OP_Next 40 /* jump */ | |
| 17137 | +#define OP_IdxLE 41 /* jump, synopsis: key=r[P3@P4] */ | |
| 17138 | +#define OP_IdxGT 42 /* jump, synopsis: key=r[P3@P4] */ | |
| 17089 | 17139 | #define OP_Or 43 /* same as TK_OR, synopsis: r[P3]=(r[P1] || r[P2]) */ |
| 17090 | 17140 | #define OP_And 44 /* same as TK_AND, synopsis: r[P3]=(r[P1] && r[P2]) */ |
| 17091 | -#define OP_IdxGE 45 /* jump, synopsis: key=r[P3@P4] */ | |
| 17092 | -#define OP_RowSetRead 46 /* jump, synopsis: r[P3]=rowset(P1) */ | |
| 17093 | -#define OP_RowSetTest 47 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ | |
| 17094 | -#define OP_Program 48 /* jump0 */ | |
| 17095 | -#define OP_FkIfZero 49 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ | |
| 17096 | -#define OP_IfPos 50 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ | |
| 17141 | +#define OP_IdxLT 45 /* jump, synopsis: key=r[P3@P4] */ | |
| 17142 | +#define OP_IdxGE 46 /* jump, synopsis: key=r[P3@P4] */ | |
| 17143 | +#define OP_RowSetRead 47 /* jump, synopsis: r[P3]=rowset(P1) */ | |
| 17144 | +#define OP_RowSetTest 48 /* jump, synopsis: if r[P3] in rowset(P1) goto P2 */ | |
| 17145 | +#define OP_Program 49 /* jump0 */ | |
| 17146 | +#define OP_FkIfZero 50 /* jump, synopsis: if fkctr[P1]==0 goto P2 */ | |
| 17097 | 17147 | #define OP_IsNull 51 /* jump, same as TK_ISNULL, synopsis: if r[P1]==NULL goto P2 */ |
| 17098 | 17148 | #define OP_NotNull 52 /* jump, same as TK_NOTNULL, synopsis: if r[P1]!=NULL goto P2 */ |
| 17099 | 17149 | #define OP_Ne 53 /* jump, same as TK_NE, synopsis: IF r[P3]!=r[P1] */ |
| 17100 | 17150 | #define OP_Eq 54 /* jump, same as TK_EQ, synopsis: IF r[P3]==r[P1] */ |
| 17101 | 17151 | #define OP_Gt 55 /* jump, same as TK_GT, synopsis: IF r[P3]>r[P1] */ |
| 17102 | 17152 | #define OP_Le 56 /* jump, same as TK_LE, synopsis: IF r[P3]<=r[P1] */ |
| 17103 | 17153 | #define OP_Lt 57 /* jump, same as TK_LT, synopsis: IF r[P3]<r[P1] */ |
| 17104 | 17154 | #define OP_Ge 58 /* jump, same as TK_GE, synopsis: IF r[P3]>=r[P1] */ |
| 17105 | 17155 | #define OP_ElseEq 59 /* jump, same as TK_ESCAPE */ |
| 17106 | -#define OP_IfNotZero 60 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ | |
| 17107 | -#define OP_DecrJumpZero 61 /* jump, synopsis: if (--r[P1])==0 goto P2 */ | |
| 17108 | -#define OP_IncrVacuum 62 /* jump */ | |
| 17109 | -#define OP_VNext 63 /* jump */ | |
| 17110 | -#define OP_Filter 64 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */ | |
| 17111 | -#define OP_PureFunc 65 /* synopsis: r[P3]=func(r[P2@NP]) */ | |
| 17112 | -#define OP_Function 66 /* synopsis: r[P3]=func(r[P2@NP]) */ | |
| 17113 | -#define OP_Return 67 | |
| 17114 | -#define OP_EndCoroutine 68 | |
| 17115 | -#define OP_HaltIfNull 69 /* synopsis: if r[P3]=null halt */ | |
| 17116 | -#define OP_Halt 70 | |
| 17117 | -#define OP_Integer 71 /* synopsis: r[P2]=P1 */ | |
| 17118 | -#define OP_Int64 72 /* synopsis: r[P2]=P4 */ | |
| 17119 | -#define OP_String 73 /* synopsis: r[P2]='P4' (len=P1) */ | |
| 17120 | -#define OP_BeginSubrtn 74 /* synopsis: r[P2]=NULL */ | |
| 17121 | -#define OP_Null 75 /* synopsis: r[P2..P3]=NULL */ | |
| 17122 | -#define OP_SoftNull 76 /* synopsis: r[P1]=NULL */ | |
| 17123 | -#define OP_Blob 77 /* synopsis: r[P2]=P4 (len=P1) */ | |
| 17124 | -#define OP_Variable 78 /* synopsis: r[P2]=parameter(P1) */ | |
| 17125 | -#define OP_Move 79 /* synopsis: r[P2@P3]=r[P1@P3] */ | |
| 17126 | -#define OP_Copy 80 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ | |
| 17127 | -#define OP_SCopy 81 /* synopsis: r[P2]=r[P1] */ | |
| 17128 | -#define OP_IntCopy 82 /* synopsis: r[P2]=r[P1] */ | |
| 17129 | -#define OP_FkCheck 83 | |
| 17130 | -#define OP_ResultRow 84 /* synopsis: output=r[P1@P2] */ | |
| 17131 | -#define OP_CollSeq 85 | |
| 17132 | -#define OP_AddImm 86 /* synopsis: r[P1]=r[P1]+P2 */ | |
| 17133 | -#define OP_RealAffinity 87 | |
| 17134 | -#define OP_Cast 88 /* synopsis: affinity(r[P1]) */ | |
| 17135 | -#define OP_Permutation 89 | |
| 17136 | -#define OP_Compare 90 /* synopsis: r[P1@P3] <-> r[P2@P3] */ | |
| 17137 | -#define OP_IsTrue 91 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ | |
| 17138 | -#define OP_ZeroOrNull 92 /* synopsis: r[P2] = 0 OR NULL */ | |
| 17139 | -#define OP_Offset 93 /* synopsis: r[P3] = sqlite_offset(P1) */ | |
| 17140 | -#define OP_Column 94 /* synopsis: r[P3]=PX cursor P1 column P2 */ | |
| 17141 | -#define OP_TypeCheck 95 /* synopsis: typecheck(r[P1@P2]) */ | |
| 17142 | -#define OP_Affinity 96 /* synopsis: affinity(r[P1@P2]) */ | |
| 17143 | -#define OP_MakeRecord 97 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ | |
| 17144 | -#define OP_Count 98 /* synopsis: r[P2]=count() */ | |
| 17145 | -#define OP_ReadCookie 99 | |
| 17146 | -#define OP_SetCookie 100 | |
| 17147 | -#define OP_ReopenIdx 101 /* synopsis: root=P2 iDb=P3 */ | |
| 17148 | -#define OP_OpenRead 102 /* synopsis: root=P2 iDb=P3 */ | |
| 17156 | +#define OP_IfPos 60 /* jump, synopsis: if r[P1]>0 then r[P1]-=P3, goto P2 */ | |
| 17157 | +#define OP_IfNotZero 61 /* jump, synopsis: if r[P1]!=0 then r[P1]--, goto P2 */ | |
| 17158 | +#define OP_DecrJumpZero 62 /* jump, synopsis: if (--r[P1])==0 goto P2 */ | |
| 17159 | +#define OP_IncrVacuum 63 /* jump */ | |
| 17160 | +#define OP_VNext 64 /* jump */ | |
| 17161 | +#define OP_Filter 65 /* jump, synopsis: if key(P3@P4) not in filter(P1) goto P2 */ | |
| 17162 | +#define OP_PureFunc 66 /* synopsis: r[P3]=func(r[P2@NP]) */ | |
| 17163 | +#define OP_Function 67 /* synopsis: r[P3]=func(r[P2@NP]) */ | |
| 17164 | +#define OP_Return 68 | |
| 17165 | +#define OP_EndCoroutine 69 | |
| 17166 | +#define OP_HaltIfNull 70 /* synopsis: if r[P3]=null halt */ | |
| 17167 | +#define OP_Halt 71 | |
| 17168 | +#define OP_Integer 72 /* synopsis: r[P2]=P1 */ | |
| 17169 | +#define OP_Int64 73 /* synopsis: r[P2]=P4 */ | |
| 17170 | +#define OP_String 74 /* synopsis: r[P2]='P4' (len=P1) */ | |
| 17171 | +#define OP_BeginSubrtn 75 /* synopsis: r[P2]=NULL */ | |
| 17172 | +#define OP_Null 76 /* synopsis: r[P2..P3]=NULL */ | |
| 17173 | +#define OP_SoftNull 77 /* synopsis: r[P1]=NULL */ | |
| 17174 | +#define OP_Blob 78 /* synopsis: r[P2]=P4 (len=P1) */ | |
| 17175 | +#define OP_Variable 79 /* synopsis: r[P2]=parameter(P1) */ | |
| 17176 | +#define OP_Move 80 /* synopsis: r[P2@P3]=r[P1@P3] */ | |
| 17177 | +#define OP_Copy 81 /* synopsis: r[P2@P3+1]=r[P1@P3+1] */ | |
| 17178 | +#define OP_SCopy 82 /* synopsis: r[P2]=r[P1] */ | |
| 17179 | +#define OP_IntCopy 83 /* synopsis: r[P2]=r[P1] */ | |
| 17180 | +#define OP_FkCheck 84 | |
| 17181 | +#define OP_ResultRow 85 /* synopsis: output=r[P1@P2] */ | |
| 17182 | +#define OP_CollSeq 86 | |
| 17183 | +#define OP_AddImm 87 /* synopsis: r[P1]=r[P1]+P2 */ | |
| 17184 | +#define OP_RealAffinity 88 | |
| 17185 | +#define OP_Cast 89 /* synopsis: affinity(r[P1]) */ | |
| 17186 | +#define OP_Permutation 90 | |
| 17187 | +#define OP_Compare 91 /* synopsis: r[P1@P3] <-> r[P2@P3] */ | |
| 17188 | +#define OP_IsTrue 92 /* synopsis: r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4 */ | |
| 17189 | +#define OP_ZeroOrNull 93 /* synopsis: r[P2] = 0 OR NULL */ | |
| 17190 | +#define OP_Offset 94 /* synopsis: r[P3] = sqlite_offset(P1) */ | |
| 17191 | +#define OP_Column 95 /* synopsis: r[P3]=PX cursor P1 column P2 */ | |
| 17192 | +#define OP_TypeCheck 96 /* synopsis: typecheck(r[P1@P2]) */ | |
| 17193 | +#define OP_Affinity 97 /* synopsis: affinity(r[P1@P2]) */ | |
| 17194 | +#define OP_MakeRecord 98 /* synopsis: r[P3]=mkrec(r[P1@P2]) */ | |
| 17195 | +#define OP_Count 99 /* synopsis: r[P2]=count() */ | |
| 17196 | +#define OP_ReadCookie 100 | |
| 17197 | +#define OP_SetCookie 101 | |
| 17198 | +#define OP_ReopenIdx 102 /* synopsis: root=P2 iDb=P3 */ | |
| 17149 | 17199 | #define OP_BitAnd 103 /* same as TK_BITAND, synopsis: r[P3]=r[P1]&r[P2] */ |
| 17150 | 17200 | #define OP_BitOr 104 /* same as TK_BITOR, synopsis: r[P3]=r[P1]|r[P2] */ |
| 17151 | 17201 | #define OP_ShiftLeft 105 /* same as TK_LSHIFT, synopsis: r[P3]=r[P2]<<r[P1] */ |
| 17152 | 17202 | #define OP_ShiftRight 106 /* same as TK_RSHIFT, synopsis: r[P3]=r[P2]>>r[P1] */ |
| 17153 | 17203 | #define OP_Add 107 /* same as TK_PLUS, synopsis: r[P3]=r[P1]+r[P2] */ |
| @@ -17154,87 +17204,88 @@ | ||
| 17154 | 17204 | #define OP_Subtract 108 /* same as TK_MINUS, synopsis: r[P3]=r[P2]-r[P1] */ |
| 17155 | 17205 | #define OP_Multiply 109 /* same as TK_STAR, synopsis: r[P3]=r[P1]*r[P2] */ |
| 17156 | 17206 | #define OP_Divide 110 /* same as TK_SLASH, synopsis: r[P3]=r[P2]/r[P1] */ |
| 17157 | 17207 | #define OP_Remainder 111 /* same as TK_REM, synopsis: r[P3]=r[P2]%r[P1] */ |
| 17158 | 17208 | #define OP_Concat 112 /* same as TK_CONCAT, synopsis: r[P3]=r[P2]+r[P1] */ |
| 17159 | -#define OP_OpenWrite 113 /* synopsis: root=P2 iDb=P3 */ | |
| 17160 | -#define OP_OpenDup 114 | |
| 17209 | +#define OP_OpenRead 113 /* synopsis: root=P2 iDb=P3 */ | |
| 17210 | +#define OP_OpenWrite 114 /* synopsis: root=P2 iDb=P3 */ | |
| 17161 | 17211 | #define OP_BitNot 115 /* same as TK_BITNOT, synopsis: r[P2]= ~r[P1] */ |
| 17162 | -#define OP_OpenAutoindex 116 /* synopsis: nColumn=P2 */ | |
| 17163 | -#define OP_OpenEphemeral 117 /* synopsis: nColumn=P2 */ | |
| 17212 | +#define OP_OpenDup 116 | |
| 17213 | +#define OP_OpenAutoindex 117 /* synopsis: nColumn=P2 */ | |
| 17164 | 17214 | #define OP_String8 118 /* same as TK_STRING, synopsis: r[P2]='P4' */ |
| 17165 | -#define OP_SorterOpen 119 | |
| 17166 | -#define OP_SequenceTest 120 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ | |
| 17167 | -#define OP_OpenPseudo 121 /* synopsis: P3 columns in r[P2] */ | |
| 17168 | -#define OP_Close 122 | |
| 17169 | -#define OP_ColumnsUsed 123 | |
| 17170 | -#define OP_SeekScan 124 /* synopsis: Scan-ahead up to P1 rows */ | |
| 17171 | -#define OP_SeekHit 125 /* synopsis: set P2<=seekHit<=P3 */ | |
| 17172 | -#define OP_Sequence 126 /* synopsis: r[P2]=cursor[P1].ctr++ */ | |
| 17173 | -#define OP_NewRowid 127 /* synopsis: r[P2]=rowid */ | |
| 17174 | -#define OP_Insert 128 /* synopsis: intkey=r[P3] data=r[P2] */ | |
| 17175 | -#define OP_RowCell 129 | |
| 17176 | -#define OP_Delete 130 | |
| 17177 | -#define OP_ResetCount 131 | |
| 17178 | -#define OP_SorterCompare 132 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ | |
| 17179 | -#define OP_SorterData 133 /* synopsis: r[P2]=data */ | |
| 17180 | -#define OP_RowData 134 /* synopsis: r[P2]=data */ | |
| 17181 | -#define OP_Rowid 135 /* synopsis: r[P2]=PX rowid of P1 */ | |
| 17182 | -#define OP_NullRow 136 | |
| 17183 | -#define OP_SeekEnd 137 | |
| 17184 | -#define OP_IdxInsert 138 /* synopsis: key=r[P2] */ | |
| 17185 | -#define OP_SorterInsert 139 /* synopsis: key=r[P2] */ | |
| 17186 | -#define OP_IdxDelete 140 /* synopsis: key=r[P2@P3] */ | |
| 17187 | -#define OP_DeferredSeek 141 /* synopsis: Move P3 to P1.rowid if needed */ | |
| 17188 | -#define OP_IdxRowid 142 /* synopsis: r[P2]=rowid */ | |
| 17189 | -#define OP_FinishSeek 143 | |
| 17190 | -#define OP_Destroy 144 | |
| 17191 | -#define OP_Clear 145 | |
| 17192 | -#define OP_ResetSorter 146 | |
| 17193 | -#define OP_CreateBtree 147 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ | |
| 17194 | -#define OP_SqlExec 148 | |
| 17195 | -#define OP_ParseSchema 149 | |
| 17196 | -#define OP_LoadAnalysis 150 | |
| 17197 | -#define OP_DropTable 151 | |
| 17198 | -#define OP_DropIndex 152 | |
| 17199 | -#define OP_DropTrigger 153 | |
| 17215 | +#define OP_OpenEphemeral 119 /* synopsis: nColumn=P2 */ | |
| 17216 | +#define OP_SorterOpen 120 | |
| 17217 | +#define OP_SequenceTest 121 /* synopsis: if( cursor[P1].ctr++ ) pc = P2 */ | |
| 17218 | +#define OP_OpenPseudo 122 /* synopsis: P3 columns in r[P2] */ | |
| 17219 | +#define OP_Close 123 | |
| 17220 | +#define OP_ColumnsUsed 124 | |
| 17221 | +#define OP_SeekScan 125 /* synopsis: Scan-ahead up to P1 rows */ | |
| 17222 | +#define OP_SeekHit 126 /* synopsis: set P2<=seekHit<=P3 */ | |
| 17223 | +#define OP_Sequence 127 /* synopsis: r[P2]=cursor[P1].ctr++ */ | |
| 17224 | +#define OP_NewRowid 128 /* synopsis: r[P2]=rowid */ | |
| 17225 | +#define OP_Insert 129 /* synopsis: intkey=r[P3] data=r[P2] */ | |
| 17226 | +#define OP_RowCell 130 | |
| 17227 | +#define OP_Delete 131 | |
| 17228 | +#define OP_ResetCount 132 | |
| 17229 | +#define OP_SorterCompare 133 /* synopsis: if key(P1)!=trim(r[P3],P4) goto P2 */ | |
| 17230 | +#define OP_SorterData 134 /* synopsis: r[P2]=data */ | |
| 17231 | +#define OP_RowData 135 /* synopsis: r[P2]=data */ | |
| 17232 | +#define OP_Rowid 136 /* synopsis: r[P2]=PX rowid of P1 */ | |
| 17233 | +#define OP_NullRow 137 | |
| 17234 | +#define OP_SeekEnd 138 | |
| 17235 | +#define OP_IdxInsert 139 /* synopsis: key=r[P2] */ | |
| 17236 | +#define OP_SorterInsert 140 /* synopsis: key=r[P2] */ | |
| 17237 | +#define OP_IdxDelete 141 /* synopsis: key=r[P2@P3] */ | |
| 17238 | +#define OP_DeferredSeek 142 /* synopsis: Move P3 to P1.rowid if needed */ | |
| 17239 | +#define OP_IdxRowid 143 /* synopsis: r[P2]=rowid */ | |
| 17240 | +#define OP_FinishSeek 144 | |
| 17241 | +#define OP_Destroy 145 | |
| 17242 | +#define OP_Clear 146 | |
| 17243 | +#define OP_ResetSorter 147 | |
| 17244 | +#define OP_CreateBtree 148 /* synopsis: r[P2]=root iDb=P1 flags=P3 */ | |
| 17245 | +#define OP_SqlExec 149 | |
| 17246 | +#define OP_ParseSchema 150 | |
| 17247 | +#define OP_LoadAnalysis 151 | |
| 17248 | +#define OP_DropTable 152 | |
| 17249 | +#define OP_DropIndex 153 | |
| 17200 | 17250 | #define OP_Real 154 /* same as TK_FLOAT, synopsis: r[P2]=P4 */ |
| 17201 | -#define OP_IntegrityCk 155 | |
| 17202 | -#define OP_RowSetAdd 156 /* synopsis: rowset(P1)=r[P2] */ | |
| 17203 | -#define OP_Param 157 | |
| 17204 | -#define OP_FkCounter 158 /* synopsis: fkctr[P1]+=P2 */ | |
| 17205 | -#define OP_MemMax 159 /* synopsis: r[P1]=max(r[P1],r[P2]) */ | |
| 17206 | -#define OP_OffsetLimit 160 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ | |
| 17207 | -#define OP_AggInverse 161 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ | |
| 17208 | -#define OP_AggStep 162 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | |
| 17209 | -#define OP_AggStep1 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | |
| 17210 | -#define OP_AggValue 164 /* synopsis: r[P3]=value N=P2 */ | |
| 17211 | -#define OP_AggFinal 165 /* synopsis: accum=r[P1] N=P2 */ | |
| 17212 | -#define OP_Expire 166 | |
| 17213 | -#define OP_CursorLock 167 | |
| 17214 | -#define OP_CursorUnlock 168 | |
| 17215 | -#define OP_TableLock 169 /* synopsis: iDb=P1 root=P2 write=P3 */ | |
| 17216 | -#define OP_VBegin 170 | |
| 17217 | -#define OP_VCreate 171 | |
| 17218 | -#define OP_VDestroy 172 | |
| 17219 | -#define OP_VOpen 173 | |
| 17220 | -#define OP_VCheck 174 | |
| 17221 | -#define OP_VInitIn 175 /* synopsis: r[P2]=ValueList(P1,P3) */ | |
| 17222 | -#define OP_VColumn 176 /* synopsis: r[P3]=vcolumn(P2) */ | |
| 17223 | -#define OP_VRename 177 | |
| 17224 | -#define OP_Pagecount 178 | |
| 17225 | -#define OP_MaxPgcnt 179 | |
| 17226 | -#define OP_ClrSubtype 180 /* synopsis: r[P1].subtype = 0 */ | |
| 17227 | -#define OP_GetSubtype 181 /* synopsis: r[P2] = r[P1].subtype */ | |
| 17228 | -#define OP_SetSubtype 182 /* synopsis: r[P2].subtype = r[P1] */ | |
| 17229 | -#define OP_FilterAdd 183 /* synopsis: filter(P1) += key(P3@P4) */ | |
| 17230 | -#define OP_Trace 184 | |
| 17231 | -#define OP_CursorHint 185 | |
| 17232 | -#define OP_ReleaseReg 186 /* synopsis: release r[P1@P2] mask P3 */ | |
| 17233 | -#define OP_Noop 187 | |
| 17234 | -#define OP_Explain 188 | |
| 17235 | -#define OP_Abortable 189 | |
| 17251 | +#define OP_DropTrigger 155 | |
| 17252 | +#define OP_IntegrityCk 156 | |
| 17253 | +#define OP_RowSetAdd 157 /* synopsis: rowset(P1)=r[P2] */ | |
| 17254 | +#define OP_Param 158 | |
| 17255 | +#define OP_FkCounter 159 /* synopsis: fkctr[P1]+=P2 */ | |
| 17256 | +#define OP_MemMax 160 /* synopsis: r[P1]=max(r[P1],r[P2]) */ | |
| 17257 | +#define OP_OffsetLimit 161 /* synopsis: if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1) */ | |
| 17258 | +#define OP_AggInverse 162 /* synopsis: accum=r[P3] inverse(r[P2@P5]) */ | |
| 17259 | +#define OP_AggStep 163 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | |
| 17260 | +#define OP_AggStep1 164 /* synopsis: accum=r[P3] step(r[P2@P5]) */ | |
| 17261 | +#define OP_AggValue 165 /* synopsis: r[P3]=value N=P2 */ | |
| 17262 | +#define OP_AggFinal 166 /* synopsis: accum=r[P1] N=P2 */ | |
| 17263 | +#define OP_Expire 167 | |
| 17264 | +#define OP_CursorLock 168 | |
| 17265 | +#define OP_CursorUnlock 169 | |
| 17266 | +#define OP_TableLock 170 /* synopsis: iDb=P1 root=P2 write=P3 */ | |
| 17267 | +#define OP_VBegin 171 | |
| 17268 | +#define OP_VCreate 172 | |
| 17269 | +#define OP_VDestroy 173 | |
| 17270 | +#define OP_VOpen 174 | |
| 17271 | +#define OP_VCheck 175 | |
| 17272 | +#define OP_VInitIn 176 /* synopsis: r[P2]=ValueList(P1,P3) */ | |
| 17273 | +#define OP_VColumn 177 /* synopsis: r[P3]=vcolumn(P2) */ | |
| 17274 | +#define OP_VRename 178 | |
| 17275 | +#define OP_Pagecount 179 | |
| 17276 | +#define OP_MaxPgcnt 180 | |
| 17277 | +#define OP_ClrSubtype 181 /* synopsis: r[P1].subtype = 0 */ | |
| 17278 | +#define OP_GetSubtype 182 /* synopsis: r[P2] = r[P1].subtype */ | |
| 17279 | +#define OP_SetSubtype 183 /* synopsis: r[P2].subtype = r[P1] */ | |
| 17280 | +#define OP_FilterAdd 184 /* synopsis: filter(P1) += key(P3@P4) */ | |
| 17281 | +#define OP_Trace 185 | |
| 17282 | +#define OP_CursorHint 186 | |
| 17283 | +#define OP_ReleaseReg 187 /* synopsis: release r[P1@P2] mask P3 */ | |
| 17284 | +#define OP_Noop 188 | |
| 17285 | +#define OP_Explain 189 | |
| 17286 | +#define OP_Abortable 190 | |
| 17236 | 17287 | |
| 17237 | 17288 | /* Properties such as "out2" or "jump" that are specified in |
| 17238 | 17289 | ** comments following the "case" for each opcode in the vdbe.c |
| 17239 | 17290 | ** are encoded into bitvectors as follows: |
| 17240 | 17291 | */ |
| @@ -17249,38 +17300,38 @@ | ||
| 17249 | 17300 | #define OPFLG_INITIALIZER {\ |
| 17250 | 17301 | /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x41, 0x00,\ |
| 17251 | 17302 | /* 8 */ 0x81, 0x01, 0x01, 0x81, 0x83, 0x83, 0x01, 0x01,\ |
| 17252 | 17303 | /* 16 */ 0x03, 0x03, 0x01, 0x12, 0x01, 0xc9, 0xc9, 0xc9,\ |
| 17253 | 17304 | /* 24 */ 0xc9, 0x01, 0x49, 0x49, 0x49, 0x49, 0xc9, 0x49,\ |
| 17254 | -/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x41, 0x41,\ | |
| 17255 | -/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x23, 0x0b,\ | |
| 17256 | -/* 48 */ 0x81, 0x01, 0x03, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ | |
| 17257 | -/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x01, 0x41,\ | |
| 17258 | -/* 64 */ 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00, 0x10,\ | |
| 17259 | -/* 72 */ 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10, 0x00,\ | |
| 17260 | -/* 80 */ 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02, 0x02,\ | |
| 17261 | -/* 88 */ 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40, 0x00,\ | |
| 17262 | -/* 96 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x40, 0x26,\ | |
| 17305 | +/* 32 */ 0xc1, 0x01, 0x41, 0x41, 0xc1, 0x01, 0x01, 0x41,\ | |
| 17306 | +/* 40 */ 0x41, 0x41, 0x41, 0x26, 0x26, 0x41, 0x41, 0x23,\ | |
| 17307 | +/* 48 */ 0x0b, 0x81, 0x01, 0x03, 0x03, 0x0b, 0x0b, 0x0b,\ | |
| 17308 | +/* 56 */ 0x0b, 0x0b, 0x0b, 0x01, 0x03, 0x03, 0x03, 0x01,\ | |
| 17309 | +/* 64 */ 0x41, 0x01, 0x00, 0x00, 0x02, 0x02, 0x08, 0x00,\ | |
| 17310 | +/* 72 */ 0x10, 0x10, 0x10, 0x00, 0x10, 0x00, 0x10, 0x10,\ | |
| 17311 | +/* 80 */ 0x00, 0x00, 0x10, 0x10, 0x00, 0x00, 0x00, 0x02,\ | |
| 17312 | +/* 88 */ 0x02, 0x02, 0x00, 0x00, 0x12, 0x1e, 0x20, 0x40,\ | |
| 17313 | +/* 96 */ 0x00, 0x00, 0x00, 0x10, 0x10, 0x00, 0x40, 0x26,\ | |
| 17263 | 17314 | /* 104 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26,\ |
| 17264 | -/* 112 */ 0x26, 0x00, 0x40, 0x12, 0x40, 0x40, 0x10, 0x00,\ | |
| 17265 | -/* 120 */ 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10, 0x10,\ | |
| 17266 | -/* 128 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x50,\ | |
| 17267 | -/* 136 */ 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50, 0x40,\ | |
| 17268 | -/* 144 */ 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00,\ | |
| 17269 | -/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x06, 0x10, 0x00, 0x04,\ | |
| 17270 | -/* 160 */ 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | |
| 17271 | -/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10, 0x50,\ | |
| 17272 | -/* 176 */ 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12, 0x00,\ | |
| 17273 | -/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} | |
| 17315 | +/* 112 */ 0x26, 0x40, 0x00, 0x12, 0x40, 0x40, 0x10, 0x40,\ | |
| 17316 | +/* 120 */ 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, 0x40, 0x10,\ | |
| 17317 | +/* 128 */ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00,\ | |
| 17318 | +/* 136 */ 0x50, 0x00, 0x40, 0x04, 0x04, 0x00, 0x40, 0x50,\ | |
| 17319 | +/* 144 */ 0x40, 0x10, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,\ | |
| 17320 | +/* 152 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x06, 0x10, 0x00,\ | |
| 17321 | +/* 160 */ 0x04, 0x1a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\ | |
| 17322 | +/* 168 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x10,\ | |
| 17323 | +/* 176 */ 0x50, 0x40, 0x00, 0x10, 0x10, 0x02, 0x12, 0x12,\ | |
| 17324 | +/* 184 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,} | |
| 17274 | 17325 | |
| 17275 | 17326 | /* The resolve3P2Values() routine is able to run faster if it knows |
| 17276 | 17327 | ** the value of the largest JUMP opcode. The smaller the maximum |
| 17277 | 17328 | ** JUMP opcode the better, so the mkopcodeh.tcl script that |
| 17278 | 17329 | ** generated this include file strives to group all JUMP opcodes |
| 17279 | 17330 | ** together near the beginning of the list. |
| 17280 | 17331 | */ |
| 17281 | -#define SQLITE_MX_JUMP_OPCODE 64 /* Maximum JUMP opcode */ | |
| 17332 | +#define SQLITE_MX_JUMP_OPCODE 65 /* Maximum JUMP opcode */ | |
| 17282 | 17333 | |
| 17283 | 17334 | /************** End of opcodes.h *********************************************/ |
| 17284 | 17335 | /************** Continuing where we left off in vdbe.h ***********************/ |
| 17285 | 17336 | |
| 17286 | 17337 | /* |
| @@ -17400,11 +17451,11 @@ | ||
| 17400 | 17451 | SQLITE_PRIVATE char *sqlite3VdbeExpandSql(Vdbe*, const char*); |
| 17401 | 17452 | #endif |
| 17402 | 17453 | SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*); |
| 17403 | 17454 | SQLITE_PRIVATE int sqlite3BlobCompare(const Mem*, const Mem*); |
| 17404 | 17455 | |
| 17405 | -SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*); | |
| 17456 | +SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(int,const void*,UnpackedRecord*); | |
| 17406 | 17457 | SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); |
| 17407 | 17458 | SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int); |
| 17408 | 17459 | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo*); |
| 17409 | 17460 | |
| 17410 | 17461 | typedef int (*RecordCompare)(int,const void*,UnpackedRecord*); |
| @@ -17413,11 +17464,13 @@ | ||
| 17413 | 17464 | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 17414 | 17465 | SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*); |
| 17415 | 17466 | |
| 17416 | 17467 | SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val); |
| 17417 | 17468 | |
| 17469 | +#ifndef SQLITE_OMIT_DATETIME_FUNCS | |
| 17418 | 17470 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*); |
| 17471 | +#endif | |
| 17419 | 17472 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 17420 | 17473 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*); |
| 17421 | 17474 | #endif |
| 17422 | 17475 | |
| 17423 | 17476 | /* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra |
| @@ -18295,10 +18348,11 @@ | ||
| 18295 | 18348 | #define SQLITE_Coroutines 0x02000000 /* Co-routines for subqueries */ |
| 18296 | 18349 | #define SQLITE_NullUnusedCols 0x04000000 /* NULL unused columns in subqueries */ |
| 18297 | 18350 | #define SQLITE_OnePass 0x08000000 /* Single-pass DELETE and UPDATE */ |
| 18298 | 18351 | #define SQLITE_OrderBySubq 0x10000000 /* ORDER BY in subquery helps outer */ |
| 18299 | 18352 | #define SQLITE_StarQuery 0x20000000 /* Heurists for star queries */ |
| 18353 | +#define SQLITE_ExistsToJoin 0x40000000 /* The EXISTS-to-JOIN optimization */ | |
| 18300 | 18354 | #define SQLITE_AllOpts 0xffffffff /* All optimizations */ |
| 18301 | 18355 | |
| 18302 | 18356 | /* |
| 18303 | 18357 | ** Macros for testing whether or not optimizations are enabled or disabled. |
| 18304 | 18358 | */ |
| @@ -18533,11 +18587,11 @@ | ||
| 18533 | 18587 | SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 18534 | 18588 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 18535 | 18589 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 18536 | 18590 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 18537 | 18591 | SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \ |
| 18538 | - pArg, 0, xFunc, 0, 0, 0, #zName, } | |
| 18592 | + pArg, 0, xFunc, 0, 0, 0, #zName, {0} } | |
| 18539 | 18593 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 18540 | 18594 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 18541 | 18595 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } |
| 18542 | 18596 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 18543 | 18597 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| @@ -18700,10 +18754,11 @@ | ||
| 18700 | 18754 | #define SQLITE_AFF_TEXT 0x42 /* 'B' */ |
| 18701 | 18755 | #define SQLITE_AFF_NUMERIC 0x43 /* 'C' */ |
| 18702 | 18756 | #define SQLITE_AFF_INTEGER 0x44 /* 'D' */ |
| 18703 | 18757 | #define SQLITE_AFF_REAL 0x45 /* 'E' */ |
| 18704 | 18758 | #define SQLITE_AFF_FLEXNUM 0x46 /* 'F' */ |
| 18759 | +#define SQLITE_AFF_DEFER 0x58 /* 'X' - defer computation until later */ | |
| 18705 | 18760 | |
| 18706 | 18761 | #define sqlite3IsNumericAffinity(X) ((X)>=SQLITE_AFF_NUMERIC) |
| 18707 | 18762 | |
| 18708 | 18763 | /* |
| 18709 | 18764 | ** The SQLITE_AFF_MASK values masks off the significant bits of an |
| @@ -19015,13 +19070,19 @@ | ||
| 19015 | 19070 | /* |
| 19016 | 19071 | ** An instance of the following structure is passed as the first |
| 19017 | 19072 | ** argument to sqlite3VdbeKeyCompare and is used to control the |
| 19018 | 19073 | ** comparison of the two index keys. |
| 19019 | 19074 | ** |
| 19020 | -** Note that aSortOrder[] and aColl[] have nField+1 slots. There | |
| 19021 | -** are nField slots for the columns of an index then one extra slot | |
| 19022 | -** for the rowid at the end. | |
| 19075 | +** The aSortOrder[] and aColl[] arrays have nAllField slots each. There | |
| 19076 | +** are nKeyField slots for the columns of an index then extra slots | |
| 19077 | +** for the rowid or key at the end. The aSortOrder array is located after | |
| 19078 | +** the aColl[] array. | |
| 19079 | +** | |
| 19080 | +** If SQLITE_ENABLE_PREUPDATE_HOOK is defined, then aSortFlags might be NULL | |
| 19081 | +** to indicate that this object is for use by a preupdate hook. When aSortFlags | |
| 19082 | +** is NULL, then nAllField is uninitialized and no space is allocated for | |
| 19083 | +** aColl[], so those fields may not be used. | |
| 19023 | 19084 | */ |
| 19024 | 19085 | struct KeyInfo { |
| 19025 | 19086 | u32 nRef; /* Number of references to this KeyInfo object */ |
| 19026 | 19087 | u8 enc; /* Text encoding - one of the SQLITE_UTF* values */ |
| 19027 | 19088 | u16 nKeyField; /* Number of key columns in the index */ |
| @@ -19029,12 +19090,21 @@ | ||
| 19029 | 19090 | sqlite3 *db; /* The database connection */ |
| 19030 | 19091 | u8 *aSortFlags; /* Sort order for each column. */ |
| 19031 | 19092 | CollSeq *aColl[FLEXARRAY]; /* Collating sequence for each term of the key */ |
| 19032 | 19093 | }; |
| 19033 | 19094 | |
| 19034 | -/* The size (in bytes) of a KeyInfo object with up to N fields */ | |
| 19095 | +/* The size (in bytes) of a KeyInfo object with up to N fields. This includes | |
| 19096 | +** the main body of the KeyInfo object and the aColl[] array of N elements, | |
| 19097 | +** but does not count the memory used to hold aSortFlags[]. */ | |
| 19035 | 19098 | #define SZ_KEYINFO(N) (offsetof(KeyInfo,aColl) + (N)*sizeof(CollSeq*)) |
| 19099 | + | |
| 19100 | +/* The size of a bare KeyInfo with no aColl[] entries */ | |
| 19101 | +#if FLEXARRAY+1 > 1 | |
| 19102 | +# define SZ_KEYINFO_0 offsetof(KeyInfo,aColl) | |
| 19103 | +#else | |
| 19104 | +# define SZ_KEYINFO_0 sizeof(KeyInfo) | |
| 19105 | +#endif | |
| 19036 | 19106 | |
| 19037 | 19107 | /* |
| 19038 | 19108 | ** Allowed bit values for entries in the KeyInfo.aSortFlags[] array. |
| 19039 | 19109 | */ |
| 19040 | 19110 | #define KEYINFO_ORDER_DESC 0x01 /* DESC sort order */ |
| @@ -19050,23 +19120,22 @@ | ||
| 19050 | 19120 | ** the OP_MakeRecord opcode of the VDBE and is disassembled by the |
| 19051 | 19121 | ** OP_Column opcode. |
| 19052 | 19122 | ** |
| 19053 | 19123 | ** An instance of this object serves as a "key" for doing a search on |
| 19054 | 19124 | ** an index b+tree. The goal of the search is to find the entry that |
| 19055 | -** is closed to the key described by this object. This object might hold | |
| 19056 | -** just a prefix of the key. The number of fields is given by | |
| 19057 | -** pKeyInfo->nField. | |
| 19125 | +** is closest to the key described by this object. This object might hold | |
| 19126 | +** just a prefix of the key. The number of fields is given by nField. | |
| 19058 | 19127 | ** |
| 19059 | 19128 | ** The r1 and r2 fields are the values to return if this key is less than |
| 19060 | 19129 | ** or greater than a key in the btree, respectively. These are normally |
| 19061 | 19130 | ** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree |
| 19062 | 19131 | ** is in DESC order. |
| 19063 | 19132 | ** |
| 19064 | 19133 | ** The key comparison functions actually return default_rc when they find |
| 19065 | 19134 | ** an equals comparison. default_rc can be -1, 0, or +1. If there are |
| 19066 | 19135 | ** multiple entries in the b-tree with the same key (when only looking |
| 19067 | -** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to | |
| 19136 | +** at the first nField elements) then default_rc can be set to -1 to | |
| 19068 | 19137 | ** cause the search to find the last match, or +1 to cause the search to |
| 19069 | 19138 | ** find the first match. |
| 19070 | 19139 | ** |
| 19071 | 19140 | ** The key comparison functions will set eqSeen to true if they ever |
| 19072 | 19141 | ** get and equal results when comparing this structure to a b-tree record. |
| @@ -19074,12 +19143,12 @@ | ||
| 19074 | 19143 | ** before the first match or immediately after the last match. The |
| 19075 | 19144 | ** eqSeen field will indicate whether or not an exact match exists in the |
| 19076 | 19145 | ** b-tree. |
| 19077 | 19146 | */ |
| 19078 | 19147 | struct UnpackedRecord { |
| 19079 | - KeyInfo *pKeyInfo; /* Collation and sort-order information */ | |
| 19080 | - Mem *aMem; /* Values */ | |
| 19148 | + KeyInfo *pKeyInfo; /* Comparison info for the index that is unpacked */ | |
| 19149 | + Mem *aMem; /* Values for columns of the index */ | |
| 19081 | 19150 | union { |
| 19082 | 19151 | char *z; /* Cache of aMem[0].z for vdbeRecordCompareString() */ |
| 19083 | 19152 | i64 i; /* Cache of aMem[0].u.i for vdbeRecordCompareInt() */ |
| 19084 | 19153 | } u; |
| 19085 | 19154 | int n; /* Cache of aMem[0].n used by vdbeRecordCompareString() */ |
| @@ -19160,14 +19229,12 @@ | ||
| 19160 | 19229 | unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */ |
| 19161 | 19230 | unsigned isResized:1; /* True if resizeIndexObject() has been called */ |
| 19162 | 19231 | unsigned isCovering:1; /* True if this is a covering index */ |
| 19163 | 19232 | unsigned noSkipScan:1; /* Do not try to use skip-scan if true */ |
| 19164 | 19233 | unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */ |
| 19165 | - unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */ | |
| 19166 | 19234 | unsigned bNoQuery:1; /* Do not use this index to optimize queries */ |
| 19167 | 19235 | unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */ |
| 19168 | - unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */ | |
| 19169 | 19236 | unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */ |
| 19170 | 19237 | unsigned bHasExpr:1; /* Index contains an expression, either a literal |
| 19171 | 19238 | ** expression, or a reference to a VIRTUAL column */ |
| 19172 | 19239 | #ifdef SQLITE_ENABLE_STAT4 |
| 19173 | 19240 | int nSample; /* Number of elements in aSample[] */ |
| @@ -19251,21 +19318,21 @@ | ||
| 19251 | 19318 | struct AggInfo { |
| 19252 | 19319 | u8 directMode; /* Direct rendering mode means take data directly |
| 19253 | 19320 | ** from source tables rather than from accumulators */ |
| 19254 | 19321 | u8 useSortingIdx; /* In direct mode, reference the sorting index rather |
| 19255 | 19322 | ** than the source table */ |
| 19256 | - u16 nSortingColumn; /* Number of columns in the sorting index */ | |
| 19323 | + u32 nSortingColumn; /* Number of columns in the sorting index */ | |
| 19257 | 19324 | int sortingIdx; /* Cursor number of the sorting index */ |
| 19258 | 19325 | int sortingIdxPTab; /* Cursor number of pseudo-table */ |
| 19259 | 19326 | int iFirstReg; /* First register in range for aCol[] and aFunc[] */ |
| 19260 | 19327 | ExprList *pGroupBy; /* The group by clause */ |
| 19261 | 19328 | struct AggInfo_col { /* For each column used in source tables */ |
| 19262 | 19329 | Table *pTab; /* Source table */ |
| 19263 | 19330 | Expr *pCExpr; /* The original expression */ |
| 19264 | 19331 | int iTable; /* Cursor number of the source table */ |
| 19265 | - i16 iColumn; /* Column number within the source table */ | |
| 19266 | - i16 iSorterColumn; /* Column number in the sorting index */ | |
| 19332 | + int iColumn; /* Column number within the source table */ | |
| 19333 | + int iSorterColumn; /* Column number in the sorting index */ | |
| 19267 | 19334 | } *aCol; |
| 19268 | 19335 | int nColumn; /* Number of used entries in aCol[] */ |
| 19269 | 19336 | int nAccumulator; /* Number of columns that show through to the output. |
| 19270 | 19337 | ** Additional columns are used only as parameters to |
| 19271 | 19338 | ** aggregate functions */ |
| @@ -19725,10 +19792,11 @@ | ||
| 19725 | 19792 | unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */ |
| 19726 | 19793 | unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */ |
| 19727 | 19794 | unsigned rowidUsed :1; /* The ROWID of this table is referenced */ |
| 19728 | 19795 | unsigned fixedSchema :1; /* Uses u4.pSchema, not u4.zDatabase */ |
| 19729 | 19796 | unsigned hadSchema :1; /* Had u4.zDatabase before u4.pSchema */ |
| 19797 | + unsigned fromExists :1; /* Comes from WHERE EXISTS(...) */ | |
| 19730 | 19798 | } fg; |
| 19731 | 19799 | int iCursor; /* The VDBE cursor number used to access this table */ |
| 19732 | 19800 | Bitmask colUsed; /* Bit N set if column N used. Details above for N>62 */ |
| 19733 | 19801 | union { |
| 19734 | 19802 | char *zIndexedBy; /* Identifier from "INDEXED BY <zIndex>" clause */ |
| @@ -20255,10 +20323,11 @@ | ||
| 20255 | 20323 | u8 mayAbort; /* True if statement may throw an ABORT exception */ |
| 20256 | 20324 | u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ |
| 20257 | 20325 | u8 disableLookaside; /* Number of times lookaside has been disabled */ |
| 20258 | 20326 | u8 prepFlags; /* SQLITE_PREPARE_* flags */ |
| 20259 | 20327 | u8 withinRJSubrtn; /* Nesting level for RIGHT JOIN body subroutines */ |
| 20328 | + u8 bHasExists; /* Has a correlated "EXISTS (SELECT ....)" expression */ | |
| 20260 | 20329 | u8 mSubrtnSig; /* mini Bloom filter on available SubrtnSig.selId */ |
| 20261 | 20330 | u8 eTriggerOp; /* TK_UPDATE, TK_INSERT or TK_DELETE */ |
| 20262 | 20331 | u8 bReturning; /* Coding a RETURNING trigger */ |
| 20263 | 20332 | u8 eOrconf; /* Default ON CONFLICT policy for trigger steps */ |
| 20264 | 20333 | u8 disableTriggers; /* True to disable triggers */ |
| @@ -21251,10 +21320,11 @@ | ||
| 21251 | 21320 | #endif |
| 21252 | 21321 | #ifndef SQLITE_OMIT_WINDOWFUNC |
| 21253 | 21322 | SQLITE_PRIVATE void sqlite3ShowWindow(const Window*); |
| 21254 | 21323 | SQLITE_PRIVATE void sqlite3ShowWinFunc(const Window*); |
| 21255 | 21324 | #endif |
| 21325 | +SQLITE_PRIVATE void sqlite3ShowBitvec(Bitvec*); | |
| 21256 | 21326 | #endif |
| 21257 | 21327 | |
| 21258 | 21328 | SQLITE_PRIVATE void sqlite3SetString(char **, sqlite3*, const char*); |
| 21259 | 21329 | SQLITE_PRIVATE void sqlite3ProgressCheck(Parse*); |
| 21260 | 21330 | SQLITE_PRIVATE void sqlite3ErrorMsg(Parse*, const char*, ...); |
| @@ -22424,10 +22494,13 @@ | ||
| 22424 | 22494 | #ifdef SQLITE_BITMASK_TYPE |
| 22425 | 22495 | "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE), |
| 22426 | 22496 | #endif |
| 22427 | 22497 | #ifdef SQLITE_BUG_COMPATIBLE_20160819 |
| 22428 | 22498 | "BUG_COMPATIBLE_20160819", |
| 22499 | +#endif | |
| 22500 | +#ifdef SQLITE_BUG_COMPATIBLE_20250510 | |
| 22501 | + "BUG_COMPATIBLE_20250510", | |
| 22429 | 22502 | #endif |
| 22430 | 22503 | #ifdef SQLITE_CASE_SENSITIVE_LIKE |
| 22431 | 22504 | "CASE_SENSITIVE_LIKE", |
| 22432 | 22505 | #endif |
| 22433 | 22506 | #ifdef SQLITE_CHECK_PAGES |
| @@ -23860,11 +23933,11 @@ | ||
| 23860 | 23933 | ** * MEM_Blob A blob, stored in Mem.z length Mem.n. |
| 23861 | 23934 | ** Incompatible with MEM_Str, MEM_Null, |
| 23862 | 23935 | ** MEM_Int, MEM_Real, and MEM_IntReal. |
| 23863 | 23936 | ** |
| 23864 | 23937 | ** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus |
| 23865 | -** MEM.u.i extra 0x00 bytes at the end. | |
| 23938 | +** Mem.u.nZero extra 0x00 bytes at the end. | |
| 23866 | 23939 | ** |
| 23867 | 23940 | ** * MEM_Int Integer stored in Mem.u.i. |
| 23868 | 23941 | ** |
| 23869 | 23942 | ** * MEM_Real Real stored in Mem.u.r. |
| 23870 | 23943 | ** |
| @@ -24129,11 +24202,11 @@ | ||
| 24129 | 24202 | Mem oldipk; /* Memory cell holding "old" IPK value */ |
| 24130 | 24203 | Mem *aNew; /* Array of new.* values */ |
| 24131 | 24204 | Table *pTab; /* Schema object being updated */ |
| 24132 | 24205 | Index *pPk; /* PK index if pTab is WITHOUT ROWID */ |
| 24133 | 24206 | sqlite3_value **apDflt; /* Array of default values, if required */ |
| 24134 | - u8 keyinfoSpace[SZ_KEYINFO(0)]; /* Space to hold pKeyinfo[0] content */ | |
| 24207 | + u8 keyinfoSpace[SZ_KEYINFO_0]; /* Space to hold pKeyinfo[0] content */ | |
| 24135 | 24208 | }; |
| 24136 | 24209 | |
| 24137 | 24210 | /* |
| 24138 | 24211 | ** An instance of this object is used to pass an vector of values into |
| 24139 | 24212 | ** OP_VFilter, the xFilter method of a virtual table. The vector is the |
| @@ -32059,10 +32132,18 @@ | ||
| 32059 | 32132 | }else{ |
| 32060 | 32133 | longvalue = va_arg(ap,unsigned int); |
| 32061 | 32134 | } |
| 32062 | 32135 | prefix = 0; |
| 32063 | 32136 | } |
| 32137 | + | |
| 32138 | +#if WHERETRACE_ENABLED | |
| 32139 | + if( xtype==etPOINTER && sqlite3WhereTrace & 0x100000 ) longvalue = 0; | |
| 32140 | +#endif | |
| 32141 | +#if TREETRACE_ENABLED | |
| 32142 | + if( xtype==etPOINTER && sqlite3TreeTrace & 0x100000 ) longvalue = 0; | |
| 32143 | +#endif | |
| 32144 | + | |
| 32064 | 32145 | if( longvalue==0 ) flag_alternateform = 0; |
| 32065 | 32146 | if( flag_zeropad && precision<width-(prefix!=0) ){ |
| 32066 | 32147 | precision = width-(prefix!=0); |
| 32067 | 32148 | } |
| 32068 | 32149 | if( precision<etBUFSIZE-10-etBUFSIZE/3 ){ |
| @@ -32987,10 +33068,19 @@ | ||
| 32987 | 33068 | va_end(ap); |
| 32988 | 33069 | zBuf[acc.nChar] = 0; |
| 32989 | 33070 | return zBuf; |
| 32990 | 33071 | } |
| 32991 | 33072 | |
| 33073 | +/* Maximum size of an sqlite3_log() message. */ | |
| 33074 | +#if defined(SQLITE_MAX_LOG_MESSAGE) | |
| 33075 | + /* Leave the definition as supplied */ | |
| 33076 | +#elif SQLITE_PRINT_BUF_SIZE*10>10000 | |
| 33077 | +# define SQLITE_MAX_LOG_MESSAGE 10000 | |
| 33078 | +#else | |
| 33079 | +# define SQLITE_MAX_LOG_MESSAGE (SQLITE_PRINT_BUF_SIZE*10) | |
| 33080 | +#endif | |
| 33081 | + | |
| 32992 | 33082 | /* |
| 32993 | 33083 | ** This is the routine that actually formats the sqlite3_log() message. |
| 32994 | 33084 | ** We house it in a separate routine from sqlite3_log() to avoid using |
| 32995 | 33085 | ** stack space on small-stack systems when logging is disabled. |
| 32996 | 33086 | ** |
| @@ -33003,11 +33093,11 @@ | ||
| 33003 | 33093 | ** Care must be taken that any sqlite3_log() calls that occur while the |
| 33004 | 33094 | ** memory mutex is held do not use these mechanisms. |
| 33005 | 33095 | */ |
| 33006 | 33096 | static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){ |
| 33007 | 33097 | StrAccum acc; /* String accumulator */ |
| 33008 | - char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */ | |
| 33098 | + char zMsg[SQLITE_MAX_LOG_MESSAGE]; /* Complete log message */ | |
| 33009 | 33099 | |
| 33010 | 33100 | sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0); |
| 33011 | 33101 | sqlite3_str_vappendf(&acc, zFormat, ap); |
| 33012 | 33102 | sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode, |
| 33013 | 33103 | sqlite3StrAccumFinish(&acc)); |
| @@ -35001,11 +35091,11 @@ | ||
| 35001 | 35091 | } |
| 35002 | 35092 | |
| 35003 | 35093 | /* |
| 35004 | 35094 | ** Write a single UTF8 character whose value is v into the |
| 35005 | 35095 | ** buffer starting at zOut. zOut must be sized to hold at |
| 35006 | -** least for bytes. Return the number of bytes needed | |
| 35096 | +** least four bytes. Return the number of bytes needed | |
| 35007 | 35097 | ** to encode the new character. |
| 35008 | 35098 | */ |
| 35009 | 35099 | SQLITE_PRIVATE int sqlite3AppendOneUtf8Character(char *zOut, u32 v){ |
| 35010 | 35100 | if( v<0x00080 ){ |
| 35011 | 35101 | zOut[0] = (u8)(v & 0xff); |
| @@ -37681,76 +37771,76 @@ | ||
| 37681 | 37771 | /* 32 */ "Last" OpHelp(""), |
| 37682 | 37772 | /* 33 */ "IfSizeBetween" OpHelp(""), |
| 37683 | 37773 | /* 34 */ "SorterSort" OpHelp(""), |
| 37684 | 37774 | /* 35 */ "Sort" OpHelp(""), |
| 37685 | 37775 | /* 36 */ "Rewind" OpHelp(""), |
| 37686 | - /* 37 */ "SorterNext" OpHelp(""), | |
| 37687 | - /* 38 */ "Prev" OpHelp(""), | |
| 37688 | - /* 39 */ "Next" OpHelp(""), | |
| 37689 | - /* 40 */ "IdxLE" OpHelp("key=r[P3@P4]"), | |
| 37690 | - /* 41 */ "IdxGT" OpHelp("key=r[P3@P4]"), | |
| 37691 | - /* 42 */ "IdxLT" OpHelp("key=r[P3@P4]"), | |
| 37776 | + /* 37 */ "IfEmpty" OpHelp("if( empty(P1) ) goto P2"), | |
| 37777 | + /* 38 */ "SorterNext" OpHelp(""), | |
| 37778 | + /* 39 */ "Prev" OpHelp(""), | |
| 37779 | + /* 40 */ "Next" OpHelp(""), | |
| 37780 | + /* 41 */ "IdxLE" OpHelp("key=r[P3@P4]"), | |
| 37781 | + /* 42 */ "IdxGT" OpHelp("key=r[P3@P4]"), | |
| 37692 | 37782 | /* 43 */ "Or" OpHelp("r[P3]=(r[P1] || r[P2])"), |
| 37693 | 37783 | /* 44 */ "And" OpHelp("r[P3]=(r[P1] && r[P2])"), |
| 37694 | - /* 45 */ "IdxGE" OpHelp("key=r[P3@P4]"), | |
| 37695 | - /* 46 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), | |
| 37696 | - /* 47 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), | |
| 37697 | - /* 48 */ "Program" OpHelp(""), | |
| 37698 | - /* 49 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), | |
| 37699 | - /* 50 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), | |
| 37784 | + /* 45 */ "IdxLT" OpHelp("key=r[P3@P4]"), | |
| 37785 | + /* 46 */ "IdxGE" OpHelp("key=r[P3@P4]"), | |
| 37786 | + /* 47 */ "RowSetRead" OpHelp("r[P3]=rowset(P1)"), | |
| 37787 | + /* 48 */ "RowSetTest" OpHelp("if r[P3] in rowset(P1) goto P2"), | |
| 37788 | + /* 49 */ "Program" OpHelp(""), | |
| 37789 | + /* 50 */ "FkIfZero" OpHelp("if fkctr[P1]==0 goto P2"), | |
| 37700 | 37790 | /* 51 */ "IsNull" OpHelp("if r[P1]==NULL goto P2"), |
| 37701 | 37791 | /* 52 */ "NotNull" OpHelp("if r[P1]!=NULL goto P2"), |
| 37702 | 37792 | /* 53 */ "Ne" OpHelp("IF r[P3]!=r[P1]"), |
| 37703 | 37793 | /* 54 */ "Eq" OpHelp("IF r[P3]==r[P1]"), |
| 37704 | 37794 | /* 55 */ "Gt" OpHelp("IF r[P3]>r[P1]"), |
| 37705 | 37795 | /* 56 */ "Le" OpHelp("IF r[P3]<=r[P1]"), |
| 37706 | 37796 | /* 57 */ "Lt" OpHelp("IF r[P3]<r[P1]"), |
| 37707 | 37797 | /* 58 */ "Ge" OpHelp("IF r[P3]>=r[P1]"), |
| 37708 | 37798 | /* 59 */ "ElseEq" OpHelp(""), |
| 37709 | - /* 60 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), | |
| 37710 | - /* 61 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), | |
| 37711 | - /* 62 */ "IncrVacuum" OpHelp(""), | |
| 37712 | - /* 63 */ "VNext" OpHelp(""), | |
| 37713 | - /* 64 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"), | |
| 37714 | - /* 65 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), | |
| 37715 | - /* 66 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), | |
| 37716 | - /* 67 */ "Return" OpHelp(""), | |
| 37717 | - /* 68 */ "EndCoroutine" OpHelp(""), | |
| 37718 | - /* 69 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), | |
| 37719 | - /* 70 */ "Halt" OpHelp(""), | |
| 37720 | - /* 71 */ "Integer" OpHelp("r[P2]=P1"), | |
| 37721 | - /* 72 */ "Int64" OpHelp("r[P2]=P4"), | |
| 37722 | - /* 73 */ "String" OpHelp("r[P2]='P4' (len=P1)"), | |
| 37723 | - /* 74 */ "BeginSubrtn" OpHelp("r[P2]=NULL"), | |
| 37724 | - /* 75 */ "Null" OpHelp("r[P2..P3]=NULL"), | |
| 37725 | - /* 76 */ "SoftNull" OpHelp("r[P1]=NULL"), | |
| 37726 | - /* 77 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), | |
| 37727 | - /* 78 */ "Variable" OpHelp("r[P2]=parameter(P1)"), | |
| 37728 | - /* 79 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), | |
| 37729 | - /* 80 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), | |
| 37730 | - /* 81 */ "SCopy" OpHelp("r[P2]=r[P1]"), | |
| 37731 | - /* 82 */ "IntCopy" OpHelp("r[P2]=r[P1]"), | |
| 37732 | - /* 83 */ "FkCheck" OpHelp(""), | |
| 37733 | - /* 84 */ "ResultRow" OpHelp("output=r[P1@P2]"), | |
| 37734 | - /* 85 */ "CollSeq" OpHelp(""), | |
| 37735 | - /* 86 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), | |
| 37736 | - /* 87 */ "RealAffinity" OpHelp(""), | |
| 37737 | - /* 88 */ "Cast" OpHelp("affinity(r[P1])"), | |
| 37738 | - /* 89 */ "Permutation" OpHelp(""), | |
| 37739 | - /* 90 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), | |
| 37740 | - /* 91 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), | |
| 37741 | - /* 92 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), | |
| 37742 | - /* 93 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), | |
| 37743 | - /* 94 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"), | |
| 37744 | - /* 95 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), | |
| 37745 | - /* 96 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | |
| 37746 | - /* 97 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), | |
| 37747 | - /* 98 */ "Count" OpHelp("r[P2]=count()"), | |
| 37748 | - /* 99 */ "ReadCookie" OpHelp(""), | |
| 37749 | - /* 100 */ "SetCookie" OpHelp(""), | |
| 37750 | - /* 101 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), | |
| 37751 | - /* 102 */ "OpenRead" OpHelp("root=P2 iDb=P3"), | |
| 37799 | + /* 60 */ "IfPos" OpHelp("if r[P1]>0 then r[P1]-=P3, goto P2"), | |
| 37800 | + /* 61 */ "IfNotZero" OpHelp("if r[P1]!=0 then r[P1]--, goto P2"), | |
| 37801 | + /* 62 */ "DecrJumpZero" OpHelp("if (--r[P1])==0 goto P2"), | |
| 37802 | + /* 63 */ "IncrVacuum" OpHelp(""), | |
| 37803 | + /* 64 */ "VNext" OpHelp(""), | |
| 37804 | + /* 65 */ "Filter" OpHelp("if key(P3@P4) not in filter(P1) goto P2"), | |
| 37805 | + /* 66 */ "PureFunc" OpHelp("r[P3]=func(r[P2@NP])"), | |
| 37806 | + /* 67 */ "Function" OpHelp("r[P3]=func(r[P2@NP])"), | |
| 37807 | + /* 68 */ "Return" OpHelp(""), | |
| 37808 | + /* 69 */ "EndCoroutine" OpHelp(""), | |
| 37809 | + /* 70 */ "HaltIfNull" OpHelp("if r[P3]=null halt"), | |
| 37810 | + /* 71 */ "Halt" OpHelp(""), | |
| 37811 | + /* 72 */ "Integer" OpHelp("r[P2]=P1"), | |
| 37812 | + /* 73 */ "Int64" OpHelp("r[P2]=P4"), | |
| 37813 | + /* 74 */ "String" OpHelp("r[P2]='P4' (len=P1)"), | |
| 37814 | + /* 75 */ "BeginSubrtn" OpHelp("r[P2]=NULL"), | |
| 37815 | + /* 76 */ "Null" OpHelp("r[P2..P3]=NULL"), | |
| 37816 | + /* 77 */ "SoftNull" OpHelp("r[P1]=NULL"), | |
| 37817 | + /* 78 */ "Blob" OpHelp("r[P2]=P4 (len=P1)"), | |
| 37818 | + /* 79 */ "Variable" OpHelp("r[P2]=parameter(P1)"), | |
| 37819 | + /* 80 */ "Move" OpHelp("r[P2@P3]=r[P1@P3]"), | |
| 37820 | + /* 81 */ "Copy" OpHelp("r[P2@P3+1]=r[P1@P3+1]"), | |
| 37821 | + /* 82 */ "SCopy" OpHelp("r[P2]=r[P1]"), | |
| 37822 | + /* 83 */ "IntCopy" OpHelp("r[P2]=r[P1]"), | |
| 37823 | + /* 84 */ "FkCheck" OpHelp(""), | |
| 37824 | + /* 85 */ "ResultRow" OpHelp("output=r[P1@P2]"), | |
| 37825 | + /* 86 */ "CollSeq" OpHelp(""), | |
| 37826 | + /* 87 */ "AddImm" OpHelp("r[P1]=r[P1]+P2"), | |
| 37827 | + /* 88 */ "RealAffinity" OpHelp(""), | |
| 37828 | + /* 89 */ "Cast" OpHelp("affinity(r[P1])"), | |
| 37829 | + /* 90 */ "Permutation" OpHelp(""), | |
| 37830 | + /* 91 */ "Compare" OpHelp("r[P1@P3] <-> r[P2@P3]"), | |
| 37831 | + /* 92 */ "IsTrue" OpHelp("r[P2] = coalesce(r[P1]==TRUE,P3) ^ P4"), | |
| 37832 | + /* 93 */ "ZeroOrNull" OpHelp("r[P2] = 0 OR NULL"), | |
| 37833 | + /* 94 */ "Offset" OpHelp("r[P3] = sqlite_offset(P1)"), | |
| 37834 | + /* 95 */ "Column" OpHelp("r[P3]=PX cursor P1 column P2"), | |
| 37835 | + /* 96 */ "TypeCheck" OpHelp("typecheck(r[P1@P2])"), | |
| 37836 | + /* 97 */ "Affinity" OpHelp("affinity(r[P1@P2])"), | |
| 37837 | + /* 98 */ "MakeRecord" OpHelp("r[P3]=mkrec(r[P1@P2])"), | |
| 37838 | + /* 99 */ "Count" OpHelp("r[P2]=count()"), | |
| 37839 | + /* 100 */ "ReadCookie" OpHelp(""), | |
| 37840 | + /* 101 */ "SetCookie" OpHelp(""), | |
| 37841 | + /* 102 */ "ReopenIdx" OpHelp("root=P2 iDb=P3"), | |
| 37752 | 37842 | /* 103 */ "BitAnd" OpHelp("r[P3]=r[P1]&r[P2]"), |
| 37753 | 37843 | /* 104 */ "BitOr" OpHelp("r[P3]=r[P1]|r[P2]"), |
| 37754 | 37844 | /* 105 */ "ShiftLeft" OpHelp("r[P3]=r[P2]<<r[P1]"), |
| 37755 | 37845 | /* 106 */ "ShiftRight" OpHelp("r[P3]=r[P2]>>r[P1]"), |
| 37756 | 37846 | /* 107 */ "Add" OpHelp("r[P3]=r[P1]+r[P2]"), |
| @@ -37757,87 +37847,88 @@ | ||
| 37757 | 37847 | /* 108 */ "Subtract" OpHelp("r[P3]=r[P2]-r[P1]"), |
| 37758 | 37848 | /* 109 */ "Multiply" OpHelp("r[P3]=r[P1]*r[P2]"), |
| 37759 | 37849 | /* 110 */ "Divide" OpHelp("r[P3]=r[P2]/r[P1]"), |
| 37760 | 37850 | /* 111 */ "Remainder" OpHelp("r[P3]=r[P2]%r[P1]"), |
| 37761 | 37851 | /* 112 */ "Concat" OpHelp("r[P3]=r[P2]+r[P1]"), |
| 37762 | - /* 113 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), | |
| 37763 | - /* 114 */ "OpenDup" OpHelp(""), | |
| 37852 | + /* 113 */ "OpenRead" OpHelp("root=P2 iDb=P3"), | |
| 37853 | + /* 114 */ "OpenWrite" OpHelp("root=P2 iDb=P3"), | |
| 37764 | 37854 | /* 115 */ "BitNot" OpHelp("r[P2]= ~r[P1]"), |
| 37765 | - /* 116 */ "OpenAutoindex" OpHelp("nColumn=P2"), | |
| 37766 | - /* 117 */ "OpenEphemeral" OpHelp("nColumn=P2"), | |
| 37855 | + /* 116 */ "OpenDup" OpHelp(""), | |
| 37856 | + /* 117 */ "OpenAutoindex" OpHelp("nColumn=P2"), | |
| 37767 | 37857 | /* 118 */ "String8" OpHelp("r[P2]='P4'"), |
| 37768 | - /* 119 */ "SorterOpen" OpHelp(""), | |
| 37769 | - /* 120 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), | |
| 37770 | - /* 121 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), | |
| 37771 | - /* 122 */ "Close" OpHelp(""), | |
| 37772 | - /* 123 */ "ColumnsUsed" OpHelp(""), | |
| 37773 | - /* 124 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), | |
| 37774 | - /* 125 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), | |
| 37775 | - /* 126 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), | |
| 37776 | - /* 127 */ "NewRowid" OpHelp("r[P2]=rowid"), | |
| 37777 | - /* 128 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), | |
| 37778 | - /* 129 */ "RowCell" OpHelp(""), | |
| 37779 | - /* 130 */ "Delete" OpHelp(""), | |
| 37780 | - /* 131 */ "ResetCount" OpHelp(""), | |
| 37781 | - /* 132 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), | |
| 37782 | - /* 133 */ "SorterData" OpHelp("r[P2]=data"), | |
| 37783 | - /* 134 */ "RowData" OpHelp("r[P2]=data"), | |
| 37784 | - /* 135 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"), | |
| 37785 | - /* 136 */ "NullRow" OpHelp(""), | |
| 37786 | - /* 137 */ "SeekEnd" OpHelp(""), | |
| 37787 | - /* 138 */ "IdxInsert" OpHelp("key=r[P2]"), | |
| 37788 | - /* 139 */ "SorterInsert" OpHelp("key=r[P2]"), | |
| 37789 | - /* 140 */ "IdxDelete" OpHelp("key=r[P2@P3]"), | |
| 37790 | - /* 141 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | |
| 37791 | - /* 142 */ "IdxRowid" OpHelp("r[P2]=rowid"), | |
| 37792 | - /* 143 */ "FinishSeek" OpHelp(""), | |
| 37793 | - /* 144 */ "Destroy" OpHelp(""), | |
| 37794 | - /* 145 */ "Clear" OpHelp(""), | |
| 37795 | - /* 146 */ "ResetSorter" OpHelp(""), | |
| 37796 | - /* 147 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), | |
| 37797 | - /* 148 */ "SqlExec" OpHelp(""), | |
| 37798 | - /* 149 */ "ParseSchema" OpHelp(""), | |
| 37799 | - /* 150 */ "LoadAnalysis" OpHelp(""), | |
| 37800 | - /* 151 */ "DropTable" OpHelp(""), | |
| 37801 | - /* 152 */ "DropIndex" OpHelp(""), | |
| 37802 | - /* 153 */ "DropTrigger" OpHelp(""), | |
| 37858 | + /* 119 */ "OpenEphemeral" OpHelp("nColumn=P2"), | |
| 37859 | + /* 120 */ "SorterOpen" OpHelp(""), | |
| 37860 | + /* 121 */ "SequenceTest" OpHelp("if( cursor[P1].ctr++ ) pc = P2"), | |
| 37861 | + /* 122 */ "OpenPseudo" OpHelp("P3 columns in r[P2]"), | |
| 37862 | + /* 123 */ "Close" OpHelp(""), | |
| 37863 | + /* 124 */ "ColumnsUsed" OpHelp(""), | |
| 37864 | + /* 125 */ "SeekScan" OpHelp("Scan-ahead up to P1 rows"), | |
| 37865 | + /* 126 */ "SeekHit" OpHelp("set P2<=seekHit<=P3"), | |
| 37866 | + /* 127 */ "Sequence" OpHelp("r[P2]=cursor[P1].ctr++"), | |
| 37867 | + /* 128 */ "NewRowid" OpHelp("r[P2]=rowid"), | |
| 37868 | + /* 129 */ "Insert" OpHelp("intkey=r[P3] data=r[P2]"), | |
| 37869 | + /* 130 */ "RowCell" OpHelp(""), | |
| 37870 | + /* 131 */ "Delete" OpHelp(""), | |
| 37871 | + /* 132 */ "ResetCount" OpHelp(""), | |
| 37872 | + /* 133 */ "SorterCompare" OpHelp("if key(P1)!=trim(r[P3],P4) goto P2"), | |
| 37873 | + /* 134 */ "SorterData" OpHelp("r[P2]=data"), | |
| 37874 | + /* 135 */ "RowData" OpHelp("r[P2]=data"), | |
| 37875 | + /* 136 */ "Rowid" OpHelp("r[P2]=PX rowid of P1"), | |
| 37876 | + /* 137 */ "NullRow" OpHelp(""), | |
| 37877 | + /* 138 */ "SeekEnd" OpHelp(""), | |
| 37878 | + /* 139 */ "IdxInsert" OpHelp("key=r[P2]"), | |
| 37879 | + /* 140 */ "SorterInsert" OpHelp("key=r[P2]"), | |
| 37880 | + /* 141 */ "IdxDelete" OpHelp("key=r[P2@P3]"), | |
| 37881 | + /* 142 */ "DeferredSeek" OpHelp("Move P3 to P1.rowid if needed"), | |
| 37882 | + /* 143 */ "IdxRowid" OpHelp("r[P2]=rowid"), | |
| 37883 | + /* 144 */ "FinishSeek" OpHelp(""), | |
| 37884 | + /* 145 */ "Destroy" OpHelp(""), | |
| 37885 | + /* 146 */ "Clear" OpHelp(""), | |
| 37886 | + /* 147 */ "ResetSorter" OpHelp(""), | |
| 37887 | + /* 148 */ "CreateBtree" OpHelp("r[P2]=root iDb=P1 flags=P3"), | |
| 37888 | + /* 149 */ "SqlExec" OpHelp(""), | |
| 37889 | + /* 150 */ "ParseSchema" OpHelp(""), | |
| 37890 | + /* 151 */ "LoadAnalysis" OpHelp(""), | |
| 37891 | + /* 152 */ "DropTable" OpHelp(""), | |
| 37892 | + /* 153 */ "DropIndex" OpHelp(""), | |
| 37803 | 37893 | /* 154 */ "Real" OpHelp("r[P2]=P4"), |
| 37804 | - /* 155 */ "IntegrityCk" OpHelp(""), | |
| 37805 | - /* 156 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), | |
| 37806 | - /* 157 */ "Param" OpHelp(""), | |
| 37807 | - /* 158 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), | |
| 37808 | - /* 159 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), | |
| 37809 | - /* 160 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), | |
| 37810 | - /* 161 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), | |
| 37811 | - /* 162 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), | |
| 37812 | - /* 163 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), | |
| 37813 | - /* 164 */ "AggValue" OpHelp("r[P3]=value N=P2"), | |
| 37814 | - /* 165 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), | |
| 37815 | - /* 166 */ "Expire" OpHelp(""), | |
| 37816 | - /* 167 */ "CursorLock" OpHelp(""), | |
| 37817 | - /* 168 */ "CursorUnlock" OpHelp(""), | |
| 37818 | - /* 169 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), | |
| 37819 | - /* 170 */ "VBegin" OpHelp(""), | |
| 37820 | - /* 171 */ "VCreate" OpHelp(""), | |
| 37821 | - /* 172 */ "VDestroy" OpHelp(""), | |
| 37822 | - /* 173 */ "VOpen" OpHelp(""), | |
| 37823 | - /* 174 */ "VCheck" OpHelp(""), | |
| 37824 | - /* 175 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), | |
| 37825 | - /* 176 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | |
| 37826 | - /* 177 */ "VRename" OpHelp(""), | |
| 37827 | - /* 178 */ "Pagecount" OpHelp(""), | |
| 37828 | - /* 179 */ "MaxPgcnt" OpHelp(""), | |
| 37829 | - /* 180 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), | |
| 37830 | - /* 181 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"), | |
| 37831 | - /* 182 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"), | |
| 37832 | - /* 183 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), | |
| 37833 | - /* 184 */ "Trace" OpHelp(""), | |
| 37834 | - /* 185 */ "CursorHint" OpHelp(""), | |
| 37835 | - /* 186 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | |
| 37836 | - /* 187 */ "Noop" OpHelp(""), | |
| 37837 | - /* 188 */ "Explain" OpHelp(""), | |
| 37838 | - /* 189 */ "Abortable" OpHelp(""), | |
| 37894 | + /* 155 */ "DropTrigger" OpHelp(""), | |
| 37895 | + /* 156 */ "IntegrityCk" OpHelp(""), | |
| 37896 | + /* 157 */ "RowSetAdd" OpHelp("rowset(P1)=r[P2]"), | |
| 37897 | + /* 158 */ "Param" OpHelp(""), | |
| 37898 | + /* 159 */ "FkCounter" OpHelp("fkctr[P1]+=P2"), | |
| 37899 | + /* 160 */ "MemMax" OpHelp("r[P1]=max(r[P1],r[P2])"), | |
| 37900 | + /* 161 */ "OffsetLimit" OpHelp("if r[P1]>0 then r[P2]=r[P1]+max(0,r[P3]) else r[P2]=(-1)"), | |
| 37901 | + /* 162 */ "AggInverse" OpHelp("accum=r[P3] inverse(r[P2@P5])"), | |
| 37902 | + /* 163 */ "AggStep" OpHelp("accum=r[P3] step(r[P2@P5])"), | |
| 37903 | + /* 164 */ "AggStep1" OpHelp("accum=r[P3] step(r[P2@P5])"), | |
| 37904 | + /* 165 */ "AggValue" OpHelp("r[P3]=value N=P2"), | |
| 37905 | + /* 166 */ "AggFinal" OpHelp("accum=r[P1] N=P2"), | |
| 37906 | + /* 167 */ "Expire" OpHelp(""), | |
| 37907 | + /* 168 */ "CursorLock" OpHelp(""), | |
| 37908 | + /* 169 */ "CursorUnlock" OpHelp(""), | |
| 37909 | + /* 170 */ "TableLock" OpHelp("iDb=P1 root=P2 write=P3"), | |
| 37910 | + /* 171 */ "VBegin" OpHelp(""), | |
| 37911 | + /* 172 */ "VCreate" OpHelp(""), | |
| 37912 | + /* 173 */ "VDestroy" OpHelp(""), | |
| 37913 | + /* 174 */ "VOpen" OpHelp(""), | |
| 37914 | + /* 175 */ "VCheck" OpHelp(""), | |
| 37915 | + /* 176 */ "VInitIn" OpHelp("r[P2]=ValueList(P1,P3)"), | |
| 37916 | + /* 177 */ "VColumn" OpHelp("r[P3]=vcolumn(P2)"), | |
| 37917 | + /* 178 */ "VRename" OpHelp(""), | |
| 37918 | + /* 179 */ "Pagecount" OpHelp(""), | |
| 37919 | + /* 180 */ "MaxPgcnt" OpHelp(""), | |
| 37920 | + /* 181 */ "ClrSubtype" OpHelp("r[P1].subtype = 0"), | |
| 37921 | + /* 182 */ "GetSubtype" OpHelp("r[P2] = r[P1].subtype"), | |
| 37922 | + /* 183 */ "SetSubtype" OpHelp("r[P2].subtype = r[P1]"), | |
| 37923 | + /* 184 */ "FilterAdd" OpHelp("filter(P1) += key(P3@P4)"), | |
| 37924 | + /* 185 */ "Trace" OpHelp(""), | |
| 37925 | + /* 186 */ "CursorHint" OpHelp(""), | |
| 37926 | + /* 187 */ "ReleaseReg" OpHelp("release r[P1@P2] mask P3"), | |
| 37927 | + /* 188 */ "Noop" OpHelp(""), | |
| 37928 | + /* 189 */ "Explain" OpHelp(""), | |
| 37929 | + /* 190 */ "Abortable" OpHelp(""), | |
| 37839 | 37930 | }; |
| 37840 | 37931 | return azName[i]; |
| 37841 | 37932 | } |
| 37842 | 37933 | #endif |
| 37843 | 37934 | |
| @@ -43860,25 +43951,24 @@ | ||
| 43860 | 43951 | assert( pShmNode->hShm<0 || pDbFd->pInode->bProcessLock==0 ); |
| 43861 | 43952 | |
| 43862 | 43953 | /* Check that, if this to be a blocking lock, no locks that occur later |
| 43863 | 43954 | ** in the following list than the lock being obtained are already held: |
| 43864 | 43955 | ** |
| 43865 | - ** 1. Checkpointer lock (ofst==1). | |
| 43866 | - ** 2. Write lock (ofst==0). | |
| 43867 | - ** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK). | |
| 43956 | + ** 1. Recovery lock (ofst==2). | |
| 43957 | + ** 2. Checkpointer lock (ofst==1). | |
| 43958 | + ** 3. Write lock (ofst==0). | |
| 43959 | + ** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK). | |
| 43868 | 43960 | ** |
| 43869 | 43961 | ** In other words, if this is a blocking lock, none of the locks that |
| 43870 | 43962 | ** occur later in the above list than the lock being obtained may be |
| 43871 | 43963 | ** held. |
| 43872 | - ** | |
| 43873 | - ** It is not permitted to block on the RECOVER lock. | |
| 43874 | 43964 | */ |
| 43875 | 43965 | #if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG) |
| 43876 | 43966 | { |
| 43877 | 43967 | u16 lockMask = (p->exclMask|p->sharedMask); |
| 43878 | 43968 | assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || ( |
| 43879 | - (ofst!=2) /* not RECOVER */ | |
| 43969 | + (ofst!=2 || lockMask==0) | |
| 43880 | 43970 | && (ofst!=1 || lockMask==0 || lockMask==2) |
| 43881 | 43971 | && (ofst!=0 || lockMask<3) |
| 43882 | 43972 | && (ofst<3 || lockMask<(1<<ofst)) |
| 43883 | 43973 | )); |
| 43884 | 43974 | } |
| @@ -49835,11 +49925,15 @@ | ||
| 49835 | 49925 | DWORD nDelay = (nMs==0 ? INFINITE : nMs); |
| 49836 | 49926 | DWORD res = osWaitForSingleObject(ovlp.hEvent, nDelay); |
| 49837 | 49927 | if( res==WAIT_OBJECT_0 ){ |
| 49838 | 49928 | ret = TRUE; |
| 49839 | 49929 | }else if( res==WAIT_TIMEOUT ){ |
| 49930 | +#if SQLITE_ENABLE_SETLK_TIMEOUT==1 | |
| 49840 | 49931 | rc = SQLITE_BUSY_TIMEOUT; |
| 49932 | +#else | |
| 49933 | + rc = SQLITE_BUSY; | |
| 49934 | +#endif | |
| 49841 | 49935 | }else{ |
| 49842 | 49936 | /* Some other error has occurred */ |
| 49843 | 49937 | rc = SQLITE_IOERR_LOCK; |
| 49844 | 49938 | } |
| 49845 | 49939 | |
| @@ -51321,17 +51415,17 @@ | ||
| 51321 | 51415 | int nChar; |
| 51322 | 51416 | LPWSTR zWideFilename; |
| 51323 | 51417 | |
| 51324 | 51418 | if( osCygwin_conv_path && !(winIsDriveLetterAndColon(zFilename) |
| 51325 | 51419 | && winIsDirSep(zFilename[2])) ){ |
| 51326 | - int nByte; | |
| 51420 | + i64 nByte; | |
| 51327 | 51421 | int convertflag = CCP_POSIX_TO_WIN_W; |
| 51328 | 51422 | if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE; |
| 51329 | - nByte = (int)osCygwin_conv_path(convertflag, | |
| 51423 | + nByte = (i64)osCygwin_conv_path(convertflag, | |
| 51330 | 51424 | zFilename, 0, 0); |
| 51331 | 51425 | if( nByte>0 ){ |
| 51332 | - zConverted = sqlite3MallocZero(nByte+12); | |
| 51426 | + zConverted = sqlite3MallocZero(12+(u64)nByte); | |
| 51333 | 51427 | if ( zConverted==0 ){ |
| 51334 | 51428 | return zConverted; |
| 51335 | 51429 | } |
| 51336 | 51430 | zWideFilename = zConverted; |
| 51337 | 51431 | /* Filenames should be prefixed, except when converted |
| @@ -51646,25 +51740,24 @@ | ||
| 51646 | 51740 | assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 ); |
| 51647 | 51741 | |
| 51648 | 51742 | /* Check that, if this to be a blocking lock, no locks that occur later |
| 51649 | 51743 | ** in the following list than the lock being obtained are already held: |
| 51650 | 51744 | ** |
| 51651 | - ** 1. Checkpointer lock (ofst==1). | |
| 51652 | - ** 2. Write lock (ofst==0). | |
| 51653 | - ** 3. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK). | |
| 51745 | + ** 1. Recovery lock (ofst==2). | |
| 51746 | + ** 2. Checkpointer lock (ofst==1). | |
| 51747 | + ** 3. Write lock (ofst==0). | |
| 51748 | + ** 4. Read locks (ofst>=3 && ofst<SQLITE_SHM_NLOCK). | |
| 51654 | 51749 | ** |
| 51655 | 51750 | ** In other words, if this is a blocking lock, none of the locks that |
| 51656 | 51751 | ** occur later in the above list than the lock being obtained may be |
| 51657 | 51752 | ** held. |
| 51658 | - ** | |
| 51659 | - ** It is not permitted to block on the RECOVER lock. | |
| 51660 | 51753 | */ |
| 51661 | 51754 | #if defined(SQLITE_ENABLE_SETLK_TIMEOUT) && defined(SQLITE_DEBUG) |
| 51662 | 51755 | { |
| 51663 | 51756 | u16 lockMask = (p->exclMask|p->sharedMask); |
| 51664 | 51757 | assert( (flags & SQLITE_SHM_UNLOCK) || pDbFd->iBusyTimeout==0 || ( |
| 51665 | - (ofst!=2) /* not RECOVER */ | |
| 51758 | + (ofst!=2 || lockMask==0) | |
| 51666 | 51759 | && (ofst!=1 || lockMask==0 || lockMask==2) |
| 51667 | 51760 | && (ofst!=0 || lockMask<3) |
| 51668 | 51761 | && (ofst<3 || lockMask<(1<<ofst)) |
| 51669 | 51762 | )); |
| 51670 | 51763 | } |
| @@ -52210,31 +52303,10 @@ | ||
| 52210 | 52303 | ** |
| 52211 | 52304 | ** This division contains the implementation of methods on the |
| 52212 | 52305 | ** sqlite3_vfs object. |
| 52213 | 52306 | */ |
| 52214 | 52307 | |
| 52215 | -#if 0 /* No longer necessary */ | |
| 52216 | -/* | |
| 52217 | -** Convert a filename from whatever the underlying operating system | |
| 52218 | -** supports for filenames into UTF-8. Space to hold the result is | |
| 52219 | -** obtained from malloc and must be freed by the calling function. | |
| 52220 | -*/ | |
| 52221 | -static char *winConvertToUtf8Filename(const void *zFilename){ | |
| 52222 | - char *zConverted = 0; | |
| 52223 | - if( osIsNT() ){ | |
| 52224 | - zConverted = winUnicodeToUtf8(zFilename); | |
| 52225 | - } | |
| 52226 | -#ifdef SQLITE_WIN32_HAS_ANSI | |
| 52227 | - else{ | |
| 52228 | - zConverted = winMbcsToUtf8(zFilename, osAreFileApisANSI()); | |
| 52229 | - } | |
| 52230 | -#endif | |
| 52231 | - /* caller will handle out of memory */ | |
| 52232 | - return zConverted; | |
| 52233 | -} | |
| 52234 | -#endif | |
| 52235 | - | |
| 52236 | 52308 | /* |
| 52237 | 52309 | ** This function returns non-zero if the specified UTF-8 string buffer |
| 52238 | 52310 | ** ends with a directory separator character or one was successfully |
| 52239 | 52311 | ** added to it. |
| 52240 | 52312 | */ |
| @@ -52370,46 +52442,10 @@ | ||
| 52370 | 52442 | sqlite3_snprintf(nMax, zBuf, "%s", zDir); |
| 52371 | 52443 | sqlite3_free(zConverted); |
| 52372 | 52444 | break; |
| 52373 | 52445 | } |
| 52374 | 52446 | sqlite3_free(zConverted); |
| 52375 | -#if 0 /* No longer necessary */ | |
| 52376 | - }else{ | |
| 52377 | - zConverted = sqlite3MallocZero( nMax+1 ); | |
| 52378 | - if( !zConverted ){ | |
| 52379 | - sqlite3_free(zBuf); | |
| 52380 | - OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); | |
| 52381 | - return SQLITE_IOERR_NOMEM_BKPT; | |
| 52382 | - } | |
| 52383 | - if( osCygwin_conv_path( | |
| 52384 | - CCP_POSIX_TO_WIN_W, zDir, | |
| 52385 | - zConverted, nMax+1)<0 ){ | |
| 52386 | - sqlite3_free(zConverted); | |
| 52387 | - sqlite3_free(zBuf); | |
| 52388 | - OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_CONVPATH\n")); | |
| 52389 | - return winLogError(SQLITE_IOERR_CONVPATH, (DWORD)errno, | |
| 52390 | - "winGetTempname2", zDir); | |
| 52391 | - } | |
| 52392 | - if( winIsDir(zConverted) ){ | |
| 52393 | - /* At this point, we know the candidate directory exists and should | |
| 52394 | - ** be used. However, we may need to convert the string containing | |
| 52395 | - ** its name into UTF-8 (i.e. if it is UTF-16 right now). | |
| 52396 | - */ | |
| 52397 | - char *zUtf8 = winConvertToUtf8Filename(zConverted); | |
| 52398 | - if( !zUtf8 ){ | |
| 52399 | - sqlite3_free(zConverted); | |
| 52400 | - sqlite3_free(zBuf); | |
| 52401 | - OSTRACE(("TEMP-FILENAME rc=SQLITE_IOERR_NOMEM\n")); | |
| 52402 | - return SQLITE_IOERR_NOMEM_BKPT; | |
| 52403 | - } | |
| 52404 | - sqlite3_snprintf(nMax, zBuf, "%s", zUtf8); | |
| 52405 | - sqlite3_free(zUtf8); | |
| 52406 | - sqlite3_free(zConverted); | |
| 52407 | - break; | |
| 52408 | - } | |
| 52409 | - sqlite3_free(zConverted); | |
| 52410 | -#endif /* No longer necessary */ | |
| 52411 | 52447 | } |
| 52412 | 52448 | } |
| 52413 | 52449 | } |
| 52414 | 52450 | #endif |
| 52415 | 52451 | |
| @@ -53304,38 +53340,10 @@ | ||
| 53304 | 53340 | winSimplifyName(zFull); |
| 53305 | 53341 | return rc; |
| 53306 | 53342 | } |
| 53307 | 53343 | } |
| 53308 | 53344 | #endif /* __CYGWIN__ */ |
| 53309 | -#if 0 /* This doesn't work correctly at all! See: | |
| 53310 | - <https://marc.info/?l=sqlite-users&m=139299149416314&w=2> | |
| 53311 | -*/ | |
| 53312 | - SimulateIOError( return SQLITE_ERROR ); | |
| 53313 | - UNUSED_PARAMETER(nFull); | |
| 53314 | - assert( nFull>=pVfs->mxPathname ); | |
| 53315 | - char *zOut = sqlite3MallocZero( pVfs->mxPathname+1 ); | |
| 53316 | - if( !zOut ){ | |
| 53317 | - return SQLITE_IOERR_NOMEM_BKPT; | |
| 53318 | - } | |
| 53319 | - if( osCygwin_conv_path( | |
| 53320 | - CCP_POSIX_TO_WIN_W, | |
| 53321 | - zRelative, zOut, pVfs->mxPathname+1)<0 ){ | |
| 53322 | - sqlite3_free(zOut); | |
| 53323 | - return winLogError(SQLITE_CANTOPEN_CONVPATH, (DWORD)errno, | |
| 53324 | - "winFullPathname2", zRelative); | |
| 53325 | - }else{ | |
| 53326 | - char *zUtf8 = winConvertToUtf8Filename(zOut); | |
| 53327 | - if( !zUtf8 ){ | |
| 53328 | - sqlite3_free(zOut); | |
| 53329 | - return SQLITE_IOERR_NOMEM_BKPT; | |
| 53330 | - } | |
| 53331 | - sqlite3_snprintf(MIN(nFull, pVfs->mxPathname), zFull, "%s", zUtf8); | |
| 53332 | - sqlite3_free(zUtf8); | |
| 53333 | - sqlite3_free(zOut); | |
| 53334 | - } | |
| 53335 | - return SQLITE_OK; | |
| 53336 | -#endif | |
| 53337 | 53345 | |
| 53338 | 53346 | #if (SQLITE_OS_WINCE || SQLITE_OS_WINRT) && defined(_WIN32) |
| 53339 | 53347 | SimulateIOError( return SQLITE_ERROR ); |
| 53340 | 53348 | /* WinCE has no concept of a relative pathname, or so I am told. */ |
| 53341 | 53349 | /* WinRT has no way to convert a relative path to an absolute one. */ |
| @@ -53477,31 +53485,12 @@ | ||
| 53477 | 53485 | ** Interfaces for opening a shared library, finding entry points |
| 53478 | 53486 | ** within the shared library, and closing the shared library. |
| 53479 | 53487 | */ |
| 53480 | 53488 | static void *winDlOpen(sqlite3_vfs *pVfs, const char *zFilename){ |
| 53481 | 53489 | HANDLE h; |
| 53482 | -#if 0 /* This doesn't work correctly at all! See: | |
| 53483 | - <https://marc.info/?l=sqlite-users&m=139299149416314&w=2> | |
| 53484 | -*/ | |
| 53485 | - int nFull = pVfs->mxPathname+1; | |
| 53486 | - char *zFull = sqlite3MallocZero( nFull ); | |
| 53487 | - void *zConverted = 0; | |
| 53488 | - if( zFull==0 ){ | |
| 53489 | - OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0)); | |
| 53490 | - return 0; | |
| 53491 | - } | |
| 53492 | - if( winFullPathname(pVfs, zFilename, nFull, zFull)!=SQLITE_OK ){ | |
| 53493 | - sqlite3_free(zFull); | |
| 53494 | - OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0)); | |
| 53495 | - return 0; | |
| 53496 | - } | |
| 53497 | - zConverted = winConvertFromUtf8Filename(zFull); | |
| 53498 | - sqlite3_free(zFull); | |
| 53499 | -#else | |
| 53500 | 53490 | void *zConverted = winConvertFromUtf8Filename(zFilename); |
| 53501 | 53491 | UNUSED_PARAMETER(pVfs); |
| 53502 | -#endif | |
| 53503 | 53492 | if( zConverted==0 ){ |
| 53504 | 53493 | OSTRACE(("DLOPEN name=%s, handle=%p\n", zFilename, (void*)0)); |
| 53505 | 53494 | return 0; |
| 53506 | 53495 | } |
| 53507 | 53496 | if( osIsNT() ){ |
| @@ -54943,10 +54932,11 @@ | ||
| 54943 | 54932 | BITVEC_TELEM aBitmap[BITVEC_NELEM]; /* Bitmap representation */ |
| 54944 | 54933 | u32 aHash[BITVEC_NINT]; /* Hash table representation */ |
| 54945 | 54934 | Bitvec *apSub[BITVEC_NPTR]; /* Recursive representation */ |
| 54946 | 54935 | } u; |
| 54947 | 54936 | }; |
| 54937 | + | |
| 54948 | 54938 | |
| 54949 | 54939 | /* |
| 54950 | 54940 | ** Create a new bitmap object able to handle bits between 0 and iSize, |
| 54951 | 54941 | ** inclusive. Return a pointer to the new object. Return NULL if |
| 54952 | 54942 | ** malloc fails. |
| @@ -55053,11 +55043,13 @@ | ||
| 55053 | 55043 | if( aiValues==0 ){ |
| 55054 | 55044 | return SQLITE_NOMEM_BKPT; |
| 55055 | 55045 | }else{ |
| 55056 | 55046 | memcpy(aiValues, p->u.aHash, sizeof(p->u.aHash)); |
| 55057 | 55047 | memset(p->u.apSub, 0, sizeof(p->u.apSub)); |
| 55058 | - p->iDivisor = (p->iSize + BITVEC_NPTR - 1)/BITVEC_NPTR; | |
| 55048 | + p->iDivisor = p->iSize/BITVEC_NPTR; | |
| 55049 | + if( (p->iSize%BITVEC_NPTR)!=0 ) p->iDivisor++; | |
| 55050 | + if( p->iDivisor<BITVEC_NBIT ) p->iDivisor = BITVEC_NBIT; | |
| 55059 | 55051 | rc = sqlite3BitvecSet(p, i); |
| 55060 | 55052 | for(j=0; j<BITVEC_NINT; j++){ |
| 55061 | 55053 | if( aiValues[j] ) rc |= sqlite3BitvecSet(p, aiValues[j]); |
| 55062 | 55054 | } |
| 55063 | 55055 | sqlite3StackFree(0, aiValues); |
| @@ -55129,10 +55121,56 @@ | ||
| 55129 | 55121 | ** was created. |
| 55130 | 55122 | */ |
| 55131 | 55123 | SQLITE_PRIVATE u32 sqlite3BitvecSize(Bitvec *p){ |
| 55132 | 55124 | return p->iSize; |
| 55133 | 55125 | } |
| 55126 | + | |
| 55127 | +#ifdef SQLITE_DEBUG | |
| 55128 | +/* | |
| 55129 | +** Show the content of a Bitvec option and its children. Indent | |
| 55130 | +** everything by n spaces. Add x to each bitvec value. | |
| 55131 | +** | |
| 55132 | +** From a debugger such as gdb, one can type: | |
| 55133 | +** | |
| 55134 | +** call sqlite3ShowBitvec(p) | |
| 55135 | +** | |
| 55136 | +** For some Bitvec p and see a recursive view of the Bitvec's content. | |
| 55137 | +*/ | |
| 55138 | +static void showBitvec(Bitvec *p, int n, unsigned x){ | |
| 55139 | + int i; | |
| 55140 | + if( p==0 ){ | |
| 55141 | + printf("NULL\n"); | |
| 55142 | + return; | |
| 55143 | + } | |
| 55144 | + printf("Bitvec 0x%p iSize=%u", p, p->iSize); | |
| 55145 | + if( p->iSize<=BITVEC_NBIT ){ | |
| 55146 | + printf(" bitmap\n"); | |
| 55147 | + printf("%*s bits:", n, ""); | |
| 55148 | + for(i=1; i<=BITVEC_NBIT; i++){ | |
| 55149 | + if( sqlite3BitvecTest(p,i) ) printf(" %u", x+(unsigned)i); | |
| 55150 | + } | |
| 55151 | + printf("\n"); | |
| 55152 | + }else if( p->iDivisor==0 ){ | |
| 55153 | + printf(" hash with %u entries\n", p->nSet); | |
| 55154 | + printf("%*s bits:", n, ""); | |
| 55155 | + for(i=0; i<BITVEC_NINT; i++){ | |
| 55156 | + if( p->u.aHash[i] ) printf(" %u", x+(unsigned)p->u.aHash[i]); | |
| 55157 | + } | |
| 55158 | + printf("\n"); | |
| 55159 | + }else{ | |
| 55160 | + printf(" sub-bitvec with iDivisor=%u\n", p->iDivisor); | |
| 55161 | + for(i=0; i<BITVEC_NPTR; i++){ | |
| 55162 | + if( p->u.apSub[i]==0 ) continue; | |
| 55163 | + printf("%*s apSub[%d]=", n, "", i); | |
| 55164 | + showBitvec(p->u.apSub[i], n+4, i*p->iDivisor); | |
| 55165 | + } | |
| 55166 | + } | |
| 55167 | +} | |
| 55168 | +SQLITE_PRIVATE void sqlite3ShowBitvec(Bitvec *p){ | |
| 55169 | + showBitvec(p, 0, 0); | |
| 55170 | +} | |
| 55171 | +#endif | |
| 55134 | 55172 | |
| 55135 | 55173 | #ifndef SQLITE_UNTESTABLE |
| 55136 | 55174 | /* |
| 55137 | 55175 | ** Let V[] be an array of unsigned characters sufficient to hold |
| 55138 | 55176 | ** up to N bits. Let I be an integer between 0 and N. 0<=I<N. |
| @@ -55140,40 +55178,48 @@ | ||
| 55140 | 55178 | ** individual bits within V. |
| 55141 | 55179 | */ |
| 55142 | 55180 | #define SETBIT(V,I) V[I>>3] |= (1<<(I&7)) |
| 55143 | 55181 | #define CLEARBIT(V,I) V[I>>3] &= ~(BITVEC_TELEM)(1<<(I&7)) |
| 55144 | 55182 | #define TESTBIT(V,I) (V[I>>3]&(1<<(I&7)))!=0 |
| 55183 | + | |
| 55145 | 55184 | |
| 55146 | 55185 | /* |
| 55147 | 55186 | ** This routine runs an extensive test of the Bitvec code. |
| 55148 | 55187 | ** |
| 55149 | 55188 | ** The input is an array of integers that acts as a program |
| 55150 | 55189 | ** to test the Bitvec. The integers are opcodes followed |
| 55151 | 55190 | ** by 0, 1, or 3 operands, depending on the opcode. Another |
| 55152 | 55191 | ** opcode follows immediately after the last operand. |
| 55153 | 55192 | ** |
| 55154 | -** There are 6 opcodes numbered from 0 through 5. 0 is the | |
| 55193 | +** There are opcodes numbered starting with 0. 0 is the | |
| 55155 | 55194 | ** "halt" opcode and causes the test to end. |
| 55156 | 55195 | ** |
| 55157 | 55196 | ** 0 Halt and return the number of errors |
| 55158 | 55197 | ** 1 N S X Set N bits beginning with S and incrementing by X |
| 55159 | 55198 | ** 2 N S X Clear N bits beginning with S and incrementing by X |
| 55160 | 55199 | ** 3 N Set N randomly chosen bits |
| 55161 | 55200 | ** 4 N Clear N randomly chosen bits |
| 55162 | 55201 | ** 5 N S X Set N bits from S increment X in array only, not in bitvec |
| 55202 | +** 6 Invoice sqlite3ShowBitvec() on the Bitvec object so far | |
| 55203 | +** 7 X Show compile-time parameters and the hash of X | |
| 55163 | 55204 | ** |
| 55164 | 55205 | ** The opcodes 1 through 4 perform set and clear operations are performed |
| 55165 | 55206 | ** on both a Bitvec object and on a linear array of bits obtained from malloc. |
| 55166 | 55207 | ** Opcode 5 works on the linear array only, not on the Bitvec. |
| 55167 | 55208 | ** Opcode 5 is used to deliberately induce a fault in order to |
| 55168 | -** confirm that error detection works. | |
| 55209 | +** confirm that error detection works. Opcodes 6 and greater are | |
| 55210 | +** state output opcodes. Opcodes 6 and greater are no-ops unless | |
| 55211 | +** SQLite has been compiled with SQLITE_DEBUG. | |
| 55169 | 55212 | ** |
| 55170 | 55213 | ** At the conclusion of the test the linear array is compared |
| 55171 | 55214 | ** against the Bitvec object. If there are any differences, |
| 55172 | 55215 | ** an error is returned. If they are the same, zero is returned. |
| 55173 | 55216 | ** |
| 55174 | 55217 | ** If a memory allocation error occurs, return -1. |
| 55218 | +** | |
| 55219 | +** sz is the size of the Bitvec. Or if sz is negative, make the size | |
| 55220 | +** 2*(unsigned)(-sz) and disabled the linear vector check. | |
| 55175 | 55221 | */ |
| 55176 | 55222 | SQLITE_PRIVATE int sqlite3BitvecBuiltinTest(int sz, int *aOp){ |
| 55177 | 55223 | Bitvec *pBitvec = 0; |
| 55178 | 55224 | unsigned char *pV = 0; |
| 55179 | 55225 | int rc = -1; |
| @@ -55180,22 +55226,45 @@ | ||
| 55180 | 55226 | int i, nx, pc, op; |
| 55181 | 55227 | void *pTmpSpace; |
| 55182 | 55228 | |
| 55183 | 55229 | /* Allocate the Bitvec to be tested and a linear array of |
| 55184 | 55230 | ** bits to act as the reference */ |
| 55185 | - pBitvec = sqlite3BitvecCreate( sz ); | |
| 55186 | - pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 ); | |
| 55231 | + if( sz<=0 ){ | |
| 55232 | + pBitvec = sqlite3BitvecCreate( 2*(unsigned)(-sz) ); | |
| 55233 | + pV = 0; | |
| 55234 | + }else{ | |
| 55235 | + pBitvec = sqlite3BitvecCreate( sz ); | |
| 55236 | + pV = sqlite3MallocZero( (7+(i64)sz)/8 + 1 ); | |
| 55237 | + } | |
| 55187 | 55238 | pTmpSpace = sqlite3_malloc64(BITVEC_SZ); |
| 55188 | - if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end; | |
| 55239 | + if( pBitvec==0 || pTmpSpace==0 || (pV==0 && sz>0) ) goto bitvec_end; | |
| 55189 | 55240 | |
| 55190 | 55241 | /* NULL pBitvec tests */ |
| 55191 | 55242 | sqlite3BitvecSet(0, 1); |
| 55192 | 55243 | sqlite3BitvecClear(0, 1, pTmpSpace); |
| 55193 | 55244 | |
| 55194 | 55245 | /* Run the program */ |
| 55195 | 55246 | pc = i = 0; |
| 55196 | 55247 | while( (op = aOp[pc])!=0 ){ |
| 55248 | + if( op>=6 ){ | |
| 55249 | +#ifdef SQLITE_DEBUG | |
| 55250 | + if( op==6 ){ | |
| 55251 | + sqlite3ShowBitvec(pBitvec); | |
| 55252 | + }else if( op==7 ){ | |
| 55253 | + printf("BITVEC_SZ = %d (%d by sizeof)\n", | |
| 55254 | + BITVEC_SZ, (int)sizeof(Bitvec)); | |
| 55255 | + printf("BITVEC_USIZE = %d\n", (int)BITVEC_USIZE); | |
| 55256 | + printf("BITVEC_NELEM = %d\n", (int)BITVEC_NELEM); | |
| 55257 | + printf("BITVEC_NBIT = %d\n", (int)BITVEC_NBIT); | |
| 55258 | + printf("BITVEC_NINT = %d\n", (int)BITVEC_NINT); | |
| 55259 | + printf("BITVEC_MXHASH = %d\n", (int)BITVEC_MXHASH); | |
| 55260 | + printf("BITVEC_NPTR = %d\n", (int)BITVEC_NPTR); | |
| 55261 | + } | |
| 55262 | +#endif | |
| 55263 | + pc++; | |
| 55264 | + continue; | |
| 55265 | + } | |
| 55197 | 55266 | switch( op ){ |
| 55198 | 55267 | case 1: |
| 55199 | 55268 | case 2: |
| 55200 | 55269 | case 5: { |
| 55201 | 55270 | nx = 4; |
| @@ -55213,33 +55282,37 @@ | ||
| 55213 | 55282 | } |
| 55214 | 55283 | if( (--aOp[pc+1]) > 0 ) nx = 0; |
| 55215 | 55284 | pc += nx; |
| 55216 | 55285 | i = (i & 0x7fffffff)%sz; |
| 55217 | 55286 | if( (op & 1)!=0 ){ |
| 55218 | - SETBIT(pV, (i+1)); | |
| 55287 | + if( pV ) SETBIT(pV, (i+1)); | |
| 55219 | 55288 | if( op!=5 ){ |
| 55220 | 55289 | if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end; |
| 55221 | 55290 | } |
| 55222 | 55291 | }else{ |
| 55223 | - CLEARBIT(pV, (i+1)); | |
| 55292 | + if( pV ) CLEARBIT(pV, (i+1)); | |
| 55224 | 55293 | sqlite3BitvecClear(pBitvec, i+1, pTmpSpace); |
| 55225 | 55294 | } |
| 55226 | 55295 | } |
| 55227 | 55296 | |
| 55228 | 55297 | /* Test to make sure the linear array exactly matches the |
| 55229 | 55298 | ** Bitvec object. Start with the assumption that they do |
| 55230 | 55299 | ** match (rc==0). Change rc to non-zero if a discrepancy |
| 55231 | 55300 | ** is found. |
| 55232 | 55301 | */ |
| 55233 | - rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1) | |
| 55234 | - + sqlite3BitvecTest(pBitvec, 0) | |
| 55235 | - + (sqlite3BitvecSize(pBitvec) - sz); | |
| 55236 | - for(i=1; i<=sz; i++){ | |
| 55237 | - if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){ | |
| 55238 | - rc = i; | |
| 55239 | - break; | |
| 55240 | - } | |
| 55302 | + if( pV ){ | |
| 55303 | + rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1) | |
| 55304 | + + sqlite3BitvecTest(pBitvec, 0) | |
| 55305 | + + (sqlite3BitvecSize(pBitvec) - sz); | |
| 55306 | + for(i=1; i<=sz; i++){ | |
| 55307 | + if( (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){ | |
| 55308 | + rc = i; | |
| 55309 | + break; | |
| 55310 | + } | |
| 55311 | + } | |
| 55312 | + }else{ | |
| 55313 | + rc = 0; | |
| 55241 | 55314 | } |
| 55242 | 55315 | |
| 55243 | 55316 | /* Free allocated structure */ |
| 55244 | 55317 | bitvec_end: |
| 55245 | 55318 | sqlite3_free(pTmpSpace); |
| @@ -58839,10 +58912,13 @@ | ||
| 58839 | 58912 | char *pTmpSpace; /* Pager.pageSize bytes of space for tmp use */ |
| 58840 | 58913 | PCache *pPCache; /* Pointer to page cache object */ |
| 58841 | 58914 | #ifndef SQLITE_OMIT_WAL |
| 58842 | 58915 | Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */ |
| 58843 | 58916 | char *zWal; /* File name for write-ahead log */ |
| 58917 | +#endif | |
| 58918 | +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT | |
| 58919 | + sqlite3 *dbWal; | |
| 58844 | 58920 | #endif |
| 58845 | 58921 | }; |
| 58846 | 58922 | |
| 58847 | 58923 | /* |
| 58848 | 58924 | ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains |
| @@ -65721,10 +65797,15 @@ | ||
| 65721 | 65797 | if( rc==SQLITE_OK ){ |
| 65722 | 65798 | rc = sqlite3WalOpen(pPager->pVfs, |
| 65723 | 65799 | pPager->fd, pPager->zWal, pPager->exclusiveMode, |
| 65724 | 65800 | pPager->journalSizeLimit, &pPager->pWal |
| 65725 | 65801 | ); |
| 65802 | +#ifdef SQLITE_ENABLE_SETLK_TIMEOUT | |
| 65803 | + if( rc==SQLITE_OK ){ | |
| 65804 | + sqlite3WalDb(pPager->pWal, pPager->dbWal); | |
| 65805 | + } | |
| 65806 | +#endif | |
| 65726 | 65807 | } |
| 65727 | 65808 | pagerFixMaplimit(pPager); |
| 65728 | 65809 | |
| 65729 | 65810 | return rc; |
| 65730 | 65811 | } |
| @@ -65840,10 +65921,11 @@ | ||
| 65840 | 65921 | /* |
| 65841 | 65922 | ** Set the database handle used by the wal layer to determine if |
| 65842 | 65923 | ** blocking locks are required. |
| 65843 | 65924 | */ |
| 65844 | 65925 | SQLITE_PRIVATE void sqlite3PagerWalDb(Pager *pPager, sqlite3 *db){ |
| 65926 | + pPager->dbWal = db; | |
| 65845 | 65927 | if( pagerUseWal(pPager) ){ |
| 65846 | 65928 | sqlite3WalDb(pPager->pWal, db); |
| 65847 | 65929 | } |
| 65848 | 65930 | } |
| 65849 | 65931 | #endif |
| @@ -69013,11 +69095,10 @@ | ||
| 69013 | 69095 | assert( rc==SQLITE_OK ); |
| 69014 | 69096 | if( pWal->bShmUnreliable==0 ){ |
| 69015 | 69097 | rc = walIndexReadHdr(pWal, pChanged); |
| 69016 | 69098 | } |
| 69017 | 69099 | #ifdef SQLITE_ENABLE_SETLK_TIMEOUT |
| 69018 | - walDisableBlocking(pWal); | |
| 69019 | 69100 | if( rc==SQLITE_BUSY_TIMEOUT ){ |
| 69020 | 69101 | rc = SQLITE_BUSY; |
| 69021 | 69102 | *pCnt |= WAL_RETRY_BLOCKED_MASK; |
| 69022 | 69103 | } |
| 69023 | 69104 | #endif |
| @@ -69028,10 +69109,11 @@ | ||
| 69028 | 69109 | ** which might cause WAL_RETRY to be returned even if BUSY_RECOVERY |
| 69029 | 69110 | ** would be technically correct. But the race is benign since with |
| 69030 | 69111 | ** WAL_RETRY this routine will be called again and will probably be |
| 69031 | 69112 | ** right on the second iteration. |
| 69032 | 69113 | */ |
| 69114 | + (void)walEnableBlocking(pWal); | |
| 69033 | 69115 | if( pWal->apWiData[0]==0 ){ |
| 69034 | 69116 | /* This branch is taken when the xShmMap() method returns SQLITE_BUSY. |
| 69035 | 69117 | ** We assume this is a transient condition, so return WAL_RETRY. The |
| 69036 | 69118 | ** xShmMap() implementation used by the default unix and win32 VFS |
| 69037 | 69119 | ** modules may return SQLITE_BUSY due to a race condition in the |
| @@ -69044,10 +69126,11 @@ | ||
| 69044 | 69126 | rc = WAL_RETRY; |
| 69045 | 69127 | }else if( rc==SQLITE_BUSY ){ |
| 69046 | 69128 | rc = SQLITE_BUSY_RECOVERY; |
| 69047 | 69129 | } |
| 69048 | 69130 | } |
| 69131 | + walDisableBlocking(pWal); | |
| 69049 | 69132 | if( rc!=SQLITE_OK ){ |
| 69050 | 69133 | return rc; |
| 69051 | 69134 | } |
| 69052 | 69135 | else if( pWal->bShmUnreliable ){ |
| 69053 | 69136 | return walBeginShmUnreliable(pWal, pChanged); |
| @@ -69731,10 +69814,11 @@ | ||
| 69731 | 69814 | rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame)); |
| 69732 | 69815 | } |
| 69733 | 69816 | if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal); |
| 69734 | 69817 | } |
| 69735 | 69818 | SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) |
| 69819 | + pWal->iReCksum = 0; | |
| 69736 | 69820 | } |
| 69737 | 69821 | return rc; |
| 69738 | 69822 | } |
| 69739 | 69823 | |
| 69740 | 69824 | /* |
| @@ -69778,10 +69862,13 @@ | ||
| 69778 | 69862 | pWal->hdr.aFrameCksum[1] = aWalData[2]; |
| 69779 | 69863 | SEH_TRY { |
| 69780 | 69864 | walCleanupHash(pWal); |
| 69781 | 69865 | } |
| 69782 | 69866 | SEH_EXCEPT( rc = SQLITE_IOERR_IN_PAGE; ) |
| 69867 | + if( pWal->iReCksum>pWal->hdr.mxFrame ){ | |
| 69868 | + pWal->iReCksum = 0; | |
| 69869 | + } | |
| 69783 | 69870 | } |
| 69784 | 69871 | |
| 69785 | 69872 | return rc; |
| 69786 | 69873 | } |
| 69787 | 69874 | |
| @@ -72493,11 +72580,11 @@ | ||
| 72493 | 72580 | if( pKey ){ |
| 72494 | 72581 | KeyInfo *pKeyInfo = pCur->pKeyInfo; |
| 72495 | 72582 | assert( nKey==(i64)(int)nKey ); |
| 72496 | 72583 | pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo); |
| 72497 | 72584 | if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT; |
| 72498 | - sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey); | |
| 72585 | + sqlite3VdbeRecordUnpack((int)nKey, pKey, pIdxKey); | |
| 72499 | 72586 | if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){ |
| 72500 | 72587 | rc = SQLITE_CORRUPT_BKPT; |
| 72501 | 72588 | }else{ |
| 72502 | 72589 | rc = sqlite3BtreeIndexMoveto(pCur, pIdxKey, pRes); |
| 72503 | 72590 | } |
| @@ -73550,14 +73637,14 @@ | ||
| 73550 | 73637 | u8 *pTmp; /* Temporary ptr into data[] */ |
| 73551 | 73638 | |
| 73552 | 73639 | assert( pPage->pBt!=0 ); |
| 73553 | 73640 | assert( sqlite3PagerIswriteable(pPage->pDbPage) ); |
| 73554 | 73641 | assert( CORRUPT_DB || iStart>=pPage->hdrOffset+6+pPage->childPtrSize ); |
| 73555 | - assert( CORRUPT_DB || iEnd <= pPage->pBt->usableSize ); | |
| 73642 | + assert( CORRUPT_DB || iEnd <= (int)pPage->pBt->usableSize ); | |
| 73556 | 73643 | assert( sqlite3_mutex_held(pPage->pBt->mutex) ); |
| 73557 | 73644 | assert( iSize>=4 ); /* Minimum cell size is 4 */ |
| 73558 | - assert( CORRUPT_DB || iStart<=pPage->pBt->usableSize-4 ); | |
| 73645 | + assert( CORRUPT_DB || iStart<=(int)pPage->pBt->usableSize-4 ); | |
| 73559 | 73646 | |
| 73560 | 73647 | /* The list of freeblocks must be in ascending order. Find the |
| 73561 | 73648 | ** spot on the list where iStart should be inserted. |
| 73562 | 73649 | */ |
| 73563 | 73650 | hdr = pPage->hdrOffset; |
| @@ -74477,10 +74564,11 @@ | ||
| 74477 | 74564 | removed = 1; |
| 74478 | 74565 | } |
| 74479 | 74566 | sqlite3_mutex_leave(pMainMtx); |
| 74480 | 74567 | return removed; |
| 74481 | 74568 | #else |
| 74569 | + UNUSED_PARAMETER( pBt ); | |
| 74482 | 74570 | return 1; |
| 74483 | 74571 | #endif |
| 74484 | 74572 | } |
| 74485 | 74573 | |
| 74486 | 74574 | /* |
| @@ -74694,10 +74782,14 @@ | ||
| 74694 | 74782 | BtShared *pBt = p->pBt; |
| 74695 | 74783 | assert( nReserve>=0 && nReserve<=255 ); |
| 74696 | 74784 | sqlite3BtreeEnter(p); |
| 74697 | 74785 | pBt->nReserveWanted = (u8)nReserve; |
| 74698 | 74786 | x = pBt->pageSize - pBt->usableSize; |
| 74787 | + if( x==nReserve && (pageSize==0 || (u32)pageSize==pBt->pageSize) ){ | |
| 74788 | + sqlite3BtreeLeave(p); | |
| 74789 | + return SQLITE_OK; | |
| 74790 | + } | |
| 74699 | 74791 | if( nReserve<x ) nReserve = x; |
| 74700 | 74792 | if( pBt->btsFlags & BTS_PAGESIZE_FIXED ){ |
| 74701 | 74793 | sqlite3BtreeLeave(p); |
| 74702 | 74794 | return SQLITE_READONLY; |
| 74703 | 74795 | } |
| @@ -75318,10 +75410,17 @@ | ||
| 75318 | 75410 | |
| 75319 | 75411 | if( rc!=SQLITE_OK ){ |
| 75320 | 75412 | (void)sqlite3PagerWalWriteLock(pPager, 0); |
| 75321 | 75413 | unlockBtreeIfUnused(pBt); |
| 75322 | 75414 | } |
| 75415 | +#if defined(SQLITE_ENABLE_SETLK_TIMEOUT) | |
| 75416 | + if( rc==SQLITE_BUSY_TIMEOUT ){ | |
| 75417 | + /* If a blocking lock timed out, break out of the loop here so that | |
| 75418 | + ** the busy-handler is not invoked. */ | |
| 75419 | + break; | |
| 75420 | + } | |
| 75421 | +#endif | |
| 75323 | 75422 | }while( (rc&0xFF)==SQLITE_BUSY && pBt->inTransaction==TRANS_NONE && |
| 75324 | 75423 | btreeInvokeBusyHandler(pBt) ); |
| 75325 | 75424 | sqlite3PagerWalDb(pPager, 0); |
| 75326 | 75425 | #ifdef SQLITE_ENABLE_SETLK_TIMEOUT |
| 75327 | 75426 | if( rc==SQLITE_BUSY_TIMEOUT ) rc = SQLITE_BUSY; |
| @@ -77275,10 +77374,34 @@ | ||
| 77275 | 77374 | *pRes = 1; |
| 77276 | 77375 | rc = SQLITE_OK; |
| 77277 | 77376 | } |
| 77278 | 77377 | return rc; |
| 77279 | 77378 | } |
| 77379 | + | |
| 77380 | +/* Set *pRes to 1 (true) if the BTree pointed to by cursor pCur contains zero | |
| 77381 | +** rows of content. Set *pRes to 0 (false) if the table contains content. | |
| 77382 | +** Return SQLITE_OK on success or some error code (ex: SQLITE_NOMEM) if | |
| 77383 | +** something goes wrong. | |
| 77384 | +*/ | |
| 77385 | +SQLITE_PRIVATE int sqlite3BtreeIsEmpty(BtCursor *pCur, int *pRes){ | |
| 77386 | + int rc; | |
| 77387 | + | |
| 77388 | + assert( cursorOwnsBtShared(pCur) ); | |
| 77389 | + assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); | |
| 77390 | + if( pCur->eState==CURSOR_VALID ){ | |
| 77391 | + *pRes = 0; | |
| 77392 | + return SQLITE_OK; | |
| 77393 | + } | |
| 77394 | + rc = moveToRoot(pCur); | |
| 77395 | + if( rc==SQLITE_EMPTY ){ | |
| 77396 | + *pRes = 1; | |
| 77397 | + rc = SQLITE_OK; | |
| 77398 | + }else{ | |
| 77399 | + *pRes = 0; | |
| 77400 | + } | |
| 77401 | + return rc; | |
| 77402 | +} | |
| 77280 | 77403 | |
| 77281 | 77404 | #ifdef SQLITE_DEBUG |
| 77282 | 77405 | /* The cursors is CURSOR_VALID and has BTCF_AtLast set. Verify that |
| 77283 | 77406 | ** this flags are true for a consistent database. |
| 77284 | 77407 | ** |
| @@ -77495,12 +77618,12 @@ | ||
| 77495 | 77618 | assert( (pCur->curFlags & BTCF_ValidOvfl)==0 ); |
| 77496 | 77619 | return rc; |
| 77497 | 77620 | } |
| 77498 | 77621 | |
| 77499 | 77622 | /* |
| 77500 | -** Compare the "idx"-th cell on the page the cursor pCur is currently | |
| 77501 | -** pointing to to pIdxKey using xRecordCompare. Return negative or | |
| 77623 | +** Compare the "idx"-th cell on the page pPage against the key | |
| 77624 | +** pointing to by pIdxKey using xRecordCompare. Return negative or | |
| 77502 | 77625 | ** zero if the cell is less than or equal pIdxKey. Return positive |
| 77503 | 77626 | ** if unknown. |
| 77504 | 77627 | ** |
| 77505 | 77628 | ** Return value negative: Cell at pCur[idx] less than pIdxKey |
| 77506 | 77629 | ** |
| @@ -77511,16 +77634,15 @@ | ||
| 77511 | 77634 | ** |
| 77512 | 77635 | ** This routine is part of an optimization. It is always safe to return |
| 77513 | 77636 | ** a positive value as that will cause the optimization to be skipped. |
| 77514 | 77637 | */ |
| 77515 | 77638 | static int indexCellCompare( |
| 77516 | - BtCursor *pCur, | |
| 77639 | + MemPage *pPage, | |
| 77517 | 77640 | int idx, |
| 77518 | 77641 | UnpackedRecord *pIdxKey, |
| 77519 | 77642 | RecordCompare xRecordCompare |
| 77520 | 77643 | ){ |
| 77521 | - MemPage *pPage = pCur->pPage; | |
| 77522 | 77644 | int c; |
| 77523 | 77645 | int nCell; /* Size of the pCell cell in bytes */ |
| 77524 | 77646 | u8 *pCell = findCellPastPtr(pPage, idx); |
| 77525 | 77647 | |
| 77526 | 77648 | nCell = pCell[0]; |
| @@ -77625,18 +77747,18 @@ | ||
| 77625 | 77747 | && pCur->pPage->leaf |
| 77626 | 77748 | && cursorOnLastPage(pCur) |
| 77627 | 77749 | ){ |
| 77628 | 77750 | int c; |
| 77629 | 77751 | if( pCur->ix==pCur->pPage->nCell-1 |
| 77630 | - && (c = indexCellCompare(pCur, pCur->ix, pIdxKey, xRecordCompare))<=0 | |
| 77752 | + && (c = indexCellCompare(pCur->pPage,pCur->ix,pIdxKey,xRecordCompare))<=0 | |
| 77631 | 77753 | && pIdxKey->errCode==SQLITE_OK |
| 77632 | 77754 | ){ |
| 77633 | 77755 | *pRes = c; |
| 77634 | 77756 | return SQLITE_OK; /* Cursor already pointing at the correct spot */ |
| 77635 | 77757 | } |
| 77636 | 77758 | if( pCur->iPage>0 |
| 77637 | - && indexCellCompare(pCur, 0, pIdxKey, xRecordCompare)<=0 | |
| 77759 | + && indexCellCompare(pCur->pPage, 0, pIdxKey, xRecordCompare)<=0 | |
| 77638 | 77760 | && pIdxKey->errCode==SQLITE_OK |
| 77639 | 77761 | ){ |
| 77640 | 77762 | pCur->curFlags &= ~(BTCF_ValidOvfl|BTCF_AtLast); |
| 77641 | 77763 | if( !pCur->pPage->isInit ){ |
| 77642 | 77764 | return SQLITE_CORRUPT_BKPT; |
| @@ -77849,11 +77971,11 @@ | ||
| 77849 | 77971 | if( pCur->eState!=CURSOR_VALID ) return 0; |
| 77850 | 77972 | if( NEVER(pCur->pPage->leaf==0) ) return -1; |
| 77851 | 77973 | |
| 77852 | 77974 | n = pCur->pPage->nCell; |
| 77853 | 77975 | for(i=0; i<pCur->iPage; i++){ |
| 77854 | - n *= pCur->apPage[i]->nCell; | |
| 77976 | + n *= pCur->apPage[i]->nCell+1; | |
| 77855 | 77977 | } |
| 77856 | 77978 | return n; |
| 77857 | 77979 | } |
| 77858 | 77980 | |
| 77859 | 77981 | /* |
| @@ -80306,11 +80428,16 @@ | ||
| 80306 | 80428 | |
| 80307 | 80429 | /* If the sibling pages are not leaves, ensure that the right-child pointer |
| 80308 | 80430 | ** of the right-most new sibling page is set to the value that was |
| 80309 | 80431 | ** originally in the same field of the right-most old sibling page. */ |
| 80310 | 80432 | if( (pageFlags & PTF_LEAF)==0 && nOld!=nNew ){ |
| 80311 | - MemPage *pOld = (nNew>nOld ? apNew : apOld)[nOld-1]; | |
| 80433 | + MemPage *pOld; | |
| 80434 | + if( nNew>nOld ){ | |
| 80435 | + pOld = apNew[nOld-1]; | |
| 80436 | + }else{ | |
| 80437 | + pOld = apOld[nOld-1]; | |
| 80438 | + } | |
| 80312 | 80439 | memcpy(&apNew[nNew-1]->aData[8], &pOld->aData[8], 4); |
| 80313 | 80440 | } |
| 80314 | 80441 | |
| 80315 | 80442 | /* Make any required updates to pointer map entries associated with |
| 80316 | 80443 | ** cells stored on sibling pages following the balance operation. Pointer |
| @@ -82938,10 +83065,11 @@ | ||
| 82938 | 83065 | ** btree as the argument handle holds an exclusive lock on the |
| 82939 | 83066 | ** sqlite_schema table. Otherwise SQLITE_OK. |
| 82940 | 83067 | */ |
| 82941 | 83068 | SQLITE_PRIVATE int sqlite3BtreeSchemaLocked(Btree *p){ |
| 82942 | 83069 | int rc; |
| 83070 | + UNUSED_PARAMETER(p); /* only used in DEBUG builds */ | |
| 82943 | 83071 | assert( sqlite3_mutex_held(p->db->mutex) ); |
| 82944 | 83072 | sqlite3BtreeEnter(p); |
| 82945 | 83073 | rc = querySharedCacheTableLock(p, SCHEMA_ROOT, READ_LOCK); |
| 82946 | 83074 | assert( rc==SQLITE_OK || rc==SQLITE_LOCKED_SHAREDCACHE ); |
| 82947 | 83075 | sqlite3BtreeLeave(p); |
| @@ -87262,10 +87390,13 @@ | ||
| 87262 | 87390 | ** into register iDest, then add the OPFLAG_TYPEOFARG flag to that |
| 87263 | 87391 | ** opcode. |
| 87264 | 87392 | */ |
| 87265 | 87393 | SQLITE_PRIVATE void sqlite3VdbeTypeofColumn(Vdbe *p, int iDest){ |
| 87266 | 87394 | VdbeOp *pOp = sqlite3VdbeGetLastOp(p); |
| 87395 | +#ifdef SQLITE_DEBUG | |
| 87396 | + while( pOp->opcode==OP_ReleaseReg ) pOp--; | |
| 87397 | +#endif | |
| 87267 | 87398 | if( pOp->p3==iDest && pOp->opcode==OP_Column ){ |
| 87268 | 87399 | pOp->p5 |= OPFLAG_TYPEOFARG; |
| 87269 | 87400 | } |
| 87270 | 87401 | } |
| 87271 | 87402 | |
| @@ -90155,34 +90286,26 @@ | ||
| 90155 | 90286 | } |
| 90156 | 90287 | } |
| 90157 | 90288 | return; |
| 90158 | 90289 | } |
| 90159 | 90290 | /* |
| 90160 | -** This routine is used to allocate sufficient space for an UnpackedRecord | |
| 90161 | -** structure large enough to be used with sqlite3VdbeRecordUnpack() if | |
| 90162 | -** the first argument is a pointer to KeyInfo structure pKeyInfo. | |
| 90163 | -** | |
| 90164 | -** The space is either allocated using sqlite3DbMallocRaw() or from within | |
| 90165 | -** the unaligned buffer passed via the second and third arguments (presumably | |
| 90166 | -** stack space). If the former, then *ppFree is set to a pointer that should | |
| 90167 | -** be eventually freed by the caller using sqlite3DbFree(). Or, if the | |
| 90168 | -** allocation comes from the pSpace/szSpace buffer, *ppFree is set to NULL | |
| 90169 | -** before returning. | |
| 90170 | -** | |
| 90171 | -** If an OOM error occurs, NULL is returned. | |
| 90291 | +** Allocate sufficient space for an UnpackedRecord structure large enough | |
| 90292 | +** to hold a decoded index record for pKeyInfo. | |
| 90293 | +** | |
| 90294 | +** The space is allocated using sqlite3DbMallocRaw(). If an OOM error | |
| 90295 | +** occurs, NULL is returned. | |
| 90172 | 90296 | */ |
| 90173 | 90297 | SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord( |
| 90174 | 90298 | KeyInfo *pKeyInfo /* Description of the record */ |
| 90175 | 90299 | ){ |
| 90176 | 90300 | UnpackedRecord *p; /* Unpacked record to return */ |
| 90177 | - int nByte; /* Number of bytes required for *p */ | |
| 90301 | + u64 nByte; /* Number of bytes required for *p */ | |
| 90178 | 90302 | assert( sizeof(UnpackedRecord) + sizeof(Mem)*65536 < 0x7fffffff ); |
| 90179 | 90303 | nByte = ROUND8P(sizeof(UnpackedRecord)) + sizeof(Mem)*(pKeyInfo->nKeyField+1); |
| 90180 | 90304 | p = (UnpackedRecord *)sqlite3DbMallocRaw(pKeyInfo->db, nByte); |
| 90181 | 90305 | if( !p ) return 0; |
| 90182 | 90306 | p->aMem = (Mem*)&((char*)p)[ROUND8P(sizeof(UnpackedRecord))]; |
| 90183 | - assert( pKeyInfo->aSortFlags!=0 ); | |
| 90184 | 90307 | p->pKeyInfo = pKeyInfo; |
| 90185 | 90308 | p->nField = pKeyInfo->nKeyField + 1; |
| 90186 | 90309 | return p; |
| 90187 | 90310 | } |
| 90188 | 90311 | |
| @@ -90190,11 +90313,10 @@ | ||
| 90190 | 90313 | ** Given the nKey-byte encoding of a record in pKey[], populate the |
| 90191 | 90314 | ** UnpackedRecord structure indicated by the fourth argument with the |
| 90192 | 90315 | ** contents of the decoded record. |
| 90193 | 90316 | */ |
| 90194 | 90317 | SQLITE_PRIVATE void sqlite3VdbeRecordUnpack( |
| 90195 | - KeyInfo *pKeyInfo, /* Information about the record format */ | |
| 90196 | 90318 | int nKey, /* Size of the binary record */ |
| 90197 | 90319 | const void *pKey, /* The binary record */ |
| 90198 | 90320 | UnpackedRecord *p /* Populate this structure before returning. */ |
| 90199 | 90321 | ){ |
| 90200 | 90322 | const unsigned char *aKey = (const unsigned char *)pKey; |
| @@ -90201,10 +90323,11 @@ | ||
| 90201 | 90323 | u32 d; |
| 90202 | 90324 | u32 idx; /* Offset in aKey[] to read from */ |
| 90203 | 90325 | u16 u; /* Unsigned loop counter */ |
| 90204 | 90326 | u32 szHdr; |
| 90205 | 90327 | Mem *pMem = p->aMem; |
| 90328 | + KeyInfo *pKeyInfo = p->pKeyInfo; | |
| 90206 | 90329 | |
| 90207 | 90330 | p->default_rc = 0; |
| 90208 | 90331 | assert( EIGHT_BYTE_ALIGNMENT(pMem) ); |
| 90209 | 90332 | idx = getVarint32(aKey, szHdr); |
| 90210 | 90333 | d = szHdr; |
| @@ -90228,10 +90351,12 @@ | ||
| 90228 | 90351 | /* In a corrupt record entry, the last pMem might have been set up using |
| 90229 | 90352 | ** uninitialized memory. Overwrite its value with NULL, to prevent |
| 90230 | 90353 | ** warnings from MSAN. */ |
| 90231 | 90354 | sqlite3VdbeMemSetNull(pMem-1); |
| 90232 | 90355 | } |
| 90356 | + testcase( u == pKeyInfo->nKeyField + 1 ); | |
| 90357 | + testcase( u < pKeyInfo->nKeyField + 1 ); | |
| 90233 | 90358 | assert( u<=pKeyInfo->nKeyField + 1 ); |
| 90234 | 90359 | p->nField = u; |
| 90235 | 90360 | } |
| 90236 | 90361 | |
| 90237 | 90362 | #ifdef SQLITE_DEBUG |
| @@ -91087,10 +91212,11 @@ | ||
| 91087 | 91212 | ** is an integer. |
| 91088 | 91213 | ** |
| 91089 | 91214 | ** The easiest way to enforce this limit is to consider only records with |
| 91090 | 91215 | ** 13 fields or less. If the first field is an integer, the maximum legal |
| 91091 | 91216 | ** header size is (12*5 + 1 + 1) bytes. */ |
| 91217 | + assert( p->pKeyInfo->aSortFlags!=0 ); | |
| 91092 | 91218 | if( p->pKeyInfo->nAllField<=13 ){ |
| 91093 | 91219 | int flags = p->aMem[0].flags; |
| 91094 | 91220 | if( p->pKeyInfo->aSortFlags[0] ){ |
| 91095 | 91221 | if( p->pKeyInfo->aSortFlags[0] & KEYINFO_ORDER_BIGNULL ){ |
| 91096 | 91222 | return sqlite3VdbeRecordCompare; |
| @@ -91336,10 +91462,11 @@ | ||
| 91336 | 91462 | }else{ |
| 91337 | 91463 | v->expmask |= ((u32)1 << (iVar-1)); |
| 91338 | 91464 | } |
| 91339 | 91465 | } |
| 91340 | 91466 | |
| 91467 | +#ifndef SQLITE_OMIT_DATETIME_FUNCS | |
| 91341 | 91468 | /* |
| 91342 | 91469 | ** Cause a function to throw an error if it was call from OP_PureFunc |
| 91343 | 91470 | ** rather than OP_Function. |
| 91344 | 91471 | ** |
| 91345 | 91472 | ** OP_PureFunc means that the function must be deterministic, and should |
| @@ -91369,10 +91496,11 @@ | ||
| 91369 | 91496 | sqlite3_free(zMsg); |
| 91370 | 91497 | return 0; |
| 91371 | 91498 | } |
| 91372 | 91499 | return 1; |
| 91373 | 91500 | } |
| 91501 | +#endif /* SQLITE_OMIT_DATETIME_FUNCS */ | |
| 91374 | 91502 | |
| 91375 | 91503 | #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG) |
| 91376 | 91504 | /* |
| 91377 | 91505 | ** This Walker callback is used to help verify that calls to |
| 91378 | 91506 | ** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have |
| @@ -91445,11 +91573,10 @@ | ||
| 91445 | 91573 | ){ |
| 91446 | 91574 | sqlite3 *db = v->db; |
| 91447 | 91575 | i64 iKey2; |
| 91448 | 91576 | PreUpdate preupdate; |
| 91449 | 91577 | const char *zTbl = pTab->zName; |
| 91450 | - static const u8 fakeSortOrder = 0; | |
| 91451 | 91578 | #ifdef SQLITE_DEBUG |
| 91452 | 91579 | int nRealCol; |
| 91453 | 91580 | if( pTab->tabFlags & TF_WithoutRowid ){ |
| 91454 | 91581 | nRealCol = sqlite3PrimaryKeyIndex(pTab)->nColumn; |
| 91455 | 91582 | }else if( pTab->tabFlags & TF_HasVirtual ){ |
| @@ -91484,11 +91611,11 @@ | ||
| 91484 | 91611 | preupdate.iNewReg = iReg; |
| 91485 | 91612 | preupdate.pKeyinfo = (KeyInfo*)&preupdate.keyinfoSpace; |
| 91486 | 91613 | preupdate.pKeyinfo->db = db; |
| 91487 | 91614 | preupdate.pKeyinfo->enc = ENC(db); |
| 91488 | 91615 | preupdate.pKeyinfo->nKeyField = pTab->nCol; |
| 91489 | - preupdate.pKeyinfo->aSortFlags = (u8*)&fakeSortOrder; | |
| 91616 | + preupdate.pKeyinfo->aSortFlags = 0; /* Indicate .aColl, .nAllField uninit */ | |
| 91490 | 91617 | preupdate.iKey1 = iKey1; |
| 91491 | 91618 | preupdate.iKey2 = iKey2; |
| 91492 | 91619 | preupdate.pTab = pTab; |
| 91493 | 91620 | preupdate.iBlobWrite = iBlobWrite; |
| 91494 | 91621 | |
| @@ -93681,11 +93808,11 @@ | ||
| 93681 | 93808 | UnpackedRecord *pRet; /* Return value */ |
| 93682 | 93809 | |
| 93683 | 93810 | pRet = sqlite3VdbeAllocUnpackedRecord(pKeyInfo); |
| 93684 | 93811 | if( pRet ){ |
| 93685 | 93812 | memset(pRet->aMem, 0, sizeof(Mem)*(pKeyInfo->nKeyField+1)); |
| 93686 | - sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, pRet); | |
| 93813 | + sqlite3VdbeRecordUnpack(nKey, pKey, pRet); | |
| 93687 | 93814 | } |
| 93688 | 93815 | return pRet; |
| 93689 | 93816 | } |
| 93690 | 93817 | |
| 93691 | 93818 | /* |
| @@ -93710,10 +93837,13 @@ | ||
| 93710 | 93837 | rc = SQLITE_MISUSE_BKPT; |
| 93711 | 93838 | goto preupdate_old_out; |
| 93712 | 93839 | } |
| 93713 | 93840 | if( p->pPk ){ |
| 93714 | 93841 | iStore = sqlite3TableColumnToIndex(p->pPk, iIdx); |
| 93842 | + }else if( iIdx >= p->pTab->nCol ){ | |
| 93843 | + rc = SQLITE_MISUSE_BKPT; | |
| 93844 | + goto preupdate_old_out; | |
| 93715 | 93845 | }else{ |
| 93716 | 93846 | iStore = sqlite3TableColumnToStorage(p->pTab, iIdx); |
| 93717 | 93847 | } |
| 93718 | 93848 | if( iStore>=p->pCsr->nField || iStore<0 ){ |
| 93719 | 93849 | rc = SQLITE_RANGE; |
| @@ -93865,10 +93995,12 @@ | ||
| 93865 | 93995 | rc = SQLITE_MISUSE_BKPT; |
| 93866 | 93996 | goto preupdate_new_out; |
| 93867 | 93997 | } |
| 93868 | 93998 | if( p->pPk && p->op!=SQLITE_UPDATE ){ |
| 93869 | 93999 | iStore = sqlite3TableColumnToIndex(p->pPk, iIdx); |
| 94000 | + }else if( iIdx >= p->pTab->nCol ){ | |
| 94001 | + return SQLITE_MISUSE_BKPT; | |
| 93870 | 94002 | }else{ |
| 93871 | 94003 | iStore = sqlite3TableColumnToStorage(p->pTab, iIdx); |
| 93872 | 94004 | } |
| 93873 | 94005 | |
| 93874 | 94006 | if( iStore>=p->pCsr->nField || iStore<0 ){ |
| @@ -95190,10 +95322,40 @@ | ||
| 95190 | 95322 | } |
| 95191 | 95323 | pDest->flags &= ~MEM_Ephem; |
| 95192 | 95324 | return rc; |
| 95193 | 95325 | } |
| 95194 | 95326 | |
| 95327 | +/* | |
| 95328 | +** Send a "statement aborts" message to the error log. | |
| 95329 | +*/ | |
| 95330 | +static SQLITE_NOINLINE void sqlite3VdbeLogAbort( | |
| 95331 | + Vdbe *p, /* The statement that is running at the time of failure */ | |
| 95332 | + int rc, /* Error code */ | |
| 95333 | + Op *pOp, /* Opcode that filed */ | |
| 95334 | + Op *aOp /* All opcodes */ | |
| 95335 | +){ | |
| 95336 | + const char *zSql = p->zSql; /* Original SQL text */ | |
| 95337 | + const char *zPrefix = ""; /* Prefix added to SQL text */ | |
| 95338 | + int pc; /* Opcode address */ | |
| 95339 | + char zXtra[100]; /* Buffer space to store zPrefix */ | |
| 95340 | + | |
| 95341 | + if( p->pFrame ){ | |
| 95342 | + assert( aOp[0].opcode==OP_Init ); | |
| 95343 | + if( aOp[0].p4.z!=0 ){ | |
| 95344 | + assert( aOp[0].p4.z[0]=='-' | |
| 95345 | + && aOp[0].p4.z[1]=='-' | |
| 95346 | + && aOp[0].p4.z[2]==' ' ); | |
| 95347 | + sqlite3_snprintf(sizeof(zXtra), zXtra,"/* %s */ ",aOp[0].p4.z+3); | |
| 95348 | + zPrefix = zXtra; | |
| 95349 | + }else{ | |
| 95350 | + zPrefix = "/* unknown trigger */ "; | |
| 95351 | + } | |
| 95352 | + } | |
| 95353 | + pc = (int)(pOp - aOp); | |
| 95354 | + sqlite3_log(rc, "statement aborts at %d: %s; [%s%s]", | |
| 95355 | + pc, p->zErrMsg, zPrefix, zSql); | |
| 95356 | +} | |
| 95195 | 95357 | |
| 95196 | 95358 | /* |
| 95197 | 95359 | ** Return the symbolic name for the data type of a pMem |
| 95198 | 95360 | */ |
| 95199 | 95361 | static const char *vdbeMemTypeName(Mem *pMem){ |
| @@ -95715,12 +95877,11 @@ | ||
| 95715 | 95877 | p->zErrMsg = sqlite3MPrintf(db, "%z: %s", p->zErrMsg, pOp->p4.z); |
| 95716 | 95878 | } |
| 95717 | 95879 | }else{ |
| 95718 | 95880 | sqlite3VdbeError(p, "%s", pOp->p4.z); |
| 95719 | 95881 | } |
| 95720 | - pcx = (int)(pOp - aOp); | |
| 95721 | - sqlite3_log(pOp->p1, "abort at %d in [%s]: %s", pcx, p->zSql, p->zErrMsg); | |
| 95882 | + sqlite3VdbeLogAbort(p, pOp->p1, pOp, aOp); | |
| 95722 | 95883 | } |
| 95723 | 95884 | rc = sqlite3VdbeHalt(p); |
| 95724 | 95885 | assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR ); |
| 95725 | 95886 | if( rc==SQLITE_BUSY ){ |
| 95726 | 95887 | p->rc = SQLITE_BUSY; |
| @@ -96874,10 +97035,11 @@ | ||
| 96874 | 97035 | } |
| 96875 | 97036 | n = pOp->p3; |
| 96876 | 97037 | pKeyInfo = pOp->p4.pKeyInfo; |
| 96877 | 97038 | assert( n>0 ); |
| 96878 | 97039 | assert( pKeyInfo!=0 ); |
| 97040 | + assert( pKeyInfo->aSortFlags!=0 ); | |
| 96879 | 97041 | p1 = pOp->p1; |
| 96880 | 97042 | p2 = pOp->p2; |
| 96881 | 97043 | #ifdef SQLITE_DEBUG |
| 96882 | 97044 | if( aPermute ){ |
| 96883 | 97045 | int k, mx = 0; |
| @@ -97042,11 +97204,11 @@ | ||
| 97042 | 97204 | pOut->u.i = ~sqlite3VdbeIntValue(pIn1); |
| 97043 | 97205 | } |
| 97044 | 97206 | break; |
| 97045 | 97207 | } |
| 97046 | 97208 | |
| 97047 | -/* Opcode: Once P1 P2 * * * | |
| 97209 | +/* Opcode: Once P1 P2 P3 * * | |
| 97048 | 97210 | ** |
| 97049 | 97211 | ** Fall through to the next instruction the first time this opcode is |
| 97050 | 97212 | ** encountered on each invocation of the byte-code program. Jump to P2 |
| 97051 | 97213 | ** on the second and all subsequent encounters during the same invocation. |
| 97052 | 97214 | ** |
| @@ -97058,10 +97220,16 @@ | ||
| 97058 | 97220 | ** |
| 97059 | 97221 | ** For subprograms, there is a bitmask in the VdbeFrame that determines |
| 97060 | 97222 | ** whether or not the jump should be taken. The bitmask is necessary |
| 97061 | 97223 | ** because the self-altering code trick does not work for recursive |
| 97062 | 97224 | ** triggers. |
| 97225 | +** | |
| 97226 | +** The P3 operand is not used directly by this opcode. However P3 is | |
| 97227 | +** used by the code generator as follows: If this opcode is the start | |
| 97228 | +** of a subroutine and that subroutine uses a Bloom filter, then P3 will | |
| 97229 | +** be the register that holds that Bloom filter. See tag-202407032019 | |
| 97230 | +** in the source code for implementation details. | |
| 97063 | 97231 | */ |
| 97064 | 97232 | case OP_Once: { /* jump */ |
| 97065 | 97233 | u32 iAddr; /* Address of this instruction */ |
| 97066 | 97234 | assert( p->aOp[0].opcode==OP_Init ); |
| 97067 | 97235 | if( p->pFrame ){ |
| @@ -97629,10 +97797,19 @@ | ||
| 97629 | 97797 | ** Synopsis: typecheck(r[P1@P2]) |
| 97630 | 97798 | ** |
| 97631 | 97799 | ** Apply affinities to the range of P2 registers beginning with P1. |
| 97632 | 97800 | ** Take the affinities from the Table object in P4. If any value |
| 97633 | 97801 | ** cannot be coerced into the correct type, then raise an error. |
| 97802 | +** | |
| 97803 | +** If P3==0, then omit checking of VIRTUAL columns. | |
| 97804 | +** | |
| 97805 | +** If P3==1, then omit checking of all generated column, both VIRTUAL | |
| 97806 | +** and STORED. | |
| 97807 | +** | |
| 97808 | +** If P3>=2, then only check column number P3-2 in the table (which will | |
| 97809 | +** be a VIRTUAL column) against the value in reg[P1]. In this case, | |
| 97810 | +** P2 will be 1. | |
| 97634 | 97811 | ** |
| 97635 | 97812 | ** This opcode is similar to OP_Affinity except that this opcode |
| 97636 | 97813 | ** forces the register type to the Table column type. This is used |
| 97637 | 97814 | ** to implement "strict affinity". |
| 97638 | 97815 | ** |
| @@ -97643,30 +97820,42 @@ | ||
| 97643 | 97820 | ** |
| 97644 | 97821 | ** Preconditions: |
| 97645 | 97822 | ** |
| 97646 | 97823 | ** <ul> |
| 97647 | 97824 | ** <li> P2 should be the number of non-virtual columns in the |
| 97648 | -** table of P4. | |
| 97649 | -** <li> Table P4 should be a STRICT table. | |
| 97825 | +** table of P4 unless P3>1, in which case P2 will be 1. | |
| 97826 | +** <li> Table P4 is a STRICT table. | |
| 97650 | 97827 | ** </ul> |
| 97651 | 97828 | ** |
| 97652 | 97829 | ** If any precondition is false, an assertion fault occurs. |
| 97653 | 97830 | */ |
| 97654 | 97831 | case OP_TypeCheck: { |
| 97655 | 97832 | Table *pTab; |
| 97656 | 97833 | Column *aCol; |
| 97657 | 97834 | int i; |
| 97835 | + int nCol; | |
| 97658 | 97836 | |
| 97659 | 97837 | assert( pOp->p4type==P4_TABLE ); |
| 97660 | 97838 | pTab = pOp->p4.pTab; |
| 97661 | 97839 | assert( pTab->tabFlags & TF_Strict ); |
| 97662 | - assert( pTab->nNVCol==pOp->p2 ); | |
| 97840 | + assert( pOp->p3>=0 && pOp->p3<pTab->nCol+2 ); | |
| 97663 | 97841 | aCol = pTab->aCol; |
| 97664 | 97842 | pIn1 = &aMem[pOp->p1]; |
| 97665 | - for(i=0; i<pTab->nCol; i++){ | |
| 97666 | - if( aCol[i].colFlags & COLFLAG_GENERATED ){ | |
| 97667 | - if( aCol[i].colFlags & COLFLAG_VIRTUAL ) continue; | |
| 97843 | + if( pOp->p3<2 ){ | |
| 97844 | + assert( pTab->nNVCol==pOp->p2 ); | |
| 97845 | + i = 0; | |
| 97846 | + nCol = pTab->nCol; | |
| 97847 | + }else{ | |
| 97848 | + i = pOp->p3-2; | |
| 97849 | + nCol = i+1; | |
| 97850 | + assert( i<pTab->nCol ); | |
| 97851 | + assert( aCol[i].colFlags & COLFLAG_VIRTUAL ); | |
| 97852 | + assert( pOp->p2==1 ); | |
| 97853 | + } | |
| 97854 | + for(; i<nCol; i++){ | |
| 97855 | + if( (aCol[i].colFlags & COLFLAG_GENERATED)!=0 && pOp->p3<2 ){ | |
| 97856 | + if( (aCol[i].colFlags & COLFLAG_VIRTUAL)!=0 ) continue; | |
| 97668 | 97857 | if( pOp->p3 ){ pIn1++; continue; } |
| 97669 | 97858 | } |
| 97670 | 97859 | assert( pIn1 < &aMem[pOp->p1+pOp->p2] ); |
| 97671 | 97860 | applyAffinity(pIn1, aCol[i].affinity, encoding); |
| 97672 | 97861 | if( (pIn1->flags & MEM_Null)==0 ){ |
| @@ -98103,10 +98292,11 @@ | ||
| 98103 | 98292 | } |
| 98104 | 98293 | }else{ |
| 98105 | 98294 | zHdr += sqlite3PutVarint(zHdr, serial_type); |
| 98106 | 98295 | if( pRec->n ){ |
| 98107 | 98296 | assert( pRec->z!=0 ); |
| 98297 | + assert( pRec->z!=(const char*)sqlite3CtypeMap ); | |
| 98108 | 98298 | memcpy(zPayload, pRec->z, pRec->n); |
| 98109 | 98299 | zPayload += pRec->n; |
| 98110 | 98300 | } |
| 98111 | 98301 | } |
| 98112 | 98302 | if( pRec==pLast ) break; |
| @@ -99740,11 +99930,11 @@ | ||
| 99740 | 99930 | rc = ExpandBlob(r.aMem); |
| 99741 | 99931 | assert( rc==SQLITE_OK || rc==SQLITE_NOMEM ); |
| 99742 | 99932 | if( rc ) goto no_mem; |
| 99743 | 99933 | pIdxKey = sqlite3VdbeAllocUnpackedRecord(pC->pKeyInfo); |
| 99744 | 99934 | if( pIdxKey==0 ) goto no_mem; |
| 99745 | - sqlite3VdbeRecordUnpack(pC->pKeyInfo, r.aMem->n, r.aMem->z, pIdxKey); | |
| 99935 | + sqlite3VdbeRecordUnpack(r.aMem->n, r.aMem->z, pIdxKey); | |
| 99746 | 99936 | pIdxKey->default_rc = 0; |
| 99747 | 99937 | rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &pC->seekResult); |
| 99748 | 99938 | sqlite3DbFreeNN(db, pIdxKey); |
| 99749 | 99939 | } |
| 99750 | 99940 | if( rc!=SQLITE_OK ){ |
| @@ -100737,10 +100927,36 @@ | ||
| 100737 | 100927 | VdbeBranchTaken(res!=0,2); |
| 100738 | 100928 | if( res ) goto jump_to_p2; |
| 100739 | 100929 | } |
| 100740 | 100930 | break; |
| 100741 | 100931 | } |
| 100932 | + | |
| 100933 | +/* Opcode: IfEmpty P1 P2 * * * | |
| 100934 | +** Synopsis: if( empty(P1) ) goto P2 | |
| 100935 | +** | |
| 100936 | +** Check to see if the b-tree table that cursor P1 references is empty | |
| 100937 | +** and jump to P2 if it is. | |
| 100938 | +*/ | |
| 100939 | +case OP_IfEmpty: { /* jump */ | |
| 100940 | + VdbeCursor *pC; | |
| 100941 | + BtCursor *pCrsr; | |
| 100942 | + int res; | |
| 100943 | + | |
| 100944 | + assert( pOp->p1>=0 && pOp->p1<p->nCursor ); | |
| 100945 | + assert( pOp->p2>=0 && pOp->p2<p->nOp ); | |
| 100946 | + | |
| 100947 | + pC = p->apCsr[pOp->p1]; | |
| 100948 | + assert( pC!=0 ); | |
| 100949 | + assert( pC->eCurType==CURTYPE_BTREE ); | |
| 100950 | + pCrsr = pC->uc.pCursor; | |
| 100951 | + assert( pCrsr ); | |
| 100952 | + rc = sqlite3BtreeIsEmpty(pCrsr, &res); | |
| 100953 | + if( rc ) goto abort_due_to_error; | |
| 100954 | + VdbeBranchTaken(res!=0,2); | |
| 100955 | + if( res ) goto jump_to_p2; | |
| 100956 | + break; | |
| 100957 | +} | |
| 100742 | 100958 | |
| 100743 | 100959 | /* Opcode: Next P1 P2 P3 * P5 |
| 100744 | 100960 | ** |
| 100745 | 100961 | ** Advance cursor P1 so that it points to the next key/data pair in its |
| 100746 | 100962 | ** table or index. If there are no more key/value pairs then fall through |
| @@ -102609,11 +102825,18 @@ | ||
| 102609 | 102825 | sqlite3_vtab_cursor *pVCur; |
| 102610 | 102826 | sqlite3_vtab *pVtab; |
| 102611 | 102827 | const sqlite3_module *pModule; |
| 102612 | 102828 | |
| 102613 | 102829 | assert( p->bIsReader ); |
| 102614 | - pCur = 0; | |
| 102830 | + pCur = p->apCsr[pOp->p1]; | |
| 102831 | + if( pCur!=0 | |
| 102832 | + && ALWAYS( pCur->eCurType==CURTYPE_VTAB ) | |
| 102833 | + && ALWAYS( pCur->uc.pVCur->pVtab==pOp->p4.pVtab->pVtab ) | |
| 102834 | + ){ | |
| 102835 | + /* This opcode is a no-op if the cursor is already open */ | |
| 102836 | + break; | |
| 102837 | + } | |
| 102615 | 102838 | pVCur = 0; |
| 102616 | 102839 | pVtab = pOp->p4.pVtab->pVtab; |
| 102617 | 102840 | if( pVtab==0 || NEVER(pVtab->pModule==0) ){ |
| 102618 | 102841 | rc = SQLITE_LOCKED; |
| 102619 | 102842 | goto abort_due_to_error; |
| @@ -103551,12 +103774,11 @@ | ||
| 103551 | 103774 | sqlite3VdbeError(p, "%s", sqlite3ErrStr(rc)); |
| 103552 | 103775 | } |
| 103553 | 103776 | p->rc = rc; |
| 103554 | 103777 | sqlite3SystemError(db, rc); |
| 103555 | 103778 | testcase( sqlite3GlobalConfig.xLog!=0 ); |
| 103556 | - sqlite3_log(rc, "statement aborts at %d: [%s] %s", | |
| 103557 | - (int)(pOp - aOp), p->zSql, p->zErrMsg); | |
| 103779 | + sqlite3VdbeLogAbort(p, rc, pOp, aOp); | |
| 103558 | 103780 | if( p->eVdbeState==VDBE_RUN_STATE ) sqlite3VdbeHalt(p); |
| 103559 | 103781 | if( rc==SQLITE_IOERR_NOMEM ) sqlite3OomFault(db); |
| 103560 | 103782 | if( rc==SQLITE_CORRUPT && db->autoCommit==0 ){ |
| 103561 | 103783 | db->flags |= SQLITE_CorruptRdOnly; |
| 103562 | 103784 | } |
| @@ -104013,11 +104235,11 @@ | ||
| 104013 | 104235 | void *z, |
| 104014 | 104236 | int n, |
| 104015 | 104237 | int iOffset, |
| 104016 | 104238 | int (*xCall)(BtCursor*, u32, u32, void*) |
| 104017 | 104239 | ){ |
| 104018 | - int rc; | |
| 104240 | + int rc = SQLITE_OK; | |
| 104019 | 104241 | Incrblob *p = (Incrblob *)pBlob; |
| 104020 | 104242 | Vdbe *v; |
| 104021 | 104243 | sqlite3 *db; |
| 104022 | 104244 | |
| 104023 | 104245 | if( p==0 ) return SQLITE_MISUSE_BKPT; |
| @@ -104053,21 +104275,36 @@ | ||
| 104053 | 104275 | ** same way as an SQLITE_DELETE (the SQLITE_DELETE code is actually |
| 104054 | 104276 | ** slightly more efficient). Since you cannot write to a PK column |
| 104055 | 104277 | ** using the incremental-blob API, this works. For the sessions module |
| 104056 | 104278 | ** anyhow. |
| 104057 | 104279 | */ |
| 104058 | - sqlite3_int64 iKey; | |
| 104059 | - iKey = sqlite3BtreeIntegerKey(p->pCsr); | |
| 104060 | - assert( v->apCsr[0]!=0 ); | |
| 104061 | - assert( v->apCsr[0]->eCurType==CURTYPE_BTREE ); | |
| 104062 | - sqlite3VdbePreUpdateHook( | |
| 104063 | - v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol | |
| 104064 | - ); | |
| 104065 | - } | |
| 104066 | -#endif | |
| 104067 | - | |
| 104280 | + if( sqlite3BtreeCursorIsValidNN(p->pCsr)==0 ){ | |
| 104281 | + /* If the cursor is not currently valid, try to reseek it. This | |
| 104282 | + ** always either fails or finds the correct row - the cursor will | |
| 104283 | + ** have been marked permanently CURSOR_INVALID if the open row has | |
| 104284 | + ** been deleted. */ | |
| 104285 | + int bDiff = 0; | |
| 104286 | + rc = sqlite3BtreeCursorRestore(p->pCsr, &bDiff); | |
| 104287 | + assert( bDiff==0 || sqlite3BtreeCursorIsValidNN(p->pCsr)==0 ); | |
| 104288 | + } | |
| 104289 | + if( sqlite3BtreeCursorIsValidNN(p->pCsr) ){ | |
| 104290 | + sqlite3_int64 iKey; | |
| 104291 | + iKey = sqlite3BtreeIntegerKey(p->pCsr); | |
| 104292 | + assert( v->apCsr[0]!=0 ); | |
| 104293 | + assert( v->apCsr[0]->eCurType==CURTYPE_BTREE ); | |
| 104294 | + sqlite3VdbePreUpdateHook( | |
| 104295 | + v, v->apCsr[0], SQLITE_DELETE, p->zDb, p->pTab, iKey, -1, p->iCol | |
| 104296 | + ); | |
| 104297 | + } | |
| 104298 | + } | |
| 104299 | + if( rc==SQLITE_OK ){ | |
| 104300 | + rc = xCall(p->pCsr, iOffset+p->iOffset, n, z); | |
| 104301 | + } | |
| 104302 | +#else | |
| 104068 | 104303 | rc = xCall(p->pCsr, iOffset+p->iOffset, n, z); |
| 104304 | +#endif | |
| 104305 | + | |
| 104069 | 104306 | sqlite3BtreeLeaveCursor(p->pCsr); |
| 104070 | 104307 | if( rc==SQLITE_ABORT ){ |
| 104071 | 104308 | sqlite3VdbeFinalize(v); |
| 104072 | 104309 | p->pStmt = 0; |
| 104073 | 104310 | }else{ |
| @@ -104916,11 +105153,11 @@ | ||
| 104916 | 105153 | const void *pKey1, int nKey1, /* Left side of comparison */ |
| 104917 | 105154 | const void *pKey2, int nKey2 /* Right side of comparison */ |
| 104918 | 105155 | ){ |
| 104919 | 105156 | UnpackedRecord *r2 = pTask->pUnpacked; |
| 104920 | 105157 | if( *pbKey2Cached==0 ){ |
| 104921 | - sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2); | |
| 105158 | + sqlite3VdbeRecordUnpack(nKey2, pKey2, r2); | |
| 104922 | 105159 | *pbKey2Cached = 1; |
| 104923 | 105160 | } |
| 104924 | 105161 | return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1); |
| 104925 | 105162 | } |
| 104926 | 105163 | |
| @@ -104943,11 +105180,11 @@ | ||
| 104943 | 105180 | const void *pKey1, int nKey1, /* Left side of comparison */ |
| 104944 | 105181 | const void *pKey2, int nKey2 /* Right side of comparison */ |
| 104945 | 105182 | ){ |
| 104946 | 105183 | UnpackedRecord *r2 = pTask->pUnpacked; |
| 104947 | 105184 | if( !*pbKey2Cached ){ |
| 104948 | - sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2); | |
| 105185 | + sqlite3VdbeRecordUnpack(nKey2, pKey2, r2); | |
| 104949 | 105186 | *pbKey2Cached = 1; |
| 104950 | 105187 | } |
| 104951 | 105188 | return sqlite3VdbeRecordCompare(nKey1, pKey1, r2); |
| 104952 | 105189 | } |
| 104953 | 105190 | |
| @@ -104983,10 +105220,11 @@ | ||
| 104983 | 105220 | res = vdbeSorterCompareTail( |
| 104984 | 105221 | pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2 |
| 104985 | 105222 | ); |
| 104986 | 105223 | } |
| 104987 | 105224 | }else{ |
| 105225 | + assert( pTask->pSorter->pKeyInfo->aSortFlags!=0 ); | |
| 104988 | 105226 | assert( !(pTask->pSorter->pKeyInfo->aSortFlags[0]&KEYINFO_ORDER_BIGNULL) ); |
| 104989 | 105227 | if( pTask->pSorter->pKeyInfo->aSortFlags[0] ){ |
| 104990 | 105228 | res = res * -1; |
| 104991 | 105229 | } |
| 104992 | 105230 | } |
| @@ -105046,10 +105284,11 @@ | ||
| 105046 | 105284 | }else{ |
| 105047 | 105285 | if( *v2 & 0x80 ) res = +1; |
| 105048 | 105286 | } |
| 105049 | 105287 | } |
| 105050 | 105288 | |
| 105289 | + assert( pTask->pSorter->pKeyInfo->aSortFlags!=0 ); | |
| 105051 | 105290 | if( res==0 ){ |
| 105052 | 105291 | if( pTask->pSorter->pKeyInfo->nKeyField>1 ){ |
| 105053 | 105292 | res = vdbeSorterCompareTail( |
| 105054 | 105293 | pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2 |
| 105055 | 105294 | ); |
| @@ -105119,11 +105358,12 @@ | ||
| 105119 | 105358 | assert( pCsr->pKeyInfo ); |
| 105120 | 105359 | assert( !pCsr->isEphemeral ); |
| 105121 | 105360 | assert( pCsr->eCurType==CURTYPE_SORTER ); |
| 105122 | 105361 | assert( sizeof(KeyInfo) + UMXV(pCsr->pKeyInfo->nKeyField)*sizeof(CollSeq*) |
| 105123 | 105362 | < 0x7fffffff ); |
| 105124 | - szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nKeyField+1); | |
| 105363 | + assert( pCsr->pKeyInfo->nKeyField<=pCsr->pKeyInfo->nAllField ); | |
| 105364 | + szKeyInfo = SZ_KEYINFO(pCsr->pKeyInfo->nAllField); | |
| 105125 | 105365 | sz = SZ_VDBESORTER(nWorker+1); |
| 105126 | 105366 | |
| 105127 | 105367 | pSorter = (VdbeSorter*)sqlite3DbMallocZero(db, sz + szKeyInfo); |
| 105128 | 105368 | pCsr->uc.pSorter = pSorter; |
| 105129 | 105369 | if( pSorter==0 ){ |
| @@ -105133,11 +105373,16 @@ | ||
| 105133 | 105373 | pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz); |
| 105134 | 105374 | memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo); |
| 105135 | 105375 | pKeyInfo->db = 0; |
| 105136 | 105376 | if( nField && nWorker==0 ){ |
| 105137 | 105377 | pKeyInfo->nKeyField = nField; |
| 105378 | + assert( nField<=pCsr->pKeyInfo->nAllField ); | |
| 105138 | 105379 | } |
| 105380 | + /* It is OK that pKeyInfo reuses the aSortFlags field from pCsr->pKeyInfo, | |
| 105381 | + ** since the pCsr->pKeyInfo->aSortFlags[] array is invariant and lives | |
| 105382 | + ** longer that pSorter. */ | |
| 105383 | + assert( pKeyInfo->aSortFlags==pCsr->pKeyInfo->aSortFlags ); | |
| 105139 | 105384 | sqlite3BtreeEnter(pBt); |
| 105140 | 105385 | pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(pBt); |
| 105141 | 105386 | sqlite3BtreeLeave(pBt); |
| 105142 | 105387 | pSorter->nTask = nWorker + 1; |
| 105143 | 105388 | pSorter->iPrev = (u8)(nWorker - 1); |
| @@ -106913,11 +107158,11 @@ | ||
| 106913 | 107158 | r2->nField = nKeyCol; |
| 106914 | 107159 | } |
| 106915 | 107160 | assert( r2->nField==nKeyCol ); |
| 106916 | 107161 | |
| 106917 | 107162 | pKey = vdbeSorterRowkey(pSorter, &nKey); |
| 106918 | - sqlite3VdbeRecordUnpack(pKeyInfo, nKey, pKey, r2); | |
| 107163 | + sqlite3VdbeRecordUnpack(nKey, pKey, r2); | |
| 106919 | 107164 | for(i=0; i<nKeyCol; i++){ |
| 106920 | 107165 | if( r2->aMem[i].flags & MEM_Null ){ |
| 106921 | 107166 | *pRes = -1; |
| 106922 | 107167 | return SQLITE_OK; |
| 106923 | 107168 | } |
| @@ -109287,17 +109532,16 @@ | ||
| 109287 | 109532 | /* Clearly non-deterministic functions like random(), but also |
| 109288 | 109533 | ** date/time functions that use 'now', and other functions like |
| 109289 | 109534 | ** sqlite_version() that might change over time cannot be used |
| 109290 | 109535 | ** in an index or generated column. Curiously, they can be used |
| 109291 | 109536 | ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all |
| 109292 | - ** all this. */ | |
| 109537 | + ** allow this. */ | |
| 109293 | 109538 | sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions", |
| 109294 | 109539 | NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr); |
| 109295 | 109540 | }else{ |
| 109296 | 109541 | assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */ |
| 109297 | 109542 | pExpr->op2 = pNC->ncFlags & NC_SelfRef; |
| 109298 | - if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL); | |
| 109299 | 109543 | } |
| 109300 | 109544 | if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0 |
| 109301 | 109545 | && pParse->nested==0 |
| 109302 | 109546 | && (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0 |
| 109303 | 109547 | ){ |
| @@ -109309,10 +109553,11 @@ | ||
| 109309 | 109553 | pDef = 0; |
| 109310 | 109554 | }else |
| 109311 | 109555 | if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0 |
| 109312 | 109556 | && !IN_RENAME_OBJECT |
| 109313 | 109557 | ){ |
| 109558 | + if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL); | |
| 109314 | 109559 | sqlite3ExprFunctionUsable(pParse, pExpr, pDef); |
| 109315 | 109560 | } |
| 109316 | 109561 | } |
| 109317 | 109562 | |
| 109318 | 109563 | if( 0==IN_RENAME_OBJECT ){ |
| @@ -109443,22 +109688,25 @@ | ||
| 109443 | 109688 | ** type of the function |
| 109444 | 109689 | */ |
| 109445 | 109690 | return WRC_Prune; |
| 109446 | 109691 | } |
| 109447 | 109692 | #ifndef SQLITE_OMIT_SUBQUERY |
| 109693 | + case TK_EXISTS: | |
| 109448 | 109694 | case TK_SELECT: |
| 109449 | - case TK_EXISTS: testcase( pExpr->op==TK_EXISTS ); | |
| 109450 | 109695 | #endif |
| 109451 | 109696 | case TK_IN: { |
| 109452 | 109697 | testcase( pExpr->op==TK_IN ); |
| 109698 | + testcase( pExpr->op==TK_EXISTS ); | |
| 109699 | + testcase( pExpr->op==TK_SELECT ); | |
| 109453 | 109700 | if( ExprUseXSelect(pExpr) ){ |
| 109454 | 109701 | int nRef = pNC->nRef; |
| 109455 | 109702 | testcase( pNC->ncFlags & NC_IsCheck ); |
| 109456 | 109703 | testcase( pNC->ncFlags & NC_PartIdx ); |
| 109457 | 109704 | testcase( pNC->ncFlags & NC_IdxExpr ); |
| 109458 | 109705 | testcase( pNC->ncFlags & NC_GenCol ); |
| 109459 | 109706 | assert( pExpr->x.pSelect ); |
| 109707 | + if( pExpr->op==TK_EXISTS ) pParse->bHasExists = 1; | |
| 109460 | 109708 | if( pNC->ncFlags & NC_SelfRef ){ |
| 109461 | 109709 | notValidImpl(pParse, pNC, "subqueries", pExpr, pExpr); |
| 109462 | 109710 | }else{ |
| 109463 | 109711 | sqlite3WalkSelect(pWalker, pExpr->x.pSelect); |
| 109464 | 109712 | } |
| @@ -110469,11 +110717,13 @@ | ||
| 110469 | 110717 | assert( pExpr->iTable==pExpr->pLeft->x.pSelect->pEList->nExpr ); |
| 110470 | 110718 | return sqlite3ExprAffinity( |
| 110471 | 110719 | pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr |
| 110472 | 110720 | ); |
| 110473 | 110721 | } |
| 110474 | - if( op==TK_VECTOR ){ | |
| 110722 | + if( op==TK_VECTOR | |
| 110723 | + || (op==TK_FUNCTION && pExpr->affExpr==SQLITE_AFF_DEFER) | |
| 110724 | + ){ | |
| 110475 | 110725 | assert( ExprUseXList(pExpr) ); |
| 110476 | 110726 | return sqlite3ExprAffinity(pExpr->x.pList->a[0].pExpr); |
| 110477 | 110727 | } |
| 110478 | 110728 | if( ExprHasProperty(pExpr, EP_Skip|EP_IfNullRow) ){ |
| 110479 | 110729 | assert( pExpr->op==TK_COLLATE |
| @@ -110662,11 +110912,13 @@ | ||
| 110662 | 110912 | } |
| 110663 | 110913 | if( op==TK_CAST || op==TK_UPLUS ){ |
| 110664 | 110914 | p = p->pLeft; |
| 110665 | 110915 | continue; |
| 110666 | 110916 | } |
| 110667 | - if( op==TK_VECTOR ){ | |
| 110917 | + if( op==TK_VECTOR | |
| 110918 | + || (op==TK_FUNCTION && p->affExpr==SQLITE_AFF_DEFER) | |
| 110919 | + ){ | |
| 110668 | 110920 | assert( ExprUseXList(p) ); |
| 110669 | 110921 | p = p->x.pList->a[0].pExpr; |
| 110670 | 110922 | continue; |
| 110671 | 110923 | } |
| 110672 | 110924 | if( op==TK_COLLATE ){ |
| @@ -111536,11 +111788,11 @@ | ||
| 111536 | 111788 | return pRight; |
| 111537 | 111789 | }else if( pRight==0 ){ |
| 111538 | 111790 | return pLeft; |
| 111539 | 111791 | }else{ |
| 111540 | 111792 | u32 f = pLeft->flags | pRight->flags; |
| 111541 | - if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse))==EP_IsFalse | |
| 111793 | + if( (f&(EP_OuterON|EP_InnerON|EP_IsFalse|EP_HasFunc))==EP_IsFalse | |
| 111542 | 111794 | && !IN_RENAME_OBJECT |
| 111543 | 111795 | ){ |
| 111544 | 111796 | sqlite3ExprDeferredDelete(pParse, pLeft); |
| 111545 | 111797 | sqlite3ExprDeferredDelete(pParse, pRight); |
| 111546 | 111798 | return sqlite3Expr(db, TK_INTEGER, "0"); |
| @@ -112764,10 +113016,90 @@ | ||
| 112764 | 113016 | pExpr = pExpr->op==TK_AND ? pLeft : pRight; |
| 112765 | 113017 | } |
| 112766 | 113018 | } |
| 112767 | 113019 | return pExpr; |
| 112768 | 113020 | } |
| 113021 | + | |
| 113022 | +/* | |
| 113023 | +** Return true if it might be advantageous to compute the right operand | |
| 113024 | +** of expression pExpr first, before the left operand. | |
| 113025 | +** | |
| 113026 | +** Normally the left operand is computed before the right operand. But if | |
| 113027 | +** the left operand contains a subquery and the right does not, then it | |
| 113028 | +** might be more efficient to compute the right operand first. | |
| 113029 | +*/ | |
| 113030 | +static int exprEvalRhsFirst(Expr *pExpr){ | |
| 113031 | + if( ExprHasProperty(pExpr->pLeft, EP_Subquery) | |
| 113032 | + && !ExprHasProperty(pExpr->pRight, EP_Subquery) | |
| 113033 | + ){ | |
| 113034 | + return 1; | |
| 113035 | + }else{ | |
| 113036 | + return 0; | |
| 113037 | + } | |
| 113038 | +} | |
| 113039 | + | |
| 113040 | +/* | |
| 113041 | +** Compute the two operands of a binary operator. | |
| 113042 | +** | |
| 113043 | +** If either operand contains a subquery, then the code strives to | |
| 113044 | +** compute the operand containing the subquery second. If the other | |
| 113045 | +** operand evalutes to NULL, then a jump is made. The address of the | |
| 113046 | +** IsNull operand that does this jump is returned. The caller can use | |
| 113047 | +** this to optimize the computation so as to avoid doing the potentially | |
| 113048 | +** expensive subquery. | |
| 113049 | +** | |
| 113050 | +** If no optimization opportunities exist, return 0. | |
| 113051 | +*/ | |
| 113052 | +static int exprComputeOperands( | |
| 113053 | + Parse *pParse, /* Parsing context */ | |
| 113054 | + Expr *pExpr, /* The comparison expression */ | |
| 113055 | + int *pR1, /* OUT: Register holding the left operand */ | |
| 113056 | + int *pR2, /* OUT: Register holding the right operand */ | |
| 113057 | + int *pFree1, /* OUT: Temp register to free if not zero */ | |
| 113058 | + int *pFree2 /* OUT: Another temp register to free if not zero */ | |
| 113059 | +){ | |
| 113060 | + int addrIsNull; | |
| 113061 | + int r1, r2; | |
| 113062 | + Vdbe *v = pParse->pVdbe; | |
| 113063 | + | |
| 113064 | + assert( v!=0 ); | |
| 113065 | + /* | |
| 113066 | + ** If the left operand contains a (possibly expensive) subquery and the | |
| 113067 | + ** right operand does not and the right operation might be NULL, | |
| 113068 | + ** then compute the right operand first and do an IsNull jump if the | |
| 113069 | + ** right operand evalutes to NULL. | |
| 113070 | + */ | |
| 113071 | + if( exprEvalRhsFirst(pExpr) && sqlite3ExprCanBeNull(pExpr->pRight) ){ | |
| 113072 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2); | |
| 113073 | + addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r2); | |
| 113074 | + VdbeComment((v, "skip left operand")); | |
| 113075 | + VdbeCoverage(v); | |
| 113076 | + }else{ | |
| 113077 | + r2 = 0; /* Silence a false-positive uninit-var warning in MSVC */ | |
| 113078 | + addrIsNull = 0; | |
| 113079 | + } | |
| 113080 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, pFree1); | |
| 113081 | + if( addrIsNull==0 ){ | |
| 113082 | + /* | |
| 113083 | + ** If the right operand contains a subquery and the left operand does not | |
| 113084 | + ** and the left operand might be NULL, then check the left operand do | |
| 113085 | + ** an IsNull check on the left operand before computing the right | |
| 113086 | + ** operand. | |
| 113087 | + */ | |
| 113088 | + if( ExprHasProperty(pExpr->pRight, EP_Subquery) | |
| 113089 | + && sqlite3ExprCanBeNull(pExpr->pLeft) | |
| 113090 | + ){ | |
| 113091 | + addrIsNull = sqlite3VdbeAddOp1(v, OP_IsNull, r1); | |
| 113092 | + VdbeComment((v, "skip right operand")); | |
| 113093 | + VdbeCoverage(v); | |
| 113094 | + } | |
| 113095 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, pFree2); | |
| 113096 | + } | |
| 113097 | + *pR1 = r1; | |
| 113098 | + *pR2 = r2; | |
| 113099 | + return addrIsNull; | |
| 113100 | +} | |
| 112769 | 113101 | |
| 112770 | 113102 | /* |
| 112771 | 113103 | ** pExpr is a TK_FUNCTION node. Try to determine whether or not the |
| 112772 | 113104 | ** function is a constant function. A function is constant if all of |
| 112773 | 113105 | ** the following are true: |
| @@ -114022,15 +114354,16 @@ | ||
| 114022 | 114354 | pCopy = sqlite3SelectDup(pParse->db, pSelect, 0); |
| 114023 | 114355 | rc = pParse->db->mallocFailed ? 1 :sqlite3Select(pParse, pCopy, &dest); |
| 114024 | 114356 | sqlite3SelectDelete(pParse->db, pCopy); |
| 114025 | 114357 | sqlite3DbFree(pParse->db, dest.zAffSdst); |
| 114026 | 114358 | if( addrBloom ){ |
| 114359 | + /* Remember that location of the Bloom filter in the P3 operand | |
| 114360 | + ** of the OP_Once that began this subroutine. tag-202407032019 */ | |
| 114027 | 114361 | sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; |
| 114028 | 114362 | if( dest.iSDParm2==0 ){ |
| 114029 | - sqlite3VdbeChangeToNoop(v, addrBloom); | |
| 114030 | - }else{ | |
| 114031 | - sqlite3VdbeGetOp(v, addrOnce)->p3 = dest.iSDParm2; | |
| 114363 | + /* If the Bloom filter won't actually be used, keep it small */ | |
| 114364 | + sqlite3VdbeGetOp(v, addrBloom)->p1 = 10; | |
| 114032 | 114365 | } |
| 114033 | 114366 | } |
| 114034 | 114367 | if( rc ){ |
| 114035 | 114368 | sqlite3KeyInfoUnref(pKeyInfo); |
| 114036 | 114369 | return; |
| @@ -114208,21 +114541,27 @@ | ||
| 114208 | 114541 | dest.eDest = SRT_Exists; |
| 114209 | 114542 | sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm); |
| 114210 | 114543 | VdbeComment((v, "Init EXISTS result")); |
| 114211 | 114544 | } |
| 114212 | 114545 | if( pSel->pLimit ){ |
| 114213 | - /* The subquery already has a limit. If the pre-existing limit is X | |
| 114214 | - ** then make the new limit X<>0 so that the new limit is either 1 or 0 */ | |
| 114215 | - sqlite3 *db = pParse->db; | |
| 114216 | - pLimit = sqlite3Expr(db, TK_INTEGER, "0"); | |
| 114217 | - if( pLimit ){ | |
| 114218 | - pLimit->affExpr = SQLITE_AFF_NUMERIC; | |
| 114219 | - pLimit = sqlite3PExpr(pParse, TK_NE, | |
| 114220 | - sqlite3ExprDup(db, pSel->pLimit->pLeft, 0), pLimit); | |
| 114221 | - } | |
| 114222 | - sqlite3ExprDeferredDelete(pParse, pSel->pLimit->pLeft); | |
| 114223 | - pSel->pLimit->pLeft = pLimit; | |
| 114546 | + /* The subquery already has a limit. If the pre-existing limit X is | |
| 114547 | + ** not already integer value 1 or 0, then make the new limit X<>0 so that | |
| 114548 | + ** the new limit is either 1 or 0 */ | |
| 114549 | + Expr *pLeft = pSel->pLimit->pLeft; | |
| 114550 | + if( ExprHasProperty(pLeft, EP_IntValue)==0 | |
| 114551 | + || (pLeft->u.iValue!=1 && pLeft->u.iValue!=0) | |
| 114552 | + ){ | |
| 114553 | + sqlite3 *db = pParse->db; | |
| 114554 | + pLimit = sqlite3Expr(db, TK_INTEGER, "0"); | |
| 114555 | + if( pLimit ){ | |
| 114556 | + pLimit->affExpr = SQLITE_AFF_NUMERIC; | |
| 114557 | + pLimit = sqlite3PExpr(pParse, TK_NE, | |
| 114558 | + sqlite3ExprDup(db, pLeft, 0), pLimit); | |
| 114559 | + } | |
| 114560 | + sqlite3ExprDeferredDelete(pParse, pLeft); | |
| 114561 | + pSel->pLimit->pLeft = pLimit; | |
| 114562 | + } | |
| 114224 | 114563 | }else{ |
| 114225 | 114564 | /* If there is no pre-existing limit add a limit of 1 */ |
| 114226 | 114565 | pLimit = sqlite3Expr(pParse->db, TK_INTEGER, "1"); |
| 114227 | 114566 | pSel->pLimit = sqlite3PExpr(pParse, TK_LIMIT, pLimit, 0); |
| 114228 | 114567 | } |
| @@ -114473,11 +114812,11 @@ | ||
| 114473 | 114812 | if( destIfFalse==destIfNull ){ |
| 114474 | 114813 | /* Combine Step 3 and Step 5 into a single opcode */ |
| 114475 | 114814 | if( ExprHasProperty(pExpr, EP_Subrtn) ){ |
| 114476 | 114815 | const VdbeOp *pOp = sqlite3VdbeGetOp(v, pExpr->y.sub.iAddr); |
| 114477 | 114816 | assert( pOp->opcode==OP_Once || pParse->nErr ); |
| 114478 | - if( pOp->opcode==OP_Once && pOp->p3>0 ){ | |
| 114817 | + if( pOp->opcode==OP_Once && pOp->p3>0 ){ /* tag-202407032019 */ | |
| 114479 | 114818 | assert( OptimizationEnabled(pParse->db, SQLITE_BloomFilter) ); |
| 114480 | 114819 | sqlite3VdbeAddOp4Int(v, OP_Filter, pOp->p3, destIfFalse, |
| 114481 | 114820 | rLhs, nVector); VdbeCoverage(v); |
| 114482 | 114821 | } |
| 114483 | 114822 | } |
| @@ -114660,11 +114999,16 @@ | ||
| 114660 | 114999 | iAddr = sqlite3VdbeAddOp3(v, OP_IfNullRow, pParse->iSelfTab-1, 0, regOut); |
| 114661 | 115000 | }else{ |
| 114662 | 115001 | iAddr = 0; |
| 114663 | 115002 | } |
| 114664 | 115003 | sqlite3ExprCodeCopy(pParse, sqlite3ColumnExpr(pTab,pCol), regOut); |
| 114665 | - if( pCol->affinity>=SQLITE_AFF_TEXT ){ | |
| 115004 | + if( (pCol->colFlags & COLFLAG_VIRTUAL)!=0 | |
| 115005 | + && (pTab->tabFlags & TF_Strict)!=0 | |
| 115006 | + ){ | |
| 115007 | + int p3 = 2+(int)(pCol - pTab->aCol); | |
| 115008 | + sqlite3VdbeAddOp4(v, OP_TypeCheck, regOut, 1, p3, (char*)pTab, P4_TABLE); | |
| 115009 | + }else if( pCol->affinity>=SQLITE_AFF_TEXT ){ | |
| 114666 | 115010 | sqlite3VdbeAddOp4(v, OP_Affinity, regOut, 1, 0, &pCol->affinity, 1); |
| 114667 | 115011 | } |
| 114668 | 115012 | if( iAddr ) sqlite3VdbeJumpHere(v, iAddr); |
| 114669 | 115013 | if( pParse->nErr>nErr ) pParse->db->errByteOffset = -1; |
| 114670 | 115014 | } |
| @@ -115347,15 +115691,21 @@ | ||
| 115347 | 115691 | case TK_GT: |
| 115348 | 115692 | case TK_GE: |
| 115349 | 115693 | case TK_NE: |
| 115350 | 115694 | case TK_EQ: { |
| 115351 | 115695 | Expr *pLeft = pExpr->pLeft; |
| 115696 | + int addrIsNull = 0; | |
| 115352 | 115697 | if( sqlite3ExprIsVector(pLeft) ){ |
| 115353 | 115698 | codeVectorCompare(pParse, pExpr, target, op, p5); |
| 115354 | 115699 | }else{ |
| 115355 | - r1 = sqlite3ExprCodeTemp(pParse, pLeft, ®Free1); | |
| 115356 | - r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 115700 | + if( ExprHasProperty(pExpr, EP_Subquery) && p5!=SQLITE_NULLEQ ){ | |
| 115701 | + addrIsNull = exprComputeOperands(pParse, pExpr, | |
| 115702 | + &r1, &r2, ®Free1, ®Free2); | |
| 115703 | + }else{ | |
| 115704 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 115705 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 115706 | + } | |
| 115357 | 115707 | sqlite3VdbeAddOp2(v, OP_Integer, 1, inReg); |
| 115358 | 115708 | codeCompare(pParse, pLeft, pExpr->pRight, op, r1, r2, |
| 115359 | 115709 | sqlite3VdbeCurrentAddr(v)+2, p5, |
| 115360 | 115710 | ExprHasProperty(pExpr,EP_Commuted)); |
| 115361 | 115711 | assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| @@ -115366,13 +115716,19 @@ | ||
| 115366 | 115716 | assert(TK_NE==OP_Ne); testcase(op==OP_Ne); VdbeCoverageIf(v,op==OP_Ne); |
| 115367 | 115717 | if( p5==SQLITE_NULLEQ ){ |
| 115368 | 115718 | sqlite3VdbeAddOp2(v, OP_Integer, 0, inReg); |
| 115369 | 115719 | }else{ |
| 115370 | 115720 | sqlite3VdbeAddOp3(v, OP_ZeroOrNull, r1, inReg, r2); |
| 115721 | + if( addrIsNull ){ | |
| 115722 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2); | |
| 115723 | + sqlite3VdbeJumpHere(v, addrIsNull); | |
| 115724 | + sqlite3VdbeAddOp2(v, OP_Null, 0, inReg); | |
| 115725 | + } | |
| 115371 | 115726 | } |
| 115372 | 115727 | testcase( regFree1==0 ); |
| 115373 | 115728 | testcase( regFree2==0 ); |
| 115729 | + | |
| 115374 | 115730 | } |
| 115375 | 115731 | break; |
| 115376 | 115732 | } |
| 115377 | 115733 | case TK_AND: |
| 115378 | 115734 | case TK_OR: |
| @@ -115384,10 +115740,11 @@ | ||
| 115384 | 115740 | case TK_BITOR: |
| 115385 | 115741 | case TK_SLASH: |
| 115386 | 115742 | case TK_LSHIFT: |
| 115387 | 115743 | case TK_RSHIFT: |
| 115388 | 115744 | case TK_CONCAT: { |
| 115745 | + int addrIsNull; | |
| 115389 | 115746 | assert( TK_AND==OP_And ); testcase( op==TK_AND ); |
| 115390 | 115747 | assert( TK_OR==OP_Or ); testcase( op==TK_OR ); |
| 115391 | 115748 | assert( TK_PLUS==OP_Add ); testcase( op==TK_PLUS ); |
| 115392 | 115749 | assert( TK_MINUS==OP_Subtract ); testcase( op==TK_MINUS ); |
| 115393 | 115750 | assert( TK_REM==OP_Remainder ); testcase( op==TK_REM ); |
| @@ -115395,15 +115752,27 @@ | ||
| 115395 | 115752 | assert( TK_BITOR==OP_BitOr ); testcase( op==TK_BITOR ); |
| 115396 | 115753 | assert( TK_SLASH==OP_Divide ); testcase( op==TK_SLASH ); |
| 115397 | 115754 | assert( TK_LSHIFT==OP_ShiftLeft ); testcase( op==TK_LSHIFT ); |
| 115398 | 115755 | assert( TK_RSHIFT==OP_ShiftRight ); testcase( op==TK_RSHIFT ); |
| 115399 | 115756 | assert( TK_CONCAT==OP_Concat ); testcase( op==TK_CONCAT ); |
| 115400 | - r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 115401 | - r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 115757 | + if( ExprHasProperty(pExpr, EP_Subquery) ){ | |
| 115758 | + addrIsNull = exprComputeOperands(pParse, pExpr, | |
| 115759 | + &r1, &r2, ®Free1, ®Free2); | |
| 115760 | + }else{ | |
| 115761 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 115762 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 115763 | + addrIsNull = 0; | |
| 115764 | + } | |
| 115402 | 115765 | sqlite3VdbeAddOp3(v, op, r2, r1, target); |
| 115403 | 115766 | testcase( regFree1==0 ); |
| 115404 | 115767 | testcase( regFree2==0 ); |
| 115768 | + if( addrIsNull ){ | |
| 115769 | + sqlite3VdbeAddOp2(v, OP_Goto, 0, sqlite3VdbeCurrentAddr(v)+2); | |
| 115770 | + sqlite3VdbeJumpHere(v, addrIsNull); | |
| 115771 | + sqlite3VdbeAddOp2(v, OP_Null, 0, target); | |
| 115772 | + VdbeComment((v, "short-circut value")); | |
| 115773 | + } | |
| 115405 | 115774 | break; |
| 115406 | 115775 | } |
| 115407 | 115776 | case TK_UMINUS: { |
| 115408 | 115777 | Expr *pLeft = pExpr->pLeft; |
| 115409 | 115778 | assert( pLeft ); |
| @@ -116248,21 +116617,31 @@ | ||
| 116248 | 116617 | case TK_AND: |
| 116249 | 116618 | case TK_OR: { |
| 116250 | 116619 | Expr *pAlt = sqlite3ExprSimplifiedAndOr(pExpr); |
| 116251 | 116620 | if( pAlt!=pExpr ){ |
| 116252 | 116621 | sqlite3ExprIfTrue(pParse, pAlt, dest, jumpIfNull); |
| 116253 | - }else if( op==TK_AND ){ | |
| 116254 | - int d2 = sqlite3VdbeMakeLabel(pParse); | |
| 116255 | - testcase( jumpIfNull==0 ); | |
| 116256 | - sqlite3ExprIfFalse(pParse, pExpr->pLeft, d2, | |
| 116257 | - jumpIfNull^SQLITE_JUMPIFNULL); | |
| 116258 | - sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull); | |
| 116259 | - sqlite3VdbeResolveLabel(v, d2); | |
| 116260 | 116622 | }else{ |
| 116261 | - testcase( jumpIfNull==0 ); | |
| 116262 | - sqlite3ExprIfTrue(pParse, pExpr->pLeft, dest, jumpIfNull); | |
| 116263 | - sqlite3ExprIfTrue(pParse, pExpr->pRight, dest, jumpIfNull); | |
| 116623 | + Expr *pFirst, *pSecond; | |
| 116624 | + if( exprEvalRhsFirst(pExpr) ){ | |
| 116625 | + pFirst = pExpr->pRight; | |
| 116626 | + pSecond = pExpr->pLeft; | |
| 116627 | + }else{ | |
| 116628 | + pFirst = pExpr->pLeft; | |
| 116629 | + pSecond = pExpr->pRight; | |
| 116630 | + } | |
| 116631 | + if( op==TK_AND ){ | |
| 116632 | + int d2 = sqlite3VdbeMakeLabel(pParse); | |
| 116633 | + testcase( jumpIfNull==0 ); | |
| 116634 | + sqlite3ExprIfFalse(pParse, pFirst, d2, | |
| 116635 | + jumpIfNull^SQLITE_JUMPIFNULL); | |
| 116636 | + sqlite3ExprIfTrue(pParse, pSecond, dest, jumpIfNull); | |
| 116637 | + sqlite3VdbeResolveLabel(v, d2); | |
| 116638 | + }else{ | |
| 116639 | + testcase( jumpIfNull==0 ); | |
| 116640 | + sqlite3ExprIfTrue(pParse, pFirst, dest, jumpIfNull); | |
| 116641 | + sqlite3ExprIfTrue(pParse, pSecond, dest, jumpIfNull); | |
| 116642 | + } | |
| 116264 | 116643 | } |
| 116265 | 116644 | break; |
| 116266 | 116645 | } |
| 116267 | 116646 | case TK_NOT: { |
| 116268 | 116647 | testcase( jumpIfNull==0 ); |
| @@ -116297,14 +116676,20 @@ | ||
| 116297 | 116676 | case TK_LE: |
| 116298 | 116677 | case TK_GT: |
| 116299 | 116678 | case TK_GE: |
| 116300 | 116679 | case TK_NE: |
| 116301 | 116680 | case TK_EQ: { |
| 116681 | + int addrIsNull; | |
| 116302 | 116682 | if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr; |
| 116303 | - testcase( jumpIfNull==0 ); | |
| 116304 | - r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 116305 | - r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 116683 | + if( ExprHasProperty(pExpr, EP_Subquery) && jumpIfNull!=SQLITE_NULLEQ ){ | |
| 116684 | + addrIsNull = exprComputeOperands(pParse, pExpr, | |
| 116685 | + &r1, &r2, ®Free1, ®Free2); | |
| 116686 | + }else{ | |
| 116687 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 116688 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 116689 | + addrIsNull = 0; | |
| 116690 | + } | |
| 116306 | 116691 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 116307 | 116692 | r1, r2, dest, jumpIfNull, ExprHasProperty(pExpr,EP_Commuted)); |
| 116308 | 116693 | assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 116309 | 116694 | assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 116310 | 116695 | assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -116315,22 +116700,29 @@ | ||
| 116315 | 116700 | assert(TK_NE==OP_Ne); testcase(op==OP_Ne); |
| 116316 | 116701 | VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ); |
| 116317 | 116702 | VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ); |
| 116318 | 116703 | testcase( regFree1==0 ); |
| 116319 | 116704 | testcase( regFree2==0 ); |
| 116705 | + if( addrIsNull ){ | |
| 116706 | + if( jumpIfNull ){ | |
| 116707 | + sqlite3VdbeChangeP2(v, addrIsNull, dest); | |
| 116708 | + }else{ | |
| 116709 | + sqlite3VdbeJumpHere(v, addrIsNull); | |
| 116710 | + } | |
| 116711 | + } | |
| 116320 | 116712 | break; |
| 116321 | 116713 | } |
| 116322 | 116714 | case TK_ISNULL: |
| 116323 | 116715 | case TK_NOTNULL: { |
| 116324 | 116716 | assert( TK_ISNULL==OP_IsNull ); testcase( op==TK_ISNULL ); |
| 116325 | 116717 | assert( TK_NOTNULL==OP_NotNull ); testcase( op==TK_NOTNULL ); |
| 116326 | 116718 | r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); |
| 116327 | - sqlite3VdbeTypeofColumn(v, r1); | |
| 116719 | + assert( regFree1==0 || regFree1==r1 ); | |
| 116720 | + if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1); | |
| 116328 | 116721 | sqlite3VdbeAddOp2(v, op, r1, dest); |
| 116329 | 116722 | VdbeCoverageIf(v, op==TK_ISNULL); |
| 116330 | 116723 | VdbeCoverageIf(v, op==TK_NOTNULL); |
| 116331 | - testcase( regFree1==0 ); | |
| 116332 | 116724 | break; |
| 116333 | 116725 | } |
| 116334 | 116726 | case TK_BETWEEN: { |
| 116335 | 116727 | testcase( jumpIfNull==0 ); |
| 116336 | 116728 | exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfTrue, jumpIfNull); |
| @@ -116422,21 +116814,31 @@ | ||
| 116422 | 116814 | case TK_AND: |
| 116423 | 116815 | case TK_OR: { |
| 116424 | 116816 | Expr *pAlt = sqlite3ExprSimplifiedAndOr(pExpr); |
| 116425 | 116817 | if( pAlt!=pExpr ){ |
| 116426 | 116818 | sqlite3ExprIfFalse(pParse, pAlt, dest, jumpIfNull); |
| 116427 | - }else if( pExpr->op==TK_AND ){ | |
| 116428 | - testcase( jumpIfNull==0 ); | |
| 116429 | - sqlite3ExprIfFalse(pParse, pExpr->pLeft, dest, jumpIfNull); | |
| 116430 | - sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); | |
| 116431 | 116819 | }else{ |
| 116432 | - int d2 = sqlite3VdbeMakeLabel(pParse); | |
| 116433 | - testcase( jumpIfNull==0 ); | |
| 116434 | - sqlite3ExprIfTrue(pParse, pExpr->pLeft, d2, | |
| 116435 | - jumpIfNull^SQLITE_JUMPIFNULL); | |
| 116436 | - sqlite3ExprIfFalse(pParse, pExpr->pRight, dest, jumpIfNull); | |
| 116437 | - sqlite3VdbeResolveLabel(v, d2); | |
| 116820 | + Expr *pFirst, *pSecond; | |
| 116821 | + if( exprEvalRhsFirst(pExpr) ){ | |
| 116822 | + pFirst = pExpr->pRight; | |
| 116823 | + pSecond = pExpr->pLeft; | |
| 116824 | + }else{ | |
| 116825 | + pFirst = pExpr->pLeft; | |
| 116826 | + pSecond = pExpr->pRight; | |
| 116827 | + } | |
| 116828 | + if( pExpr->op==TK_AND ){ | |
| 116829 | + testcase( jumpIfNull==0 ); | |
| 116830 | + sqlite3ExprIfFalse(pParse, pFirst, dest, jumpIfNull); | |
| 116831 | + sqlite3ExprIfFalse(pParse, pSecond, dest, jumpIfNull); | |
| 116832 | + }else{ | |
| 116833 | + int d2 = sqlite3VdbeMakeLabel(pParse); | |
| 116834 | + testcase( jumpIfNull==0 ); | |
| 116835 | + sqlite3ExprIfTrue(pParse, pFirst, d2, | |
| 116836 | + jumpIfNull^SQLITE_JUMPIFNULL); | |
| 116837 | + sqlite3ExprIfFalse(pParse, pSecond, dest, jumpIfNull); | |
| 116838 | + sqlite3VdbeResolveLabel(v, d2); | |
| 116839 | + } | |
| 116438 | 116840 | } |
| 116439 | 116841 | break; |
| 116440 | 116842 | } |
| 116441 | 116843 | case TK_NOT: { |
| 116442 | 116844 | testcase( jumpIfNull==0 ); |
| @@ -116474,14 +116876,20 @@ | ||
| 116474 | 116876 | case TK_LE: |
| 116475 | 116877 | case TK_GT: |
| 116476 | 116878 | case TK_GE: |
| 116477 | 116879 | case TK_NE: |
| 116478 | 116880 | case TK_EQ: { |
| 116881 | + int addrIsNull; | |
| 116479 | 116882 | if( sqlite3ExprIsVector(pExpr->pLeft) ) goto default_expr; |
| 116480 | - testcase( jumpIfNull==0 ); | |
| 116481 | - r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 116482 | - r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 116883 | + if( ExprHasProperty(pExpr, EP_Subquery) && jumpIfNull!=SQLITE_NULLEQ ){ | |
| 116884 | + addrIsNull = exprComputeOperands(pParse, pExpr, | |
| 116885 | + &r1, &r2, ®Free1, ®Free2); | |
| 116886 | + }else{ | |
| 116887 | + r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); | |
| 116888 | + r2 = sqlite3ExprCodeTemp(pParse, pExpr->pRight, ®Free2); | |
| 116889 | + addrIsNull = 0; | |
| 116890 | + } | |
| 116483 | 116891 | codeCompare(pParse, pExpr->pLeft, pExpr->pRight, op, |
| 116484 | 116892 | r1, r2, dest, jumpIfNull,ExprHasProperty(pExpr,EP_Commuted)); |
| 116485 | 116893 | assert(TK_LT==OP_Lt); testcase(op==OP_Lt); VdbeCoverageIf(v,op==OP_Lt); |
| 116486 | 116894 | assert(TK_LE==OP_Le); testcase(op==OP_Le); VdbeCoverageIf(v,op==OP_Le); |
| 116487 | 116895 | assert(TK_GT==OP_Gt); testcase(op==OP_Gt); VdbeCoverageIf(v,op==OP_Gt); |
| @@ -116492,20 +116900,27 @@ | ||
| 116492 | 116900 | assert(TK_NE==OP_Ne); testcase(op==OP_Ne); |
| 116493 | 116901 | VdbeCoverageIf(v, op==OP_Ne && jumpIfNull!=SQLITE_NULLEQ); |
| 116494 | 116902 | VdbeCoverageIf(v, op==OP_Ne && jumpIfNull==SQLITE_NULLEQ); |
| 116495 | 116903 | testcase( regFree1==0 ); |
| 116496 | 116904 | testcase( regFree2==0 ); |
| 116905 | + if( addrIsNull ){ | |
| 116906 | + if( jumpIfNull ){ | |
| 116907 | + sqlite3VdbeChangeP2(v, addrIsNull, dest); | |
| 116908 | + }else{ | |
| 116909 | + sqlite3VdbeJumpHere(v, addrIsNull); | |
| 116910 | + } | |
| 116911 | + } | |
| 116497 | 116912 | break; |
| 116498 | 116913 | } |
| 116499 | 116914 | case TK_ISNULL: |
| 116500 | 116915 | case TK_NOTNULL: { |
| 116501 | 116916 | r1 = sqlite3ExprCodeTemp(pParse, pExpr->pLeft, ®Free1); |
| 116502 | - sqlite3VdbeTypeofColumn(v, r1); | |
| 116917 | + assert( regFree1==0 || regFree1==r1 ); | |
| 116918 | + if( regFree1 ) sqlite3VdbeTypeofColumn(v, r1); | |
| 116503 | 116919 | sqlite3VdbeAddOp2(v, op, r1, dest); |
| 116504 | 116920 | testcase( op==TK_ISNULL ); VdbeCoverageIf(v, op==TK_ISNULL); |
| 116505 | 116921 | testcase( op==TK_NOTNULL ); VdbeCoverageIf(v, op==TK_NOTNULL); |
| 116506 | - testcase( regFree1==0 ); | |
| 116507 | 116922 | break; |
| 116508 | 116923 | } |
| 116509 | 116924 | case TK_BETWEEN: { |
| 116510 | 116925 | testcase( jumpIfNull==0 ); |
| 116511 | 116926 | exprCodeBetween(pParse, pExpr, dest, sqlite3ExprIfFalse, jumpIfNull); |
| @@ -117401,11 +117816,13 @@ | ||
| 117401 | 117816 | AggInfo *pAggInfo, /* The AggInfo object to search and/or modify */ |
| 117402 | 117817 | Expr *pExpr /* Expr describing the column to find or insert */ |
| 117403 | 117818 | ){ |
| 117404 | 117819 | struct AggInfo_col *pCol; |
| 117405 | 117820 | int k; |
| 117821 | + int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN]; | |
| 117406 | 117822 | |
| 117823 | + assert( mxTerm <= SMXV(i16) ); | |
| 117407 | 117824 | assert( pAggInfo->iFirstReg==0 ); |
| 117408 | 117825 | pCol = pAggInfo->aCol; |
| 117409 | 117826 | for(k=0; k<pAggInfo->nColumn; k++, pCol++){ |
| 117410 | 117827 | if( pCol->pCExpr==pExpr ) return; |
| 117411 | 117828 | if( pCol->iTable==pExpr->iTable |
| @@ -117418,10 +117835,14 @@ | ||
| 117418 | 117835 | k = addAggInfoColumn(pParse->db, pAggInfo); |
| 117419 | 117836 | if( k<0 ){ |
| 117420 | 117837 | /* OOM on resize */ |
| 117421 | 117838 | assert( pParse->db->mallocFailed ); |
| 117422 | 117839 | return; |
| 117840 | + } | |
| 117841 | + if( k>mxTerm ){ | |
| 117842 | + sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm); | |
| 117843 | + k = mxTerm; | |
| 117423 | 117844 | } |
| 117424 | 117845 | pCol = &pAggInfo->aCol[k]; |
| 117425 | 117846 | assert( ExprUseYTab(pExpr) ); |
| 117426 | 117847 | pCol->pTab = pExpr->y.pTab; |
| 117427 | 117848 | pCol->iTable = pExpr->iTable; |
| @@ -117452,10 +117873,11 @@ | ||
| 117452 | 117873 | assert( pExpr->pAggInfo==0 || pExpr->pAggInfo==pAggInfo ); |
| 117453 | 117874 | pExpr->pAggInfo = pAggInfo; |
| 117454 | 117875 | if( pExpr->op==TK_COLUMN ){ |
| 117455 | 117876 | pExpr->op = TK_AGG_COLUMN; |
| 117456 | 117877 | } |
| 117878 | + assert( k <= SMXV(pExpr->iAgg) ); | |
| 117457 | 117879 | pExpr->iAgg = (i16)k; |
| 117458 | 117880 | } |
| 117459 | 117881 | |
| 117460 | 117882 | /* |
| 117461 | 117883 | ** This is the xExprCallback for a tree walker. It is used to |
| @@ -117536,17 +117958,23 @@ | ||
| 117536 | 117958 | ){ |
| 117537 | 117959 | /* Check to see if pExpr is a duplicate of another aggregate |
| 117538 | 117960 | ** function that is already in the pAggInfo structure |
| 117539 | 117961 | */ |
| 117540 | 117962 | struct AggInfo_func *pItem = pAggInfo->aFunc; |
| 117963 | + int mxTerm = pParse->db->aLimit[SQLITE_LIMIT_COLUMN]; | |
| 117964 | + assert( mxTerm <= SMXV(i16) ); | |
| 117541 | 117965 | for(i=0; i<pAggInfo->nFunc; i++, pItem++){ |
| 117542 | 117966 | if( NEVER(pItem->pFExpr==pExpr) ) break; |
| 117543 | 117967 | if( sqlite3ExprCompare(0, pItem->pFExpr, pExpr, -1)==0 ){ |
| 117544 | 117968 | break; |
| 117545 | 117969 | } |
| 117546 | 117970 | } |
| 117547 | - if( i>=pAggInfo->nFunc ){ | |
| 117971 | + if( i>mxTerm ){ | |
| 117972 | + sqlite3ErrorMsg(pParse, "more than %d aggregate terms", mxTerm); | |
| 117973 | + i = mxTerm; | |
| 117974 | + assert( i<pAggInfo->nFunc ); | |
| 117975 | + }else if( i>=pAggInfo->nFunc ){ | |
| 117548 | 117976 | /* pExpr is original. Make a new entry in pAggInfo->aFunc[] |
| 117549 | 117977 | */ |
| 117550 | 117978 | u8 enc = ENC(pParse->db); |
| 117551 | 117979 | i = addAggInfoFunc(pParse->db, pAggInfo); |
| 117552 | 117980 | if( i>=0 ){ |
| @@ -117596,10 +118024,11 @@ | ||
| 117596 | 118024 | } |
| 117597 | 118025 | /* Make pExpr point to the appropriate pAggInfo->aFunc[] entry |
| 117598 | 118026 | */ |
| 117599 | 118027 | assert( !ExprHasProperty(pExpr, EP_TokenOnly|EP_Reduced) ); |
| 117600 | 118028 | ExprSetVVAProperty(pExpr, EP_NoReduce); |
| 118029 | + assert( i <= SMXV(pExpr->iAgg) ); | |
| 117601 | 118030 | pExpr->iAgg = (i16)i; |
| 117602 | 118031 | pExpr->pAggInfo = pAggInfo; |
| 117603 | 118032 | return WRC_Prune; |
| 117604 | 118033 | }else{ |
| 117605 | 118034 | return WRC_Continue; |
| @@ -118998,14 +119427,14 @@ | ||
| 118998 | 119427 | }else{ |
| 118999 | 119428 | nQuot = sqlite3Strlen30(zQuot)-1; |
| 119000 | 119429 | } |
| 119001 | 119430 | |
| 119002 | 119431 | assert( nQuot>=nNew && nSql>=0 && nNew>=0 ); |
| 119003 | - zOut = sqlite3DbMallocZero(db, (u64)(nSql + pRename->nList*nQuot + 1)); | |
| 119432 | + zOut = sqlite3DbMallocZero(db, (u64)nSql + pRename->nList*(u64)nQuot + 1); | |
| 119004 | 119433 | }else{ |
| 119005 | 119434 | assert( nSql>0 ); |
| 119006 | - zOut = (char*)sqlite3DbMallocZero(db, (u64)(nSql*2+1) * 3); | |
| 119435 | + zOut = (char*)sqlite3DbMallocZero(db, (2*(u64)nSql + 1) * 3); | |
| 119007 | 119436 | if( zOut ){ |
| 119008 | 119437 | zBuf1 = &zOut[nSql*2+1]; |
| 119009 | 119438 | zBuf2 = &zOut[nSql*4+2]; |
| 119010 | 119439 | } |
| 119011 | 119440 | } |
| @@ -121683,20 +122112,10 @@ | ||
| 121683 | 122112 | } |
| 121684 | 122113 | #endif |
| 121685 | 122114 | while( z[0]!=0 && z[0]!=' ' ) z++; |
| 121686 | 122115 | while( z[0]==' ' ) z++; |
| 121687 | 122116 | } |
| 121688 | - | |
| 121689 | - /* Set the bLowQual flag if the peak number of rows obtained | |
| 121690 | - ** from a full equality match is so large that a full table scan | |
| 121691 | - ** seems likely to be faster than using the index. | |
| 121692 | - */ | |
| 121693 | - if( aLog[0] > 66 /* Index has more than 100 rows */ | |
| 121694 | - && aLog[0] <= aLog[nOut-1] /* And only a single value seen */ | |
| 121695 | - ){ | |
| 121696 | - pIndex->bLowQual = 1; | |
| 121697 | - } | |
| 121698 | 122117 | } |
| 121699 | 122118 | } |
| 121700 | 122119 | |
| 121701 | 122120 | /* |
| 121702 | 122121 | ** This callback is invoked once for each index when reading the |
| @@ -124091,11 +124510,11 @@ | ||
| 124091 | 124510 | */ |
| 124092 | 124511 | SQLITE_PRIVATE int sqlite3TableColumnToIndex(Index *pIdx, int iCol){ |
| 124093 | 124512 | int i; |
| 124094 | 124513 | i16 iCol16; |
| 124095 | 124514 | assert( iCol>=(-1) && iCol<=SQLITE_MAX_COLUMN ); |
| 124096 | - assert( pIdx->nColumn<=SQLITE_MAX_COLUMN ); | |
| 124515 | + assert( pIdx->nColumn<=SQLITE_MAX_COLUMN+1 ); | |
| 124097 | 124516 | iCol16 = iCol; |
| 124098 | 124517 | for(i=0; i<pIdx->nColumn; i++){ |
| 124099 | 124518 | if( iCol16==pIdx->aiColumn[i] ){ |
| 124100 | 124519 | return i; |
| 124101 | 124520 | } |
| @@ -127239,11 +127658,10 @@ | ||
| 127239 | 127658 | }else{ |
| 127240 | 127659 | j = pCExpr->iColumn; |
| 127241 | 127660 | assert( j<=0x7fff ); |
| 127242 | 127661 | if( j<0 ){ |
| 127243 | 127662 | j = pTab->iPKey; |
| 127244 | - pIndex->bIdxRowid = 1; | |
| 127245 | 127663 | }else{ |
| 127246 | 127664 | if( pTab->aCol[j].notNull==0 ){ |
| 127247 | 127665 | pIndex->uniqNotNull = 0; |
| 127248 | 127666 | } |
| 127249 | 127667 | if( pTab->aCol[j].colFlags & COLFLAG_VIRTUAL ){ |
| @@ -128158,20 +128576,26 @@ | ||
| 128158 | 128576 | ** Append the contents of SrcList p2 to SrcList p1 and return the resulting |
| 128159 | 128577 | ** SrcList. Or, if an error occurs, return NULL. In all cases, p1 and p2 |
| 128160 | 128578 | ** are deleted by this function. |
| 128161 | 128579 | */ |
| 128162 | 128580 | SQLITE_PRIVATE SrcList *sqlite3SrcListAppendList(Parse *pParse, SrcList *p1, SrcList *p2){ |
| 128163 | - assert( p1 && p1->nSrc==1 ); | |
| 128581 | + assert( p1 ); | |
| 128582 | + assert( p2 || pParse->nErr ); | |
| 128583 | + assert( p2==0 || p2->nSrc>=1 ); | |
| 128584 | + testcase( p1->nSrc==0 ); | |
| 128164 | 128585 | if( p2 ){ |
| 128165 | - SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, 1); | |
| 128586 | + int nOld = p1->nSrc; | |
| 128587 | + SrcList *pNew = sqlite3SrcListEnlarge(pParse, p1, p2->nSrc, nOld); | |
| 128166 | 128588 | if( pNew==0 ){ |
| 128167 | 128589 | sqlite3SrcListDelete(pParse->db, p2); |
| 128168 | 128590 | }else{ |
| 128169 | 128591 | p1 = pNew; |
| 128170 | - memcpy(&p1->a[1], p2->a, p2->nSrc*sizeof(SrcItem)); | |
| 128592 | + memcpy(&p1->a[nOld], p2->a, p2->nSrc*sizeof(SrcItem)); | |
| 128593 | + assert( nOld==1 || (p2->a[0].fg.jointype & JT_LTORJ)==0 ); | |
| 128594 | + assert( p1->nSrc>=1 ); | |
| 128595 | + p1->a[0].fg.jointype |= (JT_LTORJ & p2->a[0].fg.jointype); | |
| 128171 | 128596 | sqlite3DbFree(pParse->db, p2); |
| 128172 | - p1->a[0].fg.jointype |= (JT_LTORJ & p1->a[1].fg.jointype); | |
| 128173 | 128597 | } |
| 128174 | 128598 | } |
| 128175 | 128599 | return p1; |
| 128176 | 128600 | } |
| 128177 | 128601 | |
| @@ -132064,11 +132488,11 @@ | ||
| 132064 | 132488 | int argc, |
| 132065 | 132489 | sqlite3_value **argv, |
| 132066 | 132490 | int nSep, |
| 132067 | 132491 | const char *zSep |
| 132068 | 132492 | ){ |
| 132069 | - i64 j, k, n = 0; | |
| 132493 | + i64 j, n = 0; | |
| 132070 | 132494 | int i; |
| 132071 | 132495 | char *z; |
| 132072 | 132496 | for(i=0; i<argc; i++){ |
| 132073 | 132497 | n += sqlite3_value_bytes(argv[i]); |
| 132074 | 132498 | } |
| @@ -132078,12 +132502,12 @@ | ||
| 132078 | 132502 | sqlite3_result_error_nomem(context); |
| 132079 | 132503 | return; |
| 132080 | 132504 | } |
| 132081 | 132505 | j = 0; |
| 132082 | 132506 | for(i=0; i<argc; i++){ |
| 132083 | - k = sqlite3_value_bytes(argv[i]); | |
| 132084 | - if( k>0 ){ | |
| 132507 | + if( sqlite3_value_type(argv[i])!=SQLITE_NULL ){ | |
| 132508 | + int k = sqlite3_value_bytes(argv[i]); | |
| 132085 | 132509 | const char *v = (const char*)sqlite3_value_text(argv[i]); |
| 132086 | 132510 | if( v!=0 ){ |
| 132087 | 132511 | if( j>0 && nSep>0 ){ |
| 132088 | 132512 | memcpy(&z[j], zSep, nSep); |
| 132089 | 132513 | j += nSep; |
| @@ -135017,16 +135441,19 @@ | ||
| 135017 | 135441 | if( iReg==0 ){ |
| 135018 | 135442 | /* Move the previous opcode (which should be OP_MakeRecord) forward |
| 135019 | 135443 | ** by one slot and insert a new OP_TypeCheck where the current |
| 135020 | 135444 | ** OP_MakeRecord is found */ |
| 135021 | 135445 | VdbeOp *pPrev; |
| 135446 | + int p3; | |
| 135022 | 135447 | sqlite3VdbeAppendP4(v, pTab, P4_TABLE); |
| 135023 | 135448 | pPrev = sqlite3VdbeGetLastOp(v); |
| 135024 | 135449 | assert( pPrev!=0 ); |
| 135025 | 135450 | assert( pPrev->opcode==OP_MakeRecord || sqlite3VdbeDb(v)->mallocFailed ); |
| 135026 | 135451 |