Fossil SCM

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

drh 2026-05-29 10:13 UTC trunk
Commit 3b2d0c9f59eb7bdce2473ff7c4c9f8dcf87cd3146899743beca91bb36dcdef0b
+9 -5
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1792,11 +1792,11 @@
17921792
}
17931793
if( i>0 ){
17941794
sqlite3_str_append(pOut, (const char*)z, i);
17951795
}
17961796
switch( z[i] ){
1797
- case '>': sqlite3_str_append(pOut, "<", 4); break;
1797
+ case '>': sqlite3_str_append(pOut, ">", 4); break;
17981798
case '&': sqlite3_str_append(pOut, "&", 5); break;
17991799
case '<': sqlite3_str_append(pOut, "&lt;", 4); break;
18001800
case '"': sqlite3_str_append(pOut, "&quot;", 6); break;
18011801
case '\'': sqlite3_str_append(pOut, "&#39;", 5); break;
18021802
default: i--;
@@ -2286,11 +2286,11 @@
22862286
if( bWrap && z[i]!=0 && !qrfSpace(z[i]) && qrfAlnum(c)==qrfAlnum(z[i]) ){
22872287
/* Perhaps try to back up to a better place to break the line */
22882288
for(k=i-1; k>=i/2; k--){
22892289
if( qrfSpace(z[k]) ) break;
22902290
}
2291
- if( k<i/2 ){
2291
+ if( k<i/2 && i/2>0 ){
22922292
for(k=i; k>=i/2; k--){
22932293
if( qrfAlnum(z[k-1])!=qrfAlnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
22942294
}
22952295
}
22962296
if( k>=i/2 ){
@@ -19811,11 +19811,11 @@
1981119811
" FROM temp.%s WHERE %s",
1981219812
p->zSU, zWhere);
1981319813
if( pStmt==0 ) return 1;
1981419814
rc = sqlite3_step(pStmt);
1981519815
if( rc==SQLITE_ROW ){
19816
- analysisTitle(p, zTitle);
19816
+ analysisTitle(p, "%s", zTitle);
1981719817
1981819818
nentry = sqlite3_column_int64(pStmt, 0);
1981919819
payload = sqlite3_column_int64(pStmt, 1);
1982019820
ovfl_payload = sqlite3_column_int64(pStmt, 2);
1982119821
mx_payload = sqlite3_column_int64(pStmt, 3);
@@ -25210,11 +25210,15 @@
2521025210
** of cases 1 and 2 */
2521125211
case 3: return "SQLITE_PS1";
2521225212
case 4: return "SQLITE_PS2";
2521325213
2521425214
/* Name of the application */
25215
+#ifndef SQLITE_CLI_APPNAME
2521525216
case 'A': return "SQLite";
25217
+#else
25218
+ case 'A': return SHELL_STRINGIFY(SQLITE_CLI_APPNAME);
25219
+#endif
2521625220
2521725221
/* Full version number of the application, including patch level */
2521825222
case 'V': return sqlite3_libversion();
2521925223
2522025224
/* Version number without the patch level */
@@ -37839,11 +37843,11 @@
3783937843
3784037844
#if HAVE_EDITLINE
3784137845
/*
3784237846
** https://sqlite.org/forum/forumpost/aad7a634916ff050:
3784337847
**
37844
-** Calling setlocale(LC_ALL,"") is required to get libedit to accept
37848
+** Calling setlocale(LC_...,"") is required to get libedit to accept
3784537849
** non-ASCII input.
3784637850
*/
3784737851
#define DO_SET_LOCALE 1
3784837852
#include <locale.h>
3784937853
#else
@@ -38116,11 +38120,11 @@
3811638120
stdin_is_interactive = 0;
3811738121
nCmd++;
3811838122
azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
3811938123
shell_check_oom(azCmd);
3812038124
aiCmd = realloc(aiCmd, sizeof(aiCmd[0])*nCmd);
38121
- shell_check_oom(azCmd);
38125
+ shell_check_oom(aiCmd);
3812238126
azCmd[nCmd-1] = z;
3812338127
aiCmd[nCmd-1] = i;
3812438128
}
3812538129
continue;
3812638130
}
3812738131
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1792,11 +1792,11 @@
1792 }
1793 if( i>0 ){
1794 sqlite3_str_append(pOut, (const char*)z, i);
1795 }
1796 switch( z[i] ){
1797 case '>': sqlite3_str_append(pOut, "&lt;", 4); break;
1798 case '&': sqlite3_str_append(pOut, "&amp;", 5); break;
1799 case '<': sqlite3_str_append(pOut, "&lt;", 4); break;
1800 case '"': sqlite3_str_append(pOut, "&quot;", 6); break;
1801 case '\'': sqlite3_str_append(pOut, "&#39;", 5); break;
1802 default: i--;
@@ -2286,11 +2286,11 @@
2286 if( bWrap && z[i]!=0 && !qrfSpace(z[i]) && qrfAlnum(c)==qrfAlnum(z[i]) ){
2287 /* Perhaps try to back up to a better place to break the line */
2288 for(k=i-1; k>=i/2; k--){
2289 if( qrfSpace(z[k]) ) break;
2290 }
2291 if( k<i/2 ){
2292 for(k=i; k>=i/2; k--){
2293 if( qrfAlnum(z[k-1])!=qrfAlnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
2294 }
2295 }
2296 if( k>=i/2 ){
@@ -19811,11 +19811,11 @@
19811 " FROM temp.%s WHERE %s",
19812 p->zSU, zWhere);
19813 if( pStmt==0 ) return 1;
19814 rc = sqlite3_step(pStmt);
19815 if( rc==SQLITE_ROW ){
19816 analysisTitle(p, zTitle);
19817
19818 nentry = sqlite3_column_int64(pStmt, 0);
19819 payload = sqlite3_column_int64(pStmt, 1);
19820 ovfl_payload = sqlite3_column_int64(pStmt, 2);
19821 mx_payload = sqlite3_column_int64(pStmt, 3);
@@ -25210,11 +25210,15 @@
25210 ** of cases 1 and 2 */
25211 case 3: return "SQLITE_PS1";
25212 case 4: return "SQLITE_PS2";
25213
25214 /* Name of the application */
 
25215 case 'A': return "SQLite";
 
 
 
25216
25217 /* Full version number of the application, including patch level */
25218 case 'V': return sqlite3_libversion();
25219
25220 /* Version number without the patch level */
@@ -37839,11 +37843,11 @@
37839
37840 #if HAVE_EDITLINE
37841 /*
37842 ** https://sqlite.org/forum/forumpost/aad7a634916ff050:
37843 **
37844 ** Calling setlocale(LC_ALL,"") is required to get libedit to accept
37845 ** non-ASCII input.
37846 */
37847 #define DO_SET_LOCALE 1
37848 #include <locale.h>
37849 #else
@@ -38116,11 +38120,11 @@
38116 stdin_is_interactive = 0;
38117 nCmd++;
38118 azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
38119 shell_check_oom(azCmd);
38120 aiCmd = realloc(aiCmd, sizeof(aiCmd[0])*nCmd);
38121 shell_check_oom(azCmd);
38122 azCmd[nCmd-1] = z;
38123 aiCmd[nCmd-1] = i;
38124 }
38125 continue;
38126 }
38127
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -1792,11 +1792,11 @@
1792 }
1793 if( i>0 ){
1794 sqlite3_str_append(pOut, (const char*)z, i);
1795 }
1796 switch( z[i] ){
1797 case '>': sqlite3_str_append(pOut, "&gt;", 4); break;
1798 case '&': sqlite3_str_append(pOut, "&amp;", 5); break;
1799 case '<': sqlite3_str_append(pOut, "&lt;", 4); break;
1800 case '"': sqlite3_str_append(pOut, "&quot;", 6); break;
1801 case '\'': sqlite3_str_append(pOut, "&#39;", 5); break;
1802 default: i--;
@@ -2286,11 +2286,11 @@
2286 if( bWrap && z[i]!=0 && !qrfSpace(z[i]) && qrfAlnum(c)==qrfAlnum(z[i]) ){
2287 /* Perhaps try to back up to a better place to break the line */
2288 for(k=i-1; k>=i/2; k--){
2289 if( qrfSpace(z[k]) ) break;
2290 }
2291 if( k<i/2 && i/2>0 ){
2292 for(k=i; k>=i/2; k--){
2293 if( qrfAlnum(z[k-1])!=qrfAlnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
2294 }
2295 }
2296 if( k>=i/2 ){
@@ -19811,11 +19811,11 @@
19811 " FROM temp.%s WHERE %s",
19812 p->zSU, zWhere);
19813 if( pStmt==0 ) return 1;
19814 rc = sqlite3_step(pStmt);
19815 if( rc==SQLITE_ROW ){
19816 analysisTitle(p, "%s", zTitle);
19817
19818 nentry = sqlite3_column_int64(pStmt, 0);
19819 payload = sqlite3_column_int64(pStmt, 1);
19820 ovfl_payload = sqlite3_column_int64(pStmt, 2);
19821 mx_payload = sqlite3_column_int64(pStmt, 3);
@@ -25210,11 +25210,15 @@
25210 ** of cases 1 and 2 */
25211 case 3: return "SQLITE_PS1";
25212 case 4: return "SQLITE_PS2";
25213
25214 /* Name of the application */
25215 #ifndef SQLITE_CLI_APPNAME
25216 case 'A': return "SQLite";
25217 #else
25218 case 'A': return SHELL_STRINGIFY(SQLITE_CLI_APPNAME);
25219 #endif
25220
25221 /* Full version number of the application, including patch level */
25222 case 'V': return sqlite3_libversion();
25223
25224 /* Version number without the patch level */
@@ -37839,11 +37843,11 @@
37843
37844 #if HAVE_EDITLINE
37845 /*
37846 ** https://sqlite.org/forum/forumpost/aad7a634916ff050:
37847 **
37848 ** Calling setlocale(LC_...,"") is required to get libedit to accept
37849 ** non-ASCII input.
37850 */
37851 #define DO_SET_LOCALE 1
37852 #include <locale.h>
37853 #else
@@ -38116,11 +38120,11 @@
38120 stdin_is_interactive = 0;
38121 nCmd++;
38122 azCmd = realloc(azCmd, sizeof(azCmd[0])*nCmd);
38123 shell_check_oom(azCmd);
38124 aiCmd = realloc(aiCmd, sizeof(aiCmd[0])*nCmd);
38125 shell_check_oom(aiCmd);
38126 azCmd[nCmd-1] = z;
38127 aiCmd[nCmd-1] = i;
38128 }
38129 continue;
38130 }
38131
+411 -53
--- 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
-** 9ac4a33a2932d353c4871fd8e09c10addf82 with changes in files:
21
+** 87c37dab7e53d1bd891f3fed624963b35ab1 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470470
#define SQLITE_VERSION "3.54.0"
471471
#define SQLITE_VERSION_NUMBER 3054000
472
-#define SQLITE_SOURCE_ID "2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353"
472
+#define SQLITE_SOURCE_ID "2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-05-21T15:14:35.420Z"
475
+#define SQLITE_SCM_DATETIME "2026-05-28T11:29:05.704Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -13183,15 +13183,27 @@
1318313183
** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
1318413184
** If this flag it set, then all foreign key constraints in the target
1318513185
** database behave as if they were declared with "ON UPDATE NO ACTION ON
1318613186
** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
1318713187
** or SET DEFAULT.
13188
+**
13189
+** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
13190
+** Sometimes, a changeset contains two or more update statements such that
13191
+** although after applying all updates the database will contain no
13192
+** constraint violations, no single update can be applied before the others.
13193
+** The simplest example of this is a pair of UPDATEs that have "swapped"
13194
+** two column values with a UNIQUE constraint.
13195
+** <p>
13196
+** Usually, sqlite3changeset_apply() and similar functions work hard to try
13197
+** to find a way to apply such a changeset. However, if this flag is set,
13198
+** then all such updates are considered CONSTRAINT conflicts.
1318813199
*/
1318913200
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
1319013201
#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
1319113202
#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
1319213203
#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
13204
+#define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
1319313205
1319413206
/*
1319513207
** CAPI3REF: Constants Passed To The Conflict Handler
1319613208
**
1319713209
** Values that may be passed as the second argument to a conflict-handler.
@@ -61121,11 +61133,11 @@
6112161133
*/
6112261134
rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
6112361135
if( rc!=SQLITE_OK ) goto delsuper_out;
6112461136
nSuperPtr = 1 + (i64)pVfs->mxPathname;
6112561137
assert( nSuperJournal>=0 && nSuperPtr>0 );
61126
- zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
61138
+ zFree = sqlite3Malloc(4 + nSuperJournal + 2 + nSuperPtr + 2);
6112761139
if( !zFree ){
6112861140
rc = SQLITE_NOMEM_BKPT;
6112961141
goto delsuper_out;
6113061142
}else{
6113161143
assert( nSuperJournal<=0x7fffffff );
@@ -61382,14 +61394,14 @@
6138261394
** present on disk, then the journal is not hot and does not need to be
6138361395
** played back.
6138461396
**
6138561397
** TODO: Technically the following is an error because it assumes that
6138661398
** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that
61387
- ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
61399
+ ** ((pPager->pageSize+8) >= pPager->pVfs->mxPathname+1). Using os_unix.c,
6138861400
** mxPathname is 512, which is the same as the minimum allowable value
61389
- ** for pageSize.
61390
- */
61401
+ ** for pageSize, and so this assumption holds. But it might not for some
61402
+ ** custom VFS. */
6139161403
zSuper = pPager->pTmpSpace;
6139261404
rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
6139361405
if( rc==SQLITE_OK && zSuper[0] ){
6139461406
rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
6139561407
}
@@ -77285,11 +77297,13 @@
7728577297
** in the overflow chain. The page number of the first overflow page is
7728677298
** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array
7728777299
** means "not yet known" (the cache is lazily populated).
7728877300
*/
7728977301
if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
77290
- int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
77302
+ i64 nOvfl = pCur->info.nPayload;
77303
+ testcase( nOvfl - pCur->info.nLocal + ovflSize - 1 > 0xffffffffU );
77304
+ nOvfl = (nOvfl - pCur->info.nLocal + ovflSize-1)/ovflSize;
7729177305
if( pCur->aOverflow==0
7729277306
|| nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
7729377307
){
7729477308
Pgno *aNew;
7729577309
if( sqlite3FaultSim(413) ){
@@ -213876,13 +213890,14 @@
213876213890
*/
213877213891
static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
213878213892
u8 x;
213879213893
u32 sz;
213880213894
u32 n;
213881
- assert( i<=pParse->nBlob );
213882
- x = pParse->aBlob[i]>>4;
213883
- if( x<=11 ){
213895
+ if( i>=pParse->nBlob ){
213896
+ *pSz = 0;
213897
+ return 0;
213898
+ }else if( (x = pParse->aBlob[i]>>4)<=11 ){
213884213899
sz = x;
213885213900
n = 1;
213886213901
}else if( x==12 ){
213887213902
if( i+1>=pParse->nBlob ){
213888213903
*pSz = 0;
@@ -217005,10 +217020,19 @@
217005217020
}else{
217006217021
jsonPrintf(sz+2,&p->path,".%.*s", sz, z);
217007217022
}
217008217023
}
217009217024
}
217025
+
217026
+/* Report a "malformed JSON" or OOM error against the cursor.
217027
+*/
217028
+static int jsonEachMalformedInput(sqlite3_vtab_cursor *cur){
217029
+ sqlite3_free(cur->pVtab->zErrMsg);
217030
+ cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON");
217031
+ jsonEachCursorReset((JsonEachCursor*)cur);
217032
+ return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
217033
+}
217010217034
217011217035
/* Advance the cursor to the next element for json_tree() */
217012217036
static int jsonEachNext(sqlite3_vtab_cursor *cur){
217013217037
JsonEachCursor *p = (JsonEachCursor*)cur;
217014217038
int rc = SQLITE_OK;
@@ -217017,10 +217041,11 @@
217017217041
u8 levelChange = 0;
217018217042
u32 n, sz = 0;
217019217043
u32 i = jsonSkipLabel(p);
217020217044
x = p->sParse.aBlob[i] & 0x0f;
217021217045
n = jsonbPayloadSize(&p->sParse, i, &sz);
217046
+ if( n==0 )return jsonEachMalformedInput(cur);
217022217047
if( x==JSONB_OBJECT || x==JSONB_ARRAY ){
217023217048
JsonParent *pParent;
217024217049
if( p->nParent>=p->nParentAlloc ){
217025217050
JsonParent *pNew;
217026217051
u64 nNew;
@@ -217062,10 +217087,11 @@
217062217087
}
217063217088
}else{
217064217089
u32 n, sz = 0;
217065217090
u32 i = jsonSkipLabel(p);
217066217091
n = jsonbPayloadSize(&p->sParse, i, &sz);
217092
+ if( n==0 )return jsonEachMalformedInput(cur);
217067217093
p->i = i + n + sz;
217068217094
}
217069217095
if( p->eType==JSONB_ARRAY && p->nParent ){
217070217096
p->aParent[p->nParent-1].iKey++;
217071217097
}
@@ -217298,11 +217324,11 @@
217298217324
}
217299217325
if( jsonConvertTextToBlob(&p->sParse, 0) ){
217300217326
if( p->sParse.oom ){
217301217327
return SQLITE_NOMEM;
217302217328
}
217303
- goto json_each_malformed_input;
217329
+ return jsonEachMalformedInput(cur);
217304217330
}
217305217331
}
217306217332
if( idxNum==3 ){
217307217333
zRoot = (const char*)sqlite3_value_text(argv[1]);
217308217334
if( zRoot==0 ) return SQLITE_OK;
@@ -217359,16 +217385,10 @@
217359217385
p->aParent[0].iEnd = p->iEnd;
217360217386
p->aParent[0].iHead = p->i;
217361217387
p->aParent[0].iValue = i;
217362217388
}
217363217389
return SQLITE_OK;
217364
-
217365
-json_each_malformed_input:
217366
- sqlite3_free(cur->pVtab->zErrMsg);
217367
- cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON");
217368
- jsonEachCursorReset(p);
217369
- return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
217370217390
}
217371217391
217372217392
/* The methods of the json_each virtual table */
217373217393
static sqlite3_module jsonEachModule = {
217374217394
0, /* iVersion */
@@ -224339,10 +224359,11 @@
224339224359
for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){
224340224360
sqlite3_str_appendf(pStr, " %s", aStrength[i].zName);
224341224361
}
224342224362
sqlite3_result_error(p, sqlite3_str_value(pStr), -1);
224343224363
sqlite3_free(sqlite3_str_finish(pStr));
224364
+ ucol_close(pUCollator);
224344224365
return;
224345224366
}
224346224367
}
224347224368
rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,
224348224369
icuCollationColl, icuCollationDel
@@ -234295,10 +234316,20 @@
234295234316
}
234296234317
sqlite3_free(sql.aBuf);
234297234318
234298234319
return rc;
234299234320
}
234321
+
234322
+/*
234323
+** Finalize statement pStmt. If (*pRc) is SQLITE_OK when this function is
234324
+** called, set it to the results of the sqlite3_finalize() call. Or, if
234325
+** it is already set to an error code, leave it as is.
234326
+*/
234327
+static void sessionFinalizeStmt(sqlite3_stmt *pStmt, int *pRc){
234328
+ int rc = sqlite3_finalize(pStmt);
234329
+ if( *pRc==SQLITE_OK ) *pRc = rc;
234330
+}
234300234331
234301234332
/*
234302234333
** Table pTab has one or more existing change-records with old.* records
234303234334
** with fewer than pTab->nCol columns. This function updates all such
234304234335
** change-records with the default values for the missing columns.
@@ -234318,13 +234349,12 @@
234318234349
}
234319234350
}
234320234351
}
234321234352
}
234322234353
234354
+ sessionFinalizeStmt(pStmt, &rc);
234323234355
pSession->rc = rc;
234324
- rc = sqlite3_finalize(pStmt);
234325
- if( pSession->rc==SQLITE_OK ) pSession->rc = rc;
234326234356
return pSession->rc;
234327234357
}
234328234358
234329234359
/*
234330234360
** Versions of the four methods in object SessionHook for use with the
@@ -235646,15 +235676,15 @@
235646235676
sessionAppendStr(&pkvar,
235647235677
"?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
235648235678
);
235649235679
sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
235650235680
}else{
235651
- #if 0
235681
+#if 0
235652235682
if( bRowid ){
235653235683
sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
235654235684
}
235655
- #endif
235685
+#endif
235656235686
for(i=0; i<nCol; i++){
235657235687
if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
235658235688
sessionAppendIdent(&cols, azCol[i], &rc);
235659235689
if( abPK[i] ){
235660235690
sessionAppendStr(&pkfield, zSep, &rc);
@@ -236908,11 +236938,17 @@
236908236938
while( 1 ){
236909236939
u8 eType;
236910236940
236911236941
/* Test for EOF. */
236912236942
if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;
236913
- if( pInput->iNext>=pInput->nData ) break;
236943
+ if( pInput->iNext+1>=pInput->nData ){
236944
+ if( pInput->iNext!=pInput->nData ){
236945
+ rc = SQLITE_CORRUPT_BKPT;
236946
+ goto finished_invert;
236947
+ }
236948
+ break;
236949
+ }
236914236950
eType = pInput->aData[pInput->iNext];
236915236951
236916236952
switch( eType ){
236917236953
case 'T': {
236918236954
/* A 'table' record consists of:
@@ -237104,10 +237140,11 @@
237104237140
SessionBuffer constraints; /* Deferred constraints are stored here */
237105237141
SessionBuffer rebase; /* Rebase information (if any) here */
237106237142
u8 bRebaseStarted; /* If table header is already in rebase */
237107237143
u8 bRebase; /* True to collect rebase information */
237108237144
u8 bIgnoreNoop; /* True to ignore no-op conflicts */
237145
+ u8 bNoUpdateLoop; /* No update-loop processing */
237109237146
int bRowid;
237110237147
char *zErr; /* Error message, if any */
237111237148
};
237112237149
237113237150
/* Number of prepared UPDATE statements to cache. */
@@ -237677,11 +237714,11 @@
237677237714
/* Instead of invoking the conflict handler, append the change blob
237678237715
** to the SessionApplyCtx.constraints buffer. */
237679237716
u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
237680237717
int nBlob = pIter->in.iNext - pIter->in.iCurrent;
237681237718
sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
237682
- return SQLITE_OK;
237719
+ return rc;
237683237720
}else if( p->bIgnoreNoop==0 || op!=SQLITE_DELETE
237684237721
|| eType==SQLITE_CHANGESET_CONFLICT
237685237722
){
237686237723
/* No other row with the new.* primary key. */
237687237724
res = xConflict(pCtx, eType+1, pIter);
@@ -237925,11 +237962,268 @@
237925237962
237926237963
return rc;
237927237964
}
237928237965
237929237966
/*
237930
-** Retry the changes accumulated in the pApply->constraints buffer.
237967
+** Create an iterator to iterate through the retry buffer pRetry.
237968
+*/
237969
+static int sessionRetryIterInit(
237970
+ SessionBuffer *pRetry, /* Buffer to iterate through */
237971
+ int bPatchset, /* True for patchset, false for changeset */
237972
+ const char *zTab, /* Table name */
237973
+ SessionApplyCtx *pApply, /* Session apply context */
237974
+ sqlite3_changeset_iter **ppIter /* OUT: New iterator */
237975
+){
237976
+ sqlite3_changeset_iter *pRet = 0;
237977
+ int rc = SQLITE_OK;
237978
+
237979
+ rc = sessionChangesetStart(
237980
+ &pRet, 0, 0, pRetry->nBuf, pRetry->aBuf, pApply->bInvertConstraints, 1
237981
+ );
237982
+ if( rc==SQLITE_OK ){
237983
+ size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
237984
+ pRet->bPatchset = bPatchset;
237985
+ pRet->zTab = (char*)zTab;
237986
+ pRet->nCol = pApply->nCol;
237987
+ pRet->abPK = pApply->abPK;
237988
+ sessionBufferGrow(&pRet->tblhdr, nByte, &rc);
237989
+ pRet->apValue = (sqlite3_value**)pRet->tblhdr.aBuf;
237990
+ if( rc==SQLITE_OK ){
237991
+ memset(pRet->apValue, 0, nByte);
237992
+ }else{
237993
+ sqlite3changeset_finalize(pRet);
237994
+ pRet = 0;
237995
+ }
237996
+ }
237997
+
237998
+ *ppIter = pRet;
237999
+ return rc;
238000
+}
238001
+
238002
+/*
238003
+** Attempt to apply all the changes in retry buffer pRetry to the database.
238004
+** Except, if parameter iSkip is greater than or equal to 0, skip change
238005
+** iSkip.
238006
+*/
238007
+static int sessionApplyRetryBuffer(
238008
+ SessionBuffer *pRetry, /* Buffer to apply changes from */
238009
+ int iSkip, /* If >=0, index of change to omit */
238010
+ sqlite3 *db, /* Database handle */
238011
+ int bPatchset, /* True for patchset, false for changeset */
238012
+ const char *zTab, /* Name of table to write to */
238013
+ SessionApplyCtx *pApply, /* Apply context */
238014
+ int(*xConflict)(void*, int, sqlite3_changeset_iter*),
238015
+ void *pCtx /* First argument passed to xConflict */
238016
+){
238017
+ int rc = SQLITE_OK;
238018
+ int rc2 = SQLITE_OK;
238019
+ int ii = 0;
238020
+ sqlite3_changeset_iter *pIter = 0;
238021
+
238022
+ assert( pApply->constraints.nBuf==0 );
238023
+
238024
+ rc = sessionRetryIterInit(pRetry, bPatchset, zTab, pApply, &pIter);
238025
+
238026
+ for(ii=0; rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter); ii++){
238027
+ if( ii!=iSkip ){
238028
+ rc = sessionApplyOneWithRetry(db, pIter, pApply, xConflict, pCtx);
238029
+ }
238030
+ }
238031
+
238032
+ rc2 = sqlite3changeset_finalize(pIter);
238033
+ if( rc==SQLITE_OK ) rc = rc2;
238034
+ assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
238035
+
238036
+ return rc;
238037
+}
238038
+
238039
+/*
238040
+** Check if table zTab in the "main" database of db is a WITHOUT ROWID
238041
+** table.
238042
+**
238043
+** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to
238044
+** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an
238045
+** error does occur, return an SQLite error code. The final value of (*pbWR)
238046
+** is undefined in this case.
238047
+*/
238048
+static int sessionTableIsWithoutRowid(sqlite3 *db, const char *zTab, int *pbWR){
238049
+ sqlite3_stmt *pList = 0;
238050
+ char *zSql = 0;
238051
+ int rc = SQLITE_OK;
238052
+
238053
+ zSql = sqlite3_mprintf("PRAGMA table_list = %Q", zTab);
238054
+ if( zSql==0 ){
238055
+ rc = SQLITE_NOMEM;
238056
+ }else{
238057
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pList, 0);
238058
+ sqlite3_free(zSql);
238059
+ }
238060
+
238061
+ if( rc==SQLITE_OK ){
238062
+ sqlite3_step(pList);
238063
+ *pbWR = sqlite3_column_int(pList, 4);
238064
+ rc = sqlite3_finalize(pList);
238065
+ }
238066
+
238067
+ return rc;
238068
+}
238069
+
238070
+/*
238071
+** Iterator pUp points to an UPDATE change. This function deletes the
238072
+** affected row from the database and creates an INSERT statement that
238073
+** may be used to reinsert the row as it is after the UPDATE change
238074
+** has been applied.
238075
+**
238076
+** If successful, SQLITE_OK is returned and output variable (*ppInsert)
238077
+** is left pointing to a prepared INSERT statement. It is the responsibility
238078
+** of the caller to eventually free this statement using sqlite3_finalize().
238079
+** Or, if an error occurs, an SQLite error code is returned and (*ppInsert)
238080
+** set to NULL. pApply->zErr may be set to an error message in this case.
238081
+*/
238082
+static int sessionUpdateToDeleteInsert(
238083
+ sqlite3 *db, /* Database to write to */
238084
+ const char *zTab, /* Table name */
238085
+ SessionApplyCtx *pApply, /* Apply context */
238086
+ sqlite3_changeset_iter *pUp, /* Iterator pointing to UPDATE change */
238087
+ sqlite3_stmt **ppInsert /* OUT: INSERT statement */
238088
+){
238089
+ sqlite3_stmt *pRet = 0; /* The INSERT statement */
238090
+ sqlite3_stmt *pSelect = 0; /* SELECT to read current values of row */
238091
+ int rc = SQLITE_OK;
238092
+ int bWR = 0;
238093
+
238094
+ rc = sessionTableIsWithoutRowid(db, zTab, &bWR);
238095
+ if( rc==SQLITE_OK ){
238096
+ char *zSelect = 0;
238097
+ char *zInsert = 0;
238098
+ SessionBuffer cols = {0, 0, 0};
238099
+ SessionBuffer insbind = {0, 0, 0};
238100
+ SessionBuffer pkcols = {0, 0, 0};
238101
+ SessionBuffer selbind = {0, 0, 0};
238102
+
238103
+ const char *zComma = "";
238104
+ const char *zComma2 = "";
238105
+ int ii;
238106
+ for(ii=0; ii<pApply->nCol; ii++){
238107
+ sessionAppendStr(&cols, zComma, &rc);
238108
+ sessionAppendIdent(&cols, pApply->azCol[ii], &rc);
238109
+ sessionAppendStr(&insbind, zComma, &rc);
238110
+ sessionAppendStr(&insbind, "?", &rc);
238111
+ zComma = ", ";
238112
+
238113
+ if( pApply->abPK[ii] ){
238114
+ sessionAppendStr(&pkcols, zComma2, &rc);
238115
+ sessionAppendIdent(&pkcols, pApply->azCol[ii], &rc);
238116
+ sessionAppendStr(&selbind, zComma2, &rc);
238117
+ sessionAppendPrintf(&selbind, &rc, "?%d", ii+1);
238118
+ zComma2 = ", ";
238119
+ }
238120
+ }
238121
+ if( bWR==0 ){
238122
+ sessionAppendStr(&cols, zComma, &rc);
238123
+ sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
238124
+ sessionAppendStr(&insbind, zComma, &rc);
238125
+ sessionAppendStr(&insbind, "?", &rc);
238126
+ }
238127
+
238128
+ if( rc==SQLITE_OK ){
238129
+ zSelect = sqlite3_mprintf("SELECT %s FROM %Q WHERE (%s) IS (%s)",
238130
+ cols.aBuf, zTab, pkcols.aBuf, selbind.aBuf
238131
+ );
238132
+ if( zSelect==0 ) rc = SQLITE_NOMEM;
238133
+ }
238134
+ if( rc==SQLITE_OK ){
238135
+ zInsert = sqlite3_mprintf("INSERT INTO %Q(%s) VALUES(%s)",
238136
+ zTab, cols.aBuf, insbind.aBuf
238137
+ );
238138
+ if( zInsert==0 ) rc = SQLITE_NOMEM;
238139
+ }
238140
+
238141
+ if( rc==SQLITE_OK ){
238142
+ rc = sessionPrepare(db, &pSelect, &pApply->zErr, zSelect);
238143
+ }
238144
+ if( rc==SQLITE_OK ){
238145
+ rc = sessionPrepare(db, &pRet, &pApply->zErr, zInsert);
238146
+ }
238147
+
238148
+ sqlite3_free(zSelect);
238149
+ sqlite3_free(zInsert);
238150
+ sqlite3_free(cols.aBuf);
238151
+ sqlite3_free(insbind.aBuf);
238152
+ sqlite3_free(pkcols.aBuf);
238153
+ sqlite3_free(selbind.aBuf);
238154
+ }
238155
+
238156
+ if( rc==SQLITE_OK ){
238157
+ rc = sessionBindRow(
238158
+ pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pSelect
238159
+ );
238160
+ }
238161
+
238162
+ if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){
238163
+ int iCol;
238164
+ for(iCol=0; iCol<pApply->nCol; iCol++){
238165
+ sqlite3_value *pVal = pUp->apValue[iCol+pApply->nCol];
238166
+ if( pVal==0 ){
238167
+ pVal = sqlite3_column_value(pSelect, iCol);
238168
+ }
238169
+ rc = sqlite3_bind_value(pRet, iCol+1, pVal);
238170
+ }
238171
+ if( bWR==0 ){
238172
+ sqlite3_bind_int64(pRet, iCol+1, sqlite3_column_int64(pSelect, iCol));
238173
+ }
238174
+ }
238175
+ sessionFinalizeStmt(pSelect, &rc);
238176
+
238177
+ /* Delete the row from the database. */
238178
+ if( rc==SQLITE_OK ){
238179
+ rc = sessionBindRow(
238180
+ pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pApply->pDelete
238181
+ );
238182
+ sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);
238183
+ }
238184
+ if( rc==SQLITE_OK ){
238185
+ sqlite3_step(pApply->pDelete);
238186
+ rc = sqlite3_reset(pApply->pDelete);
238187
+ }
238188
+
238189
+ if( rc!=SQLITE_OK ){
238190
+ sqlite3_finalize(pRet);
238191
+ pRet = 0;
238192
+ }
238193
+
238194
+ *ppInsert = pRet;
238195
+ return rc;
238196
+}
238197
+
238198
+/*
238199
+** Retry the changes accumulated in the pApply->constraints buffer. The
238200
+** pApply->constraints buffer contains all changes to table zTab that
238201
+** could not be applied due to SQLITE_CONSTRAINT errors. This function
238202
+** attempts to apply them as follows:
238203
+**
238204
+** 1) It runs through the buffer and attempts to retry each change,
238205
+** removing any that are successfully applied from the buffer. This
238206
+** is repeated until no further progress can be made.
238207
+**
238208
+** 2) For each UPDATE change in the buffer, try the following in a
238209
+** savepoint transaction:
238210
+**
238211
+** a) DELETE the affected row,
238212
+** b) Attempt step (1) with remaining changes,
238213
+** c) Attempt to INSERT a row equivalent to the one that would be
238214
+** created by applying this UPDATE change.
238215
+**
238216
+** If the INSERT in (c) succeeds, the savepoint is committed and all
238217
+** successfully applied changes are removed from the buffer. Step (2)
238218
+** is then repeated.
238219
+**
238220
+** 3) Once step (2) has been attempted for each UPDATE in the change,
238221
+** a final attempt is made to apply each remaining change. This time,
238222
+** if an SQLITE_CONSTRAINT error is encountered, the conflict handler
238223
+** is invoked and the user has to decide whether to omit the change
238224
+** or rollback the entire _apply() operation.
237931238225
*/
237932238226
static int sessionRetryConstraints(
237933238227
sqlite3 *db,
237934238228
int bPatchset,
237935238229
const char *zTab,
@@ -237936,45 +238230,105 @@
237936238230
SessionApplyCtx *pApply,
237937238231
int(*xConflict)(void*, int, sqlite3_changeset_iter*),
237938238232
void *pCtx /* First argument passed to xConflict */
237939238233
){
237940238234
int rc = SQLITE_OK;
238235
+ int iUpdate = 0;
237941238236
238237
+ /* Step (1) */
237942238238
while( pApply->constraints.nBuf ){
237943
- sqlite3_changeset_iter *pIter2 = 0;
237944238239
SessionBuffer cons = pApply->constraints;
237945238240
memset(&pApply->constraints, 0, sizeof(SessionBuffer));
237946238241
237947
- rc = sessionChangesetStart(
237948
- &pIter2, 0, 0, cons.nBuf, cons.aBuf, pApply->bInvertConstraints, 1
238242
+ rc = sessionApplyRetryBuffer(
238243
+ &cons, -1, db, bPatchset, zTab, pApply, xConflict, pCtx
237949238244
);
237950
- if( rc==SQLITE_OK ){
237951
- size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
237952
- int rc2;
237953
- pIter2->bPatchset = bPatchset;
237954
- pIter2->zTab = (char*)zTab;
237955
- pIter2->nCol = pApply->nCol;
237956
- pIter2->abPK = pApply->abPK;
237957
- sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);
237958
- pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;
237959
- if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);
237960
-
237961
- while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){
237962
- rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);
237963
- }
237964
-
237965
- rc2 = sqlite3changeset_finalize(pIter2);
237966
- if( rc==SQLITE_OK ) rc = rc2;
237967
- }
237968
- assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
237969238245
237970238246
sqlite3_free(cons.aBuf);
237971238247
if( rc!=SQLITE_OK ) break;
237972
- if( pApply->constraints.nBuf>=cons.nBuf ){
237973
- /* No progress was made on the last round. */
237974
- pApply->bDeferConstraints = 0;
238248
+
238249
+ /* If no progress has been made this round, break out of the loop. */
238250
+ if( pApply->constraints.nBuf>=cons.nBuf ) break;
238251
+ }
238252
+
238253
+ /* Step (2) */
238254
+ while( rc==SQLITE_OK && pApply->constraints.nBuf && !pApply->bNoUpdateLoop ){
238255
+ SessionBuffer cons = {0, 0, 0};
238256
+ sqlite3_changeset_iter *pUp = 0;
238257
+ sqlite3_stmt *pInsert = 0;
238258
+ int iSkip = 0;
238259
+
238260
+ rc = sessionRetryIterInit(
238261
+ &pApply->constraints, bPatchset, zTab, pApply, &pUp
238262
+ );
238263
+ if( rc==SQLITE_OK ){
238264
+ int iThis = -1;
238265
+ while( SQLITE_ROW==sqlite3changeset_next(pUp) ){
238266
+ if( pUp->op==SQLITE_UPDATE ) iThis++;
238267
+ if( iThis==iUpdate ) break;
238268
+ iSkip++;
238269
+ }
238270
+ if( iThis==iUpdate ){
238271
+ rc = sqlite3_exec(db, "SAVEPOINT update_op", 0, 0, 0);
238272
+ if( rc==SQLITE_OK ){
238273
+ rc = sessionUpdateToDeleteInsert(db, zTab, pApply, pUp, &pInsert);
238274
+ }
238275
+ }
238276
+ sqlite3changeset_finalize(pUp);
238277
+ if( iThis!=iUpdate ) break;
237975238278
}
238279
+
238280
+ if( rc==SQLITE_OK ){
238281
+ cons = pApply->constraints;
238282
+
238283
+ while( rc==SQLITE_OK && pApply->constraints.nBuf>0 ){
238284
+ SessionBuffer app = pApply->constraints;
238285
+ memset(&pApply->constraints, 0, sizeof(SessionBuffer));
238286
+ rc = sessionApplyRetryBuffer(
238287
+ &app, iSkip, db, bPatchset, zTab, pApply, xConflict, pCtx
238288
+ );
238289
+ if( app.aBuf!=cons.aBuf ){
238290
+ sqlite3_free(app.aBuf);
238291
+ }
238292
+ if( pApply->constraints.nBuf>=app.nBuf ){
238293
+ break;
238294
+ }
238295
+ iSkip = -1;
238296
+ }
238297
+ }
238298
+
238299
+ iUpdate++;
238300
+ if( rc==SQLITE_OK ){
238301
+ sqlite3_step(pInsert);
238302
+ rc = sqlite3_finalize(pInsert);
238303
+ if( rc==SQLITE_CONSTRAINT ){
238304
+ rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0);
238305
+ sqlite3_free(pApply->constraints.aBuf);
238306
+ pApply->constraints = cons;
238307
+ memset(&cons, 0, sizeof(cons));
238308
+ }else if( rc==SQLITE_OK ){
238309
+ iUpdate = 0;
238310
+ }
238311
+ if( rc==SQLITE_OK ){
238312
+ rc = sqlite3_exec(db, "RELEASE update_op", 0, 0, 0);
238313
+ }
238314
+ }else{
238315
+ sqlite3_finalize(pInsert);
238316
+ }
238317
+
238318
+ sqlite3_free(cons.aBuf);
238319
+ }
238320
+
238321
+ /* Step (3) */
238322
+ if( rc==SQLITE_OK && pApply->constraints.nBuf ){
238323
+ SessionBuffer cons = pApply->constraints;
238324
+ memset(&pApply->constraints, 0, sizeof(SessionBuffer));
238325
+ pApply->bDeferConstraints = 0;
238326
+ rc = sessionApplyRetryBuffer(
238327
+ &cons, -1, db, bPatchset, zTab, pApply, xConflict, pCtx
238328
+ );
238329
+ sqlite3_free(cons.aBuf);
237976238330
}
237977238331
237978238332
return rc;
237979238333
}
237980238334
@@ -238024,10 +238378,11 @@
238024238378
pIter->in.bNoDiscard = 1;
238025238379
memset(&sApply, 0, sizeof(sApply));
238026238380
sApply.bRebase = (ppRebase && pnRebase);
238027238381
sApply.bInvertConstraints = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
238028238382
sApply.bIgnoreNoop = !!(flags & SQLITE_CHANGESETAPPLY_IGNORENOOP);
238383
+ sApply.bNoUpdateLoop = !!(flags & SQLITE_CHANGESETAPPLY_NOUPDATELOOP);
238029238384
if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
238030238385
rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
238031238386
}
238032238387
if( rc==SQLITE_OK ){
238033238388
rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
@@ -239835,11 +240190,11 @@
239835240190
int bNew,
239836240191
int iCol,
239837240192
const void *pVal,
239838240193
int nVal
239839240194
){
239840
- sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + nVal;
240195
+ sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + (i64)nVal;
239841240196
int rc = SQLITE_OK;
239842240197
SessionBuffer *pBuf = 0;
239843240198
239844240199
if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
239845240200
return rc;
@@ -253306,12 +253661,15 @@
253306253661
*/
253307253662
static void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){
253308253663
253309253664
assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
253310253665
assert( pIter->pColset );
253666
+ assert( pIter->poslist.nSpace>=pIter->pIndex->pConfig->nCol );
253311253667
253312
- if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){
253668
+ if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf
253669
+ || pSeg->nPos>pIter->pIndex->pConfig->nCol
253670
+ ){
253313253671
fts5IterSetOutputs_Col(pIter, pSeg);
253314253672
}else{
253315253673
u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];
253316253674
u8 *pEnd = (u8*)&a[pSeg->nPos];
253317253675
int iPrev = 0;
@@ -262677,11 +263035,11 @@
262677263035
int nArg, /* Number of args */
262678263036
sqlite3_value **apUnused /* Function arguments */
262679263037
){
262680263038
assert( nArg==0 );
262681263039
UNUSED_PARAM2(nArg, apUnused);
262682
- sqlite3_result_text(pCtx, "fts5: 2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353", -1, SQLITE_TRANSIENT);
263040
+ sqlite3_result_text(pCtx, "fts5: 2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10", -1, SQLITE_TRANSIENT);
262683263041
}
262684263042
262685263043
/*
262686263044
** Implementation of fts5_locale(LOCALE, TEXT) function.
262687263045
**
262688263046
--- 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 ** 9ac4a33a2932d353c4871fd8e09c10addf82 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.54.0"
471 #define SQLITE_VERSION_NUMBER 3054000
472 #define SQLITE_SOURCE_ID "2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-05-21T15:14:35.420Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -13183,15 +13183,27 @@
13183 ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
13184 ** If this flag it set, then all foreign key constraints in the target
13185 ** database behave as if they were declared with "ON UPDATE NO ACTION ON
13186 ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
13187 ** or SET DEFAULT.
 
 
 
 
 
 
 
 
 
 
 
13188 */
13189 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
13190 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
13191 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
13192 #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
 
13193
13194 /*
13195 ** CAPI3REF: Constants Passed To The Conflict Handler
13196 **
13197 ** Values that may be passed as the second argument to a conflict-handler.
@@ -61121,11 +61133,11 @@
61121 */
61122 rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
61123 if( rc!=SQLITE_OK ) goto delsuper_out;
61124 nSuperPtr = 1 + (i64)pVfs->mxPathname;
61125 assert( nSuperJournal>=0 && nSuperPtr>0 );
61126 zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
61127 if( !zFree ){
61128 rc = SQLITE_NOMEM_BKPT;
61129 goto delsuper_out;
61130 }else{
61131 assert( nSuperJournal<=0x7fffffff );
@@ -61382,14 +61394,14 @@
61382 ** present on disk, then the journal is not hot and does not need to be
61383 ** played back.
61384 **
61385 ** TODO: Technically the following is an error because it assumes that
61386 ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that
61387 ** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
61388 ** mxPathname is 512, which is the same as the minimum allowable value
61389 ** for pageSize.
61390 */
61391 zSuper = pPager->pTmpSpace;
61392 rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
61393 if( rc==SQLITE_OK && zSuper[0] ){
61394 rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
61395 }
@@ -77285,11 +77297,13 @@
77285 ** in the overflow chain. The page number of the first overflow page is
77286 ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array
77287 ** means "not yet known" (the cache is lazily populated).
77288 */
77289 if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
77290 int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
 
 
77291 if( pCur->aOverflow==0
77292 || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
77293 ){
77294 Pgno *aNew;
77295 if( sqlite3FaultSim(413) ){
@@ -213876,13 +213890,14 @@
213876 */
213877 static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
213878 u8 x;
213879 u32 sz;
213880 u32 n;
213881 assert( i<=pParse->nBlob );
213882 x = pParse->aBlob[i]>>4;
213883 if( x<=11 ){
 
213884 sz = x;
213885 n = 1;
213886 }else if( x==12 ){
213887 if( i+1>=pParse->nBlob ){
213888 *pSz = 0;
@@ -217005,10 +217020,19 @@
217005 }else{
217006 jsonPrintf(sz+2,&p->path,".%.*s", sz, z);
217007 }
217008 }
217009 }
 
 
 
 
 
 
 
 
 
217010
217011 /* Advance the cursor to the next element for json_tree() */
217012 static int jsonEachNext(sqlite3_vtab_cursor *cur){
217013 JsonEachCursor *p = (JsonEachCursor*)cur;
217014 int rc = SQLITE_OK;
@@ -217017,10 +217041,11 @@
217017 u8 levelChange = 0;
217018 u32 n, sz = 0;
217019 u32 i = jsonSkipLabel(p);
217020 x = p->sParse.aBlob[i] & 0x0f;
217021 n = jsonbPayloadSize(&p->sParse, i, &sz);
 
217022 if( x==JSONB_OBJECT || x==JSONB_ARRAY ){
217023 JsonParent *pParent;
217024 if( p->nParent>=p->nParentAlloc ){
217025 JsonParent *pNew;
217026 u64 nNew;
@@ -217062,10 +217087,11 @@
217062 }
217063 }else{
217064 u32 n, sz = 0;
217065 u32 i = jsonSkipLabel(p);
217066 n = jsonbPayloadSize(&p->sParse, i, &sz);
 
217067 p->i = i + n + sz;
217068 }
217069 if( p->eType==JSONB_ARRAY && p->nParent ){
217070 p->aParent[p->nParent-1].iKey++;
217071 }
@@ -217298,11 +217324,11 @@
217298 }
217299 if( jsonConvertTextToBlob(&p->sParse, 0) ){
217300 if( p->sParse.oom ){
217301 return SQLITE_NOMEM;
217302 }
217303 goto json_each_malformed_input;
217304 }
217305 }
217306 if( idxNum==3 ){
217307 zRoot = (const char*)sqlite3_value_text(argv[1]);
217308 if( zRoot==0 ) return SQLITE_OK;
@@ -217359,16 +217385,10 @@
217359 p->aParent[0].iEnd = p->iEnd;
217360 p->aParent[0].iHead = p->i;
217361 p->aParent[0].iValue = i;
217362 }
217363 return SQLITE_OK;
217364
217365 json_each_malformed_input:
217366 sqlite3_free(cur->pVtab->zErrMsg);
217367 cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON");
217368 jsonEachCursorReset(p);
217369 return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
217370 }
217371
217372 /* The methods of the json_each virtual table */
217373 static sqlite3_module jsonEachModule = {
217374 0, /* iVersion */
@@ -224339,10 +224359,11 @@
224339 for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){
224340 sqlite3_str_appendf(pStr, " %s", aStrength[i].zName);
224341 }
224342 sqlite3_result_error(p, sqlite3_str_value(pStr), -1);
224343 sqlite3_free(sqlite3_str_finish(pStr));
 
224344 return;
224345 }
224346 }
224347 rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,
224348 icuCollationColl, icuCollationDel
@@ -234295,10 +234316,20 @@
234295 }
234296 sqlite3_free(sql.aBuf);
234297
234298 return rc;
234299 }
 
 
 
 
 
 
 
 
 
 
234300
234301 /*
234302 ** Table pTab has one or more existing change-records with old.* records
234303 ** with fewer than pTab->nCol columns. This function updates all such
234304 ** change-records with the default values for the missing columns.
@@ -234318,13 +234349,12 @@
234318 }
234319 }
234320 }
234321 }
234322
 
234323 pSession->rc = rc;
234324 rc = sqlite3_finalize(pStmt);
234325 if( pSession->rc==SQLITE_OK ) pSession->rc = rc;
234326 return pSession->rc;
234327 }
234328
234329 /*
234330 ** Versions of the four methods in object SessionHook for use with the
@@ -235646,15 +235676,15 @@
235646 sessionAppendStr(&pkvar,
235647 "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
235648 );
235649 sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
235650 }else{
235651 #if 0
235652 if( bRowid ){
235653 sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
235654 }
235655 #endif
235656 for(i=0; i<nCol; i++){
235657 if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
235658 sessionAppendIdent(&cols, azCol[i], &rc);
235659 if( abPK[i] ){
235660 sessionAppendStr(&pkfield, zSep, &rc);
@@ -236908,11 +236938,17 @@
236908 while( 1 ){
236909 u8 eType;
236910
236911 /* Test for EOF. */
236912 if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;
236913 if( pInput->iNext>=pInput->nData ) break;
 
 
 
 
 
 
236914 eType = pInput->aData[pInput->iNext];
236915
236916 switch( eType ){
236917 case 'T': {
236918 /* A 'table' record consists of:
@@ -237104,10 +237140,11 @@
237104 SessionBuffer constraints; /* Deferred constraints are stored here */
237105 SessionBuffer rebase; /* Rebase information (if any) here */
237106 u8 bRebaseStarted; /* If table header is already in rebase */
237107 u8 bRebase; /* True to collect rebase information */
237108 u8 bIgnoreNoop; /* True to ignore no-op conflicts */
 
237109 int bRowid;
237110 char *zErr; /* Error message, if any */
237111 };
237112
237113 /* Number of prepared UPDATE statements to cache. */
@@ -237677,11 +237714,11 @@
237677 /* Instead of invoking the conflict handler, append the change blob
237678 ** to the SessionApplyCtx.constraints buffer. */
237679 u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
237680 int nBlob = pIter->in.iNext - pIter->in.iCurrent;
237681 sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
237682 return SQLITE_OK;
237683 }else if( p->bIgnoreNoop==0 || op!=SQLITE_DELETE
237684 || eType==SQLITE_CHANGESET_CONFLICT
237685 ){
237686 /* No other row with the new.* primary key. */
237687 res = xConflict(pCtx, eType+1, pIter);
@@ -237925,11 +237962,268 @@
237925
237926 return rc;
237927 }
237928
237929 /*
237930 ** Retry the changes accumulated in the pApply->constraints buffer.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237931 */
237932 static int sessionRetryConstraints(
237933 sqlite3 *db,
237934 int bPatchset,
237935 const char *zTab,
@@ -237936,45 +238230,105 @@
237936 SessionApplyCtx *pApply,
237937 int(*xConflict)(void*, int, sqlite3_changeset_iter*),
237938 void *pCtx /* First argument passed to xConflict */
237939 ){
237940 int rc = SQLITE_OK;
 
237941
 
237942 while( pApply->constraints.nBuf ){
237943 sqlite3_changeset_iter *pIter2 = 0;
237944 SessionBuffer cons = pApply->constraints;
237945 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
237946
237947 rc = sessionChangesetStart(
237948 &pIter2, 0, 0, cons.nBuf, cons.aBuf, pApply->bInvertConstraints, 1
237949 );
237950 if( rc==SQLITE_OK ){
237951 size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
237952 int rc2;
237953 pIter2->bPatchset = bPatchset;
237954 pIter2->zTab = (char*)zTab;
237955 pIter2->nCol = pApply->nCol;
237956 pIter2->abPK = pApply->abPK;
237957 sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);
237958 pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;
237959 if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);
237960
237961 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){
237962 rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);
237963 }
237964
237965 rc2 = sqlite3changeset_finalize(pIter2);
237966 if( rc==SQLITE_OK ) rc = rc2;
237967 }
237968 assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
237969
237970 sqlite3_free(cons.aBuf);
237971 if( rc!=SQLITE_OK ) break;
237972 if( pApply->constraints.nBuf>=cons.nBuf ){
237973 /* No progress was made on the last round. */
237974 pApply->bDeferConstraints = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237975 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237976 }
237977
237978 return rc;
237979 }
237980
@@ -238024,10 +238378,11 @@
238024 pIter->in.bNoDiscard = 1;
238025 memset(&sApply, 0, sizeof(sApply));
238026 sApply.bRebase = (ppRebase && pnRebase);
238027 sApply.bInvertConstraints = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
238028 sApply.bIgnoreNoop = !!(flags & SQLITE_CHANGESETAPPLY_IGNORENOOP);
 
238029 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
238030 rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
238031 }
238032 if( rc==SQLITE_OK ){
238033 rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
@@ -239835,11 +240190,11 @@
239835 int bNew,
239836 int iCol,
239837 const void *pVal,
239838 int nVal
239839 ){
239840 sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + nVal;
239841 int rc = SQLITE_OK;
239842 SessionBuffer *pBuf = 0;
239843
239844 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
239845 return rc;
@@ -253306,12 +253661,15 @@
253306 */
253307 static void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){
253308
253309 assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
253310 assert( pIter->pColset );
 
253311
253312 if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){
 
 
253313 fts5IterSetOutputs_Col(pIter, pSeg);
253314 }else{
253315 u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];
253316 u8 *pEnd = (u8*)&a[pSeg->nPos];
253317 int iPrev = 0;
@@ -262677,11 +263035,11 @@
262677 int nArg, /* Number of args */
262678 sqlite3_value **apUnused /* Function arguments */
262679 ){
262680 assert( nArg==0 );
262681 UNUSED_PARAM2(nArg, apUnused);
262682 sqlite3_result_text(pCtx, "fts5: 2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353", -1, SQLITE_TRANSIENT);
262683 }
262684
262685 /*
262686 ** Implementation of fts5_locale(LOCALE, TEXT) function.
262687 **
262688
--- 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 ** 87c37dab7e53d1bd891f3fed624963b35ab1 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -467,14 +467,14 @@
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.54.0"
471 #define SQLITE_VERSION_NUMBER 3054000
472 #define SQLITE_SOURCE_ID "2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-05-28T11:29:05.704Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -13183,15 +13183,27 @@
13183 ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
13184 ** If this flag it set, then all foreign key constraints in the target
13185 ** database behave as if they were declared with "ON UPDATE NO ACTION ON
13186 ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
13187 ** or SET DEFAULT.
13188 **
13189 ** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
13190 ** Sometimes, a changeset contains two or more update statements such that
13191 ** although after applying all updates the database will contain no
13192 ** constraint violations, no single update can be applied before the others.
13193 ** The simplest example of this is a pair of UPDATEs that have "swapped"
13194 ** two column values with a UNIQUE constraint.
13195 ** <p>
13196 ** Usually, sqlite3changeset_apply() and similar functions work hard to try
13197 ** to find a way to apply such a changeset. However, if this flag is set,
13198 ** then all such updates are considered CONSTRAINT conflicts.
13199 */
13200 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
13201 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
13202 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
13203 #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
13204 #define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
13205
13206 /*
13207 ** CAPI3REF: Constants Passed To The Conflict Handler
13208 **
13209 ** Values that may be passed as the second argument to a conflict-handler.
@@ -61121,11 +61133,11 @@
61133 */
61134 rc = sqlite3OsFileSize(pSuper, &nSuperJournal);
61135 if( rc!=SQLITE_OK ) goto delsuper_out;
61136 nSuperPtr = 1 + (i64)pVfs->mxPathname;
61137 assert( nSuperJournal>=0 && nSuperPtr>0 );
61138 zFree = sqlite3Malloc(4 + nSuperJournal + 2 + nSuperPtr + 2);
61139 if( !zFree ){
61140 rc = SQLITE_NOMEM_BKPT;
61141 goto delsuper_out;
61142 }else{
61143 assert( nSuperJournal<=0x7fffffff );
@@ -61382,14 +61394,14 @@
61394 ** present on disk, then the journal is not hot and does not need to be
61395 ** played back.
61396 **
61397 ** TODO: Technically the following is an error because it assumes that
61398 ** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that
61399 ** ((pPager->pageSize+8) >= pPager->pVfs->mxPathname+1). Using os_unix.c,
61400 ** mxPathname is 512, which is the same as the minimum allowable value
61401 ** for pageSize, and so this assumption holds. But it might not for some
61402 ** custom VFS. */
61403 zSuper = pPager->pTmpSpace;
61404 rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
61405 if( rc==SQLITE_OK && zSuper[0] ){
61406 rc = sqlite3OsAccess(pVfs, zSuper, SQLITE_ACCESS_EXISTS, &res);
61407 }
@@ -77285,11 +77297,13 @@
77297 ** in the overflow chain. The page number of the first overflow page is
77298 ** stored in aOverflow[0], etc. A value of 0 in the aOverflow[] array
77299 ** means "not yet known" (the cache is lazily populated).
77300 */
77301 if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
77302 i64 nOvfl = pCur->info.nPayload;
77303 testcase( nOvfl - pCur->info.nLocal + ovflSize - 1 > 0xffffffffU );
77304 nOvfl = (nOvfl - pCur->info.nLocal + ovflSize-1)/ovflSize;
77305 if( pCur->aOverflow==0
77306 || nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
77307 ){
77308 Pgno *aNew;
77309 if( sqlite3FaultSim(413) ){
@@ -213876,13 +213890,14 @@
213890 */
213891 static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
213892 u8 x;
213893 u32 sz;
213894 u32 n;
213895 if( i>=pParse->nBlob ){
213896 *pSz = 0;
213897 return 0;
213898 }else if( (x = pParse->aBlob[i]>>4)<=11 ){
213899 sz = x;
213900 n = 1;
213901 }else if( x==12 ){
213902 if( i+1>=pParse->nBlob ){
213903 *pSz = 0;
@@ -217005,10 +217020,19 @@
217020 }else{
217021 jsonPrintf(sz+2,&p->path,".%.*s", sz, z);
217022 }
217023 }
217024 }
217025
217026 /* Report a "malformed JSON" or OOM error against the cursor.
217027 */
217028 static int jsonEachMalformedInput(sqlite3_vtab_cursor *cur){
217029 sqlite3_free(cur->pVtab->zErrMsg);
217030 cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON");
217031 jsonEachCursorReset((JsonEachCursor*)cur);
217032 return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM;
217033 }
217034
217035 /* Advance the cursor to the next element for json_tree() */
217036 static int jsonEachNext(sqlite3_vtab_cursor *cur){
217037 JsonEachCursor *p = (JsonEachCursor*)cur;
217038 int rc = SQLITE_OK;
@@ -217017,10 +217041,11 @@
217041 u8 levelChange = 0;
217042 u32 n, sz = 0;
217043 u32 i = jsonSkipLabel(p);
217044 x = p->sParse.aBlob[i] & 0x0f;
217045 n = jsonbPayloadSize(&p->sParse, i, &sz);
217046 if( n==0 )return jsonEachMalformedInput(cur);
217047 if( x==JSONB_OBJECT || x==JSONB_ARRAY ){
217048 JsonParent *pParent;
217049 if( p->nParent>=p->nParentAlloc ){
217050 JsonParent *pNew;
217051 u64 nNew;
@@ -217062,10 +217087,11 @@
217087 }
217088 }else{
217089 u32 n, sz = 0;
217090 u32 i = jsonSkipLabel(p);
217091 n = jsonbPayloadSize(&p->sParse, i, &sz);
217092 if( n==0 )return jsonEachMalformedInput(cur);
217093 p->i = i + n + sz;
217094 }
217095 if( p->eType==JSONB_ARRAY && p->nParent ){
217096 p->aParent[p->nParent-1].iKey++;
217097 }
@@ -217298,11 +217324,11 @@
217324 }
217325 if( jsonConvertTextToBlob(&p->sParse, 0) ){
217326 if( p->sParse.oom ){
217327 return SQLITE_NOMEM;
217328 }
217329 return jsonEachMalformedInput(cur);
217330 }
217331 }
217332 if( idxNum==3 ){
217333 zRoot = (const char*)sqlite3_value_text(argv[1]);
217334 if( zRoot==0 ) return SQLITE_OK;
@@ -217359,16 +217385,10 @@
217385 p->aParent[0].iEnd = p->iEnd;
217386 p->aParent[0].iHead = p->i;
217387 p->aParent[0].iValue = i;
217388 }
217389 return SQLITE_OK;
 
 
 
 
 
 
217390 }
217391
217392 /* The methods of the json_each virtual table */
217393 static sqlite3_module jsonEachModule = {
217394 0, /* iVersion */
@@ -224339,10 +224359,11 @@
224359 for(i=0; i<sizeof(aStrength)/sizeof(aStrength[0]); i++){
224360 sqlite3_str_appendf(pStr, " %s", aStrength[i].zName);
224361 }
224362 sqlite3_result_error(p, sqlite3_str_value(pStr), -1);
224363 sqlite3_free(sqlite3_str_finish(pStr));
224364 ucol_close(pUCollator);
224365 return;
224366 }
224367 }
224368 rc = sqlite3_create_collation_v2(db, zName, SQLITE_UTF16, (void *)pUCollator,
224369 icuCollationColl, icuCollationDel
@@ -234295,10 +234316,20 @@
234316 }
234317 sqlite3_free(sql.aBuf);
234318
234319 return rc;
234320 }
234321
234322 /*
234323 ** Finalize statement pStmt. If (*pRc) is SQLITE_OK when this function is
234324 ** called, set it to the results of the sqlite3_finalize() call. Or, if
234325 ** it is already set to an error code, leave it as is.
234326 */
234327 static void sessionFinalizeStmt(sqlite3_stmt *pStmt, int *pRc){
234328 int rc = sqlite3_finalize(pStmt);
234329 if( *pRc==SQLITE_OK ) *pRc = rc;
234330 }
234331
234332 /*
234333 ** Table pTab has one or more existing change-records with old.* records
234334 ** with fewer than pTab->nCol columns. This function updates all such
234335 ** change-records with the default values for the missing columns.
@@ -234318,13 +234349,12 @@
234349 }
234350 }
234351 }
234352 }
234353
234354 sessionFinalizeStmt(pStmt, &rc);
234355 pSession->rc = rc;
 
 
234356 return pSession->rc;
234357 }
234358
234359 /*
234360 ** Versions of the four methods in object SessionHook for use with the
@@ -235646,15 +235676,15 @@
235676 sessionAppendStr(&pkvar,
235677 "?1, (CASE WHEN ?2=X'' THEN NULL ELSE ?2 END)", &rc
235678 );
235679 sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
235680 }else{
235681 #if 0
235682 if( bRowid ){
235683 sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
235684 }
235685 #endif
235686 for(i=0; i<nCol; i++){
235687 if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
235688 sessionAppendIdent(&cols, azCol[i], &rc);
235689 if( abPK[i] ){
235690 sessionAppendStr(&pkfield, zSep, &rc);
@@ -236908,11 +236938,17 @@
236938 while( 1 ){
236939 u8 eType;
236940
236941 /* Test for EOF. */
236942 if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;
236943 if( pInput->iNext+1>=pInput->nData ){
236944 if( pInput->iNext!=pInput->nData ){
236945 rc = SQLITE_CORRUPT_BKPT;
236946 goto finished_invert;
236947 }
236948 break;
236949 }
236950 eType = pInput->aData[pInput->iNext];
236951
236952 switch( eType ){
236953 case 'T': {
236954 /* A 'table' record consists of:
@@ -237104,10 +237140,11 @@
237140 SessionBuffer constraints; /* Deferred constraints are stored here */
237141 SessionBuffer rebase; /* Rebase information (if any) here */
237142 u8 bRebaseStarted; /* If table header is already in rebase */
237143 u8 bRebase; /* True to collect rebase information */
237144 u8 bIgnoreNoop; /* True to ignore no-op conflicts */
237145 u8 bNoUpdateLoop; /* No update-loop processing */
237146 int bRowid;
237147 char *zErr; /* Error message, if any */
237148 };
237149
237150 /* Number of prepared UPDATE statements to cache. */
@@ -237677,11 +237714,11 @@
237714 /* Instead of invoking the conflict handler, append the change blob
237715 ** to the SessionApplyCtx.constraints buffer. */
237716 u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
237717 int nBlob = pIter->in.iNext - pIter->in.iCurrent;
237718 sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
237719 return rc;
237720 }else if( p->bIgnoreNoop==0 || op!=SQLITE_DELETE
237721 || eType==SQLITE_CHANGESET_CONFLICT
237722 ){
237723 /* No other row with the new.* primary key. */
237724 res = xConflict(pCtx, eType+1, pIter);
@@ -237925,11 +237962,268 @@
237962
237963 return rc;
237964 }
237965
237966 /*
237967 ** Create an iterator to iterate through the retry buffer pRetry.
237968 */
237969 static int sessionRetryIterInit(
237970 SessionBuffer *pRetry, /* Buffer to iterate through */
237971 int bPatchset, /* True for patchset, false for changeset */
237972 const char *zTab, /* Table name */
237973 SessionApplyCtx *pApply, /* Session apply context */
237974 sqlite3_changeset_iter **ppIter /* OUT: New iterator */
237975 ){
237976 sqlite3_changeset_iter *pRet = 0;
237977 int rc = SQLITE_OK;
237978
237979 rc = sessionChangesetStart(
237980 &pRet, 0, 0, pRetry->nBuf, pRetry->aBuf, pApply->bInvertConstraints, 1
237981 );
237982 if( rc==SQLITE_OK ){
237983 size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
237984 pRet->bPatchset = bPatchset;
237985 pRet->zTab = (char*)zTab;
237986 pRet->nCol = pApply->nCol;
237987 pRet->abPK = pApply->abPK;
237988 sessionBufferGrow(&pRet->tblhdr, nByte, &rc);
237989 pRet->apValue = (sqlite3_value**)pRet->tblhdr.aBuf;
237990 if( rc==SQLITE_OK ){
237991 memset(pRet->apValue, 0, nByte);
237992 }else{
237993 sqlite3changeset_finalize(pRet);
237994 pRet = 0;
237995 }
237996 }
237997
237998 *ppIter = pRet;
237999 return rc;
238000 }
238001
238002 /*
238003 ** Attempt to apply all the changes in retry buffer pRetry to the database.
238004 ** Except, if parameter iSkip is greater than or equal to 0, skip change
238005 ** iSkip.
238006 */
238007 static int sessionApplyRetryBuffer(
238008 SessionBuffer *pRetry, /* Buffer to apply changes from */
238009 int iSkip, /* If >=0, index of change to omit */
238010 sqlite3 *db, /* Database handle */
238011 int bPatchset, /* True for patchset, false for changeset */
238012 const char *zTab, /* Name of table to write to */
238013 SessionApplyCtx *pApply, /* Apply context */
238014 int(*xConflict)(void*, int, sqlite3_changeset_iter*),
238015 void *pCtx /* First argument passed to xConflict */
238016 ){
238017 int rc = SQLITE_OK;
238018 int rc2 = SQLITE_OK;
238019 int ii = 0;
238020 sqlite3_changeset_iter *pIter = 0;
238021
238022 assert( pApply->constraints.nBuf==0 );
238023
238024 rc = sessionRetryIterInit(pRetry, bPatchset, zTab, pApply, &pIter);
238025
238026 for(ii=0; rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter); ii++){
238027 if( ii!=iSkip ){
238028 rc = sessionApplyOneWithRetry(db, pIter, pApply, xConflict, pCtx);
238029 }
238030 }
238031
238032 rc2 = sqlite3changeset_finalize(pIter);
238033 if( rc==SQLITE_OK ) rc = rc2;
238034 assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
238035
238036 return rc;
238037 }
238038
238039 /*
238040 ** Check if table zTab in the "main" database of db is a WITHOUT ROWID
238041 ** table.
238042 **
238043 ** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to
238044 ** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an
238045 ** error does occur, return an SQLite error code. The final value of (*pbWR)
238046 ** is undefined in this case.
238047 */
238048 static int sessionTableIsWithoutRowid(sqlite3 *db, const char *zTab, int *pbWR){
238049 sqlite3_stmt *pList = 0;
238050 char *zSql = 0;
238051 int rc = SQLITE_OK;
238052
238053 zSql = sqlite3_mprintf("PRAGMA table_list = %Q", zTab);
238054 if( zSql==0 ){
238055 rc = SQLITE_NOMEM;
238056 }else{
238057 rc = sqlite3_prepare_v2(db, zSql, -1, &pList, 0);
238058 sqlite3_free(zSql);
238059 }
238060
238061 if( rc==SQLITE_OK ){
238062 sqlite3_step(pList);
238063 *pbWR = sqlite3_column_int(pList, 4);
238064 rc = sqlite3_finalize(pList);
238065 }
238066
238067 return rc;
238068 }
238069
238070 /*
238071 ** Iterator pUp points to an UPDATE change. This function deletes the
238072 ** affected row from the database and creates an INSERT statement that
238073 ** may be used to reinsert the row as it is after the UPDATE change
238074 ** has been applied.
238075 **
238076 ** If successful, SQLITE_OK is returned and output variable (*ppInsert)
238077 ** is left pointing to a prepared INSERT statement. It is the responsibility
238078 ** of the caller to eventually free this statement using sqlite3_finalize().
238079 ** Or, if an error occurs, an SQLite error code is returned and (*ppInsert)
238080 ** set to NULL. pApply->zErr may be set to an error message in this case.
238081 */
238082 static int sessionUpdateToDeleteInsert(
238083 sqlite3 *db, /* Database to write to */
238084 const char *zTab, /* Table name */
238085 SessionApplyCtx *pApply, /* Apply context */
238086 sqlite3_changeset_iter *pUp, /* Iterator pointing to UPDATE change */
238087 sqlite3_stmt **ppInsert /* OUT: INSERT statement */
238088 ){
238089 sqlite3_stmt *pRet = 0; /* The INSERT statement */
238090 sqlite3_stmt *pSelect = 0; /* SELECT to read current values of row */
238091 int rc = SQLITE_OK;
238092 int bWR = 0;
238093
238094 rc = sessionTableIsWithoutRowid(db, zTab, &bWR);
238095 if( rc==SQLITE_OK ){
238096 char *zSelect = 0;
238097 char *zInsert = 0;
238098 SessionBuffer cols = {0, 0, 0};
238099 SessionBuffer insbind = {0, 0, 0};
238100 SessionBuffer pkcols = {0, 0, 0};
238101 SessionBuffer selbind = {0, 0, 0};
238102
238103 const char *zComma = "";
238104 const char *zComma2 = "";
238105 int ii;
238106 for(ii=0; ii<pApply->nCol; ii++){
238107 sessionAppendStr(&cols, zComma, &rc);
238108 sessionAppendIdent(&cols, pApply->azCol[ii], &rc);
238109 sessionAppendStr(&insbind, zComma, &rc);
238110 sessionAppendStr(&insbind, "?", &rc);
238111 zComma = ", ";
238112
238113 if( pApply->abPK[ii] ){
238114 sessionAppendStr(&pkcols, zComma2, &rc);
238115 sessionAppendIdent(&pkcols, pApply->azCol[ii], &rc);
238116 sessionAppendStr(&selbind, zComma2, &rc);
238117 sessionAppendPrintf(&selbind, &rc, "?%d", ii+1);
238118 zComma2 = ", ";
238119 }
238120 }
238121 if( bWR==0 ){
238122 sessionAppendStr(&cols, zComma, &rc);
238123 sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
238124 sessionAppendStr(&insbind, zComma, &rc);
238125 sessionAppendStr(&insbind, "?", &rc);
238126 }
238127
238128 if( rc==SQLITE_OK ){
238129 zSelect = sqlite3_mprintf("SELECT %s FROM %Q WHERE (%s) IS (%s)",
238130 cols.aBuf, zTab, pkcols.aBuf, selbind.aBuf
238131 );
238132 if( zSelect==0 ) rc = SQLITE_NOMEM;
238133 }
238134 if( rc==SQLITE_OK ){
238135 zInsert = sqlite3_mprintf("INSERT INTO %Q(%s) VALUES(%s)",
238136 zTab, cols.aBuf, insbind.aBuf
238137 );
238138 if( zInsert==0 ) rc = SQLITE_NOMEM;
238139 }
238140
238141 if( rc==SQLITE_OK ){
238142 rc = sessionPrepare(db, &pSelect, &pApply->zErr, zSelect);
238143 }
238144 if( rc==SQLITE_OK ){
238145 rc = sessionPrepare(db, &pRet, &pApply->zErr, zInsert);
238146 }
238147
238148 sqlite3_free(zSelect);
238149 sqlite3_free(zInsert);
238150 sqlite3_free(cols.aBuf);
238151 sqlite3_free(insbind.aBuf);
238152 sqlite3_free(pkcols.aBuf);
238153 sqlite3_free(selbind.aBuf);
238154 }
238155
238156 if( rc==SQLITE_OK ){
238157 rc = sessionBindRow(
238158 pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pSelect
238159 );
238160 }
238161
238162 if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){
238163 int iCol;
238164 for(iCol=0; iCol<pApply->nCol; iCol++){
238165 sqlite3_value *pVal = pUp->apValue[iCol+pApply->nCol];
238166 if( pVal==0 ){
238167 pVal = sqlite3_column_value(pSelect, iCol);
238168 }
238169 rc = sqlite3_bind_value(pRet, iCol+1, pVal);
238170 }
238171 if( bWR==0 ){
238172 sqlite3_bind_int64(pRet, iCol+1, sqlite3_column_int64(pSelect, iCol));
238173 }
238174 }
238175 sessionFinalizeStmt(pSelect, &rc);
238176
238177 /* Delete the row from the database. */
238178 if( rc==SQLITE_OK ){
238179 rc = sessionBindRow(
238180 pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pApply->pDelete
238181 );
238182 sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);
238183 }
238184 if( rc==SQLITE_OK ){
238185 sqlite3_step(pApply->pDelete);
238186 rc = sqlite3_reset(pApply->pDelete);
238187 }
238188
238189 if( rc!=SQLITE_OK ){
238190 sqlite3_finalize(pRet);
238191 pRet = 0;
238192 }
238193
238194 *ppInsert = pRet;
238195 return rc;
238196 }
238197
238198 /*
238199 ** Retry the changes accumulated in the pApply->constraints buffer. The
238200 ** pApply->constraints buffer contains all changes to table zTab that
238201 ** could not be applied due to SQLITE_CONSTRAINT errors. This function
238202 ** attempts to apply them as follows:
238203 **
238204 ** 1) It runs through the buffer and attempts to retry each change,
238205 ** removing any that are successfully applied from the buffer. This
238206 ** is repeated until no further progress can be made.
238207 **
238208 ** 2) For each UPDATE change in the buffer, try the following in a
238209 ** savepoint transaction:
238210 **
238211 ** a) DELETE the affected row,
238212 ** b) Attempt step (1) with remaining changes,
238213 ** c) Attempt to INSERT a row equivalent to the one that would be
238214 ** created by applying this UPDATE change.
238215 **
238216 ** If the INSERT in (c) succeeds, the savepoint is committed and all
238217 ** successfully applied changes are removed from the buffer. Step (2)
238218 ** is then repeated.
238219 **
238220 ** 3) Once step (2) has been attempted for each UPDATE in the change,
238221 ** a final attempt is made to apply each remaining change. This time,
238222 ** if an SQLITE_CONSTRAINT error is encountered, the conflict handler
238223 ** is invoked and the user has to decide whether to omit the change
238224 ** or rollback the entire _apply() operation.
238225 */
238226 static int sessionRetryConstraints(
238227 sqlite3 *db,
238228 int bPatchset,
238229 const char *zTab,
@@ -237936,45 +238230,105 @@
238230 SessionApplyCtx *pApply,
238231 int(*xConflict)(void*, int, sqlite3_changeset_iter*),
238232 void *pCtx /* First argument passed to xConflict */
238233 ){
238234 int rc = SQLITE_OK;
238235 int iUpdate = 0;
238236
238237 /* Step (1) */
238238 while( pApply->constraints.nBuf ){
 
238239 SessionBuffer cons = pApply->constraints;
238240 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
238241
238242 rc = sessionApplyRetryBuffer(
238243 &cons, -1, db, bPatchset, zTab, pApply, xConflict, pCtx
238244 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238245
238246 sqlite3_free(cons.aBuf);
238247 if( rc!=SQLITE_OK ) break;
238248
238249 /* If no progress has been made this round, break out of the loop. */
238250 if( pApply->constraints.nBuf>=cons.nBuf ) break;
238251 }
238252
238253 /* Step (2) */
238254 while( rc==SQLITE_OK && pApply->constraints.nBuf && !pApply->bNoUpdateLoop ){
238255 SessionBuffer cons = {0, 0, 0};
238256 sqlite3_changeset_iter *pUp = 0;
238257 sqlite3_stmt *pInsert = 0;
238258 int iSkip = 0;
238259
238260 rc = sessionRetryIterInit(
238261 &pApply->constraints, bPatchset, zTab, pApply, &pUp
238262 );
238263 if( rc==SQLITE_OK ){
238264 int iThis = -1;
238265 while( SQLITE_ROW==sqlite3changeset_next(pUp) ){
238266 if( pUp->op==SQLITE_UPDATE ) iThis++;
238267 if( iThis==iUpdate ) break;
238268 iSkip++;
238269 }
238270 if( iThis==iUpdate ){
238271 rc = sqlite3_exec(db, "SAVEPOINT update_op", 0, 0, 0);
238272 if( rc==SQLITE_OK ){
238273 rc = sessionUpdateToDeleteInsert(db, zTab, pApply, pUp, &pInsert);
238274 }
238275 }
238276 sqlite3changeset_finalize(pUp);
238277 if( iThis!=iUpdate ) break;
238278 }
238279
238280 if( rc==SQLITE_OK ){
238281 cons = pApply->constraints;
238282
238283 while( rc==SQLITE_OK && pApply->constraints.nBuf>0 ){
238284 SessionBuffer app = pApply->constraints;
238285 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
238286 rc = sessionApplyRetryBuffer(
238287 &app, iSkip, db, bPatchset, zTab, pApply, xConflict, pCtx
238288 );
238289 if( app.aBuf!=cons.aBuf ){
238290 sqlite3_free(app.aBuf);
238291 }
238292 if( pApply->constraints.nBuf>=app.nBuf ){
238293 break;
238294 }
238295 iSkip = -1;
238296 }
238297 }
238298
238299 iUpdate++;
238300 if( rc==SQLITE_OK ){
238301 sqlite3_step(pInsert);
238302 rc = sqlite3_finalize(pInsert);
238303 if( rc==SQLITE_CONSTRAINT ){
238304 rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0);
238305 sqlite3_free(pApply->constraints.aBuf);
238306 pApply->constraints = cons;
238307 memset(&cons, 0, sizeof(cons));
238308 }else if( rc==SQLITE_OK ){
238309 iUpdate = 0;
238310 }
238311 if( rc==SQLITE_OK ){
238312 rc = sqlite3_exec(db, "RELEASE update_op", 0, 0, 0);
238313 }
238314 }else{
238315 sqlite3_finalize(pInsert);
238316 }
238317
238318 sqlite3_free(cons.aBuf);
238319 }
238320
238321 /* Step (3) */
238322 if( rc==SQLITE_OK && pApply->constraints.nBuf ){
238323 SessionBuffer cons = pApply->constraints;
238324 memset(&pApply->constraints, 0, sizeof(SessionBuffer));
238325 pApply->bDeferConstraints = 0;
238326 rc = sessionApplyRetryBuffer(
238327 &cons, -1, db, bPatchset, zTab, pApply, xConflict, pCtx
238328 );
238329 sqlite3_free(cons.aBuf);
238330 }
238331
238332 return rc;
238333 }
238334
@@ -238024,10 +238378,11 @@
238378 pIter->in.bNoDiscard = 1;
238379 memset(&sApply, 0, sizeof(sApply));
238380 sApply.bRebase = (ppRebase && pnRebase);
238381 sApply.bInvertConstraints = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
238382 sApply.bIgnoreNoop = !!(flags & SQLITE_CHANGESETAPPLY_IGNORENOOP);
238383 sApply.bNoUpdateLoop = !!(flags & SQLITE_CHANGESETAPPLY_NOUPDATELOOP);
238384 if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
238385 rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
238386 }
238387 if( rc==SQLITE_OK ){
238388 rc = sqlite3_exec(db, "PRAGMA defer_foreign_keys = 1", 0, 0, 0);
@@ -239835,11 +240190,11 @@
240190 int bNew,
240191 int iCol,
240192 const void *pVal,
240193 int nVal
240194 ){
240195 sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + (i64)nVal;
240196 int rc = SQLITE_OK;
240197 SessionBuffer *pBuf = 0;
240198
240199 if( SQLITE_OK!=(rc = checkChangeParams(pGrp, bNew, iCol, nByte, &pBuf)) ){
240200 return rc;
@@ -253306,12 +253661,15 @@
253661 */
253662 static void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){
253663
253664 assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
253665 assert( pIter->pColset );
253666 assert( pIter->poslist.nSpace>=pIter->pIndex->pConfig->nCol );
253667
253668 if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf
253669 || pSeg->nPos>pIter->pIndex->pConfig->nCol
253670 ){
253671 fts5IterSetOutputs_Col(pIter, pSeg);
253672 }else{
253673 u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];
253674 u8 *pEnd = (u8*)&a[pSeg->nPos];
253675 int iPrev = 0;
@@ -262677,11 +263035,11 @@
263035 int nArg, /* Number of args */
263036 sqlite3_value **apUnused /* Function arguments */
263037 ){
263038 assert( nArg==0 );
263039 UNUSED_PARAM2(nArg, apUnused);
263040 sqlite3_result_text(pCtx, "fts5: 2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10", -1, SQLITE_TRANSIENT);
263041 }
263042
263043 /*
263044 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263045 **
263046
+14 -2
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.54.0"
150150
#define SQLITE_VERSION_NUMBER 3054000
151
-#define SQLITE_SOURCE_ID "2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353"
151
+#define SQLITE_SOURCE_ID "2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-05-21T15:14:35.420Z"
154
+#define SQLITE_SCM_DATETIME "2026-05-28T11:29:05.704Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -12862,15 +12862,27 @@
1286212862
** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
1286312863
** If this flag it set, then all foreign key constraints in the target
1286412864
** database behave as if they were declared with "ON UPDATE NO ACTION ON
1286512865
** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
1286612866
** or SET DEFAULT.
12867
+**
12868
+** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
12869
+** Sometimes, a changeset contains two or more update statements such that
12870
+** although after applying all updates the database will contain no
12871
+** constraint violations, no single update can be applied before the others.
12872
+** The simplest example of this is a pair of UPDATEs that have "swapped"
12873
+** two column values with a UNIQUE constraint.
12874
+** <p>
12875
+** Usually, sqlite3changeset_apply() and similar functions work hard to try
12876
+** to find a way to apply such a changeset. However, if this flag is set,
12877
+** then all such updates are considered CONSTRAINT conflicts.
1286712878
*/
1286812879
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
1286912880
#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
1287012881
#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
1287112882
#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12883
+#define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
1287212884
1287312885
/*
1287412886
** CAPI3REF: Constants Passed To The Conflict Handler
1287512887
**
1287612888
** Values that may be passed as the second argument to a conflict-handler.
1287712889
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.54.0"
150 #define SQLITE_VERSION_NUMBER 3054000
151 #define SQLITE_SOURCE_ID "2026-05-21 15:14:35 9ac4a33a2932d353c4871fd8e09c10addf827f1fc3fc9380037d738cf2cd0353"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-05-21T15:14:35.420Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -12862,15 +12862,27 @@
12862 ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
12863 ** If this flag it set, then all foreign key constraints in the target
12864 ** database behave as if they were declared with "ON UPDATE NO ACTION ON
12865 ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12866 ** or SET DEFAULT.
 
 
 
 
 
 
 
 
 
 
 
12867 */
12868 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12869 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12870 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12871 #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
 
12872
12873 /*
12874 ** CAPI3REF: Constants Passed To The Conflict Handler
12875 **
12876 ** Values that may be passed as the second argument to a conflict-handler.
12877
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,14 +146,14 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.54.0"
150 #define SQLITE_VERSION_NUMBER 3054000
151 #define SQLITE_SOURCE_ID "2026-05-28 11:29:05 87c37dab7e53d1bd891f3fed624963b35ab15a785706d0964b5d07ab70421c10"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-05-28T11:29:05.704Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -12862,15 +12862,27 @@
12862 ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
12863 ** If this flag it set, then all foreign key constraints in the target
12864 ** database behave as if they were declared with "ON UPDATE NO ACTION ON
12865 ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12866 ** or SET DEFAULT.
12867 **
12868 ** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
12869 ** Sometimes, a changeset contains two or more update statements such that
12870 ** although after applying all updates the database will contain no
12871 ** constraint violations, no single update can be applied before the others.
12872 ** The simplest example of this is a pair of UPDATEs that have "swapped"
12873 ** two column values with a UNIQUE constraint.
12874 ** <p>
12875 ** Usually, sqlite3changeset_apply() and similar functions work hard to try
12876 ** to find a way to apply such a changeset. However, if this flag is set,
12877 ** then all such updates are considered CONSTRAINT conflicts.
12878 */
12879 #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12880 #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12881 #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12882 #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12883 #define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
12884
12885 /*
12886 ** CAPI3REF: Constants Passed To The Conflict Handler
12887 **
12888 ** Values that may be passed as the second argument to a conflict-handler.
12889

Keyboard Shortcuts

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