diff options
author | drh <> | 2023-07-21 15:01:53 +0000 |
---|---|---|
committer | drh <> | 2023-07-21 15:01:53 +0000 |
commit | 7a2280fe6579c69235a78c5df83f34a555558049 (patch) | |
tree | 162353cda3a46fad3e22af713900f4a93f5a34b2 /src | |
parent | f9bfc32b733c1b7b1a6655e19df14f56dd42f913 (diff) | |
download | sqlite-7a2280fe6579c69235a78c5df83f34a555558049.tar.gz sqlite-7a2280fe6579c69235a78c5df83f34a555558049.zip |
Multiple optimizations that try to preserve or infer the zero-terminated
property of TEXT values. Avoid unnecessary copying of text values destined
to become function parameters. All changes help improve performance of
doing UPDATEs on large JSON values that are indexed multiple ways.
FossilOrigin-Name: d0278cdedfa04fb0b61838ab9622be8a2c462f58d5c3ebc4c5f802a727d0974e
Diffstat (limited to 'src')
-rw-r--r-- | src/expr.c | 3 | ||||
-rw-r--r-- | src/json.c | 3 | ||||
-rw-r--r-- | src/vdbe.c | 6 | ||||
-rw-r--r-- | src/vdbeapi.c | 9 |
4 files changed, 18 insertions, 3 deletions
diff --git a/src/expr.c b/src/expr.c index a8e552f2c..0c41f6684 100644 --- a/src/expr.c +++ b/src/expr.c @@ -4690,8 +4690,7 @@ expr_code_doover: } } - sqlite3ExprCodeExprList(pParse, pFarg, r1, 0, - SQLITE_ECEL_DUP|SQLITE_ECEL_FACTOR); + sqlite3ExprCodeExprList(pParse, pFarg, r1, 0, SQLITE_ECEL_FACTOR); }else{ r1 = 0; } diff --git a/src/json.c b/src/json.c index 176dcbfdb..a9425aecd 100644 --- a/src/json.c +++ b/src/json.c @@ -501,7 +501,8 @@ static void jsonAppendValue( */ static void jsonResult(JsonString *p){ if( p->bErr==0 ){ - sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, + if( p->nAlloc>=p->nUsed+1 ) p->zBuf[p->nUsed] = 0; + sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, SQLITE_UTF8); jsonZero(p); diff --git a/src/vdbe.c b/src/vdbe.c index b248a664d..075a63211 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -556,6 +556,9 @@ void sqlite3VdbeMemPrettyPrint(Mem *pMem, StrAccum *pStr){ sqlite3_str_appendchar(pStr, 1, (c>=0x20&&c<=0x7f) ? c : '.'); } sqlite3_str_appendf(pStr, "]%s", encnames[pMem->enc]); + if( f & MEM_Term ){ + sqlite3_str_appendf(pStr, "(0-term)"); + } } } #endif @@ -3085,6 +3088,9 @@ op_column_restart: rc = sqlite3VdbeMemFromBtree(pC->uc.pCursor, aOffset[p2], len, pDest); if( rc!=SQLITE_OK ) goto abort_due_to_error; sqlite3VdbeSerialGet((const u8*)pDest->z, t, pDest); + if( (t&1)!=0 && encoding==SQLITE_UTF8 ){ + pDest->flags |= MEM_Term; + } pDest->flags &= ~MEM_Ephem; } } diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 920780a89..7f44d22bc 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -514,6 +514,15 @@ void sqlite3_result_text64( (void)invokeValueDestructor(z, xDel, pCtx); }else{ setResultStrOrError(pCtx, z, (int)n, enc, xDel); + if( xDel==sqlite3_free && enc==SQLITE_UTF8 ){ + Mem *pOut = pCtx->pOut; + if( pOut->z==z + && sqlite3_msize(pOut->z)>=pOut->n+1 + && pOut->z[n]==0 + ){ + pOut->flags |= MEM_Term; + } + } } } #ifndef SQLITE_OMIT_UTF16 |