Fossil SCM

Update the built-in SQLite to the latest trunk version for testing.

drh 2025-07-30 16:54 trunk
Commit 104c079dcdf84ba94e1dfb30a7f3b571aef7cc967b66d2c607e16f13c87ee83b
+89 -59
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -122,10 +122,13 @@
122122
typedef sqlite3_int64 i64;
123123
typedef sqlite3_uint64 u64;
124124
typedef unsigned char u8;
125125
#include <ctype.h>
126126
#include <stdarg.h>
127
+#ifndef _WIN32
128
+# include <sys/time.h>
129
+#endif
127130
128131
#if !defined(_WIN32) && !defined(WIN32)
129132
# include <signal.h>
130133
# if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
131134
# include <pwd.h>
@@ -646,24 +649,27 @@
646649
if( a==0 ) a = "";
647650
if( b==0 ) b = "";
648651
return strncmp(a,b,n);
649652
}
650653
651
-/* Return the current wall-clock time */
654
+/* Return the current wall-clock time in microseconds since the
655
+** Unix epoch (1970-01-01T00:00:00Z)
656
+*/
652657
static sqlite3_int64 timeOfDay(void){
653
- static sqlite3_vfs *clockVfs = 0;
654
- sqlite3_int64 t;
655
- if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
656
- if( clockVfs==0 ) return 0; /* Never actually happens */
657
- if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
658
- clockVfs->xCurrentTimeInt64(clockVfs, &t);
659
- }else{
660
- double r;
661
- clockVfs->xCurrentTime(clockVfs, &r);
662
- t = (sqlite3_int64)(r*86400000.0);
663
- }
658
+#if defined(_WIN32)
659
+ sqlite3_uint64 t;
660
+ FILETIME tm;
661
+ GetSystemTimePreciseAsFileTime(&tm);
662
+ t = ((u64)tm.dwHighDateTime<<32) | (u64)tm.dwLowDateTime;
663
+ t += 116444736000000000LL;
664
+ t /= 10;
664665
return t;
666
+#else
667
+ struct timeval sNow;
668
+ (void)gettimeofday(&sNow,0);
669
+ return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec;
670
+#endif
665671
}
666672
667673
#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
668674
#include <sys/time.h>
669675
#include <sys/resource.h>
@@ -704,12 +710,12 @@
704710
static void endTimer(FILE *out){
705711
if( enableTimer ){
706712
sqlite3_int64 iEnd = timeOfDay();
707713
struct rusage sEnd;
708714
getrusage(RUSAGE_SELF, &sEnd);
709
- sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
710
- (iEnd - iBegin)*0.001,
715
+ sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n",
716
+ (iEnd - iBegin)*0.000001,
711717
timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
712718
timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
713719
}
714720
}
715721
@@ -783,12 +789,12 @@
783789
static void endTimer(FILE *out){
784790
if( enableTimer && getProcessTimesAddr){
785791
FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
786792
sqlite3_int64 ftWallEnd = timeOfDay();
787793
getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
788
- sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
789
- (ftWallEnd - ftWallBegin)*0.001,
794
+ sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n",
795
+ (ftWallEnd - ftWallBegin)*0.000001,
790796
timeDiff(&ftUserBegin, &ftUserEnd),
791797
timeDiff(&ftKernelBegin, &ftKernelEnd));
792798
}
793799
}
794800
@@ -32888,76 +32894,95 @@
3288832894
3288932895
return home_dir;
3289032896
}
3289132897
3289232898
/*
32893
-** On non-Windows platforms, look for $XDG_CONFIG_HOME.
32894
-** If ${XDG_CONFIG_HOME}/sqlite3/sqliterc is found, return
32895
-** the path to it. If there is no $(XDG_CONFIG_HOME) then
32896
-** look for $(HOME)/.config/sqlite3/sqliterc and if found
32897
-** return that. If none of these are found, return 0.
32899
+** On non-Windows platforms, look for:
32900
+**
32901
+** - ${zEnvVar}/${zBaseName}
32902
+** - ${HOME}/${zSubdir}/${zBaseName}
32903
+**
32904
+** $zEnvVar is intended to be the name of an XDG_... environment
32905
+** variable, e.g. XDG_CONFIG_HOME or XDG_STATE_HOME. If zEnvVar is
32906
+** NULL or getenv(zEnvVar) is NULL then fall back to the second
32907
+** option. If the selected option is not found in the filesystem,
32908
+** return 0.
32909
+**
32910
+** zSubdir may be NULL or empty, in which case ${HOME}/${zBaseName}
32911
+** becomes the fallback.
32912
+**
32913
+** Both zSubdir and zBaseName may contain subdirectory parts. zSubdir
32914
+** will conventionally be ".config" or ".local/state", which, not
32915
+** coincidentally, is the typical subdir of the corresponding XDG_...
32916
+** var with the XDG var's $HOME prefix.
3289832917
**
32899
-** The string returned is obtained from sqlite3_malloc() and
32900
-** should be freed by the caller.
32918
+** The returned string is obtained from sqlite3_malloc() and should be
32919
+** sqlite3_free()'d by the caller.
3290132920
*/
32902
-static char *find_xdg_config(void){
32921
+static char *find_xdg_file(const char *zEnvVar, const char *zSubdir,
32922
+ const char *zBaseName){
3290332923
#if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \
3290432924
|| defined(__RTP__) || defined(_WRS_KERNEL)
3290532925
return 0;
3290632926
#else
32907
- char *zConfig = 0;
32908
- const char *zXdgHome;
32909
-
32910
- zXdgHome = getenv("XDG_CONFIG_HOME");
32911
- if( zXdgHome==0 ){
32912
- const char *zHome = getenv("HOME");
32913
- if( zHome==0 ) return 0;
32914
- zConfig = sqlite3_mprintf("%s/.config/sqlite3/sqliterc", zHome);
32927
+ char *zConfigFile = 0;
32928
+ const char *zXdgDir;
32929
+
32930
+ zXdgDir = zEnvVar ? getenv(zEnvVar) : 0;
32931
+ if( zXdgDir ){
32932
+ zConfigFile = sqlite3_mprintf("%s/%s", zXdgDir, zBaseName);
3291532933
}else{
32916
- zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome);
32917
- }
32918
- shell_check_oom(zConfig);
32919
- if( access(zConfig,0)!=0 ){
32920
- sqlite3_free(zConfig);
32921
- zConfig = 0;
32922
- }
32923
- return zConfig;
32934
+ const char * zHome = find_home_dir(0);
32935
+ if( zHome==0 ) return 0;
32936
+ zConfigFile = (zSubdir && *zSubdir)
32937
+ ? sqlite3_mprintf("%s/%s/%s", zHome, zSubdir, zBaseName)
32938
+ : sqlite3_mprintf("%s/%s", zHome, zBaseName);
32939
+ }
32940
+ shell_check_oom(zConfigFile);
32941
+ if( access(zConfigFile,0)!=0 ){
32942
+ sqlite3_free(zConfigFile);
32943
+ zConfigFile = 0;
32944
+ }
32945
+ return zConfigFile;
3292432946
#endif
3292532947
}
3292632948
3292732949
/*
32928
-** Read input from the file given by sqliterc_override. Or if that
32929
-** parameter is NULL, take input from the first of find_xdg_config()
32930
-** or ~/.sqliterc which is found.
32950
+** Read input from the file sqliterc_override. If that parameter is
32951
+** NULL, take it from find_xdg_file(), if found, or fall back to
32952
+** ~/.sqliterc.
3293132953
**
32932
-** Returns the number of errors.
32954
+** Failure to read the config is only considered a failure if
32955
+** sqliterc_override is not NULL, in which case this function may emit
32956
+** a warning or, if ::bail_on_error is true, fail fatally if the file
32957
+** named by sqliterc_override is not found.
3293332958
*/
3293432959
static void process_sqliterc(
3293532960
ShellState *p, /* Configuration data */
3293632961
const char *sqliterc_override /* Name of config file. NULL to use default */
3293732962
){
3293832963
char *home_dir = NULL;
32939
- const char *sqliterc = sqliterc_override;
32940
- char *zBuf = 0;
32964
+ char *sqliterc = (char*)sqliterc_override;
3294132965
FILE *inSaved = p->in;
3294232966
int savedLineno = p->lineno;
3294332967
3294432968
if( sqliterc == NULL ){
32945
- sqliterc = zBuf = find_xdg_config();
32969
+ sqliterc = find_xdg_file("XDG_CONFIG_HOME",
32970
+ ".config",
32971
+ "sqlite3/sqliterc");
3294632972
}
3294732973
if( sqliterc == NULL ){
3294832974
home_dir = find_home_dir(0);
3294932975
if( home_dir==0 ){
3295032976
eputz("-- warning: cannot find home directory;"
3295132977
" cannot read ~/.sqliterc\n");
3295232978
return;
3295332979
}
32954
- zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
32955
- shell_check_oom(zBuf);
32956
- sqliterc = zBuf;
32980
+ sqliterc = sqlite3_mprintf("%s/.sqliterc",home_dir);
32981
+ shell_check_oom(sqliterc);
3295732982
}
32958
- p->in = sqlite3_fopen(sqliterc,"rb");
32983
+ p->in = sqliterc ? sqlite3_fopen(sqliterc,"rb") : 0;
3295932984
if( p->in ){
3296032985
if( stdin_is_interactive ){
3296132986
sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
3296232987
}
3296332988
if( process_input(p) && bail_on_error ) exit(1);
@@ -32966,11 +32991,13 @@
3296632991
sqlite3_fprintf(stderr,"cannot open: \"%s\"\n", sqliterc);
3296732992
if( bail_on_error ) exit(1);
3296832993
}
3296932994
p->in = inSaved;
3297032995
p->lineno = savedLineno;
32971
- sqlite3_free(zBuf);
32996
+ if( sqliterc != sqliterc_override ){
32997
+ sqlite3_free(sqliterc);
32998
+ }
3297232999
}
3297333000
3297433001
/*
3297533002
** Show available command line options
3297633003
*/
@@ -33734,11 +33761,10 @@
3373433761
/* Run commands received from standard input
3373533762
*/
3373633763
if( stdin_is_interactive ){
3373733764
char *zHome;
3373833765
char *zHistory;
33739
- int nHistory;
3374033766
sqlite3_fprintf(stdout,
3374133767
"SQLite version %s %.19s\n" /*extra-version-info*/
3374233768
"Enter \".help\" for usage hints.\n",
3374333769
sqlite3_libversion(), sqlite3_sourceid());
3374433770
if( warnInmemoryDb ){
@@ -33747,15 +33773,19 @@
3374733773
sputz(stdout, ".\nUse \".open FILENAME\" to reopen on a"
3374833774
" persistent database.\n");
3374933775
}
3375033776
zHistory = getenv("SQLITE_HISTORY");
3375133777
if( zHistory ){
33752
- zHistory = strdup(zHistory);
33753
- }else if( (zHome = find_home_dir(0))!=0 ){
33754
- nHistory = strlen30(zHome) + 20;
33755
- if( (zHistory = malloc(nHistory))!=0 ){
33756
- sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
33778
+ zHistory = sqlite3_mprintf("%s", zHistory);
33779
+ shell_check_oom(zHistory);
33780
+ }else{
33781
+ zHistory = find_xdg_file("XDG_STATE_HOME",
33782
+ ".local/state",
33783
+ "sqlite_history");
33784
+ if( 0==zHistory && (zHome = find_home_dir(0))!=0 ){
33785
+ zHistory = sqlite3_mprintf("%s/.sqlite_history", zHome);
33786
+ shell_check_oom(zHistory);
3375733787
}
3375833788
}
3375933789
if( zHistory ){ shell_read_history(zHistory); }
3376033790
#if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION)
3376133791
rl_attempted_completion_function = readline_completion;
@@ -33767,11 +33797,11 @@
3376733797
data.in = 0;
3376833798
rc = process_input(&data);
3376933799
if( zHistory ){
3377033800
shell_stifle_history(2000);
3377133801
shell_write_history(zHistory);
33772
- free(zHistory);
33802
+ sqlite3_free(zHistory);
3377333803
}
3377433804
}else{
3377533805
data.in = stdin;
3377633806
rc = process_input(&data);
3377733807
}
3377833808
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -122,10 +122,13 @@
122 typedef sqlite3_int64 i64;
123 typedef sqlite3_uint64 u64;
124 typedef unsigned char u8;
125 #include <ctype.h>
126 #include <stdarg.h>
 
 
 
127
128 #if !defined(_WIN32) && !defined(WIN32)
129 # include <signal.h>
130 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
131 # include <pwd.h>
@@ -646,24 +649,27 @@
646 if( a==0 ) a = "";
647 if( b==0 ) b = "";
648 return strncmp(a,b,n);
649 }
650
651 /* Return the current wall-clock time */
 
 
652 static sqlite3_int64 timeOfDay(void){
653 static sqlite3_vfs *clockVfs = 0;
654 sqlite3_int64 t;
655 if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0);
656 if( clockVfs==0 ) return 0; /* Never actually happens */
657 if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){
658 clockVfs->xCurrentTimeInt64(clockVfs, &t);
659 }else{
660 double r;
661 clockVfs->xCurrentTime(clockVfs, &r);
662 t = (sqlite3_int64)(r*86400000.0);
663 }
664 return t;
 
 
 
 
 
665 }
666
667 #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
668 #include <sys/time.h>
669 #include <sys/resource.h>
@@ -704,12 +710,12 @@
704 static void endTimer(FILE *out){
705 if( enableTimer ){
706 sqlite3_int64 iEnd = timeOfDay();
707 struct rusage sEnd;
708 getrusage(RUSAGE_SELF, &sEnd);
709 sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
710 (iEnd - iBegin)*0.001,
711 timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
712 timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
713 }
714 }
715
@@ -783,12 +789,12 @@
783 static void endTimer(FILE *out){
784 if( enableTimer && getProcessTimesAddr){
785 FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
786 sqlite3_int64 ftWallEnd = timeOfDay();
787 getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
788 sqlite3_fprintf(out, "Run Time: real %.3f user %f sys %f\n",
789 (ftWallEnd - ftWallBegin)*0.001,
790 timeDiff(&ftUserBegin, &ftUserEnd),
791 timeDiff(&ftKernelBegin, &ftKernelEnd));
792 }
793 }
794
@@ -32888,76 +32894,95 @@
32888
32889 return home_dir;
32890 }
32891
32892 /*
32893 ** On non-Windows platforms, look for $XDG_CONFIG_HOME.
32894 ** If ${XDG_CONFIG_HOME}/sqlite3/sqliterc is found, return
32895 ** the path to it. If there is no $(XDG_CONFIG_HOME) then
32896 ** look for $(HOME)/.config/sqlite3/sqliterc and if found
32897 ** return that. If none of these are found, return 0.
 
 
 
 
 
 
 
 
 
 
 
 
 
32898 **
32899 ** The string returned is obtained from sqlite3_malloc() and
32900 ** should be freed by the caller.
32901 */
32902 static char *find_xdg_config(void){
 
32903 #if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \
32904 || defined(__RTP__) || defined(_WRS_KERNEL)
32905 return 0;
32906 #else
32907 char *zConfig = 0;
32908 const char *zXdgHome;
32909
32910 zXdgHome = getenv("XDG_CONFIG_HOME");
32911 if( zXdgHome==0 ){
32912 const char *zHome = getenv("HOME");
32913 if( zHome==0 ) return 0;
32914 zConfig = sqlite3_mprintf("%s/.config/sqlite3/sqliterc", zHome);
32915 }else{
32916 zConfig = sqlite3_mprintf("%s/sqlite3/sqliterc", zXdgHome);
32917 }
32918 shell_check_oom(zConfig);
32919 if( access(zConfig,0)!=0 ){
32920 sqlite3_free(zConfig);
32921 zConfig = 0;
32922 }
32923 return zConfig;
 
 
 
 
32924 #endif
32925 }
32926
32927 /*
32928 ** Read input from the file given by sqliterc_override. Or if that
32929 ** parameter is NULL, take input from the first of find_xdg_config()
32930 ** or ~/.sqliterc which is found.
32931 **
32932 ** Returns the number of errors.
 
 
 
32933 */
32934 static void process_sqliterc(
32935 ShellState *p, /* Configuration data */
32936 const char *sqliterc_override /* Name of config file. NULL to use default */
32937 ){
32938 char *home_dir = NULL;
32939 const char *sqliterc = sqliterc_override;
32940 char *zBuf = 0;
32941 FILE *inSaved = p->in;
32942 int savedLineno = p->lineno;
32943
32944 if( sqliterc == NULL ){
32945 sqliterc = zBuf = find_xdg_config();
 
 
32946 }
32947 if( sqliterc == NULL ){
32948 home_dir = find_home_dir(0);
32949 if( home_dir==0 ){
32950 eputz("-- warning: cannot find home directory;"
32951 " cannot read ~/.sqliterc\n");
32952 return;
32953 }
32954 zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir);
32955 shell_check_oom(zBuf);
32956 sqliterc = zBuf;
32957 }
32958 p->in = sqlite3_fopen(sqliterc,"rb");
32959 if( p->in ){
32960 if( stdin_is_interactive ){
32961 sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
32962 }
32963 if( process_input(p) && bail_on_error ) exit(1);
@@ -32966,11 +32991,13 @@
32966 sqlite3_fprintf(stderr,"cannot open: \"%s\"\n", sqliterc);
32967 if( bail_on_error ) exit(1);
32968 }
32969 p->in = inSaved;
32970 p->lineno = savedLineno;
32971 sqlite3_free(zBuf);
 
 
32972 }
32973
32974 /*
32975 ** Show available command line options
32976 */
@@ -33734,11 +33761,10 @@
33734 /* Run commands received from standard input
33735 */
33736 if( stdin_is_interactive ){
33737 char *zHome;
33738 char *zHistory;
33739 int nHistory;
33740 sqlite3_fprintf(stdout,
33741 "SQLite version %s %.19s\n" /*extra-version-info*/
33742 "Enter \".help\" for usage hints.\n",
33743 sqlite3_libversion(), sqlite3_sourceid());
33744 if( warnInmemoryDb ){
@@ -33747,15 +33773,19 @@
33747 sputz(stdout, ".\nUse \".open FILENAME\" to reopen on a"
33748 " persistent database.\n");
33749 }
33750 zHistory = getenv("SQLITE_HISTORY");
33751 if( zHistory ){
33752 zHistory = strdup(zHistory);
33753 }else if( (zHome = find_home_dir(0))!=0 ){
33754 nHistory = strlen30(zHome) + 20;
33755 if( (zHistory = malloc(nHistory))!=0 ){
33756 sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
 
 
 
 
33757 }
33758 }
33759 if( zHistory ){ shell_read_history(zHistory); }
33760 #if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION)
33761 rl_attempted_completion_function = readline_completion;
@@ -33767,11 +33797,11 @@
33767 data.in = 0;
33768 rc = process_input(&data);
33769 if( zHistory ){
33770 shell_stifle_history(2000);
33771 shell_write_history(zHistory);
33772 free(zHistory);
33773 }
33774 }else{
33775 data.in = stdin;
33776 rc = process_input(&data);
33777 }
33778
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -122,10 +122,13 @@
122 typedef sqlite3_int64 i64;
123 typedef sqlite3_uint64 u64;
124 typedef unsigned char u8;
125 #include <ctype.h>
126 #include <stdarg.h>
127 #ifndef _WIN32
128 # include <sys/time.h>
129 #endif
130
131 #if !defined(_WIN32) && !defined(WIN32)
132 # include <signal.h>
133 # if !defined(__RTP__) && !defined(_WRS_KERNEL) && !defined(SQLITE_WASI)
134 # include <pwd.h>
@@ -646,24 +649,27 @@
649 if( a==0 ) a = "";
650 if( b==0 ) b = "";
651 return strncmp(a,b,n);
652 }
653
654 /* Return the current wall-clock time in microseconds since the
655 ** Unix epoch (1970-01-01T00:00:00Z)
656 */
657 static sqlite3_int64 timeOfDay(void){
658 #if defined(_WIN32)
659 sqlite3_uint64 t;
660 FILETIME tm;
661 GetSystemTimePreciseAsFileTime(&tm);
662 t = ((u64)tm.dwHighDateTime<<32) | (u64)tm.dwLowDateTime;
663 t += 116444736000000000LL;
664 t /= 10;
 
 
 
 
665 return t;
666 #else
667 struct timeval sNow;
668 (void)gettimeofday(&sNow,0);
669 return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec;
670 #endif
671 }
672
673 #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
674 #include <sys/time.h>
675 #include <sys/resource.h>
@@ -704,12 +710,12 @@
710 static void endTimer(FILE *out){
711 if( enableTimer ){
712 sqlite3_int64 iEnd = timeOfDay();
713 struct rusage sEnd;
714 getrusage(RUSAGE_SELF, &sEnd);
715 sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n",
716 (iEnd - iBegin)*0.000001,
717 timeDiff(&sBegin.ru_utime, &sEnd.ru_utime),
718 timeDiff(&sBegin.ru_stime, &sEnd.ru_stime));
719 }
720 }
721
@@ -783,12 +789,12 @@
789 static void endTimer(FILE *out){
790 if( enableTimer && getProcessTimesAddr){
791 FILETIME ftCreation, ftExit, ftKernelEnd, ftUserEnd;
792 sqlite3_int64 ftWallEnd = timeOfDay();
793 getProcessTimesAddr(hProcess,&ftCreation,&ftExit,&ftKernelEnd,&ftUserEnd);
794 sqlite3_fprintf(out, "Run Time: real %.6f user %f sys %f\n",
795 (ftWallEnd - ftWallBegin)*0.000001,
796 timeDiff(&ftUserBegin, &ftUserEnd),
797 timeDiff(&ftKernelBegin, &ftKernelEnd));
798 }
799 }
800
@@ -32888,76 +32894,95 @@
32894
32895 return home_dir;
32896 }
32897
32898 /*
32899 ** On non-Windows platforms, look for:
32900 **
32901 ** - ${zEnvVar}/${zBaseName}
32902 ** - ${HOME}/${zSubdir}/${zBaseName}
32903 **
32904 ** $zEnvVar is intended to be the name of an XDG_... environment
32905 ** variable, e.g. XDG_CONFIG_HOME or XDG_STATE_HOME. If zEnvVar is
32906 ** NULL or getenv(zEnvVar) is NULL then fall back to the second
32907 ** option. If the selected option is not found in the filesystem,
32908 ** return 0.
32909 **
32910 ** zSubdir may be NULL or empty, in which case ${HOME}/${zBaseName}
32911 ** becomes the fallback.
32912 **
32913 ** Both zSubdir and zBaseName may contain subdirectory parts. zSubdir
32914 ** will conventionally be ".config" or ".local/state", which, not
32915 ** coincidentally, is the typical subdir of the corresponding XDG_...
32916 ** var with the XDG var's $HOME prefix.
32917 **
32918 ** The returned string is obtained from sqlite3_malloc() and should be
32919 ** sqlite3_free()'d by the caller.
32920 */
32921 static char *find_xdg_file(const char *zEnvVar, const char *zSubdir,
32922 const char *zBaseName){
32923 #if defined(_WIN32) || defined(WIN32) || defined(_WIN32_WCE) \
32924 || defined(__RTP__) || defined(_WRS_KERNEL)
32925 return 0;
32926 #else
32927 char *zConfigFile = 0;
32928 const char *zXdgDir;
32929
32930 zXdgDir = zEnvVar ? getenv(zEnvVar) : 0;
32931 if( zXdgDir ){
32932 zConfigFile = sqlite3_mprintf("%s/%s", zXdgDir, zBaseName);
 
 
32933 }else{
32934 const char * zHome = find_home_dir(0);
32935 if( zHome==0 ) return 0;
32936 zConfigFile = (zSubdir && *zSubdir)
32937 ? sqlite3_mprintf("%s/%s/%s", zHome, zSubdir, zBaseName)
32938 : sqlite3_mprintf("%s/%s", zHome, zBaseName);
32939 }
32940 shell_check_oom(zConfigFile);
32941 if( access(zConfigFile,0)!=0 ){
32942 sqlite3_free(zConfigFile);
32943 zConfigFile = 0;
32944 }
32945 return zConfigFile;
32946 #endif
32947 }
32948
32949 /*
32950 ** Read input from the file sqliterc_override. If that parameter is
32951 ** NULL, take it from find_xdg_file(), if found, or fall back to
32952 ** ~/.sqliterc.
32953 **
32954 ** Failure to read the config is only considered a failure if
32955 ** sqliterc_override is not NULL, in which case this function may emit
32956 ** a warning or, if ::bail_on_error is true, fail fatally if the file
32957 ** named by sqliterc_override is not found.
32958 */
32959 static void process_sqliterc(
32960 ShellState *p, /* Configuration data */
32961 const char *sqliterc_override /* Name of config file. NULL to use default */
32962 ){
32963 char *home_dir = NULL;
32964 char *sqliterc = (char*)sqliterc_override;
 
32965 FILE *inSaved = p->in;
32966 int savedLineno = p->lineno;
32967
32968 if( sqliterc == NULL ){
32969 sqliterc = find_xdg_file("XDG_CONFIG_HOME",
32970 ".config",
32971 "sqlite3/sqliterc");
32972 }
32973 if( sqliterc == NULL ){
32974 home_dir = find_home_dir(0);
32975 if( home_dir==0 ){
32976 eputz("-- warning: cannot find home directory;"
32977 " cannot read ~/.sqliterc\n");
32978 return;
32979 }
32980 sqliterc = sqlite3_mprintf("%s/.sqliterc",home_dir);
32981 shell_check_oom(sqliterc);
 
32982 }
32983 p->in = sqliterc ? sqlite3_fopen(sqliterc,"rb") : 0;
32984 if( p->in ){
32985 if( stdin_is_interactive ){
32986 sqlite3_fprintf(stderr,"-- Loading resources from %s\n", sqliterc);
32987 }
32988 if( process_input(p) && bail_on_error ) exit(1);
@@ -32966,11 +32991,13 @@
32991 sqlite3_fprintf(stderr,"cannot open: \"%s\"\n", sqliterc);
32992 if( bail_on_error ) exit(1);
32993 }
32994 p->in = inSaved;
32995 p->lineno = savedLineno;
32996 if( sqliterc != sqliterc_override ){
32997 sqlite3_free(sqliterc);
32998 }
32999 }
33000
33001 /*
33002 ** Show available command line options
33003 */
@@ -33734,11 +33761,10 @@
33761 /* Run commands received from standard input
33762 */
33763 if( stdin_is_interactive ){
33764 char *zHome;
33765 char *zHistory;
 
33766 sqlite3_fprintf(stdout,
33767 "SQLite version %s %.19s\n" /*extra-version-info*/
33768 "Enter \".help\" for usage hints.\n",
33769 sqlite3_libversion(), sqlite3_sourceid());
33770 if( warnInmemoryDb ){
@@ -33747,15 +33773,19 @@
33773 sputz(stdout, ".\nUse \".open FILENAME\" to reopen on a"
33774 " persistent database.\n");
33775 }
33776 zHistory = getenv("SQLITE_HISTORY");
33777 if( zHistory ){
33778 zHistory = sqlite3_mprintf("%s", zHistory);
33779 shell_check_oom(zHistory);
33780 }else{
33781 zHistory = find_xdg_file("XDG_STATE_HOME",
33782 ".local/state",
33783 "sqlite_history");
33784 if( 0==zHistory && (zHome = find_home_dir(0))!=0 ){
33785 zHistory = sqlite3_mprintf("%s/.sqlite_history", zHome);
33786 shell_check_oom(zHistory);
33787 }
33788 }
33789 if( zHistory ){ shell_read_history(zHistory); }
33790 #if (HAVE_READLINE || HAVE_EDITLINE) && !defined(SQLITE_OMIT_READLINE_COMPLETION)
33791 rl_attempted_completion_function = readline_completion;
@@ -33767,11 +33797,11 @@
33797 data.in = 0;
33798 rc = process_input(&data);
33799 if( zHistory ){
33800 shell_stifle_history(2000);
33801 shell_write_history(zHistory);
33802 sqlite3_free(zHistory);
33803 }
33804 }else{
33805 data.in = stdin;
33806 rc = process_input(&data);
33807 }
33808
+218 -154
--- 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
-** 9f184f8dfa5ef6d57e10376adc30e0060ced with changes in files:
21
+** cf7163f82ca380958a79350473b2c5a2cebd 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.51.0"
469469
#define SQLITE_VERSION_NUMBER 3051000
470
-#define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
470
+#define SQLITE_SOURCE_ID "2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -814,10 +814,13 @@
814814
** [sqlite3_extended_errcode()].
815815
*/
816816
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
817817
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
818818
#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
819
+#define SQLITE_ERROR_RESERVESIZE (SQLITE_ERROR | (4<<8))
820
+#define SQLITE_ERROR_KEY (SQLITE_ERROR | (5<<8))
821
+#define SQLITE_ERROR_UNABLE (SQLITE_ERROR | (6<<8))
819822
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
820823
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
821824
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
822825
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
823826
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -848,10 +851,12 @@
848851
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
849852
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
850853
#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
851854
#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
852855
#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
856
+#define SQLITE_IOERR_BADKEY (SQLITE_IOERR | (35<<8))
857
+#define SQLITE_IOERR_CODEC (SQLITE_IOERR | (36<<8))
853858
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
854859
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
855860
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
856861
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
857862
#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
@@ -19503,10 +19508,11 @@
1950319508
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1950419509
union {
1950519510
Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
1950619511
** for a column of an index on an expression */
1950719512
Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
19513
+ int nReg; /* TK_NULLS: Number of registers to NULL out */
1950819514
struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
1950919515
int iAddr; /* Subroutine entry address */
1951019516
int regReturn; /* Register used to hold return address */
1951119517
} sub;
1951219518
} y;
@@ -21540,10 +21546,11 @@
2154021546
SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
2154121547
#endif
2154221548
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
2154321549
SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
2154421550
SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(Parse*, Expr*, int);
21551
+SQLITE_PRIVATE void sqlite3ExprNullRegisterRange(Parse*, int, int);
2154521552
SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
2154621553
SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
2154721554
SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
2154821555
#define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
2154921556
#define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
@@ -24366,13 +24373,15 @@
2436624373
SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
2436724374
SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem*);
2436824375
#endif
2436924376
2437024377
#ifndef SQLITE_OMIT_FOREIGN_KEY
24371
-SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
24378
+SQLITE_PRIVATE int sqlite3VdbeCheckFkImmediate(Vdbe*);
24379
+SQLITE_PRIVATE int sqlite3VdbeCheckFkDeferred(Vdbe*);
2437224380
#else
24373
-# define sqlite3VdbeCheckFk(p,i) 0
24381
+# define sqlite3VdbeCheckFkImmediate(p) 0
24382
+# define sqlite3VdbeCheckFkDeferred(p) 0
2437424383
#endif
2437524384
2437624385
#ifdef SQLITE_DEBUG
2437724386
SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
2437824387
SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr);
@@ -32252,11 +32261,25 @@
3225232261
length = sqlite3Strlen30(bufpt);
3225332262
break;
3225432263
}
3225532264
}
3225632265
if( s.sign=='-' ){
32257
- prefix = '-';
32266
+ if( flag_alternateform
32267
+ && !flag_prefix
32268
+ && xtype==etFLOAT
32269
+ && s.iDP<=iRound
32270
+ ){
32271
+ /* Suppress the minus sign if all of the following are true:
32272
+ ** * The value displayed is zero
32273
+ ** * The '#' flag is used
32274
+ ** * The '+' flag is not used, and
32275
+ ** * The format is %f
32276
+ */
32277
+ prefix = 0;
32278
+ }else{
32279
+ prefix = '-';
32280
+ }
3225832281
}else{
3225932282
prefix = flag_prefix;
3226032283
}
3226132284
3226232285
exp = s.iDP-1;
@@ -51192,10 +51215,107 @@
5119251215
** on allocation size granularity boundaries.
5119351216
** During sqlite3_os_init() we do a GetSystemInfo()
5119451217
** to get the granularity size.
5119551218
*/
5119651219
static SYSTEM_INFO winSysInfo;
51220
+
51221
+/*
51222
+** Convert a UTF-8 filename into whatever form the underlying
51223
+** operating system wants filenames in. Space to hold the result
51224
+** is obtained from malloc and must be freed by the calling
51225
+** function
51226
+**
51227
+** On Cygwin, 3 possible input forms are accepted:
51228
+** - If the filename starts with "<drive>:/" or "<drive>:\",
51229
+** it is converted to UTF-16 as-is.
51230
+** - If the filename contains '/', it is assumed to be a
51231
+** Cygwin absolute path, it is converted to a win32
51232
+** absolute path in UTF-16.
51233
+** - Otherwise it must be a filename only, the win32 filename
51234
+** is returned in UTF-16.
51235
+** Note: If the function cygwin_conv_path() fails, only
51236
+** UTF-8 -> UTF-16 conversion will be done. This can only
51237
+** happen when the file path >32k, in which case winUtf8ToUnicode()
51238
+** will fail too.
51239
+*/
51240
+static void *winConvertFromUtf8Filename(const char *zFilename){
51241
+ void *zConverted = 0;
51242
+ if( osIsNT() ){
51243
+#ifdef __CYGWIN__
51244
+ int nChar;
51245
+ LPWSTR zWideFilename;
51246
+
51247
+ if( osCygwin_conv_path && !(winIsDriveLetterAndColon(zFilename)
51248
+ && winIsDirSep(zFilename[2])) ){
51249
+ i64 nByte;
51250
+ int convertflag = CCP_POSIX_TO_WIN_W;
51251
+ if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE;
51252
+ nByte = (i64)osCygwin_conv_path(convertflag,
51253
+ zFilename, 0, 0);
51254
+ if( nByte>0 ){
51255
+ zConverted = sqlite3MallocZero(12+(u64)nByte);
51256
+ if ( zConverted==0 ){
51257
+ return zConverted;
51258
+ }
51259
+ zWideFilename = zConverted;
51260
+ /* Filenames should be prefixed, except when converted
51261
+ * full path already starts with "\\?\". */
51262
+ if( osCygwin_conv_path(convertflag, zFilename,
51263
+ zWideFilename+4, nByte)==0 ){
51264
+ if( (convertflag&CCP_RELATIVE) ){
51265
+ memmove(zWideFilename, zWideFilename+4, nByte);
51266
+ }else if( memcmp(zWideFilename+4, L"\\\\", 4) ){
51267
+ memcpy(zWideFilename, L"\\\\?\\", 8);
51268
+ }else if( zWideFilename[6]!='?' ){
51269
+ memmove(zWideFilename+6, zWideFilename+4, nByte);
51270
+ memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51271
+ }else{
51272
+ memmove(zWideFilename, zWideFilename+4, nByte);
51273
+ }
51274
+ return zConverted;
51275
+ }
51276
+ sqlite3_free(zConverted);
51277
+ }
51278
+ }
51279
+ nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
51280
+ if( nChar==0 ){
51281
+ return 0;
51282
+ }
51283
+ zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+12 );
51284
+ if( zWideFilename==0 ){
51285
+ return 0;
51286
+ }
51287
+ nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
51288
+ zWideFilename, nChar);
51289
+ if( nChar==0 ){
51290
+ sqlite3_free(zWideFilename);
51291
+ zWideFilename = 0;
51292
+ }else if( nChar>MAX_PATH
51293
+ && winIsDriveLetterAndColon(zFilename)
51294
+ && winIsDirSep(zFilename[2]) ){
51295
+ memmove(zWideFilename+4, zWideFilename, nChar*sizeof(WCHAR));
51296
+ zWideFilename[2] = '\\';
51297
+ memcpy(zWideFilename, L"\\\\?\\", 8);
51298
+ }else if( nChar>MAX_PATH
51299
+ && winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
51300
+ && zFilename[2] != '?' ){
51301
+ memmove(zWideFilename+6, zWideFilename, nChar*sizeof(WCHAR));
51302
+ memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51303
+ }
51304
+ zConverted = zWideFilename;
51305
+#else
51306
+ zConverted = winUtf8ToUnicode(zFilename);
51307
+#endif /* __CYGWIN__ */
51308
+ }
51309
+#if defined(SQLITE_WIN32_HAS_ANSI) && defined(_WIN32)
51310
+ else{
51311
+ zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());
51312
+ }
51313
+#endif
51314
+ /* caller will handle out of memory */
51315
+ return zConverted;
51316
+}
5119751317
5119851318
#ifndef SQLITE_OMIT_WAL
5119951319
5120051320
/*
5120151321
** Helper functions to obtain and relinquish the global mutex. The
@@ -51387,107 +51507,10 @@
5138751507
5138851508
return rc;
5138951509
}
5139051510
5139151511
51392
-/*
51393
-** Convert a UTF-8 filename into whatever form the underlying
51394
-** operating system wants filenames in. Space to hold the result
51395
-** is obtained from malloc and must be freed by the calling
51396
-** function
51397
-**
51398
-** On Cygwin, 3 possible input forms are accepted:
51399
-** - If the filename starts with "<drive>:/" or "<drive>:\",
51400
-** it is converted to UTF-16 as-is.
51401
-** - If the filename contains '/', it is assumed to be a
51402
-** Cygwin absolute path, it is converted to a win32
51403
-** absolute path in UTF-16.
51404
-** - Otherwise it must be a filename only, the win32 filename
51405
-** is returned in UTF-16.
51406
-** Note: If the function cygwin_conv_path() fails, only
51407
-** UTF-8 -> UTF-16 conversion will be done. This can only
51408
-** happen when the file path >32k, in which case winUtf8ToUnicode()
51409
-** will fail too.
51410
-*/
51411
-static void *winConvertFromUtf8Filename(const char *zFilename){
51412
- void *zConverted = 0;
51413
- if( osIsNT() ){
51414
-#ifdef __CYGWIN__
51415
- int nChar;
51416
- LPWSTR zWideFilename;
51417
-
51418
- if( osCygwin_conv_path && !(winIsDriveLetterAndColon(zFilename)
51419
- && winIsDirSep(zFilename[2])) ){
51420
- i64 nByte;
51421
- int convertflag = CCP_POSIX_TO_WIN_W;
51422
- if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE;
51423
- nByte = (i64)osCygwin_conv_path(convertflag,
51424
- zFilename, 0, 0);
51425
- if( nByte>0 ){
51426
- zConverted = sqlite3MallocZero(12+(u64)nByte);
51427
- if ( zConverted==0 ){
51428
- return zConverted;
51429
- }
51430
- zWideFilename = zConverted;
51431
- /* Filenames should be prefixed, except when converted
51432
- * full path already starts with "\\?\". */
51433
- if( osCygwin_conv_path(convertflag, zFilename,
51434
- zWideFilename+4, nByte)==0 ){
51435
- if( (convertflag&CCP_RELATIVE) ){
51436
- memmove(zWideFilename, zWideFilename+4, nByte);
51437
- }else if( memcmp(zWideFilename+4, L"\\\\", 4) ){
51438
- memcpy(zWideFilename, L"\\\\?\\", 8);
51439
- }else if( zWideFilename[6]!='?' ){
51440
- memmove(zWideFilename+6, zWideFilename+4, nByte);
51441
- memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51442
- }else{
51443
- memmove(zWideFilename, zWideFilename+4, nByte);
51444
- }
51445
- return zConverted;
51446
- }
51447
- sqlite3_free(zConverted);
51448
- }
51449
- }
51450
- nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
51451
- if( nChar==0 ){
51452
- return 0;
51453
- }
51454
- zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+12 );
51455
- if( zWideFilename==0 ){
51456
- return 0;
51457
- }
51458
- nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
51459
- zWideFilename, nChar);
51460
- if( nChar==0 ){
51461
- sqlite3_free(zWideFilename);
51462
- zWideFilename = 0;
51463
- }else if( nChar>MAX_PATH
51464
- && winIsDriveLetterAndColon(zFilename)
51465
- && winIsDirSep(zFilename[2]) ){
51466
- memmove(zWideFilename+4, zWideFilename, nChar*sizeof(WCHAR));
51467
- zWideFilename[2] = '\\';
51468
- memcpy(zWideFilename, L"\\\\?\\", 8);
51469
- }else if( nChar>MAX_PATH
51470
- && winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
51471
- && zFilename[2] != '?' ){
51472
- memmove(zWideFilename+6, zWideFilename, nChar*sizeof(WCHAR));
51473
- memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51474
- }
51475
- zConverted = zWideFilename;
51476
-#else
51477
- zConverted = winUtf8ToUnicode(zFilename);
51478
-#endif /* __CYGWIN__ */
51479
- }
51480
-#if defined(SQLITE_WIN32_HAS_ANSI) && defined(_WIN32)
51481
- else{
51482
- zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());
51483
- }
51484
-#endif
51485
- /* caller will handle out of memory */
51486
- return zConverted;
51487
-}
51488
-
5148951512
/*
5149051513
** This function is used to open a handle on a *-shm file.
5149151514
**
5149251515
** If SQLITE_ENABLE_SETLK_TIMEOUT is defined at build time, then the file
5149351516
** is opened with FILE_FLAG_OVERLAPPED specified. If not, it is not.
@@ -89078,14 +89101,16 @@
8907889101
** simple case then too.
8907989102
*/
8908089103
if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
8908189104
|| nTrans<=1
8908289105
){
89083
- for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89084
- Btree *pBt = db->aDb[i].pBt;
89085
- if( pBt ){
89086
- rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
89106
+ if( needXcommit ){
89107
+ for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89108
+ Btree *pBt = db->aDb[i].pBt;
89109
+ if( sqlite3BtreeTxnState(pBt)>=SQLITE_TXN_WRITE ){
89110
+ rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
89111
+ }
8908789112
}
8908889113
}
8908989114
8909089115
/* Do the commit only if all databases successfully complete phase 1.
8909189116
** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
@@ -89092,11 +89117,13 @@
8909289117
** IO error while deleting or truncating a journal file. It is unlikely,
8909389118
** but could happen. In this case abandon processing and return the error.
8909489119
*/
8909589120
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
8909689121
Btree *pBt = db->aDb[i].pBt;
89097
- if( pBt ){
89122
+ int txn = sqlite3BtreeTxnState(pBt);
89123
+ if( txn!=SQLITE_TXN_NONE ){
89124
+ assert( needXcommit || txn==SQLITE_TXN_READ );
8909889125
rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);
8909989126
}
8910089127
}
8910189128
if( rc==SQLITE_OK ){
8910289129
sqlite3VtabCommit(db);
@@ -89347,32 +89374,35 @@
8934789374
return SQLITE_OK;
8934889375
}
8934989376
8935089377
8935189378
/*
89352
-** This function is called when a transaction opened by the database
89379
+** These functions are called when a transaction opened by the database
8935389380
** handle associated with the VM passed as an argument is about to be
89354
-** committed. If there are outstanding deferred foreign key constraint
89355
-** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.
89381
+** committed. If there are outstanding foreign key constraint violations
89382
+** return an error code. Otherwise, SQLITE_OK.
8935689383
**
8935789384
** If there are outstanding FK violations and this function returns
89358
-** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
89359
-** and write an error message to it. Then return SQLITE_ERROR.
89385
+** non-zero, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
89386
+** and write an error message to it.
8936089387
*/
8936189388
#ifndef SQLITE_OMIT_FOREIGN_KEY
89362
-SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
89389
+static SQLITE_NOINLINE int vdbeFkError(Vdbe *p){
89390
+ p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
89391
+ p->errorAction = OE_Abort;
89392
+ sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
89393
+ if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)==0 ) return SQLITE_ERROR;
89394
+ return SQLITE_CONSTRAINT_FOREIGNKEY;
89395
+}
89396
+SQLITE_PRIVATE int sqlite3VdbeCheckFkImmediate(Vdbe *p){
89397
+ if( p->nFkConstraint==0 ) return SQLITE_OK;
89398
+ return vdbeFkError(p);
89399
+}
89400
+SQLITE_PRIVATE int sqlite3VdbeCheckFkDeferred(Vdbe *p){
8936389401
sqlite3 *db = p->db;
89364
- if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0)
89365
- || (!deferred && p->nFkConstraint>0)
89366
- ){
89367
- p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
89368
- p->errorAction = OE_Abort;
89369
- sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
89370
- if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)==0 ) return SQLITE_ERROR;
89371
- return SQLITE_CONSTRAINT_FOREIGNKEY;
89372
- }
89373
- return SQLITE_OK;
89402
+ if( (db->nDeferredCons+db->nDeferredImmCons)==0 ) return SQLITE_OK;
89403
+ return vdbeFkError(p);
8937489404
}
8937589405
#endif
8937689406
8937789407
/*
8937889408
** This routine is called the when a VDBE tries to halt. If the VDBE
@@ -89462,11 +89492,11 @@
8946289492
}
8946389493
}
8946489494
8946589495
/* Check for immediate foreign key violations. */
8946689496
if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89467
- (void)sqlite3VdbeCheckFk(p, 0);
89497
+ (void)sqlite3VdbeCheckFkImmediate(p);
8946889498
}
8946989499
8947089500
/* If the auto-commit flag is set and this is the only active writer
8947189501
** VM, then we do either a commit or rollback of the current transaction.
8947289502
**
@@ -89476,11 +89506,11 @@
8947689506
if( !sqlite3VtabInSync(db)
8947789507
&& db->autoCommit
8947889508
&& db->nVdbeWrite==(p->readOnly==0)
8947989509
){
8948089510
if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89481
- rc = sqlite3VdbeCheckFk(p, 1);
89511
+ rc = sqlite3VdbeCheckFkDeferred(p);
8948289512
if( rc!=SQLITE_OK ){
8948389513
if( NEVER(p->readOnly) ){
8948489514
sqlite3VdbeLeave(p);
8948589515
return SQLITE_ERROR;
8948689516
}
@@ -90341,19 +90371,19 @@
9034190371
/* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
9034290372
pMem->szMalloc = 0;
9034390373
pMem->z = 0;
9034490374
sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
9034590375
d += sqlite3VdbeSerialTypeLen(serial_type);
90346
- pMem++;
9034790376
if( (++u)>=p->nField ) break;
90377
+ pMem++;
9034890378
}
9034990379
if( d>(u32)nKey && u ){
9035090380
assert( CORRUPT_DB );
9035190381
/* In a corrupt record entry, the last pMem might have been set up using
9035290382
** uninitialized memory. Overwrite its value with NULL, to prevent
9035390383
** warnings from MSAN. */
90354
- sqlite3VdbeMemSetNull(pMem-1);
90384
+ sqlite3VdbeMemSetNull(pMem-(u<p->nField));
9035590385
}
9035690386
testcase( u == pKeyInfo->nKeyField + 1 );
9035790387
testcase( u < pKeyInfo->nKeyField + 1 );
9035890388
assert( u<=pKeyInfo->nKeyField + 1 );
9035990389
p->nField = u;
@@ -90520,10 +90550,36 @@
9052090550
** Both *pMem1 and *pMem2 contain string values. Compare the two values
9052190551
** using the collation sequence pColl. As usual, return a negative , zero
9052290552
** or positive value if *pMem1 is less than, equal to or greater than
9052390553
** *pMem2, respectively. Similar in spirit to "rc = (*pMem1) - (*pMem2);".
9052490554
*/
90555
+static SQLITE_NOINLINE int vdbeCompareMemStringWithEncodingChange(
90556
+ const Mem *pMem1,
90557
+ const Mem *pMem2,
90558
+ const CollSeq *pColl,
90559
+ u8 *prcErr /* If an OOM occurs, set to SQLITE_NOMEM */
90560
+){
90561
+ int rc;
90562
+ const void *v1, *v2;
90563
+ Mem c1;
90564
+ Mem c2;
90565
+ sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
90566
+ sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
90567
+ sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
90568
+ sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
90569
+ v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
90570
+ v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
90571
+ if( (v1==0 || v2==0) ){
90572
+ if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
90573
+ rc = 0;
90574
+ }else{
90575
+ rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
90576
+ }
90577
+ sqlite3VdbeMemReleaseMalloc(&c1);
90578
+ sqlite3VdbeMemReleaseMalloc(&c2);
90579
+ return rc;
90580
+}
9052590581
static int vdbeCompareMemString(
9052690582
const Mem *pMem1,
9052790583
const Mem *pMem2,
9052890584
const CollSeq *pColl,
9052990585
u8 *prcErr /* If an OOM occurs, set to SQLITE_NOMEM */
@@ -90531,29 +90587,11 @@
9053190587
if( pMem1->enc==pColl->enc ){
9053290588
/* The strings are already in the correct encoding. Call the
9053390589
** comparison function directly */
9053490590
return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
9053590591
}else{
90536
- int rc;
90537
- const void *v1, *v2;
90538
- Mem c1;
90539
- Mem c2;
90540
- sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
90541
- sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
90542
- sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
90543
- sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
90544
- v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
90545
- v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
90546
- if( (v1==0 || v2==0) ){
90547
- if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
90548
- rc = 0;
90549
- }else{
90550
- rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
90551
- }
90552
- sqlite3VdbeMemReleaseMalloc(&c1);
90553
- sqlite3VdbeMemReleaseMalloc(&c2);
90554
- return rc;
90592
+ return vdbeCompareMemStringWithEncodingChange(pMem1,pMem2,pColl,prcErr);
9055590593
}
9055690594
}
9055790595
9055890596
/*
9055990597
** The input pBlob is guaranteed to be a Blob that is not marked
@@ -96256,11 +96294,11 @@
9625696294
** exits. This opcode is used to raise foreign key constraint errors prior
9625796295
** to returning results such as a row change count or the result of a
9625896296
** RETURNING clause.
9625996297
*/
9626096298
case OP_FkCheck: {
96261
- if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
96299
+ if( (rc = sqlite3VdbeCheckFkImmediate(p))!=SQLITE_OK ){
9626296300
goto abort_due_to_error;
9626396301
}
9626496302
break;
9626596303
}
9626696304
@@ -98440,11 +98478,11 @@
9844098478
** and this is a RELEASE command, then the current transaction
9844198479
** is committed.
9844298480
*/
9844398481
int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;
9844498482
if( isTransaction && p1==SAVEPOINT_RELEASE ){
98445
- if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
98483
+ if( (rc = sqlite3VdbeCheckFkDeferred(p))!=SQLITE_OK ){
9844698484
goto vdbe_return;
9844798485
}
9844898486
db->autoCommit = 1;
9844998487
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
9845098488
p->pc = (int)(pOp - aOp);
@@ -98558,11 +98596,11 @@
9855898596
*/
9855998597
sqlite3VdbeError(p, "cannot commit transaction - "
9856098598
"SQL statements in progress");
9856198599
rc = SQLITE_BUSY;
9856298600
goto abort_due_to_error;
98563
- }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
98601
+ }else if( (rc = sqlite3VdbeCheckFkDeferred(p))!=SQLITE_OK ){
9856498602
goto vdbe_return;
9856598603
}else{
9856698604
db->autoCommit = (u8)desiredAutoCommit;
9856798605
}
9856898606
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
@@ -109256,12 +109294,12 @@
109256109294
assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
109257109295
if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
109258109296
109259109297
/*
109260109298
** Expression p should encode a floating point value between 1.0 and 0.0.
109261
-** Return 1024 times this value. Or return -1 if p is not a floating point
109262
-** value between 1.0 and 0.0.
109299
+** Return 134,217,728 (2^27) times this value. Or return -1 if p is not
109300
+** a floating point value between 1.0 and 0.0.
109263109301
*/
109264109302
static int exprProbability(Expr *p){
109265109303
double r = -1.0;
109266109304
if( p->op!=TK_FLOAT ) return -1;
109267109305
assert( !ExprHasProperty(p, EP_IntValue) );
@@ -115633,10 +115671,16 @@
115633115671
case TK_STRING: {
115634115672
assert( !ExprHasProperty(pExpr, EP_IntValue) );
115635115673
sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
115636115674
return target;
115637115675
}
115676
+ case TK_NULLS: {
115677
+ /* Set a range of registers to NULL. pExpr->y.nReg registers starting
115678
+ ** with target */
115679
+ sqlite3VdbeAddOp3(v, OP_Null, 0, target, target + pExpr->y.nReg - 1);
115680
+ return target;
115681
+ }
115638115682
default: {
115639115683
/* Make NULL the default case so that if a bug causes an illegal
115640115684
** Expr node to be passed into this function, it will be handled
115641115685
** sanely and not crash. But keep the assert() to bring the problem
115642115686
** to the attention of the developers. */
@@ -116341,10 +116385,29 @@
116341116385
}
116342116386
pParse->pConstExpr = p;
116343116387
}
116344116388
return regDest;
116345116389
}
116390
+
116391
+/*
116392
+** Make arrangements to invoke OP_Null on a range of registers
116393
+** during initialization.
116394
+*/
116395
+SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3ExprNullRegisterRange(
116396
+ Parse *pParse, /* Parsing context */
116397
+ int iReg, /* First register to set to NULL */
116398
+ int nReg /* Number of sequential registers to NULL out */
116399
+){
116400
+ u8 okConstFactor = pParse->okConstFactor;
116401
+ Expr t;
116402
+ memset(&t, 0, sizeof(t));
116403
+ t.op = TK_NULLS;
116404
+ t.y.nReg = nReg;
116405
+ pParse->okConstFactor = 1;
116406
+ sqlite3ExprCodeRunJustOnce(pParse, &t, iReg);
116407
+ pParse->okConstFactor = okConstFactor;
116408
+}
116346116409
116347116410
/*
116348116411
** Generate code to evaluate an expression and store the results
116349116412
** into a register. Return the register number where the results
116350116413
** are stored.
@@ -152746,10 +152809,11 @@
152746152809
Select *pSub = pWhere->x.pSelect;
152747152810
Expr *pSubWhere = pSub->pWhere;
152748152811
if( pSub->pSrc->nSrc==1
152749152812
&& (pSub->selFlags & SF_Aggregate)==0
152750152813
&& !pSub->pSrc->a[0].fg.isSubquery
152814
+ && pSub->pLimit==0
152751152815
){
152752152816
memset(pWhere, 0, sizeof(*pWhere));
152753152817
pWhere->op = TK_INTEGER;
152754152818
pWhere->u.iValue = 1;
152755152819
ExprSetProperty(pWhere, EP_IntValue);
@@ -153766,10 +153830,11 @@
153766153830
iBMem = pParse->nMem + 1;
153767153831
pParse->nMem += pGroupBy->nExpr;
153768153832
sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
153769153833
VdbeComment((v, "clear abort flag"));
153770153834
sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
153835
+ sqlite3ExprNullRegisterRange(pParse, iAMem, pGroupBy->nExpr);
153771153836
153772153837
/* Begin a loop that will extract all source rows in GROUP BY order.
153773153838
** This might involve two separate loops with an OP_Sort in between, or
153774153839
** it might be a single loop that uses an index to extract information
153775153840
** in the right order to begin with.
@@ -169084,10 +169149,11 @@
169084169149
if( pProbe->bNoQuery ) continue;
169085169150
rSize = pProbe->aiRowLogEst[0];
169086169151
pNew->u.btree.nEq = 0;
169087169152
pNew->u.btree.nBtm = 0;
169088169153
pNew->u.btree.nTop = 0;
169154
+ pNew->u.btree.nDistinctCol = 0;
169089169155
pNew->nSkip = 0;
169090169156
pNew->nLTerm = 0;
169091169157
pNew->iSortIdx = 0;
169092169158
pNew->rSetup = 0;
169093169159
pNew->prereq = mPrereq;
@@ -170152,12 +170218,10 @@
170152170218
&& ((wctrlFlags&(WHERE_DISTINCTBY|WHERE_SORTBYGROUP))!=WHERE_DISTINCTBY)
170153170219
){
170154170220
obSat = obDone;
170155170221
}
170156170222
break;
170157
- }else if( wctrlFlags & WHERE_DISTINCTBY ){
170158
- pLoop->u.btree.nDistinctCol = 0;
170159170223
}
170160170224
iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
170161170225
170162170226
/* Mark off any ORDER BY term X that is a column in the table of
170163170227
** the current loop for which there is term in the WHERE
@@ -258113,11 +258177,11 @@
258113258177
int nArg, /* Number of args */
258114258178
sqlite3_value **apUnused /* Function arguments */
258115258179
){
258116258180
assert( nArg==0 );
258117258181
UNUSED_PARAM2(nArg, apUnused);
258118
- sqlite3_result_text(pCtx, "fts5: 2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839", -1, SQLITE_TRANSIENT);
258182
+ sqlite3_result_text(pCtx, "fts5: 2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1", -1, SQLITE_TRANSIENT);
258119258183
}
258120258184
258121258185
/*
258122258186
** Implementation of fts5_locale(LOCALE, TEXT) function.
258123258187
**
258124258188
--- 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 ** 9f184f8dfa5ef6d57e10376adc30e0060ced 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.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -814,10 +814,13 @@
814 ** [sqlite3_extended_errcode()].
815 */
816 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
817 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
818 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
 
 
 
819 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
820 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
821 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
822 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
823 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -848,10 +851,12 @@
848 #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
849 #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
850 #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
851 #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
852 #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
 
 
853 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
854 #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
855 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
856 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
857 #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
@@ -19503,10 +19508,11 @@
19503 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
19504 union {
19505 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
19506 ** for a column of an index on an expression */
19507 Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
 
19508 struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
19509 int iAddr; /* Subroutine entry address */
19510 int regReturn; /* Register used to hold return address */
19511 } sub;
19512 } y;
@@ -21540,10 +21546,11 @@
21540 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
21541 #endif
21542 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
21543 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
21544 SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(Parse*, Expr*, int);
 
21545 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
21546 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
21547 SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
21548 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
21549 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
@@ -24366,13 +24373,15 @@
24366 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
24367 SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem*);
24368 #endif
24369
24370 #ifndef SQLITE_OMIT_FOREIGN_KEY
24371 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *, int);
 
24372 #else
24373 # define sqlite3VdbeCheckFk(p,i) 0
 
24374 #endif
24375
24376 #ifdef SQLITE_DEBUG
24377 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
24378 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr);
@@ -32252,11 +32261,25 @@
32252 length = sqlite3Strlen30(bufpt);
32253 break;
32254 }
32255 }
32256 if( s.sign=='-' ){
32257 prefix = '-';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32258 }else{
32259 prefix = flag_prefix;
32260 }
32261
32262 exp = s.iDP-1;
@@ -51192,10 +51215,107 @@
51192 ** on allocation size granularity boundaries.
51193 ** During sqlite3_os_init() we do a GetSystemInfo()
51194 ** to get the granularity size.
51195 */
51196 static SYSTEM_INFO winSysInfo;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51197
51198 #ifndef SQLITE_OMIT_WAL
51199
51200 /*
51201 ** Helper functions to obtain and relinquish the global mutex. The
@@ -51387,107 +51507,10 @@
51387
51388 return rc;
51389 }
51390
51391
51392 /*
51393 ** Convert a UTF-8 filename into whatever form the underlying
51394 ** operating system wants filenames in. Space to hold the result
51395 ** is obtained from malloc and must be freed by the calling
51396 ** function
51397 **
51398 ** On Cygwin, 3 possible input forms are accepted:
51399 ** - If the filename starts with "<drive>:/" or "<drive>:\",
51400 ** it is converted to UTF-16 as-is.
51401 ** - If the filename contains '/', it is assumed to be a
51402 ** Cygwin absolute path, it is converted to a win32
51403 ** absolute path in UTF-16.
51404 ** - Otherwise it must be a filename only, the win32 filename
51405 ** is returned in UTF-16.
51406 ** Note: If the function cygwin_conv_path() fails, only
51407 ** UTF-8 -> UTF-16 conversion will be done. This can only
51408 ** happen when the file path >32k, in which case winUtf8ToUnicode()
51409 ** will fail too.
51410 */
51411 static void *winConvertFromUtf8Filename(const char *zFilename){
51412 void *zConverted = 0;
51413 if( osIsNT() ){
51414 #ifdef __CYGWIN__
51415 int nChar;
51416 LPWSTR zWideFilename;
51417
51418 if( osCygwin_conv_path && !(winIsDriveLetterAndColon(zFilename)
51419 && winIsDirSep(zFilename[2])) ){
51420 i64 nByte;
51421 int convertflag = CCP_POSIX_TO_WIN_W;
51422 if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE;
51423 nByte = (i64)osCygwin_conv_path(convertflag,
51424 zFilename, 0, 0);
51425 if( nByte>0 ){
51426 zConverted = sqlite3MallocZero(12+(u64)nByte);
51427 if ( zConverted==0 ){
51428 return zConverted;
51429 }
51430 zWideFilename = zConverted;
51431 /* Filenames should be prefixed, except when converted
51432 * full path already starts with "\\?\". */
51433 if( osCygwin_conv_path(convertflag, zFilename,
51434 zWideFilename+4, nByte)==0 ){
51435 if( (convertflag&CCP_RELATIVE) ){
51436 memmove(zWideFilename, zWideFilename+4, nByte);
51437 }else if( memcmp(zWideFilename+4, L"\\\\", 4) ){
51438 memcpy(zWideFilename, L"\\\\?\\", 8);
51439 }else if( zWideFilename[6]!='?' ){
51440 memmove(zWideFilename+6, zWideFilename+4, nByte);
51441 memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51442 }else{
51443 memmove(zWideFilename, zWideFilename+4, nByte);
51444 }
51445 return zConverted;
51446 }
51447 sqlite3_free(zConverted);
51448 }
51449 }
51450 nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
51451 if( nChar==0 ){
51452 return 0;
51453 }
51454 zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+12 );
51455 if( zWideFilename==0 ){
51456 return 0;
51457 }
51458 nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
51459 zWideFilename, nChar);
51460 if( nChar==0 ){
51461 sqlite3_free(zWideFilename);
51462 zWideFilename = 0;
51463 }else if( nChar>MAX_PATH
51464 && winIsDriveLetterAndColon(zFilename)
51465 && winIsDirSep(zFilename[2]) ){
51466 memmove(zWideFilename+4, zWideFilename, nChar*sizeof(WCHAR));
51467 zWideFilename[2] = '\\';
51468 memcpy(zWideFilename, L"\\\\?\\", 8);
51469 }else if( nChar>MAX_PATH
51470 && winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
51471 && zFilename[2] != '?' ){
51472 memmove(zWideFilename+6, zWideFilename, nChar*sizeof(WCHAR));
51473 memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51474 }
51475 zConverted = zWideFilename;
51476 #else
51477 zConverted = winUtf8ToUnicode(zFilename);
51478 #endif /* __CYGWIN__ */
51479 }
51480 #if defined(SQLITE_WIN32_HAS_ANSI) && defined(_WIN32)
51481 else{
51482 zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());
51483 }
51484 #endif
51485 /* caller will handle out of memory */
51486 return zConverted;
51487 }
51488
51489 /*
51490 ** This function is used to open a handle on a *-shm file.
51491 **
51492 ** If SQLITE_ENABLE_SETLK_TIMEOUT is defined at build time, then the file
51493 ** is opened with FILE_FLAG_OVERLAPPED specified. If not, it is not.
@@ -89078,14 +89101,16 @@
89078 ** simple case then too.
89079 */
89080 if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
89081 || nTrans<=1
89082 ){
89083 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89084 Btree *pBt = db->aDb[i].pBt;
89085 if( pBt ){
89086 rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
 
 
89087 }
89088 }
89089
89090 /* Do the commit only if all databases successfully complete phase 1.
89091 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
@@ -89092,11 +89117,13 @@
89092 ** IO error while deleting or truncating a journal file. It is unlikely,
89093 ** but could happen. In this case abandon processing and return the error.
89094 */
89095 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89096 Btree *pBt = db->aDb[i].pBt;
89097 if( pBt ){
 
 
89098 rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);
89099 }
89100 }
89101 if( rc==SQLITE_OK ){
89102 sqlite3VtabCommit(db);
@@ -89347,32 +89374,35 @@
89347 return SQLITE_OK;
89348 }
89349
89350
89351 /*
89352 ** This function is called when a transaction opened by the database
89353 ** handle associated with the VM passed as an argument is about to be
89354 ** committed. If there are outstanding deferred foreign key constraint
89355 ** violations, return SQLITE_ERROR. Otherwise, SQLITE_OK.
89356 **
89357 ** If there are outstanding FK violations and this function returns
89358 ** SQLITE_ERROR, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
89359 ** and write an error message to it. Then return SQLITE_ERROR.
89360 */
89361 #ifndef SQLITE_OMIT_FOREIGN_KEY
89362 SQLITE_PRIVATE int sqlite3VdbeCheckFk(Vdbe *p, int deferred){
 
 
 
 
 
 
 
 
 
 
 
89363 sqlite3 *db = p->db;
89364 if( (deferred && (db->nDeferredCons+db->nDeferredImmCons)>0)
89365 || (!deferred && p->nFkConstraint>0)
89366 ){
89367 p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
89368 p->errorAction = OE_Abort;
89369 sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
89370 if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)==0 ) return SQLITE_ERROR;
89371 return SQLITE_CONSTRAINT_FOREIGNKEY;
89372 }
89373 return SQLITE_OK;
89374 }
89375 #endif
89376
89377 /*
89378 ** This routine is called the when a VDBE tries to halt. If the VDBE
@@ -89462,11 +89492,11 @@
89462 }
89463 }
89464
89465 /* Check for immediate foreign key violations. */
89466 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89467 (void)sqlite3VdbeCheckFk(p, 0);
89468 }
89469
89470 /* If the auto-commit flag is set and this is the only active writer
89471 ** VM, then we do either a commit or rollback of the current transaction.
89472 **
@@ -89476,11 +89506,11 @@
89476 if( !sqlite3VtabInSync(db)
89477 && db->autoCommit
89478 && db->nVdbeWrite==(p->readOnly==0)
89479 ){
89480 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89481 rc = sqlite3VdbeCheckFk(p, 1);
89482 if( rc!=SQLITE_OK ){
89483 if( NEVER(p->readOnly) ){
89484 sqlite3VdbeLeave(p);
89485 return SQLITE_ERROR;
89486 }
@@ -90341,19 +90371,19 @@
90341 /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
90342 pMem->szMalloc = 0;
90343 pMem->z = 0;
90344 sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
90345 d += sqlite3VdbeSerialTypeLen(serial_type);
90346 pMem++;
90347 if( (++u)>=p->nField ) break;
 
90348 }
90349 if( d>(u32)nKey && u ){
90350 assert( CORRUPT_DB );
90351 /* In a corrupt record entry, the last pMem might have been set up using
90352 ** uninitialized memory. Overwrite its value with NULL, to prevent
90353 ** warnings from MSAN. */
90354 sqlite3VdbeMemSetNull(pMem-1);
90355 }
90356 testcase( u == pKeyInfo->nKeyField + 1 );
90357 testcase( u < pKeyInfo->nKeyField + 1 );
90358 assert( u<=pKeyInfo->nKeyField + 1 );
90359 p->nField = u;
@@ -90520,10 +90550,36 @@
90520 ** Both *pMem1 and *pMem2 contain string values. Compare the two values
90521 ** using the collation sequence pColl. As usual, return a negative , zero
90522 ** or positive value if *pMem1 is less than, equal to or greater than
90523 ** *pMem2, respectively. Similar in spirit to "rc = (*pMem1) - (*pMem2);".
90524 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90525 static int vdbeCompareMemString(
90526 const Mem *pMem1,
90527 const Mem *pMem2,
90528 const CollSeq *pColl,
90529 u8 *prcErr /* If an OOM occurs, set to SQLITE_NOMEM */
@@ -90531,29 +90587,11 @@
90531 if( pMem1->enc==pColl->enc ){
90532 /* The strings are already in the correct encoding. Call the
90533 ** comparison function directly */
90534 return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
90535 }else{
90536 int rc;
90537 const void *v1, *v2;
90538 Mem c1;
90539 Mem c2;
90540 sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
90541 sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
90542 sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
90543 sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
90544 v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
90545 v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
90546 if( (v1==0 || v2==0) ){
90547 if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
90548 rc = 0;
90549 }else{
90550 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
90551 }
90552 sqlite3VdbeMemReleaseMalloc(&c1);
90553 sqlite3VdbeMemReleaseMalloc(&c2);
90554 return rc;
90555 }
90556 }
90557
90558 /*
90559 ** The input pBlob is guaranteed to be a Blob that is not marked
@@ -96256,11 +96294,11 @@
96256 ** exits. This opcode is used to raise foreign key constraint errors prior
96257 ** to returning results such as a row change count or the result of a
96258 ** RETURNING clause.
96259 */
96260 case OP_FkCheck: {
96261 if( (rc = sqlite3VdbeCheckFk(p,0))!=SQLITE_OK ){
96262 goto abort_due_to_error;
96263 }
96264 break;
96265 }
96266
@@ -98440,11 +98478,11 @@
98440 ** and this is a RELEASE command, then the current transaction
98441 ** is committed.
98442 */
98443 int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;
98444 if( isTransaction && p1==SAVEPOINT_RELEASE ){
98445 if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
98446 goto vdbe_return;
98447 }
98448 db->autoCommit = 1;
98449 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
98450 p->pc = (int)(pOp - aOp);
@@ -98558,11 +98596,11 @@
98558 */
98559 sqlite3VdbeError(p, "cannot commit transaction - "
98560 "SQL statements in progress");
98561 rc = SQLITE_BUSY;
98562 goto abort_due_to_error;
98563 }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
98564 goto vdbe_return;
98565 }else{
98566 db->autoCommit = (u8)desiredAutoCommit;
98567 }
98568 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
@@ -109256,12 +109294,12 @@
109256 assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
109257 if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
109258
109259 /*
109260 ** Expression p should encode a floating point value between 1.0 and 0.0.
109261 ** Return 1024 times this value. Or return -1 if p is not a floating point
109262 ** value between 1.0 and 0.0.
109263 */
109264 static int exprProbability(Expr *p){
109265 double r = -1.0;
109266 if( p->op!=TK_FLOAT ) return -1;
109267 assert( !ExprHasProperty(p, EP_IntValue) );
@@ -115633,10 +115671,16 @@
115633 case TK_STRING: {
115634 assert( !ExprHasProperty(pExpr, EP_IntValue) );
115635 sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
115636 return target;
115637 }
 
 
 
 
 
 
115638 default: {
115639 /* Make NULL the default case so that if a bug causes an illegal
115640 ** Expr node to be passed into this function, it will be handled
115641 ** sanely and not crash. But keep the assert() to bring the problem
115642 ** to the attention of the developers. */
@@ -116341,10 +116385,29 @@
116341 }
116342 pParse->pConstExpr = p;
116343 }
116344 return regDest;
116345 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
116346
116347 /*
116348 ** Generate code to evaluate an expression and store the results
116349 ** into a register. Return the register number where the results
116350 ** are stored.
@@ -152746,10 +152809,11 @@
152746 Select *pSub = pWhere->x.pSelect;
152747 Expr *pSubWhere = pSub->pWhere;
152748 if( pSub->pSrc->nSrc==1
152749 && (pSub->selFlags & SF_Aggregate)==0
152750 && !pSub->pSrc->a[0].fg.isSubquery
 
152751 ){
152752 memset(pWhere, 0, sizeof(*pWhere));
152753 pWhere->op = TK_INTEGER;
152754 pWhere->u.iValue = 1;
152755 ExprSetProperty(pWhere, EP_IntValue);
@@ -153766,10 +153830,11 @@
153766 iBMem = pParse->nMem + 1;
153767 pParse->nMem += pGroupBy->nExpr;
153768 sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
153769 VdbeComment((v, "clear abort flag"));
153770 sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
 
153771
153772 /* Begin a loop that will extract all source rows in GROUP BY order.
153773 ** This might involve two separate loops with an OP_Sort in between, or
153774 ** it might be a single loop that uses an index to extract information
153775 ** in the right order to begin with.
@@ -169084,10 +169149,11 @@
169084 if( pProbe->bNoQuery ) continue;
169085 rSize = pProbe->aiRowLogEst[0];
169086 pNew->u.btree.nEq = 0;
169087 pNew->u.btree.nBtm = 0;
169088 pNew->u.btree.nTop = 0;
 
169089 pNew->nSkip = 0;
169090 pNew->nLTerm = 0;
169091 pNew->iSortIdx = 0;
169092 pNew->rSetup = 0;
169093 pNew->prereq = mPrereq;
@@ -170152,12 +170218,10 @@
170152 && ((wctrlFlags&(WHERE_DISTINCTBY|WHERE_SORTBYGROUP))!=WHERE_DISTINCTBY)
170153 ){
170154 obSat = obDone;
170155 }
170156 break;
170157 }else if( wctrlFlags & WHERE_DISTINCTBY ){
170158 pLoop->u.btree.nDistinctCol = 0;
170159 }
170160 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
170161
170162 /* Mark off any ORDER BY term X that is a column in the table of
170163 ** the current loop for which there is term in the WHERE
@@ -258113,11 +258177,11 @@
258113 int nArg, /* Number of args */
258114 sqlite3_value **apUnused /* Function arguments */
258115 ){
258116 assert( nArg==0 );
258117 UNUSED_PARAM2(nArg, apUnused);
258118 sqlite3_result_text(pCtx, "fts5: 2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839", -1, SQLITE_TRANSIENT);
258119 }
258120
258121 /*
258122 ** Implementation of fts5_locale(LOCALE, TEXT) function.
258123 **
258124
--- 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 ** cf7163f82ca380958a79350473b2c5a2cebd 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.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -814,10 +814,13 @@
814 ** [sqlite3_extended_errcode()].
815 */
816 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
817 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
818 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
819 #define SQLITE_ERROR_RESERVESIZE (SQLITE_ERROR | (4<<8))
820 #define SQLITE_ERROR_KEY (SQLITE_ERROR | (5<<8))
821 #define SQLITE_ERROR_UNABLE (SQLITE_ERROR | (6<<8))
822 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
823 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
824 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
825 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
826 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -848,10 +851,12 @@
851 #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
852 #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
853 #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
854 #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
855 #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
856 #define SQLITE_IOERR_BADKEY (SQLITE_IOERR | (35<<8))
857 #define SQLITE_IOERR_CODEC (SQLITE_IOERR | (36<<8))
858 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
859 #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
860 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
861 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
862 #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
@@ -19503,10 +19508,11 @@
19508 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
19509 union {
19510 Table *pTab; /* TK_COLUMN: Table containing column. Can be NULL
19511 ** for a column of an index on an expression */
19512 Window *pWin; /* EP_WinFunc: Window/Filter defn for a function */
19513 int nReg; /* TK_NULLS: Number of registers to NULL out */
19514 struct { /* TK_IN, TK_SELECT, and TK_EXISTS */
19515 int iAddr; /* Subroutine entry address */
19516 int regReturn; /* Register used to hold return address */
19517 } sub;
19518 } y;
@@ -21540,10 +21546,11 @@
21546 SQLITE_PRIVATE void sqlite3ExprCodeGeneratedColumn(Parse*, Table*, Column*, int);
21547 #endif
21548 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, Expr*, int);
21549 SQLITE_PRIVATE void sqlite3ExprCodeFactorable(Parse*, Expr*, int);
21550 SQLITE_PRIVATE int sqlite3ExprCodeRunJustOnce(Parse*, Expr*, int);
21551 SQLITE_PRIVATE void sqlite3ExprNullRegisterRange(Parse*, int, int);
21552 SQLITE_PRIVATE int sqlite3ExprCodeTemp(Parse*, Expr*, int*);
21553 SQLITE_PRIVATE int sqlite3ExprCodeTarget(Parse*, Expr*, int);
21554 SQLITE_PRIVATE int sqlite3ExprCodeExprList(Parse*, ExprList*, int, int, u8);
21555 #define SQLITE_ECEL_DUP 0x01 /* Deep, not shallow copies */
21556 #define SQLITE_ECEL_FACTOR 0x02 /* Factor out constant terms */
@@ -24366,13 +24373,15 @@
24373 SQLITE_PRIVATE void sqlite3VdbeMemAboutToChange(Vdbe*,Mem*);
24374 SQLITE_PRIVATE int sqlite3VdbeCheckMemInvariants(Mem*);
24375 #endif
24376
24377 #ifndef SQLITE_OMIT_FOREIGN_KEY
24378 SQLITE_PRIVATE int sqlite3VdbeCheckFkImmediate(Vdbe*);
24379 SQLITE_PRIVATE int sqlite3VdbeCheckFkDeferred(Vdbe*);
24380 #else
24381 # define sqlite3VdbeCheckFkImmediate(p) 0
24382 # define sqlite3VdbeCheckFkDeferred(p) 0
24383 #endif
24384
24385 #ifdef SQLITE_DEBUG
24386 SQLITE_PRIVATE void sqlite3VdbePrintSql(Vdbe*);
24387 SQLITE_PRIVATE void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr);
@@ -32252,11 +32261,25 @@
32261 length = sqlite3Strlen30(bufpt);
32262 break;
32263 }
32264 }
32265 if( s.sign=='-' ){
32266 if( flag_alternateform
32267 && !flag_prefix
32268 && xtype==etFLOAT
32269 && s.iDP<=iRound
32270 ){
32271 /* Suppress the minus sign if all of the following are true:
32272 ** * The value displayed is zero
32273 ** * The '#' flag is used
32274 ** * The '+' flag is not used, and
32275 ** * The format is %f
32276 */
32277 prefix = 0;
32278 }else{
32279 prefix = '-';
32280 }
32281 }else{
32282 prefix = flag_prefix;
32283 }
32284
32285 exp = s.iDP-1;
@@ -51192,10 +51215,107 @@
51215 ** on allocation size granularity boundaries.
51216 ** During sqlite3_os_init() we do a GetSystemInfo()
51217 ** to get the granularity size.
51218 */
51219 static SYSTEM_INFO winSysInfo;
51220
51221 /*
51222 ** Convert a UTF-8 filename into whatever form the underlying
51223 ** operating system wants filenames in. Space to hold the result
51224 ** is obtained from malloc and must be freed by the calling
51225 ** function
51226 **
51227 ** On Cygwin, 3 possible input forms are accepted:
51228 ** - If the filename starts with "<drive>:/" or "<drive>:\",
51229 ** it is converted to UTF-16 as-is.
51230 ** - If the filename contains '/', it is assumed to be a
51231 ** Cygwin absolute path, it is converted to a win32
51232 ** absolute path in UTF-16.
51233 ** - Otherwise it must be a filename only, the win32 filename
51234 ** is returned in UTF-16.
51235 ** Note: If the function cygwin_conv_path() fails, only
51236 ** UTF-8 -> UTF-16 conversion will be done. This can only
51237 ** happen when the file path >32k, in which case winUtf8ToUnicode()
51238 ** will fail too.
51239 */
51240 static void *winConvertFromUtf8Filename(const char *zFilename){
51241 void *zConverted = 0;
51242 if( osIsNT() ){
51243 #ifdef __CYGWIN__
51244 int nChar;
51245 LPWSTR zWideFilename;
51246
51247 if( osCygwin_conv_path && !(winIsDriveLetterAndColon(zFilename)
51248 && winIsDirSep(zFilename[2])) ){
51249 i64 nByte;
51250 int convertflag = CCP_POSIX_TO_WIN_W;
51251 if( !strchr(zFilename, '/') ) convertflag |= CCP_RELATIVE;
51252 nByte = (i64)osCygwin_conv_path(convertflag,
51253 zFilename, 0, 0);
51254 if( nByte>0 ){
51255 zConverted = sqlite3MallocZero(12+(u64)nByte);
51256 if ( zConverted==0 ){
51257 return zConverted;
51258 }
51259 zWideFilename = zConverted;
51260 /* Filenames should be prefixed, except when converted
51261 * full path already starts with "\\?\". */
51262 if( osCygwin_conv_path(convertflag, zFilename,
51263 zWideFilename+4, nByte)==0 ){
51264 if( (convertflag&CCP_RELATIVE) ){
51265 memmove(zWideFilename, zWideFilename+4, nByte);
51266 }else if( memcmp(zWideFilename+4, L"\\\\", 4) ){
51267 memcpy(zWideFilename, L"\\\\?\\", 8);
51268 }else if( zWideFilename[6]!='?' ){
51269 memmove(zWideFilename+6, zWideFilename+4, nByte);
51270 memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51271 }else{
51272 memmove(zWideFilename, zWideFilename+4, nByte);
51273 }
51274 return zConverted;
51275 }
51276 sqlite3_free(zConverted);
51277 }
51278 }
51279 nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1, NULL, 0);
51280 if( nChar==0 ){
51281 return 0;
51282 }
51283 zWideFilename = sqlite3MallocZero( nChar*sizeof(WCHAR)+12 );
51284 if( zWideFilename==0 ){
51285 return 0;
51286 }
51287 nChar = osMultiByteToWideChar(CP_UTF8, 0, zFilename, -1,
51288 zWideFilename, nChar);
51289 if( nChar==0 ){
51290 sqlite3_free(zWideFilename);
51291 zWideFilename = 0;
51292 }else if( nChar>MAX_PATH
51293 && winIsDriveLetterAndColon(zFilename)
51294 && winIsDirSep(zFilename[2]) ){
51295 memmove(zWideFilename+4, zWideFilename, nChar*sizeof(WCHAR));
51296 zWideFilename[2] = '\\';
51297 memcpy(zWideFilename, L"\\\\?\\", 8);
51298 }else if( nChar>MAX_PATH
51299 && winIsDirSep(zFilename[0]) && winIsDirSep(zFilename[1])
51300 && zFilename[2] != '?' ){
51301 memmove(zWideFilename+6, zWideFilename, nChar*sizeof(WCHAR));
51302 memcpy(zWideFilename, L"\\\\?\\UNC", 14);
51303 }
51304 zConverted = zWideFilename;
51305 #else
51306 zConverted = winUtf8ToUnicode(zFilename);
51307 #endif /* __CYGWIN__ */
51308 }
51309 #if defined(SQLITE_WIN32_HAS_ANSI) && defined(_WIN32)
51310 else{
51311 zConverted = winUtf8ToMbcs(zFilename, osAreFileApisANSI());
51312 }
51313 #endif
51314 /* caller will handle out of memory */
51315 return zConverted;
51316 }
51317
51318 #ifndef SQLITE_OMIT_WAL
51319
51320 /*
51321 ** Helper functions to obtain and relinquish the global mutex. The
@@ -51387,107 +51507,10 @@
51507
51508 return rc;
51509 }
51510
51511
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51512 /*
51513 ** This function is used to open a handle on a *-shm file.
51514 **
51515 ** If SQLITE_ENABLE_SETLK_TIMEOUT is defined at build time, then the file
51516 ** is opened with FILE_FLAG_OVERLAPPED specified. If not, it is not.
@@ -89078,14 +89101,16 @@
89101 ** simple case then too.
89102 */
89103 if( 0==sqlite3Strlen30(sqlite3BtreeGetFilename(db->aDb[0].pBt))
89104 || nTrans<=1
89105 ){
89106 if( needXcommit ){
89107 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89108 Btree *pBt = db->aDb[i].pBt;
89109 if( sqlite3BtreeTxnState(pBt)>=SQLITE_TXN_WRITE ){
89110 rc = sqlite3BtreeCommitPhaseOne(pBt, 0);
89111 }
89112 }
89113 }
89114
89115 /* Do the commit only if all databases successfully complete phase 1.
89116 ** If one of the BtreeCommitPhaseOne() calls fails, this indicates an
@@ -89092,11 +89117,13 @@
89117 ** IO error while deleting or truncating a journal file. It is unlikely,
89118 ** but could happen. In this case abandon processing and return the error.
89119 */
89120 for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
89121 Btree *pBt = db->aDb[i].pBt;
89122 int txn = sqlite3BtreeTxnState(pBt);
89123 if( txn!=SQLITE_TXN_NONE ){
89124 assert( needXcommit || txn==SQLITE_TXN_READ );
89125 rc = sqlite3BtreeCommitPhaseTwo(pBt, 0);
89126 }
89127 }
89128 if( rc==SQLITE_OK ){
89129 sqlite3VtabCommit(db);
@@ -89347,32 +89374,35 @@
89374 return SQLITE_OK;
89375 }
89376
89377
89378 /*
89379 ** These functions are called when a transaction opened by the database
89380 ** handle associated with the VM passed as an argument is about to be
89381 ** committed. If there are outstanding foreign key constraint violations
89382 ** return an error code. Otherwise, SQLITE_OK.
89383 **
89384 ** If there are outstanding FK violations and this function returns
89385 ** non-zero, set the result of the VM to SQLITE_CONSTRAINT_FOREIGNKEY
89386 ** and write an error message to it.
89387 */
89388 #ifndef SQLITE_OMIT_FOREIGN_KEY
89389 static SQLITE_NOINLINE int vdbeFkError(Vdbe *p){
89390 p->rc = SQLITE_CONSTRAINT_FOREIGNKEY;
89391 p->errorAction = OE_Abort;
89392 sqlite3VdbeError(p, "FOREIGN KEY constraint failed");
89393 if( (p->prepFlags & SQLITE_PREPARE_SAVESQL)==0 ) return SQLITE_ERROR;
89394 return SQLITE_CONSTRAINT_FOREIGNKEY;
89395 }
89396 SQLITE_PRIVATE int sqlite3VdbeCheckFkImmediate(Vdbe *p){
89397 if( p->nFkConstraint==0 ) return SQLITE_OK;
89398 return vdbeFkError(p);
89399 }
89400 SQLITE_PRIVATE int sqlite3VdbeCheckFkDeferred(Vdbe *p){
89401 sqlite3 *db = p->db;
89402 if( (db->nDeferredCons+db->nDeferredImmCons)==0 ) return SQLITE_OK;
89403 return vdbeFkError(p);
 
 
 
 
 
 
 
 
89404 }
89405 #endif
89406
89407 /*
89408 ** This routine is called the when a VDBE tries to halt. If the VDBE
@@ -89462,11 +89492,11 @@
89492 }
89493 }
89494
89495 /* Check for immediate foreign key violations. */
89496 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89497 (void)sqlite3VdbeCheckFkImmediate(p);
89498 }
89499
89500 /* If the auto-commit flag is set and this is the only active writer
89501 ** VM, then we do either a commit or rollback of the current transaction.
89502 **
@@ -89476,11 +89506,11 @@
89506 if( !sqlite3VtabInSync(db)
89507 && db->autoCommit
89508 && db->nVdbeWrite==(p->readOnly==0)
89509 ){
89510 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
89511 rc = sqlite3VdbeCheckFkDeferred(p);
89512 if( rc!=SQLITE_OK ){
89513 if( NEVER(p->readOnly) ){
89514 sqlite3VdbeLeave(p);
89515 return SQLITE_ERROR;
89516 }
@@ -90341,19 +90371,19 @@
90371 /* pMem->flags = 0; // sqlite3VdbeSerialGet() will set this for us */
90372 pMem->szMalloc = 0;
90373 pMem->z = 0;
90374 sqlite3VdbeSerialGet(&aKey[d], serial_type, pMem);
90375 d += sqlite3VdbeSerialTypeLen(serial_type);
 
90376 if( (++u)>=p->nField ) break;
90377 pMem++;
90378 }
90379 if( d>(u32)nKey && u ){
90380 assert( CORRUPT_DB );
90381 /* In a corrupt record entry, the last pMem might have been set up using
90382 ** uninitialized memory. Overwrite its value with NULL, to prevent
90383 ** warnings from MSAN. */
90384 sqlite3VdbeMemSetNull(pMem-(u<p->nField));
90385 }
90386 testcase( u == pKeyInfo->nKeyField + 1 );
90387 testcase( u < pKeyInfo->nKeyField + 1 );
90388 assert( u<=pKeyInfo->nKeyField + 1 );
90389 p->nField = u;
@@ -90520,10 +90550,36 @@
90550 ** Both *pMem1 and *pMem2 contain string values. Compare the two values
90551 ** using the collation sequence pColl. As usual, return a negative , zero
90552 ** or positive value if *pMem1 is less than, equal to or greater than
90553 ** *pMem2, respectively. Similar in spirit to "rc = (*pMem1) - (*pMem2);".
90554 */
90555 static SQLITE_NOINLINE int vdbeCompareMemStringWithEncodingChange(
90556 const Mem *pMem1,
90557 const Mem *pMem2,
90558 const CollSeq *pColl,
90559 u8 *prcErr /* If an OOM occurs, set to SQLITE_NOMEM */
90560 ){
90561 int rc;
90562 const void *v1, *v2;
90563 Mem c1;
90564 Mem c2;
90565 sqlite3VdbeMemInit(&c1, pMem1->db, MEM_Null);
90566 sqlite3VdbeMemInit(&c2, pMem1->db, MEM_Null);
90567 sqlite3VdbeMemShallowCopy(&c1, pMem1, MEM_Ephem);
90568 sqlite3VdbeMemShallowCopy(&c2, pMem2, MEM_Ephem);
90569 v1 = sqlite3ValueText((sqlite3_value*)&c1, pColl->enc);
90570 v2 = sqlite3ValueText((sqlite3_value*)&c2, pColl->enc);
90571 if( (v1==0 || v2==0) ){
90572 if( prcErr ) *prcErr = SQLITE_NOMEM_BKPT;
90573 rc = 0;
90574 }else{
90575 rc = pColl->xCmp(pColl->pUser, c1.n, v1, c2.n, v2);
90576 }
90577 sqlite3VdbeMemReleaseMalloc(&c1);
90578 sqlite3VdbeMemReleaseMalloc(&c2);
90579 return rc;
90580 }
90581 static int vdbeCompareMemString(
90582 const Mem *pMem1,
90583 const Mem *pMem2,
90584 const CollSeq *pColl,
90585 u8 *prcErr /* If an OOM occurs, set to SQLITE_NOMEM */
@@ -90531,29 +90587,11 @@
90587 if( pMem1->enc==pColl->enc ){
90588 /* The strings are already in the correct encoding. Call the
90589 ** comparison function directly */
90590 return pColl->xCmp(pColl->pUser,pMem1->n,pMem1->z,pMem2->n,pMem2->z);
90591 }else{
90592 return vdbeCompareMemStringWithEncodingChange(pMem1,pMem2,pColl,prcErr);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90593 }
90594 }
90595
90596 /*
90597 ** The input pBlob is guaranteed to be a Blob that is not marked
@@ -96256,11 +96294,11 @@
96294 ** exits. This opcode is used to raise foreign key constraint errors prior
96295 ** to returning results such as a row change count or the result of a
96296 ** RETURNING clause.
96297 */
96298 case OP_FkCheck: {
96299 if( (rc = sqlite3VdbeCheckFkImmediate(p))!=SQLITE_OK ){
96300 goto abort_due_to_error;
96301 }
96302 break;
96303 }
96304
@@ -98440,11 +98478,11 @@
98478 ** and this is a RELEASE command, then the current transaction
98479 ** is committed.
98480 */
98481 int isTransaction = pSavepoint->pNext==0 && db->isTransactionSavepoint;
98482 if( isTransaction && p1==SAVEPOINT_RELEASE ){
98483 if( (rc = sqlite3VdbeCheckFkDeferred(p))!=SQLITE_OK ){
98484 goto vdbe_return;
98485 }
98486 db->autoCommit = 1;
98487 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
98488 p->pc = (int)(pOp - aOp);
@@ -98558,11 +98596,11 @@
98596 */
98597 sqlite3VdbeError(p, "cannot commit transaction - "
98598 "SQL statements in progress");
98599 rc = SQLITE_BUSY;
98600 goto abort_due_to_error;
98601 }else if( (rc = sqlite3VdbeCheckFkDeferred(p))!=SQLITE_OK ){
98602 goto vdbe_return;
98603 }else{
98604 db->autoCommit = (u8)desiredAutoCommit;
98605 }
98606 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
@@ -109256,12 +109294,12 @@
109294 assert( ((X)&~(NC_IsCheck|NC_PartIdx|NC_IdxExpr|NC_GenCol))==0 ); \
109295 if( ((N)->ncFlags & (X))!=0 ) notValidImpl(P,N,M,E,R);
109296
109297 /*
109298 ** Expression p should encode a floating point value between 1.0 and 0.0.
109299 ** Return 134,217,728 (2^27) times this value. Or return -1 if p is not
109300 ** a floating point value between 1.0 and 0.0.
109301 */
109302 static int exprProbability(Expr *p){
109303 double r = -1.0;
109304 if( p->op!=TK_FLOAT ) return -1;
109305 assert( !ExprHasProperty(p, EP_IntValue) );
@@ -115633,10 +115671,16 @@
115671 case TK_STRING: {
115672 assert( !ExprHasProperty(pExpr, EP_IntValue) );
115673 sqlite3VdbeLoadString(v, target, pExpr->u.zToken);
115674 return target;
115675 }
115676 case TK_NULLS: {
115677 /* Set a range of registers to NULL. pExpr->y.nReg registers starting
115678 ** with target */
115679 sqlite3VdbeAddOp3(v, OP_Null, 0, target, target + pExpr->y.nReg - 1);
115680 return target;
115681 }
115682 default: {
115683 /* Make NULL the default case so that if a bug causes an illegal
115684 ** Expr node to be passed into this function, it will be handled
115685 ** sanely and not crash. But keep the assert() to bring the problem
115686 ** to the attention of the developers. */
@@ -116341,10 +116385,29 @@
116385 }
116386 pParse->pConstExpr = p;
116387 }
116388 return regDest;
116389 }
116390
116391 /*
116392 ** Make arrangements to invoke OP_Null on a range of registers
116393 ** during initialization.
116394 */
116395 SQLITE_PRIVATE SQLITE_NOINLINE void sqlite3ExprNullRegisterRange(
116396 Parse *pParse, /* Parsing context */
116397 int iReg, /* First register to set to NULL */
116398 int nReg /* Number of sequential registers to NULL out */
116399 ){
116400 u8 okConstFactor = pParse->okConstFactor;
116401 Expr t;
116402 memset(&t, 0, sizeof(t));
116403 t.op = TK_NULLS;
116404 t.y.nReg = nReg;
116405 pParse->okConstFactor = 1;
116406 sqlite3ExprCodeRunJustOnce(pParse, &t, iReg);
116407 pParse->okConstFactor = okConstFactor;
116408 }
116409
116410 /*
116411 ** Generate code to evaluate an expression and store the results
116412 ** into a register. Return the register number where the results
116413 ** are stored.
@@ -152746,10 +152809,11 @@
152809 Select *pSub = pWhere->x.pSelect;
152810 Expr *pSubWhere = pSub->pWhere;
152811 if( pSub->pSrc->nSrc==1
152812 && (pSub->selFlags & SF_Aggregate)==0
152813 && !pSub->pSrc->a[0].fg.isSubquery
152814 && pSub->pLimit==0
152815 ){
152816 memset(pWhere, 0, sizeof(*pWhere));
152817 pWhere->op = TK_INTEGER;
152818 pWhere->u.iValue = 1;
152819 ExprSetProperty(pWhere, EP_IntValue);
@@ -153766,10 +153830,11 @@
153830 iBMem = pParse->nMem + 1;
153831 pParse->nMem += pGroupBy->nExpr;
153832 sqlite3VdbeAddOp2(v, OP_Integer, 0, iAbortFlag);
153833 VdbeComment((v, "clear abort flag"));
153834 sqlite3VdbeAddOp3(v, OP_Null, 0, iAMem, iAMem+pGroupBy->nExpr-1);
153835 sqlite3ExprNullRegisterRange(pParse, iAMem, pGroupBy->nExpr);
153836
153837 /* Begin a loop that will extract all source rows in GROUP BY order.
153838 ** This might involve two separate loops with an OP_Sort in between, or
153839 ** it might be a single loop that uses an index to extract information
153840 ** in the right order to begin with.
@@ -169084,10 +169149,11 @@
169149 if( pProbe->bNoQuery ) continue;
169150 rSize = pProbe->aiRowLogEst[0];
169151 pNew->u.btree.nEq = 0;
169152 pNew->u.btree.nBtm = 0;
169153 pNew->u.btree.nTop = 0;
169154 pNew->u.btree.nDistinctCol = 0;
169155 pNew->nSkip = 0;
169156 pNew->nLTerm = 0;
169157 pNew->iSortIdx = 0;
169158 pNew->rSetup = 0;
169159 pNew->prereq = mPrereq;
@@ -170152,12 +170218,10 @@
170218 && ((wctrlFlags&(WHERE_DISTINCTBY|WHERE_SORTBYGROUP))!=WHERE_DISTINCTBY)
170219 ){
170220 obSat = obDone;
170221 }
170222 break;
 
 
170223 }
170224 iCur = pWInfo->pTabList->a[pLoop->iTab].iCursor;
170225
170226 /* Mark off any ORDER BY term X that is a column in the table of
170227 ** the current loop for which there is term in the WHERE
@@ -258113,11 +258177,11 @@
258177 int nArg, /* Number of args */
258178 sqlite3_value **apUnused /* Function arguments */
258179 ){
258180 assert( nArg==0 );
258181 UNUSED_PARAM2(nArg, apUnused);
258182 sqlite3_result_text(pCtx, "fts5: 2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1", -1, SQLITE_TRANSIENT);
258183 }
258184
258185 /*
258186 ** Implementation of fts5_locale(LOCALE, TEXT) function.
258187 **
258188
--- 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.51.0"
150150
#define SQLITE_VERSION_NUMBER 3051000
151
-#define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
151
+#define SQLITE_SOURCE_ID "2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -495,10 +495,13 @@
495495
** [sqlite3_extended_errcode()].
496496
*/
497497
#define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
498498
#define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
499499
#define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
500
+#define SQLITE_ERROR_RESERVESIZE (SQLITE_ERROR | (4<<8))
501
+#define SQLITE_ERROR_KEY (SQLITE_ERROR | (5<<8))
502
+#define SQLITE_ERROR_UNABLE (SQLITE_ERROR | (6<<8))
500503
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
501504
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
502505
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
503506
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
504507
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -529,10 +532,12 @@
529532
#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
530533
#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
531534
#define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
532535
#define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
533536
#define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
537
+#define SQLITE_IOERR_BADKEY (SQLITE_IOERR | (35<<8))
538
+#define SQLITE_IOERR_CODEC (SQLITE_IOERR | (36<<8))
534539
#define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
535540
#define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
536541
#define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
537542
#define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
538543
#define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
539544
--- 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.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -495,10 +495,13 @@
495 ** [sqlite3_extended_errcode()].
496 */
497 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
498 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
499 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
 
 
 
500 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
501 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
502 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
503 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
504 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -529,10 +532,12 @@
529 #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
530 #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
531 #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
532 #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
533 #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
 
 
534 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
535 #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
536 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
537 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
538 #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
539
--- 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.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-07-30 16:17:14 cf7163f82ca380958a79350473b2c5a2cebda7496d6d575fa2835c362010fea1"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -495,10 +495,13 @@
495 ** [sqlite3_extended_errcode()].
496 */
497 #define SQLITE_ERROR_MISSING_COLLSEQ (SQLITE_ERROR | (1<<8))
498 #define SQLITE_ERROR_RETRY (SQLITE_ERROR | (2<<8))
499 #define SQLITE_ERROR_SNAPSHOT (SQLITE_ERROR | (3<<8))
500 #define SQLITE_ERROR_RESERVESIZE (SQLITE_ERROR | (4<<8))
501 #define SQLITE_ERROR_KEY (SQLITE_ERROR | (5<<8))
502 #define SQLITE_ERROR_UNABLE (SQLITE_ERROR | (6<<8))
503 #define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
504 #define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
505 #define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
506 #define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
507 #define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
@@ -529,10 +532,12 @@
532 #define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8))
533 #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
534 #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
535 #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
536 #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
537 #define SQLITE_IOERR_BADKEY (SQLITE_IOERR | (35<<8))
538 #define SQLITE_IOERR_CODEC (SQLITE_IOERR | (36<<8))
539 #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
540 #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
541 #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
542 #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8))
543 #define SQLITE_BUSY_TIMEOUT (SQLITE_BUSY | (3<<8))
544

Keyboard Shortcuts

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