Fossil SCM

Update the built-in SQLite to the first 3.50.0 beta for testing.

drh 2025-05-14 16:46 trunk
Commit f40c00b3b5c13dc2bc1928459565cb408d4bbaffefd11e1863871d886274d8fd
+81 -78
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1796,10 +1796,11 @@
17961796
# ifdef FILENAME_MAX
17971797
# define NAME_MAX (FILENAME_MAX)
17981798
# else
17991799
# define NAME_MAX (260)
18001800
# endif
1801
+# define DIRENT_NAME_MAX (NAME_MAX)
18011802
#endif
18021803
18031804
/*
18041805
** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
18051806
*/
@@ -1839,12 +1840,11 @@
18391840
#endif
18401841
18411842
/*
18421843
** Provide a macro, for use by the implementation, to determine if a
18431844
** particular directory entry should be skipped over when searching for
1844
-** the next directory entry that should be returned by the readdir() or
1845
-** readdir_r() functions.
1845
+** the next directory entry that should be returned by the readdir().
18461846
*/
18471847
18481848
#ifndef is_filtered
18491849
# define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
18501850
#endif
@@ -1856,16 +1856,15 @@
18561856
18571857
extern const char *windirent_getenv(const char *name);
18581858
18591859
/*
18601860
** Finally, we can provide the function prototypes for the opendir(),
1861
-** readdir(), readdir_r(), and closedir() POSIX functions.
1861
+** readdir(), and closedir() POSIX functions.
18621862
*/
18631863
18641864
extern LPDIR opendir(const char *dirname);
18651865
extern LPDIRENT readdir(LPDIR dirp);
1866
-extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
18671866
extern INT closedir(LPDIR dirp);
18681867
18691868
#endif /* defined(WIN32) && defined(_MSC_VER) */
18701869
18711870
/************************* End test_windirent.h ********************/
@@ -1918,27 +1917,45 @@
19181917
19191918
/*
19201919
** Implementation of the POSIX opendir() function using the MSVCRT.
19211920
*/
19221921
LPDIR opendir(
1923
- const char *dirname
1922
+ const char *dirname /* Directory name, UTF8 encoding */
19241923
){
1925
- struct _finddata_t data;
1924
+ struct _wfinddata_t data;
19261925
LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));
19271926
SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);
1927
+ wchar_t *b1;
1928
+ sqlite3_int64 sz;
19281929
19291930
if( dirp==NULL ) return NULL;
19301931
memset(dirp, 0, sizeof(DIR));
19311932
19321933
/* TODO: Remove this if Unix-style root paths are not used. */
19331934
if( sqlite3_stricmp(dirname, "/")==0 ){
19341935
dirname = windirent_getenv("SystemDrive");
19351936
}
19361937
1937
- memset(&data, 0, sizeof(struct _finddata_t));
1938
- _snprintf(data.name, namesize, "%s\\*", dirname);
1939
- dirp->d_handle = _findfirst(data.name, &data);
1938
+ memset(&data, 0, sizeof(data));
1939
+ sz = strlen(dirname);
1940
+ b1 = sqlite3_malloc64( (sz+3)*sizeof(b1[0]) );
1941
+ if( b1==0 ){
1942
+ closedir(dirp);
1943
+ return NULL;
1944
+ }
1945
+ sz = MultiByteToWideChar(CP_UTF8, 0, dirname, sz, b1, sz);
1946
+ b1[sz++] = '\\';
1947
+ b1[sz++] = '*';
1948
+ b1[sz] = 0;
1949
+ if( sz+1>(sqlite3_int64)namesize ){
1950
+ closedir(dirp);
1951
+ sqlite3_free(b1);
1952
+ return NULL;
1953
+ }
1954
+ memcpy(data.name, b1, (sz+1)*sizeof(b1[0]));
1955
+ sqlite3_free(b1);
1956
+ dirp->d_handle = _wfindfirst(data.name, &data);
19401957
19411958
if( dirp->d_handle==BAD_INTPTR_T ){
19421959
closedir(dirp);
19431960
return NULL;
19441961
}
@@ -1945,34 +1962,33 @@
19451962
19461963
/* TODO: Remove this block to allow hidden and/or system files. */
19471964
if( is_filtered(data) ){
19481965
next:
19491966
1950
- memset(&data, 0, sizeof(struct _finddata_t));
1951
- if( _findnext(dirp->d_handle, &data)==-1 ){
1967
+ memset(&data, 0, sizeof(data));
1968
+ if( _wfindnext(dirp->d_handle, &data)==-1 ){
19521969
closedir(dirp);
19531970
return NULL;
19541971
}
19551972
19561973
/* TODO: Remove this block to allow hidden and/or system files. */
19571974
if( is_filtered(data) ) goto next;
19581975
}
19591976
19601977
dirp->d_first.d_attributes = data.attrib;
1961
- strncpy(dirp->d_first.d_name, data.name, NAME_MAX);
1962
- dirp->d_first.d_name[NAME_MAX] = '\0';
1963
-
1978
+ WideCharToMultiByte(CP_UTF8, 0, data.name, -1,
1979
+ dirp->d_first.d_name, DIRENT_NAME_MAX, 0, 0);
19641980
return dirp;
19651981
}
19661982
19671983
/*
19681984
** Implementation of the POSIX readdir() function using the MSVCRT.
19691985
*/
19701986
LPDIRENT readdir(
19711987
LPDIR dirp
19721988
){
1973
- struct _finddata_t data;
1989
+ struct _wfinddata_t data;
19741990
19751991
if( dirp==NULL ) return NULL;
19761992
19771993
if( dirp->d_first.d_ino==0 ){
19781994
dirp->d_first.d_ino++;
@@ -1981,69 +1997,23 @@
19811997
return &dirp->d_first;
19821998
}
19831999
19842000
next:
19852001
1986
- memset(&data, 0, sizeof(struct _finddata_t));
1987
- if( _findnext(dirp->d_handle, &data)==-1 ) return NULL;
2002
+ memset(&data, 0, sizeof(data));
2003
+ if( _wfindnext(dirp->d_handle, &data)==-1 ) return NULL;
19882004
19892005
/* TODO: Remove this block to allow hidden and/or system files. */
19902006
if( is_filtered(data) ) goto next;
19912007
19922008
dirp->d_next.d_ino++;
19932009
dirp->d_next.d_attributes = data.attrib;
1994
- strncpy(dirp->d_next.d_name, data.name, NAME_MAX);
1995
- dirp->d_next.d_name[NAME_MAX] = '\0';
1996
-
2010
+ WideCharToMultiByte(CP_UTF8, 0, data.name, -1,
2011
+ dirp->d_next.d_name, DIRENT_NAME_MAX, 0, 0);
19972012
return &dirp->d_next;
19982013
}
19992014
2000
-/*
2001
-** Implementation of the POSIX readdir_r() function using the MSVCRT.
2002
-*/
2003
-INT readdir_r(
2004
- LPDIR dirp,
2005
- LPDIRENT entry,
2006
- LPDIRENT *result
2007
-){
2008
- struct _finddata_t data;
2009
-
2010
- if( dirp==NULL ) return EBADF;
2011
-
2012
- if( dirp->d_first.d_ino==0 ){
2013
- dirp->d_first.d_ino++;
2014
- dirp->d_next.d_ino++;
2015
-
2016
- entry->d_ino = dirp->d_first.d_ino;
2017
- entry->d_attributes = dirp->d_first.d_attributes;
2018
- strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX);
2019
- entry->d_name[NAME_MAX] = '\0';
2020
-
2021
- *result = entry;
2022
- return 0;
2023
- }
2024
-
2025
-next:
2026
-
2027
- memset(&data, 0, sizeof(struct _finddata_t));
2028
- if( _findnext(dirp->d_handle, &data)==-1 ){
2029
- *result = NULL;
2030
- return ENOENT;
2031
- }
2032
-
2033
- /* TODO: Remove this block to allow hidden and/or system files. */
2034
- if( is_filtered(data) ) goto next;
2035
-
2036
- entry->d_ino = (ino_t)-1; /* not available */
2037
- entry->d_attributes = data.attrib;
2038
- strncpy(entry->d_name, data.name, NAME_MAX);
2039
- entry->d_name[NAME_MAX] = '\0';
2040
-
2041
- *result = entry;
2042
- return 0;
2043
-}
2044
-
20452015
/*
20462016
** Implementation of the POSIX closedir() function using the MSVCRT.
20472017
*/
20482018
INT closedir(
20492019
LPDIR dirp
@@ -8061,18 +8031,13 @@
80618031
# include "windows.h"
80628032
# include <io.h>
80638033
# include <direct.h>
80648034
/* # include "test_windirent.h" */
80658035
# define dirent DIRENT
8066
-# ifndef chmod
8067
-# define chmod _chmod
8068
-# endif
8069
-# ifndef stat
8070
-# define stat _stat
8071
-# endif
8072
-# define mkdir(path,mode) _mkdir(path)
8073
-# define lstat(path,buf) stat(path,buf)
8036
+# define stat _stat
8037
+# define chmod(path,mode) fileio_chmod(path,mode)
8038
+# define mkdir(path,mode) fileio_mkdir(path)
80748039
#endif
80758040
#include <time.h>
80768041
#include <errno.h>
80778042
80788043
/* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -8093,10 +8058,44 @@
80938058
#define FSDIR_COLUMN_MTIME 2 /* Last modification time */
80948059
#define FSDIR_COLUMN_DATA 3 /* File content */
80958060
#define FSDIR_COLUMN_PATH 4 /* Path to top of search */
80968061
#define FSDIR_COLUMN_DIR 5 /* Path is relative to this directory */
80978062
8063
+/*
8064
+** UTF8 chmod() function for Windows
8065
+*/
8066
+#if defined(_WIN32) || defined(WIN32)
8067
+static int fileio_chmod(const char *zPath, int pmode){
8068
+ sqlite3_int64 sz = strlen(zPath);
8069
+ wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8070
+ int rc;
8071
+ if( b1==0 ) return -1;
8072
+ sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8073
+ b1[sz] = 0;
8074
+ rc = _wchmod(b1, pmode);
8075
+ sqlite3_free(b1);
8076
+ return rc;
8077
+}
8078
+#endif
8079
+
8080
+/*
8081
+** UTF8 mkdir() function for Windows
8082
+*/
8083
+#if defined(_WIN32) || defined(WIN32)
8084
+static int fileio_mkdir(const char *zPath){
8085
+ sqlite3_int64 sz = strlen(zPath);
8086
+ wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8087
+ int rc;
8088
+ if( b1==0 ) return -1;
8089
+ sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8090
+ b1[sz] = 0;
8091
+ rc = _wmkdir(b1);
8092
+ sqlite3_free(b1);
8093
+ return rc;
8094
+}
8095
+#endif
8096
+
80988097
80998098
/*
81008099
** Set the result stored by context ctx to a blob containing the
81018100
** contents of file zName. Or, leave the result unchanged (NULL)
81028101
** if the file does not exist or is unreadable.
@@ -8254,11 +8253,17 @@
82548253
static int fileStat(
82558254
const char *zPath,
82568255
struct stat *pStatBuf
82578256
){
82588257
#if defined(_WIN32)
8259
- int rc = stat(zPath, pStatBuf);
8258
+ sqlite3_int64 sz = strlen(zPath);
8259
+ wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8260
+ int rc;
8261
+ if( b1==0 ) return 1;
8262
+ sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8263
+ b1[sz] = 0;
8264
+ rc = _wstat(b1, pStatBuf);
82608265
if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
82618266
return rc;
82628267
#else
82638268
return stat(zPath, pStatBuf);
82648269
#endif
@@ -8272,13 +8277,11 @@
82728277
static int fileLinkStat(
82738278
const char *zPath,
82748279
struct stat *pStatBuf
82758280
){
82768281
#if defined(_WIN32)
8277
- int rc = lstat(zPath, pStatBuf);
8278
- if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
8279
- return rc;
8282
+ return fileStat(zPath, pStatBuf);
82808283
#else
82818284
return lstat(zPath, pStatBuf);
82828285
#endif
82838286
}
82848287
@@ -16784,11 +16787,11 @@
1678416787
case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
1678516788
case SQLITE_FCNTL_PRAGMA: {
1678616789
const char *const* a = (const char*const*)pArg;
1678716790
if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
1678816791
const u8 *zArg = (const u8*)a[2];
16789
- if( zArg[0]>='0' && zArg[0]<=9 ){
16792
+ if( zArg[0]>='0' && zArg[0]<='9' ){
1679016793
pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
1679116794
}else{
1679216795
static const struct {
1679316796
const char *z;
1679416797
unsigned int m;
1679516798
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1796,10 +1796,11 @@
1796 # ifdef FILENAME_MAX
1797 # define NAME_MAX (FILENAME_MAX)
1798 # else
1799 # define NAME_MAX (260)
1800 # endif
 
1801 #endif
1802
1803 /*
1804 ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
1805 */
@@ -1839,12 +1840,11 @@
1839 #endif
1840
1841 /*
1842 ** Provide a macro, for use by the implementation, to determine if a
1843 ** particular directory entry should be skipped over when searching for
1844 ** the next directory entry that should be returned by the readdir() or
1845 ** readdir_r() functions.
1846 */
1847
1848 #ifndef is_filtered
1849 # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
1850 #endif
@@ -1856,16 +1856,15 @@
1856
1857 extern const char *windirent_getenv(const char *name);
1858
1859 /*
1860 ** Finally, we can provide the function prototypes for the opendir(),
1861 ** readdir(), readdir_r(), and closedir() POSIX functions.
1862 */
1863
1864 extern LPDIR opendir(const char *dirname);
1865 extern LPDIRENT readdir(LPDIR dirp);
1866 extern INT readdir_r(LPDIR dirp, LPDIRENT entry, LPDIRENT *result);
1867 extern INT closedir(LPDIR dirp);
1868
1869 #endif /* defined(WIN32) && defined(_MSC_VER) */
1870
1871 /************************* End test_windirent.h ********************/
@@ -1918,27 +1917,45 @@
1918
1919 /*
1920 ** Implementation of the POSIX opendir() function using the MSVCRT.
1921 */
1922 LPDIR opendir(
1923 const char *dirname
1924 ){
1925 struct _finddata_t data;
1926 LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));
1927 SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);
 
 
1928
1929 if( dirp==NULL ) return NULL;
1930 memset(dirp, 0, sizeof(DIR));
1931
1932 /* TODO: Remove this if Unix-style root paths are not used. */
1933 if( sqlite3_stricmp(dirname, "/")==0 ){
1934 dirname = windirent_getenv("SystemDrive");
1935 }
1936
1937 memset(&data, 0, sizeof(struct _finddata_t));
1938 _snprintf(data.name, namesize, "%s\\*", dirname);
1939 dirp->d_handle = _findfirst(data.name, &data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1940
1941 if( dirp->d_handle==BAD_INTPTR_T ){
1942 closedir(dirp);
1943 return NULL;
1944 }
@@ -1945,34 +1962,33 @@
1945
1946 /* TODO: Remove this block to allow hidden and/or system files. */
1947 if( is_filtered(data) ){
1948 next:
1949
1950 memset(&data, 0, sizeof(struct _finddata_t));
1951 if( _findnext(dirp->d_handle, &data)==-1 ){
1952 closedir(dirp);
1953 return NULL;
1954 }
1955
1956 /* TODO: Remove this block to allow hidden and/or system files. */
1957 if( is_filtered(data) ) goto next;
1958 }
1959
1960 dirp->d_first.d_attributes = data.attrib;
1961 strncpy(dirp->d_first.d_name, data.name, NAME_MAX);
1962 dirp->d_first.d_name[NAME_MAX] = '\0';
1963
1964 return dirp;
1965 }
1966
1967 /*
1968 ** Implementation of the POSIX readdir() function using the MSVCRT.
1969 */
1970 LPDIRENT readdir(
1971 LPDIR dirp
1972 ){
1973 struct _finddata_t data;
1974
1975 if( dirp==NULL ) return NULL;
1976
1977 if( dirp->d_first.d_ino==0 ){
1978 dirp->d_first.d_ino++;
@@ -1981,69 +1997,23 @@
1981 return &dirp->d_first;
1982 }
1983
1984 next:
1985
1986 memset(&data, 0, sizeof(struct _finddata_t));
1987 if( _findnext(dirp->d_handle, &data)==-1 ) return NULL;
1988
1989 /* TODO: Remove this block to allow hidden and/or system files. */
1990 if( is_filtered(data) ) goto next;
1991
1992 dirp->d_next.d_ino++;
1993 dirp->d_next.d_attributes = data.attrib;
1994 strncpy(dirp->d_next.d_name, data.name, NAME_MAX);
1995 dirp->d_next.d_name[NAME_MAX] = '\0';
1996
1997 return &dirp->d_next;
1998 }
1999
2000 /*
2001 ** Implementation of the POSIX readdir_r() function using the MSVCRT.
2002 */
2003 INT readdir_r(
2004 LPDIR dirp,
2005 LPDIRENT entry,
2006 LPDIRENT *result
2007 ){
2008 struct _finddata_t data;
2009
2010 if( dirp==NULL ) return EBADF;
2011
2012 if( dirp->d_first.d_ino==0 ){
2013 dirp->d_first.d_ino++;
2014 dirp->d_next.d_ino++;
2015
2016 entry->d_ino = dirp->d_first.d_ino;
2017 entry->d_attributes = dirp->d_first.d_attributes;
2018 strncpy(entry->d_name, dirp->d_first.d_name, NAME_MAX);
2019 entry->d_name[NAME_MAX] = '\0';
2020
2021 *result = entry;
2022 return 0;
2023 }
2024
2025 next:
2026
2027 memset(&data, 0, sizeof(struct _finddata_t));
2028 if( _findnext(dirp->d_handle, &data)==-1 ){
2029 *result = NULL;
2030 return ENOENT;
2031 }
2032
2033 /* TODO: Remove this block to allow hidden and/or system files. */
2034 if( is_filtered(data) ) goto next;
2035
2036 entry->d_ino = (ino_t)-1; /* not available */
2037 entry->d_attributes = data.attrib;
2038 strncpy(entry->d_name, data.name, NAME_MAX);
2039 entry->d_name[NAME_MAX] = '\0';
2040
2041 *result = entry;
2042 return 0;
2043 }
2044
2045 /*
2046 ** Implementation of the POSIX closedir() function using the MSVCRT.
2047 */
2048 INT closedir(
2049 LPDIR dirp
@@ -8061,18 +8031,13 @@
8061 # include "windows.h"
8062 # include <io.h>
8063 # include <direct.h>
8064 /* # include "test_windirent.h" */
8065 # define dirent DIRENT
8066 # ifndef chmod
8067 # define chmod _chmod
8068 # endif
8069 # ifndef stat
8070 # define stat _stat
8071 # endif
8072 # define mkdir(path,mode) _mkdir(path)
8073 # define lstat(path,buf) stat(path,buf)
8074 #endif
8075 #include <time.h>
8076 #include <errno.h>
8077
8078 /* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -8093,10 +8058,44 @@
8093 #define FSDIR_COLUMN_MTIME 2 /* Last modification time */
8094 #define FSDIR_COLUMN_DATA 3 /* File content */
8095 #define FSDIR_COLUMN_PATH 4 /* Path to top of search */
8096 #define FSDIR_COLUMN_DIR 5 /* Path is relative to this directory */
8097
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8098
8099 /*
8100 ** Set the result stored by context ctx to a blob containing the
8101 ** contents of file zName. Or, leave the result unchanged (NULL)
8102 ** if the file does not exist or is unreadable.
@@ -8254,11 +8253,17 @@
8254 static int fileStat(
8255 const char *zPath,
8256 struct stat *pStatBuf
8257 ){
8258 #if defined(_WIN32)
8259 int rc = stat(zPath, pStatBuf);
 
 
 
 
 
 
8260 if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
8261 return rc;
8262 #else
8263 return stat(zPath, pStatBuf);
8264 #endif
@@ -8272,13 +8277,11 @@
8272 static int fileLinkStat(
8273 const char *zPath,
8274 struct stat *pStatBuf
8275 ){
8276 #if defined(_WIN32)
8277 int rc = lstat(zPath, pStatBuf);
8278 if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
8279 return rc;
8280 #else
8281 return lstat(zPath, pStatBuf);
8282 #endif
8283 }
8284
@@ -16784,11 +16787,11 @@
16784 case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
16785 case SQLITE_FCNTL_PRAGMA: {
16786 const char *const* a = (const char*const*)pArg;
16787 if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
16788 const u8 *zArg = (const u8*)a[2];
16789 if( zArg[0]>='0' && zArg[0]<=9 ){
16790 pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
16791 }else{
16792 static const struct {
16793 const char *z;
16794 unsigned int m;
16795
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1796,10 +1796,11 @@
1796 # ifdef FILENAME_MAX
1797 # define NAME_MAX (FILENAME_MAX)
1798 # else
1799 # define NAME_MAX (260)
1800 # endif
1801 # define DIRENT_NAME_MAX (NAME_MAX)
1802 #endif
1803
1804 /*
1805 ** We need to define "NULL_INTPTR_T" and "BAD_INTPTR_T".
1806 */
@@ -1839,12 +1840,11 @@
1840 #endif
1841
1842 /*
1843 ** Provide a macro, for use by the implementation, to determine if a
1844 ** particular directory entry should be skipped over when searching for
1845 ** the next directory entry that should be returned by the readdir().
 
1846 */
1847
1848 #ifndef is_filtered
1849 # define is_filtered(a) ((((a).attrib)&_A_HIDDEN) || (((a).attrib)&_A_SYSTEM))
1850 #endif
@@ -1856,16 +1856,15 @@
1856
1857 extern const char *windirent_getenv(const char *name);
1858
1859 /*
1860 ** Finally, we can provide the function prototypes for the opendir(),
1861 ** readdir(), and closedir() POSIX functions.
1862 */
1863
1864 extern LPDIR opendir(const char *dirname);
1865 extern LPDIRENT readdir(LPDIR dirp);
 
1866 extern INT closedir(LPDIR dirp);
1867
1868 #endif /* defined(WIN32) && defined(_MSC_VER) */
1869
1870 /************************* End test_windirent.h ********************/
@@ -1918,27 +1917,45 @@
1917
1918 /*
1919 ** Implementation of the POSIX opendir() function using the MSVCRT.
1920 */
1921 LPDIR opendir(
1922 const char *dirname /* Directory name, UTF8 encoding */
1923 ){
1924 struct _wfinddata_t data;
1925 LPDIR dirp = (LPDIR)sqlite3_malloc(sizeof(DIR));
1926 SIZE_T namesize = sizeof(data.name) / sizeof(data.name[0]);
1927 wchar_t *b1;
1928 sqlite3_int64 sz;
1929
1930 if( dirp==NULL ) return NULL;
1931 memset(dirp, 0, sizeof(DIR));
1932
1933 /* TODO: Remove this if Unix-style root paths are not used. */
1934 if( sqlite3_stricmp(dirname, "/")==0 ){
1935 dirname = windirent_getenv("SystemDrive");
1936 }
1937
1938 memset(&data, 0, sizeof(data));
1939 sz = strlen(dirname);
1940 b1 = sqlite3_malloc64( (sz+3)*sizeof(b1[0]) );
1941 if( b1==0 ){
1942 closedir(dirp);
1943 return NULL;
1944 }
1945 sz = MultiByteToWideChar(CP_UTF8, 0, dirname, sz, b1, sz);
1946 b1[sz++] = '\\';
1947 b1[sz++] = '*';
1948 b1[sz] = 0;
1949 if( sz+1>(sqlite3_int64)namesize ){
1950 closedir(dirp);
1951 sqlite3_free(b1);
1952 return NULL;
1953 }
1954 memcpy(data.name, b1, (sz+1)*sizeof(b1[0]));
1955 sqlite3_free(b1);
1956 dirp->d_handle = _wfindfirst(data.name, &data);
1957
1958 if( dirp->d_handle==BAD_INTPTR_T ){
1959 closedir(dirp);
1960 return NULL;
1961 }
@@ -1945,34 +1962,33 @@
1962
1963 /* TODO: Remove this block to allow hidden and/or system files. */
1964 if( is_filtered(data) ){
1965 next:
1966
1967 memset(&data, 0, sizeof(data));
1968 if( _wfindnext(dirp->d_handle, &data)==-1 ){
1969 closedir(dirp);
1970 return NULL;
1971 }
1972
1973 /* TODO: Remove this block to allow hidden and/or system files. */
1974 if( is_filtered(data) ) goto next;
1975 }
1976
1977 dirp->d_first.d_attributes = data.attrib;
1978 WideCharToMultiByte(CP_UTF8, 0, data.name, -1,
1979 dirp->d_first.d_name, DIRENT_NAME_MAX, 0, 0);
 
1980 return dirp;
1981 }
1982
1983 /*
1984 ** Implementation of the POSIX readdir() function using the MSVCRT.
1985 */
1986 LPDIRENT readdir(
1987 LPDIR dirp
1988 ){
1989 struct _wfinddata_t data;
1990
1991 if( dirp==NULL ) return NULL;
1992
1993 if( dirp->d_first.d_ino==0 ){
1994 dirp->d_first.d_ino++;
@@ -1981,69 +1997,23 @@
1997 return &dirp->d_first;
1998 }
1999
2000 next:
2001
2002 memset(&data, 0, sizeof(data));
2003 if( _wfindnext(dirp->d_handle, &data)==-1 ) return NULL;
2004
2005 /* TODO: Remove this block to allow hidden and/or system files. */
2006 if( is_filtered(data) ) goto next;
2007
2008 dirp->d_next.d_ino++;
2009 dirp->d_next.d_attributes = data.attrib;
2010 WideCharToMultiByte(CP_UTF8, 0, data.name, -1,
2011 dirp->d_next.d_name, DIRENT_NAME_MAX, 0, 0);
 
2012 return &dirp->d_next;
2013 }
2014
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2015 /*
2016 ** Implementation of the POSIX closedir() function using the MSVCRT.
2017 */
2018 INT closedir(
2019 LPDIR dirp
@@ -8061,18 +8031,13 @@
8031 # include "windows.h"
8032 # include <io.h>
8033 # include <direct.h>
8034 /* # include "test_windirent.h" */
8035 # define dirent DIRENT
8036 # define stat _stat
8037 # define chmod(path,mode) fileio_chmod(path,mode)
8038 # define mkdir(path,mode) fileio_mkdir(path)
 
 
 
 
 
8039 #endif
8040 #include <time.h>
8041 #include <errno.h>
8042
8043 /* When used as part of the CLI, the sqlite3_stdio.h module will have
@@ -8093,10 +8058,44 @@
8058 #define FSDIR_COLUMN_MTIME 2 /* Last modification time */
8059 #define FSDIR_COLUMN_DATA 3 /* File content */
8060 #define FSDIR_COLUMN_PATH 4 /* Path to top of search */
8061 #define FSDIR_COLUMN_DIR 5 /* Path is relative to this directory */
8062
8063 /*
8064 ** UTF8 chmod() function for Windows
8065 */
8066 #if defined(_WIN32) || defined(WIN32)
8067 static int fileio_chmod(const char *zPath, int pmode){
8068 sqlite3_int64 sz = strlen(zPath);
8069 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8070 int rc;
8071 if( b1==0 ) return -1;
8072 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8073 b1[sz] = 0;
8074 rc = _wchmod(b1, pmode);
8075 sqlite3_free(b1);
8076 return rc;
8077 }
8078 #endif
8079
8080 /*
8081 ** UTF8 mkdir() function for Windows
8082 */
8083 #if defined(_WIN32) || defined(WIN32)
8084 static int fileio_mkdir(const char *zPath){
8085 sqlite3_int64 sz = strlen(zPath);
8086 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8087 int rc;
8088 if( b1==0 ) return -1;
8089 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8090 b1[sz] = 0;
8091 rc = _wmkdir(b1);
8092 sqlite3_free(b1);
8093 return rc;
8094 }
8095 #endif
8096
8097
8098 /*
8099 ** Set the result stored by context ctx to a blob containing the
8100 ** contents of file zName. Or, leave the result unchanged (NULL)
8101 ** if the file does not exist or is unreadable.
@@ -8254,11 +8253,17 @@
8253 static int fileStat(
8254 const char *zPath,
8255 struct stat *pStatBuf
8256 ){
8257 #if defined(_WIN32)
8258 sqlite3_int64 sz = strlen(zPath);
8259 wchar_t *b1 = sqlite3_malloc64( (sz+1)*sizeof(b1[0]) );
8260 int rc;
8261 if( b1==0 ) return 1;
8262 sz = MultiByteToWideChar(CP_UTF8, 0, zPath, sz, b1, sz);
8263 b1[sz] = 0;
8264 rc = _wstat(b1, pStatBuf);
8265 if( rc==0 ) statTimesToUtc(zPath, pStatBuf);
8266 return rc;
8267 #else
8268 return stat(zPath, pStatBuf);
8269 #endif
@@ -8272,13 +8277,11 @@
8277 static int fileLinkStat(
8278 const char *zPath,
8279 struct stat *pStatBuf
8280 ){
8281 #if defined(_WIN32)
8282 return fileStat(zPath, pStatBuf);
 
 
8283 #else
8284 return lstat(zPath, pStatBuf);
8285 #endif
8286 }
8287
@@ -16784,11 +16787,11 @@
16787 case SQLITE_FCNTL_POWERSAFE_OVERWRITE: zOp = "POWERSAFE_OVERWRITE"; break;
16788 case SQLITE_FCNTL_PRAGMA: {
16789 const char *const* a = (const char*const*)pArg;
16790 if( a[1] && strcmp(a[1],"vfstrace")==0 && a[2] ){
16791 const u8 *zArg = (const u8*)a[2];
16792 if( zArg[0]>='0' && zArg[0]<='9' ){
16793 pInfo->mTrace = (sqlite3_uint64)strtoll(a[2], 0, 0);
16794 }else{
16795 static const struct {
16796 const char *z;
16797 unsigned int m;
16798
+34 -26
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** 6eb2939a6093c0796910645172d80c530555 with changes in files:
21
+** e7dcf25efae364b7cdf9eb8265803c816c8b with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468468
#define SQLITE_VERSION "3.50.0"
469469
#define SQLITE_VERSION_NUMBER 3050000
470
-#define SQLITE_SOURCE_ID "2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447"
470
+#define SQLITE_SOURCE_ID "2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -12084,11 +12084,11 @@
1208412084
** CAPI3REF: Flags for sqlite3changeset_start_v2
1208512085
**
1208612086
** The following flags may passed via the 4th parameter to
1208712087
** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
1208812088
**
12089
-** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
12089
+** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
1209012090
** Invert the changeset while iterating through it. This is equivalent to
1209112091
** inverting a changeset using sqlite3changeset_invert() before applying it.
1209212092
** It is an error to specify this flag with a patchset.
1209312093
*/
1209412094
#define SQLITE_CHANGESETSTART_INVERT 0x0002
@@ -19161,11 +19161,10 @@
1916119161
unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
1916219162
unsigned isResized:1; /* True if resizeIndexObject() has been called */
1916319163
unsigned isCovering:1; /* True if this is a covering index */
1916419164
unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
1916519165
unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
19166
- unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
1916719166
unsigned bNoQuery:1; /* Do not use this index to optimize queries */
1916819167
unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
1916919168
unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
1917019169
unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
1917119170
unsigned bHasExpr:1; /* Index contains an expression, either a literal
@@ -22425,10 +22424,13 @@
2242522424
#ifdef SQLITE_BITMASK_TYPE
2242622425
"BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
2242722426
#endif
2242822427
#ifdef SQLITE_BUG_COMPATIBLE_20160819
2242922428
"BUG_COMPATIBLE_20160819",
22429
+#endif
22430
+#ifdef SQLITE_BUG_COMPATIBLE_20250510
22431
+ "BUG_COMPATIBLE_20250510",
2243022432
#endif
2243122433
#ifdef SQLITE_CASE_SENSITIVE_LIKE
2243222434
"CASE_SENSITIVE_LIKE",
2243322435
#endif
2243422436
#ifdef SQLITE_CHECK_PAGES
@@ -109307,17 +109309,16 @@
109307109309
/* Clearly non-deterministic functions like random(), but also
109308109310
** date/time functions that use 'now', and other functions like
109309109311
** sqlite_version() that might change over time cannot be used
109310109312
** in an index or generated column. Curiously, they can be used
109311109313
** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
109312
- ** all this. */
109314
+ ** allow this. */
109313109315
sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
109314109316
NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
109315109317
}else{
109316109318
assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
109317109319
pExpr->op2 = pNC->ncFlags & NC_SelfRef;
109318
- if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
109319109320
}
109320109321
if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
109321109322
&& pParse->nested==0
109322109323
&& (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0
109323109324
){
@@ -109329,10 +109330,11 @@
109329109330
pDef = 0;
109330109331
}else
109331109332
if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0
109332109333
&& !IN_RENAME_OBJECT
109333109334
){
109335
+ if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
109334109336
sqlite3ExprFunctionUsable(pParse, pExpr, pDef);
109335109337
}
109336109338
}
109337109339
109338109340
if( 0==IN_RENAME_OBJECT ){
@@ -121704,20 +121706,10 @@
121704121706
}
121705121707
#endif
121706121708
while( z[0]!=0 && z[0]!=' ' ) z++;
121707121709
while( z[0]==' ' ) z++;
121708121710
}
121709
-
121710
- /* Set the bLowQual flag if the peak number of rows obtained
121711
- ** from a full equality match is so large that a full table scan
121712
- ** seems likely to be faster than using the index.
121713
- */
121714
- if( aLog[0] > 66 /* Index has more than 100 rows */
121715
- && aLog[0] <= aLog[nOut-1] /* And only a single value seen */
121716
- ){
121717
- pIndex->bLowQual = 1;
121718
- }
121719121711
}
121720121712
}
121721121713
121722121714
/*
121723121715
** This callback is invoked once for each index when reading the
@@ -167641,15 +167633,12 @@
167641167633
opMask = WO_LT|WO_LE;
167642167634
}else{
167643167635
assert( pNew->u.btree.nBtm==0 );
167644167636
opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
167645167637
}
167646
- if( pProbe->bUnordered || pProbe->bLowQual ){
167647
- if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
167648
- if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){
167649
- opMask &= ~(WO_EQ|WO_IN|WO_IS);
167650
- }
167638
+ if( pProbe->bUnordered ){
167639
+ opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
167651167640
}
167652167641
167653167642
assert( pNew->u.btree.nEq<pProbe->nColumn );
167654167643
assert( pNew->u.btree.nEq<pProbe->nKeyCol
167655167644
|| pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
@@ -168582,11 +168571,11 @@
168582168571
}
168583168572
}else if( m==0
168584168573
&& (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
168585168574
){
168586168575
WHERETRACE(0x200,
168587
- ("-> %s a covering index according to bitmasks\n",
168576
+ ("-> %s is a covering index according to bitmasks\n",
168588168577
pProbe->zName, m==0 ? "is" : "is not"));
168589168578
pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
168590168579
}
168591168580
}
168592168581
@@ -209594,11 +209583,16 @@
209594209583
c = z[++j];
209595209584
if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
209596209585
|| c=='n' || c=='r' || c=='t'
209597209586
|| (c=='u' && jsonIs4Hex(&z[j+1])) ){
209598209587
if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ;
209599
- }else if( c=='\'' || c=='0' || c=='v' || c=='\n'
209588
+ }else if( c=='\'' || c=='v' || c=='\n'
209589
+#ifdef SQLITE_BUG_COMPATIBLE_20250510
209590
+ || (c=='0') /* Legacy bug compatible */
209591
+#else
209592
+ || (c=='0' && !sqlite3Isdigit(z[j+1])) /* Correct implementation */
209593
+#endif
209600209594
|| (0xe2==(u8)c && 0x80==(u8)z[j+1]
209601209595
&& (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2]))
209602209596
|| (c=='x' && jsonIs2Hex(&z[j+1])) ){
209603209597
opcode = JSONB_TEXT5;
209604209598
pParse->hasNonstd = 1;
@@ -209981,11 +209975,11 @@
209981209975
|| pParse->aBlob[i+4]!=0
209982209976
){
209983209977
*pSz = 0;
209984209978
return 0;
209985209979
}
209986
- sz = (pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
209980
+ sz = ((u32)pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
209987209981
(pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
209988209982
n = 9;
209989209983
}
209990209984
if( (i64)i+sz+n > pParse->nBlob
209991209985
&& (i64)i+sz+n > pParse->nBlob-pParse->delta
@@ -210562,11 +210556,25 @@
210562210556
case 'f': { *piOut = '\f'; return 2; }
210563210557
case 'n': { *piOut = '\n'; return 2; }
210564210558
case 'r': { *piOut = '\r'; return 2; }
210565210559
case 't': { *piOut = '\t'; return 2; }
210566210560
case 'v': { *piOut = '\v'; return 2; }
210567
- case '0': { *piOut = 0; return 2; }
210561
+ case '0': {
210562
+ /* JSON5 requires that the \0 escape not be followed by a digit.
210563
+ ** But SQLite did not enforce this restriction in versions 3.42.0
210564
+ ** through 3.49.2. That was a bug. But some applications might have
210565
+ ** come to depend on that bug. Use the SQLITE_BUG_COMPATIBLE_20250510
210566
+ ** option to restore the old buggy behavior. */
210567
+#ifdef SQLITE_BUG_COMPATIBLE_20250510
210568
+ /* Legacy bug-compatible behavior */
210569
+ *piOut = 0;
210570
+#else
210571
+ /* Correct behavior */
210572
+ *piOut = (n>2 && sqlite3Isdigit(z[2])) ? JSON_INVALID_CHAR : 0;
210573
+#endif
210574
+ return 2;
210575
+ }
210568210576
case '\'':
210569210577
case '"':
210570210578
case '/':
210571210579
case '\\':{ *piOut = z[1]; return 2; }
210572210580
case 'x': {
@@ -257267,11 +257275,11 @@
257267257275
int nArg, /* Number of args */
257268257276
sqlite3_value **apUnused /* Function arguments */
257269257277
){
257270257278
assert( nArg==0 );
257271257279
UNUSED_PARAM2(nArg, apUnused);
257272
- sqlite3_result_text(pCtx, "fts5: 2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447", -1, SQLITE_TRANSIENT);
257280
+ sqlite3_result_text(pCtx, "fts5: 2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875", -1, SQLITE_TRANSIENT);
257273257281
}
257274257282
257275257283
/*
257276257284
** Implementation of fts5_locale(LOCALE, TEXT) function.
257277257285
**
257278257286
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 6eb2939a6093c0796910645172d80c530555 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.50.0"
469 #define SQLITE_VERSION_NUMBER 3050000
470 #define SQLITE_SOURCE_ID "2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -12084,11 +12084,11 @@
12084 ** CAPI3REF: Flags for sqlite3changeset_start_v2
12085 **
12086 ** The following flags may passed via the 4th parameter to
12087 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
12088 **
12089 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
12090 ** Invert the changeset while iterating through it. This is equivalent to
12091 ** inverting a changeset using sqlite3changeset_invert() before applying it.
12092 ** It is an error to specify this flag with a patchset.
12093 */
12094 #define SQLITE_CHANGESETSTART_INVERT 0x0002
@@ -19161,11 +19161,10 @@
19161 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
19162 unsigned isResized:1; /* True if resizeIndexObject() has been called */
19163 unsigned isCovering:1; /* True if this is a covering index */
19164 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
19165 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
19166 unsigned bLowQual:1; /* sqlite_stat1 says this is a low-quality index */
19167 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
19168 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19169 unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
19170 unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
19171 unsigned bHasExpr:1; /* Index contains an expression, either a literal
@@ -22425,10 +22424,13 @@
22425 #ifdef SQLITE_BITMASK_TYPE
22426 "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
22427 #endif
22428 #ifdef SQLITE_BUG_COMPATIBLE_20160819
22429 "BUG_COMPATIBLE_20160819",
 
 
 
22430 #endif
22431 #ifdef SQLITE_CASE_SENSITIVE_LIKE
22432 "CASE_SENSITIVE_LIKE",
22433 #endif
22434 #ifdef SQLITE_CHECK_PAGES
@@ -109307,17 +109309,16 @@
109307 /* Clearly non-deterministic functions like random(), but also
109308 ** date/time functions that use 'now', and other functions like
109309 ** sqlite_version() that might change over time cannot be used
109310 ** in an index or generated column. Curiously, they can be used
109311 ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
109312 ** all this. */
109313 sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
109314 NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
109315 }else{
109316 assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
109317 pExpr->op2 = pNC->ncFlags & NC_SelfRef;
109318 if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
109319 }
109320 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
109321 && pParse->nested==0
109322 && (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0
109323 ){
@@ -109329,10 +109330,11 @@
109329 pDef = 0;
109330 }else
109331 if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0
109332 && !IN_RENAME_OBJECT
109333 ){
 
109334 sqlite3ExprFunctionUsable(pParse, pExpr, pDef);
109335 }
109336 }
109337
109338 if( 0==IN_RENAME_OBJECT ){
@@ -121704,20 +121706,10 @@
121704 }
121705 #endif
121706 while( z[0]!=0 && z[0]!=' ' ) z++;
121707 while( z[0]==' ' ) z++;
121708 }
121709
121710 /* Set the bLowQual flag if the peak number of rows obtained
121711 ** from a full equality match is so large that a full table scan
121712 ** seems likely to be faster than using the index.
121713 */
121714 if( aLog[0] > 66 /* Index has more than 100 rows */
121715 && aLog[0] <= aLog[nOut-1] /* And only a single value seen */
121716 ){
121717 pIndex->bLowQual = 1;
121718 }
121719 }
121720 }
121721
121722 /*
121723 ** This callback is invoked once for each index when reading the
@@ -167641,15 +167633,12 @@
167641 opMask = WO_LT|WO_LE;
167642 }else{
167643 assert( pNew->u.btree.nBtm==0 );
167644 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
167645 }
167646 if( pProbe->bUnordered || pProbe->bLowQual ){
167647 if( pProbe->bUnordered ) opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
167648 if( pProbe->bLowQual && pSrc->fg.isIndexedBy==0 ){
167649 opMask &= ~(WO_EQ|WO_IN|WO_IS);
167650 }
167651 }
167652
167653 assert( pNew->u.btree.nEq<pProbe->nColumn );
167654 assert( pNew->u.btree.nEq<pProbe->nKeyCol
167655 || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
@@ -168582,11 +168571,11 @@
168582 }
168583 }else if( m==0
168584 && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
168585 ){
168586 WHERETRACE(0x200,
168587 ("-> %s a covering index according to bitmasks\n",
168588 pProbe->zName, m==0 ? "is" : "is not"));
168589 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
168590 }
168591 }
168592
@@ -209594,11 +209583,16 @@
209594 c = z[++j];
209595 if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
209596 || c=='n' || c=='r' || c=='t'
209597 || (c=='u' && jsonIs4Hex(&z[j+1])) ){
209598 if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ;
209599 }else if( c=='\'' || c=='0' || c=='v' || c=='\n'
 
 
 
 
 
209600 || (0xe2==(u8)c && 0x80==(u8)z[j+1]
209601 && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2]))
209602 || (c=='x' && jsonIs2Hex(&z[j+1])) ){
209603 opcode = JSONB_TEXT5;
209604 pParse->hasNonstd = 1;
@@ -209981,11 +209975,11 @@
209981 || pParse->aBlob[i+4]!=0
209982 ){
209983 *pSz = 0;
209984 return 0;
209985 }
209986 sz = (pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
209987 (pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
209988 n = 9;
209989 }
209990 if( (i64)i+sz+n > pParse->nBlob
209991 && (i64)i+sz+n > pParse->nBlob-pParse->delta
@@ -210562,11 +210556,25 @@
210562 case 'f': { *piOut = '\f'; return 2; }
210563 case 'n': { *piOut = '\n'; return 2; }
210564 case 'r': { *piOut = '\r'; return 2; }
210565 case 't': { *piOut = '\t'; return 2; }
210566 case 'v': { *piOut = '\v'; return 2; }
210567 case '0': { *piOut = 0; return 2; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210568 case '\'':
210569 case '"':
210570 case '/':
210571 case '\\':{ *piOut = z[1]; return 2; }
210572 case 'x': {
@@ -257267,11 +257275,11 @@
257267 int nArg, /* Number of args */
257268 sqlite3_value **apUnused /* Function arguments */
257269 ){
257270 assert( nArg==0 );
257271 UNUSED_PARAM2(nArg, apUnused);
257272 sqlite3_result_text(pCtx, "fts5: 2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447", -1, SQLITE_TRANSIENT);
257273 }
257274
257275 /*
257276 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257277 **
257278
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** e7dcf25efae364b7cdf9eb8265803c816c8b with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.50.0"
469 #define SQLITE_VERSION_NUMBER 3050000
470 #define SQLITE_SOURCE_ID "2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -12084,11 +12084,11 @@
12084 ** CAPI3REF: Flags for sqlite3changeset_start_v2
12085 **
12086 ** The following flags may passed via the 4th parameter to
12087 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
12088 **
12089 ** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
12090 ** Invert the changeset while iterating through it. This is equivalent to
12091 ** inverting a changeset using sqlite3changeset_invert() before applying it.
12092 ** It is an error to specify this flag with a patchset.
12093 */
12094 #define SQLITE_CHANGESETSTART_INVERT 0x0002
@@ -19161,11 +19161,10 @@
19161 unsigned uniqNotNull:1; /* True if UNIQUE and NOT NULL for all columns */
19162 unsigned isResized:1; /* True if resizeIndexObject() has been called */
19163 unsigned isCovering:1; /* True if this is a covering index */
19164 unsigned noSkipScan:1; /* Do not try to use skip-scan if true */
19165 unsigned hasStat1:1; /* aiRowLogEst values come from sqlite_stat1 */
 
19166 unsigned bNoQuery:1; /* Do not use this index to optimize queries */
19167 unsigned bAscKeyBug:1; /* True if the bba7b69f9849b5bf bug applies */
19168 unsigned bIdxRowid:1; /* One or more of the index keys is the ROWID */
19169 unsigned bHasVCol:1; /* Index references one or more VIRTUAL columns */
19170 unsigned bHasExpr:1; /* Index contains an expression, either a literal
@@ -22425,10 +22424,13 @@
22424 #ifdef SQLITE_BITMASK_TYPE
22425 "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
22426 #endif
22427 #ifdef SQLITE_BUG_COMPATIBLE_20160819
22428 "BUG_COMPATIBLE_20160819",
22429 #endif
22430 #ifdef SQLITE_BUG_COMPATIBLE_20250510
22431 "BUG_COMPATIBLE_20250510",
22432 #endif
22433 #ifdef SQLITE_CASE_SENSITIVE_LIKE
22434 "CASE_SENSITIVE_LIKE",
22435 #endif
22436 #ifdef SQLITE_CHECK_PAGES
@@ -109307,17 +109309,16 @@
109309 /* Clearly non-deterministic functions like random(), but also
109310 ** date/time functions that use 'now', and other functions like
109311 ** sqlite_version() that might change over time cannot be used
109312 ** in an index or generated column. Curiously, they can be used
109313 ** in a CHECK constraint. SQLServer, MySQL, and PostgreSQL all
109314 ** allow this. */
109315 sqlite3ResolveNotValid(pParse, pNC, "non-deterministic functions",
109316 NC_IdxExpr|NC_PartIdx|NC_GenCol, 0, pExpr);
109317 }else{
109318 assert( (NC_SelfRef & 0xff)==NC_SelfRef ); /* Must fit in 8 bits */
109319 pExpr->op2 = pNC->ncFlags & NC_SelfRef;
 
109320 }
109321 if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
109322 && pParse->nested==0
109323 && (pParse->db->mDbFlags & DBFLAG_InternalFunc)==0
109324 ){
@@ -109329,10 +109330,11 @@
109330 pDef = 0;
109331 }else
109332 if( (pDef->funcFlags & (SQLITE_FUNC_DIRECT|SQLITE_FUNC_UNSAFE))!=0
109333 && !IN_RENAME_OBJECT
109334 ){
109335 if( pNC->ncFlags & NC_FromDDL ) ExprSetProperty(pExpr, EP_FromDDL);
109336 sqlite3ExprFunctionUsable(pParse, pExpr, pDef);
109337 }
109338 }
109339
109340 if( 0==IN_RENAME_OBJECT ){
@@ -121704,20 +121706,10 @@
121706 }
121707 #endif
121708 while( z[0]!=0 && z[0]!=' ' ) z++;
121709 while( z[0]==' ' ) z++;
121710 }
 
 
 
 
 
 
 
 
 
 
121711 }
121712 }
121713
121714 /*
121715 ** This callback is invoked once for each index when reading the
@@ -167641,15 +167633,12 @@
167633 opMask = WO_LT|WO_LE;
167634 }else{
167635 assert( pNew->u.btree.nBtm==0 );
167636 opMask = WO_EQ|WO_IN|WO_GT|WO_GE|WO_LT|WO_LE|WO_ISNULL|WO_IS;
167637 }
167638 if( pProbe->bUnordered ){
167639 opMask &= ~(WO_GT|WO_GE|WO_LT|WO_LE);
 
 
 
167640 }
167641
167642 assert( pNew->u.btree.nEq<pProbe->nColumn );
167643 assert( pNew->u.btree.nEq<pProbe->nKeyCol
167644 || pProbe->idxType!=SQLITE_IDXTYPE_PRIMARYKEY );
@@ -168582,11 +168571,11 @@
168571 }
168572 }else if( m==0
168573 && (HasRowid(pTab) || pWInfo->pSelect!=0 || sqlite3FaultSim(700))
168574 ){
168575 WHERETRACE(0x200,
168576 ("-> %s is a covering index according to bitmasks\n",
168577 pProbe->zName, m==0 ? "is" : "is not"));
168578 pNew->wsFlags = WHERE_IDX_ONLY | WHERE_INDEXED;
168579 }
168580 }
168581
@@ -209594,11 +209583,16 @@
209583 c = z[++j];
209584 if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f'
209585 || c=='n' || c=='r' || c=='t'
209586 || (c=='u' && jsonIs4Hex(&z[j+1])) ){
209587 if( opcode==JSONB_TEXT ) opcode = JSONB_TEXTJ;
209588 }else if( c=='\'' || c=='v' || c=='\n'
209589 #ifdef SQLITE_BUG_COMPATIBLE_20250510
209590 || (c=='0') /* Legacy bug compatible */
209591 #else
209592 || (c=='0' && !sqlite3Isdigit(z[j+1])) /* Correct implementation */
209593 #endif
209594 || (0xe2==(u8)c && 0x80==(u8)z[j+1]
209595 && (0xa8==(u8)z[j+2] || 0xa9==(u8)z[j+2]))
209596 || (c=='x' && jsonIs2Hex(&z[j+1])) ){
209597 opcode = JSONB_TEXT5;
209598 pParse->hasNonstd = 1;
@@ -209981,11 +209975,11 @@
209975 || pParse->aBlob[i+4]!=0
209976 ){
209977 *pSz = 0;
209978 return 0;
209979 }
209980 sz = ((u32)pParse->aBlob[i+5]<<24) + (pParse->aBlob[i+6]<<16) +
209981 (pParse->aBlob[i+7]<<8) + pParse->aBlob[i+8];
209982 n = 9;
209983 }
209984 if( (i64)i+sz+n > pParse->nBlob
209985 && (i64)i+sz+n > pParse->nBlob-pParse->delta
@@ -210562,11 +210556,25 @@
210556 case 'f': { *piOut = '\f'; return 2; }
210557 case 'n': { *piOut = '\n'; return 2; }
210558 case 'r': { *piOut = '\r'; return 2; }
210559 case 't': { *piOut = '\t'; return 2; }
210560 case 'v': { *piOut = '\v'; return 2; }
210561 case '0': {
210562 /* JSON5 requires that the \0 escape not be followed by a digit.
210563 ** But SQLite did not enforce this restriction in versions 3.42.0
210564 ** through 3.49.2. That was a bug. But some applications might have
210565 ** come to depend on that bug. Use the SQLITE_BUG_COMPATIBLE_20250510
210566 ** option to restore the old buggy behavior. */
210567 #ifdef SQLITE_BUG_COMPATIBLE_20250510
210568 /* Legacy bug-compatible behavior */
210569 *piOut = 0;
210570 #else
210571 /* Correct behavior */
210572 *piOut = (n>2 && sqlite3Isdigit(z[2])) ? JSON_INVALID_CHAR : 0;
210573 #endif
210574 return 2;
210575 }
210576 case '\'':
210577 case '"':
210578 case '/':
210579 case '\\':{ *piOut = z[1]; return 2; }
210580 case 'x': {
@@ -257267,11 +257275,11 @@
257275 int nArg, /* Number of args */
257276 sqlite3_value **apUnused /* Function arguments */
257277 ){
257278 assert( nArg==0 );
257279 UNUSED_PARAM2(nArg, apUnused);
257280 sqlite3_result_text(pCtx, "fts5: 2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875", -1, SQLITE_TRANSIENT);
257281 }
257282
257283 /*
257284 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257285 **
257286
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.50.0"
150150
#define SQLITE_VERSION_NUMBER 3050000
151
-#define SQLITE_SOURCE_ID "2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447"
151
+#define SQLITE_SOURCE_ID "2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -11765,11 +11765,11 @@
1176511765
** CAPI3REF: Flags for sqlite3changeset_start_v2
1176611766
**
1176711767
** The following flags may passed via the 4th parameter to
1176811768
** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
1176911769
**
11770
-** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
11770
+** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
1177111771
** Invert the changeset while iterating through it. This is equivalent to
1177211772
** inverting a changeset using sqlite3changeset_invert() before applying it.
1177311773
** It is an error to specify this flag with a patchset.
1177411774
*/
1177511775
#define SQLITE_CHANGESETSTART_INVERT 0x0002
1177611776
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.50.0"
150 #define SQLITE_VERSION_NUMBER 3050000
151 #define SQLITE_SOURCE_ID "2025-05-06 17:56:32 6eb2939a6093c0796910645172d80c53055559dd57c012f1dc815d89fbf84447"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -11765,11 +11765,11 @@
11765 ** CAPI3REF: Flags for sqlite3changeset_start_v2
11766 **
11767 ** The following flags may passed via the 4th parameter to
11768 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
11769 **
11770 ** <dt>SQLITE_CHANGESETAPPLY_INVERT <dd>
11771 ** Invert the changeset while iterating through it. This is equivalent to
11772 ** inverting a changeset using sqlite3changeset_invert() before applying it.
11773 ** It is an error to specify this flag with a patchset.
11774 */
11775 #define SQLITE_CHANGESETSTART_INVERT 0x0002
11776
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.50.0"
150 #define SQLITE_VERSION_NUMBER 3050000
151 #define SQLITE_SOURCE_ID "2025-05-14 16:40:05 e7dcf25efae364b7cdf9eb8265803c816c8b8557e4a7684da428badc6ffb3875"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -11765,11 +11765,11 @@
11765 ** CAPI3REF: Flags for sqlite3changeset_start_v2
11766 **
11767 ** The following flags may passed via the 4th parameter to
11768 ** [sqlite3changeset_start_v2] and [sqlite3changeset_start_v2_strm]:
11769 **
11770 ** <dt>SQLITE_CHANGESETSTART_INVERT <dd>
11771 ** Invert the changeset while iterating through it. This is equivalent to
11772 ** inverting a changeset using sqlite3changeset_invert() before applying it.
11773 ** It is an error to specify this flag with a patchset.
11774 */
11775 #define SQLITE_CHANGESETSTART_INVERT 0x0002
11776

Keyboard Shortcuts

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