Fossil SCM
Update the built-in SQLite to the latest trunk version, for testing.
Commit
01855974c9c4197079c6d01272ca3b470429e5ceee314273372d3aa9864430a4
Parent
3f8d014f99cf91d…
2 files changed
+250
-49
+56
-13
+250
-49
| --- extsrc/sqlite3.c | ||
| +++ extsrc/sqlite3.c | ||
| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | 19 | ** |
| 20 | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | -** 498ee8d514e64cdc93a8d68e1971b6326c61 with changes in files: | |
| 21 | +** 9f184f8dfa5ef6d57e10376adc30e0060ced with changes in files: | |
| 22 | 22 | ** |
| 23 | 23 | ** |
| 24 | 24 | */ |
| 25 | 25 | #ifndef SQLITE_AMALGAMATION |
| 26 | 26 | #define SQLITE_CORE 1 |
| @@ -465,11 +465,11 @@ | ||
| 465 | 465 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 466 | 466 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 467 | 467 | */ |
| 468 | 468 | #define SQLITE_VERSION "3.51.0" |
| 469 | 469 | #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" | |
| 471 | 471 | |
| 472 | 472 | /* |
| 473 | 473 | ** CAPI3REF: Run-Time Library Version Numbers |
| 474 | 474 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 475 | 475 | ** |
| @@ -12631,17 +12631,26 @@ | ||
| 12631 | 12631 | ** Apply a changeset or patchset to a database. These functions attempt to |
| 12632 | 12632 | ** update the "main" database attached to handle db with the changes found in |
| 12633 | 12633 | ** the changeset passed via the second and third arguments. |
| 12634 | 12634 | ** |
| 12635 | 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. | |
| 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. | |
| 12643 | 12652 | ** |
| 12644 | 12653 | ** For each table that is not excluded by the filter callback, this function |
| 12645 | 12654 | ** tests that the target database contains a compatible table. A table is |
| 12646 | 12655 | ** considered compatible if all of the following are true: |
| 12647 | 12656 | ** |
| @@ -12658,15 +12667,15 @@ | ||
| 12658 | 12667 | ** changes associated with the table are applied. A warning message is issued |
| 12659 | 12668 | ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most |
| 12660 | 12669 | ** one such warning is issued for each table in the changeset. |
| 12661 | 12670 | ** |
| 12662 | 12671 | ** 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. | |
| 12668 | 12677 | ** |
| 12669 | 12678 | ** Unlike the xFilter argument, xConflict may not be passed NULL. The results |
| 12670 | 12679 | ** of passing anything other than a valid function pointer as the xConflict |
| 12671 | 12680 | ** argument are undefined. |
| 12672 | 12681 | ** |
| @@ -12804,10 +12813,27 @@ | ||
| 12804 | 12813 | void *pChangeset, /* Changeset blob */ |
| 12805 | 12814 | int(*xFilter)( |
| 12806 | 12815 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12807 | 12816 | const char *zTab /* Table name */ |
| 12808 | 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 | + ), | |
| 12809 | 12835 | int(*xConflict)( |
| 12810 | 12836 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12811 | 12837 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 12812 | 12838 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 12813 | 12839 | ), |
| @@ -13223,10 +13249,27 @@ | ||
| 13223 | 13249 | void *pIn, /* First arg for xInput */ |
| 13224 | 13250 | int(*xFilter)( |
| 13225 | 13251 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 13226 | 13252 | const char *zTab /* Table name */ |
| 13227 | 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 | + ), | |
| 13228 | 13271 | int(*xConflict)( |
| 13229 | 13272 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 13230 | 13273 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 13231 | 13274 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 13232 | 13275 | ), |
| @@ -17421,11 +17464,13 @@ | ||
| 17421 | 17464 | SQLITE_PRIVATE void sqlite3VdbeLinkSubProgram(Vdbe *, SubProgram *); |
| 17422 | 17465 | SQLITE_PRIVATE int sqlite3VdbeHasSubProgram(Vdbe*); |
| 17423 | 17466 | |
| 17424 | 17467 | SQLITE_PRIVATE void sqlite3MemSetArrayInt64(sqlite3_value *aMem, int iIdx, i64 val); |
| 17425 | 17468 | |
| 17469 | +#ifndef SQLITE_OMIT_DATETIME_FUNCS | |
| 17426 | 17470 | SQLITE_PRIVATE int sqlite3NotPureFunc(sqlite3_context*); |
| 17471 | +#endif | |
| 17427 | 17472 | #ifdef SQLITE_ENABLE_BYTECODE_VTAB |
| 17428 | 17473 | SQLITE_PRIVATE int sqlite3VdbeBytecodeVtabInit(sqlite3*); |
| 17429 | 17474 | #endif |
| 17430 | 17475 | |
| 17431 | 17476 | /* Use SQLITE_ENABLE_EXPLAIN_COMMENTS to enable generation of extra |
| @@ -18542,11 +18587,11 @@ | ||
| 18542 | 18587 | SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags,\ |
| 18543 | 18588 | SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, 0, #zName, {0} } |
| 18544 | 18589 | #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \ |
| 18545 | 18590 | {nArg, SQLITE_FUNC_BUILTIN|\ |
| 18546 | 18591 | 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} } | |
| 18548 | 18593 | #define LIKEFUNC(zName, nArg, arg, flags) \ |
| 18549 | 18594 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_FUNC_CONSTANT|SQLITE_UTF8|flags, \ |
| 18550 | 18595 | (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} } |
| 18551 | 18596 | #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \ |
| 18552 | 18597 | {nArg, SQLITE_FUNC_BUILTIN|SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \ |
| @@ -23888,11 +23933,11 @@ | ||
| 23888 | 23933 | ** * MEM_Blob A blob, stored in Mem.z length Mem.n. |
| 23889 | 23934 | ** Incompatible with MEM_Str, MEM_Null, |
| 23890 | 23935 | ** MEM_Int, MEM_Real, and MEM_IntReal. |
| 23891 | 23936 | ** |
| 23892 | 23937 | ** * 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. | |
| 23894 | 23939 | ** |
| 23895 | 23940 | ** * MEM_Int Integer stored in Mem.u.i. |
| 23896 | 23941 | ** |
| 23897 | 23942 | ** * MEM_Real Real stored in Mem.u.r. |
| 23898 | 23943 | ** |
| @@ -91417,10 +91462,11 @@ | ||
| 91417 | 91462 | }else{ |
| 91418 | 91463 | v->expmask |= ((u32)1 << (iVar-1)); |
| 91419 | 91464 | } |
| 91420 | 91465 | } |
| 91421 | 91466 | |
| 91467 | +#ifndef SQLITE_OMIT_DATETIME_FUNCS | |
| 91422 | 91468 | /* |
| 91423 | 91469 | ** Cause a function to throw an error if it was call from OP_PureFunc |
| 91424 | 91470 | ** rather than OP_Function. |
| 91425 | 91471 | ** |
| 91426 | 91472 | ** OP_PureFunc means that the function must be deterministic, and should |
| @@ -91450,10 +91496,11 @@ | ||
| 91450 | 91496 | sqlite3_free(zMsg); |
| 91451 | 91497 | return 0; |
| 91452 | 91498 | } |
| 91453 | 91499 | return 1; |
| 91454 | 91500 | } |
| 91501 | +#endif /* SQLITE_OMIT_DATETIME_FUNCS */ | |
| 91455 | 91502 | |
| 91456 | 91503 | #if defined(SQLITE_ENABLE_CURSOR_HINTS) && defined(SQLITE_DEBUG) |
| 91457 | 91504 | /* |
| 91458 | 91505 | ** This Walker callback is used to help verify that calls to |
| 91459 | 91506 | ** sqlite3BtreeCursorHint() with opcode BTREE_HINT_RANGE have |
| @@ -148367,11 +148414,11 @@ | ||
| 148367 | 148414 | } |
| 148368 | 148415 | default: assert( p->op==TK_INTERSECT ); { |
| 148369 | 148416 | int tab1, tab2; |
| 148370 | 148417 | int iCont, iBreak, iStart; |
| 148371 | 148418 | Expr *pLimit; |
| 148372 | - int addr; | |
| 148419 | + int addr, iLimit, iOffset; | |
| 148373 | 148420 | SelectDest intersectdest; |
| 148374 | 148421 | int r1; |
| 148375 | 148422 | int emptyBypass; |
| 148376 | 148423 | |
| 148377 | 148424 | /* INTERSECT is different from the others since it requires |
| @@ -148394,20 +148441,33 @@ | ||
| 148394 | 148441 | TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT left...\n")); |
| 148395 | 148442 | rc = sqlite3Select(pParse, pPrior, &intersectdest); |
| 148396 | 148443 | if( rc ){ |
| 148397 | 148444 | goto multi_select_end; |
| 148398 | 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); | |
| 148399 | 148451 | emptyBypass = sqlite3VdbeAddOp1(v, OP_IfEmpty, tab1); VdbeCoverage(v); |
| 148400 | 148452 | |
| 148401 | 148453 | /* Code the current SELECT into temporary table "tab2" |
| 148402 | 148454 | */ |
| 148403 | 148455 | addr = sqlite3VdbeAddOp2(v, OP_OpenEphemeral, tab2, 0); |
| 148404 | 148456 | assert( p->addrOpenEphm[1] == -1 ); |
| 148405 | 148457 | 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 */ | |
| 148407 | 148461 | pLimit = p->pLimit; |
| 148462 | + iLimit = p->iLimit; | |
| 148463 | + iOffset = p->iOffset; | |
| 148464 | + p->pPrior = 0; | |
| 148408 | 148465 | p->pLimit = 0; |
| 148466 | + p->iLimit = 0; | |
| 148467 | + p->iOffset = 0; | |
| 148468 | + | |
| 148409 | 148469 | intersectdest.iSDParm = tab2; |
| 148410 | 148470 | ExplainQueryPlan((pParse, 1, "%s USING TEMP B-TREE", |
| 148411 | 148471 | sqlite3SelectOpName(p->op))); |
| 148412 | 148472 | TREETRACE(0x400, pParse, p, ("multiSelect INTERSECT right...\n")); |
| 148413 | 148473 | rc = sqlite3Select(pParse, p, &intersectdest); |
| @@ -148416,23 +148476,25 @@ | ||
| 148416 | 148476 | p->pPrior = pPrior; |
| 148417 | 148477 | if( p->nSelectRow>pPrior->nSelectRow ){ |
| 148418 | 148478 | p->nSelectRow = pPrior->nSelectRow; |
| 148419 | 148479 | } |
| 148420 | 148480 | sqlite3ExprDelete(db, p->pLimit); |
| 148481 | + | |
| 148482 | + /* Reinstate the LIMIT counters prior to running the final intersect */ | |
| 148421 | 148483 | p->pLimit = pLimit; |
| 148484 | + p->iLimit = iLimit; | |
| 148485 | + p->iOffset = iOffset; | |
| 148422 | 148486 | |
| 148423 | 148487 | /* Generate code to take the intersection of the two temporary |
| 148424 | 148488 | ** tables. |
| 148425 | 148489 | */ |
| 148426 | 148490 | if( rc ) break; |
| 148427 | 148491 | assert( p->pEList ); |
| 148428 | - iBreak = sqlite3VdbeMakeLabel(pParse); | |
| 148429 | - iCont = sqlite3VdbeMakeLabel(pParse); | |
| 148430 | - computeLimitRegisters(pParse, p, iBreak); | |
| 148431 | 148492 | sqlite3VdbeAddOp1(v, OP_Rewind, tab1); |
| 148432 | 148493 | r1 = sqlite3GetTempReg(pParse); |
| 148433 | 148494 | iStart = sqlite3VdbeAddOp2(v, OP_RowData, tab1, r1); |
| 148495 | + iCont = sqlite3VdbeMakeLabel(pParse); | |
| 148434 | 148496 | sqlite3VdbeAddOp4Int(v, OP_NotFound, tab2, iCont, r1, 0); |
| 148435 | 148497 | VdbeCoverage(v); |
| 148436 | 148498 | sqlite3ReleaseTempReg(pParse, r1); |
| 148437 | 148499 | selectInnerLoop(pParse, p, tab1, |
| 148438 | 148500 | 0, 0, &dest, iCont, iBreak); |
| @@ -164584,11 +164646,11 @@ | ||
| 164584 | 164646 | pNewExpr->w.iJoin = pExpr->w.iJoin; |
| 164585 | 164647 | } |
| 164586 | 164648 | idxNew = whereClauseInsert(pWC, pNewExpr, TERM_VIRTUAL|TERM_DYNAMIC); |
| 164587 | 164649 | testcase( idxNew==0 ); |
| 164588 | 164650 | pNewTerm = &pWC->a[idxNew]; |
| 164589 | - pNewTerm->prereqRight = prereqExpr; | |
| 164651 | + pNewTerm->prereqRight = prereqExpr | extraRight; | |
| 164590 | 164652 | pNewTerm->leftCursor = pLeft->iTable; |
| 164591 | 164653 | pNewTerm->u.x.leftColumn = pLeft->iColumn; |
| 164592 | 164654 | pNewTerm->eOperator = WO_AUX; |
| 164593 | 164655 | pNewTerm->eMatchOp = eOp2; |
| 164594 | 164656 | markTermAsChild(pWC, idxNew, idxTerm); |
| @@ -215133,10 +215195,16 @@ | ||
| 215133 | 215195 | pStmt = pCsr->pReadAux; |
| 215134 | 215196 | memset(pCsr, 0, sizeof(RtreeCursor)); |
| 215135 | 215197 | pCsr->base.pVtab = (sqlite3_vtab*)pRtree; |
| 215136 | 215198 | pCsr->pReadAux = pStmt; |
| 215137 | 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); | |
| 215138 | 215206 | } |
| 215139 | 215207 | |
| 215140 | 215208 | /* |
| 215141 | 215209 | ** Rtree virtual table module xClose method. |
| 215142 | 215210 | */ |
| @@ -233861,10 +233929,14 @@ | ||
| 233861 | 233929 | sqlite3_changeset_iter *pIter, /* Changeset to apply */ |
| 233862 | 233930 | int(*xFilter)( |
| 233863 | 233931 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 233864 | 233932 | const char *zTab /* Table name */ |
| 233865 | 233933 | ), |
| 233934 | + int(*xFilterIter)( | |
| 233935 | + void *pCtx, /* Copy of sixth arg to _apply() */ | |
| 233936 | + sqlite3_changeset_iter *p | |
| 233937 | + ), | |
| 233866 | 233938 | int(*xConflict)( |
| 233867 | 233939 | void *pCtx, /* Copy of fifth arg to _apply() */ |
| 233868 | 233940 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 233869 | 233941 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 233870 | 233942 | ), |
| @@ -234000,10 +234072,13 @@ | ||
| 234000 | 234072 | } |
| 234001 | 234073 | |
| 234002 | 234074 | /* If there is a schema mismatch on the current table, proceed to the |
| 234003 | 234075 | ** next change. A log message has already been issued. */ |
| 234004 | 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; | |
| 234005 | 234080 | |
| 234006 | 234081 | rc = sessionApplyOneWithRetry(db, pIter, &sApply, xConflict, pCtx); |
| 234007 | 234082 | } |
| 234008 | 234083 | |
| 234009 | 234084 | bPatchset = pIter->bPatchset; |
| @@ -234067,10 +234142,91 @@ | ||
| 234067 | 234142 | db->aDb[0].pSchema->schema_cookie -= 32; |
| 234068 | 234143 | } |
| 234069 | 234144 | sqlite3_mutex_leave(sqlite3_db_mutex(db)); |
| 234070 | 234145 | return rc; |
| 234071 | 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 | +} | |
| 234072 | 234228 | |
| 234073 | 234229 | /* |
| 234074 | 234230 | ** Apply the changeset passed via pChangeset/nChangeset to the main |
| 234075 | 234231 | ** database attached to handle "db". |
| 234076 | 234232 | */ |
| @@ -234089,21 +234245,43 @@ | ||
| 234089 | 234245 | ), |
| 234090 | 234246 | void *pCtx, /* First argument passed to xConflict */ |
| 234091 | 234247 | void **ppRebase, int *pnRebase, |
| 234092 | 234248 | int flags |
| 234093 | 234249 | ){ |
| 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 | + ); | |
| 234105 | 234283 | } |
| 234106 | 234284 | |
| 234107 | 234285 | /* |
| 234108 | 234286 | ** Apply the changeset passed via pChangeset/nChangeset to the main database |
| 234109 | 234287 | ** attached to handle "db". Invoke the supplied conflict handler callback |
| @@ -234122,20 +234300,45 @@ | ||
| 234122 | 234300 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 234123 | 234301 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 234124 | 234302 | ), |
| 234125 | 234303 | void *pCtx /* First argument passed to xConflict */ |
| 234126 | 234304 | ){ |
| 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 | |
| 234129 | 234309 | ); |
| 234130 | 234310 | } |
| 234131 | 234311 | |
| 234132 | 234312 | /* |
| 234133 | 234313 | ** Apply the changeset passed via xInput/pIn to the main database |
| 234134 | 234314 | ** attached to handle "db". Invoke the supplied conflict handler callback |
| 234135 | 234315 | ** to resolve any conflicts encountered while applying the change. |
| 234136 | 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 | +} | |
| 234137 | 234340 | SQLITE_API int sqlite3changeset_apply_v2_strm( |
| 234138 | 234341 | sqlite3 *db, /* Apply change to "main" db of this handle */ |
| 234139 | 234342 | int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ |
| 234140 | 234343 | void *pIn, /* First arg for xInput */ |
| 234141 | 234344 | int(*xFilter)( |
| @@ -234149,19 +234352,15 @@ | ||
| 234149 | 234352 | ), |
| 234150 | 234353 | void *pCtx, /* First argument passed to xConflict */ |
| 234151 | 234354 | void **ppRebase, int *pnRebase, |
| 234152 | 234355 | int flags |
| 234153 | 234356 | ){ |
| 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 | + ); | |
| 234163 | 234362 | } |
| 234164 | 234363 | SQLITE_API int sqlite3changeset_apply_strm( |
| 234165 | 234364 | sqlite3 *db, /* Apply change to "main" db of this handle */ |
| 234166 | 234365 | int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */ |
| 234167 | 234366 | void *pIn, /* First arg for xInput */ |
| @@ -234174,12 +234373,14 @@ | ||
| 234174 | 234373 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 234175 | 234374 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 234176 | 234375 | ), |
| 234177 | 234376 | void *pCtx /* First argument passed to xConflict */ |
| 234178 | 234377 | ){ |
| 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 | |
| 234181 | 234382 | ); |
| 234182 | 234383 | } |
| 234183 | 234384 | |
| 234184 | 234385 | /* |
| 234185 | 234386 | ** sqlite3_changegroup handle. |
| @@ -246784,13 +246985,13 @@ | ||
| 246784 | 246985 | ** Allocate a tombstone hash page array object (pIter->pTombArray) for |
| 246785 | 246986 | ** the iterator passed as the second argument. If an OOM error occurs, |
| 246786 | 246987 | ** leave an error in the Fts5Index object. |
| 246787 | 246988 | */ |
| 246788 | 246989 | static void fts5SegIterAllocTombstone(Fts5Index *p, Fts5SegIter *pIter){ |
| 246789 | - const int nTomb = pIter->pSeg->nPgTombstone; | |
| 246990 | + const i64 nTomb = (i64)pIter->pSeg->nPgTombstone; | |
| 246790 | 246991 | if( nTomb>0 ){ |
| 246791 | - int nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1); | |
| 246992 | + i64 nByte = SZ_FTS5TOMBSTONEARRAY(nTomb+1); | |
| 246792 | 246993 | Fts5TombstoneArray *pNew; |
| 246793 | 246994 | pNew = (Fts5TombstoneArray*)sqlite3Fts5MallocZero(&p->rc, nByte); |
| 246794 | 246995 | if( pNew ){ |
| 246795 | 246996 | pNew->nTombstone = nTomb; |
| 246796 | 246997 | pNew->nRef = 1; |
| @@ -257912,11 +258113,11 @@ | ||
| 257912 | 258113 | int nArg, /* Number of args */ |
| 257913 | 258114 | sqlite3_value **apUnused /* Function arguments */ |
| 257914 | 258115 | ){ |
| 257915 | 258116 | assert( nArg==0 ); |
| 257916 | 258117 | 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); | |
| 257918 | 258119 | } |
| 257919 | 258120 | |
| 257920 | 258121 | /* |
| 257921 | 258122 | ** Implementation of fts5_locale(LOCALE, TEXT) function. |
| 257922 | 258123 | ** |
| 257923 | 258124 |
| --- extsrc/sqlite3.c | |
| +++ extsrc/sqlite3.c | |
| @@ -16,11 +16,11 @@ | |
| 16 | ** if you want a wrapper to interface SQLite with your choice of programming |
| 17 | ** language. The code for the "sqlite3" command-line shell is also in a |
| 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | ** |
| 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | ** 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 @@ | ||
| 146 | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | 148 | */ |
| 149 | 149 | #define SQLITE_VERSION "3.51.0" |
| 150 | 150 | #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" | |
| 152 | 152 | |
| 153 | 153 | /* |
| 154 | 154 | ** CAPI3REF: Run-Time Library Version Numbers |
| 155 | 155 | ** KEYWORDS: sqlite3_version sqlite3_sourceid |
| 156 | 156 | ** |
| @@ -12312,17 +12312,26 @@ | ||
| 12312 | 12312 | ** Apply a changeset or patchset to a database. These functions attempt to |
| 12313 | 12313 | ** update the "main" database attached to handle db with the changes found in |
| 12314 | 12314 | ** the changeset passed via the second and third arguments. |
| 12315 | 12315 | ** |
| 12316 | 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. | |
| 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. | |
| 12324 | 12333 | ** |
| 12325 | 12334 | ** For each table that is not excluded by the filter callback, this function |
| 12326 | 12335 | ** tests that the target database contains a compatible table. A table is |
| 12327 | 12336 | ** considered compatible if all of the following are true: |
| 12328 | 12337 | ** |
| @@ -12339,15 +12348,15 @@ | ||
| 12339 | 12348 | ** changes associated with the table are applied. A warning message is issued |
| 12340 | 12349 | ** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most |
| 12341 | 12350 | ** one such warning is issued for each table in the changeset. |
| 12342 | 12351 | ** |
| 12343 | 12352 | ** 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. | |
| 12349 | 12358 | ** |
| 12350 | 12359 | ** Unlike the xFilter argument, xConflict may not be passed NULL. The results |
| 12351 | 12360 | ** of passing anything other than a valid function pointer as the xConflict |
| 12352 | 12361 | ** argument are undefined. |
| 12353 | 12362 | ** |
| @@ -12485,10 +12494,27 @@ | ||
| 12485 | 12494 | void *pChangeset, /* Changeset blob */ |
| 12486 | 12495 | int(*xFilter)( |
| 12487 | 12496 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12488 | 12497 | const char *zTab /* Table name */ |
| 12489 | 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 | + ), | |
| 12490 | 12516 | int(*xConflict)( |
| 12491 | 12517 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12492 | 12518 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 12493 | 12519 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 12494 | 12520 | ), |
| @@ -12904,10 +12930,27 @@ | ||
| 12904 | 12930 | void *pIn, /* First arg for xInput */ |
| 12905 | 12931 | int(*xFilter)( |
| 12906 | 12932 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12907 | 12933 | const char *zTab /* Table name */ |
| 12908 | 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 | + ), | |
| 12909 | 12952 | int(*xConflict)( |
| 12910 | 12953 | void *pCtx, /* Copy of sixth arg to _apply() */ |
| 12911 | 12954 | int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */ |
| 12912 | 12955 | sqlite3_changeset_iter *p /* Handle describing change and conflict */ |
| 12913 | 12956 | ), |
| 12914 | 12957 |
| --- 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 |