mirror of
				https://github.com/isar/rusqlite.git
				synced 2025-10-31 05:48:56 +08:00 
			
		
		
		
	Merge pull request #1110 from gwenn/3.37.2
Upgrade SQLite bundled version to 3.37.2
This commit is contained in:
		| @@ -1,9 +1,9 @@ | ||||
| /* automatically generated by rust-bindgen 0.59.2 */ | ||||
|  | ||||
| pub const SQLITE_VERSION: &[u8; 7usize] = b"3.37.1\0"; | ||||
| pub const SQLITE_VERSION_NUMBER: i32 = 3037001; | ||||
| pub const SQLITE_VERSION: &[u8; 7usize] = b"3.37.2\0"; | ||||
| pub const SQLITE_VERSION_NUMBER: i32 = 3037002; | ||||
| pub const SQLITE_SOURCE_ID: &[u8; 85usize] = | ||||
|     b"2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62\0"; | ||||
|     b"2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0\0"; | ||||
| pub const SQLITE_OK: i32 = 0; | ||||
| pub const SQLITE_ERROR: i32 = 1; | ||||
| pub const SQLITE_INTERNAL: i32 = 2; | ||||
|   | ||||
							
								
								
									
										85
									
								
								libsqlite3-sys/sqlite3/sqlite3.c
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										85
									
								
								libsqlite3-sys/sqlite3/sqlite3.c
									
									
									
									
										vendored
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| /******************************************************************************
 | ||||
| ** This file is an amalgamation of many separate C source files from SQLite | ||||
| ** version 3.37.1.  By combining all the individual C code files into this | ||||
| ** version 3.37.2.  By combining all the individual C code files into this | ||||
| ** single large file, the entire code can be compiled as a single translation | ||||
| ** unit.  This allows many compilers to do optimizations that would not be | ||||
| ** possible if the files were compiled separately.  Performance improvements | ||||
| @@ -452,9 +452,9 @@ extern "C" { | ||||
| ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | ||||
| ** [sqlite_version()] and [sqlite_source_id()]. | ||||
| */ | ||||
| #define SQLITE_VERSION        "3.37.1" | ||||
| #define SQLITE_VERSION_NUMBER 3037001 | ||||
| #define SQLITE_SOURCE_ID      "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62" | ||||
| #define SQLITE_VERSION        "3.37.2" | ||||
| #define SQLITE_VERSION_NUMBER 3037002 | ||||
| #define SQLITE_SOURCE_ID      "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0" | ||||
| 
 | ||||
| /*
 | ||||
| ** CAPI3REF: Run-Time Library Version Numbers | ||||
| @@ -18503,6 +18503,8 @@ struct Parse { | ||||
|   AutoincInfo *pAinc;  /* Information about AUTOINCREMENT counters */ | ||||
|   Parse *pToplevel;    /* Parse structure for main program (or NULL) */ | ||||
|   Table *pTriggerTab;  /* Table triggers are being coded for */ | ||||
|   TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */ | ||||
|   ParseCleanup *pCleanup;   /* List of cleanup operations to run after parse */ | ||||
|   union { | ||||
|     int addrCrTab;         /* Address of OP_CreateBtree on CREATE TABLE */ | ||||
|     Returning *pReturning; /* The RETURNING clause */ | ||||
| @@ -18557,9 +18559,7 @@ struct Parse { | ||||
|   Token sArg;               /* Complete text of a module argument */ | ||||
|   Table **apVtabLock;       /* Pointer to virtual tables needing locking */ | ||||
| #endif | ||||
|   TriggerPrg *pTriggerPrg;  /* Linked list of coded triggers */ | ||||
|   With *pWith;              /* Current WITH clause, or NULL */ | ||||
|   ParseCleanup *pCleanup;   /* List of cleanup operations to run after parse */ | ||||
| #ifndef SQLITE_OMIT_ALTERTABLE | ||||
|   RenameToken *pRename;     /* Tokens subject to renaming by ALTER TABLE */ | ||||
| #endif | ||||
| @@ -20093,6 +20093,7 @@ SQLITE_PRIVATE   void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int | ||||
| SQLITE_PRIVATE   int sqlite3FkRequired(Parse*, Table*, int*, int); | ||||
| SQLITE_PRIVATE   u32 sqlite3FkOldmask(Parse*, Table*); | ||||
| SQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *); | ||||
| SQLITE_PRIVATE   void sqlite3FkClearTriggerCache(sqlite3*,int); | ||||
| #else | ||||
|   #define sqlite3FkActions(a,b,c,d,e,f) | ||||
|   #define sqlite3FkCheck(a,b,c,d,e,f) | ||||
| @@ -20100,6 +20101,7 @@ SQLITE_PRIVATE   FKey *sqlite3FkReferences(Table *); | ||||
|   #define sqlite3FkOldmask(a,b)         0 | ||||
|   #define sqlite3FkRequired(a,b,c,d)    0 | ||||
|   #define sqlite3FkReferences(a)        0 | ||||
|   #define sqlite3FkClearTriggerCache(a,b) | ||||
| #endif | ||||
| #ifndef SQLITE_OMIT_FOREIGN_KEY | ||||
| SQLITE_PRIVATE   void sqlite3FkDelete(sqlite3 *, Table*); | ||||
| @@ -56574,7 +56576,7 @@ static int pager_wait_on_lock(Pager *pPager, int locktype){ | ||||
| #if defined(SQLITE_DEBUG) | ||||
| static void assertTruncateConstraintCb(PgHdr *pPg){ | ||||
|   assert( pPg->flags&PGHDR_DIRTY ); | ||||
|   assert( !subjRequiresPage(pPg) || pPg->pgno<=pPg->pPager->dbSize ); | ||||
|   assert( pPg->pgno<=pPg->pPager->dbSize || !subjRequiresPage(pPg) ); | ||||
| } | ||||
| static void assertTruncateConstraint(Pager *pPager){ | ||||
|   sqlite3PcacheIterateDirty(pPager->pPCache, assertTruncateConstraintCb); | ||||
| @@ -57915,7 +57917,7 @@ SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager){ | ||||
|       ** may mean that the pager was in the error-state when this | ||||
|       ** function was called and the journal file does not exist. | ||||
|       */ | ||||
|       if( !isOpen(pPager->jfd) ){ | ||||
|       if( !isOpen(pPager->jfd) && pPager->journalMode!=PAGER_JOURNALMODE_OFF ){ | ||||
|         sqlite3_vfs * const pVfs = pPager->pVfs; | ||||
|         int bExists;              /* True if journal file exists */ | ||||
|         rc = sqlite3OsAccess( | ||||
| @@ -66818,7 +66820,7 @@ static void btreeParseCellPtr( | ||||
|   pInfo->nPayload = nPayload; | ||||
|   pInfo->pPayload = pIter; | ||||
|   testcase( nPayload==pPage->maxLocal ); | ||||
|   testcase( nPayload==pPage->maxLocal+1 ); | ||||
|   testcase( nPayload==(u32)pPage->maxLocal+1 ); | ||||
|   if( nPayload<=pPage->maxLocal ){ | ||||
|     /* This is the (easy) common case where the entire payload fits
 | ||||
|     ** on the local page.  No overflow is required. | ||||
| @@ -66855,7 +66857,7 @@ static void btreeParseCellPtrIndex( | ||||
|   pInfo->nPayload = nPayload; | ||||
|   pInfo->pPayload = pIter; | ||||
|   testcase( nPayload==pPage->maxLocal ); | ||||
|   testcase( nPayload==pPage->maxLocal+1 ); | ||||
|   testcase( nPayload==(u32)pPage->maxLocal+1 ); | ||||
|   if( nPayload<=pPage->maxLocal ){ | ||||
|     /* This is the (easy) common case where the entire payload fits
 | ||||
|     ** on the local page.  No overflow is required. | ||||
| @@ -66918,7 +66920,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){ | ||||
|     while( (*pIter++)&0x80 && pIter<pEnd ); | ||||
|   } | ||||
|   testcase( nSize==pPage->maxLocal ); | ||||
|   testcase( nSize==pPage->maxLocal+1 ); | ||||
|   testcase( nSize==(u32)pPage->maxLocal+1 ); | ||||
|   if( nSize<=pPage->maxLocal ){ | ||||
|     nSize += (u32)(pIter - pCell); | ||||
|     if( nSize<4 ) nSize = 4; | ||||
| @@ -66926,7 +66928,7 @@ static u16 cellSizePtr(MemPage *pPage, u8 *pCell){ | ||||
|     int minLocal = pPage->minLocal; | ||||
|     nSize = minLocal + (nSize - minLocal) % (pPage->pBt->usableSize - 4); | ||||
|     testcase( nSize==pPage->maxLocal ); | ||||
|     testcase( nSize==pPage->maxLocal+1 ); | ||||
|     testcase( nSize==(u32)pPage->maxLocal+1 ); | ||||
|     if( nSize>pPage->maxLocal ){ | ||||
|       nSize = minLocal; | ||||
|     } | ||||
| @@ -69817,7 +69819,7 @@ static void btreeSetNPage(BtShared *pBt, MemPage *pPage1){ | ||||
|   int nPage = get4byte(&pPage1->aData[28]); | ||||
|   testcase( nPage==0 ); | ||||
|   if( nPage==0 ) sqlite3PagerPagecount(pBt->pPager, &nPage); | ||||
|   testcase( pBt->nPage!=nPage ); | ||||
|   testcase( pBt->nPage!=(u32)nPage ); | ||||
|   pBt->nPage = nPage; | ||||
| } | ||||
| 
 | ||||
| @@ -72382,16 +72384,18 @@ static void dropCell(MemPage *pPage, int idx, int sz, int *pRC){ | ||||
|   int hdr;        /* Beginning of the header.  0 most pages.  100 page 1 */ | ||||
| 
 | ||||
|   if( *pRC ) return; | ||||
|   assert( idx>=0 && idx<pPage->nCell ); | ||||
|   assert( idx>=0 ); | ||||
|   assert( idx<pPage->nCell ); | ||||
|   assert( CORRUPT_DB || sz==cellSize(pPage, idx) ); | ||||
|   assert( sqlite3PagerIswriteable(pPage->pDbPage) ); | ||||
|   assert( sqlite3_mutex_held(pPage->pBt->mutex) ); | ||||
|   assert( pPage->nFree>=0 ); | ||||
|   data = pPage->aData; | ||||
|   ptr = &pPage->aCellIdx[2*idx]; | ||||
|   assert( pPage->pBt->usableSize > (int)(ptr-data) ); | ||||
|   pc = get2byte(ptr); | ||||
|   hdr = pPage->hdrOffset; | ||||
|   testcase( pc==get2byte(&data[hdr+5]) ); | ||||
|   testcase( pc==(u32)get2byte(&data[hdr+5]) ); | ||||
|   testcase( pc+sz==pPage->pBt->usableSize ); | ||||
|   if( pc+sz > pPage->pBt->usableSize ){ | ||||
|     *pRC = SQLITE_CORRUPT_BKPT; | ||||
| @@ -72683,7 +72687,7 @@ static int rebuildPage( | ||||
| 
 | ||||
|   assert( i<iEnd ); | ||||
|   j = get2byte(&aData[hdr+5]); | ||||
|   if( NEVER(j>(u32)usableSize) ){ j = 0; } | ||||
|   if( j>(u32)usableSize ){ j = 0; } | ||||
|   memcpy(&pTmp[j], &aData[j], usableSize - j); | ||||
| 
 | ||||
|   for(k=0; pCArray->ixNx[k]<=i && ALWAYS(k<NB*2); k++){} | ||||
| @@ -72914,7 +72918,7 @@ static int editPage( | ||||
| 
 | ||||
|   pData = &aData[get2byteNotZero(&aData[hdr+5])]; | ||||
|   if( pData<pBegin ) goto editpage_fail; | ||||
|   if( NEVER(pData>pPg->aDataEnd) ) goto editpage_fail; | ||||
|   if( pData>pPg->aDataEnd ) goto editpage_fail; | ||||
| 
 | ||||
|   /* Add cells to the start of the page */ | ||||
|   if( iNew<iOld ){ | ||||
| @@ -74817,7 +74821,12 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){ | ||||
|   iCellIdx = pCur->ix; | ||||
|   pPage = pCur->pPage; | ||||
|   pCell = findCell(pPage, iCellIdx); | ||||
|   if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ) return SQLITE_CORRUPT; | ||||
|   if( pPage->nFree<0 && btreeComputeFreeSpace(pPage) ){ | ||||
|     return SQLITE_CORRUPT_BKPT; | ||||
|   } | ||||
|   if( pPage->nCell<=iCellIdx ){ | ||||
|     return SQLITE_CORRUPT_BKPT; | ||||
|   } | ||||
| 
 | ||||
|   /* If the bPreserve flag is set to true, then the cursor position must
 | ||||
|   ** be preserved following this delete operation. If the current delete | ||||
| @@ -84101,7 +84110,7 @@ SQLITE_PRIVATE int sqlite3VdbeIdxRowid(sqlite3 *db, BtCursor *pCur, i64 *rowid){ | ||||
|   /* The index entry must begin with a header size */ | ||||
|   getVarint32NR((u8*)m.z, szHdr); | ||||
|   testcase( szHdr==3 ); | ||||
|   testcase( szHdr==m.n ); | ||||
|   testcase( szHdr==(u32)m.n ); | ||||
|   testcase( szHdr>0x7fffffff ); | ||||
|   assert( m.n>=0 ); | ||||
|   if( unlikely(szHdr<3 || szHdr>(unsigned)m.n) ){ | ||||
| @@ -90511,6 +90520,7 @@ case OP_SetCookie: { | ||||
|     /* When the schema cookie changes, record the new cookie internally */ | ||||
|     pDb->pSchema->schema_cookie = pOp->p3 - pOp->p5; | ||||
|     db->mDbFlags |= DBFLAG_SchemaChange; | ||||
|     sqlite3FkClearTriggerCache(db, pOp->p1); | ||||
|   }else if( pOp->p2==BTREE_FILE_FORMAT ){ | ||||
|     /* Record changes in the file format */ | ||||
|     pDb->pSchema->file_format = pOp->p3; | ||||
| @@ -99143,7 +99153,7 @@ static int memjrnlTruncate(sqlite3_file *pJfd, sqlite_int64 size){ | ||||
|       p->pFirst = 0; | ||||
|     }else{ | ||||
|       i64 iOff = p->nChunkSize; | ||||
|       for(pIter=p->pFirst; ALWAYS(pIter) && iOff<=size; pIter=pIter->pNext){ | ||||
|       for(pIter=p->pFirst; ALWAYS(pIter) && iOff<size; pIter=pIter->pNext){ | ||||
|         iOff += p->nChunkSize; | ||||
|       } | ||||
|       if( ALWAYS(pIter) ){ | ||||
| @@ -123234,6 +123244,25 @@ static void fkTriggerDelete(sqlite3 *dbMem, Trigger *p){ | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| ** Clear the apTrigger[] cache of CASCADE triggers for all foreign keys | ||||
| ** in a particular database.  This needs to happen when the schema | ||||
| ** changes. | ||||
| */ | ||||
| SQLITE_PRIVATE void sqlite3FkClearTriggerCache(sqlite3 *db, int iDb){ | ||||
|   HashElem *k; | ||||
|   Hash *pHash = &db->aDb[iDb].pSchema->tblHash; | ||||
|   for(k=sqliteHashFirst(pHash); k; k=sqliteHashNext(k)){ | ||||
|     Table *pTab = sqliteHashData(k); | ||||
|     FKey *pFKey; | ||||
|     if( !IsOrdinaryTable(pTab) ) continue; | ||||
|     for(pFKey=pTab->u.tab.pFKey; pFKey; pFKey=pFKey->pNextFrom){ | ||||
|       fkTriggerDelete(db, pFKey->apTrigger[0]); pFKey->apTrigger[0] = 0; | ||||
|       fkTriggerDelete(db, pFKey->apTrigger[1]); pFKey->apTrigger[1] = 0; | ||||
|     } | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
| ** This function is called to generate code that runs when table pTab is | ||||
| ** being dropped from the database. The SrcList passed as the second argument | ||||
| @@ -124034,7 +124063,7 @@ SQLITE_PRIVATE void sqlite3OpenTable( | ||||
|   }else{ | ||||
|     Index *pPk = sqlite3PrimaryKeyIndex(pTab); | ||||
|     assert( pPk!=0 ); | ||||
|     assert( pPk->tnum==pTab->tnum ); | ||||
|     assert( pPk->tnum==pTab->tnum || CORRUPT_DB ); | ||||
|     sqlite3VdbeAddOp3(v, opcode, iCur, pPk->tnum, iDb); | ||||
|     sqlite3VdbeSetP4KeyInfo(pParse, pPk); | ||||
|     VdbeComment((v, "%s", pTab->zName)); | ||||
| @@ -126540,7 +126569,6 @@ SQLITE_PRIVATE void sqlite3CompleteInsertion( | ||||
|     } | ||||
|     pik_flags = (useSeekResult ? OPFLAG_USESEEKRESULT : 0); | ||||
|     if( IsPrimaryKeyIndex(pIdx) && !HasRowid(pTab) ){ | ||||
|       assert( pParse->nested==0 ); | ||||
|       pik_flags |= OPFLAG_NCHANGE; | ||||
|       pik_flags |= (update_flags & OPFLAG_SAVEPOSITION); | ||||
|       if( update_flags==0 ){ | ||||
| @@ -132946,7 +132974,7 @@ static int sqlite3Prepare( | ||||
|     sParse.checkSchema = 0; | ||||
|   } | ||||
|   if( sParse.rc!=SQLITE_OK && sParse.rc!=SQLITE_DONE ){ | ||||
|     if( sParse.checkSchema ){ | ||||
|     if( sParse.checkSchema && db->init.busy==0 ){ | ||||
|       schemaIsValid(&sParse); | ||||
|     } | ||||
|     if( sParse.pVdbe ){ | ||||
| @@ -141889,7 +141917,7 @@ static void codeReturningTrigger( | ||||
|   } | ||||
|   sqlite3ExprListDelete(db, sSelect.pEList); | ||||
|   pNew = sqlite3ExpandReturning(pParse, pReturning->pReturnEL, pTab); | ||||
|   if( pNew ){ | ||||
|   if( !db->mallocFailed ){ | ||||
|     NameContext sNC; | ||||
|     memset(&sNC, 0, sizeof(sNC)); | ||||
|     if( pReturning->nRetCol==0 ){ | ||||
| @@ -141901,7 +141929,9 @@ static void codeReturningTrigger( | ||||
|     sNC.ncFlags = NC_UBaseReg; | ||||
|     pParse->eTriggerOp = pTrigger->op; | ||||
|     pParse->pTriggerTab = pTab; | ||||
|     if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK ){ | ||||
|     if( sqlite3ResolveExprListNames(&sNC, pNew)==SQLITE_OK | ||||
|      && !db->mallocFailed | ||||
|     ){ | ||||
|       int i; | ||||
|       int nCol = pNew->nExpr; | ||||
|       int reg = pParse->nMem+1; | ||||
| @@ -141909,17 +141939,18 @@ static void codeReturningTrigger( | ||||
|       pReturning->iRetReg = reg; | ||||
|       for(i=0; i<nCol; i++){ | ||||
|         Expr *pCol = pNew->a[i].pExpr; | ||||
|         assert( pCol!=0 ); /* Due to !db->mallocFailed ~9 lines above */ | ||||
|         sqlite3ExprCodeFactorable(pParse, pCol, reg+i); | ||||
|       } | ||||
|       sqlite3VdbeAddOp3(v, OP_MakeRecord, reg, i, reg+i); | ||||
|       sqlite3VdbeAddOp2(v, OP_NewRowid, pReturning->iRetCur, reg+i+1); | ||||
|       sqlite3VdbeAddOp3(v, OP_Insert, pReturning->iRetCur, reg+i, reg+i+1); | ||||
|     } | ||||
|   } | ||||
|   sqlite3ExprListDelete(db, pNew); | ||||
|   pParse->eTriggerOp = 0; | ||||
|   pParse->pTriggerTab = 0; | ||||
| } | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @@ -232502,7 +232533,7 @@ static void fts5SourceIdFunc( | ||||
| ){ | ||||
|   assert( nArg==0 ); | ||||
|   UNUSED_PARAM2(nArg, apUnused); | ||||
|   sqlite3_result_text(pCtx, "fts5: 2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62", -1, SQLITE_TRANSIENT); | ||||
|   sqlite3_result_text(pCtx, "fts5: 2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0", -1, SQLITE_TRANSIENT); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|   | ||||
							
								
								
									
										6
									
								
								libsqlite3-sys/sqlite3/sqlite3.h
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								libsqlite3-sys/sqlite3/sqlite3.h
									
									
									
									
										vendored
									
									
								
							| @@ -146,9 +146,9 @@ extern "C" { | ||||
| ** [sqlite3_libversion_number()], [sqlite3_sourceid()], | ||||
| ** [sqlite_version()] and [sqlite_source_id()]. | ||||
| */ | ||||
| #define SQLITE_VERSION        "3.37.1" | ||||
| #define SQLITE_VERSION_NUMBER 3037001 | ||||
| #define SQLITE_SOURCE_ID      "2021-12-30 15:30:28 378629bf2ea546f73eee84063c5358439a12f7300e433f18c9e1bddd948dea62" | ||||
| #define SQLITE_VERSION        "3.37.2" | ||||
| #define SQLITE_VERSION_NUMBER 3037002 | ||||
| #define SQLITE_SOURCE_ID      "2022-01-06 13:25:41 872ba256cbf61d9290b571c0e6d82a20c224ca3ad82971edc46b29818d5d17a0" | ||||
|  | ||||
| /* | ||||
| ** CAPI3REF: Run-Time Library Version Numbers | ||||
|   | ||||
| @@ -10,8 +10,8 @@ export SQLITE3_LIB_DIR="$SCRIPT_DIR/sqlite3" | ||||
| export SQLITE3_INCLUDE_DIR="$SQLITE3_LIB_DIR" | ||||
|  | ||||
| # Download and extract amalgamation | ||||
| SQLITE=sqlite-amalgamation-3370100 | ||||
| curl -O https://sqlite.org/2021/$SQLITE.zip | ||||
| SQLITE=sqlite-amalgamation-3370200 | ||||
| curl -O https://sqlite.org/2022/$SQLITE.zip | ||||
| unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.c" > "$SQLITE3_LIB_DIR/sqlite3.c" | ||||
| unzip -p "$SQLITE.zip" "$SQLITE/sqlite3.h" > "$SQLITE3_LIB_DIR/sqlite3.h" | ||||
| unzip -p "$SQLITE.zip" "$SQLITE/sqlite3ext.h" > "$SQLITE3_LIB_DIR/sqlite3ext.h" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user