erdbpro 2.4.5-beta.5 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.html +1 -1
- package/dist-server/index.js +1 -1
- package/dist-server/node_modules/better-sqlite3/build/Makefile +2 -2
- package/dist-server/node_modules/better-sqlite3/build/Release/.deps/4292fa9a667d77b27488aa109b010a85bce8e4e7a1c7aa0370cea902395c3866.intermediate.d +1 -1
- package/dist-server/node_modules/better-sqlite3/deps/download.sh +1 -1
- package/dist-server/node_modules/better-sqlite3/deps/sqlite3/sqlite3.c +176 -692
- package/dist-server/node_modules/better-sqlite3/deps/sqlite3/sqlite3.h +5 -17
- package/dist-server/node_modules/better-sqlite3/package.json +1 -1
- package/dist-server/node_modules/better-sqlite3/src/better_sqlite3.cpp +1 -1
- package/dist-server/node_modules/better-sqlite3/src/util/helpers.cpp +1 -1
- package/dist-server/node_modules/better-sqlite3/src/util/macros.cpp +1 -8
- package/package.json +6 -8
- package/dist/assets/index-Bmk-1vOU.js +0 -12701
- package/dist/assets/index-DJM3xl0X.js +0 -12701
- package/dist-server/node_modules/better-sqlite3/build/Release/.deps/Release/obj.target/better_sqlite3/src/better_sqlite3.o.d.raw +0 -82
- package/dist-server/node_modules/better-sqlite3/build/Release/.deps/Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o.d +0 -4
- package/dist-server/node_modules/better-sqlite3/build/Release/.deps/Release/sqlite3.a.d +0 -1
- package/dist-server/node_modules/better-sqlite3/build/Release/better_sqlite3.node +0 -0
- package/dist-server/node_modules/better-sqlite3/build/Release/obj.target/sqlite3/gen/sqlite3/sqlite3.o +0 -0
- package/dist-server/node_modules/better-sqlite3/build/Release/sqlite3.a +0 -0
- package/menubar/ERDBProTray.app/Contents/Info.plist +0 -20
- package/menubar/ERDBProTray.app/Contents/MacOS/ERDBProTray +0 -0
- package/menubar/ERDBProTray.swift +0 -129
- package/menubar/erdbpro-tray +0 -0
- package/menubar/icon.svg +0 -14
- package/menubar/launch.sh +0 -4
- package/menubar/tray.sh +0 -59
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/******************************************************************************
|
|
2
2
|
** This file is an amalgamation of many separate C source files from SQLite
|
|
3
|
-
** version 3.53.
|
|
3
|
+
** version 3.53.1. By combining all the individual C code files into this
|
|
4
4
|
** single large file, the entire code can be compiled as a single translation
|
|
5
5
|
** unit. This allows many compilers to do optimizations that would not be
|
|
6
6
|
** possible if the files were compiled separately. Performance improvements
|
|
@@ -18,7 +18,7 @@
|
|
|
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
|
-
**
|
|
21
|
+
** c88b22011a54b4f6fbd149e9f8e4de77658c with changes in files:
|
|
22
22
|
**
|
|
23
23
|
**
|
|
24
24
|
*/
|
|
@@ -468,12 +468,12 @@ extern "C" {
|
|
|
468
468
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
|
469
469
|
** [sqlite_version()] and [sqlite_source_id()].
|
|
470
470
|
*/
|
|
471
|
-
#define SQLITE_VERSION "3.53.
|
|
472
|
-
#define SQLITE_VERSION_NUMBER
|
|
473
|
-
#define SQLITE_SOURCE_ID "2026-
|
|
471
|
+
#define SQLITE_VERSION "3.53.1"
|
|
472
|
+
#define SQLITE_VERSION_NUMBER 3053001
|
|
473
|
+
#define SQLITE_SOURCE_ID "2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9"
|
|
474
474
|
#define SQLITE_SCM_BRANCH "branch-3.53"
|
|
475
|
-
#define SQLITE_SCM_TAGS "release version-3.53.
|
|
476
|
-
#define SQLITE_SCM_DATETIME "2026-
|
|
475
|
+
#define SQLITE_SCM_TAGS "release version-3.53.1"
|
|
476
|
+
#define SQLITE_SCM_DATETIME "2026-05-05T10:34:17.344Z"
|
|
477
477
|
|
|
478
478
|
/*
|
|
479
479
|
** CAPI3REF: Run-Time Library Version Numbers
|
|
@@ -13175,23 +13175,11 @@ SQLITE_API int sqlite3changeset_apply_v3(
|
|
|
13175
13175
|
** database behave as if they were declared with "ON UPDATE NO ACTION ON
|
|
13176
13176
|
** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
|
|
13177
13177
|
** or SET DEFAULT.
|
|
13178
|
-
**
|
|
13179
|
-
** <dt>SQLITE_CHANGESETAPPLY_NOUPDATELOOP <dd>
|
|
13180
|
-
** Sometimes, a changeset contains two or more update statements such that
|
|
13181
|
-
** although after applying all updates the database will contain no
|
|
13182
|
-
** constraint violations, no single update can be applied before the others.
|
|
13183
|
-
** The simplest example of this is a pair of UPDATEs that have "swapped"
|
|
13184
|
-
** two column values with a UNIQUE constraint.
|
|
13185
|
-
** <p>
|
|
13186
|
-
** Usually, sqlite3changeset_apply() and similar functions work hard to try
|
|
13187
|
-
** to find a way to apply such a changeset. However, if this flag is set,
|
|
13188
|
-
** then all such updates are considered CONSTRAINT conflicts.
|
|
13189
13178
|
*/
|
|
13190
13179
|
#define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
|
|
13191
13180
|
#define SQLITE_CHANGESETAPPLY_INVERT 0x0002
|
|
13192
13181
|
#define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
|
|
13193
13182
|
#define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
|
|
13194
|
-
#define SQLITE_CHANGESETAPPLY_NOUPDATELOOP 0x0010
|
|
13195
13183
|
|
|
13196
13184
|
/*
|
|
13197
13185
|
** CAPI3REF: Constants Passed To The Conflict Handler
|
|
@@ -22461,15 +22449,7 @@ SQLITE_PRIVATE void sqlite3AlterFunctions(void);
|
|
|
22461
22449
|
SQLITE_PRIVATE void sqlite3AlterRenameTable(Parse*, SrcList*, Token*);
|
|
22462
22450
|
SQLITE_PRIVATE void sqlite3AlterRenameColumn(Parse*, SrcList*, Token*, Token*);
|
|
22463
22451
|
SQLITE_PRIVATE void sqlite3AlterDropConstraint(Parse*,SrcList*,Token*,Token*);
|
|
22464
|
-
SQLITE_PRIVATE void sqlite3AlterAddConstraint(
|
|
22465
|
-
Parse *pParse, /* Parse context */
|
|
22466
|
-
SrcList *pSrc, /* Table to add constraint to */
|
|
22467
|
-
Token *pFirst, /* First token of new constraint */
|
|
22468
|
-
Token *pName, /* Name of new constraint. NULL if name omitted. */
|
|
22469
|
-
const char *zExpr, /* Text of CHECK expression */
|
|
22470
|
-
int nExpr, /* Size of pExpr in bytes */
|
|
22471
|
-
Expr *pExpr /* The parsed CHECK expression */
|
|
22472
|
-
);
|
|
22452
|
+
SQLITE_PRIVATE void sqlite3AlterAddConstraint(Parse*,SrcList*,Token*,Token*,const char*,int);
|
|
22473
22453
|
SQLITE_PRIVATE void sqlite3AlterSetNotNull(Parse*, SrcList*, Token*, Token*);
|
|
22474
22454
|
SQLITE_PRIVATE i64 sqlite3GetToken(const unsigned char *, int *);
|
|
22475
22455
|
SQLITE_PRIVATE void sqlite3NestedParse(Parse*, const char*, ...);
|
|
@@ -33278,8 +33258,8 @@ SQLITE_API void sqlite3_str_vappendf(
|
|
|
33278
33258
|
** all control characters, and for backslash itself.
|
|
33279
33259
|
** For %#Q, do the same but only if there is at least
|
|
33280
33260
|
** one control character. */
|
|
33281
|
-
|
|
33282
|
-
|
|
33261
|
+
u32 nBack = 0;
|
|
33262
|
+
u32 nCtrl = 0;
|
|
33283
33263
|
for(k=0; k<i; k++){
|
|
33284
33264
|
if( escarg[k]=='\\' ){
|
|
33285
33265
|
nBack++;
|
|
@@ -45328,9 +45308,9 @@ static int unixShmMap(
|
|
|
45328
45308
|
nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap;
|
|
45329
45309
|
|
|
45330
45310
|
if( pShmNode->nRegion<nReqRegion ){
|
|
45331
|
-
char **apNew;
|
|
45332
|
-
|
|
45333
|
-
struct stat sStat;
|
|
45311
|
+
char **apNew; /* New apRegion[] array */
|
|
45312
|
+
int nByte = nReqRegion*szRegion; /* Minimum required file size */
|
|
45313
|
+
struct stat sStat; /* Used by fstat() */
|
|
45334
45314
|
|
|
45335
45315
|
pShmNode->szRegion = szRegion;
|
|
45336
45316
|
|
|
@@ -45361,7 +45341,7 @@ static int unixShmMap(
|
|
|
45361
45341
|
*/
|
|
45362
45342
|
else{
|
|
45363
45343
|
static const int pgsz = 4096;
|
|
45364
|
-
|
|
45344
|
+
int iPg;
|
|
45365
45345
|
|
|
45366
45346
|
/* Write to the last byte of each newly allocated or extended page */
|
|
45367
45347
|
assert( (nByte % pgsz)==0 );
|
|
@@ -45387,8 +45367,8 @@ static int unixShmMap(
|
|
|
45387
45367
|
}
|
|
45388
45368
|
pShmNode->apRegion = apNew;
|
|
45389
45369
|
while( pShmNode->nRegion<nReqRegion ){
|
|
45390
|
-
|
|
45391
|
-
|
|
45370
|
+
int nMap = szRegion*nShmPerMap;
|
|
45371
|
+
int i;
|
|
45392
45372
|
void *pMem;
|
|
45393
45373
|
if( pShmNode->hShm>=0 ){
|
|
45394
45374
|
pMem = osMmap(0, nMap,
|
|
@@ -53362,7 +53342,7 @@ static int winShmMap(
|
|
|
53362
53342
|
if( pShmNode->nRegion<=iRegion ){
|
|
53363
53343
|
HANDLE hShared = pShmNode->hSharedShm;
|
|
53364
53344
|
struct ShmRegion *apNew; /* New aRegion[] array */
|
|
53365
|
-
|
|
53345
|
+
int nByte = (iRegion+1)*szRegion; /* Minimum required file size */
|
|
53366
53346
|
sqlite3_int64 sz; /* Current size of wal-index file */
|
|
53367
53347
|
|
|
53368
53348
|
pShmNode->szRegion = szRegion;
|
|
@@ -53393,7 +53373,7 @@ static int winShmMap(
|
|
|
53393
53373
|
|
|
53394
53374
|
/* Map the requested memory region into this processes address space. */
|
|
53395
53375
|
apNew = (struct ShmRegion*)sqlite3_realloc64(
|
|
53396
|
-
pShmNode->aRegion, (
|
|
53376
|
+
pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
|
|
53397
53377
|
);
|
|
53398
53378
|
if( !apNew ){
|
|
53399
53379
|
rc = SQLITE_IOERR_NOMEM_BKPT;
|
|
@@ -53415,14 +53395,15 @@ static int winShmMap(
|
|
|
53415
53395
|
#elif defined(SQLITE_WIN32_HAS_ANSI) && SQLITE_WIN32_CREATEFILEMAPPINGA
|
|
53416
53396
|
hMap = osCreateFileMappingA(hShared, NULL, protect, 0, nByte, NULL);
|
|
53417
53397
|
#endif
|
|
53418
|
-
|
|
53398
|
+
|
|
53399
|
+
OSTRACE(("SHM-MAP-CREATE pid=%lu, region=%d, size=%d, rc=%s\n",
|
|
53419
53400
|
osGetCurrentProcessId(), pShmNode->nRegion, nByte,
|
|
53420
53401
|
hMap ? "ok" : "failed"));
|
|
53421
53402
|
if( hMap ){
|
|
53422
|
-
|
|
53403
|
+
int iOffset = pShmNode->nRegion*szRegion;
|
|
53423
53404
|
int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
|
|
53424
53405
|
pMap = osMapViewOfFile(hMap, flags,
|
|
53425
|
-
0, iOffset - iOffsetShift,
|
|
53406
|
+
0, iOffset - iOffsetShift, szRegion + iOffsetShift
|
|
53426
53407
|
);
|
|
53427
53408
|
OSTRACE(("SHM-MAP-MAP pid=%lu, region=%d, offset=%d, size=%d, rc=%s\n",
|
|
53428
53409
|
osGetCurrentProcessId(), pShmNode->nRegion, iOffset,
|
|
@@ -53444,7 +53425,7 @@ static int winShmMap(
|
|
|
53444
53425
|
|
|
53445
53426
|
shmpage_out:
|
|
53446
53427
|
if( pShmNode->nRegion>iRegion ){
|
|
53447
|
-
|
|
53428
|
+
int iOffset = iRegion*szRegion;
|
|
53448
53429
|
int iOffsetShift = iOffset % winSysInfo.dwAllocationGranularity;
|
|
53449
53430
|
char *p = (char *)pShmNode->aRegion[iRegion].pMap;
|
|
53450
53431
|
*pp = (void *)&p[iOffsetShift];
|
|
@@ -62172,7 +62153,7 @@ static int pager_delsuper(Pager *pPager, const char *zSuper){
|
|
|
62172
62153
|
if( rc!=SQLITE_OK ) goto delsuper_out;
|
|
62173
62154
|
nSuperPtr = 1 + (i64)pVfs->mxPathname;
|
|
62174
62155
|
assert( nSuperJournal>=0 && nSuperPtr>0 );
|
|
62175
|
-
zFree = sqlite3Malloc(4 + nSuperJournal +
|
|
62156
|
+
zFree = sqlite3Malloc(4 + nSuperJournal + nSuperPtr + 2);
|
|
62176
62157
|
if( !zFree ){
|
|
62177
62158
|
rc = SQLITE_NOMEM_BKPT;
|
|
62178
62159
|
goto delsuper_out;
|
|
@@ -62433,10 +62414,10 @@ static int pager_playback(Pager *pPager, int isHot){
|
|
|
62433
62414
|
**
|
|
62434
62415
|
** TODO: Technically the following is an error because it assumes that
|
|
62435
62416
|
** buffer Pager.pTmpSpace is (mxPathname+1) bytes or larger. i.e. that
|
|
62436
|
-
** (
|
|
62417
|
+
** (pPager->pageSize >= pPager->pVfs->mxPathname+1). Using os_unix.c,
|
|
62437
62418
|
** mxPathname is 512, which is the same as the minimum allowable value
|
|
62438
|
-
** for pageSize
|
|
62439
|
-
|
|
62419
|
+
** for pageSize.
|
|
62420
|
+
*/
|
|
62440
62421
|
zSuper = pPager->pTmpSpace;
|
|
62441
62422
|
rc = readSuperJournal(pPager->jfd, zSuper, 1+(i64)pPager->pVfs->mxPathname);
|
|
62442
62423
|
if( rc==SQLITE_OK && zSuper[0] ){
|
|
@@ -78326,9 +78307,7 @@ static int accessPayload(
|
|
|
78326
78307
|
** means "not yet known" (the cache is lazily populated).
|
|
78327
78308
|
*/
|
|
78328
78309
|
if( (pCur->curFlags & BTCF_ValidOvfl)==0 ){
|
|
78329
|
-
|
|
78330
|
-
testcase( nOvfl - pCur->info.nLocal + ovflSize - 1 > 0xffffffffU );
|
|
78331
|
-
nOvfl = (nOvfl - pCur->info.nLocal + ovflSize-1)/ovflSize;
|
|
78310
|
+
int nOvfl = (pCur->info.nPayload-pCur->info.nLocal+ovflSize-1)/ovflSize;
|
|
78332
78311
|
if( pCur->aOverflow==0
|
|
78333
78312
|
|| nOvfl*(int)sizeof(Pgno) > sqlite3MallocSize(pCur->aOverflow)
|
|
78334
78313
|
){
|
|
@@ -78433,12 +78412,6 @@ static int accessPayload(
|
|
|
78433
78412
|
(eOp==0 ? PAGER_GET_READONLY : 0)
|
|
78434
78413
|
);
|
|
78435
78414
|
if( rc==SQLITE_OK ){
|
|
78436
|
-
if( eOp!=0
|
|
78437
|
-
&& (sqlite3PagerPageRefcount(pDbPage)!=1
|
|
78438
|
-
|| NEVER(((MemPage*)sqlite3PagerGetExtra(pDbPage))->isInit)) ){
|
|
78439
|
-
sqlite3PagerUnref(pDbPage);
|
|
78440
|
-
return SQLITE_CORRUPT_PAGE(pPage);
|
|
78441
|
-
}
|
|
78442
78415
|
aPayload = sqlite3PagerGetData(pDbPage);
|
|
78443
78416
|
nextPage = get4byte(aPayload);
|
|
78444
78417
|
rc = copyPayload(&aPayload[offset+4], pBuf, a, eOp, pDbPage);
|
|
@@ -111127,7 +111100,6 @@ static int lookupName(
|
|
|
111127
111100
|
pExpr->op = TK_FUNCTION;
|
|
111128
111101
|
pExpr->u.zToken = "coalesce";
|
|
111129
111102
|
pExpr->x.pList = pFJMatch;
|
|
111130
|
-
pExpr->affExpr = SQLITE_AFF_DEFER;
|
|
111131
111103
|
cnt = 1;
|
|
111132
111104
|
goto lookupname_end;
|
|
111133
111105
|
}else{
|
|
@@ -111296,26 +111268,6 @@ static int exprProbability(Expr *p){
|
|
|
111296
111268
|
return (int)(r*134217728.0);
|
|
111297
111269
|
}
|
|
111298
111270
|
|
|
111299
|
-
/*
|
|
111300
|
-
** Set the EP_SubtArg property on every expression inside of
|
|
111301
|
-
** pList. If any subexpression is actually a subquery, then
|
|
111302
|
-
** also set the EP_SubtArg property on the first result-set
|
|
111303
|
-
** column of that subquery.
|
|
111304
|
-
*/
|
|
111305
|
-
static SQLITE_NOINLINE void resolveSetExprSubtypeArg(ExprList *pList){
|
|
111306
|
-
int nn, ii;
|
|
111307
|
-
nn = pList ? pList->nExpr : 0;
|
|
111308
|
-
for(ii=0; ii<nn; ii++){
|
|
111309
|
-
Expr *pExpr = pList->a[ii].pExpr;
|
|
111310
|
-
ExprSetProperty(pExpr, EP_SubtArg);
|
|
111311
|
-
if( pExpr->op==TK_SELECT ){
|
|
111312
|
-
assert( ExprUseXSelect(pExpr) );
|
|
111313
|
-
assert( pExpr->x.pSelect!=0 );
|
|
111314
|
-
resolveSetExprSubtypeArg(pExpr->x.pSelect->pEList);
|
|
111315
|
-
}
|
|
111316
|
-
}
|
|
111317
|
-
}
|
|
111318
|
-
|
|
111319
111271
|
/*
|
|
111320
111272
|
** This routine is callback for sqlite3WalkExpr().
|
|
111321
111273
|
**
|
|
@@ -111560,7 +111512,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){
|
|
|
111560
111512
|
if( (pDef->funcFlags & SQLITE_SUBTYPE)
|
|
111561
111513
|
|| ExprHasProperty(pExpr, EP_SubtArg)
|
|
111562
111514
|
){
|
|
111563
|
-
|
|
111515
|
+
int ii;
|
|
111516
|
+
for(ii=0; ii<n; ii++){
|
|
111517
|
+
ExprSetProperty(pList->a[ii].pExpr, EP_SubtArg);
|
|
111518
|
+
}
|
|
111564
111519
|
}
|
|
111565
111520
|
|
|
111566
111521
|
if( pDef->funcFlags & (SQLITE_FUNC_CONSTANT|SQLITE_FUNC_SLOCHNG) ){
|
|
@@ -116955,16 +116910,7 @@ static void sqlite3ExprCodeIN(
|
|
|
116955
116910
|
CollSeq *pColl;
|
|
116956
116911
|
int r3 = sqlite3GetTempReg(pParse);
|
|
116957
116912
|
p = sqlite3VectorFieldSubexpr(pLeft, i);
|
|
116958
|
-
|
|
116959
|
-
Expr *pRhs = pExpr->x.pSelect->pEList->a[i].pExpr;
|
|
116960
|
-
pColl = sqlite3BinaryCompareCollSeq(pParse, p, pRhs);
|
|
116961
|
-
}else{
|
|
116962
|
-
/* If the RHS of the IN(...) expression are scalar expressions, do
|
|
116963
|
-
** not consider their collation sequences. The documentation says
|
|
116964
|
-
** "The collating sequence used for expressions of the form "x IN (y, z,
|
|
116965
|
-
** ...)" is the collating sequence of x.". */
|
|
116966
|
-
pColl = sqlite3ExprCollSeq(pParse, p);
|
|
116967
|
-
}
|
|
116913
|
+
pColl = sqlite3ExprCollSeq(pParse, p);
|
|
116968
116914
|
sqlite3VdbeAddOp3(v, OP_Column, iTab, i, r3);
|
|
116969
116915
|
sqlite3VdbeAddOp4(v, OP_Ne, rLhs+i, destNotNull, r3,
|
|
116970
116916
|
(void*)pColl, P4_COLLSEQ);
|
|
@@ -117387,37 +117333,26 @@ static int exprCodeInlineFunction(
|
|
|
117387
117333
|
}
|
|
117388
117334
|
|
|
117389
117335
|
/*
|
|
117390
|
-
** Expression Node callback for sqlite3ExprCanReturnSubtype().
|
|
117391
|
-
** pExpr is able to return a subtype, set pWalker->eCode and abort
|
|
117392
|
-
** the search. If pExpr can never return a subtype, prune search.
|
|
117393
|
-
**
|
|
117394
|
-
** The only expressions that can return a subtype are:
|
|
117395
|
-
**
|
|
117396
|
-
** 1. A function
|
|
117397
|
-
** 2. The no-op "+" operator
|
|
117398
|
-
** 3. A CASE...END expression
|
|
117399
|
-
** 4. A CAST() expression
|
|
117400
|
-
** 5. A "expr COLLATE colseq" expression.
|
|
117336
|
+
** Expression Node callback for sqlite3ExprCanReturnSubtype().
|
|
117401
117337
|
**
|
|
117402
|
-
**
|
|
117338
|
+
** Only a function call is able to return a subtype. So if the node
|
|
117339
|
+
** is not a function call, return WRC_Prune immediately.
|
|
117403
117340
|
**
|
|
117404
|
-
**
|
|
117405
|
-
**
|
|
117406
|
-
** a subtype (via sqlite3_result_value()) if any of the arguments can
|
|
117407
|
-
** return a subtype.
|
|
117341
|
+
** A function call is able to return a subtype if it has the
|
|
117342
|
+
** SQLITE_RESULT_SUBTYPE property.
|
|
117408
117343
|
**
|
|
117409
|
-
**
|
|
117410
|
-
**
|
|
117344
|
+
** Assume that every function is able to pass-through a subtype from
|
|
117345
|
+
** one of its argument (using sqlite3_result_value()). Most functions
|
|
117346
|
+
** are not this way, but we don't have a mechanism to distinguish those
|
|
117347
|
+
** that are from those that are not, so assume they all work this way.
|
|
117348
|
+
** That means that if one of its arguments is another function and that
|
|
117349
|
+
** other function is able to return a subtype, then this function is
|
|
117350
|
+
** able to return a subtype.
|
|
117411
117351
|
*/
|
|
117412
117352
|
static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){
|
|
117413
117353
|
int n;
|
|
117414
117354
|
FuncDef *pDef;
|
|
117415
117355
|
sqlite3 *db;
|
|
117416
|
-
if( pExpr->op==TK_CASE || pExpr->op==TK_UPLUS
|
|
117417
|
-
|| pExpr->op==TK_COLLATE || pExpr->op==TK_CAST
|
|
117418
|
-
){
|
|
117419
|
-
return WRC_Continue;
|
|
117420
|
-
}
|
|
117421
117356
|
if( pExpr->op!=TK_FUNCTION ){
|
|
117422
117357
|
return WRC_Prune;
|
|
117423
117358
|
}
|
|
@@ -117427,7 +117362,7 @@ static int exprNodeCanReturnSubtype(Walker *pWalker, Expr *pExpr){
|
|
|
117427
117362
|
pDef = sqlite3FindFunction(db, pExpr->u.zToken, n, ENC(db), 0);
|
|
117428
117363
|
if( NEVER(pDef==0) || (pDef->funcFlags & SQLITE_RESULT_SUBTYPE)!=0 ){
|
|
117429
117364
|
pWalker->eCode = 1;
|
|
117430
|
-
return
|
|
117365
|
+
return WRC_Prune;
|
|
117431
117366
|
}
|
|
117432
117367
|
return WRC_Continue;
|
|
117433
117368
|
}
|
|
@@ -123405,31 +123340,19 @@ SQLITE_PRIVATE void sqlite3AlterAddConstraint(
|
|
|
123405
123340
|
SrcList *pSrc, /* Table to add constraint to */
|
|
123406
123341
|
Token *pFirst, /* First token of new constraint */
|
|
123407
123342
|
Token *pName, /* Name of new constraint. NULL if name omitted. */
|
|
123408
|
-
const char *
|
|
123409
|
-
int nExpr
|
|
123410
|
-
Expr *pExpr /* The parsed CHECK expression */
|
|
123343
|
+
const char *pExpr, /* Text of CHECK expression */
|
|
123344
|
+
int nExpr /* Size of pExpr in bytes */
|
|
123411
123345
|
){
|
|
123412
123346
|
Table *pTab = 0; /* Table identified by pSrc */
|
|
123413
123347
|
int iDb = 0; /* Which schema does pTab live in */
|
|
123414
123348
|
const char *zDb = 0; /* Name of the schema in which pTab lives */
|
|
123415
123349
|
const char *pCons = 0; /* Text of the constraint */
|
|
123416
123350
|
int nCons; /* Bytes of text to use from pCons[] */
|
|
123417
|
-
int rc; /* Result from error checking pExpr */
|
|
123418
123351
|
|
|
123419
123352
|
/* Look up the table being altered. */
|
|
123420
123353
|
assert( pSrc->nSrc==1 );
|
|
123421
123354
|
pTab = alterFindTable(pParse, pSrc, &iDb, &zDb, 1);
|
|
123422
|
-
if( !pTab )
|
|
123423
|
-
sqlite3ExprDelete(pParse->db, pExpr);
|
|
123424
|
-
return;
|
|
123425
|
-
}
|
|
123426
|
-
|
|
123427
|
-
/* Verify that the new CHECK constraint does not contain any
|
|
123428
|
-
** internal-use-only function. Forum post 2026-05-10T01:11:28Z
|
|
123429
|
-
*/
|
|
123430
|
-
rc = sqlite3ResolveSelfReference(pParse, pTab, NC_IsCheck, pExpr, 0);
|
|
123431
|
-
sqlite3ExprDelete(pParse->db, pExpr);
|
|
123432
|
-
if( rc ) return;
|
|
123355
|
+
if( !pTab ) return;
|
|
123433
123356
|
|
|
123434
123357
|
/* If this new constraint has a name, check that it is not a duplicate of
|
|
123435
123358
|
** an existing constraint. It is an error if it is. */
|
|
@@ -123450,7 +123373,7 @@ SQLITE_PRIVATE void sqlite3AlterAddConstraint(
|
|
|
123450
123373
|
sqlite3NestedParse(pParse,
|
|
123451
123374
|
"SELECT sqlite_fail('constraint failed', %d) "
|
|
123452
123375
|
"FROM %Q.%Q WHERE (%.*s) IS NOT TRUE",
|
|
123453
|
-
SQLITE_CONSTRAINT, zDb, pTab->zName, nExpr,
|
|
123376
|
+
SQLITE_CONSTRAINT, zDb, pTab->zName, nExpr, pExpr
|
|
123454
123377
|
);
|
|
123455
123378
|
|
|
123456
123379
|
/* Edit the SQL for the named table. */
|
|
@@ -134127,18 +134050,9 @@ static void printfFunc(
|
|
|
134127
134050
|
sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
|
|
134128
134051
|
str.printfFlags = SQLITE_PRINTF_SQLFUNC;
|
|
134129
134052
|
sqlite3_str_appendf(&str, zFormat, &x);
|
|
134130
|
-
|
|
134131
|
-
|
|
134132
|
-
|
|
134133
|
-
SQLITE_DYNAMIC);
|
|
134134
|
-
}else{
|
|
134135
|
-
if( str.accError==SQLITE_NOMEM ){
|
|
134136
|
-
sqlite3_result_error_nomem(context);
|
|
134137
|
-
}else{
|
|
134138
|
-
sqlite3_result_error_toobig(context);
|
|
134139
|
-
}
|
|
134140
|
-
sqlite3_str_reset(&str);
|
|
134141
|
-
}
|
|
134053
|
+
n = str.nChar;
|
|
134054
|
+
sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
|
|
134055
|
+
SQLITE_DYNAMIC);
|
|
134142
134056
|
}
|
|
134143
134057
|
}
|
|
134144
134058
|
|
|
@@ -135776,16 +135690,11 @@ static void sumInverse(sqlite3_context *context, int argc, sqlite3_value**argv){
|
|
|
135776
135690
|
assert( p->cnt>0 );
|
|
135777
135691
|
p->cnt--;
|
|
135778
135692
|
if( !p->approx ){
|
|
135779
|
-
|
|
135780
|
-
|
|
135781
|
-
p->
|
|
135782
|
-
return;
|
|
135693
|
+
if( sqlite3SubInt64(&p->iSum, sqlite3_value_int64(argv[0])) ){
|
|
135694
|
+
p->ovrfl = 1;
|
|
135695
|
+
p->approx = 1;
|
|
135783
135696
|
}
|
|
135784
|
-
|
|
135785
|
-
p->approx = 1;
|
|
135786
|
-
kahanBabuskaNeumaierInit(p, p->iSum);
|
|
135787
|
-
}
|
|
135788
|
-
if( type==SQLITE_INTEGER ){
|
|
135697
|
+
}else if( type==SQLITE_INTEGER ){
|
|
135789
135698
|
i64 iVal = sqlite3_value_int64(argv[0]);
|
|
135790
135699
|
if( iVal!=SMALLEST_INT64 ){
|
|
135791
135700
|
kahanBabuskaNeumaierStepInt64(p, -iVal);
|
|
@@ -136758,46 +136667,47 @@ static void percentSort(double *a, unsigned int n){
|
|
|
136758
136667
|
int i; /* Loop counter */
|
|
136759
136668
|
double rPivot; /* The pivot value */
|
|
136760
136669
|
|
|
136761
|
-
|
|
136762
|
-
|
|
136763
|
-
|
|
136764
|
-
|
|
136765
|
-
|
|
136766
|
-
|
|
136767
|
-
|
|
136768
|
-
|
|
136769
|
-
|
|
136770
|
-
|
|
136670
|
+
assert( n>=2 );
|
|
136671
|
+
if( a[0]>a[n-1] ){
|
|
136672
|
+
SWAP_DOUBLE(a[0],a[n-1])
|
|
136673
|
+
}
|
|
136674
|
+
if( n==2 ) return;
|
|
136675
|
+
iGt = n-1;
|
|
136676
|
+
i = n/2;
|
|
136677
|
+
if( a[0]>a[i] ){
|
|
136678
|
+
SWAP_DOUBLE(a[0],a[i])
|
|
136679
|
+
}else if( a[i]>a[iGt] ){
|
|
136680
|
+
SWAP_DOUBLE(a[i],a[iGt])
|
|
136681
|
+
}
|
|
136682
|
+
if( n==3 ) return;
|
|
136683
|
+
rPivot = a[i];
|
|
136684
|
+
iLt = i = 1;
|
|
136685
|
+
do{
|
|
136686
|
+
if( a[i]<rPivot ){
|
|
136687
|
+
if( i>iLt ) SWAP_DOUBLE(a[i],a[iLt])
|
|
136688
|
+
iLt++;
|
|
136689
|
+
i++;
|
|
136690
|
+
}else if( a[i]>rPivot ){
|
|
136691
|
+
do{
|
|
136692
|
+
iGt--;
|
|
136693
|
+
}while( iGt>i && a[iGt]>rPivot );
|
|
136771
136694
|
SWAP_DOUBLE(a[i],a[iGt])
|
|
136772
|
-
}
|
|
136773
|
-
if( n==3 ) return;
|
|
136774
|
-
rPivot = a[i];
|
|
136775
|
-
iLt = i = 1;
|
|
136776
|
-
do{
|
|
136777
|
-
if( a[i]<rPivot ){
|
|
136778
|
-
if( i>iLt ) SWAP_DOUBLE(a[i],a[iLt])
|
|
136779
|
-
iLt++;
|
|
136780
|
-
i++;
|
|
136781
|
-
}else if( a[i]>rPivot ){
|
|
136782
|
-
do{
|
|
136783
|
-
iGt--;
|
|
136784
|
-
}while( iGt>i && a[iGt]>rPivot );
|
|
136785
|
-
SWAP_DOUBLE(a[i],a[iGt])
|
|
136786
|
-
}else{
|
|
136787
|
-
i++;
|
|
136788
|
-
}
|
|
136789
|
-
}while( i<iGt );
|
|
136790
|
-
if( iLt>n/2 ){
|
|
136791
|
-
if( n-iGt>=2 ) percentSort(a+iGt, n-iGt);
|
|
136792
|
-
n = iLt;
|
|
136793
136695
|
}else{
|
|
136794
|
-
|
|
136795
|
-
a += iGt;
|
|
136796
|
-
n -= iGt;
|
|
136696
|
+
i++;
|
|
136797
136697
|
}
|
|
136698
|
+
}while( i<iGt );
|
|
136699
|
+
if( iLt>=2 ) percentSort(a, iLt);
|
|
136700
|
+
if( n-iGt>=2 ) percentSort(a+iGt, n-iGt);
|
|
136701
|
+
|
|
136702
|
+
/* Uncomment for testing */
|
|
136703
|
+
#if 0
|
|
136704
|
+
for(i=0; i<n-1; i++){
|
|
136705
|
+
assert( a[i]<=a[i+1] );
|
|
136798
136706
|
}
|
|
136707
|
+
#endif
|
|
136799
136708
|
}
|
|
136800
136709
|
|
|
136710
|
+
|
|
136801
136711
|
/*
|
|
136802
136712
|
** The "inverse" function for percentile(Y,P) is called to remove a
|
|
136803
136713
|
** row that was previously inserted by "step".
|
|
@@ -156295,11 +156205,8 @@ static int selectCheckOnClausesExpr(Walker *pWalker, Expr *pExpr){
|
|
|
156295
156205
|
** does not refer to a table to the right of CheckOnCtx.iJoin. */
|
|
156296
156206
|
do {
|
|
156297
156207
|
SrcList *pSrc = pCtx->pSrc;
|
|
156298
|
-
int nSrc = pSrc->nSrc;
|
|
156299
156208
|
int iTab = pExpr->iTable;
|
|
156300
|
-
|
|
156301
|
-
for(ii=0; ii<nSrc && pSrc->a[ii].iCursor!=iTab; ii++){}
|
|
156302
|
-
if( ii<nSrc ){
|
|
156209
|
+
if( iTab>=pSrc->a[0].iCursor && iTab<=pSrc->a[pSrc->nSrc-1].iCursor ){
|
|
156303
156210
|
if( pCtx->iJoin && iTab>pCtx->iJoin ){
|
|
156304
156211
|
sqlite3ErrorMsg(pWalker->pParse,
|
|
156305
156212
|
"%s references tables to its right",
|
|
@@ -166499,7 +166406,6 @@ SQLITE_PRIVATE Bitmask sqlite3WhereCodeOneLoopStart(
|
|
|
166499
166406
|
WO_EQ|WO_IN|WO_IS, 0);
|
|
166500
166407
|
if( pAlt==0 ) continue;
|
|
166501
166408
|
if( pAlt->wtFlags & (TERM_CODED) ) continue;
|
|
166502
|
-
if( ExprHasProperty(pAlt->pExpr, EP_Collate) ) continue;
|
|
166503
166409
|
if( (pAlt->eOperator & WO_IN)
|
|
166504
166410
|
&& ExprUseXSelect(pAlt->pExpr)
|
|
166505
166411
|
&& (pAlt->pExpr->x.pSelect->pEList->nExpr>1)
|
|
@@ -167692,8 +167598,8 @@ static void exprAnalyzeOrTerm(
|
|
|
167692
167598
|
** 3. Not originating in the ON clause of an OUTER JOIN
|
|
167693
167599
|
** 4. The operator is not IS or else the query does not contain RIGHT JOIN
|
|
167694
167600
|
** 5. The affinities of A and B must be compatible
|
|
167695
|
-
**
|
|
167696
|
-
**
|
|
167601
|
+
** 6a. Both operands use the same collating sequence OR
|
|
167602
|
+
** 6b. The overall collating sequence is BINARY
|
|
167697
167603
|
** If this routine returns TRUE, that means that the RHS can be substituted
|
|
167698
167604
|
** for the LHS anyplace else in the WHERE clause where the LHS column occurs.
|
|
167699
167605
|
** This is an optimization. No harm comes from returning 0. But if 1 is
|
|
@@ -167701,9 +167607,10 @@ static void exprAnalyzeOrTerm(
|
|
|
167701
167607
|
*/
|
|
167702
167608
|
static int termIsEquivalence(Parse *pParse, Expr *pExpr, SrcList *pSrc){
|
|
167703
167609
|
char aff1, aff2;
|
|
167610
|
+
CollSeq *pColl;
|
|
167704
167611
|
if( !OptimizationEnabled(pParse->db, SQLITE_Transitive) ) return 0; /* (1) */
|
|
167705
167612
|
if( pExpr->op!=TK_EQ && pExpr->op!=TK_IS ) return 0; /* (2) */
|
|
167706
|
-
if( ExprHasProperty(pExpr, EP_OuterON
|
|
167613
|
+
if( ExprHasProperty(pExpr, EP_OuterON) ) return 0; /* (3) */
|
|
167707
167614
|
assert( pSrc!=0 );
|
|
167708
167615
|
if( pExpr->op==TK_IS
|
|
167709
167616
|
&& pSrc->nSrc>=2
|
|
@@ -167718,7 +167625,10 @@ static int termIsEquivalence(Parse *pParse, Expr *pExpr, SrcList *pSrc){
|
|
|
167718
167625
|
){
|
|
167719
167626
|
return 0; /* (5) */
|
|
167720
167627
|
}
|
|
167721
|
-
|
|
167628
|
+
pColl = sqlite3ExprCompareCollSeq(pParse, pExpr);
|
|
167629
|
+
if( !sqlite3IsBinary(pColl)
|
|
167630
|
+
&& !sqlite3ExprCollSeqMatch(pParse, pExpr->pLeft, pExpr->pRight)
|
|
167631
|
+
){
|
|
167722
167632
|
return 0; /* (6) */
|
|
167723
167633
|
}
|
|
167724
167634
|
return 1;
|
|
@@ -168050,7 +167960,7 @@ static void exprAnalyze(
|
|
|
168050
167960
|
/* Analyze a term that is composed of two or more subterms connected by
|
|
168051
167961
|
** an OR operator.
|
|
168052
167962
|
*/
|
|
168053
|
-
else if( pExpr->op==TK_OR
|
|
167963
|
+
else if( pExpr->op==TK_OR ){
|
|
168054
167964
|
assert( pWC->op==TK_AND );
|
|
168055
167965
|
exprAnalyzeOrTerm(pSrc, pWC, idxTerm);
|
|
168056
167966
|
pTerm = &pWC->a[idxTerm];
|
|
@@ -171868,8 +171778,7 @@ static int whereRangeVectorLen(
|
|
|
171868
171778
|
idxaff = sqlite3TableColumnAffinity(pIdx->pTable, pLhs->iColumn);
|
|
171869
171779
|
if( aff!=idxaff ) break;
|
|
171870
171780
|
|
|
171871
|
-
|
|
171872
|
-
pColl = sqlite3BinaryCompareCollSeq(pParse, pLhs, pRhs);
|
|
171781
|
+
pColl = sqlite3ExprCompareCollSeq(pParse, pTerm->pExpr);
|
|
171873
171782
|
if( pColl==0 ) break;
|
|
171874
171783
|
if( sqlite3StrICmp(pColl->zName, pIdx->azColl[i+nEq]) ) break;
|
|
171875
171784
|
}
|
|
@@ -184361,11 +184270,9 @@ static YYACTIONTYPE yy_reduce(
|
|
|
184361
184270
|
ExprList *pList = sqlite3ExprListAppend(pParse, yymsp[-3].minor.yy14, yymsp[-1].minor.yy454);
|
|
184362
184271
|
yymsp[-4].minor.yy454 = sqlite3PExpr(pParse, TK_VECTOR, 0, 0);
|
|
184363
184272
|
if( yymsp[-4].minor.yy454 ){
|
|
184364
|
-
int i;
|
|
184365
184273
|
yymsp[-4].minor.yy454->x.pList = pList;
|
|
184366
|
-
|
|
184367
|
-
|
|
184368
|
-
yymsp[-4].minor.yy454->flags |= pList->a[i].pExpr->flags & EP_Propagate;
|
|
184274
|
+
if( ALWAYS(pList->nExpr) ){
|
|
184275
|
+
yymsp[-4].minor.yy454->flags |= pList->a[0].pExpr->flags & EP_Propagate;
|
|
184369
184276
|
}
|
|
184370
184277
|
}else{
|
|
184371
184278
|
sqlite3ExprListDelete(pParse->db, pList);
|
|
@@ -184833,13 +184740,15 @@ static YYACTIONTYPE yy_reduce(
|
|
|
184833
184740
|
break;
|
|
184834
184741
|
case 300: /* cmd ::= ALTER TABLE fullname ADD CONSTRAINT nm CHECK LP expr RP onconf */
|
|
184835
184742
|
{
|
|
184836
|
-
sqlite3AlterAddConstraint(pParse, yymsp[-8].minor.yy203, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy0.z+1, (yymsp[-1].minor.yy0.z-yymsp[-3].minor.yy0.z-1)
|
|
184743
|
+
sqlite3AlterAddConstraint(pParse, yymsp[-8].minor.yy203, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0, yymsp[-3].minor.yy0.z+1, (yymsp[-1].minor.yy0.z-yymsp[-3].minor.yy0.z-1));
|
|
184837
184744
|
}
|
|
184745
|
+
yy_destructor(yypParser,219,&yymsp[-2].minor);
|
|
184838
184746
|
break;
|
|
184839
184747
|
case 301: /* cmd ::= ALTER TABLE fullname ADD CHECK LP expr RP onconf */
|
|
184840
184748
|
{
|
|
184841
|
-
sqlite3AlterAddConstraint(pParse, yymsp[-6].minor.yy203, &yymsp[-4].minor.yy0, 0, yymsp[-3].minor.yy0.z+1, (yymsp[-1].minor.yy0.z-yymsp[-3].minor.yy0.z-1)
|
|
184749
|
+
sqlite3AlterAddConstraint(pParse, yymsp[-6].minor.yy203, &yymsp[-4].minor.yy0, 0, yymsp[-3].minor.yy0.z+1, (yymsp[-1].minor.yy0.z-yymsp[-3].minor.yy0.z-1));
|
|
184842
184750
|
}
|
|
184751
|
+
yy_destructor(yypParser,219,&yymsp[-2].minor);
|
|
184843
184752
|
break;
|
|
184844
184753
|
case 302: /* cmd ::= create_vtab */
|
|
184845
184754
|
{sqlite3VtabFinishParse(pParse,0);}
|
|
@@ -194043,12 +193952,6 @@ SQLITE_PRIVATE int sqlite3Fts3IntegrityCheck(Fts3Table *p, int *pbOk);
|
|
|
194043
193952
|
SQLITE_EXTENSION_INIT1
|
|
194044
193953
|
#endif
|
|
194045
193954
|
|
|
194046
|
-
|
|
194047
|
-
/*
|
|
194048
|
-
** Assume any b-tree layer with more levels than this is corrupt.
|
|
194049
|
-
*/
|
|
194050
|
-
#define FTS3_MAX_BTREE_HEIGHT 48
|
|
194051
|
-
|
|
194052
193955
|
typedef struct Fts3HashWrapper Fts3HashWrapper;
|
|
194053
193956
|
struct Fts3HashWrapper {
|
|
194054
193957
|
Fts3Hash hash; /* Hash table */
|
|
@@ -195765,11 +195668,7 @@ static int fts3SelectLeaf(
|
|
|
195765
195668
|
assert( piLeaf || piLeaf2 );
|
|
195766
195669
|
|
|
195767
195670
|
fts3GetVarint32(zNode, &iHeight);
|
|
195768
|
-
|
|
195769
|
-
rc = FTS_CORRUPT_VTAB;
|
|
195770
|
-
}else{
|
|
195771
|
-
rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
|
|
195772
|
-
}
|
|
195671
|
+
rc = fts3ScanInteriorNode(zTerm, nTerm, zNode, nNode, piLeaf, piLeaf2);
|
|
195773
195672
|
assert_fts3_nc( !piLeaf2 || !piLeaf || rc!=SQLITE_OK || (*piLeaf<=*piLeaf2) );
|
|
195774
195673
|
|
|
195775
195674
|
if( rc==SQLITE_OK && iHeight>1 ){
|
|
@@ -200298,7 +200197,7 @@ static int fts3auxNextMethod(sqlite3_vtab_cursor *pCursor){
|
|
|
200298
200197
|
/* State 3. The integer just read is a column number. */
|
|
200299
200198
|
default: assert( eState==3 );
|
|
200300
200199
|
iCol = (int)v;
|
|
200301
|
-
if( iCol<1
|
|
200200
|
+
if( iCol<1 ){
|
|
200302
200201
|
rc = SQLITE_CORRUPT_VTAB;
|
|
200303
200202
|
break;
|
|
200304
200203
|
}
|
|
@@ -200988,7 +200887,6 @@ static int getNextNode(
|
|
|
200988
200887
|
assert( nKey==4 );
|
|
200989
200888
|
if( zInput[4]=='/' && zInput[5]>='0' && zInput[5]<='9' ){
|
|
200990
200889
|
nKey += 1+sqlite3Fts3ReadInt(&zInput[nKey+1], &nNear);
|
|
200991
|
-
if( nNear>=1000000000 ) nNear = 1000000000;
|
|
200992
200890
|
}
|
|
200993
200891
|
}
|
|
200994
200892
|
|
|
@@ -210852,7 +210750,7 @@ static int fts3ExprLHits(
|
|
|
210852
210750
|
if( p->flag==FTS3_MATCHINFO_LHITS ){
|
|
210853
210751
|
p->aMatchinfo[iStart + iCol] = (u32)nHit;
|
|
210854
210752
|
}else if( nHit ){
|
|
210855
|
-
p->aMatchinfo[iStart + iCol/32] |= (
|
|
210753
|
+
p->aMatchinfo[iStart + (iCol+1)/32] |= (1 << (iCol&0x1F));
|
|
210856
210754
|
}
|
|
210857
210755
|
}
|
|
210858
210756
|
assert( *pIter==0x00 || *pIter==0x01 );
|
|
@@ -213342,7 +213240,7 @@ static void jsonAppendSqlValue(
|
|
|
213342
213240
|
break;
|
|
213343
213241
|
}
|
|
213344
213242
|
case SQLITE_FLOAT: {
|
|
213345
|
-
jsonPrintf(100, p, "%!0.
|
|
213243
|
+
jsonPrintf(100, p, "%!0.15g", sqlite3_value_double(pValue));
|
|
213346
213244
|
break;
|
|
213347
213245
|
}
|
|
213348
213246
|
case SQLITE_INTEGER: {
|
|
@@ -214656,10 +214554,9 @@ static u32 jsonbPayloadSize(const JsonParse *pParse, u32 i, u32 *pSz){
|
|
|
214656
214554
|
u8 x;
|
|
214657
214555
|
u32 sz;
|
|
214658
214556
|
u32 n;
|
|
214659
|
-
|
|
214660
|
-
|
|
214661
|
-
|
|
214662
|
-
}else if( (x = pParse->aBlob[i]>>4)<=11 ){
|
|
214557
|
+
assert( i<=pParse->nBlob );
|
|
214558
|
+
x = pParse->aBlob[i]>>4;
|
|
214559
|
+
if( x<=11 ){
|
|
214663
214560
|
sz = x;
|
|
214664
214561
|
n = 1;
|
|
214665
214562
|
}else if( x==12 ){
|
|
@@ -217442,9 +217339,11 @@ static void jsonGroupInverse(
|
|
|
217442
217339
|
UNUSED_PARAMETER(argc);
|
|
217443
217340
|
UNUSED_PARAMETER(argv);
|
|
217444
217341
|
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
|
|
217342
|
+
#ifdef NEVER
|
|
217445
217343
|
/* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will
|
|
217446
217344
|
** always have been called to initialize it */
|
|
217447
217345
|
if( NEVER(!pStr) ) return;
|
|
217346
|
+
#endif
|
|
217448
217347
|
z = pStr->zBuf;
|
|
217449
217348
|
for(i=1; i<pStr->nUsed && ((c = z[i])!=',' || inStr || nNest); i++){
|
|
217450
217349
|
if( c=='"' ){
|
|
@@ -217473,13 +217372,6 @@ static void jsonGroupInverse(
|
|
|
217473
217372
|
** json_group_obj(NAME,VALUE)
|
|
217474
217373
|
**
|
|
217475
217374
|
** Return a JSON object composed of all names and values in the aggregate.
|
|
217476
|
-
**
|
|
217477
|
-
** Rows for which NAME is NULL do not result in a new entry. However, we
|
|
217478
|
-
** do initially insert a "@" entry into the growing string for each null entry
|
|
217479
|
-
** and change the first character of the string to "@" to signal that the
|
|
217480
|
-
** string contains null entries. The "@" markers are needed in order to
|
|
217481
|
-
** correctly process xInverse() requests. The initial "@" is converted
|
|
217482
|
-
** back into "{" and the "@" null values are removed by jsonObjectCompute().
|
|
217483
217375
|
*/
|
|
217484
217376
|
static void jsonObjectStep(
|
|
217485
217377
|
sqlite3_context *ctx,
|
|
@@ -217497,7 +217389,7 @@ static void jsonObjectStep(
|
|
|
217497
217389
|
if( pStr->zBuf==0 ){
|
|
217498
217390
|
jsonStringInit(pStr, ctx);
|
|
217499
217391
|
jsonAppendChar(pStr, '{');
|
|
217500
|
-
}else if( pStr->nUsed>1 ){
|
|
217392
|
+
}else if( pStr->nUsed>1 && z!=0 ){
|
|
217501
217393
|
jsonAppendChar(pStr, ',');
|
|
217502
217394
|
}
|
|
217503
217395
|
pStr->pCtx = ctx;
|
|
@@ -217505,9 +217397,6 @@ static void jsonObjectStep(
|
|
|
217505
217397
|
jsonAppendString(pStr, z, n);
|
|
217506
217398
|
jsonAppendChar(pStr, ':');
|
|
217507
217399
|
jsonAppendSqlValue(pStr, argv[1]);
|
|
217508
|
-
}else{
|
|
217509
|
-
pStr->zBuf[0] = '@';
|
|
217510
|
-
jsonAppendRawNZ(pStr, "@", 1);
|
|
217511
217400
|
}
|
|
217512
217401
|
}
|
|
217513
217402
|
}
|
|
@@ -217516,64 +217405,20 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
|
|
|
217516
217405
|
int flags = SQLITE_PTR_TO_INT(sqlite3_user_data(ctx));
|
|
217517
217406
|
pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
|
|
217518
217407
|
if( pStr ){
|
|
217519
|
-
|
|
217520
|
-
|
|
217521
|
-
jsonAppendRawNZ(pOgStr, "}", 2); /* Ensure it is zero-terminated */
|
|
217522
|
-
jsonStringTrimOneChar(pOgStr); /* Remove the zero terminator */
|
|
217408
|
+
jsonAppendRawNZ(pStr, "}", 2);
|
|
217409
|
+
jsonStringTrimOneChar(pStr);
|
|
217523
217410
|
pStr->pCtx = ctx;
|
|
217524
217411
|
if( pStr->eErr ){
|
|
217525
217412
|
jsonReturnString(pStr, 0, 0);
|
|
217526
217413
|
return;
|
|
217527
|
-
}
|
|
217528
|
-
if( pStr->zBuf[0]!='{' ){
|
|
217529
|
-
/* The string contains null entries that need to be removed */
|
|
217530
|
-
u64 i, j;
|
|
217531
|
-
int inStr = 0;
|
|
217532
|
-
if( !isFinal ){
|
|
217533
|
-
/* Work with a temporary copy of the string if this is not the
|
|
217534
|
-
** final result */
|
|
217535
|
-
jsonStringInit(&tmpStr, ctx);
|
|
217536
|
-
jsonAppendRawNZ(&tmpStr, pStr->zBuf, pStr->nUsed+1);
|
|
217537
|
-
pStr = &tmpStr;
|
|
217538
|
-
if( pStr->eErr ){
|
|
217539
|
-
jsonReturnString(pStr, 0, 0);
|
|
217540
|
-
return;
|
|
217541
|
-
}
|
|
217542
|
-
jsonStringTrimOneChar(pStr); /* Remove zero terminator */
|
|
217543
|
-
}
|
|
217544
|
-
/* Fix up the string by changing the initial "@" flag back to
|
|
217545
|
-
** to "{" and removing all subsequence "@" entries, with their
|
|
217546
|
-
** associated comma delimeters. */
|
|
217547
|
-
pStr->zBuf[0] = '{';
|
|
217548
|
-
for(i=j=1; i<pStr->nUsed; i++){
|
|
217549
|
-
char c = pStr->zBuf[i];
|
|
217550
|
-
if( c=='"' ){
|
|
217551
|
-
inStr = !inStr;
|
|
217552
|
-
pStr->zBuf[j++] = '"';
|
|
217553
|
-
}else if( c=='\\' ){
|
|
217554
|
-
pStr->zBuf[j++] = '\\';
|
|
217555
|
-
pStr->zBuf[j++] = pStr->zBuf[++i];
|
|
217556
|
-
}else if( c=='@' && !inStr ){
|
|
217557
|
-
assert( i+1<pStr->nUsed );
|
|
217558
|
-
if( pStr->zBuf[i+1]==',' ){
|
|
217559
|
-
i++;
|
|
217560
|
-
}else if( pStr->zBuf[j-1]==',' ){
|
|
217561
|
-
j--;
|
|
217562
|
-
}
|
|
217563
|
-
}else{
|
|
217564
|
-
pStr->zBuf[j++] = c;
|
|
217565
|
-
}
|
|
217566
|
-
}
|
|
217567
|
-
pStr->zBuf[j] = 0; /* Restore zero terminator */
|
|
217568
|
-
pStr->nUsed = j; /* Truncate the string */
|
|
217569
|
-
}
|
|
217570
|
-
if( flags & JSON_BLOB ){
|
|
217414
|
+
}else if( flags & JSON_BLOB ){
|
|
217571
217415
|
jsonReturnStringAsBlob(pStr);
|
|
217572
217416
|
if( isFinal ){
|
|
217573
217417
|
if( !pStr->bStatic ) sqlite3RCStrUnref(pStr->zBuf);
|
|
217574
217418
|
}else{
|
|
217575
|
-
jsonStringTrimOneChar(
|
|
217419
|
+
jsonStringTrimOneChar(pStr);
|
|
217576
217420
|
}
|
|
217421
|
+
return;
|
|
217577
217422
|
}else if( isFinal ){
|
|
217578
217423
|
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed,
|
|
217579
217424
|
pStr->bStatic ? SQLITE_TRANSIENT :
|
|
@@ -217581,9 +217426,8 @@ static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){
|
|
|
217581
217426
|
pStr->bStatic = 1;
|
|
217582
217427
|
}else{
|
|
217583
217428
|
sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT);
|
|
217584
|
-
jsonStringTrimOneChar(
|
|
217429
|
+
jsonStringTrimOneChar(pStr);
|
|
217585
217430
|
}
|
|
217586
|
-
if( pStr!=pOgStr ) jsonStringReset(pStr);
|
|
217587
217431
|
}else if( flags & JSON_BLOB ){
|
|
217588
217432
|
static const unsigned char emptyObject = 0x0c;
|
|
217589
217433
|
sqlite3_result_blob(ctx, &emptyObject, 1, SQLITE_STATIC);
|
|
@@ -218435,7 +218279,7 @@ struct Rtree {
|
|
|
218435
218279
|
u8 eCoordType; /* RTREE_COORD_REAL32 or RTREE_COORD_INT32 */
|
|
218436
218280
|
u8 nBytesPerCell; /* Bytes consumed per cell */
|
|
218437
218281
|
u8 inWrTrans; /* True if inside write transaction */
|
|
218438
|
-
|
|
218282
|
+
u8 nAux; /* # of auxiliary columns in %_rowid */
|
|
218439
218283
|
#ifdef SQLITE_ENABLE_GEOPOLY
|
|
218440
218284
|
u8 nAuxNotNull; /* Number of initial not-null aux columns */
|
|
218441
218285
|
#endif
|
|
@@ -219671,7 +219515,7 @@ static int nodeRowidIndex(
|
|
|
219671
219515
|
){
|
|
219672
219516
|
int ii;
|
|
219673
219517
|
int nCell = NCELL(pNode);
|
|
219674
|
-
assert( nCell<
|
|
219518
|
+
assert( nCell<200 );
|
|
219675
219519
|
for(ii=0; ii<nCell; ii++){
|
|
219676
219520
|
if( nodeGetRowid(pRtree, pNode, ii)==iRowid ){
|
|
219677
219521
|
*piIndex = ii;
|
|
@@ -219933,10 +219777,7 @@ static int rtreeStepToLeaf(RtreeCursor *pCur){
|
|
|
219933
219777
|
pNode = rtreeNodeOfFirstSearchPoint(pCur, &rc);
|
|
219934
219778
|
if( rc ) return rc;
|
|
219935
219779
|
nCell = NCELL(pNode);
|
|
219936
|
-
|
|
219937
|
-
RTREE_IS_CORRUPT(pRtree);
|
|
219938
|
-
return SQLITE_CORRUPT_VTAB;
|
|
219939
|
-
}
|
|
219780
|
+
assert( nCell<200 );
|
|
219940
219781
|
pCellData = pNode->zData + (4+pRtree->nBytesPerCell*p->iCell);
|
|
219941
219782
|
while( p->iCell<nCell ){
|
|
219942
219783
|
sqlite3_rtree_dbl rScore = (sqlite3_rtree_dbl)-1;
|
|
@@ -221913,7 +221754,7 @@ static int rtreeInit(
|
|
|
221913
221754
|
"Auxiliary rtree columns must be last" /* 4 */
|
|
221914
221755
|
};
|
|
221915
221756
|
|
|
221916
|
-
assert( RTREE_MAX_AUX_COLUMN<256 );
|
|
221757
|
+
assert( RTREE_MAX_AUX_COLUMN<256 ); /* Aux columns counted by a u8 */
|
|
221917
221758
|
if( argc<6 || argc>RTREE_MAX_AUX_COLUMN+3 ){
|
|
221918
221759
|
*pzErr = sqlite3_mprintf("%s", aErrMsg[2 + (argc>=6)]);
|
|
221919
221760
|
return SQLITE_ERROR;
|
|
@@ -223832,11 +223673,6 @@ static int geopolyInit(
|
|
|
223832
223673
|
int ii;
|
|
223833
223674
|
(void)pAux;
|
|
223834
223675
|
|
|
223835
|
-
if( argc>=RTREE_MAX_AUX_COLUMN+4 ){
|
|
223836
|
-
*pzErr = sqlite3_mprintf("Too many columns for a geopoly table");
|
|
223837
|
-
return SQLITE_ERROR;
|
|
223838
|
-
}
|
|
223839
|
-
|
|
223840
223676
|
sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
|
|
223841
223677
|
sqlite3_vtab_config(db, SQLITE_VTAB_INNOCUOUS);
|
|
223842
223678
|
|
|
@@ -224971,7 +224807,7 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
|
|
224971
224807
|
const UChar *zInput; /* Pointer to input string */
|
|
224972
224808
|
UChar *zOutput = 0; /* Pointer to output buffer */
|
|
224973
224809
|
int nInput; /* Size of utf-16 input string in bytes */
|
|
224974
|
-
|
|
224810
|
+
int nOut; /* Size of output buffer in bytes */
|
|
224975
224811
|
int cnt;
|
|
224976
224812
|
int bToUpper; /* True for toupper(), false for tolower() */
|
|
224977
224813
|
UErrorCode status;
|
|
@@ -224994,7 +224830,7 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
|
|
224994
224830
|
}
|
|
224995
224831
|
|
|
224996
224832
|
for(cnt=0; cnt<2; cnt++){
|
|
224997
|
-
UChar *zNew =
|
|
224833
|
+
UChar *zNew = sqlite3_realloc(zOutput, nOut);
|
|
224998
224834
|
if( zNew==0 ){
|
|
224999
224835
|
sqlite3_free(zOutput);
|
|
225000
224836
|
sqlite3_result_error_nomem(p);
|
|
@@ -225003,9 +224839,9 @@ static void icuCaseFunc16(sqlite3_context *p, int nArg, sqlite3_value **apArg){
|
|
|
225003
224839
|
zOutput = zNew;
|
|
225004
224840
|
status = U_ZERO_ERROR;
|
|
225005
224841
|
if( bToUpper ){
|
|
225006
|
-
nOut =
|
|
224842
|
+
nOut = 2*u_strToUpper(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
|
|
225007
224843
|
}else{
|
|
225008
|
-
nOut =
|
|
224844
|
+
nOut = 2*u_strToLower(zOutput,nOut/2,zInput,nInput/2,zLocale,&status);
|
|
225009
224845
|
}
|
|
225010
224846
|
|
|
225011
224847
|
if( U_SUCCESS(status) ){
|
|
@@ -232720,13 +232556,12 @@ static int dbpageFilter(
|
|
|
232720
232556
|
pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
|
|
232721
232557
|
pCsr->mxPgno = sqlite3BtreeLastPage(pBt);
|
|
232722
232558
|
if( idxNum & 1 ){
|
|
232723
|
-
i64 iPg = sqlite3_value_int64(argv[idxNum>>1]);
|
|
232724
232559
|
assert( argc>(idxNum>>1) );
|
|
232725
|
-
|
|
232560
|
+
pCsr->pgno = sqlite3_value_int(argv[idxNum>>1]);
|
|
232561
|
+
if( pCsr->pgno<1 || pCsr->pgno>pCsr->mxPgno ){
|
|
232726
232562
|
pCsr->pgno = 1;
|
|
232727
232563
|
pCsr->mxPgno = 0;
|
|
232728
232564
|
}else{
|
|
232729
|
-
pCsr->pgno = (Pgno)iPg;
|
|
232730
232565
|
pCsr->mxPgno = pCsr->pgno;
|
|
232731
232566
|
}
|
|
232732
232567
|
}else{
|
|
@@ -235073,16 +234908,6 @@ static int sessionPrepareDfltStmt(
|
|
|
235073
234908
|
return rc;
|
|
235074
234909
|
}
|
|
235075
234910
|
|
|
235076
|
-
/*
|
|
235077
|
-
** Finalize statement pStmt. If (*pRc) is SQLITE_OK when this function is
|
|
235078
|
-
** called, set it to the results of the sqlite3_finalize() call. Or, if
|
|
235079
|
-
** it is already set to an error code, leave it as is.
|
|
235080
|
-
*/
|
|
235081
|
-
static void sessionFinalizeStmt(sqlite3_stmt *pStmt, int *pRc){
|
|
235082
|
-
int rc = sqlite3_finalize(pStmt);
|
|
235083
|
-
if( *pRc==SQLITE_OK ) *pRc = rc;
|
|
235084
|
-
}
|
|
235085
|
-
|
|
235086
234911
|
/*
|
|
235087
234912
|
** Table pTab has one or more existing change-records with old.* records
|
|
235088
234913
|
** with fewer than pTab->nCol columns. This function updates all such
|
|
@@ -235105,8 +234930,9 @@ static int sessionUpdateChanges(sqlite3_session *pSession, SessionTable *pTab){
|
|
|
235105
234930
|
}
|
|
235106
234931
|
}
|
|
235107
234932
|
|
|
235108
|
-
sessionFinalizeStmt(pStmt, &rc);
|
|
235109
234933
|
pSession->rc = rc;
|
|
234934
|
+
rc = sqlite3_finalize(pStmt);
|
|
234935
|
+
if( pSession->rc==SQLITE_OK ) pSession->rc = rc;
|
|
235110
234936
|
return pSession->rc;
|
|
235111
234937
|
}
|
|
235112
234938
|
|
|
@@ -235674,7 +235500,7 @@ static int sessionDiffFindNew(
|
|
|
235674
235500
|
rc = SQLITE_NOMEM;
|
|
235675
235501
|
}else{
|
|
235676
235502
|
sqlite3_stmt *pStmt;
|
|
235677
|
-
rc =
|
|
235503
|
+
rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);
|
|
235678
235504
|
if( rc==SQLITE_OK ){
|
|
235679
235505
|
SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;
|
|
235680
235506
|
pDiffCtx->pStmt = pStmt;
|
|
@@ -235737,7 +235563,7 @@ static int sessionDiffFindModified(
|
|
|
235737
235563
|
rc = SQLITE_NOMEM;
|
|
235738
235564
|
}else{
|
|
235739
235565
|
sqlite3_stmt *pStmt;
|
|
235740
|
-
rc =
|
|
235566
|
+
rc = sqlite3_prepare(pSession->db, zStmt, -1, &pStmt, 0);
|
|
235741
235567
|
|
|
235742
235568
|
if( rc==SQLITE_OK ){
|
|
235743
235569
|
SessionDiffCtx *pDiffCtx = (SessionDiffCtx*)pSession->hook.pCtx;
|
|
@@ -236432,11 +236258,11 @@ static int sessionSelectStmt(
|
|
|
236432
236258
|
);
|
|
236433
236259
|
sessionAppendStr(&cols, "tbl, ?2, stat", &rc);
|
|
236434
236260
|
}else{
|
|
236435
|
-
#if 0
|
|
236261
|
+
#if 0
|
|
236436
236262
|
if( bRowid ){
|
|
236437
236263
|
sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
|
|
236438
236264
|
}
|
|
236439
|
-
#endif
|
|
236265
|
+
#endif
|
|
236440
236266
|
for(i=0; i<nCol; i++){
|
|
236441
236267
|
if( cols.nBuf ) sessionAppendStr(&cols, ", ", &rc);
|
|
236442
236268
|
sessionAppendIdent(&cols, azCol[i], &rc);
|
|
@@ -237690,13 +237516,7 @@ static int sessionChangesetInvert(
|
|
|
237690
237516
|
|
|
237691
237517
|
/* Test for EOF. */
|
|
237692
237518
|
if( (rc = sessionInputBuffer(pInput, 2)) ) goto finished_invert;
|
|
237693
|
-
if( pInput->iNext
|
|
237694
|
-
if( pInput->iNext!=pInput->nData ){
|
|
237695
|
-
rc = SQLITE_CORRUPT_BKPT;
|
|
237696
|
-
goto finished_invert;
|
|
237697
|
-
}
|
|
237698
|
-
break;
|
|
237699
|
-
}
|
|
237519
|
+
if( pInput->iNext>=pInput->nData ) break;
|
|
237700
237520
|
eType = pInput->aData[pInput->iNext];
|
|
237701
237521
|
|
|
237702
237522
|
switch( eType ){
|
|
@@ -237892,7 +237712,6 @@ struct SessionApplyCtx {
|
|
|
237892
237712
|
u8 bRebaseStarted; /* If table header is already in rebase */
|
|
237893
237713
|
u8 bRebase; /* True to collect rebase information */
|
|
237894
237714
|
u8 bIgnoreNoop; /* True to ignore no-op conflicts */
|
|
237895
|
-
u8 bNoUpdateLoop; /* No update-loop processing */
|
|
237896
237715
|
int bRowid;
|
|
237897
237716
|
char *zErr; /* Error message, if any */
|
|
237898
237717
|
};
|
|
@@ -238466,7 +238285,7 @@ static int sessionConflictHandler(
|
|
|
238466
238285
|
u8 *aBlob = &pIter->in.aData[pIter->in.iCurrent];
|
|
238467
238286
|
int nBlob = pIter->in.iNext - pIter->in.iCurrent;
|
|
238468
238287
|
sessionAppendBlob(&p->constraints, aBlob, nBlob, &rc);
|
|
238469
|
-
return
|
|
238288
|
+
return SQLITE_OK;
|
|
238470
238289
|
}else if( p->bIgnoreNoop==0 || op!=SQLITE_DELETE
|
|
238471
238290
|
|| eType==SQLITE_CHANGESET_CONFLICT
|
|
238472
238291
|
){
|
|
@@ -238588,7 +238407,7 @@ static int sessionApplyOneOp(
|
|
|
238588
238407
|
for(i=0; rc==SQLITE_OK && i<nCol; i++){
|
|
238589
238408
|
sqlite3_value *pOld = sessionChangesetOld(pIter, i);
|
|
238590
238409
|
sqlite3_value *pNew = sessionChangesetNew(pIter, i);
|
|
238591
|
-
if(
|
|
238410
|
+
if( p->abPK[i] || (bPatchset==0 && pOld) ){
|
|
238592
238411
|
rc = sessionBindValue(pUp, i*2+2, pOld);
|
|
238593
238412
|
}
|
|
238594
238413
|
if( rc==SQLITE_OK && pNew ){
|
|
@@ -238714,264 +238533,7 @@ static int sessionApplyOneWithRetry(
|
|
|
238714
238533
|
}
|
|
238715
238534
|
|
|
238716
238535
|
/*
|
|
238717
|
-
**
|
|
238718
|
-
*/
|
|
238719
|
-
static int sessionRetryIterInit(
|
|
238720
|
-
SessionBuffer *pRetry, /* Buffer to iterate through */
|
|
238721
|
-
int bPatchset, /* True for patchset, false for changeset */
|
|
238722
|
-
const char *zTab, /* Table name */
|
|
238723
|
-
SessionApplyCtx *pApply, /* Session apply context */
|
|
238724
|
-
sqlite3_changeset_iter **ppIter /* OUT: New iterator */
|
|
238725
|
-
){
|
|
238726
|
-
sqlite3_changeset_iter *pRet = 0;
|
|
238727
|
-
int rc = SQLITE_OK;
|
|
238728
|
-
|
|
238729
|
-
rc = sessionChangesetStart(
|
|
238730
|
-
&pRet, 0, 0, pRetry->nBuf, pRetry->aBuf, pApply->bInvertConstraints, 1
|
|
238731
|
-
);
|
|
238732
|
-
if( rc==SQLITE_OK ){
|
|
238733
|
-
size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
|
|
238734
|
-
pRet->bPatchset = bPatchset;
|
|
238735
|
-
pRet->zTab = (char*)zTab;
|
|
238736
|
-
pRet->nCol = pApply->nCol;
|
|
238737
|
-
pRet->abPK = pApply->abPK;
|
|
238738
|
-
sessionBufferGrow(&pRet->tblhdr, nByte, &rc);
|
|
238739
|
-
pRet->apValue = (sqlite3_value**)pRet->tblhdr.aBuf;
|
|
238740
|
-
if( rc==SQLITE_OK ){
|
|
238741
|
-
memset(pRet->apValue, 0, nByte);
|
|
238742
|
-
}else{
|
|
238743
|
-
sqlite3changeset_finalize(pRet);
|
|
238744
|
-
pRet = 0;
|
|
238745
|
-
}
|
|
238746
|
-
}
|
|
238747
|
-
|
|
238748
|
-
*ppIter = pRet;
|
|
238749
|
-
return rc;
|
|
238750
|
-
}
|
|
238751
|
-
|
|
238752
|
-
/*
|
|
238753
|
-
** Attempt to apply all the changes in retry buffer pRetry to the database.
|
|
238754
|
-
** Except, if parameter iSkip is greater than or equal to 0, skip change
|
|
238755
|
-
** iSkip.
|
|
238756
|
-
*/
|
|
238757
|
-
static int sessionApplyRetryBuffer(
|
|
238758
|
-
SessionBuffer *pRetry, /* Buffer to apply changes from */
|
|
238759
|
-
int iSkip, /* If >=0, index of change to omit */
|
|
238760
|
-
sqlite3 *db, /* Database handle */
|
|
238761
|
-
int bPatchset, /* True for patchset, false for changeset */
|
|
238762
|
-
const char *zTab, /* Name of table to write to */
|
|
238763
|
-
SessionApplyCtx *pApply, /* Apply context */
|
|
238764
|
-
int(*xConflict)(void*, int, sqlite3_changeset_iter*),
|
|
238765
|
-
void *pCtx /* First argument passed to xConflict */
|
|
238766
|
-
){
|
|
238767
|
-
int rc = SQLITE_OK;
|
|
238768
|
-
int rc2 = SQLITE_OK;
|
|
238769
|
-
int ii = 0;
|
|
238770
|
-
sqlite3_changeset_iter *pIter = 0;
|
|
238771
|
-
|
|
238772
|
-
assert( pApply->constraints.nBuf==0 );
|
|
238773
|
-
|
|
238774
|
-
rc = sessionRetryIterInit(pRetry, bPatchset, zTab, pApply, &pIter);
|
|
238775
|
-
|
|
238776
|
-
for(ii=0; rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter); ii++){
|
|
238777
|
-
if( ii!=iSkip ){
|
|
238778
|
-
rc = sessionApplyOneWithRetry(db, pIter, pApply, xConflict, pCtx);
|
|
238779
|
-
}
|
|
238780
|
-
}
|
|
238781
|
-
|
|
238782
|
-
rc2 = sqlite3changeset_finalize(pIter);
|
|
238783
|
-
if( rc==SQLITE_OK ) rc = rc2;
|
|
238784
|
-
assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
|
|
238785
|
-
|
|
238786
|
-
return rc;
|
|
238787
|
-
}
|
|
238788
|
-
|
|
238789
|
-
/*
|
|
238790
|
-
** Check if table zTab in the "main" database of db is a WITHOUT ROWID
|
|
238791
|
-
** table.
|
|
238792
|
-
**
|
|
238793
|
-
** If no error occurs, return SQLITE_OK and set output variable (*pbWR) to
|
|
238794
|
-
** true if zTab is a WITHOUT ROWID table, or false otherwise. Or, if an
|
|
238795
|
-
** error does occur, return an SQLite error code. The final value of (*pbWR)
|
|
238796
|
-
** is undefined in this case.
|
|
238797
|
-
*/
|
|
238798
|
-
static int sessionTableIsWithoutRowid(sqlite3 *db, const char *zTab, int *pbWR){
|
|
238799
|
-
sqlite3_stmt *pList = 0;
|
|
238800
|
-
char *zSql = 0;
|
|
238801
|
-
int rc = SQLITE_OK;
|
|
238802
|
-
|
|
238803
|
-
zSql = sqlite3_mprintf("PRAGMA table_list = %Q", zTab);
|
|
238804
|
-
if( zSql==0 ){
|
|
238805
|
-
rc = SQLITE_NOMEM;
|
|
238806
|
-
}else{
|
|
238807
|
-
rc = sqlite3_prepare_v2(db, zSql, -1, &pList, 0);
|
|
238808
|
-
sqlite3_free(zSql);
|
|
238809
|
-
}
|
|
238810
|
-
|
|
238811
|
-
if( rc==SQLITE_OK ){
|
|
238812
|
-
sqlite3_step(pList);
|
|
238813
|
-
*pbWR = sqlite3_column_int(pList, 4);
|
|
238814
|
-
rc = sqlite3_finalize(pList);
|
|
238815
|
-
}
|
|
238816
|
-
|
|
238817
|
-
return rc;
|
|
238818
|
-
}
|
|
238819
|
-
|
|
238820
|
-
/*
|
|
238821
|
-
** Iterator pUp points to an UPDATE change. This function deletes the
|
|
238822
|
-
** affected row from the database and creates an INSERT statement that
|
|
238823
|
-
** may be used to reinsert the row as it is after the UPDATE change
|
|
238824
|
-
** has been applied.
|
|
238825
|
-
**
|
|
238826
|
-
** If successful, SQLITE_OK is returned and output variable (*ppInsert)
|
|
238827
|
-
** is left pointing to a prepared INSERT statement. It is the responsibility
|
|
238828
|
-
** of the caller to eventually free this statement using sqlite3_finalize().
|
|
238829
|
-
** Or, if an error occurs, an SQLite error code is returned and (*ppInsert)
|
|
238830
|
-
** set to NULL. pApply->zErr may be set to an error message in this case.
|
|
238831
|
-
*/
|
|
238832
|
-
static int sessionUpdateToDeleteInsert(
|
|
238833
|
-
sqlite3 *db, /* Database to write to */
|
|
238834
|
-
const char *zTab, /* Table name */
|
|
238835
|
-
SessionApplyCtx *pApply, /* Apply context */
|
|
238836
|
-
sqlite3_changeset_iter *pUp, /* Iterator pointing to UPDATE change */
|
|
238837
|
-
sqlite3_stmt **ppInsert /* OUT: INSERT statement */
|
|
238838
|
-
){
|
|
238839
|
-
sqlite3_stmt *pRet = 0; /* The INSERT statement */
|
|
238840
|
-
sqlite3_stmt *pSelect = 0; /* SELECT to read current values of row */
|
|
238841
|
-
int rc = SQLITE_OK;
|
|
238842
|
-
int bWR = 0;
|
|
238843
|
-
|
|
238844
|
-
rc = sessionTableIsWithoutRowid(db, zTab, &bWR);
|
|
238845
|
-
if( rc==SQLITE_OK ){
|
|
238846
|
-
char *zSelect = 0;
|
|
238847
|
-
char *zInsert = 0;
|
|
238848
|
-
SessionBuffer cols = {0, 0, 0};
|
|
238849
|
-
SessionBuffer insbind = {0, 0, 0};
|
|
238850
|
-
SessionBuffer pkcols = {0, 0, 0};
|
|
238851
|
-
SessionBuffer selbind = {0, 0, 0};
|
|
238852
|
-
|
|
238853
|
-
const char *zComma = "";
|
|
238854
|
-
const char *zComma2 = "";
|
|
238855
|
-
int ii;
|
|
238856
|
-
for(ii=0; ii<pApply->nCol; ii++){
|
|
238857
|
-
sessionAppendStr(&cols, zComma, &rc);
|
|
238858
|
-
sessionAppendIdent(&cols, pApply->azCol[ii], &rc);
|
|
238859
|
-
sessionAppendStr(&insbind, zComma, &rc);
|
|
238860
|
-
sessionAppendStr(&insbind, "?", &rc);
|
|
238861
|
-
zComma = ", ";
|
|
238862
|
-
|
|
238863
|
-
if( pApply->abPK[ii] ){
|
|
238864
|
-
sessionAppendStr(&pkcols, zComma2, &rc);
|
|
238865
|
-
sessionAppendIdent(&pkcols, pApply->azCol[ii], &rc);
|
|
238866
|
-
sessionAppendStr(&selbind, zComma2, &rc);
|
|
238867
|
-
sessionAppendPrintf(&selbind, &rc, "?%d", ii+1);
|
|
238868
|
-
zComma2 = ", ";
|
|
238869
|
-
}
|
|
238870
|
-
}
|
|
238871
|
-
if( bWR==0 ){
|
|
238872
|
-
sessionAppendStr(&cols, zComma, &rc);
|
|
238873
|
-
sessionAppendStr(&cols, SESSIONS_ROWID, &rc);
|
|
238874
|
-
sessionAppendStr(&insbind, zComma, &rc);
|
|
238875
|
-
sessionAppendStr(&insbind, "?", &rc);
|
|
238876
|
-
}
|
|
238877
|
-
|
|
238878
|
-
if( rc==SQLITE_OK ){
|
|
238879
|
-
zSelect = sqlite3_mprintf("SELECT %s FROM %Q WHERE (%s) IS (%s)",
|
|
238880
|
-
cols.aBuf, zTab, pkcols.aBuf, selbind.aBuf
|
|
238881
|
-
);
|
|
238882
|
-
if( zSelect==0 ) rc = SQLITE_NOMEM;
|
|
238883
|
-
}
|
|
238884
|
-
if( rc==SQLITE_OK ){
|
|
238885
|
-
zInsert = sqlite3_mprintf("INSERT INTO %Q(%s) VALUES(%s)",
|
|
238886
|
-
zTab, cols.aBuf, insbind.aBuf
|
|
238887
|
-
);
|
|
238888
|
-
if( zInsert==0 ) rc = SQLITE_NOMEM;
|
|
238889
|
-
}
|
|
238890
|
-
|
|
238891
|
-
if( rc==SQLITE_OK ){
|
|
238892
|
-
rc = sessionPrepare(db, &pSelect, &pApply->zErr, zSelect);
|
|
238893
|
-
}
|
|
238894
|
-
if( rc==SQLITE_OK ){
|
|
238895
|
-
rc = sessionPrepare(db, &pRet, &pApply->zErr, zInsert);
|
|
238896
|
-
}
|
|
238897
|
-
|
|
238898
|
-
sqlite3_free(zSelect);
|
|
238899
|
-
sqlite3_free(zInsert);
|
|
238900
|
-
sqlite3_free(cols.aBuf);
|
|
238901
|
-
sqlite3_free(insbind.aBuf);
|
|
238902
|
-
sqlite3_free(pkcols.aBuf);
|
|
238903
|
-
sqlite3_free(selbind.aBuf);
|
|
238904
|
-
}
|
|
238905
|
-
|
|
238906
|
-
if( rc==SQLITE_OK ){
|
|
238907
|
-
rc = sessionBindRow(
|
|
238908
|
-
pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pSelect
|
|
238909
|
-
);
|
|
238910
|
-
}
|
|
238911
|
-
|
|
238912
|
-
if( rc==SQLITE_OK && sqlite3_step(pSelect)==SQLITE_ROW ){
|
|
238913
|
-
int iCol;
|
|
238914
|
-
for(iCol=0; iCol<pApply->nCol; iCol++){
|
|
238915
|
-
sqlite3_value *pVal = pUp->apValue[iCol+pApply->nCol];
|
|
238916
|
-
if( pVal==0 ){
|
|
238917
|
-
pVal = sqlite3_column_value(pSelect, iCol);
|
|
238918
|
-
}
|
|
238919
|
-
rc = sqlite3_bind_value(pRet, iCol+1, pVal);
|
|
238920
|
-
}
|
|
238921
|
-
if( bWR==0 ){
|
|
238922
|
-
sqlite3_bind_int64(pRet, iCol+1, sqlite3_column_int64(pSelect, iCol));
|
|
238923
|
-
}
|
|
238924
|
-
}
|
|
238925
|
-
sessionFinalizeStmt(pSelect, &rc);
|
|
238926
|
-
|
|
238927
|
-
/* Delete the row from the database. */
|
|
238928
|
-
if( rc==SQLITE_OK ){
|
|
238929
|
-
rc = sessionBindRow(
|
|
238930
|
-
pUp, sqlite3changeset_old, pApply->nCol, pApply->abPK, pApply->pDelete
|
|
238931
|
-
);
|
|
238932
|
-
sqlite3_bind_int(pApply->pDelete, pApply->nCol+1, 1);
|
|
238933
|
-
}
|
|
238934
|
-
if( rc==SQLITE_OK ){
|
|
238935
|
-
sqlite3_step(pApply->pDelete);
|
|
238936
|
-
rc = sqlite3_reset(pApply->pDelete);
|
|
238937
|
-
}
|
|
238938
|
-
|
|
238939
|
-
if( rc!=SQLITE_OK ){
|
|
238940
|
-
sqlite3_finalize(pRet);
|
|
238941
|
-
pRet = 0;
|
|
238942
|
-
}
|
|
238943
|
-
|
|
238944
|
-
*ppInsert = pRet;
|
|
238945
|
-
return rc;
|
|
238946
|
-
}
|
|
238947
|
-
|
|
238948
|
-
/*
|
|
238949
|
-
** Retry the changes accumulated in the pApply->constraints buffer. The
|
|
238950
|
-
** pApply->constraints buffer contains all changes to table zTab that
|
|
238951
|
-
** could not be applied due to SQLITE_CONSTRAINT errors. This function
|
|
238952
|
-
** attempts to apply them as follows:
|
|
238953
|
-
**
|
|
238954
|
-
** 1) It runs through the buffer and attempts to retry each change,
|
|
238955
|
-
** removing any that are successfully applied from the buffer. This
|
|
238956
|
-
** is repeated until no further progress can be made.
|
|
238957
|
-
**
|
|
238958
|
-
** 2) For each UPDATE change in the buffer, try the following in a
|
|
238959
|
-
** savepoint transaction:
|
|
238960
|
-
**
|
|
238961
|
-
** a) DELETE the affected row,
|
|
238962
|
-
** b) Attempt step (1) with remaining changes,
|
|
238963
|
-
** c) Attempt to INSERT a row equivalent to the one that would be
|
|
238964
|
-
** created by applying this UPDATE change.
|
|
238965
|
-
**
|
|
238966
|
-
** If the INSERT in (c) succeeds, the savepoint is committed and all
|
|
238967
|
-
** successfully applied changes are removed from the buffer. Step (2)
|
|
238968
|
-
** is then repeated.
|
|
238969
|
-
**
|
|
238970
|
-
** 3) Once step (2) has been attempted for each UPDATE in the change,
|
|
238971
|
-
** a final attempt is made to apply each remaining change. This time,
|
|
238972
|
-
** if an SQLITE_CONSTRAINT error is encountered, the conflict handler
|
|
238973
|
-
** is invoked and the user has to decide whether to omit the change
|
|
238974
|
-
** or rollback the entire _apply() operation.
|
|
238536
|
+
** Retry the changes accumulated in the pApply->constraints buffer.
|
|
238975
238537
|
*/
|
|
238976
238538
|
static int sessionRetryConstraints(
|
|
238977
238539
|
sqlite3 *db,
|
|
@@ -238982,101 +238544,41 @@ static int sessionRetryConstraints(
|
|
|
238982
238544
|
void *pCtx /* First argument passed to xConflict */
|
|
238983
238545
|
){
|
|
238984
238546
|
int rc = SQLITE_OK;
|
|
238985
|
-
int iUpdate = 0;
|
|
238986
238547
|
|
|
238987
|
-
/* Step (1) */
|
|
238988
238548
|
while( pApply->constraints.nBuf ){
|
|
238549
|
+
sqlite3_changeset_iter *pIter2 = 0;
|
|
238989
238550
|
SessionBuffer cons = pApply->constraints;
|
|
238990
238551
|
memset(&pApply->constraints, 0, sizeof(SessionBuffer));
|
|
238991
238552
|
|
|
238992
|
-
rc =
|
|
238993
|
-
&
|
|
238994
|
-
);
|
|
238995
|
-
|
|
238996
|
-
sqlite3_free(cons.aBuf);
|
|
238997
|
-
if( rc!=SQLITE_OK ) break;
|
|
238998
|
-
|
|
238999
|
-
/* If no progress has been made this round, break out of the loop. */
|
|
239000
|
-
if( pApply->constraints.nBuf>=cons.nBuf ) break;
|
|
239001
|
-
}
|
|
239002
|
-
|
|
239003
|
-
/* Step (2) */
|
|
239004
|
-
while( rc==SQLITE_OK && pApply->constraints.nBuf && !pApply->bNoUpdateLoop ){
|
|
239005
|
-
SessionBuffer cons = {0, 0, 0};
|
|
239006
|
-
sqlite3_changeset_iter *pUp = 0;
|
|
239007
|
-
sqlite3_stmt *pInsert = 0;
|
|
239008
|
-
int iSkip = 0;
|
|
239009
|
-
|
|
239010
|
-
rc = sessionRetryIterInit(
|
|
239011
|
-
&pApply->constraints, bPatchset, zTab, pApply, &pUp
|
|
238553
|
+
rc = sessionChangesetStart(
|
|
238554
|
+
&pIter2, 0, 0, cons.nBuf, cons.aBuf, pApply->bInvertConstraints, 1
|
|
239012
238555
|
);
|
|
239013
238556
|
if( rc==SQLITE_OK ){
|
|
239014
|
-
|
|
239015
|
-
|
|
239016
|
-
|
|
239017
|
-
|
|
239018
|
-
|
|
239019
|
-
|
|
239020
|
-
|
|
239021
|
-
|
|
239022
|
-
|
|
239023
|
-
rc = sessionUpdateToDeleteInsert(db, zTab, pApply, pUp, &pInsert);
|
|
239024
|
-
}
|
|
239025
|
-
}
|
|
239026
|
-
sqlite3changeset_finalize(pUp);
|
|
239027
|
-
if( iThis!=iUpdate ) break;
|
|
239028
|
-
}
|
|
239029
|
-
|
|
239030
|
-
if( rc==SQLITE_OK ){
|
|
239031
|
-
cons = pApply->constraints;
|
|
238557
|
+
size_t nByte = 2*pApply->nCol*sizeof(sqlite3_value*);
|
|
238558
|
+
int rc2;
|
|
238559
|
+
pIter2->bPatchset = bPatchset;
|
|
238560
|
+
pIter2->zTab = (char*)zTab;
|
|
238561
|
+
pIter2->nCol = pApply->nCol;
|
|
238562
|
+
pIter2->abPK = pApply->abPK;
|
|
238563
|
+
sessionBufferGrow(&pIter2->tblhdr, nByte, &rc);
|
|
238564
|
+
pIter2->apValue = (sqlite3_value**)pIter2->tblhdr.aBuf;
|
|
238565
|
+
if( rc==SQLITE_OK ) memset(pIter2->apValue, 0, nByte);
|
|
239032
238566
|
|
|
239033
|
-
while( rc==SQLITE_OK &&
|
|
239034
|
-
|
|
239035
|
-
memset(&pApply->constraints, 0, sizeof(SessionBuffer));
|
|
239036
|
-
rc = sessionApplyRetryBuffer(
|
|
239037
|
-
&app, iSkip, db, bPatchset, zTab, pApply, xConflict, pCtx
|
|
239038
|
-
);
|
|
239039
|
-
if( app.aBuf!=cons.aBuf ){
|
|
239040
|
-
sqlite3_free(app.aBuf);
|
|
239041
|
-
}
|
|
239042
|
-
if( pApply->constraints.nBuf>=app.nBuf ){
|
|
239043
|
-
break;
|
|
239044
|
-
}
|
|
239045
|
-
iSkip = -1;
|
|
238567
|
+
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3changeset_next(pIter2) ){
|
|
238568
|
+
rc = sessionApplyOneWithRetry(db, pIter2, pApply, xConflict, pCtx);
|
|
239046
238569
|
}
|
|
239047
|
-
}
|
|
239048
238570
|
|
|
239049
|
-
|
|
239050
|
-
|
|
239051
|
-
sqlite3_step(pInsert);
|
|
239052
|
-
rc = sqlite3_finalize(pInsert);
|
|
239053
|
-
if( rc==SQLITE_CONSTRAINT ){
|
|
239054
|
-
rc = sqlite3_exec(db, "ROLLBACK TO update_op", 0, 0, 0);
|
|
239055
|
-
sqlite3_free(pApply->constraints.aBuf);
|
|
239056
|
-
pApply->constraints = cons;
|
|
239057
|
-
memset(&cons, 0, sizeof(cons));
|
|
239058
|
-
}else if( rc==SQLITE_OK ){
|
|
239059
|
-
iUpdate = 0;
|
|
239060
|
-
}
|
|
239061
|
-
if( rc==SQLITE_OK ){
|
|
239062
|
-
rc = sqlite3_exec(db, "RELEASE update_op", 0, 0, 0);
|
|
239063
|
-
}
|
|
239064
|
-
}else{
|
|
239065
|
-
sqlite3_finalize(pInsert);
|
|
238571
|
+
rc2 = sqlite3changeset_finalize(pIter2);
|
|
238572
|
+
if( rc==SQLITE_OK ) rc = rc2;
|
|
239066
238573
|
}
|
|
238574
|
+
assert( pApply->bDeferConstraints || pApply->constraints.nBuf==0 );
|
|
239067
238575
|
|
|
239068
238576
|
sqlite3_free(cons.aBuf);
|
|
239069
|
-
|
|
239070
|
-
|
|
239071
|
-
|
|
239072
|
-
|
|
239073
|
-
|
|
239074
|
-
memset(&pApply->constraints, 0, sizeof(SessionBuffer));
|
|
239075
|
-
pApply->bDeferConstraints = 0;
|
|
239076
|
-
rc = sessionApplyRetryBuffer(
|
|
239077
|
-
&cons, -1, db, bPatchset, zTab, pApply, xConflict, pCtx
|
|
239078
|
-
);
|
|
239079
|
-
sqlite3_free(cons.aBuf);
|
|
238577
|
+
if( rc!=SQLITE_OK ) break;
|
|
238578
|
+
if( pApply->constraints.nBuf>=cons.nBuf ){
|
|
238579
|
+
/* No progress was made on the last round. */
|
|
238580
|
+
pApply->bDeferConstraints = 0;
|
|
238581
|
+
}
|
|
239080
238582
|
}
|
|
239081
238583
|
|
|
239082
238584
|
return rc;
|
|
@@ -239130,7 +238632,6 @@ static int sessionChangesetApply(
|
|
|
239130
238632
|
sApply.bRebase = (ppRebase && pnRebase);
|
|
239131
238633
|
sApply.bInvertConstraints = !!(flags & SQLITE_CHANGESETAPPLY_INVERT);
|
|
239132
238634
|
sApply.bIgnoreNoop = !!(flags & SQLITE_CHANGESETAPPLY_IGNORENOOP);
|
|
239133
|
-
sApply.bNoUpdateLoop = !!(flags & SQLITE_CHANGESETAPPLY_NOUPDATELOOP);
|
|
239134
238635
|
if( (flags & SQLITE_CHANGESETAPPLY_NOSAVEPOINT)==0 ){
|
|
239135
238636
|
rc = sqlite3_exec(db, "SAVEPOINT changeset_apply", 0, 0, 0);
|
|
239136
238637
|
}
|
|
@@ -240942,7 +240443,7 @@ SQLITE_API int sqlite3changegroup_change_blob(
|
|
|
240942
240443
|
const void *pVal,
|
|
240943
240444
|
int nVal
|
|
240944
240445
|
){
|
|
240945
|
-
sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) +
|
|
240446
|
+
sqlite3_int64 nByte = 1 + sessionVarintLen(nVal) + nVal;
|
|
240946
240447
|
int rc = SQLITE_OK;
|
|
240947
240448
|
SessionBuffer *pBuf = 0;
|
|
240948
240449
|
|
|
@@ -251526,7 +251027,7 @@ static void fts5DataRelease(Fts5Data *pData){
|
|
|
251526
251027
|
static Fts5Data *fts5LeafRead(Fts5Index *p, i64 iRowid){
|
|
251527
251028
|
Fts5Data *pRet = fts5DataRead(p, iRowid);
|
|
251528
251029
|
if( pRet ){
|
|
251529
|
-
if( pRet->
|
|
251030
|
+
if( pRet->nn<4 || pRet->szLeaf>pRet->nn ){
|
|
251530
251031
|
FTS5_CORRUPT_ROWID(p, iRowid);
|
|
251531
251032
|
fts5DataRelease(pRet);
|
|
251532
251033
|
pRet = 0;
|
|
@@ -253180,10 +252681,6 @@ static void fts5LeafSeek(
|
|
|
253180
252681
|
if( nKeep<nMatch ){
|
|
253181
252682
|
goto search_failed;
|
|
253182
252683
|
}
|
|
253183
|
-
if( (iOff+nNew)>n ){
|
|
253184
|
-
FTS5_CORRUPT_ITER(p, pIter);
|
|
253185
|
-
return;
|
|
253186
|
-
}
|
|
253187
252684
|
|
|
253188
252685
|
assert( nKeep>=nMatch );
|
|
253189
252686
|
if( nKeep==nMatch ){
|
|
@@ -254160,7 +253657,8 @@ static void fts5PoslistFilterCallback(
|
|
|
254160
253657
|
|
|
254161
253658
|
do {
|
|
254162
253659
|
while( i<nChunk && pChunk[i]!=0x01 ){
|
|
254163
|
-
|
|
253660
|
+
while( pChunk[i] & 0x80 ) i++;
|
|
253661
|
+
i++;
|
|
254164
253662
|
}
|
|
254165
253663
|
if( pCtx->eState ){
|
|
254166
253664
|
fts5BufferSafeAppendBlob(pCtx->pBuf, &pChunk[iStart], i-iStart);
|
|
@@ -254309,7 +253807,7 @@ static void fts5IndexExtractColset(
|
|
|
254309
253807
|
/* Advance pointer p until it points to pEnd or an 0x01 byte that is
|
|
254310
253808
|
** not part of a varint */
|
|
254311
253809
|
while( p<pEnd && *p!=0x01 ){
|
|
254312
|
-
while(
|
|
253810
|
+
while( *p++ & 0x80 );
|
|
254313
253811
|
}
|
|
254314
253812
|
|
|
254315
253813
|
if( pColset->aiCol[i]==iCurrent ){
|
|
@@ -254406,11 +253904,8 @@ static void fts5IterSetOutputs_Col100(Fts5Iter *pIter, Fts5SegIter *pSeg){
|
|
|
254406
253904
|
|
|
254407
253905
|
assert( pIter->pIndex->pConfig->eDetail==FTS5_DETAIL_COLUMNS );
|
|
254408
253906
|
assert( pIter->pColset );
|
|
254409
|
-
assert( pIter->poslist.nSpace>=pIter->pIndex->pConfig->nCol );
|
|
254410
253907
|
|
|
254411
|
-
if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf
|
|
254412
|
-
|| pSeg->nPos>pIter->pIndex->pConfig->nCol
|
|
254413
|
-
){
|
|
253908
|
+
if( pSeg->iLeafOffset+pSeg->nPos>pSeg->pLeaf->szLeaf ){
|
|
254414
253909
|
fts5IterSetOutputs_Col(pIter, pSeg);
|
|
254415
253910
|
}else{
|
|
254416
253911
|
u8 *a = (u8*)&pSeg->pLeaf->p[pSeg->iLeafOffset];
|
|
@@ -255904,11 +255399,6 @@ static void fts5DoSecureDelete(
|
|
|
255904
255399
|
}else{
|
|
255905
255400
|
iStart = fts5GetU16(&aPg[0]);
|
|
255906
255401
|
}
|
|
255907
|
-
if( iStart>nPg ){
|
|
255908
|
-
FTS5_CORRUPT_IDX(p);
|
|
255909
|
-
sqlite3_free(aIdx);
|
|
255910
|
-
return;
|
|
255911
|
-
}
|
|
255912
255402
|
|
|
255913
255403
|
iSOP = iStart + fts5GetVarint(&aPg[iStart], &iDelta);
|
|
255914
255404
|
assert_nc( iSOP<=pSeg->iLeafOffset );
|
|
@@ -263785,7 +263275,7 @@ static void fts5SourceIdFunc(
|
|
|
263785
263275
|
){
|
|
263786
263276
|
assert( nArg==0 );
|
|
263787
263277
|
UNUSED_PARAM2(nArg, apUnused);
|
|
263788
|
-
sqlite3_result_text(pCtx, "fts5: 2026-
|
|
263278
|
+
sqlite3_result_text(pCtx, "fts5: 2026-05-05 10:34:17 c88b22011a54b4f6fbd149e9f8e4de77658ce58143a1af0e3785e4e6475127e9", -1, SQLITE_TRANSIENT);
|
|
263789
263279
|
}
|
|
263790
263280
|
|
|
263791
263281
|
/*
|
|
@@ -266179,14 +265669,8 @@ static int fts5PorterCreate(
|
|
|
266179
265669
|
const char *zBase = "unicode61";
|
|
266180
265670
|
fts5_tokenizer_v2 *pV2 = 0;
|
|
266181
265671
|
|
|
266182
|
-
|
|
266183
|
-
|
|
266184
|
-
nArg--;
|
|
266185
|
-
azArg++;
|
|
266186
|
-
}else{
|
|
266187
|
-
zBase = azArg[0];
|
|
266188
|
-
break;
|
|
266189
|
-
}
|
|
265672
|
+
if( nArg>0 ){
|
|
265673
|
+
zBase = azArg[0];
|
|
266190
265674
|
}
|
|
266191
265675
|
|
|
266192
265676
|
pRet = (PorterTokenizer*)sqlite3_malloc64(sizeof(PorterTokenizer));
|