Fossil SCM

Update the built-in SQLite to the first 3.46.0 release candidate.

drh 2024-05-21 11:18 trunk
Commit 2ba99c273b03890e0fe3000eb6af1c0ff22d2e149cf2d10fbd043c784e817806
+91 -60
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15915,66 +15915,78 @@
1591515915
u32 enc,
1591615916
int eType,
1591715917
u8 *pData,
1591815918
sqlite3_int64 nData
1591915919
){
15920
- if( eType>=0 && dbdataValueBytes(eType)<=nData ){
15921
- switch( eType ){
15922
- case 0:
15923
- case 10:
15924
- case 11:
15925
- sqlite3_result_null(pCtx);
15926
- break;
15927
-
15928
- case 8:
15920
+ if( eType>=0 ){
15921
+ if( dbdataValueBytes(eType)<=nData ){
15922
+ switch( eType ){
15923
+ case 0:
15924
+ case 10:
15925
+ case 11:
15926
+ sqlite3_result_null(pCtx);
15927
+ break;
15928
+
15929
+ case 8:
15930
+ sqlite3_result_int(pCtx, 0);
15931
+ break;
15932
+ case 9:
15933
+ sqlite3_result_int(pCtx, 1);
15934
+ break;
15935
+
15936
+ case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
15937
+ sqlite3_uint64 v = (signed char)pData[0];
15938
+ pData++;
15939
+ switch( eType ){
15940
+ case 7:
15941
+ case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15942
+ case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15943
+ case 4: v = (v<<8) + pData[0]; pData++;
15944
+ case 3: v = (v<<8) + pData[0]; pData++;
15945
+ case 2: v = (v<<8) + pData[0]; pData++;
15946
+ }
15947
+
15948
+ if( eType==7 ){
15949
+ double r;
15950
+ memcpy(&r, &v, sizeof(r));
15951
+ sqlite3_result_double(pCtx, r);
15952
+ }else{
15953
+ sqlite3_result_int64(pCtx, (sqlite3_int64)v);
15954
+ }
15955
+ break;
15956
+ }
15957
+
15958
+ default: {
15959
+ int n = ((eType-12) / 2);
15960
+ if( eType % 2 ){
15961
+ switch( enc ){
15962
+ #ifndef SQLITE_OMIT_UTF16
15963
+ case SQLITE_UTF16BE:
15964
+ sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15965
+ break;
15966
+ case SQLITE_UTF16LE:
15967
+ sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15968
+ break;
15969
+ #endif
15970
+ default:
15971
+ sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
15972
+ break;
15973
+ }
15974
+ }else{
15975
+ sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
15976
+ }
15977
+ }
15978
+ }
15979
+ }else{
15980
+ if( eType==7 ){
15981
+ sqlite3_result_double(pCtx, 0.0);
15982
+ }else if( eType<7 ){
1592915983
sqlite3_result_int(pCtx, 0);
15930
- break;
15931
- case 9:
15932
- sqlite3_result_int(pCtx, 1);
15933
- break;
15934
-
15935
- case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
15936
- sqlite3_uint64 v = (signed char)pData[0];
15937
- pData++;
15938
- switch( eType ){
15939
- case 7:
15940
- case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15941
- case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15942
- case 4: v = (v<<8) + pData[0]; pData++;
15943
- case 3: v = (v<<8) + pData[0]; pData++;
15944
- case 2: v = (v<<8) + pData[0]; pData++;
15945
- }
15946
-
15947
- if( eType==7 ){
15948
- double r;
15949
- memcpy(&r, &v, sizeof(r));
15950
- sqlite3_result_double(pCtx, r);
15951
- }else{
15952
- sqlite3_result_int64(pCtx, (sqlite3_int64)v);
15953
- }
15954
- break;
15955
- }
15956
-
15957
- default: {
15958
- int n = ((eType-12) / 2);
15959
- if( eType % 2 ){
15960
- switch( enc ){
15961
-#ifndef SQLITE_OMIT_UTF16
15962
- case SQLITE_UTF16BE:
15963
- sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15964
- break;
15965
- case SQLITE_UTF16LE:
15966
- sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15967
- break;
15968
-#endif
15969
- default:
15970
- sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
15971
- break;
15972
- }
15973
- }else{
15974
- sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
15975
- }
15984
+ }else if( eType%2 ){
15985
+ sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
15986
+ }else{
15987
+ sqlite3_result_blob(pCtx, "", 0, SQLITE_STATIC);
1597615988
}
1597715989
}
1597815990
}
1597915991
}
1598015992
@@ -26032,30 +26044,37 @@
2603226044
int iId; /* ID that triggers a simulated fault. -1 means "any" */
2603326045
int iErr; /* The error code to return on a fault */
2603426046
int iCnt; /* Trigger the fault only if iCnt is already zero */
2603526047
int iInterval; /* Reset iCnt to this value after each fault */
2603626048
int eVerbose; /* When to print output */
26037
-} faultsim_state = {-1, 0, 0, 0, 0};
26049
+ int nHit; /* Number of hits seen so far */
26050
+ int nRepeat; /* Turn off after this many hits. 0 for never */
26051
+ int nSkip; /* Skip this many before first fault */
26052
+} faultsim_state = {-1, 0, 0, 0, 0, 0, 0};
2603826053
2603926054
/*
2604026055
** This is the fault-sim callback
2604126056
*/
2604226057
static int faultsim_callback(int iArg){
2604326058
if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){
2604426059
return SQLITE_OK;
2604526060
}
26046
- if( faultsim_state.iCnt>0 ){
26047
- faultsim_state.iCnt--;
26061
+ if( faultsim_state.iCnt ){
26062
+ if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--;
2604826063
if( faultsim_state.eVerbose>=2 ){
2604926064
oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt);
2605026065
}
2605126066
return SQLITE_OK;
2605226067
}
2605326068
if( faultsim_state.eVerbose>=1 ){
2605426069
oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr);
2605526070
}
2605626071
faultsim_state.iCnt = faultsim_state.iInterval;
26072
+ faultsim_state.nHit++;
26073
+ if( faultsim_state.nRepeat>0 && faultsim_state.nRepeat<=faultsim_state.nHit ){
26074
+ faultsim_state.iCnt = -1;
26075
+ }
2605726076
return faultsim_state.iErr;
2605826077
}
2605926078
2606026079
/*
2606126080
** If an input line begins with "." then invoke this routine to
@@ -29213,21 +29232,27 @@
2921329232
const char *z = azArg[kk];
2921429233
if( z[0]=='-' && z[1]=='-' ) z++;
2921529234
if( cli_strcmp(z,"off")==0 ){
2921629235
sqlite3_test_control(testctrl, 0);
2921729236
}else if( cli_strcmp(z,"on")==0 ){
29218
- faultsim_state.iCnt = faultsim_state.iInterval;
29237
+ faultsim_state.iCnt = faultsim_state.nSkip;
2921929238
if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1;
29239
+ faultsim_state.nHit = 0;
2922029240
sqlite3_test_control(testctrl, faultsim_callback);
2922129241
}else if( cli_strcmp(z,"reset")==0 ){
29222
- faultsim_state.iCnt = faultsim_state.iInterval;
29242
+ faultsim_state.iCnt = faultsim_state.nSkip;
29243
+ faultsim_state.nHit = 0;
29244
+ sqlite3_test_control(testctrl, faultsim_callback);
2922329245
}else if( cli_strcmp(z,"status")==0 ){
2922429246
oputf("faultsim.iId: %d\n", faultsim_state.iId);
2922529247
oputf("faultsim.iErr: %d\n", faultsim_state.iErr);
2922629248
oputf("faultsim.iCnt: %d\n", faultsim_state.iCnt);
29249
+ oputf("faultsim.nHit: %d\n", faultsim_state.nHit);
2922729250
oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval);
2922829251
oputf("faultsim.eVerbose: %d\n", faultsim_state.eVerbose);
29252
+ oputf("faultsim.nRepeat: %d\n", faultsim_state.nRepeat);
29253
+ oputf("faultsim.nSkip: %d\n", faultsim_state.nSkip);
2922929254
}else if( cli_strcmp(z,"-v")==0 ){
2923029255
if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++;
2923129256
}else if( cli_strcmp(z,"-q")==0 ){
2923229257
if( faultsim_state.eVerbose>0 ) faultsim_state.eVerbose--;
2923329258
}else if( cli_strcmp(z,"-id")==0 && kk+1<nArg ){
@@ -29234,10 +29259,14 @@
2923429259
faultsim_state.iId = atoi(azArg[++kk]);
2923529260
}else if( cli_strcmp(z,"-errcode")==0 && kk+1<nArg ){
2923629261
faultsim_state.iErr = atoi(azArg[++kk]);
2923729262
}else if( cli_strcmp(z,"-interval")==0 && kk+1<nArg ){
2923829263
faultsim_state.iInterval = atoi(azArg[++kk]);
29264
+ }else if( cli_strcmp(z,"-repeat")==0 && kk+1<nArg ){
29265
+ faultsim_state.nRepeat = atoi(azArg[++kk]);
29266
+ }else if( cli_strcmp(z,"-skip")==0 && kk+1<nArg ){
29267
+ faultsim_state.nSkip = atoi(azArg[++kk]);
2923929268
}else if( cli_strcmp(z,"-?")==0 || sqlite3_strglob("*help*",z)==0){
2924029269
bShowHelp = 1;
2924129270
}else{
2924229271
eputf("Unrecognized fault_install argument: \"%s\"\n",
2924329272
azArg[kk]);
@@ -29257,10 +29286,12 @@
2925729286
" -v Increase verbosity\n"
2925829287
" -q Decrease verbosity\n"
2925929288
" --errcode N When triggered, return N as error code\n"
2926029289
" --id ID Trigger only for the ID specified\n"
2926129290
" --interval N Trigger only after every N-th call\n"
29291
+ " --repeat N Turn off after N hits. 0 means never\n"
29292
+ " --skip N Skip the first N encounters\n"
2926229293
);
2926329294
}
2926429295
break;
2926529296
}
2926629297
}
2926729298
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15915,66 +15915,78 @@
15915 u32 enc,
15916 int eType,
15917 u8 *pData,
15918 sqlite3_int64 nData
15919 ){
15920 if( eType>=0 && dbdataValueBytes(eType)<=nData ){
15921 switch( eType ){
15922 case 0:
15923 case 10:
15924 case 11:
15925 sqlite3_result_null(pCtx);
15926 break;
15927
15928 case 8:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15929 sqlite3_result_int(pCtx, 0);
15930 break;
15931 case 9:
15932 sqlite3_result_int(pCtx, 1);
15933 break;
15934
15935 case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
15936 sqlite3_uint64 v = (signed char)pData[0];
15937 pData++;
15938 switch( eType ){
15939 case 7:
15940 case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15941 case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15942 case 4: v = (v<<8) + pData[0]; pData++;
15943 case 3: v = (v<<8) + pData[0]; pData++;
15944 case 2: v = (v<<8) + pData[0]; pData++;
15945 }
15946
15947 if( eType==7 ){
15948 double r;
15949 memcpy(&r, &v, sizeof(r));
15950 sqlite3_result_double(pCtx, r);
15951 }else{
15952 sqlite3_result_int64(pCtx, (sqlite3_int64)v);
15953 }
15954 break;
15955 }
15956
15957 default: {
15958 int n = ((eType-12) / 2);
15959 if( eType % 2 ){
15960 switch( enc ){
15961 #ifndef SQLITE_OMIT_UTF16
15962 case SQLITE_UTF16BE:
15963 sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15964 break;
15965 case SQLITE_UTF16LE:
15966 sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15967 break;
15968 #endif
15969 default:
15970 sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
15971 break;
15972 }
15973 }else{
15974 sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
15975 }
15976 }
15977 }
15978 }
15979 }
15980
@@ -26032,30 +26044,37 @@
26032 int iId; /* ID that triggers a simulated fault. -1 means "any" */
26033 int iErr; /* The error code to return on a fault */
26034 int iCnt; /* Trigger the fault only if iCnt is already zero */
26035 int iInterval; /* Reset iCnt to this value after each fault */
26036 int eVerbose; /* When to print output */
26037 } faultsim_state = {-1, 0, 0, 0, 0};
 
 
 
26038
26039 /*
26040 ** This is the fault-sim callback
26041 */
26042 static int faultsim_callback(int iArg){
26043 if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){
26044 return SQLITE_OK;
26045 }
26046 if( faultsim_state.iCnt>0 ){
26047 faultsim_state.iCnt--;
26048 if( faultsim_state.eVerbose>=2 ){
26049 oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt);
26050 }
26051 return SQLITE_OK;
26052 }
26053 if( faultsim_state.eVerbose>=1 ){
26054 oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr);
26055 }
26056 faultsim_state.iCnt = faultsim_state.iInterval;
 
 
 
 
26057 return faultsim_state.iErr;
26058 }
26059
26060 /*
26061 ** If an input line begins with "." then invoke this routine to
@@ -29213,21 +29232,27 @@
29213 const char *z = azArg[kk];
29214 if( z[0]=='-' && z[1]=='-' ) z++;
29215 if( cli_strcmp(z,"off")==0 ){
29216 sqlite3_test_control(testctrl, 0);
29217 }else if( cli_strcmp(z,"on")==0 ){
29218 faultsim_state.iCnt = faultsim_state.iInterval;
29219 if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1;
 
29220 sqlite3_test_control(testctrl, faultsim_callback);
29221 }else if( cli_strcmp(z,"reset")==0 ){
29222 faultsim_state.iCnt = faultsim_state.iInterval;
 
 
29223 }else if( cli_strcmp(z,"status")==0 ){
29224 oputf("faultsim.iId: %d\n", faultsim_state.iId);
29225 oputf("faultsim.iErr: %d\n", faultsim_state.iErr);
29226 oputf("faultsim.iCnt: %d\n", faultsim_state.iCnt);
 
29227 oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval);
29228 oputf("faultsim.eVerbose: %d\n", faultsim_state.eVerbose);
 
 
29229 }else if( cli_strcmp(z,"-v")==0 ){
29230 if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++;
29231 }else if( cli_strcmp(z,"-q")==0 ){
29232 if( faultsim_state.eVerbose>0 ) faultsim_state.eVerbose--;
29233 }else if( cli_strcmp(z,"-id")==0 && kk+1<nArg ){
@@ -29234,10 +29259,14 @@
29234 faultsim_state.iId = atoi(azArg[++kk]);
29235 }else if( cli_strcmp(z,"-errcode")==0 && kk+1<nArg ){
29236 faultsim_state.iErr = atoi(azArg[++kk]);
29237 }else if( cli_strcmp(z,"-interval")==0 && kk+1<nArg ){
29238 faultsim_state.iInterval = atoi(azArg[++kk]);
 
 
 
 
29239 }else if( cli_strcmp(z,"-?")==0 || sqlite3_strglob("*help*",z)==0){
29240 bShowHelp = 1;
29241 }else{
29242 eputf("Unrecognized fault_install argument: \"%s\"\n",
29243 azArg[kk]);
@@ -29257,10 +29286,12 @@
29257 " -v Increase verbosity\n"
29258 " -q Decrease verbosity\n"
29259 " --errcode N When triggered, return N as error code\n"
29260 " --id ID Trigger only for the ID specified\n"
29261 " --interval N Trigger only after every N-th call\n"
 
 
29262 );
29263 }
29264 break;
29265 }
29266 }
29267
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -15915,66 +15915,78 @@
15915 u32 enc,
15916 int eType,
15917 u8 *pData,
15918 sqlite3_int64 nData
15919 ){
15920 if( eType>=0 ){
15921 if( dbdataValueBytes(eType)<=nData ){
15922 switch( eType ){
15923 case 0:
15924 case 10:
15925 case 11:
15926 sqlite3_result_null(pCtx);
15927 break;
15928
15929 case 8:
15930 sqlite3_result_int(pCtx, 0);
15931 break;
15932 case 9:
15933 sqlite3_result_int(pCtx, 1);
15934 break;
15935
15936 case 1: case 2: case 3: case 4: case 5: case 6: case 7: {
15937 sqlite3_uint64 v = (signed char)pData[0];
15938 pData++;
15939 switch( eType ){
15940 case 7:
15941 case 6: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15942 case 5: v = (v<<16) + (pData[0]<<8) + pData[1]; pData += 2;
15943 case 4: v = (v<<8) + pData[0]; pData++;
15944 case 3: v = (v<<8) + pData[0]; pData++;
15945 case 2: v = (v<<8) + pData[0]; pData++;
15946 }
15947
15948 if( eType==7 ){
15949 double r;
15950 memcpy(&r, &v, sizeof(r));
15951 sqlite3_result_double(pCtx, r);
15952 }else{
15953 sqlite3_result_int64(pCtx, (sqlite3_int64)v);
15954 }
15955 break;
15956 }
15957
15958 default: {
15959 int n = ((eType-12) / 2);
15960 if( eType % 2 ){
15961 switch( enc ){
15962 #ifndef SQLITE_OMIT_UTF16
15963 case SQLITE_UTF16BE:
15964 sqlite3_result_text16be(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15965 break;
15966 case SQLITE_UTF16LE:
15967 sqlite3_result_text16le(pCtx, (void*)pData, n, SQLITE_TRANSIENT);
15968 break;
15969 #endif
15970 default:
15971 sqlite3_result_text(pCtx, (char*)pData, n, SQLITE_TRANSIENT);
15972 break;
15973 }
15974 }else{
15975 sqlite3_result_blob(pCtx, pData, n, SQLITE_TRANSIENT);
15976 }
15977 }
15978 }
15979 }else{
15980 if( eType==7 ){
15981 sqlite3_result_double(pCtx, 0.0);
15982 }else if( eType<7 ){
15983 sqlite3_result_int(pCtx, 0);
15984 }else if( eType%2 ){
15985 sqlite3_result_text(pCtx, "", 0, SQLITE_STATIC);
15986 }else{
15987 sqlite3_result_blob(pCtx, "", 0, SQLITE_STATIC);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15988 }
15989 }
15990 }
15991 }
15992
@@ -26032,30 +26044,37 @@
26044 int iId; /* ID that triggers a simulated fault. -1 means "any" */
26045 int iErr; /* The error code to return on a fault */
26046 int iCnt; /* Trigger the fault only if iCnt is already zero */
26047 int iInterval; /* Reset iCnt to this value after each fault */
26048 int eVerbose; /* When to print output */
26049 int nHit; /* Number of hits seen so far */
26050 int nRepeat; /* Turn off after this many hits. 0 for never */
26051 int nSkip; /* Skip this many before first fault */
26052 } faultsim_state = {-1, 0, 0, 0, 0, 0, 0};
26053
26054 /*
26055 ** This is the fault-sim callback
26056 */
26057 static int faultsim_callback(int iArg){
26058 if( faultsim_state.iId>0 && faultsim_state.iId!=iArg ){
26059 return SQLITE_OK;
26060 }
26061 if( faultsim_state.iCnt ){
26062 if( faultsim_state.iCnt>0 ) faultsim_state.iCnt--;
26063 if( faultsim_state.eVerbose>=2 ){
26064 oputf("FAULT-SIM id=%d no-fault (cnt=%d)\n", iArg, faultsim_state.iCnt);
26065 }
26066 return SQLITE_OK;
26067 }
26068 if( faultsim_state.eVerbose>=1 ){
26069 oputf("FAULT-SIM id=%d returns %d\n", iArg, faultsim_state.iErr);
26070 }
26071 faultsim_state.iCnt = faultsim_state.iInterval;
26072 faultsim_state.nHit++;
26073 if( faultsim_state.nRepeat>0 && faultsim_state.nRepeat<=faultsim_state.nHit ){
26074 faultsim_state.iCnt = -1;
26075 }
26076 return faultsim_state.iErr;
26077 }
26078
26079 /*
26080 ** If an input line begins with "." then invoke this routine to
@@ -29213,21 +29232,27 @@
29232 const char *z = azArg[kk];
29233 if( z[0]=='-' && z[1]=='-' ) z++;
29234 if( cli_strcmp(z,"off")==0 ){
29235 sqlite3_test_control(testctrl, 0);
29236 }else if( cli_strcmp(z,"on")==0 ){
29237 faultsim_state.iCnt = faultsim_state.nSkip;
29238 if( faultsim_state.iErr==0 ) faultsim_state.iErr = 1;
29239 faultsim_state.nHit = 0;
29240 sqlite3_test_control(testctrl, faultsim_callback);
29241 }else if( cli_strcmp(z,"reset")==0 ){
29242 faultsim_state.iCnt = faultsim_state.nSkip;
29243 faultsim_state.nHit = 0;
29244 sqlite3_test_control(testctrl, faultsim_callback);
29245 }else if( cli_strcmp(z,"status")==0 ){
29246 oputf("faultsim.iId: %d\n", faultsim_state.iId);
29247 oputf("faultsim.iErr: %d\n", faultsim_state.iErr);
29248 oputf("faultsim.iCnt: %d\n", faultsim_state.iCnt);
29249 oputf("faultsim.nHit: %d\n", faultsim_state.nHit);
29250 oputf("faultsim.iInterval: %d\n", faultsim_state.iInterval);
29251 oputf("faultsim.eVerbose: %d\n", faultsim_state.eVerbose);
29252 oputf("faultsim.nRepeat: %d\n", faultsim_state.nRepeat);
29253 oputf("faultsim.nSkip: %d\n", faultsim_state.nSkip);
29254 }else if( cli_strcmp(z,"-v")==0 ){
29255 if( faultsim_state.eVerbose<2 ) faultsim_state.eVerbose++;
29256 }else if( cli_strcmp(z,"-q")==0 ){
29257 if( faultsim_state.eVerbose>0 ) faultsim_state.eVerbose--;
29258 }else if( cli_strcmp(z,"-id")==0 && kk+1<nArg ){
@@ -29234,10 +29259,14 @@
29259 faultsim_state.iId = atoi(azArg[++kk]);
29260 }else if( cli_strcmp(z,"-errcode")==0 && kk+1<nArg ){
29261 faultsim_state.iErr = atoi(azArg[++kk]);
29262 }else if( cli_strcmp(z,"-interval")==0 && kk+1<nArg ){
29263 faultsim_state.iInterval = atoi(azArg[++kk]);
29264 }else if( cli_strcmp(z,"-repeat")==0 && kk+1<nArg ){
29265 faultsim_state.nRepeat = atoi(azArg[++kk]);
29266 }else if( cli_strcmp(z,"-skip")==0 && kk+1<nArg ){
29267 faultsim_state.nSkip = atoi(azArg[++kk]);
29268 }else if( cli_strcmp(z,"-?")==0 || sqlite3_strglob("*help*",z)==0){
29269 bShowHelp = 1;
29270 }else{
29271 eputf("Unrecognized fault_install argument: \"%s\"\n",
29272 azArg[kk]);
@@ -29257,10 +29286,12 @@
29286 " -v Increase verbosity\n"
29287 " -q Decrease verbosity\n"
29288 " --errcode N When triggered, return N as error code\n"
29289 " --id ID Trigger only for the ID specified\n"
29290 " --interval N Trigger only after every N-th call\n"
29291 " --repeat N Turn off after N hits. 0 means never\n"
29292 " --skip N Skip the first N encounters\n"
29293 );
29294 }
29295 break;
29296 }
29297 }
29298
+78 -52
--- 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
-** 42d67c6fed3a5f21d7b71515aca471ba61d3.
21
+** de8182cf1773ac0d04268d896a613841cf6b.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459459
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460460
** [sqlite_version()] and [sqlite_source_id()].
461461
*/
462462
#define SQLITE_VERSION "3.46.0"
463463
#define SQLITE_VERSION_NUMBER 3046000
464
-#define SQLITE_SOURCE_ID "2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf"
464
+#define SQLITE_SOURCE_ID "2024-05-21 11:11:29 de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb"
465465
466466
/*
467467
** CAPI3REF: Run-Time Library Version Numbers
468468
** KEYWORDS: sqlite3_version sqlite3_sourceid
469469
**
@@ -10253,27 +10253,48 @@
1025310253
** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
1025410254
** is doing a GROUP BY.
1025510255
** <li value="2"><p>
1025610256
** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
1025710257
** that the query planner does not need the rows returned in any particular
10258
-** order, as long as rows with the same values in all "aOrderBy" columns
10259
-** are adjacent.)^ ^(Furthermore, only a single row for each particular
10260
-** combination of values in the columns identified by the "aOrderBy" field
10261
-** needs to be returned.)^ ^It is always ok for two or more rows with the same
10262
-** values in all "aOrderBy" columns to be returned, as long as all such rows
10263
-** are adjacent. ^The virtual table may, if it chooses, omit extra rows
10264
-** that have the same value for all columns identified by "aOrderBy".
10265
-** ^However omitting the extra rows is optional.
10258
+** order, as long as rows with the same values in all columns identified
10259
+** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows
10260
+** contain the same values for all columns identified by "colUsed", all but
10261
+** one such row may optionally be omitted from the result.)^
10262
+** The virtual table is not required to omit rows that are duplicates
10263
+** over the "colUsed" columns, but if the virtual table can do that without
10264
+** too much extra effort, it could potentially help the query to run faster.
1026610265
** This mode is used for a DISTINCT query.
1026710266
** <li value="3"><p>
10268
-** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
10269
-** that the query planner needs only distinct rows but it does need the
10270
-** rows to be sorted.)^ ^The virtual table implementation is free to omit
10271
-** rows that are identical in all aOrderBy columns, if it wants to, but
10272
-** it is not required to omit any rows. This mode is used for queries
10267
+** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
10268
+** virtual table must return rows in the order defined by "aOrderBy" as
10269
+** if the sqlite3_vtab_distinct() interface had returned 0. However if
10270
+** two or more rows in the result have the same values for all columns
10271
+** identified by "colUsed", then all but one such row may optionally be
10272
+** omitted.)^ Like when the return value is 2, the virtual table
10273
+** is not required to omit rows that are duplicates over the "colUsed"
10274
+** columns, but if the virtual table can do that without
10275
+** too much extra effort, it could potentially help the query to run faster.
10276
+** This mode is used for queries
1027310277
** that have both DISTINCT and ORDER BY clauses.
1027410278
** </ol>
10279
+**
10280
+** <p>The following table summarizes the conditions under which the
10281
+** virtual table is allowed to set the "orderByConsumed" flag based on
10282
+** the value returned by sqlite3_vtab_distinct(). This table is a
10283
+** restatement of the previous four paragraphs:
10284
+**
10285
+** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10286
+** <tr>
10287
+** <td valign="top">sqlite3_vtab_distinct() return value
10288
+** <td valign="top">Rows are returned in aOrderBy order
10289
+** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10290
+** <td valign="top">Duplicates over all colUsed columns may be omitted
10291
+** <tr><td>0<td>yes<td>yes<td>no
10292
+** <tr><td>1<td>no<td>yes<td>no
10293
+** <tr><td>2<td>no<td>yes<td>yes
10294
+** <tr><td>3<td>yes<td>yes<td>yes
10295
+** </table>
1027510296
**
1027610297
** ^For the purposes of comparing virtual table output values to see if the
1027710298
** values are same value for sorting purposes, two NULL values are considered
1027810299
** to be the same. In other words, the comparison operator is "IS"
1027910300
** (or "IS NOT DISTINCT FROM") and not "==".
@@ -19262,10 +19283,11 @@
1926219283
unsigned notCte :1; /* This item may not match a CTE */
1926319284
unsigned isUsing :1; /* u3.pUsing is valid */
1926419285
unsigned isOn :1; /* u3.pOn was once valid and non-NULL */
1926519286
unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
1926619287
unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
19288
+ unsigned rowidUsed :1; /* The ROWID of this table is referenced */
1926719289
} fg;
1926819290
int iCursor; /* The VDBE cursor number used to access this table */
1926919291
union {
1927019292
Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */
1927119293
IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */
@@ -20806,11 +20828,11 @@
2080620828
SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*);
2080720829
SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
2080820830
SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
2080920831
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
2081020832
SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*);
20811
-SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
20833
+SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse*, Expr*);
2081220834
SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
2081320835
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
2081420836
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
2081520837
SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
2081620838
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
@@ -21217,11 +21239,13 @@
2121721239
SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
2121821240
SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
2121921241
SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
2122021242
SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*);
2122121243
SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);
21244
+#if !defined(SQLITE_OMIT_BLOB_LITERAL)
2122221245
SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
21246
+#endif
2122321247
SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
2122421248
SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
2122521249
2122621250
#if defined(SQLITE_NEED_ERR_NAME)
2122721251
SQLITE_PRIVATE const char *sqlite3ErrName(int);
@@ -32752,12 +32776,14 @@
3275232776
char zLine[1000];
3275332777
sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
3275432778
x.printfFlags |= SQLITE_PRINTF_INTERNAL;
3275532779
sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
3275632780
if( pItem->pTab ){
32757
- sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
32758
- pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
32781
+ sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s",
32782
+ pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab,
32783
+ pItem->colUsed,
32784
+ pItem->fg.rowidUsed ? "+rowid" : "");
3275932785
}
3276032786
if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){
3276132787
sqlite3_str_appendf(&x, " FULL-OUTER-JOIN");
3276232788
}else if( pItem->fg.jointype & JT_LEFT ){
3276332789
sqlite3_str_appendf(&x, " LEFT-JOIN");
@@ -88164,11 +88190,11 @@
8816488190
}
8816588191
}
8816688192
8816788193
/* Check for immediate foreign key violations. */
8816888194
if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
88169
- sqlite3VdbeCheckFk(p, 0);
88195
+ (void)sqlite3VdbeCheckFk(p, 0);
8817088196
}
8817188197
8817288198
/* If the auto-commit flag is set and this is the only active writer
8817388199
** VM, then we do either a commit or rollback of the current transaction.
8817488200
**
@@ -107522,12 +107548,16 @@
107522107548
** (See ticket [b92e5e8ec2cdbaa1]).
107523107549
**
107524107550
** If a generated column is referenced, set bits for every column
107525107551
** of the table.
107526107552
*/
107527
- if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){
107528
- pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
107553
+ if( pMatch ){
107554
+ if( pExpr->iColumn>=0 ){
107555
+ pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
107556
+ }else{
107557
+ pMatch->fg.rowidUsed = 1;
107558
+ }
107529107559
}
107530107560
107531107561
pExpr->op = eNewExprOp;
107532107562
lookupname_end:
107533107563
if( cnt==1 ){
@@ -107975,15 +108005,13 @@
107975108005
#else
107976108006
pNC->ncFlags &= ~NC_AllowAgg;
107977108007
#endif
107978108008
}
107979108009
}
107980
-#ifndef SQLITE_OMIT_WINDOWFUNC
107981
- else if( ExprHasProperty(pExpr, EP_WinFunc) ){
108010
+ else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){
107982108011
is_agg = 1;
107983108012
}
107984
-#endif
107985108013
sqlite3WalkExprList(pWalker, pList);
107986108014
if( is_agg ){
107987108015
if( pExpr->pLeft ){
107988108016
assert( pExpr->pLeft->op==TK_ORDER );
107989108017
assert( ExprUseXList(pExpr->pLeft) );
@@ -110419,15 +110447,15 @@
110419110447
** This is similar to sqlite3ExprDelete() except that the delete is
110420110448
** deferred until the pParse is deleted.
110421110449
**
110422110450
** The pExpr might be deleted immediately on an OOM error.
110423110451
**
110424
-** The deferred delete is (currently) implemented by adding the
110425
-** pExpr to the pParse->pConstExpr list with a register number of 0.
110452
+** Return 0 if the delete was successfully deferred. Return non-zero
110453
+** if the delete happened immediately because of an OOM.
110426110454
*/
110427
-SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
110428
- sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
110455
+SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
110456
+ return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
110429110457
}
110430110458
110431110459
/* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the
110432110460
** expression.
110433110461
*/
@@ -115657,24 +115685,22 @@
115657115685
if( pExpr->op!=TK_AGG_FUNCTION ){
115658115686
if( iAgg<pAggInfo->nColumn
115659115687
&& pAggInfo->aCol[iAgg].pCExpr==pExpr
115660115688
){
115661115689
pExpr = sqlite3ExprDup(db, pExpr, 0);
115662
- if( pExpr ){
115690
+ if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
115663115691
pAggInfo->aCol[iAgg].pCExpr = pExpr;
115664
- sqlite3ExprDeferredDelete(pParse, pExpr);
115665115692
}
115666115693
}
115667115694
}else{
115668115695
assert( pExpr->op==TK_AGG_FUNCTION );
115669115696
if( ALWAYS(iAgg<pAggInfo->nFunc)
115670115697
&& pAggInfo->aFunc[iAgg].pFExpr==pExpr
115671115698
){
115672115699
pExpr = sqlite3ExprDup(db, pExpr, 0);
115673
- if( pExpr ){
115700
+ if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
115674115701
pAggInfo->aFunc[iAgg].pFExpr = pExpr;
115675
- sqlite3ExprDeferredDelete(pParse, pExpr);
115676115702
}
115677115703
}
115678115704
}
115679115705
}
115680115706
return WRC_Continue;
@@ -142399,11 +142425,17 @@
142399142425
SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
142400142426
Parse *pParse, /* Destroy when this Parser finishes */
142401142427
void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */
142402142428
void *pPtr /* Pointer to object to be cleaned up */
142403142429
){
142404
- ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
142430
+ ParseCleanup *pCleanup;
142431
+ if( sqlite3FaultSim(300) ){
142432
+ pCleanup = 0;
142433
+ sqlite3OomFault(pParse->db);
142434
+ }else{
142435
+ pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
142436
+ }
142405142437
if( pCleanup ){
142406142438
pCleanup->pNext = pParse->pCleanup;
142407142439
pParse->pCleanup = pCleanup;
142408142440
pCleanup->pPtr = pPtr;
142409142441
pCleanup->xCleanup = xCleanup;
@@ -145172,12 +145204,11 @@
145172145204
Expr *p;
145173145205
struct ExprList_item *a;
145174145206
NameContext sNC;
145175145207
145176145208
assert( pSelect!=0 );
145177
- testcase( (pSelect->selFlags & SF_Resolved)==0 );
145178
- assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT );
145209
+ assert( (pSelect->selFlags & SF_Resolved)!=0 );
145179145210
assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
145180145211
assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
145181145212
if( db->mallocFailed || IN_RENAME_OBJECT ) return;
145182145213
while( pSelect->pPrior ) pSelect = pSelect->pPrior;
145183145214
a = pSelect->pEList->a;
@@ -145229,16 +145260,16 @@
145229145260
}
145230145261
}
145231145262
}
145232145263
}
145233145264
if( zType ){
145234
- i64 m = sqlite3Strlen30(zType);
145265
+ const i64 k = sqlite3Strlen30(zType);
145235145266
n = sqlite3Strlen30(pCol->zCnName);
145236
- pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
145267
+ pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2);
145237145268
pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
145238145269
if( pCol->zCnName ){
145239
- memcpy(&pCol->zCnName[n+1], zType, m+1);
145270
+ memcpy(&pCol->zCnName[n+1], zType, k+1);
145240145271
pCol->colFlags |= COLFLAG_HASTYPE;
145241145272
}
145242145273
}
145243145274
pColl = sqlite3ExprCollSeq(pParse, p);
145244145275
if( pColl ){
@@ -149260,12 +149291,11 @@
149260149291
SrcItem *pFrom;
149261149292
149262149293
if( p->selFlags & SF_HasTypeInfo ) return;
149263149294
p->selFlags |= SF_HasTypeInfo;
149264149295
pParse = pWalker->pParse;
149265
- testcase( (p->selFlags & SF_Resolved)==0 );
149266
- assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT );
149296
+ assert( (p->selFlags & SF_Resolved) );
149267149297
pTabList = p->pSrc;
149268149298
for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
149269149299
Table *pTab = pFrom->pTab;
149270149300
assert( pTab!=0 );
149271149301
if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
@@ -156182,11 +156212,14 @@
156182156212
*/
156183156213
z = (const unsigned char*)zCreateTable;
156184156214
for(i=0; aKeyword[i]; i++){
156185156215
int tokenType = 0;
156186156216
do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
156187
- if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT;
156217
+ if( tokenType!=aKeyword[i] ){
156218
+ sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
156219
+ return SQLITE_ERROR;
156220
+ }
156188156221
}
156189156222
156190156223
sqlite3_mutex_enter(db->mutex);
156191156224
pCtx = db->pVtabCtx;
156192156225
if( !pCtx || pCtx->bDeclared ){
@@ -158803,11 +158836,11 @@
158803158836
|| pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
158804158837
);
158805158838
if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
158806158839
pLevel->iLeftJoin = ++pParse->nMem;
158807158840
sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
158808
- VdbeComment((v, "init LEFT JOIN no-match flag"));
158841
+ VdbeComment((v, "init LEFT JOIN match flag"));
158809158842
}
158810158843
158811158844
/* Compute a safe address to jump to if we discover that the table for
158812158845
** this loop is empty and can never contribute content. */
158813158846
for(j=iLevel; j>0; j--){
@@ -163489,11 +163522,11 @@
163489163522
/* No matches cause a break out of the loop */
163490163523
break;
163491163524
}
163492163525
if( i==n ){
163493163526
nOrderBy = n;
163494
- if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){
163527
+ if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){
163495163528
eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0);
163496163529
}else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){
163497163530
eDistinct = 1;
163498163531
}
163499163532
}
@@ -208622,17 +208655,10 @@
208622208655
}
208623208656
if( !eErr ) sqlite3_result_int64(ctx, cnt);
208624208657
jsonParseFree(p);
208625208658
}
208626208659
208627
-/* True if the string is all digits */
208628
-static int jsonAllDigits(const char *z, int n){
208629
- int i;
208630
- for(i=0; i<n && sqlite3Isdigit(z[i]); i++){}
208631
- return i==n;
208632
-}
208633
-
208634208660
/* True if the string is all alphanumerics and underscores */
208635208661
static int jsonAllAlphanum(const char *z, int n){
208636208662
int i;
208637208663
for(i=0; i<n && (sqlite3Isalnum(z[i]) || z[i]=='_'); i++){}
208638208664
return i==n;
@@ -208693,11 +208719,11 @@
208693208719
** NUMBER ==> $[NUMBER] // PG compatible
208694208720
** LABEL ==> $.LABEL // PG compatible
208695208721
** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
208696208722
*/
208697208723
jsonStringInit(&jx, ctx);
208698
- if( jsonAllDigits(zPath, nPath) ){
208724
+ if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
208699208725
jsonAppendRawNZ(&jx, "[", 1);
208700208726
jsonAppendRaw(&jx, zPath, nPath);
208701208727
jsonAppendRawNZ(&jx, "]", 2);
208702208728
}else if( jsonAllAlphanum(zPath, nPath) ){
208703208729
jsonAppendRawNZ(&jx, ".", 1);
@@ -252511,11 +252537,11 @@
252511252537
int nArg, /* Number of args */
252512252538
sqlite3_value **apUnused /* Function arguments */
252513252539
){
252514252540
assert( nArg==0 );
252515252541
UNUSED_PARAM2(nArg, apUnused);
252516
- sqlite3_result_text(pCtx, "fts5: 2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf", -1, SQLITE_TRANSIENT);
252542
+ sqlite3_result_text(pCtx, "fts5: 2024-05-20 17:52:35 08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29", -1, SQLITE_TRANSIENT);
252517252543
}
252518252544
252519252545
/*
252520252546
** Return true if zName is the extension on one of the shadow tables used
252521252547
** by this module.
252522252548
--- 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 ** 42d67c6fed3a5f21d7b71515aca471ba61d3.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.46.0"
463 #define SQLITE_VERSION_NUMBER 3046000
464 #define SQLITE_SOURCE_ID "2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -10253,27 +10253,48 @@
10253 ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
10254 ** is doing a GROUP BY.
10255 ** <li value="2"><p>
10256 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
10257 ** that the query planner does not need the rows returned in any particular
10258 ** order, as long as rows with the same values in all "aOrderBy" columns
10259 ** are adjacent.)^ ^(Furthermore, only a single row for each particular
10260 ** combination of values in the columns identified by the "aOrderBy" field
10261 ** needs to be returned.)^ ^It is always ok for two or more rows with the same
10262 ** values in all "aOrderBy" columns to be returned, as long as all such rows
10263 ** are adjacent. ^The virtual table may, if it chooses, omit extra rows
10264 ** that have the same value for all columns identified by "aOrderBy".
10265 ** ^However omitting the extra rows is optional.
10266 ** This mode is used for a DISTINCT query.
10267 ** <li value="3"><p>
10268 ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
10269 ** that the query planner needs only distinct rows but it does need the
10270 ** rows to be sorted.)^ ^The virtual table implementation is free to omit
10271 ** rows that are identical in all aOrderBy columns, if it wants to, but
10272 ** it is not required to omit any rows. This mode is used for queries
 
 
 
 
 
10273 ** that have both DISTINCT and ORDER BY clauses.
10274 ** </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10275 **
10276 ** ^For the purposes of comparing virtual table output values to see if the
10277 ** values are same value for sorting purposes, two NULL values are considered
10278 ** to be the same. In other words, the comparison operator is "IS"
10279 ** (or "IS NOT DISTINCT FROM") and not "==".
@@ -19262,10 +19283,11 @@
19262 unsigned notCte :1; /* This item may not match a CTE */
19263 unsigned isUsing :1; /* u3.pUsing is valid */
19264 unsigned isOn :1; /* u3.pOn was once valid and non-NULL */
19265 unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
19266 unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
 
19267 } fg;
19268 int iCursor; /* The VDBE cursor number used to access this table */
19269 union {
19270 Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */
19271 IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */
@@ -20806,11 +20828,11 @@
20806 SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*);
20807 SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
20808 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
20809 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
20810 SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*);
20811 SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
20812 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
20813 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
20814 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
20815 SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
20816 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
@@ -21217,11 +21239,13 @@
21217 SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
21218 SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
21219 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
21220 SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*);
21221 SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);
 
21222 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
 
21223 SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
21224 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
21225
21226 #if defined(SQLITE_NEED_ERR_NAME)
21227 SQLITE_PRIVATE const char *sqlite3ErrName(int);
@@ -32752,12 +32776,14 @@
32752 char zLine[1000];
32753 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
32754 x.printfFlags |= SQLITE_PRINTF_INTERNAL;
32755 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
32756 if( pItem->pTab ){
32757 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
32758 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
 
 
32759 }
32760 if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){
32761 sqlite3_str_appendf(&x, " FULL-OUTER-JOIN");
32762 }else if( pItem->fg.jointype & JT_LEFT ){
32763 sqlite3_str_appendf(&x, " LEFT-JOIN");
@@ -88164,11 +88190,11 @@
88164 }
88165 }
88166
88167 /* Check for immediate foreign key violations. */
88168 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
88169 sqlite3VdbeCheckFk(p, 0);
88170 }
88171
88172 /* If the auto-commit flag is set and this is the only active writer
88173 ** VM, then we do either a commit or rollback of the current transaction.
88174 **
@@ -107522,12 +107548,16 @@
107522 ** (See ticket [b92e5e8ec2cdbaa1]).
107523 **
107524 ** If a generated column is referenced, set bits for every column
107525 ** of the table.
107526 */
107527 if( pExpr->iColumn>=0 && cnt==1 && pMatch!=0 ){
107528 pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
 
 
 
 
107529 }
107530
107531 pExpr->op = eNewExprOp;
107532 lookupname_end:
107533 if( cnt==1 ){
@@ -107975,15 +108005,13 @@
107975 #else
107976 pNC->ncFlags &= ~NC_AllowAgg;
107977 #endif
107978 }
107979 }
107980 #ifndef SQLITE_OMIT_WINDOWFUNC
107981 else if( ExprHasProperty(pExpr, EP_WinFunc) ){
107982 is_agg = 1;
107983 }
107984 #endif
107985 sqlite3WalkExprList(pWalker, pList);
107986 if( is_agg ){
107987 if( pExpr->pLeft ){
107988 assert( pExpr->pLeft->op==TK_ORDER );
107989 assert( ExprUseXList(pExpr->pLeft) );
@@ -110419,15 +110447,15 @@
110419 ** This is similar to sqlite3ExprDelete() except that the delete is
110420 ** deferred until the pParse is deleted.
110421 **
110422 ** The pExpr might be deleted immediately on an OOM error.
110423 **
110424 ** The deferred delete is (currently) implemented by adding the
110425 ** pExpr to the pParse->pConstExpr list with a register number of 0.
110426 */
110427 SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
110428 sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
110429 }
110430
110431 /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the
110432 ** expression.
110433 */
@@ -115657,24 +115685,22 @@
115657 if( pExpr->op!=TK_AGG_FUNCTION ){
115658 if( iAgg<pAggInfo->nColumn
115659 && pAggInfo->aCol[iAgg].pCExpr==pExpr
115660 ){
115661 pExpr = sqlite3ExprDup(db, pExpr, 0);
115662 if( pExpr ){
115663 pAggInfo->aCol[iAgg].pCExpr = pExpr;
115664 sqlite3ExprDeferredDelete(pParse, pExpr);
115665 }
115666 }
115667 }else{
115668 assert( pExpr->op==TK_AGG_FUNCTION );
115669 if( ALWAYS(iAgg<pAggInfo->nFunc)
115670 && pAggInfo->aFunc[iAgg].pFExpr==pExpr
115671 ){
115672 pExpr = sqlite3ExprDup(db, pExpr, 0);
115673 if( pExpr ){
115674 pAggInfo->aFunc[iAgg].pFExpr = pExpr;
115675 sqlite3ExprDeferredDelete(pParse, pExpr);
115676 }
115677 }
115678 }
115679 }
115680 return WRC_Continue;
@@ -142399,11 +142425,17 @@
142399 SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
142400 Parse *pParse, /* Destroy when this Parser finishes */
142401 void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */
142402 void *pPtr /* Pointer to object to be cleaned up */
142403 ){
142404 ParseCleanup *pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
 
 
 
 
 
 
142405 if( pCleanup ){
142406 pCleanup->pNext = pParse->pCleanup;
142407 pParse->pCleanup = pCleanup;
142408 pCleanup->pPtr = pPtr;
142409 pCleanup->xCleanup = xCleanup;
@@ -145172,12 +145204,11 @@
145172 Expr *p;
145173 struct ExprList_item *a;
145174 NameContext sNC;
145175
145176 assert( pSelect!=0 );
145177 testcase( (pSelect->selFlags & SF_Resolved)==0 );
145178 assert( (pSelect->selFlags & SF_Resolved)!=0 || IN_RENAME_OBJECT );
145179 assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
145180 assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
145181 if( db->mallocFailed || IN_RENAME_OBJECT ) return;
145182 while( pSelect->pPrior ) pSelect = pSelect->pPrior;
145183 a = pSelect->pEList->a;
@@ -145229,16 +145260,16 @@
145229 }
145230 }
145231 }
145232 }
145233 if( zType ){
145234 i64 m = sqlite3Strlen30(zType);
145235 n = sqlite3Strlen30(pCol->zCnName);
145236 pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+m+2);
145237 pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
145238 if( pCol->zCnName ){
145239 memcpy(&pCol->zCnName[n+1], zType, m+1);
145240 pCol->colFlags |= COLFLAG_HASTYPE;
145241 }
145242 }
145243 pColl = sqlite3ExprCollSeq(pParse, p);
145244 if( pColl ){
@@ -149260,12 +149291,11 @@
149260 SrcItem *pFrom;
149261
149262 if( p->selFlags & SF_HasTypeInfo ) return;
149263 p->selFlags |= SF_HasTypeInfo;
149264 pParse = pWalker->pParse;
149265 testcase( (p->selFlags & SF_Resolved)==0 );
149266 assert( (p->selFlags & SF_Resolved) || IN_RENAME_OBJECT );
149267 pTabList = p->pSrc;
149268 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
149269 Table *pTab = pFrom->pTab;
149270 assert( pTab!=0 );
149271 if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
@@ -156182,11 +156212,14 @@
156182 */
156183 z = (const unsigned char*)zCreateTable;
156184 for(i=0; aKeyword[i]; i++){
156185 int tokenType = 0;
156186 do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
156187 if( tokenType!=aKeyword[i] ) return SQLITE_MISUSE_BKPT;
 
 
 
156188 }
156189
156190 sqlite3_mutex_enter(db->mutex);
156191 pCtx = db->pVtabCtx;
156192 if( !pCtx || pCtx->bDeclared ){
@@ -158803,11 +158836,11 @@
158803 || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
158804 );
158805 if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
158806 pLevel->iLeftJoin = ++pParse->nMem;
158807 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
158808 VdbeComment((v, "init LEFT JOIN no-match flag"));
158809 }
158810
158811 /* Compute a safe address to jump to if we discover that the table for
158812 ** this loop is empty and can never contribute content. */
158813 for(j=iLevel; j>0; j--){
@@ -163489,11 +163522,11 @@
163489 /* No matches cause a break out of the loop */
163490 break;
163491 }
163492 if( i==n ){
163493 nOrderBy = n;
163494 if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) ){
163495 eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0);
163496 }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){
163497 eDistinct = 1;
163498 }
163499 }
@@ -208622,17 +208655,10 @@
208622 }
208623 if( !eErr ) sqlite3_result_int64(ctx, cnt);
208624 jsonParseFree(p);
208625 }
208626
208627 /* True if the string is all digits */
208628 static int jsonAllDigits(const char *z, int n){
208629 int i;
208630 for(i=0; i<n && sqlite3Isdigit(z[i]); i++){}
208631 return i==n;
208632 }
208633
208634 /* True if the string is all alphanumerics and underscores */
208635 static int jsonAllAlphanum(const char *z, int n){
208636 int i;
208637 for(i=0; i<n && (sqlite3Isalnum(z[i]) || z[i]=='_'); i++){}
208638 return i==n;
@@ -208693,11 +208719,11 @@
208693 ** NUMBER ==> $[NUMBER] // PG compatible
208694 ** LABEL ==> $.LABEL // PG compatible
208695 ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
208696 */
208697 jsonStringInit(&jx, ctx);
208698 if( jsonAllDigits(zPath, nPath) ){
208699 jsonAppendRawNZ(&jx, "[", 1);
208700 jsonAppendRaw(&jx, zPath, nPath);
208701 jsonAppendRawNZ(&jx, "]", 2);
208702 }else if( jsonAllAlphanum(zPath, nPath) ){
208703 jsonAppendRawNZ(&jx, ".", 1);
@@ -252511,11 +252537,11 @@
252511 int nArg, /* Number of args */
252512 sqlite3_value **apUnused /* Function arguments */
252513 ){
252514 assert( nArg==0 );
252515 UNUSED_PARAM2(nArg, apUnused);
252516 sqlite3_result_text(pCtx, "fts5: 2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf", -1, SQLITE_TRANSIENT);
252517 }
252518
252519 /*
252520 ** Return true if zName is the extension on one of the shadow tables used
252521 ** by this module.
252522
--- 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 ** de8182cf1773ac0d04268d896a613841cf6b.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -459,11 +459,11 @@
459 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
460 ** [sqlite_version()] and [sqlite_source_id()].
461 */
462 #define SQLITE_VERSION "3.46.0"
463 #define SQLITE_VERSION_NUMBER 3046000
464 #define SQLITE_SOURCE_ID "2024-05-21 11:11:29 de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb"
465
466 /*
467 ** CAPI3REF: Run-Time Library Version Numbers
468 ** KEYWORDS: sqlite3_version sqlite3_sourceid
469 **
@@ -10253,27 +10253,48 @@
10253 ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
10254 ** is doing a GROUP BY.
10255 ** <li value="2"><p>
10256 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
10257 ** that the query planner does not need the rows returned in any particular
10258 ** order, as long as rows with the same values in all columns identified
10259 ** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows
10260 ** contain the same values for all columns identified by "colUsed", all but
10261 ** one such row may optionally be omitted from the result.)^
10262 ** The virtual table is not required to omit rows that are duplicates
10263 ** over the "colUsed" columns, but if the virtual table can do that without
10264 ** too much extra effort, it could potentially help the query to run faster.
 
10265 ** This mode is used for a DISTINCT query.
10266 ** <li value="3"><p>
10267 ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
10268 ** virtual table must return rows in the order defined by "aOrderBy" as
10269 ** if the sqlite3_vtab_distinct() interface had returned 0. However if
10270 ** two or more rows in the result have the same values for all columns
10271 ** identified by "colUsed", then all but one such row may optionally be
10272 ** omitted.)^ Like when the return value is 2, the virtual table
10273 ** is not required to omit rows that are duplicates over the "colUsed"
10274 ** columns, but if the virtual table can do that without
10275 ** too much extra effort, it could potentially help the query to run faster.
10276 ** This mode is used for queries
10277 ** that have both DISTINCT and ORDER BY clauses.
10278 ** </ol>
10279 **
10280 ** <p>The following table summarizes the conditions under which the
10281 ** virtual table is allowed to set the "orderByConsumed" flag based on
10282 ** the value returned by sqlite3_vtab_distinct(). This table is a
10283 ** restatement of the previous four paragraphs:
10284 **
10285 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
10286 ** <tr>
10287 ** <td valign="top">sqlite3_vtab_distinct() return value
10288 ** <td valign="top">Rows are returned in aOrderBy order
10289 ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
10290 ** <td valign="top">Duplicates over all colUsed columns may be omitted
10291 ** <tr><td>0<td>yes<td>yes<td>no
10292 ** <tr><td>1<td>no<td>yes<td>no
10293 ** <tr><td>2<td>no<td>yes<td>yes
10294 ** <tr><td>3<td>yes<td>yes<td>yes
10295 ** </table>
10296 **
10297 ** ^For the purposes of comparing virtual table output values to see if the
10298 ** values are same value for sorting purposes, two NULL values are considered
10299 ** to be the same. In other words, the comparison operator is "IS"
10300 ** (or "IS NOT DISTINCT FROM") and not "==".
@@ -19262,10 +19283,11 @@
19283 unsigned notCte :1; /* This item may not match a CTE */
19284 unsigned isUsing :1; /* u3.pUsing is valid */
19285 unsigned isOn :1; /* u3.pOn was once valid and non-NULL */
19286 unsigned isSynthUsing :1; /* u3.pUsing is synthesized from NATURAL */
19287 unsigned isNestedFrom :1; /* pSelect is a SF_NestedFrom subquery */
19288 unsigned rowidUsed :1; /* The ROWID of this table is referenced */
19289 } fg;
19290 int iCursor; /* The VDBE cursor number used to access this table */
19291 union {
19292 Expr *pOn; /* fg.isUsing==0 => The ON clause of a join */
19293 IdList *pUsing; /* fg.isUsing==1 => The USING clause of a join */
@@ -20806,11 +20828,11 @@
20828 SQLITE_PRIVATE void sqlite3ExprOrderByAggregateError(Parse*,Expr*);
20829 SQLITE_PRIVATE void sqlite3ExprFunctionUsable(Parse*,const Expr*,const FuncDef*);
20830 SQLITE_PRIVATE void sqlite3ExprAssignVarNumber(Parse*, Expr*, u32);
20831 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
20832 SQLITE_PRIVATE void sqlite3ExprDeleteGeneric(sqlite3*,void*);
20833 SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse*, Expr*);
20834 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
20835 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
20836 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
20837 SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
20838 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
@@ -21217,11 +21239,13 @@
21239 SQLITE_PRIVATE int sqlite3DecOrHexToI64(const char*, i64*);
21240 SQLITE_PRIVATE void sqlite3ErrorWithMsg(sqlite3*, int, const char*,...);
21241 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
21242 SQLITE_PRIVATE void sqlite3ErrorClear(sqlite3*);
21243 SQLITE_PRIVATE void sqlite3SystemError(sqlite3*,int);
21244 #if !defined(SQLITE_OMIT_BLOB_LITERAL)
21245 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
21246 #endif
21247 SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
21248 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
21249
21250 #if defined(SQLITE_NEED_ERR_NAME)
21251 SQLITE_PRIVATE const char *sqlite3ErrName(int);
@@ -32752,12 +32776,14 @@
32776 char zLine[1000];
32777 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
32778 x.printfFlags |= SQLITE_PRINTF_INTERNAL;
32779 sqlite3_str_appendf(&x, "{%d:*} %!S", pItem->iCursor, pItem);
32780 if( pItem->pTab ){
32781 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx%s",
32782 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab,
32783 pItem->colUsed,
32784 pItem->fg.rowidUsed ? "+rowid" : "");
32785 }
32786 if( (pItem->fg.jointype & (JT_LEFT|JT_RIGHT))==(JT_LEFT|JT_RIGHT) ){
32787 sqlite3_str_appendf(&x, " FULL-OUTER-JOIN");
32788 }else if( pItem->fg.jointype & JT_LEFT ){
32789 sqlite3_str_appendf(&x, " LEFT-JOIN");
@@ -88164,11 +88190,11 @@
88190 }
88191 }
88192
88193 /* Check for immediate foreign key violations. */
88194 if( p->rc==SQLITE_OK || (p->errorAction==OE_Fail && !isSpecialError) ){
88195 (void)sqlite3VdbeCheckFk(p, 0);
88196 }
88197
88198 /* If the auto-commit flag is set and this is the only active writer
88199 ** VM, then we do either a commit or rollback of the current transaction.
88200 **
@@ -107522,12 +107548,16 @@
107548 ** (See ticket [b92e5e8ec2cdbaa1]).
107549 **
107550 ** If a generated column is referenced, set bits for every column
107551 ** of the table.
107552 */
107553 if( pMatch ){
107554 if( pExpr->iColumn>=0 ){
107555 pMatch->colUsed |= sqlite3ExprColUsed(pExpr);
107556 }else{
107557 pMatch->fg.rowidUsed = 1;
107558 }
107559 }
107560
107561 pExpr->op = eNewExprOp;
107562 lookupname_end:
107563 if( cnt==1 ){
@@ -107975,15 +108005,13 @@
108005 #else
108006 pNC->ncFlags &= ~NC_AllowAgg;
108007 #endif
108008 }
108009 }
108010 else if( ExprHasProperty(pExpr, EP_WinFunc) || pExpr->pLeft ){
 
108011 is_agg = 1;
108012 }
 
108013 sqlite3WalkExprList(pWalker, pList);
108014 if( is_agg ){
108015 if( pExpr->pLeft ){
108016 assert( pExpr->pLeft->op==TK_ORDER );
108017 assert( ExprUseXList(pExpr->pLeft) );
@@ -110419,15 +110447,15 @@
110447 ** This is similar to sqlite3ExprDelete() except that the delete is
110448 ** deferred until the pParse is deleted.
110449 **
110450 ** The pExpr might be deleted immediately on an OOM error.
110451 **
110452 ** Return 0 if the delete was successfully deferred. Return non-zero
110453 ** if the delete happened immediately because of an OOM.
110454 */
110455 SQLITE_PRIVATE int sqlite3ExprDeferredDelete(Parse *pParse, Expr *pExpr){
110456 return 0==sqlite3ParserAddCleanup(pParse, sqlite3ExprDeleteGeneric, pExpr);
110457 }
110458
110459 /* Invoke sqlite3RenameExprUnmap() and sqlite3ExprDelete() on the
110460 ** expression.
110461 */
@@ -115657,24 +115685,22 @@
115685 if( pExpr->op!=TK_AGG_FUNCTION ){
115686 if( iAgg<pAggInfo->nColumn
115687 && pAggInfo->aCol[iAgg].pCExpr==pExpr
115688 ){
115689 pExpr = sqlite3ExprDup(db, pExpr, 0);
115690 if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
115691 pAggInfo->aCol[iAgg].pCExpr = pExpr;
 
115692 }
115693 }
115694 }else{
115695 assert( pExpr->op==TK_AGG_FUNCTION );
115696 if( ALWAYS(iAgg<pAggInfo->nFunc)
115697 && pAggInfo->aFunc[iAgg].pFExpr==pExpr
115698 ){
115699 pExpr = sqlite3ExprDup(db, pExpr, 0);
115700 if( pExpr && !sqlite3ExprDeferredDelete(pParse, pExpr) ){
115701 pAggInfo->aFunc[iAgg].pFExpr = pExpr;
 
115702 }
115703 }
115704 }
115705 }
115706 return WRC_Continue;
@@ -142399,11 +142425,17 @@
142425 SQLITE_PRIVATE void *sqlite3ParserAddCleanup(
142426 Parse *pParse, /* Destroy when this Parser finishes */
142427 void (*xCleanup)(sqlite3*,void*), /* The cleanup routine */
142428 void *pPtr /* Pointer to object to be cleaned up */
142429 ){
142430 ParseCleanup *pCleanup;
142431 if( sqlite3FaultSim(300) ){
142432 pCleanup = 0;
142433 sqlite3OomFault(pParse->db);
142434 }else{
142435 pCleanup = sqlite3DbMallocRaw(pParse->db, sizeof(*pCleanup));
142436 }
142437 if( pCleanup ){
142438 pCleanup->pNext = pParse->pCleanup;
142439 pParse->pCleanup = pCleanup;
142440 pCleanup->pPtr = pPtr;
142441 pCleanup->xCleanup = xCleanup;
@@ -145172,12 +145204,11 @@
145204 Expr *p;
145205 struct ExprList_item *a;
145206 NameContext sNC;
145207
145208 assert( pSelect!=0 );
145209 assert( (pSelect->selFlags & SF_Resolved)!=0 );
 
145210 assert( pTab->nCol==pSelect->pEList->nExpr || pParse->nErr>0 );
145211 assert( aff==SQLITE_AFF_NONE || aff==SQLITE_AFF_BLOB );
145212 if( db->mallocFailed || IN_RENAME_OBJECT ) return;
145213 while( pSelect->pPrior ) pSelect = pSelect->pPrior;
145214 a = pSelect->pEList->a;
@@ -145229,16 +145260,16 @@
145260 }
145261 }
145262 }
145263 }
145264 if( zType ){
145265 const i64 k = sqlite3Strlen30(zType);
145266 n = sqlite3Strlen30(pCol->zCnName);
145267 pCol->zCnName = sqlite3DbReallocOrFree(db, pCol->zCnName, n+k+2);
145268 pCol->colFlags &= ~(COLFLAG_HASTYPE|COLFLAG_HASCOLL);
145269 if( pCol->zCnName ){
145270 memcpy(&pCol->zCnName[n+1], zType, k+1);
145271 pCol->colFlags |= COLFLAG_HASTYPE;
145272 }
145273 }
145274 pColl = sqlite3ExprCollSeq(pParse, p);
145275 if( pColl ){
@@ -149260,12 +149291,11 @@
149291 SrcItem *pFrom;
149292
149293 if( p->selFlags & SF_HasTypeInfo ) return;
149294 p->selFlags |= SF_HasTypeInfo;
149295 pParse = pWalker->pParse;
149296 assert( (p->selFlags & SF_Resolved) );
 
149297 pTabList = p->pSrc;
149298 for(i=0, pFrom=pTabList->a; i<pTabList->nSrc; i++, pFrom++){
149299 Table *pTab = pFrom->pTab;
149300 assert( pTab!=0 );
149301 if( (pTab->tabFlags & TF_Ephemeral)!=0 ){
@@ -156182,11 +156212,14 @@
156212 */
156213 z = (const unsigned char*)zCreateTable;
156214 for(i=0; aKeyword[i]; i++){
156215 int tokenType = 0;
156216 do{ z += sqlite3GetToken(z, &tokenType); }while( tokenType==TK_SPACE );
156217 if( tokenType!=aKeyword[i] ){
156218 sqlite3ErrorWithMsg(db, SQLITE_ERROR, "syntax error");
156219 return SQLITE_ERROR;
156220 }
156221 }
156222
156223 sqlite3_mutex_enter(db->mutex);
156224 pCtx = db->pVtabCtx;
156225 if( !pCtx || pCtx->bDeclared ){
@@ -158803,11 +158836,11 @@
158836 || pLevel->iFrom>0 || (pTabItem[0].fg.jointype & JT_LEFT)==0
158837 );
158838 if( pLevel->iFrom>0 && (pTabItem[0].fg.jointype & JT_LEFT)!=0 ){
158839 pLevel->iLeftJoin = ++pParse->nMem;
158840 sqlite3VdbeAddOp2(v, OP_Integer, 0, pLevel->iLeftJoin);
158841 VdbeComment((v, "init LEFT JOIN match flag"));
158842 }
158843
158844 /* Compute a safe address to jump to if we discover that the table for
158845 ** this loop is empty and can never contribute content. */
158846 for(j=iLevel; j>0; j--){
@@ -163489,11 +163522,11 @@
163522 /* No matches cause a break out of the loop */
163523 break;
163524 }
163525 if( i==n ){
163526 nOrderBy = n;
163527 if( (pWInfo->wctrlFlags & WHERE_DISTINCTBY) && !pSrc->fg.rowidUsed ){
163528 eDistinct = 2 + ((pWInfo->wctrlFlags & WHERE_SORTBYGROUP)!=0);
163529 }else if( pWInfo->wctrlFlags & WHERE_GROUPBY ){
163530 eDistinct = 1;
163531 }
163532 }
@@ -208622,17 +208655,10 @@
208655 }
208656 if( !eErr ) sqlite3_result_int64(ctx, cnt);
208657 jsonParseFree(p);
208658 }
208659
 
 
 
 
 
 
 
208660 /* True if the string is all alphanumerics and underscores */
208661 static int jsonAllAlphanum(const char *z, int n){
208662 int i;
208663 for(i=0; i<n && (sqlite3Isalnum(z[i]) || z[i]=='_'); i++){}
208664 return i==n;
@@ -208693,11 +208719,11 @@
208719 ** NUMBER ==> $[NUMBER] // PG compatible
208720 ** LABEL ==> $.LABEL // PG compatible
208721 ** [NUMBER] ==> $[NUMBER] // Not PG. Purely for convenience
208722 */
208723 jsonStringInit(&jx, ctx);
208724 if( sqlite3_value_type(argv[i])==SQLITE_INTEGER ){
208725 jsonAppendRawNZ(&jx, "[", 1);
208726 jsonAppendRaw(&jx, zPath, nPath);
208727 jsonAppendRawNZ(&jx, "]", 2);
208728 }else if( jsonAllAlphanum(zPath, nPath) ){
208729 jsonAppendRawNZ(&jx, ".", 1);
@@ -252511,11 +252537,11 @@
252537 int nArg, /* Number of args */
252538 sqlite3_value **apUnused /* Function arguments */
252539 ){
252540 assert( nArg==0 );
252541 UNUSED_PARAM2(nArg, apUnused);
252542 sqlite3_result_text(pCtx, "fts5: 2024-05-20 17:52:35 08058d66d1bde4fcf8324482ee4c6c030c681383470d5076b6f75b74aac2ae29", -1, SQLITE_TRANSIENT);
252543 }
252544
252545 /*
252546 ** Return true if zName is the extension on one of the shadow tables used
252547 ** by this module.
252548
+35 -14
--- 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.46.0"
150150
#define SQLITE_VERSION_NUMBER 3046000
151
-#define SQLITE_SOURCE_ID "2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf"
151
+#define SQLITE_SOURCE_ID "2024-05-21 11:11:29 de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -9940,27 +9940,48 @@
99409940
** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
99419941
** is doing a GROUP BY.
99429942
** <li value="2"><p>
99439943
** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
99449944
** that the query planner does not need the rows returned in any particular
9945
-** order, as long as rows with the same values in all "aOrderBy" columns
9946
-** are adjacent.)^ ^(Furthermore, only a single row for each particular
9947
-** combination of values in the columns identified by the "aOrderBy" field
9948
-** needs to be returned.)^ ^It is always ok for two or more rows with the same
9949
-** values in all "aOrderBy" columns to be returned, as long as all such rows
9950
-** are adjacent. ^The virtual table may, if it chooses, omit extra rows
9951
-** that have the same value for all columns identified by "aOrderBy".
9952
-** ^However omitting the extra rows is optional.
9945
+** order, as long as rows with the same values in all columns identified
9946
+** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows
9947
+** contain the same values for all columns identified by "colUsed", all but
9948
+** one such row may optionally be omitted from the result.)^
9949
+** The virtual table is not required to omit rows that are duplicates
9950
+** over the "colUsed" columns, but if the virtual table can do that without
9951
+** too much extra effort, it could potentially help the query to run faster.
99539952
** This mode is used for a DISTINCT query.
99549953
** <li value="3"><p>
9955
-** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
9956
-** that the query planner needs only distinct rows but it does need the
9957
-** rows to be sorted.)^ ^The virtual table implementation is free to omit
9958
-** rows that are identical in all aOrderBy columns, if it wants to, but
9959
-** it is not required to omit any rows. This mode is used for queries
9954
+** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
9955
+** virtual table must return rows in the order defined by "aOrderBy" as
9956
+** if the sqlite3_vtab_distinct() interface had returned 0. However if
9957
+** two or more rows in the result have the same values for all columns
9958
+** identified by "colUsed", then all but one such row may optionally be
9959
+** omitted.)^ Like when the return value is 2, the virtual table
9960
+** is not required to omit rows that are duplicates over the "colUsed"
9961
+** columns, but if the virtual table can do that without
9962
+** too much extra effort, it could potentially help the query to run faster.
9963
+** This mode is used for queries
99609964
** that have both DISTINCT and ORDER BY clauses.
99619965
** </ol>
9966
+**
9967
+** <p>The following table summarizes the conditions under which the
9968
+** virtual table is allowed to set the "orderByConsumed" flag based on
9969
+** the value returned by sqlite3_vtab_distinct(). This table is a
9970
+** restatement of the previous four paragraphs:
9971
+**
9972
+** <table border=1 cellspacing=0 cellpadding=10 width="90%">
9973
+** <tr>
9974
+** <td valign="top">sqlite3_vtab_distinct() return value
9975
+** <td valign="top">Rows are returned in aOrderBy order
9976
+** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
9977
+** <td valign="top">Duplicates over all colUsed columns may be omitted
9978
+** <tr><td>0<td>yes<td>yes<td>no
9979
+** <tr><td>1<td>no<td>yes<td>no
9980
+** <tr><td>2<td>no<td>yes<td>yes
9981
+** <tr><td>3<td>yes<td>yes<td>yes
9982
+** </table>
99629983
**
99639984
** ^For the purposes of comparing virtual table output values to see if the
99649985
** values are same value for sorting purposes, two NULL values are considered
99659986
** to be the same. In other words, the comparison operator is "IS"
99669987
** (or "IS NOT DISTINCT FROM") and not "==".
99679988
--- 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.46.0"
150 #define SQLITE_VERSION_NUMBER 3046000
151 #define SQLITE_SOURCE_ID "2024-05-08 11:51:56 42d67c6fed3a5f21d7b71515aca471ba61d387e620022735a2e7929fa3a237cf"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9940,27 +9940,48 @@
9940 ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
9941 ** is doing a GROUP BY.
9942 ** <li value="2"><p>
9943 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
9944 ** that the query planner does not need the rows returned in any particular
9945 ** order, as long as rows with the same values in all "aOrderBy" columns
9946 ** are adjacent.)^ ^(Furthermore, only a single row for each particular
9947 ** combination of values in the columns identified by the "aOrderBy" field
9948 ** needs to be returned.)^ ^It is always ok for two or more rows with the same
9949 ** values in all "aOrderBy" columns to be returned, as long as all such rows
9950 ** are adjacent. ^The virtual table may, if it chooses, omit extra rows
9951 ** that have the same value for all columns identified by "aOrderBy".
9952 ** ^However omitting the extra rows is optional.
9953 ** This mode is used for a DISTINCT query.
9954 ** <li value="3"><p>
9955 ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means
9956 ** that the query planner needs only distinct rows but it does need the
9957 ** rows to be sorted.)^ ^The virtual table implementation is free to omit
9958 ** rows that are identical in all aOrderBy columns, if it wants to, but
9959 ** it is not required to omit any rows. This mode is used for queries
 
 
 
 
 
9960 ** that have both DISTINCT and ORDER BY clauses.
9961 ** </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9962 **
9963 ** ^For the purposes of comparing virtual table output values to see if the
9964 ** values are same value for sorting purposes, two NULL values are considered
9965 ** to be the same. In other words, the comparison operator is "IS"
9966 ** (or "IS NOT DISTINCT FROM") and not "==".
9967
--- 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.46.0"
150 #define SQLITE_VERSION_NUMBER 3046000
151 #define SQLITE_SOURCE_ID "2024-05-21 11:11:29 de8182cf1773ac0d04268d896a613841cf6bf61f9f030342170657d5e06f2acb"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -9940,27 +9940,48 @@
9940 ** "aOrderBy" field are adjacent.)^ This mode is used when the query planner
9941 ** is doing a GROUP BY.
9942 ** <li value="2"><p>
9943 ** ^(If the sqlite3_vtab_distinct() interface returns 2, that means
9944 ** that the query planner does not need the rows returned in any particular
9945 ** order, as long as rows with the same values in all columns identified
9946 ** by "aOrderBy" are adjacent.)^ ^(Furthermore, when two or more rows
9947 ** contain the same values for all columns identified by "colUsed", all but
9948 ** one such row may optionally be omitted from the result.)^
9949 ** The virtual table is not required to omit rows that are duplicates
9950 ** over the "colUsed" columns, but if the virtual table can do that without
9951 ** too much extra effort, it could potentially help the query to run faster.
 
9952 ** This mode is used for a DISTINCT query.
9953 ** <li value="3"><p>
9954 ** ^(If the sqlite3_vtab_distinct() interface returns 3, that means the
9955 ** virtual table must return rows in the order defined by "aOrderBy" as
9956 ** if the sqlite3_vtab_distinct() interface had returned 0. However if
9957 ** two or more rows in the result have the same values for all columns
9958 ** identified by "colUsed", then all but one such row may optionally be
9959 ** omitted.)^ Like when the return value is 2, the virtual table
9960 ** is not required to omit rows that are duplicates over the "colUsed"
9961 ** columns, but if the virtual table can do that without
9962 ** too much extra effort, it could potentially help the query to run faster.
9963 ** This mode is used for queries
9964 ** that have both DISTINCT and ORDER BY clauses.
9965 ** </ol>
9966 **
9967 ** <p>The following table summarizes the conditions under which the
9968 ** virtual table is allowed to set the "orderByConsumed" flag based on
9969 ** the value returned by sqlite3_vtab_distinct(). This table is a
9970 ** restatement of the previous four paragraphs:
9971 **
9972 ** <table border=1 cellspacing=0 cellpadding=10 width="90%">
9973 ** <tr>
9974 ** <td valign="top">sqlite3_vtab_distinct() return value
9975 ** <td valign="top">Rows are returned in aOrderBy order
9976 ** <td valign="top">Rows with the same value in all aOrderBy columns are adjacent
9977 ** <td valign="top">Duplicates over all colUsed columns may be omitted
9978 ** <tr><td>0<td>yes<td>yes<td>no
9979 ** <tr><td>1<td>no<td>yes<td>no
9980 ** <tr><td>2<td>no<td>yes<td>yes
9981 ** <tr><td>3<td>yes<td>yes<td>yes
9982 ** </table>
9983 **
9984 ** ^For the purposes of comparing virtual table output values to see if the
9985 ** values are same value for sorting purposes, two NULL values are considered
9986 ** to be the same. In other words, the comparison operator is "IS"
9987 ** (or "IS NOT DISTINCT FROM") and not "==".
9988

Keyboard Shortcuts

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