diff options
| author | 2023-09-15 11:17:47 -0400 | |
|---|---|---|
| committer | 2023-09-15 17:57:14 +0200 | |
| commit | f101ae075124f77a44444d368c869a5b3d3d4a6f (patch) | |
| tree | 207326f2501e8e8cf5547ba1278b8132c1036df4 /c | |
| parent | Merge branch 'update-sqlite' (diff) | |
| download | zig-sqlite-f101ae075124f77a44444d368c869a5b3d3d4a6f.tar.gz zig-sqlite-f101ae075124f77a44444d368c869a5b3d3d4a6f.tar.xz zig-sqlite-f101ae075124f77a44444d368c869a5b3d3d4a6f.zip | |
update sqlite to 3.43.1
Diffstat (limited to 'c')
| -rw-r--r-- | c/sqlite3.c | 183 | ||||
| -rw-r--r-- | c/sqlite3.h | 6 |
2 files changed, 99 insertions, 90 deletions
diff --git a/c/sqlite3.c b/c/sqlite3.c index 310583f..1884b08 100644 --- a/c/sqlite3.c +++ b/c/sqlite3.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /****************************************************************************** | 1 | /****************************************************************************** |
| 2 | ** This file is an amalgamation of many separate C source files from SQLite | 2 | ** This file is an amalgamation of many separate C source files from SQLite |
| 3 | ** version 3.43.0. By combining all the individual C code files into this | 3 | ** version 3.43.1. By combining all the individual C code files into this |
| 4 | ** single large file, the entire code can be compiled as a single translation | 4 | ** single large file, the entire code can be compiled as a single translation |
| 5 | ** unit. This allows many compilers to do optimizations that would not be | 5 | ** unit. This allows many compilers to do optimizations that would not be |
| 6 | ** possible if the files were compiled separately. Performance improvements | 6 | ** possible if the files were compiled separately. Performance improvements |
| @@ -18,7 +18,7 @@ | |||
| 18 | ** separate file. This file contains only code for the core SQLite library. | 18 | ** separate file. This file contains only code for the core SQLite library. |
| 19 | ** | 19 | ** |
| 20 | ** The content in this amalgamation comes from Fossil check-in | 20 | ** The content in this amalgamation comes from Fossil check-in |
| 21 | ** f80b798b3f4b81a7bb4233c58294edd0f11. | 21 | ** d3a40c05c49e1a49264912b1a05bc2143ac. |
| 22 | */ | 22 | */ |
| 23 | #define SQLITE_CORE 1 | 23 | #define SQLITE_CORE 1 |
| 24 | #define SQLITE_AMALGAMATION 1 | 24 | #define SQLITE_AMALGAMATION 1 |
| @@ -459,9 +459,9 @@ extern "C" { | |||
| 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 459 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 460 | ** [sqlite_version()] and [sqlite_source_id()]. | 460 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 461 | */ | 461 | */ |
| 462 | #define SQLITE_VERSION "3.43.0" | 462 | #define SQLITE_VERSION "3.43.1" |
| 463 | #define SQLITE_VERSION_NUMBER 3043000 | 463 | #define SQLITE_VERSION_NUMBER 3043001 |
| 464 | #define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" | 464 | #define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" |
| 465 | 465 | ||
| 466 | /* | 466 | /* |
| 467 | ** CAPI3REF: Run-Time Library Version Numbers | 467 | ** CAPI3REF: Run-Time Library Version Numbers |
| @@ -128461,8 +128461,10 @@ static void sumFinalize(sqlite3_context *context){ | |||
| 128461 | if( p->approx ){ | 128461 | if( p->approx ){ |
| 128462 | if( p->ovrfl ){ | 128462 | if( p->ovrfl ){ |
| 128463 | sqlite3_result_error(context,"integer overflow",-1); | 128463 | sqlite3_result_error(context,"integer overflow",-1); |
| 128464 | }else{ | 128464 | }else if( !sqlite3IsNaN(p->rErr) ){ |
| 128465 | sqlite3_result_double(context, p->rSum+p->rErr); | 128465 | sqlite3_result_double(context, p->rSum+p->rErr); |
| 128466 | }else{ | ||
| 128467 | sqlite3_result_double(context, p->rSum); | ||
| 128466 | } | 128468 | } |
| 128467 | }else{ | 128469 | }else{ |
| 128468 | sqlite3_result_int64(context, p->iSum); | 128470 | sqlite3_result_int64(context, p->iSum); |
| @@ -128475,7 +128477,8 @@ static void avgFinalize(sqlite3_context *context){ | |||
| 128475 | if( p && p->cnt>0 ){ | 128477 | if( p && p->cnt>0 ){ |
| 128476 | double r; | 128478 | double r; |
| 128477 | if( p->approx ){ | 128479 | if( p->approx ){ |
| 128478 | r = p->rSum+p->rErr; | 128480 | r = p->rSum; |
| 128481 | if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; | ||
| 128479 | }else{ | 128482 | }else{ |
| 128480 | r = (double)(p->iSum); | 128483 | r = (double)(p->iSum); |
| 128481 | } | 128484 | } |
| @@ -128488,7 +128491,8 @@ static void totalFinalize(sqlite3_context *context){ | |||
| 128488 | p = sqlite3_aggregate_context(context, 0); | 128491 | p = sqlite3_aggregate_context(context, 0); |
| 128489 | if( p ){ | 128492 | if( p ){ |
| 128490 | if( p->approx ){ | 128493 | if( p->approx ){ |
| 128491 | r = p->rSum+p->rErr; | 128494 | r = p->rSum; |
| 128495 | if( !sqlite3IsNaN(p->rErr) ) r += p->rErr; | ||
| 128492 | }else{ | 128496 | }else{ |
| 128493 | r = (double)(p->iSum); | 128497 | r = (double)(p->iSum); |
| 128494 | } | 128498 | } |
| @@ -145691,12 +145695,12 @@ static int disableUnusedSubqueryResultColumns(SrcItem *pItem){ | |||
| 145691 | assert( pItem->pSelect!=0 ); | 145695 | assert( pItem->pSelect!=0 ); |
| 145692 | pSub = pItem->pSelect; | 145696 | pSub = pItem->pSelect; |
| 145693 | assert( pSub->pEList->nExpr==pTab->nCol ); | 145697 | assert( pSub->pEList->nExpr==pTab->nCol ); |
| 145694 | if( (pSub->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ | ||
| 145695 | testcase( pSub->selFlags & SF_Distinct ); | ||
| 145696 | testcase( pSub->selFlags & SF_Aggregate ); | ||
| 145697 | return 0; | ||
| 145698 | } | ||
| 145699 | for(pX=pSub; pX; pX=pX->pPrior){ | 145698 | for(pX=pSub; pX; pX=pX->pPrior){ |
| 145699 | if( (pX->selFlags & (SF_Distinct|SF_Aggregate))!=0 ){ | ||
| 145700 | testcase( pX->selFlags & SF_Distinct ); | ||
| 145701 | testcase( pX->selFlags & SF_Aggregate ); | ||
| 145702 | return 0; | ||
| 145703 | } | ||
| 145700 | if( pX->pPrior && pX->op!=TK_ALL ){ | 145704 | if( pX->pPrior && pX->op!=TK_ALL ){ |
| 145701 | /* This optimization does not work for compound subqueries that | 145705 | /* This optimization does not work for compound subqueries that |
| 145702 | ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ | 145706 | ** use UNION, INTERSECT, or EXCEPT. Only UNION ALL is allowed. */ |
| @@ -198084,7 +198088,7 @@ static u64 fts3ChecksumIndex( | |||
| 198084 | int rc; | 198088 | int rc; |
| 198085 | u64 cksum = 0; | 198089 | u64 cksum = 0; |
| 198086 | 198090 | ||
| 198087 | assert( *pRc==SQLITE_OK ); | 198091 | if( *pRc ) return 0; |
| 198088 | 198092 | ||
| 198089 | memset(&filter, 0, sizeof(filter)); | 198093 | memset(&filter, 0, sizeof(filter)); |
| 198090 | memset(&csr, 0, sizeof(csr)); | 198094 | memset(&csr, 0, sizeof(csr)); |
| @@ -203714,7 +203718,9 @@ static void jsonArrayLengthFunc( | |||
| 203714 | } | 203718 | } |
| 203715 | if( pNode->eType==JSON_ARRAY ){ | 203719 | if( pNode->eType==JSON_ARRAY ){ |
| 203716 | while( 1 /*exit-by-break*/ ){ | 203720 | while( 1 /*exit-by-break*/ ){ |
| 203717 | for(i=1; i<=pNode->n; n++){ | 203721 | i = 1; |
| 203722 | while( i<=pNode->n ){ | ||
| 203723 | if( (pNode[i].jnFlags & JNODE_REMOVE)==0 ) n++; | ||
| 203718 | i += jsonNodeSize(&pNode[i]); | 203724 | i += jsonNodeSize(&pNode[i]); |
| 203719 | } | 203725 | } |
| 203720 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; | 203726 | if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; |
| @@ -222986,15 +222992,19 @@ static int sessionReadRecord( | |||
| 222986 | } | 222992 | } |
| 222987 | } | 222993 | } |
| 222988 | if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ | 222994 | if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){ |
| 222989 | sqlite3_int64 v = sessionGetI64(aVal); | 222995 | if( (pIn->nData-pIn->iNext)<8 ){ |
| 222990 | if( eType==SQLITE_INTEGER ){ | 222996 | rc = SQLITE_CORRUPT_BKPT; |
| 222991 | sqlite3VdbeMemSetInt64(apOut[i], v); | ||
| 222992 | }else{ | 222997 | }else{ |
| 222993 | double d; | 222998 | sqlite3_int64 v = sessionGetI64(aVal); |
| 222994 | memcpy(&d, &v, 8); | 222999 | if( eType==SQLITE_INTEGER ){ |
| 222995 | sqlite3VdbeMemSetDouble(apOut[i], d); | 223000 | sqlite3VdbeMemSetInt64(apOut[i], v); |
| 223001 | }else{ | ||
| 223002 | double d; | ||
| 223003 | memcpy(&d, &v, 8); | ||
| 223004 | sqlite3VdbeMemSetDouble(apOut[i], d); | ||
| 223005 | } | ||
| 223006 | pIn->iNext += 8; | ||
| 222996 | } | 223007 | } |
| 222997 | pIn->iNext += 8; | ||
| 222998 | } | 223008 | } |
| 222999 | } | 223009 | } |
| 223000 | } | 223010 | } |
| @@ -239820,80 +239830,79 @@ static void fts5DoSecureDelete( | |||
| 239820 | } | 239830 | } |
| 239821 | } | 239831 | } |
| 239822 | }else if( iStart==4 ){ | 239832 | }else if( iStart==4 ){ |
| 239823 | int iPgno; | 239833 | int iPgno; |
| 239824 | 239834 | ||
| 239825 | assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); | 239835 | assert_nc( pSeg->iLeafPgno>pSeg->iTermLeafPgno ); |
| 239826 | /* The entry being removed may be the only position list in | 239836 | /* The entry being removed may be the only position list in |
| 239827 | ** its doclist. */ | 239837 | ** its doclist. */ |
| 239828 | for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ | 239838 | for(iPgno=pSeg->iLeafPgno-1; iPgno>pSeg->iTermLeafPgno; iPgno-- ){ |
| 239829 | Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); | 239839 | Fts5Data *pPg = fts5DataRead(p, FTS5_SEGMENT_ROWID(iSegid, iPgno)); |
| 239830 | int bEmpty = (pPg && pPg->nn==4); | 239840 | int bEmpty = (pPg && pPg->nn==4); |
| 239831 | fts5DataRelease(pPg); | 239841 | fts5DataRelease(pPg); |
| 239832 | if( bEmpty==0 ) break; | 239842 | if( bEmpty==0 ) break; |
| 239833 | } | 239843 | } |
| 239834 | |||
| 239835 | if( iPgno==pSeg->iTermLeafPgno ){ | ||
| 239836 | i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); | ||
| 239837 | Fts5Data *pTerm = fts5DataRead(p, iId); | ||
| 239838 | if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ | ||
| 239839 | u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; | ||
| 239840 | int nTermIdx = pTerm->nn - pTerm->szLeaf; | ||
| 239841 | int iTermIdx = 0; | ||
| 239842 | int iTermOff = 0; | ||
| 239843 | |||
| 239844 | while( 1 ){ | ||
| 239845 | u32 iVal = 0; | ||
| 239846 | int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); | ||
| 239847 | iTermOff += iVal; | ||
| 239848 | if( (iTermIdx+nByte)>=nTermIdx ) break; | ||
| 239849 | iTermIdx += nByte; | ||
| 239850 | } | ||
| 239851 | nTermIdx = iTermIdx; | ||
| 239852 | 239844 | ||
| 239853 | memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); | 239845 | if( iPgno==pSeg->iTermLeafPgno ){ |
| 239854 | fts5PutU16(&pTerm->p[2], iTermOff); | 239846 | i64 iId = FTS5_SEGMENT_ROWID(iSegid, pSeg->iTermLeafPgno); |
| 239847 | Fts5Data *pTerm = fts5DataRead(p, iId); | ||
| 239848 | if( pTerm && pTerm->szLeaf==pSeg->iTermLeafOffset ){ | ||
| 239849 | u8 *aTermIdx = &pTerm->p[pTerm->szLeaf]; | ||
| 239850 | int nTermIdx = pTerm->nn - pTerm->szLeaf; | ||
| 239851 | int iTermIdx = 0; | ||
| 239852 | int iTermOff = 0; | ||
| 239855 | 239853 | ||
| 239856 | fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); | 239854 | while( 1 ){ |
| 239857 | if( nTermIdx==0 ){ | 239855 | u32 iVal = 0; |
| 239858 | fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); | 239856 | int nByte = fts5GetVarint32(&aTermIdx[iTermIdx], iVal); |
| 239859 | } | 239857 | iTermOff += iVal; |
| 239858 | if( (iTermIdx+nByte)>=nTermIdx ) break; | ||
| 239859 | iTermIdx += nByte; | ||
| 239860 | } | 239860 | } |
| 239861 | fts5DataRelease(pTerm); | 239861 | nTermIdx = iTermIdx; |
| 239862 | } | ||
| 239863 | } | ||
| 239864 | 239862 | ||
| 239865 | if( p->rc==SQLITE_OK ){ | 239863 | memmove(&pTerm->p[iTermOff], &pTerm->p[pTerm->szLeaf], nTermIdx); |
| 239866 | const int nMove = nPg - iNextOff; | 239864 | fts5PutU16(&pTerm->p[2], iTermOff); |
| 239867 | int nShift = 0; | 239865 | |
| 239868 | 239866 | fts5DataWrite(p, iId, pTerm->p, iTermOff+nTermIdx); | |
| 239869 | memmove(&aPg[iOff], &aPg[iNextOff], nMove); | 239867 | if( nTermIdx==0 ){ |
| 239870 | iPgIdx -= (iNextOff - iOff); | 239868 | fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iTermLeafPgno); |
| 239871 | nPg = iPgIdx; | ||
| 239872 | fts5PutU16(&aPg[2], iPgIdx); | ||
| 239873 | |||
| 239874 | nShift = iNextOff - iOff; | ||
| 239875 | for(iIdx=0, iKeyOff=0, iPrevKeyOff=0; iIdx<nIdx; /* no-op */){ | ||
| 239876 | u32 iVal = 0; | ||
| 239877 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | ||
| 239878 | iKeyOff += iVal; | ||
| 239879 | if( iKeyOff!=iDelKeyOff ){ | ||
| 239880 | if( iKeyOff>iOff ){ | ||
| 239881 | iKeyOff -= nShift; | ||
| 239882 | nShift = 0; | ||
| 239883 | } | ||
| 239884 | nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOff - iPrevKeyOff); | ||
| 239885 | iPrevKeyOff = iKeyOff; | ||
| 239886 | } | 239869 | } |
| 239887 | } | 239870 | } |
| 239871 | fts5DataRelease(pTerm); | ||
| 239872 | } | ||
| 239873 | } | ||
| 239874 | |||
| 239875 | if( p->rc==SQLITE_OK ){ | ||
| 239876 | const int nMove = nPg - iNextOff; /* Number of bytes to move */ | ||
| 239877 | int nShift = iNextOff - iOff; /* Distance to move them */ | ||
| 239888 | 239878 | ||
| 239889 | if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ | 239879 | int iPrevKeyOut = 0; |
| 239890 | fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); | 239880 | int iKeyIn = 0; |
| 239881 | |||
| 239882 | memmove(&aPg[iOff], &aPg[iNextOff], nMove); | ||
| 239883 | iPgIdx -= nShift; | ||
| 239884 | nPg = iPgIdx; | ||
| 239885 | fts5PutU16(&aPg[2], iPgIdx); | ||
| 239886 | |||
| 239887 | for(iIdx=0; iIdx<nIdx; /* no-op */){ | ||
| 239888 | u32 iVal = 0; | ||
| 239889 | iIdx += fts5GetVarint32(&aIdx[iIdx], iVal); | ||
| 239890 | iKeyIn += iVal; | ||
| 239891 | if( iKeyIn!=iDelKeyOff ){ | ||
| 239892 | int iKeyOut = (iKeyIn - (iKeyIn>iOff ? nShift : 0)); | ||
| 239893 | nPg += sqlite3Fts5PutVarint(&aPg[nPg], iKeyOut - iPrevKeyOut); | ||
| 239894 | iPrevKeyOut = iKeyOut; | ||
| 239891 | } | 239895 | } |
| 239896 | } | ||
| 239892 | 239897 | ||
| 239893 | assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); | 239898 | if( iPgIdx==nPg && nIdx>0 && pSeg->iLeafPgno!=1 ){ |
| 239894 | fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg,nPg); | 239899 | fts5SecureDeleteIdxEntry(p, iSegid, pSeg->iLeafPgno); |
| 239895 | } | 239900 | } |
| 239896 | sqlite3_free(aIdx); | 239901 | |
| 239902 | assert_nc( nPg>4 || fts5GetU16(aPg)==0 ); | ||
| 239903 | fts5DataWrite(p, FTS5_SEGMENT_ROWID(iSegid,pSeg->iLeafPgno), aPg, nPg); | ||
| 239904 | } | ||
| 239905 | sqlite3_free(aIdx); | ||
| 239897 | } | 239906 | } |
| 239898 | 239907 | ||
| 239899 | /* | 239908 | /* |
| @@ -245745,7 +245754,7 @@ static void fts5SourceIdFunc( | |||
| 245745 | ){ | 245754 | ){ |
| 245746 | assert( nArg==0 ); | 245755 | assert( nArg==0 ); |
| 245747 | UNUSED_PARAM2(nArg, apUnused); | 245756 | UNUSED_PARAM2(nArg, apUnused); |
| 245748 | sqlite3_result_text(pCtx, "fts5: 2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c", -1, SQLITE_TRANSIENT); | 245757 | sqlite3_result_text(pCtx, "fts5: 2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0", -1, SQLITE_TRANSIENT); |
| 245749 | } | 245758 | } |
| 245750 | 245759 | ||
| 245751 | /* | 245760 | /* |
diff --git a/c/sqlite3.h b/c/sqlite3.h index ec451a5..b9d0692 100644 --- a/c/sqlite3.h +++ b/c/sqlite3.h | |||
| @@ -146,9 +146,9 @@ extern "C" { | |||
| 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | 146 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 147 | ** [sqlite_version()] and [sqlite_source_id()]. | 147 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 148 | */ | 148 | */ |
| 149 | #define SQLITE_VERSION "3.43.0" | 149 | #define SQLITE_VERSION "3.43.1" |
| 150 | #define SQLITE_VERSION_NUMBER 3043000 | 150 | #define SQLITE_VERSION_NUMBER 3043001 |
| 151 | #define SQLITE_SOURCE_ID "2023-08-24 12:36:59 0f80b798b3f4b81a7bb4233c58294edd0f1156f36b6ecf5ab8e83631d468778c" | 151 | #define SQLITE_SOURCE_ID "2023-09-11 12:01:27 2d3a40c05c49e1a49264912b1a05bc2143ac0e7c3df588276ce80a4cbc9bd1b0" |
| 152 | 152 | ||
| 153 | /* | 153 | /* |
| 154 | ** CAPI3REF: Run-Time Library Version Numbers | 154 | ** CAPI3REF: Run-Time Library Version Numbers |