Fossil SCM

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

drh 2025-07-15 20:11 trunk
Commit 01855974c9c4197079c6d01272ca3b470429e5ceee314273372d3aa9864430a4
2 files changed +250 -49 +56 -13
+250 -49
--- 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
-** 498ee8d514e64cdc93a8d68e1971b6326c61 with changes in files:
21
+** 9f184f8dfa5ef6d57e10376adc30e0060ced with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465465
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466466
** [sqlite_version()] and [sqlite_source_id()].
467467
*/
468468
#define SQLITE_VERSION "3.51.0"
469469
#define SQLITE_VERSION_NUMBER 3051000
470
-#define SQLITE_SOURCE_ID "2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa"
470
+#define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
471471
472472
/*
473473
** CAPI3REF: Run-Time Library Version Numbers
474474
** KEYWORDS: sqlite3_version sqlite3_sourceid
475475
**
@@ -12631,17 +12631,26 @@
1263112631
** Apply a changeset or patchset to a database. These functions attempt to
1263212632
** update the "main" database attached to handle db with the changes found in
1263312633
** the changeset passed via the second and third arguments.
1263412634
**
1263512635
** The fourth argument (xFilter) passed to these functions is the "filter
12636
-** callback". If it is not NULL, then for each table affected by at least one
12637
-** change in the changeset, the filter callback is invoked with
12638
-** the table name as the second argument, and a copy of the context pointer
12639
-** passed as the sixth argument as the first. If the "filter callback"
12640
-** returns zero, then no attempt is made to apply any changes to the table.
12641
-** Otherwise, if the return value is non-zero or the xFilter argument to
12642
-** is NULL, all changes related to the table are attempted.
12636
+** callback". This may be passed NULL, in which case all changes in the
12637
+** changeset are applied to the database. For sqlite3changeset_apply() and
12638
+** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once
12639
+** for each table affected by at least one change in the changeset. In this
12640
+** case the table name is passed as the second argument, and a copy of
12641
+** the context pointer passed as the sixth argument to apply() or apply_v2()
12642
+** as the first. If the "filter callback" returns zero, then no attempt is
12643
+** made to apply any changes to the table. Otherwise, if the return value is
12644
+** non-zero, all changes related to the table are attempted.
12645
+**
12646
+** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once
12647
+** per change. The second argument in this case is an sqlite3_changeset_iter
12648
+** that may be queried using the usual APIs for the details of the current
12649
+** change. If the "filter callback" returns zero in this case, then no attempt
12650
+** is made to apply the current change. If it returns non-zero, the change
12651
+** is applied.
1264312652
**
1264412653
** For each table that is not excluded by the filter callback, this function
1264512654
** tests that the target database contains a compatible table. A table is
1264612655
** considered compatible if all of the following are true:
1264712656
**
@@ -12658,15 +12667,15 @@
1265812667
** changes associated with the table are applied. A warning message is issued
1265912668
** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
1266012669
** one such warning is issued for each table in the changeset.
1266112670
**
1266212671
** For each change for which there is a compatible table, an attempt is made
12663
-** to modify the table contents according to the UPDATE, INSERT or DELETE
12664
-** change. If a change cannot be applied cleanly, the conflict handler
12665
-** function passed as the fifth argument to sqlite3changeset_apply() may be
12666
-** invoked. A description of exactly when the conflict handler is invoked for
12667
-** each type of change is below.
12672
+** to modify the table contents according to each UPDATE, INSERT or DELETE
12673
+** change that is not excluded by a filter callback. If a change cannot be
12674
+** applied cleanly, the conflict handler function passed as the fifth argument
12675
+** to sqlite3changeset_apply() may be invoked. A description of exactly when
12676
+** the conflict handler is invoked for each type of change is below.
1266812677
**
1266912678
** Unlike the xFilter argument, xConflict may not be passed NULL. The results
1267012679
** of passing anything other than a valid function pointer as the xConflict
1267112680
** argument are undefined.
1267212681
**
@@ -12804,10 +12813,27 @@
1280412813
void *pChangeset, /* Changeset blob */
1280512814
int(*xFilter)(
1280612815
void *pCtx, /* Copy of sixth arg to _apply() */
1280712816
const char *zTab /* Table name */
1280812817
),
12818
+ int(*xConflict)(
12819
+ void *pCtx, /* Copy of sixth arg to _apply() */
12820
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12821
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
12822
+ ),
12823
+ void *pCtx, /* First argument passed to xConflict */
12824
+ void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12825
+ int flags /* SESSION_CHANGESETAPPLY_* flags */
12826
+);
12827
+SQLITE_API int sqlite3changeset_apply_v3(
12828
+ sqlite3 *db, /* Apply change to "main" db of this handle */
12829
+ int nChangeset, /* Size of changeset in bytes */
12830
+ void *pChangeset, /* Changeset blob */
12831
+ int(*xFilter)(
12832
+ void *pCtx, /* Copy of sixth arg to _apply() */
12833
+ sqlite3_changeset_iter *p /* Handle describing change */
12834
+ ),
1280912835
int(*xConflict)(
1281012836
void *pCtx, /* Copy of sixth arg to _apply() */
1281112837
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1281212838
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1281312839
),
@@ -13223,10 +13249,27 @@
1322313249
void *pIn, /* First arg for xInput */
1322413250
int(*xFilter)(
1322513251
void *pCtx, /* Copy of sixth arg to _apply() */
1322613252
const char *zTab /* Table name */
1322713253
),
13254
+ int(*xConflict)(
13255
+ void *pCtx, /* Copy of sixth arg to _apply() */
13256
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
13257
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
13258
+ ),
13259
+ void *pCtx, /* First argument passed to xConflict */
13260
+ void **ppRebase, int *pnRebase,
13261
+ int flags
13262
+);
13263
+SQLITE_API int sqlite3changeset_apply_v3_strm(
13264
+ sqlite3 *db, /* Apply change to "main" db of this handle */
13265
+ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
13266
+ void *pIn, /* First arg for xInput */
13267
+ int(*xFilter)(
13268
+ void *pCtx, /* Copy of sixth arg to _apply() */
13269
+ sqlite3_changeset_iter *p
13270
+ ),
1322813271
int(*xConflict)(
1322913272
void *pCtx, /* Copy of sixth arg to _apply() */
1323013273
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1323113274
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1323213275
),
@@ -17421,11 +17464,13 @@
1742117464
SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
1742217465
SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
1742317466
1742417467
SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val);
1742517468
17469
+#ifndef SQLITE_OMIT_DATETIME_FUNCS
1742617470
SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
17471
+#endif
1742717472
#ifdef SQLITE_ENABLE_BYTECODE_VTAB
1742817473
SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
1742917474
#endif
1743017475
1743117476
/* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra
@@ -18542,11 +18587,11 @@
1854218587
SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
1854318588
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
1854418589
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
1854518590
{nArg, SQLITE_FUNC_BUILTIN|\
1854618591
SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
18547
- pArg, 0, xFunc, 0, 0, 0, #zName, }
18592
+ pArg, 0, xFunc, 0, 0, 0, #zName, {0} }
1854818593
#define LIKEFUNC(zName, nArg, arg, flags) \
1854918594
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
1855018595
(void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
1855118596
#define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
1855218597
{nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
@@ -23888,11 +23933,11 @@
2388823933
** * MEM_Blob A blob, stored in Mem.z length Mem.n.
2388923934
** Incompatible with MEM_Str, MEM_Null,
2389023935
** MEM_Int, MEM_Real, and MEM_IntReal.
2389123936
**
2389223937
** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus
23893
-** MEM.u.i extra 0x00 bytes at the end.
23938
+** Mem.u.nZero extra 0x00 bytes at the end.
2389423939
**
2389523940
** * MEM_Int Integer stored in Mem.u.i.
2389623941
**
2389723942
** * MEM_Real Real stored in Mem.u.r.
2389823943
**
@@ -91417,10 +91462,11 @@
9141791462
}else{
9141891463
v->expmask |= ((u32)1 << (iVar-1));
9141991464
}
9142091465
}
9142191466
91467
+#ifndef SQLITE_OMIT_DATETIME_FUNCS
9142291468
/*
9142391469
** Cause a function to throw an error if it was call from OP_PureFunc
9142491470
** rather than OP_Function.
9142591471
**
9142691472
** OP_PureFunc means that the function must be deterministic, and should
@@ -91450,10 +91496,11 @@
9145091496
sqlite3_free(zMsg);
9145191497
return 0;
9145291498
}
9145391499
return 1;
9145491500
}
91501
+#endif /* SQLITE_OMIT_DATETIME_FUNCS */
9145591502
9145691503
#if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
9145791504
/*
9145891505
** This Walker callback is used to help verify that calls to
9145991506
** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
@@ -148367,11 +148414,11 @@
148367148414
}
148368148415
default: assert( p->op==TK_INTERSECT ); {
148369148416
int tab1, tab2;
148370148417
int iCont, iBreak, iStart;
148371148418
Expr *pLimit;
148372
- int addr;
148419
+ int addr, iLimit, iOffset;
148373148420
SelectDest intersectdest;
148374148421
int r1;
148375148422
int emptyBypass;
148376148423
148377148424
/* INTERSECT is different from the others since it requires
@@ -148394,20 +148441,33 @@
148394148441
TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148395148442
rc = sqlite3Select(pParse, pPrior, &intersectdest);
148396148443
if( rc ){
148397148444
goto multi_select_end;
148398148445
}
148446
+
148447
+ /* Initialize LIMIT counters before checking to see if the LHS
148448
+ ** is empty, in case the jump is taken */
148449
+ iBreak = sqlite3VdbeMakeLabel(pParse);
148450
+ computeLimitRegisters(pParse, p, iBreak);
148399148451
emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
148400148452
148401148453
/* Code the current SELECT into temporary table "tab2"
148402148454
*/
148403148455
addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148404148456
assert( p->addrOpenEphm[1] == -1 );
148405148457
p->addrOpenEphm[1] = addr;
148406
- p->pPrior = 0;
148458
+
148459
+ /* Disable prior SELECTs and the LIMIT counters during the computation
148460
+ ** of the RHS select */
148407148461
pLimit = p->pLimit;
148462
+ iLimit = p->iLimit;
148463
+ iOffset = p->iOffset;
148464
+ p->pPrior = 0;
148408148465
p->pLimit = 0;
148466
+ p->iLimit = 0;
148467
+ p->iOffset = 0;
148468
+
148409148469
intersectdest.iSDParm = tab2;
148410148470
ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
148411148471
sqlite3SelectOpName(p->op)));
148412148472
TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT right...\n"));
148413148473
rc = sqlite3Select(pParse, p, &intersectdest);
@@ -148416,23 +148476,25 @@
148416148476
p->pPrior = pPrior;
148417148477
if( p->nSelectRow>pPrior->nSelectRow ){
148418148478
p->nSelectRow = pPrior->nSelectRow;
148419148479
}
148420148480
sqlite3ExprDelete(db, p->pLimit);
148481
+
148482
+ /* Reinstate the LIMIT counters prior to running the final intersect */
148421148483
p->pLimit = pLimit;
148484
+ p->iLimit = iLimit;
148485
+ p->iOffset = iOffset;
148422148486
148423148487
/* Generate code to take the intersection of the two temporary
148424148488
** tables.
148425148489
*/
148426148490
if( rc ) break;
148427148491
assert( p->pEList );
148428
- iBreak = sqlite3VdbeMakeLabel(pParse);
148429
- iCont = sqlite3VdbeMakeLabel(pParse);
148430
- computeLimitRegisters(pParse, p, iBreak);
148431148492
sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
148432148493
r1 = sqlite3GetTempReg(pParse);
148433148494
iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
148495
+ iCont = sqlite3VdbeMakeLabel(pParse);
148434148496
sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148435148497
VdbeCoverage(v);
148436148498
sqlite3ReleaseTempReg(pParse, r1);
148437148499
selectInnerLoop(pParse, p, tab1,
148438148500
0, 0, &dest, iCont, iBreak);
@@ -164584,11 +164646,11 @@
164584164646
pNewExpr->w.iJoin = pExpr->w.iJoin;
164585164647
}
164586164648
idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
164587164649
testcase( idxNew==0 );
164588164650
pNewTerm = &pWC->a[idxNew];
164589
- pNewTerm->prereqRight = prereqExpr;
164651
+ pNewTerm->prereqRight = prereqExpr | extraRight;
164590164652
pNewTerm->leftCursor = pLeft->iTable;
164591164653
pNewTerm->u.x.leftColumn = pLeft->iColumn;
164592164654
pNewTerm->eOperator = WO_AUX;
164593164655
pNewTerm->eMatchOp = eOp2;
164594164656
markTermAsChild(pWC, idxNew, idxTerm);
@@ -215133,10 +215195,16 @@
215133215195
pStmt = pCsr->pReadAux;
215134215196
memset(pCsr, 0, sizeof(RtreeCursor));
215135215197
pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
215136215198
pCsr->pReadAux = pStmt;
215137215199
215200
+ /* The following will only fail if the previous sqlite3_step() call failed,
215201
+ ** in which case the error has already been caught. This statement never
215202
+ ** encounters an error within an sqlite3_column_xxx() function, as it
215203
+ ** calls sqlite3_column_value(), which does not use malloc(). So it is safe
215204
+ ** to ignore the error code here. */
215205
+ sqlite3_reset(pStmt);
215138215206
}
215139215207
215140215208
/*
215141215209
** Rtree virtual table module xClose method.
215142215210
*/
@@ -233861,10 +233929,14 @@
233861233929
sqlite3_changeset_iter *pIter, /* Changeset to apply */
233862233930
int(*xFilter)(
233863233931
void *pCtx, /* Copy of sixth arg to _apply() */
233864233932
const char *zTab /* Table name */
233865233933
),
233934
+ int(*xFilterIter)(
233935
+ void *pCtx, /* Copy of sixth arg to _apply() */
233936
+ sqlite3_changeset_iter *p
233937
+ ),
233866233938
int(*xConflict)(
233867233939
void *pCtx, /* Copy of fifth arg to _apply() */
233868233940
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
233869233941
sqlite3_changeset_iter *p /* Handle describing change and conflict */
233870233942
),
@@ -234000,10 +234072,13 @@
234000234072
}
234001234073
234002234074
/* If there is a schema mismatch on the current table, proceed to the
234003234075
** next change. A log message has already been issued. */
234004234076
if( schemaMismatch ) continue;
234077
+
234078
+ /* If this is a call to apply_v3(), invoke xFilterIter here. */
234079
+ if( xFilterIter && 0==xFilterIter(pCtx, pIter) ) continue;
234005234080
234006234081
rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);
234007234082
}
234008234083
234009234084
bPatchset = pIter->bPatchset;
@@ -234067,10 +234142,91 @@
234067234142
db->aDb[0].pSchema->schema_cookie -= 32;
234068234143
}
234069234144
sqlite3_mutex_leave(sqlite3_db_mutex(db));
234070234145
return rc;
234071234146
}
234147
+
234148
+/*
234149
+** This function is called by all six sqlite3changeset_apply() variants:
234150
+**
234151
+** + sqlite3changeset_apply()
234152
+** + sqlite3changeset_apply_v2()
234153
+** + sqlite3changeset_apply_v3()
234154
+** + sqlite3changeset_apply_strm()
234155
+** + sqlite3changeset_apply_strm_v2()
234156
+** + sqlite3changeset_apply_strm_v3()
234157
+**
234158
+** Arguments passed to this function are as follows:
234159
+**
234160
+** db:
234161
+** Database handle to apply changeset to main database of.
234162
+**
234163
+** nChangeset/pChangeset:
234164
+** These are both passed zero for the streaming variants. For the normal
234165
+** apply() functions, these are passed the size of and the buffer containing
234166
+** the changeset, respectively.
234167
+**
234168
+** xInput/pIn:
234169
+** These are both passed zero for the normal variants. For the streaming
234170
+** apply() functions, these are passed the input callback and context
234171
+** pointer, respectively.
234172
+**
234173
+** xFilter:
234174
+** The filter function as passed to apply() or apply_v2() (to filter by
234175
+** table name), if any. This is always NULL for apply_v3() calls.
234176
+**
234177
+** xFilterIter:
234178
+** The filter function as passed to apply_v3(), if any.
234179
+**
234180
+** xConflict:
234181
+** The conflict handler callback (must not be NULL).
234182
+**
234183
+** pCtx:
234184
+** The context pointer passed to the xFilter and xConflict handler callbacks.
234185
+**
234186
+** ppRebase, pnRebase:
234187
+** Zero for apply(). The rebase changeset output pointers, if any, for
234188
+** apply_v2() and apply_v3().
234189
+**
234190
+** flags:
234191
+** Zero for apply(). The flags parameter for apply_v2() and apply_v3().
234192
+*/
234193
+static int sessionChangesetApplyV23(
234194
+ sqlite3 *db, /* Apply change to "main" db of this handle */
234195
+ int nChangeset, /* Size of changeset in bytes */
234196
+ void *pChangeset, /* Changeset blob */
234197
+ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234198
+ void *pIn, /* First arg for xInput */
234199
+ int(*xFilter)(
234200
+ void *pCtx, /* Copy of sixth arg to _apply() */
234201
+ const char *zTab /* Table name */
234202
+ ),
234203
+ int(*xFilterIter)(
234204
+ void *pCtx, /* Copy of sixth arg to _apply() */
234205
+ sqlite3_changeset_iter *p /* Handle describing current change */
234206
+ ),
234207
+ int(*xConflict)(
234208
+ void *pCtx, /* Copy of sixth arg to _apply() */
234209
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234210
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
234211
+ ),
234212
+ void *pCtx, /* First argument passed to xConflict */
234213
+ void **ppRebase, int *pnRebase,
234214
+ int flags
234215
+){
234216
+ sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234217
+ int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234218
+ int rc = sessionChangesetStart(
234219
+ &pIter, xInput, pIn, nChangeset, pChangeset, bInverse, 1
234220
+ );
234221
+ if( rc==SQLITE_OK ){
234222
+ rc = sessionChangesetApply(db, pIter,
234223
+ xFilter, xFilterIter, xConflict, pCtx, ppRebase, pnRebase, flags
234224
+ );
234225
+ }
234226
+ return rc;
234227
+}
234072234228
234073234229
/*
234074234230
** Apply the changeset passed via pChangeset/nChangeset to the main
234075234231
** database attached to handle "db".
234076234232
*/
@@ -234089,21 +234245,43 @@
234089234245
),
234090234246
void *pCtx, /* First argument passed to xConflict */
234091234247
void **ppRebase, int *pnRebase,
234092234248
int flags
234093234249
){
234094
- sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234095
- int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234096
- int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1);
234097
-
234098
- if( rc==SQLITE_OK ){
234099
- rc = sessionChangesetApply(
234100
- db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
234101
- );
234102
- }
234103
-
234104
- return rc;
234250
+ return sessionChangesetApplyV23(db,
234251
+ nChangeset, pChangeset, 0, 0,
234252
+ xFilter, 0, xConflict, pCtx,
234253
+ ppRebase, pnRebase, flags
234254
+ );
234255
+}
234256
+
234257
+/*
234258
+** Apply the changeset passed via pChangeset/nChangeset to the main
234259
+** database attached to handle "db".
234260
+*/
234261
+SQLITE_API int sqlite3changeset_apply_v3(
234262
+ sqlite3 *db, /* Apply change to "main" db of this handle */
234263
+ int nChangeset, /* Size of changeset in bytes */
234264
+ void *pChangeset, /* Changeset blob */
234265
+ int(*xFilter)(
234266
+ void *pCtx, /* Copy of sixth arg to _apply() */
234267
+ sqlite3_changeset_iter *p /* Handle describing current change */
234268
+ ),
234269
+ int(*xConflict)(
234270
+ void *pCtx, /* Copy of sixth arg to _apply() */
234271
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234272
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
234273
+ ),
234274
+ void *pCtx, /* First argument passed to xConflict */
234275
+ void **ppRebase, int *pnRebase,
234276
+ int flags
234277
+){
234278
+ return sessionChangesetApplyV23(db,
234279
+ nChangeset, pChangeset, 0, 0,
234280
+ 0, xFilter, xConflict, pCtx,
234281
+ ppRebase, pnRebase, flags
234282
+ );
234105234283
}
234106234284
234107234285
/*
234108234286
** Apply the changeset passed via pChangeset/nChangeset to the main database
234109234287
** attached to handle "db". Invoke the supplied conflict handler callback
@@ -234122,20 +234300,45 @@
234122234300
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234123234301
sqlite3_changeset_iter *p /* Handle describing change and conflict */
234124234302
),
234125234303
void *pCtx /* First argument passed to xConflict */
234126234304
){
234127
- return sqlite3changeset_apply_v2(
234128
- db, nChangeset, pChangeset, xFilter, xConflict, pCtx, 0, 0, 0
234305
+ return sessionChangesetApplyV23(db,
234306
+ nChangeset, pChangeset, 0, 0,
234307
+ xFilter, 0, xConflict, pCtx,
234308
+ 0, 0, 0
234129234309
);
234130234310
}
234131234311
234132234312
/*
234133234313
** Apply the changeset passed via xInput/pIn to the main database
234134234314
** attached to handle "db". Invoke the supplied conflict handler callback
234135234315
** to resolve any conflicts encountered while applying the change.
234136234316
*/
234317
+SQLITE_API int sqlite3changeset_apply_v3_strm(
234318
+ sqlite3 *db, /* Apply change to "main" db of this handle */
234319
+ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234320
+ void *pIn, /* First arg for xInput */
234321
+ int(*xFilter)(
234322
+ void *pCtx, /* Copy of sixth arg to _apply() */
234323
+ sqlite3_changeset_iter *p
234324
+ ),
234325
+ int(*xConflict)(
234326
+ void *pCtx, /* Copy of sixth arg to _apply() */
234327
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234328
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
234329
+ ),
234330
+ void *pCtx, /* First argument passed to xConflict */
234331
+ void **ppRebase, int *pnRebase,
234332
+ int flags
234333
+){
234334
+ return sessionChangesetApplyV23(db,
234335
+ 0, 0, xInput, pIn,
234336
+ 0, xFilter, xConflict, pCtx,
234337
+ ppRebase, pnRebase, flags
234338
+ );
234339
+}
234137234340
SQLITE_API int sqlite3changeset_apply_v2_strm(
234138234341
sqlite3 *db, /* Apply change to "main" db of this handle */
234139234342
int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234140234343
void *pIn, /* First arg for xInput */
234141234344
int(*xFilter)(
@@ -234149,19 +234352,15 @@
234149234352
),
234150234353
void *pCtx, /* First argument passed to xConflict */
234151234354
void **ppRebase, int *pnRebase,
234152234355
int flags
234153234356
){
234154
- sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234155
- int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234156
- int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse, 1);
234157
- if( rc==SQLITE_OK ){
234158
- rc = sessionChangesetApply(
234159
- db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
234160
- );
234161
- }
234162
- return rc;
234357
+ return sessionChangesetApplyV23(db,
234358
+ 0, 0, xInput, pIn,
234359
+ xFilter, 0, xConflict, pCtx,
234360
+ ppRebase, pnRebase, flags
234361
+ );
234163234362
}
234164234363
SQLITE_API int sqlite3changeset_apply_strm(
234165234364
sqlite3 *db, /* Apply change to "main" db of this handle */
234166234365
int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234167234366
void *pIn, /* First arg for xInput */
@@ -234174,12 +234373,14 @@
234174234373
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234175234374
sqlite3_changeset_iter *p /* Handle describing change and conflict */
234176234375
),
234177234376
void *pCtx /* First argument passed to xConflict */
234178234377
){
234179
- return sqlite3changeset_apply_v2_strm(
234180
- db, xInput, pIn, xFilter, xConflict, pCtx, 0, 0, 0
234378
+ return sessionChangesetApplyV23(db,
234379
+ 0, 0, xInput, pIn,
234380
+ xFilter, 0, xConflict, pCtx,
234381
+ 0, 0, 0
234181234382
);
234182234383
}
234183234384
234184234385
/*
234185234386
** sqlite3_changegroup handle.
@@ -246784,13 +246985,13 @@
246784246985
** Allocate a tombstone hash page array object (pIter->pTombArray) for
246785246986
** the iterator passed as the second argument. If an OOM error occurs,
246786246987
** leave an error in the Fts5Index object.
246787246988
*/
246788246989
static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){
246789
- const int nTomb = pIter->pSeg->nPgTombstone;
246990
+ const i64 nTomb = (i64)pIter->pSeg->nPgTombstone;
246790246991
if( nTomb>0 ){
246791
- int nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246992
+ i64 nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246792246993
Fts5TombstoneArray *pNew;
246793246994
pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte);
246794246995
if( pNew ){
246795246996
pNew->nTombstone = nTomb;
246796246997
pNew->nRef = 1;
@@ -257912,11 +258113,11 @@
257912258113
int nArg, /* Number of args */
257913258114
sqlite3_value **apUnused /* Function arguments */
257914258115
){
257915258116
assert( nArg==0 );
257916258117
UNUSED_PARAM2(nArg, apUnused);
257917
- sqlite3_result_text(pCtx, "fts5: 2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa", -1, SQLITE_TRANSIENT);
258118
+ sqlite3_result_text(pCtx, "fts5: 2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839", -1, SQLITE_TRANSIENT);
257918258119
}
257919258120
257920258121
/*
257921258122
** Implementation of fts5_locale(LOCALE, TEXT) function.
257922258123
**
257923258124
--- 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 ** 498ee8d514e64cdc93a8d68e1971b6326c61 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -12631,17 +12631,26 @@
12631 ** Apply a changeset or patchset to a database. These functions attempt to
12632 ** update the "main" database attached to handle db with the changes found in
12633 ** the changeset passed via the second and third arguments.
12634 **
12635 ** The fourth argument (xFilter) passed to these functions is the "filter
12636 ** callback". If it is not NULL, then for each table affected by at least one
12637 ** change in the changeset, the filter callback is invoked with
12638 ** the table name as the second argument, and a copy of the context pointer
12639 ** passed as the sixth argument as the first. If the "filter callback"
12640 ** returns zero, then no attempt is made to apply any changes to the table.
12641 ** Otherwise, if the return value is non-zero or the xFilter argument to
12642 ** is NULL, all changes related to the table are attempted.
 
 
 
 
 
 
 
 
 
12643 **
12644 ** For each table that is not excluded by the filter callback, this function
12645 ** tests that the target database contains a compatible table. A table is
12646 ** considered compatible if all of the following are true:
12647 **
@@ -12658,15 +12667,15 @@
12658 ** changes associated with the table are applied. A warning message is issued
12659 ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
12660 ** one such warning is issued for each table in the changeset.
12661 **
12662 ** For each change for which there is a compatible table, an attempt is made
12663 ** to modify the table contents according to the UPDATE, INSERT or DELETE
12664 ** change. If a change cannot be applied cleanly, the conflict handler
12665 ** function passed as the fifth argument to sqlite3changeset_apply() may be
12666 ** invoked. A description of exactly when the conflict handler is invoked for
12667 ** each type of change is below.
12668 **
12669 ** Unlike the xFilter argument, xConflict may not be passed NULL. The results
12670 ** of passing anything other than a valid function pointer as the xConflict
12671 ** argument are undefined.
12672 **
@@ -12804,10 +12813,27 @@
12804 void *pChangeset, /* Changeset blob */
12805 int(*xFilter)(
12806 void *pCtx, /* Copy of sixth arg to _apply() */
12807 const char *zTab /* Table name */
12808 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12809 int(*xConflict)(
12810 void *pCtx, /* Copy of sixth arg to _apply() */
12811 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12812 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12813 ),
@@ -13223,10 +13249,27 @@
13223 void *pIn, /* First arg for xInput */
13224 int(*xFilter)(
13225 void *pCtx, /* Copy of sixth arg to _apply() */
13226 const char *zTab /* Table name */
13227 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13228 int(*xConflict)(
13229 void *pCtx, /* Copy of sixth arg to _apply() */
13230 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
13231 sqlite3_changeset_iter *p /* Handle describing change and conflict */
13232 ),
@@ -17421,11 +17464,13 @@
17421 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
17422 SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
17423
17424 SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val);
17425
 
17426 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
 
17427 #ifdef SQLITE_ENABLE_BYTECODE_VTAB
17428 SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
17429 #endif
17430
17431 /* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra
@@ -18542,11 +18587,11 @@
18542 SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
18543 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
18544 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
18545 {nArg, SQLITE_FUNC_BUILTIN|\
18546 SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
18547 pArg, 0, xFunc, 0, 0, 0, #zName, }
18548 #define LIKEFUNC(zName, nArg, arg, flags) \
18549 {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
18550 (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
18551 #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
18552 {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
@@ -23888,11 +23933,11 @@
23888 ** * MEM_Blob A blob, stored in Mem.z length Mem.n.
23889 ** Incompatible with MEM_Str, MEM_Null,
23890 ** MEM_Int, MEM_Real, and MEM_IntReal.
23891 **
23892 ** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus
23893 ** MEM.u.i extra 0x00 bytes at the end.
23894 **
23895 ** * MEM_Int Integer stored in Mem.u.i.
23896 **
23897 ** * MEM_Real Real stored in Mem.u.r.
23898 **
@@ -91417,10 +91462,11 @@
91417 }else{
91418 v->expmask |= ((u32)1 << (iVar-1));
91419 }
91420 }
91421
 
91422 /*
91423 ** Cause a function to throw an error if it was call from OP_PureFunc
91424 ** rather than OP_Function.
91425 **
91426 ** OP_PureFunc means that the function must be deterministic, and should
@@ -91450,10 +91496,11 @@
91450 sqlite3_free(zMsg);
91451 return 0;
91452 }
91453 return 1;
91454 }
 
91455
91456 #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
91457 /*
91458 ** This Walker callback is used to help verify that calls to
91459 ** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
@@ -148367,11 +148414,11 @@
148367 }
148368 default: assert( p->op==TK_INTERSECT ); {
148369 int tab1, tab2;
148370 int iCont, iBreak, iStart;
148371 Expr *pLimit;
148372 int addr;
148373 SelectDest intersectdest;
148374 int r1;
148375 int emptyBypass;
148376
148377 /* INTERSECT is different from the others since it requires
@@ -148394,20 +148441,33 @@
148394 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148395 rc = sqlite3Select(pParse, pPrior, &intersectdest);
148396 if( rc ){
148397 goto multi_select_end;
148398 }
 
 
 
 
 
148399 emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
148400
148401 /* Code the current SELECT into temporary table "tab2"
148402 */
148403 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148404 assert( p->addrOpenEphm[1] == -1 );
148405 p->addrOpenEphm[1] = addr;
148406 p->pPrior = 0;
 
 
148407 pLimit = p->pLimit;
 
 
 
148408 p->pLimit = 0;
 
 
 
148409 intersectdest.iSDParm = tab2;
148410 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
148411 sqlite3SelectOpName(p->op)));
148412 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT right...\n"));
148413 rc = sqlite3Select(pParse, p, &intersectdest);
@@ -148416,23 +148476,25 @@
148416 p->pPrior = pPrior;
148417 if( p->nSelectRow>pPrior->nSelectRow ){
148418 p->nSelectRow = pPrior->nSelectRow;
148419 }
148420 sqlite3ExprDelete(db, p->pLimit);
 
 
148421 p->pLimit = pLimit;
 
 
148422
148423 /* Generate code to take the intersection of the two temporary
148424 ** tables.
148425 */
148426 if( rc ) break;
148427 assert( p->pEList );
148428 iBreak = sqlite3VdbeMakeLabel(pParse);
148429 iCont = sqlite3VdbeMakeLabel(pParse);
148430 computeLimitRegisters(pParse, p, iBreak);
148431 sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
148432 r1 = sqlite3GetTempReg(pParse);
148433 iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
 
148434 sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148435 VdbeCoverage(v);
148436 sqlite3ReleaseTempReg(pParse, r1);
148437 selectInnerLoop(pParse, p, tab1,
148438 0, 0, &dest, iCont, iBreak);
@@ -164584,11 +164646,11 @@
164584 pNewExpr->w.iJoin = pExpr->w.iJoin;
164585 }
164586 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
164587 testcase( idxNew==0 );
164588 pNewTerm = &pWC->a[idxNew];
164589 pNewTerm->prereqRight = prereqExpr;
164590 pNewTerm->leftCursor = pLeft->iTable;
164591 pNewTerm->u.x.leftColumn = pLeft->iColumn;
164592 pNewTerm->eOperator = WO_AUX;
164593 pNewTerm->eMatchOp = eOp2;
164594 markTermAsChild(pWC, idxNew, idxTerm);
@@ -215133,10 +215195,16 @@
215133 pStmt = pCsr->pReadAux;
215134 memset(pCsr, 0, sizeof(RtreeCursor));
215135 pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
215136 pCsr->pReadAux = pStmt;
215137
 
 
 
 
 
 
215138 }
215139
215140 /*
215141 ** Rtree virtual table module xClose method.
215142 */
@@ -233861,10 +233929,14 @@
233861 sqlite3_changeset_iter *pIter, /* Changeset to apply */
233862 int(*xFilter)(
233863 void *pCtx, /* Copy of sixth arg to _apply() */
233864 const char *zTab /* Table name */
233865 ),
 
 
 
 
233866 int(*xConflict)(
233867 void *pCtx, /* Copy of fifth arg to _apply() */
233868 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
233869 sqlite3_changeset_iter *p /* Handle describing change and conflict */
233870 ),
@@ -234000,10 +234072,13 @@
234000 }
234001
234002 /* If there is a schema mismatch on the current table, proceed to the
234003 ** next change. A log message has already been issued. */
234004 if( schemaMismatch ) continue;
 
 
 
234005
234006 rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);
234007 }
234008
234009 bPatchset = pIter->bPatchset;
@@ -234067,10 +234142,91 @@
234067 db->aDb[0].pSchema->schema_cookie -= 32;
234068 }
234069 sqlite3_mutex_leave(sqlite3_db_mutex(db));
234070 return rc;
234071 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234072
234073 /*
234074 ** Apply the changeset passed via pChangeset/nChangeset to the main
234075 ** database attached to handle "db".
234076 */
@@ -234089,21 +234245,43 @@
234089 ),
234090 void *pCtx, /* First argument passed to xConflict */
234091 void **ppRebase, int *pnRebase,
234092 int flags
234093 ){
234094 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234095 int bInv = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234096 int rc = sessionChangesetStart(&pIter, 0, 0, nChangeset, pChangeset, bInv, 1);
234097
234098 if( rc==SQLITE_OK ){
234099 rc = sessionChangesetApply(
234100 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
234101 );
234102 }
234103
234104 return rc;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234105 }
234106
234107 /*
234108 ** Apply the changeset passed via pChangeset/nChangeset to the main database
234109 ** attached to handle "db". Invoke the supplied conflict handler callback
@@ -234122,20 +234300,45 @@
234122 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234123 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234124 ),
234125 void *pCtx /* First argument passed to xConflict */
234126 ){
234127 return sqlite3changeset_apply_v2(
234128 db, nChangeset, pChangeset, xFilter, xConflict, pCtx, 0, 0, 0
 
 
234129 );
234130 }
234131
234132 /*
234133 ** Apply the changeset passed via xInput/pIn to the main database
234134 ** attached to handle "db". Invoke the supplied conflict handler callback
234135 ** to resolve any conflicts encountered while applying the change.
234136 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234137 SQLITE_API int sqlite3changeset_apply_v2_strm(
234138 sqlite3 *db, /* Apply change to "main" db of this handle */
234139 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234140 void *pIn, /* First arg for xInput */
234141 int(*xFilter)(
@@ -234149,19 +234352,15 @@
234149 ),
234150 void *pCtx, /* First argument passed to xConflict */
234151 void **ppRebase, int *pnRebase,
234152 int flags
234153 ){
234154 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234155 int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234156 int rc = sessionChangesetStart(&pIter, xInput, pIn, 0, 0, bInverse, 1);
234157 if( rc==SQLITE_OK ){
234158 rc = sessionChangesetApply(
234159 db, pIter, xFilter, xConflict, pCtx, ppRebase, pnRebase, flags
234160 );
234161 }
234162 return rc;
234163 }
234164 SQLITE_API int sqlite3changeset_apply_strm(
234165 sqlite3 *db, /* Apply change to "main" db of this handle */
234166 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234167 void *pIn, /* First arg for xInput */
@@ -234174,12 +234373,14 @@
234174 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234175 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234176 ),
234177 void *pCtx /* First argument passed to xConflict */
234178 ){
234179 return sqlite3changeset_apply_v2_strm(
234180 db, xInput, pIn, xFilter, xConflict, pCtx, 0, 0, 0
 
 
234181 );
234182 }
234183
234184 /*
234185 ** sqlite3_changegroup handle.
@@ -246784,13 +246985,13 @@
246784 ** Allocate a tombstone hash page array object (pIter->pTombArray) for
246785 ** the iterator passed as the second argument. If an OOM error occurs,
246786 ** leave an error in the Fts5Index object.
246787 */
246788 static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){
246789 const int nTomb = pIter->pSeg->nPgTombstone;
246790 if( nTomb>0 ){
246791 int nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246792 Fts5TombstoneArray *pNew;
246793 pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte);
246794 if( pNew ){
246795 pNew->nTombstone = nTomb;
246796 pNew->nRef = 1;
@@ -257912,11 +258113,11 @@
257912 int nArg, /* Number of args */
257913 sqlite3_value **apUnused /* Function arguments */
257914 ){
257915 assert( nArg==0 );
257916 UNUSED_PARAM2(nArg, apUnused);
257917 sqlite3_result_text(pCtx, "fts5: 2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa", -1, SQLITE_TRANSIENT);
257918 }
257919
257920 /*
257921 ** Implementation of fts5_locale(LOCALE, TEXT) function.
257922 **
257923
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 9f184f8dfa5ef6d57e10376adc30e0060ced with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,11 +465,11 @@
465 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
466 ** [sqlite_version()] and [sqlite_source_id()].
467 */
468 #define SQLITE_VERSION "3.51.0"
469 #define SQLITE_VERSION_NUMBER 3051000
470 #define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
471
472 /*
473 ** CAPI3REF: Run-Time Library Version Numbers
474 ** KEYWORDS: sqlite3_version sqlite3_sourceid
475 **
@@ -12631,17 +12631,26 @@
12631 ** Apply a changeset or patchset to a database. These functions attempt to
12632 ** update the "main" database attached to handle db with the changes found in
12633 ** the changeset passed via the second and third arguments.
12634 **
12635 ** The fourth argument (xFilter) passed to these functions is the "filter
12636 ** callback". This may be passed NULL, in which case all changes in the
12637 ** changeset are applied to the database. For sqlite3changeset_apply() and
12638 ** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once
12639 ** for each table affected by at least one change in the changeset. In this
12640 ** case the table name is passed as the second argument, and a copy of
12641 ** the context pointer passed as the sixth argument to apply() or apply_v2()
12642 ** as the first. If the "filter callback" returns zero, then no attempt is
12643 ** made to apply any changes to the table. Otherwise, if the return value is
12644 ** non-zero, all changes related to the table are attempted.
12645 **
12646 ** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once
12647 ** per change. The second argument in this case is an sqlite3_changeset_iter
12648 ** that may be queried using the usual APIs for the details of the current
12649 ** change. If the "filter callback" returns zero in this case, then no attempt
12650 ** is made to apply the current change. If it returns non-zero, the change
12651 ** is applied.
12652 **
12653 ** For each table that is not excluded by the filter callback, this function
12654 ** tests that the target database contains a compatible table. A table is
12655 ** considered compatible if all of the following are true:
12656 **
@@ -12658,15 +12667,15 @@
12667 ** changes associated with the table are applied. A warning message is issued
12668 ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
12669 ** one such warning is issued for each table in the changeset.
12670 **
12671 ** For each change for which there is a compatible table, an attempt is made
12672 ** to modify the table contents according to each UPDATE, INSERT or DELETE
12673 ** change that is not excluded by a filter callback. If a change cannot be
12674 ** applied cleanly, the conflict handler function passed as the fifth argument
12675 ** to sqlite3changeset_apply() may be invoked. A description of exactly when
12676 ** the conflict handler is invoked for each type of change is below.
12677 **
12678 ** Unlike the xFilter argument, xConflict may not be passed NULL. The results
12679 ** of passing anything other than a valid function pointer as the xConflict
12680 ** argument are undefined.
12681 **
@@ -12804,10 +12813,27 @@
12813 void *pChangeset, /* Changeset blob */
12814 int(*xFilter)(
12815 void *pCtx, /* Copy of sixth arg to _apply() */
12816 const char *zTab /* Table name */
12817 ),
12818 int(*xConflict)(
12819 void *pCtx, /* Copy of sixth arg to _apply() */
12820 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12821 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12822 ),
12823 void *pCtx, /* First argument passed to xConflict */
12824 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12825 int flags /* SESSION_CHANGESETAPPLY_* flags */
12826 );
12827 SQLITE_API int sqlite3changeset_apply_v3(
12828 sqlite3 *db, /* Apply change to "main" db of this handle */
12829 int nChangeset, /* Size of changeset in bytes */
12830 void *pChangeset, /* Changeset blob */
12831 int(*xFilter)(
12832 void *pCtx, /* Copy of sixth arg to _apply() */
12833 sqlite3_changeset_iter *p /* Handle describing change */
12834 ),
12835 int(*xConflict)(
12836 void *pCtx, /* Copy of sixth arg to _apply() */
12837 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12838 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12839 ),
@@ -13223,10 +13249,27 @@
13249 void *pIn, /* First arg for xInput */
13250 int(*xFilter)(
13251 void *pCtx, /* Copy of sixth arg to _apply() */
13252 const char *zTab /* Table name */
13253 ),
13254 int(*xConflict)(
13255 void *pCtx, /* Copy of sixth arg to _apply() */
13256 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
13257 sqlite3_changeset_iter *p /* Handle describing change and conflict */
13258 ),
13259 void *pCtx, /* First argument passed to xConflict */
13260 void **ppRebase, int *pnRebase,
13261 int flags
13262 );
13263 SQLITE_API int sqlite3changeset_apply_v3_strm(
13264 sqlite3 *db, /* Apply change to "main" db of this handle */
13265 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
13266 void *pIn, /* First arg for xInput */
13267 int(*xFilter)(
13268 void *pCtx, /* Copy of sixth arg to _apply() */
13269 sqlite3_changeset_iter *p
13270 ),
13271 int(*xConflict)(
13272 void *pCtx, /* Copy of sixth arg to _apply() */
13273 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
13274 sqlite3_changeset_iter *p /* Handle describing change and conflict */
13275 ),
@@ -17421,11 +17464,13 @@
17464 SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *);
17465 SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*);
17466
17467 SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val);
17468
17469 #ifndef SQLITE_OMIT_DATETIME_FUNCS
17470 SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*);
17471 #endif
17472 #ifdef SQLITE_ENABLE_BYTECODE_VTAB
17473 SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*);
17474 #endif
17475
17476 /* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra
@@ -18542,11 +18587,11 @@
18587 SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\
18588 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} }
18589 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
18590 {nArg, SQLITE_FUNC_BUILTIN|\
18591 SQLITE_FUNC_SLOCHNG|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
18592 pArg, 0, xFunc, 0, 0, 0, #zName, {0} }
18593 #define LIKEFUNC(zName, nArg, arg, flags) \
18594 {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \
18595 (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
18596 #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
18597 {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
@@ -23888,11 +23933,11 @@
23933 ** * MEM_Blob A blob, stored in Mem.z length Mem.n.
23934 ** Incompatible with MEM_Str, MEM_Null,
23935 ** MEM_Int, MEM_Real, and MEM_IntReal.
23936 **
23937 ** * MEM_Blob|MEM_Zero A blob in Mem.z of length Mem.n plus
23938 ** Mem.u.nZero extra 0x00 bytes at the end.
23939 **
23940 ** * MEM_Int Integer stored in Mem.u.i.
23941 **
23942 ** * MEM_Real Real stored in Mem.u.r.
23943 **
@@ -91417,10 +91462,11 @@
91462 }else{
91463 v->expmask |= ((u32)1 << (iVar-1));
91464 }
91465 }
91466
91467 #ifndef SQLITE_OMIT_DATETIME_FUNCS
91468 /*
91469 ** Cause a function to throw an error if it was call from OP_PureFunc
91470 ** rather than OP_Function.
91471 **
91472 ** OP_PureFunc means that the function must be deterministic, and should
@@ -91450,10 +91496,11 @@
91496 sqlite3_free(zMsg);
91497 return 0;
91498 }
91499 return 1;
91500 }
91501 #endif /* SQLITE_OMIT_DATETIME_FUNCS */
91502
91503 #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG)
91504 /*
91505 ** This Walker callback is used to help verify that calls to
91506 ** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have
@@ -148367,11 +148414,11 @@
148414 }
148415 default: assert( p->op==TK_INTERSECT ); {
148416 int tab1, tab2;
148417 int iCont, iBreak, iStart;
148418 Expr *pLimit;
148419 int addr, iLimit, iOffset;
148420 SelectDest intersectdest;
148421 int r1;
148422 int emptyBypass;
148423
148424 /* INTERSECT is different from the others since it requires
@@ -148394,20 +148441,33 @@
148441 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n"));
148442 rc = sqlite3Select(pParse, pPrior, &intersectdest);
148443 if( rc ){
148444 goto multi_select_end;
148445 }
148446
148447 /* Initialize LIMIT counters before checking to see if the LHS
148448 ** is empty, in case the jump is taken */
148449 iBreak = sqlite3VdbeMakeLabel(pParse);
148450 computeLimitRegisters(pParse, p, iBreak);
148451 emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v);
148452
148453 /* Code the current SELECT into temporary table "tab2"
148454 */
148455 addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0);
148456 assert( p->addrOpenEphm[1] == -1 );
148457 p->addrOpenEphm[1] = addr;
148458
148459 /* Disable prior SELECTs and the LIMIT counters during the computation
148460 ** of the RHS select */
148461 pLimit = p->pLimit;
148462 iLimit = p->iLimit;
148463 iOffset = p->iOffset;
148464 p->pPrior = 0;
148465 p->pLimit = 0;
148466 p->iLimit = 0;
148467 p->iOffset = 0;
148468
148469 intersectdest.iSDParm = tab2;
148470 ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE",
148471 sqlite3SelectOpName(p->op)));
148472 TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT right...\n"));
148473 rc = sqlite3Select(pParse, p, &intersectdest);
@@ -148416,23 +148476,25 @@
148476 p->pPrior = pPrior;
148477 if( p->nSelectRow>pPrior->nSelectRow ){
148478 p->nSelectRow = pPrior->nSelectRow;
148479 }
148480 sqlite3ExprDelete(db, p->pLimit);
148481
148482 /* Reinstate the LIMIT counters prior to running the final intersect */
148483 p->pLimit = pLimit;
148484 p->iLimit = iLimit;
148485 p->iOffset = iOffset;
148486
148487 /* Generate code to take the intersection of the two temporary
148488 ** tables.
148489 */
148490 if( rc ) break;
148491 assert( p->pEList );
 
 
 
148492 sqlite3VdbeAddOp1(v, OP_Rewind, tab1);
148493 r1 = sqlite3GetTempReg(pParse);
148494 iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1);
148495 iCont = sqlite3VdbeMakeLabel(pParse);
148496 sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0);
148497 VdbeCoverage(v);
148498 sqlite3ReleaseTempReg(pParse, r1);
148499 selectInnerLoop(pParse, p, tab1,
148500 0, 0, &dest, iCont, iBreak);
@@ -164584,11 +164646,11 @@
164646 pNewExpr->w.iJoin = pExpr->w.iJoin;
164647 }
164648 idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC);
164649 testcase( idxNew==0 );
164650 pNewTerm = &pWC->a[idxNew];
164651 pNewTerm->prereqRight = prereqExpr | extraRight;
164652 pNewTerm->leftCursor = pLeft->iTable;
164653 pNewTerm->u.x.leftColumn = pLeft->iColumn;
164654 pNewTerm->eOperator = WO_AUX;
164655 pNewTerm->eMatchOp = eOp2;
164656 markTermAsChild(pWC, idxNew, idxTerm);
@@ -215133,10 +215195,16 @@
215195 pStmt = pCsr->pReadAux;
215196 memset(pCsr, 0, sizeof(RtreeCursor));
215197 pCsr->base.pVtab = (sqlite3_vtab*)pRtree;
215198 pCsr->pReadAux = pStmt;
215199
215200 /* The following will only fail if the previous sqlite3_step() call failed,
215201 ** in which case the error has already been caught. This statement never
215202 ** encounters an error within an sqlite3_column_xxx() function, as it
215203 ** calls sqlite3_column_value(), which does not use malloc(). So it is safe
215204 ** to ignore the error code here. */
215205 sqlite3_reset(pStmt);
215206 }
215207
215208 /*
215209 ** Rtree virtual table module xClose method.
215210 */
@@ -233861,10 +233929,14 @@
233929 sqlite3_changeset_iter *pIter, /* Changeset to apply */
233930 int(*xFilter)(
233931 void *pCtx, /* Copy of sixth arg to _apply() */
233932 const char *zTab /* Table name */
233933 ),
233934 int(*xFilterIter)(
233935 void *pCtx, /* Copy of sixth arg to _apply() */
233936 sqlite3_changeset_iter *p
233937 ),
233938 int(*xConflict)(
233939 void *pCtx, /* Copy of fifth arg to _apply() */
233940 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
233941 sqlite3_changeset_iter *p /* Handle describing change and conflict */
233942 ),
@@ -234000,10 +234072,13 @@
234072 }
234073
234074 /* If there is a schema mismatch on the current table, proceed to the
234075 ** next change. A log message has already been issued. */
234076 if( schemaMismatch ) continue;
234077
234078 /* If this is a call to apply_v3(), invoke xFilterIter here. */
234079 if( xFilterIter && 0==xFilterIter(pCtx, pIter) ) continue;
234080
234081 rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx);
234082 }
234083
234084 bPatchset = pIter->bPatchset;
@@ -234067,10 +234142,91 @@
234142 db->aDb[0].pSchema->schema_cookie -= 32;
234143 }
234144 sqlite3_mutex_leave(sqlite3_db_mutex(db));
234145 return rc;
234146 }
234147
234148 /*
234149 ** This function is called by all six sqlite3changeset_apply() variants:
234150 **
234151 ** + sqlite3changeset_apply()
234152 ** + sqlite3changeset_apply_v2()
234153 ** + sqlite3changeset_apply_v3()
234154 ** + sqlite3changeset_apply_strm()
234155 ** + sqlite3changeset_apply_strm_v2()
234156 ** + sqlite3changeset_apply_strm_v3()
234157 **
234158 ** Arguments passed to this function are as follows:
234159 **
234160 ** db:
234161 ** Database handle to apply changeset to main database of.
234162 **
234163 ** nChangeset/pChangeset:
234164 ** These are both passed zero for the streaming variants. For the normal
234165 ** apply() functions, these are passed the size of and the buffer containing
234166 ** the changeset, respectively.
234167 **
234168 ** xInput/pIn:
234169 ** These are both passed zero for the normal variants. For the streaming
234170 ** apply() functions, these are passed the input callback and context
234171 ** pointer, respectively.
234172 **
234173 ** xFilter:
234174 ** The filter function as passed to apply() or apply_v2() (to filter by
234175 ** table name), if any. This is always NULL for apply_v3() calls.
234176 **
234177 ** xFilterIter:
234178 ** The filter function as passed to apply_v3(), if any.
234179 **
234180 ** xConflict:
234181 ** The conflict handler callback (must not be NULL).
234182 **
234183 ** pCtx:
234184 ** The context pointer passed to the xFilter and xConflict handler callbacks.
234185 **
234186 ** ppRebase, pnRebase:
234187 ** Zero for apply(). The rebase changeset output pointers, if any, for
234188 ** apply_v2() and apply_v3().
234189 **
234190 ** flags:
234191 ** Zero for apply(). The flags parameter for apply_v2() and apply_v3().
234192 */
234193 static int sessionChangesetApplyV23(
234194 sqlite3 *db, /* Apply change to "main" db of this handle */
234195 int nChangeset, /* Size of changeset in bytes */
234196 void *pChangeset, /* Changeset blob */
234197 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234198 void *pIn, /* First arg for xInput */
234199 int(*xFilter)(
234200 void *pCtx, /* Copy of sixth arg to _apply() */
234201 const char *zTab /* Table name */
234202 ),
234203 int(*xFilterIter)(
234204 void *pCtx, /* Copy of sixth arg to _apply() */
234205 sqlite3_changeset_iter *p /* Handle describing current change */
234206 ),
234207 int(*xConflict)(
234208 void *pCtx, /* Copy of sixth arg to _apply() */
234209 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234210 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234211 ),
234212 void *pCtx, /* First argument passed to xConflict */
234213 void **ppRebase, int *pnRebase,
234214 int flags
234215 ){
234216 sqlite3_changeset_iter *pIter; /* Iterator to skip through changeset */
234217 int bInverse = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
234218 int rc = sessionChangesetStart(
234219 &pIter, xInput, pIn, nChangeset, pChangeset, bInverse, 1
234220 );
234221 if( rc==SQLITE_OK ){
234222 rc = sessionChangesetApply(db, pIter,
234223 xFilter, xFilterIter, xConflict, pCtx, ppRebase, pnRebase, flags
234224 );
234225 }
234226 return rc;
234227 }
234228
234229 /*
234230 ** Apply the changeset passed via pChangeset/nChangeset to the main
234231 ** database attached to handle "db".
234232 */
@@ -234089,21 +234245,43 @@
234245 ),
234246 void *pCtx, /* First argument passed to xConflict */
234247 void **ppRebase, int *pnRebase,
234248 int flags
234249 ){
234250 return sessionChangesetApplyV23(db,
234251 nChangeset, pChangeset, 0, 0,
234252 xFilter, 0, xConflict, pCtx,
234253 ppRebase, pnRebase, flags
234254 );
234255 }
234256
234257 /*
234258 ** Apply the changeset passed via pChangeset/nChangeset to the main
234259 ** database attached to handle "db".
234260 */
234261 SQLITE_API int sqlite3changeset_apply_v3(
234262 sqlite3 *db, /* Apply change to "main" db of this handle */
234263 int nChangeset, /* Size of changeset in bytes */
234264 void *pChangeset, /* Changeset blob */
234265 int(*xFilter)(
234266 void *pCtx, /* Copy of sixth arg to _apply() */
234267 sqlite3_changeset_iter *p /* Handle describing current change */
234268 ),
234269 int(*xConflict)(
234270 void *pCtx, /* Copy of sixth arg to _apply() */
234271 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234272 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234273 ),
234274 void *pCtx, /* First argument passed to xConflict */
234275 void **ppRebase, int *pnRebase,
234276 int flags
234277 ){
234278 return sessionChangesetApplyV23(db,
234279 nChangeset, pChangeset, 0, 0,
234280 0, xFilter, xConflict, pCtx,
234281 ppRebase, pnRebase, flags
234282 );
234283 }
234284
234285 /*
234286 ** Apply the changeset passed via pChangeset/nChangeset to the main database
234287 ** attached to handle "db". Invoke the supplied conflict handler callback
@@ -234122,20 +234300,45 @@
234300 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234301 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234302 ),
234303 void *pCtx /* First argument passed to xConflict */
234304 ){
234305 return sessionChangesetApplyV23(db,
234306 nChangeset, pChangeset, 0, 0,
234307 xFilter, 0, xConflict, pCtx,
234308 0, 0, 0
234309 );
234310 }
234311
234312 /*
234313 ** Apply the changeset passed via xInput/pIn to the main database
234314 ** attached to handle "db". Invoke the supplied conflict handler callback
234315 ** to resolve any conflicts encountered while applying the change.
234316 */
234317 SQLITE_API int sqlite3changeset_apply_v3_strm(
234318 sqlite3 *db, /* Apply change to "main" db of this handle */
234319 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234320 void *pIn, /* First arg for xInput */
234321 int(*xFilter)(
234322 void *pCtx, /* Copy of sixth arg to _apply() */
234323 sqlite3_changeset_iter *p
234324 ),
234325 int(*xConflict)(
234326 void *pCtx, /* Copy of sixth arg to _apply() */
234327 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234328 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234329 ),
234330 void *pCtx, /* First argument passed to xConflict */
234331 void **ppRebase, int *pnRebase,
234332 int flags
234333 ){
234334 return sessionChangesetApplyV23(db,
234335 0, 0, xInput, pIn,
234336 0, xFilter, xConflict, pCtx,
234337 ppRebase, pnRebase, flags
234338 );
234339 }
234340 SQLITE_API int sqlite3changeset_apply_v2_strm(
234341 sqlite3 *db, /* Apply change to "main" db of this handle */
234342 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234343 void *pIn, /* First arg for xInput */
234344 int(*xFilter)(
@@ -234149,19 +234352,15 @@
234352 ),
234353 void *pCtx, /* First argument passed to xConflict */
234354 void **ppRebase, int *pnRebase,
234355 int flags
234356 ){
234357 return sessionChangesetApplyV23(db,
234358 0, 0, xInput, pIn,
234359 xFilter, 0, xConflict, pCtx,
234360 ppRebase, pnRebase, flags
234361 );
 
 
 
 
234362 }
234363 SQLITE_API int sqlite3changeset_apply_strm(
234364 sqlite3 *db, /* Apply change to "main" db of this handle */
234365 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
234366 void *pIn, /* First arg for xInput */
@@ -234174,12 +234373,14 @@
234373 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
234374 sqlite3_changeset_iter *p /* Handle describing change and conflict */
234375 ),
234376 void *pCtx /* First argument passed to xConflict */
234377 ){
234378 return sessionChangesetApplyV23(db,
234379 0, 0, xInput, pIn,
234380 xFilter, 0, xConflict, pCtx,
234381 0, 0, 0
234382 );
234383 }
234384
234385 /*
234386 ** sqlite3_changegroup handle.
@@ -246784,13 +246985,13 @@
246985 ** Allocate a tombstone hash page array object (pIter->pTombArray) for
246986 ** the iterator passed as the second argument. If an OOM error occurs,
246987 ** leave an error in the Fts5Index object.
246988 */
246989 static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){
246990 const i64 nTomb = (i64)pIter->pSeg->nPgTombstone;
246991 if( nTomb>0 ){
246992 i64 nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1);
246993 Fts5TombstoneArray *pNew;
246994 pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte);
246995 if( pNew ){
246996 pNew->nTombstone = nTomb;
246997 pNew->nRef = 1;
@@ -257912,11 +258113,11 @@
258113 int nArg, /* Number of args */
258114 sqlite3_value **apUnused /* Function arguments */
258115 ){
258116 assert( nArg==0 );
258117 UNUSED_PARAM2(nArg, apUnused);
258118 sqlite3_result_text(pCtx, "fts5: 2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839", -1, SQLITE_TRANSIENT);
258119 }
258120
258121 /*
258122 ** Implementation of fts5_locale(LOCALE, TEXT) function.
258123 **
258124
+56 -13
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.51.0"
150150
#define SQLITE_VERSION_NUMBER 3051000
151
-#define SQLITE_SOURCE_ID "2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa"
151
+#define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -12312,17 +12312,26 @@
1231212312
** Apply a changeset or patchset to a database. These functions attempt to
1231312313
** update the "main" database attached to handle db with the changes found in
1231412314
** the changeset passed via the second and third arguments.
1231512315
**
1231612316
** The fourth argument (xFilter) passed to these functions is the "filter
12317
-** callback". If it is not NULL, then for each table affected by at least one
12318
-** change in the changeset, the filter callback is invoked with
12319
-** the table name as the second argument, and a copy of the context pointer
12320
-** passed as the sixth argument as the first. If the "filter callback"
12321
-** returns zero, then no attempt is made to apply any changes to the table.
12322
-** Otherwise, if the return value is non-zero or the xFilter argument to
12323
-** is NULL, all changes related to the table are attempted.
12317
+** callback". This may be passed NULL, in which case all changes in the
12318
+** changeset are applied to the database. For sqlite3changeset_apply() and
12319
+** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once
12320
+** for each table affected by at least one change in the changeset. In this
12321
+** case the table name is passed as the second argument, and a copy of
12322
+** the context pointer passed as the sixth argument to apply() or apply_v2()
12323
+** as the first. If the "filter callback" returns zero, then no attempt is
12324
+** made to apply any changes to the table. Otherwise, if the return value is
12325
+** non-zero, all changes related to the table are attempted.
12326
+**
12327
+** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once
12328
+** per change. The second argument in this case is an sqlite3_changeset_iter
12329
+** that may be queried using the usual APIs for the details of the current
12330
+** change. If the "filter callback" returns zero in this case, then no attempt
12331
+** is made to apply the current change. If it returns non-zero, the change
12332
+** is applied.
1232412333
**
1232512334
** For each table that is not excluded by the filter callback, this function
1232612335
** tests that the target database contains a compatible table. A table is
1232712336
** considered compatible if all of the following are true:
1232812337
**
@@ -12339,15 +12348,15 @@
1233912348
** changes associated with the table are applied. A warning message is issued
1234012349
** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
1234112350
** one such warning is issued for each table in the changeset.
1234212351
**
1234312352
** For each change for which there is a compatible table, an attempt is made
12344
-** to modify the table contents according to the UPDATE, INSERT or DELETE
12345
-** change. If a change cannot be applied cleanly, the conflict handler
12346
-** function passed as the fifth argument to sqlite3changeset_apply() may be
12347
-** invoked. A description of exactly when the conflict handler is invoked for
12348
-** each type of change is below.
12353
+** to modify the table contents according to each UPDATE, INSERT or DELETE
12354
+** change that is not excluded by a filter callback. If a change cannot be
12355
+** applied cleanly, the conflict handler function passed as the fifth argument
12356
+** to sqlite3changeset_apply() may be invoked. A description of exactly when
12357
+** the conflict handler is invoked for each type of change is below.
1234912358
**
1235012359
** Unlike the xFilter argument, xConflict may not be passed NULL. The results
1235112360
** of passing anything other than a valid function pointer as the xConflict
1235212361
** argument are undefined.
1235312362
**
@@ -12485,10 +12494,27 @@
1248512494
void *pChangeset, /* Changeset blob */
1248612495
int(*xFilter)(
1248712496
void *pCtx, /* Copy of sixth arg to _apply() */
1248812497
const char *zTab /* Table name */
1248912498
),
12499
+ int(*xConflict)(
12500
+ void *pCtx, /* Copy of sixth arg to _apply() */
12501
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12502
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
12503
+ ),
12504
+ void *pCtx, /* First argument passed to xConflict */
12505
+ void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12506
+ int flags /* SESSION_CHANGESETAPPLY_* flags */
12507
+);
12508
+SQLITE_API int sqlite3changeset_apply_v3(
12509
+ sqlite3 *db, /* Apply change to "main" db of this handle */
12510
+ int nChangeset, /* Size of changeset in bytes */
12511
+ void *pChangeset, /* Changeset blob */
12512
+ int(*xFilter)(
12513
+ void *pCtx, /* Copy of sixth arg to _apply() */
12514
+ sqlite3_changeset_iter *p /* Handle describing change */
12515
+ ),
1249012516
int(*xConflict)(
1249112517
void *pCtx, /* Copy of sixth arg to _apply() */
1249212518
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1249312519
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1249412520
),
@@ -12904,10 +12930,27 @@
1290412930
void *pIn, /* First arg for xInput */
1290512931
int(*xFilter)(
1290612932
void *pCtx, /* Copy of sixth arg to _apply() */
1290712933
const char *zTab /* Table name */
1290812934
),
12935
+ int(*xConflict)(
12936
+ void *pCtx, /* Copy of sixth arg to _apply() */
12937
+ int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12938
+ sqlite3_changeset_iter *p /* Handle describing change and conflict */
12939
+ ),
12940
+ void *pCtx, /* First argument passed to xConflict */
12941
+ void **ppRebase, int *pnRebase,
12942
+ int flags
12943
+);
12944
+SQLITE_API int sqlite3changeset_apply_v3_strm(
12945
+ sqlite3 *db, /* Apply change to "main" db of this handle */
12946
+ int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
12947
+ void *pIn, /* First arg for xInput */
12948
+ int(*xFilter)(
12949
+ void *pCtx, /* Copy of sixth arg to _apply() */
12950
+ sqlite3_changeset_iter *p
12951
+ ),
1290912952
int(*xConflict)(
1291012953
void *pCtx, /* Copy of sixth arg to _apply() */
1291112954
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
1291212955
sqlite3_changeset_iter *p /* Handle describing change and conflict */
1291312956
),
1291412957
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-07-08 22:11:39 498ee8d514e64cdc93a8d68e1971b6326c6132daf25067936bec921c42494caa"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -12312,17 +12312,26 @@
12312 ** Apply a changeset or patchset to a database. These functions attempt to
12313 ** update the "main" database attached to handle db with the changes found in
12314 ** the changeset passed via the second and third arguments.
12315 **
12316 ** The fourth argument (xFilter) passed to these functions is the "filter
12317 ** callback". If it is not NULL, then for each table affected by at least one
12318 ** change in the changeset, the filter callback is invoked with
12319 ** the table name as the second argument, and a copy of the context pointer
12320 ** passed as the sixth argument as the first. If the "filter callback"
12321 ** returns zero, then no attempt is made to apply any changes to the table.
12322 ** Otherwise, if the return value is non-zero or the xFilter argument to
12323 ** is NULL, all changes related to the table are attempted.
 
 
 
 
 
 
 
 
 
12324 **
12325 ** For each table that is not excluded by the filter callback, this function
12326 ** tests that the target database contains a compatible table. A table is
12327 ** considered compatible if all of the following are true:
12328 **
@@ -12339,15 +12348,15 @@
12339 ** changes associated with the table are applied. A warning message is issued
12340 ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
12341 ** one such warning is issued for each table in the changeset.
12342 **
12343 ** For each change for which there is a compatible table, an attempt is made
12344 ** to modify the table contents according to the UPDATE, INSERT or DELETE
12345 ** change. If a change cannot be applied cleanly, the conflict handler
12346 ** function passed as the fifth argument to sqlite3changeset_apply() may be
12347 ** invoked. A description of exactly when the conflict handler is invoked for
12348 ** each type of change is below.
12349 **
12350 ** Unlike the xFilter argument, xConflict may not be passed NULL. The results
12351 ** of passing anything other than a valid function pointer as the xConflict
12352 ** argument are undefined.
12353 **
@@ -12485,10 +12494,27 @@
12485 void *pChangeset, /* Changeset blob */
12486 int(*xFilter)(
12487 void *pCtx, /* Copy of sixth arg to _apply() */
12488 const char *zTab /* Table name */
12489 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12490 int(*xConflict)(
12491 void *pCtx, /* Copy of sixth arg to _apply() */
12492 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12493 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12494 ),
@@ -12904,10 +12930,27 @@
12904 void *pIn, /* First arg for xInput */
12905 int(*xFilter)(
12906 void *pCtx, /* Copy of sixth arg to _apply() */
12907 const char *zTab /* Table name */
12908 ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12909 int(*xConflict)(
12910 void *pCtx, /* Copy of sixth arg to _apply() */
12911 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12912 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12913 ),
12914
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.51.0"
150 #define SQLITE_VERSION_NUMBER 3051000
151 #define SQLITE_SOURCE_ID "2025-07-15 19:00:01 9f184f8dfa5ef6d57e10376adc30e0060ceda07d283c23dfdfe3dbdd6608f839"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -12312,17 +12312,26 @@
12312 ** Apply a changeset or patchset to a database. These functions attempt to
12313 ** update the "main" database attached to handle db with the changes found in
12314 ** the changeset passed via the second and third arguments.
12315 **
12316 ** The fourth argument (xFilter) passed to these functions is the "filter
12317 ** callback". This may be passed NULL, in which case all changes in the
12318 ** changeset are applied to the database. For sqlite3changeset_apply() and
12319 ** sqlite3_changeset_apply_v2(), if it is not NULL, then it is invoked once
12320 ** for each table affected by at least one change in the changeset. In this
12321 ** case the table name is passed as the second argument, and a copy of
12322 ** the context pointer passed as the sixth argument to apply() or apply_v2()
12323 ** as the first. If the "filter callback" returns zero, then no attempt is
12324 ** made to apply any changes to the table. Otherwise, if the return value is
12325 ** non-zero, all changes related to the table are attempted.
12326 **
12327 ** For sqlite3_changeset_apply_v3(), the xFilter callback is invoked once
12328 ** per change. The second argument in this case is an sqlite3_changeset_iter
12329 ** that may be queried using the usual APIs for the details of the current
12330 ** change. If the "filter callback" returns zero in this case, then no attempt
12331 ** is made to apply the current change. If it returns non-zero, the change
12332 ** is applied.
12333 **
12334 ** For each table that is not excluded by the filter callback, this function
12335 ** tests that the target database contains a compatible table. A table is
12336 ** considered compatible if all of the following are true:
12337 **
@@ -12339,15 +12348,15 @@
12348 ** changes associated with the table are applied. A warning message is issued
12349 ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
12350 ** one such warning is issued for each table in the changeset.
12351 **
12352 ** For each change for which there is a compatible table, an attempt is made
12353 ** to modify the table contents according to each UPDATE, INSERT or DELETE
12354 ** change that is not excluded by a filter callback. If a change cannot be
12355 ** applied cleanly, the conflict handler function passed as the fifth argument
12356 ** to sqlite3changeset_apply() may be invoked. A description of exactly when
12357 ** the conflict handler is invoked for each type of change is below.
12358 **
12359 ** Unlike the xFilter argument, xConflict may not be passed NULL. The results
12360 ** of passing anything other than a valid function pointer as the xConflict
12361 ** argument are undefined.
12362 **
@@ -12485,10 +12494,27 @@
12494 void *pChangeset, /* Changeset blob */
12495 int(*xFilter)(
12496 void *pCtx, /* Copy of sixth arg to _apply() */
12497 const char *zTab /* Table name */
12498 ),
12499 int(*xConflict)(
12500 void *pCtx, /* Copy of sixth arg to _apply() */
12501 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12502 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12503 ),
12504 void *pCtx, /* First argument passed to xConflict */
12505 void **ppRebase, int *pnRebase, /* OUT: Rebase data */
12506 int flags /* SESSION_CHANGESETAPPLY_* flags */
12507 );
12508 SQLITE_API int sqlite3changeset_apply_v3(
12509 sqlite3 *db, /* Apply change to "main" db of this handle */
12510 int nChangeset, /* Size of changeset in bytes */
12511 void *pChangeset, /* Changeset blob */
12512 int(*xFilter)(
12513 void *pCtx, /* Copy of sixth arg to _apply() */
12514 sqlite3_changeset_iter *p /* Handle describing change */
12515 ),
12516 int(*xConflict)(
12517 void *pCtx, /* Copy of sixth arg to _apply() */
12518 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12519 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12520 ),
@@ -12904,10 +12930,27 @@
12930 void *pIn, /* First arg for xInput */
12931 int(*xFilter)(
12932 void *pCtx, /* Copy of sixth arg to _apply() */
12933 const char *zTab /* Table name */
12934 ),
12935 int(*xConflict)(
12936 void *pCtx, /* Copy of sixth arg to _apply() */
12937 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12938 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12939 ),
12940 void *pCtx, /* First argument passed to xConflict */
12941 void **ppRebase, int *pnRebase,
12942 int flags
12943 );
12944 SQLITE_API int sqlite3changeset_apply_v3_strm(
12945 sqlite3 *db, /* Apply change to "main" db of this handle */
12946 int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
12947 void *pIn, /* First arg for xInput */
12948 int(*xFilter)(
12949 void *pCtx, /* Copy of sixth arg to _apply() */
12950 sqlite3_changeset_iter *p
12951 ),
12952 int(*xConflict)(
12953 void *pCtx, /* Copy of sixth arg to _apply() */
12954 int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
12955 sqlite3_changeset_iter *p /* Handle describing change and conflict */
12956 ),
12957

Keyboard Shortcuts

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